Skip to content

Commit 001cbcb

Browse files
committed
resume working
1 parent 3a140d3 commit 001cbcb

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

app/js/timer.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,12 @@ angular.module('timer', [])
3030
};
3131

3232
$scope.resume = $element[0].resume = function () {
33+
$scope.startTime = new Date() - ($scope.stoppedTime - $scope.startTime);
3334
tick();
3435
};
3536

3637
$scope.stop = $element[0].stop = function () {
37-
$timeout.cancel($scope.timeoutId);
38-
};
39-
40-
41-
$element[0].stop = function () {
38+
$scope.stoppedTime = new Date();
4239
$timeout.cancel($scope.timeoutId);
4340
};
4441

index.html

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,15 @@
7575
<a class="brand" href="#">Angular Timer</a>
7676
<div class="nav-collapse collapse">
7777
<ul class="nav">
78-
<!--<li class="active"><a href="#introduction">Home</a></li>-->
7978
<li class="dropdown">
8079
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Examples <b class="caret"></b></a>
8180
<ul class="dropdown-menu">
8281
<li><a href="index.html#basic-timer">Basic Example</a></li>
83-
<li><a href="index.html#clock-timer">Clock timer</a></li>
82+
<li><a href="index.html#clock-timer">Clock Timer</a></li>
8483
<li><a href="index.html#progressbar-timer">Progressbar Timer</a></li>
8584
</ul>
8685
</li>
87-
<li><a href="#introduction">Markup</a></li>
86+
<li ng-non-bindable><a href="index.html#markup">&lt;timer/&gt;</a></li>
8887
<li class="dropdown">
8988
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Usage <b class="caret"></b></a>
9089
<ul class="dropdown-menu">
@@ -143,6 +142,22 @@ <h3><timer><div class="progress progress-striped active">
143142
</div>
144143
</section>
145144

145+
<section id="markup">
146+
<h3>Markup</h3>
147+
<div class="bs-docs-example">
148+
<p>Timer directive along with <a target="_new" href="http://twitter.github.io/bootstrap/components.html#progress">Twitter Bootstrap's Progressbar</a> will set the timer on Progressbar control.</p>
149+
<code ng-non-bindable>&lt;timer interval="1000"&gt;&lt;div class="progress progress-striped active"&gt;
150+
&lt;div class="bar" style="width: {{seconds}}%;"&gt;&lt;/div&gt;
151+
&lt;/div&gt;&lt;/timer&gt;
152+
</code>
153+
<h3><timer><div class="progress progress-striped active">
154+
<div class="bar" style="width: {{seconds}}%;"></div>
155+
</div></timer></h3>
156+
<button type="button" class="btn" onclick="startTimer('progressbar-timer')">Start</button>
157+
<button type="button" class="btn" onclick="stopTimer('progressbar-timer')">Stop</button>
158+
</div>
159+
</section>
160+
146161
<h3>Examples</h3>
147162
<section id="angularjs-example">
148163
<h4>Using timer directive from Angular</h4>

0 commit comments

Comments
 (0)