daddy 0.2.19 → 0.2.20

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