/*! jQuery-Mobile-DateBox |2014-10-03T17:22:11Z | (c) 2010, 2014 JTSage | https://github.com/jtsage/jquery-mobile-datebox/blob/master/LICENSE.txt */
!function(a){a.extend(a.mobile.datebox.prototype.options,{themeDatePick:"b",themeDate:"a",useSetButton:!0,validHours:!1,flen:{y:15,m:12,d:20,h:12,i:15},durationStep:1,durationSteppers:{d:1,h:1,i:1,s:1}}),a.extend(a.mobile.datebox.prototype,{_fbox_pos:function(){var b,c,d,e,f=this,g=this.d.intHTML.find(".ui-datebox-flipcontent").innerHeight();f.d.intHTML.find(".ui-datebox-flipcenter").each(function(){c=a(this),d=c.innerHeight(),c.css("top",-1*(g/2-d/2-3))}),f.d.intHTML.find("ul").each(function(){c=a(this),g=c.parent().innerHeight(),d=c.find("li").first(),e=c.find("li").last().offset().top-c.find("li").first().offset().top,b=-1*((e-g)/2+d.outerHeight()),d.css("marginTop",b)})},_fbox_fixstep:function(b){var c=this.options.durationSteppers,d=this.options.durationStep;a.inArray("h",b)>-1&&(c.d=1,c.h=d),a.inArray("i",b)>-1&&(c.h=1,c.i=d),a.inArray("s",b)>-1&&(c.i=1,c.s=d)},_fbox_series:function(a,b,c,d){for(var e,f,g=this.options,h="h"===c?24:60,i=[[a.toString(),a]],j=1;b>=j;j++)e=a+j*g.durationSteppers[c],f=a-j*g.durationSteppers[c],i.unshift([e.toString(),e]),i.push(f>-1?[f.toString(),f]:d?[(h+f).toString(),f]:["",-1]);return i},_fbox_mktxt:{y:function(a){return this.theDate.get(0)+a},m:function(a){var b=this.theDate.copy([0],[0,0,1]).adj(1,a);return this.__("monthsOfYearShort")[b.get(1)]},d:function(a){return this.theDate.copy([0,0,a]).get(2)},h:function(a){var b=this.theDate.copy([0,0,0,a]);return 12===this.__("timeFormat")?b.get12hr():b.get(3)},i:function(a){return this._zPad(this.theDate.copy([0,0,0,0,a]).get(4))}}}),a.extend(a.mobile.datebox.prototype._build,{timeflipbox:function(){this._build.flipbox.apply(this)},durationflipbox:function(){this._build.flipbox.apply(this)},flipbox:function(){var b,c,d,e,f,g,h,i,j=this,k=this.options,l=this.drag,m={},n=["d","h","i","s"],o="durationflipbox"===k.mode?!0:!1,p="ui-datebox-",q=a("
"),r=a("",{"class":p+"flipcontent"}),s=j.theDate.getTime()-j.initDate.getTime(),t=j._dur(0>s?0:s);if(0>s&&(j.lastDuration=0,o&&j.theDate.setTime(j.initDate.getTime())),"boolean"!=typeof j.d.intHTML?j.d.intHTML.empty().remove():j.d.input.on("datebox",function(a,b){"postrefresh"===b.method&&j._fbox_pos()}),j.d.headerText=j._grabLabel()!==!1?j._grabLabel():j.__("flipbox"===k.mode?"titleDateDialogLabel":"titleTimeDialogLabel"),j.d.intHTML=a(""),a(document).one("popupafteropen",function(){j._fbox_pos()}),j.fldOrder=j.__("flipbox"===k.mode?"dateFieldOrder":o?"durationOrder":"timeFieldOrder"),o||(j._check(),j._minStepFix()),"flipbox"===k.mode&&a("").appendTo(j.d.intHTML),o){for(j._fbox_fixstep(j.fldOrder),e=a(""),c=0;c"+j.__("durationLabel")[a.inArray(j.fldOrder[c],n)]+"
").appendTo(e);for(e.appendTo(j.d.intHTML),j.dateOK=!0,m.d=j._fbox_series(t[0],16,"d",!1),m.h=j._fbox_series(t[1],16,"h",t[0]>0),m.i=j._fbox_series(t[2],20,"i",t[0]>0||t[1]>0),m.s=j._fbox_series(t[3],20,"s",t[0]>0||t[1]>0||t[2]>0),r.addClass(p+"flipcontentd"),c=0;c"+m[g][b][0]+"").addClass("ui-body-"+(m[g][b][1]!==h?k.themeDate:k.themeDatePick)).appendTo(f);d.appendTo(r)}}for(c=0;c"+j._fbox_mktxt[h].apply(j,[b])+"").appendTo(f);d.appendTo(r)}if("a"===h&&12===j.__("timeFormat")){for(i=a(""),e=j.theDate.get(3)>11?[k.themeDate,k.themeDatePick,2,5]:[k.themeDatePick,k.themeDate,2,3],b=-1*e[2];bb||b>1?i.clone().appendTo(f):a("",{"class":"ui-body-"+e[b]}).html(""+j.__("meridiem")[b]+"").appendTo(f);d.appendTo(r)}}j.d.intHTML.append(r),a("",{"class":p+"flipcenter ui-overlay-shadow"}).css("pointerEvents","none").appendTo(j.d.intHTML),(k.useSetButton||k.useClearButton)&&(c=a("
",{"class":p+"controls"}),k.useSetButton&&c.append(j._stdBtn.close.apply(j,[j.__("datebox"===k.mode?"setDateButtonLabel":o?"setDurationButtonLabel":"setTimeButtonLabel")])),k.useClearButton&&c.append(j._stdBtn.clear.apply(j)),k.useCollapsedBut?(c.controlgroup({type:"horizontal"}),c.addClass("ui-datebox-collapse")):c.controlgroup(),c.appendTo(j.d.intHTML)),j.wheelExists&&j.d.intHTML.on("mousewheel",".ui-overlay-shadow",function(b,c){b.preventDefault(),j._offset(a(this).data("field"),(0>c?-1:1)*a(this).data("amount"))}),j.d.intHTML.on(l.eStart,"ul",function(b,c){l.move||("undefined"!=typeof c&&(b=c),l.move=!0,l.target=a(this).find("li").first(),l.pos=parseInt(l.target.css("marginTop").replace(/px/i,""),10),l.start=j.touch?b.originalEvent.changedTouches[0].pageY:b.pageY,l.end=!1,l.direc=o?-1:1,b.stopPropagation(),b.preventDefault())})}}),a.extend(a.mobile.datebox.prototype._drag,{timeflipbox:function(){this._drag.flipbox.apply(this)},durationflipbox:function(){this._drag.flipbox.apply(this)},flipbox:function(){var b=this,c=this.options,d=this.drag;a(document).on(d.eMove,function(a){return d.move&&"flipbox"===c.mode.slice(-7)?(d.end=b.touch?a.originalEvent.changedTouches[0].pageY:a.pageY,d.target.css("marginTop",d.pos+d.end-d.start+"px"),a.preventDefault(),a.stopPropagation(),!1):void 0}),a(document).on(d.eEnd,function(a){d.move&&"flipbox"===c.mode.slice(-7)&&(d.move=!1,d.end!==!1&&(a.preventDefault(),a.stopPropagation(),d.tmp=d.target.parent().parent(),b._offset(d.tmp.data("field"),parseInt((d.start-d.end)/(d.target.outerHeight()-2),10)*d.tmp.data("amount")*d.direc)),d.start=!1,d.end=!1)})}})}(jQuery);