From b2a1d9440a54d0e864160d9010d327f4cf7b41bf Mon Sep 17 00:00:00 2001 From: kumm Date: Sun, 23 Jan 2011 12:35:49 +0100 Subject: [PATCH 01/17] fix default hour,minute,second by changing init order --- jquery-ui-timepicker-addon.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js index 4f32e5b..6ebb5ae 100644 --- a/jquery-ui-timepicker-addon.js +++ b/jquery-ui-timepicker-addon.js @@ -107,14 +107,7 @@ $.extend(Timepicker.prototype, { _newInst: function($input, o) { var tp_inst = new Timepicker(), inlineSettings = {}; - - tp_inst.hour = tp_inst._defaults.hour; - tp_inst.minute = tp_inst._defaults.minute; - tp_inst.second = tp_inst._defaults.second; - tp_inst.ampm = ''; - tp_inst.$input = $input; - for (var attrName in this._defaults) { var attrValue = $input.attr('time:' + attrName); if (attrValue) { @@ -145,6 +138,12 @@ $.extend(Timepicker.prototype, { timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker'); }); + tp_inst.hour = tp_inst._defaults.hour; + tp_inst.minute = tp_inst._defaults.minute; + tp_inst.second = tp_inst._defaults.second; + tp_inst.ampm = ''; + tp_inst.$input = $input; + if (o.altField) tp_inst.$altInput = $(o.altField) .css({ cursor: 'pointer' }) From 03d141abb6a510f2cfd2e52fdbd6437d0091b08c Mon Sep 17 00:00:00 2001 From: Trent Date: Sat, 5 Feb 2011 11:30:23 -0500 Subject: [PATCH 02/17] Updated version to 0.9.4 dev --- jquery-ui-timepicker-addon.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js index 4f32e5b..0b11a97 100644 --- a/jquery-ui-timepicker-addon.js +++ b/jquery-ui-timepicker-addon.js @@ -1,7 +1,7 @@ /* * jQuery timepicker addon * By: Trent Richardson [http://trentrichardson.com] -* Version 0.9.3-dev +* Version 0.9.4-dev * Last Modified: 12/27/2010 * * Copyright 2010 Trent Richardson @@ -19,7 +19,7 @@ (function($) { -$.extend($.ui, { timepicker: { version: "0.9.3" } }); +$.extend($.ui, { timepicker: { version: "0.9.4" } }); /* Time picker manager. Use the singleton instance of this class, $.timepicker, to interact with the time picker. @@ -906,6 +906,6 @@ function extendRemove(target, props) { } $.timepicker = new Timepicker(); // singleton instance -$.timepicker.version = "0.9.3"; +$.timepicker.version = "0.9.4"; })(jQuery); From 1f57183f820cc3c36595afa91af747e87f9fd378 Mon Sep 17 00:00:00 2001 From: kumm Date: Sun, 6 Feb 2011 18:53:31 +0100 Subject: [PATCH 03/17] Refactor onSelect handler. Bind to grid onclick too. --- jquery-ui-timepicker-addon.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js index 6ebb5ae..5c3e9e7 100644 --- a/jquery-ui-timepicker-addon.js +++ b/jquery-ui-timepicker-addon.js @@ -401,6 +401,7 @@ $.extend(Timepicker.prototype, { } tp_inst.hour_slider.slider("option", "value", h); tp_inst._onTimeChange(); + tp_inst._onSelectHandler(); }).css({ cursor: 'pointer', width: (100 / hourGridSize) + '%', @@ -420,6 +421,7 @@ $.extend(Timepicker.prototype, { $(this).click(function() { tp_inst.minute_slider.slider("option", "value", $(this).html()); tp_inst._onTimeChange(); + tp_inst._onSelectHandler(); }).css({ cursor: 'pointer', width: (100 / minuteGridSize) + '%', @@ -438,6 +440,7 @@ $.extend(Timepicker.prototype, { $(this).click(function() { tp_inst.second_slider.slider("option", "value", $(this).html()); tp_inst._onTimeChange(); + tp_inst._onSelectHandler(); }).css({ cursor: 'pointer', width: (100 / secondGridSize) + '%', @@ -460,16 +463,12 @@ $.extend(Timepicker.prototype, { } //Emulate datepicker onSelect behavior. Call on slidestop. - var onSelect = tp_inst._defaults['onSelect']; - if (onSelect) { - var inputEl = tp_inst.$input ? tp_inst.$input[0] : null; - var onSelectHandler = function() { - onSelect.apply(inputEl, [tp_inst.formattedDateTime, tp_inst]); // trigger custom callback*/ - } - this.hour_slider.bind('slidestop',onSelectHandler); - this.minute_slider.bind('slidestop',onSelectHandler); - this.second_slider.bind('slidestop',onSelectHandler); + var onSelectDelegate = function() { + tp_inst._onSelectHandler(); } + this.hour_slider.bind('slidestop',onSelectDelegate); + this.minute_slider.bind('slidestop',onSelectDelegate); + this.second_slider.bind('slidestop',onSelectDelegate); } }, @@ -572,6 +571,18 @@ $.extend(Timepicker.prototype, { this.timeDefined = true; if (hasChanged) this._updateDateTime(); }, + + //######################################################################## + // call custom onSelect. + // bind to sliders slidestop, and grid click. + //######################################################################## + _onSelectHandler: function() { + var onSelect = this._defaults['onSelect']; + var inputEl = this.$input ? this.$input[0] : null; + if (onSelect && inputEl) { + onSelect.apply(inputEl, [this.formattedDateTime, this]); + } + }, //######################################################################## // format the time all pretty... From 9c5de29f1befa4f5f43c79d13dd6151b89e3827f Mon Sep 17 00:00:00 2001 From: Bruno Harbulot Date: Mon, 28 Feb 2011 12:18:46 +0000 Subject: [PATCH 04/17] Added timezone selection. --- jquery-ui-timepicker-addon.js | 60 ++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 11 deletions(-) diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js index 0b11a97..19c1b7b 100644 --- a/jquery-ui-timepicker-addon.js +++ b/jquery-ui-timepicker-addon.js @@ -37,7 +37,8 @@ function Timepicker() { timeText: 'Time', hourText: 'Hour', minuteText: 'Minute', - secondText: 'Second' + secondText: 'Second', + timezoneText: 'Time Zone' }; this._defaults = { // Global defaults for all the datetime picker instances showButtonPanel: true, @@ -45,6 +46,7 @@ function Timepicker() { showHour: true, showMinute: true, showSecond: false, + showTimezone: false, showTime: true, stepHour: 0.05, stepMinute: 0.05, @@ -66,7 +68,11 @@ function Timepicker() { alwaysSetTime: true, separator: ' ', altFieldTimeOnly: true, - showTimepicker: true + showTimepicker: true, + timezoneList: ["-1100", "-1000", "-0900", "-0800", "-0700", "-0600", + "-0500", "-0400", "-0300", "-0200", "-0100", "+0000", + "+0100", "+0200", "+0300", "+0400", "+0500", "+0600", + "+0700", "+0800", "+0900", "+1000", "+1100", "+1200"] }; $.extend(this._defaults, this.regional['']); } @@ -79,9 +85,11 @@ $.extend(Timepicker.prototype, { hour_slider: null, minute_slider: null, second_slider: null, + timezone_select: null, hour: 0, minute: 0, second: 0, + timezone: '+0000', hourMinOriginal: null, minuteMinOriginal: null, secondMinOriginal: null, @@ -92,6 +100,10 @@ $.extend(Timepicker.prototype, { formattedDate: '', formattedTime: '', formattedDateTime: '', + timezoneList: ["-1100", "-1000", "-0900", "-0800", "-0700", "-0600", + "-0500", "-0400", "-0300", "-0200", "-0100", "+0000", + "+0100", "+0200", "+0300", "+0400", "+0500", "+0600", + "+0700", "+0800", "+0900", "+1000", "+1100", "+1200"], /* Override the default settings for all instances of the time picker. @param settings object - the new settings to use as defaults (anonymous object) @@ -112,6 +124,7 @@ $.extend(Timepicker.prototype, { tp_inst.minute = tp_inst._defaults.minute; tp_inst.second = tp_inst._defaults.second; tp_inst.ampm = ''; + tp_inst.timezone = tp_inst._defaults.timezone; tp_inst.$input = $input; @@ -185,6 +198,7 @@ $.extend(Timepicker.prototype, { .replace(/m{1,2}/ig, '(\\d?\\d)') .replace(/s{1,2}/ig, '(\\d?\\d)') .replace(/t{1,2}/ig, '(am|pm|a|p)?') + .replace(/z{1}/ig, '((\\+|-)\\d\\d\\d\\d)?') .replace(/\s/g, '\\s?') + '$', order = this._getFormatPositions(), treg; @@ -197,7 +211,7 @@ $.extend(Timepicker.prototype, { var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat'); regstr = '.{' + dp_dateFormat.length + ',}' + this._defaults.separator + regstr; } - + treg = timeString.match(new RegExp(regstr, 'i')); if (treg) { @@ -216,6 +230,7 @@ $.extend(Timepicker.prototype, { if (order.m !== -1) this.minute = Number(treg[order.m]); if (order.s !== -1) this.second = Number(treg[order.s]); + if (order.z !== -1) this.timezone = treg[order.z]; return true; @@ -227,8 +242,8 @@ $.extend(Timepicker.prototype, { // figure out position of time elements.. cause js cant do named captures //######################################################################## _getFormatPositions: function() { - var finds = this._defaults.timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|t{1,2})/g), - orders = { h: -1, m: -1, s: -1, t: -1 }; + var finds = this._defaults.timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|t{1,2}|z)/g), + orders = { h: -1, m: -1, s: -1, t: -1, z: -1 }; if (finds) for (var i = 0; i < finds.length; i++) @@ -328,6 +343,11 @@ $.extend(Timepicker.prototype, { ''; } else html += '
'; + + html += '
' + o.timezoneText + '
'; + html += '
'; html += ''; $tp = $(html); @@ -379,6 +399,20 @@ $.extend(Timepicker.prototype, { tp_inst._onTimeChange(); } }); + + + this.timezone_select = $tp.find('#ui_tpicker_timezone_'+ dp_id).append('').find("select"); + $.fn.append.apply(this.timezone_select, + $.map(o.timezoneList, function(val, idx) { + return $("