Mailing List Archive

rt branch, 4.0/datetimepicker-ui, updated. rt-4.0.2-119-g65baec6
The branch, 4.0/datetimepicker-ui has been updated
via 65baec61998427d0382999ba7e27747915a5d1da (commit)
from 5ffc08ce7b575a3be82a260f57d7031b0486958f (commit)

Summary of changes:
devel/third-party/README | 2 +-
.../NoAuth/css/base/jquery-ui-timepicker-addon.css | 4 +-
share/html/NoAuth/js/jquery-ui-timepicker-addon.js | 351 +++++++++++---------
3 files changed, 204 insertions(+), 153 deletions(-)

- Log -----------------------------------------------------------------
commit 65baec61998427d0382999ba7e27747915a5d1da
Author: Thomas Sibley <trs@bestpractical.com>
Date: Thu Jun 28 14:23:06 2012 -0700

Upgrade the timepicker to the latest stable version

diff --git a/devel/third-party/README b/devel/third-party/README
index 2391517..7d632e0 100644
--- a/devel/third-party/README
+++ b/devel/third-party/README
@@ -22,6 +22,6 @@ jquery.tablesorter.js
http://tablesorter.com/jquery.tablesorter.js
jQuery tablesorter plugin version 2.05b

-jquery-ui-timepicker-addon.js fae432b1
+jquery-ui-timepicker-addon.js 2050b7b6
https://github.com/trentrichardson/jQuery-Timepicker-Addon
Timepicker integrated with the jQuery UI datepicker
diff --git a/share/html/NoAuth/css/base/jquery-ui-timepicker-addon.css b/share/html/NoAuth/css/base/jquery-ui-timepicker-addon.css
index b4837d6..7eb8715 100644
--- a/share/html/NoAuth/css/base/jquery-ui-timepicker-addon.css
+++ b/share/html/NoAuth/css/base/jquery-ui-timepicker-addon.css
@@ -1,7 +1,7 @@
.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
.ui-timepicker-div dl { text-align: left; }
-.ui-timepicker-div dl dt { height: 25px; }
-.ui-timepicker-div dl dd { margin: -25px 10px 10px 65px; }
+.ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
+.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
.ui-timepicker-div td { font-size: 90%; }
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
.ui-datepicker-buttonpane button.ui-datepicker-current { opacity: 1.0; }
diff --git a/share/html/NoAuth/js/jquery-ui-timepicker-addon.js b/share/html/NoAuth/js/jquery-ui-timepicker-addon.js
index 72abe04..0a4ff02 100644
--- a/share/html/NoAuth/js/jquery-ui-timepicker-addon.js
+++ b/share/html/NoAuth/js/jquery-ui-timepicker-addon.js
@@ -1,26 +1,32 @@
/*
* jQuery timepicker addon
* By: Trent Richardson [http://trentrichardson.com]
-* Version 0.9.7
-* Last Modified: 10/02/2011
-*
-* Copyright 2011 Trent Richardson
+* Version 1.0.0
+* Last Modified: 02/05/2012
+*
+* Copyright 2012 Trent Richardson
* Dual licensed under the MIT and GPL licenses.
* http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
* http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
-*
+*
* HERES THE CSS:
* .ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
* .ui-timepicker-div dl { text-align: left; }
-* .ui-timepicker-div dl dt { height: 25px; }
-* .ui-timepicker-div dl dd { margin: -25px 10px 10px 65px; }
+* .ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
+* .ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
* .ui-timepicker-div td { font-size: 90%; }
* .ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
*/

(function($) {

-$.extend($.ui, { timepicker: { version: "0.9.7" } });
+// Prevent "Uncaught RangeError: Maximum call stack size exceeded"
+$.ui.timepicker = $.ui.timepicker || {};
+if ($.ui.timepicker.version) {
+ return;
+}
+
+$.extend($.ui, { timepicker: { version: "1.0.0" } });

/* Time picker manager.
Use the singleton instance of this class, $.timepicker, to interact with the time picker.
@@ -54,10 +60,10 @@ function Timepicker() {
showMillisec: false,
showTimezone: false,
showTime: true,
- stepHour: 0.05,
- stepMinute: 0.05,
- stepSecond: 0.05,
- stepMillisec: 0.5,
+ stepHour: 1,
+ stepMinute: 1,
+ stepSecond: 1,
+ stepMillisec: 1,
hour: 0,
minute: 0,
second: 0,
@@ -83,10 +89,12 @@ function Timepicker() {
altFieldTimeOnly: true,
showTimepicker: true,
timezoneIso8609: false,
- timezoneList: null
+ timezoneList: null,
+ addSliderAccess: false,
+ sliderAccessArgs: null
};
$.extend(this._defaults, this.regional['']);
-}
+};

$.extend(Timepicker.prototype, {
$input: null,
@@ -131,7 +139,7 @@ $.extend(Timepicker.prototype, {
_newInst: function($input, o) {
var tp_inst = new Timepicker(),
inlineSettings = {};
-
+
for (var attrName in this._defaults) {
var attrValue = $input.attr('time:' + attrName);
if (attrValue) {
@@ -145,7 +153,7 @@ $.extend(Timepicker.prototype, {
tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, o, {
beforeShow: function(input, dp_inst) {
if ($.isFunction(o.beforeShow))
- o.beforeShow(input, dp_inst, tp_inst);
+ return o.beforeShow(input, dp_inst, tp_inst);
},
onChangeMonthYear: function(year, month, dp_inst) {
// Update the time as well : this prevents the time from disappearing from the $input field.
@@ -161,8 +169,8 @@ $.extend(Timepicker.prototype, {
},
timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
});
- tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) { return val.toUpperCase() });
- tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) { return val.toUpperCase() });
+ tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) { return val.toUpperCase(); });
+ tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) { return val.toUpperCase(); });

if (tp_inst._defaults.timezoneList === null) {
var timezoneList = [];
@@ -186,7 +194,7 @@ $.extend(Timepicker.prototype, {
tp_inst.$altInput = $(o.altField)
.css({ cursor: 'pointer' })
.focus(function(){ $input.trigger("focus"); });
-
+
if(tp_inst._defaults.minDate==0 || tp_inst._defaults.minDateTime==0)
{
tp_inst._defaults.minDate=new Date();
@@ -195,7 +203,7 @@ $.extend(Timepicker.prototype, {
{
tp_inst._defaults.maxDate=new Date();
}
-
+
// datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime..
if(tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date)
tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime());
@@ -213,7 +221,7 @@ $.extend(Timepicker.prototype, {
//########################################################################
_addTimePicker: function(dp_inst) {
var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ?
- this.$input.val() + ' ' + this.$altInput.val() :
+ this.$input.val() + ' ' + this.$altInput.val() :
this.$input.val();

this.timeDefined = this._parseTime(currDT);
@@ -245,9 +253,9 @@ $.extend(Timepicker.prototype, {
var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
// escape special regex characters in the seperator
var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g");
- regstr = '.{' + dp_dateFormat.length + ',}' + this._defaults.separator.replace(specials, "\\$&") + regstr;
+ regstr = '^.{' + dp_dateFormat.length + ',}?' + this._defaults.separator.replace(specials, "\\$&") + regstr;
}
-
+
treg = timeString.match(new RegExp(regstr, 'i'));

if (treg) {
@@ -295,7 +303,7 @@ $.extend(Timepicker.prototype, {
}
this.timezone = tz;
}
-
+
return true;

}
@@ -306,13 +314,13 @@ $.extend(Timepicker.prototype, {
// pattern for standard and localized AM/PM markers
//########################################################################
_getPatternAmpm: function() {
- var markers = [];
+ var markers = [],
o = this._defaults;
if (o.amNames)
$.merge(markers, o.amNames);
if (o.pmNames)
$.merge(markers, o.pmNames);
- markers = $.map(markers, function(val) { return val.replace(/[.*+?|()\[\]{}\\]/g, '\\$&') });
+ markers = $.map(markers, function(val) { return val.replace(/[.*+?|()\[\]{}\\]/g, '\\$&'); });
return '(' + markers.join('|') + ')?';
},

@@ -341,10 +349,10 @@ $.extend(Timepicker.prototype, {
// Added by Peter Medeiros:
// - Figure out what the hour/minute/second max should be based on the step values.
// - Example: if stepMinute is 15, then minMax is 45.
- hourMax = (o.hourMax - ((o.hourMax - o.hourMin) % o.stepHour)).toFixed(0),
- minMax = (o.minuteMax - ((o.minuteMax - o.minuteMin) % o.stepMinute)).toFixed(0),
- secMax = (o.secondMax - ((o.secondMax - o.secondMin) % o.stepSecond)).toFixed(0),
- millisecMax = (o.millisecMax - ((o.millisecMax - o.millisecMin) % o.stepMillisec)).toFixed(0),
+ hourMax = parseInt((o.hourMax - ((o.hourMax - o.hourMin) % o.stepHour)) ,10),
+ minMax = parseInt((o.minuteMax - ((o.minuteMax - o.minuteMin) % o.stepMinute)) ,10),
+ secMax = parseInt((o.secondMax - ((o.secondMax - o.secondMin) % o.stepSecond)) ,10),
+ millisecMax = parseInt((o.millisecMax - ((o.millisecMax - o.millisecMin) % o.stepMillisec)) ,10),
dp_id = this.inst.id.toString().replace(/([^A-Za-z0-9_])/g, '');

// Prevent displaying twice
@@ -362,13 +370,13 @@ $.extend(Timepicker.prototype, {
minuteGridSize = 0,
secondGridSize = 0,
millisecGridSize = 0,
- size;
+ size = null;

// Hours
+ html += '<dd class="ui_tpicker_hour"><div id="ui_tpicker_hour_' + dp_id + '"' +
+ ((o.showHour) ? '' : noDisplay) + '></div>';
if (o.showHour && o.hourGrid > 0) {
- html += '<dd class="ui_tpicker_hour">' +
- '<div id="ui_tpicker_hour_' + dp_id + '"' + ((o.showHour) ? '' : noDisplay) + '></div>' +
- '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
+ html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';

for (var h = o.hourMin; h <= hourMax; h += parseInt(o.hourGrid,10)) {
hourGridSize++;
@@ -382,70 +390,63 @@ $.extend(Timepicker.prototype, {
html += '<td>' + tmph + '</td>';
}

- html += '</tr></table></div>' +
- '</dd>';
- } else html += '<dd class="ui_tpicker_hour" id="ui_tpicker_hour_' + dp_id + '"' +
- ((o.showHour) ? '' : noDisplay) + '></dd>';
+ html += '</tr></table></div>';
+ }
+ html += '</dd>';

+ // Minutes
html += '<dt class="ui_tpicker_minute_label" id="ui_tpicker_minute_label_' + dp_id + '"' +
- ((o.showMinute) ? '' : noDisplay) + '>' + o.minuteText + '</dt>';
+ ((o.showMinute) ? '' : noDisplay) + '>' + o.minuteText + '</dt>'+
+ '<dd class="ui_tpicker_minute"><div id="ui_tpicker_minute_' + dp_id + '"' +
+ ((o.showMinute) ? '' : noDisplay) + '></div>';

- // Minutes
if (o.showMinute && o.minuteGrid > 0) {
- html += '<dd class="ui_tpicker_minute ui_tpicker_minute_' + o.minuteGrid + '">' +
- '<div id="ui_tpicker_minute_' + dp_id + '"' +
- ((o.showMinute) ? '' : noDisplay) + '></div>' +
- '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
+ html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';

for (var m = o.minuteMin; m <= minMax; m += parseInt(o.minuteGrid,10)) {
minuteGridSize++;
html += '<td>' + ((m < 10) ? '0' : '') + m + '</td>';
}

- html += '</tr></table></div>' +
- '</dd>';
- } else html += '<dd class="ui_tpicker_minute" id="ui_tpicker_minute_' + dp_id + '"' +
- ((o.showMinute) ? '' : noDisplay) + '></dd>';
+ html += '</tr></table></div>';
+ }
+ html += '</dd>';

// Seconds
html += '<dt class="ui_tpicker_second_label" id="ui_tpicker_second_label_' + dp_id + '"' +
- ((o.showSecond) ? '' : noDisplay) + '>' + o.secondText + '</dt>';
+ ((o.showSecond) ? '' : noDisplay) + '>' + o.secondText + '</dt>'+
+ '<dd class="ui_tpicker_second"><div id="ui_tpicker_second_' + dp_id + '"'+
+ ((o.showSecond) ? '' : noDisplay) + '></div>';

if (o.showSecond && o.secondGrid > 0) {
- html += '<dd class="ui_tpicker_second ui_tpicker_second_' + o.secondGrid + '">' +
- '<div id="ui_tpicker_second_' + dp_id + '"' +
- ((o.showSecond) ? '' : noDisplay) + '></div>' +
- '<div style="padding-left: 1px"><table><tr>';
+ html += '<div style="padding-left: 1px"><table><tr>';

for (var s = o.secondMin; s <= secMax; s += parseInt(o.secondGrid,10)) {
secondGridSize++;
html += '<td>' + ((s < 10) ? '0' : '') + s + '</td>';
}

- html += '</tr></table></div>' +
- '</dd>';
- } else html += '<dd class="ui_tpicker_second" id="ui_tpicker_second_' + dp_id + '"' +
- ((o.showSecond) ? '' : noDisplay) + '></dd>';
+ html += '</tr></table></div>';
+ }
+ html += '</dd>';

// Milliseconds
html += '<dt class="ui_tpicker_millisec_label" id="ui_tpicker_millisec_label_' + dp_id + '"' +
- ((o.showMillisec) ? '' : noDisplay) + '>' + o.millisecText + '</dt>';
+ ((o.showMillisec) ? '' : noDisplay) + '>' + o.millisecText + '</dt>'+
+ '<dd class="ui_tpicker_millisec"><div id="ui_tpicker_millisec_' + dp_id + '"'+
+ ((o.showMillisec) ? '' : noDisplay) + '></div>';

if (o.showMillisec && o.millisecGrid > 0) {
- html += '<dd class="ui_tpicker_millisec ui_tpicker_millisec_' + o.millisecGrid + '">' +
- '<div id="ui_tpicker_millisec_' + dp_id + '"' +
- ((o.showMillisec) ? '' : noDisplay) + '></div>' +
- '<div style="padding-left: 1px"><table><tr>';
+ html += '<div style="padding-left: 1px"><table><tr>';

for (var l = o.millisecMin; l <= millisecMax; l += parseInt(o.millisecGrid,10)) {
millisecGridSize++;
- html += '<td>' + ((l < 10) ? '0' : '') + s + '</td>';
+ html += '<td>' + ((l < 10) ? '0' : '') + l + '</td>';
}

- html += '</tr></table></div>' +
- '</dd>';
- } else html += '<dd class="ui_tpicker_millisec" id="ui_tpicker_millisec_' + dp_id + '"' +
- ((o.showMillisec) ? '' : noDisplay) + '></dd>';
+ html += '</tr></table></div>';
+ }
+ html += '</dd>';

// Timezone
html += '<dt class="ui_tpicker_timezone_label" id="ui_tpicker_timezone_label_' + dp_id + '"' +
@@ -477,6 +478,7 @@ $.extend(Timepicker.prototype, {
}
});

+
// Updated by Peter Medeiros:
// - Pass in Event and UI instance into slide function
this.minute_slider = $tp.find('#ui_tpicker_minute_'+ dp_id).slider({
@@ -486,7 +488,6 @@ $.extend(Timepicker.prototype, {
max: minMax,
step: o.stepMinute,
slide: function(event, ui) {
- // update the global minute slider instance value with the current slider value
tp_inst.minute_slider.slider( "option", "value", ui.value);
tp_inst._onTimeChange();
}
@@ -639,6 +640,32 @@ $.extend(Timepicker.prototype, {
this.minute_slider.bind('slidestop',onSelectDelegate);
this.second_slider.bind('slidestop',onSelectDelegate);
this.millisec_slider.bind('slidestop',onSelectDelegate);
+
+ // slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/
+ if (this._defaults.addSliderAccess){
+ var sliderAccessArgs = this._defaults.sliderAccessArgs;
+ setTimeout(function(){ // fix for inline mode
+ if($tp.find('.ui-slider-access').length == 0){
+ $tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
+
+ // fix any grids since sliders are shorter
+ var sliderAccessWidth = $tp.find('.ui-slider-access:eq(0)').outerWidth(true);
+ if(sliderAccessWidth){
+ $tp.find('table:visible').each(function(){
+ var $g = $(this),
+ oldWidth = $g.outerWidth(),
+ oldMarginLeft = $g.css('marginLeft').toString().replace('%',''),
+ newWidth = oldWidth - sliderAccessWidth,
+ newMarginLeft = ((oldMarginLeft * newWidth)/oldWidth) + '%';
+
+ $g.css({ width: newWidth, marginLeft: newMarginLeft });
+ });
+ }
+ }
+ },0);
+ }
+ // end slideAccess integration
+
}
},

@@ -732,10 +759,10 @@ $.extend(Timepicker.prototype, {
}

if(adjustSliders !== undefined && adjustSliders === true){
- var hourMax = (this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)).toFixed(0),
- minMax = (this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)).toFixed(0),
- secMax = (this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)).toFixed(0),
- millisecMax = (this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)).toFixed(0);
+ var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)) ,10),
+ minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)) ,10),
+ secMax = parseInt((this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)) ,10),
+ millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)) ,10);

if(this.hour_slider)
this.hour_slider.slider("option", { min: this._defaults.hourMin, max: hourMax }).slider('value', this.hour);
@@ -749,7 +776,7 @@ $.extend(Timepicker.prototype, {

},

-
+
//########################################################################
// when a slider moves, set the internal time...
// on time change is also called when the time is updated in the text field
@@ -782,7 +809,7 @@ $.extend(Timepicker.prototype, {
|| (this.ampm.length > 0
&& (hour < 12) != ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1))
|| timezone != this.timezone);
-
+
if (hasChanged) {

if (hour !== false)this.hour = hour;
@@ -790,21 +817,22 @@ $.extend(Timepicker.prototype, {
if (second !== false) this.second = second;
if (millisec !== false) this.millisec = millisec;
if (timezone !== false) this.timezone = timezone;
-
+
if (!this.inst) this.inst = $.datepicker._getInst(this.$input[0]);
-
+
this._limitMinMaxDateTime(this.inst, true);
}
if (o.ampm) this.ampm = ampm;
-
- this._formatTime();
+
+ //this._formatTime();
+ this.formattedTime = $.datepicker.formatTime(this._defaults.timeFormat, this, this._defaults);
if (this.$timeObj) this.$timeObj.text(this.formattedTime + o.timeSuffix);
this.timeDefined = true;
if (hasChanged) this._updateDateTime();
},
-
+
//########################################################################
- // call custom onSelect.
+ // call custom onSelect.
// bind to sliders slidestop, and grid click.
//########################################################################
_onSelectHandler: function() {
@@ -816,40 +844,13 @@ $.extend(Timepicker.prototype, {
},

//########################################################################
- // format the time all pretty...
+ // left for any backwards compatibility
//########################################################################
- _formatTime: function(time, format, ampm) {
- if (ampm == undefined) ampm = this._defaults.ampm;
+ _formatTime: function(time, format) {
time = time || { hour: this.hour, minute: this.minute, second: this.second, millisec: this.millisec, ampm: this.ampm, timezone: this.timezone };
var tmptime = (format || this._defaults.timeFormat).toString();

- var hour = parseInt(time.hour, 10);
- if (ampm) {
- if (!$.inArray(time.ampm.toUpperCase(), this.amNames) !== -1)
- hour = hour % 12;
- if (hour === 0)
- hour = 12;
- }
- tmptime = tmptime.replace(/(?:hh?|mm?|ss?|[tT]{1,2}|[lz])/g, function(match) {
- switch (match.toLowerCase()) {
- case 'hh': return ('0' + hour).slice(-2);
- case 'h': return hour;
- case 'mm': return ('0' + time.minute).slice(-2);
- case 'm': return time.minute;
- case 'ss': return ('0' + time.second).slice(-2);
- case 's': return time.second;
- case 'l': return ('00' + time.millisec).slice(-3);
- case 'z': return time.timezone;
- case 't': case 'tt':
- if (ampm) {
- var _ampm = time.ampm;
- if (match.length == 1)
- _ampm = _ampm.charAt(0);
- return match.charAt(0) == 'T' ? _ampm.toUpperCase() : _ampm.toLowerCase();
- }
- return '';
- }
- });
+ tmptime = $.datepicker.formatTime(tmptime, time, this._defaults);

if (arguments.length) return tmptime;
else this.formattedTime = tmptime;
@@ -859,8 +860,8 @@ $.extend(Timepicker.prototype, {
// update our input with the new date time..
//########################################################################
_updateDateTime: function(dp_inst) {
- dp_inst = this.inst || dp_inst,
- dt = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay),
+ dp_inst = this.inst || dp_inst;
+ var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
formatCfg = $.datepicker._getFormatConfig(dp_inst),
timeAvailable = dt !== null && this.timeDefined;
@@ -888,7 +889,7 @@ $.extend(Timepicker.prototype, {
} else {
this.$input.val(formattedDateTime);
}
-
+
this.$input.trigger("change");
}

@@ -914,13 +915,12 @@ $.fn.extend({
//########################################################################
datetimepicker: function(o) {
o = o || {};
- var $input = this,
tmp_args = arguments;

if (typeof(o) == 'string'){
- if(o == 'getDate')
+ if(o == 'getDate')
return $.fn.datepicker.apply($(this[0]), tmp_args);
- else
+ else
return this.each(function() {
var $t = $(this);
$t.datepicker.apply($t, tmp_args);
@@ -935,6 +935,54 @@ $.fn.extend({
});

//########################################################################
+// format the time all pretty...
+// format = string format of the time
+// time = a {}, not a Date() for timezones
+// options = essentially the regional[].. amNames, pmNames, ampm
+//########################################################################
+$.datepicker.formatTime = function(format, time, options) {
+ options = options || {};
+ options = $.extend($.timepicker._defaults, options);
+ time = $.extend({hour:0, minute:0, second:0, millisec:0, timezone:'+0000'}, time);
+
+ var tmptime = format;
+ var ampmName = options['amNames'][0];
+
+ var hour = parseInt(time.hour, 10);
+ if (options.ampm) {
+ if (hour > 11){
+ ampmName = options['pmNames'][0];
+ if(hour > 12)
+ hour = hour % 12;
+ }
+ if (hour === 0)
+ hour = 12;
+ }
+ tmptime = tmptime.replace(/(?:hh?|mm?|ss?|[tT]{1,2}|[lz])/g, function(match) {
+ switch (match.toLowerCase()) {
+ case 'hh': return ('0' + hour).slice(-2);
+ case 'h': return hour;
+ case 'mm': return ('0' + time.minute).slice(-2);
+ case 'm': return time.minute;
+ case 'ss': return ('0' + time.second).slice(-2);
+ case 's': return time.second;
+ case 'l': return ('00' + time.millisec).slice(-3);
+ case 'z': return time.timezone;
+ case 't': case 'tt':
+ if (options.ampm) {
+ if (match.length == 1)
+ ampmName = ampmName.charAt(0);
+ return match.charAt(0) == 'T' ? ampmName.toUpperCase() : ampmName.toLowerCase();
+ }
+ return '';
+ }
+ });
+
+ tmptime = $.trim(tmptime);
+ return tmptime;
+};
+
+//########################################################################
// the bad hack :/ override datepicker so it doesnt close on select
// inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
//########################################################################
@@ -972,8 +1020,9 @@ $.datepicker._updateDatepicker = function(inst) {
}

if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
+
this._base_updateDatepicker(inst);
-
+
// Reload the time control when changing something in the input text field.
var tp_inst = this._get(inst, 'timepicker');
if(tp_inst) tp_inst._addTimePicker(inst);
@@ -1011,7 +1060,7 @@ $.datepicker._doKeyPress = function(event) {
return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1);
}
}
-
+
return $.datepicker._base_doKeyPress(event);
};

@@ -1051,14 +1100,14 @@ $.datepicker._gotoToday = function(id) {
var tzoffset = now.getTimezoneOffset(); // If +0100, returns -60
var tzsign = tzoffset > 0 ? '-' : '+';
tzoffset = Math.abs(tzoffset);
- var tzmin = tzoffset % 60
+ var tzmin = tzoffset % 60;
tzoffset = tzsign + ('0' + (tzoffset - tzmin) / 60).slice(-2) + ('0' + tzmin).slice(-2);
if (tp_inst._defaults.timezoneIso8609)
tzoffset = tzoffset.substring(0, 3) + ':' + tzoffset.substring(3);
tp_inst.timezone_select.val(tzoffset);
}
this._setTime(inst, now);
- $( '.ui-datepicker-today', $dp).click();
+ $( '.ui-datepicker-today', $dp).click();
};

//#######################################################################################
@@ -1185,10 +1234,15 @@ $.datepicker.parseDate = function(format, value, settings) {
try {
date = this._base_parseDate(format, value, settings);
} catch (err) {
- // Hack! The error message ends with a colon, a space, and
- // the "extra" characters. We rely on that instead of
- // attempting to perfectly reproduce the parsing algorithm.
- date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
+ if (err.indexOf(":") >= 0) {
+ // Hack! The error message ends with a colon, a space, and
+ // the "extra" characters. We rely on that instead of
+ // attempting to perfectly reproduce the parsing algorithm.
+ date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
+ } else {
+ // The underlying error was not related to the time
+ throw err;
+ }
}
return date;
};
@@ -1196,18 +1250,15 @@ $.datepicker.parseDate = function(format, value, settings) {
//#######################################################################################
// override formatDate to set date with time to the input
//#######################################################################################
-$.datepicker._base_formatDate=$.datepicker._formatDate;
+$.datepicker._base_formatDate = $.datepicker._formatDate;
$.datepicker._formatDate = function(inst, day, month, year){
var tp_inst = this._get(inst, 'timepicker');
- if(tp_inst)
- {
- if(day)
- var b = this._base_formatDate(inst, day, month, year);
- tp_inst._updateDateTime();
+ if(tp_inst) {
+ tp_inst._updateDateTime(inst);
return tp_inst.$input.val();
}
return this._base_formatDate(inst);
-}
+};

//#######################################################################################
// override options setter to add time to maxDate(Time) and minDate(Time). MaxDate
@@ -1217,16 +1268,16 @@ $.datepicker._optionDatepicker = function(target, name, value) {
var inst = this._getInst(target),
tp_inst = this._get(inst, 'timepicker');
if (tp_inst) {
- var min,max,onselect;
+ var min = null, max = null, onselect = null;
if (typeof name == 'string') { // if min/max was set with the string
- if (name==='minDate' || name==='minDateTime' )
+ if (name === 'minDate' || name === 'minDateTime' )
min = value;
- else if (name==='maxDate' || name==='maxDateTime')
+ else if (name === 'maxDate' || name === 'maxDateTime')
max = value;
- else if (name==='onSelect')
- onselect=value;
+ else if (name === 'onSelect')
+ onselect = value;
} else if (typeof name == 'object') { //if min/max was set with the JSON
- if(name.minDate)
+ if (name.minDate)
min = name.minDate;
else if (name.minDateTime)
min = name.minDateTime;
@@ -1235,26 +1286,27 @@ $.datepicker._optionDatepicker = function(target, name, value) {
else if (name.maxDateTime)
max = name.maxDateTime;
}
- if(min){ //if min was set
- if(min==0)
- min=new Date();
+ if(min) { //if min was set
+ if (min == 0)
+ min = new Date();
else
- min= new Date(min);
-
+ min = new Date(min);
+
tp_inst._defaults.minDate = min;
tp_inst._defaults.minDateTime = min;
- } else if (max){ //if max was set
+ } else if (max) { //if max was set
if(max==0)
max=new Date();
else
max= new Date(max);
tp_inst._defaults.maxDate = max;
tp_inst._defaults.maxDateTime = max;
- }
- else if (onselect)
- tp_inst._defaults.onSelect=onselect;
+ } else if (onselect)
+ tp_inst._defaults.onSelect = onselect;
}
- this._base_optionDatepicker(target, name, value);
+ if (value === undefined)
+ return this._base_optionDatepicker(target, name);
+ return this._base_optionDatepicker(target, name, value);
};

//#######################################################################################
@@ -1266,10 +1318,9 @@ function extendRemove(target, props) {
if (props[name] === null || props[name] === undefined)
target[name] = props[name];
return target;
-}
+};

$.timepicker = new Timepicker(); // singleton instance
-$.timepicker.version = "0.9.7";
+$.timepicker.version = "1.0.0";

})(jQuery);
-

-----------------------------------------------------------------------
_______________________________________________
Rt-commit mailing list
Rt-commit@lists.bestpractical.com
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-commit