11/**
2- * angular-timer - v1.0.11 - 2014-01-10 2:05 PM
2+ * angular-timer - v1.0.12 - 2014-02-03 9:30 PM
33 * https://github.com/siddii/angular-timer
44 *
55 * Copyright (c) 2014 Siddique Hameed
@@ -48,6 +48,10 @@ angular.module('timer', [])
4848 $scope . stop ( ) ;
4949 } ) ;
5050
51+ $scope . $on ( 'timer-clear' , function ( ) {
52+ $scope . clear ( ) ;
53+ } ) ;
54+
5155 function resetTimeout ( ) {
5256 if ( $scope . timeoutId ) {
5357 clearTimeout ( $scope . timeoutId ) ;
@@ -60,6 +64,7 @@ angular.module('timer', [])
6064 $scope . countdown = $scope . countdownattr && parseInt ( $scope . countdownattr , 10 ) > 0 ? parseInt ( $scope . countdownattr , 10 ) : undefined ;
6165 resetTimeout ( ) ;
6266 tick ( ) ;
67+ $scope . isRunning = true ;
6368 } ;
6469
6570 $scope . resume = $element [ 0 ] . resume = function ( ) {
@@ -69,17 +74,25 @@ angular.module('timer', [])
6974 }
7075 $scope . startTime = new Date ( ) - ( $scope . stoppedTime - $scope . startTime ) ;
7176 tick ( ) ;
77+ $scope . isRunning = true ;
7278 } ;
7379
7480 $scope . stop = $scope . pause = $element [ 0 ] . stop = $element [ 0 ] . pause = function ( ) {
81+ $scope . clear ( ) ;
82+ $scope . $emit ( 'timer-stopped' , { millis : $scope . millis , seconds : $scope . seconds , minutes : $scope . minutes , hours : $scope . hours , days : $scope . days } ) ;
83+ } ;
84+
85+ $scope . clear = $element [ 0 ] . clear = function ( ) {
86+ // same as stop but without the event being triggered
7587 $scope . stoppedTime = new Date ( ) ;
7688 resetTimeout ( ) ;
77- $scope . $emit ( 'timer-stopped' , { millis : $scope . millis , seconds : $scope . seconds , minutes : $scope . minutes , hours : $scope . hours , days : $scope . days } ) ;
7889 $scope . timeoutId = null ;
90+ $scope . isRunning = false ;
7991 } ;
8092
8193 $element . bind ( '$destroy' , function ( ) {
8294 resetTimeout ( ) ;
95+ $scope . isRunning = false ;
8396 } ) ;
8497
8598 function calculateTimeUnits ( ) {
0 commit comments