Skip to content

Commit d6e00b6

Browse files
committed
timer-stopped event returning timeoutId as arg
1 parent d34157e commit d6e00b6

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

app/js/timer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ angular.module('timer', [])
8686
};
8787

8888
$scope.stop = $scope.pause = $element[0].stop = $element[0].pause = function () {
89+
var timeoutId = $scope.timeoutId;
8990
$scope.clear();
90-
$scope.$emit('timer-stopped', {millis: $scope.millis, seconds: $scope.seconds, minutes: $scope.minutes, hours: $scope.hours, days: $scope.days});
91+
$scope.$emit('timer-stopped', {timeoutId: timeoutId, millis: $scope.millis, seconds: $scope.seconds, minutes: $scope.minutes, hours: $scope.hours, days: $scope.days});
9192
};
9293

9394
$scope.clear = $element[0].clear = function () {

dist/angular-timer.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* angular-timer - v1.1.0 - 2014-04-23 5:44 AM
2+
* angular-timer - v1.1.0 - 2014-05-16 7:22 PM
33
* https://github.com/siddii/angular-timer
44
*
55
* Copyright (c) 2014 Siddique Hameed
@@ -93,8 +93,9 @@ angular.module('timer', [])
9393
};
9494

9595
$scope.stop = $scope.pause = $element[0].stop = $element[0].pause = function () {
96+
var timeoutId = $scope.timeoutId;
9697
$scope.clear();
97-
$scope.$emit('timer-stopped', {millis: $scope.millis, seconds: $scope.seconds, minutes: $scope.minutes, hours: $scope.hours, days: $scope.days});
98+
$scope.$emit('timer-stopped', {timeoutId: timeoutId, millis: $scope.millis, seconds: $scope.seconds, minutes: $scope.minutes, hours: $scope.hours, days: $scope.days});
9899
};
99100

100101
$scope.clear = $element[0].clear = function () {
@@ -164,6 +165,16 @@ angular.module('timer', [])
164165
$scope.addCDSeconds(extraSeconds);
165166
});
166167
});
168+
169+
$scope.$on('timer-set-countdown-seconds', function(e, countdownSeconds) {
170+
if (!$scope.isRunning) {
171+
$scope.clear();
172+
}
173+
174+
$scope.countdown = countdownSeconds;
175+
$scope.millis = countdownSeconds * 1000;
176+
calculateTimeUnits();
177+
});
167178
} else {
168179
$scope.millis = 0;
169180
}

dist/angular-timer.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/angularjs-multiple-timers.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
$scope.$broadcast('timer-stop');
1919
$scope.timerRunning = false;
2020
};
21+
22+
$scope.$on('timer-stopped', function (event, args) {
23+
console.log('timer-stopped args = ', args);
24+
});
2125
}
2226
MyAppController.$inject = ['$scope'];
2327
</script>

0 commit comments

Comments
 (0)