You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
11 lines
18 KiB
11 lines
18 KiB
4 years ago
|
/*!
|
||
|
* Timepicker Component for Twitter Bootstrap
|
||
|
*
|
||
|
* Copyright 2013 Joris de Wit
|
||
|
*
|
||
|
* Contributors https://github.com/jdewit/bootstrap-timepicker/graphs/contributors
|
||
|
*
|
||
|
* For the full copyright and license information, please view the LICENSE
|
||
|
* file that was distributed with this source code.
|
||
|
*/
|
||
|
(function(d,c,a,e){var b=function(g,f){this.iconUp=f.iconUp||"fa fa-chevron-up";this.iconDown=f.iconDown||"fa fa-chevron-down";this.widget="";this.$element=d(g);this.defaultTime=f.defaultTime;this.disableFocus=f.disableFocus;this.disableMousewheel=f.disableMousewheel;this.isOpen=f.isOpen;this.minuteStep=f.minuteStep;this.modalBackdrop=f.modalBackdrop;this.orientation=f.orientation;this.secondStep=f.secondStep;this.showInputs=f.showInputs;this.showMeridian=f.showMeridian;this.showSeconds=f.showSeconds;this.template=f.template;this.appendWidgetTo=f.appendWidgetTo;this.showWidgetOnAddonClick=f.showWidgetOnAddonClick;this._init()};b.prototype={constructor:b,_init:function(){var f=this;if(this.showWidgetOnAddonClick&&(this.$element.parent().hasClass("input-append")||this.$element.parent().hasClass("input-prepend"))){this.$element.parent(".input-append, .input-prepend").find(".add-on").on({"click.timepicker":d.proxy(this.showWidget,this)});this.$element.on({"focus.timepicker":d.proxy(this.highlightUnit,this),"click.timepicker":d.proxy(this.highlightUnit,this),"keydown.timepicker":d.proxy(this.elementKeydown,this),"blur.timepicker":d.proxy(this.blurElement,this),"mousewheel.timepicker DOMMouseScroll.timepicker":d.proxy(this.mousewheel,this)})}else{if(this.template){this.$element.on({"focus.timepicker":d.proxy(this.showWidget,this),"click.timepicker":d.proxy(this.showWidget,this),"blur.timepicker":d.proxy(this.blurElement,this),"mousewheel.timepicker DOMMouseScroll.timepicker":d.proxy(this.mousewheel,this)})}else{this.$element.on({"focus.timepicker":d.proxy(this.highlightUnit,this),"click.timepicker":d.proxy(this.highlightUnit,this),"keydown.timepicker":d.proxy(this.elementKeydown,this),"blur.timepicker":d.proxy(this.blurElement,this),"mousewheel.timepicker DOMMouseScroll.timepicker":d.proxy(this.mousewheel,this)})}}if(this.template!==false){this.$widget=d(this.getTemplate()).on("click",d.proxy(this.widgetClick,this))}else{this.$widget=false}if(this.showInputs&&this.$widget!==false){this.$widget.find("input").each(function(){d(this).on({"click.timepicker":function(){d(this).select()},"keydown.timepicker":d.proxy(f.widgetKeydown,f),"keyup.timepicker":d.proxy(f.widgetKeyup,f)})})}this.setDefaultTime(this.defaultTime)},blurElement:function(){this.highlightedUnit=null;this.updateFromElementVal()},clear:function(){this.hour="";this.minute="";this.second="";this.meridian="";this.$element.val("")},decrementHour:function(){if(this.showMeridian){if(this.hour===1){this.hour=12}else{if(this.hour===12){this.hour--;return this.toggleMeridian()}else{if(this.hour===0){this.hour=11;return this.toggleMeridian()}else{this.hour--}}}}else{if(this.hour<=0){this.hour=23}else{this.hour--}}},decrementMinute:function(g){var f;if(g){f=this.minute-g}else{f=this.minute-this.minuteStep}if(f<0){this.decrementHour();this.minute=f+60}else{this.minute=f}},decrementSecond:function(){var f=this.second-this.secondStep;if(f<0){this.decrementMinute(true);this.second=f+60}else{this.second=f}},elementKeydown:function(f){switch(f.keyCode){case 9:case 27:this.updateFromElementVal();break;case 37:f.preventDefault();this.highlightPrevUnit();break;case 38:f.preventDefault();switch(this.highlightedUnit){case"hour":this.incrementHour();this.highlightHour();break;case"minute":this.incrementMinute();this.highlightMinute();break;case"second":this.incrementSecond();this.highlightSecond();break;case"meridian":this.toggleMeridian();this.highlightMeridian();break}this.update();break;case 39:f.preventDefault();this.highlightNextUnit();break;case 40:f.preventDefault();switch(this.highlightedUnit){case"hour":this.decrementHour();this.highlightHour();break;case"minute":this.decrementMinute();this.highlightMinute();break;case"second":this.decrementSecond();this.highlightSecond();break;case"meridian":this.toggleMeridian();this.highlightMeridian();break}this.update();break}},getCursorPosition:function(){var g=this.$element.get(0);if("selectionStart" in g){return g.selectionStart}else{if(a.selection){g.focus();var h=a.selection.createRange(),f=a.selection.createRange().text.length;h.moveS
|