Skip to content

Commit

Permalink
timer-stopped event returning timeoutId as arg
Browse files Browse the repository at this point in the history
  • Loading branch information
siddii committed May 17, 2014
1 parent d34157e commit d6e00b6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/js/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ angular.module('timer', [])
};

$scope.stop = $scope.pause = $element[0].stop = $element[0].pause = function () {
var timeoutId = $scope.timeoutId;
$scope.clear();
$scope.$emit('timer-stopped', {millis: $scope.millis, seconds: $scope.seconds, minutes: $scope.minutes, hours: $scope.hours, days: $scope.days});
$scope.$emit('timer-stopped', {timeoutId: timeoutId, millis: $scope.millis, seconds: $scope.seconds, minutes: $scope.minutes, hours: $scope.hours, days: $scope.days});
};

$scope.clear = $element[0].clear = function () {
Expand Down
15 changes: 13 additions & 2 deletions dist/angular-timer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* angular-timer - v1.1.0 - 2014-04-23 5:44 AM
* angular-timer - v1.1.0 - 2014-05-16 7:22 PM
* https://github.com/siddii/angular-timer
*
* Copyright (c) 2014 Siddique Hameed
Expand Down Expand Up @@ -93,8 +93,9 @@ angular.module('timer', [])
};

$scope.stop = $scope.pause = $element[0].stop = $element[0].pause = function () {
var timeoutId = $scope.timeoutId;
$scope.clear();
$scope.$emit('timer-stopped', {millis: $scope.millis, seconds: $scope.seconds, minutes: $scope.minutes, hours: $scope.hours, days: $scope.days});
$scope.$emit('timer-stopped', {timeoutId: timeoutId, millis: $scope.millis, seconds: $scope.seconds, minutes: $scope.minutes, hours: $scope.hours, days: $scope.days});
};

$scope.clear = $element[0].clear = function () {
Expand Down Expand Up @@ -164,6 +165,16 @@ angular.module('timer', [])
$scope.addCDSeconds(extraSeconds);
});
});

$scope.$on('timer-set-countdown-seconds', function(e, countdownSeconds) {
if (!$scope.isRunning) {
$scope.clear();
}

$scope.countdown = countdownSeconds;
$scope.millis = countdownSeconds * 1000;
calculateTimeUnits();
});
} else {
$scope.millis = 0;
}
Expand Down
4 changes: 2 additions & 2 deletions dist/angular-timer.min.js

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

4 changes: 4 additions & 0 deletions examples/angularjs-multiple-timers.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
$scope.$broadcast('timer-stop');
$scope.timerRunning = false;
};

$scope.$on('timer-stopped', function (event, args) {
console.log('timer-stopped args = ', args);
});
}
MyAppController.$inject = ['$scope'];
</script>
Expand Down

0 comments on commit d6e00b6

Please sign in to comment.