View | Details | Raw Unified | Return to bug 11618
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery-ui-timepicker-addon.min.js (+5 lines)
Line 0 Link Here
1
/*! jQuery Timepicker Addon - v1.4.3 - 2013-11-30
2
* http://trentrichardson.com/examples/timepicker
3
* Copyright (c) 2013 Trent Richardson; Licensed MIT */
4
(function($){if($.ui.timepicker=$.ui.timepicker||{},!$.ui.timepicker.version){$.extend($.ui,{timepicker:{version:"1.4.3"}});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:!1},this._defaults={showButtonPanel:!0,timeOnly:!1,showHour:null,showMinute:null,showSecond:null,showMillisec:null,showMicrosec:null,showTimezone:null,showTime:!0,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:!0,separator:" ",altFieldTimeOnly:!0,altTimeFormat:null,altSeparator:null,altTimeSuffix:null,pickerTimeFormat:null,pickerTimeSuffix:null,showTimepicker:!0,timezoneList:null,addSliderAccess:!1,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","millisec","microsec"],support:{},control:null,setDefaults:function(e){return extendRemove(this._defaults,e||{}),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){return $.isFunction(tp_inst._defaults.evnts.beforeShow)?tp_inst._defaults.evnts.beforeShow.call($input[0],e,t,tp_inst):void 0},onChangeMonthYear:function(e,t,i){tp_inst._updateDateTime(i),$.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)&&tp_inst._defaults.evnts.onChangeMonthYear.call($input[0],e,t,i,tp_inst)},onClose:function(e,t){tp_inst.timeDefined===!0&&""!==$input.val()&&tp_inst._updateDateTime(t),$.isFunction(tp_inst._defaults.evnts.onClose)&&tp_inst._defaults.evnts.onClose.call($input[0],e,t,tp_inst)}};for(i in overrides)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:"")),"string"==typeof tp_inst._defaults.controlType?("slider"===tp_inst._defaults.controlType&&$.ui.slider===void 0&&(tp_inst._defaults.controlType="select"),tp_inst.control=tp_inst._controls[tp_inst._defaults.controlType]):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];null!==tp_inst._defaults.timezoneList&&(timezoneList=tp_inst._defaults.timezoneList);var tzl=timezoneList.length,tzi=0,tzv=null;if(tzl>0&&"object"!=typeof timezoneList[0])for(;tzl>tzi;tzi++)tzv=timezoneList[tzi],timezoneList[tzi]={value:tzv,label:$.timepicker.timezoneOffsetString(tzv,tp_inst.support.iso8601)};return tp_inst._defaults.timezoneList=timezoneList,tp_inst.timezone=null!==tp_inst._defaults.timezone?$.timepicker.timezoneOffsetNumber(tp_inst._defaults.timezone):-1*(new Date).getTimezoneOffset(),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._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._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._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._defaults.microsec>tp_inst._defaults.microsecMax?tp_inst._defaults.microsecMax:tp_inst._defaults.microsec,tp_inst.ampm="",tp_inst.$input=$input,tp_inst._defaults.altField&&(tp_inst.$altInput=$(tp_inst._defaults.altField).css({cursor:"pointer"}).focus(function(){$input.trigger("focus")})),(0===tp_inst._defaults.minDate||0===tp_inst._defaults.minDateTime)&&(tp_inst._defaults.minDate=new Date),(0===tp_inst._defaults.maxDate||0===tp_inst._defaults.maxDateTime)&&(tp_inst._defaults.maxDate=new Date),void 0!==tp_inst._defaults.minDate&&tp_inst._defaults.minDate instanceof Date&&(tp_inst._defaults.minDateTime=new Date(tp_inst._defaults.minDate.getTime())),void 0!==tp_inst._defaults.minDateTime&&tp_inst._defaults.minDateTime instanceof Date&&(tp_inst._defaults.minDate=new Date(tp_inst._defaults.minDateTime.getTime())),void 0!==tp_inst._defaults.maxDate&&tp_inst._defaults.maxDate instanceof Date&&(tp_inst._defaults.maxDateTime=new Date(tp_inst._defaults.maxDate.getTime())),void 0!==tp_inst._defaults.maxDateTime&&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()}),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,!1),this._injectTimePicker()},_parseTime:function(e,t){if(this.inst||(this.inst=$.datepicker._getInst(this.$input[0])),t||!this._defaults.timeOnly){var i=$.datepicker._get(this.inst,"dateFormat");try{var s=parseDateTimeInternal(i,this._defaults.timeFormat,e,$.datepicker._getFormatConfig(this.inst),this._defaults);if(!s.timeObj)return!1;$.extend(this,s.timeObj)}catch(a){return $.timepicker.log("Error parsing the date/time string: "+a+"\ndate/time string = "+e+"\ntimeFormat = "+this._defaults.timeFormat+"\ndateFormat = "+i),!1}return!0}var n=$.datepicker.parseTime(this._defaults.timeFormat,e,this._defaults);return n?($.extend(this,n),!0):!1},_injectTimePicker:function(){var e=this.inst.dpDiv,t=this.inst.settings,i=this,s="",a="",n=null,r={},l={},o=null,c=0,u=0;if(0===e.find("div.ui-timepicker-div").length&&t.showTimepicker){var m=' style="display:none;"',d='<div class="ui-timepicker-div'+(t.isRTL?" ui-timepicker-rtl":"")+'"><dl>'+'<dt class="ui_tpicker_time_label"'+(t.showTime?"":m)+">"+t.timeText+"</dt>"+'<dd class="ui_tpicker_time"'+(t.showTime?"":m)+"></dd>";for(c=0,u=this.units.length;u>c;c++){if(s=this.units[c],a=s.substr(0,1).toUpperCase()+s.substr(1),n=null!==t["show"+a]?t["show"+a]:this.support[s],r[s]=parseInt(t[s+"Max"]-(t[s+"Max"]-t[s+"Min"])%t["step"+a],10),l[s]=0,d+='<dt class="ui_tpicker_'+s+'_label"'+(n?"":m)+">"+t[s+"Text"]+"</dt>"+'<dd class="ui_tpicker_'+s+'"><div class="ui_tpicker_'+s+'_slider"'+(n?"":m)+"></div>",n&&t[s+"Grid"]>0){if(d+='<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>',"hour"===s)for(var p=t[s+"Min"];r[s]>=p;p+=parseInt(t[s+"Grid"],10)){l[s]++;var h=$.datepicker.formatTime(this.support.ampm?"hht":"HH",{hour:p},t);d+='<td data-for="'+s+'">'+h+"</td>"}else for(var _=t[s+"Min"];r[s]>=_;_+=parseInt(t[s+"Grid"],10))l[s]++,d+='<td data-for="'+s+'">'+(10>_?"0":"")+_+"</td>";d+="</tr></table></div>"}d+="</dd>"}var f=null!==t.showTimezone?t.showTimezone:this.support.timezone;d+='<dt class="ui_tpicker_timezone_label"'+(f?"":m)+">"+t.timezoneText+"</dt>",d+='<dd class="ui_tpicker_timezone" '+(f?"":m)+"></dd>",d+="</dl></div>";var g=$(d);for(t.timeOnly===!0&&(g.prepend('<div class="ui-widget-header ui-helper-clearfix ui-corner-all"><div class="ui-datepicker-title">'+t.timeOnlyTitle+"</div>"+"</div>"),e.find(".ui-datepicker-header, .ui-datepicker-calendar").hide()),c=0,u=i.units.length;u>c;c++)s=i.units[c],a=s.substr(0,1).toUpperCase()+s.substr(1),n=null!==t["show"+a]?t["show"+a]:this.support[s],i[s+"_slider"]=i.control.create(i,g.find(".ui_tpicker_"+s+"_slider"),s,i[s],t[s+"Min"],r[s],t["step"+a]),n&&t[s+"Grid"]>0&&(o=100*l[s]*t[s+"Grid"]/(r[s]-t[s+"Min"]),g.find(".ui_tpicker_"+s+" table").css({width:o+"%",marginLeft:t.isRTL?"0":o/(-2*l[s])+"%",marginRight:t.isRTL?o/(-2*l[s])+"%":"0",borderCollapse:"collapse"}).find("td").click(function(){var e=$(this),t=e.html(),a=parseInt(t.replace(/[^0-9]/g),10),n=t.replace(/[^apm]/gi),r=e.data("for");"hour"===r&&(-1!==n.indexOf("p")&&12>a?a+=12:-1!==n.indexOf("a")&&12===a&&(a=0)),i.control.value(i,i[r+"_slider"],s,a),i._onTimeChange(),i._onSelectHandler()}).css({cursor:"pointer",width:100/l[s]+"%",textAlign:"center",overflow:"hidden"}));if(this.timezone_select=g.find(".ui_tpicker_timezone").append("<select></select>").find("select"),$.fn.append.apply(this.timezone_select,$.map(t.timezoneList,function(e){return $("<option />").val("object"==typeof e?e.value:e).text("object"==typeof e?e.label:e)})),this.timezone!==void 0&&null!==this.timezone&&""!==this.timezone){var M=-1*new Date(this.inst.selectedYear,this.inst.selectedMonth,this.inst.selectedDay,12).getTimezoneOffset();M===this.timezone?selectLocalTimezone(i):this.timezone_select.val(this.timezone)}else this.hour!==void 0&&null!==this.hour&&""!==this.hour?this.timezone_select.val(t.timezone):selectLocalTimezone(i);this.timezone_select.change(function(){i._onTimeChange(),i._onSelectHandler()});var v=e.find(".ui-datepicker-buttonpane");if(v.length?v.before(g):e.append(g),this.$timeObj=g.find(".ui_tpicker_time"),null!==this.inst){var k=this.timeDefined;this._onTimeChange(),this.timeDefined=k}if(this._defaults.addSliderAccess){var T=this._defaults.sliderAccessArgs,D=this._defaults.isRTL;T.isRTL=D,setTimeout(function(){if(0===g.find(".ui-slider-access").length){g.find(".ui-slider:visible").sliderAccess(T);var e=g.find(".ui-slider-access:eq(0)").outerWidth(!0);e&&g.find("table:visible").each(function(){var t=$(this),i=t.outerWidth(),s=(""+t.css(D?"marginRight":"marginLeft")).replace("%",""),a=i-e,n=s*a/i+"%",r={width:a,marginRight:0,marginLeft:0};r[D?"marginRight":"marginLeft"]=n,t.css(r)})}},10)}i._limitMinMaxDateTime(this.inst,!0)}},_limitMinMaxDateTime:function(e,t){var i=this._defaults,s=new Date(e.selectedYear,e.selectedMonth,e.selectedDay);if(this._defaults.showTimepicker){if(null!==$.datepicker._get(e,"minDateTime")&&void 0!==$.datepicker._get(e,"minDateTime")&&s){var a=$.datepicker._get(e,"minDateTime"),n=new Date(a.getFullYear(),a.getMonth(),a.getDate(),0,0,0,0);(null===this.hourMinOriginal||null===this.minuteMinOriginal||null===this.secondMinOriginal||null===this.millisecMinOriginal||null===this.microsecMinOriginal)&&(this.hourMinOriginal=i.hourMin,this.minuteMinOriginal=i.minuteMin,this.secondMinOriginal=i.secondMin,this.millisecMinOriginal=i.millisecMin,this.microsecMinOriginal=i.microsecMin),e.settings.timeOnly||n.getTime()===s.getTime()?(this._defaults.hourMin=a.getHours(),this.hour<=this._defaults.hourMin?(this.hour=this._defaults.hourMin,this._defaults.minuteMin=a.getMinutes(),this.minute<=this._defaults.minuteMin?(this.minute=this._defaults.minuteMin,this._defaults.secondMin=a.getSeconds(),this.second<=this._defaults.secondMin?(this.second=this._defaults.secondMin,this._defaults.millisecMin=a.getMilliseconds(),this.millisec<=this._defaults.millisecMin?(this.millisec=this._defaults.millisecMin,this._defaults.microsecMin=a.getMicroseconds()):(this.microsec<this._defaults.microsecMin&&(this.microsec=this._defaults.microsecMin),this._defaults.microsecMin=this.microsecMinOriginal)):(this._defaults.millisecMin=this.millisecMinOriginal,this._defaults.microsecMin=this.microsecMinOriginal)):(this._defaults.secondMin=this.secondMinOriginal,this._defaults.millisecMin=this.millisecMinOriginal,this._defaults.microsecMin=this.microsecMinOriginal)):(this._defaults.minuteMin=this.minuteMinOriginal,this._defaults.secondMin=this.secondMinOriginal,this._defaults.millisecMin=this.millisecMinOriginal,this._defaults.microsecMin=this.microsecMinOriginal)):(this._defaults.hourMin=this.hourMinOriginal,this._defaults.minuteMin=this.minuteMinOriginal,this._defaults.secondMin=this.secondMinOriginal,this._defaults.millisecMin=this.millisecMinOriginal,this._defaults.microsecMin=this.microsecMinOriginal)}if(null!==$.datepicker._get(e,"maxDateTime")&&void 0!==$.datepicker._get(e,"maxDateTime")&&s){var r=$.datepicker._get(e,"maxDateTime"),l=new Date(r.getFullYear(),r.getMonth(),r.getDate(),0,0,0,0);(null===this.hourMaxOriginal||null===this.minuteMaxOriginal||null===this.secondMaxOriginal||null===this.millisecMaxOriginal)&&(this.hourMaxOriginal=i.hourMax,this.minuteMaxOriginal=i.minuteMax,this.secondMaxOriginal=i.secondMax,this.millisecMaxOriginal=i.millisecMax,this.microsecMaxOriginal=i.microsecMax),e.settings.timeOnly||l.getTime()===s.getTime()?(this._defaults.hourMax=r.getHours(),this.hour>=this._defaults.hourMax?(this.hour=this._defaults.hourMax,this._defaults.minuteMax=r.getMinutes(),this.minute>=this._defaults.minuteMax?(this.minute=this._defaults.minuteMax,this._defaults.secondMax=r.getSeconds(),this.second>=this._defaults.secondMax?(this.second=this._defaults.secondMax,this._defaults.millisecMax=r.getMilliseconds(),this.millisec>=this._defaults.millisecMax?(this.millisec=this._defaults.millisecMax,this._defaults.microsecMax=r.getMicroseconds()):(this.microsec>this._defaults.microsecMax&&(this.microsec=this._defaults.microsecMax),this._defaults.microsecMax=this.microsecMaxOriginal)):(this._defaults.millisecMax=this.millisecMaxOriginal,this._defaults.microsecMax=this.microsecMaxOriginal)):(this._defaults.secondMax=this.secondMaxOriginal,this._defaults.millisecMax=this.millisecMaxOriginal,this._defaults.microsecMax=this.microsecMaxOriginal)):(this._defaults.minuteMax=this.minuteMaxOriginal,this._defaults.secondMax=this.secondMaxOriginal,this._defaults.millisecMax=this.millisecMaxOriginal,this._defaults.microsecMax=this.microsecMaxOriginal)):(this._defaults.hourMax=this.hourMaxOriginal,this._defaults.minuteMax=this.minuteMaxOriginal,this._defaults.secondMax=this.secondMaxOriginal,this._defaults.millisecMax=this.millisecMaxOriginal,this._defaults.microsecMax=this.microsecMaxOriginal)}if(void 0!==t&&t===!0){var o=parseInt(this._defaults.hourMax-(this._defaults.hourMax-this._defaults.hourMin)%this._defaults.stepHour,10),c=parseInt(this._defaults.minuteMax-(this._defaults.minuteMax-this._defaults.minuteMin)%this._defaults.stepMinute,10),u=parseInt(this._defaults.secondMax-(this._defaults.secondMax-this._defaults.secondMin)%this._defaults.stepSecond,10),m=parseInt(this._defaults.millisecMax-(this._defaults.millisecMax-this._defaults.millisecMin)%this._defaults.stepMillisec,10),d=parseInt(this._defaults.microsecMax-(this._defaults.microsecMax-this._defaults.microsecMin)%this._defaults.stepMicrosec,10);this.hour_slider&&(this.control.options(this,this.hour_slider,"hour",{min:this._defaults.hourMin,max:o}),this.control.value(this,this.hour_slider,"hour",this.hour-this.hour%this._defaults.stepHour)),this.minute_slider&&(this.control.options(this,this.minute_slider,"minute",{min:this._defaults.minuteMin,max:c}),this.control.value(this,this.minute_slider,"minute",this.minute-this.minute%this._defaults.stepMinute)),this.second_slider&&(this.control.options(this,this.second_slider,"second",{min:this._defaults.secondMin,max:u}),this.control.value(this,this.second_slider,"second",this.second-this.second%this._defaults.stepSecond)),this.millisec_slider&&(this.control.options(this,this.millisec_slider,"millisec",{min:this._defaults.millisecMin,max:m}),this.control.value(this,this.millisec_slider,"millisec",this.millisec-this.millisec%this._defaults.stepMillisec)),this.microsec_slider&&(this.control.options(this,this.microsec_slider,"microsec",{min:this._defaults.microsecMin,max:d}),this.control.value(this,this.microsec_slider,"microsec",this.microsec-this.microsec%this._defaults.stepMicrosec))}}},_onTimeChange:function(){if(this._defaults.showTimepicker){var e=this.hour_slider?this.control.value(this,this.hour_slider,"hour"):!1,t=this.minute_slider?this.control.value(this,this.minute_slider,"minute"):!1,i=this.second_slider?this.control.value(this,this.second_slider,"second"):!1,s=this.millisec_slider?this.control.value(this,this.millisec_slider,"millisec"):!1,a=this.microsec_slider?this.control.value(this,this.microsec_slider,"microsec"):!1,n=this.timezone_select?this.timezone_select.val():!1,r=this._defaults,l=r.pickerTimeFormat||r.timeFormat,o=r.pickerTimeSuffix||r.timeSuffix;"object"==typeof e&&(e=!1),"object"==typeof t&&(t=!1),"object"==typeof i&&(i=!1),"object"==typeof s&&(s=!1),"object"==typeof a&&(a=!1),"object"==typeof n&&(n=!1),e!==!1&&(e=parseInt(e,10)),t!==!1&&(t=parseInt(t,10)),i!==!1&&(i=parseInt(i,10)),s!==!1&&(s=parseInt(s,10)),a!==!1&&(a=parseInt(a,10)),n!==!1&&(n=""+n);var c=r[12>e?"amNames":"pmNames"][0],u=e!==parseInt(this.hour,10)||t!==parseInt(this.minute,10)||i!==parseInt(this.second,10)||s!==parseInt(this.millisec,10)||a!==parseInt(this.microsec,10)||this.ampm.length>0&&12>e!=(-1!==$.inArray(this.ampm.toUpperCase(),this.amNames))||null!==this.timezone&&n!==""+this.timezone;u&&(e!==!1&&(this.hour=e),t!==!1&&(this.minute=t),i!==!1&&(this.second=i),s!==!1&&(this.millisec=s),a!==!1&&(this.microsec=a),n!==!1&&(this.timezone=n),this.inst||(this.inst=$.datepicker._getInst(this.$input[0])),this._limitMinMaxDateTime(this.inst,!0)),this.support.ampm&&(this.ampm=c),this.formattedTime=$.datepicker.formatTime(r.timeFormat,this,r),this.$timeObj&&(l===r.timeFormat?this.$timeObj.text(this.formattedTime+o):this.$timeObj.text($.datepicker.formatTime(l,this,r)+o)),this.timeDefined=!0,u&&(this._updateDateTime(),this.$input.focus())}},_onSelectHandler:function(){var e=this._defaults.onSelect||this.inst.settings.onSelect,t=this.$input?this.$input[0]:null;e&&t&&e.apply(t,[this.formattedDateTime,this])},_updateDateTime:function(e){e=this.inst||e;var t=e.currentYear>0?new Date(e.currentYear,e.currentMonth,e.currentDay):new Date(e.selectedYear,e.selectedMonth,e.selectedDay),i=$.datepicker._daylightSavingAdjust(t),s=$.datepicker._get(e,"dateFormat"),a=$.datepicker._getFormatConfig(e),n=null!==i&&this.timeDefined;this.formattedDate=$.datepicker.formatDate(s,null===i?new Date:i,a);var r=this.formattedDate;if(""===e.lastVal&&(e.currentYear=e.selectedYear,e.currentMonth=e.selectedMonth,e.currentDay=e.selectedDay),this._defaults.timeOnly===!0?r=this.formattedTime:this._defaults.timeOnly!==!0&&(this._defaults.alwaysSetTime||n)&&(r+=this._defaults.separator+this.formattedTime+this._defaults.timeSuffix),this.formattedDateTime=r,this._defaults.showTimepicker)if(this.$altInput&&this._defaults.timeOnly===!1&&this._defaults.altFieldTimeOnly===!0)this.$altInput.val(this.formattedTime),this.$input.val(this.formattedDate);else if(this.$altInput){this.$input.val(r);var l="",o=this._defaults.altSeparator?this._defaults.altSeparator:this._defaults.separator,c=this._defaults.altTimeSuffix?this._defaults.altTimeSuffix:this._defaults.timeSuffix;this._defaults.timeOnly||(l=this._defaults.altFormat?$.datepicker.formatDate(this._defaults.altFormat,null===i?new Date:i,a):this.formattedDate,l&&(l+=o)),l+=this._defaults.altTimeFormat?$.datepicker.formatTime(this._defaults.altTimeFormat,this,this._defaults)+c:this.formattedTime+c,this.$altInput.val(l)}else this.$input.val(r);else this.$input.val(this.formattedDate);this.$input.trigger("change")},_onFocus:function(){if(!this.$input.val()&&this._defaults.defaultValue){this.$input.val(this._defaults.defaultValue);var e=$.datepicker._getInst(this.$input.get(0)),t=$.datepicker._get(e,"timepicker");if(t&&t._defaults.timeOnly&&e.input.val()!==e.lastVal)try{$.datepicker._updateDatepicker(e)}catch(i){$.timepicker.log(i)}}},_controls:{slider:{create:function(e,t,i,s,a,n,r){var l=e._defaults.isRTL;return t.prop("slide",null).slider({orientation:"horizontal",value:l?-1*s:s,min:l?-1*n:a,max:l?-1*a:n,step:r,slide:function(t,s){e.control.value(e,$(this),i,l?-1*s.value:s.value),e._onTimeChange()},stop:function(){e._onSelectHandler()}})},options:function(e,t,i,s,a){if(e._defaults.isRTL){if("string"==typeof s)return"min"===s||"max"===s?void 0!==a?t.slider(s,-1*a):Math.abs(t.slider(s)):t.slider(s);var n=s.min,r=s.max;return s.min=s.max=null,void 0!==n&&(s.max=-1*n),void 0!==r&&(s.min=-1*r),t.slider(s)}return"string"==typeof s&&void 0!==a?t.slider(s,a):t.slider(s)},value:function(e,t,i,s){return e._defaults.isRTL?void 0!==s?t.slider("value",-1*s):Math.abs(t.slider("value")):void 0!==s?t.slider("value",s):t.slider("value")}},select:{create:function(e,t,i,s,a,n,r){for(var l='<select class="ui-timepicker-select" data-unit="'+i+'" data-min="'+a+'" data-max="'+n+'" data-step="'+r+'">',o=e._defaults.pickerTimeFormat||e._defaults.timeFormat,c=a;n>=c;c+=r)l+='<option value="'+c+'"'+(c===s?" selected":"")+">",l+="hour"===i?$.datepicker.formatTime($.trim(o.replace(/[^ht ]/gi,"")),{hour:c},e._defaults):"millisec"===i||"microsec"===i||c>=10?c:"0"+(""+c),l+="</option>";return l+="</select>",t.children("select").remove(),$(l).appendTo(t).change(function(){e._onTimeChange(),e._onSelectHandler()}),t},options:function(e,t,i,s,a){var n={},r=t.children("select");if("string"==typeof s){if(void 0===a)return r.data(s);n[s]=a}else n=s;return e.control.create(e,t,r.data("unit"),r.val(),n.min||r.data("min"),n.max||r.data("max"),n.step||r.data("step"))},value:function(e,t,i,s){var a=t.children("select");return void 0!==s?a.val(s):a.val()}}}}),$.fn.extend({timepicker:function(e){e=e||{};var t=Array.prototype.slice.call(arguments);return"object"==typeof e&&(t[0]=$.extend(e,{timeOnly:!0})),$(this).each(function(){$.fn.datetimepicker.apply($(this),t)})},datetimepicker:function(e){e=e||{};var t=arguments;return"string"==typeof e?"getDate"===e?$.fn.datepicker.apply($(this[0]),t):this.each(function(){var e=$(this);e.datepicker.apply(e,t)}):this.each(function(){var t=$(this);t.datepicker($.timepicker._newInst(t,e)._defaults)})}}),$.datepicker.parseDateTime=function(e,t,i,s,a){var n=parseDateTimeInternal(e,t,i,s,a);if(n.timeObj){var r=n.timeObj;n.date.setHours(r.hour,r.minute,r.second,r.millisec),n.date.setMicroseconds(r.microsec)}return n.date},$.datepicker.parseTime=function(e,t,i){var s=extendRemove(extendRemove({},$.timepicker._defaults),i||{});-1!==e.replace(/\'.*?\'/g,"").indexOf("Z");var a=function(e,t,i){var s,a=function(e,t){var i=[];return e&&$.merge(i,e),t&&$.merge(i,t),i=$.map(i,function(e){return e.replace(/[.*+?|()\[\]{}\\]/g,"\\$&")}),"("+i.join("|")+")?"},n=function(e){var t=e.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|c{1}|t{1,2}|z|'.*?')/g),i={h:-1,m:-1,s:-1,l:-1,c:-1,t:-1,z:-1};if(t)for(var s=0;t.length>s;s++)-1===i[(""+t[s]).charAt(0)]&&(i[(""+t[s]).charAt(0)]=s+1);return i},r="^"+(""+e).replace(/([hH]{1,2}|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g,function(e){var t=e.length;switch(e.charAt(0).toLowerCase()){case"h":return 1===t?"(\\d?\\d)":"(\\d{"+t+"})";case"m":return 1===t?"(\\d?\\d)":"(\\d{"+t+"})";case"s":return 1===t?"(\\d?\\d)":"(\\d{"+t+"})";case"l":return"(\\d?\\d?\\d)";case"c":return"(\\d?\\d?\\d)";case"z":return"(z|[-+]\\d\\d:?\\d\\d|\\S+)?";case"t":return a(i.amNames,i.pmNames);default:return"("+e.replace(/\'/g,"").replace(/(\.|\$|\^|\\|\/|\(|\)|\[|\]|\?|\+|\*)/g,function(e){return"\\"+e})+")?"}}).replace(/\s/g,"\\s?")+i.timeSuffix+"$",l=n(e),o="";s=t.match(RegExp(r,"i"));var c={hour:0,minute:0,second:0,millisec:0,microsec:0};return s?(-1!==l.t&&(void 0===s[l.t]||0===s[l.t].length?(o="",c.ampm=""):(o=-1!==$.inArray(s[l.t].toUpperCase(),i.amNames)?"AM":"PM",c.ampm=i["AM"===o?"amNames":"pmNames"][0])),-1!==l.h&&(c.hour="AM"===o&&"12"===s[l.h]?0:"PM"===o&&"12"!==s[l.h]?parseInt(s[l.h],10)+12:Number(s[l.h])),-1!==l.m&&(c.minute=Number(s[l.m])),-1!==l.s&&(c.second=Number(s[l.s])),-1!==l.l&&(c.millisec=Number(s[l.l])),-1!==l.c&&(c.microsec=Number(s[l.c])),-1!==l.z&&void 0!==s[l.z]&&(c.timezone=$.timepicker.timezoneOffsetNumber(s[l.z])),c):!1},n=function(e,t,i){try{var s=new Date("2012-01-01 "+t);if(isNaN(s.getTime())&&(s=new Date("2012-01-01T"+t),isNaN(s.getTime())&&(s=new Date("01/01/2012 "+t),isNaN(s.getTime()))))throw"Unable to parse time with native Date: "+t;return{hour:s.getHours(),minute:s.getMinutes(),second:s.getSeconds(),millisec:s.getMilliseconds(),microsec:s.getMicroseconds(),timezone:-1*s.getTimezoneOffset()}}catch(n){try{return a(e,t,i)}catch(r){$.timepicker.log("Unable to parse \ntimeString: "+t+"\ntimeFormat: "+e)}}return!1};return"function"==typeof s.parse?s.parse(e,t,s):"loose"===s.parse?n(e,t,s):a(e,t,s)},$.datepicker.formatTime=function(e,t,i){i=i||{},i=$.extend({},$.timepicker._defaults,i),t=$.extend({hour:0,minute:0,second:0,millisec:0,microsec:0,timezone:null},t);var s=e,a=i.amNames[0],n=parseInt(t.hour,10);return n>11&&(a=i.pmNames[0]),s=s.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g,function(e){switch(e){case"HH":return("0"+n).slice(-2);case"H":return n;case"hh":return("0"+convert24to12(n)).slice(-2);case"h":return convert24to12(n);case"mm":return("0"+t.minute).slice(-2);case"m":return t.minute;case"ss":return("0"+t.second).slice(-2);case"s":return t.second;case"l":return("00"+t.millisec).slice(-3);case"c":return("00"+t.microsec).slice(-3);case"z":return $.timepicker.timezoneOffsetString(null===t.timezone?i.timezone:t.timezone,!1);case"Z":return $.timepicker.timezoneOffsetString(null===t.timezone?i.timezone:t.timezone,!0);case"T":return a.charAt(0).toUpperCase();case"TT":return a.toUpperCase();case"t":return a.charAt(0).toLowerCase();case"tt":return a.toLowerCase();default:return e.replace(/'/g,"")}})},$.datepicker._base_selectDate=$.datepicker._selectDate,$.datepicker._selectDate=function(e,t){var i=this._getInst($(e)[0]),s=this._get(i,"timepicker");s?(s._limitMinMaxDateTime(i,!0),i.inline=i.stay_open=!0,this._base_selectDate(e,t),i.inline=i.stay_open=!1,this._notifyChange(i),this._updateDatepicker(i)):this._base_selectDate(e,t)},$.datepicker._base_updateDatepicker=$.datepicker._updateDatepicker,$.datepicker._updateDatepicker=function(e){var t=e.input[0];if(!($.datepicker._curInst&&$.datepicker._curInst!==e&&$.datepicker._datepickerShowing&&$.datepicker._lastInput!==t||"boolean"==typeof e.stay_open&&e.stay_open!==!1)){this._base_updateDatepicker(e);var i=this._get(e,"timepicker");i&&i._addTimePicker(e)}},$.datepicker._base_doKeyPress=$.datepicker._doKeyPress,$.datepicker._doKeyPress=function(e){var t=$.datepicker._getInst(e.target),i=$.datepicker._get(t,"timepicker");if(i&&$.datepicker._get(t,"constrainInput")){var s=i.support.ampm,a=null!==i._defaults.showTimezone?i._defaults.showTimezone:i.support.timezone,n=$.datepicker._possibleChars($.datepicker._get(t,"dateFormat")),r=(""+i._defaults.timeFormat).replace(/[hms]/g,"").replace(/TT/g,s?"APM":"").replace(/Tt/g,s?"AaPpMm":"").replace(/tT/g,s?"AaPpMm":"").replace(/T/g,s?"AP":"").replace(/tt/g,s?"apm":"").replace(/t/g,s?"ap":"")+" "+i._defaults.separator+i._defaults.timeSuffix+(a?i._defaults.timezoneList.join(""):"")+i._defaults.amNames.join("")+i._defaults.pmNames.join("")+n,l=String.fromCharCode(void 0===e.charCode?e.keyCode:e.charCode);return e.ctrlKey||" ">l||!n||r.indexOf(l)>-1}return $.datepicker._base_doKeyPress(e)},$.datepicker._base_updateAlternate=$.datepicker._updateAlternate,$.datepicker._updateAlternate=function(e){var t=this._get(e,"timepicker");if(t){var i=t._defaults.altField;if(i){var s=(t._defaults.altFormat||t._defaults.dateFormat,this._getDate(e)),a=$.datepicker._getFormatConfig(e),n="",r=t._defaults.altSeparator?t._defaults.altSeparator:t._defaults.separator,l=t._defaults.altTimeSuffix?t._defaults.altTimeSuffix:t._defaults.timeSuffix,o=null!==t._defaults.altTimeFormat?t._defaults.altTimeFormat:t._defaults.timeFormat;n+=$.datepicker.formatTime(o,t,t._defaults)+l,t._defaults.timeOnly||t._defaults.altFieldTimeOnly||null===s||(n=t._defaults.altFormat?$.datepicker.formatDate(t._defaults.altFormat,s,a)+r+n:t.formattedDate+r+n),$(i).val(n)}}else $.datepicker._base_updateAlternate(e)},$.datepicker._base_doKeyUp=$.datepicker._doKeyUp,$.datepicker._doKeyUp=function(e){var t=$.datepicker._getInst(e.target),i=$.datepicker._get(t,"timepicker");if(i&&i._defaults.timeOnly&&t.input.val()!==t.lastVal)try{$.datepicker._updateDatepicker(t)}catch(s){$.timepicker.log(s)}return $.datepicker._base_doKeyUp(e)},$.datepicker._base_gotoToday=$.datepicker._gotoToday,$.datepicker._gotoToday=function(e){var t=this._getInst($(e)[0]),i=t.dpDiv;this._base_gotoToday(e);var s=this._get(t,"timepicker");selectLocalTimezone(s);var a=new Date;this._setTime(t,a),$(".ui-datepicker-today",i).click()},$.datepicker._disableTimepickerDatepicker=function(e){var t=this._getInst(e);if(t){var i=this._get(t,"timepicker");$(e).datepicker("getDate"),i&&(t.settings.showTimepicker=!1,i._defaults.showTimepicker=!1,i._updateDateTime(t))}},$.datepicker._enableTimepickerDatepicker=function(e){var t=this._getInst(e);if(t){var i=this._get(t,"timepicker");$(e).datepicker("getDate"),i&&(t.settings.showTimepicker=!0,i._defaults.showTimepicker=!0,i._addTimePicker(t),i._updateDateTime(t))}},$.datepicker._setTime=function(e,t){var i=this._get(e,"timepicker");if(i){var s=i._defaults;i.hour=t?t.getHours():s.hour,i.minute=t?t.getMinutes():s.minute,i.second=t?t.getSeconds():s.second,i.millisec=t?t.getMilliseconds():s.millisec,i.microsec=t?t.getMicroseconds():s.microsec,i._limitMinMaxDateTime(e,!0),i._onTimeChange(),i._updateDateTime(e)}},$.datepicker._setTimeDatepicker=function(e,t,i){var s=this._getInst(e);if(s){var a=this._get(s,"timepicker");if(a){this._setDateFromField(s);var n;t&&("string"==typeof t?(a._parseTime(t,i),n=new Date,n.setHours(a.hour,a.minute,a.second,a.millisec),n.setMicroseconds(a.microsec)):(n=new Date(t.getTime()),n.setMicroseconds(t.getMicroseconds())),"Invalid Date"==""+n&&(n=void 0),this._setTime(s,n))}}},$.datepicker._base_setDateDatepicker=$.datepicker._setDateDatepicker,$.datepicker._setDateDatepicker=function(e,t){var i=this._getInst(e);if(i){"string"==typeof t&&(t=new Date(t),t.getTime()||$.timepicker.log("Error creating Date object from string."));var s,a=this._get(i,"timepicker");t instanceof Date?(s=new Date(t.getTime()),s.setMicroseconds(t.getMicroseconds())):s=t,a&&s&&(a.support.timezone||null!==a._defaults.timezone||(a.timezone=-1*s.getTimezoneOffset()),t=$.timepicker.timezoneAdjust(t,a.timezone),s=$.timepicker.timezoneAdjust(s,a.timezone)),this._updateDatepicker(i),this._base_setDateDatepicker.apply(this,arguments),this._setTimeDatepicker(e,s,!0)}},$.datepicker._base_getDateDatepicker=$.datepicker._getDateDatepicker,$.datepicker._getDateDatepicker=function(e,t){var i=this._getInst(e);if(i){var s=this._get(i,"timepicker");if(s){void 0===i.lastVal&&this._setDateFromField(i,t);var a=this._getDate(i);return a&&s._parseTime($(e).val(),s.timeOnly)&&(a.setHours(s.hour,s.minute,s.second,s.millisec),a.setMicroseconds(s.microsec),null!=s.timezone&&(s.support.timezone||null!==s._defaults.timezone||(s.timezone=-1*a.getTimezoneOffset()),a=$.timepicker.timezoneAdjust(a,s.timezone))),a
5
}return this._base_getDateDatepicker(e,t)}},$.datepicker._base_parseDate=$.datepicker.parseDate,$.datepicker.parseDate=function(e,t,i){var s;try{s=this._base_parseDate(e,t,i)}catch(a){if(!(a.indexOf(":")>=0))throw a;s=this._base_parseDate(e,t.substring(0,t.length-(a.length-a.indexOf(":")-2)),i),$.timepicker.log("Error parsing the date string: "+a+"\ndate string = "+t+"\ndate format = "+e)}return s},$.datepicker._base_formatDate=$.datepicker._formatDate,$.datepicker._formatDate=function(e){var t=this._get(e,"timepicker");return t?(t._updateDateTime(e),t.$input.val()):this._base_formatDate(e)},$.datepicker._base_optionDatepicker=$.datepicker._optionDatepicker,$.datepicker._optionDatepicker=function(e,t,i){var s,a=this._getInst(e);if(!a)return null;var n=this._get(a,"timepicker");if(n){var r,l=null,o=null,c=null,u=n._defaults.evnts,m={};if("string"==typeof t){if("minDate"===t||"minDateTime"===t)l=i;else if("maxDate"===t||"maxDateTime"===t)o=i;else if("onSelect"===t)c=i;else if(u.hasOwnProperty(t)){if(i===void 0)return u[t];m[t]=i,s={}}}else if("object"==typeof t){t.minDate?l=t.minDate:t.minDateTime?l=t.minDateTime:t.maxDate?o=t.maxDate:t.maxDateTime&&(o=t.maxDateTime);for(r in u)u.hasOwnProperty(r)&&t[r]&&(m[r]=t[r])}for(r in m)m.hasOwnProperty(r)&&(u[r]=m[r],s||(s=$.extend({},t)),delete s[r]);if(s&&isEmptyObject(s))return;l?(l=0===l?new Date:new Date(l),n._defaults.minDate=l,n._defaults.minDateTime=l):o?(o=0===o?new Date:new Date(o),n._defaults.maxDate=o,n._defaults.maxDateTime=o):c&&(n._defaults.onSelect=c)}return void 0===i?this._base_optionDatepicker.call($.datepicker,e,t):this._base_optionDatepicker.call($.datepicker,e,s||t,i)};var isEmptyObject=function(e){var t;for(t in e)if(e.hasOwnProperty(t))return!1;return!0},extendRemove=function(e,t){$.extend(e,t);for(var i in t)(null===t[i]||void 0===t[i])&&(e[i]=t[i]);return e},detectSupport=function(e){var t=e.replace(/'.*?'/g,"").toLowerCase(),i=function(e,t){return-1!==e.indexOf(t)?!0:!1};return{hour:i(t,"h"),minute:i(t,"m"),second:i(t,"s"),millisec:i(t,"l"),microsec:i(t,"c"),timezone:i(t,"z"),ampm:i(t,"t")&&i(e,"h"),iso8601:i(e,"Z")}},convert24to12=function(e){return e%=12,0===e&&(e=12),e+""},computeEffectiveSetting=function(e,t){return e&&e[t]?e[t]:$.timepicker._defaults[t]},splitDateTime=function(e,t){var i=computeEffectiveSetting(t,"separator"),s=computeEffectiveSetting(t,"timeFormat"),a=s.split(i),n=a.length,r=e.split(i),l=r.length;return l>1?{dateString:r.splice(0,l-n).join(i),timeString:r.splice(0,n).join(i)}:{dateString:e,timeString:""}},parseDateTimeInternal=function(e,t,i,s,a){var n,r,l;if(r=splitDateTime(i,a),n=$.datepicker._base_parseDate(e,r.dateString,s),""===r.timeString)return{date:n};if(l=$.datepicker.parseTime(t,r.timeString,a),!l)throw"Wrong time format";return{date:n,timeObj:l}},selectLocalTimezone=function(e,t){if(e&&e.timezone_select){var i=t||new Date;e.timezone_select.val(-i.getTimezoneOffset())}};$.timepicker=new Timepicker,$.timepicker.timezoneOffsetString=function(e,t){if(isNaN(e)||e>840||-720>e)return e;var i=e,s=i%60,a=(i-s)/60,n=t?":":"",r=(i>=0?"+":"-")+("0"+Math.abs(a)).slice(-2)+n+("0"+Math.abs(s)).slice(-2);return"+00:00"===r?"Z":r},$.timepicker.timezoneOffsetNumber=function(e){var t=(""+e).replace(":","");return"Z"===t.toUpperCase()?0:/^(\-|\+)\d{4}$/.test(t)?("-"===t.substr(0,1)?-1:1)*(60*parseInt(t.substr(1,2),10)+parseInt(t.substr(3,2),10)):e},$.timepicker.timezoneAdjust=function(e,t){var i=$.timepicker.timezoneOffsetNumber(t);return isNaN(i)||e.setMinutes(e.getMinutes()+-e.getTimezoneOffset()-i),e},$.timepicker.timeRange=function(e,t,i){return $.timepicker.handleRange("timepicker",e,t,i)},$.timepicker.datetimeRange=function(e,t,i){$.timepicker.handleRange("datetimepicker",e,t,i)},$.timepicker.dateRange=function(e,t,i){$.timepicker.handleRange("datepicker",e,t,i)},$.timepicker.handleRange=function(e,t,i,s){function a(a,n){var r=t[e]("getDate"),l=i[e]("getDate"),o=a[e]("getDate");if(null!==r){var c=new Date(r.getTime()),u=new Date(r.getTime());c.setMilliseconds(c.getMilliseconds()+s.minInterval),u.setMilliseconds(u.getMilliseconds()+s.maxInterval),s.minInterval>0&&c>l?i[e]("setDate",c):s.maxInterval>0&&l>u?i[e]("setDate",u):r>l&&n[e]("setDate",o)}}function n(t,i,a){if(t.val()){var n=t[e].call(t,"getDate");null!==n&&s.minInterval>0&&("minDate"===a&&n.setMilliseconds(n.getMilliseconds()+s.minInterval),"maxDate"===a&&n.setMilliseconds(n.getMilliseconds()-s.minInterval)),n.getTime&&i[e].call(i,"option",a,n)}}return s=$.extend({},{minInterval:0,maxInterval:0,start:{},end:{}},s),$.fn[e].call(t,$.extend({onClose:function(){a($(this),i)},onSelect:function(){n($(this),i,"minDate")}},s,s.start)),$.fn[e].call(i,$.extend({onClose:function(){a($(this),t)},onSelect:function(){n($(this),t,"maxDate")}},s,s.end)),a(t,i),n(t,i,"minDate"),n(i,t,"maxDate"),$([t.get(0),i.get(0)])},$.timepicker.log=function(e){window.console&&window.console.log(e)},$.timepicker._util={_extendRemove:extendRemove,_isEmptyObject:isEmptyObject,_convert24to12:convert24to12,_detectSupport:detectSupport,_selectLocalTimezone:selectLocalTimezone,_computeEffectiveSetting:computeEffectiveSetting,_splitDateTime:splitDateTime,_parseDateTimeInternal:parseDateTimeInternal},Date.prototype.getMicroseconds||(Date.prototype.microseconds=0,Date.prototype.getMicroseconds=function(){return this.microseconds},Date.prototype.setMicroseconds=function(e){return this.setMilliseconds(this.getMilliseconds()+Math.floor(e/1e3)),this.microseconds=e%1e3,this}),$.timepicker.version="1.4.3"}})(jQuery);
(-)a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css (+5 lines)
Lines 2379-2384 div.authorizedheading { Link Here
2379
.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
2379
.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
2380
.ui-timepicker-div td { font-size: 90%; }
2380
.ui-timepicker-div td { font-size: 90%; }
2381
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
2381
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
2382
.ui_tpicker_second,
2383
.ui_tpicker_millisec,
2384
.ui_tpicker_microsec {
2385
    display: none;
2386
}
2382
2387
2383
/* jQuery UI Accordion */
2388
/* jQuery UI Accordion */
2384
.ui-accordion-header,
2389
.ui-accordion-header,
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/timepicker.inc (+26 lines)
Line 0 Link Here
1
<script type="text/javascript">
2
    //<![CDATA[
3
4
        /* Localization of the timepicker plugin */
5
        jQuery(function($){
6
            $.timepicker.regional[''] = {
7
                currentText: _("Now"),
8
                closeText: _("Done"),
9
                amNames: [_("AM"), _("A")],
10
                pmNames: [_("PM"), _("P")],
11
                timeSuffix: "",
12
                timeOnlyTitle: _("Choose time"),
13
                timeText: _("Time"),
14
                hourText: _("Hour"),
15
                minuteText: _("Minute"),
16
                secondText: _("Second"),
17
                millisecText: _("Millisecond"),
18
                microsecText: _("Microsecond"),
19
                timezoneText: _("Time zone"),
20
                [% IF ( bidi ) %] isRTL: true [% ELSE %] isRTL: false [% END %]
21
            };
22
            $.timepicker.setDefaults($.timepicker.regional['']);
23
        });
24
25
    //]]>
26
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery-ui-timepicker-addon.js (-1530 lines)
Lines 1-1530 Link Here
1
/*
2
* jQuery timepicker addon
3
* By: Trent Richardson [http://trentrichardson.com]
4
* Version 1.0.1
5
* Last Modified: 07/01/2012
6
*
7
* Copyright 2012 Trent Richardson
8
* You may use this project under MIT or GPL licenses.
9
* http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
10
* http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
11
*
12
* HERES THE CSS:
13
* .ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
14
* .ui-timepicker-div dl { text-align: left; }
15
* .ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
16
* .ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
17
* .ui-timepicker-div td { font-size: 90%; }
18
* .ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
19
*/
20
21
/*jslint evil: true, maxlen: 300, white: false, undef: false, nomen: false, onevar: false */
22
23
(function($) {
24
25
// Prevent "Uncaught RangeError: Maximum call stack size exceeded"
26
$.ui.timepicker = $.ui.timepicker || {};
27
if ($.ui.timepicker.version) {
28
    return;
29
}
30
31
$.extend($.ui, { timepicker: { version: "1.0.1" } });
32
33
/* Time picker manager.
34
   Use the singleton instance of this class, $.timepicker, to interact with the time picker.
35
   Settings for (groups of) time pickers are maintained in an instance object,
36
   allowing multiple different settings on the same page. */
37
38
function Timepicker() {
39
    this.regional = []; // Available regional settings, indexed by language code
40
    this.regional[''] = { // Default regional settings
41
        currentText: 'Now',
42
        closeText: 'Done',
43
        ampm: false,
44
        amNames: ['AM', 'A'],
45
        pmNames: ['PM', 'P'],
46
        timeFormat: 'hh:mm tt',
47
        timeSuffix: '',
48
        timeOnlyTitle: 'Choose Time',
49
        timeText: 'Time',
50
        hourText: 'Hour',
51
        minuteText: 'Minute',
52
        secondText: 'Second',
53
        millisecText: 'Millisecond',
54
        timezoneText: 'Time Zone'
55
    };
56
    this._defaults = { // Global defaults for all the datetime picker instances
57
        showButtonPanel: true,
58
        timeOnly: false,
59
        showHour: true,
60
        showMinute: true,
61
        showSecond: false,
62
        showMillisec: false,
63
        showTimezone: false,
64
        showTime: true,
65
        stepHour: 1,
66
        stepMinute: 1,
67
        stepSecond: 1,
68
        stepMillisec: 1,
69
        hour: 0,
70
        minute: 0,
71
        second: 0,
72
        millisec: 0,
73
        timezone: null,
74
        useLocalTimezone: false,
75
        defaultTimezone: "+0000",
76
        hourMin: 0,
77
        minuteMin: 0,
78
        secondMin: 0,
79
        millisecMin: 0,
80
        hourMax: 23,
81
        minuteMax: 59,
82
        secondMax: 59,
83
        millisecMax: 999,
84
        minDateTime: null,
85
        maxDateTime: null,
86
        onSelect: null,
87
        hourGrid: 0,
88
        minuteGrid: 0,
89
        secondGrid: 0,
90
        millisecGrid: 0,
91
        alwaysSetTime: true,
92
        separator: ' ',
93
        altFieldTimeOnly: true,
94
        showTimepicker: true,
95
        timezoneIso8601: false,
96
        timezoneList: null,
97
        addSliderAccess: false,
98
        sliderAccessArgs: null
99
    };
100
    $.extend(this._defaults, this.regional['']);
101
}
102
103
$.extend(Timepicker.prototype, {
104
    $input: null,
105
    $altInput: null,
106
    $timeObj: null,
107
    inst: null,
108
    hour_slider: null,
109
    minute_slider: null,
110
    second_slider: null,
111
    millisec_slider: null,
112
    timezone_select: null,
113
    hour: 0,
114
    minute: 0,
115
    second: 0,
116
    millisec: 0,
117
    timezone: null,
118
    defaultTimezone: "+0000",
119
    hourMinOriginal: null,
120
    minuteMinOriginal: null,
121
    secondMinOriginal: null,
122
    millisecMinOriginal: null,
123
    hourMaxOriginal: null,
124
    minuteMaxOriginal: null,
125
    secondMaxOriginal: null,
126
    millisecMaxOriginal: null,
127
    ampm: '',
128
    formattedDate: '',
129
    formattedTime: '',
130
    formattedDateTime: '',
131
    timezoneList: null,
132
133
    /* Override the default settings for all instances of the time picker.
134
       @param  settings  object - the new settings to use as defaults (anonymous object)
135
       @return the manager object */
136
    setDefaults: function(settings) {
137
        extendRemove(this._defaults, settings || {});
138
        return this;
139
    },
140
141
    //########################################################################
142
    // Create a new Timepicker instance
143
    //########################################################################
144
    _newInst: function($input, o) {
145
        var tp_inst = new Timepicker(),
146
            inlineSettings = {};
147
148
        for (var attrName in this._defaults) {
149
            var attrValue = $input.attr('time:' + attrName);
150
            if (attrValue) {
151
                try {
152
                    inlineSettings[attrName] = eval(attrValue);
153
                } catch (err) {
154
                    inlineSettings[attrName] = attrValue;
155
                }
156
            }
157
        }
158
        tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, o, {
159
            beforeShow: function(input, dp_inst) {
160
                if ($.isFunction(o.beforeShow)) {
161
                    return o.beforeShow(input, dp_inst, tp_inst);
162
                }
163
            },
164
            onChangeMonthYear: function(year, month, dp_inst) {
165
                // Update the time as well : this prevents the time from disappearing from the $input field.
166
                tp_inst._updateDateTime(dp_inst);
167
                if ($.isFunction(o.onChangeMonthYear)) {
168
                    o.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst);
169
                }
170
            },
171
            onClose: function(dateText, dp_inst) {
172
                if (tp_inst.timeDefined === true && $input.val() !== '') {
173
                    tp_inst._updateDateTime(dp_inst);
174
                }
175
                if ($.isFunction(o.onClose)) {
176
                    o.onClose.call($input[0], dateText, dp_inst, tp_inst);
177
                }
178
            },
179
            timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
180
        });
181
        tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) { return val.toUpperCase(); });
182
        tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) { return val.toUpperCase(); });
183
184
        if (tp_inst._defaults.timezoneList === null) {
185
            var timezoneList = [];
186
            for (var i = -11; i <= 12; i++) {
187
                timezoneList.push((i >= 0 ? '+' : '-') + ('0' + Math.abs(i).toString()).slice(-2) + '00');
188
            }
189
            if (tp_inst._defaults.timezoneIso8601) {
190
                timezoneList = $.map(timezoneList, function(val) {
191
                    return val == '+0000' ? 'Z' : (val.substring(0, 3) + ':' + val.substring(3));
192
                });
193
            }
194
            tp_inst._defaults.timezoneList = timezoneList;
195
        }
196
197
        tp_inst.timezone = tp_inst._defaults.timezone;
198
        tp_inst.hour = tp_inst._defaults.hour;
199
        tp_inst.minute = tp_inst._defaults.minute;
200
        tp_inst.second = tp_inst._defaults.second;
201
        tp_inst.millisec = tp_inst._defaults.millisec;
202
        tp_inst.ampm = '';
203
        tp_inst.$input = $input;
204
205
        if (o.altField) {
206
            tp_inst.$altInput = $(o.altField)
207
                .css({ cursor: 'pointer' })
208
                .focus(function(){ $input.trigger("focus"); });
209
        }
210
211
        if(tp_inst._defaults.minDate===0 || tp_inst._defaults.minDateTime===0)
212
        {
213
            tp_inst._defaults.minDate=new Date();
214
        }
215
        if(tp_inst._defaults.maxDate===0 || tp_inst._defaults.maxDateTime===0)
216
        {
217
            tp_inst._defaults.maxDate=new Date();
218
        }
219
220
        // datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime..
221
        if(tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date) {
222
            tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime());
223
        }
224
        if(tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date) {
225
            tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime());
226
        }
227
        if(tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date) {
228
            tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime());
229
        }
230
        if(tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date) {
231
            tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime());
232
        }
233
        return tp_inst;
234
    },
235
236
    //########################################################################
237
    // add our sliders to the calendar
238
    //########################################################################
239
    _addTimePicker: function(dp_inst) {
240
        var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ?
241
                this.$input.val() + ' ' + this.$altInput.val() :
242
                this.$input.val();
243
244
        this.timeDefined = this._parseTime(currDT);
245
        this._limitMinMaxDateTime(dp_inst, false);
246
        this._injectTimePicker();
247
    },
248
249
    //########################################################################
250
    // parse the time string from input value or _setTime
251
    //########################################################################
252
    _parseTime: function(timeString, withDate) {
253
        if (!this.inst) {
254
            this.inst = $.datepicker._getInst(this.$input[0]);
255
        }
256
257
        if (withDate || !this._defaults.timeOnly)
258
        {
259
            var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
260
            try {
261
                var parseRes = parseDateTimeInternal(dp_dateFormat, this._defaults.timeFormat, timeString, $.datepicker._getFormatConfig(this.inst), this._defaults);
262
                if (!parseRes.timeObj) { return false; }
263
                $.extend(this, parseRes.timeObj);
264
            } catch (err)
265
            {
266
                return false;
267
            }
268
            return true;
269
        }
270
        else
271
        {
272
            var timeObj = $.datepicker.parseTime(this._defaults.timeFormat, timeString, this._defaults);
273
            if(!timeObj) { return false; }
274
            $.extend(this, timeObj);
275
            return true;
276
        }
277
    },
278
279
    //########################################################################
280
    // generate and inject html for timepicker into ui datepicker
281
    //########################################################################
282
    _injectTimePicker: function() {
283
        var $dp = this.inst.dpDiv,
284
            o = this._defaults,
285
            tp_inst = this,
286
            // Added by Peter Medeiros:
287
            // - Figure out what the hour/minute/second max should be based on the step values.
288
            // - Example: if stepMinute is 15, then minMax is 45.
289
            hourMax = parseInt((o.hourMax - ((o.hourMax - o.hourMin) % o.stepHour)) ,10),
290
            minMax  = parseInt((o.minuteMax - ((o.minuteMax - o.minuteMin) % o.stepMinute)) ,10),
291
            secMax  = parseInt((o.secondMax - ((o.secondMax - o.secondMin) % o.stepSecond)) ,10),
292
            millisecMax  = parseInt((o.millisecMax - ((o.millisecMax - o.millisecMin) % o.stepMillisec)) ,10),
293
            dp_id = this.inst.id.toString().replace(/([^A-Za-z0-9_])/g, '');
294
295
        // Prevent displaying twice
296
        //if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0) {
297
        if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0 && o.showTimepicker) {
298
            var noDisplay = ' style="display:none;"',
299
                html =	'<div class="ui-timepicker-div" id="ui-timepicker-div-' + dp_id + '"><dl>' +
300
                        '<dt class="ui_tpicker_time_label" id="ui_tpicker_time_label_' + dp_id + '"' +
301
                        ((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
302
                        '<dd class="ui_tpicker_time" id="ui_tpicker_time_' + dp_id + '"' +
303
                        ((o.showTime) ? '' : noDisplay) + '></dd>' +
304
                        '<dt class="ui_tpicker_hour_label" id="ui_tpicker_hour_label_' + dp_id + '"' +
305
                        ((o.showHour) ? '' : noDisplay) + '>' + o.hourText + '</dt>',
306
                hourGridSize = 0,
307
                minuteGridSize = 0,
308
                secondGridSize = 0,
309
                millisecGridSize = 0,
310
                size = null;
311
312
            // Hours
313
            html += '<dd class="ui_tpicker_hour"><div id="ui_tpicker_hour_' + dp_id + '"' +
314
                        ((o.showHour) ? '' : noDisplay) + '></div>';
315
            if (o.showHour && o.hourGrid > 0) {
316
                html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
317
318
                for (var h = o.hourMin; h <= hourMax; h += parseInt(o.hourGrid,10)) {
319
                    hourGridSize++;
320
                    var tmph = (o.ampm && h > 12) ? h-12 : h;
321
                    if (tmph < 10) { tmph = '0' + tmph; }
322
                    if (o.ampm) {
323
                        if (h === 0) {
324
                            tmph = 12 +'a';
325
                        } else {
326
                            if (h < 12) { tmph += 'a'; }
327
                            else { tmph += 'p'; }
328
                        }
329
                    }
330
                    html += '<td>' + tmph + '</td>';
331
                }
332
333
                html += '</tr></table></div>';
334
            }
335
            html += '</dd>';
336
337
            // Minutes
338
            html += '<dt class="ui_tpicker_minute_label" id="ui_tpicker_minute_label_' + dp_id + '"' +
339
                    ((o.showMinute) ? '' : noDisplay) + '>' + o.minuteText + '</dt>'+
340
                    '<dd class="ui_tpicker_minute"><div id="ui_tpicker_minute_' + dp_id + '"' +
341
                            ((o.showMinute) ? '' : noDisplay) + '></div>';
342
343
            if (o.showMinute && o.minuteGrid > 0) {
344
                html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
345
346
                for (var m = o.minuteMin; m <= minMax; m += parseInt(o.minuteGrid,10)) {
347
                    minuteGridSize++;
348
                    html += '<td>' + ((m < 10) ? '0' : '') + m + '</td>';
349
                }
350
351
                html += '</tr></table></div>';
352
            }
353
            html += '</dd>';
354
355
            // Seconds
356
            html += '<dt class="ui_tpicker_second_label" id="ui_tpicker_second_label_' + dp_id + '"' +
357
                    ((o.showSecond) ? '' : noDisplay) + '>' + o.secondText + '</dt>'+
358
                    '<dd class="ui_tpicker_second"><div id="ui_tpicker_second_' + dp_id + '"'+
359
                            ((o.showSecond) ? '' : noDisplay) + '></div>';
360
361
            if (o.showSecond && o.secondGrid > 0) {
362
                html += '<div style="padding-left: 1px"><table><tr>';
363
364
                for (var s = o.secondMin; s <= secMax; s += parseInt(o.secondGrid,10)) {
365
                    secondGridSize++;
366
                    html += '<td>' + ((s < 10) ? '0' : '') + s + '</td>';
367
                }
368
369
                html += '</tr></table></div>';
370
            }
371
            html += '</dd>';
372
373
            // Milliseconds
374
            html += '<dt class="ui_tpicker_millisec_label" id="ui_tpicker_millisec_label_' + dp_id + '"' +
375
                    ((o.showMillisec) ? '' : noDisplay) + '>' + o.millisecText + '</dt>'+
376
                    '<dd class="ui_tpicker_millisec"><div id="ui_tpicker_millisec_' + dp_id + '"'+
377
                            ((o.showMillisec) ? '' : noDisplay) + '></div>';
378
379
            if (o.showMillisec && o.millisecGrid > 0) {
380
                html += '<div style="padding-left: 1px"><table><tr>';
381
382
                for (var l = o.millisecMin; l <= millisecMax; l += parseInt(o.millisecGrid,10)) {
383
                    millisecGridSize++;
384
                    html += '<td>' + ((l < 10) ? '0' : '') + l + '</td>';
385
                }
386
387
                html += '</tr></table></div>';
388
            }
389
            html += '</dd>';
390
391
            // Timezone
392
            html += '<dt class="ui_tpicker_timezone_label" id="ui_tpicker_timezone_label_' + dp_id + '"' +
393
                    ((o.showTimezone) ? '' : noDisplay) + '>' + o.timezoneText + '</dt>';
394
            html += '<dd class="ui_tpicker_timezone" id="ui_tpicker_timezone_' + dp_id + '"'	+
395
                            ((o.showTimezone) ? '' : noDisplay) + '></dd>';
396
397
            html += '</dl></div>';
398
            var $tp = $(html);
399
400
                // if we only want time picker...
401
            if (o.timeOnly === true) {
402
                $tp.prepend(
403
                    '<div class="ui-widget-header ui-helper-clearfix ui-corner-all">' +
404
                        '<div class="ui-datepicker-title">' + o.timeOnlyTitle + '</div>' +
405
                    '</div>');
406
                $dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide();
407
            }
408
409
            this.hour_slider = $tp.find('#ui_tpicker_hour_'+ dp_id).slider({
410
                orientation: "horizontal",
411
                value: this.hour,
412
                min: o.hourMin,
413
                max: hourMax,
414
                step: o.stepHour,
415
                slide: function(event, ui) {
416
                    tp_inst.hour_slider.slider( "option", "value", ui.value);
417
                    tp_inst._onTimeChange();
418
                }
419
            });
420
421
422
            // Updated by Peter Medeiros:
423
            // - Pass in Event and UI instance into slide function
424
            this.minute_slider = $tp.find('#ui_tpicker_minute_'+ dp_id).slider({
425
                orientation: "horizontal",
426
                value: this.minute,
427
                min: o.minuteMin,
428
                max: minMax,
429
                step: o.stepMinute,
430
                slide: function(event, ui) {
431
                    tp_inst.minute_slider.slider( "option", "value", ui.value);
432
                    tp_inst._onTimeChange();
433
                }
434
            });
435
436
            this.second_slider = $tp.find('#ui_tpicker_second_'+ dp_id).slider({
437
                orientation: "horizontal",
438
                value: this.second,
439
                min: o.secondMin,
440
                max: secMax,
441
                step: o.stepSecond,
442
                slide: function(event, ui) {
443
                    tp_inst.second_slider.slider( "option", "value", ui.value);
444
                    tp_inst._onTimeChange();
445
                }
446
            });
447
448
            this.millisec_slider = $tp.find('#ui_tpicker_millisec_'+ dp_id).slider({
449
                orientation: "horizontal",
450
                value: this.millisec,
451
                min: o.millisecMin,
452
                max: millisecMax,
453
                step: o.stepMillisec,
454
                slide: function(event, ui) {
455
                    tp_inst.millisec_slider.slider( "option", "value", ui.value);
456
                    tp_inst._onTimeChange();
457
                }
458
            });
459
460
            this.timezone_select = $tp.find('#ui_tpicker_timezone_'+ dp_id).append('<select></select>').find("select");
461
            $.fn.append.apply(this.timezone_select,
462
                $.map(o.timezoneList, function(val, idx) {
463
                    return $("<option />")
464
                        .val(typeof val == "object" ? val.value : val)
465
                        .text(typeof val == "object" ? val.label : val);
466
                })
467
            );
468
            if (typeof(this.timezone) != "undefined" && this.timezone !== null && this.timezone !== "") {
469
                var local_date = new Date(this.inst.selectedYear, this.inst.selectedMonth, this.inst.selectedDay, 12);
470
                var local_timezone = timeZoneString(local_date);
471
                if (local_timezone == this.timezone) {
472
                    selectLocalTimeZone(tp_inst);
473
                } else {
474
                    this.timezone_select.val(this.timezone);
475
                }
476
            } else {
477
                if (typeof(this.hour) != "undefined" && this.hour !== null && this.hour !== "") {
478
                    this.timezone_select.val(o.defaultTimezone);
479
                } else {
480
                    selectLocalTimeZone(tp_inst);
481
                }
482
            }
483
            this.timezone_select.change(function() {
484
                tp_inst._defaults.useLocalTimezone = false;
485
                tp_inst._onTimeChange();
486
            });
487
488
            // Add grid functionality
489
            if (o.showHour && o.hourGrid > 0) {
490
                size = 100 * hourGridSize * o.hourGrid / (hourMax - o.hourMin);
491
492
                $tp.find(".ui_tpicker_hour table").css({
493
                    width: size + "%",
494
                    marginLeft: (size / (-2 * hourGridSize)) + "%",
495
                    borderCollapse: 'collapse'
496
                }).find("td").each( function(index) {
497
                    $(this).click(function() {
498
                        var h = $(this).html();
499
                        if(o.ampm)	{
500
                            var ap = h.substring(2).toLowerCase(),
501
                                aph = parseInt(h.substring(0,2), 10);
502
                            if (ap == 'a') {
503
                                if (aph == 12) { h = 0; }
504
                                else { h = aph; }
505
                            } else if (aph == 12) { h = 12; }
506
                            else { h = aph + 12; }
507
                        }
508
                        tp_inst.hour_slider.slider("option", "value", h);
509
                        tp_inst._onTimeChange();
510
                        tp_inst._onSelectHandler();
511
                    }).css({
512
                        cursor: 'pointer',
513
                        width: (100 / hourGridSize) + '%',
514
                        textAlign: 'center',
515
                        overflow: 'hidden'
516
                    });
517
                });
518
            }
519
520
            if (o.showMinute && o.minuteGrid > 0) {
521
                size = 100 * minuteGridSize * o.minuteGrid / (minMax - o.minuteMin);
522
                $tp.find(".ui_tpicker_minute table").css({
523
                    width: size + "%",
524
                    marginLeft: (size / (-2 * minuteGridSize)) + "%",
525
                    borderCollapse: 'collapse'
526
                }).find("td").each(function(index) {
527
                    $(this).click(function() {
528
                        tp_inst.minute_slider.slider("option", "value", $(this).html());
529
                        tp_inst._onTimeChange();
530
                        tp_inst._onSelectHandler();
531
                    }).css({
532
                        cursor: 'pointer',
533
                        width: (100 / minuteGridSize) + '%',
534
                        textAlign: 'center',
535
                        overflow: 'hidden'
536
                    });
537
                });
538
            }
539
540
            if (o.showSecond && o.secondGrid > 0) {
541
                $tp.find(".ui_tpicker_second table").css({
542
                    width: size + "%",
543
                    marginLeft: (size / (-2 * secondGridSize)) + "%",
544
                    borderCollapse: 'collapse'
545
                }).find("td").each(function(index) {
546
                    $(this).click(function() {
547
                        tp_inst.second_slider.slider("option", "value", $(this).html());
548
                        tp_inst._onTimeChange();
549
                        tp_inst._onSelectHandler();
550
                    }).css({
551
                        cursor: 'pointer',
552
                        width: (100 / secondGridSize) + '%',
553
                        textAlign: 'center',
554
                        overflow: 'hidden'
555
                    });
556
                });
557
            }
558
559
            if (o.showMillisec && o.millisecGrid > 0) {
560
                $tp.find(".ui_tpicker_millisec table").css({
561
                    width: size + "%",
562
                    marginLeft: (size / (-2 * millisecGridSize)) + "%",
563
                    borderCollapse: 'collapse'
564
                }).find("td").each(function(index) {
565
                    $(this).click(function() {
566
                        tp_inst.millisec_slider.slider("option", "value", $(this).html());
567
                        tp_inst._onTimeChange();
568
                        tp_inst._onSelectHandler();
569
                    }).css({
570
                        cursor: 'pointer',
571
                        width: (100 / millisecGridSize) + '%',
572
                        textAlign: 'center',
573
                        overflow: 'hidden'
574
                    });
575
                });
576
            }
577
578
            var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
579
            if ($buttonPanel.length) { $buttonPanel.before($tp); }
580
            else { $dp.append($tp); }
581
582
            this.$timeObj = $tp.find('#ui_tpicker_time_'+ dp_id);
583
584
            if (this.inst !== null) {
585
                var timeDefined = this.timeDefined;
586
                this._onTimeChange();
587
                this.timeDefined = timeDefined;
588
            }
589
590
            //Emulate datepicker onSelect behavior. Call on slidestop.
591
            var onSelectDelegate = function() {
592
                tp_inst._onSelectHandler();
593
            };
594
            this.hour_slider.bind('slidestop',onSelectDelegate);
595
            this.minute_slider.bind('slidestop',onSelectDelegate);
596
            this.second_slider.bind('slidestop',onSelectDelegate);
597
            this.millisec_slider.bind('slidestop',onSelectDelegate);
598
599
            // slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/
600
            if (this._defaults.addSliderAccess){
601
                var sliderAccessArgs = this._defaults.sliderAccessArgs;
602
                setTimeout(function(){ // fix for inline mode
603
                    if($tp.find('.ui-slider-access').length === 0){
604
                        $tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
605
606
                        // fix any grids since sliders are shorter
607
                        var sliderAccessWidth = $tp.find('.ui-slider-access:eq(0)').outerWidth(true);
608
                        if(sliderAccessWidth){
609
                            $tp.find('table:visible').each(function(){
610
                                var $g = $(this),
611
                                    oldWidth = $g.outerWidth(),
612
                                    oldMarginLeft = $g.css('marginLeft').toString().replace('%',''),
613
                                    newWidth = oldWidth - sliderAccessWidth,
614
                                    newMarginLeft = ((oldMarginLeft * newWidth)/oldWidth) + '%';
615
616
                                $g.css({ width: newWidth, marginLeft: newMarginLeft });
617
                            });
618
                        }
619
                    }
620
                },0);
621
            }
622
            // end slideAccess integration
623
624
        }
625
    },
626
627
    //########################################################################
628
    // This function tries to limit the ability to go outside the
629
    // min/max date range
630
    //########################################################################
631
    _limitMinMaxDateTime: function(dp_inst, adjustSliders){
632
        var o = this._defaults,
633
            dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay);
634
635
        if(!this._defaults.showTimepicker) { return; } // No time so nothing to check here
636
637
        if($.datepicker._get(dp_inst, 'minDateTime') !== null && $.datepicker._get(dp_inst, 'minDateTime') !== undefined && dp_date){
638
            var minDateTime = $.datepicker._get(dp_inst, 'minDateTime'),
639
                minDateTimeDate = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), 0, 0, 0, 0);
640
641
            if(this.hourMinOriginal === null || this.minuteMinOriginal === null || this.secondMinOriginal === null || this.millisecMinOriginal === null){
642
                this.hourMinOriginal = o.hourMin;
643
                this.minuteMinOriginal = o.minuteMin;
644
                this.secondMinOriginal = o.secondMin;
645
                this.millisecMinOriginal = o.millisecMin;
646
            }
647
648
            if(dp_inst.settings.timeOnly || minDateTimeDate.getTime() == dp_date.getTime()) {
649
                this._defaults.hourMin = minDateTime.getHours();
650
                if (this.hour <= this._defaults.hourMin) {
651
                    this.hour = this._defaults.hourMin;
652
                    this._defaults.minuteMin = minDateTime.getMinutes();
653
                    if (this.minute <= this._defaults.minuteMin) {
654
                        this.minute = this._defaults.minuteMin;
655
                        this._defaults.secondMin = minDateTime.getSeconds();
656
                    } else if (this.second <= this._defaults.secondMin){
657
                        this.second = this._defaults.secondMin;
658
                        this._defaults.millisecMin = minDateTime.getMilliseconds();
659
                    } else {
660
                        if(this.millisec < this._defaults.millisecMin) {
661
                            this.millisec = this._defaults.millisecMin;
662
                        }
663
                        this._defaults.millisecMin = this.millisecMinOriginal;
664
                    }
665
                } else {
666
                    this._defaults.minuteMin = this.minuteMinOriginal;
667
                    this._defaults.secondMin = this.secondMinOriginal;
668
                    this._defaults.millisecMin = this.millisecMinOriginal;
669
                }
670
            }else{
671
                this._defaults.hourMin = this.hourMinOriginal;
672
                this._defaults.minuteMin = this.minuteMinOriginal;
673
                this._defaults.secondMin = this.secondMinOriginal;
674
                this._defaults.millisecMin = this.millisecMinOriginal;
675
            }
676
        }
677
678
        if($.datepicker._get(dp_inst, 'maxDateTime') !== null && $.datepicker._get(dp_inst, 'maxDateTime') !== undefined && dp_date){
679
            var maxDateTime = $.datepicker._get(dp_inst, 'maxDateTime'),
680
                maxDateTimeDate = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), 0, 0, 0, 0);
681
682
            if(this.hourMaxOriginal === null || this.minuteMaxOriginal === null || this.secondMaxOriginal === null){
683
                this.hourMaxOriginal = o.hourMax;
684
                this.minuteMaxOriginal = o.minuteMax;
685
                this.secondMaxOriginal = o.secondMax;
686
                this.millisecMaxOriginal = o.millisecMax;
687
            }
688
689
            if(dp_inst.settings.timeOnly || maxDateTimeDate.getTime() == dp_date.getTime()){
690
                this._defaults.hourMax = maxDateTime.getHours();
691
                if (this.hour >= this._defaults.hourMax) {
692
                    this.hour = this._defaults.hourMax;
693
                    this._defaults.minuteMax = maxDateTime.getMinutes();
694
                    if (this.minute >= this._defaults.minuteMax) {
695
                        this.minute = this._defaults.minuteMax;
696
                        this._defaults.secondMax = maxDateTime.getSeconds();
697
                    } else if (this.second >= this._defaults.secondMax) {
698
                        this.second = this._defaults.secondMax;
699
                        this._defaults.millisecMax = maxDateTime.getMilliseconds();
700
                    } else {
701
                        if(this.millisec > this._defaults.millisecMax) { this.millisec = this._defaults.millisecMax; }
702
                        this._defaults.millisecMax = this.millisecMaxOriginal;
703
                    }
704
                } else {
705
                    this._defaults.minuteMax = this.minuteMaxOriginal;
706
                    this._defaults.secondMax = this.secondMaxOriginal;
707
                    this._defaults.millisecMax = this.millisecMaxOriginal;
708
                }
709
            }else{
710
                this._defaults.hourMax = this.hourMaxOriginal;
711
                this._defaults.minuteMax = this.minuteMaxOriginal;
712
                this._defaults.secondMax = this.secondMaxOriginal;
713
                this._defaults.millisecMax = this.millisecMaxOriginal;
714
            }
715
        }
716
717
        if(adjustSliders !== undefined && adjustSliders === true){
718
            var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)) ,10),
719
                minMax  = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)) ,10),
720
                secMax  = parseInt((this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)) ,10),
721
                millisecMax  = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)) ,10);
722
723
            if(this.hour_slider) {
724
                this.hour_slider.slider("option", { min: this._defaults.hourMin, max: hourMax }).slider('value', this.hour);
725
            }
726
            if(this.minute_slider) {
727
                this.minute_slider.slider("option", { min: this._defaults.minuteMin, max: minMax }).slider('value', this.minute);
728
            }
729
            if(this.second_slider){
730
                this.second_slider.slider("option", { min: this._defaults.secondMin, max: secMax }).slider('value', this.second);
731
            }
732
            if(this.millisec_slider) {
733
                this.millisec_slider.slider("option", { min: this._defaults.millisecMin, max: millisecMax }).slider('value', this.millisec);
734
            }
735
        }
736
737
    },
738
739
740
    //########################################################################
741
    // when a slider moves, set the internal time...
742
    // on time change is also called when the time is updated in the text field
743
    //########################################################################
744
    _onTimeChange: function() {
745
        var hour   = (this.hour_slider) ? this.hour_slider.slider('value') : false,
746
            minute = (this.minute_slider) ? this.minute_slider.slider('value') : false,
747
            second = (this.second_slider) ? this.second_slider.slider('value') : false,
748
            millisec = (this.millisec_slider) ? this.millisec_slider.slider('value') : false,
749
            timezone = (this.timezone_select) ? this.timezone_select.val() : false,
750
            o = this._defaults;
751
752
        if (typeof(hour) == 'object') { hour = false; }
753
        if (typeof(minute) == 'object') { minute = false; }
754
        if (typeof(second) == 'object') { second = false; }
755
        if (typeof(millisec) == 'object') { millisec = false; }
756
        if (typeof(timezone) == 'object') { timezone = false; }
757
758
        if (hour !== false) { hour = parseInt(hour,10); }
759
        if (minute !== false) { minute = parseInt(minute,10); }
760
        if (second !== false) { second = parseInt(second,10); }
761
        if (millisec !== false) { millisec = parseInt(millisec,10); }
762
763
        var ampm = o[hour < 12 ? 'amNames' : 'pmNames'][0];
764
765
        // If the update was done in the input field, the input field should not be updated.
766
        // If the update was done using the sliders, update the input field.
767
        var hasChanged = (hour != this.hour || minute != this.minute ||
768
                second != this.second || millisec != this.millisec ||
769
                (this.ampm.length > 0 &&
770
                    (hour < 12) != ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1)) ||
771
                timezone != this.timezone);
772
773
        if (hasChanged) {
774
775
            if (hour !== false) { this.hour = hour; }
776
            if (minute !== false) { this.minute = minute; }
777
            if (second !== false) { this.second = second; }
778
            if (millisec !== false) { this.millisec = millisec; }
779
            if (timezone !== false) { this.timezone = timezone; }
780
781
            if (!this.inst) { this.inst = $.datepicker._getInst(this.$input[0]); }
782
783
            this._limitMinMaxDateTime(this.inst, true);
784
        }
785
        if (o.ampm) { this.ampm = ampm; }
786
787
        //this._formatTime();
788
        this.formattedTime = $.datepicker.formatTime(this._defaults.timeFormat, this, this._defaults);
789
        if (this.$timeObj) { this.$timeObj.text(this.formattedTime + o.timeSuffix); }
790
        this.timeDefined = true;
791
        if (hasChanged) { this._updateDateTime(); }
792
    },
793
794
    //########################################################################
795
    // call custom onSelect.
796
    // bind to sliders slidestop, and grid click.
797
    //########################################################################
798
    _onSelectHandler: function() {
799
        var onSelect = this._defaults.onSelect;
800
        var inputEl = this.$input ? this.$input[0] : null;
801
        if (onSelect && inputEl) {
802
            onSelect.apply(inputEl, [this.formattedDateTime, this]);
803
        }
804
    },
805
806
    //########################################################################
807
    // left for any backwards compatibility
808
    //########################################################################
809
    _formatTime: function(time, format) {
810
        time = time || { hour: this.hour, minute: this.minute, second: this.second, millisec: this.millisec, ampm: this.ampm, timezone: this.timezone };
811
        var tmptime = (format || this._defaults.timeFormat).toString();
812
813
        tmptime = $.datepicker.formatTime(tmptime, time, this._defaults);
814
815
        if (arguments.length) { return tmptime; }
816
        else { this.formattedTime = tmptime; }
817
    },
818
819
    //########################################################################
820
    // update our input with the new date time..
821
    //########################################################################
822
    _updateDateTime: function(dp_inst) {
823
        dp_inst = this.inst || dp_inst;
824
        var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
825
            dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
826
            formatCfg = $.datepicker._getFormatConfig(dp_inst),
827
            timeAvailable = dt !== null && this.timeDefined;
828
        this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
829
        var formattedDateTime = this.formattedDate;
830
        // remove following lines to force every changes in date picker to change the input value
831
        // Bug descriptions: when an input field has a default value, and click on the field to pop up the date picker.
832
        // If the user manually empty the value in the input field, the date picker will never change selected value.
833
        //if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0)) {
834
        //	return;
835
        //}
836
837
        if (this._defaults.timeOnly === true) {
838
            formattedDateTime = this.formattedTime;
839
        } else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
840
            formattedDateTime += this._defaults.separator + this.formattedTime + this._defaults.timeSuffix;
841
        }
842
843
        this.formattedDateTime = formattedDateTime;
844
845
        if(!this._defaults.showTimepicker) {
846
            this.$input.val(this.formattedDate);
847
        } else if (this.$altInput && this._defaults.altFieldTimeOnly === true) {
848
            this.$altInput.val(this.formattedTime);
849
            this.$input.val(this.formattedDate);
850
        } else if(this.$altInput) {
851
            this.$altInput.val(formattedDateTime);
852
            this.$input.val(formattedDateTime);
853
        } else {
854
            this.$input.val(formattedDateTime);
855
        }
856
857
        this.$input.trigger("change");
858
    }
859
860
});
861
862
$.fn.extend({
863
    //########################################################################
864
    // shorthand just to use timepicker..
865
    //########################################################################
866
    timepicker: function(o) {
867
        o = o || {};
868
        var tmp_args = arguments;
869
870
        if (typeof o == 'object') { tmp_args[0] = $.extend(o, { timeOnly: true }); }
871
872
        return $(this).each(function() {
873
            $.fn.datetimepicker.apply($(this), tmp_args);
874
        });
875
    },
876
877
    //########################################################################
878
    // extend timepicker to datepicker
879
    //########################################################################
880
    datetimepicker: function(o) {
881
        o = o || {};
882
        var tmp_args = arguments;
883
884
        if (typeof(o) == 'string'){
885
            if(o == 'getDate') {
886
                return $.fn.datepicker.apply($(this[0]), tmp_args);
887
            }
888
            else {
889
                return this.each(function() {
890
                    var $t = $(this);
891
                    $t.datepicker.apply($t, tmp_args);
892
                });
893
            }
894
        }
895
        else {
896
            return this.each(function() {
897
                var $t = $(this);
898
                $t.datepicker($.timepicker._newInst($t, o)._defaults);
899
            });
900
        }
901
    }
902
});
903
904
$.datepicker.parseDateTime = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
905
    var parseRes = parseDateTimeInternal(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings);
906
    if (parseRes.timeObj)
907
    {
908
        var t = parseRes.timeObj;
909
        parseRes.date.setHours(t.hour, t.minute, t.second, t.millisec);
910
    }
911
912
    return parseRes.date;
913
};
914
915
$.datepicker.parseTime = function(timeFormat, timeString, options) {
916
917
    //########################################################################
918
    // pattern for standard and localized AM/PM markers
919
    //########################################################################
920
    var getPatternAmpm = function(amNames, pmNames) {
921
        var markers = [];
922
        if (amNames) {
923
            $.merge(markers, amNames);
924
        }
925
        if (pmNames) {
926
            $.merge(markers, pmNames);
927
        }
928
        markers = $.map(markers, function(val) { return val.replace(/[.*+?|()\[\]{}\\]/g, '\\$&'); });
929
        return '(' + markers.join('|') + ')?';
930
    };
931
932
    //########################################################################
933
    // figure out position of time elements.. cause js cant do named captures
934
    //########################################################################
935
    var getFormatPositions = function( timeFormat ) {
936
        var finds = timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|t{1,2}|z)/g),
937
            orders = { h: -1, m: -1, s: -1, l: -1, t: -1, z: -1 };
938
939
        if (finds) {
940
            for (var i = 0; i < finds.length; i++) {
941
                if (orders[finds[i].toString().charAt(0)] == -1) {
942
                    orders[finds[i].toString().charAt(0)] = i + 1;
943
                }
944
            }
945
        }
946
        return orders;
947
    };
948
949
    var o = extendRemove(extendRemove({}, $.timepicker._defaults), options || {});
950
951
    var regstr = '^' + timeFormat.toString()
952
            .replace(/h{1,2}/ig, '(\\d?\\d)')
953
            .replace(/m{1,2}/ig, '(\\d?\\d)')
954
            .replace(/s{1,2}/ig, '(\\d?\\d)')
955
            .replace(/l{1}/ig, '(\\d?\\d?\\d)')
956
            .replace(/t{1,2}/ig, getPatternAmpm(o.amNames, o.pmNames))
957
            .replace(/z{1}/ig, '(z|[-+]\\d\\d:?\\d\\d)?')
958
            .replace(/\s/g, '\\s?') + o.timeSuffix + '$',
959
        order = getFormatPositions(timeFormat),
960
        ampm = '',
961
        treg;
962
963
    treg = timeString.match(new RegExp(regstr, 'i'));
964
965
    var resTime = {hour: 0, minute: 0, second: 0, millisec: 0};
966
967
    if (treg) {
968
        if (order.t !== -1) {
969
            if (treg[order.t] === undefined || treg[order.t].length === 0) {
970
                ampm = '';
971
                resTime.ampm = '';
972
            } else {
973
                ampm = $.inArray(treg[order.t], o.amNames) !== -1 ? 'AM' : 'PM';
974
                resTime.ampm = o[ampm == 'AM' ? 'amNames' : 'pmNames'][0];
975
            }
976
        }
977
978
        if (order.h !== -1) {
979
            if (ampm == 'AM' && treg[order.h] == '12') {
980
                resTime.hour = 0; // 12am = 0 hour
981
            } else {
982
                if (ampm == 'PM' && treg[order.h] != '12') {
983
                    resTime.hour = parseInt(treg[order.h],10) + 12; // 12pm = 12 hour, any other pm = hour + 12
984
                }
985
                else { resTime.hour = Number(treg[order.h]); }
986
            }
987
        }
988
989
        if (order.m !== -1) { resTime.minute = Number(treg[order.m]); }
990
        if (order.s !== -1) { resTime.second = Number(treg[order.s]); }
991
        if (order.l !== -1) { resTime.millisec = Number(treg[order.l]); }
992
        if (order.z !== -1 && treg[order.z] !== undefined) {
993
            var tz = treg[order.z].toUpperCase();
994
            switch (tz.length) {
995
                case 1:	// Z
996
                    tz = o.timezoneIso8601 ? 'Z' : '+0000';
997
                    break;
998
                case 5:	// +hhmm
999
                    if (o.timezoneIso8601) {
1000
                        tz = tz.substring(1) == '0000' ?
1001
                            'Z' :
1002
                            tz.substring(0, 3) + ':' + tz.substring(3);
1003
                    }
1004
                    break;
1005
                case 6:	// +hh:mm
1006
                    if (!o.timezoneIso8601) {
1007
                        tz = tz == 'Z' || tz.substring(1) == '00:00' ?
1008
                            '+0000' :
1009
                            tz.replace(/:/, '');
1010
                    } else {
1011
                        if (tz.substring(1) == '00:00') {
1012
                            tz = 'Z';
1013
                        }
1014
                    }
1015
                    break;
1016
            }
1017
            resTime.timezone = tz;
1018
        }
1019
1020
1021
        return resTime;
1022
    }
1023
1024
    return false;
1025
};
1026
1027
//########################################################################
1028
// format the time all pretty...
1029
// format = string format of the time
1030
// time = a {}, not a Date() for timezones
1031
// options = essentially the regional[].. amNames, pmNames, ampm
1032
//########################################################################
1033
$.datepicker.formatTime = function(format, time, options) {
1034
    options = options || {};
1035
    options = $.extend($.timepicker._defaults, options);
1036
    time = $.extend({hour:0, minute:0, second:0, millisec:0, timezone:'+0000'}, time);
1037
1038
    var tmptime = format;
1039
    var ampmName = options.amNames[0];
1040
1041
    var hour = parseInt(time.hour, 10);
1042
    if (options.ampm) {
1043
        if (hour > 11){
1044
            ampmName = options.pmNames[0];
1045
            if(hour > 12) {
1046
                hour = hour % 12;
1047
            }
1048
        }
1049
        if (hour === 0) {
1050
            hour = 12;
1051
        }
1052
    }
1053
    tmptime = tmptime.replace(/(?:hh?|mm?|ss?|[tT]{1,2}|[lz])/g, function(match) {
1054
        switch (match.toLowerCase()) {
1055
            case 'hh': return ('0' + hour).slice(-2);
1056
            case 'h':  return hour;
1057
            case 'mm': return ('0' + time.minute).slice(-2);
1058
            case 'm':  return time.minute;
1059
            case 'ss': return ('0' + time.second).slice(-2);
1060
            case 's':  return time.second;
1061
            case 'l':  return ('00' + time.millisec).slice(-3);
1062
            case 'z':  return time.timezone;
1063
            case 't': case 'tt':
1064
                if (options.ampm) {
1065
                    if (match.length == 1) {
1066
                        ampmName = ampmName.charAt(0);
1067
                    }
1068
                    return match.charAt(0) == 'T' ? ampmName.toUpperCase() : ampmName.toLowerCase();
1069
                }
1070
                return '';
1071
        }
1072
    });
1073
1074
    tmptime = $.trim(tmptime);
1075
    return tmptime;
1076
};
1077
1078
//########################################################################
1079
// the bad hack :/ override datepicker so it doesnt close on select
1080
// inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
1081
//########################################################################
1082
$.datepicker._base_selectDate = $.datepicker._selectDate;
1083
$.datepicker._selectDate = function (id, dateStr) {
1084
    var inst = this._getInst($(id)[0]),
1085
        tp_inst = this._get(inst, 'timepicker');
1086
1087
    if (tp_inst) {
1088
        tp_inst._limitMinMaxDateTime(inst, true);
1089
        inst.inline = inst.stay_open = true;
1090
        //This way the onSelect handler called from calendarpicker get the full dateTime
1091
        this._base_selectDate(id, dateStr);
1092
        inst.inline = inst.stay_open = false;
1093
        this._notifyChange(inst);
1094
        this._updateDatepicker(inst);
1095
    }
1096
    else { this._base_selectDate(id, dateStr); }
1097
};
1098
1099
//#############################################################################################
1100
// second bad hack :/ override datepicker so it triggers an event when changing the input field
1101
// and does not redraw the datepicker on every selectDate event
1102
//#############################################################################################
1103
$.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
1104
$.datepicker._updateDatepicker = function(inst) {
1105
1106
    // don't popup the datepicker if there is another instance already opened
1107
    var input = inst.input[0];
1108
    if($.datepicker._curInst &&
1109
       $.datepicker._curInst != inst &&
1110
       $.datepicker._datepickerShowing &&
1111
       $.datepicker._lastInput != input) {
1112
        return;
1113
    }
1114
1115
    if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
1116
1117
        this._base_updateDatepicker(inst);
1118
1119
        // Reload the time control when changing something in the input text field.
1120
        var tp_inst = this._get(inst, 'timepicker');
1121
        if(tp_inst) {
1122
            tp_inst._addTimePicker(inst);
1123
1124
            if (tp_inst._defaults.useLocalTimezone) { //checks daylight saving with the new date.
1125
                var date = new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay, 12);
1126
                selectLocalTimeZone(tp_inst, date);
1127
                tp_inst._onTimeChange();
1128
            }
1129
        }
1130
    }
1131
};
1132
1133
//#######################################################################################
1134
// third bad hack :/ override datepicker so it allows spaces and colon in the input field
1135
//#######################################################################################
1136
$.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
1137
$.datepicker._doKeyPress = function(event) {
1138
    var inst = $.datepicker._getInst(event.target),
1139
        tp_inst = $.datepicker._get(inst, 'timepicker');
1140
1141
    if (tp_inst) {
1142
        if ($.datepicker._get(inst, 'constrainInput')) {
1143
            var ampm = tp_inst._defaults.ampm,
1144
                dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
1145
                datetimeChars = tp_inst._defaults.timeFormat.toString()
1146
                                .replace(/[hms]/g, '')
1147
                                .replace(/TT/g, ampm ? 'APM' : '')
1148
                                .replace(/Tt/g, ampm ? 'AaPpMm' : '')
1149
                                .replace(/tT/g, ampm ? 'AaPpMm' : '')
1150
                                .replace(/T/g, ampm ? 'AP' : '')
1151
                                .replace(/tt/g, ampm ? 'apm' : '')
1152
                                .replace(/t/g, ampm ? 'ap' : '') +
1153
                                " " +
1154
                                tp_inst._defaults.separator +
1155
                                tp_inst._defaults.timeSuffix +
1156
                                (tp_inst._defaults.showTimezone ? tp_inst._defaults.timezoneList.join('') : '') +
1157
                                (tp_inst._defaults.amNames.join('')) +
1158
                                (tp_inst._defaults.pmNames.join('')) +
1159
                                dateChars,
1160
                chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
1161
            return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1);
1162
        }
1163
    }
1164
1165
    return $.datepicker._base_doKeyPress(event);
1166
};
1167
1168
//#######################################################################################
1169
// Override key up event to sync manual input changes.
1170
//#######################################################################################
1171
$.datepicker._base_doKeyUp = $.datepicker._doKeyUp;
1172
$.datepicker._doKeyUp = function (event) {
1173
    var inst = $.datepicker._getInst(event.target),
1174
        tp_inst = $.datepicker._get(inst, 'timepicker');
1175
1176
    if (tp_inst) {
1177
        if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
1178
            try {
1179
                $.datepicker._updateDatepicker(inst);
1180
            }
1181
            catch (err) {
1182
                $.datepicker.log(err);
1183
            }
1184
        }
1185
    }
1186
1187
    return $.datepicker._base_doKeyUp(event);
1188
};
1189
1190
//#######################################################################################
1191
// override "Today" button to also grab the time.
1192
//#######################################################################################
1193
$.datepicker._base_gotoToday = $.datepicker._gotoToday;
1194
$.datepicker._gotoToday = function(id) {
1195
    var inst = this._getInst($(id)[0]),
1196
        $dp = inst.dpDiv;
1197
    this._base_gotoToday(id);
1198
    var tp_inst = this._get(inst, 'timepicker');
1199
    selectLocalTimeZone(tp_inst);
1200
    var now = new Date();
1201
    this._setTime(inst, now);
1202
    $( '.ui-datepicker-today', $dp).click();
1203
};
1204
1205
//#######################################################################################
1206
// Disable & enable the Time in the datetimepicker
1207
//#######################################################################################
1208
$.datepicker._disableTimepickerDatepicker = function(target) {
1209
    var inst = this._getInst(target);
1210
    if (!inst) { return; }
1211
1212
    var tp_inst = this._get(inst, 'timepicker');
1213
    $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
1214
    if (tp_inst) {
1215
        tp_inst._defaults.showTimepicker = false;
1216
        tp_inst._updateDateTime(inst);
1217
    }
1218
};
1219
1220
$.datepicker._enableTimepickerDatepicker = function(target) {
1221
    var inst = this._getInst(target);
1222
    if (!inst) { return; }
1223
1224
    var tp_inst = this._get(inst, 'timepicker');
1225
    $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
1226
    if (tp_inst) {
1227
        tp_inst._defaults.showTimepicker = true;
1228
        tp_inst._addTimePicker(inst); // Could be disabled on page load
1229
        tp_inst._updateDateTime(inst);
1230
    }
1231
};
1232
1233
//#######################################################################################
1234
// Create our own set time function
1235
//#######################################################################################
1236
$.datepicker._setTime = function(inst, date) {
1237
    var tp_inst = this._get(inst, 'timepicker');
1238
    if (tp_inst) {
1239
        var defaults = tp_inst._defaults,
1240
            // calling _setTime with no date sets time to defaults
1241
            hour = date ? date.getHours() : defaults.hour,
1242
            minute = date ? date.getMinutes() : defaults.minute,
1243
            second = date ? date.getSeconds() : defaults.second,
1244
            millisec = date ? date.getMilliseconds() : defaults.millisec;
1245
        //check if within min/max times..
1246
        // correct check if within min/max times.
1247
        // Rewritten by Scott A. Woodward
1248
        var hourEq = hour === defaults.hourMin,
1249
            minuteEq = minute === defaults.minuteMin,
1250
            secondEq = second === defaults.secondMin;
1251
        var reset = false;
1252
        if(hour < defaults.hourMin || hour > defaults.hourMax)
1253
            reset = true;
1254
        else if( (minute < defaults.minuteMin || minute > defaults.minuteMax) && hourEq)
1255
            reset = true;
1256
        else if( (second < defaults.secondMin || second > defaults.secondMax ) && hourEq && minuteEq)
1257
            reset = true;
1258
        else if( (millisec < defaults.millisecMin || millisec > defaults.millisecMax) && hourEq && minuteEq && secondEq)
1259
            reset = true;
1260
        if(reset) {
1261
            hour = defaults.hourMin;
1262
            minute = defaults.minuteMin;
1263
            second = defaults.secondMin;
1264
            millisec = defaults.millisecMin;
1265
        }
1266
        tp_inst.hour = hour;
1267
        tp_inst.minute = minute;
1268
        tp_inst.second = second;
1269
        tp_inst.millisec = millisec;
1270
        if (tp_inst.hour_slider) tp_inst.hour_slider.slider('value', hour);
1271
        if (tp_inst.minute_slider) tp_inst.minute_slider.slider('value', minute);
1272
        if (tp_inst.second_slider) tp_inst.second_slider.slider('value', second);
1273
        if (tp_inst.millisec_slider) tp_inst.millisec_slider.slider('value', millisec);
1274
1275
        tp_inst._onTimeChange();
1276
        tp_inst._updateDateTime(inst);
1277
    }
1278
};
1279
1280
//#######################################################################################
1281
// Create new public method to set only time, callable as $().datepicker('setTime', date)
1282
//#######################################################################################
1283
$.datepicker._setTimeDatepicker = function(target, date, withDate) {
1284
    var inst = this._getInst(target);
1285
    if (!inst) { return; }
1286
1287
    var tp_inst = this._get(inst, 'timepicker');
1288
1289
    if (tp_inst) {
1290
        this._setDateFromField(inst);
1291
        var tp_date;
1292
        if (date) {
1293
            if (typeof date == "string") {
1294
                tp_inst._parseTime(date, withDate);
1295
                tp_date = new Date();
1296
                tp_date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
1297
            }
1298
            else { tp_date = new Date(date.getTime()); }
1299
            if (tp_date.toString() == 'Invalid Date') { tp_date = undefined; }
1300
            this._setTime(inst, tp_date);
1301
        }
1302
    }
1303
1304
};
1305
1306
//#######################################################################################
1307
// override setDate() to allow setting time too within Date object
1308
//#######################################################################################
1309
$.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
1310
$.datepicker._setDateDatepicker = function(target, date) {
1311
    var inst = this._getInst(target);
1312
    if (!inst) { return; }
1313
1314
    var tp_date = (date instanceof Date) ? new Date(date.getTime()) : date;
1315
1316
    this._updateDatepicker(inst);
1317
    this._base_setDateDatepicker.apply(this, arguments);
1318
    this._setTimeDatepicker(target, tp_date, true);
1319
};
1320
1321
//#######################################################################################
1322
// override getDate() to allow getting time too within Date object
1323
//#######################################################################################
1324
$.datepicker._base_getDateDatepicker = $.datepicker._getDateDatepicker;
1325
$.datepicker._getDateDatepicker = function(target, noDefault) {
1326
    var inst = this._getInst(target);
1327
    if (!inst) { return; }
1328
1329
    var tp_inst = this._get(inst, 'timepicker');
1330
1331
    if (tp_inst) {
1332
        this._setDateFromField(inst, noDefault);
1333
        var date = this._getDate(inst);
1334
        if (date && tp_inst._parseTime($(target).val(), tp_inst.timeOnly)) { date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec); }
1335
        return date;
1336
    }
1337
    return this._base_getDateDatepicker(target, noDefault);
1338
};
1339
1340
//#######################################################################################
1341
// override parseDate() because UI 1.8.14 throws an error about "Extra characters"
1342
// An option in datapicker to ignore extra format characters would be nicer.
1343
//#######################################################################################
1344
$.datepicker._base_parseDate = $.datepicker.parseDate;
1345
$.datepicker.parseDate = function(format, value, settings) {
1346
    var splitRes = splitDateTime(format, value, settings);
1347
    return $.datepicker._base_parseDate(format, splitRes[0], settings);
1348
};
1349
1350
//#######################################################################################
1351
// override formatDate to set date with time to the input
1352
//#######################################################################################
1353
$.datepicker._base_formatDate = $.datepicker._formatDate;
1354
$.datepicker._formatDate = function(inst, day, month, year){
1355
    var tp_inst = this._get(inst, 'timepicker');
1356
    if(tp_inst) {
1357
        tp_inst._updateDateTime(inst);
1358
        return tp_inst.$input.val();
1359
    }
1360
    return this._base_formatDate(inst);
1361
};
1362
1363
//#######################################################################################
1364
// override options setter to add time to maxDate(Time) and minDate(Time). MaxDate
1365
//#######################################################################################
1366
$.datepicker._base_optionDatepicker = $.datepicker._optionDatepicker;
1367
$.datepicker._optionDatepicker = function(target, name, value) {
1368
    var inst = this._getInst(target);
1369
    if (!inst) { return null; }
1370
1371
    var tp_inst = this._get(inst, 'timepicker');
1372
    if (tp_inst) {
1373
        var min = null, max = null, onselect = null;
1374
        if (typeof name == 'string') { // if min/max was set with the string
1375
            if (name === 'minDate' || name === 'minDateTime' ) {
1376
                min = value;
1377
            }
1378
            else {
1379
                if (name === 'maxDate' || name === 'maxDateTime') {
1380
                    max = value;
1381
                }
1382
                else {
1383
                    if (name === 'onSelect') {
1384
                        onselect = value;
1385
                    }
1386
                }
1387
            }
1388
        } else {
1389
            if (typeof name == 'object') { //if min/max was set with the JSON
1390
                if (name.minDate) {
1391
                    min = name.minDate;
1392
                } else {
1393
                    if (name.minDateTime) {
1394
                        min = name.minDateTime;
1395
                    } else {
1396
                        if (name.maxDate) {
1397
                            max = name.maxDate;
1398
                        } else {
1399
                            if (name.maxDateTime) {
1400
                                max = name.maxDateTime;
1401
                            }
1402
                        }
1403
                    }
1404
                }
1405
            }
1406
        }
1407
        if(min) { //if min was set
1408
            if (min === 0) {
1409
                min = new Date();
1410
            } else {
1411
                min = new Date(min);
1412
            }
1413
1414
            tp_inst._defaults.minDate = min;
1415
            tp_inst._defaults.minDateTime = min;
1416
        } else if (max) { //if max was set
1417
            if(max===0) {
1418
                max=new Date();
1419
            } else {
1420
                max= new Date(max);
1421
            }
1422
            tp_inst._defaults.maxDate = max;
1423
            tp_inst._defaults.maxDateTime = max;
1424
        } else if (onselect) {
1425
            tp_inst._defaults.onSelect = onselect;
1426
        }
1427
    }
1428
    if (value === undefined) {
1429
        return this._base_optionDatepicker(target, name);
1430
    }
1431
    return this._base_optionDatepicker(target, name, value);
1432
};
1433
1434
//#######################################################################################
1435
// jQuery extend now ignores nulls!
1436
//#######################################################################################
1437
function extendRemove(target, props) {
1438
    $.extend(target, props);
1439
    for (var name in props) {
1440
        if (props[name] === null || props[name] === undefined) {
1441
            target[name] = props[name];
1442
        }
1443
    }
1444
    return target;
1445
}
1446
1447
//#######################################################################################
1448
// Splits datetime string into date ans time substrings.
1449
// Throws exception when date can't be parsed
1450
// If only date is present, time substring eill be ''
1451
//#######################################################################################
1452
var splitDateTime = function(dateFormat, dateTimeString, dateSettings)
1453
{
1454
    try {
1455
        var date = $.datepicker._base_parseDate(dateFormat, dateTimeString, dateSettings);
1456
    } catch (err) {
1457
        if (err.indexOf(":") >= 0) {
1458
            // Hack!  The error message ends with a colon, a space, and
1459
            // the "extra" characters.  We rely on that instead of
1460
            // attempting to perfectly reproduce the parsing algorithm.
1461
            var dateStringLength = dateTimeString.length-(err.length-err.indexOf(':')-2);
1462
            var timeString = dateTimeString.substring(dateStringLength);
1463
1464
            return [dateTimeString.substring(0, dateStringLength), dateTimeString.substring(dateStringLength)];
1465
1466
        } else {
1467
            throw err;
1468
        }
1469
    }
1470
    return [dateTimeString, ''];
1471
};
1472
1473
//#######################################################################################
1474
// Internal function to parse datetime interval
1475
// Returns: {date: Date, timeObj: Object}, where
1476
//   date - parsed date without time (type Date)
1477
//   timeObj = {hour: , minute: , second: , millisec: } - parsed time. Optional
1478
//#######################################################################################
1479
var parseDateTimeInternal = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings)
1480
{
1481
    var date;
1482
    var splitRes = splitDateTime(dateFormat, dateTimeString, dateSettings);
1483
    date = $.datepicker._base_parseDate(dateFormat, splitRes[0], dateSettings);
1484
    if (splitRes[1] !== '')
1485
    {
1486
        var timeString = splitRes[1];
1487
        var separator = timeSettings && timeSettings.separator ? timeSettings.separator : $.timepicker._defaults.separator;
1488
        if ( timeString.indexOf(separator) !== 0) {
1489
            throw 'Missing time separator';
1490
        }
1491
        timeString = timeString.substring(separator.length);
1492
        var parsedTime = $.datepicker.parseTime(timeFormat, timeString, timeSettings);
1493
        if (parsedTime === null) {
1494
            throw 'Wrong time format';
1495
        }
1496
        return {date: date, timeObj: parsedTime};
1497
    } else {
1498
        return {date: date};
1499
    }
1500
};
1501
1502
//#######################################################################################
1503
// Internal function to set timezone_select to the local timezone
1504
//#######################################################################################
1505
var selectLocalTimeZone = function(tp_inst, date)
1506
{
1507
    if (tp_inst && tp_inst.timezone_select) {
1508
        tp_inst._defaults.useLocalTimezone = true;
1509
        var now = typeof date !== 'undefined' ? date : new Date();
1510
        var tzoffset = timeZoneString(now);
1511
        if (tp_inst._defaults.timezoneIso8601) {
1512
            tzoffset = tzoffset.substring(0, 3) + ':' + tzoffset.substring(3);
1513
        }
1514
        tp_inst.timezone_select.val(tzoffset);
1515
    }
1516
};
1517
1518
// Input: Date Object
1519
// Output: String with timezone offset, e.g. '+0100'
1520
var timeZoneString = function(date)
1521
{
1522
    var off = date.getTimezoneOffset() * -10100 / 60;
1523
    var timezone = (off >= 0 ? '+' : '-') + Math.abs(off).toString().substr(1);
1524
    return timezone;
1525
};
1526
1527
$.timepicker = new Timepicker(); // singleton instance
1528
$.timepicker.version = "1.0.1";
1529
1530
})(jQuery);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-1 / +2 lines)
Lines 18-24 Link Here
18
[% INCLUDE 'datatables-strings.inc' %]
18
[% INCLUDE 'datatables-strings.inc' %]
19
<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>[% END %]
19
<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>[% END %]
20
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
20
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
21
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery-ui-timepicker-addon.js"></script>
21
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery-ui-timepicker-addon.min.js"></script>
22
[% INCLUDE 'timepicker.inc' %]
22
<script type="text/javascript" src="[% themelang %]/js/pages/circulation.js"></script>
23
<script type="text/javascript" src="[% themelang %]/js/pages/circulation.js"></script>
23
<script type="text/javascript">
24
<script type="text/javascript">
24
//<![CDATA[
25
//<![CDATA[
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline-mf.tt (-1 / +1 lines)
Lines 21-27 CACHE: Link Here
21
[% themelang %]/js/basket.js
21
[% themelang %]/js/basket.js
22
[% themelang %]/js/offlinecirc.js
22
[% themelang %]/js/offlinecirc.js
23
[% themelang %]/js/staff-global.js
23
[% themelang %]/js/staff-global.js
24
[% themelang %]/lib/jquery/plugins/jquery-ui-timepicker-addon.js
24
[% interface %]/lib/jquery/plugins/jquery-ui-timepicker-addon.min.js
25
[% themelang %]/lib/yui/button/button-min.js
25
[% themelang %]/lib/yui/button/button-min.js
26
[% themelang %]/lib/yui/container/container_core-min.js
26
[% themelang %]/lib/yui/container/container_core-min.js
27
[% themelang %]/lib/yui/menu/menu-min.js
27
[% themelang %]/lib/yui/menu/menu-min.js
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt (-1 / +3 lines)
Lines 9-17 Link Here
9
<head>
9
<head>
10
<title>Koha &rsaquo; Circulation</title>
10
<title>Koha &rsaquo; Circulation</title>
11
[% INCLUDE 'doc-head-close.inc' %]
11
[% INCLUDE 'doc-head-close.inc' %]
12
[% INCLUDE 'calendar.inc' %]
12
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.indexeddb.js"></script>
13
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.indexeddb.js"></script>
13
<script type="text/javascript" src="[% interface %]/prog/en/js/offlinecirc.js"></script>
14
<script type="text/javascript" src="[% interface %]/prog/en/js/offlinecirc.js"></script>
14
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery-ui-timepicker-addon.js"></script>
15
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery-ui-timepicker-addon.min.js"></script>
16
[% INCLUDE 'timepicker.inc' %]
15
<script type="text/javascript">
17
<script type="text/javascript">
16
//<![CDATA[
18
//<![CDATA[
17
var ALERT_SUCCESSFUL_CHECKIN = _("Checked in item.");
19
var ALERT_SUCCESSFUL_CHECKIN = _("Checked in item.");
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-2 / +2 lines)
Lines 14-20 Link Here
14
[% INCLUDE 'datatables-strings.inc' %]
14
[% INCLUDE 'datatables-strings.inc' %]
15
<script type="text/javascript" src="[% interface %]/[% theme %]/en/js/datatables.js"></script>
15
<script type="text/javascript" src="[% interface %]/[% theme %]/en/js/datatables.js"></script>
16
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
16
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
17
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery-ui-timepicker-addon.js"></script>
17
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery-ui-timepicker-addon.min.js"></script>
18
[% INCLUDE 'timepicker.inc' %]
18
<script type="text/JavaScript">
19
<script type="text/JavaScript">
19
//<![CDATA[
20
//<![CDATA[
20
$(document).ready(function() {
21
$(document).ready(function() {
21
- 

Return to bug 11618