h2ocube_rails_assets 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/README.md +1 -1
  2. data/h2ocube_rails_assets.gemspec +2 -2
  3. data/lib/h2ocube_rails_assets.rb +1 -4
  4. data/vendor/assets/images/jquery.ui/animated-overlay.gif +0 -0
  5. data/vendor/assets/images/jquery.ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  6. data/vendor/assets/images/jquery.ui/ui-bg_flat_75_ffffff_40x100.png +0 -0
  7. data/vendor/assets/images/jquery.ui/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  8. data/vendor/assets/images/jquery.ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
  9. data/vendor/assets/images/jquery.ui/ui-bg_glass_75_dadada_1x400.png +0 -0
  10. data/vendor/assets/images/jquery.ui/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  11. data/vendor/assets/images/jquery.ui/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  12. data/vendor/assets/images/jquery.ui/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  13. data/vendor/assets/images/jquery.ui/ui-icons_222222_256x240.png +0 -0
  14. data/vendor/assets/images/jquery.ui/ui-icons_2e83ff_256x240.png +0 -0
  15. data/vendor/assets/images/jquery.ui/ui-icons_454545_256x240.png +0 -0
  16. data/vendor/assets/images/jquery.ui/ui-icons_888888_256x240.png +0 -0
  17. data/vendor/assets/images/jquery.ui/ui-icons_cd0a0a_256x240.png +0 -0
  18. data/vendor/assets/javascripts/_bootstrap.js +189 -80
  19. data/vendor/assets/javascripts/_jquery.fancybox.js +1983 -0
  20. data/vendor/assets/javascripts/_jquery.fileupload.js +1164 -0
  21. data/vendor/assets/javascripts/_jquery.js +1 -1
  22. data/vendor/assets/javascripts/{jquery.ui/jquery-ui.custom.js → _jquery.ui.js} +3717 -3693
  23. data/vendor/assets/javascripts/_jquery.validate.js +1207 -0
  24. data/vendor/assets/javascripts/_sammy.js +2120 -0
  25. data/vendor/assets/javascripts/jquery/1.9.js +229 -187
  26. data/vendor/assets/javascripts/jquery.cookie.js +29 -11
  27. data/vendor/assets/javascripts/jquery.fancybox.js +2 -1985
  28. data/vendor/assets/javascripts/jquery.fileupload.js +4 -1114
  29. data/vendor/assets/javascripts/jquery.iframe-transport.js +20 -7
  30. data/vendor/assets/javascripts/jquery.ui/jquery.ui.accordion.js +131 -290
  31. data/vendor/assets/javascripts/jquery.ui/jquery.ui.autocomplete.js +43 -37
  32. data/vendor/assets/javascripts/jquery.ui/jquery.ui.button.js +9 -8
  33. data/vendor/assets/javascripts/jquery.ui/jquery.ui.core.js +19 -51
  34. data/vendor/assets/javascripts/jquery.ui/jquery.ui.datepicker.js +1082 -878
  35. data/vendor/assets/javascripts/jquery.ui/jquery.ui.dialog.js +483 -542
  36. data/vendor/assets/javascripts/jquery.ui/jquery.ui.draggable.js +319 -212
  37. data/vendor/assets/javascripts/jquery.ui/jquery.ui.droppable.js +177 -100
  38. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-blind.js +2 -2
  39. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-bounce.js +2 -2
  40. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-clip.js +2 -2
  41. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-drop.js +2 -2
  42. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-explode.js +2 -2
  43. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-fade.js +2 -2
  44. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-fold.js +2 -2
  45. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-highlight.js +2 -2
  46. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-pulsate.js +2 -2
  47. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-scale.js +2 -2
  48. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-shake.js +2 -2
  49. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-slide.js +2 -2
  50. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-transfer.js +3 -3
  51. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect.js +93 -101
  52. data/vendor/assets/javascripts/jquery.ui/jquery.ui.menu.js +21 -10
  53. data/vendor/assets/javascripts/jquery.ui/jquery.ui.mouse.js +25 -25
  54. data/vendor/assets/javascripts/jquery.ui/jquery.ui.position.js +42 -62
  55. data/vendor/assets/javascripts/jquery.ui/jquery.ui.progressbar.js +73 -33
  56. data/vendor/assets/javascripts/jquery.ui/jquery.ui.resizable.js +461 -294
  57. data/vendor/assets/javascripts/jquery.ui/jquery.ui.selectable.js +67 -51
  58. data/vendor/assets/javascripts/jquery.ui/jquery.ui.slider.js +179 -151
  59. data/vendor/assets/javascripts/jquery.ui/jquery.ui.sortable.js +411 -257
  60. data/vendor/assets/javascripts/jquery.ui/jquery.ui.spinner.js +19 -5
  61. data/vendor/assets/javascripts/jquery.ui/jquery.ui.tabs.js +47 -567
  62. data/vendor/assets/javascripts/jquery.ui/jquery.ui.tooltip.js +14 -10
  63. data/vendor/assets/javascripts/jquery.ui/jquery.ui.widget.js +33 -40
  64. data/vendor/assets/javascripts/jquery.ui.js +1 -1
  65. data/vendor/assets/javascripts/jquery.validate.js +1 -1258
  66. data/vendor/assets/javascripts/sammy.js +1 -2107
  67. data/vendor/assets/javascripts/underscore.js +101 -75
  68. data/vendor/assets/stylesheets/bootstrap.responsive.css +24 -7
  69. data/vendor/assets/stylesheets/bootstrap.scss +238 -119
  70. data/vendor/assets/stylesheets/jquery.fancybox.scss +6 -6
  71. data/vendor/assets/stylesheets/jquery.ui.scss +918 -217
  72. data/vendor/assets/stylesheets/normalize.css +396 -0
  73. metadata +16 -20
@@ -1,8 +1,8 @@
1
1
  /*!
2
- * jQuery UI Datepicker 1.9.2
2
+ * jQuery UI Datepicker 1.10.1
3
3
  * http://jqueryui.com
4
4
  *
5
- * Copyright 2012 jQuery Foundation and other contributors
5
+ * Copyright 2013 jQuery Foundation and other contributors
6
6
  * Released under the MIT license.
7
7
  * http://jquery.org/license
8
8
  *
@@ -13,11 +13,11 @@
13
13
  */
14
14
  (function( $, undefined ) {
15
15
 
16
- $.extend($.ui, { datepicker: { version: "1.9.2" } });
16
+ $.extend($.ui, { datepicker: { version: "1.10.1" } });
17
17
 
18
- var PROP_NAME = 'datepicker';
19
- var dpuuid = new Date().getTime();
20
- var instActive;
18
+ var PROP_NAME = "datepicker",
19
+ dpuuid = new Date().getTime(),
20
+ instActive;
21
21
 
22
22
  /* Date picker manager.
23
23
  Use the singleton instance of this class, $.datepicker, to interact with the date picker.
@@ -25,50 +25,49 @@ var instActive;
25
25
  allowing multiple different settings on the same page. */
26
26
 
27
27
  function Datepicker() {
28
- this.debug = false; // Change this to true to start debugging
29
28
  this._curInst = null; // The current instance in use
30
29
  this._keyEvent = false; // If the last event was a key event
31
30
  this._disabledInputs = []; // List of date picker inputs that have been disabled
32
31
  this._datepickerShowing = false; // True if the popup picker is showing , false if not
33
32
  this._inDialog = false; // True if showing within a "dialog", false if not
34
- this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
35
- this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class
36
- this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
37
- this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
38
- this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
39
- this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class
40
- this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
41
- this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
42
- this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class
33
+ this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
34
+ this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
35
+ this._appendClass = "ui-datepicker-append"; // The name of the append marker class
36
+ this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
37
+ this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
38
+ this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
39
+ this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
40
+ this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
41
+ this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
43
42
  this.regional = []; // Available regional settings, indexed by language code
44
- this.regional[''] = { // Default regional settings
45
- closeText: 'Done', // Display text for close link
46
- prevText: 'Prev', // Display text for previous month link
47
- nextText: 'Next', // Display text for next month link
48
- currentText: 'Today', // Display text for current month link
49
- monthNames: ['January','February','March','April','May','June',
50
- 'July','August','September','October','November','December'], // Names of months for drop-down and formatting
51
- monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
52
- dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
53
- dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
54
- dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
55
- weekHeader: 'Wk', // Column header for week of the year
56
- dateFormat: 'mm/dd/yy', // See format options on parseDate
43
+ this.regional[""] = { // Default regional settings
44
+ closeText: "Done", // Display text for close link
45
+ prevText: "Prev", // Display text for previous month link
46
+ nextText: "Next", // Display text for next month link
47
+ currentText: "Today", // Display text for current month link
48
+ monthNames: ["January","February","March","April","May","June",
49
+ "July","August","September","October","November","December"], // Names of months for drop-down and formatting
50
+ monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
51
+ dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
52
+ dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
53
+ dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
54
+ weekHeader: "Wk", // Column header for week of the year
55
+ dateFormat: "mm/dd/yy", // See format options on parseDate
57
56
  firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
58
57
  isRTL: false, // True if right-to-left language, false if left-to-right
59
58
  showMonthAfterYear: false, // True if the year select precedes month, false for month then year
60
- yearSuffix: '' // Additional text to append to the year in the month headers
59
+ yearSuffix: "" // Additional text to append to the year in the month headers
61
60
  };
62
61
  this._defaults = { // Global defaults for all the date picker instances
63
- showOn: 'focus', // 'focus' for popup on focus,
64
- // 'button' for trigger button, or 'both' for either
65
- showAnim: 'fadeIn', // Name of jQuery animation for popup
62
+ showOn: "focus", // "focus" for popup on focus,
63
+ // "button" for trigger button, or "both" for either
64
+ showAnim: "fadeIn", // Name of jQuery animation for popup
66
65
  showOptions: {}, // Options for enhanced animations
67
66
  defaultDate: null, // Used when field is blank: actual date,
68
67
  // +/-number for offset from today, null for today
69
- appendText: '', // Display text following the input box, e.g. showing the format
70
- buttonText: '...', // Text for trigger button
71
- buttonImage: '', // URL for trigger button image
68
+ appendText: "", // Display text following the input box, e.g. showing the format
69
+ buttonText: "...", // Text for trigger button
70
+ buttonImage: "", // URL for trigger button image
72
71
  buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
73
72
  hideIfNoPrevNext: false, // True to hide next/previous month links
74
73
  // if not applicable, false to just disable them
@@ -76,7 +75,7 @@ function Datepicker() {
76
75
  gotoCurrent: false, // True if today link goes back to current selection instead
77
76
  changeMonth: false, // True if month can be selected directly, false if only prev/next
78
77
  changeYear: false, // True if year can be selected directly, false if only prev/next
79
- yearRange: 'c-10:c+10', // Range of years to display in drop-down,
78
+ yearRange: "c-10:c+10", // Range of years to display in drop-down,
80
79
  // either relative to today's year (-nn:+nn), relative to currently displayed year
81
80
  // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
82
81
  showOtherMonths: false, // True to show dates in other months, false to leave blank
@@ -84,14 +83,14 @@ function Datepicker() {
84
83
  showWeek: false, // True to show week of the year, false to not show it
85
84
  calculateWeek: this.iso8601Week, // How to calculate the week of the year,
86
85
  // takes a Date and returns the number of the week for it
87
- shortYearCutoff: '+10', // Short year values < this are in the current century,
86
+ shortYearCutoff: "+10", // Short year values < this are in the current century,
88
87
  // > this are in the previous century,
89
- // string value starting with '+' for current year + value
88
+ // string value starting with "+" for current year + value
90
89
  minDate: null, // The earliest selectable date, or null for no limit
91
90
  maxDate: null, // The latest selectable date, or null for no limit
92
- duration: 'fast', // Duration of display/closure
91
+ duration: "fast", // Duration of display/closure
93
92
  beforeShowDay: null, // Function that takes a date and returns an array with
94
- // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '',
93
+ // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
95
94
  // [2] = cell title (optional), e.g. $.datepicker.noWeekends
96
95
  beforeShow: null, // Function that takes an input field and
97
96
  // returns a set of custom settings for the date picker
@@ -102,69 +101,53 @@ function Datepicker() {
102
101
  showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
103
102
  stepMonths: 1, // Number of months to step back/forward
104
103
  stepBigMonths: 12, // Number of months to step back/forward for the big links
105
- altField: '', // Selector for an alternate field to store selected dates into
106
- altFormat: '', // The date format to use for the alternate field
104
+ altField: "", // Selector for an alternate field to store selected dates into
105
+ altFormat: "", // The date format to use for the alternate field
107
106
  constrainInput: true, // The input is constrained by the current date format
108
107
  showButtonPanel: false, // True to show button panel, false to not show it
109
108
  autoSize: false, // True to size the input for the date format, false to leave as is
110
109
  disabled: false // The initial disabled state
111
110
  };
112
- $.extend(this._defaults, this.regional['']);
113
- this.dpDiv = bindHover($('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'));
111
+ $.extend(this._defaults, this.regional[""]);
112
+ this.dpDiv = bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
114
113
  }
115
114
 
116
115
  $.extend(Datepicker.prototype, {
117
116
  /* Class name added to elements to indicate already configured with a date picker. */
118
- markerClassName: 'hasDatepicker',
117
+ markerClassName: "hasDatepicker",
119
118
 
120
119
  //Keep track of the maximum number of rows displayed (see #7043)
121
120
  maxRows: 4,
122
121
 
123
- /* Debug logging (if enabled). */
124
- log: function () {
125
- if (this.debug)
126
- console.log.apply('', arguments);
127
- },
128
-
129
122
  // TODO rename to "widget" when switching to widget factory
130
123
  _widgetDatepicker: function() {
131
124
  return this.dpDiv;
132
125
  },
133
126
 
134
127
  /* Override the default settings for all instances of the date picker.
135
- @param settings object - the new settings to use as defaults (anonymous object)
136
- @return the manager object */
128
+ * @param settings object - the new settings to use as defaults (anonymous object)
129
+ * @return the manager object
130
+ */
137
131
  setDefaults: function(settings) {
138
132
  extendRemove(this._defaults, settings || {});
139
133
  return this;
140
134
  },
141
135
 
142
136
  /* Attach the date picker to a jQuery selection.
143
- @param target element - the target input field or division or span
144
- @param settings object - the new settings to use for this date picker instance (anonymous) */
137
+ * @param target element - the target input field or division or span
138
+ * @param settings object - the new settings to use for this date picker instance (anonymous)
139
+ */
145
140
  _attachDatepicker: function(target, settings) {
146
- // check for settings on the control itself - in namespace 'date:'
147
- var inlineSettings = null;
148
- for (var attrName in this._defaults) {
149
- var attrValue = target.getAttribute('date:' + attrName);
150
- if (attrValue) {
151
- inlineSettings = inlineSettings || {};
152
- try {
153
- inlineSettings[attrName] = eval(attrValue);
154
- } catch (err) {
155
- inlineSettings[attrName] = attrValue;
156
- }
157
- }
158
- }
159
- var nodeName = target.nodeName.toLowerCase();
160
- var inline = (nodeName == 'div' || nodeName == 'span');
141
+ var nodeName, inline, inst;
142
+ nodeName = target.nodeName.toLowerCase();
143
+ inline = (nodeName === "div" || nodeName === "span");
161
144
  if (!target.id) {
162
145
  this.uuid += 1;
163
- target.id = 'dp' + this.uuid;
146
+ target.id = "dp" + this.uuid;
164
147
  }
165
- var inst = this._newInst($(target), inline);
166
- inst.settings = $.extend({}, settings || {}, inlineSettings || {});
167
- if (nodeName == 'input') {
148
+ inst = this._newInst($(target), inline);
149
+ inst.settings = $.extend({}, settings || {});
150
+ if (nodeName === "input") {
168
151
  this._connectDatepicker(target, inst);
169
152
  } else if (inline) {
170
153
  this._inlineDatepicker(target, inst);
@@ -173,13 +156,13 @@ $.extend(Datepicker.prototype, {
173
156
 
174
157
  /* Create a new instance object. */
175
158
  _newInst: function(target, inline) {
176
- var id = target[0].id.replace(/([^A-Za-z0-9_-])/g, '\\\\$1'); // escape jQuery meta chars
159
+ var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
177
160
  return {id: id, input: target, // associated target
178
161
  selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
179
162
  drawMonth: 0, drawYear: 0, // month being drawn
180
163
  inline: inline, // is datepicker inline or not
181
164
  dpDiv: (!inline ? this.dpDiv : // presentation div
182
- bindHover($('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')))};
165
+ bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
183
166
  },
184
167
 
185
168
  /* Attach the date picker to an input field. */
@@ -187,16 +170,12 @@ $.extend(Datepicker.prototype, {
187
170
  var input = $(target);
188
171
  inst.append = $([]);
189
172
  inst.trigger = $([]);
190
- if (input.hasClass(this.markerClassName))
173
+ if (input.hasClass(this.markerClassName)) {
191
174
  return;
175
+ }
192
176
  this._attachments(input, inst);
193
177
  input.addClass(this.markerClassName).keydown(this._doKeyDown).
194
- keypress(this._doKeyPress).keyup(this._doKeyUp).
195
- bind("setData.datepicker", function(event, key, value) {
196
- inst.settings[key] = value;
197
- }).bind("getData.datepicker", function(event, key) {
198
- return this._get(inst, key);
199
- });
178
+ keypress(this._doKeyPress).keyup(this._doKeyUp);
200
179
  this._autoSize(inst);
201
180
  $.data(target, PROP_NAME, inst);
202
181
  //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
@@ -207,38 +186,47 @@ $.extend(Datepicker.prototype, {
207
186
 
208
187
  /* Make attachments based on settings. */
209
188
  _attachments: function(input, inst) {
210
- var appendText = this._get(inst, 'appendText');
211
- var isRTL = this._get(inst, 'isRTL');
212
- if (inst.append)
189
+ var showOn, buttonText, buttonImage,
190
+ appendText = this._get(inst, "appendText"),
191
+ isRTL = this._get(inst, "isRTL");
192
+
193
+ if (inst.append) {
213
194
  inst.append.remove();
195
+ }
214
196
  if (appendText) {
215
- inst.append = $('<span class="' + this._appendClass + '">' + appendText + '</span>');
216
- input[isRTL ? 'before' : 'after'](inst.append);
197
+ inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
198
+ input[isRTL ? "before" : "after"](inst.append);
217
199
  }
218
- input.unbind('focus', this._showDatepicker);
219
- if (inst.trigger)
200
+
201
+ input.unbind("focus", this._showDatepicker);
202
+
203
+ if (inst.trigger) {
220
204
  inst.trigger.remove();
221
- var showOn = this._get(inst, 'showOn');
222
- if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
205
+ }
206
+
207
+ showOn = this._get(inst, "showOn");
208
+ if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
223
209
  input.focus(this._showDatepicker);
224
- if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
225
- var buttonText = this._get(inst, 'buttonText');
226
- var buttonImage = this._get(inst, 'buttonImage');
227
- inst.trigger = $(this._get(inst, 'buttonImageOnly') ?
228
- $('<img/>').addClass(this._triggerClass).
210
+ }
211
+ if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
212
+ buttonText = this._get(inst, "buttonText");
213
+ buttonImage = this._get(inst, "buttonImage");
214
+ inst.trigger = $(this._get(inst, "buttonImageOnly") ?
215
+ $("<img/>").addClass(this._triggerClass).
229
216
  attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
230
- $('<button type="button"></button>').addClass(this._triggerClass).
231
- html(buttonImage == '' ? buttonText : $('<img/>').attr(
217
+ $("<button type='button'></button>").addClass(this._triggerClass).
218
+ html(!buttonImage ? buttonText : $("<img/>").attr(
232
219
  { src:buttonImage, alt:buttonText, title:buttonText })));
233
- input[isRTL ? 'before' : 'after'](inst.trigger);
220
+ input[isRTL ? "before" : "after"](inst.trigger);
234
221
  inst.trigger.click(function() {
235
- if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0])
222
+ if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
236
223
  $.datepicker._hideDatepicker();
237
- else if ($.datepicker._datepickerShowing && $.datepicker._lastInput != input[0]) {
224
+ } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
238
225
  $.datepicker._hideDatepicker();
239
226
  $.datepicker._showDatepicker(input[0]);
240
- } else
227
+ } else {
241
228
  $.datepicker._showDatepicker(input[0]);
229
+ }
242
230
  return false;
243
231
  });
244
232
  }
@@ -246,14 +234,16 @@ $.extend(Datepicker.prototype, {
246
234
 
247
235
  /* Apply the maximum length for the date format. */
248
236
  _autoSize: function(inst) {
249
- if (this._get(inst, 'autoSize') && !inst.inline) {
250
- var date = new Date(2009, 12 - 1, 20); // Ensure double digits
251
- var dateFormat = this._get(inst, 'dateFormat');
237
+ if (this._get(inst, "autoSize") && !inst.inline) {
238
+ var findMax, max, maxI, i,
239
+ date = new Date(2009, 12 - 1, 20), // Ensure double digits
240
+ dateFormat = this._get(inst, "dateFormat");
241
+
252
242
  if (dateFormat.match(/[DM]/)) {
253
- var findMax = function(names) {
254
- var max = 0;
255
- var maxI = 0;
256
- for (var i = 0; i < names.length; i++) {
243
+ findMax = function(names) {
244
+ max = 0;
245
+ maxI = 0;
246
+ for (i = 0; i < names.length; i++) {
257
247
  if (names[i].length > max) {
258
248
  max = names[i].length;
259
249
  maxI = i;
@@ -262,25 +252,21 @@ $.extend(Datepicker.prototype, {
262
252
  return maxI;
263
253
  };
264
254
  date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
265
- 'monthNames' : 'monthNamesShort'))));
255
+ "monthNames" : "monthNamesShort"))));
266
256
  date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
267
- 'dayNames' : 'dayNamesShort'))) + 20 - date.getDay());
257
+ "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
268
258
  }
269
- inst.input.attr('size', this._formatDate(inst, date).length);
259
+ inst.input.attr("size", this._formatDate(inst, date).length);
270
260
  }
271
261
  },
272
262
 
273
263
  /* Attach an inline date picker to a div. */
274
264
  _inlineDatepicker: function(target, inst) {
275
265
  var divSpan = $(target);
276
- if (divSpan.hasClass(this.markerClassName))
266
+ if (divSpan.hasClass(this.markerClassName)) {
277
267
  return;
278
- divSpan.addClass(this.markerClassName).append(inst.dpDiv).
279
- bind("setData.datepicker", function(event, key, value){
280
- inst.settings[key] = value;
281
- }).bind("getData.datepicker", function(event, key){
282
- return this._get(inst, key);
283
- });
268
+ }
269
+ divSpan.addClass(this.markerClassName).append(inst.dpDiv);
284
270
  $.data(target, PROP_NAME, inst);
285
271
  this._setDate(inst, this._getDefaultDate(inst), true);
286
272
  this._updateDatepicker(inst);
@@ -295,186 +281,219 @@ $.extend(Datepicker.prototype, {
295
281
  },
296
282
 
297
283
  /* Pop-up the date picker in a "dialog" box.
298
- @param input element - ignored
299
- @param date string or Date - the initial date to display
300
- @param onSelect function - the function to call when a date is selected
301
- @param settings object - update the dialog date picker instance's settings (anonymous object)
302
- @param pos int[2] - coordinates for the dialog's position within the screen or
303
- event - with x/y coordinates or
304
- leave empty for default (screen centre)
305
- @return the manager object */
284
+ * @param input element - ignored
285
+ * @param date string or Date - the initial date to display
286
+ * @param onSelect function - the function to call when a date is selected
287
+ * @param settings object - update the dialog date picker instance's settings (anonymous object)
288
+ * @param pos int[2] - coordinates for the dialog's position within the screen or
289
+ * event - with x/y coordinates or
290
+ * leave empty for default (screen centre)
291
+ * @return the manager object
292
+ */
306
293
  _dialogDatepicker: function(input, date, onSelect, settings, pos) {
307
- var inst = this._dialogInst; // internal instance
294
+ var id, browserWidth, browserHeight, scrollX, scrollY,
295
+ inst = this._dialogInst; // internal instance
296
+
308
297
  if (!inst) {
309
298
  this.uuid += 1;
310
- var id = 'dp' + this.uuid;
311
- this._dialogInput = $('<input type="text" id="' + id +
312
- '" style="position: absolute; top: -100px; width: 0px;"/>');
299
+ id = "dp" + this.uuid;
300
+ this._dialogInput = $("<input type='text' id='" + id +
301
+ "' style='position: absolute; top: -100px; width: 0px;'/>");
313
302
  this._dialogInput.keydown(this._doKeyDown);
314
- $('body').append(this._dialogInput);
303
+ $("body").append(this._dialogInput);
315
304
  inst = this._dialogInst = this._newInst(this._dialogInput, false);
316
305
  inst.settings = {};
317
306
  $.data(this._dialogInput[0], PROP_NAME, inst);
318
307
  }
319
308
  extendRemove(inst.settings, settings || {});
320
- date = (date && date.constructor == Date ? this._formatDate(inst, date) : date);
309
+ date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
321
310
  this._dialogInput.val(date);
322
311
 
323
312
  this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
324
313
  if (!this._pos) {
325
- var browserWidth = document.documentElement.clientWidth;
326
- var browserHeight = document.documentElement.clientHeight;
327
- var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
328
- var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
314
+ browserWidth = document.documentElement.clientWidth;
315
+ browserHeight = document.documentElement.clientHeight;
316
+ scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
317
+ scrollY = document.documentElement.scrollTop || document.body.scrollTop;
329
318
  this._pos = // should use actual width/height below
330
319
  [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
331
320
  }
332
321
 
333
322
  // move input on screen for focus, but hidden behind dialog
334
- this._dialogInput.css('left', (this._pos[0] + 20) + 'px').css('top', this._pos[1] + 'px');
323
+ this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
335
324
  inst.settings.onSelect = onSelect;
336
325
  this._inDialog = true;
337
326
  this.dpDiv.addClass(this._dialogClass);
338
327
  this._showDatepicker(this._dialogInput[0]);
339
- if ($.blockUI)
328
+ if ($.blockUI) {
340
329
  $.blockUI(this.dpDiv);
330
+ }
341
331
  $.data(this._dialogInput[0], PROP_NAME, inst);
342
332
  return this;
343
333
  },
344
334
 
345
335
  /* Detach a datepicker from its control.
346
- @param target element - the target input field or division or span */
336
+ * @param target element - the target input field or division or span
337
+ */
347
338
  _destroyDatepicker: function(target) {
348
- var $target = $(target);
349
- var inst = $.data(target, PROP_NAME);
339
+ var nodeName,
340
+ $target = $(target),
341
+ inst = $.data(target, PROP_NAME);
342
+
350
343
  if (!$target.hasClass(this.markerClassName)) {
351
344
  return;
352
345
  }
353
- var nodeName = target.nodeName.toLowerCase();
346
+
347
+ nodeName = target.nodeName.toLowerCase();
354
348
  $.removeData(target, PROP_NAME);
355
- if (nodeName == 'input') {
349
+ if (nodeName === "input") {
356
350
  inst.append.remove();
357
351
  inst.trigger.remove();
358
352
  $target.removeClass(this.markerClassName).
359
- unbind('focus', this._showDatepicker).
360
- unbind('keydown', this._doKeyDown).
361
- unbind('keypress', this._doKeyPress).
362
- unbind('keyup', this._doKeyUp);
363
- } else if (nodeName == 'div' || nodeName == 'span')
353
+ unbind("focus", this._showDatepicker).
354
+ unbind("keydown", this._doKeyDown).
355
+ unbind("keypress", this._doKeyPress).
356
+ unbind("keyup", this._doKeyUp);
357
+ } else if (nodeName === "div" || nodeName === "span") {
364
358
  $target.removeClass(this.markerClassName).empty();
359
+ }
365
360
  },
366
361
 
367
362
  /* Enable the date picker to a jQuery selection.
368
- @param target element - the target input field or division or span */
363
+ * @param target element - the target input field or division or span
364
+ */
369
365
  _enableDatepicker: function(target) {
370
- var $target = $(target);
371
- var inst = $.data(target, PROP_NAME);
366
+ var nodeName, inline,
367
+ $target = $(target),
368
+ inst = $.data(target, PROP_NAME);
369
+
372
370
  if (!$target.hasClass(this.markerClassName)) {
373
371
  return;
374
372
  }
375
- var nodeName = target.nodeName.toLowerCase();
376
- if (nodeName == 'input') {
373
+
374
+ nodeName = target.nodeName.toLowerCase();
375
+ if (nodeName === "input") {
377
376
  target.disabled = false;
378
- inst.trigger.filter('button').
377
+ inst.trigger.filter("button").
379
378
  each(function() { this.disabled = false; }).end().
380
- filter('img').css({opacity: '1.0', cursor: ''});
381
- }
382
- else if (nodeName == 'div' || nodeName == 'span') {
383
- var inline = $target.children('.' + this._inlineClass);
384
- inline.children().removeClass('ui-state-disabled');
379
+ filter("img").css({opacity: "1.0", cursor: ""});
380
+ } else if (nodeName === "div" || nodeName === "span") {
381
+ inline = $target.children("." + this._inlineClass);
382
+ inline.children().removeClass("ui-state-disabled");
385
383
  inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
386
384
  prop("disabled", false);
387
385
  }
388
386
  this._disabledInputs = $.map(this._disabledInputs,
389
- function(value) { return (value == target ? null : value); }); // delete entry
387
+ function(value) { return (value === target ? null : value); }); // delete entry
390
388
  },
391
389
 
392
390
  /* Disable the date picker to a jQuery selection.
393
- @param target element - the target input field or division or span */
391
+ * @param target element - the target input field or division or span
392
+ */
394
393
  _disableDatepicker: function(target) {
395
- var $target = $(target);
396
- var inst = $.data(target, PROP_NAME);
394
+ var nodeName, inline,
395
+ $target = $(target),
396
+ inst = $.data(target, PROP_NAME);
397
+
397
398
  if (!$target.hasClass(this.markerClassName)) {
398
399
  return;
399
400
  }
400
- var nodeName = target.nodeName.toLowerCase();
401
- if (nodeName == 'input') {
401
+
402
+ nodeName = target.nodeName.toLowerCase();
403
+ if (nodeName === "input") {
402
404
  target.disabled = true;
403
- inst.trigger.filter('button').
405
+ inst.trigger.filter("button").
404
406
  each(function() { this.disabled = true; }).end().
405
- filter('img').css({opacity: '0.5', cursor: 'default'});
406
- }
407
- else if (nodeName == 'div' || nodeName == 'span') {
408
- var inline = $target.children('.' + this._inlineClass);
409
- inline.children().addClass('ui-state-disabled');
407
+ filter("img").css({opacity: "0.5", cursor: "default"});
408
+ } else if (nodeName === "div" || nodeName === "span") {
409
+ inline = $target.children("." + this._inlineClass);
410
+ inline.children().addClass("ui-state-disabled");
410
411
  inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
411
412
  prop("disabled", true);
412
413
  }
413
414
  this._disabledInputs = $.map(this._disabledInputs,
414
- function(value) { return (value == target ? null : value); }); // delete entry
415
+ function(value) { return (value === target ? null : value); }); // delete entry
415
416
  this._disabledInputs[this._disabledInputs.length] = target;
416
417
  },
417
418
 
418
419
  /* Is the first field in a jQuery collection disabled as a datepicker?
419
- @param target element - the target input field or division or span
420
- @return boolean - true if disabled, false if enabled */
420
+ * @param target element - the target input field or division or span
421
+ * @return boolean - true if disabled, false if enabled
422
+ */
421
423
  _isDisabledDatepicker: function(target) {
422
424
  if (!target) {
423
425
  return false;
424
426
  }
425
427
  for (var i = 0; i < this._disabledInputs.length; i++) {
426
- if (this._disabledInputs[i] == target)
428
+ if (this._disabledInputs[i] === target) {
427
429
  return true;
430
+ }
428
431
  }
429
432
  return false;
430
433
  },
431
434
 
432
435
  /* Retrieve the instance data for the target control.
433
- @param target element - the target input field or division or span
434
- @return object - the associated instance data
435
- @throws error if a jQuery problem getting data */
436
+ * @param target element - the target input field or division or span
437
+ * @return object - the associated instance data
438
+ * @throws error if a jQuery problem getting data
439
+ */
436
440
  _getInst: function(target) {
437
441
  try {
438
442
  return $.data(target, PROP_NAME);
439
443
  }
440
444
  catch (err) {
441
- throw 'Missing instance data for this datepicker';
445
+ throw "Missing instance data for this datepicker";
442
446
  }
443
447
  },
444
448
 
445
449
  /* Update or retrieve the settings for a date picker attached to an input field or division.
446
- @param target element - the target input field or division or span
447
- @param name object - the new settings to update or
448
- string - the name of the setting to change or retrieve,
449
- when retrieving also 'all' for all instance settings or
450
- 'defaults' for all global defaults
451
- @param value any - the new value for the setting
452
- (omit if above is an object or to retrieve a value) */
450
+ * @param target element - the target input field or division or span
451
+ * @param name object - the new settings to update or
452
+ * string - the name of the setting to change or retrieve,
453
+ * when retrieving also "all" for all instance settings or
454
+ * "defaults" for all global defaults
455
+ * @param value any - the new value for the setting
456
+ * (omit if above is an object or to retrieve a value)
457
+ */
453
458
  _optionDatepicker: function(target, name, value) {
454
- var inst = this._getInst(target);
455
- if (arguments.length == 2 && typeof name == 'string') {
456
- return (name == 'defaults' ? $.extend({}, $.datepicker._defaults) :
457
- (inst ? (name == 'all' ? $.extend({}, inst.settings) :
459
+ var settings, date, minDate, maxDate,
460
+ inst = this._getInst(target);
461
+
462
+ if (arguments.length === 2 && typeof name === "string") {
463
+ return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
464
+ (inst ? (name === "all" ? $.extend({}, inst.settings) :
458
465
  this._get(inst, name)) : null));
459
466
  }
460
- var settings = name || {};
461
- if (typeof name == 'string') {
467
+
468
+ settings = name || {};
469
+ if (typeof name === "string") {
462
470
  settings = {};
463
471
  settings[name] = value;
464
472
  }
473
+
465
474
  if (inst) {
466
- if (this._curInst == inst) {
475
+ if (this._curInst === inst) {
467
476
  this._hideDatepicker();
468
477
  }
469
- var date = this._getDateDatepicker(target, true);
470
- var minDate = this._getMinMaxDate(inst, 'min');
471
- var maxDate = this._getMinMaxDate(inst, 'max');
478
+
479
+ date = this._getDateDatepicker(target, true);
480
+ minDate = this._getMinMaxDate(inst, "min");
481
+ maxDate = this._getMinMaxDate(inst, "max");
472
482
  extendRemove(inst.settings, settings);
473
483
  // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
474
- if (minDate !== null && settings['dateFormat'] !== undefined && settings['minDate'] === undefined)
484
+ if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
475
485
  inst.settings.minDate = this._formatDate(inst, minDate);
476
- if (maxDate !== null && settings['dateFormat'] !== undefined && settings['maxDate'] === undefined)
486
+ }
487
+ if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
477
488
  inst.settings.maxDate = this._formatDate(inst, maxDate);
489
+ }
490
+ if ( "disabled" in settings ) {
491
+ if ( settings.disabled ) {
492
+ this._disableDatepicker(target);
493
+ } else {
494
+ this._enableDatepicker(target);
495
+ }
496
+ }
478
497
  this._attachments($(target), inst);
479
498
  this._autoSize(inst);
480
499
  this._setDate(inst, date);
@@ -489,7 +508,8 @@ $.extend(Datepicker.prototype, {
489
508
  },
490
509
 
491
510
  /* Redraw the date picker attached to an input field or division.
492
- @param target element - the target input field or division or span */
511
+ * @param target element - the target input field or division or span
512
+ */
493
513
  _refreshDatepicker: function(target) {
494
514
  var inst = this._getInst(target);
495
515
  if (inst) {
@@ -498,8 +518,9 @@ $.extend(Datepicker.prototype, {
498
518
  },
499
519
 
500
520
  /* Set the dates for a jQuery selection.
501
- @param target element - the target input field or division or span
502
- @param date Date - the new date */
521
+ * @param target element - the target input field or division or span
522
+ * @param date Date - the new date
523
+ */
503
524
  _setDateDatepicker: function(target, date) {
504
525
  var inst = this._getInst(target);
505
526
  if (inst) {
@@ -510,87 +531,110 @@ $.extend(Datepicker.prototype, {
510
531
  },
511
532
 
512
533
  /* Get the date(s) for the first entry in a jQuery selection.
513
- @param target element - the target input field or division or span
514
- @param noDefault boolean - true if no default date is to be used
515
- @return Date - the current date */
534
+ * @param target element - the target input field or division or span
535
+ * @param noDefault boolean - true if no default date is to be used
536
+ * @return Date - the current date
537
+ */
516
538
  _getDateDatepicker: function(target, noDefault) {
517
539
  var inst = this._getInst(target);
518
- if (inst && !inst.inline)
540
+ if (inst && !inst.inline) {
519
541
  this._setDateFromField(inst, noDefault);
542
+ }
520
543
  return (inst ? this._getDate(inst) : null);
521
544
  },
522
545
 
523
546
  /* Handle keystrokes. */
524
547
  _doKeyDown: function(event) {
525
- var inst = $.datepicker._getInst(event.target);
526
- var handled = true;
527
- var isRTL = inst.dpDiv.is('.ui-datepicker-rtl');
548
+ var onSelect, dateStr, sel,
549
+ inst = $.datepicker._getInst(event.target),
550
+ handled = true,
551
+ isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
552
+
528
553
  inst._keyEvent = true;
529
- if ($.datepicker._datepickerShowing)
554
+ if ($.datepicker._datepickerShowing) {
530
555
  switch (event.keyCode) {
531
556
  case 9: $.datepicker._hideDatepicker();
532
557
  handled = false;
533
558
  break; // hide on tab out
534
- case 13: var sel = $('td.' + $.datepicker._dayOverClass + ':not(.' +
535
- $.datepicker._currentClass + ')', inst.dpDiv);
536
- if (sel[0])
559
+ case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
560
+ $.datepicker._currentClass + ")", inst.dpDiv);
561
+ if (sel[0]) {
537
562
  $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
538
- var onSelect = $.datepicker._get(inst, 'onSelect');
539
- if (onSelect) {
540
- var dateStr = $.datepicker._formatDate(inst);
563
+ }
541
564
 
542
- // trigger custom callback
543
- onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
544
- }
545
- else
565
+ onSelect = $.datepicker._get(inst, "onSelect");
566
+ if (onSelect) {
567
+ dateStr = $.datepicker._formatDate(inst);
568
+
569
+ // trigger custom callback
570
+ onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
571
+ } else {
546
572
  $.datepicker._hideDatepicker();
573
+ }
574
+
547
575
  return false; // don't submit the form
548
- break; // select the value on enter
549
576
  case 27: $.datepicker._hideDatepicker();
550
577
  break; // hide on escape
551
578
  case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
552
- -$.datepicker._get(inst, 'stepBigMonths') :
553
- -$.datepicker._get(inst, 'stepMonths')), 'M');
579
+ -$.datepicker._get(inst, "stepBigMonths") :
580
+ -$.datepicker._get(inst, "stepMonths")), "M");
554
581
  break; // previous month/year on page up/+ ctrl
555
582
  case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
556
- +$.datepicker._get(inst, 'stepBigMonths') :
557
- +$.datepicker._get(inst, 'stepMonths')), 'M');
583
+ +$.datepicker._get(inst, "stepBigMonths") :
584
+ +$.datepicker._get(inst, "stepMonths")), "M");
558
585
  break; // next month/year on page down/+ ctrl
559
- case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target);
586
+ case 35: if (event.ctrlKey || event.metaKey) {
587
+ $.datepicker._clearDate(event.target);
588
+ }
560
589
  handled = event.ctrlKey || event.metaKey;
561
590
  break; // clear on ctrl or command +end
562
- case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target);
591
+ case 36: if (event.ctrlKey || event.metaKey) {
592
+ $.datepicker._gotoToday(event.target);
593
+ }
563
594
  handled = event.ctrlKey || event.metaKey;
564
595
  break; // current on ctrl or command +home
565
- case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D');
596
+ case 37: if (event.ctrlKey || event.metaKey) {
597
+ $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
598
+ }
566
599
  handled = event.ctrlKey || event.metaKey;
567
600
  // -1 day on ctrl or command +left
568
- if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
569
- -$.datepicker._get(inst, 'stepBigMonths') :
570
- -$.datepicker._get(inst, 'stepMonths')), 'M');
601
+ if (event.originalEvent.altKey) {
602
+ $.datepicker._adjustDate(event.target, (event.ctrlKey ?
603
+ -$.datepicker._get(inst, "stepBigMonths") :
604
+ -$.datepicker._get(inst, "stepMonths")), "M");
605
+ }
571
606
  // next month/year on alt +left on Mac
572
607
  break;
573
- case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D');
608
+ case 38: if (event.ctrlKey || event.metaKey) {
609
+ $.datepicker._adjustDate(event.target, -7, "D");
610
+ }
574
611
  handled = event.ctrlKey || event.metaKey;
575
612
  break; // -1 week on ctrl or command +up
576
- case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D');
613
+ case 39: if (event.ctrlKey || event.metaKey) {
614
+ $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
615
+ }
577
616
  handled = event.ctrlKey || event.metaKey;
578
617
  // +1 day on ctrl or command +right
579
- if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
580
- +$.datepicker._get(inst, 'stepBigMonths') :
581
- +$.datepicker._get(inst, 'stepMonths')), 'M');
618
+ if (event.originalEvent.altKey) {
619
+ $.datepicker._adjustDate(event.target, (event.ctrlKey ?
620
+ +$.datepicker._get(inst, "stepBigMonths") :
621
+ +$.datepicker._get(inst, "stepMonths")), "M");
622
+ }
582
623
  // next month/year on alt +right
583
624
  break;
584
- case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D');
625
+ case 40: if (event.ctrlKey || event.metaKey) {
626
+ $.datepicker._adjustDate(event.target, +7, "D");
627
+ }
585
628
  handled = event.ctrlKey || event.metaKey;
586
629
  break; // +1 week on ctrl or command +down
587
630
  default: handled = false;
588
631
  }
589
- else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home
632
+ } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
590
633
  $.datepicker._showDatepicker(this);
591
- else {
634
+ } else {
592
635
  handled = false;
593
636
  }
637
+
594
638
  if (handled) {
595
639
  event.preventDefault();
596
640
  event.stopPropagation();
@@ -599,22 +643,27 @@ $.extend(Datepicker.prototype, {
599
643
 
600
644
  /* Filter entered characters - based on date format. */
601
645
  _doKeyPress: function(event) {
602
- var inst = $.datepicker._getInst(event.target);
603
- if ($.datepicker._get(inst, 'constrainInput')) {
604
- var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
605
- var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode);
606
- return event.ctrlKey || event.metaKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
646
+ var chars, chr,
647
+ inst = $.datepicker._getInst(event.target);
648
+
649
+ if ($.datepicker._get(inst, "constrainInput")) {
650
+ chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
651
+ chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
652
+ return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
607
653
  }
608
654
  },
609
655
 
610
656
  /* Synchronise manual entry and field/alternate field. */
611
657
  _doKeyUp: function(event) {
612
- var inst = $.datepicker._getInst(event.target);
613
- if (inst.input.val() != inst.lastVal) {
658
+ var date,
659
+ inst = $.datepicker._getInst(event.target);
660
+
661
+ if (inst.input.val() !== inst.lastVal) {
614
662
  try {
615
- var date = $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
663
+ date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
616
664
  (inst.input ? inst.input.val() : null),
617
665
  $.datepicker._getFormatConfig(inst));
666
+
618
667
  if (date) { // only if valid
619
668
  $.datepicker._setDateFromField(inst);
620
669
  $.datepicker._updateAlternate(inst);
@@ -622,86 +671,91 @@ $.extend(Datepicker.prototype, {
622
671
  }
623
672
  }
624
673
  catch (err) {
625
- $.datepicker.log(err);
626
674
  }
627
675
  }
628
676
  return true;
629
677
  },
630
678
 
631
679
  /* Pop-up the date picker for a given input field.
632
- If false returned from beforeShow event handler do not show.
633
- @param input element - the input field attached to the date picker or
634
- event - if triggered by focus */
680
+ * If false returned from beforeShow event handler do not show.
681
+ * @param input element - the input field attached to the date picker or
682
+ * event - if triggered by focus
683
+ */
635
684
  _showDatepicker: function(input) {
636
685
  input = input.target || input;
637
- if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger
638
- input = $('input', input.parentNode)[0];
639
- if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here
686
+ if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
687
+ input = $("input", input.parentNode)[0];
688
+ }
689
+
690
+ if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
640
691
  return;
641
- var inst = $.datepicker._getInst(input);
642
- if ($.datepicker._curInst && $.datepicker._curInst != inst) {
692
+ }
693
+
694
+ var inst, beforeShow, beforeShowSettings, isFixed,
695
+ offset, showAnim, duration;
696
+
697
+ inst = $.datepicker._getInst(input);
698
+ if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
643
699
  $.datepicker._curInst.dpDiv.stop(true, true);
644
700
  if ( inst && $.datepicker._datepickerShowing ) {
645
701
  $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
646
702
  }
647
703
  }
648
- var beforeShow = $.datepicker._get(inst, 'beforeShow');
649
- var beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
704
+
705
+ beforeShow = $.datepicker._get(inst, "beforeShow");
706
+ beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
650
707
  if(beforeShowSettings === false){
651
- //false
652
708
  return;
653
709
  }
654
710
  extendRemove(inst.settings, beforeShowSettings);
711
+
655
712
  inst.lastVal = null;
656
713
  $.datepicker._lastInput = input;
657
714
  $.datepicker._setDateFromField(inst);
658
- if ($.datepicker._inDialog) // hide cursor
659
- input.value = '';
715
+
716
+ if ($.datepicker._inDialog) { // hide cursor
717
+ input.value = "";
718
+ }
660
719
  if (!$.datepicker._pos) { // position below input
661
720
  $.datepicker._pos = $.datepicker._findPos(input);
662
721
  $.datepicker._pos[1] += input.offsetHeight; // add the height
663
722
  }
664
- var isFixed = false;
723
+
724
+ isFixed = false;
665
725
  $(input).parents().each(function() {
666
- isFixed |= $(this).css('position') == 'fixed';
726
+ isFixed |= $(this).css("position") === "fixed";
667
727
  return !isFixed;
668
728
  });
669
- var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
729
+
730
+ offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
670
731
  $.datepicker._pos = null;
671
732
  //to avoid flashes on Firefox
672
733
  inst.dpDiv.empty();
673
734
  // determine sizing offscreen
674
- inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
735
+ inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
675
736
  $.datepicker._updateDatepicker(inst);
676
737
  // fix width for dynamic number of date pickers
677
738
  // and adjust position before showing
678
739
  offset = $.datepicker._checkOffset(inst, offset, isFixed);
679
740
  inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
680
- 'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
681
- left: offset.left + 'px', top: offset.top + 'px'});
741
+ "static" : (isFixed ? "fixed" : "absolute")), display: "none",
742
+ left: offset.left + "px", top: offset.top + "px"});
743
+
682
744
  if (!inst.inline) {
683
- var showAnim = $.datepicker._get(inst, 'showAnim');
684
- var duration = $.datepicker._get(inst, 'duration');
685
- var postProcess = function() {
686
- var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
687
- if( !! cover.length ){
688
- var borders = $.datepicker._getBorders(inst.dpDiv);
689
- cover.css({left: -borders[0], top: -borders[1],
690
- width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()});
691
- }
692
- };
745
+ showAnim = $.datepicker._get(inst, "showAnim");
746
+ duration = $.datepicker._get(inst, "duration");
693
747
  inst.dpDiv.zIndex($(input).zIndex()+1);
694
748
  $.datepicker._datepickerShowing = true;
695
749
 
696
- // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
697
- if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) )
698
- inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
699
- else
700
- inst.dpDiv[showAnim || 'show']((showAnim ? duration : null), postProcess);
701
- if (!showAnim || !duration)
702
- postProcess();
703
- if (inst.input.is(':visible') && !inst.input.is(':disabled'))
750
+ if ( $.effects && $.effects.effect[ showAnim ] ) {
751
+ inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
752
+ } else {
753
+ inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
754
+ }
755
+
756
+ if (inst.input.is(":visible") && !inst.input.is(":disabled")) {
704
757
  inst.input.focus();
758
+ }
705
759
  $.datepicker._curInst = inst;
706
760
  }
707
761
  },
@@ -709,37 +763,39 @@ $.extend(Datepicker.prototype, {
709
763
  /* Generate the date picker content. */
710
764
  _updateDatepicker: function(inst) {
711
765
  this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
712
- var borders = $.datepicker._getBorders(inst.dpDiv);
713
766
  instActive = inst; // for delegate hover events
714
767
  inst.dpDiv.empty().append(this._generateHTML(inst));
715
768
  this._attachHandlers(inst);
716
- var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
717
- if( !!cover.length ){ //avoid call to outerXXXX() when not in IE6
718
- cover.css({left: -borders[0], top: -borders[1], width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()})
719
- }
720
- inst.dpDiv.find('.' + this._dayOverClass + ' a').mouseover();
721
- var numMonths = this._getNumberOfMonths(inst);
722
- var cols = numMonths[1];
723
- var width = 17;
724
- inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width('');
725
- if (cols > 1)
726
- inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em');
727
- inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') +
728
- 'Class']('ui-datepicker-multi');
729
- inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') +
730
- 'Class']('ui-datepicker-rtl');
731
- if (inst == $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
732
- // #6694 - don't focus the input if it's already focused
733
- // this breaks the change event in IE
734
- inst.input.is(':visible') && !inst.input.is(':disabled') && inst.input[0] != document.activeElement)
769
+ inst.dpDiv.find("." + this._dayOverClass + " a").mouseover();
770
+
771
+ var origyearshtml,
772
+ numMonths = this._getNumberOfMonths(inst),
773
+ cols = numMonths[1],
774
+ width = 17;
775
+
776
+ inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
777
+ if (cols > 1) {
778
+ inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
779
+ }
780
+ inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
781
+ "Class"]("ui-datepicker-multi");
782
+ inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
783
+ "Class"]("ui-datepicker-rtl");
784
+
785
+ // #6694 - don't focus the input if it's already focused
786
+ // this breaks the change event in IE
787
+ if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
788
+ inst.input.is(":visible") && !inst.input.is(":disabled") && inst.input[0] !== document.activeElement) {
735
789
  inst.input.focus();
790
+ }
791
+
736
792
  // deffered render of the years select (to avoid flashes on Firefox)
737
793
  if( inst.yearshtml ){
738
- var origyearshtml = inst.yearshtml;
794
+ origyearshtml = inst.yearshtml;
739
795
  setTimeout(function(){
740
796
  //assure that inst.yearshtml didn't change.
741
797
  if( origyearshtml === inst.yearshtml && inst.yearshtml ){
742
- inst.dpDiv.find('select.ui-datepicker-year:first').replaceWith(inst.yearshtml);
798
+ inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
743
799
  }
744
800
  origyearshtml = inst.yearshtml = null;
745
801
  }, 0);
@@ -747,28 +803,29 @@ $.extend(Datepicker.prototype, {
747
803
  },
748
804
 
749
805
  /* Retrieve the size of left and top borders for an element.
750
- @param elem (jQuery object) the element of interest
751
- @return (number[2]) the left and top borders */
806
+ * @param elem (jQuery object) the element of interest
807
+ * @return (number[2]) the left and top borders
808
+ */
752
809
  _getBorders: function(elem) {
753
810
  var convert = function(value) {
754
811
  return {thin: 1, medium: 2, thick: 3}[value] || value;
755
812
  };
756
- return [parseFloat(convert(elem.css('border-left-width'))),
757
- parseFloat(convert(elem.css('border-top-width')))];
813
+ return [parseFloat(convert(elem.css("border-left-width"))),
814
+ parseFloat(convert(elem.css("border-top-width")))];
758
815
  },
759
816
 
760
817
  /* Check positioning to remain on screen. */
761
818
  _checkOffset: function(inst, offset, isFixed) {
762
- var dpWidth = inst.dpDiv.outerWidth();
763
- var dpHeight = inst.dpDiv.outerHeight();
764
- var inputWidth = inst.input ? inst.input.outerWidth() : 0;
765
- var inputHeight = inst.input ? inst.input.outerHeight() : 0;
766
- var viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft());
767
- var viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
819
+ var dpWidth = inst.dpDiv.outerWidth(),
820
+ dpHeight = inst.dpDiv.outerHeight(),
821
+ inputWidth = inst.input ? inst.input.outerWidth() : 0,
822
+ inputHeight = inst.input ? inst.input.outerHeight() : 0,
823
+ viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
824
+ viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
768
825
 
769
- offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0);
770
- offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0;
771
- offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
826
+ offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
827
+ offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
828
+ offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
772
829
 
773
830
  // now check if datepicker is showing outside window viewport - move to a better place if so.
774
831
  offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
@@ -781,47 +838,60 @@ $.extend(Datepicker.prototype, {
781
838
 
782
839
  /* Find an object's position on the screen. */
783
840
  _findPos: function(obj) {
784
- var inst = this._getInst(obj);
785
- var isRTL = this._get(inst, 'isRTL');
786
- while (obj && (obj.type == 'hidden' || obj.nodeType != 1 || $.expr.filters.hidden(obj))) {
787
- obj = obj[isRTL ? 'previousSibling' : 'nextSibling'];
841
+ var position,
842
+ inst = this._getInst(obj),
843
+ isRTL = this._get(inst, "isRTL");
844
+
845
+ while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
846
+ obj = obj[isRTL ? "previousSibling" : "nextSibling"];
788
847
  }
789
- var position = $(obj).offset();
848
+
849
+ position = $(obj).offset();
790
850
  return [position.left, position.top];
791
851
  },
792
852
 
793
853
  /* Hide the date picker from view.
794
- @param input element - the input field attached to the date picker */
854
+ * @param input element - the input field attached to the date picker
855
+ */
795
856
  _hideDatepicker: function(input) {
796
- var inst = this._curInst;
797
- if (!inst || (input && inst != $.data(input, PROP_NAME)))
857
+ var showAnim, duration, postProcess, onClose,
858
+ inst = this._curInst;
859
+
860
+ if (!inst || (input && inst !== $.data(input, PROP_NAME))) {
798
861
  return;
862
+ }
863
+
799
864
  if (this._datepickerShowing) {
800
- var showAnim = this._get(inst, 'showAnim');
801
- var duration = this._get(inst, 'duration');
802
- var postProcess = function() {
865
+ showAnim = this._get(inst, "showAnim");
866
+ duration = this._get(inst, "duration");
867
+ postProcess = function() {
803
868
  $.datepicker._tidyDialog(inst);
804
869
  };
805
870
 
806
871
  // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
807
- if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) )
808
- inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
809
- else
810
- inst.dpDiv[(showAnim == 'slideDown' ? 'slideUp' :
811
- (showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
812
- if (!showAnim)
872
+ if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
873
+ inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
874
+ } else {
875
+ inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
876
+ (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
877
+ }
878
+
879
+ if (!showAnim) {
813
880
  postProcess();
881
+ }
814
882
  this._datepickerShowing = false;
815
- var onClose = this._get(inst, 'onClose');
816
- if (onClose)
817
- onClose.apply((inst.input ? inst.input[0] : null),
818
- [(inst.input ? inst.input.val() : ''), inst]);
883
+
884
+ onClose = this._get(inst, "onClose");
885
+ if (onClose) {
886
+ onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
887
+ }
888
+
819
889
  this._lastInput = null;
820
890
  if (this._inDialog) {
821
- this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
891
+ this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
822
892
  if ($.blockUI) {
823
893
  $.unblockUI();
824
- $('body').append(this.dpDiv);
894
+ $("body").append(this.dpDiv);
825
895
  }
826
896
  }
827
897
  this._inDialog = false;
@@ -830,50 +900,54 @@ $.extend(Datepicker.prototype, {
830
900
 
831
901
  /* Tidy up after a dialog display. */
832
902
  _tidyDialog: function(inst) {
833
- inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar');
903
+ inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
834
904
  },
835
905
 
836
906
  /* Close date picker if clicked elsewhere. */
837
907
  _checkExternalClick: function(event) {
838
- if (!$.datepicker._curInst)
908
+ if (!$.datepicker._curInst) {
839
909
  return;
910
+ }
840
911
 
841
912
  var $target = $(event.target),
842
913
  inst = $.datepicker._getInst($target[0]);
843
914
 
844
- if ( ( ( $target[0].id != $.datepicker._mainDivId &&
845
- $target.parents('#' + $.datepicker._mainDivId).length == 0 &&
915
+ if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
916
+ $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
846
917
  !$target.hasClass($.datepicker.markerClassName) &&
847
918
  !$target.closest("." + $.datepicker._triggerClass).length &&
848
919
  $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
849
- ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst != inst ) )
850
- $.datepicker._hideDatepicker();
920
+ ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
921
+ $.datepicker._hideDatepicker();
922
+ }
851
923
  },
852
924
 
853
925
  /* Adjust one of the date sub-fields. */
854
926
  _adjustDate: function(id, offset, period) {
855
- var target = $(id);
856
- var inst = this._getInst(target[0]);
927
+ var target = $(id),
928
+ inst = this._getInst(target[0]);
929
+
857
930
  if (this._isDisabledDatepicker(target[0])) {
858
931
  return;
859
932
  }
860
933
  this._adjustInstDate(inst, offset +
861
- (period == 'M' ? this._get(inst, 'showCurrentAtPos') : 0), // undo positioning
934
+ (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
862
935
  period);
863
936
  this._updateDatepicker(inst);
864
937
  },
865
938
 
866
939
  /* Action for current link. */
867
940
  _gotoToday: function(id) {
868
- var target = $(id);
869
- var inst = this._getInst(target[0]);
870
- if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
941
+ var date,
942
+ target = $(id),
943
+ inst = this._getInst(target[0]);
944
+
945
+ if (this._get(inst, "gotoCurrent") && inst.currentDay) {
871
946
  inst.selectedDay = inst.currentDay;
872
947
  inst.drawMonth = inst.selectedMonth = inst.currentMonth;
873
948
  inst.drawYear = inst.selectedYear = inst.currentYear;
874
- }
875
- else {
876
- var date = new Date();
949
+ } else {
950
+ date = new Date();
877
951
  inst.selectedDay = date.getDate();
878
952
  inst.drawMonth = inst.selectedMonth = date.getMonth();
879
953
  inst.drawYear = inst.selectedYear = date.getFullYear();
@@ -884,23 +958,28 @@ $.extend(Datepicker.prototype, {
884
958
 
885
959
  /* Action for selecting a new month/year. */
886
960
  _selectMonthYear: function(id, select, period) {
887
- var target = $(id);
888
- var inst = this._getInst(target[0]);
889
- inst['selected' + (period == 'M' ? 'Month' : 'Year')] =
890
- inst['draw' + (period == 'M' ? 'Month' : 'Year')] =
961
+ var target = $(id),
962
+ inst = this._getInst(target[0]);
963
+
964
+ inst["selected" + (period === "M" ? "Month" : "Year")] =
965
+ inst["draw" + (period === "M" ? "Month" : "Year")] =
891
966
  parseInt(select.options[select.selectedIndex].value,10);
967
+
892
968
  this._notifyChange(inst);
893
969
  this._adjustDate(target);
894
970
  },
895
971
 
896
972
  /* Action for selecting a day. */
897
973
  _selectDay: function(id, month, year, td) {
898
- var target = $(id);
974
+ var inst,
975
+ target = $(id);
976
+
899
977
  if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
900
978
  return;
901
979
  }
902
- var inst = this._getInst(target[0]);
903
- inst.selectedDay = inst.currentDay = $('a', td).html();
980
+
981
+ inst = this._getInst(target[0]);
982
+ inst.selectedDay = inst.currentDay = $("a", td).html();
904
983
  inst.selectedMonth = inst.currentMonth = month;
905
984
  inst.selectedYear = inst.currentYear = year;
906
985
  this._selectDate(id, this._formatDate(inst,
@@ -910,372 +989,427 @@ $.extend(Datepicker.prototype, {
910
989
  /* Erase the input field and hide the date picker. */
911
990
  _clearDate: function(id) {
912
991
  var target = $(id);
913
- var inst = this._getInst(target[0]);
914
- this._selectDate(target, '');
992
+ this._selectDate(target, "");
915
993
  },
916
994
 
917
995
  /* Update the input field with the selected date. */
918
996
  _selectDate: function(id, dateStr) {
919
- var target = $(id);
920
- var inst = this._getInst(target[0]);
997
+ var onSelect,
998
+ target = $(id),
999
+ inst = this._getInst(target[0]);
1000
+
921
1001
  dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
922
- if (inst.input)
1002
+ if (inst.input) {
923
1003
  inst.input.val(dateStr);
1004
+ }
924
1005
  this._updateAlternate(inst);
925
- var onSelect = this._get(inst, 'onSelect');
926
- if (onSelect)
1006
+
1007
+ onSelect = this._get(inst, "onSelect");
1008
+ if (onSelect) {
927
1009
  onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
928
- else if (inst.input)
929
- inst.input.trigger('change'); // fire the change event
930
- if (inst.inline)
1010
+ } else if (inst.input) {
1011
+ inst.input.trigger("change"); // fire the change event
1012
+ }
1013
+
1014
+ if (inst.inline){
931
1015
  this._updateDatepicker(inst);
932
- else {
1016
+ } else {
933
1017
  this._hideDatepicker();
934
1018
  this._lastInput = inst.input[0];
935
- if (typeof(inst.input[0]) != 'object')
1019
+ if (typeof(inst.input[0]) !== "object") {
936
1020
  inst.input.focus(); // restore focus
1021
+ }
937
1022
  this._lastInput = null;
938
1023
  }
939
1024
  },
940
1025
 
941
1026
  /* Update any alternate field to synchronise with the main field. */
942
1027
  _updateAlternate: function(inst) {
943
- var altField = this._get(inst, 'altField');
1028
+ var altFormat, date, dateStr,
1029
+ altField = this._get(inst, "altField");
1030
+
944
1031
  if (altField) { // update alternate field too
945
- var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat');
946
- var date = this._getDate(inst);
947
- var dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
1032
+ altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
1033
+ date = this._getDate(inst);
1034
+ dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
948
1035
  $(altField).each(function() { $(this).val(dateStr); });
949
1036
  }
950
1037
  },
951
1038
 
952
1039
  /* Set as beforeShowDay function to prevent selection of weekends.
953
- @param date Date - the date to customise
954
- @return [boolean, string] - is this date selectable?, what is its CSS class? */
1040
+ * @param date Date - the date to customise
1041
+ * @return [boolean, string] - is this date selectable?, what is its CSS class?
1042
+ */
955
1043
  noWeekends: function(date) {
956
1044
  var day = date.getDay();
957
- return [(day > 0 && day < 6), ''];
1045
+ return [(day > 0 && day < 6), ""];
958
1046
  },
959
1047
 
960
1048
  /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
961
- @param date Date - the date to get the week for
962
- @return number - the number of the week within the year that contains this date */
1049
+ * @param date Date - the date to get the week for
1050
+ * @return number - the number of the week within the year that contains this date
1051
+ */
963
1052
  iso8601Week: function(date) {
964
- var checkDate = new Date(date.getTime());
1053
+ var time,
1054
+ checkDate = new Date(date.getTime());
1055
+
965
1056
  // Find Thursday of this week starting on Monday
966
1057
  checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
967
- var time = checkDate.getTime();
1058
+
1059
+ time = checkDate.getTime();
968
1060
  checkDate.setMonth(0); // Compare with Jan 1
969
1061
  checkDate.setDate(1);
970
1062
  return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
971
1063
  },
972
1064
 
973
1065
  /* Parse a string value into a date object.
974
- See formatDate below for the possible formats.
975
-
976
- @param format string - the expected format of the date
977
- @param value string - the date in the above format
978
- @param settings Object - attributes include:
979
- shortYearCutoff number - the cutoff year for determining the century (optional)
980
- dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
981
- dayNames string[7] - names of the days from Sunday (optional)
982
- monthNamesShort string[12] - abbreviated names of the months (optional)
983
- monthNames string[12] - names of the months (optional)
984
- @return Date - the extracted date value or null if value is blank */
1066
+ * See formatDate below for the possible formats.
1067
+ *
1068
+ * @param format string - the expected format of the date
1069
+ * @param value string - the date in the above format
1070
+ * @param settings Object - attributes include:
1071
+ * shortYearCutoff number - the cutoff year for determining the century (optional)
1072
+ * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
1073
+ * dayNames string[7] - names of the days from Sunday (optional)
1074
+ * monthNamesShort string[12] - abbreviated names of the months (optional)
1075
+ * monthNames string[12] - names of the months (optional)
1076
+ * @return Date - the extracted date value or null if value is blank
1077
+ */
985
1078
  parseDate: function (format, value, settings) {
986
- if (format == null || value == null)
987
- throw 'Invalid arguments';
988
- value = (typeof value == 'object' ? value.toString() : value + '');
989
- if (value == '')
1079
+ if (format == null || value == null) {
1080
+ throw "Invalid arguments";
1081
+ }
1082
+
1083
+ value = (typeof value === "object" ? value.toString() : value + "");
1084
+ if (value === "") {
990
1085
  return null;
991
- var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff;
992
- shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
993
- new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
994
- var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
995
- var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
996
- var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
997
- var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
998
- var year = -1;
999
- var month = -1;
1000
- var day = -1;
1001
- var doy = -1;
1002
- var literal = false;
1003
- // Check whether a format character is doubled
1004
- var lookAhead = function(match) {
1005
- var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
1006
- if (matches)
1007
- iFormat++;
1008
- return matches;
1009
- };
1010
- // Extract a number from the string value
1011
- var getNumber = function(match) {
1012
- var isDoubled = lookAhead(match);
1013
- var size = (match == '@' ? 14 : (match == '!' ? 20 :
1014
- (match == 'y' && isDoubled ? 4 : (match == 'o' ? 3 : 2))));
1015
- var digits = new RegExp('^\\d{1,' + size + '}');
1016
- var num = value.substring(iValue).match(digits);
1017
- if (!num)
1018
- throw 'Missing number at position ' + iValue;
1019
- iValue += num[0].length;
1020
- return parseInt(num[0], 10);
1021
- };
1022
- // Extract a name from the string value and convert to an index
1023
- var getName = function(match, shortNames, longNames) {
1024
- var names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
1025
- return [ [k, v] ];
1026
- }).sort(function (a, b) {
1027
- return -(a[1].length - b[1].length);
1028
- });
1029
- var index = -1;
1030
- $.each(names, function (i, pair) {
1031
- var name = pair[1];
1032
- if (value.substr(iValue, name.length).toLowerCase() == name.toLowerCase()) {
1033
- index = pair[0];
1034
- iValue += name.length;
1035
- return false;
1086
+ }
1087
+
1088
+ var iFormat, dim, extra,
1089
+ iValue = 0,
1090
+ shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
1091
+ shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
1092
+ new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
1093
+ dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
1094
+ dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
1095
+ monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
1096
+ monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
1097
+ year = -1,
1098
+ month = -1,
1099
+ day = -1,
1100
+ doy = -1,
1101
+ literal = false,
1102
+ date,
1103
+ // Check whether a format character is doubled
1104
+ lookAhead = function(match) {
1105
+ var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
1106
+ if (matches) {
1107
+ iFormat++;
1036
1108
  }
1037
- });
1038
- if (index != -1)
1039
- return index + 1;
1040
- else
1041
- throw 'Unknown name at position ' + iValue;
1042
- };
1043
- // Confirm that a literal character matches the string value
1044
- var checkLiteral = function() {
1045
- if (value.charAt(iValue) != format.charAt(iFormat))
1046
- throw 'Unexpected literal at position ' + iValue;
1047
- iValue++;
1048
- };
1049
- var iValue = 0;
1050
- for (var iFormat = 0; iFormat < format.length; iFormat++) {
1051
- if (literal)
1052
- if (format.charAt(iFormat) == "'" && !lookAhead("'"))
1109
+ return matches;
1110
+ },
1111
+ // Extract a number from the string value
1112
+ getNumber = function(match) {
1113
+ var isDoubled = lookAhead(match),
1114
+ size = (match === "@" ? 14 : (match === "!" ? 20 :
1115
+ (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
1116
+ digits = new RegExp("^\\d{1," + size + "}"),
1117
+ num = value.substring(iValue).match(digits);
1118
+ if (!num) {
1119
+ throw "Missing number at position " + iValue;
1120
+ }
1121
+ iValue += num[0].length;
1122
+ return parseInt(num[0], 10);
1123
+ },
1124
+ // Extract a name from the string value and convert to an index
1125
+ getName = function(match, shortNames, longNames) {
1126
+ var index = -1,
1127
+ names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
1128
+ return [ [k, v] ];
1129
+ }).sort(function (a, b) {
1130
+ return -(a[1].length - b[1].length);
1131
+ });
1132
+
1133
+ $.each(names, function (i, pair) {
1134
+ var name = pair[1];
1135
+ if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
1136
+ index = pair[0];
1137
+ iValue += name.length;
1138
+ return false;
1139
+ }
1140
+ });
1141
+ if (index !== -1) {
1142
+ return index + 1;
1143
+ } else {
1144
+ throw "Unknown name at position " + iValue;
1145
+ }
1146
+ },
1147
+ // Confirm that a literal character matches the string value
1148
+ checkLiteral = function() {
1149
+ if (value.charAt(iValue) !== format.charAt(iFormat)) {
1150
+ throw "Unexpected literal at position " + iValue;
1151
+ }
1152
+ iValue++;
1153
+ };
1154
+
1155
+ for (iFormat = 0; iFormat < format.length; iFormat++) {
1156
+ if (literal) {
1157
+ if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
1053
1158
  literal = false;
1054
- else
1159
+ } else {
1055
1160
  checkLiteral();
1056
- else
1161
+ }
1162
+ } else {
1057
1163
  switch (format.charAt(iFormat)) {
1058
- case 'd':
1059
- day = getNumber('d');
1164
+ case "d":
1165
+ day = getNumber("d");
1060
1166
  break;
1061
- case 'D':
1062
- getName('D', dayNamesShort, dayNames);
1167
+ case "D":
1168
+ getName("D", dayNamesShort, dayNames);
1063
1169
  break;
1064
- case 'o':
1065
- doy = getNumber('o');
1170
+ case "o":
1171
+ doy = getNumber("o");
1066
1172
  break;
1067
- case 'm':
1068
- month = getNumber('m');
1173
+ case "m":
1174
+ month = getNumber("m");
1069
1175
  break;
1070
- case 'M':
1071
- month = getName('M', monthNamesShort, monthNames);
1176
+ case "M":
1177
+ month = getName("M", monthNamesShort, monthNames);
1072
1178
  break;
1073
- case 'y':
1074
- year = getNumber('y');
1179
+ case "y":
1180
+ year = getNumber("y");
1075
1181
  break;
1076
- case '@':
1077
- var date = new Date(getNumber('@'));
1182
+ case "@":
1183
+ date = new Date(getNumber("@"));
1078
1184
  year = date.getFullYear();
1079
1185
  month = date.getMonth() + 1;
1080
1186
  day = date.getDate();
1081
1187
  break;
1082
- case '!':
1083
- var date = new Date((getNumber('!') - this._ticksTo1970) / 10000);
1188
+ case "!":
1189
+ date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
1084
1190
  year = date.getFullYear();
1085
1191
  month = date.getMonth() + 1;
1086
1192
  day = date.getDate();
1087
1193
  break;
1088
1194
  case "'":
1089
- if (lookAhead("'"))
1195
+ if (lookAhead("'")){
1090
1196
  checkLiteral();
1091
- else
1197
+ } else {
1092
1198
  literal = true;
1199
+ }
1093
1200
  break;
1094
1201
  default:
1095
1202
  checkLiteral();
1096
1203
  }
1204
+ }
1097
1205
  }
1206
+
1098
1207
  if (iValue < value.length){
1099
- var extra = value.substr(iValue);
1208
+ extra = value.substr(iValue);
1100
1209
  if (!/^\s+/.test(extra)) {
1101
1210
  throw "Extra/unparsed characters found in date: " + extra;
1102
1211
  }
1103
1212
  }
1104
- if (year == -1)
1213
+
1214
+ if (year === -1) {
1105
1215
  year = new Date().getFullYear();
1106
- else if (year < 100)
1216
+ } else if (year < 100) {
1107
1217
  year += new Date().getFullYear() - new Date().getFullYear() % 100 +
1108
1218
  (year <= shortYearCutoff ? 0 : -100);
1219
+ }
1220
+
1109
1221
  if (doy > -1) {
1110
1222
  month = 1;
1111
1223
  day = doy;
1112
1224
  do {
1113
- var dim = this._getDaysInMonth(year, month - 1);
1114
- if (day <= dim)
1225
+ dim = this._getDaysInMonth(year, month - 1);
1226
+ if (day <= dim) {
1115
1227
  break;
1228
+ }
1116
1229
  month++;
1117
1230
  day -= dim;
1118
1231
  } while (true);
1119
1232
  }
1120
- var date = this._daylightSavingAdjust(new Date(year, month - 1, day));
1121
- if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day)
1122
- throw 'Invalid date'; // E.g. 31/02/00
1233
+
1234
+ date = this._daylightSavingAdjust(new Date(year, month - 1, day));
1235
+ if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
1236
+ throw "Invalid date"; // E.g. 31/02/00
1237
+ }
1123
1238
  return date;
1124
1239
  },
1125
1240
 
1126
1241
  /* Standard date formats. */
1127
- ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601)
1128
- COOKIE: 'D, dd M yy',
1129
- ISO_8601: 'yy-mm-dd',
1130
- RFC_822: 'D, d M y',
1131
- RFC_850: 'DD, dd-M-y',
1132
- RFC_1036: 'D, d M y',
1133
- RFC_1123: 'D, d M yy',
1134
- RFC_2822: 'D, d M yy',
1135
- RSS: 'D, d M y', // RFC 822
1136
- TICKS: '!',
1137
- TIMESTAMP: '@',
1138
- W3C: 'yy-mm-dd', // ISO 8601
1242
+ ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
1243
+ COOKIE: "D, dd M yy",
1244
+ ISO_8601: "yy-mm-dd",
1245
+ RFC_822: "D, d M y",
1246
+ RFC_850: "DD, dd-M-y",
1247
+ RFC_1036: "D, d M y",
1248
+ RFC_1123: "D, d M yy",
1249
+ RFC_2822: "D, d M yy",
1250
+ RSS: "D, d M y", // RFC 822
1251
+ TICKS: "!",
1252
+ TIMESTAMP: "@",
1253
+ W3C: "yy-mm-dd", // ISO 8601
1139
1254
 
1140
1255
  _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
1141
1256
  Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
1142
1257
 
1143
1258
  /* Format a date object into a string value.
1144
- The format can be combinations of the following:
1145
- d - day of month (no leading zero)
1146
- dd - day of month (two digit)
1147
- o - day of year (no leading zeros)
1148
- oo - day of year (three digit)
1149
- D - day name short
1150
- DD - day name long
1151
- m - month of year (no leading zero)
1152
- mm - month of year (two digit)
1153
- M - month name short
1154
- MM - month name long
1155
- y - year (two digit)
1156
- yy - year (four digit)
1157
- @ - Unix timestamp (ms since 01/01/1970)
1158
- ! - Windows ticks (100ns since 01/01/0001)
1159
- '...' - literal text
1160
- '' - single quote
1161
-
1162
- @param format string - the desired format of the date
1163
- @param date Date - the date value to format
1164
- @param settings Object - attributes include:
1165
- dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
1166
- dayNames string[7] - names of the days from Sunday (optional)
1167
- monthNamesShort string[12] - abbreviated names of the months (optional)
1168
- monthNames string[12] - names of the months (optional)
1169
- @return string - the date in the above format */
1259
+ * The format can be combinations of the following:
1260
+ * d - day of month (no leading zero)
1261
+ * dd - day of month (two digit)
1262
+ * o - day of year (no leading zeros)
1263
+ * oo - day of year (three digit)
1264
+ * D - day name short
1265
+ * DD - day name long
1266
+ * m - month of year (no leading zero)
1267
+ * mm - month of year (two digit)
1268
+ * M - month name short
1269
+ * MM - month name long
1270
+ * y - year (two digit)
1271
+ * yy - year (four digit)
1272
+ * @ - Unix timestamp (ms since 01/01/1970)
1273
+ * ! - Windows ticks (100ns since 01/01/0001)
1274
+ * "..." - literal text
1275
+ * '' - single quote
1276
+ *
1277
+ * @param format string - the desired format of the date
1278
+ * @param date Date - the date value to format
1279
+ * @param settings Object - attributes include:
1280
+ * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
1281
+ * dayNames string[7] - names of the days from Sunday (optional)
1282
+ * monthNamesShort string[12] - abbreviated names of the months (optional)
1283
+ * monthNames string[12] - names of the months (optional)
1284
+ * @return string - the date in the above format
1285
+ */
1170
1286
  formatDate: function (format, date, settings) {
1171
- if (!date)
1172
- return '';
1173
- var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
1174
- var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
1175
- var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
1176
- var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
1177
- // Check whether a format character is doubled
1178
- var lookAhead = function(match) {
1179
- var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
1180
- if (matches)
1181
- iFormat++;
1182
- return matches;
1183
- };
1184
- // Format a number, with leading zero if necessary
1185
- var formatNumber = function(match, value, len) {
1186
- var num = '' + value;
1187
- if (lookAhead(match))
1188
- while (num.length < len)
1189
- num = '0' + num;
1190
- return num;
1191
- };
1192
- // Format a name, short or long as requested
1193
- var formatName = function(match, value, shortNames, longNames) {
1194
- return (lookAhead(match) ? longNames[value] : shortNames[value]);
1195
- };
1196
- var output = '';
1197
- var literal = false;
1198
- if (date)
1199
- for (var iFormat = 0; iFormat < format.length; iFormat++) {
1200
- if (literal)
1201
- if (format.charAt(iFormat) == "'" && !lookAhead("'"))
1287
+ if (!date) {
1288
+ return "";
1289
+ }
1290
+
1291
+ var iFormat,
1292
+ dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
1293
+ dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
1294
+ monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
1295
+ monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
1296
+ // Check whether a format character is doubled
1297
+ lookAhead = function(match) {
1298
+ var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
1299
+ if (matches) {
1300
+ iFormat++;
1301
+ }
1302
+ return matches;
1303
+ },
1304
+ // Format a number, with leading zero if necessary
1305
+ formatNumber = function(match, value, len) {
1306
+ var num = "" + value;
1307
+ if (lookAhead(match)) {
1308
+ while (num.length < len) {
1309
+ num = "0" + num;
1310
+ }
1311
+ }
1312
+ return num;
1313
+ },
1314
+ // Format a name, short or long as requested
1315
+ formatName = function(match, value, shortNames, longNames) {
1316
+ return (lookAhead(match) ? longNames[value] : shortNames[value]);
1317
+ },
1318
+ output = "",
1319
+ literal = false;
1320
+
1321
+ if (date) {
1322
+ for (iFormat = 0; iFormat < format.length; iFormat++) {
1323
+ if (literal) {
1324
+ if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
1202
1325
  literal = false;
1203
- else
1326
+ } else {
1204
1327
  output += format.charAt(iFormat);
1205
- else
1328
+ }
1329
+ } else {
1206
1330
  switch (format.charAt(iFormat)) {
1207
- case 'd':
1208
- output += formatNumber('d', date.getDate(), 2);
1331
+ case "d":
1332
+ output += formatNumber("d", date.getDate(), 2);
1209
1333
  break;
1210
- case 'D':
1211
- output += formatName('D', date.getDay(), dayNamesShort, dayNames);
1334
+ case "D":
1335
+ output += formatName("D", date.getDay(), dayNamesShort, dayNames);
1212
1336
  break;
1213
- case 'o':
1214
- output += formatNumber('o',
1337
+ case "o":
1338
+ output += formatNumber("o",
1215
1339
  Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
1216
1340
  break;
1217
- case 'm':
1218
- output += formatNumber('m', date.getMonth() + 1, 2);
1341
+ case "m":
1342
+ output += formatNumber("m", date.getMonth() + 1, 2);
1219
1343
  break;
1220
- case 'M':
1221
- output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
1344
+ case "M":
1345
+ output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
1222
1346
  break;
1223
- case 'y':
1224
- output += (lookAhead('y') ? date.getFullYear() :
1225
- (date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
1347
+ case "y":
1348
+ output += (lookAhead("y") ? date.getFullYear() :
1349
+ (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
1226
1350
  break;
1227
- case '@':
1351
+ case "@":
1228
1352
  output += date.getTime();
1229
1353
  break;
1230
- case '!':
1354
+ case "!":
1231
1355
  output += date.getTime() * 10000 + this._ticksTo1970;
1232
1356
  break;
1233
1357
  case "'":
1234
- if (lookAhead("'"))
1358
+ if (lookAhead("'")) {
1235
1359
  output += "'";
1236
- else
1360
+ } else {
1237
1361
  literal = true;
1362
+ }
1238
1363
  break;
1239
1364
  default:
1240
1365
  output += format.charAt(iFormat);
1241
1366
  }
1367
+ }
1242
1368
  }
1369
+ }
1243
1370
  return output;
1244
1371
  },
1245
1372
 
1246
1373
  /* Extract all possible characters from the date format. */
1247
1374
  _possibleChars: function (format) {
1248
- var chars = '';
1249
- var literal = false;
1250
- // Check whether a format character is doubled
1251
- var lookAhead = function(match) {
1252
- var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
1253
- if (matches)
1254
- iFormat++;
1255
- return matches;
1256
- };
1257
- for (var iFormat = 0; iFormat < format.length; iFormat++)
1258
- if (literal)
1259
- if (format.charAt(iFormat) == "'" && !lookAhead("'"))
1375
+ var iFormat,
1376
+ chars = "",
1377
+ literal = false,
1378
+ // Check whether a format character is doubled
1379
+ lookAhead = function(match) {
1380
+ var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
1381
+ if (matches) {
1382
+ iFormat++;
1383
+ }
1384
+ return matches;
1385
+ };
1386
+
1387
+ for (iFormat = 0; iFormat < format.length; iFormat++) {
1388
+ if (literal) {
1389
+ if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
1260
1390
  literal = false;
1261
- else
1391
+ } else {
1262
1392
  chars += format.charAt(iFormat);
1263
- else
1393
+ }
1394
+ } else {
1264
1395
  switch (format.charAt(iFormat)) {
1265
- case 'd': case 'm': case 'y': case '@':
1266
- chars += '0123456789';
1396
+ case "d": case "m": case "y": case "@":
1397
+ chars += "0123456789";
1267
1398
  break;
1268
- case 'D': case 'M':
1399
+ case "D": case "M":
1269
1400
  return null; // Accept anything
1270
1401
  case "'":
1271
- if (lookAhead("'"))
1402
+ if (lookAhead("'")) {
1272
1403
  chars += "'";
1273
- else
1404
+ } else {
1274
1405
  literal = true;
1406
+ }
1275
1407
  break;
1276
1408
  default:
1277
1409
  chars += format.charAt(iFormat);
1278
1410
  }
1411
+ }
1412
+ }
1279
1413
  return chars;
1280
1414
  },
1281
1415
 
@@ -1287,19 +1421,20 @@ $.extend(Datepicker.prototype, {
1287
1421
 
1288
1422
  /* Parse existing date and initialise date picker. */
1289
1423
  _setDateFromField: function(inst, noDefault) {
1290
- if (inst.input.val() == inst.lastVal) {
1424
+ if (inst.input.val() === inst.lastVal) {
1291
1425
  return;
1292
1426
  }
1293
- var dateFormat = this._get(inst, 'dateFormat');
1294
- var dates = inst.lastVal = inst.input ? inst.input.val() : null;
1295
- var date, defaultDate;
1296
- date = defaultDate = this._getDefaultDate(inst);
1297
- var settings = this._getFormatConfig(inst);
1427
+
1428
+ var dateFormat = this._get(inst, "dateFormat"),
1429
+ dates = inst.lastVal = inst.input ? inst.input.val() : null,
1430
+ defaultDate = this._getDefaultDate(inst),
1431
+ date = defaultDate,
1432
+ settings = this._getFormatConfig(inst);
1433
+
1298
1434
  try {
1299
1435
  date = this.parseDate(dateFormat, dates, settings) || defaultDate;
1300
1436
  } catch (event) {
1301
- this.log(event);
1302
- dates = (noDefault ? '' : dates);
1437
+ dates = (noDefault ? "" : dates);
1303
1438
  }
1304
1439
  inst.selectedDay = date.getDate();
1305
1440
  inst.drawMonth = inst.selectedMonth = date.getMonth();
@@ -1313,53 +1448,56 @@ $.extend(Datepicker.prototype, {
1313
1448
  /* Retrieve the default date shown on opening. */
1314
1449
  _getDefaultDate: function(inst) {
1315
1450
  return this._restrictMinMax(inst,
1316
- this._determineDate(inst, this._get(inst, 'defaultDate'), new Date()));
1451
+ this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
1317
1452
  },
1318
1453
 
1319
1454
  /* A date may be specified as an exact value or a relative one. */
1320
1455
  _determineDate: function(inst, date, defaultDate) {
1321
1456
  var offsetNumeric = function(offset) {
1322
- var date = new Date();
1323
- date.setDate(date.getDate() + offset);
1324
- return date;
1325
- };
1326
- var offsetString = function(offset) {
1327
- try {
1328
- return $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
1329
- offset, $.datepicker._getFormatConfig(inst));
1330
- }
1331
- catch (e) {
1332
- // Ignore
1333
- }
1334
- var date = (offset.toLowerCase().match(/^c/) ?
1335
- $.datepicker._getDate(inst) : null) || new Date();
1336
- var year = date.getFullYear();
1337
- var month = date.getMonth();
1338
- var day = date.getDate();
1339
- var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
1340
- var matches = pattern.exec(offset);
1341
- while (matches) {
1342
- switch (matches[2] || 'd') {
1343
- case 'd' : case 'D' :
1344
- day += parseInt(matches[1],10); break;
1345
- case 'w' : case 'W' :
1346
- day += parseInt(matches[1],10) * 7; break;
1347
- case 'm' : case 'M' :
1348
- month += parseInt(matches[1],10);
1349
- day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
1350
- break;
1351
- case 'y': case 'Y' :
1352
- year += parseInt(matches[1],10);
1353
- day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
1354
- break;
1457
+ var date = new Date();
1458
+ date.setDate(date.getDate() + offset);
1459
+ return date;
1460
+ },
1461
+ offsetString = function(offset) {
1462
+ try {
1463
+ return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
1464
+ offset, $.datepicker._getFormatConfig(inst));
1355
1465
  }
1356
- matches = pattern.exec(offset);
1357
- }
1358
- return new Date(year, month, day);
1359
- };
1360
- var newDate = (date == null || date === '' ? defaultDate : (typeof date == 'string' ? offsetString(date) :
1361
- (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
1362
- newDate = (newDate && newDate.toString() == 'Invalid Date' ? defaultDate : newDate);
1466
+ catch (e) {
1467
+ // Ignore
1468
+ }
1469
+
1470
+ var date = (offset.toLowerCase().match(/^c/) ?
1471
+ $.datepicker._getDate(inst) : null) || new Date(),
1472
+ year = date.getFullYear(),
1473
+ month = date.getMonth(),
1474
+ day = date.getDate(),
1475
+ pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
1476
+ matches = pattern.exec(offset);
1477
+
1478
+ while (matches) {
1479
+ switch (matches[2] || "d") {
1480
+ case "d" : case "D" :
1481
+ day += parseInt(matches[1],10); break;
1482
+ case "w" : case "W" :
1483
+ day += parseInt(matches[1],10) * 7; break;
1484
+ case "m" : case "M" :
1485
+ month += parseInt(matches[1],10);
1486
+ day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
1487
+ break;
1488
+ case "y": case "Y" :
1489
+ year += parseInt(matches[1],10);
1490
+ day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
1491
+ break;
1492
+ }
1493
+ matches = pattern.exec(offset);
1494
+ }
1495
+ return new Date(year, month, day);
1496
+ },
1497
+ newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
1498
+ (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
1499
+
1500
+ newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
1363
1501
  if (newDate) {
1364
1502
  newDate.setHours(0);
1365
1503
  newDate.setMinutes(0);
@@ -1370,37 +1508,42 @@ $.extend(Datepicker.prototype, {
1370
1508
  },
1371
1509
 
1372
1510
  /* Handle switch to/from daylight saving.
1373
- Hours may be non-zero on daylight saving cut-over:
1374
- > 12 when midnight changeover, but then cannot generate
1375
- midnight datetime, so jump to 1AM, otherwise reset.
1376
- @param date (Date) the date to check
1377
- @return (Date) the corrected date */
1511
+ * Hours may be non-zero on daylight saving cut-over:
1512
+ * > 12 when midnight changeover, but then cannot generate
1513
+ * midnight datetime, so jump to 1AM, otherwise reset.
1514
+ * @param date (Date) the date to check
1515
+ * @return (Date) the corrected date
1516
+ */
1378
1517
  _daylightSavingAdjust: function(date) {
1379
- if (!date) return null;
1518
+ if (!date) {
1519
+ return null;
1520
+ }
1380
1521
  date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
1381
1522
  return date;
1382
1523
  },
1383
1524
 
1384
1525
  /* Set the date(s) directly. */
1385
1526
  _setDate: function(inst, date, noChange) {
1386
- var clear = !date;
1387
- var origMonth = inst.selectedMonth;
1388
- var origYear = inst.selectedYear;
1389
- var newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
1527
+ var clear = !date,
1528
+ origMonth = inst.selectedMonth,
1529
+ origYear = inst.selectedYear,
1530
+ newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
1531
+
1390
1532
  inst.selectedDay = inst.currentDay = newDate.getDate();
1391
1533
  inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
1392
1534
  inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
1393
- if ((origMonth != inst.selectedMonth || origYear != inst.selectedYear) && !noChange)
1535
+ if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
1394
1536
  this._notifyChange(inst);
1537
+ }
1395
1538
  this._adjustInstDate(inst);
1396
1539
  if (inst.input) {
1397
- inst.input.val(clear ? '' : this._formatDate(inst));
1540
+ inst.input.val(clear ? "" : this._formatDate(inst));
1398
1541
  }
1399
1542
  },
1400
1543
 
1401
1544
  /* Retrieve the date(s) directly. */
1402
1545
  _getDate: function(inst) {
1403
- var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null :
1546
+ var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
1404
1547
  this._daylightSavingAdjust(new Date(
1405
1548
  inst.currentYear, inst.currentMonth, inst.currentDay)));
1406
1549
  return startDate;
@@ -1410,64 +1553,71 @@ $.extend(Datepicker.prototype, {
1410
1553
  * they work with static code transformers like Caja.
1411
1554
  */
1412
1555
  _attachHandlers: function(inst) {
1413
- var stepMonths = this._get(inst, 'stepMonths');
1414
- var id = '#' + inst.id.replace( /\\\\/g, "\\" );
1415
- inst.dpDiv.find('[data-handler]').map(function () {
1556
+ var stepMonths = this._get(inst, "stepMonths"),
1557
+ id = "#" + inst.id.replace( /\\\\/g, "\\" );
1558
+ inst.dpDiv.find("[data-handler]").map(function () {
1416
1559
  var handler = {
1417
1560
  prev: function () {
1418
- window['DP_jQuery_' + dpuuid].datepicker._adjustDate(id, -stepMonths, 'M');
1561
+ window["DP_jQuery_" + dpuuid].datepicker._adjustDate(id, -stepMonths, "M");
1419
1562
  },
1420
1563
  next: function () {
1421
- window['DP_jQuery_' + dpuuid].datepicker._adjustDate(id, +stepMonths, 'M');
1564
+ window["DP_jQuery_" + dpuuid].datepicker._adjustDate(id, +stepMonths, "M");
1422
1565
  },
1423
1566
  hide: function () {
1424
- window['DP_jQuery_' + dpuuid].datepicker._hideDatepicker();
1567
+ window["DP_jQuery_" + dpuuid].datepicker._hideDatepicker();
1425
1568
  },
1426
1569
  today: function () {
1427
- window['DP_jQuery_' + dpuuid].datepicker._gotoToday(id);
1570
+ window["DP_jQuery_" + dpuuid].datepicker._gotoToday(id);
1428
1571
  },
1429
1572
  selectDay: function () {
1430
- window['DP_jQuery_' + dpuuid].datepicker._selectDay(id, +this.getAttribute('data-month'), +this.getAttribute('data-year'), this);
1573
+ window["DP_jQuery_" + dpuuid].datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
1431
1574
  return false;
1432
1575
  },
1433
1576
  selectMonth: function () {
1434
- window['DP_jQuery_' + dpuuid].datepicker._selectMonthYear(id, this, 'M');
1577
+ window["DP_jQuery_" + dpuuid].datepicker._selectMonthYear(id, this, "M");
1435
1578
  return false;
1436
1579
  },
1437
1580
  selectYear: function () {
1438
- window['DP_jQuery_' + dpuuid].datepicker._selectMonthYear(id, this, 'Y');
1581
+ window["DP_jQuery_" + dpuuid].datepicker._selectMonthYear(id, this, "Y");
1439
1582
  return false;
1440
1583
  }
1441
1584
  };
1442
- $(this).bind(this.getAttribute('data-event'), handler[this.getAttribute('data-handler')]);
1585
+ $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
1443
1586
  });
1444
1587
  },
1445
1588
 
1446
1589
  /* Generate the HTML for the current state of the date picker. */
1447
1590
  _generateHTML: function(inst) {
1448
- var today = new Date();
1449
- today = this._daylightSavingAdjust(
1450
- new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time
1451
- var isRTL = this._get(inst, 'isRTL');
1452
- var showButtonPanel = this._get(inst, 'showButtonPanel');
1453
- var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext');
1454
- var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
1455
- var numMonths = this._getNumberOfMonths(inst);
1456
- var showCurrentAtPos = this._get(inst, 'showCurrentAtPos');
1457
- var stepMonths = this._get(inst, 'stepMonths');
1458
- var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
1459
- var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
1460
- new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
1461
- var minDate = this._getMinMaxDate(inst, 'min');
1462
- var maxDate = this._getMinMaxDate(inst, 'max');
1463
- var drawMonth = inst.drawMonth - showCurrentAtPos;
1464
- var drawYear = inst.drawYear;
1591
+ var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
1592
+ controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
1593
+ monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
1594
+ selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
1595
+ cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
1596
+ printDate, dRow, tbody, daySettings, otherMonth, unselectable,
1597
+ tempDate = new Date(),
1598
+ today = this._daylightSavingAdjust(
1599
+ new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
1600
+ isRTL = this._get(inst, "isRTL"),
1601
+ showButtonPanel = this._get(inst, "showButtonPanel"),
1602
+ hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
1603
+ navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
1604
+ numMonths = this._getNumberOfMonths(inst),
1605
+ showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
1606
+ stepMonths = this._get(inst, "stepMonths"),
1607
+ isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
1608
+ currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
1609
+ new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
1610
+ minDate = this._getMinMaxDate(inst, "min"),
1611
+ maxDate = this._getMinMaxDate(inst, "max"),
1612
+ drawMonth = inst.drawMonth - showCurrentAtPos,
1613
+ drawYear = inst.drawYear;
1614
+
1465
1615
  if (drawMonth < 0) {
1466
1616
  drawMonth += 12;
1467
1617
  drawYear--;
1468
1618
  }
1469
1619
  if (maxDate) {
1470
- var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
1620
+ maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
1471
1621
  maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
1472
1622
  maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
1473
1623
  while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
@@ -1480,133 +1630,142 @@ $.extend(Datepicker.prototype, {
1480
1630
  }
1481
1631
  inst.drawMonth = drawMonth;
1482
1632
  inst.drawYear = drawYear;
1483
- var prevText = this._get(inst, 'prevText');
1633
+
1634
+ prevText = this._get(inst, "prevText");
1484
1635
  prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
1485
1636
  this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
1486
1637
  this._getFormatConfig(inst)));
1487
- var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
1488
- '<a class="ui-datepicker-prev ui-corner-all" data-handler="prev" data-event="click"' +
1489
- ' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' :
1490
- (hideIfNoPrevNext ? '' : '<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+ prevText +'"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>'));
1491
- var nextText = this._get(inst, 'nextText');
1638
+
1639
+ prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
1640
+ "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
1641
+ " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
1642
+ (hideIfNoPrevNext ? "" : "<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='"+ prevText +"'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>"));
1643
+
1644
+ nextText = this._get(inst, "nextText");
1492
1645
  nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
1493
1646
  this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
1494
1647
  this._getFormatConfig(inst)));
1495
- var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
1496
- '<a class="ui-datepicker-next ui-corner-all" data-handler="next" data-event="click"' +
1497
- ' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' :
1498
- (hideIfNoPrevNext ? '' : '<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+ nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>'));
1499
- var currentText = this._get(inst, 'currentText');
1500
- var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today);
1648
+
1649
+ next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
1650
+ "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
1651
+ " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
1652
+ (hideIfNoPrevNext ? "" : "<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='"+ nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>"));
1653
+
1654
+ currentText = this._get(inst, "currentText");
1655
+ gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
1501
1656
  currentText = (!navigationAsDateFormat ? currentText :
1502
1657
  this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
1503
- var controls = (!inst.inline ? '<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" data-handler="hide" data-event="click">' +
1504
- this._get(inst, 'closeText') + '</button>' : '');
1505
- var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') +
1506
- (this._isInRange(inst, gotoDate) ? '<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" data-handler="today" data-event="click"' +
1507
- '>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : '';
1508
- var firstDay = parseInt(this._get(inst, 'firstDay'),10);
1658
+
1659
+ controls = (!inst.inline ? "<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>" +
1660
+ this._get(inst, "closeText") + "</button>" : "");
1661
+
1662
+ buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
1663
+ (this._isInRange(inst, gotoDate) ? "<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'" +
1664
+ ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
1665
+
1666
+ firstDay = parseInt(this._get(inst, "firstDay"),10);
1509
1667
  firstDay = (isNaN(firstDay) ? 0 : firstDay);
1510
- var showWeek = this._get(inst, 'showWeek');
1511
- var dayNames = this._get(inst, 'dayNames');
1512
- var dayNamesShort = this._get(inst, 'dayNamesShort');
1513
- var dayNamesMin = this._get(inst, 'dayNamesMin');
1514
- var monthNames = this._get(inst, 'monthNames');
1515
- var monthNamesShort = this._get(inst, 'monthNamesShort');
1516
- var beforeShowDay = this._get(inst, 'beforeShowDay');
1517
- var showOtherMonths = this._get(inst, 'showOtherMonths');
1518
- var selectOtherMonths = this._get(inst, 'selectOtherMonths');
1519
- var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week;
1520
- var defaultDate = this._getDefaultDate(inst);
1521
- var html = '';
1522
- for (var row = 0; row < numMonths[0]; row++) {
1523
- var group = '';
1668
+
1669
+ showWeek = this._get(inst, "showWeek");
1670
+ dayNames = this._get(inst, "dayNames");
1671
+ dayNamesMin = this._get(inst, "dayNamesMin");
1672
+ monthNames = this._get(inst, "monthNames");
1673
+ monthNamesShort = this._get(inst, "monthNamesShort");
1674
+ beforeShowDay = this._get(inst, "beforeShowDay");
1675
+ showOtherMonths = this._get(inst, "showOtherMonths");
1676
+ selectOtherMonths = this._get(inst, "selectOtherMonths");
1677
+ defaultDate = this._getDefaultDate(inst);
1678
+ html = "";
1679
+ dow;
1680
+ for (row = 0; row < numMonths[0]; row++) {
1681
+ group = "";
1524
1682
  this.maxRows = 4;
1525
- for (var col = 0; col < numMonths[1]; col++) {
1526
- var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
1527
- var cornerClass = ' ui-corner-all';
1528
- var calender = '';
1683
+ for (col = 0; col < numMonths[1]; col++) {
1684
+ selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
1685
+ cornerClass = " ui-corner-all";
1686
+ calender = "";
1529
1687
  if (isMultiMonth) {
1530
- calender += '<div class="ui-datepicker-group';
1531
- if (numMonths[1] > 1)
1688
+ calender += "<div class='ui-datepicker-group";
1689
+ if (numMonths[1] > 1) {
1532
1690
  switch (col) {
1533
- case 0: calender += ' ui-datepicker-group-first';
1534
- cornerClass = ' ui-corner-' + (isRTL ? 'right' : 'left'); break;
1535
- case numMonths[1]-1: calender += ' ui-datepicker-group-last';
1536
- cornerClass = ' ui-corner-' + (isRTL ? 'left' : 'right'); break;
1537
- default: calender += ' ui-datepicker-group-middle'; cornerClass = ''; break;
1691
+ case 0: calender += " ui-datepicker-group-first";
1692
+ cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
1693
+ case numMonths[1]-1: calender += " ui-datepicker-group-last";
1694
+ cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
1695
+ default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
1538
1696
  }
1539
- calender += '">';
1697
+ }
1698
+ calender += "'>";
1540
1699
  }
1541
- calender += '<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix' + cornerClass + '">' +
1542
- (/all|left/.test(cornerClass) && row == 0 ? (isRTL ? next : prev) : '') +
1543
- (/all|right/.test(cornerClass) && row == 0 ? (isRTL ? prev : next) : '') +
1700
+ calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
1701
+ (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
1702
+ (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
1544
1703
  this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
1545
1704
  row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
1546
- '</div><table class="ui-datepicker-calendar"><thead>' +
1547
- '<tr>';
1548
- var thead = (showWeek ? '<th class="ui-datepicker-week-col">' + this._get(inst, 'weekHeader') + '</th>' : '');
1549
- for (var dow = 0; dow < 7; dow++) { // days of the week
1550
- var day = (dow + firstDay) % 7;
1551
- thead += '<th' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end"' : '') + '>' +
1552
- '<span title="' + dayNames[day] + '">' + dayNamesMin[day] + '</span></th>';
1705
+ "</div><table class='ui-datepicker-calendar'><thead>" +
1706
+ "<tr>";
1707
+ thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
1708
+ for (dow = 0; dow < 7; dow++) { // days of the week
1709
+ day = (dow + firstDay) % 7;
1710
+ thead += "<th" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
1711
+ "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
1553
1712
  }
1554
- calender += thead + '</tr></thead><tbody>';
1555
- var daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
1556
- if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth)
1713
+ calender += thead + "</tr></thead><tbody>";
1714
+ daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
1715
+ if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
1557
1716
  inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
1558
- var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
1559
- var curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
1560
- var numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
1717
+ }
1718
+ leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
1719
+ curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
1720
+ numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
1561
1721
  this.maxRows = numRows;
1562
- var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
1563
- for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows
1564
- calender += '<tr>';
1565
- var tbody = (!showWeek ? '' : '<td class="ui-datepicker-week-col">' +
1566
- this._get(inst, 'calculateWeek')(printDate) + '</td>');
1567
- for (var dow = 0; dow < 7; dow++) { // create date picker days
1568
- var daySettings = (beforeShowDay ?
1569
- beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']);
1570
- var otherMonth = (printDate.getMonth() != drawMonth);
1571
- var unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
1722
+ printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
1723
+ for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
1724
+ calender += "<tr>";
1725
+ tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
1726
+ this._get(inst, "calculateWeek")(printDate) + "</td>");
1727
+ for (dow = 0; dow < 7; dow++) { // create date picker days
1728
+ daySettings = (beforeShowDay ?
1729
+ beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
1730
+ otherMonth = (printDate.getMonth() !== drawMonth);
1731
+ unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
1572
1732
  (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
1573
- tbody += '<td class="' +
1574
- ((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end' : '') + // highlight weekends
1575
- (otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months
1576
- ((printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth && inst._keyEvent) || // user pressed key
1577
- (defaultDate.getTime() == printDate.getTime() && defaultDate.getTime() == selectedDate.getTime()) ?
1733
+ tbody += "<td class='" +
1734
+ ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
1735
+ (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
1736
+ ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
1737
+ (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
1578
1738
  // or defaultDate is current printedDate and defaultDate is selectedDate
1579
- ' ' + this._dayOverClass : '') + // highlight selected day
1580
- (unselectable ? ' ' + this._unselectableClass + ' ui-state-disabled': '') + // highlight unselectable days
1581
- (otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates
1582
- (printDate.getTime() == currentDate.getTime() ? ' ' + this._currentClass : '') + // highlight selected day
1583
- (printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different)
1584
- ((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title
1585
- (unselectable ? '' : ' data-handler="selectDay" data-event="click" data-month="' + printDate.getMonth() + '" data-year="' + printDate.getFullYear() + '"') + '>' + // actions
1586
- (otherMonth && !showOtherMonths ? '&#xa0;' : // display for other months
1587
- (unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' +
1588
- (printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') +
1589
- (printDate.getTime() == currentDate.getTime() ? ' ui-state-active' : '') + // highlight selected day
1590
- (otherMonth ? ' ui-priority-secondary' : '') + // distinguish dates from other months
1591
- '" href="#">' + printDate.getDate() + '</a>')) + '</td>'; // display selectable date
1739
+ " " + this._dayOverClass : "") + // highlight selected day
1740
+ (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
1741
+ (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
1742
+ (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
1743
+ (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
1744
+ ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
1745
+ (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
1746
+ (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
1747
+ (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
1748
+ (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
1749
+ (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
1750
+ (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
1751
+ "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
1592
1752
  printDate.setDate(printDate.getDate() + 1);
1593
1753
  printDate = this._daylightSavingAdjust(printDate);
1594
1754
  }
1595
- calender += tbody + '</tr>';
1755
+ calender += tbody + "</tr>";
1596
1756
  }
1597
1757
  drawMonth++;
1598
1758
  if (drawMonth > 11) {
1599
1759
  drawMonth = 0;
1600
1760
  drawYear++;
1601
1761
  }
1602
- calender += '</tbody></table>' + (isMultiMonth ? '</div>' +
1603
- ((numMonths[0] > 0 && col == numMonths[1]-1) ? '<div class="ui-datepicker-row-break"></div>' : '') : '');
1762
+ calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
1763
+ ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
1604
1764
  group += calender;
1605
1765
  }
1606
1766
  html += group;
1607
1767
  }
1608
- html += buttonPanel + ($.ui.ie6 && !inst.inline ?
1609
- '<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>' : '');
1768
+ html += buttonPanel;
1610
1769
  inst._keyEvent = false;
1611
1770
  return html;
1612
1771
  },
@@ -1614,108 +1773,116 @@ $.extend(Datepicker.prototype, {
1614
1773
  /* Generate the month and year header. */
1615
1774
  _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
1616
1775
  secondary, monthNames, monthNamesShort) {
1617
- var changeMonth = this._get(inst, 'changeMonth');
1618
- var changeYear = this._get(inst, 'changeYear');
1619
- var showMonthAfterYear = this._get(inst, 'showMonthAfterYear');
1620
- var html = '<div class="ui-datepicker-title">';
1621
- var monthHtml = '';
1776
+
1777
+ var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
1778
+ changeMonth = this._get(inst, "changeMonth"),
1779
+ changeYear = this._get(inst, "changeYear"),
1780
+ showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
1781
+ html = "<div class='ui-datepicker-title'>",
1782
+ monthHtml = "";
1783
+
1622
1784
  // month selection
1623
- if (secondary || !changeMonth)
1624
- monthHtml += '<span class="ui-datepicker-month">' + monthNames[drawMonth] + '</span>';
1625
- else {
1626
- var inMinYear = (minDate && minDate.getFullYear() == drawYear);
1627
- var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
1628
- monthHtml += '<select class="ui-datepicker-month" data-handler="selectMonth" data-event="change">';
1629
- for (var month = 0; month < 12; month++) {
1630
- if ((!inMinYear || month >= minDate.getMonth()) &&
1631
- (!inMaxYear || month <= maxDate.getMonth()))
1632
- monthHtml += '<option value="' + month + '"' +
1633
- (month == drawMonth ? ' selected="selected"' : '') +
1634
- '>' + monthNamesShort[month] + '</option>';
1785
+ if (secondary || !changeMonth) {
1786
+ monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
1787
+ } else {
1788
+ inMinYear = (minDate && minDate.getFullYear() === drawYear);
1789
+ inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
1790
+ monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
1791
+ for ( month = 0; month < 12; month++) {
1792
+ if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
1793
+ monthHtml += "<option value='" + month + "'" +
1794
+ (month === drawMonth ? " selected='selected'" : "") +
1795
+ ">" + monthNamesShort[month] + "</option>";
1796
+ }
1635
1797
  }
1636
- monthHtml += '</select>';
1798
+ monthHtml += "</select>";
1799
+ }
1800
+
1801
+ if (!showMonthAfterYear) {
1802
+ html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
1637
1803
  }
1638
- if (!showMonthAfterYear)
1639
- html += monthHtml + (secondary || !(changeMonth && changeYear) ? '&#xa0;' : '');
1804
+
1640
1805
  // year selection
1641
1806
  if ( !inst.yearshtml ) {
1642
- inst.yearshtml = '';
1643
- if (secondary || !changeYear)
1644
- html += '<span class="ui-datepicker-year">' + drawYear + '</span>';
1645
- else {
1807
+ inst.yearshtml = "";
1808
+ if (secondary || !changeYear) {
1809
+ html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
1810
+ } else {
1646
1811
  // determine range of years to display
1647
- var years = this._get(inst, 'yearRange').split(':');
1648
- var thisYear = new Date().getFullYear();
1649
- var determineYear = function(value) {
1650
- var year = (value.match(/c[+-].*/) ? drawYear + parseInt(value.substring(1), 10) :
1651
- (value.match(/[+-].*/) ? thisYear + parseInt(value, 10) :
1812
+ years = this._get(inst, "yearRange").split(":");
1813
+ thisYear = new Date().getFullYear();
1814
+ determineYear = function(value) {
1815
+ var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
1816
+ (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
1652
1817
  parseInt(value, 10)));
1653
1818
  return (isNaN(year) ? thisYear : year);
1654
1819
  };
1655
- var year = determineYear(years[0]);
1656
- var endYear = Math.max(year, determineYear(years[1] || ''));
1820
+ year = determineYear(years[0]);
1821
+ endYear = Math.max(year, determineYear(years[1] || ""));
1657
1822
  year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
1658
1823
  endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
1659
- inst.yearshtml += '<select class="ui-datepicker-year" data-handler="selectYear" data-event="change">';
1824
+ inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
1660
1825
  for (; year <= endYear; year++) {
1661
- inst.yearshtml += '<option value="' + year + '"' +
1662
- (year == drawYear ? ' selected="selected"' : '') +
1663
- '>' + year + '</option>';
1826
+ inst.yearshtml += "<option value='" + year + "'" +
1827
+ (year === drawYear ? " selected='selected'" : "") +
1828
+ ">" + year + "</option>";
1664
1829
  }
1665
- inst.yearshtml += '</select>';
1830
+ inst.yearshtml += "</select>";
1666
1831
 
1667
1832
  html += inst.yearshtml;
1668
1833
  inst.yearshtml = null;
1669
1834
  }
1670
1835
  }
1671
- html += this._get(inst, 'yearSuffix');
1672
- if (showMonthAfterYear)
1673
- html += (secondary || !(changeMonth && changeYear) ? '&#xa0;' : '') + monthHtml;
1674
- html += '</div>'; // Close datepicker_header
1836
+
1837
+ html += this._get(inst, "yearSuffix");
1838
+ if (showMonthAfterYear) {
1839
+ html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
1840
+ }
1841
+ html += "</div>"; // Close datepicker_header
1675
1842
  return html;
1676
1843
  },
1677
1844
 
1678
1845
  /* Adjust one of the date sub-fields. */
1679
1846
  _adjustInstDate: function(inst, offset, period) {
1680
- var year = inst.drawYear + (period == 'Y' ? offset : 0);
1681
- var month = inst.drawMonth + (period == 'M' ? offset : 0);
1682
- var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) +
1683
- (period == 'D' ? offset : 0);
1684
- var date = this._restrictMinMax(inst,
1685
- this._daylightSavingAdjust(new Date(year, month, day)));
1847
+ var year = inst.drawYear + (period === "Y" ? offset : 0),
1848
+ month = inst.drawMonth + (period === "M" ? offset : 0),
1849
+ day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
1850
+ date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
1851
+
1686
1852
  inst.selectedDay = date.getDate();
1687
1853
  inst.drawMonth = inst.selectedMonth = date.getMonth();
1688
1854
  inst.drawYear = inst.selectedYear = date.getFullYear();
1689
- if (period == 'M' || period == 'Y')
1855
+ if (period === "M" || period === "Y") {
1690
1856
  this._notifyChange(inst);
1857
+ }
1691
1858
  },
1692
1859
 
1693
1860
  /* Ensure a date is within any min/max bounds. */
1694
1861
  _restrictMinMax: function(inst, date) {
1695
- var minDate = this._getMinMaxDate(inst, 'min');
1696
- var maxDate = this._getMinMaxDate(inst, 'max');
1697
- var newDate = (minDate && date < minDate ? minDate : date);
1698
- newDate = (maxDate && newDate > maxDate ? maxDate : newDate);
1699
- return newDate;
1862
+ var minDate = this._getMinMaxDate(inst, "min"),
1863
+ maxDate = this._getMinMaxDate(inst, "max"),
1864
+ newDate = (minDate && date < minDate ? minDate : date);
1865
+ return (maxDate && newDate > maxDate ? maxDate : newDate);
1700
1866
  },
1701
1867
 
1702
1868
  /* Notify change of month/year. */
1703
1869
  _notifyChange: function(inst) {
1704
- var onChange = this._get(inst, 'onChangeMonthYear');
1705
- if (onChange)
1870
+ var onChange = this._get(inst, "onChangeMonthYear");
1871
+ if (onChange) {
1706
1872
  onChange.apply((inst.input ? inst.input[0] : null),
1707
1873
  [inst.selectedYear, inst.selectedMonth + 1, inst]);
1874
+ }
1708
1875
  },
1709
1876
 
1710
1877
  /* Determine the number of months to show. */
1711
1878
  _getNumberOfMonths: function(inst) {
1712
- var numMonths = this._get(inst, 'numberOfMonths');
1713
- return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
1879
+ var numMonths = this._get(inst, "numberOfMonths");
1880
+ return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
1714
1881
  },
1715
1882
 
1716
1883
  /* Determine the current maximum date - ensure no time components are set. */
1717
1884
  _getMinMaxDate: function(inst, minMax) {
1718
- return this._determineDate(inst, this._get(inst, minMax + 'Date'), null);
1885
+ return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
1719
1886
  },
1720
1887
 
1721
1888
  /* Find the number of days in a given month. */
@@ -1730,30 +1897,51 @@ $.extend(Datepicker.prototype, {
1730
1897
 
1731
1898
  /* Determines if we should allow a "next/prev" month display change. */
1732
1899
  _canAdjustMonth: function(inst, offset, curYear, curMonth) {
1733
- var numMonths = this._getNumberOfMonths(inst);
1734
- var date = this._daylightSavingAdjust(new Date(curYear,
1900
+ var numMonths = this._getNumberOfMonths(inst),
1901
+ date = this._daylightSavingAdjust(new Date(curYear,
1735
1902
  curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
1736
- if (offset < 0)
1903
+
1904
+ if (offset < 0) {
1737
1905
  date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
1906
+ }
1738
1907
  return this._isInRange(inst, date);
1739
1908
  },
1740
1909
 
1741
1910
  /* Is the given date in the accepted range? */
1742
1911
  _isInRange: function(inst, date) {
1743
- var minDate = this._getMinMaxDate(inst, 'min');
1744
- var maxDate = this._getMinMaxDate(inst, 'max');
1912
+ var yearSplit, currentYear,
1913
+ minDate = this._getMinMaxDate(inst, "min"),
1914
+ maxDate = this._getMinMaxDate(inst, "max"),
1915
+ minYear = null,
1916
+ maxYear = null,
1917
+ years = this._get(inst, "yearRange");
1918
+ if (years){
1919
+ yearSplit = years.split(":");
1920
+ currentYear = new Date().getFullYear();
1921
+ minYear = parseInt(yearSplit[0], 10);
1922
+ maxYear = parseInt(yearSplit[1], 10);
1923
+ if ( yearSplit[0].match(/[+\-].*/) ) {
1924
+ minYear += currentYear;
1925
+ }
1926
+ if ( yearSplit[1].match(/[+\-].*/) ) {
1927
+ maxYear += currentYear;
1928
+ }
1929
+ }
1930
+
1745
1931
  return ((!minDate || date.getTime() >= minDate.getTime()) &&
1746
- (!maxDate || date.getTime() <= maxDate.getTime()));
1932
+ (!maxDate || date.getTime() <= maxDate.getTime()) &&
1933
+ (!minYear || date.getFullYear() >= minYear) &&
1934
+ (!maxYear || date.getFullYear() <= maxYear));
1747
1935
  },
1748
1936
 
1749
1937
  /* Provide the configuration settings for formatting/parsing. */
1750
1938
  _getFormatConfig: function(inst) {
1751
- var shortYearCutoff = this._get(inst, 'shortYearCutoff');
1752
- shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
1939
+ var shortYearCutoff = this._get(inst, "shortYearCutoff");
1940
+ shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
1753
1941
  new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
1754
1942
  return {shortYearCutoff: shortYearCutoff,
1755
- dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'),
1756
- monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')};
1943
+ dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
1944
+ monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
1757
1945
  },
1758
1946
 
1759
1947
  /* Format the given date for display. */
@@ -1763,10 +1951,10 @@ $.extend(Datepicker.prototype, {
1763
1951
  inst.currentMonth = inst.selectedMonth;
1764
1952
  inst.currentYear = inst.selectedYear;
1765
1953
  }
1766
- var date = (day ? (typeof day == 'object' ? day :
1954
+ var date = (day ? (typeof day === "object" ? day :
1767
1955
  this._daylightSavingAdjust(new Date(year, month, day))) :
1768
1956
  this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
1769
- return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst));
1957
+ return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
1770
1958
  }
1771
1959
  });
1772
1960
 
@@ -1776,18 +1964,26 @@ $.extend(Datepicker.prototype, {
1776
1964
  * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
1777
1965
  */
1778
1966
  function bindHover(dpDiv) {
1779
- var selector = 'button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a';
1780
- return dpDiv.delegate(selector, 'mouseout', function() {
1781
- $(this).removeClass('ui-state-hover');
1782
- if (this.className.indexOf('ui-datepicker-prev') != -1) $(this).removeClass('ui-datepicker-prev-hover');
1783
- if (this.className.indexOf('ui-datepicker-next') != -1) $(this).removeClass('ui-datepicker-next-hover');
1967
+ var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
1968
+ return dpDiv.delegate(selector, "mouseout", function() {
1969
+ $(this).removeClass("ui-state-hover");
1970
+ if (this.className.indexOf("ui-datepicker-prev") !== -1) {
1971
+ $(this).removeClass("ui-datepicker-prev-hover");
1972
+ }
1973
+ if (this.className.indexOf("ui-datepicker-next") !== -1) {
1974
+ $(this).removeClass("ui-datepicker-next-hover");
1975
+ }
1784
1976
  })
1785
- .delegate(selector, 'mouseover', function(){
1977
+ .delegate(selector, "mouseover", function(){
1786
1978
  if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
1787
- $(this).parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover');
1788
- $(this).addClass('ui-state-hover');
1789
- if (this.className.indexOf('ui-datepicker-prev') != -1) $(this).addClass('ui-datepicker-prev-hover');
1790
- if (this.className.indexOf('ui-datepicker-next') != -1) $(this).addClass('ui-datepicker-next-hover');
1979
+ $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
1980
+ $(this).addClass("ui-state-hover");
1981
+ if (this.className.indexOf("ui-datepicker-prev") !== -1) {
1982
+ $(this).addClass("ui-datepicker-prev-hover");
1983
+ }
1984
+ if (this.className.indexOf("ui-datepicker-next") !== -1) {
1985
+ $(this).addClass("ui-datepicker-next-hover");
1986
+ }
1791
1987
  }
1792
1988
  });
1793
1989
  }
@@ -1795,15 +1991,17 @@ function bindHover(dpDiv) {
1795
1991
  /* jQuery extend now ignores nulls! */
1796
1992
  function extendRemove(target, props) {
1797
1993
  $.extend(target, props);
1798
- for (var name in props)
1799
- if (props[name] == null || props[name] == undefined)
1994
+ for (var name in props) {
1995
+ if (props[name] == null) {
1800
1996
  target[name] = props[name];
1997
+ }
1998
+ }
1801
1999
  return target;
1802
- };
2000
+ }
1803
2001
 
1804
2002
  /* Invoke the datepicker functionality.
1805
2003
  @param options string - a command, optionally followed by additional parameters or
1806
- Object - settings for attaching new datepicker functionality
2004
+ Object - settings for attaching new datepicker functionality
1807
2005
  @return jQuery object */
1808
2006
  $.fn.datepicker = function(options){
1809
2007
 
@@ -1814,21 +2012,27 @@ $.fn.datepicker = function(options){
1814
2012
 
1815
2013
  /* Initialise the date picker. */
1816
2014
  if (!$.datepicker.initialized) {
1817
- $(document).mousedown($.datepicker._checkExternalClick).
1818
- find(document.body).append($.datepicker.dpDiv);
2015
+ $(document).mousedown($.datepicker._checkExternalClick);
1819
2016
  $.datepicker.initialized = true;
1820
2017
  }
1821
2018
 
2019
+ /* Append datepicker main container to body if not exist. */
2020
+ if ($("#"+$.datepicker._mainDivId).length === 0) {
2021
+ $("body").append($.datepicker.dpDiv);
2022
+ }
2023
+
1822
2024
  var otherArgs = Array.prototype.slice.call(arguments, 1);
1823
- if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate' || options == 'widget'))
1824
- return $.datepicker['_' + options + 'Datepicker'].
2025
+ if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
2026
+ return $.datepicker["_" + options + "Datepicker"].
1825
2027
  apply($.datepicker, [this[0]].concat(otherArgs));
1826
- if (options == 'option' && arguments.length == 2 && typeof arguments[1] == 'string')
1827
- return $.datepicker['_' + options + 'Datepicker'].
2028
+ }
2029
+ if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
2030
+ return $.datepicker["_" + options + "Datepicker"].
1828
2031
  apply($.datepicker, [this[0]].concat(otherArgs));
2032
+ }
1829
2033
  return this.each(function() {
1830
- typeof options == 'string' ?
1831
- $.datepicker['_' + options + 'Datepicker'].
2034
+ typeof options === "string" ?
2035
+ $.datepicker["_" + options + "Datepicker"].
1832
2036
  apply($.datepicker, [this].concat(otherArgs)) :
1833
2037
  $.datepicker._attachDatepicker(this, options);
1834
2038
  });
@@ -1837,10 +2041,10 @@ $.fn.datepicker = function(options){
1837
2041
  $.datepicker = new Datepicker(); // singleton instance
1838
2042
  $.datepicker.initialized = false;
1839
2043
  $.datepicker.uuid = new Date().getTime();
1840
- $.datepicker.version = "1.9.2";
2044
+ $.datepicker.version = "1.10.1";
1841
2045
 
1842
2046
  // Workaround for #4055
1843
2047
  // Add another global to avoid noConflict issues with inline event handlers
1844
- window['DP_jQuery_' + dpuuid] = $;
2048
+ window["DP_jQuery_" + dpuuid] = $;
1845
2049
 
1846
2050
  })(jQuery);