# HG changeset patch # User Pawel Solyga # Date 1232469113 0 # Node ID 3e50c012a4a87842abeef620eadd34a76450bb2c # Parent 58da949dd64c419bd3f4e03f15f35b666392654b Add datetimepicker javascript widget files and css file. Patch by: Pawel Solyga Review by: to-be-reviewed diff -r 58da949dd64c -r 3e50c012a4a8 app/jquery/jquery-ui.core.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/jquery/jquery-ui.core.js Tue Jan 20 16:31:53 2009 +0000 @@ -0,0 +1,530 @@ +/* + * jQuery UI @VERSION + * + * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://docs.jquery.com/UI + */ +;(function($) { + +var _remove = $.fn.remove, + isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9); + +//Helper functions and ui object +$.ui = { + version: "@VERSION", + + // $.ui.plugin is deprecated. Use the proxy pattern instead. + plugin: { + add: function(module, option, set) { + var proto = $.ui[module].prototype; + for(var i in set) { + proto.plugins[i] = proto.plugins[i] || []; + proto.plugins[i].push([option, set[i]]); + } + }, + call: function(instance, name, args) { + var set = instance.plugins[name]; + if(!set) { return; } + + for (var i = 0; i < set.length; i++) { + if (instance.options[set[i][0]]) { + set[i][1].apply(instance.element, args); + } + } + } + }, + + contains: function(a, b) { + return document.compareDocumentPosition + ? a.compareDocumentPosition(b) & 16 + : a !== b && a.contains(b); + }, + + cssCache: {}, + css: function(name) { + if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; } + var tmp = $('
').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body'); + + //if (!$.browser.safari) + //tmp.appendTo('body'); + + //Opera and Safari set width and height to 0px instead of auto + //Safari returns rgba(0,0,0,0) when bgcolor is not set + $.ui.cssCache[name] = !!( + (!(/auto|default/).test(tmp.css('cursor')) || (/^[1-9]/).test(tmp.css('height')) || (/^[1-9]/).test(tmp.css('width')) || + !(/none/).test(tmp.css('backgroundImage')) || !(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor'))) + ); + try { $('body').get(0).removeChild(tmp.get(0)); } catch(e){} + return $.ui.cssCache[name]; + }, + + hasScroll: function(el, a) { + + //If overflow is hidden, the element might have extra content, but the user wants to hide it + if ($(el).css('overflow') == 'hidden') { return false; } + + var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop', + has = false; + + if (el[scroll] > 0) { return true; } + + // TODO: determine which cases actually cause this to happen + // if the element doesn't have the scroll set, see if it's possible to + // set the scroll + el[scroll] = 1; + has = (el[scroll] > 0); + el[scroll] = 0; + return has; + }, + + isOverAxis: function(x, reference, size) { + //Determines when x coordinate is over "b" element axis + return (x > reference) && (x < (reference + size)); + }, + + isOver: function(y, x, top, left, height, width) { + //Determines when x, y coordinates is over "b" element + return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width); + }, + + keyCode: { + BACKSPACE: 8, + CAPS_LOCK: 20, + COMMA: 188, + CONTROL: 17, + DELETE: 46, + DOWN: 40, + END: 35, + ENTER: 13, + ESCAPE: 27, + HOME: 36, + INSERT: 45, + LEFT: 37, + NUMPAD_ADD: 107, + NUMPAD_DECIMAL: 110, + NUMPAD_DIVIDE: 111, + NUMPAD_ENTER: 108, + NUMPAD_MULTIPLY: 106, + NUMPAD_SUBTRACT: 109, + PAGE_DOWN: 34, + PAGE_UP: 33, + PERIOD: 190, + RIGHT: 39, + SHIFT: 16, + SPACE: 32, + TAB: 9, + UP: 38 + } +}; + +// WAI-ARIA normalization +if (isFF2) { + var attr = $.attr, + removeAttr = $.fn.removeAttr, + ariaNS = "http://www.w3.org/2005/07/aaa", + ariaState = /^aria-/, + ariaRole = /^wairole:/; + + $.attr = function(elem, name, value) { + var set = value !== undefined; + + return (name == 'role' + ? (set + ? attr.call(this, elem, name, "wairole:" + value) + : (attr.apply(this, arguments) || "").replace(ariaRole, "")) + : (ariaState.test(name) + ? (set + ? elem.setAttributeNS(ariaNS, + name.replace(ariaState, "aaa:"), value) + : attr.call(this, elem, name.replace(ariaState, "aaa:"))) + : attr.apply(this, arguments))); + }; + + $.fn.removeAttr = function(name) { + return (ariaState.test(name) + ? this.each(function() { + this.removeAttributeNS(ariaNS, name.replace(ariaState, "")); + }) : removeAttr.call(this, name)); + }; +} + +//jQuery plugins +$.fn.extend({ + remove: function() { + // Safari has a native remove event which actually removes DOM elements, + // so we have to use triggerHandler instead of trigger (#3037). + $("*", this).add(this).each(function() { + $(this).triggerHandler("remove"); + }); + return _remove.apply(this, arguments ); + }, + + enableSelection: function() { + return this + .attr('unselectable', 'off') + .css('MozUserSelect', '') + .unbind('selectstart.ui'); + }, + + disableSelection: function() { + return this + .attr('unselectable', 'on') + .css('MozUserSelect', 'none') + .bind('selectstart.ui', function() { return false; }); + }, + + scrollParent: function() { + var scrollParent; + if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) { + scrollParent = this.parents().filter(function() { + return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1)); + }).eq(0); + } else { + scrollParent = this.parents().filter(function() { + return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1)); + }).eq(0); + } + + return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent; + } +}); + + +//Additional selectors +$.extend($.expr[':'], { + data: function(elem, i, match) { + return !!$.data(elem, match[3]); + }, + + // TODO: add support for object, area + tabbable: function(elem) { + var nodeName = elem.nodeName.toLowerCase(); + function isVisible(element) { + return !($(element).is(':hidden') || $(element).parents(':hidden').length); + } + + return ( + // in tab order + elem.tabIndex >= 0 && + + ( // filter node types that participate in the tab order + + // anchor tag + ('a' == nodeName && elem.href) || + + // enabled form element + (/input|select|textarea|button/.test(nodeName) && + 'hidden' != elem.type && !elem.disabled) + ) && + + // visible on page + isVisible(elem) + ); + } +}); + + +// $.widget is a factory to create jQuery plugins +// taking some boilerplate code out of the plugin code +function getter(namespace, plugin, method, args) { + function getMethods(type) { + var methods = $[namespace][plugin][type] || []; + return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods); + } + + var methods = getMethods('getter'); + if (args.length == 1 && typeof args[0] == 'string') { + methods = methods.concat(getMethods('getterSetter')); + } + return ($.inArray(method, methods) != -1); +} + +$.widget = function(name, prototype) { + var namespace = name.split(".")[0]; + name = name.split(".")[1]; + + // create plugin method + $.fn[name] = function(options) { + var isMethodCall = (typeof options == 'string'), + args = Array.prototype.slice.call(arguments, 1); + + // prevent calls to internal methods + if (isMethodCall && options.substring(0, 1) == '_') { + return this; + } + + // handle getter methods + if (isMethodCall && getter(namespace, name, options, args)) { + var instance = $.data(this[0], name); + return (instance ? instance[options].apply(instance, args) + : undefined); + } + + // handle initialization and non-getter methods + return this.each(function() { + var instance = $.data(this, name); + + // constructor + (!instance && !isMethodCall && + $.data(this, name, new $[namespace][name](this, options))); + + // method call + (instance && isMethodCall && $.isFunction(instance[options]) && + instance[options].apply(instance, args)); + }); + }; + + // create widget constructor + $[namespace] = $[namespace] || {}; + $[namespace][name] = function(element, options) { + var self = this; + + this.namespace = namespace; + this.widgetName = name; + this.widgetEventPrefix = $[namespace][name].eventPrefix || name; + this.widgetBaseClass = namespace + '-' + name; + + this.options = $.extend({}, + $.widget.defaults, + $[namespace][name].defaults, + $.metadata && $.metadata.get(element)[name], + options); + + this.element = $(element) + .bind('setData.' + name, function(event, key, value) { + if (event.target == element) { + return self._setData(key, value); + } + }) + .bind('getData.' + name, function(event, key) { + if (event.target == element) { + return self._getData(key); + } + }) + .bind('remove', function() { + return self.destroy(); + }); + + this._init(); + }; + + // add widget prototype + $[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype); + + // TODO: merge getter and getterSetter properties from widget prototype + // and plugin prototype + $[namespace][name].getterSetter = 'option'; +}; + +$.widget.prototype = { + _init: function() {}, + destroy: function() { + this.element.removeData(this.widgetName) + .removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled') + .removeAttr('aria-disabled'); + }, + + option: function(key, value) { + var options = key, + self = this; + + if (typeof key == "string") { + if (value === undefined) { + return this._getData(key); + } + options = {}; + options[key] = value; + } + + $.each(options, function(key, value) { + self._setData(key, value); + }); + }, + _getData: function(key) { + return this.options[key]; + }, + _setData: function(key, value) { + this.options[key] = value; + + if (key == 'disabled') { + this.element + [value ? 'addClass' : 'removeClass']( + this.widgetBaseClass + '-disabled' + ' ' + + this.namespace + '-state-disabled') + .attr("aria-disabled", value); + } + }, + + enable: function() { + this._setData('disabled', false); + }, + disable: function() { + this._setData('disabled', true); + }, + + _trigger: function(type, event, data) { + var callback = this.options[type], + eventName = (type == this.widgetEventPrefix + ? type : this.widgetEventPrefix + type); + + event = event ? $.event.fix(event) : $.Event(); + event.type = eventName; + + this.element.trigger(event, data); + + return !(callback && callback.call(this.element[0], event, data) === false + || event.isDefaultPrevented()); + } +}; + +$.widget.defaults = { + disabled: false +}; + + +/** Mouse Interaction Plugin **/ + +$.ui.mouse = { + _mouseInit: function() { + var self = this; + + this.element + .bind('mousedown.'+this.widgetName, function(event) { + return self._mouseDown(event); + }) + .bind('click.'+this.widgetName, function(event) { + if(self._preventClickEvent) { + self._preventClickEvent = false; + return false; + } + }); + + // Prevent text selection in IE + if ($.browser.msie) { + this._mouseUnselectable = this.element.attr('unselectable'); + this.element.attr('unselectable', 'on'); + } + + this.started = false; + }, + + // TODO: make sure destroying one instance of mouse doesn't mess with + // other instances of mouse + _mouseDestroy: function() { + this.element.unbind('.'+this.widgetName); + + // Restore text selection in IE + ($.browser.msie + && this.element.attr('unselectable', this._mouseUnselectable)); + }, + + _mouseDown: function(event) { + // we may have missed mouseup (out of window) + (this._mouseStarted && this._mouseUp(event)); + + this._mouseDownEvent = event; + + var self = this, + btnIsLeft = (event.which == 1), + elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false); + if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { + return true; + } + + this.mouseDelayMet = !this.options.delay; + if (!this.mouseDelayMet) { + this._mouseDelayTimer = setTimeout(function() { + self.mouseDelayMet = true; + }, this.options.delay); + } + + if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { + this._mouseStarted = (this._mouseStart(event) !== false); + if (!this._mouseStarted) { + event.preventDefault(); + return true; + } + } + + // these delegates are required to keep context + this._mouseMoveDelegate = function(event) { + return self._mouseMove(event); + }; + this._mouseUpDelegate = function(event) { + return self._mouseUp(event); + }; + $(document) + .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate) + .bind('mouseup.'+this.widgetName, this._mouseUpDelegate); + + // preventDefault() is used to prevent the selection of text here - + // however, in Safari, this causes select boxes not to be selectable + // anymore, so this fix is needed + ($.browser.safari || event.preventDefault()); + + return true; + }, + + _mouseMove: function(event) { + // IE mouseup check - mouseup happened when mouse was out of window + if ($.browser.msie && !event.button) { + return this._mouseUp(event); + } + + if (this._mouseStarted) { + this._mouseDrag(event); + return event.preventDefault(); + } + + if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { + this._mouseStarted = + (this._mouseStart(this._mouseDownEvent, event) !== false); + (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event)); + } + + return !this._mouseStarted; + }, + + _mouseUp: function(event) { + $(document) + .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate) + .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate); + + if (this._mouseStarted) { + this._mouseStarted = false; + this._preventClickEvent = true; + this._mouseStop(event); + } + + return false; + }, + + _mouseDistanceMet: function(event) { + return (Math.max( + Math.abs(this._mouseDownEvent.pageX - event.pageX), + Math.abs(this._mouseDownEvent.pageY - event.pageY) + ) >= this.options.distance + ); + }, + + _mouseDelayMet: function(event) { + return this.mouseDelayMet; + }, + + // These are placeholder methods, to be overriden by extending plugin + _mouseStart: function(event) {}, + _mouseDrag: function(event) {}, + _mouseStop: function(event) {}, + _mouseCapture: function(event) { return true; } +}; + +$.ui.mouse.defaults = { + cancel: null, + distance: 1, + delay: 0 +}; + +})(jQuery); diff -r 58da949dd64c -r 3e50c012a4a8 app/jquery/jquery-ui.datetimepicker.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/jquery/jquery-ui.datetimepicker.js Tue Jan 20 16:31:53 2009 +0000 @@ -0,0 +1,1523 @@ +/* jQuery UI Date Picker v3.4.3 (previously jQuery Calendar) + Written by Marc Grabanski (m@marcgrabanski.com) and Keith Wood (kbwood@virginbroadband.com.au). + + Copyright (c) 2007 Marc Grabanski (http://marcgrabanski.com/code/ui-datetimepicker) + Dual licensed under the MIT (MIT-LICENSE.txt) + and GPL (GPL-LICENSE.txt) licenses. + Date: 09-03-2007 */ +/* + * Time functionality added by Stanislav Dobry (stanislav.dobry@datesoft.cz) + * Date: 2008-06-04 + */ + +;(function($) { // hide the namespace + +/* Date picker manager. + Use the singleton instance of this class, $.datetimepicker, to interact with the date picker. + Settings for (groups of) date pickers are maintained in an instance object + (DatepickerInstance), allowing multiple different settings on the same page. */ + +function DateTimepicker() { + this.debug = false; // Change this to true to start debugging + this._nextId = 0; // Next ID for a date picker instance + this._inst = []; // List of instances indexed by ID + this._curInst = null; // The current instance in use + this._disabledInputs = []; // List of date picker inputs that have been disabled + this._datetimepickerShowing = false; // True if the popup picker is showing , false if not + this._inDialog = false; // True if showing within a "dialog", false if not + this.regional = []; // Available regional settings, indexed by language code + this.regional[''] = { // Default regional settings + clearText: 'Clear', // Display text for clear link + clearStatus: 'Erase the current date', // Status text for clear link + closeText: 'Close', // Display text for close link + closeStatus: 'Close without change', // Status text for close link + prevText: '<Prev', // Display text for previous month link + prevStatus: 'Show the previous month', // Status text for previous month link + nextText: 'Next>', // Display text for next month link + nextStatus: 'Show the next month', // Status text for next month link + currentText: 'Today', // Display text for current month link + currentStatus: 'Show the current month', // Status text for current month link + monthNames: ['January','February','March','April','May','June', + 'July','August','September','October','November','December'], // Names of months for drop-down and formatting + monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting + monthStatus: 'Show a different month', // Status text for selecting a month + yearStatus: 'Show a different year', // Status text for selecting a year + weekHeader: 'Wk', // Header for the week of the year column + weekStatus: 'Week of the year', // Status text for the week of the year column + dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting + dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting + dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday + dayStatus: 'Set DD as first week day', // Status text for the day of the week selection + dateStatus: 'Select DD, M d', // Status text for the date selection + dateFormat: 'mm/dd/yy', // See format options on parseDate + timeFormat: 'hh:ii', + firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ... + initStatus: 'Select a date', // Initial Status text on opening + isRTL: false // True if right-to-left language, false if left-to-right + }; + this._defaults = { // Global defaults for all the date picker instances + showOn: 'focus', // 'focus' for popup on focus, + // 'button' for trigger button, or 'both' for either + showAnim: 'show', // Name of jQuery animation for popup + defaultDate: null, // Used when field is blank: actual date, + // +/-number for offset from today, null for today + appendText: '', // Display text following the input box, e.g. showing the format + buttonText: '...', // Text for trigger button + buttonImage: '', // URL for trigger button image + buttonImageOnly: false, // True if the image appears alone, false if it appears on a button + closeAtTop: true, // True to have the clear/close at the top, + // false to have them at the bottom + mandatory: false, // True to hide the Clear link, false to include it + hideIfNoPrevNext: false, // True to hide next/previous month links + // if not applicable, false to just disable them + changeMonth: true, // True if month can be selected directly, false if only prev/next + changeYear: true, // True if year can be selected directly, false if only prev/next + yearRange: '-10:+10', // Range of years to display in drop-down, + // either relative to current year (-nn:+nn) or absolute (nnnn:nnnn) + changeFirstDay: true, // True to click on day name to change, false to remain as set + showOtherMonths: false, // True to show dates in other months, false to leave blank + showWeeks: false, // True to show week of the year, false to omit + calculateWeek: this.iso8601Week, // How to calculate the week of the year, + // takes a Date and returns the number of the week for it + shortYearCutoff: '+10', // Short year values < this are in the current century, + // > this are in the previous century, + // string value starting with '+' for current year + value + showStatus: false, // True to show status bar at bottom, false to not show it + statusForDate: this.dateStatus, // Function to provide status text for a date - + // takes date and instance as parameters, returns display text + minDate: null, // The earliest selectable date, or null for no limit + maxDate: null, // The latest selectable date, or null for no limit + speed: 'normal', // Speed of display/closure + beforeShowDay: null, // Function that takes a date and returns an array with + // [0] = true if selectable, false if not, + // [1] = custom CSS class name(s) or '', e.g. $.datetimepicker.noWeekends + beforeShow: null, // Function that takes an input field and + // returns a set of custom settings for the date picker + onSelect: null, // Define a callback function when a date is selected + onClose: null, // Define a callback function when the datetimepicker is closed + numberOfMonths: 1, // Number of months to show at a time + stepMonths: 1, // Number of months to step back/forward + rangeSelect: false, // Allows for selecting a date range on one date picker + rangeSeparator: ' - ' // Text between two dates in a range + }; + $.extend(this._defaults, this.regional['']); + this._datetimepickerDiv = $('
'); +} + +$.extend(DateTimepicker.prototype, { + /* Class name added to elements to indicate already configured with a date picker. */ + markerClassName: 'hasDatepicker', + + /* Debug logging (if enabled). */ + log: function () { + if (this.debug) + console.log.apply('', arguments); + }, + + /* Register a new date picker instance - with custom settings. */ + _register: function(inst) { + var id = this._nextId++; + this._inst[id] = inst; + return id; + }, + + /* Retrieve a particular date picker instance based on its ID. */ + _getInst: function(id) { + return this._inst[id] || id; + }, + + /* Override the default settings for all instances of the date picker. + @param settings object - the new settings to use as defaults (anonymous object) + @return the manager object */ + setDefaults: function(settings) { + extendRemove(this._defaults, settings || {}); + return this; + }, + + /* Attach the date picker to a jQuery selection. + @param target element - the target input field or division or span + @param settings object - the new settings to use for this date picker instance (anonymous) */ + _attachDatepicker: function(target, settings) { + // check for settings on the control itself - in namespace 'date:' + var inlineSettings = null; + for (attrName in this._defaults) { + var attrValue = target.getAttribute('date:' + attrName); + if (attrValue) { + inlineSettings = inlineSettings || {}; + try { + inlineSettings[attrName] = eval(attrValue); + } catch (err) { + inlineSettings[attrName] = attrValue; + } + } + } + var nodeName = target.nodeName.toLowerCase(); + var instSettings = (inlineSettings ? + $.extend(settings || {}, inlineSettings || {}) : settings); + if (nodeName == 'input') { + var inst = (inst && !inlineSettings ? inst : + new DateTimepickerInstance(instSettings, false)); + this._connectDatepicker(target, inst); + } else if (nodeName == 'div' || nodeName == 'span') { + var inst = new DateTimepickerInstance(instSettings, true); + this._inlineDatepicker(target, inst); + } + }, + + /* Detach a datetimepicker from its control. + @param target element - the target input field or division or span */ + _destroyDatepicker: function(target) { + var nodeName = target.nodeName.toLowerCase(); + var calId = target._calId; + target._calId = null; + var $target = $(target); + if (nodeName == 'input') { + $target.siblings('.datetimepicker_append').replaceWith('').end() + .siblings('.datetimepicker_trigger').replaceWith('').end() + .removeClass(this.markerClassName) + .unbind('focus', this._showDatepicker) + .unbind('keydown', this._doKeyDown) + .unbind('keypress', this._doKeyPress); + var wrapper = $target.parents('.datetimepicker_wrap'); + if (wrapper) + wrapper.replaceWith(wrapper.html()); + } else if (nodeName == 'div' || nodeName == 'span') + $target.removeClass(this.markerClassName).empty(); + if ($('input[_calId=' + calId + ']').length == 0) + // clean up if last for this ID + this._inst[calId] = null; + }, + + /* Enable the date picker to a jQuery selection. + @param target element - the target input field or division or span */ + _enableDatepicker: function(target) { + target.disabled = false; + $(target).siblings('button.datetimepicker_trigger').each(function() { this.disabled = false; }).end() + .siblings('img.datetimepicker_trigger').css({opacity: '1.0', cursor: ''}); + this._disabledInputs = $.map(this._disabledInputs, + function(value) { return (value == target ? null : value); }); // delete entry + }, + + /* Disable the date picker to a jQuery selection. + @param target element - the target input field or division or span */ + _disableDatepicker: function(target) { + target.disabled = true; + $(target).siblings('button.datetimepicker_trigger').each(function() { this.disabled = true; }).end() + .siblings('img.datetimepicker_trigger').css({opacity: '0.5', cursor: 'default'}); + this._disabledInputs = $.map($.datetimepicker._disabledInputs, + function(value) { return (value == target ? null : value); }); // delete entry + this._disabledInputs[$.datetimepicker._disabledInputs.length] = target; + }, + + /* Is the first field in a jQuery collection disabled as a datetimepicker? + @param target element - the target input field or division or span + @return boolean - true if disabled, false if enabled */ + _isDisabledDatepicker: function(target) { + if (!target) + return false; + for (var i = 0; i < this._disabledInputs.length; i++) { + if (this._disabledInputs[i] == target) + return true; + } + return false; + }, + + /* Update 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 string - the name of the setting to change or + object - the new settings to update + @param value any - the new value for the setting (omit if above is an object) */ + _changeDatepicker: function(target, name, value) { + var settings = name || {}; + if (typeof name == 'string') { + settings = {}; + settings[name] = value; + } + if (inst = this._getInst(target._calId)) { + extendRemove(inst._settings, settings); + this._updateDatepicker(inst); + } + }, + + /* Set the dates for a jQuery selection. + @param target element - the target input field or division or span + @param date Date - the new date + @param endDate Date - the new end date for a range (optional) */ + _setDateDatepicker: function(target, date, endDate) { + if (inst = this._getInst(target._calId)) { + inst._setDate(date, endDate); + this._updateDatepicker(inst); + } + }, + + /* Get the date(s) for the first entry in a jQuery selection. + @param target element - the target input field or division or span + @return Date - the current date or + Date[2] - the current dates for a range */ + _getDateDatepicker: function(target) { + var inst = this._getInst(target._calId); + return (inst ? inst._getDate() : null); + }, + + /* Handle keystrokes. */ + _doKeyDown: function(e) { + var inst = $.datetimepicker._getInst(this._calId); + if ($.datetimepicker._datetimepickerShowing) + switch (e.keyCode) { + case 9: $.datetimepicker._hideDatepicker(null, ''); + break; // hide on tab out + case 13: $.datetimepicker._selectDay(inst, inst._selectedMonth, inst._selectedYear, + $('td.datetimepicker_daysCellOver', inst._datetimepickerDiv)[0]); + return false; // don't submit the form + break; // select the value on enter + case 27: $.datetimepicker._hideDatepicker(null, inst._get('speed')); + break; // hide on escape + case 33: $.datetimepicker._adjustDate(inst, + (e.ctrlKey ? -1 : -inst._get('stepMonths')), (e.ctrlKey ? 'Y' : 'M')); + break; // previous month/year on page up/+ ctrl + case 34: $.datetimepicker._adjustDate(inst, + (e.ctrlKey ? +1 : +inst._get('stepMonths')), (e.ctrlKey ? 'Y' : 'M')); + break; // next month/year on page down/+ ctrl + case 35: if (e.ctrlKey) $.datetimepicker._clearDate(inst); + break; // clear on ctrl+end + case 36: if (e.ctrlKey) $.datetimepicker._gotoToday(inst); + break; // current on ctrl+home + case 37: if (e.ctrlKey) $.datetimepicker._adjustDate(inst, -1, 'D'); + break; // -1 day on ctrl+left + case 38: if (e.ctrlKey) $.datetimepicker._adjustDate(inst, -7, 'D'); + break; // -1 week on ctrl+up + case 39: if (e.ctrlKey) $.datetimepicker._adjustDate(inst, +1, 'D'); + break; // +1 day on ctrl+right + case 40: if (e.ctrlKey) $.datetimepicker._adjustDate(inst, +7, 'D'); + break; // +1 week on ctrl+down + } + else if (e.keyCode == 36 && e.ctrlKey) // display the date picker on ctrl+home + $.datetimepicker._showDatepicker(this); + }, + + /* Filter entered characters - based on date format. */ + _doKeyPress: function(e) { + var inst = $.datetimepicker._getInst(this._calId); + var chars = $.datetimepicker._possibleChars(inst._get('dateFormat')+' '+inst._get('timeFormat')); + var chr = String.fromCharCode(e.charCode == undefined ? e.keyCode : e.charCode); + return e.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1); + }, + + /* Attach the date picker to an input field. */ + _connectDatepicker: function(target, inst) { + var input = $(target); + if (input.is('.' + this.markerClassName)) + return; + var appendText = inst._get('appendText'); + var isRTL = inst._get('isRTL'); + if (appendText) { + if (isRTL) + input.before('' + appendText); + else + input.after('' + appendText); + } + var showOn = inst._get('showOn'); + if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field + input.focus(this._showDatepicker); + if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked + input.wrap(''); + var buttonText = inst._get('buttonText'); + var buttonImage = inst._get('buttonImage'); + var trigger = $(inst._get('buttonImageOnly') ? + $('').addClass('datetimepicker_trigger').attr({ src: buttonImage, alt: buttonText, title: buttonText }) : + $('