1 line
6.2 KiB
JavaScript
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)).en
|