summaryrefslogtreecommitdiffstats
path: root/dist/jquery-ui-timepicker-addon.js
diff options
context:
space:
mode:
authorTrent <trentdrichardson@gmail.com>2016-02-10 14:30:33 -0500
committerTrent <trentdrichardson@gmail.com>2016-02-10 14:30:33 -0500
commit3e276d32703761c99c72ebd5538f65f9b159ceff (patch)
tree89dff1dfbf92130ef5751d783759ee2aa7419138 /dist/jquery-ui-timepicker-addon.js
parent8fe6ab220453fcb9f1f44d6753257336bf7c8015 (diff)
downloadjQuery-Timepicker-Addon-3e276d32703761c99c72ebd5538f65f9b159ceff.zip
jQuery-Timepicker-Addon-3e276d32703761c99c72ebd5538f65f9b159ceff.tar.gz
jQuery-Timepicker-Addon-3e276d32703761c99c72ebd5538f65f9b159ceff.tar.bz2
Pull #861 - Add check for setSelectionRange for older IE
Diffstat (limited to 'dist/jquery-ui-timepicker-addon.js')
-rw-r--r--dist/jquery-ui-timepicker-addon.js149
1 files changed, 85 insertions, 64 deletions
diff --git a/dist/jquery-ui-timepicker-addon.js b/dist/jquery-ui-timepicker-addon.js
index b55897d..d31125b 100644
--- a/dist/jquery-ui-timepicker-addon.js
+++ b/dist/jquery-ui-timepicker-addon.js
@@ -26,7 +26,7 @@
}
});
- /*
+ /*
* Timepicker manager.
* Use the singleton instance of this class, $.timepicker, to interact with the time picker.
* Settings for (groups of) time pickers are maintained in an instance object,
@@ -153,7 +153,7 @@
support: {},
control: null,
- /*
+ /*
* Override the default settings for all instances of the time picker.
* @param {Object} settings object - the new settings to use as defaults (anonymous object)
* @return {Object} the manager object
@@ -226,7 +226,7 @@
// detect which units are supported
tp_inst.support = detectSupport(
- tp_inst._defaults.timeFormat +
+ tp_inst._defaults.timeFormat +
(tp_inst._defaults.pickerTimeFormat ? tp_inst._defaults.pickerTimeFormat : '') +
(tp_inst._defaults.altTimeFormat ? tp_inst._defaults.altTimeFormat : ''));
@@ -425,7 +425,7 @@
}
html += '</dd>';
}
-
+
// Timezone
var showTz = o.showTimezone !== null ? o.showTimezone : this.support.timezone;
html += '<dt class="ui_tpicker_timezone_label' + (showTz ? '' : noDisplay) + '">' + o.timezoneText + '</dt>';
@@ -440,7 +440,7 @@
$tp.prepend('<div class="ui-widget-header ui-helper-clearfix ui-corner-all">' + '<div class="ui-datepicker-title">' + o.timeOnlyTitle + '</div>' + '</div>');
$dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide();
}
-
+
// add sliders, adjust grids, add events
for (i = 0, l = tp_inst.units.length; i < l; i++) {
litem = tp_inst.units[i];
@@ -475,7 +475,7 @@
}
}
}
-
+
tp_inst.control.value(tp_inst, tp_inst[f + '_slider'], litem, n);
tp_inst._onTimeChange();
@@ -515,7 +515,7 @@
tp_inst._afterInject();
});
// End timezone options
-
+
// inject timepicker into datepicker
var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
if ($buttonPanel.length) {
@@ -551,7 +551,7 @@
var sliderAccessArgs = this._defaults.sliderAccessArgs,
rtl = this._defaults.isRTL;
sliderAccessArgs.isRTL = rtl;
-
+
setTimeout(function () { // fix for inline mode
if ($tp.find('.ui-slider-access').length === 0) {
$tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
@@ -703,44 +703,44 @@
}
}
- if (dp_inst.settings.minTime!==null) {
- var tempMinTime=new Date("01/01/1970 " + dp_inst.settings.minTime);
+ if (dp_inst.settings.minTime!==null) {
+ var tempMinTime=new Date("01/01/1970 " + dp_inst.settings.minTime);
if (this.hour<tempMinTime.getHours()) {
this.hour=this._defaults.hourMin=tempMinTime.getHours();
- this.minute=this._defaults.minuteMin=tempMinTime.getMinutes();
+ this.minute=this._defaults.minuteMin=tempMinTime.getMinutes();
} else if (this.hour===tempMinTime.getHours() && this.minute<tempMinTime.getMinutes()) {
this.minute=this._defaults.minuteMin=tempMinTime.getMinutes();
- } else {
+ } else {
if (this._defaults.hourMin<tempMinTime.getHours()) {
this._defaults.hourMin=tempMinTime.getHours();
- this._defaults.minuteMin=tempMinTime.getMinutes();
+ this._defaults.minuteMin=tempMinTime.getMinutes();
} else if (this._defaults.hourMin===tempMinTime.getHours()===this.hour && this._defaults.minuteMin<tempMinTime.getMinutes()) {
- this._defaults.minuteMin=tempMinTime.getMinutes();
+ this._defaults.minuteMin=tempMinTime.getMinutes();
} else {
this._defaults.minuteMin=0;
}
- }
+ }
}
-
- if (dp_inst.settings.maxTime!==null) {
+
+ if (dp_inst.settings.maxTime!==null) {
var tempMaxTime=new Date("01/01/1970 " + dp_inst.settings.maxTime);
if (this.hour>tempMaxTime.getHours()) {
- this.hour=this._defaults.hourMax=tempMaxTime.getHours();
+ this.hour=this._defaults.hourMax=tempMaxTime.getHours();
+ this.minute=this._defaults.minuteMax=tempMaxTime.getMinutes();
+ } else if (this.hour===tempMaxTime.getHours() && this.minute>tempMaxTime.getMinutes()) {
this.minute=this._defaults.minuteMax=tempMaxTime.getMinutes();
- } else if (this.hour===tempMaxTime.getHours() && this.minute>tempMaxTime.getMinutes()) {
- this.minute=this._defaults.minuteMax=tempMaxTime.getMinutes();
} else {
if (this._defaults.hourMax>tempMaxTime.getHours()) {
this._defaults.hourMax=tempMaxTime.getHours();
- this._defaults.minuteMax=tempMaxTime.getMinutes();
+ this._defaults.minuteMax=tempMaxTime.getMinutes();
} else if (this._defaults.hourMax===tempMaxTime.getHours()===this.hour && this._defaults.minuteMax>tempMaxTime.getMinutes()) {
- this._defaults.minuteMax=tempMaxTime.getMinutes();
+ this._defaults.minuteMax=tempMaxTime.getMinutes();
} else {
this._defaults.minuteMax=59;
}
- }
+ }
}
-
+
if (adjustSliders !== undefined && adjustSliders === true) {
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),
@@ -834,11 +834,11 @@
// If the update was done using the sliders, update the input field.
var hasChanged = (
hour !== parseInt(this.hour,10) || // sliders should all be numeric
- minute !== parseInt(this.minute,10) ||
- second !== parseInt(this.second,10) ||
- millisec !== parseInt(this.millisec,10) ||
- microsec !== parseInt(this.microsec,10) ||
- (this.ampm.length > 0 && (hour < 12) !== ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1)) ||
+ minute !== parseInt(this.minute,10) ||
+ second !== parseInt(this.second,10) ||
+ millisec !== parseInt(this.millisec,10) ||
+ microsec !== parseInt(this.microsec,10) ||
+ (this.ampm.length > 0 && (hour < 12) !== ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1)) ||
(this.timezone !== null && timezone !== this.timezone.toString()) // could be numeric or "EST" format, so use toString()
);
@@ -876,15 +876,17 @@
// Updates the time within the timepicker
this.formattedTime = $.datepicker.formatTime(o.timeFormat, this, o);
if (this.$timeObj) {
- var sPos = this.$timeObj[0].selectionStart;
- var ePos = this.$timeObj[0].selectionEnd;
if (pickerTimeFormat === o.timeFormat) {
this.$timeObj.val(this.formattedTime + pickerTimeSuffix);
}
else {
this.$timeObj.val($.datepicker.formatTime(pickerTimeFormat, this, o) + pickerTimeSuffix);
}
- this.$timeObj[0].setSelectionRange(sPos, ePos);
+ if (this.$timeObj[0].setSelectionRange) {
+ var sPos = this.$timeObj[0].selectionStart;
+ var ePos = this.$timeObj[0].selectionEnd;
+ this.$timeObj[0].setSelectionRange(sPos, ePos);
+ }
}
this.timeDefined = true;
@@ -911,8 +913,8 @@
*/
_updateDateTime: function (dp_inst) {
dp_inst = this.inst || dp_inst;
- var dtTmp = (dp_inst.currentYear > 0?
- new Date(dp_inst.currentYear, dp_inst.currentMonth, dp_inst.currentDay) :
+ var dtTmp = (dp_inst.currentYear > 0?
+ new Date(dp_inst.currentYear, dp_inst.currentMonth, dp_inst.currentDay) :
new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
dt = $.datepicker._daylightSavingAdjust(dtTmp),
//dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
@@ -922,7 +924,7 @@
timeAvailable = dt !== null && this.timeDefined;
this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
var formattedDateTime = this.formattedDate;
-
+
// if a slider was changed but datepicker doesn't have a value yet, set it
if (dp_inst.lastVal === "") {
dp_inst.currentYear = dp_inst.selectedYear;
@@ -932,7 +934,7 @@
/*
* remove following lines to force every changes in date picker to change the input value
- * Bug descriptions: when an input field has a default value, and click on the field to pop up the date picker.
+ * Bug descriptions: when an input field has a default value, and click on the field to pop up the date picker.
* If the user manually empty the value in the input field, the date picker will never change selected value.
*/
//if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0)) {
@@ -957,7 +959,7 @@
var altFormattedDateTime = '',
altSeparator = this._defaults.altSeparator !== null ? this._defaults.altSeparator : this._defaults.separator,
altTimeSuffix = this._defaults.altTimeSuffix !== null ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
-
+
if (!this._defaults.timeOnly) {
if (this._defaults.altFormat) {
altFormattedDateTime = $.datepicker.formatDate(this._defaults.altFormat, (dt === null ? new Date() : dt), formatCfg);
@@ -1024,7 +1026,7 @@
stop: function (event, ui) {
tp_inst._onSelectHandler();
}
- });
+ });
},
options: function (tp_inst, obj, unit, opts, val) {
if (tp_inst._defaults.isRTL) {
@@ -1037,7 +1039,7 @@
}
return obj.slider(opts);
}
- var min = opts.min,
+ var min = opts.min,
max = opts.max;
opts.min = opts.max = null;
if (min !== undefined) {
@@ -1100,7 +1102,7 @@
if (val === undefined) {
return $t.data(opts);
}
- o[opts] = val;
+ o[opts] = val;
}
else { o = opts; }
return tp_inst.control.create(tp_inst, obj, $t.data('unit'), $t.val(), o.min>=0 ? o.min : $t.data('min'), o.max || $t.data('max'), o.step || $t.data('step'));
@@ -1335,11 +1337,11 @@
}
catch (err2) {
$.timepicker.log("Unable to parse \ntimeString: " + s + "\ntimeFormat: " + f);
- }
+ }
}
return false;
}; // end looseParse
-
+
if (typeof o.parse === "function") {
return o.parse(timeFormat, timeString, o);
}
@@ -1488,11 +1490,11 @@
.replace(/tT/g, ampm ? 'AaPpMm' : '')
.replace(/T/g, ampm ? 'AP' : '')
.replace(/tt/g, ampm ? 'apm' : '')
- .replace(/t/g, ampm ? 'ap' : '') +
- " " + tp_inst._defaults.separator +
- tp_inst._defaults.timeSuffix +
- (tz ? tp_inst._defaults.timezoneList.join('') : '') +
- (tp_inst._defaults.amNames.join('')) + (tp_inst._defaults.pmNames.join('')) +
+ .replace(/t/g, ampm ? 'ap' : '') +
+ " " + tp_inst._defaults.separator +
+ tp_inst._defaults.timeSuffix +
+ (tz ? tp_inst._defaults.timezoneList.join('') : '') +
+ (tp_inst._defaults.amNames.join('')) + (tp_inst._defaults.pmNames.join('')) +
dateChars,
chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1);
@@ -1515,11 +1517,11 @@
var altFormat = tp_inst._defaults.altFormat || tp_inst._defaults.dateFormat,
date = this._getDate(inst),
formatCfg = $.datepicker._getFormatConfig(inst),
- altFormattedDateTime = '',
- altSeparator = tp_inst._defaults.altSeparator ? tp_inst._defaults.altSeparator : tp_inst._defaults.separator,
+ altFormattedDateTime = '',
+ altSeparator = tp_inst._defaults.altSeparator ? tp_inst._defaults.altSeparator : tp_inst._defaults.separator,
altTimeSuffix = tp_inst._defaults.altTimeSuffix ? tp_inst._defaults.altTimeSuffix : tp_inst._defaults.timeSuffix,
altTimeFormat = tp_inst._defaults.altTimeFormat !== null ? tp_inst._defaults.altTimeFormat : tp_inst._defaults.timeFormat;
-
+
altFormattedDateTime += $.datepicker.formatTime(altTimeFormat, tp_inst, tp_inst._defaults) + altTimeSuffix;
if (!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly && date !== null) {
if (tp_inst._defaults.altFormat) {
@@ -1533,7 +1535,7 @@
}
}
else {
- $.datepicker._base_updateAlternate(inst);
+ $.datepicker._base_updateAlternate(inst);
}
};
@@ -1623,7 +1625,7 @@
tp_inst.millisec = date ? date.getMilliseconds() : defaults.millisec;
tp_inst.microsec = date ? date.getMicroseconds() : defaults.microsec;
- //check if within min/max times..
+ //check if within min/max times..
tp_inst._limitMinMaxDateTime(inst, true);
tp_inst._onTimeChange();
@@ -1691,9 +1693,9 @@
} else {
tp_date = date;
}
-
- // This is important if you are using the timezone option, javascript's Date
- // object will only return the timezone offset for the current locale, so we
+
+ // This is important if you are using the timezone option, javascript's Date
+ // object will only return the timezone offset for the current locale, so we
// adjust it accordingly. If not using timezone option this won't matter..
// If a timezone is different in tp, keep the timezone as is
if (tp_inst && tp_date) {
@@ -1729,13 +1731,32 @@
}
var date = this._getDate(inst);
- var currDT = $.trim((tp_inst.$altInput && tp_inst._defaults.altFieldTimeOnly) ? tp_inst.$input.val() + ' ' + tp_inst.$altInput.val() : tp_inst.$input.val());
+
+ var currDT = null;
+
+ if (tp_inst.$altInput && tp_inst._defaults.altFieldTimeOnly) {
+ currDT = tp_inst.$input.val() + ' ' + tp_inst.$altInput.val();
+ }
+ else if (tp_inst.$input.get(0).tagName !== 'INPUT' && tp_inst.$altInput) {
+ /**
+ * in case the datetimepicker has been applied to a non-input tag for inline UI,
+ * and the user has not configured the plugin to display only time in altInput,
+ * pick current date time from the altInput (and hope for the best, for now, until "ER1" is applied)
+ *
+ * @todo ER1. Since altInput can have a totally difference format, convert it to standard format by reading input format from "altFormat" and "altTimeFormat" option values
+ */
+ currDT = tp_inst.$altInput.val();
+ }
+ else {
+ currDT = tp_inst.$input.val();
+ }
+
if (date && tp_inst._parseTime(currDT, !inst.settings.timeOnly)) {
date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
date.setMicroseconds(tp_inst.microsec);
- // This is important if you are using the timezone option, javascript's Date
- // object will only return the timezone offset for the current locale, so we
+ // This is important if you are using the timezone option, javascript's Date
+ // object will only return the timezone offset for the current locale, so we
// adjust it accordingly. If not using timezone option this won't matter..
if (tp_inst.timezone != null) {
// look out for DST if tz wasn't specified
@@ -1866,8 +1887,8 @@
tp_inst._defaults.onSelect = onselect;
}
- // Datepicker will override our date when we call _base_optionDatepicker when
- // calling minDate/maxDate, so we will first grab the value, call
+ // Datepicker will override our date when we call _base_optionDatepicker when
+ // calling minDate/maxDate, so we will first grab the value, call
// _base_optionDatepicker, then set our value back.
if(min || max){
$target = $(target);
@@ -1882,7 +1903,7 @@
}
return this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
};
-
+
/*
* jQuery isEmptyObject does not check hasOwnProperty - if someone has added to the object prototype,
* it will return false for all objects
@@ -2040,7 +2061,7 @@
hours = (off - minutes) / 60,
iso = iso8601 ? ':' : '',
tz = (off >= 0 ? '+' : '-') + ('0' + Math.abs(hours)).slice(-2) + iso + ('0' + Math.abs(minutes)).slice(-2);
-
+
if (tz === '+00:00') {
return 'Z';
}
@@ -2184,7 +2205,7 @@
date.setMilliseconds(date.getMilliseconds() - options.minInterval);
}
}
-
+
if (date.getTime) {
other[method].call(other, 'option', option, date);
}
@@ -2210,7 +2231,7 @@
}, options, options.end));
checkDates(startTime, endTime);
-
+
selected(startTime, endTime, 'minDate');
selected(endTime, startTime, 'maxDate');