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

1 line
5.7 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 c=this.$input=f.find(".t-input").bind({change:function(g){g.stopPropagation()},keydown:a.proxy(this._keydown,this),focus:a.proxy(function(g){this._change(c.val());this.$input.removeClass("t-state-error")},this)});this.inputValue=c.val();f.find(".t-icon-clock").bind("click",a.proxy(this._toggleTimeView,this)).end().find(".t-icon-calendar").bind("click",a.proxy(this._toggleDateView,this));this.timeView=new b.timeView({effects:this.effects,dropDownAttr:this.dropDownAttr,format:this.timeFormat,interval:this.interval,isRtl:c.closest(".t-rtl").length,minValue:this.startTimeValue,maxValue:this.endTimeValue,onNavigateWithOpenPopup:a.proxy(function(h){var g=this.parse(h,this.timeFormat);this.$input.val(b.datetime.format(g.toDate(),this.format))},this),onChange:a.proxy(function(g){this._change(this.parse(g,this.timeFormat));this._close("time")},this)});this.dateView=new b.dateView({selectedValue:this.selectedValue,minValue:this.minValue,maxValue:this.maxValue,effects:this.effects,isRtl:c.closest(".t-rtl").length,onChange:a.proxy(function(g){this._change(g);this._close("date")},this)});a(document.documentElement).bind("mousedown",a.proxy(function(k){var g=this.dateView.$calendar;if(!g){return}var j=this.timeView.dropDown.$element;var h=j&&j.parent().length>0;var l=g.data("associatedDateView");var i=k.target;if(a.contains(this.element,i)||(l&&l==this.dateView&&a.contains(g[0],i))||(h&&a.contains(j.parent()[0],i))){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(d){var e=this.minValue;var c=this.maxValue;var g=this.parse(d);var f=this.selectedValue;if(g!=null){if(g.value-e.value<=0){g=e}else{if(g.value-c.value>=0){g=c}}}if((f===null&&g!==null)||(f!==null&&g===null)||(f&&g&&(f.value>g.value||g.value>f.value))){b.trigger(this.element,"change",{previousValue:f===null?null:f.toDate(),value:g===null?null:g.toDate()})}this._value(g)},_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 f=c+"Value";if(e===undefined){return this[f].toDate()}var g=this.parse(e);if(g!==null){this[f]=g;this.dateView[c](g);this.timeView[c](g)}}},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)}}},this));a.fn.tDateTimePicker=function(c){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,timeFormat:b.cultureInfo.shortTime,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);