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