Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start time and autostart working togheter now #109

Merged
merged 1 commit into from
Sep 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/js/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ var timerModule = angular.module('timer', [])
});

function calculateTimeUnits() {

if ($attrs.startTime !== undefined){
$scope.millis = new Date() - new Date($scope.startTimeAttr);
}
// compute time values based on maxTimeUnit specification
if (!$scope.maxTimeUnit || $scope.maxTimeUnit === 'day') {
$scope.seconds = Math.floor(($scope.millis / 1000) % 60);
Expand Down Expand Up @@ -151,7 +153,6 @@ var timerModule = angular.module('timer', [])
$scope.months = Math.floor((($scope.millis / (3600000)) / 24 / 30) % 12);
$scope.years = Math.floor(($scope.millis / (3600000)) / 24 / 365);
}

// plural - singular unit decision
$scope.secondsS = $scope.seconds == 1 ? '' : 's';
$scope.minutesS = $scope.minutes == 1 ? '' : 's';
Expand Down
15 changes: 15 additions & 0 deletions examples/timer-with-autostart-false-and-starttime.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>Start Time and Auto Start set - Timer Example</title>
<script src="../bower_components/angular/angular.min.js"></script>
<script src="../app/js/timer.js"></script>
</head>
<body ng-app="timer">
<div id="start-time-and-auto-start-set">
<h2>Start Time and Auto Start set - Timer Example</h2>
<h3><timer start-time="1410914940000" autostart="false"></timer></h3>
</div>
<br/>
</body>
</html>
11 changes: 11 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ <h3>
<button class="btn" onclick="stopTimer('basic-timer')" type="button">Stop</button>
</div>
</section>
<section id="start-time-and-auto-start-set">
<h3>Timer with start time and auto start set</h3>

<div class="bs-docs-example">
<p>This will start a timer with 1410914940000 milliseconds and stopped</p>

<h3>
<timer start-time="1410914940000" autostart="false"></timer>
</h3>
</div>
</section>
<section id="clock-timer">
<h3>
Timer with hours, minutes &amp; seconds</h3>
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/scenarios.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ describe('Angular Timer E2E Tests', function () {

});

it('Start time with auto start', function() {
expect(element('#start-time-and-auto-start-set timer span').html()).toBeGreaterThan(1000);
});

it('Countdown timer with maxTimeUnit- should display time value from lower to specified maxTimeUnit', function() {
var timer1Val = element('#max-time-unit-countdown-timer .WithMaxTimeUnitAsMinute timer').text();

Expand Down