From: Sascha Greuel Date: Wed, 28 May 2014 10:15:40 +0000 (+0200) Subject: Updated timepicker X-Git-Tag: 2.1.0_Alpha_1~548^2~8^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a887015c36b72fc70b9626f82fa8bb37167ff7da;p=GitHub%2FWoltLab%2FWCF.git Updated timepicker --- diff --git a/wcfsetup/install/files/js/3rdParty/jquery-ui.timepicker.js b/wcfsetup/install/files/js/3rdParty/jquery-ui.timepicker.js index c769aaf449..b46b03e267 100644 --- a/wcfsetup/install/files/js/3rdParty/jquery-ui.timepicker.js +++ b/wcfsetup/install/files/js/3rdParty/jquery-ui.timepicker.js @@ -1,6 +1,6 @@ -/*! jQuery Timepicker Addon - v1.4 - 2013-08-11 +/*! jQuery Timepicker Addon - v1.4.5 - 2014-05-26 * http://trentrichardson.com/examples/timepicker -* Copyright (c) 2013 Trent Richardson; Licensed MIT */ +* Copyright (c) 2014 Trent Richardson; Licensed MIT */ (function ($) { /* @@ -16,7 +16,7 @@ */ $.extend($.ui, { timepicker: { - version: "1.4" + version: "1.4.5" } }); @@ -48,6 +48,7 @@ this._defaults = { // Global defaults for all the datetime picker instances showButtonPanel: true, timeOnly: false, + timeOnlyShowDate: false, showHour: null, showMinute: null, showSecond: null, @@ -78,6 +79,8 @@ microsecMax: 999, minDateTime: null, maxDateTime: null, + maxTime: null, + minTime: null, onSelect: null, hourGrid: 0, minuteGrid: 0, @@ -90,6 +93,7 @@ altTimeFormat: null, altSeparator: null, altTimeSuffix: null, + altRedirectFocus: true, pickerTimeFormat: null, pickerTimeSuffix: null, showTimepicker: true, @@ -114,6 +118,8 @@ millisec_slider: null, microsec_slider: null, timezone_select: null, + maxTime: null, + minTime: null, hour: 0, minute: 0, second: 0, @@ -261,11 +267,14 @@ tp_inst.$input = $input; if (tp_inst._defaults.altField) { - tp_inst.$altInput = $(tp_inst._defaults.altField).css({ - cursor: 'pointer' - }).focus(function () { - $input.trigger("focus"); - }); + tp_inst.$altInput = $(tp_inst._defaults.altField); + if (tp_inst._defaults.altRedirectFocus === true) { + tp_inst.$altInput.css({ + cursor: 'pointer' + }).focus(function () { + $input.trigger("focus"); + }); + } } if (tp_inst._defaults.minDate === 0 || tp_inst._defaults.minDateTime === 0) { @@ -661,6 +670,44 @@ } } + if (dp_inst.settings.minTime!==null) { + var tempMinTime=new Date("01/01/1970 " + dp_inst.settings.minTime); + if (this.hourtempMaxTime.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) { 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), @@ -669,23 +716,23 @@ microsecMax = parseInt((this._defaults.microsecMax - ((this._defaults.microsecMax - this._defaults.microsecMin) % this._defaults.stepMicrosec)), 10); 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)); } 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)); } 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)); } 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)); } 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)); } } @@ -744,13 +791,23 @@ if (microsec !== false) { microsec = parseInt(microsec, 10); } + if (timezone !== false) { + timezone = timezone.toString(); + } var ampm = o[hour < 12 ? 'amNames' : 'pmNames'][0]; // 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)) || (this.timezone !== null && timezone !== this.timezone)); + 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)) || + (this.timezone !== null && timezone !== this.timezone.toString()) // could be numeric or "EST" format, so use toString() + ); if (hasChanged) { @@ -797,6 +854,7 @@ this.timeDefined = true; if (hasChanged) { this._updateDateTime(); + //this.$input.focus(); // may automatically open the picker on setDate } }, @@ -830,7 +888,7 @@ var formattedDateTime = this.formattedDate; // if a slider was changed but datepicker doesn't have a value yet, set it - if (dp_inst.lastVa === "") { + if (dp_inst.lastVal === "") { dp_inst.currentYear = dp_inst.selectedYear; dp_inst.currentMonth = dp_inst.selectedMonth; dp_inst.currentDay = dp_inst.selectedDay; @@ -845,9 +903,9 @@ // return; //} - if (this._defaults.timeOnly === true) { + if (this._defaults.timeOnly === true && this._defaults.timeOnlyShowDate === false) { 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; } @@ -861,8 +919,8 @@ } else if (this.$altInput) { this.$input.val(formattedDateTime); var altFormattedDateTime = '', - altSeparator = this._defaults.altSeparator ? this._defaults.altSeparator : this._defaults.separator, - altTimeSuffix = this._defaults.altTimeSuffix ? this._defaults.altTimeSuffix : this._defaults.timeSuffix; + 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) { @@ -877,7 +935,7 @@ } } - if (this._defaults.altTimeFormat) { + if (this._defaults.altTimeFormat !== null) { altFormattedDateTime += $.datepicker.formatTime(this._defaults.altTimeFormat, this, this._defaults) + altTimeSuffix; } else { @@ -1049,7 +1107,7 @@ var tmp_args = arguments; 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); } else { return this.each(function () { @@ -1332,7 +1390,7 @@ var inst = this._getInst($(id)[0]), tp_inst = this._get(inst, 'timepicker'); - if (tp_inst) { + if (tp_inst && inst.settings.showTimepicker) { tp_inst._limitMinMaxDateTime(inst, true); inst.inline = inst.stay_open = true; //This way the onSelect handler called from calendarpicker get the full dateTime @@ -1431,11 +1489,11 @@ altFormattedDateTime = tp_inst.formattedDate + altSeparator + altFormattedDateTime; } } - $(altField).val(altFormattedDateTime); + $(altField).val( inst.input.val() ? altFormattedDateTime : ""); } } else { - $.datepicker._base_updateAlternate(inst); + $.datepicker._base_updateAlternate(inst); } }; @@ -1569,16 +1627,18 @@ * override setDate() to allow setting time too within Date object */ $.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker; - $.datepicker._setDateDatepicker = function (target, date) { + $.datepicker._setDateDatepicker = function (target, _date) { var inst = this._getInst(target); + var date = _date; if (!inst) { return; } - if (typeof(date) === 'string') { - date = new Date(date); + if (typeof(_date) === 'string') { + date = new Date(_date); if (!date.getTime()) { - $.timepicker.log("Error creating Date object from string."); + this._base_setDateDatepicker.apply(this, arguments); + date = $(target).datepicker('getDate'); } } @@ -1595,7 +1655,7 @@ // 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) { + if (tp_inst && tp_date) { // look out for DST if tz wasn't specified if (!tp_inst.support.timezone && tp_inst._defaults.timezone === null) { tp_inst.timezone = tp_date.getTimezoneOffset() * -1; @@ -2024,6 +2084,13 @@ end: {} // options for end picker }, 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) { var startdt = startTime[method]('getDate'), enddt = endTime[method]('getDate'), @@ -2067,6 +2134,7 @@ } $.fn[method].call(startTime, $.extend({ + timeOnly: timeOnly, onClose: function (dateText, inst) { checkDates($(this), endTime); }, @@ -2075,6 +2143,7 @@ } }, options, options.start)); $.fn[method].call(endTime, $.extend({ + timeOnly: timeOnly, onClose: function (dateText, inst) { checkDates($(this), startTime); }, @@ -2130,6 +2199,6 @@ /* * Keep up with the version */ - $.timepicker.version = "1.4"; + $.timepicker.version = "1.4.5"; })(jQuery); \ No newline at end of file diff --git a/wcfsetup/install/files/js/3rdParty/jquery-ui.timepicker.min.js b/wcfsetup/install/files/js/3rdParty/jquery-ui.timepicker.min.js index 7d19759a96..a1c5fea58d 100644 --- a/wcfsetup/install/files/js/3rdParty/jquery-ui.timepicker.min.js +++ b/wcfsetup/install/files/js/3rdParty/jquery-ui.timepicker.min.js @@ -1,4 +1,5 @@ -/*! jQuery Timepicker Addon - v1.4 - 2013-08-11 +/*! jQuery Timepicker Addon - v1.4.5 - 2014-05-26 * http://trentrichardson.com/examples/timepicker -* Copyright (c) 2013 Trent Richardson; Licensed MIT */ -(function($){$.ui.timepicker=$.ui.timepicker||{};if($.ui.timepicker.version){return}$.extend($.ui,{timepicker:{version:"1.4"}});var Timepicker=function(){this.regional=[];this.regional[""]={currentText:"Now",closeText:"Done",amNames:["AM","A"],pmNames:["PM","P"],timeFormat:"HH:mm",timeSuffix:"",timeOnlyTitle:"Choose Time",timeText:"Time",hourText:"Hour",minuteText:"Minute",secondText:"Second",millisecText:"Millisecond",microsecText:"Microsecond",timezoneText:"Time Zone",isRTL:false};this._defaults={showButtonPanel:true,timeOnly:false,showHour:null,showMinute:null,showSecond:null,showMillisec:null,showMicrosec:null,showTimezone:null,showTime:true,stepHour:1,stepMinute:1,stepSecond:1,stepMillisec:1,stepMicrosec:1,hour:0,minute:0,second:0,millisec:0,microsec:0,timezone:null,hourMin:0,minuteMin:0,secondMin:0,millisecMin:0,microsecMin:0,hourMax:23,minuteMax:59,secondMax:59,millisecMax:999,microsecMax:999,minDateTime:null,maxDateTime:null,onSelect:null,hourGrid:0,minuteGrid:0,secondGrid:0,millisecGrid:0,microsecGrid:0,alwaysSetTime:true,separator:" ",altFieldTimeOnly:true,altTimeFormat:null,altSeparator:null,altTimeSuffix:null,pickerTimeFormat:null,pickerTimeSuffix:null,showTimepicker:true,timezoneList:null,addSliderAccess:false,sliderAccessArgs:null,controlType:"slider",defaultValue:null,parse:"strict"};$.extend(this._defaults,this.regional[""])};$.extend(Timepicker.prototype,{$input:null,$altInput:null,$timeObj:null,inst:null,hour_slider:null,minute_slider:null,second_slider:null,millisec_slider:null,microsec_slider:null,timezone_select:null,hour:0,minute:0,second:0,millisec:0,microsec:0,timezone:null,hourMinOriginal:null,minuteMinOriginal:null,secondMinOriginal:null,millisecMinOriginal:null,microsecMinOriginal:null,hourMaxOriginal:null,minuteMaxOriginal:null,secondMaxOriginal:null,millisecMaxOriginal:null,microsecMaxOriginal:null,ampm:"",formattedDate:"",formattedTime:"",formattedDateTime:"",timezoneList:null,units:["hour","minute","second"],support:{},control:null,setDefaults:function(e){extendRemove(this._defaults,e||{});return this},_newInst:function($input,opts){var tp_inst=new Timepicker,inlineSettings={},fns={},overrides,i;for(var attrName in this._defaults){if(this._defaults.hasOwnProperty(attrName)){var attrValue=$input.attr("time:"+attrName);if(attrValue){try{inlineSettings[attrName]=eval(attrValue)}catch(err){inlineSettings[attrName]=attrValue}}}}overrides={beforeShow:function(e,t){if($.isFunction(tp_inst._defaults.evnts.beforeShow)){return tp_inst._defaults.evnts.beforeShow.call($input[0],e,t,tp_inst)}},onChangeMonthYear:function(e,t,n){tp_inst._updateDateTime(n);if($.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)){tp_inst._defaults.evnts.onChangeMonthYear.call($input[0],e,t,n,tp_inst)}},onClose:function(e,t){if(tp_inst.timeDefined===true&&$input.val()!==""){tp_inst._updateDateTime(t)}if($.isFunction(tp_inst._defaults.evnts.onClose)){tp_inst._defaults.evnts.onClose.call($input[0],e,t,tp_inst)}}};for(i in overrides){if(overrides.hasOwnProperty(i)){fns[i]=opts[i]||null}}tp_inst._defaults=$.extend({},this._defaults,inlineSettings,opts,overrides,{evnts:fns,timepicker:tp_inst});tp_inst.amNames=$.map(tp_inst._defaults.amNames,function(e){return e.toUpperCase()});tp_inst.pmNames=$.map(tp_inst._defaults.pmNames,function(e){return e.toUpperCase()});tp_inst.support=detectSupport(tp_inst._defaults.timeFormat+(tp_inst._defaults.pickerTimeFormat?tp_inst._defaults.pickerTimeFormat:"")+(tp_inst._defaults.altTimeFormat?tp_inst._defaults.altTimeFormat:""));if(typeof tp_inst._defaults.controlType==="string"){if(tp_inst._defaults.controlType==="slider"&&typeof $.ui.slider==="undefined"){tp_inst._defaults.controlType="select"}tp_inst.control=tp_inst._controls[tp_inst._defaults.controlType]}else{tp_inst.control=tp_inst._defaults.controlType}var timezoneList=[-720,-660,-600,-570,-540,-480,-420,-360,-300,-270,-240,-210,-180,-120,-60,0,60,120,180,210,240,270,300,330,345,360,390,420,480,525,540,570,600,630,660,690,720,765,780,840];if(tp_inst._defaults.timezoneList!==null){timezoneList=tp_inst._defaults.timezoneList}var tzl=timezoneList.length,tzi=0,tzv=null;if(tzl>0&&typeof timezoneList[0]!=="object"){for(;tzitp_inst._defaults.hourMax?tp_inst._defaults.hourMax:tp_inst._defaults.hour;tp_inst.minute=tp_inst._defaults.minutetp_inst._defaults.minuteMax?tp_inst._defaults.minuteMax:tp_inst._defaults.minute;tp_inst.second=tp_inst._defaults.secondtp_inst._defaults.secondMax?tp_inst._defaults.secondMax:tp_inst._defaults.second;tp_inst.millisec=tp_inst._defaults.millisectp_inst._defaults.millisecMax?tp_inst._defaults.millisecMax:tp_inst._defaults.millisec;tp_inst.microsec=tp_inst._defaults.microsectp_inst._defaults.microsecMax?tp_inst._defaults.microsecMax:tp_inst._defaults.microsec;tp_inst.ampm="";tp_inst.$input=$input;if(tp_inst._defaults.altField){tp_inst.$altInput=$(tp_inst._defaults.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}if(tp_inst._defaults.maxDate===0||tp_inst._defaults.maxDateTime===0){tp_inst._defaults.maxDate=new Date}if(tp_inst._defaults.minDate!==undefined&&tp_inst._defaults.minDate instanceof Date){tp_inst._defaults.minDateTime=new Date(tp_inst._defaults.minDate.getTime())}if(tp_inst._defaults.minDateTime!==undefined&&tp_inst._defaults.minDateTime instanceof Date){tp_inst._defaults.minDate=new Date(tp_inst._defaults.minDateTime.getTime())}if(tp_inst._defaults.maxDate!==undefined&&tp_inst._defaults.maxDate instanceof Date){tp_inst._defaults.maxDateTime=new Date(tp_inst._defaults.maxDate.getTime())}if(tp_inst._defaults.maxDateTime!==undefined&&tp_inst._defaults.maxDateTime instanceof Date){tp_inst._defaults.maxDate=new Date(tp_inst._defaults.maxDateTime.getTime())}tp_inst.$input.bind("focus",function(){tp_inst._onFocus()});return tp_inst},_addTimePicker:function(e){var t=this.$altInput&&this._defaults.altFieldTimeOnly?this.$input.val()+" "+this.$altInput.val():this.$input.val();this.timeDefined=this._parseTime(t);this._limitMinMaxDateTime(e,false);this._injectTimePicker()},_parseTime:function(e,t){if(!this.inst){this.inst=$.datepicker._getInst(this.$input[0])}if(t||!this._defaults.timeOnly){var n=$.datepicker._get(this.inst,"dateFormat");try{var r=parseDateTimeInternal(n,this._defaults.timeFormat,e,$.datepicker._getFormatConfig(this.inst),this._defaults);if(!r.timeObj){return false}$.extend(this,r.timeObj)}catch(i){$.timepicker.log("Error parsing the date/time string: "+i+"\ndate/time string = "+e+"\ntimeFormat = "+this._defaults.timeFormat+"\ndateFormat = "+n);return false}return true}else{var s=$.datepicker.parseTime(this._defaults.timeFormat,e,this._defaults);if(!s){return false}$.extend(this,s);return true}},_injectTimePicker:function(){var e=this.inst.dpDiv,t=this.inst.settings,n=this,r="",i="",s=null,o={},u={},a=null,f=0,l=0;if(e.find("div.ui-timepicker-div").length===0&&t.showTimepicker){var c=' style="display:none;"',h='
'+'
"+t.timeText+"
"+'
";for(f=0,l=this.units.length;f"+t[r+"Text"]+""+'
";if(s&&t[r+"Grid"]>0){h+='
';if(r==="hour"){for(var p=t[r+"Min"];p<=o[r];p+=parseInt(t[r+"Grid"],10)){u[r]++;var d=$.datepicker.formatTime(this.support.ampm?"hht":"HH",{hour:p},t);h+='"}}else{for(var v=t[r+"Min"];v<=o[r];v+=parseInt(t[r+"Grid"],10)){u[r]++;h+='"}}h+="
'+d+"'+(v<10?"0":"")+v+"
"}h+="
"}var m=t.showTimezone!==null?t.showTimezone:this.support.timezone;h+='
"+t.timezoneText+"
";h+='
";h+="
";var g=$(h);if(t.timeOnly===true){g.prepend('
'+'
'+t.timeOnlyTitle+"
"+"
");e.find(".ui-datepicker-header, .ui-datepicker-calendar").hide()}for(f=0,l=n.units.length;f0){a=100*u[r]*t[r+"Grid"]/(o[r]-t[r+"Min"]);g.find(".ui_tpicker_"+r+" table").css({width:a+"%",marginLeft:t.isRTL?"0":a/(-2*u[r])+"%",marginRight:t.isRTL?a/(-2*u[r])+"%":"0",borderCollapse:"collapse"}).find("td").click(function(e){var t=$(this),i=t.html(),s=parseInt(i.replace(/[^0-9]/g),10),o=i.replace(/[^apm]/ig),u=t.data("for");if(u==="hour"){if(o.indexOf("p")!==-1&&s<12){s+=12}else{if(o.indexOf("a")!==-1&&s===12){s=0}}}n.control.value(n,n[u+"_slider"],r,s);n._onTimeChange();n._onSelectHandler()}).css({cursor:"pointer",width:100/u[r]+"%",textAlign:"center",overflow:"hidden"})}}this.timezone_select=g.find(".ui_tpicker_timezone").append("").find("select");$.fn.append.apply(this.timezone_select,$.map(t.timezoneList,function(e,t){return $("