Advertisement
1stein

AjaxControlToolkit CalendarExtender 'Reset' feature

Sep 27th, 2012
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. /// <reference name="MicrosoftAjax.debug.js" />
  4. /// <reference name="MicrosoftAjaxTimer.debug.js" />
  5. /// <reference name="MicrosoftAjaxWebForms.debug.js" />
  6. /// <reference path="../ExtenderBase/BaseScripts.js" />
  7. /// <reference path="../Common/Common.js" />
  8. /// <reference path="../Common/DateTime.js" />
  9. /// <reference path="../Common/Threading.js" />
  10. /// <reference path="../Animation/Animations.js" />
  11. /// <reference path="../Animation/AnimationBehavior.js" />
  12. /// <reference path="../PopupExtender/PopupBehavior.js" />
  13.  
  14. (function () {
  15.     var scriptName = "ExtendedCalendar";
  16.  
  17.     function execute() {
  18.  
  19.         Type.registerNamespace("Sys.Extended.UI");
  20.  
  21.         Sys.Extended.UI.CalendarBehavior = function (element) {
  22.             /// <summary>
  23.             /// A behavior that attaches a calendar date selector to a textbox
  24.             /// </summmary>
  25.             /// <param name="element" type="Sys.UI.DomElement">The element to attach to</param>
  26.  
  27.             Sys.Extended.UI.CalendarBehavior.initializeBase(this, [element]);
  28.  
  29.             this._textbox = Sys.Extended.UI.TextBoxWrapper.get_Wrapper(element);
  30.             this._format = "d";
  31.             this._todaysDateFormat = "MMMM d, yyyy";
  32.             this._daysModeTitleFormat = "MMMM, yyyy";
  33.             this._cssClass = "ajax__calendar";
  34.             this._enabled = true;
  35.             this._animated = true;
  36.             this._buttonID = null;
  37.             this._layoutRequested = 0;
  38.             this._layoutSuspended = false;
  39.             this._button = null;
  40.             this._popupMouseDown = false;
  41.             this._selectedDate = null;
  42.             this._startDate = null;
  43.             this._endDate = null;
  44.             this._visibleDate = null;
  45.             this._todaysDate = null;
  46.             this._firstDayOfWeek = Sys.Extended.UI.FirstDayOfWeek.Default;
  47.             this._firstPopUp = true;
  48.  
  49.             this._container = null;
  50.             this._popupDiv = null;
  51.             this._header = null;
  52.             this._prevArrow = null;
  53.             this._nextArrow = null;
  54.             this._title = null;
  55.             this._body = null;
  56.             this._today = null;
  57.  
  58.             this._reset = null;
  59.             this._defaultSelectedDate = null;
  60.  
  61.             this._days = null;
  62.             this._daysTable = null;
  63.             this._daysTableHeader = null;
  64.             this._daysTableHeaderRow = null;
  65.             this._daysBody = null;
  66.             this._months = null;
  67.             this._monthsTable = null;
  68.             this._monthsBody = null;
  69.             this._years = null;
  70.             this._yearsTable = null;
  71.             this._yearsBody = null;
  72.             this._popupPosition = Sys.Extended.UI.CalendarPosition.BottomLeft;
  73.             this._defaultView = Sys.Extended.UI.CalendarDefaultView.Days;
  74.  
  75.             this._popupBehavior = null;
  76.             this._modeChangeAnimation = null;
  77.             this._modeChangeMoveTopOrLeftAnimation = null;
  78.             this._modeChangeMoveBottomOrRightAnimation = null;
  79.             this._mode = "days";
  80.             this._selectedDateChanging = false;
  81.             this._isOpen = false;
  82.             this._isAnimating = false;
  83.             this._clearTime = false;
  84.             this._width = 170;
  85.             this._height = 139;
  86.             this._modes = { "days": null, "months": null, "years": null };
  87.             this._modeOrder = { "days": 0, "months": 1, "years": 2 };
  88.             //this._hourOffsetForDst = 12;  // Hour value for calls to new Date(...) to avoid DST issues
  89.             this._blur = new Sys.Extended.UI.DeferredOperation(1, this, this.blur);
  90.  
  91.             this._button$delegates = {
  92.                 click: Function.createDelegate(this, this._button_onclick),
  93.                 keypress: Function.createDelegate(this, this._button_onkeypress),
  94.                 blur: Function.createDelegate(this, this._button_onblur)
  95.             }
  96.             this._element$delegates = {
  97.                 change: Function.createDelegate(this, this._element_onchange),
  98.                 keypress: Function.createDelegate(this, this._element_onkeypress),
  99.                 click: Function.createDelegate(this, this._element_onclick),
  100.                 focus: Function.createDelegate(this, this._element_onfocus),
  101.                 blur: Function.createDelegate(this, this._element_onblur)
  102.             }
  103.             this._popup$delegates = {
  104.                 mousedown: Function.createDelegate(this, this._popup_onmousedown),
  105.                 mouseup: Function.createDelegate(this, this._popup_onmouseup),
  106.                 drag: Function.createDelegate(this, this._popup_onevent),
  107.                 dragstart: Function.createDelegate(this, this._popup_onevent)
  108.             }
  109.             this._cell$delegates = {
  110.                 mouseover: Function.createDelegate(this, this._cell_onmouseover),
  111.                 mouseout: Function.createDelegate(this, this._cell_onmouseout),
  112.                 click: Function.createDelegate(this, this._cell_onclick)
  113.             }
  114.         }
  115.         Sys.Extended.UI.CalendarBehavior.prototype = {
  116.  
  117.             get_clearTime: function () {
  118.                 /// <summary>
  119.                 /// Whether time should be cleared in edited date/time
  120.                 /// </summary>
  121.                 /// <value type="Boolean" />
  122.  
  123.                 return this._clearTime;
  124.             },
  125.             set_clearTime: function (value) {
  126.                 if (this._clearTime != value) {
  127.                     this._clearTime = value;
  128.                     this.raisePropertyChanged("_clearTime");
  129.                 }
  130.             },
  131.  
  132.             get_animated: function () {
  133.                 /// <summary>
  134.                 /// Whether changing modes is animated
  135.                 /// </summary>
  136.                 /// <value type="Boolean" />
  137.  
  138.                 return this._animated;
  139.             },
  140.             set_animated: function (value) {
  141.                 if (this._animated != value) {
  142.                     this._animated = value;
  143.                     this.raisePropertyChanged("animated");
  144.                 }
  145.             },
  146.  
  147.             get_enabled: function () {
  148.                 /// <value type="Boolean">
  149.                 /// Whether this behavior is available for the current element
  150.                 /// </value>
  151.  
  152.                 return this._enabled;
  153.             },
  154.             set_enabled: function (value) {
  155.                 if (this._enabled != value) {
  156.                     this._enabled = value;
  157.                     this.raisePropertyChanged("enabled");
  158.                 }
  159.             },
  160.  
  161.             get_button: function () {
  162.                 /// <value type="Sys.UI.DomElement">
  163.                 /// The button to use to show the calendar (optional)
  164.                 /// </value>
  165.  
  166.                 return this._button;
  167.             },
  168.             set_button: function (value) {
  169.                 if (this._button != value) {
  170.                     if (this._button && this.get_isInitialized()) {
  171.                         $common.removeHandlers(this._button, this._button$delegates);
  172.                     }
  173.                     this._button = value;
  174.                     if (this._button && this.get_isInitialized()) {
  175.                         $addHandlers(this._button, this._button$delegates);
  176.                     }
  177.                     this.raisePropertyChanged("button");
  178.                 }
  179.             },
  180.  
  181.             get_popupPosition: function () {
  182.                 /// <value type="Sys.Extended.UI.CalendarPosition">
  183.                 /// Where the popup should be positioned relative to the target control.
  184.                 /// Can be BottomLeft (Default), BottomRight, TopLeft, TopRight.
  185.                 /// </value>
  186.  
  187.                 return this._popupPosition;
  188.             },
  189.             set_popupPosition: function (value) {
  190.                 if (this._popupPosition != value) {
  191.                     this._popupPosition = value;
  192.                     this.raisePropertyChanged('popupPosition');
  193.                 }
  194.             },
  195.  
  196.             set_startDate: function (value) {
  197.                 /// <value type="Date">
  198.                 /// The property of the start date for range
  199.                 /// </value>
  200.                 if (this._startDate != value) {
  201.                     this._startDate = new Date(value);
  202.                     this.raisePropertyChanged('startDate');
  203.                 }
  204.             },
  205.  
  206.             get_startDate: function () {
  207.                 /// <value type="Date">
  208.                 /// The property of the start date for range
  209.                 /// </value>
  210.                 return this._startDate;
  211.             },
  212.  
  213.             set_endDate: function (value) {
  214.                 /// <value type="Date">
  215.                 /// The property of the end date for range
  216.                 /// </value>
  217.                 if (this._endDate != value) {
  218.                     this._endDate = new Date(value);
  219.                     this.raisePropertyChanged('_endDate');
  220.                 }
  221.             },
  222.  
  223.             get_endDate: function () {
  224.                 /// <value type="Date">
  225.                 /// The property of the end date for range
  226.                 /// </value>
  227.                 return this._endDate;
  228.             },
  229.  
  230.             get_format: function () {
  231.                 /// <value type="String">
  232.                 /// The format to use for the date value
  233.                 /// </value>
  234.  
  235.                 return this._format;
  236.             },
  237.             set_format: function (value) {
  238.                 if (this._format != value) {
  239.                     this._format = value;
  240.                     this.raisePropertyChanged("format");
  241.                 }
  242.             },
  243.  
  244.             get_todaysDateFormat: function () {
  245.                 /// <value type="String">
  246.                 /// The format to use for the todays date
  247.                 /// </value>
  248.  
  249.                 return this._todaysDateFormat;
  250.             },
  251.             set_todaysDateFormat: function (value) {
  252.                 if (this._todaysDateFormat != value) {
  253.                     this._todaysDateFormat = value;
  254.                     this.raisePropertyChanged("todaysDateFormat");
  255.                 }
  256.             },
  257.  
  258.             get_daysModeTitleFormat: function () {
  259.                 /// <value type="String">
  260.                 /// The format to use for the title when in days mode
  261.                 /// </value>
  262.  
  263.                 return this._daysModeTitleFormat;
  264.             },
  265.             set_daysModeTitleFormat: function (value) {
  266.                 if (this._daysModeTitleFormat != value) {
  267.                     this._daysModeTitleFormat = value;
  268.                     this.raisePropertyChanged("daysModeTitleFormat");
  269.                 }
  270.             },
  271.  
  272.             get_selectedDate: function () {
  273.                 /// <value type="Date">
  274.                 /// The date value represented by the text box
  275.                 /// </value>
  276.                 if (this._selectedDate == null) {
  277.                     var value = this._textbox.get_Value();
  278.                     if (value) {
  279.                         value = this._parseTextValue(value);
  280.                         if (value) {
  281.                             this._selectedDate = value;
  282.                         }
  283.                     }
  284.                 }
  285.                 return this._selectedDate;
  286.             },
  287.             set_selectedDate: function (value) {
  288.                 if (value && (String.isInstanceOfType(value)) && (value.length != 0)) {
  289.                     value = new Date(value);
  290.                 }
  291.  
  292.                 if (this._selectedDate != value) {
  293.                     this._selectedDate = value;
  294.                     this._selectedDateChanging = true;
  295.                     var text = "";
  296.                     if (value) {
  297.                         text = this._convertToLocal(value).localeFormat(this._format);
  298.  
  299.                         // If we don't clear the time then we transfer the time from the
  300.                         // textbox to the selected value
  301.                         if (!this._clearTime) {
  302.                             var tbvalue = this._textbox.get_Value();
  303.                             if (tbvalue) {
  304.                                 tbvalue = this._parseTextValue(tbvalue);
  305.                             }
  306.                             if (tbvalue) {
  307.                                 if (value != tbvalue.getDateOnly()) {
  308.                                     // Transfer time from textbox to selected value
  309.                                     value.setUTCHours(tbvalue.getUTCHours());
  310.                                     value.setUTCMinutes(tbvalue.getUTCMinutes());
  311.                                     value.setUTCMilliseconds(tbvalue.getUTCMilliseconds());
  312.  
  313.                                     text = this._convertToLocal(value).localeFormat(this._format);
  314.                                 }
  315.                             }
  316.                         }
  317.  
  318.                     }
  319.                     if (text != this._textbox.get_Value()) {
  320.                         this._textbox.set_Value(text);
  321.                         this._fireChanged();
  322.                     }
  323.                     this._selectedDateChanging = false;
  324.                     this.invalidate();
  325.                     this.raisePropertyChanged("selectedDate");
  326.                 }
  327.             },
  328.  
  329.             get_defaultView: function () {
  330.                 /// <value type="Sys.Extended.UI.CalendarDefaultView">
  331.                 /// The default view of the calendar when it first pops up.
  332.                 /// </value>
  333.  
  334.                 return this._defaultView;
  335.             },
  336.             set_defaultView: function (value) {
  337.                 if (this._defaultView != value) {
  338.                     this._defaultView = value;
  339.                     this.raisePropertyChanged("defaultView");
  340.                 }
  341.             },
  342.  
  343.             get_visibleDate: function () {
  344.                 /// <summary>
  345.                 /// The date currently visible in the calendar
  346.                 /// </summary>
  347.                 /// <value type="Date" />
  348.  
  349.                 return this._visibleDate;
  350.             },
  351.             set_visibleDate: function (value) {
  352.                 if (value && (String.isInstanceOfType(value)) && (value.length != 0)) {
  353.                     value = new Date(value);
  354.                 }
  355.  
  356.                 if (this._visibleDate != value) {
  357.                     this._switchMonth(value, !this._isOpen);
  358.                     this.raisePropertyChanged("visibleDate");
  359.                 }
  360.             },
  361.  
  362.             get_isOpen: function () {
  363.                 /// <value type="Boolean">
  364.                 /// Whether the calendar is open
  365.                 /// </value>
  366.                 return this._isOpen;
  367.             },
  368.  
  369.             get_todaysDate: function () {
  370.                 /// <value type="Date">
  371.                 /// The date to use for "Today"
  372.                 /// </value>
  373.                 if (this._todaysDate != null) {
  374.                     return this._todaysDate;
  375.                 }
  376.                 return new Date();
  377.             },
  378.             set_todaysDate: function (value) {
  379.                 if (this._todaysDate != value) {
  380.                     this._todaysDate = value;
  381.  
  382.                     this.invalidate();
  383.                     this.raisePropertyChanged("todaysDate");
  384.                 }
  385.             },
  386.  
  387.             get_firstDayOfWeek: function () {
  388.                 /// <value type="Sys.Extended.UI.FirstDayOfWeek">
  389.                 /// The day of the week to appear as the first day in the calendar
  390.                 /// </value>
  391.  
  392.                 return this._firstDayOfWeek;
  393.             },
  394.             set_firstDayOfWeek: function (value) {
  395.                 if (this._firstDayOfWeek != value) {
  396.                     this._firstDayOfWeek = value;
  397.                     this.invalidate();
  398.                     this.raisePropertyChanged("firstDayOfWeek");
  399.                 }
  400.             },
  401.  
  402.             get_cssClass: function () {
  403.                 /// <value type="String">
  404.                 /// The CSS class selector to use to change the calendar's appearance
  405.                 /// </value>
  406.  
  407.                 return this._cssClass;
  408.             },
  409.             set_cssClass: function (value) {
  410.                 if (this._cssClass != value) {
  411.                     if (this._cssClass && this.get_isInitialized()) {
  412.                         Sys.UI.DomElement.removeCssClass(this._container, this._cssClass);
  413.                     }
  414.                     this._cssClass = value;
  415.                     if (this._cssClass && this.get_isInitialized()) {
  416.                         Sys.UI.DomElement.addCssClass(this._container, this._cssClass);
  417.                     }
  418.                     this.raisePropertyChanged("cssClass");
  419.                 }
  420.             },
  421.  
  422.             get_todayButton: function () {
  423.                 /// <value type="Sys.UI.DomElement">
  424.                 /// The button used to select todays date
  425.                 /// </value>
  426.  
  427.                 return this._today;
  428.             },
  429.  
  430.             get_dayCell: function (row, col) {
  431.                 /// <value type="Sys.UI.DomElement">
  432.                 /// Gets the day cell at the specified row or column
  433.                 /// </value>
  434.                 if (this._daysBody) {
  435.                     return this._daysBody.rows[row].cells[col].firstChild;
  436.                 }
  437.                 return null;
  438.             },
  439.  
  440.             add_showing: function (handler) {
  441.                 /// <summary>
  442.                 /// Adds an event handler for the <code>showiwng</code> event.
  443.                 /// </summary>
  444.                 /// <param name="handler" type="Function">
  445.                 /// The handler to add to the event.
  446.                 /// </param>
  447.                 /// <returns />
  448.  
  449.                 this.get_events().addHandler("showing", handler);
  450.             },
  451.             remove_showing: function (handler) {
  452.                 /// <summary>
  453.                 /// Removes an event handler for the <code>showing</code> event.
  454.                 /// </summary>
  455.                 /// <param name="handler" type="Function">
  456.                 /// The handler to remove from the event.
  457.                 /// </param>
  458.                 /// <returns />
  459.  
  460.                 this.get_events().removeHandler("showing", handler);
  461.             },
  462.             raiseShowing: function (eventArgs) {
  463.                 /// <summary>
  464.                 /// Raise the showing event
  465.                 /// </summary>
  466.                 /// <param name="eventArgs" type="Sys.CancelEventArgs" mayBeNull="false">
  467.                 /// Event arguments for the showing event
  468.                 /// </param>
  469.                 /// <returns />
  470.  
  471.                 var handler = this.get_events().getHandler('showing');
  472.                 if (handler) {
  473.                     handler(this, eventArgs);
  474.                 }
  475.             },
  476.  
  477.             add_shown: function (handler) {
  478.                 /// <summary>
  479.                 /// Adds an event handler for the <code>shown</code> event.
  480.                 /// </summary>
  481.                 /// <param name="handler" type="Function">
  482.                 /// The handler to add to the event.
  483.                 /// </param>
  484.                 /// <returns />
  485.  
  486.                 this.get_events().addHandler("shown", handler);
  487.             },
  488.             remove_shown: function (handler) {
  489.                 /// <summary>
  490.                 /// Removes an event handler for the <code>shown</code> event.
  491.                 /// </summary>
  492.                 /// <param name="handler" type="Function">
  493.                 /// The handler to remove from the event.
  494.                 /// </param>
  495.                 /// <returns />
  496.  
  497.                 this.get_events().removeHandler("shown", handler);
  498.             },
  499.             raiseShown: function () {
  500.                 /// <summary>
  501.                 /// Raise the <code>shown</code> event
  502.                 /// </summary>
  503.                 /// <returns />
  504.  
  505.                 var handlers = this.get_events().getHandler("shown");
  506.                 if (handlers) {
  507.                     handlers(this, Sys.EventArgs.Empty);
  508.                 }
  509.             },
  510.  
  511.             add_hiding: function (handler) {
  512.                 /// <summary>
  513.                 /// Adds an event handler for the <code>hiding</code> event.
  514.                 /// </summary>
  515.                 /// <param name="handler" type="Function">
  516.                 /// The handler to add to the event.
  517.                 /// </param>
  518.                 /// <returns />
  519.  
  520.                 this.get_events().addHandler("hiding", handler);
  521.             },
  522.             remove_hiding: function (handler) {
  523.                 /// <summary>
  524.                 /// Removes an event handler for the <code>hiding</code> event.
  525.                 /// </summary>
  526.                 /// <param name="handler" type="Function">
  527.                 /// The handler to remove from the event.
  528.                 /// </param>
  529.                 /// <returns />
  530.  
  531.                 this.get_events().removeHandler("hiding", handler);
  532.             },
  533.             raiseHiding: function (eventArgs) {
  534.                 /// <summary>
  535.                 /// Raise the hiding event
  536.                 /// </summary>
  537.                 /// <param name="eventArgs" type="Sys.CancelEventArgs" mayBeNull="false">
  538.                 /// Event arguments for the hiding event
  539.                 /// </param>
  540.                 /// <returns />
  541.  
  542.                 var handler = this.get_events().getHandler('hiding');
  543.                 if (handler) {
  544.                     handler(this, eventArgs);
  545.                 }
  546.             },
  547.  
  548.             add_hidden: function (handler) {
  549.                 /// <summary>
  550.                 /// Adds an event handler for the <code>hidden</code> event.
  551.                 /// </summary>
  552.                 /// <param name="handler" type="Function">
  553.                 /// The handler to add to the event.
  554.                 /// </param>
  555.                 /// <returns />
  556.  
  557.                 this.get_events().addHandler("hidden", handler);
  558.             },
  559.             remove_hidden: function (handler) {
  560.                 /// <summary>
  561.                 /// Removes an event handler for the <code>hidden</code> event.
  562.                 /// </summary>
  563.                 /// <param name="handler" type="Function">
  564.                 /// The handler to remove from the event.
  565.                 /// </param>
  566.                 /// <returns />
  567.  
  568.                 this.get_events().removeHandler("hidden", handler);
  569.             },
  570.             raiseHidden: function () {
  571.                 /// <summary>
  572.                 /// Raise the <code>hidden</code> event
  573.                 /// </summary>
  574.                 /// <returns />
  575.  
  576.                 var handlers = this.get_events().getHandler("hidden");
  577.                 if (handlers) {
  578.                     handlers(this, Sys.EventArgs.Empty);
  579.                 }
  580.             },
  581.  
  582.             add_dateSelectionChanged: function (handler) {
  583.                 /// <summary>
  584.                 /// Adds an event handler for the <code>dateSelectionChanged</code> event.
  585.                 /// </summary>
  586.                 /// <param name="handler" type="Function">
  587.                 /// The handler to add to the event.
  588.                 /// </param>
  589.                 /// <returns />
  590.  
  591.                 this.get_events().addHandler("dateSelectionChanged", handler);
  592.             },
  593.             remove_dateSelectionChanged: function (handler) {
  594.                 /// <summary>
  595.                 /// Removes an event handler for the <code>dateSelectionChanged</code> event.
  596.                 /// </summary>
  597.                 /// <param name="handler" type="Function">
  598.                 /// The handler to remove from the event.
  599.                 /// </param>
  600.                 /// <returns />
  601.  
  602.                 this.get_events().removeHandler("dateSelectionChanged", handler);
  603.             },
  604.             raiseDateSelectionChanged: function () {
  605.                 /// <summary>
  606.                 /// Raise the <code>dateSelectionChanged</code> event
  607.                 /// </summary>
  608.                 /// <returns />
  609.  
  610.                 var handlers = this.get_events().getHandler("dateSelectionChanged");
  611.                 if (handlers) {
  612.                     handlers(this, Sys.EventArgs.Empty);
  613.                 }
  614.             },
  615.  
  616.             initialize: function () {
  617.                 /// <summary>
  618.                 /// Initializes the components and parameters for this behavior
  619.                 /// </summary>
  620.                 Sys.Extended.UI.CalendarBehavior.callBaseMethod(this, "initialize");
  621.  
  622.                 var elt = this.get_element();
  623.                 $addHandlers(elt, this._element$delegates);
  624.  
  625.                 if (this._button) {
  626.                     $addHandlers(this._button, this._button$delegates);
  627.                 }
  628.  
  629.                 this._modeChangeMoveTopOrLeftAnimation = new Sys.Extended.UI.Animation.LengthAnimation(null, null, null, "style", null, 0, 0, "px");
  630.                 this._modeChangeMoveBottomOrRightAnimation = new Sys.Extended.UI.Animation.LengthAnimation(null, null, null, "style", null, 0, 0, "px");
  631.                 this._modeChangeAnimation = new Sys.Extended.UI.Animation.ParallelAnimation(null, .25, null, [this._modeChangeMoveTopOrLeftAnimation, this._modeChangeMoveBottomOrRightAnimation]);
  632.  
  633.                 var value = this.get_selectedDate();
  634.                 if (value) {
  635.                     this._defaultSelectedDate = value;
  636.                     this.set_selectedDate(value);
  637.                 }
  638.             },
  639.             dispose: function () {
  640.                 /// <summary>
  641.                 /// Disposes this behavior's resources
  642.                 /// </summary>
  643.  
  644.                 if (this._popupBehavior) {
  645.                     this._popupBehavior.dispose();
  646.                     this._popupBehavior = null;
  647.                 }
  648.                 this._modes = null;
  649.                 this._modeOrder = null;
  650.                 if (this._modeChangeMoveTopOrLeftAnimation) {
  651.                     this._modeChangeMoveTopOrLeftAnimation.dispose();
  652.                     this._modeChangeMoveTopOrLeftAnimation = null;
  653.                 }
  654.                 if (this._modeChangeMoveBottomOrRightAnimation) {
  655.                     this._modeChangeMoveBottomOrRightAnimation.dispose();
  656.                     this._modeChangeMoveBottomOrRightAnimation = null;
  657.                 }
  658.                 if (this._modeChangeAnimation) {
  659.                     this._modeChangeAnimation.dispose();
  660.                     this._modeChangeAnimation = null;
  661.                 }
  662.                 if (this._container) {
  663.                     if (this._container.parentNode) { // added this check before calling removeChild WI: 8486
  664.                         this._container.parentNode.removeChild(this._container);
  665.                     }
  666.                     this._container = null;
  667.                 }
  668.                 if (this._popupDiv) {
  669.                     $common.removeHandlers(this._popupDiv, this._popup$delegates);
  670.                     this._popupDiv = null;
  671.                 }
  672.                 if (this._prevArrow) {
  673.                     $common.removeHandlers(this._prevArrow, this._cell$delegates);
  674.                     this._prevArrow = null;
  675.                 }
  676.                 if (this._nextArrow) {
  677.                     $common.removeHandlers(this._nextArrow, this._cell$delegates);
  678.                     this._nextArrow = null;
  679.                 }
  680.                 if (this._title) {
  681.                     $common.removeHandlers(this._title, this._cell$delegates);
  682.                     this._title = null;
  683.                 }
  684.                 if (this._today) {
  685.                     $common.removeHandlers(this._today, this._cell$delegates);
  686.                     this._today = null;
  687.                 }
  688.  
  689.                 if (this._reset) {
  690.                     $common.removeHandlers(this._reset, this._cell$delegates);
  691.                     this._reset = null;
  692.                 }
  693.  
  694.                 if (this._button) {
  695.                     $common.removeHandlers(this._button, this._button$delegates);
  696.                     this._button = null;
  697.                 }
  698.                 if (this._daysBody) {
  699.                     for (var i = 0; i < this._daysBody.rows.length; i++) {
  700.                         var row = this._daysBody.rows[i];
  701.                         for (var j = 0; j < row.cells.length; j++) {
  702.                             $common.removeHandlers(row.cells[j].firstChild, this._cell$delegates);
  703.                         }
  704.                     }
  705.                     this._daysBody = null;
  706.                 }
  707.                 if (this._monthsBody) {
  708.                     for (var i = 0; i < this._monthsBody.rows.length; i++) {
  709.                         var row = this._monthsBody.rows[i];
  710.                         for (var j = 0; j < row.cells.length; j++) {
  711.                             $common.removeHandlers(row.cells[j].firstChild, this._cell$delegates);
  712.                         }
  713.                     }
  714.                     this._monthsBody = null;
  715.                 }
  716.                 if (this._yearsBody) {
  717.                     for (var i = 0; i < this._yearsBody.rows.length; i++) {
  718.                         var row = this._yearsBody.rows[i];
  719.                         for (var j = 0; j < row.cells.length; j++) {
  720.                             $common.removeHandlers(row.cells[j].firstChild, this._cell$delegates);
  721.                         }
  722.                     }
  723.                     this._yearsBody = null;
  724.                 }
  725.                 var elt = this.get_element();
  726.                 $common.removeHandlers(elt, this._element$delegates);
  727.                 Sys.Extended.UI.CalendarBehavior.callBaseMethod(this, "dispose");
  728.             },
  729.  
  730.             show: function () {
  731.                 /// <summary>
  732.                 /// Shows the calendar
  733.                 /// </summary>
  734.  
  735.                 this._ensureCalendar();
  736.  
  737.                 if (!this._isOpen) {
  738.  
  739.                     var eventArgs = new Sys.CancelEventArgs();
  740.                     this.raiseShowing(eventArgs);
  741.                     if (eventArgs.get_cancel()) {
  742.                         return;
  743.                     }
  744.  
  745.                     this._isOpen = true;
  746.  
  747.                     this._popupBehavior.show();
  748.  
  749.                     if (this._firstPopUp) {
  750.                         this._switchMonth(null, true);
  751.                         switch (this._defaultView) {
  752.                             case Sys.Extended.UI.CalendarDefaultView.Months:
  753.                                 this._switchMode("months", true);
  754.                                 break;
  755.                             case Sys.Extended.UI.CalendarDefaultView.Years:
  756.                                 this._switchMode("years", true);
  757.                                 break;
  758.                         }
  759.                         this._firstPopUp = false;
  760.                     }
  761.  
  762.                     this.raiseShown();
  763.                 }
  764.             },
  765.             hide: function () {
  766.                 /// <summary>
  767.                 /// Hides the calendar
  768.                 /// </summary>
  769.  
  770.                 if (this._isOpen) {
  771.                     var eventArgs = new Sys.CancelEventArgs();
  772.                     this.raiseHiding(eventArgs);
  773.                     if (eventArgs.get_cancel()) {
  774.                         return;
  775.                     }
  776.  
  777.                     if (this._container) {
  778.                         this._popupBehavior.hide();
  779.                     }
  780.                     this._isOpen = false;
  781.                     this.raiseHidden();
  782.  
  783.                     // make sure we clean up the flag due to issues with alert/alt-tab/etc
  784.                     this._popupMouseDown = false;
  785.                 }
  786.             },
  787.             focus: function () {
  788.                 if (this._button) {
  789.                     this._button.focus();
  790.                 } else {
  791.                     this.get_element().focus();
  792.                 }
  793.             },
  794.             blur: function (force) {
  795.                 if (!force && Sys.Browser.agent === Sys.Browser.Opera) {
  796.                     this._blur.post(true);
  797.                 } else {
  798.                     if (!this._popupMouseDown) {
  799.                         this.hide();
  800.                     }
  801.                     // make sure we clean up the flag due to issues with alert/alt-tab/etc
  802.                     this._popupMouseDown = false;
  803.                 }
  804.             },
  805.  
  806.             suspendLayout: function () {
  807.                 /// <summary>
  808.                 /// Suspends layout of the behavior while setting properties
  809.                 /// </summary>
  810.  
  811.                 this._layoutSuspended++;
  812.             },
  813.             resumeLayout: function () {
  814.                 /// <summary>
  815.                 /// Resumes layout of the behavior and performs any pending layout requests
  816.                 /// </summary>
  817.  
  818.                 this._layoutSuspended--;
  819.                 if (this._layoutSuspended <= 0) {
  820.                     this._layoutSuspended = 0;
  821.                     if (this._layoutRequested) {
  822.                         this._performLayout();
  823.                     }
  824.                 }
  825.             },
  826.             invalidate: function () {
  827.                 /// <summary>
  828.                 /// Performs layout of the behavior unless layout is suspended
  829.                 /// </summary>
  830.  
  831.                 if (this._layoutSuspended > 0) {
  832.                     this._layoutRequested = true;
  833.                 } else {
  834.                     this._performLayout();
  835.                 }
  836.             },
  837.  
  838.             _buildCalendar: function () {
  839.                 /// <summary>
  840.                 /// Builds the calendar's layout
  841.                 /// </summary>
  842.  
  843.                 var elt = this.get_element();
  844.                 var id = this.get_id();
  845.  
  846.                 this._container = $common.createElementFromTemplate({
  847.                     nodeName: "div",
  848.                     properties: { id: id + "_container" },
  849.                     cssClasses: [this._cssClass],
  850.                     visible: false
  851.                 }, elt.parentNode);
  852.  
  853.                 this._popupDiv = $common.createElementFromTemplate({
  854.                     nodeName: "div",
  855.                     events: this._popup$delegates,
  856.                     properties: {
  857.                         id: id + "_popupDiv"
  858.                     },
  859.                     cssClasses: ["ajax__calendar_container"]
  860.                 }, this._container);
  861.             },
  862.             _buildHeader: function () {
  863.                 /// <summary>
  864.                 /// Builds the header for the calendar
  865.                 /// </summary>
  866.  
  867.                 var id = this.get_id();
  868.  
  869.                 this._header = $common.createElementFromTemplate({
  870.                     nodeName: "div",
  871.                     properties: { id: id + "_header" },
  872.                     cssClasses: ["ajax__calendar_header"]
  873.                 }, this._popupDiv);
  874.  
  875.                 var prevArrowWrapper = $common.createElementFromTemplate({ nodeName: "div" }, this._header);
  876.                 this._prevArrow = $common.createElementFromTemplate({
  877.                     nodeName: "div",
  878.                     properties: {
  879.                         id: id + "_prevArrow",
  880.                         mode: "prev"
  881.                     },
  882.                     events: this._cell$delegates,
  883.                     cssClasses: ["ajax__calendar_prev"]
  884.                 }, prevArrowWrapper);
  885.  
  886.                 var nextArrowWrapper = $common.createElementFromTemplate({ nodeName: "div" }, this._header);
  887.                 this._nextArrow = $common.createElementFromTemplate({
  888.                     nodeName: "div",
  889.                     properties: {
  890.                         id: id + "_nextArrow",
  891.                         mode: "next"
  892.                     },
  893.                     events: this._cell$delegates,
  894.                     cssClasses: ["ajax__calendar_next"]
  895.                 }, nextArrowWrapper);
  896.  
  897.                 var titleWrapper = $common.createElementFromTemplate({ nodeName: "div" }, this._header);
  898.  
  899.                 this._title = $common.createElementFromTemplate({
  900.                     nodeName: "div",
  901.                     properties: {
  902.                         id: id + "_title",
  903.                         mode: "title"
  904.                     },
  905.                     events: this._cell$delegates,
  906.                     cssClasses: ["ajax__calendar_title"]
  907.                 }, titleWrapper);
  908.             },
  909.             _buildBody: function () {
  910.                 /// <summary>
  911.                 /// Builds the body region for the calendar
  912.                 /// </summary>
  913.  
  914.                 this._body = $common.createElementFromTemplate({
  915.                     nodeName: "div",
  916.                     properties: { id: this.get_id() + "_body" },
  917.                     cssClasses: ["ajax__calendar_body"]
  918.                 }, this._popupDiv);
  919.  
  920.                 this._buildDays();
  921.                 this._buildMonths();
  922.                 this._buildYears();
  923.             },
  924.             _buildFooter: function () {
  925.                 /// <summary>
  926.                 /// Builds the footer for the calendar
  927.                 /// </summary>
  928.  
  929.                 var todayWrapper = $common.createElementFromTemplate({ nodeName: "div" }, this._popupDiv);
  930.                 this._today = $common.createElementFromTemplate({
  931.                     nodeName: "div",
  932.                     properties: {
  933.                         id: this.get_id() + "_today",
  934.                         mode: "today"
  935.                     },
  936.                     events: this._cell$delegates,
  937.                     cssClasses: ["ajax__calendar_footer", "ajax__calendar_today"]
  938.                 }, todayWrapper);
  939.  
  940.                 this._reset = $common.createElementFromTemplate({
  941.                     nodeName: "div",
  942.                     properties: {
  943.                         id: this.get_id() + "_reset",
  944.                         mode: "reset"
  945.                     },
  946.                     events: this._cell$delegates,
  947.                     cssClasses: ["ajax__calendar_footer", "ajax__calendar_today", "ajax__calendar_reset"]
  948.                 }, todayWrapper);
  949.             },
  950.             _buildDays: function () {
  951.                 /// <summary>
  952.                 /// Builds a "days of the month" view for the calendar
  953.                 /// </summary>
  954.  
  955.                 var dtf = Sys.CultureInfo.CurrentCulture.dateTimeFormat;
  956.                 var id = this.get_id();
  957.  
  958.                 this._days = $common.createElementFromTemplate({
  959.                     nodeName: "div",
  960.                     properties: { id: id + "_days" },
  961.                     cssClasses: ["ajax__calendar_days"]
  962.                 }, this._body);
  963.                 this._modes["days"] = this._days;
  964.  
  965.                 this._daysTable = $common.createElementFromTemplate({
  966.                     nodeName: "table",
  967.                     properties: {
  968.                         id: id + "_daysTable",
  969.                         cellPadding: 0,
  970.                         cellSpacing: 0,
  971.                         border: 0,
  972.                         style: { margin: "auto" }
  973.                     }
  974.                 }, this._days);
  975.  
  976.                 this._daysTableHeader = $common.createElementFromTemplate({ nodeName: "thead", properties: { id: id + "_daysTableHeader"} }, this._daysTable);
  977.                 this._daysTableHeaderRow = $common.createElementFromTemplate({ nodeName: "tr", properties: { id: id + "_daysTableHeaderRow"} }, this._daysTableHeader);
  978.                 for (var i = 0; i < 7; i++) {
  979.                     var dayCell = $common.createElementFromTemplate({ nodeName: "td" }, this._daysTableHeaderRow);
  980.                     var dayDiv = $common.createElementFromTemplate({
  981.                         nodeName: "div",
  982.                         cssClasses: ["ajax__calendar_dayname"]
  983.                     }, dayCell);
  984.                 }
  985.  
  986.                 this._daysBody = $common.createElementFromTemplate({ nodeName: "tbody", properties: { id: id + "_daysBody"} }, this._daysTable);
  987.                 for (var i = 0; i < 6; i++) {
  988.                     var daysRow = $common.createElementFromTemplate({ nodeName: "tr" }, this._daysBody);
  989.                     for (var j = 0; j < 7; j++) {
  990.                         var dayCell = $common.createElementFromTemplate({ nodeName: "td" }, daysRow);
  991.                         var dayDiv = $common.createElementFromTemplate({
  992.                             nodeName: "div",
  993.                             properties: {
  994.                                 mode: "day",
  995.                                 id: id + "_day_" + i + "_" + j,
  996.                                 innerHTML: "&nbsp;"
  997.                             },
  998.                             events: this._cell$delegates,
  999.                             cssClasses: ["ajax__calendar_day"]
  1000.                         }, dayCell);
  1001.                     }
  1002.                 }
  1003.             },
  1004.             _buildMonths: function () {
  1005.                 /// <summary>
  1006.                 /// Builds a "months of the year" view for the calendar
  1007.                 /// </summary>
  1008.  
  1009.                 var dtf = Sys.CultureInfo.CurrentCulture.dateTimeFormat;
  1010.                 var id = this.get_id();
  1011.  
  1012.                 this._months = $common.createElementFromTemplate({
  1013.                     nodeName: "div",
  1014.                     properties: { id: id + "_months" },
  1015.                     cssClasses: ["ajax__calendar_months"],
  1016.                     visible: false
  1017.                 }, this._body);
  1018.                 this._modes["months"] = this._months;
  1019.  
  1020.                 this._monthsTable = $common.createElementFromTemplate({
  1021.                     nodeName: "table",
  1022.                     properties: {
  1023.                         id: id + "_monthsTable",
  1024.                         cellPadding: 0,
  1025.                         cellSpacing: 0,
  1026.                         border: 0,
  1027.                         style: { margin: "auto" }
  1028.                     }
  1029.                 }, this._months);
  1030.  
  1031.                 this._monthsBody = $common.createElementFromTemplate({ nodeName: "tbody", properties: { id: id + "_monthsBody"} }, this._monthsTable);
  1032.                 for (var i = 0; i < 3; i++) {
  1033.                     var monthsRow = $common.createElementFromTemplate({ nodeName: "tr" }, this._monthsBody);
  1034.                     for (var j = 0; j < 4; j++) {
  1035.                         var monthCell = $common.createElementFromTemplate({ nodeName: "td" }, monthsRow);
  1036.                         var monthDiv = $common.createElementFromTemplate({
  1037.                             nodeName: "div",
  1038.                             properties: {
  1039.                                 id: id + "_month_" + i + "_" + j,
  1040.                                 mode: "month",
  1041.                                 month: (i * 4) + j,
  1042.                                 innerHTML: "<br />" + dtf.AbbreviatedMonthNames[(i * 4) + j]
  1043.                             },
  1044.                             events: this._cell$delegates,
  1045.                             cssClasses: ["ajax__calendar_month"]
  1046.                         }, monthCell);
  1047.                     }
  1048.                 }
  1049.             },
  1050.             _buildYears: function () {
  1051.                 /// <summary>
  1052.                 /// Builds a "years in this decade" view for the calendar
  1053.                 /// </summary>
  1054.  
  1055.                 var id = this.get_id();
  1056.  
  1057.                 this._years = $common.createElementFromTemplate({
  1058.                     nodeName: "div",
  1059.                     properties: { id: id + "_years" },
  1060.                     cssClasses: ["ajax__calendar_years"],
  1061.                     visible: false
  1062.                 }, this._body);
  1063.                 this._modes["years"] = this._years;
  1064.  
  1065.                 this._yearsTable = $common.createElementFromTemplate({
  1066.                     nodeName: "table",
  1067.                     properties: {
  1068.                         id: id + "_yearsTable",
  1069.                         cellPadding: 0,
  1070.                         cellSpacing: 0,
  1071.                         border: 0,
  1072.                         style: { margin: "auto" }
  1073.                     }
  1074.                 }, this._years);
  1075.  
  1076.                 this._yearsBody = $common.createElementFromTemplate({ nodeName: "tbody", properties: { id: id + "_yearsBody"} }, this._yearsTable);
  1077.                 for (var i = 0; i < 3; i++) {
  1078.                     var yearsRow = $common.createElementFromTemplate({ nodeName: "tr" }, this._yearsBody);
  1079.                     for (var j = 0; j < 4; j++) {
  1080.                         var yearCell = $common.createElementFromTemplate({ nodeName: "td" }, yearsRow);
  1081.                         var yearDiv = $common.createElementFromTemplate({
  1082.                             nodeName: "div",
  1083.                             properties: {
  1084.                                 id: id + "_year_" + i + "_" + j,
  1085.                                 mode: "year",
  1086.                                 year: ((i * 4) + j) - 1
  1087.                             },
  1088.                             events: this._cell$delegates,
  1089.                             cssClasses: ["ajax__calendar_year"]
  1090.                         }, yearCell);
  1091.                     }
  1092.                 }
  1093.             },
  1094.  
  1095.  
  1096.             _isInDateRange: function (date, part) {
  1097.                 switch (part) {
  1098.                     case "d":
  1099.                         if ((this._startDate) && (this._getDateOnly(date) < this._getDateOnly(this._startDate))) { return false; }
  1100.                         if ((this._endDate) && (this._getDateOnly(date) > this._getDateOnly(this._endDate))) { return false; }
  1101.                         break;
  1102.                     case "M":
  1103.                         if ((this._startDate) && (this._getMonthOnly(date) < this._getMonthOnly(this._startDate))) { return false; }
  1104.                         if ((this._endDate) && (this._getMonthOnly(date) > this._getMonthOnly(this._endDate))) { return false; }
  1105.                         break;
  1106.                     case "y":
  1107.                         if ((this._startDate) && (date.getUTCFullYear() < this._startDate.getUTCFullYear())) { return false; }
  1108.                         if ((this._endDate) && (date.getUTCFullYear() > this._endDate.getUTCFullYear())) { return false; }
  1109.                         break;
  1110.                 }
  1111.                 return true;
  1112.             },
  1113.  
  1114.  
  1115.             _getDateOnly: function (date) {
  1116.                 return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()));
  1117.             },
  1118.  
  1119.  
  1120.             _getMonthOnly: function (date) {
  1121.                 return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), 1));
  1122.             },
  1123.  
  1124.  
  1125.  
  1126.             _convertToUTC: function (value) {
  1127.                 /// <summary>Converts a local date such as 1/1/2007 into 1/1/2007 GMT
  1128.                 /// without adjusting for time zone</summary>
  1129.                 if (value) {
  1130.                     value = new Date(Date.UTC(value.getFullYear(), value.getMonth(), value.getDate(), value.getHours(), value.getMinutes(), value.getSeconds(), value.getMilliseconds()));
  1131.                 }
  1132.                 return value;
  1133.             },
  1134.  
  1135.  
  1136.             _convertToLocal: function (value) {
  1137.                 /// <summary>Converts a UTC date such as 1/1/2007 GMT into 1/1/2007 without adjusting for time zone</summary>
  1138.                 /// <param name="value" type="Date">The date to convert</param>
  1139.  
  1140.                 var result = new Date(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate(), value.getUTCHours(), value.getUTCMinutes(), value.getUTCSeconds(), value.getUTCMilliseconds());
  1141.  
  1142.                 // Handle daylight savings time offset (The first hour of September 25 becomes the last hour of September 24 when DST starts)
  1143.                 if (result.getDate() != value.getUTCDate()) {
  1144.                     result = new Date(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate(), value.getUTCHours() + 1, value.getUTCMinutes(), value.getUTCSeconds(), value.getUTCMilliseconds());
  1145.                 }
  1146.                 return result;
  1147.             },
  1148.  
  1149.  
  1150.  
  1151.  
  1152.             _performLayout: function () {
  1153.                 /// <summmary>
  1154.                 /// Updates the various views of the calendar to match the current selected and visible dates
  1155.                 /// </summary>
  1156.  
  1157.                 var elt = this.get_element();
  1158.                 if (!elt) return;
  1159.                 if (!this.get_isInitialized()) return;
  1160.                 if (!this._isOpen) return;
  1161.  
  1162.                 var dtf = Sys.CultureInfo.CurrentCulture.dateTimeFormat;
  1163.                 var selectedDate = this.get_selectedDate();
  1164.                 var visibleDate = this._getEffectiveVisibleDate();
  1165.                 var todaysDate = this.get_todaysDate();
  1166.                 switch (this._mode) {
  1167.                     case "days":
  1168.  
  1169.                         var firstDayOfWeek = this._getFirstDayOfWeek();
  1170.                         var daysToBacktrack = visibleDate.getUTCDay() - firstDayOfWeek;
  1171.                         if (daysToBacktrack <= 0)
  1172.                             daysToBacktrack += 7;
  1173.  
  1174.                         var startDate = new Date(visibleDate);
  1175.                         startDate.setUTCDate(startDate.getUTCDate() - daysToBacktrack);
  1176.                         var currentDate = new Date(startDate);
  1177.  
  1178.                         for (var i = 0; i < 7; i++) {
  1179.                             var dayCell = this._daysTableHeaderRow.cells[i].firstChild;
  1180.                             if (dayCell.firstChild) {
  1181.                                 dayCell.removeChild(dayCell.firstChild);
  1182.                             }
  1183.                             dayCell.appendChild(document.createTextNode(dtf.ShortestDayNames[(i + firstDayOfWeek) % 7]));
  1184.                         }
  1185.                         for (var week = 0; week < 6; week++) {
  1186.                             var weekRow = this._daysBody.rows[week];
  1187.                             for (var dayOfWeek = 0; dayOfWeek < 7; dayOfWeek++) {
  1188.                                 var dayCell = weekRow.cells[dayOfWeek].firstChild;
  1189.                                 if (dayCell.firstChild) {
  1190.                                     dayCell.removeChild(dayCell.firstChild);
  1191.                                 }
  1192.                                 dayCell.appendChild(document.createTextNode(currentDate.getUTCDate()));
  1193.                                 dayCell.title = this._convertToLocal(currentDate).localeFormat("D");
  1194.                                 dayCell.date = currentDate;
  1195.                                 $common.removeCssClasses(dayCell.parentNode, ["ajax__calendar_other", "ajax__calendar_active", "ajax__calendar_today"]);
  1196.  
  1197.                                 if (!this._isInDateRange(currentDate, "d")) {
  1198.                                     $common.removeCssClasses(dayCell.parentNode, ["ajax__calendar_other", "ajax__calendar_active"]);
  1199.                                     Sys.UI.DomElement.addCssClass(dayCell.parentNode, "ajax__calendar_invalid");
  1200.                                 } else {
  1201.                                     $common.removeCssClasses(dayCell.parentNode, ["ajax__calendar_invalid", "ajax__calendar_other", "ajax__calendar_active", ""]);
  1202.                                     Sys.UI.DomElement.addCssClass(dayCell.parentNode, this._getCssClass(dayCell.date, 'd'));
  1203.                                 }
  1204.  
  1205.                                 currentDate = new Date(currentDate);
  1206.                                 currentDate.setUTCDate(currentDate.getUTCDate() + 1);
  1207.                             }
  1208.                         }
  1209.  
  1210.                         this._prevArrow.date = new Date(Date.UTC(visibleDate.getUTCFullYear(), visibleDate.getUTCMonth() - 1, 1));
  1211.                         this._nextArrow.date = new Date(Date.UTC(visibleDate.getUTCFullYear(), visibleDate.getUTCMonth() + 1, 1));
  1212.                         if (this._title.firstChild) {
  1213.                             this._title.removeChild(this._title.firstChild);
  1214.                         }
  1215.  
  1216.                         this._title.appendChild(document.createTextNode(this._convertToLocal(visibleDate).localeFormat(this.get_daysModeTitleFormat())));
  1217.                         this._title.date = visibleDate;
  1218.  
  1219.                         break;
  1220.                     case "months":
  1221.                         for (var i = 0; i < this._monthsBody.rows.length; i++) {
  1222.                             var row = this._monthsBody.rows[i];
  1223.                             for (var j = 0; j < row.cells.length; j++) {
  1224.                                 var cell = row.cells[j].firstChild;
  1225.                                 cell.date = new Date(Date.UTC(visibleDate.getUTCFullYear(), cell.month, 1));
  1226.                                 cell.title = this._convertToLocal(cell.date).localeFormat("Y");
  1227.  
  1228.                                 if (!this._isInDateRange(cell.date, "M")) {
  1229.                                     $common.removeCssClasses(cell.parentNode, ["ajax__calendar_other", "ajax__calendar_active"]);
  1230.                                     Sys.UI.DomElement.addCssClass(cell.parentNode, "ajax__calendar_invalid");
  1231.                                 }
  1232.                                 else {
  1233.  
  1234.                                     $common.removeCssClasses(cell.parentNode, ["ajax__calendar_invalid", "ajax__calendar_other", "ajax__calendar_active"]);
  1235.                                     Sys.UI.DomElement.addCssClass(cell.parentNode, this._getCssClass(cell.date, 'M'));
  1236.                                 }
  1237.                             }
  1238.                         }
  1239.  
  1240.                         if (this._title.firstChild) {
  1241.                             this._title.removeChild(this._title.firstChild);
  1242.                         }
  1243.  
  1244.                         this._title.appendChild(document.createTextNode(this._convertToLocal(visibleDate).localeFormat("yyyy")));
  1245.                         this._title.date = visibleDate;
  1246.                         this._prevArrow.date = new Date(Date.UTC(visibleDate.getUTCFullYear() - 1, 0, 1));
  1247.                         this._nextArrow.date = new Date(Date.UTC(visibleDate.getUTCFullYear() + 1, 0, 1));
  1248.  
  1249.                         break;
  1250.                     case "years":
  1251.  
  1252.                         var minYear = (Math.floor(visibleDate.getUTCFullYear() / 10) * 10);
  1253.                         for (var i = 0; i < this._yearsBody.rows.length; i++) {
  1254.                             var row = this._yearsBody.rows[i];
  1255.                             for (var j = 0; j < row.cells.length; j++) {
  1256.                                 var cell = row.cells[j].firstChild;
  1257.                                 cell.date = new Date(Date.UTC(minYear + cell.year, 0, 1));
  1258.                                 if (cell.firstChild) {
  1259.                                     cell.removeChild(cell.lastChild);
  1260.                                 } else {
  1261.                                     cell.appendChild(document.createElement("br"));
  1262.                                 }
  1263.                                 cell.appendChild(document.createTextNode(minYear + cell.year));
  1264.  
  1265.                                 if (!this._isInDateRange(cell.date, "y")) {
  1266.                                     $common.removeCssClasses(cell.parentNode, ["ajax__calendar_other", "ajax__calendar_active"]);
  1267.                                     Sys.UI.DomElement.addCssClass(cell.parentNode, "ajax__calendar_invalid");
  1268.                                 }
  1269.                                 else {
  1270.                                     $common.removeCssClasses(cell.parentNode, ["ajax__calendar_invalid", "ajax__calendar_other", "ajax__calendar_active"]);
  1271.                                     Sys.UI.DomElement.addCssClass(cell.parentNode, this._getCssClass(cell.date, 'y'));
  1272.                                 }
  1273.                             }
  1274.                         }
  1275.  
  1276.                         if (this._title.firstChild) {
  1277.                             this._title.removeChild(this._title.firstChild);
  1278.                         }
  1279.  
  1280.                         this._title.appendChild(document.createTextNode(minYear.toString() + "-" + (minYear + 9).toString()));
  1281.                         this._title.date = visibleDate;
  1282.                         this._prevArrow.date = new Date(Date.UTC(minYear - 10, 0, 1));
  1283.                         this._nextArrow.date = new Date(Date.UTC(minYear + 10, 0, 1));
  1284.  
  1285.                         break;
  1286.                 }
  1287.                 if (this._today.firstChild) {
  1288.                     this._today.removeChild(this._today.firstChild);
  1289.                 }
  1290.  
  1291.                 $common.removeCssClasses(this._today.parentNode, ["ajax__calendar_invalid"]);
  1292.                 this._today.appendChild(document.createTextNode(String.format(Sys.Extended.UI.Resources.Calendar_Today, todaysDate.localeFormat(this.get_todaysDateFormat()))));
  1293.                 if (!this._isInDateRange(todaysDate, "d")) {
  1294.                     Sys.UI.DomElement.addCssClass(this._today.parentNode, "ajax__calendar_invalid");
  1295.                 }
  1296.  
  1297.                 this._today.date = this._convertToUTC(todaysDate);
  1298.  
  1299.                 if (this._reset.firstChild) {
  1300.                     this._reset.removeChild(this._reset.firstChild);
  1301.                 }
  1302.                 this._reset.appendChild(document.createTextNode("Reset"));
  1303.  
  1304.                 this._reset.date = this._defaultSelectedDate;
  1305.             },
  1306.  
  1307.             _ensureCalendar: function () {
  1308.  
  1309.                 if (!this._container) {
  1310.  
  1311.                     var elt = this.get_element();
  1312.  
  1313.                     this._buildCalendar();
  1314.                     this._buildHeader();
  1315.                     this._buildBody();
  1316.                     this._buildFooter();
  1317.  
  1318.                     this._popupBehavior = new $create(Sys.Extended.UI.PopupBehavior, { parentElement: elt }, {}, {}, this._container);
  1319.                     if (this._popupPosition == Sys.Extended.UI.CalendarPosition.TopLeft) {
  1320.                         this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.TopLeft);
  1321.                     } else if (this._popupPosition == Sys.Extended.UI.CalendarPosition.TopRight) {
  1322.                         this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.TopRight);
  1323.                     } else if (this._popupPosition == Sys.Extended.UI.CalendarPosition.BottomRight) {
  1324.                         this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.BottomRight);
  1325.                     } else if (this._popupPosition == Sys.Extended.UI.CalendarPosition.Right) {
  1326.                         this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.Right);
  1327.                     } else if (this._popupPosition == Sys.Extended.UI.CalendarPosition.Left) {
  1328.                         this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.Left);
  1329.                     } else {
  1330.                         this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.BottomLeft);
  1331.                     }
  1332.                 }
  1333.             },
  1334.  
  1335.             _fireChanged: function () {
  1336.                 /// <summary>
  1337.                 /// Attempts to fire the change event on the attached textbox
  1338.                 /// </summary>
  1339.  
  1340.                 var elt = this.get_element();
  1341.                 if (document.createEventObject) {
  1342.                     elt.fireEvent("onchange");
  1343.                 } else if (document.createEvent) {
  1344.                     var e = document.createEvent("HTMLEvents");
  1345.                     e.initEvent("change", true, true);
  1346.                     elt.dispatchEvent(e);
  1347.                 }
  1348.             },
  1349.             _switchMonth: function (date, dontAnimate) {
  1350.                 /// <summary>
  1351.                 /// Switches the visible month in the days view
  1352.                 /// </summary>
  1353.                 /// <param name="date" type="Date">The visible date to switch to</param>
  1354.                 /// <param name="dontAnimate" type="Boolean">Prevents animation from occuring if the control is animated</param>
  1355.  
  1356.                 // Check _isAnimating to make sure we don't animate horizontally and vertically at the same time
  1357.                 if (this._isAnimating) {
  1358.                     return;
  1359.                 }
  1360.  
  1361.  
  1362.                 // Check if can switch month depending on the startDate and endDAte
  1363.                 if (date && !this._canSwitchMonth(date)) {
  1364.                     return;
  1365.                 }
  1366.  
  1367.                 var visibleDate = this._getEffectiveVisibleDate();
  1368.                 if ((date && date.getFullYear() == visibleDate.getFullYear() && date.getMonth() == visibleDate.getMonth())) {
  1369.                     dontAnimate = true;
  1370.                 }
  1371.  
  1372.                 if (this._animated && !dontAnimate) {
  1373.                     this._isAnimating = true;
  1374.  
  1375.                     var newElement = this._modes[this._mode];
  1376.                     var oldElement = newElement.cloneNode(true);
  1377.                     this._body.appendChild(oldElement);
  1378.                     if (visibleDate > date) {
  1379.  
  1380.                         // animating down
  1381.                         // the newIndex element is the top
  1382.                         // the oldIndex element is the bottom (visible)
  1383.  
  1384.                         // move in, fade in
  1385.                         $common.setLocation(newElement, { x: -162, y: 0 });
  1386.                         $common.setVisible(newElement, true);
  1387.                         this._modeChangeMoveTopOrLeftAnimation.set_propertyKey("left");
  1388.                         this._modeChangeMoveTopOrLeftAnimation.set_target(newElement);
  1389.                         this._modeChangeMoveTopOrLeftAnimation.set_startValue(-this._width);
  1390.                         this._modeChangeMoveTopOrLeftAnimation.set_endValue(0);
  1391.  
  1392.                         // move out, fade out
  1393.                         $common.setLocation(oldElement, { x: 0, y: 0 });
  1394.                         $common.setVisible(oldElement, true);
  1395.                         this._modeChangeMoveBottomOrRightAnimation.set_propertyKey("left");
  1396.                         this._modeChangeMoveBottomOrRightAnimation.set_target(oldElement);
  1397.                         this._modeChangeMoveBottomOrRightAnimation.set_startValue(0);
  1398.                         this._modeChangeMoveBottomOrRightAnimation.set_endValue(this._width);
  1399.  
  1400.                     } else {
  1401.                         // animating up
  1402.                         // the oldIndex element is the top (visible)
  1403.                         // the newIndex element is the bottom
  1404.  
  1405.                         // move out, fade out
  1406.                         $common.setLocation(oldElement, { x: 0, y: 0 });
  1407.                         $common.setVisible(oldElement, true);
  1408.                         this._modeChangeMoveTopOrLeftAnimation.set_propertyKey("left");
  1409.                         this._modeChangeMoveTopOrLeftAnimation.set_target(oldElement);
  1410.                         this._modeChangeMoveTopOrLeftAnimation.set_endValue(-this._width);
  1411.                         this._modeChangeMoveTopOrLeftAnimation.set_startValue(0);
  1412.  
  1413.                         // move in, fade in
  1414.                         $common.setLocation(newElement, { x: 162, y: 0 });
  1415.                         $common.setVisible(newElement, true);
  1416.                         this._modeChangeMoveBottomOrRightAnimation.set_propertyKey("left");
  1417.                         this._modeChangeMoveBottomOrRightAnimation.set_target(newElement);
  1418.                         this._modeChangeMoveBottomOrRightAnimation.set_endValue(0);
  1419.                         this._modeChangeMoveBottomOrRightAnimation.set_startValue(this._width);
  1420.                     }
  1421.                     this._visibleDate = date;
  1422.                     this.invalidate();
  1423.  
  1424.                     var endHandler = Function.createDelegate(this, function () {
  1425.                         this._body.removeChild(oldElement);
  1426.                         oldElement = null;
  1427.                         this._isAnimating = false;
  1428.                         this._modeChangeAnimation.remove_ended(endHandler);
  1429.                     });
  1430.                     this._modeChangeAnimation.add_ended(endHandler);
  1431.                     this._modeChangeAnimation.play();
  1432.                 } else {
  1433.                     this._visibleDate = date;
  1434.                     this.invalidate();
  1435.                 }
  1436.             },
  1437.  
  1438.             _canSwitchMonth: function (date) {
  1439.                 switch (this._mode) {
  1440.                     case "days":
  1441.                         if (!this._isInDateRange(date, "M")) {
  1442.                             return false;
  1443.                         }
  1444.                         break;
  1445.                     case "months":
  1446.                         if (!this._isInDateRange(date, "y")) {
  1447.                             return false;
  1448.                         }
  1449.                         break;
  1450.                     case "years":
  1451.                         if (!this._isInDateRange(date, "y")) {
  1452.                             return false;
  1453.                         }
  1454.                         break;
  1455.                 }
  1456.                 return true;
  1457.             },
  1458.  
  1459.             _switchMode: function (mode, dontAnimate) {
  1460.                 /// <summary>
  1461.                 /// Switches the visible view from "days" to "months" to "years"
  1462.                 /// </summary>
  1463.                 /// <param name="mode" type="String">The view mode to switch to</param>
  1464.                 /// <param name="dontAnimate" type="Boolean">Prevents animation from occuring if the control is animated</param>
  1465.  
  1466.                 // Check _isAnimating to make sure we don't animate horizontally and vertically at the same time
  1467.                 if (this._isAnimating || (this._mode == mode)) {
  1468.                     return;
  1469.                 }
  1470.  
  1471.                 var moveDown = this._modeOrder[this._mode] < this._modeOrder[mode];
  1472.                 var oldElement = this._modes[this._mode];
  1473.                 var newElement = this._modes[mode];
  1474.                 this._mode = mode;
  1475.  
  1476.                 if (this._animated && !dontAnimate) {
  1477.                     this._isAnimating = true;
  1478.  
  1479.                     this.invalidate();
  1480.  
  1481.                     if (moveDown) {
  1482.                         // animating down
  1483.                         // the newIndex element is the top
  1484.                         // the oldIndex element is the bottom (visible)
  1485.  
  1486.                         // move in, fade in
  1487.                         $common.setLocation(newElement, { x: 0, y: -this._height });
  1488.                         $common.setVisible(newElement, true);
  1489.                         this._modeChangeMoveTopOrLeftAnimation.set_propertyKey("top");
  1490.                         this._modeChangeMoveTopOrLeftAnimation.set_target(newElement);
  1491.                         this._modeChangeMoveTopOrLeftAnimation.set_startValue(-this._height);
  1492.                         this._modeChangeMoveTopOrLeftAnimation.set_endValue(0);
  1493.  
  1494.                         // move out, fade out
  1495.                         $common.setLocation(oldElement, { x: 0, y: 0 });
  1496.                         $common.setVisible(oldElement, true);
  1497.  
  1498.                         this._modeChangeMoveBottomOrRightAnimation.set_propertyKey("top");
  1499.                         this._modeChangeMoveBottomOrRightAnimation.set_target(oldElement);
  1500.                         this._modeChangeMoveBottomOrRightAnimation.set_startValue(0);
  1501.                         this._modeChangeMoveBottomOrRightAnimation.set_endValue(this._height);
  1502.  
  1503.                     } else {
  1504.                         // animating up
  1505.                         // the oldIndex element is the top (visible)
  1506.                         // the newIndex element is the bottom
  1507.  
  1508.                         // move out, fade out
  1509.                         $common.setLocation(oldElement, { x: 0, y: 0 });
  1510.                         $common.setVisible(oldElement, true);
  1511.                         this._modeChangeMoveTopOrLeftAnimation.set_propertyKey("top");
  1512.                         this._modeChangeMoveTopOrLeftAnimation.set_target(oldElement);
  1513.                         this._modeChangeMoveTopOrLeftAnimation.set_endValue(-this._height);
  1514.                         this._modeChangeMoveTopOrLeftAnimation.set_startValue(0);
  1515.  
  1516.                         // move in, fade in
  1517.                         $common.setLocation(newElement, { x: 0, y: 139 });
  1518.                         $common.setVisible(newElement, true);
  1519.                         this._modeChangeMoveBottomOrRightAnimation.set_propertyKey("top");
  1520.                         this._modeChangeMoveBottomOrRightAnimation.set_target(newElement);
  1521.                         this._modeChangeMoveBottomOrRightAnimation.set_endValue(0);
  1522.                         this._modeChangeMoveBottomOrRightAnimation.set_startValue(this._height);
  1523.                     }
  1524.                     var endHandler = Function.createDelegate(this, function () {
  1525.                         this._isAnimating = false;
  1526.                         this._modeChangeAnimation.remove_ended(endHandler);
  1527.                     });
  1528.                     this._modeChangeAnimation.add_ended(endHandler);
  1529.                     this._modeChangeAnimation.play();
  1530.                 } else {
  1531.                     this._mode = mode;
  1532.                     $common.setVisible(oldElement, false);
  1533.                     this.invalidate();
  1534.                     $common.setVisible(newElement, true);
  1535.                     $common.setLocation(newElement, { x: 0, y: 0 });
  1536.                 }
  1537.             },
  1538.             _isSelected: function (date, part) {
  1539.                 /// <summary>
  1540.                 /// Gets whether the supplied date is the currently selected date
  1541.                 /// </summary>
  1542.                 /// <param name="date" type="Date">The date to match</param>
  1543.                 /// <param name="part" type="String">The most significant part of the date to test</param>
  1544.                 /// <returns type="Boolean" />
  1545.  
  1546.                 var value = this.get_selectedDate();
  1547.                 if (!value) return false;
  1548.                 switch (part) {
  1549.                     case 'd':
  1550.                         if (date.getUTCDate() != value.getUTCDate()) return false;
  1551.                         // goto case 'M';
  1552.                     case 'M':
  1553.                         if (date.getUTCMonth() != value.getUTCMonth()) return false;
  1554.                         // goto case 'y';
  1555.                     case 'y':
  1556.                         if (date.getUTCFullYear() != value.getUTCFullYear()) return false;
  1557.                         break;
  1558.                 }
  1559.                 return true;
  1560.             },
  1561.  
  1562.  
  1563.  
  1564.  
  1565.             _isOther: function (date, part) {
  1566.                 /// <summary>
  1567.                 /// Gets whether the supplied date is in a different view from the current visible month
  1568.                 /// </summary>
  1569.                 /// <param name="date" type="Date">The date to match</param>
  1570.                 /// <param name="part" type="String">The most significant part of the date to test</param>
  1571.                 /// <returns type="Boolean" />
  1572.  
  1573.                 var value = this._getEffectiveVisibleDate();
  1574.                 switch (part) {
  1575.                     case 'd':
  1576.                         return (date.getUTCFullYear() != value.getUTCFullYear() || date.getUTCMonth() != value.getUTCMonth());
  1577.                     case 'M':
  1578.                         return false;
  1579.                     case 'y':
  1580.                         var minYear = (Math.floor(value.getUTCFullYear() / 10) * 10);
  1581.                         return date.getUTCFullYear() < minYear || (minYear + 10) <= date.getUTCFullYear();
  1582.                 }
  1583.                 return false;
  1584.             },
  1585.  
  1586.             _isTodaysDate: function (date) {
  1587.                 return this._getDateOnly(this._convertToUTC(this.get_todaysDate())).valueOf() === this._getDateOnly(date).valueOf();
  1588.             },
  1589.  
  1590.             _getCssClass: function (date, part) {
  1591.                 /// <summary>
  1592.                 /// Gets the cssClass to apply to a cell based on a supplied date
  1593.                 /// </summary>
  1594.                 /// <param name="date" type="Date">The date to match</param>
  1595.                 /// <param name="part" type="String">The most significant part of the date to test</param>
  1596.                 /// <returns type="String" />
  1597.  
  1598.                 if (this._isSelected(date, part)) {
  1599.                     return "ajax__calendar_active";
  1600.                 } else if (this._isOther(date, part)) {
  1601.                     return "ajax__calendar_other";
  1602.                     // Highlight today's date
  1603.                 } else if (this._isTodaysDate(date)) {
  1604.                     return "ajax__calendar_today";
  1605.                 } else {
  1606.                     return "";
  1607.                 }
  1608.             },
  1609.             _getEffectiveVisibleDate: function () {
  1610.                 var value = this.get_visibleDate();
  1611.                 if (value == null)
  1612.                     value = this.get_selectedDate();
  1613.                 if (value == null)
  1614.                     value = this.get_todaysDate();
  1615.  
  1616.                 value = new Date(value);
  1617.                 value.setUTCDate(1);
  1618.  
  1619.                 return this._getDateOnly(value);
  1620.             },
  1621.  
  1622.  
  1623.             _getFirstDayOfWeek: function () {
  1624.                 /// <summary>
  1625.                 /// Gets the first day of the week
  1626.                 /// </summary>
  1627.  
  1628.                 if (this.get_firstDayOfWeek() != Sys.Extended.UI.FirstDayOfWeek.Default) {
  1629.                     return this.get_firstDayOfWeek();
  1630.                 }
  1631.                 return Sys.CultureInfo.CurrentCulture.dateTimeFormat.FirstDayOfWeek;
  1632.             },
  1633.             _parseTextValue: function (text) {
  1634.                 /// <summary>
  1635.                 /// Converts a text value from the textbox into a date
  1636.                 /// </summary>
  1637.                 /// <param name="text" type="String" mayBeNull="true">The text value to parse</param>
  1638.                 /// <returns type="Date" />
  1639.  
  1640.                 var value = null;
  1641.                 if (text) {
  1642.                     value = this._convertToUTC(Date.parseLocale(text, this.get_format()));
  1643.                 }
  1644.                 if (isNaN(value)) {
  1645.                     value = null;
  1646.                 }
  1647.                 return value;
  1648.             },
  1649.  
  1650.             _element_onfocus: function (e) {
  1651.                 /// <summary>
  1652.                 /// Handles the focus event of the element
  1653.                 /// </summary>
  1654.                 /// <param name="e" type="Sys.UI.DomEvent">The arguments for the event</param>
  1655.                 if (!this._enabled) return;
  1656.                 if (!this._button) {
  1657.                     this.show();
  1658.                     // make sure we clean up the flag due to issues with alert/alt-tab/etc
  1659.                     this._popupMouseDown = false;
  1660.                 }
  1661.             },
  1662.             _element_onblur: function (e) {
  1663.                 /// <summary>
  1664.                 /// Handles the blur event of the element
  1665.                 /// </summary>
  1666.                 /// <param name="e" type="Sys.UI.DomEvent">The arguments for the event</param>        
  1667.                 if (!this._enabled) return;
  1668.                 if (!this._button) {
  1669.                     this.blur();
  1670.                 }
  1671.             },
  1672.             _element_onchange: function (e) {
  1673.                 /// <summary>
  1674.                 /// Handles the change event of the element
  1675.                 /// </summary>
  1676.                 /// <param name="e" type="Sys.UI.DomEvent">The arguments for the event</param>
  1677.                 if (!this._selectedDateChanging) {
  1678.                     var value = this._parseTextValue(this._textbox.get_Value());
  1679.                     this._selectedDate = value;
  1680.                     if (this._isOpen) {
  1681.                         this._switchMonth(this._selectedDate, this._selectedDate == null);
  1682.                     }
  1683.                 }
  1684.             },
  1685.             _element_onkeypress: function (e) {
  1686.                 /// <summary>
  1687.                 /// Handles the keypress event of the element
  1688.                 /// </summary>
  1689.                 /// <param name="e" type="Sys.UI.DomEvent">The arguments for the event</param>
  1690.                 if (!this._enabled) return;
  1691.                 if (!this._button && e.charCode == Sys.UI.Key.esc) {
  1692.                     e.stopPropagation();
  1693.                     e.preventDefault();
  1694.                     this.hide();
  1695.                 }
  1696.             },
  1697.             _element_onclick: function (e) {
  1698.                 /// <summary>
  1699.                 /// Handles the click event of the element
  1700.                 /// </summary>
  1701.                 /// <param name="e" type="Sys.UI.DomEvent">The arguments for the event</param>
  1702.                 if (!this._enabled) return;
  1703.                 if (!this._button) {
  1704.                     this.show();
  1705.                     // make sure we clean up the flag due to issues with alert/alt-tab/etc
  1706.                     this._popupMouseDown = false;
  1707.                 }
  1708.             },
  1709.  
  1710.             _popup_onevent: function (e) {
  1711.                 /// <summary>
  1712.                 /// Handles the drag-start event of the popup calendar
  1713.                 /// </summary>
  1714.                 /// <param name="e" type="Sys.UI.DomEvent">The arguments for the event</param>
  1715.                 e.stopPropagation();
  1716.                 e.preventDefault();
  1717.             },
  1718.             _popup_onmousedown: function (e) {
  1719.                 /// <summary>
  1720.                 /// Handles the mousedown event of the popup
  1721.                 /// </summary>
  1722.                 /// <param name="e" type="Sys.UI.DomEvent">The arguments for the event</param>
  1723.  
  1724.                 // signal that the popup has received a mousedown event, this handles
  1725.                 // onblur issues on browsers like FF, OP, and SF
  1726.                 this._popupMouseDown = true;
  1727.             },
  1728.             _popup_onmouseup: function (e) {
  1729.                 /// <summary>
  1730.                 /// Handles the mouseup event of the popup
  1731.                 /// </summary>
  1732.                 /// <param name="e" type="Sys.UI.DomEvent">The arguments for the event</param>
  1733.  
  1734.                 // signal that the popup has received a mouseup event, this handles
  1735.                 // onblur issues on browsers like FF, OP, and SF
  1736.                 if (Sys.Browser.agent === Sys.Browser.Opera && this._blur.get_isPending()) {
  1737.                     this._blur.cancel();
  1738.                 }
  1739.                 this._popupMouseDown = false;
  1740.                 this.focus();
  1741.             },
  1742.  
  1743.             _cell_onmouseover: function (e) {
  1744.                 /// <summary>
  1745.                 /// Handles the mouseover event of a cell
  1746.                 /// </summary>
  1747.                 /// <param name="e" type="Sys.UI.DomEvent">The arguments for the event</param>
  1748.  
  1749.                 e.stopPropagation();
  1750.  
  1751.                 if (Sys.Browser.agent === Sys.Browser.Safari) {
  1752.                     // Safari doesn't reliably call _cell_onmouseout, so clear other cells here to keep the UI correct
  1753.                     for (var i = 0; i < this._daysBody.rows.length; i++) {
  1754.                         var row = this._daysBody.rows[i];
  1755.                         for (var j = 0; j < row.cells.length; j++) {
  1756.                             Sys.UI.DomElement.removeCssClass(row.cells[j].firstChild.parentNode, "ajax__calendar_hover");
  1757.                         }
  1758.                     }
  1759.                 }
  1760.  
  1761.                 var target = e.target;
  1762.  
  1763.                 Sys.UI.DomElement.addCssClass(target.parentNode, "ajax__calendar_hover");
  1764.             },
  1765.             _cell_onmouseout: function (e) {
  1766.                 /// <summary>
  1767.                 /// Handles the mouseout event of a cell
  1768.                 /// </summary>
  1769.                 /// <param name="e" type="Sys.UI.DomEvent">The arguments for the event</param>
  1770.  
  1771.                 e.stopPropagation();
  1772.  
  1773.                 var target = e.target;
  1774.  
  1775.                 Sys.UI.DomElement.removeCssClass(target.parentNode, "ajax__calendar_hover");
  1776.             },
  1777.             _cell_onclick: function (e) {
  1778.                 /// <summary>
  1779.                 /// Handles the click event of a cell
  1780.                 /// </summary>
  1781.                 /// <param name="e" type="Sys.UI.DomEvent">The arguments for the event</param>
  1782.  
  1783.                 e.stopPropagation();
  1784.                 e.preventDefault();
  1785.  
  1786.                 if (!this._enabled) return;
  1787.  
  1788.                 var target = e.target;
  1789.                 if (target.parentNode.className.indexOf("ajax__calendar_invalid") != -1) {
  1790.                     return;
  1791.                 }
  1792.                 var visibleDate = this._getEffectiveVisibleDate();
  1793.                 Sys.UI.DomElement.removeCssClass(target.parentNode, "ajax__calendar_hover");
  1794.                 switch (target.mode) {
  1795.                     case "prev":
  1796.                     case "next":
  1797.                         this._switchMonth(target.date);
  1798.                         break;
  1799.                     case "title":
  1800.                         switch (this._mode) {
  1801.                             case "days": this._switchMode("months"); break;
  1802.                             case "months": this._switchMode("years"); break;
  1803.                         }
  1804.                         break;
  1805.                     case "month":
  1806.                         if (target.month == visibleDate.getMonth()) {
  1807.                             this._switchMode("days");
  1808.                         } else {
  1809.                             this._visibleDate = target.date;
  1810.                             this._switchMode("days");
  1811.                         }
  1812.                         break;
  1813.                     case "year":
  1814.                         if (target.date.getFullYear() == visibleDate.getFullYear()) {
  1815.                             this._switchMode("months");
  1816.                         } else {
  1817.                             this._visibleDate = target.date;
  1818.                             this._switchMode("months");
  1819.                         }
  1820.                         break;
  1821.                     case "day":
  1822.                         this.set_selectedDate(target.date);
  1823.                         this._switchMonth(target.date);
  1824.                         this._blur.post(true);
  1825.                         this.raiseDateSelectionChanged();
  1826.                         break;
  1827.                     case "today":
  1828.                     case "reset":
  1829.                         this.set_selectedDate(target.date);
  1830.                         if (target.date) {
  1831.                             this._switchMonth(target.date);
  1832.                         }
  1833.                         this._blur.post(true);
  1834.                         this.raiseDateSelectionChanged();
  1835.                         break;
  1836.                 }
  1837.             },
  1838.  
  1839.             _button_onclick: function (e) {
  1840.                 /// <summary>
  1841.                 /// Handles the click event of the asociated button
  1842.                 /// </summary>
  1843.                 /// <param name="e" type="Sys.UI.DomEvent">The arguments for the event</param>
  1844.  
  1845.                 e.preventDefault();
  1846.                 e.stopPropagation();
  1847.  
  1848.                 if (!this._enabled) return;
  1849.                 //If event was rised not by mouse click
  1850.                 if (e.clientX == 0) return;
  1851.  
  1852.                 if (!this._isOpen) {
  1853.                     this.show();
  1854.                 } else {
  1855.                     this.hide();
  1856.                 }
  1857.                 this.focus();
  1858.                 // make sure we clean up the flag due to issues with alert/alt-tab/etc
  1859.                 this._popupMouseDown = false;
  1860.                 // set to the date currently in the text box
  1861.                 if (this._visibleDate != this._selectedDate) {
  1862.                     this._visibleDate = this._selectedDate
  1863.                     this.invalidate();
  1864.                 }
  1865.             },
  1866.             _button_onblur: function (e) {
  1867.                 /// <summary>
  1868.                 /// Handles the blur event of the button
  1869.                 /// </summary>
  1870.                 /// <param name="e" type="Sys.UI.DomEvent">The arguments for the event</param>
  1871.                 if (!this._enabled) return;
  1872.                 if (!this._popupMouseDown) {
  1873.                     this.hide();
  1874.                 }
  1875.                 // make sure we clean up the flag due to issues with alert/alt-tab/etc
  1876.                 this._popupMouseDown = false;
  1877.             },
  1878.             _button_onkeypress: function (e) {
  1879.                 /// <summary>
  1880.                 /// Handles the keypress event of the element
  1881.                 /// </summary>
  1882.                 /// <param name="e" type="Sys.UI.DomEvent">The arguments for the event</param>
  1883.                 if (!this._enabled) return;
  1884.                 if (e.charCode == Sys.UI.Key.esc) {
  1885.                     e.stopPropagation();
  1886.                     e.preventDefault();
  1887.                     this.hide();
  1888.                 }
  1889.                 // make sure we clean up the flag due to issues with alert/alt-tab/etc
  1890.                 this._popupMouseDown = false;
  1891.             }
  1892.         }
  1893.         Sys.Extended.UI.CalendarBehavior.registerClass("Sys.Extended.UI.CalendarBehavior", Sys.Extended.UI.BehaviorBase);
  1894.         Sys.registerComponent(Sys.Extended.UI.CalendarBehavior, { name: "calendar" });
  1895.  
  1896.         Sys.Extended.UI.CalendarPosition = function () {
  1897.             /// <summary>
  1898.             /// Position of the popup relative to the target control
  1899.             /// </summary>
  1900.             /// <field name="BottomLeft" type="Number" integer="true" />
  1901.             /// <field name="BottomRight" type="Number" integer="true" />
  1902.             /// <field name="TopLeft" type="Number" integer="true" />
  1903.             /// <field name="TopRight" type="Number" integer="true" />
  1904.             /// <field name="Right" type="Number" integer="true" />
  1905.             /// <field name="Left" type="Number" integer="true" />
  1906.             throw Error.invalidOperation();
  1907.         }
  1908.         Sys.Extended.UI.CalendarPosition.prototype = {
  1909.             BottomLeft: 0,
  1910.             BottomRight: 1,
  1911.             TopLeft: 2,
  1912.             TopRight: 3,
  1913.             Right: 4,
  1914.             Left: 5
  1915.         }
  1916.         Sys.Extended.UI.CalendarPosition.registerEnum('Sys.Extended.UI.CalendarPosition');
  1917.  
  1918.         Sys.Extended.UI.CalendarDefaultView = function () {
  1919.             /// <summary>
  1920.             /// Choices for default view of the calendar when it first pops up.
  1921.             /// </summary>
  1922.             /// <field name="Days" type="Number" integer="true" />
  1923.             /// <field name="Months" type="Number" integer="true" />
  1924.             /// <field name="Years" type="Number" integer="true" />
  1925.             throw Error.invalidOperation();
  1926.         }
  1927.         Sys.Extended.UI.CalendarDefaultView.prototype = {
  1928.             Days: 0,
  1929.             Months: 1,
  1930.             Years: 2
  1931.         }
  1932.         Sys.Extended.UI.CalendarDefaultView.registerEnum('Sys.Extended.UI.CalendarDefaultView');
  1933.  
  1934.     } // execute
  1935.  
  1936.     if (window.Sys && Sys.loader) {
  1937.         Sys.loader.registerScript(scriptName, ["Globalization", "ExtendedBase", "ExtendedDateTime", "ExtendedThreading", "ExtendedAnimationBehavior", "ExtendedPopup"], execute);
  1938.     }
  1939.     else {
  1940.         execute();
  1941.     }
  1942.  
  1943. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement