Révision 503b3f7b
Ajouté par Assos Assos il y a environ 10 ans
drupal7/sites/all/modules/jquery_update/replace/ui/ui/jquery.ui.datepicker.js | ||
---|---|---|
1 |
/* |
|
2 |
* jQuery UI Datepicker 1.8.11 |
|
1 |
/*! |
|
2 |
* jQuery UI Datepicker 1.10.2 |
|
3 |
* http://jqueryui.com |
|
3 | 4 |
* |
4 |
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
5 |
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
5 |
* Copyright 2013 jQuery Foundation and other contributors
|
|
6 |
* Released under the MIT license.
|
|
6 | 7 |
* http://jquery.org/license |
7 | 8 |
* |
8 |
* http://docs.jquery.com/UI/Datepicker
|
|
9 |
* http://api.jqueryui.com/datepicker/
|
|
9 | 10 |
* |
10 | 11 |
* Depends: |
11 | 12 |
* jquery.ui.core.js |
12 | 13 |
*/ |
13 | 14 |
(function( $, undefined ) { |
14 | 15 |
|
15 |
$.extend($.ui, { datepicker: { version: "1.8.11" } });
|
|
16 |
$.extend($.ui, { datepicker: { version: "1.10.2" } });
|
|
16 | 17 |
|
17 |
var PROP_NAME = 'datepicker'; |
|
18 |
var dpuuid = new Date().getTime(); |
|
18 |
var PROP_NAME = "datepicker", |
|
19 |
dpuuid = new Date().getTime(), |
|
20 |
instActive; |
|
19 | 21 |
|
20 | 22 |
/* Date picker manager. |
21 | 23 |
Use the singleton instance of this class, $.datepicker, to interact with the date picker. |
... | ... | |
23 | 25 |
allowing multiple different settings on the same page. */ |
24 | 26 |
|
25 | 27 |
function Datepicker() { |
26 |
this.debug = false; // Change this to true to start debugging |
|
27 | 28 |
this._curInst = null; // The current instance in use |
28 | 29 |
this._keyEvent = false; // If the last event was a key event |
29 | 30 |
this._disabledInputs = []; // List of date picker inputs that have been disabled |
30 | 31 |
this._datepickerShowing = false; // True if the popup picker is showing , false if not |
31 | 32 |
this._inDialog = false; // True if showing within a "dialog", false if not |
32 |
this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
|
|
33 |
this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class
|
|
34 |
this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
|
|
35 |
this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
|
|
36 |
this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
|
|
37 |
this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class
|
|
38 |
this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
|
|
39 |
this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
|
|
40 |
this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class
|
|
33 |
this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
|
|
34 |
this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
|
|
35 |
this._appendClass = "ui-datepicker-append"; // The name of the append marker class
|
|
36 |
this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
|
|
37 |
this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
|
|
38 |
this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
|
|
39 |
this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
|
|
40 |
this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
|
|
41 |
this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
|
|
41 | 42 |
this.regional = []; // Available regional settings, indexed by language code |
42 |
this.regional[''] = { // Default regional settings
|
|
43 |
closeText: 'Done', // Display text for close link
|
|
44 |
prevText: 'Prev', // Display text for previous month link
|
|
45 |
nextText: 'Next', // Display text for next month link
|
|
46 |
currentText: 'Today', // Display text for current month link
|
|
47 |
monthNames: ['January','February','March','April','May','June',
|
|
48 |
'July','August','September','October','November','December'], // Names of months for drop-down and formatting
|
|
49 |
monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
|
|
50 |
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
|
|
51 |
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
|
|
52 |
dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
|
|
53 |
weekHeader: 'Wk', // Column header for week of the year
|
|
54 |
dateFormat: 'mm/dd/yy', // See format options on parseDate
|
|
43 |
this.regional[""] = { // Default regional settings
|
|
44 |
closeText: "Done", // Display text for close link
|
|
45 |
prevText: "Prev", // Display text for previous month link
|
|
46 |
nextText: "Next", // Display text for next month link
|
|
47 |
currentText: "Today", // Display text for current month link
|
|
48 |
monthNames: ["January","February","March","April","May","June",
|
|
49 |
"July","August","September","October","November","December"], // Names of months for drop-down and formatting
|
|
50 |
monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
|
|
51 |
dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
|
|
52 |
dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
|
|
53 |
dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
|
|
54 |
weekHeader: "Wk", // Column header for week of the year
|
|
55 |
dateFormat: "mm/dd/yy", // See format options on parseDate
|
|
55 | 56 |
firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ... |
56 | 57 |
isRTL: false, // True if right-to-left language, false if left-to-right |
57 | 58 |
showMonthAfterYear: false, // True if the year select precedes month, false for month then year |
58 |
yearSuffix: '' // Additional text to append to the year in the month headers
|
|
59 |
yearSuffix: "" // Additional text to append to the year in the month headers
|
|
59 | 60 |
}; |
60 | 61 |
this._defaults = { // Global defaults for all the date picker instances |
61 |
showOn: 'focus', // 'focus' for popup on focus,
|
|
62 |
// 'button' for trigger button, or 'both' for either
|
|
63 |
showAnim: 'fadeIn', // Name of jQuery animation for popup
|
|
62 |
showOn: "focus", // "focus" for popup on focus,
|
|
63 |
// "button" for trigger button, or "both" for either
|
|
64 |
showAnim: "fadeIn", // Name of jQuery animation for popup
|
|
64 | 65 |
showOptions: {}, // Options for enhanced animations |
65 | 66 |
defaultDate: null, // Used when field is blank: actual date, |
66 | 67 |
// +/-number for offset from today, null for today |
67 |
appendText: '', // Display text following the input box, e.g. showing the format
|
|
68 |
buttonText: '...', // Text for trigger button
|
|
69 |
buttonImage: '', // URL for trigger button image
|
|
68 |
appendText: "", // Display text following the input box, e.g. showing the format
|
|
69 |
buttonText: "...", // Text for trigger button
|
|
70 |
buttonImage: "", // URL for trigger button image
|
|
70 | 71 |
buttonImageOnly: false, // True if the image appears alone, false if it appears on a button |
71 | 72 |
hideIfNoPrevNext: false, // True to hide next/previous month links |
72 | 73 |
// if not applicable, false to just disable them |
... | ... | |
74 | 75 |
gotoCurrent: false, // True if today link goes back to current selection instead |
75 | 76 |
changeMonth: false, // True if month can be selected directly, false if only prev/next |
76 | 77 |
changeYear: false, // True if year can be selected directly, false if only prev/next |
77 |
yearRange: 'c-10:c+10', // Range of years to display in drop-down,
|
|
78 |
yearRange: "c-10:c+10", // Range of years to display in drop-down,
|
|
78 | 79 |
// either relative to today's year (-nn:+nn), relative to currently displayed year |
79 | 80 |
// (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n) |
80 | 81 |
showOtherMonths: false, // True to show dates in other months, false to leave blank |
... | ... | |
82 | 83 |
showWeek: false, // True to show week of the year, false to not show it |
83 | 84 |
calculateWeek: this.iso8601Week, // How to calculate the week of the year, |
84 | 85 |
// takes a Date and returns the number of the week for it |
85 |
shortYearCutoff: '+10', // Short year values < this are in the current century,
|
|
86 |
shortYearCutoff: "+10", // Short year values < this are in the current century,
|
|
86 | 87 |
// > this are in the previous century, |
87 |
// string value starting with '+' for current year + value
|
|
88 |
// string value starting with "+" for current year + value
|
|
88 | 89 |
minDate: null, // The earliest selectable date, or null for no limit |
89 | 90 |
maxDate: null, // The latest selectable date, or null for no limit |
90 |
duration: 'fast', // Duration of display/closure
|
|
91 |
duration: "fast", // Duration of display/closure
|
|
91 | 92 |
beforeShowDay: null, // Function that takes a date and returns an array with |
92 |
// [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '',
|
|
93 |
// [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
|
|
93 | 94 |
// [2] = cell title (optional), e.g. $.datepicker.noWeekends |
94 | 95 |
beforeShow: null, // Function that takes an input field and |
95 | 96 |
// returns a set of custom settings for the date picker |
... | ... | |
100 | 101 |
showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0) |
101 | 102 |
stepMonths: 1, // Number of months to step back/forward |
102 | 103 |
stepBigMonths: 12, // Number of months to step back/forward for the big links |
103 |
altField: '', // Selector for an alternate field to store selected dates into
|
|
104 |
altFormat: '', // The date format to use for the alternate field
|
|
104 |
altField: "", // Selector for an alternate field to store selected dates into
|
|
105 |
altFormat: "", // The date format to use for the alternate field
|
|
105 | 106 |
constrainInput: true, // The input is constrained by the current date format |
106 | 107 |
showButtonPanel: false, // True to show button panel, false to not show it |
107 |
autoSize: false // True to size the input for the date format, false to leave as is |
|
108 |
autoSize: false, // True to size the input for the date format, false to leave as is |
|
109 |
disabled: false // The initial disabled state |
|
108 | 110 |
}; |
109 |
$.extend(this._defaults, this.regional['']);
|
|
110 |
this.dpDiv = $('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>');
|
|
111 |
$.extend(this._defaults, this.regional[""]);
|
|
112 |
this.dpDiv = bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
|
|
111 | 113 |
} |
112 | 114 |
|
113 | 115 |
$.extend(Datepicker.prototype, { |
114 | 116 |
/* Class name added to elements to indicate already configured with a date picker. */ |
115 |
markerClassName: 'hasDatepicker', |
|
117 |
markerClassName: "hasDatepicker", |
|
118 |
|
|
119 |
//Keep track of the maximum number of rows displayed (see #7043) |
|
120 |
maxRows: 4, |
|
116 | 121 |
|
117 |
/* Debug logging (if enabled). */ |
|
118 |
log: function () { |
|
119 |
if (this.debug) |
|
120 |
console.log.apply('', arguments); |
|
121 |
}, |
|
122 |
|
|
123 | 122 |
// TODO rename to "widget" when switching to widget factory |
124 | 123 |
_widgetDatepicker: function() { |
125 | 124 |
return this.dpDiv; |
126 | 125 |
}, |
127 | 126 |
|
128 | 127 |
/* Override the default settings for all instances of the date picker. |
129 |
@param settings object - the new settings to use as defaults (anonymous object) |
|
130 |
@return the manager object */ |
|
128 |
* @param settings object - the new settings to use as defaults (anonymous object) |
|
129 |
* @return the manager object |
|
130 |
*/ |
|
131 | 131 |
setDefaults: function(settings) { |
132 | 132 |
extendRemove(this._defaults, settings || {}); |
133 | 133 |
return this; |
134 | 134 |
}, |
135 | 135 |
|
136 | 136 |
/* Attach the date picker to a jQuery selection. |
137 |
@param target element - the target input field or division or span |
|
138 |
@param settings object - the new settings to use for this date picker instance (anonymous) */ |
|
137 |
* @param target element - the target input field or division or span |
|
138 |
* @param settings object - the new settings to use for this date picker instance (anonymous) |
|
139 |
*/ |
|
139 | 140 |
_attachDatepicker: function(target, settings) { |
140 |
// check for settings on the control itself - in namespace 'date:' |
|
141 |
var inlineSettings = null; |
|
142 |
for (var attrName in this._defaults) { |
|
143 |
var attrValue = target.getAttribute('date:' + attrName); |
|
144 |
if (attrValue) { |
|
145 |
inlineSettings = inlineSettings || {}; |
|
146 |
try { |
|
147 |
inlineSettings[attrName] = eval(attrValue); |
|
148 |
} catch (err) { |
|
149 |
inlineSettings[attrName] = attrValue; |
|
150 |
} |
|
151 |
} |
|
152 |
} |
|
153 |
var nodeName = target.nodeName.toLowerCase(); |
|
154 |
var inline = (nodeName == 'div' || nodeName == 'span'); |
|
141 |
var nodeName, inline, inst; |
|
142 |
nodeName = target.nodeName.toLowerCase(); |
|
143 |
inline = (nodeName === "div" || nodeName === "span"); |
|
155 | 144 |
if (!target.id) { |
156 | 145 |
this.uuid += 1; |
157 |
target.id = 'dp' + this.uuid;
|
|
146 |
target.id = "dp" + this.uuid;
|
|
158 | 147 |
} |
159 |
var inst = this._newInst($(target), inline);
|
|
160 |
inst.settings = $.extend({}, settings || {}, inlineSettings || {});
|
|
161 |
if (nodeName == 'input') {
|
|
148 |
inst = this._newInst($(target), inline); |
|
149 |
inst.settings = $.extend({}, settings || {}); |
|
150 |
if (nodeName === "input") {
|
|
162 | 151 |
this._connectDatepicker(target, inst); |
163 | 152 |
} else if (inline) { |
164 | 153 |
this._inlineDatepicker(target, inst); |
... | ... | |
167 | 156 |
|
168 | 157 |
/* Create a new instance object. */ |
169 | 158 |
_newInst: function(target, inline) { |
170 |
var id = target[0].id.replace(/([^A-Za-z0-9_-])/g, '\\\\$1'); // escape jQuery meta chars
|
|
159 |
var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
|
|
171 | 160 |
return {id: id, input: target, // associated target |
172 | 161 |
selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection |
173 | 162 |
drawMonth: 0, drawYear: 0, // month being drawn |
174 | 163 |
inline: inline, // is datepicker inline or not |
175 | 164 |
dpDiv: (!inline ? this.dpDiv : // presentation div |
176 |
$('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))};
|
|
165 |
bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
|
|
177 | 166 |
}, |
178 | 167 |
|
179 | 168 |
/* Attach the date picker to an input field. */ |
... | ... | |
181 | 170 |
var input = $(target); |
182 | 171 |
inst.append = $([]); |
183 | 172 |
inst.trigger = $([]); |
184 |
if (input.hasClass(this.markerClassName)) |
|
173 |
if (input.hasClass(this.markerClassName)) {
|
|
185 | 174 |
return; |
175 |
} |
|
186 | 176 |
this._attachments(input, inst); |
187 | 177 |
input.addClass(this.markerClassName).keydown(this._doKeyDown). |
188 |
keypress(this._doKeyPress).keyup(this._doKeyUp). |
|
189 |
bind("setData.datepicker", function(event, key, value) { |
|
190 |
inst.settings[key] = value; |
|
191 |
}).bind("getData.datepicker", function(event, key) { |
|
192 |
return this._get(inst, key); |
|
193 |
}); |
|
178 |
keypress(this._doKeyPress).keyup(this._doKeyUp); |
|
194 | 179 |
this._autoSize(inst); |
195 | 180 |
$.data(target, PROP_NAME, inst); |
181 |
//If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665) |
|
182 |
if( inst.settings.disabled ) { |
|
183 |
this._disableDatepicker( target ); |
|
184 |
} |
|
196 | 185 |
}, |
197 | 186 |
|
198 | 187 |
/* Make attachments based on settings. */ |
199 | 188 |
_attachments: function(input, inst) { |
200 |
var appendText = this._get(inst, 'appendText'); |
|
201 |
var isRTL = this._get(inst, 'isRTL'); |
|
202 |
if (inst.append) |
|
189 |
var showOn, buttonText, buttonImage, |
|
190 |
appendText = this._get(inst, "appendText"), |
|
191 |
isRTL = this._get(inst, "isRTL"); |
|
192 |
|
|
193 |
if (inst.append) { |
|
203 | 194 |
inst.append.remove(); |
195 |
} |
|
204 | 196 |
if (appendText) { |
205 |
inst.append = $('<span class="' + this._appendClass + '">' + appendText + '</span>');
|
|
206 |
input[isRTL ? 'before' : 'after'](inst.append);
|
|
197 |
inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
|
|
198 |
input[isRTL ? "before" : "after"](inst.append);
|
|
207 | 199 |
} |
208 |
input.unbind('focus', this._showDatepicker); |
|
209 |
if (inst.trigger) |
|
200 |
|
|
201 |
input.unbind("focus", this._showDatepicker); |
|
202 |
|
|
203 |
if (inst.trigger) { |
|
210 | 204 |
inst.trigger.remove(); |
211 |
var showOn = this._get(inst, 'showOn'); |
|
212 |
if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field |
|
205 |
} |
|
206 |
|
|
207 |
showOn = this._get(inst, "showOn"); |
|
208 |
if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field |
|
213 | 209 |
input.focus(this._showDatepicker); |
214 |
if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked |
|
215 |
var buttonText = this._get(inst, 'buttonText'); |
|
216 |
var buttonImage = this._get(inst, 'buttonImage'); |
|
217 |
inst.trigger = $(this._get(inst, 'buttonImageOnly') ? |
|
218 |
$('<img/>').addClass(this._triggerClass). |
|
210 |
} |
|
211 |
if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked |
|
212 |
buttonText = this._get(inst, "buttonText"); |
|
213 |
buttonImage = this._get(inst, "buttonImage"); |
|
214 |
inst.trigger = $(this._get(inst, "buttonImageOnly") ? |
|
215 |
$("<img/>").addClass(this._triggerClass). |
|
219 | 216 |
attr({ src: buttonImage, alt: buttonText, title: buttonText }) : |
220 |
$('<button type="button"></button>').addClass(this._triggerClass).
|
|
221 |
html(buttonImage == '' ? buttonText : $('<img/>').attr(
|
|
217 |
$("<button type='button'></button>").addClass(this._triggerClass).
|
|
218 |
html(!buttonImage ? buttonText : $("<img/>").attr(
|
|
222 | 219 |
{ src:buttonImage, alt:buttonText, title:buttonText }))); |
223 |
input[isRTL ? 'before' : 'after'](inst.trigger);
|
|
220 |
input[isRTL ? "before" : "after"](inst.trigger);
|
|
224 | 221 |
inst.trigger.click(function() { |
225 |
if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0]) |
|
222 |
if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) { |
|
223 |
$.datepicker._hideDatepicker(); |
|
224 |
} else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) { |
|
226 | 225 |
$.datepicker._hideDatepicker(); |
227 |
else |
|
228 | 226 |
$.datepicker._showDatepicker(input[0]); |
227 |
} else { |
|
228 |
$.datepicker._showDatepicker(input[0]); |
|
229 |
} |
|
229 | 230 |
return false; |
230 | 231 |
}); |
231 | 232 |
} |
... | ... | |
233 | 234 |
|
234 | 235 |
/* Apply the maximum length for the date format. */ |
235 | 236 |
_autoSize: function(inst) { |
236 |
if (this._get(inst, 'autoSize') && !inst.inline) { |
|
237 |
var date = new Date(2009, 12 - 1, 20); // Ensure double digits |
|
238 |
var dateFormat = this._get(inst, 'dateFormat'); |
|
237 |
if (this._get(inst, "autoSize") && !inst.inline) { |
|
238 |
var findMax, max, maxI, i, |
|
239 |
date = new Date(2009, 12 - 1, 20), // Ensure double digits |
|
240 |
dateFormat = this._get(inst, "dateFormat"); |
|
241 |
|
|
239 | 242 |
if (dateFormat.match(/[DM]/)) { |
240 |
var findMax = function(names) {
|
|
241 |
var max = 0;
|
|
242 |
var maxI = 0;
|
|
243 |
for (var i = 0; i < names.length; i++) {
|
|
243 |
findMax = function(names) { |
|
244 |
max = 0; |
|
245 |
maxI = 0; |
|
246 |
for (i = 0; i < names.length; i++) { |
|
244 | 247 |
if (names[i].length > max) { |
245 | 248 |
max = names[i].length; |
246 | 249 |
maxI = i; |
... | ... | |
249 | 252 |
return maxI; |
250 | 253 |
}; |
251 | 254 |
date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ? |
252 |
'monthNames' : 'monthNamesShort'))));
|
|
255 |
"monthNames" : "monthNamesShort"))));
|
|
253 | 256 |
date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ? |
254 |
'dayNames' : 'dayNamesShort'))) + 20 - date.getDay());
|
|
257 |
"dayNames" : "dayNamesShort"))) + 20 - date.getDay());
|
|
255 | 258 |
} |
256 |
inst.input.attr('size', this._formatDate(inst, date).length);
|
|
259 |
inst.input.attr("size", this._formatDate(inst, date).length);
|
|
257 | 260 |
} |
258 | 261 |
}, |
259 | 262 |
|
260 | 263 |
/* Attach an inline date picker to a div. */ |
261 | 264 |
_inlineDatepicker: function(target, inst) { |
262 | 265 |
var divSpan = $(target); |
263 |
if (divSpan.hasClass(this.markerClassName)) |
|
266 |
if (divSpan.hasClass(this.markerClassName)) {
|
|
264 | 267 |
return; |
265 |
divSpan.addClass(this.markerClassName).append(inst.dpDiv). |
|
266 |
bind("setData.datepicker", function(event, key, value){ |
|
267 |
inst.settings[key] = value; |
|
268 |
}).bind("getData.datepicker", function(event, key){ |
|
269 |
return this._get(inst, key); |
|
270 |
}); |
|
268 |
} |
|
269 |
divSpan.addClass(this.markerClassName).append(inst.dpDiv); |
|
271 | 270 |
$.data(target, PROP_NAME, inst); |
272 | 271 |
this._setDate(inst, this._getDefaultDate(inst), true); |
273 | 272 |
this._updateDatepicker(inst); |
274 | 273 |
this._updateAlternate(inst); |
275 |
inst.dpDiv.show(); |
|
274 |
//If disabled option is true, disable the datepicker before showing it (see ticket #5665) |
|
275 |
if( inst.settings.disabled ) { |
|
276 |
this._disableDatepicker( target ); |
|
277 |
} |
|
278 |
// Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements |
|
279 |
// http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height |
|
280 |
inst.dpDiv.css( "display", "block" ); |
|
276 | 281 |
}, |
277 | 282 |
|
278 | 283 |
/* Pop-up the date picker in a "dialog" box. |
279 |
@param input element - ignored |
|
280 |
@param date string or Date - the initial date to display |
|
281 |
@param onSelect function - the function to call when a date is selected |
|
282 |
@param settings object - update the dialog date picker instance's settings (anonymous object) |
|
283 |
@param pos int[2] - coordinates for the dialog's position within the screen or |
|
284 |
event - with x/y coordinates or |
|
285 |
leave empty for default (screen centre) |
|
286 |
@return the manager object */ |
|
284 |
* @param input element - ignored |
|
285 |
* @param date string or Date - the initial date to display |
|
286 |
* @param onSelect function - the function to call when a date is selected |
|
287 |
* @param settings object - update the dialog date picker instance's settings (anonymous object) |
|
288 |
* @param pos int[2] - coordinates for the dialog's position within the screen or |
|
289 |
* event - with x/y coordinates or |
|
290 |
* leave empty for default (screen centre) |
|
291 |
* @return the manager object |
|
292 |
*/ |
|
287 | 293 |
_dialogDatepicker: function(input, date, onSelect, settings, pos) { |
288 |
var inst = this._dialogInst; // internal instance |
|
294 |
var id, browserWidth, browserHeight, scrollX, scrollY, |
|
295 |
inst = this._dialogInst; // internal instance |
|
296 |
|
|
289 | 297 |
if (!inst) { |
290 | 298 |
this.uuid += 1; |
291 |
var id = 'dp' + this.uuid;
|
|
292 |
this._dialogInput = $('<input type="text" id="' + id +
|
|
293 |
'" style="position: absolute; top: -100px; width: 0px; z-index: -10;"/>');
|
|
299 |
id = "dp" + this.uuid;
|
|
300 |
this._dialogInput = $("<input type='text' id='" + id +
|
|
301 |
"' style='position: absolute; top: -100px; width: 0px;'/>");
|
|
294 | 302 |
this._dialogInput.keydown(this._doKeyDown); |
295 |
$('body').append(this._dialogInput);
|
|
303 |
$("body").append(this._dialogInput);
|
|
296 | 304 |
inst = this._dialogInst = this._newInst(this._dialogInput, false); |
297 | 305 |
inst.settings = {}; |
298 | 306 |
$.data(this._dialogInput[0], PROP_NAME, inst); |
299 | 307 |
} |
300 | 308 |
extendRemove(inst.settings, settings || {}); |
301 |
date = (date && date.constructor == Date ? this._formatDate(inst, date) : date); |
|
309 |
date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
|
|
302 | 310 |
this._dialogInput.val(date); |
303 | 311 |
|
304 | 312 |
this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null); |
305 | 313 |
if (!this._pos) { |
306 |
var browserWidth = document.documentElement.clientWidth;
|
|
307 |
var browserHeight = document.documentElement.clientHeight;
|
|
308 |
var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
|
|
309 |
var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
|
|
314 |
browserWidth = document.documentElement.clientWidth; |
|
315 |
browserHeight = document.documentElement.clientHeight; |
|
316 |
scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; |
|
317 |
scrollY = document.documentElement.scrollTop || document.body.scrollTop; |
|
310 | 318 |
this._pos = // should use actual width/height below |
311 | 319 |
[(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY]; |
312 | 320 |
} |
313 | 321 |
|
314 | 322 |
// move input on screen for focus, but hidden behind dialog |
315 |
this._dialogInput.css('left', (this._pos[0] + 20) + 'px').css('top', this._pos[1] + 'px');
|
|
323 |
this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
|
|
316 | 324 |
inst.settings.onSelect = onSelect; |
317 | 325 |
this._inDialog = true; |
318 | 326 |
this.dpDiv.addClass(this._dialogClass); |
319 | 327 |
this._showDatepicker(this._dialogInput[0]); |
320 |
if ($.blockUI) |
|
328 |
if ($.blockUI) {
|
|
321 | 329 |
$.blockUI(this.dpDiv); |
330 |
} |
|
322 | 331 |
$.data(this._dialogInput[0], PROP_NAME, inst); |
323 | 332 |
return this; |
324 | 333 |
}, |
325 | 334 |
|
326 | 335 |
/* Detach a datepicker from its control. |
327 |
@param target element - the target input field or division or span */ |
|
336 |
* @param target element - the target input field or division or span |
|
337 |
*/ |
|
328 | 338 |
_destroyDatepicker: function(target) { |
329 |
var $target = $(target); |
|
330 |
var inst = $.data(target, PROP_NAME); |
|
339 |
var nodeName, |
|
340 |
$target = $(target), |
|
341 |
inst = $.data(target, PROP_NAME); |
|
342 |
|
|
331 | 343 |
if (!$target.hasClass(this.markerClassName)) { |
332 | 344 |
return; |
333 | 345 |
} |
334 |
var nodeName = target.nodeName.toLowerCase(); |
|
346 |
|
|
347 |
nodeName = target.nodeName.toLowerCase(); |
|
335 | 348 |
$.removeData(target, PROP_NAME); |
336 |
if (nodeName == 'input') {
|
|
349 |
if (nodeName === "input") {
|
|
337 | 350 |
inst.append.remove(); |
338 | 351 |
inst.trigger.remove(); |
339 | 352 |
$target.removeClass(this.markerClassName). |
340 |
unbind('focus', this._showDatepicker).
|
|
341 |
unbind('keydown', this._doKeyDown).
|
|
342 |
unbind('keypress', this._doKeyPress).
|
|
343 |
unbind('keyup', this._doKeyUp);
|
|
344 |
} else if (nodeName == 'div' || nodeName == 'span')
|
|
353 |
unbind("focus", this._showDatepicker).
|
|
354 |
unbind("keydown", this._doKeyDown).
|
|
355 |
unbind("keypress", this._doKeyPress).
|
|
356 |
unbind("keyup", this._doKeyUp);
|
|
357 |
} else if (nodeName === "div" || nodeName === "span") {
|
|
345 | 358 |
$target.removeClass(this.markerClassName).empty(); |
359 |
} |
|
346 | 360 |
}, |
347 | 361 |
|
348 | 362 |
/* Enable the date picker to a jQuery selection. |
349 |
@param target element - the target input field or division or span */ |
|
363 |
* @param target element - the target input field or division or span |
|
364 |
*/ |
|
350 | 365 |
_enableDatepicker: function(target) { |
351 |
var $target = $(target); |
|
352 |
var inst = $.data(target, PROP_NAME); |
|
366 |
var nodeName, inline, |
|
367 |
$target = $(target), |
|
368 |
inst = $.data(target, PROP_NAME); |
|
369 |
|
|
353 | 370 |
if (!$target.hasClass(this.markerClassName)) { |
354 | 371 |
return; |
355 | 372 |
} |
356 |
var nodeName = target.nodeName.toLowerCase(); |
|
357 |
if (nodeName == 'input') { |
|
373 |
|
|
374 |
nodeName = target.nodeName.toLowerCase(); |
|
375 |
if (nodeName === "input") { |
|
358 | 376 |
target.disabled = false; |
359 |
inst.trigger.filter('button').
|
|
377 |
inst.trigger.filter("button").
|
|
360 | 378 |
each(function() { this.disabled = false; }).end(). |
361 |
filter('img').css({opacity: '1.0', cursor: ''}); |
|
362 |
} |
|
363 |
else if (nodeName == 'div' || nodeName == 'span') { |
|
364 |
var inline = $target.children('.' + this._inlineClass); |
|
365 |
inline.children().removeClass('ui-state-disabled'); |
|
379 |
filter("img").css({opacity: "1.0", cursor: ""}); |
|
380 |
} else if (nodeName === "div" || nodeName === "span") { |
|
381 |
inline = $target.children("." + this._inlineClass); |
|
382 |
inline.children().removeClass("ui-state-disabled"); |
|
383 |
inline.find("select.ui-datepicker-month, select.ui-datepicker-year"). |
|
384 |
prop("disabled", false); |
|
366 | 385 |
} |
367 | 386 |
this._disabledInputs = $.map(this._disabledInputs, |
368 |
function(value) { return (value == target ? null : value); }); // delete entry |
|
387 |
function(value) { return (value === target ? null : value); }); // delete entry
|
|
369 | 388 |
}, |
370 | 389 |
|
371 | 390 |
/* Disable the date picker to a jQuery selection. |
372 |
@param target element - the target input field or division or span */ |
|
391 |
* @param target element - the target input field or division or span |
|
392 |
*/ |
|
373 | 393 |
_disableDatepicker: function(target) { |
374 |
var $target = $(target); |
|
375 |
var inst = $.data(target, PROP_NAME); |
|
394 |
var nodeName, inline, |
|
395 |
$target = $(target), |
|
396 |
inst = $.data(target, PROP_NAME); |
|
397 |
|
|
376 | 398 |
if (!$target.hasClass(this.markerClassName)) { |
377 | 399 |
return; |
378 | 400 |
} |
379 |
var nodeName = target.nodeName.toLowerCase(); |
|
380 |
if (nodeName == 'input') { |
|
401 |
|
|
402 |
nodeName = target.nodeName.toLowerCase(); |
|
403 |
if (nodeName === "input") { |
|
381 | 404 |
target.disabled = true; |
382 |
inst.trigger.filter('button').
|
|
405 |
inst.trigger.filter("button").
|
|
383 | 406 |
each(function() { this.disabled = true; }).end(). |
384 |
filter('img').css({opacity: '0.5', cursor: 'default'}); |
|
385 |
} |
|
386 |
else if (nodeName == 'div' || nodeName == 'span') { |
|
387 |
var inline = $target.children('.' + this._inlineClass); |
|
388 |
inline.children().addClass('ui-state-disabled'); |
|
407 |
filter("img").css({opacity: "0.5", cursor: "default"}); |
|
408 |
} else if (nodeName === "div" || nodeName === "span") { |
|
409 |
inline = $target.children("." + this._inlineClass); |
|
410 |
inline.children().addClass("ui-state-disabled"); |
|
411 |
inline.find("select.ui-datepicker-month, select.ui-datepicker-year"). |
|
412 |
prop("disabled", true); |
|
389 | 413 |
} |
390 | 414 |
this._disabledInputs = $.map(this._disabledInputs, |
391 |
function(value) { return (value == target ? null : value); }); // delete entry |
|
415 |
function(value) { return (value === target ? null : value); }); // delete entry
|
|
392 | 416 |
this._disabledInputs[this._disabledInputs.length] = target; |
393 | 417 |
}, |
394 | 418 |
|
395 | 419 |
/* Is the first field in a jQuery collection disabled as a datepicker? |
396 |
@param target element - the target input field or division or span |
|
397 |
@return boolean - true if disabled, false if enabled */ |
|
420 |
* @param target element - the target input field or division or span |
|
421 |
* @return boolean - true if disabled, false if enabled |
|
422 |
*/ |
|
398 | 423 |
_isDisabledDatepicker: function(target) { |
399 | 424 |
if (!target) { |
400 | 425 |
return false; |
401 | 426 |
} |
402 | 427 |
for (var i = 0; i < this._disabledInputs.length; i++) { |
403 |
if (this._disabledInputs[i] == target)
|
|
428 |
if (this._disabledInputs[i] === target) {
|
|
404 | 429 |
return true; |
430 |
} |
|
405 | 431 |
} |
406 | 432 |
return false; |
407 | 433 |
}, |
408 | 434 |
|
409 | 435 |
/* Retrieve the instance data for the target control. |
410 |
@param target element - the target input field or division or span |
|
411 |
@return object - the associated instance data |
|
412 |
@throws error if a jQuery problem getting data */ |
|
436 |
* @param target element - the target input field or division or span |
|
437 |
* @return object - the associated instance data |
|
438 |
* @throws error if a jQuery problem getting data |
|
439 |
*/ |
|
413 | 440 |
_getInst: function(target) { |
414 | 441 |
try { |
415 | 442 |
return $.data(target, PROP_NAME); |
416 | 443 |
} |
417 | 444 |
catch (err) { |
418 |
throw 'Missing instance data for this datepicker';
|
|
445 |
throw "Missing instance data for this datepicker";
|
|
419 | 446 |
} |
420 | 447 |
}, |
421 | 448 |
|
422 | 449 |
/* Update or retrieve the settings for a date picker attached to an input field or division. |
423 |
@param target element - the target input field or division or span |
|
424 |
@param name object - the new settings to update or |
|
425 |
string - the name of the setting to change or retrieve, |
|
426 |
when retrieving also 'all' for all instance settings or |
|
427 |
'defaults' for all global defaults |
|
428 |
@param value any - the new value for the setting |
|
429 |
(omit if above is an object or to retrieve a value) */ |
|
450 |
* @param target element - the target input field or division or span |
|
451 |
* @param name object - the new settings to update or |
|
452 |
* string - the name of the setting to change or retrieve, |
|
453 |
* when retrieving also "all" for all instance settings or |
|
454 |
* "defaults" for all global defaults |
|
455 |
* @param value any - the new value for the setting |
|
456 |
* (omit if above is an object or to retrieve a value) |
|
457 |
*/ |
|
430 | 458 |
_optionDatepicker: function(target, name, value) { |
431 |
var inst = this._getInst(target); |
|
432 |
if (arguments.length == 2 && typeof name == 'string') { |
|
433 |
return (name == 'defaults' ? $.extend({}, $.datepicker._defaults) : |
|
434 |
(inst ? (name == 'all' ? $.extend({}, inst.settings) : |
|
459 |
var settings, date, minDate, maxDate, |
|
460 |
inst = this._getInst(target); |
|
461 |
|
|
462 |
if (arguments.length === 2 && typeof name === "string") { |
|
463 |
return (name === "defaults" ? $.extend({}, $.datepicker._defaults) : |
|
464 |
(inst ? (name === "all" ? $.extend({}, inst.settings) : |
|
435 | 465 |
this._get(inst, name)) : null)); |
436 | 466 |
} |
437 |
var settings = name || {}; |
|
438 |
if (typeof name == 'string') { |
|
467 |
|
|
468 |
settings = name || {}; |
|
469 |
if (typeof name === "string") { |
|
439 | 470 |
settings = {}; |
440 | 471 |
settings[name] = value; |
441 | 472 |
} |
473 |
|
|
442 | 474 |
if (inst) { |
443 |
if (this._curInst == inst) { |
|
475 |
if (this._curInst === inst) {
|
|
444 | 476 |
this._hideDatepicker(); |
445 | 477 |
} |
446 |
var date = this._getDateDatepicker(target, true); |
|
447 |
var minDate = this._getMinMaxDate(inst, 'min'); |
|
448 |
var maxDate = this._getMinMaxDate(inst, 'max'); |
|
478 |
|
|
479 |
date = this._getDateDatepicker(target, true); |
|
480 |
minDate = this._getMinMaxDate(inst, "min"); |
|
481 |
maxDate = this._getMinMaxDate(inst, "max"); |
|
449 | 482 |
extendRemove(inst.settings, settings); |
450 | 483 |
// reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided |
451 |
if (minDate !== null && settings['dateFormat'] !== undefined && settings['minDate'] === undefined)
|
|
484 |
if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
|
|
452 | 485 |
inst.settings.minDate = this._formatDate(inst, minDate); |
453 |
if (maxDate !== null && settings['dateFormat'] !== undefined && settings['maxDate'] === undefined) |
|
486 |
} |
|
487 |
if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) { |
|
454 | 488 |
inst.settings.maxDate = this._formatDate(inst, maxDate); |
489 |
} |
|
490 |
if ( "disabled" in settings ) { |
|
491 |
if ( settings.disabled ) { |
|
492 |
this._disableDatepicker(target); |
|
493 |
} else { |
|
494 |
this._enableDatepicker(target); |
|
495 |
} |
|
496 |
} |
|
455 | 497 |
this._attachments($(target), inst); |
456 | 498 |
this._autoSize(inst); |
457 |
this._setDateDatepicker(target, date); |
|
499 |
this._setDate(inst, date); |
|
500 |
this._updateAlternate(inst); |
|
458 | 501 |
this._updateDatepicker(inst); |
459 | 502 |
} |
460 | 503 |
}, |
... | ... | |
465 | 508 |
}, |
466 | 509 |
|
467 | 510 |
/* Redraw the date picker attached to an input field or division. |
468 |
@param target element - the target input field or division or span */ |
|
511 |
* @param target element - the target input field or division or span |
|
512 |
*/ |
|
469 | 513 |
_refreshDatepicker: function(target) { |
470 | 514 |
var inst = this._getInst(target); |
471 | 515 |
if (inst) { |
... | ... | |
474 | 518 |
}, |
475 | 519 |
|
476 | 520 |
/* Set the dates for a jQuery selection. |
477 |
@param target element - the target input field or division or span |
|
478 |
@param date Date - the new date */ |
|
521 |
* @param target element - the target input field or division or span |
|
522 |
* @param date Date - the new date |
|
523 |
*/ |
|
479 | 524 |
_setDateDatepicker: function(target, date) { |
480 | 525 |
var inst = this._getInst(target); |
481 | 526 |
if (inst) { |
... | ... | |
486 | 531 |
}, |
487 | 532 |
|
488 | 533 |
/* Get the date(s) for the first entry in a jQuery selection. |
489 |
@param target element - the target input field or division or span |
|
490 |
@param noDefault boolean - true if no default date is to be used |
|
491 |
@return Date - the current date */ |
|
534 |
* @param target element - the target input field or division or span |
|
535 |
* @param noDefault boolean - true if no default date is to be used |
|
536 |
* @return Date - the current date |
|
537 |
*/ |
|
492 | 538 |
_getDateDatepicker: function(target, noDefault) { |
493 | 539 |
var inst = this._getInst(target); |
494 |
if (inst && !inst.inline) |
|
540 |
if (inst && !inst.inline) {
|
|
495 | 541 |
this._setDateFromField(inst, noDefault); |
542 |
} |
|
496 | 543 |
return (inst ? this._getDate(inst) : null); |
497 | 544 |
}, |
498 | 545 |
|
499 | 546 |
/* Handle keystrokes. */ |
500 | 547 |
_doKeyDown: function(event) { |
501 |
var inst = $.datepicker._getInst(event.target); |
|
502 |
var handled = true; |
|
503 |
var isRTL = inst.dpDiv.is('.ui-datepicker-rtl'); |
|
548 |
var onSelect, dateStr, sel, |
|
549 |
inst = $.datepicker._getInst(event.target), |
|
550 |
handled = true, |
|
551 |
isRTL = inst.dpDiv.is(".ui-datepicker-rtl"); |
|
552 |
|
|
504 | 553 |
inst._keyEvent = true; |
505 |
if ($.datepicker._datepickerShowing) |
|
554 |
if ($.datepicker._datepickerShowing) {
|
|
506 | 555 |
switch (event.keyCode) { |
507 | 556 |
case 9: $.datepicker._hideDatepicker(); |
508 | 557 |
handled = false; |
509 | 558 |
break; // hide on tab out |
510 |
case 13: var sel = $('td.' + $.datepicker._dayOverClass + ':not(.' +
|
|
511 |
$.datepicker._currentClass + ')', inst.dpDiv);
|
|
512 |
if (sel[0]) |
|
559 |
case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
|
|
560 |
$.datepicker._currentClass + ")", inst.dpDiv);
|
|
561 |
if (sel[0]) {
|
|
513 | 562 |
$.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]); |
514 |
else |
|
563 |
} |
|
564 |
|
|
565 |
onSelect = $.datepicker._get(inst, "onSelect"); |
|
566 |
if (onSelect) { |
|
567 |
dateStr = $.datepicker._formatDate(inst); |
|
568 |
|
|
569 |
// trigger custom callback |
|
570 |
onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); |
|
571 |
} else { |
|
515 | 572 |
$.datepicker._hideDatepicker(); |
573 |
} |
|
574 |
|
|
516 | 575 |
return false; // don't submit the form |
517 |
break; // select the value on enter |
|
518 | 576 |
case 27: $.datepicker._hideDatepicker(); |
519 | 577 |
break; // hide on escape |
520 | 578 |
case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ? |
521 |
-$.datepicker._get(inst, 'stepBigMonths') :
|
|
522 |
-$.datepicker._get(inst, 'stepMonths')), 'M');
|
|
579 |
-$.datepicker._get(inst, "stepBigMonths") :
|
|
580 |
-$.datepicker._get(inst, "stepMonths")), "M");
|
|
523 | 581 |
break; // previous month/year on page up/+ ctrl |
524 | 582 |
case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ? |
525 |
+$.datepicker._get(inst, 'stepBigMonths') :
|
|
526 |
+$.datepicker._get(inst, 'stepMonths')), 'M');
|
|
583 |
+$.datepicker._get(inst, "stepBigMonths") :
|
|
584 |
+$.datepicker._get(inst, "stepMonths")), "M");
|
|
527 | 585 |
break; // next month/year on page down/+ ctrl |
528 |
case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target); |
|
586 |
case 35: if (event.ctrlKey || event.metaKey) { |
|
587 |
$.datepicker._clearDate(event.target); |
|
588 |
} |
|
529 | 589 |
handled = event.ctrlKey || event.metaKey; |
530 | 590 |
break; // clear on ctrl or command +end |
531 |
case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target); |
|
591 |
case 36: if (event.ctrlKey || event.metaKey) { |
|
592 |
$.datepicker._gotoToday(event.target); |
|
593 |
} |
|
532 | 594 |
handled = event.ctrlKey || event.metaKey; |
533 | 595 |
break; // current on ctrl or command +home |
534 |
case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D'); |
|
596 |
case 37: if (event.ctrlKey || event.metaKey) { |
|
597 |
$.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D"); |
|
598 |
} |
|
535 | 599 |
handled = event.ctrlKey || event.metaKey; |
536 | 600 |
// -1 day on ctrl or command +left |
537 |
if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ? |
|
538 |
-$.datepicker._get(inst, 'stepBigMonths') : |
|
539 |
-$.datepicker._get(inst, 'stepMonths')), 'M'); |
|
601 |
if (event.originalEvent.altKey) { |
|
602 |
$.datepicker._adjustDate(event.target, (event.ctrlKey ? |
|
603 |
-$.datepicker._get(inst, "stepBigMonths") : |
|
604 |
-$.datepicker._get(inst, "stepMonths")), "M"); |
|
605 |
} |
|
540 | 606 |
// next month/year on alt +left on Mac |
541 | 607 |
break; |
542 |
case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D'); |
|
608 |
case 38: if (event.ctrlKey || event.metaKey) { |
|
609 |
$.datepicker._adjustDate(event.target, -7, "D"); |
|
610 |
} |
|
543 | 611 |
handled = event.ctrlKey || event.metaKey; |
544 | 612 |
break; // -1 week on ctrl or command +up |
545 |
case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D'); |
|
613 |
case 39: if (event.ctrlKey || event.metaKey) { |
|
614 |
$.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D"); |
|
615 |
} |
|
546 | 616 |
handled = event.ctrlKey || event.metaKey; |
547 | 617 |
// +1 day on ctrl or command +right |
548 |
if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ? |
|
549 |
+$.datepicker._get(inst, 'stepBigMonths') : |
|
550 |
+$.datepicker._get(inst, 'stepMonths')), 'M'); |
|
618 |
if (event.originalEvent.altKey) { |
|
619 |
$.datepicker._adjustDate(event.target, (event.ctrlKey ? |
|
620 |
+$.datepicker._get(inst, "stepBigMonths") : |
|
621 |
+$.datepicker._get(inst, "stepMonths")), "M"); |
|
622 |
} |
|
551 | 623 |
// next month/year on alt +right |
552 | 624 |
break; |
553 |
case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D'); |
|
625 |
case 40: if (event.ctrlKey || event.metaKey) { |
|
626 |
$.datepicker._adjustDate(event.target, +7, "D"); |
|
627 |
} |
|
554 | 628 |
handled = event.ctrlKey || event.metaKey; |
555 | 629 |
break; // +1 week on ctrl or command +down |
556 | 630 |
default: handled = false; |
557 | 631 |
} |
558 |
else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home
|
|
632 |
} else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
|
|
559 | 633 |
$.datepicker._showDatepicker(this); |
560 |
else { |
|
634 |
} else {
|
|
561 | 635 |
handled = false; |
562 | 636 |
} |
637 |
|
|
563 | 638 |
if (handled) { |
564 | 639 |
event.preventDefault(); |
565 | 640 |
event.stopPropagation(); |
... | ... | |
568 | 643 |
|
569 | 644 |
/* Filter entered characters - based on date format. */ |
570 | 645 |
_doKeyPress: function(event) { |
571 |
var inst = $.datepicker._getInst(event.target); |
|
572 |
if ($.datepicker._get(inst, 'constrainInput')) { |
|
573 |
var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')); |
|
574 |
var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode); |
|
575 |
return event.ctrlKey || event.metaKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1); |
|
646 |
var chars, chr, |
|
647 |
inst = $.datepicker._getInst(event.target); |
|
648 |
|
|
649 |
if ($.datepicker._get(inst, "constrainInput")) { |
|
650 |
chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat")); |
|
651 |
chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode); |
|
652 |
return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1); |
|
576 | 653 |
} |
577 | 654 |
}, |
578 | 655 |
|
579 | 656 |
/* Synchronise manual entry and field/alternate field. */ |
580 | 657 |
_doKeyUp: function(event) { |
581 |
var inst = $.datepicker._getInst(event.target); |
|
582 |
if (inst.input.val() != inst.lastVal) { |
|
658 |
var date, |
|
659 |
inst = $.datepicker._getInst(event.target); |
|
660 |
|
|
661 |
if (inst.input.val() !== inst.lastVal) { |
|
583 | 662 |
try { |
584 |
var date = $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
|
|
663 |
date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
|
|
585 | 664 |
(inst.input ? inst.input.val() : null), |
586 | 665 |
$.datepicker._getFormatConfig(inst)); |
666 |
|
|
587 | 667 |
if (date) { // only if valid |
588 | 668 |
$.datepicker._setDateFromField(inst); |
589 | 669 |
$.datepicker._updateAlternate(inst); |
590 | 670 |
$.datepicker._updateDatepicker(inst); |
591 | 671 |
} |
592 | 672 |
} |
593 |
catch (event) { |
|
594 |
$.datepicker.log(event); |
|
673 |
catch (err) { |
|
595 | 674 |
} |
596 | 675 |
} |
597 | 676 |
return true; |
598 | 677 |
}, |
599 | 678 |
|
600 | 679 |
/* Pop-up the date picker for a given input field. |
601 |
@param input element - the input field attached to the date picker or |
|
602 |
event - if triggered by focus */ |
|
680 |
* If false returned from beforeShow event handler do not show. |
|
681 |
* @param input element - the input field attached to the date picker or |
|
682 |
* event - if triggered by focus |
|
683 |
*/ |
|
603 | 684 |
_showDatepicker: function(input) { |
604 | 685 |
input = input.target || input; |
605 |
if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger |
|
606 |
input = $('input', input.parentNode)[0]; |
|
607 |
if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here |
|
686 |
if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger |
|
687 |
input = $("input", input.parentNode)[0]; |
|
688 |
} |
|
689 |
|
|
690 |
if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here |
|
608 | 691 |
return; |
609 |
var inst = $.datepicker._getInst(input); |
|
610 |
if ($.datepicker._curInst && $.datepicker._curInst != inst) { |
|
692 |
} |
|
693 |
|
|
694 |
var inst, beforeShow, beforeShowSettings, isFixed, |
|
695 |
offset, showAnim, duration; |
|
696 |
|
|
697 |
inst = $.datepicker._getInst(input); |
|
698 |
if ($.datepicker._curInst && $.datepicker._curInst !== inst) { |
|
611 | 699 |
$.datepicker._curInst.dpDiv.stop(true, true); |
700 |
if ( inst && $.datepicker._datepickerShowing ) { |
|
701 |
$.datepicker._hideDatepicker( $.datepicker._curInst.input[0] ); |
|
702 |
} |
|
612 | 703 |
} |
613 |
var beforeShow = $.datepicker._get(inst, 'beforeShow'); |
|
614 |
extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input, [input, inst]) : {})); |
|
704 |
|
|
705 |
beforeShow = $.datepicker._get(inst, "beforeShow"); |
|
706 |
beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {}; |
|
707 |
if(beforeShowSettings === false){ |
|
708 |
return; |
|
709 |
} |
|
710 |
extendRemove(inst.settings, beforeShowSettings); |
|
711 |
|
|
615 | 712 |
inst.lastVal = null; |
616 | 713 |
$.datepicker._lastInput = input; |
617 | 714 |
$.datepicker._setDateFromField(inst); |
618 |
if ($.datepicker._inDialog) // hide cursor |
|
619 |
input.value = ''; |
|
715 |
|
|
716 |
if ($.datepicker._inDialog) { // hide cursor |
|
717 |
input.value = ""; |
|
718 |
} |
|
620 | 719 |
if (!$.datepicker._pos) { // position below input |
621 | 720 |
$.datepicker._pos = $.datepicker._findPos(input); |
622 | 721 |
$.datepicker._pos[1] += input.offsetHeight; // add the height |
623 | 722 |
} |
624 |
var isFixed = false; |
|
723 |
|
|
724 |
isFixed = false; |
|
625 | 725 |
$(input).parents().each(function() { |
626 |
isFixed |= $(this).css('position') == 'fixed';
|
|
726 |
isFixed |= $(this).css("position") === "fixed";
|
|
627 | 727 |
return !isFixed; |
628 | 728 |
}); |
629 |
if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled |
|
630 |
$.datepicker._pos[0] -= document.documentElement.scrollLeft; |
|
631 |
$.datepicker._pos[1] -= document.documentElement.scrollTop; |
|
632 |
} |
|
633 |
var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]}; |
|
729 |
|
|
730 |
offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]}; |
|
634 | 731 |
$.datepicker._pos = null; |
635 | 732 |
//to avoid flashes on Firefox |
636 | 733 |
inst.dpDiv.empty(); |
637 | 734 |
// determine sizing offscreen |
638 |
inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
|
|
735 |
inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
|
|
639 | 736 |
$.datepicker._updateDatepicker(inst); |
640 | 737 |
// fix width for dynamic number of date pickers |
641 | 738 |
// and adjust position before showing |
642 | 739 |
offset = $.datepicker._checkOffset(inst, offset, isFixed); |
643 | 740 |
inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ? |
644 |
'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none', |
|
645 |
left: offset.left + 'px', top: offset.top + 'px'}); |
|
741 |
"static" : (isFixed ? "fixed" : "absolute")), display: "none", |
|
742 |
left: offset.left + "px", top: offset.top + "px"}); |
|
743 |
|
|
646 | 744 |
if (!inst.inline) { |
647 |
var showAnim = $.datepicker._get(inst, 'showAnim'); |
|
648 |
var duration = $.datepicker._get(inst, 'duration'); |
|
649 |
var postProcess = function() { |
|
650 |
$.datepicker._datepickerShowing = true; |
|
651 |
var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only |
|
652 |
if( !! cover.length ){ |
|
653 |
var borders = $.datepicker._getBorders(inst.dpDiv); |
|
654 |
cover.css({left: -borders[0], top: -borders[1], |
|
655 |
width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()}); |
|
656 |
} |
|
657 |
}; |
|
745 |
showAnim = $.datepicker._get(inst, "showAnim"); |
|
746 |
duration = $.datepicker._get(inst, "duration"); |
|
658 | 747 |
inst.dpDiv.zIndex($(input).zIndex()+1); |
659 |
if ($.effects && $.effects[showAnim]) |
|
660 |
inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess); |
|
661 |
else |
|
662 |
inst.dpDiv[showAnim || 'show']((showAnim ? duration : null), postProcess); |
|
663 |
if (!showAnim || !duration) |
|
664 |
postProcess(); |
|
665 |
if (inst.input.is(':visible') && !inst.input.is(':disabled')) |
|
748 |
$.datepicker._datepickerShowing = true; |
|
749 |
|
|
750 |
if ( $.effects && $.effects.effect[ showAnim ] ) { |
|
751 |
inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration); |
|
752 |
} else { |
|
753 |
inst.dpDiv[showAnim || "show"](showAnim ? duration : null); |
|
754 |
} |
|
755 |
|
|
756 |
if (inst.input.is(":visible") && !inst.input.is(":disabled")) { |
|
666 | 757 |
inst.input.focus(); |
758 |
} |
|
667 | 759 |
$.datepicker._curInst = inst; |
668 | 760 |
} |
669 | 761 |
}, |
670 | 762 |
|
671 | 763 |
/* Generate the date picker content. */ |
672 | 764 |
_updateDatepicker: function(inst) { |
673 |
var self = this;
|
|
674 |
var borders = $.datepicker._getBorders(inst.dpDiv);
|
|
765 |
this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
|
|
766 |
instActive = inst; // for delegate hover events
|
|
675 | 767 |
inst.dpDiv.empty().append(this._generateHTML(inst)); |
676 |
var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only |
|
677 |
if( !!cover.length ){ //avoid call to outerXXXX() when not in IE6 |
|
678 |
cover.css({left: -borders[0], top: -borders[1], width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()}) |
|
679 |
} |
|
680 |
inst.dpDiv.find('button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a') |
|
681 |
.bind('mouseout', function(){ |
|
682 |
$(this).removeClass('ui-state-hover'); |
|
683 |
if(this.className.indexOf('ui-datepicker-prev') != -1) $(this).removeClass('ui-datepicker-prev-hover'); |
|
684 |
if(this.className.indexOf('ui-datepicker-next') != -1) $(this).removeClass('ui-datepicker-next-hover'); |
|
685 |
}) |
|
686 |
.bind('mouseover', function(){ |
|
687 |
if (!self._isDisabledDatepicker( inst.inline ? inst.dpDiv.parent()[0] : inst.input[0])) { |
|
688 |
$(this).parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover'); |
|
689 |
$(this).addClass('ui-state-hover'); |
|
690 |
if(this.className.indexOf('ui-datepicker-prev') != -1) $(this).addClass('ui-datepicker-prev-hover'); |
|
691 |
if(this.className.indexOf('ui-datepicker-next') != -1) $(this).addClass('ui-datepicker-next-hover'); |
|
692 |
} |
|
693 |
}) |
|
694 |
.end() |
|
695 |
.find('.' + this._dayOverClass + ' a') |
|
696 |
.trigger('mouseover') |
|
697 |
.end(); |
|
698 |
var numMonths = this._getNumberOfMonths(inst); |
|
699 |
var cols = numMonths[1]; |
|
700 |
var width = 17; |
|
701 |
if (cols > 1) |
|
702 |
inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em'); |
|
703 |
else |
|
704 |
inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width(''); |
|
705 |
inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') + |
|
706 |
'Class']('ui-datepicker-multi'); |
|
707 |
inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') + |
|
708 |
'Class']('ui-datepicker-rtl'); |
|
709 |
if (inst == $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input && |
|
710 |
// #6694 - don't focus the input if it's already focused |
|
711 |
// this breaks the change event in IE |
|
712 |
inst.input.is(':visible') && !inst.input.is(':disabled') && inst.input[0] != document.activeElement) |
|
768 |
this._attachHandlers(inst); |
|
769 |
inst.dpDiv.find("." + this._dayOverClass + " a").mouseover(); |
|
770 |
|
|
771 |
var origyearshtml, |
|
772 |
numMonths = this._getNumberOfMonths(inst), |
|
773 |
cols = numMonths[1], |
|
774 |
width = 17; |
|
775 |
|
|
776 |
inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width(""); |
|
777 |
if (cols > 1) { |
|
778 |
inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em"); |
|
779 |
} |
|
780 |
inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") + |
|
781 |
"Class"]("ui-datepicker-multi"); |
|
782 |
inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") + |
|
783 |
"Class"]("ui-datepicker-rtl"); |
|
784 |
|
|
785 |
// #6694 - don't focus the input if it's already focused |
|
786 |
// this breaks the change event in IE |
|
787 |
if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input && |
|
788 |
inst.input.is(":visible") && !inst.input.is(":disabled") && inst.input[0] !== document.activeElement) { |
|
713 | 789 |
inst.input.focus(); |
714 |
// deffered render of the years select (to avoid flashes on Firefox) |
|
790 |
} |
|
791 |
|
|
792 |
// deffered render of the years select (to avoid flashes on Firefox) |
|
715 | 793 |
if( inst.yearshtml ){ |
716 |
var origyearshtml = inst.yearshtml;
|
|
794 |
origyearshtml = inst.yearshtml; |
|
717 | 795 |
setTimeout(function(){ |
718 | 796 |
//assure that inst.yearshtml didn't change. |
719 |
if( origyearshtml === inst.yearshtml ){ |
|
720 |
inst.dpDiv.find('select.ui-datepicker-year:first').replaceWith(inst.yearshtml);
|
|
797 |
if( origyearshtml === inst.yearshtml && inst.yearshtml ){
|
|
798 |
inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
|
|
721 | 799 |
} |
722 | 800 |
origyearshtml = inst.yearshtml = null; |
723 | 801 |
}, 0); |
... | ... | |
725 | 803 |
}, |
726 | 804 |
|
727 | 805 |
/* Retrieve the size of left and top borders for an element. |
728 |
@param elem (jQuery object) the element of interest |
|
729 |
@return (number[2]) the left and top borders */ |
|
806 |
* @param elem (jQuery object) the element of interest |
|
807 |
* @return (number[2]) the left and top borders |
|
808 |
*/ |
|
730 | 809 |
_getBorders: function(elem) { |
731 | 810 |
var convert = function(value) { |
732 | 811 |
return {thin: 1, medium: 2, thick: 3}[value] || value; |
733 | 812 |
}; |
734 |
return [parseFloat(convert(elem.css('border-left-width'))),
|
|
735 |
parseFloat(convert(elem.css('border-top-width')))];
|
|
813 |
return [parseFloat(convert(elem.css("border-left-width"))),
|
|
814 |
parseFloat(convert(elem.css("border-top-width")))];
|
|
736 | 815 |
}, |
737 | 816 |
|
738 | 817 |
/* Check positioning to remain on screen. */ |
739 | 818 |
_checkOffset: function(inst, offset, isFixed) { |
740 |
var dpWidth = inst.dpDiv.outerWidth();
|
|
741 |
var dpHeight = inst.dpDiv.outerHeight();
|
|
742 |
var inputWidth = inst.input ? inst.input.outerWidth() : 0;
|
|
743 |
var inputHeight = inst.input ? inst.input.outerHeight() : 0;
|
|
744 |
var viewWidth = document.documentElement.clientWidth + $(document).scrollLeft();
|
|
745 |
var viewHeight = document.documentElement.clientHeight + $(document).scrollTop();
|
|
819 |
var dpWidth = inst.dpDiv.outerWidth(),
|
|
820 |
dpHeight = inst.dpDiv.outerHeight(),
|
|
821 |
inputWidth = inst.input ? inst.input.outerWidth() : 0,
|
|
822 |
inputHeight = inst.input ? inst.input.outerHeight() : 0,
|
|
823 |
viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
|
|
824 |
viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
|
|
746 | 825 |
|
747 |
offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0);
|
|
748 |
offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0; |
|
749 |
offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0; |
|
826 |
offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
|
|
827 |
offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
|
|
828 |
offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
|
|
750 | 829 |
|
751 | 830 |
// now check if datepicker is showing outside window viewport - move to a better place if so. |
752 | 831 |
offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ? |
... | ... | |
759 | 838 |
|
760 | 839 |
/* Find an object's position on the screen. */ |
761 | 840 |
_findPos: function(obj) { |
762 |
var inst = this._getInst(obj); |
|
763 |
var isRTL = this._get(inst, 'isRTL'); |
|
764 |
while (obj && (obj.type == 'hidden' || obj.nodeType != 1 || $.expr.filters.hidden(obj))) { |
|
765 |
obj = obj[isRTL ? 'previousSibling' : 'nextSibling']; |
|
766 |
} |
|
767 |
var position = $(obj).offset(); |
|
768 |
return [position.left, position.top]; |
|
841 |
var position, |
|
842 |
inst = this._getInst(obj), |
|
843 |
isRTL = this._get(inst, "isRTL"); |
|
844 |
|
|
845 |
while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) { |
|
846 |
obj = obj[isRTL ? "previousSibling" : "nextSibling"]; |
|
847 |
} |
|
848 |
|
|
849 |
position = $(obj).offset(); |
|
850 |
return [position.left, position.top]; |
|
769 | 851 |
}, |
770 | 852 |
|
771 | 853 |
/* Hide the date picker from view. |
772 |
@param input element - the input field attached to the date picker */ |
|
854 |
* @param input element - the input field attached to the date picker |
|
855 |
*/ |
|
773 | 856 |
_hideDatepicker: function(input) { |
774 |
var inst = this._curInst; |
|
775 |
if (!inst || (input && inst != $.data(input, PROP_NAME))) |
|
857 |
var showAnim, duration, postProcess, onClose, |
|
858 |
inst = this._curInst; |
|
859 |
|
|
860 |
if (!inst || (input && inst !== $.data(input, PROP_NAME))) { |
|
776 | 861 |
return; |
862 |
} |
|
863 |
|
|
777 | 864 |
if (this._datepickerShowing) { |
778 |
var showAnim = this._get(inst, 'showAnim');
|
|
779 |
var duration = this._get(inst, 'duration');
|
|
780 |
var postProcess = function() {
|
|
865 |
showAnim = this._get(inst, "showAnim");
|
|
866 |
duration = this._get(inst, "duration");
|
|
867 |
postProcess = function() { |
|
781 | 868 |
$.datepicker._tidyDialog(inst); |
782 |
this._curInst = null; |
|
783 | 869 |
}; |
784 |
if ($.effects && $.effects[showAnim]) |
|
785 |
inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess); |
|
786 |
else |
|
787 |
inst.dpDiv[(showAnim == 'slideDown' ? 'slideUp' : |
|
788 |
(showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess); |
|
789 |
if (!showAnim) |
|
870 |
|
|
871 |
// DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed |
|
872 |
if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) { |
|
873 |
inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess); |
|
874 |
} else { |
|
875 |
inst.dpDiv[(showAnim === "slideDown" ? "slideUp" : |
|
876 |
(showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess); |
|
877 |
} |
|
878 |
|
|
879 |
if (!showAnim) { |
|
790 | 880 |
postProcess(); |
791 |
var onClose = this._get(inst, 'onClose'); |
|
792 |
if (onClose) |
|
793 |
onClose.apply((inst.input ? inst.input[0] : null), |
|
794 |
[(inst.input ? inst.input.val() : ''), inst]); // trigger custom callback |
|
881 |
} |
|
795 | 882 |
this._datepickerShowing = false; |
883 |
|
|
884 |
onClose = this._get(inst, "onClose"); |
|
885 |
if (onClose) { |
|
886 |
onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]); |
|
887 |
} |
|
888 |
|
|
796 | 889 |
this._lastInput = null; |
797 | 890 |
if (this._inDialog) { |
798 |
this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
|
|
891 |
this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
|
|
799 | 892 |
if ($.blockUI) { |
800 | 893 |
$.unblockUI(); |
801 |
$('body').append(this.dpDiv);
|
|
894 |
$("body").append(this.dpDiv);
|
|
802 | 895 |
} |
803 | 896 |
} |
804 | 897 |
this._inDialog = false; |
... | ... | |
807 | 900 |
|
808 | 901 |
/* Tidy up after a dialog display. */ |
809 | 902 |
_tidyDialog: function(inst) { |
810 |
inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar');
|
|
903 |
inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
|
|
811 | 904 |
}, |
812 | 905 |
|
813 | 906 |
/* Close date picker if clicked elsewhere. */ |
814 | 907 |
_checkExternalClick: function(event) { |
815 |
if (!$.datepicker._curInst) |
|
908 |
if (!$.datepicker._curInst) {
|
|
816 | 909 |
return; |
817 |
var $target = $(event.target); |
|
818 |
if ($target[0].id != $.datepicker._mainDivId && |
|
819 |
$target.parents('#' + $.datepicker._mainDivId).length == 0 && |
|
910 |
} |
|
911 |
|
|
912 |
var $target = $(event.target), |
|
913 |
inst = $.datepicker._getInst($target[0]); |
|
914 |
|
|
915 |
if ( ( ( $target[0].id !== $.datepicker._mainDivId && |
|
916 |
$target.parents("#" + $.datepicker._mainDivId).length === 0 && |
|
820 | 917 |
!$target.hasClass($.datepicker.markerClassName) && |
821 |
!$target.hasClass($.datepicker._triggerClass) && |
|
822 |
$.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI)) |
|
823 |
$.datepicker._hideDatepicker(); |
|
918 |
!$target.closest("." + $.datepicker._triggerClass).length && |
|
919 |
$.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) || |
|
920 |
( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) { |
|
921 |
$.datepicker._hideDatepicker(); |
|
922 |
} |
|
824 | 923 |
}, |
825 | 924 |
|
826 | 925 |
/* Adjust one of the date sub-fields. */ |
827 | 926 |
_adjustDate: function(id, offset, period) { |
828 |
var target = $(id); |
|
829 |
var inst = this._getInst(target[0]); |
|
927 |
var target = $(id), |
|
928 |
inst = this._getInst(target[0]); |
|
929 |
|
|
830 | 930 |
if (this._isDisabledDatepicker(target[0])) { |
831 | 931 |
return; |
832 | 932 |
} |
833 | 933 |
this._adjustInstDate(inst, offset + |
834 |
(period == 'M' ? this._get(inst, 'showCurrentAtPos') : 0), // undo positioning
|
|
934 |
(period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
|
|
835 | 935 |
period); |
836 | 936 |
this._updateDatepicker(inst); |
837 | 937 |
}, |
838 | 938 |
|
839 | 939 |
/* Action for current link. */ |
840 | 940 |
_gotoToday: function(id) { |
841 |
var target = $(id); |
|
842 |
var inst = this._getInst(target[0]); |
|
843 |
if (this._get(inst, 'gotoCurrent') && inst.currentDay) { |
|
941 |
var date, |
|
942 |
target = $(id), |
|
943 |
inst = this._getInst(target[0]); |
|
944 |
|
|
945 |
if (this._get(inst, "gotoCurrent") && inst.currentDay) { |
|
844 | 946 |
inst.selectedDay = inst.currentDay; |
845 | 947 |
inst.drawMonth = inst.selectedMonth = inst.currentMonth; |
846 | 948 |
inst.drawYear = inst.selectedYear = inst.currentYear; |
847 |
} |
|
848 |
else { |
|
849 |
var date = new Date(); |
|
949 |
} else { |
|
950 |
date = new Date(); |
|
850 | 951 |
inst.selectedDay = date.getDate(); |
851 | 952 |
inst.drawMonth = inst.selectedMonth = date.getMonth(); |
852 | 953 |
inst.drawYear = inst.selectedYear = date.getFullYear(); |
... | ... | |
857 | 958 |
|
858 | 959 |
/* Action for selecting a new month/year. */ |
859 | 960 |
_selectMonthYear: function(id, select, period) { |
860 |
var target = $(id);
|
|
861 |
var inst = this._getInst(target[0]);
|
|
862 |
inst._selectingMonthYear = false; |
|
863 |
inst['selected' + (period == 'M' ? 'Month' : 'Year')] =
|
|
864 |
inst['draw' + (period == 'M' ? 'Month' : 'Year')] =
|
|
961 |
var target = $(id),
|
|
962 |
inst = this._getInst(target[0]);
|
|
963 |
|
|
964 |
inst["selected" + (period === "M" ? "Month" : "Year")] =
|
|
965 |
inst["draw" + (period === "M" ? "Month" : "Year")] =
|
|
865 | 966 |
parseInt(select.options[select.selectedIndex].value,10); |
967 |
|
|
866 | 968 |
this._notifyChange(inst); |
867 | 969 |
this._adjustDate(target); |
868 | 970 |
}, |
869 | 971 |
|
870 |
/* Restore input focus after not changing month/year. */ |
|
871 |
_clickMonthYear: function(id) { |
|
872 |
var target = $(id); |
|
873 |
var inst = this._getInst(target[0]); |
|
874 |
if (inst.input && inst._selectingMonthYear) { |
|
875 |
setTimeout(function() { |
|
876 |
inst.input.focus(); |
|
877 |
}, 0); |
|
878 |
} |
|
879 |
inst._selectingMonthYear = !inst._selectingMonthYear; |
|
880 |
}, |
|
881 |
|
|
882 | 972 |
/* Action for selecting a day. */ |
883 | 973 |
_selectDay: function(id, month, year, td) { |
884 |
var target = $(id); |
|
974 |
var inst, |
|
975 |
target = $(id); |
|
976 |
|
|
885 | 977 |
if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) { |
886 | 978 |
return; |
887 | 979 |
} |
888 |
var inst = this._getInst(target[0]); |
|
889 |
inst.selectedDay = inst.currentDay = $('a', td).html(); |
|
980 |
|
|
981 |
inst = this._getInst(target[0]); |
|
982 |
inst.selectedDay = inst.currentDay = $("a", td).html(); |
|
890 | 983 |
inst.selectedMonth = inst.currentMonth = month; |
891 | 984 |
inst.selectedYear = inst.currentYear = year; |
892 | 985 |
this._selectDate(id, this._formatDate(inst, |
... | ... | |
896 | 989 |
/* Erase the input field and hide the date picker. */ |
897 | 990 |
_clearDate: function(id) { |
898 | 991 |
var target = $(id); |
899 |
var inst = this._getInst(target[0]); |
|
900 |
this._selectDate(target, ''); |
|
992 |
this._selectDate(target, ""); |
|
901 | 993 |
}, |
902 | 994 |
|
903 | 995 |
/* Update the input field with the selected date. */ |
904 | 996 |
_selectDate: function(id, dateStr) { |
905 |
var target = $(id); |
|
906 |
var inst = this._getInst(target[0]); |
|
997 |
var onSelect, |
|
998 |
target = $(id), |
|
999 |
inst = this._getInst(target[0]); |
|
1000 |
|
|
907 | 1001 |
dateStr = (dateStr != null ? dateStr : this._formatDate(inst)); |
908 |
if (inst.input) |
|
1002 |
if (inst.input) {
|
|
909 | 1003 |
inst.input.val(dateStr); |
1004 |
} |
|
910 | 1005 |
this._updateAlternate(inst); |
911 |
var onSelect = this._get(inst, 'onSelect'); |
|
912 |
if (onSelect) |
|
1006 |
|
|
1007 |
onSelect = this._get(inst, "onSelect"); |
|
1008 |
if (onSelect) { |
|
913 | 1009 |
onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback |
914 |
else if (inst.input) |
|
915 |
inst.input.trigger('change'); // fire the change event |
|
916 |
if (inst.inline) |
|
1010 |
} else if (inst.input) { |
|
1011 |
inst.input.trigger("change"); // fire the change event |
|
1012 |
} |
|
1013 |
|
|
1014 |
if (inst.inline){ |
|
917 | 1015 |
this._updateDatepicker(inst); |
918 |
else { |
|
1016 |
} else {
|
|
919 | 1017 |
this._hideDatepicker(); |
920 | 1018 |
this._lastInput = inst.input[0]; |
921 |
if (typeof(inst.input[0]) != 'object')
|
|
1019 |
if (typeof(inst.input[0]) !== "object") {
|
|
922 | 1020 |
inst.input.focus(); // restore focus |
1021 |
} |
|
923 | 1022 |
this._lastInput = null; |
924 | 1023 |
} |
925 | 1024 |
}, |
926 | 1025 |
|
927 | 1026 |
/* Update any alternate field to synchronise with the main field. */ |
928 | 1027 |
_updateAlternate: function(inst) { |
929 |
var altField = this._get(inst, 'altField'); |
|
1028 |
var altFormat, date, dateStr, |
|
1029 |
altField = this._get(inst, "altField"); |
|
1030 |
|
|
930 | 1031 |
if (altField) { // update alternate field too |
931 |
var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat');
|
|
932 |
var date = this._getDate(inst);
|
|
933 |
var dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
|
|
1032 |
altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
|
|
1033 |
date = this._getDate(inst); |
|
1034 |
dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst)); |
|
934 | 1035 |
$(altField).each(function() { $(this).val(dateStr); }); |
935 | 1036 |
} |
936 | 1037 |
}, |
937 | 1038 |
|
938 | 1039 |
/* Set as beforeShowDay function to prevent selection of weekends. |
939 |
@param date Date - the date to customise |
|
940 |
@return [boolean, string] - is this date selectable?, what is its CSS class? */ |
|
1040 |
* @param date Date - the date to customise |
|
1041 |
* @return [boolean, string] - is this date selectable?, what is its CSS class? |
|
1042 |
*/ |
|
941 | 1043 |
noWeekends: function(date) { |
942 | 1044 |
var day = date.getDay(); |
943 |
return [(day > 0 && day < 6), ''];
|
|
1045 |
return [(day > 0 && day < 6), ""];
|
|
944 | 1046 |
}, |
945 | 1047 |
|
946 | 1048 |
/* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition. |
947 |
@param date Date - the date to get the week for |
|
948 |
@return number - the number of the week within the year that contains this date */ |
|
1049 |
* @param date Date - the date to get the week for |
|
1050 |
* @return number - the number of the week within the year that contains this date |
|
1051 |
*/ |
|
949 | 1052 |
iso8601Week: function(date) { |
950 |
var checkDate = new Date(date.getTime()); |
|
1053 |
var time, |
|
1054 |
checkDate = new Date(date.getTime()); |
|
1055 |
|
|
951 | 1056 |
// Find Thursday of this week starting on Monday |
952 | 1057 |
checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7)); |
953 |
var time = checkDate.getTime(); |
|
1058 |
|
|
1059 |
time = checkDate.getTime(); |
|
954 | 1060 |
checkDate.setMonth(0); // Compare with Jan 1 |
955 | 1061 |
checkDate.setDate(1); |
956 | 1062 |
return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1; |
957 | 1063 |
}, |
958 | 1064 |
|
959 | 1065 |
/* Parse a string value into a date object. |
960 |
See formatDate below for the possible formats. |
|
961 |
|
|
962 |
@param format string - the expected format of the date |
|
963 |
@param value string - the date in the above format |
|
964 |
@param settings Object - attributes include: |
|
965 |
shortYearCutoff number - the cutoff year for determining the century (optional) |
|
966 |
dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) |
|
967 |
dayNames string[7] - names of the days from Sunday (optional) |
|
968 |
monthNamesShort string[12] - abbreviated names of the months (optional) |
|
969 |
monthNames string[12] - names of the months (optional) |
|
970 |
@return Date - the extracted date value or null if value is blank */ |
|
1066 |
* See formatDate below for the possible formats. |
|
1067 |
* |
|
1068 |
* @param format string - the expected format of the date |
|
1069 |
* @param value string - the date in the above format |
|
1070 |
* @param settings Object - attributes include: |
|
1071 |
* shortYearCutoff number - the cutoff year for determining the century (optional) |
|
1072 |
* dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) |
|
1073 |
* dayNames string[7] - names of the days from Sunday (optional) |
Formats disponibles : Unified diff
Weekly update of contrib modules