Run pre-commit on legacy code

This commit is contained in:
jo 2021-10-12 11:17:57 +02:00
parent fea11ac752
commit 83b7e4162e
323 changed files with 6126 additions and 6462 deletions
legacy/public/js/timepicker

View file

@ -31,7 +31,7 @@
}
});
/*
/*
* Timepicker manager.
* Use the singleton instance of this class, $.datetimepicker, to interact with the time picker.
* Settings for (groups of) time pickers are maintained in an instance object,
@ -150,7 +150,7 @@
support: {},
control: null,
/*
/*
* Override the default settings for all instances of the time picker.
* @param settings object - the new settings to use as defaults (anonymous object)
* @return the manager object
@ -223,8 +223,8 @@
// detect which units are supported
tp_inst.support = detectSupport(
tp_inst._defaults.timeFormat +
(tp_inst._defaults.pickerTimeFormat? tp_inst._defaults.pickerTimeFormat:'') +
tp_inst._defaults.timeFormat +
(tp_inst._defaults.pickerTimeFormat? tp_inst._defaults.pickerTimeFormat:'') +
(tp_inst._defaults.altTimeFormat? tp_inst._defaults.altTimeFormat:''));
// controlType is string - key to our this._controls
@ -235,7 +235,7 @@
tp_inst.control = tp_inst._controls[tp_inst._defaults.controlType];
}
// controlType is an object and must implement create, options, value methods
else{
else{
tp_inst.control = tp_inst._defaults.controlType;
}
@ -255,17 +255,17 @@
tp_inst._defaults.timezoneList = timezoneList;
// set the default units
tp_inst.timezone = tp_inst._defaults.timezone !== null? $.datetimepicker.timezoneOffsetNumber(tp_inst._defaults.timezone) :
tp_inst.timezone = tp_inst._defaults.timezone !== null? $.datetimepicker.timezoneOffsetNumber(tp_inst._defaults.timezone) :
((new Date()).getTimezoneOffset()*-1);
tp_inst.hour = tp_inst._defaults.hour < tp_inst._defaults.hourMin? tp_inst._defaults.hourMin :
tp_inst.hour = tp_inst._defaults.hour < tp_inst._defaults.hourMin? tp_inst._defaults.hourMin :
tp_inst._defaults.hour > tp_inst._defaults.hourMax? tp_inst._defaults.hourMax : tp_inst._defaults.hour;
tp_inst.minute = tp_inst._defaults.minute < tp_inst._defaults.minuteMin? tp_inst._defaults.minuteMin :
tp_inst.minute = tp_inst._defaults.minute < tp_inst._defaults.minuteMin? tp_inst._defaults.minuteMin :
tp_inst._defaults.minute > tp_inst._defaults.minuteMax? tp_inst._defaults.minuteMax : tp_inst._defaults.minute;
tp_inst.second = tp_inst._defaults.second < tp_inst._defaults.secondMin? tp_inst._defaults.secondMin :
tp_inst.second = tp_inst._defaults.second < tp_inst._defaults.secondMin? tp_inst._defaults.secondMin :
tp_inst._defaults.second > tp_inst._defaults.secondMax? tp_inst._defaults.secondMax : tp_inst._defaults.second;
tp_inst.millisec = tp_inst._defaults.millisec < tp_inst._defaults.millisecMin? tp_inst._defaults.millisecMin :
tp_inst.millisec = tp_inst._defaults.millisec < tp_inst._defaults.millisecMin? tp_inst._defaults.millisecMin :
tp_inst._defaults.millisec > tp_inst._defaults.millisecMax? tp_inst._defaults.millisecMax : tp_inst._defaults.millisec;
tp_inst.microsec = tp_inst._defaults.microsec < tp_inst._defaults.microsecMin? tp_inst._defaults.microsecMin :
tp_inst.microsec = tp_inst._defaults.microsec < tp_inst._defaults.microsecMin? tp_inst._defaults.microsecMin :
tp_inst._defaults.microsec > tp_inst._defaults.microsecMax? tp_inst._defaults.microsecMax : tp_inst._defaults.microsec;
tp_inst.ampm = '';
tp_inst.$input = $input;
@ -369,7 +369,7 @@
// Prevent displaying twice
if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) {
var noDisplay = ' style="display:none;"',
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' : '') +'"><dl>' + '<dt class="ui_tpicker_time_label"' + ((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
'<dd class="ui_tpicker_time"' + ((o.showTime) ? '' : noDisplay) + '></dd>';
// Create the markup
@ -384,7 +384,7 @@
max[litem] = parseInt((o[litem+'Max'] - ((o[litem+'Max'] - o[litem+'Min']) % o['step'+uitem])), 10);
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>';
if (show && o[litem+'Grid'] > 0) {
@ -393,7 +393,7 @@
if(litem == 'hour'){
for (var h = o[litem+'Min']; h <= max[litem]; h += parseInt(o[litem+'Grid'], 10)) {
gridSize[litem]++;
var tmph = $.datepicker.formatTime(this.support.ampm? 'hht':'HH', {hour:h}, o);
var tmph = $.datepicker.formatTime(this.support.ampm? 'hht':'HH', {hour:h}, o);
html += '<td data-for="'+litem+'">' + tmph + '</td>';
}
}
@ -408,7 +408,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>';
@ -423,7 +423,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];
@ -458,7 +458,7 @@
}
}
}
tp_inst.control.value(tp_inst, tp_inst[f+'_slider'], litem, n);
tp_inst._onTimeChange();
@ -497,7 +497,7 @@
tp_inst._onSelectHandler();
});
// End timezone options
// inject timepicker into datepicker
var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
if ($buttonPanel.length) {
@ -519,7 +519,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);
@ -756,8 +756,8 @@
// If the update was done in the input field, the input field should not be updated.
// If the update was done using the sliders, update the input field.
var hasChanged = (hour != this.hour || minute != this.minute || second != this.second || millisec != this.millisec || microsec != this.microsec
|| (this.ampm.length > 0 && (hour < 12) != ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1))
var hasChanged = (hour != this.hour || minute != this.minute || second != this.second || millisec != this.millisec || microsec != this.microsec
|| (this.ampm.length > 0 && (hour < 12) != ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1))
|| (this.timezone !== null && timezone != this.timezone));
if (hasChanged) {
@ -832,7 +832,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;
@ -842,7 +842,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)) {
@ -867,7 +867,7 @@
var altFormattedDateTime = '',
altSeparator = this._defaults.altSeparator ? this._defaults.altSeparator : this._defaults.separator,
altTimeSuffix = this._defaults.altTimeSuffix ? 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);
@ -934,7 +934,7 @@
stop: function(event, ui) {
tp_inst._onSelectHandler();
}
});
});
},
options: function(tp_inst, obj, unit, opts, val){
if(tp_inst._defaults.isRTL){
@ -947,7 +947,7 @@
}
return obj.slider(opts);
}
var min = opts.min,
var min = opts.min,
max = opts.max;
opts.min = opts.max = null;
if(min !== undefined){
@ -982,7 +982,7 @@
var sel = '<select class="ui-timepicker-select" data-unit="'+ unit +'" data-min="'+ min +'" data-max="'+ max +'" data-step="'+ step +'">',
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){
sel += '<option value="'+ i +'"'+ (i==val? ' selected':'') +'>';
if(unit == 'hour'){
sel += $.datepicker.formatTime($.trim(format.replace(/[^ht ]/ig,'')), {hour:i}, tp_inst._defaults);
@ -1009,7 +1009,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 || $t.data('min'), o.max || $t.data('max'), o.step || $t.data('step'));
@ -1087,7 +1087,7 @@
/*
* Public utility to parse time
*/
$.datepicker.parseTime = function(timeFormat, timeString, options) {
$.datepicker.parseTime = function(timeFormat, timeString, options) {
var o = extendRemove(extendRemove({}, $.datetimepicker._defaults), options || {}),
iso8601 = (timeFormat.replace(/\'.*?\'/g,'').indexOf('Z') !== -1);
@ -1237,11 +1237,11 @@
}
catch(err2){
$.datetimepicker.log("Unable to parse \ntimeString: "+ s +"\ntimeFormat: "+ f);
}
}
}
return false;
}; // end looseParse
if(typeof o.parse === "function"){
return o.parse(timeFormat, timeString, o);
}
@ -1302,9 +1302,9 @@
return $.datetimepicker.timezoneOffsetString(time.timezone === null? options.timezone : time.timezone, false);
case 'Z':
return $.datetimepicker.timezoneOffsetString(time.timezone === null? options.timezone : time.timezone, true);
case 'T':
case 'T':
return ampmName.charAt(0).toUpperCase();
case 'TT':
case 'TT':
return ampmName.toUpperCase();
case 't':
return ampmName.charAt(0).toLowerCase();
@ -1377,7 +1377,7 @@
if (tp_inst) {
if ($.datepicker._get(inst, 'constrainInput')) {
var ampm = tp_inst.support.ampm,
tz = tp_inst._defaults.showTimezone !== null? tp_inst._defaults.showTimezone : tp_inst.support.timezone,
tz = tp_inst._defaults.showTimezone !== null? tp_inst._defaults.showTimezone : tp_inst.support.timezone,
dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
datetimeChars = tp_inst._defaults.timeFormat.toString()
.replace(/[hms]/g, '')
@ -1386,11 +1386,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);
@ -1413,11 +1413,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){
@ -1518,7 +1518,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();
@ -1584,9 +1584,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){
@ -1626,8 +1626,8 @@
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
@ -1760,7 +1760,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
@ -1795,7 +1795,7 @@
var detectSupport = function(timeFormat){
var tf = timeFormat.replace(/\'.*?\'/g,'').toLowerCase(), // removes literals
isIn = function(f, t){ // does the format contain the token?
return f.indexOf(t) !== -1? true:false;
return f.indexOf(t) !== -1? true:false;
};
return {
hour: isIn(tf,'h'),
@ -1832,7 +1832,7 @@
*/
var splitDateTime = function(dateFormat, dateTimeString, dateSettings, timeSettings) {
try {
// The idea is to get the number separator occurrences in datetime and the time format requested (since time has
// The idea is to get the number separator occurrences in datetime and the time format requested (since time has
// fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split.
var separator = timeSettings && timeSettings.separator ? timeSettings.separator : $.datetimepicker._defaults.separator,
format = timeSettings && timeSettings.timeFormat ? timeSettings.timeFormat : $.datetimepicker._defaults.timeFormat,
@ -1931,7 +1931,7 @@
hours = (off - minutes) / 60,
iso = iso8601? ':':'',
tz = (off >= 0 ? '+' : '-') + ('0' + (hours * 101).toString()).slice(-2) + iso + ('0' + (minutes * 101).toString()).slice(-2);
if(tz == '+00:00'){
return 'Z';
}
@ -2083,7 +2083,7 @@
var date = changed[method].call(changed, 'getDate');
if(date !== null && options.minInterval > 0){
if(option == 'minDate'){
date.setMilliseconds(date.getMilliseconds() + options.minInterval);
date.setMilliseconds(date.getMilliseconds() + options.minInterval);
}
if(option == 'maxDate'){
date.setMilliseconds(date.getMilliseconds() - options.minInterval);
@ -2113,7 +2113,7 @@
if(!Date.prototype.getMicroseconds){
Date.prototype.microseconds = 0;
Date.prototype.getMicroseconds = function(){ return this.microseconds; };
Date.prototype.setMicroseconds = function(m){
Date.prototype.setMicroseconds = function(m){
this.setMilliseconds(this.getMilliseconds() + Math.floor(m/1000));
this.microseconds = m%1000;
return this;