r2603 - Merged r2418 to 1.7.2 (fixes #4301 - Datepicker: option dateFormat getter does not return...

r2603 - Merged r2418 to 1.7.2 (fixes #4301 - Datepicker: option dateFormat getter does not return...


Author: rdworth
Date: Tue May 26 03:50:32 2009
New Revision: 2603
Modified:
branches/1.7.2/ (props changed)
branches/1.7.2/tests/unit/datepicker/datepicker_options.js
branches/1.7.2/tests/visual/accordion/ (props changed)
branches/1.7.2/tests/visual/datepicker/ (props changed)
branches/1.7.2/tests/visual/resizable/ (props changed)
branches/1.7.2/tests/visual/selectable/ (props changed)
branches/1.7.2/tests/visual/slider/ (props changed)
branches/1.7.2/ui/i18n/ui.datepicker-ro.js (props changed)
branches/1.7.2/ui/i18n/ui.datepicker-sq.js (props changed)
branches/1.7.2/ui/i18n/ui.datepicker-uk.js (props changed)
branches/1.7.2/ui/ui.accordion.js (props changed)
branches/1.7.2/ui/ui.datepicker.js (contents, props changed)
branches/1.7.2/ui/ui.droppable.js (props changed)
branches/1.7.2/ui/ui.resizable.js (props changed)
branches/1.7.2/ui/ui.selectable.js (props changed)
branches/1.7.2/ui/ui.slider.js (props changed)
Log:
Merged r2418 to 1.7.2 (fixes #4301 - Datepicker: option dateFormat getter
does not return same value as setter)
Modified: branches/1.7.2/tests/unit/datepicker/datepicker_options.js
==============================================================================
--- branches/1.7.2/tests/unit/datepicker/datepicker_options.js    (original)
+++ branches/1.7.2/tests/unit/datepicker/datepicker_options.js    Tue May 26
03:50:32 2009
@@ -18,6 +18,7 @@
test('option', function() {
    var inp = init('#inp');
    var inst = $.data(inp[0], PROP_NAME);
+    // Set option
    equals(inst.settings.showOn, null, 'Initial setting showOn');
    equals($.datepicker._get(inst, 'showOn'), 'focus', 'Initial instance
showOn');
    equals($.datepicker._defaults.showOn, 'focus', 'Initial default showOn');
@@ -33,6 +34,16 @@
    equals(inst.settings.showOn, null, 'Clear setting showOn');
    equals($.datepicker._get(inst, 'showOn'), 'focus', 'Restore instance
showOn');
    equals($.datepicker._defaults.showOn, 'focus', 'Retain default showOn');
+    // Get option
+    inp = init('#inp');
+    equals(inp.datepicker('option', 'showOn'), 'focus', 'Initial setting
showOn');
+    inp.datepicker('option', 'showOn', 'button');
+    equals(inp.datepicker('option', 'showOn'), 'button', 'Change instance
showOn');
+    inp.datepicker('option', 'showOn', undefined);
+    equals(inp.datepicker('option', 'showOn'), 'focus', 'Reset instance
showOn');
+    same(inp.datepicker('option', 'all'), {duration: ''}, 'Get instance
settings');
+    same(inp.datepicker('option', 'defaults'), $.datepicker._defaults,
+        'Get default settings');
});
test('change', function() {
Modified: branches/1.7.2/ui/ui.datepicker.js
==============================================================================
--- branches/1.7.2/ui/ui.datepicker.js    (original)
+++ branches/1.7.2/ui/ui.datepicker.js    Tue May 26 03:50:32 2009
@@ -364,31 +364,33 @@
        }
    },
-    /* Update the settings for a date picker attached to an input field or
division.
+    /* Update or retrieve the settings for a date picker attached to an input
field or division.
     @param target element - the target input field or division or span
     @param name object - the new settings to update or
-     string - the name of the setting to change or
-     @param value any - the new value for the setting (omit if above is
an object) */
+     string - the name of the setting to change or retrieve,
+     when retrieving also 'all' for all instance settings or
+     'defaults' for all global defaults
+     @param value any - the new value for the setting
+     (omit if above is an object or to retrieve a value) */
    _optionDatepicker: function(target, name, value) {
+        var inst = this._getInst(target);
+        if (arguments.length == 2 && typeof name == 'string') {
+            return (name == 'defaults' ? $.extend({}, $.datepicker._defaults) :
+                (inst ? (name == 'all' ? $.extend({}, inst.settings) :
+                this._get(inst, name)) : null));
+        }
        var settings = name || {};
        if (typeof name == 'string') {
            settings = {};
            settings[name] = value;
        }
-        var inst = this._getInst(target);
        if (inst) {
            if (this._curInst == inst) {
                this._hideDatepicker(null);
            }
+            var date = this._getDateDatepicker(target);
            extendRemove(inst.settings, settings);
-            var date = new Date();
-            extendRemove(inst, {rangeStart: null, // start of range
-                endDay: null, endMonth: null, endYear: null, // end of range
-                selectedDay: date.getDate(), selectedMonth: date.getMonth(),
-                selectedYear: date.getFullYear(), // starting point
-                currentDay: date.getDate(), currentMonth: date.getMonth(),
-                currentYear: date.getFullYear(), // current selection
-                drawMonth: date.getMonth(), drawYear: date.getFullYear()}); // month
being drawn
+            this._setDateDatepicker(target, date);
            this._updateDatepicker(inst);
        }
    },
@@ -1609,6 +1611,9 @@
    var otherArgs = Array.prototype.slice.call(arguments, 1);
    if (typeof options == 'string' && (options == 'isDisabled' || options
== 'getDate'))
+        return $.datepicker['_' + options + 'Datepicker'].
+            apply($.datepicker, [this[0]].concat(otherArgs));
+    if (options == 'option' && arguments.length == 2 && typeof arguments[1]
== 'string')
        return $.datepicker['_' + options + 'Datepicker'].
            apply($.datepicker, [this[0]].concat(otherArgs));
    return this.each(function() {