Skip to content
Open
Changes from 3 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
30 changes: 28 additions & 2 deletions js/bootstrap-timepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,20 @@
if (step) {
newVal = this.minute - step;
} else {
newVal = this.minute - this.minuteStep;
var minuteStep = this.minuteStep;
if (this.minuteStep > 60) {
var hourStep = Math.floor(this.minuteStep / 60);
minuteStep -= (hourStep * 60);
if (minuteStep == 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=== please; this fails lint checks

minuteStep = 60;
}

for (var i = 0; i<hourStep-(minuteStep == 60 ? 1 : 0); i++) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ===, and add whitespace around operators, like you see in the rest of the code (hopefully).

If you're worried about verbosity on this line, you can pull out hourStep - (minuteStep === 60 ? 1 : 0) into a variable declared in the line above.

this.decrementHour();
}
}

newVal = this.minute - minuteStep;
}

if (newVal < 0) {
Expand Down Expand Up @@ -559,7 +572,20 @@
if (step) {
newVal = this.minute + step;
} else {
newVal = this.minute + this.minuteStep - (this.minute % this.minuteStep);
var minuteStep = this.minuteStep;
if (this.minuteStep > 60) {
var hourStep = Math.floor(this.minuteStep / 60);
minuteStep -= (hourStep * 60);
if (minuteStep == 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

===

minuteStep = 60;
}

for (var i = 0; i<hourStep-(minuteStep == 60 ? 1 : 0); i++) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

===

this.incrementHour();
}
}

newVal = this.minute + minuteStep - (this.minute % minuteStep);
}

if (newVal > 59) {
Expand Down