Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/timer.jquery.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions src/timer.jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@
* Render pretty time
*/
function render() {
var sec = totalSeconds;

if (options.countdown && duration > 0) {
$el[display](secondsToTime(duration - totalSeconds));
} else {
$el[display](secondsToTime(totalSeconds));
sec = duration - totalSeconds;
}
$el.data('seconds', totalSeconds);

$el[display](secondsToTime(sec));
$el.data('seconds', sec);
}

function makeEditable() {
Expand Down Expand Up @@ -265,7 +267,6 @@
duration = options.duration = timeToSeconds(options.duration);
}


if (options.editable) {
makeEditable();
}
Expand Down
23 changes: 22 additions & 1 deletion test/timer.jquery.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@
scenarios = [],
count = 0; // To print 'Done! on completion of tests

/*test('timer supports countdown', function() {
$('#timer').timer({
duration: '3s',
countdown: true,
callback: function() {
$('#timer').timer('pause');
}
});

// Pause test momentarily
stop();

// Check value of callbackExecuted in 3 seconds (+ minor offset to run assertion comfortably)
setTimeout(function() {
equal($('#timer').data('seconds'), 0, 'Timer counts down to 0 seconds if countdown was enabled.');
$('#timer').val('').timer('remove');

start();
}, 3500);
});*/

// Timer resets to 0 seconds if reset was called
test('timer resets to 0 seconds if reset was called', function() {
$('#timer').timer({
Expand Down Expand Up @@ -142,7 +163,7 @@
equal(callbackExecuted, true, 'Timer translates duration of 5h30m10s correctly.');
$('#timer').val('').timer('remove');

start();
start();
}, 2500);
});

Expand Down