Ver Mensaje Individual
  #5 (permalink)  
Antiguo 26/01/2012, 16:13
bartman742
 
Fecha de Ingreso: enero-2012
Mensajes: 64
Antigüedad: 12 años, 3 meses
Puntos: 0
Respuesta: calendario jquery

Código Javascript:
Ver original
  1. if (this.displayedYear == this.endDate.getFullYear() && this.displayedMonth == this.endDate.getMonth()) {
  2.                     $('.dp-nav-next-year', this.context).addClass('disabled');
  3.                     $('.dp-nav-next-month', this.context).addClass('disabled');
  4.                     $('.dp-calendar td.other-month', this.context).each(
  5.                         function()
  6.                         {
  7.                             var $this = $(this);
  8.                             if (Number($this.text()) < 14) {
  9.                                 $this.addClass('disabled');
  10.                             }
  11.                         }
  12.                     );
  13.                     var d = this.endDate.getDate();
  14.                     $('.dp-calendar td.current-month', this.context).each(
  15.                         function()
  16.                         {
  17.                             var $this = $(this);
  18.                             if (Number($this.text()) > d) {
  19.                                 $this.addClass('disabled');
  20.                             }
  21.                         }
  22.                     );
  23.                 } else {
  24.                     $('.dp-nav-next-year', this.context).removeClass('disabled');
  25.                     $('.dp-nav-next-month', this.context).removeClass('disabled');
  26.                     var d = this.endDate.getDate();
  27.                     if (d < 13) {
  28.                         // check if the endDate is next month as we might need to add some disabled classes...
  29.                         var ed = new Date(this.endDate.getTime());
  30.                         ed.addMonths(-1);
  31.                         if (this.displayedYear == ed.getFullYear() && this.displayedMonth == ed.getMonth()) {
  32.                             $('.dp-calendar td.other-month', this.context).each(
  33.                                 function()
  34.                                 {
  35.                                     var $this = $(this);
  36.                                     var cellDay = Number($this.text());
  37.                                     if (cellDay < 13 && cellDay > d) {
  38.                                         $this.addClass('disabled');
  39.                                     }
  40.                                 }
  41.                             );
  42.                         }
  43.                     }
  44.                 }
  45.                 this._applyRenderCallbacks();
  46.             },
  47.             _closeCalendar : function(programatic, ele)
  48.             {
  49.                 if (!ele || ele == this.ele)
  50.                 {
  51.                     $(document).unbind('mousedown.datepicker');
  52.                     $(document).unbind('keydown.datepicker');
  53.                     this._clearCalendar();
  54.                     $('#dp-popup a').unbind();
  55.                     $('#dp-popup').empty().remove();
  56.                     if (!programatic) {
  57.                         $(this.ele).trigger('dpClosed', [this.getSelected()]);
  58.                     }
  59.                 }
  60.             },
  61.             // empties the current dp-calendar div and makes sure that all events are unbound
  62.             // and expandos removed to avoid memory leaks...
  63.             _clearCalendar : function()
  64.             {
  65.                 // TODO.
  66.                 $('.dp-calendar td', this.context).unbind();
  67.                 $('.dp-calendar', this.context).empty();
  68.             }
  69.         }
  70.     );
  71.    
  72.     // static constants
  73.     $.dpConst = {
  74.         SHOW_HEADER_NONE    :   0,
  75.         SHOW_HEADER_SHORT   :   1,
  76.         SHOW_HEADER_LONG    :   2,
  77.         POS_TOP             :   0,
  78.         POS_BOTTOM          :   1,
  79.         POS_LEFT            :   0,
  80.         POS_RIGHT           :   1,
  81.         DP_INTERNAL_FOCUS   :   'dpInternalFocusTrigger'
  82.     };
  83.     // localisable text
  84.     $.dpText = {
  85.         TEXT_PREV_YEAR      :   'Previous year',
  86.         TEXT_PREV_MONTH     :   'Previous month',
  87.         TEXT_NEXT_YEAR      :   'Next year',
  88.         TEXT_NEXT_MONTH     :   'Next month',
  89.         TEXT_CLOSE          :   'Close',
  90.         TEXT_CHOOSE_DATE    :   'Choose date',
  91.         HEADER_FORMAT       :   'mmmm yyyy'
  92.     };
  93.     // version
  94.     $.dpVersion = '$Id: jquery.datePicker.js 108 2011-11-17 21:19:57Z [email protected] $';
  95.  
  96.     $.fn.datePicker.defaults = {
  97.         month               : undefined,
  98.         year                : undefined,
  99.         showHeader          : $.dpConst.SHOW_HEADER_SHORT,
  100.         startDate           : undefined,
  101.         endDate             : undefined,
  102.         inline              : false,
  103.         renderCallback      : null,
  104.         createButton        : true,
  105.         showYearNavigation  : true,
  106.         closeOnSelect       : true,
  107.         displayClose        : false,
  108.         selectMultiple      : false,
  109.         numSelectable       : Number.MAX_VALUE,
  110.         clickInput          : false,
  111.         rememberViewedMonth : true,
  112.         selectWeek          : false,
  113.         verticalPosition    : $.dpConst.POS_TOP,
  114.         horizontalPosition  : $.dpConst.POS_LEFT,
  115.         verticalOffset      : 0,
  116.         horizontalOffset    : 0,
  117.         hoverClass          : 'dp-hover',
  118.         autoFocusNextInput  : false
  119.     };
  120.  
  121.     function _getController(ele)
  122.     {
  123.         if (ele._dpId) return $.event._dpCache[ele._dpId];
  124.         return false;
  125.     };
  126.    
  127.     // make it so that no error is thrown if bgIframe plugin isn't included (allows you to use conditional
  128.     // comments to only include bgIframe where it is needed in IE without breaking this plugin).
  129.     if ($.fn.bgIframe == undefined) {
  130.         $.fn.bgIframe = function() {return this; };
  131.     };
  132.  
  133.  
  134.     // clean-up
  135.     $(window)
  136.         .bind('unload', function() {
  137.             var els = $.event._dpCache || [];
  138.             for (var i in els) {
  139.                 $(els[i].ele)._dpDestroy();
  140.             }
  141.         });
  142.        
  143.    
  144. })(jQuery);