Lidarr/NzbDrone.Web/Scripts/2010.3.1318/telerik.datetimepicker.min.js

1 line
6.2 KiB
JavaScript

(function(a){var b=a.telerik;b.datetimepicker=function(d,e){a.extend(this,e);this.element=d;var f=this.$element=a(d);var g=this.$input=f.find(".t-input").bind({change:function(i){i.stopPropagation()},keydown:a.proxy(this._keydown,this),focus:a.proxy(function(i){this._change(g.val());this.$input.removeClass("t-state-error")},this)});f.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);this.timeView=new b.timeView({effects:this.effects,dropDownAttr:this.dropDownAttr,format:this.timeFormat,interval:this.interval,isRtl:g.closest(".t-rtl").length,minValue:this.startTimeValue,maxValue:this.endTimeValue,onNavigateWithOpenPopup:a.proxy(function(j){var i=this.parse(j,this.timeFormat);this.$input.val(b.datetime.format(i.toDate(),this.format))},this),onChange:a.proxy(function(i){this._change(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:g.closest(".t-rtl").length,onChange:a.proxy(function(i){this._change(i);this._close("date")},this)});this.inputValue=g.val();var c=this.selectedValue||this.inputValue;if(c){var h=this.parse(c);this.dateView.selectedValue=h;this._value(this.parse(c))}a(document.documentElement).bind("mousedown",a.proxy(function(m){var i=this.dateView.$calendar;if(!i){return}var l=this.timeView.dropDown.$element;var j=l&&l.parent().length>0;var n=i.data("associatedDateView");var k=m.target;if(a.contains(this.element,k)||(n&&n==this.dateView&&a.contains(i[0],k))||(j&&a.contains(l.parent()[0],k))){return}this._change(this.$input.val());this._close("date");this._close("time")},this));b.bind(this,{open:this.onOpen,close:this.onClose,change:this.onChange,load:this.onLoad})};b.datetimepicker.prototype={_change:function(c){var g=this.minValue;var d=this.maxValue;var f=this.parse(c);var h=this.selectedValue;if(f!=null){if(f.value-g.value<=0){f=g}else{if(f.value-d.value>=0){f=d}}}var e=(c&&c.date)?b.datetime.format(c.toDate(),this.format):c;if(f==null||this.inputValue!=e){this._value(f);if((h===null&&f!==null)||(h!==null&&f===null)||(h&&f&&(h.value>f.value||f.value>h.value))){b.trigger(this.element,"change",{previousValue:h===null?null:h.toDate(),value:f===null?null:f.toDate()})}}},_value:function(c){var g=this.$input.val();var f=c===null;var d=this.dateView;var e=d.$calendar.data("associatedDateView");this.selectedValue=c;this.timeView.value(f?null:b.datetime.format(c.toDate(),this.timeFormat));if(e&&e==d){d.value(c)}if(!f){g=b.datetime.format(c.toDate(),this.format)}this.inputValue=g;this.$input.toggleClass("t-state-error",f&&g!="").val(g)},_open:function(c){if(!this[c=="time"?"timeView":"dateView"].isOpened()){this._trigger(c,"open")}},_close:function(e){var c=this.dateView;var d=this.timeView.dropDown;if((e=="time"&&!d.$element.is(":animated")&&d.isOpened())||(!c.$calendar.is(":animated")&&c.isOpened())){this._trigger(e,"close")}},_trigger:function(c,d){if(!b.trigger(this.element,d,{popup:c})){this[d](c)}},_keydown:function(f){var d=f.keyCode;var c=f.target.value;if(d==9||d==27||(d==13&&this.inputValue!=c)){this._change(c);this._close("date");this._close("time");return}if(f.altKey){if(d==40){this._open("date")}else{if(d==38){this._close("date")}}return}if(this.dateView.isOpened()){this.dateView.navigate(f)}if(this.timeView.isOpened()){this.timeView.navigate(f)}},_toggleDateView:function(){if(this.dateView.isOpened()){this._close("date")}else{this.$input[0].focus();this._change(this.parse(this.$input.val()));this._open("date");this._close("time")}},_toggleTimeView:function(){if(this.timeView.isOpened()){this._close("time")}else{this.$input[0].focus();this._change(this.parse(this.$input.val()));this._open("time");this._close("date")}},enable:function(){this.$input.attr("disabled",false);this.$element.removeClass("t-state-disabled").find(".t-icon-clock").unbind("click").bind("click",a.proxy(this._toggleTimeView,this)).end().find(".t-icon-calendar").unbind("click").bind("click",a.proxy(this._toggleDateView,this))},disable:function(c){this.$input.attr("disabled",true);this.$element.addClass("t-state-disabled").find(".t-icon").unbind("click").bind("click",b.preventDefault)},open:function(d){var e=this.$input;var c={offset:e.offset(),outerHeight:e.outerHeight(),outerWidth:e.outerWidth(),zIndex:b.getElementZIndex(e[0])};this[d=="time"?"timeView":"dateView"].open(c)},close:function(c){this[c=="time"?"timeView":"dateView"].close()},value:function(c){if(c===undefined){return this.selectedValue===null?null:this.selectedValue.toDate()}var d=this.parse(c);d=b.calendar.isInRange(d,this.minValue,this.maxValue)?d:null;if(d===null){this.$input.removeClass("t-state-error").val("")}this._value(d);return this},parse:function(d,c){if(d===null||d.value){return d}c=c||this.format;return d.getDate?new b.datetime(d):b.datetime.parse({AM:b.cultureInfo.AM,PM:b.cultureInfo.PM,value:d,format:c,baseDate:this.selectedValue?new b.datetime(this.selectedValue.value):new b.datetime()})}};a.each(["min","max"],a.proxy(function(d,c){b.datetimepicker.prototype[c]=function(e){var g=c+"Value";if(e===undefined){return this[g].toDate()}var h=this.parse(e);if(h!==null){var f=this[g];this[g]=h;if(this.minValue.value>this.maxValue.value){this[g]=f;return}this.dateView[c](h);if(!b.calendar.isInRange(this.selectedValue,this.minValue,this.maxValue)){this.value(h)}}}},this));a.each(["startTime","endTime"],a.proxy(function(d,c){b.datetimepicker.prototype[c]=function(e){var f=c+"Value";if(e===undefined){return this[f].toDate()}var g=this.parse(e,b.cultureInfo.shortTime);if(g!==null){this[f]=g;c=="startTime"?this.timeView.min(g):this.timeView.max(g);if(!b.timeView.isInRange(this.selectedValue,this.minValue,this.maxValue)){this.value(g)}}}},this));a.fn.tDateTimePicker=function(c){a.fn.tDateTimePicker.defaults.timeFormat=b.cultureInfo.shortTime;return b.create(this,{name:"tDateTimePicker",init:function(d,e){return new b.datetimepicker(d,e)},options:c})};a.fn.tDateTimePicker.defaults={effects:b.fx.slide.defaults(),selectedValue:null,format:b.cultureInfo.generalDateShortTime,focusedDate:new b.datetime(),minValue:new b.datetime(1899,11,31),maxValue:new b.datetime(2100,0,1),shortYearCutOff:30,enabled:true,interval:30}})(jQuery);