MailChimp List Subscribe Form - Version 1.5.7

Version Description

  • Fix undefined variable notice.
  • Fix HTML submission message.
Download this release

Release Info

Developer MailChimp
Plugin Icon wp plugin MailChimp List Subscribe Form
Version 1.5.7
Comparing to
See all releases

Code changes from version 1.5.2 to 1.5.7

bin/install-wp-tests.sh DELETED
@@ -1,118 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- if [ $# -lt 3 ]; then
4
- echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version]"
5
- exit 1
6
- fi
7
-
8
- DB_NAME=$1
9
- DB_USER=$2
10
- DB_PASS=$3
11
- DB_HOST=${4-localhost}
12
- WP_VERSION=${5-latest}
13
-
14
- WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
15
- WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}
16
-
17
- download() {
18
- if [ `which curl` ]; then
19
- curl -s "$1" > "$2";
20
- elif [ `which wget` ]; then
21
- wget -nv -O "$2" "$1"
22
- fi
23
- }
24
-
25
- if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then
26
- WP_TESTS_TAG="tags/$WP_VERSION"
27
- elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
28
- WP_TESTS_TAG="trunk"
29
- else
30
- # http serves a single offer, whereas https serves multiple. we only want one
31
- download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
32
- grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
33
- LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
34
- if [[ -z "$LATEST_VERSION" ]]; then
35
- echo "Latest WordPress version could not be found"
36
- exit 1
37
- fi
38
- WP_TESTS_TAG="tags/$LATEST_VERSION"
39
- fi
40
-
41
- set -ex
42
-
43
- install_wp() {
44
-
45
- if [ -d $WP_CORE_DIR ]; then
46
- return;
47
- fi
48
-
49
- mkdir -p $WP_CORE_DIR
50
-
51
- if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
52
- mkdir -p /tmp/wordpress-nightly
53
- download https://wordpress.org/nightly-builds/wordpress-latest.zip /tmp/wordpress-nightly/wordpress-nightly.zip
54
- unzip -q /tmp/wordpress-nightly/wordpress-nightly.zip -d /tmp/wordpress-nightly/
55
- mv /tmp/wordpress-nightly/wordpress/* $WP_CORE_DIR
56
- else
57
- if [ $WP_VERSION == 'latest' ]; then
58
- local ARCHIVE_NAME='latest'
59
- else
60
- local ARCHIVE_NAME="wordpress-$WP_VERSION"
61
- fi
62
- download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz
63
- tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
64
- fi
65
-
66
- download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
67
- }
68
-
69
- install_test_suite() {
70
- # portable in-place argument for both GNU sed and Mac OSX sed
71
- if [[ $(uname -s) == 'Darwin' ]]; then
72
- local ioption='-i .bak'
73
- else
74
- local ioption='-i'
75
- fi
76
-
77
- # set up testing suite if it doesn't yet exist
78
- if [ ! -d $WP_TESTS_DIR ]; then
79
- # set up testing suite
80
- mkdir -p $WP_TESTS_DIR
81
- svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
82
- fi
83
-
84
- if [ ! -f wp-tests-config.php ]; then
85
- download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
86
- sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" "$WP_TESTS_DIR"/wp-tests-config.php
87
- sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
88
- sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
89
- sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
90
- sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
91
- fi
92
-
93
- }
94
-
95
- install_db() {
96
- # parse DB_HOST for port or socket references
97
- local PARTS=(${DB_HOST//\:/ })
98
- local DB_HOSTNAME=${PARTS[0]};
99
- local DB_SOCK_OR_PORT=${PARTS[1]};
100
- local EXTRA=""
101
-
102
- if ! [ -z $DB_HOSTNAME ] ; then
103
- if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
104
- EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
105
- elif ! [ -z $DB_SOCK_OR_PORT ] ; then
106
- EXTRA=" --socket=$DB_SOCK_OR_PORT"
107
- elif ! [ -z $DB_HOSTNAME ] ; then
108
- EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
109
- fi
110
- fi
111
-
112
- # create database
113
- mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
114
- }
115
-
116
- install_wp
117
- install_test_suite
118
- install_db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
datepicker.js ADDED
@@ -0,0 +1,1815 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * jQuery UI Datepicker 1.8.14
3
+ *
4
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5
+ * Dual licensed under the MIT or GPL Version 2 licenses.
6
+ * http://jquery.org/license
7
+ *
8
+ * http://docs.jquery.com/UI/Datepicker
9
+ *
10
+ * Depends:
11
+ * jquery.ui.core.js
12
+ */
13
+ (function( $, undefined ) {
14
+
15
+ $.extend($.ui, { datepicker: { version: "1.8.14" } });
16
+
17
+ var PROP_NAME = 'datepicker';
18
+ var dpuuid = new Date().getTime();
19
+ var instActive;
20
+
21
+ /* Date picker manager.
22
+ Use the singleton instance of this class, $.datepicker, to interact with the date picker.
23
+ Settings for (groups of) date pickers are maintained in an instance object,
24
+ allowing multiple different settings on the same page. */
25
+
26
+ function Datepicker() {
27
+ this.debug = false; // Change this to true to start debugging
28
+ this._curInst = null; // The current instance in use
29
+ this._keyEvent = false; // If the last event was a key event
30
+ this._disabledInputs = []; // List of date picker inputs that have been disabled
31
+ this._datepickerShowing = false; // True if the popup picker is showing , false if not
32
+ this._inDialog = false; // True if showing within a "dialog", false if not
33
+ this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
34
+ this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class
35
+ this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
36
+ this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
37
+ this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
38
+ this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class
39
+ this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
40
+ this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
41
+ this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class
42
+ this.regional = []; // Available regional settings, indexed by language code
43
+ this.regional[''] = { // Default regional settings
44
+ closeText: 'Done', // Display text for close link
45
+ prevText: 'Prev', // Display text for previous month link
46
+ nextText: 'Next', // Display text for next month link
47
+ currentText: 'Today', // Display text for current month link
48
+ monthNames: ['January','February','March','April','May','June',
49
+ 'July','August','September','October','November','December'], // Names of months for drop-down and formatting
50
+ monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
51
+ dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
52
+ dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
53
+ dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
54
+ weekHeader: 'Wk', // Column header for week of the year
55
+ dateFormat: 'mm/dd/yy', // See format options on parseDate
56
+ firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
57
+ isRTL: false, // True if right-to-left language, false if left-to-right
58
+ showMonthAfterYear: false, // True if the year select precedes month, false for month then year
59
+ yearSuffix: '' // Additional text to append to the year in the month headers
60
+ };
61
+ this._defaults = { // Global defaults for all the date picker instances
62
+ showOn: 'focus', // 'focus' for popup on focus,
63
+ // 'button' for trigger button, or 'both' for either
64
+ showAnim: 'fadeIn', // Name of jQuery animation for popup
65
+ showOptions: {}, // Options for enhanced animations
66
+ defaultDate: null, // Used when field is blank: actual date,
67
+ // +/-number for offset from today, null for today
68
+ appendText: '', // Display text following the input box, e.g. showing the format
69
+ buttonText: '...', // Text for trigger button
70
+ buttonImage: '', // URL for trigger button image
71
+ buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
72
+ hideIfNoPrevNext: false, // True to hide next/previous month links
73
+ // if not applicable, false to just disable them
74
+ navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
75
+ gotoCurrent: false, // True if today link goes back to current selection instead
76
+ changeMonth: false, // True if month can be selected directly, false if only prev/next
77
+ changeYear: false, // True if year can be selected directly, false if only prev/next
78
+ yearRange: 'c-10:c+10', // Range of years to display in drop-down,
79
+ // either relative to today's year (-nn:+nn), relative to currently displayed year
80
+ // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
81
+ showOtherMonths: false, // True to show dates in other months, false to leave blank
82
+ selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
83
+ showWeek: false, // True to show week of the year, false to not show it
84
+ calculateWeek: this.iso8601Week, // How to calculate the week of the year,
85
+ // takes a Date and returns the number of the week for it
86
+ shortYearCutoff: '+10', // Short year values < this are in the current century,
87
+ // > this are in the previous century,
88
+ // string value starting with '+' for current year + value
89
+ minDate: null, // The earliest selectable date, or null for no limit
90
+ maxDate: null, // The latest selectable date, or null for no limit
91
+ duration: 'fast', // Duration of display/closure
92
+ beforeShowDay: null, // Function that takes a date and returns an array with
93
+ // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '',
94
+ // [2] = cell title (optional), e.g. $.datepicker.noWeekends
95
+ beforeShow: null, // Function that takes an input field and
96
+ // returns a set of custom settings for the date picker
97
+ onSelect: null, // Define a callback function when a date is selected
98
+ onChangeMonthYear: null, // Define a callback function when the month or year is changed
99
+ onClose: null, // Define a callback function when the datepicker is closed
100
+ numberOfMonths: 1, // Number of months to show at a time
101
+ showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
102
+ stepMonths: 1, // Number of months to step back/forward
103
+ stepBigMonths: 12, // Number of months to step back/forward for the big links
104
+ altField: '', // Selector for an alternate field to store selected dates into
105
+ altFormat: '', // The date format to use for the alternate field
106
+ constrainInput: true, // The input is constrained by the current date format
107
+ showButtonPanel: false, // True to show button panel, false to not show it
108
+ autoSize: false // True to size the input for the date format, false to leave as is
109
+ };
110
+ $.extend(this._defaults, this.regional['']);
111
+ this.dpDiv = bindHover($('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'));
112
+ }
113
+
114
+ $.extend(Datepicker.prototype, {
115
+ /* Class name added to elements to indicate already configured with a date picker. */
116
+ markerClassName: 'hasDatepicker',
117
+
118
+ //Keep track of the maximum number of rows displayed (see #7043)
119
+ maxRows: 4,
120
+
121
+ /* Debug logging (if enabled). */
122
+ log: function () {
123
+ if (this.debug)
124
+ console.log.apply('', arguments);
125
+ },
126
+
127
+ // TODO rename to "widget" when switching to widget factory
128
+ _widgetDatepicker: function() {
129
+ return this.dpDiv;
130
+ },
131
+
132
+ /* Override the default settings for all instances of the date picker.
133
+ @param settings object - the new settings to use as defaults (anonymous object)
134
+ @return the manager object */
135
+ setDefaults: function(settings) {
136
+ extendRemove(this._defaults, settings || {});
137
+ return this;
138
+ },
139
+
140
+ /* Attach the date picker to a jQuery selection.
141
+ @param target element - the target input field or division or span
142
+ @param settings object - the new settings to use for this date picker instance (anonymous) */
143
+ _attachDatepicker: function(target, settings) {
144
+ // check for settings on the control itself - in namespace 'date:'
145
+ var inlineSettings = null;
146
+ for (var attrName in this._defaults) {
147
+ var attrValue = target.getAttribute('date:' + attrName);
148
+ if (attrValue) {
149
+ inlineSettings = inlineSettings || {};
150
+ try {
151
+ inlineSettings[attrName] = eval(attrValue);
152
+ } catch (err) {
153
+ inlineSettings[attrName] = attrValue;
154
+ }
155
+ }
156
+ }
157
+ var nodeName = target.nodeName.toLowerCase();
158
+ var inline = (nodeName == 'div' || nodeName == 'span');
159
+ if (!target.id) {
160
+ this.uuid += 1;
161
+ target.id = 'dp' + this.uuid;
162
+ }
163
+ var inst = this._newInst($(target), inline);
164
+ inst.settings = $.extend({}, settings || {}, inlineSettings || {});
165
+ if (nodeName == 'input') {
166
+ this._connectDatepicker(target, inst);
167
+ } else if (inline) {
168
+ this._inlineDatepicker(target, inst);
169
+ }
170
+ },
171
+
172
+ /* Create a new instance object. */
173
+ _newInst: function(target, inline) {
174
+ var id = target[0].id.replace(/([^A-Za-z0-9_-])/g, '\\\\$1'); // escape jQuery meta chars
175
+ return {id: id, input: target, // associated target
176
+ selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
177
+ drawMonth: 0, drawYear: 0, // month being drawn
178
+ inline: inline, // is datepicker inline or not
179
+ dpDiv: (!inline ? this.dpDiv : // presentation div
180
+ bindHover($('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')))};
181
+ },
182
+
183
+ /* Attach the date picker to an input field. */
184
+ _connectDatepicker: function(target, inst) {
185
+ var input = $(target);
186
+ inst.append = $([]);
187
+ inst.trigger = $([]);
188
+ if (input.hasClass(this.markerClassName))
189
+ return;
190
+ this._attachments(input, inst);
191
+ input.addClass(this.markerClassName).keydown(this._doKeyDown).
192
+ keypress(this._doKeyPress).keyup(this._doKeyUp).
193
+ bind("setData.datepicker", function(event, key, value) {
194
+ inst.settings[key] = value;
195
+ }).bind("getData.datepicker", function(event, key) {
196
+ return this._get(inst, key);
197
+ });
198
+ this._autoSize(inst);
199
+ $.data(target, PROP_NAME, inst);
200
+ },
201
+
202
+ /* Make attachments based on settings. */
203
+ _attachments: function(input, inst) {
204
+ var appendText = this._get(inst, 'appendText');
205
+ var isRTL = this._get(inst, 'isRTL');
206
+ if (inst.append)
207
+ inst.append.remove();
208
+ if (appendText) {
209
+ inst.append = $('<span class="' + this._appendClass + '">' + appendText + '</span>');
210
+ input[isRTL ? 'before' : 'after'](inst.append);
211
+ }
212
+ input.unbind('focus', this._showDatepicker);
213
+ if (inst.trigger)
214
+ inst.trigger.remove();
215
+ var showOn = this._get(inst, 'showOn');
216
+ if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
217
+ input.focus(this._showDatepicker);
218
+ if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
219
+ var buttonText = this._get(inst, 'buttonText');
220
+ var buttonImage = this._get(inst, 'buttonImage');
221
+ inst.trigger = $(this._get(inst, 'buttonImageOnly') ?
222
+ $('<img/>').addClass(this._triggerClass).
223
+ attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
224
+ $('<button type="button"></button>').addClass(this._triggerClass).
225
+ html(buttonImage == '' ? buttonText : $('<img/>').attr(
226
+ { src:buttonImage, alt:buttonText, title:buttonText })));
227
+ input[isRTL ? 'before' : 'after'](inst.trigger);
228
+ inst.trigger.click(function() {
229
+ if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0])
230
+ $.datepicker._hideDatepicker();
231
+ else
232
+ $.datepicker._showDatepicker(input[0]);
233
+ return false;
234
+ });
235
+ }
236
+ },
237
+
238
+ /* Apply the maximum length for the date format. */
239
+ _autoSize: function(inst) {
240
+ if (this._get(inst, 'autoSize') && !inst.inline) {
241
+ var date = new Date(2009, 12 - 1, 20); // Ensure double digits
242
+ var dateFormat = this._get(inst, 'dateFormat');
243
+ if (dateFormat.match(/[DM]/)) {
244
+ var findMax = function(names) {
245
+ var max = 0;
246
+ var maxI = 0;
247
+ for (var i = 0; i < names.length; i++) {
248
+ if (names[i].length > max) {
249
+ max = names[i].length;
250
+ maxI = i;
251
+ }
252
+ }
253
+ return maxI;
254
+ };
255
+ date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
256
+ 'monthNames' : 'monthNamesShort'))));
257
+ date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
258
+ 'dayNames' : 'dayNamesShort'))) + 20 - date.getDay());
259
+ }
260
+ inst.input.attr('size', this._formatDate(inst, date).length);
261
+ }
262
+ },
263
+
264
+ /* Attach an inline date picker to a div. */
265
+ _inlineDatepicker: function(target, inst) {
266
+ var divSpan = $(target);
267
+ if (divSpan.hasClass(this.markerClassName))
268
+ return;
269
+ divSpan.addClass(this.markerClassName).append(inst.dpDiv).
270
+ bind("setData.datepicker", function(event, key, value){
271
+ inst.settings[key] = value;
272
+ }).bind("getData.datepicker", function(event, key){
273
+ return this._get(inst, key);
274
+ });
275
+ $.data(target, PROP_NAME, inst);
276
+ this._setDate(inst, this._getDefaultDate(inst), true);
277
+ this._updateDatepicker(inst);
278
+ this._updateAlternate(inst);
279
+ inst.dpDiv.show();
280
+ },
281
+
282
+ /* Pop-up the date picker in a "dialog" box.
283
+ @param input element - ignored
284
+ @param date string or Date - the initial date to display
285
+ @param onSelect function - the function to call when a date is selected
286
+ @param settings object - update the dialog date picker instance's settings (anonymous object)
287
+ @param pos int[2] - coordinates for the dialog's position within the screen or
288
+ event - with x/y coordinates or
289
+ leave empty for default (screen centre)
290
+ @return the manager object */
291
+ _dialogDatepicker: function(input, date, onSelect, settings, pos) {
292
+ var inst = this._dialogInst; // internal instance
293
+ if (!inst) {
294
+ this.uuid += 1;
295
+ var id = 'dp' + this.uuid;
296
+ this._dialogInput = $('<input type="text" id="' + id +
297
+ '" style="position: absolute; top: -100px; width: 0px; z-index: -10;"/>');
298
+ this._dialogInput.keydown(this._doKeyDown);
299
+ $('body').append(this._dialogInput);
300
+ inst = this._dialogInst = this._newInst(this._dialogInput, false);
301
+ inst.settings = {};
302
+ $.data(this._dialogInput[0], PROP_NAME, inst);
303
+ }
304
+ extendRemove(inst.settings, settings || {});
305
+ date = (date && date.constructor == Date ? this._formatDate(inst, date) : date);
306
+ this._dialogInput.val(date);
307
+
308
+ this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
309
+ if (!this._pos) {
310
+ var browserWidth = document.documentElement.clientWidth;
311
+ var browserHeight = document.documentElement.clientHeight;
312
+ var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
313
+ var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
314
+ this._pos = // should use actual width/height below
315
+ [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
316
+ }
317
+
318
+ // move input on screen for focus, but hidden behind dialog
319
+ this._dialogInput.css('left', (this._pos[0] + 20) + 'px').css('top', this._pos[1] + 'px');
320
+ inst.settings.onSelect = onSelect;
321
+ this._inDialog = true;
322
+ this.dpDiv.addClass(this._dialogClass);
323
+ this._showDatepicker(this._dialogInput[0]);
324
+ if ($.blockUI)
325
+ $.blockUI(this.dpDiv);
326
+ $.data(this._dialogInput[0], PROP_NAME, inst);
327
+ return this;
328
+ },
329
+
330
+ /* Detach a datepicker from its control.
331
+ @param target element - the target input field or division or span */
332
+ _destroyDatepicker: function(target) {
333
+ var $target = $(target);
334
+ var inst = $.data(target, PROP_NAME);
335
+ if (!$target.hasClass(this.markerClassName)) {
336
+ return;
337
+ }
338
+ var nodeName = target.nodeName.toLowerCase();
339
+ $.removeData(target, PROP_NAME);
340
+ if (nodeName == 'input') {
341
+ inst.append.remove();
342
+ inst.trigger.remove();
343
+ $target.removeClass(this.markerClassName).
344
+ unbind('focus', this._showDatepicker).
345
+ unbind('keydown', this._doKeyDown).
346
+ unbind('keypress', this._doKeyPress).
347
+ unbind('keyup', this._doKeyUp);
348
+ } else if (nodeName == 'div' || nodeName == 'span')
349
+ $target.removeClass(this.markerClassName).empty();
350
+ },
351
+
352
+ /* Enable the date picker to a jQuery selection.
353
+ @param target element - the target input field or division or span */
354
+ _enableDatepicker: function(target) {
355
+ var $target = $(target);
356
+ var inst = $.data(target, PROP_NAME);
357
+ if (!$target.hasClass(this.markerClassName)) {
358
+ return;
359
+ }
360
+ var nodeName = target.nodeName.toLowerCase();
361
+ if (nodeName == 'input') {
362
+ target.disabled = false;
363
+ inst.trigger.filter('button').
364
+ each(function() { this.disabled = false; }).end().
365
+ filter('img').css({opacity: '1.0', cursor: ''});
366
+ }
367
+ else if (nodeName == 'div' || nodeName == 'span') {
368
+ var inline = $target.children('.' + this._inlineClass);
369
+ inline.children().removeClass('ui-state-disabled');
370
+ inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
371
+ removeAttr("disabled");
372
+ }
373
+ this._disabledInputs = $.map(this._disabledInputs,
374
+ function(value) { return (value == target ? null : value); }); // delete entry
375
+ },
376
+
377
+ /* Disable the date picker to a jQuery selection.
378
+ @param target element - the target input field or division or span */
379
+ _disableDatepicker: function(target) {
380
+ var $target = $(target);
381
+ var inst = $.data(target, PROP_NAME);
382
+ if (!$target.hasClass(this.markerClassName)) {
383
+ return;
384
+ }
385
+ var nodeName = target.nodeName.toLowerCase();
386
+ if (nodeName == 'input') {
387
+ target.disabled = true;
388
+ inst.trigger.filter('button').
389
+ each(function() { this.disabled = true; }).end().
390
+ filter('img').css({opacity: '0.5', cursor: 'default'});
391
+ }
392
+ else if (nodeName == 'div' || nodeName == 'span') {
393
+ var inline = $target.children('.' + this._inlineClass);
394
+ inline.children().addClass('ui-state-disabled');
395
+ inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
396
+ attr("disabled", "disabled");
397
+ }
398
+ this._disabledInputs = $.map(this._disabledInputs,
399
+ function(value) { return (value == target ? null : value); }); // delete entry
400
+ this._disabledInputs[this._disabledInputs.length] = target;
401
+ },
402
+
403
+ /* Is the first field in a jQuery collection disabled as a datepicker?
404
+ @param target element - the target input field or division or span
405
+ @return boolean - true if disabled, false if enabled */
406
+ _isDisabledDatepicker: function(target) {
407
+ if (!target) {
408
+ return false;
409
+ }
410
+ for (var i = 0; i < this._disabledInputs.length; i++) {
411
+ if (this._disabledInputs[i] == target)
412
+ return true;
413
+ }
414
+ return false;
415
+ },
416
+
417
+ /* Retrieve the instance data for the target control.
418
+ @param target element - the target input field or division or span
419
+ @return object - the associated instance data
420
+ @throws error if a jQuery problem getting data */
421
+ _getInst: function(target) {
422
+ try {
423
+ return $.data(target, PROP_NAME);
424
+ }
425
+ catch (err) {
426
+ throw 'Missing instance data for this datepicker';
427
+ }
428
+ },
429
+
430
+ /* Update or retrieve the settings for a date picker attached to an input field or division.
431
+ @param target element - the target input field or division or span
432
+ @param name object - the new settings to update or
433
+ string - the name of the setting to change or retrieve,
434
+ when retrieving also 'all' for all instance settings or
435
+ 'defaults' for all global defaults
436
+ @param value any - the new value for the setting
437
+ (omit if above is an object or to retrieve a value) */
438
+ _optionDatepicker: function(target, name, value) {
439
+ var inst = this._getInst(target);
440
+ if (arguments.length == 2 && typeof name == 'string') {
441
+ return (name == 'defaults' ? $.extend({}, $.datepicker._defaults) :
442
+ (inst ? (name == 'all' ? $.extend({}, inst.settings) :
443
+ this._get(inst, name)) : null));
444
+ }
445
+ var settings = name || {};
446
+ if (typeof name == 'string') {
447
+ settings = {};
448
+ settings[name] = value;
449
+ }
450
+ if (inst) {
451
+ if (this._curInst == inst) {
452
+ this._hideDatepicker();
453
+ }
454
+ var date = this._getDateDatepicker(target, true);
455
+ var minDate = this._getMinMaxDate(inst, 'min');
456
+ var maxDate = this._getMinMaxDate(inst, 'max');
457
+ extendRemove(inst.settings, settings);
458
+ // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
459
+ if (minDate !== null && settings['dateFormat'] !== undefined && settings['minDate'] === undefined)
460
+ inst.settings.minDate = this._formatDate(inst, minDate);
461
+ if (maxDate !== null && settings['dateFormat'] !== undefined && settings['maxDate'] === undefined)
462
+ inst.settings.maxDate = this._formatDate(inst, maxDate);
463
+ this._attachments($(target), inst);
464
+ this._autoSize(inst);
465
+ this._setDate(inst, date);
466
+ this._updateAlternate(inst);
467
+ this._updateDatepicker(inst);
468
+ }
469
+ },
470
+
471
+ // change method deprecated
472
+ _changeDatepicker: function(target, name, value) {
473
+ this._optionDatepicker(target, name, value);
474
+ },
475
+
476
+ /* Redraw the date picker attached to an input field or division.
477
+ @param target element - the target input field or division or span */
478
+ _refreshDatepicker: function(target) {
479
+ var inst = this._getInst(target);
480
+ if (inst) {
481
+ this._updateDatepicker(inst);
482
+ }
483
+ },
484
+
485
+ /* Set the dates for a jQuery selection.
486
+ @param target element - the target input field or division or span
487
+ @param date Date - the new date */
488
+ _setDateDatepicker: function(target, date) {
489
+ var inst = this._getInst(target);
490
+ if (inst) {
491
+ this._setDate(inst, date);
492
+ this._updateDatepicker(inst);
493
+ this._updateAlternate(inst);
494
+ }
495
+ },
496
+
497
+ /* Get the date(s) for the first entry in a jQuery selection.
498
+ @param target element - the target input field or division or span
499
+ @param noDefault boolean - true if no default date is to be used
500
+ @return Date - the current date */
501
+ _getDateDatepicker: function(target, noDefault) {
502
+ var inst = this._getInst(target);
503
+ if (inst && !inst.inline)
504
+ this._setDateFromField(inst, noDefault);
505
+ return (inst ? this._getDate(inst) : null);
506
+ },
507
+
508
+ /* Handle keystrokes. */
509
+ _doKeyDown: function(event) {
510
+ var inst = $.datepicker._getInst(event.target);
511
+ var handled = true;
512
+ var isRTL = inst.dpDiv.is('.ui-datepicker-rtl');
513
+ inst._keyEvent = true;
514
+ if ($.datepicker._datepickerShowing)
515
+ switch (event.keyCode) {
516
+ case 9: $.datepicker._hideDatepicker();
517
+ handled = false;
518
+ break; // hide on tab out
519
+ case 13: var sel = $('td.' + $.datepicker._dayOverClass + ':not(.' +
520
+ $.datepicker._currentClass + ')', inst.dpDiv);
521
+ if (sel[0])
522
+ $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
523
+ else
524
+ $.datepicker._hideDatepicker();
525
+ return false; // don't submit the form
526
+ break; // select the value on enter
527
+ case 27: $.datepicker._hideDatepicker();
528
+ break; // hide on escape
529
+ case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
530
+ -$.datepicker._get(inst, 'stepBigMonths') :
531
+ -$.datepicker._get(inst, 'stepMonths')), 'M');
532
+ break; // previous month/year on page up/+ ctrl
533
+ case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
534
+ +$.datepicker._get(inst, 'stepBigMonths') :
535
+ +$.datepicker._get(inst, 'stepMonths')), 'M');
536
+ break; // next month/year on page down/+ ctrl
537
+ case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target);
538
+ handled = event.ctrlKey || event.metaKey;
539
+ break; // clear on ctrl or command +end
540
+ case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target);
541
+ handled = event.ctrlKey || event.metaKey;
542
+ break; // current on ctrl or command +home
543
+ case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D');
544
+ handled = event.ctrlKey || event.metaKey;
545
+ // -1 day on ctrl or command +left
546
+ if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
547
+ -$.datepicker._get(inst, 'stepBigMonths') :
548
+ -$.datepicker._get(inst, 'stepMonths')), 'M');
549
+ // next month/year on alt +left on Mac
550
+ break;
551
+ case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D');
552
+ handled = event.ctrlKey || event.metaKey;
553
+ break; // -1 week on ctrl or command +up
554
+ case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D');
555
+ handled = event.ctrlKey || event.metaKey;
556
+ // +1 day on ctrl or command +right
557
+ if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
558
+ +$.datepicker._get(inst, 'stepBigMonths') :
559
+ +$.datepicker._get(inst, 'stepMonths')), 'M');
560
+ // next month/year on alt +right
561
+ break;
562
+ case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D');
563
+ handled = event.ctrlKey || event.metaKey;
564
+ break; // +1 week on ctrl or command +down
565
+ default: handled = false;
566
+ }
567
+ else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home
568
+ $.datepicker._showDatepicker(this);
569
+ else {
570
+ handled = false;
571
+ }
572
+ if (handled) {
573
+ event.preventDefault();
574
+ event.stopPropagation();
575
+ }
576
+ },
577
+
578
+ /* Filter entered characters - based on date format. */
579
+ _doKeyPress: function(event) {
580
+ var inst = $.datepicker._getInst(event.target);
581