Lidarr/packages/TelerikMvcExtensions.2011.1.../content/Scripts/2011.1.315/telerik.datetimepicker.min.js

1 line
7.0 KiB
JavaScript

(function(c){var b=c.telerik;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.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(f){f=this.parse(f);if(f!=null){if(f-this.minValue<=0){f=this.minValue}else{if(f-this.maxValue>=0){f=this.maxValue}}}var g=this.selectedValue,e=g?b.datetime.format(g,this.format):"",d=f?b.datetime.format(f,this.format):"";if(d!=e){var h={previousValue:g,value:f};if(b.trigger(this.element,"valueChange",h)){f=new Date(g)}}this._value(f)},_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&&f==e){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("date");this._close("time");return}if(g.altKey){if(f==40){this._close(d?"date":"time");this._open(d?"time":"date")}else{if(f==38){this._close(d?"date":"time")}}return}if(d){this.dateView.navigate(g);return}if(this.timeView.isOpened()&&(f===38||f===40)){this.timeView.navigate(g);return}},_toggleDateView:function(){if(this.dateView.isOpened()){this._close("date")}else{this.element.focus();this._open("date");this._close("time")}},_toggleTimeView:function(){if(this.timeView.isOpened()){this._close("time")}else{this.element.focus();this._open("time");this._close("date")}},enable:function(){this.$element.attr("disabled",false);this.$wrapper.removeClass("t-state-disabled").find(".t-icon-clock").unbind("click").bind("click",c.proxy(this._toggleTimeView,this)).end().find(".t-icon-calendar").unbind("click").bind("click",c.proxy(this._toggleDateView,this))},disable:function(d){this.$element.attr("disabled",true);this.$wrapper.addClass("t-state-disabled").find(".t-icon").unbind("click").bind("click",b.preventDefault)},open:function(e){var f=this.$element;var d={offset:f.offset(),outerHeight:f.outerHeight(),outerWidth:f.outerWidth(),zIndex:b.getElementZIndex(f[0])};this[e=="time"?"timeView":"dateView"].open(d)},close:function(d){this[d=="time"?"timeView":"dateView"].close()},value:function(d){if(d===undefined){return this.selectedValue}var e=this.parse(d);e=b.datepicker.isInRange(e,this.minValue,this.maxValue)?e:null;if(e===null){this.$element.removeClass("t-state-error").val("")}this._value(e);return this},parse:function(d,f){if(d===null||d.getDate){return d}f=f||this.format;var e=b.datetime.parse({AM:b.cultureInfo.AM,PM:b.cultureInfo.PM,value:d,format:f,baseDate:this.selectedValue?new b.datetime(this.selectedValue):new b.datetime()});return e!=null?e.toDate():null}};c.each(["min","max"],c.proxy(function(e,d){b.datetimepicker.prototype[d]=function(f){var h=d+"Value";if(f===undefined){return this[h]}var i=this.parse(f);if(i!==null){var g=this[h];this[h]=i;if(this.minValue>this.maxValue){this[h]=g;return}this.dateView[d](i);if(!b.datepicker.isInRange(this.selectedValue,this.minValue,this.maxValue)){this.value(i)}}}},this));c.each(["startTime","endTime"],c.proxy(function(e,d){b.datetimepicker.prototype[d]=function(f){var g=d+"Value";if(f===undefined){return this[g]}var h=this.parse(f,b.cultureInfo.shortTime);if(h!==null){this[g]=h;d=="startTime"?this.timeView.min(h):this.timeView.max(h);if(!b.timeView.isInRange(this.selectedValue,this.minValue,this.maxValue)){this.value(h)}}}},this));c.fn.tDateTimePicker=function(d){c.fn.tDateTimePicker.defaults.timeFormat=b.cultureInfo.shortTime;return b.create(this,{name:"tDateTimePicker",init:function(e,f){return new b.datetimepicker(e,f)},options:d})};c.fn.tDateTimePicker.defaults={effects:b.fx.slide.defaults(),selectedValue:null,format:b.cultureInfo.generalDateShortTime,focusedDate:new b.datetime(),minValue:new Date(1899,11,31),maxValue:new Date(2100,0,1),startTimeValue:new b.datetime().hours(0).minutes(0).seconds(0).toDate(),endTimeValue:new b.datetime().hours(0).minutes(0).seconds(0).toDate(),calendarButtonTitle:"Open the calendar",timeButtonTitle:"Open the time view",showCalendarButton:true,showTimeButton:true,shortYearCutOff:30,enabled:true,interval:30}})(jQuery);