@@ -41,6 +41,10 @@ angular.module('timer', [])
41
41
$scope . stop ( ) ;
42
42
} ) ;
43
43
44
+ $scope . $on ( 'timer-clear' , function ( ) {
45
+ $scope . clear ( ) ;
46
+ } ) ;
47
+
44
48
function resetTimeout ( ) {
45
49
if ( $scope . timeoutId ) {
46
50
clearTimeout ( $scope . timeoutId ) ;
@@ -53,6 +57,7 @@ angular.module('timer', [])
53
57
$scope . countdown = $scope . countdownattr && parseInt ( $scope . countdownattr , 10 ) > 0 ? parseInt ( $scope . countdownattr , 10 ) : undefined ;
54
58
resetTimeout ( ) ;
55
59
tick ( ) ;
60
+ $scope . isRunning = true ;
56
61
} ;
57
62
58
63
$scope . resume = $element [ 0 ] . resume = function ( ) {
@@ -62,17 +67,28 @@ angular.module('timer', [])
62
67
}
63
68
$scope . startTime = new Date ( ) - ( $scope . stoppedTime - $scope . startTime ) ;
64
69
tick ( ) ;
70
+ $scope . isRunning = true ;
65
71
} ;
66
72
67
73
$scope . stop = $scope . pause = $element [ 0 ] . stop = $element [ 0 ] . pause = function ( ) {
68
74
$scope . stoppedTime = new Date ( ) ;
69
75
resetTimeout ( ) ;
70
76
$scope . $emit ( 'timer-stopped' , { millis : $scope . millis , seconds : $scope . seconds , minutes : $scope . minutes , hours : $scope . hours , days : $scope . days } ) ;
71
77
$scope . timeoutId = null ;
78
+ $scope . isRunning = false ;
79
+ } ;
80
+
81
+ $scope . clear = $element [ 0 ] . clear = function ( ) {
82
+ // same as stop but without the event being triggered
83
+ $scope . stoppedTime = new Date ( ) ;
84
+ resetTimeout ( ) ;
85
+ $scope . timeoutId = null ;
86
+ $scope . isRunning = false ;
72
87
} ;
73
88
74
89
$element . bind ( '$destroy' , function ( ) {
75
90
resetTimeout ( ) ;
91
+ $scope . isRunning = false ;
76
92
} ) ;
77
93
78
94
function calculateTimeUnits ( ) {
0 commit comments