timepicker: add attribute 'tillMidnight'
to allow for 00:00-24:00 timeframes (24:01 will set to 00:01) needed in business hours
This commit is contained in:
parent
c7ec0d9c5a
commit
7ff1e3e2d8
1 changed files with 31 additions and 6 deletions
|
@ -12,6 +12,7 @@
|
||||||
* - automatically jump from hours to minutes when typing in a number
|
* - automatically jump from hours to minutes when typing in a number
|
||||||
* - continue stepping from manually input value
|
* - continue stepping from manually input value
|
||||||
* - activate meridian on class 'time--12'
|
* - activate meridian on class 'time--12'
|
||||||
|
* - tillMidnight (special mode to allow to display 24:00)
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
|
@ -38,6 +39,7 @@
|
||||||
this.template = options.template;
|
this.template = options.template;
|
||||||
this.appendWidgetTo = options.appendWidgetTo;
|
this.appendWidgetTo = options.appendWidgetTo;
|
||||||
this.showWidgetOnAddonClick = options.showWidgetOnAddonClick;
|
this.showWidgetOnAddonClick = options.showWidgetOnAddonClick;
|
||||||
|
this.tillMidnight = options.tillMidnight;
|
||||||
|
|
||||||
this._init();
|
this._init();
|
||||||
};
|
};
|
||||||
|
@ -140,7 +142,11 @@
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.hour <= 0) {
|
if (this.hour <= 0) {
|
||||||
|
if(this.tillMidnight) {
|
||||||
this.hour = this.maxHours;
|
this.hour = this.maxHours;
|
||||||
|
} else {
|
||||||
|
this.hour = this.maxHours - 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.hour--;
|
this.hour--;
|
||||||
}
|
}
|
||||||
|
@ -514,11 +520,17 @@
|
||||||
this.hour = 0;
|
this.hour = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.hour === this.maxHours) {
|
if (this.tillMidnight) {
|
||||||
this.hour = 0;
|
if (this.hour === 24) {
|
||||||
|
this.hour = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (this.hour === 23) {
|
||||||
|
this.hour = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
this.hour++;
|
this.hour++;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -537,6 +549,12 @@
|
||||||
} else {
|
} else {
|
||||||
this.minute = newVal;
|
this.minute = newVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.tillMidnight && this.hour === 24) {
|
||||||
|
if (this.minute !== 0) {
|
||||||
|
this.hour = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
incrementSecond: function() {
|
incrementSecond: function() {
|
||||||
|
@ -548,6 +566,12 @@
|
||||||
} else {
|
} else {
|
||||||
this.second = newVal;
|
this.second = newVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.tillMidnight && this.hour === 24) {
|
||||||
|
if (this.second !== 0) {
|
||||||
|
this.hour = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mousewheel: function(e) {
|
mousewheel: function(e) {
|
||||||
|
@ -1093,7 +1117,8 @@
|
||||||
template: false,
|
template: false,
|
||||||
appendWidgetTo: 'body',
|
appendWidgetTo: 'body',
|
||||||
showWidgetOnAddonClick: true,
|
showWidgetOnAddonClick: true,
|
||||||
maxHours: 23
|
maxHours: 23,
|
||||||
|
tillMidnight: false
|
||||||
};
|
};
|
||||||
|
|
||||||
$.fn.timepicker.Constructor = Timepicker;
|
$.fn.timepicker.Constructor = Timepicker;
|
||||||
|
|
Loading…
Reference in a new issue