﻿Type.registerNamespace("Telerik.Web.UI");
Telerik.Web.UI.RadDatePicker=function(_1){
Telerik.Web.UI.RadDatePicker.initializeBase(this,[_1]);
this._calendar=null;
this._dateInput=null;
this._popupButton=null;
this._validationInput=null;
this._popupControlID=null;
this._popupButtonSettings=null;
this._focusedDate="";
this._minDate=new Date(1980,0,1);
this._maxDate=new Date(2099,11,31);
this._enabled=true;
this._onPopupImageMouseOverDelegate=null;
this._onPopupImageMouseOutDelegate=null;
this._onPopupButtonClickDelegate=null;
this._onDateInputFocusDelegate=null;
};
Telerik.Web.UI.RadDatePicker.PopupInstances={};
Telerik.Web.UI.RadDatePicker.prototype={initialize:function(){
Telerik.Web.UI.RadDatePicker.callBaseMethod(this,"initialize");
this._initializeDateInput();
this._initializeCalendar();
this.CalendarSelectionInProgress=false;
this.InputSelectionInProgress=false;
},dispose:function(){
if(this._calendar!=null){
this._calendar.dispose();
}
if(this._popupButton!=null){
var _2=this.get__popupImage();
if(_2!=null){
if(this._onPopupImageMouseOverDelegate){
try{
$removeHandler(_2,"mouseover",this._onPopupImageMouseOverDelegate);
}
catch(ex){
}
this._onPopupImageMouseOverDelegate=null;
}
if(this._onPopupImageMouseOutDelegate){
try{
$removeHandler(_2,"mouseout",this._onPopupImageMouseOutDelegate);
}
catch(ex){
}
this._onPopupImageMouseOutDelegate=null;
}
}
if(this._onPopupButtonClickDelegate){
try{
$removeHandler(this._popupButton,"click",this._onPopupButtonClickDelegate);
}
catch(ex){
}
this._onPopupButtonClickDelegate=null;
}
}
if(this._popupButton){
this._popupButton._events=null;
}
Telerik.Web.UI.RadDatePicker.callBaseMethod(this,"dispose");
},clear:function(){
if(this._dateInput){
this._dateInput.clear();
}
if(this._calendar){
this._calendar.unselectDates(this._calendar.get_selectedDates());
}
},togglePopup:function(){
if(this.isPopupVisible()){
this.hidePopup();
}else{
this.showPopup();
}
return false;
},isPopupVisible:function(){
if(!this._calendar){
return false;
}
return this.get__popup().IsVisible()&&(this.get__popup().Opener==this);
},showPopup:function(x,y){
if(this.isPopupVisible()){
return;
}
this._actionBeforeShowPopup();
var _5=this.get_textBox();
if(typeof (x)=="undefined"||typeof (y)=="undefined"){
var _6=_5;
if(_5.style.display=="none"){
_6=this.get__popupImage();
}
var _7=this.getElementPosition(_6);
x=_7.x;
y=_7.y+_6.offsetHeight;
}
this.get__popup().ExcludeFromHiding=this.get__PopupVisibleControls();
this.hidePopup();
var _8=true;
var _9=new Telerik.Web.UI.DatePickerPopupOpeningEventArgs(this._calendar,false);
this.raise_popupOpening(_9);
if(_9.get_cancel()==true){
return;
}
_8=!_9.get_cancelCalendarSynchronization();
this.get__popup().Opener=this;
this.get__popup().Show(x,y,this.get_popupContainer());
if(_8==true){
var _a=this._dateInput.get_selectedDate();
if(this.isEmpty()){
this._focusCalendar();
}else{
this._setCalendarDate(_a);
}
}
if(this._calendar&&!this._calendar._linksHandlersAdded){
var _b=this._calendar.get_element().getElementsByTagName("a");
for(var i=0,_d=_b.length;i<_d;i++){
var _e=_b[i];
$addHandlers(_e,{click:Function.createDelegate(this,this._click)});
}
this._calendar._linksHandlersAdded=true;
}
},_click:function(e){
var _10=(e.srcElement)?e.srcElement:e.target;
if(_10.tagName&&_10.tagName.toLowerCase()=="a"){
var _11=_10.getAttribute("href",2);
if(_11=="#"||(location.href+"#"==_11)){
if(e.preventDefault){
e.preventDefault();
}
return false;
}
}
},isEmpty:function(){
return this._dateInput.isEmpty();
},hidePopup:function(){
this._hideFastNavigationPopup(this);
if(this.get__popup().IsVisible()){
var _12=new Telerik.Web.UI.DatePickerPopupClosingEventArgs(this._calendar);
this.raise_popupClosing(_12);
if(_12.get_cancel()){
return false;
}
this.get__popup().Hide();
this.get__popup().Opener=null;
}
return true;
},getElementDimensions:function(_13){
var _14=_13.style.left;
var _15=_13.style.display;
var _16=_13.style.position;
_13.style.left="-10000px";
_13.style.display="";
_13.style.position="absolute";
var _17=_13.offsetHeight;
var _18=_13.offsetWidth;
_13.style.left=_14;
_13.style.display=_15;
_13.style.position=_16;
return {width:_18,height:_17};
},getElementPosition:function(el){
return Telerik.Web.UI.Calendar.Utils.GetElementPosition(el);
},get_calendar:function(){
return this._calendar;
},set_calendar:function(_1a){
this._calendar=_1a;
},get_popupButton:function(){
return this._popupButton;
},get_dateInput:function(){
return this._dateInput;
},set_dateInput:function(_1b){
this._dateInput=_1b;
},get_textBox:function(){
return $get(this._dateInput.get_id()+"_text");
},get_popupContainer:function(){
if((this._popupContainer==null)){
if(this._popupContainerID){
this._popupContainer=$get(this._popupContainerID);
}else{
this._popupContainer=null;
}
}
return this._popupContainer;
},get_enabled:function(){
return this._enabled;
},set_enabled:function(_1c){
if(this._enabled!=_1c){
if(_1c){
this._enabled=true;
if(this._dateInput){
this._dateInput.enable();
}
if(this._calendar){
this._calendar.set_enabled(true);
}
if(this._onPopupButtonClickDelegate){
$addHandler(this.get_popupButton(),"click",this._onPopupButtonClickDelegate);
}
if(this._onPopupImageMouseOverDelegate){
$addHandler(this.get__popupImage(),"mouseover",this._onPopupImageMouseOverDelegate);
}
if(this._onPopupImageMouseOutDelegate){
$addHandler(this.get__popupImage(),"mouseout",this._onPopupImageMouseOutDelegate);
}
}else{
this._enabled=false;
if(this._dateInput){
this._dateInput.disable();
}
if(this._calendar){
this._calendar.set_enabled(false);
}
if(this._onPopupButtonClickDelegate){
$removeHandler(this.get_popupButton(),"click",this._onPopupButtonClickDelegate);
}
if(this._onPopupImageMouseOverDelegate){
$removeHandler(this.get__popupImage(),"mouseover",this._onPopupImageMouseOverDelegate);
}
if(this._onPopupImageMouseOutDelegate){
$removeHandler(this.get__popupImage(),"mouseout",this._onPopupImageMouseOutDelegate);
}
}
this.raisePropertyChanged("enabled");
}
},get_selectedDate:function(){
return this._dateInput.get_selectedDate();
},set_selectedDate:function(_1d){
this._dateInput.set_selectedDate(_1d);
},get_minDate:function(){
return this._minDate;
},set_minDate:function(_1e){
var _1f=this._cloneDate(_1e);
if(this._minDate.toString()!=_1f.toString()){
if(!this._dateInput){
this._minDate=_1f;
}else{
var _20=false;
if(this.isEmpty()){
_20=true;
}
this._minDate=_1f;
this._dateInput.set_minDate(_1f);
if(this.get_focusedDate()<_1f){
this.set_focusedDate(_1f);
}
if(_20||(this.get_selectedDate()<this.get_minDate())){
this._dateInput.clear();
}
var _21=[_1f.getFullYear(),(_1f.getMonth()+1),_1f.getDate()];
if(this._calendar){
this._calendar.set_rangeMinDate(_21);
}
}
this.raisePropertyChanged("minDate");
}
},get_maxDate:function(){
return this._maxDate;
},set_maxDate:function(_22){
var _23=this._cloneDate(_22);
if(this._maxDate.toString()!=_23.toString()){
if(!this._dateInput){
this._maxDate=_23;
}else{
this._maxDate=_23;
this._dateInput.set_maxDate(_23);
if(this.get_selectedDate()>this.get_maxDate()){
this.set_selectedDate(this.get_maxDate());
}
var _24=[_23.getFullYear(),(_23.getMonth()+1),_23.getDate()];
if(this._calendar){
this._calendar.set_rangeMaxDate(_24);
}
}
this.raisePropertyChanged("maxDate");
}
},get_focusedDate:function(){
return this._focusedDate;
},set_focusedDate:function(_25){
var _26=this._cloneDate(_25);
if(this._focusedDate.toString()!=_26.toString()){
this._focusedDate=_26;
this.raisePropertyChanged("focusedDate");
}
},_initializeDateInput:function(){
if(this._dateInput!=null&&(!this._dateInput.get_owner)){
var _27=this;
this._dateInput.get_owner=function(){
return _27;
};
this._dateInput.Owner=this;
this._setUpValidationInput();
this._setUpDateInput();
this._propagateRangeValues();
this._initializePopupButton();
}
this._updatePercentageHeight();
},_updatePercentageHeight:function(){
var _28=$get(this.get_id()+"_wrapper");
if(_28.style.height.indexOf("%")>-1){
if(_28.offsetHeight!=0){
this.get_textBox().style.height=_28.offsetHeight+"px";
this.get_dateInput()._originalTextBoxCssText+="height:"+this.get_textBox().style.height+";";
}else{
var obj=this;
window.setTimeout(function(){
obj.get_textBox().style.height=_28.offsetHeight+"px";
obj.get_dateInput()._originalTextBoxCssText+="height:"+obj.get_textBox().style.height+";";
},0);
}
}
},_initializeCalendar:function(){
if(this._calendar!=null){
this._setUpCalendar();
this._calendar.set_enableMultiSelect(false);
this._calendar.set_useColumnHeadersAsSelectors(false);
this._calendar.set_useRowHeadersAsSelectors(false);
this._popupContainerID=this._calendar.get_id()+"_wrapper";
}
},_propagateRangeValues:function(){
if(this.get_minDate().toString()!=new Date(1980,0,1)){
this._dateInput.set_minDate(this.get_minDate());
}
if(this.get_maxDate().toString()!=new Date(2099,11,31)){
this._dateInput.set_maxDate(this.get_maxDate());
}
},_triggerDomChangeEvent:function(){
this._dateInput._triggerDOMChangeEvent(this._validationInput);
},_initializePopupButton:function(){
this._popupButton=$get(this._popupControlID);
if(this._popupButton!=null){
this._attachPopupButtonEvents();
}
},_attachPopupButtonEvents:function(){
var _2a=this.get__popupImage();
var _2b=this;
if(_2a!=null){
if(!this._hasAttribute("onmouseover")){
this._onPopupImageMouseOverDelegate=Function.createDelegate(this,this._onPopupImageMouseOverHandler);
$addHandler(_2a,"mouseover",this._onPopupImageMouseOverDelegate);
}
if(!this._hasAttribute("onmouseout")){
this._onPopupImageMouseOutDelegate=Function.createDelegate(this,this._onPopupImageMouseOutHandler);
$addHandler(_2a,"mouseout",this._onPopupImageMouseOutDelegate);
}
}
if(this._hasAttribute("href")!=null&&this._hasAttribute("href")!=""&&this._hasAttribute("onclick")==null){
this._onPopupButtonClickDelegate=Function.createDelegate(this,this._onPopupButtonClickHandler);
$addHandler(this._popupButton,"click",this._onPopupButtonClickDelegate);
}
},_onPopupImageMouseOverHandler:function(e){
this.get__popupImage().src=this._popupButtonSettings.ResolvedHoverImageUrl;
},_onPopupImageMouseOutHandler:function(e){
this.get__popupImage().src=this._popupButtonSettings.ResolvedImageUrl;
},_onPopupButtonClickHandler:function(e){
this.togglePopup();
e.stopPropagation();
e.preventDefault();
return false;
},_hasAttribute:function(_2f){
return this._popupButton.getAttribute(_2f);
},_calendarDateSelected:function(_30){
if(this.InputSelectionInProgress==true){
return;
}
if(_30.IsSelected){
if(this.hidePopup()==false){
return;
}
var _31=this._getJavaScriptDate(_30.get_date());
this.CalendarSelectionInProgress=true;
this._setInputDate(_31);
}
},_actionBeforeShowPopup:function(){
for(var _32 in Telerik.Web.UI.RadDatePicker.PopupInstances){
if(Telerik.Web.UI.RadDatePicker.PopupInstances.hasOwnProperty(_32)){
var _33=Telerik.Web.UI.RadDatePicker.PopupInstances[_32].Opener;
this._hideFastNavigationPopup(_33);
Telerik.Web.UI.RadDatePicker.PopupInstances[_32].Hide();
}
}
},_hideFastNavigationPopup:function(_34){
if(_34){
var _35=_34.get_calendar()._getFastNavigation().Popup;
if(_35&&_35.IsVisible()){
_35.Hide(true);
}
}
},_setInputDate:function(_36){
this._dateInput.set_selectedDate(_36);
},_getJavaScriptDate:function(_37){
var _38=new Date();
_38.setFullYear(_37[0],_37[1]-1,_37[2]);
return _38;
},_onDateInputDateChanged:function(_39,_3a){
this._setValidatorDate(_3a.get_newDate());
this._triggerDomChangeEvent();
if(!this.isPopupVisible()){
return;
}
if(this.isEmpty()){
this._focusCalendar();
}else{
if(!this.CalendarSelectionInProgress){
this._setCalendarDate(_3a.get_newDate());
}
}
},_focusCalendar:function(){
this._calendar.unselectDates(this._calendar.get_selectedDates());
var _3b=[this.get_focusedDate().getFullYear(),this.get_focusedDate().getMonth()+1,this.get_focusedDate().getDate()];
this._calendar.navigateToDate(_3b);
},_setValidatorDate:function(_3c){
var _3d="";
if(_3c!=null){
var _3e=(_3c.getMonth()+1).toString();
if(_3e.length==1){
_3e="0"+_3e;
}
var day=_3c.getDate().toString();
if(day.length==1){
day="0"+day;
}
_3d=_3c.getFullYear()+"-"+_3e+"-"+day;
}
this._validationInput.value=_3d;
},_setCalendarDate:function(_40){
var _41=[_40.getFullYear(),_40.getMonth()+1,_40.getDate()];
var _42=(this._calendar.FocusedDate[1]!=_41[1])||(this._calendar.FocusedDate[0]!=_41[0]);
this.InputSelectionInProgress=true;
this._calendar.unselectDates(this._calendar.get_selectedDates());
this._calendar.selectDate(_41,_42);
this.InputSelectionInProgress=false;
},_cloneDate:function(_43){
var _44=null;
if(!_43){
return null;
}
if(typeof (_43.setFullYear)=="function"){
_44=[];
_44[_44.length]=_43.getFullYear();
_44[_44.length]=_43.getMonth()+1;
_44[_44.length]=_43.getDate();
_44[_44.length]=_43.getHours();
_44[_44.length]=_43.getMinutes();
_44[_44.length]=_43.getSeconds();
_44[_44.length]=_43.getMilliseconds();
}else{
if(typeof (_43)=="string"){
_44=_43.split(/-/);
}
}
if(_44!=null){
var _45=new Date();
_45.setDate(1);
_45.setFullYear(_44[0]);
_45.setMonth(_44[1]-1);
_45.setDate(_44[2]);
_45.setHours(_44[3]);
_45.setMinutes(_44[4]);
_45.setSeconds(_44[5]);
_45.setMilliseconds(0);
return _45;
}
return null;
},_setUpValidationInput:function(){
this._validationInput=$get(this.get_id());
},_setUpDateInput:function(){
this._onDateInputValueChangedDelegate=Function.createDelegate(this,this._onDateInputValueChangedHandler);
this._dateInput.add_valueChanged(this._onDateInputValueChangedDelegate);
this._onDateInputBlurDelegate=Function.createDelegate(this,this._onDateInputBlurHandler);
this._dateInput.add_blur(this._onDateInputBlurDelegate);
this._onDateInputKeyPressDelegate=Function.createDelegate(this,this._onDateInputKeyPressHandler);
this._dateInput.add_keyPress(this._onDateInputKeyPressDelegate);
this._onDateInputFocusDelegate=Function.createDelegate(this,this._onDateInputFocusHandler);
this._dateInput.add_focus(this._onDateInputFocusDelegate);
},_onDateInputValueChangedHandler:function(_46,_47){
this._onDateInputDateChanged(_46,_47);
this.raise_dateSelected(_47);
this.CalendarSelectionInProgress=false;
},_onDateInputBlurHandler:function(_48,_49){
},_onDateInputFocusHandler:function(_4a,_4b){
this._triggerDomEvent("focus",this._validationInput);
},_triggerDomEvent:function(_4c,_4d){
if(!_4c||_4c==""||!_4d){
return;
}
if(_4d.fireEvent&&document.createEventObject){
var _4e=document.createEventObject();
_4d.fireEvent(String.format("on{0}",_4c),_4e);
}else{
if(_4d.dispatchEvent){
var _4f=true;
var _4e=document.createEvent("HTMLEvents");
_4e.initEvent(_4c,_4f,true);
_4d.dispatchEvent(_4e);
}
}
},_onDateInputKeyPressHandler:function(_50,_51){
if(_51.get_keyCode()==13){
this._setValidatorDate(_50.get_selectedDate());
}
},_setUpCalendar:function(){
this._onCalendarDateSelectedDelegate=Function.createDelegate(this,this._onCalendarDateSelectedHandler);
this._calendar.add_dateSelected(this._onCalendarDateSelectedDelegate);
},_onCalendarDateSelectedHandler:function(_52,_53){
if(this.isPopupVisible()){
this._calendarDateSelected(_53.get_renderDay());
}
},get__popupImage:function(){
var _54=null;
if(this._popupButton!=null){
var _55=this._popupButton.getElementsByTagName("img");
if(_55.length>0){
_54=_55[0];
}
}
return _54;
},get__popup:function(){
var _56=Telerik.Web.UI.RadDatePicker.PopupInstances[this._calendar.get_id()];
if(!_56){
_56=new Telerik.Web.UI.Calendar.Popup();
Telerik.Web.UI.RadDatePicker.PopupInstances[this._calendar.get_id()]=_56;
}
return _56;
},get__PopupVisibleControls:function(){
var _57=[this.get_textBox(),this.get_popupContainer()];
if(this._popupButton!=null){
_57[_57.length]=this._popupButton;
}
return _57;
},get__PopupButtonSettings:function(){
return this._popupButtonSettings;
},set__PopupButtonSettings:function(_58){
this._popupButtonSettings=_58;
},add_dateSelected:function(_59){
this.get_events().addHandler("dateSelected",_59);
},remove_dateSelected:function(_5a){
this.get_events().removeHandler("dateSelected",_5a);
},raise_dateSelected:function(_5b){
this.raiseEvent("dateSelected",_5b);
},add_popupOpening:function(_5c){
this.get_events().addHandler("popupOpening",_5c);
},remove_popupOpening:function(_5d){
this.get_events().removeHandler("popupOpening",_5d);
},raise_popupOpening:function(_5e){
this.raiseEvent("popupOpening",_5e);
},add_popupClosing:function(_5f){
this.get_events().addHandler("popupClosing",_5f);
},remove_popupClosing:function(_60){
this.get_events().removeHandler("popupClosing",_60);
},raise_popupClosing:function(_61){
this.raiseEvent("popupClosing",_61);
}};
Telerik.Web.UI.RadDatePicker.registerClass("Telerik.Web.UI.RadDatePicker",Telerik.Web.UI.RadWebControl);


if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();