Update timepicker library to 1.6.1

This commit is contained in:
Nathan Gray 2016-04-13 18:44:45 +00:00
parent a423e82de2
commit 0c438366d7
7 changed files with 2311 additions and 2155 deletions

View File

@ -0,0 +1,30 @@
.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
.ui-timepicker-div dl { text-align: left; }
.ui-timepicker-div dl dt { float: left; clear:left; padding: 0 0 0 5px; }
.ui-timepicker-div dl dd { margin: 0 10px 10px 40%; }
.ui-timepicker-div td { font-size: 90%; }
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
.ui-timepicker-div .ui_tpicker_unit_hide{ display: none; }
.ui-timepicker-div .ui_tpicker_time .ui_tpicker_time_input { background: none; color: inherit; border: none; outline: none; border-bottom: solid 1px #555; width: 95%; }
.ui-timepicker-div .ui_tpicker_time .ui_tpicker_time_input:focus { border-bottom-color: #aaa; }
.ui-timepicker-rtl{ direction: rtl; }
.ui-timepicker-rtl dl { text-align: right; padding: 0 5px 0 0; }
.ui-timepicker-rtl dl dt{ float: right; clear: right; }
.ui-timepicker-rtl dl dd { margin: 0 40% 10px 10px; }
/* Shortened version style */
.ui-timepicker-div.ui-timepicker-oneLine { padding-right: 2px; }
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_time,
.ui-timepicker-div.ui-timepicker-oneLine dt { display: none; }
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_time_label { display: block; padding-top: 2px; }
.ui-timepicker-div.ui-timepicker-oneLine dl { text-align: right; }
.ui-timepicker-div.ui-timepicker-oneLine dl dd,
.ui-timepicker-div.ui-timepicker-oneLine dl dd > div { display:inline-block; margin:0; }
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_minute:before,
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_second:before { content:':'; display:inline-block; }
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_millisec:before,
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_microsec:before { content:'.'; display:inline-block; }
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_unit_hide,
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_unit_hide:before{ display: none; }

View File

@ -1,13 +1,13 @@
/* /*! jQuery Timepicker Addon - v1.6.1 - 2015-11-14
* jQuery Timepicker Addon * http://trentrichardson.com/examples/timepicker
* By: Trent Richardson [http://trentrichardson.com] * Copyright (c) 2015 Trent Richardson; Licensed MIT */
* (function (factory) {
* Copyright 2013 Trent Richardson if (typeof define === 'function' && define.amd) {
* You may use this project under MIT license. define(['jquery', 'jquery-ui'], factory);
* http://trentrichardson.com/Impromptu/MIT-LICENSE.txt } else {
*/ factory(jQuery);
}
(function ($) { }(function ($) {
/* /*
* Lets not redefine timepicker, Prevent "Uncaught RangeError: Maximum call stack size exceeded" * Lets not redefine timepicker, Prevent "Uncaught RangeError: Maximum call stack size exceeded"
@ -22,7 +22,7 @@
*/ */
$.extend($.ui, { $.extend($.ui, {
timepicker: { timepicker: {
version: "@@version" version: "1.6.1"
} }
}); });
@ -54,6 +54,7 @@
this._defaults = { // Global defaults for all the datetime picker instances this._defaults = { // Global defaults for all the datetime picker instances
showButtonPanel: true, showButtonPanel: true,
timeOnly: false, timeOnly: false,
timeOnlyShowDate: false,
showHour: null, showHour: null,
showMinute: null, showMinute: null,
showSecond: null, showSecond: null,
@ -84,6 +85,8 @@
microsecMax: 999, microsecMax: 999,
minDateTime: null, minDateTime: null,
maxDateTime: null, maxDateTime: null,
maxTime: null,
minTime: null,
onSelect: null, onSelect: null,
hourGrid: 0, hourGrid: 0,
minuteGrid: 0, minuteGrid: 0,
@ -96,6 +99,7 @@
altTimeFormat: null, altTimeFormat: null,
altSeparator: null, altSeparator: null,
altTimeSuffix: null, altTimeSuffix: null,
altRedirectFocus: true,
pickerTimeFormat: null, pickerTimeFormat: null,
pickerTimeSuffix: null, pickerTimeSuffix: null,
showTimepicker: true, showTimepicker: true,
@ -103,8 +107,10 @@
addSliderAccess: false, addSliderAccess: false,
sliderAccessArgs: null, sliderAccessArgs: null,
controlType: 'slider', controlType: 'slider',
oneLine: false,
defaultValue: null, defaultValue: null,
parse: 'strict' parse: 'strict',
afterInject: null
}; };
$.extend(this._defaults, this.regional['']); $.extend(this._defaults, this.regional['']);
}; };
@ -120,6 +126,8 @@
millisec_slider: null, millisec_slider: null,
microsec_slider: null, microsec_slider: null,
timezone_select: null, timezone_select: null,
maxTime: null,
minTime: null,
hour: 0, hour: 0,
minute: 0, minute: 0,
second: 0, second: 0,
@ -185,7 +193,7 @@
}, },
onChangeMonthYear: function (year, month, dp_inst) { onChangeMonthYear: function (year, month, dp_inst) {
// Update the time as well : this prevents the time from disappearing from the $input field. // Update the time as well : this prevents the time from disappearing from the $input field.
tp_inst._updateDateTime(dp_inst); // tp_inst._updateDateTime(dp_inst);
if ($.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)) { if ($.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)) {
tp_inst._defaults.evnts.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst); tp_inst._defaults.evnts.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst);
} }
@ -201,7 +209,7 @@
}; };
for (i in overrides) { for (i in overrides) {
if (overrides.hasOwnProperty(i)) { if (overrides.hasOwnProperty(i)) {
fns[i] = opts[i] || null; fns[i] = opts[i] || this._defaults[i] || null;
} }
} }
@ -266,12 +274,15 @@
tp_inst.$input = $input; tp_inst.$input = $input;
if (tp_inst._defaults.altField) { if (tp_inst._defaults.altField) {
tp_inst.$altInput = $(tp_inst._defaults.altField).css({ tp_inst.$altInput = $(tp_inst._defaults.altField);
if (tp_inst._defaults.altRedirectFocus === true) {
tp_inst.$altInput.css({
cursor: 'pointer' cursor: 'pointer'
}).focus(function () { }).focus(function () {
$input.trigger("focus"); $input.trigger("focus");
}); });
} }
}
if (tp_inst._defaults.minDate === 0 || tp_inst._defaults.minDateTime === 0) { if (tp_inst._defaults.minDate === 0 || tp_inst._defaults.minDateTime === 0) {
tp_inst._defaults.minDate = new Date(); tp_inst._defaults.minDate = new Date();
@ -304,11 +315,12 @@
* add our sliders to the calendar * add our sliders to the calendar
*/ */
_addTimePicker: function (dp_inst) { _addTimePicker: function (dp_inst) {
var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ? this.$input.val() + ' ' + this.$altInput.val() : this.$input.val(); var currDT = $.trim((this.$altInput && this._defaults.altFieldTimeOnly) ? this.$input.val() + ' ' + this.$altInput.val() : this.$input.val());
this.timeDefined = this._parseTime(currDT); this.timeDefined = this._parseTime(currDT);
this._limitMinMaxDateTime(dp_inst, false); this._limitMinMaxDateTime(dp_inst, false);
this._injectTimePicker(); this._injectTimePicker();
this._afterInject();
}, },
/* /*
@ -345,6 +357,16 @@
} }
}, },
/*
* Handle callback option after injecting timepicker
*/
_afterInject: function() {
var o = this.inst.settings;
if ($.isFunction(o.afterInject)) {
o.afterInject.call(this);
}
},
/* /*
* generate and inject html for timepicker into ui datepicker * generate and inject html for timepicker into ui datepicker
*/ */
@ -363,9 +385,9 @@
// Prevent displaying twice // Prevent displaying twice
if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) { if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) {
var noDisplay = ' style="display:none;"', var noDisplay = ' ui_tpicker_unit_hide',
html = '<div class="ui-timepicker-div' + (o.isRTL ? ' ui-timepicker-rtl' : '') + '"><dl>' + '<dt class="ui_tpicker_time_label"' + ((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' + html = '<div class="ui-timepicker-div' + (o.isRTL ? ' ui-timepicker-rtl' : '') + (o.oneLine && o.controlType === 'select' ? ' ui-timepicker-oneLine' : '') + '"><dl>' + '<dt class="ui_tpicker_time_label' + ((o.showTime) ? '' : noDisplay) + '">' + o.timeText + '</dt>' +
'<dd class="ui_tpicker_time"' + ((o.showTime) ? '' : noDisplay) + '></dd>'; '<dd class="ui_tpicker_time '+ ((o.showTime) ? '' : noDisplay) + '"><input class="ui_tpicker_time_input" ' + (o.timeInput ? '' : 'disabled') + '/></dd>';
// Create the markup // Create the markup
for (i = 0, l = this.units.length; i < l; i++) { for (i = 0, l = this.units.length; i < l; i++) {
@ -379,8 +401,8 @@
max[litem] = parseInt((o[litem + 'Max'] - ((o[litem + 'Max'] - o[litem + 'Min']) % o['step' + uitem])), 10); max[litem] = parseInt((o[litem + 'Max'] - ((o[litem + 'Max'] - o[litem + 'Min']) % o['step' + uitem])), 10);
gridSize[litem] = 0; gridSize[litem] = 0;
html += '<dt class="ui_tpicker_' + litem + '_label"' + (show ? '' : noDisplay) + '>' + o[litem + 'Text'] + '</dt>' + html += '<dt class="ui_tpicker_' + litem + '_label' + (show ? '' : noDisplay) + '">' + o[litem + 'Text'] + '</dt>' +
'<dd class="ui_tpicker_' + litem + '"><div class="ui_tpicker_' + litem + '_slider"' + (show ? '' : noDisplay) + '></div>'; '<dd class="ui_tpicker_' + litem + (show ? '' : noDisplay) + '"><div class="ui_tpicker_' + litem + '_slider' + (show ? '' : noDisplay) + '"></div>';
if (show && o[litem + 'Grid'] > 0) { if (show && o[litem + 'Grid'] > 0) {
html += '<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>';
@ -406,8 +428,8 @@
// Timezone // Timezone
var showTz = o.showTimezone !== null ? o.showTimezone : this.support.timezone; var showTz = o.showTimezone !== null ? o.showTimezone : this.support.timezone;
html += '<dt class="ui_tpicker_timezone_label"' + (showTz ? '' : noDisplay) + '>' + o.timezoneText + '</dt>'; html += '<dt class="ui_tpicker_timezone_label' + (showTz ? '' : noDisplay) + '">' + o.timezoneText + '</dt>';
html += '<dd class="ui_tpicker_timezone" ' + (showTz ? '' : noDisplay) + '></dd>'; html += '<dd class="ui_tpicker_timezone' + (showTz ? '' : noDisplay) + '"></dd>';
// Create the elements from string // Create the elements from string
html += '</dl></div>'; html += '</dl></div>';
@ -490,6 +512,7 @@
this.timezone_select.change(function () { this.timezone_select.change(function () {
tp_inst._onTimeChange(); tp_inst._onTimeChange();
tp_inst._onSelectHandler(); tp_inst._onSelectHandler();
tp_inst._afterInject();
}); });
// End timezone options // End timezone options
@ -501,7 +524,21 @@
$dp.append($tp); $dp.append($tp);
} }
this.$timeObj = $tp.find('.ui_tpicker_time'); this.$timeObj = $tp.find('.ui_tpicker_time_input');
this.$timeObj.change(function () {
var timeFormat = tp_inst.inst.settings.timeFormat;
var parsedTime = $.datepicker.parseTime(timeFormat, this.value);
var update = new Date();
if (parsedTime) {
update.setHours(parsedTime.hour);
update.setMinutes(parsedTime.minute);
update.setSeconds(parsedTime.second);
$.datepicker._setTime(tp_inst.inst, update);
} else {
this.value = tp_inst.formattedTime;
this.blur();
}
});
if (this.inst !== null) { if (this.inst !== null) {
var timeDefined = this.timeDefined; var timeDefined = this.timeDefined;
@ -666,6 +703,44 @@
} }
} }
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();
} else if (this.hour===tempMinTime.getHours() && this.minute<tempMinTime.getMinutes()) {
this.minute=this._defaults.minuteMin=tempMinTime.getMinutes();
} else {
if (this._defaults.hourMin<tempMinTime.getHours()) {
this._defaults.hourMin=tempMinTime.getHours();
this._defaults.minuteMin=tempMinTime.getMinutes();
} else if (this._defaults.hourMin===tempMinTime.getHours()===this.hour && this._defaults.minuteMin<tempMinTime.getMinutes()) {
this._defaults.minuteMin=tempMinTime.getMinutes();
} else {
this._defaults.minuteMin=0;
}
}
}
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.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();
} else if (this._defaults.hourMax===tempMaxTime.getHours()===this.hour && this._defaults.minuteMax>tempMaxTime.getMinutes()) {
this._defaults.minuteMax=tempMaxTime.getMinutes();
} else {
this._defaults.minuteMax=59;
}
}
}
if (adjustSliders !== undefined && adjustSliders === true) { if (adjustSliders !== undefined && adjustSliders === true) {
var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)), 10), 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), minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)), 10),
@ -674,23 +749,23 @@
microsecMax = parseInt((this._defaults.microsecMax - ((this._defaults.microsecMax - this._defaults.microsecMin) % this._defaults.stepMicrosec)), 10); microsecMax = parseInt((this._defaults.microsecMax - ((this._defaults.microsecMax - this._defaults.microsecMin) % this._defaults.stepMicrosec)), 10);
if (this.hour_slider) { if (this.hour_slider) {
this.control.options(this, this.hour_slider, 'hour', { min: this._defaults.hourMin, max: hourMax }); this.control.options(this, this.hour_slider, 'hour', { min: this._defaults.hourMin, max: hourMax, step: this._defaults.stepHour });
this.control.value(this, this.hour_slider, 'hour', this.hour - (this.hour % this._defaults.stepHour)); this.control.value(this, this.hour_slider, 'hour', this.hour - (this.hour % this._defaults.stepHour));
} }
if (this.minute_slider) { if (this.minute_slider) {
this.control.options(this, this.minute_slider, 'minute', { min: this._defaults.minuteMin, max: minMax }); this.control.options(this, this.minute_slider, 'minute', { min: this._defaults.minuteMin, max: minMax, step: this._defaults.stepMinute });
this.control.value(this, this.minute_slider, 'minute', this.minute - (this.minute % this._defaults.stepMinute)); this.control.value(this, this.minute_slider, 'minute', this.minute - (this.minute % this._defaults.stepMinute));
} }
if (this.second_slider) { if (this.second_slider) {
this.control.options(this, this.second_slider, 'second', { min: this._defaults.secondMin, max: secMax }); this.control.options(this, this.second_slider, 'second', { min: this._defaults.secondMin, max: secMax, step: this._defaults.stepSecond });
this.control.value(this, this.second_slider, 'second', this.second - (this.second % this._defaults.stepSecond)); this.control.value(this, this.second_slider, 'second', this.second - (this.second % this._defaults.stepSecond));
} }
if (this.millisec_slider) { if (this.millisec_slider) {
this.control.options(this, this.millisec_slider, 'millisec', { min: this._defaults.millisecMin, max: millisecMax }); this.control.options(this, this.millisec_slider, 'millisec', { min: this._defaults.millisecMin, max: millisecMax, step: this._defaults.stepMillisec });
this.control.value(this, this.millisec_slider, 'millisec', this.millisec - (this.millisec % this._defaults.stepMillisec)); this.control.value(this, this.millisec_slider, 'millisec', this.millisec - (this.millisec % this._defaults.stepMillisec));
} }
if (this.microsec_slider) { if (this.microsec_slider) {
this.control.options(this, this.microsec_slider, 'microsec', { min: this._defaults.microsecMin, max: microsecMax }); this.control.options(this, this.microsec_slider, 'microsec', { min: this._defaults.microsecMin, max: microsecMax, step: this._defaults.stepMicrosec });
this.control.value(this, this.microsec_slider, 'microsec', this.microsec - (this.microsec % this._defaults.stepMicrosec)); this.control.value(this, this.microsec_slider, 'microsec', this.microsec - (this.microsec % this._defaults.stepMicrosec));
} }
} }
@ -801,18 +876,21 @@
// Updates the time within the timepicker // Updates the time within the timepicker
this.formattedTime = $.datepicker.formatTime(o.timeFormat, this, o); this.formattedTime = $.datepicker.formatTime(o.timeFormat, this, o);
if (this.$timeObj) { if (this.$timeObj) {
var sPos = this.$timeObj[0].selectionStart;
var ePos = this.$timeObj[0].selectionEnd;
if (pickerTimeFormat === o.timeFormat) { if (pickerTimeFormat === o.timeFormat) {
this.$timeObj.text(this.formattedTime + pickerTimeSuffix); this.$timeObj.val(this.formattedTime + pickerTimeSuffix);
} }
else { else {
this.$timeObj.text($.datepicker.formatTime(pickerTimeFormat, this, o) + pickerTimeSuffix); this.$timeObj.val($.datepicker.formatTime(pickerTimeFormat, this, o) + pickerTimeSuffix);
} }
this.$timeObj[0].setSelectionRange(sPos, ePos);
} }
this.timeDefined = true; this.timeDefined = true;
if (hasChanged) { if (hasChanged) {
this._updateDateTime(); this._updateDateTime();
this.$input.focus(); //this.$input.focus(); // may automatically open the picker on setDate
} }
}, },
@ -861,9 +939,9 @@
// return; // return;
//} //}
if (this._defaults.timeOnly === true) { if (this._defaults.timeOnly === true && this._defaults.timeOnlyShowDate === false) {
formattedDateTime = this.formattedTime; formattedDateTime = this.formattedTime;
} else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) { } else if ((this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) || (this._defaults.timeOnly === true && this._defaults.timeOnlyShowDate === true)) {
formattedDateTime += this._defaults.separator + this.formattedTime + this._defaults.timeSuffix; formattedDateTime += this._defaults.separator + this.formattedTime + this._defaults.timeSuffix;
} }
@ -877,8 +955,8 @@
} else if (this.$altInput) { } else if (this.$altInput) {
this.$input.val(formattedDateTime); this.$input.val(formattedDateTime);
var altFormattedDateTime = '', var altFormattedDateTime = '',
altSeparator = this._defaults.altSeparator ? this._defaults.altSeparator : this._defaults.separator, altSeparator = this._defaults.altSeparator !== null ? this._defaults.altSeparator : this._defaults.separator,
altTimeSuffix = this._defaults.altTimeSuffix ? this._defaults.altTimeSuffix : this._defaults.timeSuffix; altTimeSuffix = this._defaults.altTimeSuffix !== null ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
if (!this._defaults.timeOnly) { if (!this._defaults.timeOnly) {
if (this._defaults.altFormat) { if (this._defaults.altFormat) {
@ -893,7 +971,7 @@
} }
} }
if (this._defaults.altTimeFormat) { if (this._defaults.altTimeFormat !== null) {
altFormattedDateTime += $.datepicker.formatTime(this._defaults.altTimeFormat, this, this._defaults) + altTimeSuffix; altFormattedDateTime += $.datepicker.formatTime(this._defaults.altTimeFormat, this, this._defaults) + altTimeSuffix;
} }
else { else {
@ -991,7 +1069,7 @@
// select methods // select methods
select: { select: {
create: function (tp_inst, obj, unit, val, min, max, step) { create: function (tp_inst, obj, unit, val, min, max, step) {
var sel = '<select class="ui-timepicker-select" data-unit="' + unit + '" data-min="' + min + '" data-max="' + max + '" data-step="' + step + '">', var sel = '<select class="ui-timepicker-select ui-state-default ui-corner-all" data-unit="' + unit + '" data-min="' + min + '" data-max="' + max + '" data-step="' + step + '">',
format = tp_inst._defaults.pickerTimeFormat || tp_inst._defaults.timeFormat; format = tp_inst._defaults.pickerTimeFormat || tp_inst._defaults.timeFormat;
for (var i = min; i <= max; i += step) { for (var i = min; i <= max; i += step) {
@ -1010,6 +1088,7 @@
$(sel).appendTo(obj).change(function (e) { $(sel).appendTo(obj).change(function (e) {
tp_inst._onTimeChange(); tp_inst._onTimeChange();
tp_inst._onSelectHandler(); tp_inst._onSelectHandler();
tp_inst._afterInject();
}); });
return obj; return obj;
@ -1024,7 +1103,7 @@
o[opts] = val; o[opts] = val;
} }
else { o = opts; } else { o = opts; }
return tp_inst.control.create(tp_inst, obj, $t.data('unit'), $t.val(), o.min || $t.data('min'), o.max || $t.data('max'), o.step || $t.data('step')); 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'));
}, },
value: function (tp_inst, obj, unit, val) { value: function (tp_inst, obj, unit, val) {
var $t = obj.children('select'); var $t = obj.children('select');
@ -1065,7 +1144,7 @@
var tmp_args = arguments; var tmp_args = arguments;
if (typeof(o) === 'string') { if (typeof(o) === 'string') {
if (o === 'getDate') { if (o === 'getDate' || (o === 'option' && tmp_args.length === 2 && typeof (tmp_args[1]) === 'string')) {
return $.fn.datepicker.apply($(this[0]), tmp_args); return $.fn.datepicker.apply($(this[0]), tmp_args);
} else { } else {
return this.each(function () { return this.each(function () {
@ -1188,7 +1267,7 @@
ampm = ''; ampm = '';
resTime.ampm = ''; resTime.ampm = '';
} else { } else {
ampm = $.inArray(treg[order.t].toUpperCase(), o.amNames) !== -1 ? 'AM' : 'PM'; ampm = $.inArray(treg[order.t].toUpperCase(), $.map(o.amNames, function (x,i) { return x.toUpperCase(); })) !== -1 ? 'AM' : 'PM';
resTime.ampm = o[ampm === 'AM' ? 'amNames' : 'pmNames'][0]; resTime.ampm = o[ampm === 'AM' ? 'amNames' : 'pmNames'][0];
} }
} }
@ -1346,14 +1425,17 @@
$.datepicker._base_selectDate = $.datepicker._selectDate; $.datepicker._base_selectDate = $.datepicker._selectDate;
$.datepicker._selectDate = function (id, dateStr) { $.datepicker._selectDate = function (id, dateStr) {
var inst = this._getInst($(id)[0]), var inst = this._getInst($(id)[0]),
tp_inst = this._get(inst, 'timepicker'); tp_inst = this._get(inst, 'timepicker'),
was_inline;
if (tp_inst) { if (tp_inst && inst.settings.showTimepicker) {
tp_inst._limitMinMaxDateTime(inst, true); tp_inst._limitMinMaxDateTime(inst, true);
was_inline = inst.inline;
inst.inline = inst.stay_open = true; inst.inline = inst.stay_open = true;
//This way the onSelect handler called from calendarpicker get the full dateTime //This way the onSelect handler called from calendarpicker get the full dateTime
this._base_selectDate(id, dateStr); this._base_selectDate(id, dateStr);
inst.inline = inst.stay_open = false; inst.inline = was_inline;
inst.stay_open = false;
this._notifyChange(inst); this._notifyChange(inst);
this._updateDatepicker(inst); this._updateDatepicker(inst);
} else { } else {
@ -1447,7 +1529,7 @@
altFormattedDateTime = tp_inst.formattedDate + altSeparator + altFormattedDateTime; altFormattedDateTime = tp_inst.formattedDate + altSeparator + altFormattedDateTime;
} }
} }
$(altField).val(altFormattedDateTime); $(altField).val( inst.input.val() ? altFormattedDateTime : "");
} }
} }
else { else {
@ -1477,18 +1559,19 @@
}; };
/* /*
* override "Today" button to also grab the time. * override "Today" button to also grab the time and set it to input field.
*/ */
$.datepicker._base_gotoToday = $.datepicker._gotoToday; $.datepicker._base_gotoToday = $.datepicker._gotoToday;
$.datepicker._gotoToday = function (id) { $.datepicker._gotoToday = function (id) {
var inst = this._getInst($(id)[0]), var inst = this._getInst($(id)[0]);
$dp = inst.dpDiv;
this._base_gotoToday(id); this._base_gotoToday(id);
var tp_inst = this._get(inst, 'timepicker'); var tp_inst = this._get(inst, 'timepicker');
selectLocalTimezone(tp_inst); var tzoffset = $.timepicker.timezoneOffsetNumber(tp_inst.timezone);
var now = new Date(); var now = new Date();
now.setMinutes(now.getMinutes() + now.getTimezoneOffset() + tzoffset);
this._setTime(inst, now); this._setTime(inst, now);
$('.ui-datepicker-today', $dp).click(); this._setDate(inst, now);
tp_inst._onSelectHandler();
}; };
/* /*
@ -1585,16 +1668,18 @@
* override setDate() to allow setting time too within Date object * override setDate() to allow setting time too within Date object
*/ */
$.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker; $.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
$.datepicker._setDateDatepicker = function (target, date) { $.datepicker._setDateDatepicker = function (target, _date) {
var inst = this._getInst(target); var inst = this._getInst(target);
var date = _date;
if (!inst) { if (!inst) {
return; return;
} }
if (typeof(date) === 'string') { if (typeof(_date) === 'string') {
date = new Date(date); date = new Date(_date);
if (!date.getTime()) { if (!date.getTime()) {
$.timepicker.log("Error creating Date object from string."); this._base_setDateDatepicker.apply(this, arguments);
date = $(target).datepicker('getDate');
} }
} }
@ -1644,7 +1729,8 @@
} }
var date = this._getDate(inst); var date = this._getDate(inst);
if (date && tp_inst._parseTime($(target).val(), tp_inst.timeOnly)) { var currDT = $.trim((tp_inst.$altInput && tp_inst._defaults.altFieldTimeOnly) ? tp_inst.$input.val() + ' ' + tp_inst.$altInput.val() : 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.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
date.setMicroseconds(tp_inst.microsec); date.setMicroseconds(tp_inst.microsec);
@ -1718,7 +1804,10 @@
onselect = null, onselect = null,
overrides = tp_inst._defaults.evnts, overrides = tp_inst._defaults.evnts,
fns = {}, fns = {},
prop; prop,
ret,
oldVal,
$target;
if (typeof name === 'string') { // if min/max was set with the string if (typeof name === 'string') { // if min/max was set with the string
if (name === 'minDate' || name === 'minDateTime') { if (name === 'minDate' || name === 'minDateTime') {
min = value; min = value;
@ -1776,6 +1865,17 @@
} else if (onselect) { } else if (onselect) {
tp_inst._defaults.onSelect = onselect; 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
// _base_optionDatepicker, then set our value back.
if(min || max){
$target = $(target);
oldVal = $target.datetimepicker('getDate');
ret = this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
$target.datetimepicker('setDate', oldVal);
return ret;
}
} }
if (value === undefined) { if (value === undefined) {
return this._base_optionDatepicker.call($.datepicker, target, name); return this._base_optionDatepicker.call($.datepicker, target, name);
@ -2040,6 +2140,13 @@
end: {} // options for end picker end: {} // options for end picker
}, options); }, options);
// for the mean time this fixes an issue with calling getDate with timepicker()
var timeOnly = false;
if(method === 'timepicker'){
timeOnly = true;
method = 'datetimepicker';
}
function checkDates(changed, other) { function checkDates(changed, other) {
var startdt = startTime[method]('getDate'), var startdt = startTime[method]('getDate'),
enddt = endTime[method]('getDate'), enddt = endTime[method]('getDate'),
@ -2077,12 +2184,14 @@
date.setMilliseconds(date.getMilliseconds() - options.minInterval); date.setMilliseconds(date.getMilliseconds() - options.minInterval);
} }
} }
if (date.getTime) { if (date.getTime) {
other[method].call(other, 'option', option, date); other[method].call(other, 'option', option, date);
} }
} }
$.fn[method].call(startTime, $.extend({ $.fn[method].call(startTime, $.extend({
timeOnly: timeOnly,
onClose: function (dateText, inst) { onClose: function (dateText, inst) {
checkDates($(this), endTime); checkDates($(this), endTime);
}, },
@ -2091,6 +2200,7 @@
} }
}, options, options.start)); }, options, options.start));
$.fn[method].call(endTime, $.extend({ $.fn[method].call(endTime, $.extend({
timeOnly: timeOnly,
onClose: function (dateText, inst) { onClose: function (dateText, inst) {
checkDates($(this), startTime); checkDates($(this), startTime);
}, },
@ -2100,8 +2210,10 @@
}, options, options.end)); }, options, options.end));
checkDates(startTime, endTime); checkDates(startTime, endTime);
selected(startTime, endTime, 'minDate'); selected(startTime, endTime, 'minDate');
selected(endTime, startTime, 'maxDate'); selected(endTime, startTime, 'maxDate');
return $([startTime.get(0), endTime.get(0)]); return $([startTime.get(0), endTime.get(0)]);
}; };
@ -2110,9 +2222,9 @@
* @param {Object} err pass any type object to log to the console during error or debugging * @param {Object} err pass any type object to log to the console during error or debugging
* @return {void} * @return {void}
*/ */
$.timepicker.log = function (err) { $.timepicker.log = function () {
if (window.console) { if (window.console) {
window.console.log(err); window.console.log.apply(window.console, Array.prototype.slice.call(arguments));
} }
}; };
@ -2146,6 +2258,6 @@
/* /*
* Keep up with the version * Keep up with the version
*/ */
$.timepicker.version = "@@version"; $.timepicker.version = "1.6.1";
})(jQuery); }));

View File

@ -9,6 +9,7 @@
/* These imports processed by framework */ /* These imports processed by framework */
/*@import url("../../js/jquery/magicsuggest/magicsuggest.css");*/ /*@import url("../../js/jquery/magicsuggest/magicsuggest.css");*/
/*@import url("../../js/jquery/jpicker/css/jPicker-1.1.6.min.css");*/ /*@import url("../../js/jquery/jpicker/css/jPicker-1.1.6.min.css");*/
/*@import url("../../js/jquery/jquery-ui-timepicker-addon.css");*/
/*@import url("../../js/jquery/blueimp/css/blueimp-gallery.min.css");*/ /*@import url("../../js/jquery/blueimp/css/blueimp-gallery.min.css");*/
@ -470,6 +471,10 @@ span.et2_date_duration input.et2_date_duration{
background-size: contain; background-size: contain;
background-image: url(images/today.png); background-image: url(images/today.png);
} }
.ui-timepicker-div dl dd { margin: 0 0px 10px 30%; }
.ui-timepicker-div .ui_tpicker_time .ui_tpicker_time_input {
border: none;
}
/** /**
* Dialog widget * Dialog widget

View File

@ -1414,10 +1414,12 @@ div#ui-datepicker-div {
font-size: 0.9em; font-size: 0.9em;
} }
.ui-datepicker div.ui-timepicker-div dd.ui_tpicker_time { .ui-datepicker div.ui-timepicker-div dd.ui_tpicker_time {
font-size: 1.3em;
padding-left: 75px; padding-left: 75px;
background-color: #ffc200; background-color: #ffc200;
} }
.ui-datepicker div.ui-timepicker-div dd.ui_tpicker_time input {
font-size: 1.3em;
}
.ui-datepicker div.ui-timepicker-div dt.ui_tpicker_time_label { .ui-datepicker div.ui-timepicker-div dt.ui_tpicker_time_label {
font-size: 0.9em; font-size: 0.9em;
} }

View File

@ -1403,10 +1403,12 @@ div#ui-datepicker-div {
font-size: 0.9em; font-size: 0.9em;
} }
.ui-datepicker div.ui-timepicker-div dd.ui_tpicker_time { .ui-datepicker div.ui-timepicker-div dd.ui_tpicker_time {
font-size: 1.3em;
padding-left: 75px; padding-left: 75px;
background-color: #ffc200; background-color: #ffc200;
} }
.ui-datepicker div.ui-timepicker-div dd.ui_tpicker_time input {
font-size: 1.3em;
}
.ui-datepicker div.ui-timepicker-div dt.ui_tpicker_time_label { .ui-datepicker div.ui-timepicker-div dt.ui_tpicker_time_label {
font-size: 0.9em; font-size: 0.9em;
} }

View File

@ -362,7 +362,10 @@ div.ui-timepicker-div{
//Uhrzeit - Label //Uhrzeit - Label
dt.ui_tpicker_time_label{font-size: 0.9em} dt.ui_tpicker_time_label{font-size: 0.9em}
//Uhrzeit //Uhrzeit
dd.ui_tpicker_time{font-size: 1.3em; padding-left: 75px; background-color: @egw_color_1_a;} dd.ui_tpicker_time {
padding-left: 75px; background-color: @egw_color_1_a;
input {font-size: 1.3em;}
}
//Stunde - Label //Stunde - Label
dt.ui_tpicker_time_label{font-size: 0.9em} dt.ui_tpicker_time_label{font-size: 0.9em}

View File

@ -1425,10 +1425,12 @@ div#ui-datepicker-div {
font-size: 0.9em; font-size: 0.9em;
} }
.ui-datepicker div.ui-timepicker-div dd.ui_tpicker_time { .ui-datepicker div.ui-timepicker-div dd.ui_tpicker_time {
font-size: 1.3em;
padding-left: 75px; padding-left: 75px;
background-color: #ffc200; background-color: #ffc200;
} }
.ui-datepicker div.ui-timepicker-div dd.ui_tpicker_time input {
font-size: 1.3em;
}
.ui-datepicker div.ui-timepicker-div dt.ui_tpicker_time_label { .ui-datepicker div.ui-timepicker-div dt.ui_tpicker_time_label {
font-size: 0.9em; font-size: 0.9em;
} }