mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-06 19:12:38 +01:00
1 line
7.2 KiB
JavaScript
1 line
7.2 KiB
JavaScript
|
(function(c){var b=c.telerik;b.scripts.push("telerik.datetimepicker.js");function a(e,f){var d=new b.stringBuilder();return d.cat('<span class="t-icon t-icon-').cat(e).cat('" ').catIf('title="',f).catIf(f,f).cat('"></span>').string()}b.datetimepicker=function(f,g){c.extend(this,g);if(f.nodeName.toLowerCase()!=="input"&&f.type.toLowerCase()!=="text"){throw"Target element is not a INPUT"}this.element=f;var h=this.$element=c(f).addClass("t-input").attr("autocomplete","off").bind({keydown:c.proxy(this._keydown,this),focus:c.proxy(function(i){this.$element.removeClass("t-state-error")},this)});if(!h.parent().hasClass("t-picker-wrap")){h.wrap('<div class="t-widget t-datetimepicker"><div class="t-picker-wrap"></div></div>');if(g.showCalendarButton||g.showTimeButton){c(new b.stringBuilder().cat('<span class="t-select">').catIf(a("calendar",g.calendarButtonTitle),g.showCalendarButton).cat(a("clock",g.timeButtonTitle),g.showTimeButton).cat("</span>").string()).insertAfter(h)}}this.$wrapper=h.closest(".t-datetimepicker").find(".t-icon-clock").bind("click",this.enabled?c.proxy(this._toggleTimeView,this):b.preventDefault).end().find(".t-icon-calendar").bind("click",this.enabled?c.proxy(this._toggleDateView,this):b.preventDefault).end();this.timeView=new b.timeView({effects:this.effects,dropDownAttr:this.dropDownAttr,format:this.timeFormat,interval:this.interval,isRtl:h.closest(".t-rtl").length,minValue:this.startTimeValue,maxValue:this.endTimeValue,onNavigateWithOpenPopup:c.proxy(function(j){var i=this.parse(j,this.timeFormat);this.$element.val(b.datetime.format(i,this.format))},this),onChange:c.proxy(function(i){this._update(this.parse(i,this.timeFormat));this._close("time")},this)});this.dateView=new b.dateView({selectedValue:this.selectedValue,minValue:this.minValue,maxValue:this.maxValue,effects:this.effects,isRtl:h.closest(".t-rtl").length,onChange:c.proxy(function(i){this._update(i);this._close("date")},this)});this.dateView.$calendar.bind("click",c.proxy(function(i){i.stopPropagation();if(i.target.parentNode.className.indexOf("t-state-selected")!=-1){this._close("date")}},this));this.inputValue=h.val();var d=this.selectedValue||this.inputValue;if(d){var e=this.parse(d);this.dateView.selectedValue=e;this._value(this.parse(d))}c(document.documentElement).bind("mousedown",c.proxy(function(n){var l=this.$element.val();if(l!=this.inputValue){this._update(l)}var i=this.dateView.$calendar;if(!i){return}var m=this.timeView.dropDown.$element;var j=m&&m.parent().length>0;var o=i.data("associatedDateView");var k=n.target;if(c.contains(this.$wrapper[0],k)||(o&&o==this.dateView&&c.contains(i[0],k))||(j&&c.contains(m.parent()[0],k))){return}this._close("date");this._close("time")},this));b.bind(this,{open:this.onOpen,close:this.onClose,valueChange:this.onChange,load:this.onLoad})};b.datetimepicker.prototype={_update:function(e){e=this.parse(e);if(e!=null){if(e-this.minValue<=0){e=this.minValue}else{if(e-this.maxValue>=0){e=this.maxValue}}}var d=this.selectedValue,h=d?b.datetime.format(d,this.format):"",g=e?b.datetime.format(e,this.format):"";this._value(e);if(g!=h){var f={previousValue:d,value:e};if(b.trigger(this.element,"valueChange",f)){this._value(d)}}},_value:function(d){var h=this.$element.val();var g=d===null;var e=this.dateView;var f=e.$calendar.data("associatedDateView");this.selectedValue=d;this.timeView.value(g?null:b.datetime.format(d,this.timeFormat));if(f){e.value(d)}if(!g){h=b.datetime.format(d,this.format)}this.inputValue=h;this.$element.toggleClass("t-state-error",g&&h!="").val(h)},_open:function(d){if(!this[d=="time"?"timeView":"dateView"].isOpened()){this._trigger(d,"open")}},_close:function(f){var d=this.dateView;var e=this.timeView.dropDown;if((f=="time"&&!e.$element.is(":animated")&&e.isOpened())||(!d.$calendar.is(":animated")&&d.isOpened())){this._trigger(f,"close")}},_trigger:function(d,e){if(!b.trigger(this.element,e,{popup:d})){this[e](d)}},_keydown:function(g){var f=g.keyCode,d=this.dateView.isOpened();if(f==9||f==27||(f==13&&this.inputValue!=this.$element.val())){this._update(this.$element.val());this._close("da
|