/*! * jQuery timepicker addon * By: Trent Richardson [http://trentrichardson.com] * Version 0.9.6 * Last Modified: 07/20/2011 * * Copyright 2011 Trent Richardson * Dual licensed under the MIT and GPL licenses. * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt * http://trentrichardson.com/Impromptu/MIT-LICENSE.txt */ (function($){function extendRemove(a,b){$.extend(a,b);for(var c in b)if(b[c]===null||b[c]===undefined)a[c]=b[c];return a}function Timepicker(){this.regional=[];this.regional[""]={currentText:"Now",closeText:"Done",ampm:false,timeFormat:"hh:mm tt",timeSuffix:"",timeOnlyTitle:"Choose Time",timeText:"Time",hourText:"Hour",minuteText:"Minute",secondText:"Second",timezoneText:"Time Zone"};this._defaults={showButtonPanel:true,timeOnly:false,showHour:true,showMinute:true,showSecond:false,showTimezone:false,showTime:true,stepHour:.05,stepMinute:.05,stepSecond:.05,hour:0,minute:0,second:0,timezone:"+0000",hourMin:0,minuteMin:0,secondMin:0,hourMax:23,minuteMax:59,secondMax:59,minDateTime:null,maxDateTime:null,hourGrid:0,minuteGrid:0,secondGrid:0,alwaysSetTime:true,separator:" ",altFieldTimeOnly:true,showTimepicker:true,timezoneList:["-1100","-1000","-0900","-0800","-0700","-0600","-0500","-0400","-0300","-0200","-0100","+0000","+0100","+0200","+0300","+0400","+0500","+0600","+0700","+0800","+0900","+1000","+1100","+1200"]};$.extend(this._defaults,this.regional[""])}$.extend($.ui,{timepicker:{version:"0.9.6"}});$.extend(Timepicker.prototype,{$input:null,$altInput:null,$timeObj:null,inst:null,hour_slider:null,minute_slider:null,second_slider:null,timezone_select:null,hour:0,minute:0,second:0,timezone:"+0000",hourMinOriginal:null,minuteMinOriginal:null,secondMinOriginal:null,hourMaxOriginal:null,minuteMaxOriginal:null,secondMaxOriginal:null,ampm:"",formattedDate:"",formattedTime:"",formattedDateTime:"",timezoneList:["-1100","-1000","-0900","-0800","-0700","-0600","-0500","-0400","-0300","-0200","-0100","+0000","+0100","+0200","+0300","+0400","+0500","+0600","+0700","+0800","+0900","+1000","+1100","+1200"],setDefaults:function(a){extendRemove(this._defaults,a||{});return this},_newInst:function($input,o){var tp_inst=new Timepicker,inlineSettings={};for(var attrName in this._defaults){var attrValue=$input.attr("time:"+attrName);if(attrValue){try{inlineSettings[attrName]=eval(attrValue)}catch(err){inlineSettings[attrName]=attrValue}}}tp_inst._defaults=$.extend({},this._defaults,inlineSettings,o,{beforeShow:function(a,b){if($.isFunction(o.beforeShow))o.beforeShow(a,b,tp_inst)},onChangeMonthYear:function(a,b,c){tp_inst._updateDateTime(c);if($.isFunction(o.onChangeMonthYear))o.onChangeMonthYear.call($input[0],a,b,c,tp_inst)},onClose:function(a,b){if(tp_inst.timeDefined===true&&$input.val()!="")tp_inst._updateDateTime(b);if($.isFunction(o.onClose))o.onClose.call($input[0],a,b,tp_inst)},timepicker:tp_inst});tp_inst.hour=tp_inst._defaults.hour;tp_inst.minute=tp_inst._defaults.minute;tp_inst.second=tp_inst._defaults.second;tp_inst.ampm="";tp_inst.$input=$input;if(o.altField)tp_inst.$altInput=$(o.altField).css({cursor:"pointer"}).focus(function(){$input.trigger("focus")});if(tp_inst._defaults.minDate!==undefined&&tp_inst._defaults.minDate instanceof Date)tp_inst._defaults.minDateTime=new Date(tp_inst._defaults.minDate.getTime());if(tp_inst._defaults.minDateTime!==undefined&&tp_inst._defaults.minDateTime instanceof Date)tp_inst._defaults.minDate=new Date(tp_inst._defaults.minDateTime.getTime());if(tp_inst._defaults.maxDate!==undefined&&tp_inst._defaults.maxDate instanceof Date)tp_inst._defaults.maxDateTime=new Date(tp_inst._defaults.maxDate.getTime());if(tp_inst._defaults.maxDateTime!==undefined&&tp_inst._defaults.maxDateTime instanceof Date)tp_inst._defaults.maxDate=new Date(tp_inst._defaults.maxDateTime.getTime());return tp_inst},_addTimePicker:function(a){var b=this.$altInput&&this._defaults.altFieldTimeOnly?this.$input.val()+" "+this.$altInput.val():this.$input.val();this.timeDefined=this._parseTime(b);this._limitMinMaxDateTime(a,false);this._injectTimePicker()},_parseTime:function(a,b){var c=this._defaults.timeFormat.toString().replace(/h{1,2}/ig,"(\\d?\\d)").replace(/m{1,2}/ig,"(\\d?\\d)").replace(/s{1,2}/ig,"(\\d?\\d)").replace(/t{1,2}/ig,"(am|pm|a|p)?").replace(/z{1}/ig,"((\\+|-)\\d\\d\\d\\d)?").replace(/\s/g,"\\s?")+this._defaults.timeSuffix+"$",d=this._getFormatPositions(),e;if(!this.inst)this.inst=$.datepicker._getInst(this.$input[0]);if(b||!this._defaults.timeOnly){var f=$.datepicker._get(this.inst,"dateFormat");var g=new RegExp("[.*+?|()\\[\\]{}\\\\]","g");c=".{"+f.length+",}"+this._defaults.separator.replace(g,"\\$&")+c}e=a.match(new RegExp(c,"i"));if(e){if(d.t!==-1)this.ampm=(e[d.t]===undefined||e[d.t].length===0?"":e[d.t].charAt(0).toUpperCase()=="A"?"AM":"PM").toUpperCase();if(d.h!==-1){if(this.ampm=="AM"&&e[d.h]=="12")this.hour=0;else if(this.ampm=="PM"&&e[d.h]!="12")this.hour=(parseFloat(e[d.h])+12).toFixed(0);else this.hour=Number(e[d.h])}if(d.m!==-1)this.minute=Number(e[d.m]);if(d.s!==-1)this.second=Number(e[d.s]);if(d.z!==-1)this.timezone=e[d.z];return true}return false},_getFormatPositions:function(){var a=this._defaults.timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|t{1,2}|z)/g),b={h:-1,m:-1,s:-1,t:-1,z:-1};if(a)for(var c=0;c
'+'
"+b.timeText+"
"+'
"+'
"+b.hourText+"
",j=0,k=0,l=0,m;if(b.showHour&&b.hourGrid>0){i+='
'+'
"+'
';for(var n=b.hourMin;n<=d;n+=b.hourGrid){j++;var o=b.ampm&&n>12?n-12:n;if(o<10)o="0"+o;if(b.ampm){if(n==0)o=12+"a";else if(n<12)o+="a";else o+="p"}i+=""}i+="
"+o+"
"+"
"}else i+='
";i+='
"+b.minuteText+"
";if(b.showMinute&&b.minuteGrid>0){i+='
'+'
"+'
';for(var p=b.minuteMin;p<=e;p+=b.minuteGrid){k++;i+=""}i+="
"+(p<10?"0":"")+p+"
"+"
"}else i+='
";i+='
"+b.secondText+"
";if(b.showSecond&&b.secondGrid>0){i+='
'+'
"+'
';for(var q=b.secondMin;q<=f;q+=b.secondGrid){l++;i+=""}i+="
"+(q<10?"0":"")+q+"
"+"
"}else i+='
";i+='
"+b.timezoneText+"
";i+='
";i+="
";$tp=$(i);if(b.timeOnly===true){$tp.prepend('
'+'
'+b.timeOnlyTitle+"
"+"
");a.find(".ui-datepicker-header, .ui-datepicker-calendar").hide()}this.hour_slider=$tp.find("#ui_tpicker_hour_"+g).slider({orientation:"horizontal",value:this.hour,min:b.hourMin,max:d,step:b.stepHour,slide:function(a,b){c.hour_slider.slider("option","value",b.value);c._onTimeChange()}});this.minute_slider=$tp.find("#ui_tpicker_minute_"+g).slider({orientation:"horizontal",value:this.minute,min:b.minuteMin,max:e,step:b.stepMinute,slide:function(a,b){c.minute_slider.slider("option","value",b.value);c._onTimeChange()}});this.second_slider=$tp.find("#ui_tpicker_second_"+g).slider({orientation:"horizontal",value:this.second,min:b.secondMin,max:f,step:b.stepSecond,slide:function(a,b){c.second_slider.slider("option","value",b.value);c._onTimeChange()}});this.timezone_select=$tp.find("#ui_tpicker_timezone_"+g).append("").find("select");$.fn.append.apply(this.timezone_select,$.map(b.timezoneList,function(a,b){return $("