jquery-ui-rails 3.0.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jquery-ui-rails might be problematic. Click here for more details.

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