js-pkg
Version:
Npm package of Syncfusion.JavaScript.
10 lines • 51.3 kB
JavaScript
/*!
* filename: ej.daterangepicker.min.js
* version : 15.3.0.33
* Copyright Syncfusion Inc. 2001 - 2017. All rights reserved.
* Use of this code is subject to the terms of our license.
* A copy of the current license can be obtained at any time by e-mailing
* licensing@syncfusion.com. Any infringement will be prosecuted under
* applicable laws.
*/
(function(n){typeof define=="function"&&define.amd?define(["./../common/ej.globalize.min","./../common/ej.core.min","./../common/ej.scroller.min","./ej.datepicker.min","./ej.timepicker.min"],n):n()})(function(){"use strict";var n=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);r.prototype=t.prototype;n.prototype=new r},t=function(t){function i(n){return t.call(this),this._rootCSS="e-daterangepicker",this._setFirst=!1,this.PluginName="ejDateRangePicker",this.id="myDateRange",this._addToPersist=["value"],this.type="editor",this.angular={require:["?ngModel","^?form","^?ngModelOptions"],requireFormatters:!0},this._requiresID=!0,this.model=null,this.validTags=["input"],this.defaults={height:"",width:"",value:"",cssClass:"",enabled:!0,startDate:null,endDate:null,enableTimePicker:!1,ranges:null,locale:"en-US",separator:"-",watermarkText:"Select Range",dateFormat:"",timeFormat:"",showPopupButton:!0,showRoundedCorner:!1,allowEdit:!0,enablePersistence:!1,create:null,change:null,beforeClose:null,beforeOpen:null,close:null,open:null,hover:null,click:null,clear:null,destroy:null,select:null,htmlAttributes:{}},this._isIE8=ej.browserInfo().name=="msie"&&ej.browserInfo().version=="8.0"?!0:!1,this._prevValue=null,this._validState=null,i.prototype.observables=["value"],n&&(n.jquery||(n=$("#"+n)),n.length)?$(n).ejDateRangePicker().data(this.PluginName):void 0}return n(i,t),i.prototype.setModel=function(n,t){this.setModel(n,t)},i.prototype.option=function(n,t){this.option(n,t)},i.prototype._setModel=function(n){var t,i;this.popup||(this._onMainFocusOut(),this._renderPopup(),this._updateValues());for(t in n)switch(t){case"allowEdit":if(!n[t]){this.element.attr("readonly","readonly");this.element.on("mousedown",$.proxy(this._showDatePopUp,this));this.element.off("blur",$.proxy(this._onMainFocusOut,this))}break;case"startDate":i=this._validateValues(n[t],"left");i==!1?n[t]=null:(this._startEndValidation()||this.model.endDate==null||(this._resetValues(),this.model.endDate=null),this._updateValues(),this._selectedStartDate=this.model.startDate,n[t]=this.model.startDate);break;case"endDate":i=this._validateValues(n[t],"right");i==!1?n[t]=null:(this._startEndValidation()||(this._rightDP.element.parents(".e-datewidget").addClass("e-val-error"),this.model.endDate=null),this._updateValues(),n[t]=this.model.endDate);break;case"enableTimePicker":this.model.enableTimePicker=n[t];n[t]?this._renderTimePicker():this._removeTimePicker();this._scrollerObj&&(this._scrollerObj.model.height=this.datePopup.height(),this._scrollerObj.refresh());break;case"locale":this._setCulture(n[t]);n[t]=this.model.locale;break;case"separator":this.model.separator=n[t];this._mainValue();break;case"dateFormat":this._leftDP&&this._leftDP.option(t,n[t]);this._rightDP&&this._rightDP.option(t,n[t]);this.model.dateFormat=n[t];this._getDateTimeFormat();this._updateInput();break;case"timeFormat":this._leftTP&&this._leftTP.option(t,n[t]);this._rightTP&&this._rightTP.option(t,n[t]);this.model.timeFormat=n[t];this._getDateTimeFormat();this._updateInput();break;case"watermarkText":ej.isNullOrUndefined(this._options)&&(this._options={});this._options.watermarkText=this.model.watermarkText=n[t];this._localizedLabels.watermarkText=this.model.watermarkText;this._setWaterMark();break;case"cssClass":this._changeSkin(n[t]);break;case"showRoundedCorner":this._setRoundedCorner(n[t]);break;case"showPopupButton":this._renderDateIcon(n[t]);break;case"value":this.element.val(n[t]);this._onMainFocusOut();n[t]=this.model.value;break;case"height":this.wrapper.height(n[t]);break;case"width":this.wrapper.width(n[t]);break;case"enabled":n[t]?this.enable():this.disable();break;case"htmlAttributes":this._addAttr(n[t])}},i.prototype._init=function(n){this._cloneElement=this.element.clone();this._options=n;this._flagevents=!1;this._id=this.element.attr("id");this._isSupport=document.createElement("input").placeholder==undefined?!1:!0;this._startEndValidation()||(this.model.endDate=null);this.element.val()==""&&this.model.value&&this.element.val(this.model.value);this._getDateTimeFormat();this.element.val()?this._setInitValue():this.model.startDate!=null&&this.model.endDate!=null&&this._startEndValidation()&&this._mainValue();this._createWrapper();this._validState==!1&&this.element.val()&&this.wrapper.addClass("e-error");this._popupOpen=!1;this._isPopScroll=!1;this.model.enabled||this.disable();this._wireEvents()},i.prototype._setInitValue=function(){var n=this.element.val().split(this.model.separator),t=ej.parseDate(n[0],this._dateTimeFormat,this.model.locale),i=ej.parseDate(n[1],this._dateTimeFormat,this.model.locale);t&&i&&(this.model.startDate=t,this.model.endDate=i)},i.prototype._getNextMonth=function(n){var i=n,r,u,t;return(i instanceof Date)?(r=i.getMonth(),r==11?(u=i.getFullYear()+1,r=-1):u=i.getFullYear(),t=new Date,t=new Date(t.setFullYear(u)),t=new Date(t.setMonth(r+1)),new Date(t.setDate(1))):new Date},i.prototype._getDateTimeFormat=function(){var n=ej.preferredCulture(this.model.locale).calendars.standard.patterns;this.model.dateFormat||(this.model.dateFormat=n.d);this.model.enableTimePicker?(this.model.timeFormat||(this.model.timeFormat=n.t),this._dateTimeFormat=this.model.dateFormat+" "+this.model.timeFormat):this._dateTimeFormat=this.model.dateFormat},i.prototype._setValues=function(){this._leftDP.option("value",this.model.startDate);this._rightDP.option("value",this.model.endDate||null);this.model.startDate&&this._setStartDate(this.model.startDate,$('.current-month[data-date="'+this.model.startDate.toDateString()+'"]'),!0);this.model.endDate&&this._setEndDate(this.model.endDate,$('.current-month[data-date="'+this.model.endDate.toDateString()+'"]'),!0);this._rangeRefresh(this._setArgs(this._leftDP.popup));this._rangeRefresh(this._setArgs(this._rightDP.popup));this._rightDP.element.parents(".e-datewidget").removeClass("e-error");this.model.enableTimePicker&&(this._leftTP.option("value",this.model.startDate),this._rightTP.option("value",this.model.endDate));this._updateRanges("left");this._updateRanges("right")},i.prototype._customSet=function(){this._selectedStartDate=this.model.startDate;this._selectedEndDate=this.model.endDate;this._resetValues();this.popup&&this._setValues();this._popupOpen||this._mainValue();this._refreshMinMax();this._setWaterMark()},i.prototype._setCulture=function(n){n=ej.preferredCulture(n).name;this.model.locale=n;this._setOption("locale",n);this._localizedLabels=this._getLocalizedLabels();this._setLocalizedText();this._updateInput()},i.prototype._setRoundedCorner=function(n){n?(this._input_innerWrapper.addClass("e-corner"),this.popup&&this.popup.addClass("e-corner")):(this._input_innerWrapper.removeClass("e-corner"),this.popup&&this.popup.removeClass("e-corner"));this._setOption("showRoundedCorner",n)},i.prototype._renderDateIcon=function(n){n?(this.dateRangeIcon=ej.buildTag("span.e-select#"+this.id+"-img","",{},this._isIE8?{unselectable:"on"}:{}).append(ej.buildTag("span.e-icon e-calendar","",{},{"aria-label":"Select"}).attr(this._isIE8?{unselectable:"on"}:{})).insertAfter(this.element),this._input_innerWrapper.addClass("e-padding"),this._on(this.dateRangeIcon,"mousedown",this._showDatePopUp),this._off(this.dateRangeIcon,"click",this._showDatePopUp)):(this.dateRangeIcon&&this.dateRangeIcon.remove(),this._input_innerWrapper.removeClass("e-padding"),this._off(this.dateRangeIcon,"click",this._showDatePopUp))},i.prototype._validateValues=function(n,t){var r=t=="right"?this._rightDP:this._leftDP,i=n;if(i!=null&&typeof i=="string")t=="left"?(this.model.startDate=ej.parseDate(n,this.model.dateFormat,this.model.locale)||null,this.model.startDate=this.model.startDate!=null?this.model.startDate:new Date(i)):(this.model.endDate=ej.parseDate(n,this.model.dateFormat,this.model.locale)||null,this.model.endDate=this.model.endDate!=null?this.model.endDate:new Date(i));else if(n instanceof Date){if(t=="left"){if(this.model.startDate=n,isNaN(n.getDate()))return!1;typeof this._formatter(this.model.startDate,this.model.locale)!="string"&&(this.model.startDate=ej.parseDate(this._formatter(this.model.startDate,this.model.locale),this.model.dateFormat))}else if(t=="right"){if(this.model.endDate=n,isNaN(n.getDate()))return!1;typeof this._formatter(this.model.endDate,this.model.locale)!="string"&&(this.model.endDate=ej.parseDate(this._formatter(this.model.endDate,this.model.locale),this.model.dateFormat))}}else return!1;return!0},i.prototype._formatter=function(n,t){var i=this._checkFormat(t);return ej.format(n,i,this.model.locale)},i.prototype._checkFormat=function(n){var t=this,i=this._regExp();return n.replace(i,function(n){return n==="/"?ej.preferredCulture(t.model.locale).calendars.standard["/"]!=="/"?"'/'":n:n})},i.prototype._regExp=function(){return/\/dddd|ddd|dd|d|MMMM|MMM|MM|M|yyyy|yy|HH|H|hh|h|mm|m|fff|ff|f|tt|ss|s|zzz|zz|z|gg|g|"[^"]*"|'[^']*'|[/]/g},i.prototype._setArgs=function(n){var t=new Date($(n.find(".current-month")[0]).attr("data-date"));return this.args={},this.args.element=n,this.args.month=t.getMonth(),this.args.year=t.getFullYear(),this.args},i.prototype._changeSkin=function(n){this.wrapper.removeClass(this.model.cssClass).addClass(n);this.popup.removeClass(this.model.cssClass).addClass(n);this._setOption("cssClass",n)},i.prototype._renderDatePicker=function(){this.calendar_left=ej.buildTag("input.leftDate_wrapper#"+this.element[0].id+"leftDate_wrapper","",{},{type:"text"});this._leftDiv.append(this.calendar_left);this.calendar_right=ej.buildTag("input.rightDate_wrapper#"+this.element[0].id+"rightDate_wrapper","",{},{type:"text"});this._rightDiv.append(this.calendar_right);var n=this,t={displayInline:!0,showFooter:!1,watermarkText:"",enableStrictMode:!0,locale:this.model.locale,dateFormat:this.model.dateFormat,_month_Loaded:function(t){n._previousNextHandler(t)},enablePersistence:this.model.enablePersistence};this.calendar_left.ejDatePicker(t);this.calendar_left.ejDatePicker("option","layoutChange",function(){n._refreshEvents("left");n._updateRanges("left");n.popup.hasClass("e-daterange-responsive")||n._scrollerObj&&(n._scrollerObj.model.height=n.datePopup.height(),n._scrollerObj.refresh())});this._leftDP=this.calendar_left.data("ejDatePicker");this._leftDP.option("showPopupButton",!1);this._leftDP._getInternalEvents=!0;this._leftDP._DRPdisableFade=!0;this._leftDP.popup.css({position:"static",visibility:"inherit"});this.calendar_right.ejDatePicker(t);this.calendar_right.ejDatePicker("option","layoutChange",function(){n._refreshEvents("right");n._updateRanges("right");n.popup.hasClass("e-daterange-responsive")||n._scrollerObj&&(n._scrollerObj.model.height=n.datePopup.height(),n._scrollerObj.refresh())});this._rightDP=this.calendar_right.data("ejDatePicker");this._rightDP.option("showPopupButton",!1);this._rightDP._getInternalEvents=!0;this._rightDP._DRPdisableFade=!0;this._rightDP.popup.css({position:"static",visibility:"inherit"});this._on($(this._leftDP.sfCalendar.find("table .e-datepicker-months td")),"click",$.proxy(this._previousNextHandler,this));this._on(this._leftDP.element,"keydown",this._onKeyDown);this._on(this._rightDP.element,"keydown",this._onKeyDown)},i.prototype._renderPopup=function(){this.popup=ej.buildTag("div.e-daterangepicker-popup e-popup e-widget e-box"+this.model.cssClass+"#"+this.element[0].id+"_popup").css("display","none");$("body").append(this.popup);this.datePopup=ej.buildTag("div.e-datepickers-popup");this.popup.append(this.datePopup);this._leftDiv=ej.buildTag("div.e-left-datepicker");this._rightDiv=ej.buildTag("div.e-right-datepicker");this.datePopup.append(this._leftDiv);this.datePopup.append(this._rightDiv);this._renderDatePicker();this.model.ranges&&this._renderRanges();this.model.enableTimePicker&&this._renderTimePicker();this._renderButton();this._bindDateButton();this._refreshEvents("left");this._refreshEvents("right");this._updateRanges("left");this._updateRanges("right");this._setRoundedCorner(this.model.showRoundedCorner);this._addAttr(this.model.htmlAttributes);this._on(this.popup.find(".leftDate_wrapper.e-datepicker.e-js.e-input"),"blur",this._onPopupFocusOut);this._on(this.popup.find(".rightDate_wrapper.e-datepicker.e-js.e-input"),"blur",this._onPopupFocusOut);this._on(this.popup.find(".leftDate_wrapper.e-timepicker.e-js.e-input"),"blur",this._onPopupFocusOut);this._on(this.popup.find(".rightDate_wrapper.e-timepicker.e-js.e-input"),"blur",this._onPopupFocusOut);this.popup.on("mouseenter touchstart",$.proxy(function(){this._isPopScroll=!0},this));this.popup.on("mouseleave touchend",$.proxy(function(){this._isPopScroll=!1},this));this._on($(window),"resize",this._resizePopup);this._wirePopupEvents()},i.prototype._createWrapper=function(){var n;this._localizedLabels=this._getLocalizedLabels();this.element.addClass("e-input").attr({"aria-atomic":"true","aria-live":"assertive",tabindex:"0",role:"combobox","aria-expanded":"false",name:this.element.attr("name")==undefined?this._id:this.element.attr("name")});this._isSupport||(this._hiddenInput=ej.buildTag("input.e-input e-placeholder ","",{},{type:"text"}).insertAfter(this.element),this._hiddenInput.val(this._localizedLabels.watermarkText),this._hiddenInput.css("display","block"),n=this,$(this._hiddenInput).focus(function(){n.element.focus()}));this.wrapper=ej.buildTag("span.e-daterangewidget e-widget "+this.model.cssClass);ej.isTouchDevice()||this.wrapper.addClass("e-ntouch");this._input_innerWrapper=ej.buildTag("span.e-in-wrap e-box");this.wrapper.append(this._input_innerWrapper).insertBefore(this.element);this._input_innerWrapper.append(this.element);this._input_innerWrapper.addClass("e-padding");n=this;this.culture=ej.preferredCulture(this.model.locale);this._setRoundedCorner(this.model.showRoundedCorner);this._renderDateIcon(this.model.showPopupButton);this.wrapper&&(this.model.width&&this.wrapper.width(this.model.width),this.model.height&&this.wrapper.height(this.model.height));this._setWaterMark()},i.prototype._updateOnRender=function(){this.model.enableTimePicker?this._rightTime&&(this._rightTP=this._rightTime.ejTimePicker("instance"),this._updateValues()):this.calendar_right&&(this._rightDP=this.calendar_right.ejDatePicker("instance"),this._updateValues())},i.prototype._updateRangesList=function(){$(".e-dateranges-ul").find(".rangeItem.e-active").removeClass("e-active");$(".e-dateranges-ul").find(".rangeItem.e-custompic").addClass("e-active")},i.prototype._updateValues=function(){this._updateRangesList();this._getDateTimeFormat();this._startEndValidation()||this.model.startDate!=null&&this.model.endDate==null?(this._validateValues(this.model.startDate,"left"),this._validateValues(this.model.endDate,"right"),this.popup&&this._setValues(),this._mainValue()):(this._clearRanges(),this.element.val(""));this._refreshMinMax();this._setWaterMark()},i.prototype._startEndValidation=function(){if(this.model.startDate&&this.model.endDate){var t=this.model.startDate,n=this.model.endDate;return!(n&&t>n)}return!1},i.prototype._addAttr=function(n){var t=this;$.map(n,function(n,i){var r=i.toLowerCase();r=="class"?t.wrapper.addClass(n):r=="disabled"?t.disable():r=="readOnly"?t.model.readOnly=!0:r=="style"||r=="id"?t.wrapper.attr(i,n):ej.isValidAttr(t.element[0],i)?t.element.attr(i,n):t.wrapper.attr(i,n)})},i.prototype._renderButton=function(){var n;this._buttonDiv=ej.buildTag("div.e-drpbuttons");var t=ej.buildTag("div.e-drp-button e-drp-reset e-btn e-select e-flat").attr({tabindex:"0"}),i=ej.buildTag("div.e-drp-button e-drp-apply e-disable e-btn e-select e-flat").attr({tabindex:"0"}),r=ej.buildTag("div.e-drp-button e-drp-cancel e-btn e-select e-flat").attr({tabindex:"0"});this._buttonDiv.append(t);this._buttonDiv.append(i);this._buttonDiv.append(r);this.popup.append(this._buttonDiv);this._setLocalizedText();this._on($(this._buttonDiv.find("div.e-drp-reset")),"click",this.clearRanges);n=this;this._on($(this._buttonDiv.find("div.e-drp-apply")),"click",function(){n._buttonDiv.find(".e-drp-apply").hasClass("e-disable")||(n._isPopScroll=!1,n._updateInput(),n._showhidePopup(),n._buttonDiv.find(".e-drp-apply").addClass("e-disable"),this._trigger("change",{value:this.model.value,startDate:this.model.startDate,endDate:this.model.endDate}),this._trigger("select",{startDate:this.model.startDate,endDate:this.model.endDate,value:this.model.value}))});this._on($(this._buttonDiv.find("div.e-drp-cancel")),"click",this._cancelButton)},i.prototype._setLocalizedText=function(){ej.isNullOrUndefined(this._options)||(ej.isNullOrUndefined(this._options.buttonText)||$.extend(this._localizedLabels.ButtonText,this._options.buttonText),ej.isNullOrUndefined(this._options.watermarkText)||(this._localizedLabels.watermarkText=this._options.watermarkText));this.model.buttonText=this._localizedLabels.ButtonText;$(this._buttonDiv.find("div.e-drp-reset")).text(this.model.buttonText.reset);$(this._buttonDiv.find("div.e-drp-apply")).text(this.model.buttonText.apply);$(this._buttonDiv.find("div.e-drp-cancel")).text(this.model.buttonText.cancel);this._customRangePicker&&this._customRangePicker.find("ul li.e-custompic").length>0&&this._customRangePicker.find("ul li.e-custompic").text(this._localizedLabels.customPicker);this._setWaterMark()},i.prototype._renderRanges=function(){var f,i,t,n,r,u;if(this._renderRangesWrapper(),this.popup.append(this._customRangePicker),this._ranges_li="",f=this,this.model.ranges)for(i=0;i<this.model.ranges.length;i++)t=this.model.ranges[i],n=t.range,n.length===2&&(r=new Date(n[0]),u=new Date(n[1]),ej.isNullOrUndefined(r)&&(r=new Date(n[0])),ej.isNullOrUndefined(u)&&(u=new Date(n[1])),r<=u&&(f._ranges_li+="<li role='menuitem' title='"+t.label+"' class='rangeItem' data-e-range='"+JSON.stringify(n)+"' data-e-value='"+t.range+"'>"+t.label+"<\/li>"));this._ranges_li+="<li role='menuitem' class='rangeItem e-active e-custompic' data-e-range='customPicker'>"+this._localizedLabels.customPicker+"<\/li>";this.popup.find("div.e-custom-dateranges ul").append(this._ranges_li);this._on(this._customRangePicker.find("ul li.rangeItem"),"click",this._customSelection);this._customRangePicker.ejScroller({height:this.datePopup.height(),width:0,scrollerSize:15});f._scrollerObj=this._customRangePicker.ejScroller("instance")},i.prototype._removeTimePicker=function(){this._leftDiv.removeClass("e-left-timepicker");this._rightDiv.removeClass("e-right-timepicker");this._leftTP.destroy();this._rightTP.destroy();this._rightTP=null;this._leftTP=null;this._leftTime.remove();this._rightTime.remove();this._setOption("width","");this._setOption("width","100%");this._updateValues()},i.prototype._setOption=function(n,t){this._leftDP&&this._leftDP.option(n,t);this._rightDP&&this._rightDP.option(n,t);this.model.enableTimePicker&&(this._leftTP&&this._leftTP.option(n,t),this._rightTP&&this._rightTP.option(n,t))},i.prototype._renderTimePicker=function(){this.model.timeFormat==""&&(this.model.timeFormat=this.culture.calendar.patterns.t);this._leftTime=ej.buildTag("input.leftTime#"+this._id+"_lTime");this._leftDiv.append(this._leftTime);this._leftDiv.addClass("e-left-timepicker");var n=this,t={popupWidth:"115px",locale:this.model.locale,timeFormat:this.model.timeFormat,open:function(){this.popup.addClass("e-daterange-timepopup");this.model.open=null}};this._leftTime.ejTimePicker(t);this._leftTime.ejTimePicker({select:function(t){n.model.startDate&&n.model.endDate&&(n._rightTP&&n.model.startDate.toLocaleDateString()==n.model.endDate.toLocaleDateString()&&n._rightTP.option("minTime",t.value),n._buttonDiv.find(".e-drp-apply").removeClass("e-disable"))}});this._leftTP=this._leftTime.ejTimePicker("instance");this._rightTime=ej.buildTag("input.rightTime#"+this._id+"_rTime");this._rightDiv.append(this._rightTime);this._rightDiv.addClass("e-right-timepicker");this._rightTime.ejTimePicker(t);this._leftTime.ejTimePicker({select:function(){n.model.startDate&&n.model.endDate&&n._buttonDiv.find(".e-drp-apply").removeClass("e-disable")}});this._rightTP=this._rightTime.ejTimePicker("instance");this._on(this._leftTP.element,"keydown",this._onKeyDown);this._on(this._rightTP.element,"keydown",this._onKeyDown);this._setTimePickerPos()},i.prototype._setTimePickerPos=function(){$("#"+this._id+"_lTime_timewidget").css({position:"absolute",top:0,left:this._leftDP.popup.width()+this._leftDP.popup.position().left-this.popup.find($("#"+this._id+"_lTime_timewidget")).outerWidth()});$("#"+this._id+"_rTime_timewidget").css({position:"absolute",top:this.popup.hasClass("e-daterange-responsive")?this._rightDP.wrapper.position().top:0,left:this._rightDP.popup.width()+this._rightDP.popup.position().left-this.popup.find($("#"+this._id+"_rTime_timewidget")).outerWidth()})},i.prototype._updateInput=function(){if(!(this.model.startDate&&this.model.endDate)){this.model.value&&this.element.val(this.model.value);this._popupOpen&&this.popupHide();return}this._resetValues();this.wrapper.removeClass("e-error");this._mainValue();this._refreshMinMax()},i.prototype._removeWatermark=function(){this.element.val()==""||this._isSupport||this._hiddenInput.css("display","none")},i.prototype._mainValue=function(){var i=this.model.startDate,r=this.model.endDate,u=ej.format(i,this.model.timeFormat,this.model.locale),f=ej.format(r,this.model.timeFormat,this.model.locale),n=ej.format(i,this.model.dateFormat,this.model.locale),t=ej.format(r,this.model.dateFormat,this.model.locale);this.model.enableTimePicker?(this.popup&&this._leftTP&&this._rightTP&&this._leftTP.model.value&&this._rightTP.model.value&&(u=this._leftTP.model.value,f=this._rightTP.model.value),n=ej.format(n+" "+u,this._dateTimeFormat,this.model.locale),t=ej.format(t+" "+f,this._dateTimeFormat,this.model.locale),this.model.startDate=ej.parseDate(n,this._dateTimeFormat,this.model.locale),this.model.endDate=ej.parseDate(t,this._dateTimeFormat,this.model.locale)):this.popup&&(this.model.startDate=ej.parseDate(n,this._leftDP.model.dateFormat,this.model.locale),this.model.endDate=ej.parseDate(t,this._rightDP.model.dateFormat,this.model.locale));n!=null&&t!=null?(this.model.value=n+" "+this.model.separator+" "+t,this.element.val(this.model.value),this._hiddenInput&&this._hiddenInput.attr("value",this.model.value),this._removeWatermark(),this._validState=!0):(this.model.value=null,this._setWaterMark(),this._validState=!1);this._prevValue=this.model.value;this._buttonDiv&&this._buttonDiv.find(".e-drp-apply").addClass("e-disable");this._trigger("_change",{value:this.model.value})},i.prototype._bindDateButton=function(){if(this.dateRangeicon&&this._on(this.dateRangeIcon,"click",this._showDatePopUp),!this.model.allowEdit){this.element.attr("readonly","readonly");this.element.on("mousedown",$.proxy(this._showDatePopUp,this));this.element.off("blur",$.proxy(this._onMainFocusOut,this))}this.model.allowEdit&&this.element.off("mousedown",$.proxy(this._showDatePopUp,this))},i.prototype._showDatePopUp=function(n){if(!this.model.enabled)return!1;var t=!1;(n.button?t=n.button==2:n.which&&(t=n.which==3),t)||this._showhidePopup(n)},i.prototype._showhidePopup=function(n){this._popupOpen?(this._isFocused||!this.element.is(":input")||ej.isTouchDevice()||this.wrapper.addClass("e-focus"),this.popupHide(n)):(this._isFocused||!this.element.is(":input")||ej.isTouchDevice()||this.wrapper.addClass("e-focus"),this.popupShow(n))},i.prototype.popupHide=function(n){if(!n||n.type!="touchmove"&&n.type!="scroll"||!($(n.target).parents("#"+this.popup[0].id).length>0)){if(!this._popupOpen||this._isPopScroll)return!1;var t=this;this._trigger("beforeClose",{element:this.popup,events:n});this.popup.attr({"aria-hidden":"true"});this.element.attr({"aria-expanded":"false"});this._leftTP&&!this._leftTP._popupOpen&&this._leftTP.hide();this._rightTP&&!this._rightTP._popupOpen&&this._rightTP.hide();this.popup.css("visibility","visible").slideUp(100,function(){t._popupOpen=!1});this._off(ej.getScrollableParents(this.wrapper),"scroll",this.popupHide);this._off(ej.getScrollableParents(this.wrapper),"touchmove",this.popupHide);this._trigger("close",{element:this.popup,events:n});this.wrapper.removeClass("e-active")}},i.prototype.popupShow=function(n){if((this.popup||(this._onMainFocusOut(),this._renderPopup(),this._updateValues()),!this.model.enabled)||this._popupOpen)return!1;var t=this;this._trigger("beforeOpen",{element:this.popup,events:n});this.wrapper.addClass("e-focus");this.popup.attr({"aria-hidden":"false"});this.element.attr({"aria-expanded":"true"});t._popupOpen=!0;this.popup.css({visibility:"hidden",display:"block"});this._resizePopup();this.popup.css({display:"none",visibility:"visible"}).slideDown(100,function(){});this._on(ej.getScrollableParents(this.wrapper),"scroll",this.popupHide);this._on(ej.getScrollableParents(this.wrapper),"touchmove",this.popupHide);this._trigger("open",{element:this.popup,events:n});this.wrapper.addClass("e-active")},i.prototype._resizePopup=function(){var n=this,r=0,t=0,u=n.datePopup.find(".e-popup.e-calendar").outerWidth(),i=n.datePopup.find(".e-popup.e-calendar").height();if(this._customRangePicker&&this._customRangePicker.height()<=0&&this._customRangePicker.height(this.datePopup.height()),this.model.ranges&&this.model.ranges.length>0&&(t=this._customRangePicker.find("ul").height(),r=n._customRangePicker.outerWidth()),$(window).width()-this.wrapper.position().left<u*2+r+25){if(n.popup.addClass("e-daterange-responsive"),n._setOption("width","95%"),this.model.enableTimePicker){this._setOption("width","47%");this._setDatePickerPosition();$("#"+this._id+"_lTime_timewidget").css({left:this._leftDP.wrapper.outerWidth()+5});$("#"+this._id+"_rTime_timewidget").css({left:this._rightDP.wrapper.outerWidth()+5});n._scrollerObj&&(n._scrollerObj.model.height=t<i?t+10:i,n._scrollerObj.refresh());return}n._scrollerObj&&(n._scrollerObj.model.height=t<i?t+10:i,n._scrollerObj.refresh())}else n.popup.removeClass("e-daterange-responsive"),this.model.enableTimePicker&&(this._leftTP.option("width","115px"),this._rightTP.option("width","115px"),this._setTimePickerPos()),n._scrollerObj&&(n._scrollerObj.model.height=this.datePopup.height(),n._scrollerObj.refresh());this._setDatePickerPosition()},i.prototype._onDocumentClick=function(n){this.model&&(this.popup?!this.popup||$(n.target).is(this.popup)||$(n.target).parents(".e-popup").is(this.popup)||$(n.target).is(this.wrapper)||$(n.target).parents(".e-daterangewidget").is(this.wrapper)||(this.model.enableTimePicker?!this.model.enableTimePicker||$(n.target).is(this._leftTP.popup)||$(n.target).parents(".e-popup").is(this._leftTP.popup)||$(n.target).is(this._rightTP.popup)||$(n.target).parents(".e-popup").is(this._rightTP.popup)||(this._popupOpen&&this.popupHide(n),this.wrapper.removeClass("e-focus")):(this._popupOpen&&this.popupHide(n),this.wrapper.removeClass("e-focus"))):this.wrapper.removeClass("e-focus"))},i.prototype._getOffset=function(n){var t=n.offset()||{left:0,top:0},i;return $("body").css("position")!="static"&&(i=$("body").offset(),t.left-=i.left,t.top-=i.top),t},i.prototype._getZindexPartial=function(n,t){var u,r,i;if(!ej.isNullOrUndefined(n)&&n.length>0)return u=n.parents(),r=$("body").children(),!ej.isNullOrUndefined(n)&&n.length>0&&r.splice(r.index(t),1),$(r).each(function(n,t){u.push(t)}),i=Math.max.apply(i,$.map(u,function(n){if($(n).css("position")!="static")return parseInt($(n).css("z-index"))||1})),!i||i<1e4?i=1e4:i+=1,i},i.prototype._setDatePickerPosition=function(){var n=this.element.is("input")?this.wrapper:this.element,t=this._getOffset(n),u,s=$(document).scrollTop()+$(window).height()-(t.top+$(n).outerHeight()),h=t.top-$(document).scrollTop(),r=this.popup.outerHeight(),f=this.popup.outerWidth(),i=t.left,e=n.outerHeight(),a=(e-n.height())/2,c=this._getZindexPartial(this.element,this.popup),o=3,l=r<s||r>h?t.top+e+o:t.top-r-o;u=$(document).scrollLeft()+$(window).width()-i;f>u&&f<i+n.outerWidth()&&(i-=this.popup.outerWidth()-n.outerWidth());this.popup.css({left:i+"px",top:l+"px","z-index":c});this.model.enableTimePicker&&($("#"+this._id+"_lTime_timewidget").css({position:"absolute",top:0,left:this._leftDP.popup.width()+this._leftDP.popup.position().left-$("#"+this._id+"_lTime_timewidget").width()}),$("#"+this._id+"_rTime_timewidget").css({position:"absolute",top:this.popup.hasClass("e-daterange-responsive")?this._rightDP.wrapper.position().top:0,left:this._rightDP.popup.width()+this._rightDP.popup.position().left-$("#"+this._id+"_rTime_timewidget").width()}))},i.prototype._dateEleClicked=function(n){var r,i,u,e,t,f;if(this._updateRangesList(),this._activeItem=$(n.currentTarget),this._activeItem.hasClass("e-hidedate")){n.stopPropagation();return}(this._activeItem.hasClass("other-month")&&this._refreshMinMax(),t=this._activeItem.attr("data-date"),r=$(n.currentTarget).parents(".e-left-datepicker").length>0?"left":"right",ej.isNullOrUndefined(t)||t==="")||(i=new Date(t),this._selectedStartDate!=null&&this._selectedEndDate!=null&&(this._selectedStartDate=null),this._selectedStartDate==null?(this._selectedStartDate=i,this._selectedEndDate=null,this._startDate&&(this._startDate.date=null),this._rightDP.element.val(null),r=="right"&&(this._leftDP._stopRefresh=!0,this._leftDP.option("value",this._selectedStartDate),this._leftDP.element.val(this._selectedStartDate.toLocaleDateString())),this._rightTP&&this._rightTP.option("value",""),this.popup.find(".in-range").removeClass("in-range"),this.datePopup.find("td.e-state-default.e-active").removeClass("e-active"),this._rightDP.element.parents(".e-datewidget").removeClass("e-error"),u=$(this.datePopup.find('.current-month[data-date="'+t+'"]')),this._selectedStartDate=new Date(u.attr("data-date")),this._setStartDate(this._selectedStartDate,u,!0)):this._selectedStartDate===null||this._selectedEndDate!=null||i<this._selectedStartDate?(this._selectedStartDate=i,this._selectedEndDate=null,this._endDate&&(this._endDate.date=null),this.popup.find(".in-range").removeClass("in-range"),this._rightDP.option("value",null),this._rightTP&&this._rightTP.option("value",""),r=="right"&&(this._leftDP._stopRefresh=!0,this._leftDP.option("value",this._selectedStartDate),this._leftDP.element.val(this._selectedStartDate.toLocaleDateString())),this._setStartDate(this._selectedStartDate,this._activeItem,!0),this._updateRanges("left"),this._updateRanges("right")):(e=i,t=$(n.currentTarget).attr("data-date"),this._rightDP._stopRefresh=!0,this._rightDP.option("value",new Date(t)),this._rightDP._stopRefresh=!1,this._rightTP&&this._rightTP.option("value",new Date(t)),this._rightDP.element.parents(".e-datewidget").removeClass("e-error"),f=$(this.datePopup.find('.current-month[data-date="'+t+'"]')),this._selectedStartDate=this.model.startDate,this._selectedEndDate=new Date(t),this._setEndDate(this._selectedEndDate,f,!0),this._startDate={},this._startDate.date=this._selectedStartDate,this._updateRanges("left"),this._updateRanges("right"),r=="left"&&(this._leftDP._stopRefresh=!0,this._leftDP.option("value",this.model.startDate),this._leftDP.element.val(this.model.startDate.toLocaleDateString()))),this._trigger("click",{element:$(n.currentTarget),startDate:this.model.startDate,endDate:this.model.endDate,value:new Date($(n.currentTarget).attr("data-date"))}))},i.prototype._setStartDate=function(n,t,i){if(this._startDate={},this._startDate.date=n,i&&(this._endDate={},this._endDate.date=null),this._leftDP._checkDateArrows(),this.datePopup.find("td.e-state-default").removeClass("e-select e-start-date e-active showrange e-end-date e-state-hover"),this.popup.find(".in-range").removeClass("in-range"),t.addClass("e-start-date"),this.model.startDate=n,this._buttonDiv&&this._buttonDiv.find(".e-drp-apply").addClass("e-disable"),this.model.enableTimePicker){var u=this._leftTP,r=ej.format(this._leftTP.model.value||this._leftDP.model.value,u.model.timeFormat,this.model.locale);r&&this._rightTP.option("minTime",r);r&&this._leftTP.option("value",r)}},i.prototype._setEndDate=function(n,t){if((this._rightDP.element.parents(".e-datewidget").removeClass("e-val-error"),this._endDate={},this._endDate.date=n,this.popup.find("td.e-end-date").removeClass("e-select e-end-date"),t.addClass("e-end-date"),this._buttonDiv&&this._buttonDiv.find(".e-disable").removeClass("e-disable"),this.model.endDate=n,this._startDate.date.getFullYear()!=this._endDate.date.getFullYear()||this._startDate.date.getMonth()!=this._endDate.date.getMonth())&&this.model.enableTimePicker)if(this.model.startDate.getDate()==this.model.endDate.getDate())this._rightTP.option("minTime",this._leftTP.option("value")||""),this._rightTP.option("value",this._leftTP.option("value")||"");else{var r=this._rightTP,i=ej.format(this._rightTP.model.value,r.model.timeFormat,this.model.locale);i&&this._rightTP.option("minTime",i);i&&this._rightTP.option("value",i)}},i.prototype._rangeRefresh=function(n){var t,r,i,f,u;this._rightDP&&(i=n.element.parent().hasClass("e-left-datepicker")?this._leftDP.popup:this._rightDP.popup);this._startDate&&this._startDate.date&&this._startDate.date.getMonth()==n.month&&this._startDate.date.getFullYear()==n.year&&(t=$(i.find('.current-month[data-date="'+this._startDate.date.toDateString()+'"]')),this._setStartDate(this._startDate.date,t,!1),this._startDate.date.getDate()+1==t.next("td").text()&&$(t).addClass("showrange"));this._endDate&&this._endDate.date&&this._endDate.date.getMonth()==n.month&&this._endDate.date.getFullYear()==n.year&&(r=$(i.find('.current-month[data-date="'+this._endDate.date.toDateString()+'"]')),this._setEndDate(this._endDate.date,r,!1));t==r&&$(t).removeClass("showrange");this._rightDP&&this._startDate&&this._startDate.date&&this._endDate&&this._endDate.date&&this._startDate.date.getFullYear()<=n.year&&this._endDate.date.getFullYear()>=n.year&&(f=n.element.parent().hasClass("e-left-datepicker")?$(i.find("td.current-month")[0]):$(i.find("td.current-month")[0]),u=n.element.parent().hasClass("e-left-datepicker")?"left":"right",this._updateRanges(u))},i.prototype._renderRangesWrapper=function(){ej.isNullOrUndefined(this._customRangePicker)&&(this._customRangePicker=ej.buildTag("div.e-custom-dateranges").css("height",this.datePopup.height()),this.popup.append(this._customRangePicker),this._customRangePicker.insertBefore(this._buttonDiv),this._ranges_li="<ul class='e-dateranges-ul' role=menu><\/ul>",this._customRangePicker.append(this._ranges_li))},i.prototype.setRange=function(n){var t,i;if(this._clearRanges(),typeof n=="string"){for(i=0;i<this.model.ranges.length;i++)if(t=this.model.ranges[i],t.label==n){this.model.startDate=t.range[0];this.model.endDate=t.range[1];this._updatePreRanges();return}}else if(typeof n=="object"&&n.length==2){this.model.startDate=n[0];this.model.endDate=n[1];this._updatePreRanges();return}},i.prototype._updatePreRanges=function(){this._selectedStartDate=this.model.startDate;this._selectedEndDate=this.model.endDate;this._resetValues();this.popup&&this._setValues();this._refreshMinMax();this._popupOpen||this._mainValue();this._setWaterMark()},i.prototype.destroy=function(){this.destroy()},i.prototype._destroy=function(){this._popupOpen&&this._showhidePopup();this.wrapper&&(this.element.removeClass("e-input"),this.element.removeAttr("aria-atomic aria-live placeholder"),!this._cloneElement.attr("tabindex")&&this.element.attr("tabindex")&&this.element.removeAttr("tabindex"),this.element.insertAfter(this.wrapper),this.wrapper.remove());ej.isNullOrUndefined(this._leftDP)||this._leftDP.destroy();ej.isNullOrUndefined(this._rightDP)||this._rightDP.destroy();ej.isNullOrUndefined(this._rightTP)||this._rightTP.destroy();ej.isNullOrUndefined(this._leftTP)||this._leftTP.destroy();ej.isNullOrUndefined(this._scrollerObj)||this._scrollerObj.destroy();this.popup.remove()},i.prototype.addRanges=function(n){var o=this,e="",r,t,i,u,f;if(n)for(r=0;r<n.length;r++)t=n[r],i=t.range,i.length===2&&(u=new Date(i[0]),f=new Date(i[1]),ej.isNullOrUndefined(u)&&(u=new Date(i[0])),ej.isNullOrUndefined(f)&&(f=new Date(i[1])),u<=f&&(t.label||(t.label="PreDefined Ranges"),e+="<li aria-selected='false' title='"+t.label+"'class='rangeItem' data-e-range='"+JSON.stringify(i)+"' data-e-value='"+t.range+"'>"+t.label+"<\/li>"));this._renderRangesWrapper();this._customRangePicker.find(".e-dateranges-ul").append(e);this._off(this._customRangePicker.find("ul li.rangeItem"),"click",this._customSelection);this._on(this._customRangePicker.find("ul li.rangeItem"),"click",this._customSelection);this._scrollerObj&&this._scrollerObj.refresh()},i.prototype._righthoverRange=function(n){var r,i,t;if(this._activeItem=$(n.currentTarget),this._activeItem.hasClass("e-hidedate")){n.stopPropagation();return}this.popup.find(".range-hover").removeClass("range-hover");this._activeItem.hasClass("in-range")&&this._activeItem.addClass("range-hover");r=this._activeItem.attr("data-date");i=new Date(r);this._trigger("hover",{element:n.currentTarget,events:n,value:new Date(this._activeItem.attr("data-date"))});t=this;!ej.isNullOrUndefined(t._selectedStartDate)&&ej.isNullOrUndefined(t._selectedEndDate)&&this.popup.find(".current-month").each(function(n,r){var u=$(r),e=u.attr("data-date"),f;ej.isNullOrUndefined(e)||e===""||(f=new Date(e),f>t._startDate.date&&f<i?u.addClass("in-range"):u.removeClass("in-range"),f.getTime()===t._selectedStartDate.getTime()&&u.next().length!==0&&u.next("td.current-month").length!==0&&i>t._selectedStartDate&&new Date(new Date(t._selectedStartDate.getTime()).setDate(t._selectedStartDate.getDate()+1)).getTime()!==i.getTime()?u.addClass("showrange"):u.removeClass("showrange"))})},i.prototype._customSelection=function(n){if(this._customRangePicker.find(".e-active").removeClass("e-active"),$(n.currentTarget).attr("data-e-range")!="customPicker"){var t=$(n.currentTarget).attr("data-e-value").split(",");this.model.startDate=new Date(t[0]);this.model.endDate=new Date(t[1]);this._rightDP.element.parents(".e-datewidget").removeClass("e-error");this._customSet()}else this.model.startDate=null,this.model.endDate=null,this._clearRanges();$(n.currentTarget).addClass("e-active")},i.prototype._setWaterMark=function(){if(this.element!=null&&this.element.hasClass("e-input"))return this._isSupport||this.element.val()!=""?$(this.element).attr("placeholder",this._localizedLabels.watermarkText):this._hiddenInput.css("display","block").val(this._localizedLabels.watermarkText),!0},i.prototype._clearRanges=function(){this._updateRangesList();this._setOption("value","");this.popup&&this._rightDP.element.parents(".e-datewidget").removeClass("e-val-error");this._selectedStartDate=null;this._selectedEndDate=null;this._startDate&&(this._startDate.date=null);this._endDate&&(this._endDate.date=null);this.popup&&this.popup.find("td").removeClass("e-start-date e-end-date in-range e-active e-state-hover today");this.model.value=null;this.model.startDate=null;this.model.endDate=null;this._buttonDiv&&this._buttonDiv.find(".e-drp-apply").addClass("e-disable")},i.prototype.clearRanges=function(){this._clearRanges();this._refreshMinMax();this.element.val("");this._trigger("_change",{value:this.model.value});this._trigger("change",{value:this.model.value,startDate:this.model.startDate,endDate:this.model.endDate});this._trigger("clear",{})},i.prototype._getLocalizedLabels=function(){return ej.getLocalizedConstants("ej.DateRangePicker",this.model.locale)},i.prototype._unWireEvents=function(){this._off($(".e-next",this.popup),"click",$.proxy(this._previousNextHandler,this));this._off($(".e-prev",this.popup),"click",$.proxy(this._previousNextHandler,this));this._off($(this._buttonDiv.find("div.e-drp-cancel")),"click",this._cancelButton);this._off($(this._buttonDiv.find("div.e-drp-reset")),"click",this.clearRanges);this._off(this.popup.find(".leftDate_wrapper.e-datepicker.e-js.e-input"),"blur",this._onPopupFocusOut);this._off(this.popup.find(".rightDate_wrapper.e-datepicker.e-js.e-input"),"blur",this._onPopupFocusOut);this.model.allowEdit&&(this._off(this.element,"blur",this._onMainFocusOut),this._off(this.element,"focus",this._onFocusIn),this._off(this.element,"keydown",this._onKeyDown))},i.prototype._onDocumentKeyDown=function(n){n.keyCode=="13"&&!this._buttonDiv.find(".e-drp-apply").hasClass("e-disable")&&this.wrapper.hasClass("e-focus")&&this._buttonDiv.find(".e-drp-apply").click()},i.prototype._wirePopupEvents=function(){this._on($(".e-next",this.popup),"click",$.proxy(this._previousNextHandler,this));this._on($(".e-prev",this.popup),"click",$.proxy(this._previousNextHandler,this))},i.prototype._wireEvents=function(){$(document).on("mousedown",$.proxy(this._onDocumentClick,this));$(document).on("keydown",$.proxy(this._onDocumentKeyDown,this));this.model.allowEdit&&(this._on(this.element,"blur",this._onMainFocusOut),this._on(this.element,"focus",this._onFocusIn),this._on(this.element,"keydown",this._onKeyDown))},i.prototype._onFocusIn=function(n){this._isSupport&&(n.preventDefault(),this._isFocused=!0);this.wrapper.hasClass("e-error")&&(this._validState=!1,this.wrapper.removeClass("e-error"));this.model.showPopupButton||this.model.readOnly||this.popupShow(n);this.model.showPopupButton||this._on(this.element,"click",this._elementClick);this.wrapper.addClass("e-focus")},i.prototype._onKeyDown=function(n){n.keyCode==13&&($(n.currentTarget).hasClass("e-datepicker")?(this._validateValues($(n.currentTarget).val(),$(n.currentTarget).parents(".e-left-datepicker").length>0?"left":"right"),$(n.currentTarget).parents(".e-left-datepicker").length>0?this._leftDP.model.value=this.model.startDate:this._rightDP.model.value=this.model.endDate,this._onPopupFocusOut(n)):$(n.currentTarget).hasClass("leftTime")&&this._leftTP&&this._rightTP?this._leftTP._trigger("select"):this._rightTP._trigger("select"));n.stopImmediatePropagation()},i.prototype._cancelButton=function(){this._prevValue=null;this._isPopScroll=!1;this._clearRanges();this._onMainFocusOut();this._showhidePopup()},i.prototype._updateRanges=function(n){var i=n=="left"?this._leftDP:this._rightDP,t=this;if(i.popup.find("td.current-month").each(function(n,i){var r=$(i),f=r.attr("data-date"),u;ej.isNullOrUndefined(f)||f===""||(u=new Date(f),ej.isNullOrUndefined(t._startDate)||ej.isNullOrUndefined(t._startDate.date)||ej.isNullOrUndefined(t._endDate.date)||(u>t._startDate.date&&u<t._endDate.date?r.addClass("in-range"):r.removeClass("in-range")),ej.isNullOrUndefined(t._startDate)||ej.isNullOrUndefined(t._startDate.date)||u.toDateString()!=t._startDate.date.toDateString()||(r.addClass("e-start-date"),ej.isNullOrUndefined(t._endDate)||ej.isNullOrUndefined(t._endDate.date)||t._startDate.date.toDateString()==t._endDate.date.toDateString()||r.addClass("showrange"),r.removeClass("in-range")),ej.isNullOrUndefined(t._endDate)||ej.isNullOrUndefined(t._endDate.date)||ej.isNullOrUndefined(t._endDate)||u.toDateString()!=t._endDate.date.toDateString()||(r.addClass("e-end-date"),r.removeClass("in-range")))}),i.popup.find(".e-start-date").length>0){if($(i.popup.find(".e-start-date")).next("td.in-range").length>0)return;$(i.popup.find(".e-start-date")).removeClass("showrange")}},i.prototype.getSelectedRange=function(){return{startDate:this.model.startDate,endDate:this.model.endDate}},i.prototype.enable=function(){this.element[0].disabled=!1;this.model.enabled=!0;this.wrapper.removeClass("e-disable");this.element.removeClass("e-disable");this.element.attr("aria-disabled","false");this._isSupport||this._hiddenInput.attr("enabled","enabled");this.dateRangeIcon&&this.dateRangeIcon.removeClass("e-disable").attr("aria-disabled","false");this.popup&&this.popup.children("div").removeClass("e-disable").attr("aria-disabled","false");this._setOption("enabled",!0)},i.prototype.disable=function(){this.element[0].disabled=!0;this.model.enabled=!1;this.wrapper.addClass("e-disable");this.element.addClass("e-disable");this.element.attr("aria-disabled","true");this.element.attr("disabled","disabled");this._isSupport||this._hiddenInput.attr("disabled","disabled");this.dateRangeIcon&&this.dateRangeIcon.addClass("e-disable").attr("aria-disabled","true");this.popup&&this.popup.children("div").addClass("e-disable").attr("aria-disabled","true");this.popupHide();this._setOption("enabled",!1)},i.prototype._onMainFocusOut=function(){var n=this.element.val(),t;if(this.wrapper.removeClass("e-focus"),this.element.val()!=""||this._prevValue!=null){if(this._prevValue&&this._prevValue==this.element.val()){this._validState?this.wrapper.removeClass("e-error"):this.wrapper.addClass("e-error");return}if(this._updateRangesList(),this.element.val()==""){this.wrapper.removeClass("e-error");this._clearRanges();this._setWaterMark();this._refreshMinMax();this._trigger("change",{value:this.model.value,startDate:null,endDate:null});this._trigger("_change",{value:this.model.value});return}this.wrapper.removeClass("e-error");var i=this.element.val().split(this.model.separator),r=ej.parseDate(i[0],this._dateTimeFormat,this.model.locale),u=ej.parseDate(i[1],this._dateTimeFormat,this.model.locale);if(this._validState=!0,this._validateValues(r,"left")&&this._validateValues(u,"right")&&this._startEndValidation()||(this._clearRanges(),this._refreshMinMax(),t=!0),n!=""&&t){this.element.val(n);this.wrapper.addClass("e-error");this.model.value=null;this._validState=!1;this._trigger("_change",{value:this.element.val()});this._trigger("change",{value:this.model.value,startDate:null,endDate:null});return}this._resetValues();this.popup&&this._setValues();this._refreshMinMax();this.model.value=this._validState&&n!=""?n:null;this._popupOpen||this._mainValue();this._prevValue=this.model.value;this._validState?this.wrapper.removeClass("e-error").removeClass("e-focus"):this.wrapper.addClass("e-error").removeClass("e-focus");this._trigger("change",{value:this.model.value,startDate:this.model.startDate,endDate:this.model.endDate})}},i.prototype._onPopupFocusOut=function(n){var r;(ej.format(this._selectedStartDate,"M/d/yyyy")!=$("#daterangeleftDate_wrapper").val()||ej.format(this._selectedEndDate,"M/d/yyyy")!=$("#daterangerightDate_wrapper").val())&&this._updateRangesList();r=$(n.currentTarget).parents(".e-left-datepicker").length>0?this._leftDP:this._rightDP;this._validateValues($(n.currentTarget).val(),$(n.currentTarget).parents(".e-left-datepicker").length>0?"left":"right");$(n.currentTarget).parents(".e-left-datepicker").length>0?this._leftDP.model.value=this.model.startDate:this._rightDP.model.value=this.model.endDate;var t=this.model.startDate,u=this.model.endDate,i=!1;if(this._rightDP.element.parents(".e-datewidget").removeClass("e-val-error"),this._startEndValidation()||($(n.currentTarget).parents(".e-left-datepicker").length>0?(this._clearRanges(),this.model.startDate=t,this._selectedStartDate=this.model.startDate):(this._rightDP.element.parents(".e-datewidget").addClass("e-val-error"),this.model.endDate=null,i=!0)),t==null){this._clearRanges();return}this._selectedStartDate=this.model.startDate;this._selectedEndDate=this.model.endDate;this._resetValues();this.popup&&this._setValues();this.model.showPopupButton||this._off(this.element,"click",this._elementClick);this._refreshMinMax();this._popupOpen||this._mainValue();i&&this._rightDP.element.val(u.toLocaleDateString());this._setWaterMark()},i.prototype._resetValues=function(){this.popup&&(this._leftDP.option("maxDate",null),this._rightDP.option("minDate",null),this._leftDP.option("value",this._leftDP.model.value),this._rightDP.option("value",this._rightDP.model.value))},i.prototype._resetRanges=function(){this.popup&&(this._leftDP.option("maxDate",null),this._rightDP.option("minDate",null),this._leftDP.option("value",this._leftDP.model.value),this._rightDP.option("value",this._rightDP.model.value))},i.prototype._refreshMinMax=function(){var n,t;if(this.popup){n=this._getNextMonth(this._leftDP._calendarDate);n.toDateString()>this._rightDP._calendarDate.toDateString()&&(t=this._rightDP.model.value,this._rightDP._calendarDate=n,this._rightDP._dateValue=n,this._rightDP.option("value",n));this._rightDP.option("minDate",n);this._rightDP.option("value",t);var t=this._rightDP._calendarDate,i=t.getFullYear(),r=t.getMonth();this._leftDP.option("maxDate",new Date(i,r,0))}},i.prototype._refreshEvents=function(){this._off(this._rightDP.sfCalendar.find("table .e-datepicker-days td.e-state-default"),"click",this._dateEleClicked);this._off(this._leftDP.sfCalendar.find("table .e-datepicker-days td.e-state-default"),"click",this._dateEleClicked);this._off(this._rightDP.sfCalendar.find("table .e-datepicker-days td.e-state-default"),"mouseover",this._righthoverRange);this._off(this._leftDP.sfCalendar.find("table .e-datepicker-days td.e-state-default"),"mouseover",this._righthoverRange);this._on(this._leftDP.sfCalendar.find("table .e-datepicker-days td.e-state-default"),"mouseover",this._righthoverRange);this._on(this._leftDP.sfCalendar.find("table .e-datepicker-days td.e-state-default"),"click",this._dateEleClicked);this._on(this._rightDP.sfCalendar.find("table .e-datepicker-days td.e-state-default"),"mouseover",this._righthoverRange);this._on(this._rightDP.sfCalendar.find("table .e-datepicker-days td.e-state-default"),"click",this._dateEleClicked);this._on($(this._leftDP.sfCalendar.find("table .e-datepicker-months td")),"click",$.proxy(this._previousNextHandler,this))},i.prototype._previousNextHandler=function(n){var s=$(n.currentTarget).closest(".e-calendar").parent(),u=s.hasClass("e-left-datepicker")?"left":"right",i,r,f,e,h,t;if(n.type=="_month_Loaded"?u=="left"?(r=$(this._rightDP.popup.find("td.current-month")[0]).attr("data-date"),i=this._leftDP._dateValue.toDateString()):u=="right"&&(i=$(this._leftDP.popup.find("td.current-month")[0]).attr("data-date"),r=this._rightDP._dateValue.toDateString()):(r=$(this._rightDP.popup.find("td.current-month")[0]).attr("data-date"),i=$(t