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