This repository was archived by the owner on Feb 19, 2020. It is now read-only.
forked from rbiggs/chocolatechip-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchui.min.js
12 lines (11 loc) · 69.9 KB
/
chui.min.js
1
2
3
4
5
6
7
8
9
10
11
12
/*
ChocolateChip-UI
ChUI.js
Copyright 2011 Robert Biggs: www.chocolatechip-ui.com
License: BSD
Version: 1.1.4
Includes:
iScroll v4.1.9 ~ Copyright (c) 2011 Matteo Spinelli, http://cubiq.org
Released under MIT license, http://cubiq.org/license
*/
(function($,w){window.CHUIVersion='1.1.4';var z='1.3.7';var A=function(){if($.version!==z){console.error('This version of ChocolateChip-UI requries ChococlateChip.js version '+z+'!');console.error('The version of ChocolateChip.js which you are using is: '+$.version);console.error('ChocolateChip.js has been disabled until this problem is resolved.');window.$=null}};A();$(function(){$.body=$('body');$.app=$('app');$.main=$('#main');$.views=w('view');if(!$.touchEnabled){var a=$('head').find('link[rel=stylesheet]').href;var b=a.replace(/chui\.css/,'chui.desktop.css');console.log('Desktop: '+b);$('head').append('<link rel="stylesheet" href="'+b+'">')}if($.touchEnabled)$.userAction='touchstart'});$.tablet=false;if(window.innerWidth>600){$.tablet=true}$.extend({UIUuidSeed:function(a){if(a){return(((1+Math.random())*0x10000)|0).toString(a).substring(1)}else{return(((1+Math.random())*0x10000)|0).toString(16).substring(1)}},AlphaSeed:function(){var a='';var b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';a+=b.charAt(Math.floor(Math.random()*b.length));return a},UIUuid:function(){return($.AlphaSeed()+$.UIUuidSeed(20)+$.UIUuidSeed()+'-'+$.UIUuidSeed()+'-'+$.UIUuidSeed()+'-'+$.UIUuidSeed()+'-'+$.UIUuidSeed()+$.UIUuidSeed()+$.UIUuidSeed())},resetApp:function(b){if(b==='hard'){window.location.reload(true)}else{$.views.each(function(a){a.setAttribute('ui-navigation-status','upcoming')});$.main.setAttribute('ui-navigation-status','current');$.UINavigationHistory=['#main']}}});$.extend(HTMLElement.prototype,{UIIdentifyChildNodes:function(){var a=this.childElementCount;for(var i=0;i<a;i++){this.children[i].setAttribute('ui-child-position',i)}}});$.extend(HTMLElement.prototype,{UIHandleTouchState:function(a){if($.UIScrollingActive)return;a=a||200;var b=this;if($.mobile){this.addClass('touched');setTimeout(function(){b.removeClass('touched')},a)}},UIToggleButtonLabel:function(a,b){if($('label',this).text()===a){$('label',this).text(b)}else{$('label',this).text(a)}}});$(function(){$.app.delegate('uibutton','touchstart',function(a){if(a.hasClass('disabled')){return false}else{a.UIHandleTouchState()}})});$.extend({UINavigationHistory:['#main'],UINavigateBack:function(){var a=$.UINavigationHistory[$.UINavigationHistory.length-1];$.UINavigationHistory.pop();$($.UINavigationHistory[$.UINavigationHistory.length-1]).setAttribute('ui-navigation-status','current');$(a).setAttribute('ui-navigation-status','upcoming');$.UIHideURLbar();if($.app.getAttribute('ui-kind')==='navigation-with-one-navbar'&&$.UINavigationHistory[$.UINavigationHistory.length-1]==='#main'){$('navbar > uibutton[ui-implements=back]',$.app).css('display','none')}},UINavigateToNextView:function(a){$($.UINavigationHistory[$.UINavigationHistory.length-1]).setAttribute('ui-navigation-status','traversed');$(a).setAttribute('ui-navigation-status','current');$.UINavigationHistory.push(a);if($.app.getAttribute('ui-kind')==='navigation-with-one-navbar'){$('navbar uibutton[ui-implements=back]').css({'display':'block'})}},UIDoubleTapDelta:700,UIDoubleTapTimer:null,UIDoubleTapFunction1:null,UIDoubleTapFunction2:null,UIDoubleTapTimeout:function(){$.UIDoubleTapFunction1();$.UIDoubleTapTimer=null},UIDoubleTap:function(a,b){if($.UIDoubleTapTimer===null){$.UIDoubleTapTimer=setTimeout($.UIDoubleTapTimeout,$.UIDoubleTapDelta);$.UIDoubleTapFunction1=a;$.UIDoubleTapFunction2=b}else{$.UIDoubleTapTimer=null;$.UIDoubleTapFunction2()}},UINavigationEvent:false,UINavigationEnabled:false,UINavigationList:function(){var b=function(a){try{if($.app.getAttribute('ui-kind')==='navigation-with-one-navbar'){$('navbar > uibutton[ui-implements=back]',$.app).css('display: block;')}$(a.getAttribute('href')).setAttribute('ui-navigation-status','current');$($.UINavigationHistory[$.UINavigationHistory.length-1]).setAttribute('ui-navigation-status','traversed');if($('#main').getAttribute('ui-navigation-status')!=='traversed'){$('#main').setAttribute('ui-navigation-status','traversed')}$.UINavigationHistory.push(a.getAttribute('href'));$.UIHideURLbar()}catch(err){}};$.app.delegate('tablecell',$.userAction,function(a){if(a.hasAttribute('href')){setTimeout(function(){a.UIHandleTouchState()},100);if($.UINavigationEvent){return}else{$.UINavigationEnabled=true;$.UINavigationEvent=false;b(a);$.UINavigationEvent=true}}})},UITouchedTableCell:null});$(function(){$.app.delegate('uibutton',$.userAction,function(a){if(a.getAttribute('ui-implements')==='back'){try{$.UINavigateBack()}catch(err){}}});$.UINavigationList();$.app.delegate('view','webkitTransitionEnd',function(){if(!$('view[ui-navigation-status=current]')){$($.UINavigationHistory[$.UINavigationHistory.length-2]).setAttribute('ui-navigation-status','current');$.UINavigationHistory.pop()}$.UINavigationEvent=false})});$.UIScrollingActive=false;(function(){var m=Math,mround=function(r){return r>>0},vendor=(/webkit/i).test(navigator.appVersion)?'webkit':(/firefox/i).test(navigator.userAgent)?'Moz':(/trident/i).test(navigator.userAgent)?'ms':'opera'in window?'O':'',isAndroid=(/android/gi).test(navigator.appVersion),isIDevice=(/iphone|ipad/gi).test(navigator.appVersion),isPlaybook=(/playbook/gi).test(navigator.appVersion),isTouchPad=(/hp-tablet/gi).test(navigator.appVersion),has3d='WebKitCSSMatrix'in window&&'m11'in new WebKitCSSMatrix(),hasTouch='ontouchstart'in window&&!isTouchPad,hasTransform=vendor+'Transform'in document.documentElement.style,hasTransitionEnd=isIDevice||isPlaybook,nextFrame=(function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){return setTimeout(a,1)}})(),cancelFrame=(function(){return window.cancelRequestAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||clearTimeout})(),RESIZE_EV='onorientationchange'in window?'orientationchange':'resize',START_EV=hasTouch?'touchstart':'mousedown',MOVE_EV=hasTouch?'touchmove':'mousemove',END_EV=hasTouch?'touchend':'mouseup',CANCEL_EV=hasTouch?'touchcancel':'mouseup',WHEEL_EV=vendor=='Moz'?'DOMMouseScroll':'mousewheel',trnOpen='translate'+(has3d?'3d(':'('),trnClose=has3d?',0)':')',iScroll=function(a,b){var c=this,doc=document,i;c.wrapper=typeof a=='object'?a:doc.querySelector(a);c.wrapper.style.overflow='hidden';c.scroller=c.wrapper.children[0];c.options={hScroll:true,vScroll:true,x:0,y:0,bounce:true,bounceLock:false,momentum:true,lockDirection:true,useTransform:true,useTransition:false,topOffset:0,checkDOMChanges:false,hScrollbar:true,vScrollbar:true,fixedScrollbar:isAndroid,hideScrollbar:isIDevice,fadeScrollbar:isIDevice&&has3d,scrollbarClass:'',zoom:false,zoomMin:1,zoomMax:4,doubleTapZoom:2,wheelAction:'scroll',snap:false,snapThreshold:1,onRefresh:null,onBeforeScrollStart:function(e){e.preventDefault()},onScrollStart:null,onBeforeScrollMove:null,onScrollMove:null,onBeforeScrollEnd:null,onScrollEnd:null,onTouchEnd:null,onDestroy:null,onZoomStart:null,onZoom:null,onZoomEnd:null};for(i in b)c.options[i]=b[i];c.x=c.options.x;c.y=c.options.y;c.options.useTransform=hasTransform?c.options.useTransform:false;c.options.hScrollbar=c.options.hScroll&&c.options.hScrollbar;c.options.vScrollbar=c.options.vScroll&&c.options.vScrollbar;c.options.zoom=c.options.useTransform&&c.options.zoom;c.options.useTransition=hasTransitionEnd&&c.options.useTransition;if(c.options.zoom&&isAndroid){trnOpen='translate(';trnClose=')'}c.scroller.style[vendor+'TransitionProperty']=c.options.useTransform?'-'+vendor.toLowerCase()+'-transform':'top left';c.scroller.style[vendor+'TransitionDuration']='0';c.scroller.style[vendor+'TransformOrigin']='0 0';if(c.options.useTransition)c.scroller.style[vendor+'TransitionTimingFunction']='cubic-bezier(0.33,0.66,0.66,1)';if(c.options.useTransform)c.scroller.style[vendor+'Transform']=trnOpen+c.x+'px,'+c.y+'px'+trnClose;else c.scroller.style.cssText+=';position:absolute;top:'+c.y+'px;left:'+c.x+'px';if(c.options.useTransition)c.options.fixedScrollbar=true;c.refresh();c._bind(RESIZE_EV,window);c._bind(START_EV);if(!hasTouch){c._bind('mouseout',c.wrapper);if(c.options.wheelAction!='none')c._bind(WHEEL_EV)}if(c.options.checkDOMChanges)c.checkDOMTime=setInterval(function(){c._checkDOMChanges()},500)};iScroll.prototype={enabled:true,x:0,y:0,steps:[],scale:1,currPageX:0,currPageY:0,pagesX:[],pagesY:[],aniTime:null,wheelZoomCount:0,handleEvent:function(e){var a=this;switch(e.type){case START_EV:if(!hasTouch&&e.button!==0)return;if(e.target.tagName==="TEXTAREA")return;if(e.target.tagName==="INPUT")return;if(e.target.tagName==="SELECT")return;a._start(e);break;case MOVE_EV:a._move(e);break;case END_EV:case CANCEL_EV:a._end(e);break;case RESIZE_EV:a._resize();break;case WHEEL_EV:a._wheel(e);break;case'mouseout':a._mouseout(e);break;case'webkitTransitionEnd':a._transitionEnd(e);break}},_checkDOMChanges:function(){if(this.moved||this.zoomed||this.animating||(this.scrollerW==this.scroller.offsetWidth*this.scale&&this.scrollerH==this.scroller.offsetHeight*this.scale))return;this.refresh()},_scrollbar:function(a){var b=this,doc=document,bar;if(!b[a+'Scrollbar']){if(b[a+'ScrollbarWrapper']){if(hasTransform)b[a+'ScrollbarIndicator'].style[vendor+'Transform']='';b[a+'ScrollbarWrapper'].parentNode.removeChild(b[a+'ScrollbarWrapper']);b[a+'ScrollbarWrapper']=null;b[a+'ScrollbarIndicator']=null}return}if(!b[a+'ScrollbarWrapper']){bar=doc.createElement('div');if(b.options.scrollbarClass)bar.className=b.options.scrollbarClass+a.toUpperCase();else bar.style.cssText='position:absolute;z-index:100;'+(a=='h'?'height:7px;bottom:1px;left:2px;right:'+(b.vScrollbar?'7':'2')+'px':'width:7px;bottom:'+(b.hScrollbar?'7':'2')+'px;top:2px;right:1px');bar.style.cssText+=';pointer-events:none;-'+vendor+'-transition-property:opacity;-'+vendor+'-transition-duration:'+(b.options.fadeScrollbar?'350ms':'0')+';overflow:hidden;opacity:'+(b.options.hideScrollbar?'0':'1');b.wrapper.appendChild(bar);b[a+'ScrollbarWrapper']=bar;bar=doc.createElement('div');if(!b.options.scrollbarClass){bar.style.cssText='position:absolute;z-index:100;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);-'+vendor+'-background-clip:padding-box;-'+vendor+'-box-sizing:border-box;'+(a=='h'?'height:100%':'width:100%')+';-'+vendor+'-border-radius:3px;border-radius:3px'}bar.style.cssText+=';pointer-events:none;-'+vendor+'-transition-property:-'+vendor+'-transform;-'+vendor+'-transition-timing-function:cubic-bezier(0.33,0.66,0.66,1);-'+vendor+'-transition-duration:0;-'+vendor+'-transform:'+trnOpen+'0,0'+trnClose;if(b.options.useTransition)bar.style.cssText+=';-'+vendor+'-transition-timing-function:cubic-bezier(0.33,0.66,0.66,1)';b[a+'ScrollbarWrapper'].appendChild(bar);b[a+'ScrollbarIndicator']=bar}if(a=='h'){b.hScrollbarSize=b.hScrollbarWrapper.clientWidth;b.hScrollbarIndicatorSize=m.max(mround(b.hScrollbarSize*b.hScrollbarSize/b.scrollerW),8);b.hScrollbarIndicator.style.width=b.hScrollbarIndicatorSize+'px';b.hScrollbarMaxScroll=b.hScrollbarSize-b.hScrollbarIndicatorSize;b.hScrollbarProp=b.hScrollbarMaxScroll/b.maxScrollX}else{b.vScrollbarSize=b.vScrollbarWrapper.clientHeight;b.vScrollbarIndicatorSize=m.max(mround(b.vScrollbarSize*b.vScrollbarSize/b.scrollerH),8);b.vScrollbarIndicator.style.height=b.vScrollbarIndicatorSize+'px';b.vScrollbarMaxScroll=b.vScrollbarSize-b.vScrollbarIndicatorSize;b.vScrollbarProp=b.vScrollbarMaxScroll/b.maxScrollY}b._scrollbarPos(a,true)},_resize:function(){var a=this;setTimeout(function(){a.refresh()},isAndroid?200:0)},_pos:function(x,y){x=this.hScroll?x:0;y=this.vScroll?y:0;if(this.options.useTransform){this.scroller.style[vendor+'Transform']=trnOpen+x+'px,'+y+'px'+trnClose+' scale('+this.scale+')'}else{x=mround(x);y=mround(y);this.scroller.style.left=x+'px';this.scroller.style.top=y+'px'}this.x=x;this.y=y;this._scrollbarPos('h');this._scrollbarPos('v')},_scrollbarPos:function(a,b){var c=this,pos=a=='h'?c.x:c.y,size;if(!c[a+'Scrollbar'])return;pos=c[a+'ScrollbarProp']*pos;if(pos<0){if(!c.options.fixedScrollbar){size=c[a+'ScrollbarIndicatorSize']+mround(pos*3);if(size<8)size=8;c[a+'ScrollbarIndicator'].style[a=='h'?'width':'height']=size+'px'}pos=0}else if(pos>c[a+'ScrollbarMaxScroll']){if(!c.options.fixedScrollbar){size=c[a+'ScrollbarIndicatorSize']-mround((pos-c[a+'ScrollbarMaxScroll'])*3);if(size<8)size=8;c[a+'ScrollbarIndicator'].style[a=='h'?'width':'height']=size+'px';pos=c[a+'ScrollbarMaxScroll']+(c[a+'ScrollbarIndicatorSize']-size)}else{pos=c[a+'ScrollbarMaxScroll']}}c[a+'ScrollbarWrapper'].style[vendor+'TransitionDelay']='0';c[a+'ScrollbarWrapper'].style.opacity=b&&c.options.hideScrollbar?'0':'1';c[a+'ScrollbarIndicator'].style[vendor+'Transform']=trnOpen+(a=='h'?pos+'px,0':'0,'+pos+'px')+trnClose},_start:function(e){var a=this,point=hasTouch?e.touches[0]:e,matrix,x,y,c1,c2;if(!a.enabled)return;if(a.options.onBeforeScrollStart)a.options.onBeforeScrollStart.call(a,e);if(a.options.useTransition||a.options.zoom)a._transitionTime(0);a.moved=false;a.animating=false;a.zoomed=false;a.distX=0;a.distY=0;a.absDistX=0;a.absDistY=0;a.dirX=0;a.dirY=0;if(a.options.zoom&&hasTouch&&e.touches.length>1){c1=m.abs(e.touches[0].pageX-e.touches[1].pageX);c2=m.abs(e.touches[0].pageY-e.touches[1].pageY);a.touchesDistStart=m.sqrt(c1*c1+c2*c2);a.originX=m.abs(e.touches[0].pageX+e.touches[1].pageX-a.wrapperOffsetLeft*2)/2-a.x;a.originY=m.abs(e.touches[0].pageY+e.touches[1].pageY-a.wrapperOffsetTop*2)/2-a.y;if(a.options.onZoomStart)a.options.onZoomStart.call(a,e)}if(a.options.momentum){if(a.options.useTransform){matrix=getComputedStyle(a.scroller,null)[vendor+'Transform'].replace(/[^0-9-.,]/g,'').split(',');x=matrix[4]*1;y=matrix[5]*1}else{x=getComputedStyle(a.scroller,null).left.replace(/[^0-9-]/g,'')*1;y=getComputedStyle(a.scroller,null).top.replace(/[^0-9-]/g,'')*1}if(x!=a.x||y!=a.y){if(a.options.useTransition)a._unbind('webkitTransitionEnd');else cancelFrame(a.aniTime);a.steps=[];a._pos(x,y)}}a.absStartX=a.x;a.absStartY=a.y;a.startX=a.x;a.startY=a.y;a.pointX=point.pageX;a.pointY=point.pageY;a.startTime=e.timeStamp||Date.now();if(a.options.onScrollStart)a.options.onScrollStart.call(a,e);a._bind(MOVE_EV);a._bind(END_EV);a._bind(CANCEL_EV)},_move:function(e){$.UIScrollingActive=true;var a=this,point=hasTouch?e.touches[0]:e,deltaX=point.pageX-a.pointX,deltaY=point.pageY-a.pointY,newX=a.x+deltaX,newY=a.y+deltaY,c1,c2,scale,timestamp=e.timeStamp||Date.now();if(a.options.onBeforeScrollMove)a.options.onBeforeScrollMove.call(a,e);if(a.options.zoom&&hasTouch&&e.touches.length>1){c1=m.abs(e.touches[0].pageX-e.touches[1].pageX);c2=m.abs(e.touches[0].pageY-e.touches[1].pageY);a.touchesDist=m.sqrt(c1*c1+c2*c2);a.zoomed=true;scale=1/a.touchesDistStart*a.touchesDist*this.scale;if(scale<a.options.zoomMin)scale=0.5*a.options.zoomMin*Math.pow(2.0,scale/a.options.zoomMin);else if(scale>a.options.zoomMax)scale=2.0*a.options.zoomMax*Math.pow(0.5,a.options.zoomMax/scale);a.lastScale=scale/this.scale;newX=this.originX-this.originX*a.lastScale+this.x,newY=this.originY-this.originY*a.lastScale+this.y;this.scroller.style[vendor+'Transform']=trnOpen+newX+'px,'+newY+'px'+trnClose+' scale('+scale+')';if(a.options.onZoom)a.options.onZoom.call(a,e);return}a.pointX=point.pageX;a.pointY=point.pageY;if(newX>0||newX<a.maxScrollX){newX=a.options.bounce?a.x+(deltaX/2):newX>=0||a.maxScrollX>=0?0:a.maxScrollX}if(newY>a.minScrollY||newY<a.maxScrollY){newY=a.options.bounce?a.y+(deltaY/2):newY>=a.minScrollY||a.maxScrollY>=0?a.minScrollY:a.maxScrollY}a.distX+=deltaX;a.distY+=deltaY;a.absDistX=m.abs(a.distX);a.absDistY=m.abs(a.distY);if(a.absDistX<6&&a.absDistY<6){return}if(a.options.lockDirection){if(a.absDistX>a.absDistY+5){newY=a.y;deltaY=0}else if(a.absDistY>a.absDistX+5){newX=a.x;deltaX=0}}a.moved=true;a._pos(newX,newY);a.dirX=deltaX>0?-1:deltaX<0?1:0;a.dirY=deltaY>0?-1:deltaY<0?1:0;if(timestamp-a.startTime>300){a.startTime=timestamp;a.startX=a.x;a.startY=a.y}if(a.options.onScrollMove)a.options.onScrollMove.call(a,e)},_end:function(e){$.UIScrollingActive=false;if(hasTouch&&e.touches.length!=0)return;var a=this,point=hasTouch?e.changedTouches[0]:e,target,ev,momentumX={dist:0,time:0},momentumY={dist:0,time:0},duration=(e.timeStamp||Date.now())-a.startTime,newPosX=a.x,newPosY=a.y,distX,distY,newDuration,snap,scale;a._unbind(MOVE_EV);a._unbind(END_EV);a._unbind(CANCEL_EV);if(a.options.onBeforeScrollEnd)a.options.onBeforeScrollEnd.call(a,e);if(a.zoomed){scale=a.scale*a.lastScale;scale=Math.max(a.options.zoomMin,scale);scale=Math.min(a.options.zoomMax,scale);a.lastScale=scale/a.scale;a.scale=scale;a.x=a.originX-a.originX*a.lastScale+a.x;a.y=a.originY-a.originY*a.lastScale+a.y;a.scroller.style[vendor+'TransitionDuration']='200ms';a.scroller.style[vendor+'Transform']=trnOpen+a.x+'px,'+a.y+'px'+trnClose+' scale('+a.scale+')';a.zoomed=false;a.refresh();if(a.options.onZoomEnd)a.options.onZoomEnd.call(a,e);return}if(!a.moved){if(hasTouch){if(a.doubleTapTimer&&a.options.zoom){clearTimeout(a.doubleTapTimer);a.doubleTapTimer=null;if(a.options.onZoomStart)a.options.onZoomStart.call(a,e);a.zoom(a.pointX,a.pointY,a.scale==1?a.options.doubleTapZoom:1);if(a.options.onZoomEnd){setTimeout(function(){a.options.onZoomEnd.call(a,e)},200)}}else{a.doubleTapTimer=setTimeout(function(){a.doubleTapTimer=null;target=point.target;while(target.nodeType!=1)target=target.parentNode;if(target.tagName!='SELECT'&&target.tagName!='INPUT'&&target.tagName!='TEXTAREA'){ev=document.createEvent('MouseEvents');ev.initMouseEvent('click',true,true,e.view,1,point.screenX,point.screenY,point.clientX,point.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,0,null);ev._fake=true;target.dispatchEvent(ev)}},a.options.zoom?250:0)}}a._resetPos(200);if(a.options.onTouchEnd)a.options.onTouchEnd.call(a,e);return}if(duration<300&&a.options.momentum){momentumX=newPosX?a._momentum(newPosX-a.startX,duration,-a.x,a.scrollerW-a.wrapperW+a.x,a.options.bounce?a.wrapperW:0):momentumX;momentumY=newPosY?a._momentum(newPosY-a.startY,duration,-a.y,(a.maxScrollY<0?a.scrollerH-a.wrapperH+a.y-a.minScrollY:0),a.options.bounce?a.wrapperH:0):momentumY;newPosX=a.x+momentumX.dist;newPosY=a.y+momentumY.dist;if((a.x>0&&newPosX>0)||(a.x<a.maxScrollX&&newPosX<a.maxScrollX))momentumX={dist:0,time:0};if((a.y>a.minScrollY&&newPosY>a.minScrollY)||(a.y<a.maxScrollY&&newPosY<a.maxScrollY))momentumY={dist:0,time:0}}if(momentumX.dist||momentumY.dist){newDuration=m.max(m.max(momentumX.time,momentumY.time),10);if(a.options.snap){distX=newPosX-a.absStartX;distY=newPosY-a.absStartY;if(m.abs(distX)<a.options.snapThreshold&&m.abs(distY)<a.options.snapThreshold){a.scrollTo(a.absStartX,a.absStartY,200)}else{snap=a._snap(newPosX,newPosY);newPosX=snap.x;newPosY=snap.y;newDuration=m.max(snap.time,newDuration)}}a.scrollTo(mround(newPosX),mround(newPosY),newDuration);if(a.options.onTouchEnd)a.options.onTouchEnd.call(a,e);return}if(a.options.snap){distX=newPosX-a.absStartX;distY=newPosY-a.absStartY;if(m.abs(distX)<a.options.snapThreshold&&m.abs(distY)<a.options.snapThreshold)a.scrollTo(a.absStartX,a.absStartY,200);else{snap=a._snap(a.x,a.y);if(snap.x!=a.x||snap.y!=a.y)a.scrollTo(snap.x,snap.y,snap.time)}if(a.options.onTouchEnd)a.options.onTouchEnd.call(a,e);return}a._resetPos(200);if(a.options.onTouchEnd)a.options.onTouchEnd.call(a,e)},_resetPos:function(a){var b=this,resetX=b.x>=0?0:b.x<b.maxScrollX?b.maxScrollX:b.x,resetY=b.y>=b.minScrollY||b.maxScrollY>0?b.minScrollY:b.y<b.maxScrollY?b.maxScrollY:b.y;if(resetX==b.x&&resetY==b.y){if(b.moved){b.moved=false;if(b.options.onScrollEnd)b.options.onScrollEnd.call(b)}if(b.hScrollbar&&b.options.hideScrollbar){if(vendor=='webkit')b.hScrollbarWrapper.style[vendor+'TransitionDelay']='300ms';b.hScrollbarWrapper.style.opacity='0'}if(b.vScrollbar&&b.options.hideScrollbar){if(vendor=='webkit')b.vScrollbarWrapper.style[vendor+'TransitionDelay']='300ms';b.vScrollbarWrapper.style.opacity='0'}return}b.scrollTo(resetX,resetY,a||0)},_wheel:function(e){var a=this,wheelDeltaX,wheelDeltaY,deltaX,deltaY,deltaScale;if('wheelDeltaX'in e){wheelDeltaX=e.wheelDeltaX/12;wheelDeltaY=e.wheelDeltaY/12}else if('wheelDelta'in e){wheelDeltaX=wheelDeltaY=e.wheelDelta/12}else if('detail'in e){wheelDeltaX=wheelDeltaY=-e.detail*3}else{return}if(a.options.wheelAction=='zoom'){deltaScale=a.scale*Math.pow(2,1/3*(wheelDeltaY?wheelDeltaY/Math.abs(wheelDeltaY):0));if(deltaScale<a.options.zoomMin)deltaScale=a.options.zoomMin;if(deltaScale>a.options.zoomMax)deltaScale=a.options.zoomMax;if(deltaScale!=a.scale){if(!a.wheelZoomCount&&a.options.onZoomStart)a.options.onZoomStart.call(a,e);a.wheelZoomCount++;a.zoom(e.pageX,e.pageY,deltaScale,400);setTimeout(function(){a.wheelZoomCount--;if(!a.wheelZoomCount&&a.options.onZoomEnd)a.options.onZoomEnd.call(a,e)},400)}return}deltaX=a.x+wheelDeltaX;deltaY=a.y+wheelDeltaY;if(deltaX>0)deltaX=0;else if(deltaX<a.maxScrollX)deltaX=a.maxScrollX;if(deltaY>a.minScrollY)deltaY=a.minScrollY;else if(deltaY<a.maxScrollY)deltaY=a.maxScrollY;a.scrollTo(deltaX,deltaY,0)},_mouseout:function(e){var t=e.relatedTarget;if(!t){this._end(e);return}while(t=t.parentNode)if(t==this.wrapper)return;this._end(e)},_transitionEnd:function(e){var a=this;if(e.target!=a.scroller)return;a._unbind('webkitTransitionEnd');a._startAni()},_startAni:function(){var b=this,startX=b.x,startY=b.y,startTime=Date.now(),step,easeOut,animate;if(b.animating)return;if(!b.steps.length){b._resetPos(400);return}step=b.steps.shift();if(step.x==startX&&step.y==startY)step.time=0;b.animating=true;b.moved=true;if(b.options.useTransition){b._transitionTime(step.time);b._pos(step.x,step.y);b.animating=false;if(step.time)b._bind('webkitTransitionEnd');else b._resetPos(0);return}animate=function(){var a=Date.now(),newX,newY;if(a>=startTime+step.time){b._pos(step.x,step.y);b.animating=false;if(b.options.onAnimationEnd)b.options.onAnimationEnd.call(b);b._startAni();return}a=(a-startTime)/step.time-1;easeOut=m.sqrt(1-a*a);newX=(step.x-startX)*easeOut+startX;newY=(step.y-startY)*easeOut+startY;b._pos(newX,newY);if(b.animating)b.aniTime=nextFrame(animate)};animate()},_transitionTime:function(a){a+='ms';this.scroller.style[vendor+'TransitionDuration']=a;if(this.hScrollbar)this.hScrollbarIndicator.style[vendor+'TransitionDuration']=a;if(this.vScrollbar)this.vScrollbarIndicator.style[vendor+'TransitionDuration']=a},_momentum:function(a,b,c,d,e){var f=0.0006,speed=m.abs(a)/b,newDist=(speed*speed)/(2*f),newTime=0,outsideDist=0;if(a>0&&newDist>c){outsideDist=e/(6/(newDist/speed*f));c=c+outsideDist;speed=speed*c/newDist;newDist=c}else if(a<0&&newDist>d){outsideDist=e/(6/(newDist/speed*f));d=d+outsideDist;speed=speed*d/newDist;newDist=d}newDist=newDist*(a<0?-1:1);newTime=speed/f;return{dist:newDist,time:mround(newTime)}},_offset:function(a){var b=-a.offsetLeft,top=-a.offsetTop;while(a=a.offsetParent){b-=a.offsetLeft;top-=a.offsetTop}if(a!=this.wrapper){b*=this.scale;top*=this.scale}return{left:b,top:top}},_snap:function(x,y){var a=this,i,l,page,time,sizeX,sizeY;page=a.pagesX.length-1;for(i=0,l=a.pagesX.length;i<l;i++){if(x>=a.pagesX[i]){page=i;break}}if(page==a.currPageX&&page>0&&a.dirX<0)page--;x=a.pagesX[page];sizeX=m.abs(x-a.pagesX[a.currPageX]);sizeX=sizeX?m.abs(a.x-x)/sizeX*500:0;a.currPageX=page;page=a.pagesY.length-1;for(i=0;i<page;i++){if(y>=a.pagesY[i]){page=i;break}}if(page==a.currPageY&&page>0&&a.dirY<0)page--;y=a.pagesY[page];sizeY=m.abs(y-a.pagesY[a.currPageY]);sizeY=sizeY?m.abs(a.y-y)/sizeY*500:0;a.currPageY=page;time=mround(m.max(sizeX,sizeY))||200;return{x:x,y:y,time:time}},_bind:function(a,b,c){(b||this.scroller).addEventListener(a,this,!!c)},_unbind:function(a,b,c){(b||this.scroller).removeEventListener(a,this,!!c)},destroy:function(){var a=this;a.scroller.style[vendor+'Transform']='';a.hScrollbar=false;a.vScrollbar=false;a._scrollbar('h');a._scrollbar('v');a._unbind(RESIZE_EV,window);a._unbind(START_EV);a._unbind(MOVE_EV);a._unbind(END_EV);a._unbind(CANCEL_EV);if(!a.options.hasTouch){a._unbind('mouseout',a.wrapper);a._unbind(WHEEL_EV)}if(a.options.useTransition)a._unbind('webkitTransitionEnd');if(a.options.checkDOMChanges)clearInterval(a.checkDOMTime);if(a.options.onDestroy)a.options.onDestroy.call(a)},refresh:function(){var a=this,offset,i,l,els,pos=0,page=0;if(a.scale<a.options.zoomMin)a.scale=a.options.zoomMin;a.wrapperW=a.wrapper.clientWidth||1;a.wrapperH=a.wrapper.clientHeight||1;a.minScrollY=-a.options.topOffset||0;a.scrollerW=mround(a.scroller.offsetWidth*a.scale);a.scrollerH=mround((a.scroller.offsetHeight+a.minScrollY)*a.scale);a.maxScrollX=a.wrapperW-a.scrollerW;a.maxScrollY=a.wrapperH-a.scrollerH+a.minScrollY;a.dirX=0;a.dirY=0;if(a.options.onRefresh)a.options.onRefresh.call(a);a.hScroll=a.options.hScroll&&a.maxScrollX<0;a.vScroll=a.options.vScroll&&(!a.options.bounceLock&&!a.hScroll||a.scrollerH>a.wrapperH);a.hScrollbar=a.hScroll&&a.options.hScrollbar;a.vScrollbar=a.vScroll&&a.options.vScrollbar&&a.scrollerH>a.wrapperH;offset=a._offset(a.wrapper);a.wrapperOffsetLeft=-offset.left;a.wrapperOffsetTop=-offset.top;if(typeof a.options.snap=='string'){a.pagesX=[];a.pagesY=[];els=a.scroller.querySelectorAll(a.options.snap);for(i=0,l=els.length;i<l;i++){pos=a._offset(els[i]);pos.left+=a.wrapperOffsetLeft;pos.top+=a.wrapperOffsetTop;a.pagesX[i]=pos.left<a.maxScrollX?a.maxScrollX:pos.left*a.scale;a.pagesY[i]=pos.top<a.maxScrollY?a.maxScrollY:pos.top*a.scale}}else if(a.options.snap){a.pagesX=[];while(pos>=a.maxScrollX){a.pagesX[page]=pos;pos=pos-a.wrapperW;page++}if(a.maxScrollX%a.wrapperW)a.pagesX[a.pagesX.length]=a.maxScrollX-a.pagesX[a.pagesX.length-1]+a.pagesX[a.pagesX.length-1];pos=0;page=0;a.pagesY=[];while(pos>=a.maxScrollY){a.pagesY[page]=pos;pos=pos-a.wrapperH;page++}if(a.maxScrollY%a.wrapperH)a.pagesY[a.pagesY.length]=a.maxScrollY-a.pagesY[a.pagesY.length-1]+a.pagesY[a.pagesY.length-1]}a._scrollbar('h');a._scrollbar('v');if(!a.zoomed){a.scroller.style[vendor+'TransitionDuration']='0';a._resetPos(200)}},scrollTo:function(x,y,a,b){var c=this,step=x,i,l;c.stop();if(!step.length)step=[{x:x,y:y,time:a,relative:b}];for(i=0,l=step.length;i<l;i++){if(step[i].relative){step[i].x=c.x-step[i].x;step[i].y=c.y-step[i].y}c.steps.push({x:step[i].x,y:step[i].y,time:step[i].time||0})}c._startAni()},scrollToElement:function(a,b){var c=this,pos;a=a.nodeType?a:c.scroller.querySelector(a);if(!a)return;pos=c._offset(a);pos.left+=c.wrapperOffsetLeft;pos.top+=c.wrapperOffsetTop;pos.left=pos.left>0?0:pos.left<c.maxScrollX?c.maxScrollX:pos.left;pos.top=pos.top>c.minScrollY?c.minScrollY:pos.top<c.maxScrollY?c.maxScrollY:pos.top;b=b===undefined?m.max(m.abs(pos.left)*2,m.abs(pos.top)*2):b;c.scrollTo(pos.left,pos.top,b)},scrollToPage:function(a,b,c){var d=this,x,y;c=c===undefined?400:c;if(d.options.onScrollStart)d.options.onScrollStart.call(d);if(d.options.snap){a=a=='next'?d.currPageX+1:a=='prev'?d.currPageX-1:a;b=b=='next'?d.currPageY+1:b=='prev'?d.currPageY-1:b;a=a<0?0:a>d.pagesX.length-1?d.pagesX.length-1:a;b=b<0?0:b>d.pagesY.length-1?d.pagesY.length-1:b;d.currPageX=a;d.currPageY=b;x=d.pagesX[a];y=d.pagesY[b]}else{x=-d.wrapperW*a;y=-d.wrapperH*b;if(x<d.maxScrollX)x=d.maxScrollX;if(y<d.maxScrollY)y=d.maxScrollY}d.scrollTo(x,y,c)},disable:function(){this.stop();this._resetPos(0);this.enabled=false;this._unbind(MOVE_EV);this._unbind(END_EV);this._unbind(CANCEL_EV)},enable:function(){this.enabled=true},stop:function(){if(this.options.useTransition)this._unbind('webkitTransitionEnd');else cancelFrame(this.aniTime);this.steps=[];this.moved=false;this.animating=false},zoom:function(x,y,a,b){var c=this,relScale=a/c.scale;if(!c.options.useTransform)return;c.zoomed=true;b=b===undefined?200:b;x=x-c.wrapperOffsetLeft-c.x;y=y-c.wrapperOffsetTop-c.y;c.x=x-x*relScale+c.x;c.y=y-y*relScale+c.y;c.scale=a;c.refresh();c.x=c.x>0?0:c.x<c.maxScrollX?c.maxScrollX:c.x;c.y=c.y>c.minScrollY?c.minScrollY:c.y<c.maxScrollY?c.maxScrollY:c.y;c.scroller.style[vendor+'TransitionDuration']=b+'ms';c.scroller.style[vendor+'Transform']=trnOpen+c.x+'px,'+c.y+'px'+trnClose+' scale('+a+')';c.zoomed=false},isReady:function(){return!this.moved&&!this.zoomed&&!this.animating}};if(typeof exports!=='undefined')exports.iScroll=iScroll;else window.iScroll=iScroll})();$.extend({UIScrollers:{},UIEnableScrolling:function(b){var c;try{var d=w('scrollpanel');d.each(function(a){if(a.hasAttribute('ui-scroller')){c=a.getAttribute('ui-scroller');$.UIScrollers[c]=new iScroll(a.parentNode,b)}else{a.setAttribute('ui-scroller',$.UIUuid());c=a.getAttribute('ui-scroller');$.UIScrollers[c]=new iScroll(a.parentNode,b)}})}catch(e){}}});$(function(){$.UIEnableScrolling()});$.extend({UIPaging:function(c,d){var e=new iScroll(c,d);var f=null;if(c.nodeType===1){f=$('stack',c);c.parentNode.setAttribute('ui-scroller','myPager')}else{f=$('stack',$(c));c=$(c);c.parentNode.setAttribute('ui-scroller','myPager')}var g=c.parentNode.css('width');var h='<stack ui-implements="indicators" style="width:"'+g+';">';[].slice.apply(f.children).each(function(a,b){if(b===0){h+='<indicator class="active"></indicator>'}else{h+="<indicator></indicator>"}});h+="</stack>";c.parentNode.insert(h)},UISetupPaging:function(){if($("stack[ui-implements=paging]")){$.UIPaging("stack[ui-implements=paging]",{snap:true,momentum:false,hScrollbar:false,onScrollEnd:function(){document.querySelector('stack[ui-implements="indicators"] > indicator.active').removeClass('active');document.querySelector('stack[ui-implements="indicators"] > indicator:nth-child('+(this.currPageX+1)+')').addClass('active')}})}}});$(function(){$.UISetupPaging()});$.extend({UIDeletableTableCells:[],UIDeleteTableCell:function(c){var d;if(c.editButton){d=c.editButton[0]}else{d='Edit'}var e;if(c.editButton){e=c.editButton[1]}else{e='Done'}var f;if(c.deleteButton){f=c.deleteButton}else{f='Delete'}var g=c.callback||function(){};this.deletionList=[];var h=$(c.selector);var i=$(c.toolbar);if((i.first().nodeName)==='UIBUTTON'){i.first().setAttribute('ui-contains','uibutton')}var j='<uibutton ui-kind="deletionListDeleteButton" ui-bar-align="left" ui-implements="delete" class="disabled" style="display: none;"><label>'+f+'</label></uibutton>';var k='<uibutton ui-kind="deletionListEditButton" ui-bar-align="right" ui-implements="edit" ui-button-labels="'+d+','+e+'"><label>'+d+'</label></uibutton>';i.insertAdjacentHTML("afterBegin",j);i.insertAdjacentHTML("beforeEnd",k);var l='<deletedisclosure><span>✓</span></deletedisclosure>';w(c.selector+" > tablecell").each(function(a){a.insertAdjacentHTML("afterBegin",l)});h.setAttribute('data-deletable-items',0);var m=function(){$(c.toolbar+' > uibutton[ui-implements=edit]').bind($.userAction,function(){var b=this.getAttribute('ui-button-labels');if($('label',this).text()===d){this.UIToggleButtonLabel(d,e);this.setAttribute('ui-implements','done');h.addClass('ui-show-delete-disclosures');this.parentNode.firstElementChild.style.display='-webkit-inline-box';if(/uibutton/i.test(i.children[1].nodeName)){i.children[1].css('display','none;')}w('tablecell > img',h).each(function(a){a.css('-webkit-transform: translate3d(40px, 0, 0)')})}else{this.UIToggleButtonLabel(d,e);this.removeAttribute('ui-implements');this.parentNode.firstElementChild.style.display='none';h.removeClass('ui-show-delete-disclosures');w('deletedisclosure').each(function(a){a.removeClass('checked');a.ancestor('tablecell').removeClass('deletable')});if(/uibutton/i.test(i.children[1].nodeName)){i.children[1].css('display','-webkit-inline-box')}$('uibutton[ui-implements=delete]').addClass('disabled');w('tablecell > img',h).each(function(a){a.css('-webkit-transform: translate3d(0, 0, 0)')})}})};var n=function(){w('deletedisclosure').each(function(a){a.bind($.userAction,function(){a.toggleClass('checked');a.ancestor('tablecell').toggleClass('deletable');$('uibutton[ui-implements=delete]').removeClass('disabled');if(!a.ancestor('tablecell').hasClass('deletable')){h.setAttribute('data-deletable-items',parseInt(h.data('deletable-items'),10)-1);if(parseInt(h.data('deletable-items'),10)===0){i.firstElementChild.addClass('disabled')}}else{h.data('deletable-items',parseInt(h.data('deletable-items'),10)+1)}})})};var o=function(){$('uibutton[ui-implements=delete]').bind($.userAction,function(){if(this.hasClass('disabled')){return}w('.deletable').each(function(a){h.data('deletable-items',parseInt(h.data('deletable-items'),10)-1);$.UIDeletableTableCells.push(a.id);if(!!g){g.call(this,a)}a.remove();$.UIDeletableTableCells=[];h.setAttribute('data-deletable-items',0)});this.addClass('disabled');$.UIScrollers[$('scrollpanel',$(c.selector).ancestor('view')).getAttribute('ui-scroller')].refresh()})};m();n();o()},UIResetDeletionList:function(b,c){b=$(b);c=$(c);if(b.hasClass('ui-show-delete-disclosures')){b.setAttribute('data-deletable-items',0);$.slice.apply(b.children).forEach(function(a){a.firstElementChild.removeClass('checked')});b.removeClass('ui-show-delete-disclosures');var d=c.find('uibutton[ui-kind=deletionListEditButton]').getAttribute('ui-button-labels');d=d.split(',');d=d[0];c.find('uibutton[ui-kind=deletionListEditButton] > label').text(d);c.find('uibutton[ui-kind=deletionListEditButton]').setAttribute('ui-implements','edit');c.find('uibutton[ui-kind=deletionListDeleteButton]').css('display','none');c.find('uibutton[ui-kind=deletionListDeleteButton]').toggleClass('disabled')}b.findAll('tablecell').forEach(function(a){a.removeClass('deletable')})}});$.extend({UISpinner:function(b){var c=$(b.selector);var d=null;var e=null;var f=b.step;if(b.range.start>=0){var g=b.range.start||"";var h=b.range.end||"";var k=h-g;k++;e=[];if(f){var l=((h-g)/f);if(b.range.start===0){e.push(0)}else{e.push(g)}for(var i=1;i<l;i++){e.push(e[i-1]+f)}e.push(e[e.length-1]+f)}else{for(var j=0;j<k;j++){e.push(g+j)}}}var m=(b.indicator==="plus")?"<icon class='indicator'></icon>":"<icon></icon>";var n=b.buttonClass?" class='"+b.buttonClass+"' ":"";var o="<uibutton "+n+"ui-implements='icon'>"+m+"</uibutton>";var p="<uibutton "+n+"ui-implements='icon'>"+m+"</uibutton>";var q=o+"<label ui-kind='spinner-label'></label><input type='text'/>"+p;c.insert(q);if(b.range.values){c.data('range-value',b.range.values.join(','))}if(!b.defaultValue){if(!!b.range.start||b.range.start===0){d=b.range.start===0?'0':b.range.start}else if(b.range.values instanceof Array){d=b.range.values[0];$('uibutton:first-of-type',b.selector).addClass('disabled')}}else{d=b.defaultValue}if(e){c.data('range-value',e.join(','))}$('label[ui-kind=spinner-label]',c).text(d);$('input',c).value=d;if(b.namePrefix){var r=b.namePrefix+'.'+c.id;$('input',c).setAttribute('name',r)}else{$('input',c).setAttribute('name',c.id)}if(d===b.range.start){$('uibutton:first-of-type',c).addClass('disabled')}if(d==b.range.end){$('uibutton:last-of-type',c).addClass('disabled')}$('uibutton:first-of-type',b.selector).bind($.userAction,function(a){$.decreaseSpinnerValue.call(this,b.selector)});$('uibutton:last-of-type',b.selector).bind($.userAction,function(a){$.increaseSpinnerValue.call(this,b.selector)})},decreaseSpinnerValue:function(a){var b=$(a).data('range-value');b=b.split(',');var c=$('label',a).text().trim();var d=b.indexOf(c);if(d!==-1){$('uibutton:last-of-type',a).removeClass('disabled');$('[ui-kind=spinner-label]',a).text(b[d-1]);$('input',a).value=b[d-1];if(d===1){this.addClass('disabled')}}},increaseSpinnerValue:function(a){var b=$(a).data('range-value');b=b.split(',');var c=$('label',a).text().trim();var d=b.indexOf(c);if(d!==-1){$('uibutton:first-of-type',a).removeClass('disabled');$('label[ui-kind=spinner-label]',a).text(b[d+1]);$('input',a).value=b[d+1];if(d===b.length-2){this.addClass('disabled')}}},resetSpinner:function(a){var b=$(a).data('range-value');b=b.split(',')[0];$(a).find('label').text(b);$(a).find('uibutton:first-of-type').addClass('disabled');$(a).find('uibutton:last-of-type').removeClass('disabled')}});$(function(){$.extend($,{UIPopUpIsActive:null,UIPopUpIdentifier:null,UIPopUp:function(b){var c=b.id||$.UIUuid();var d=b.title||'Alert!';var f=b.message||'';var g=b.cancelUIButton||'Cancel';var h=b.continueUIButton||'Continue';var i=b.callback||function(){};var j='<popup id='+c+' ui-visible-state="hidden"> <panel> <toolbar ui-placement="top"> <h1>'+d+'</h1> </toolbar> <p>'+f+'</p> <toolbar ui-placement="bottom"> <uibutton ui-kind="action" ui-implements="cancel"> <label>'+g+'</label> </uibutton> <uibutton ui-kind="action" ui-implements="continue"> <label>'+h+'</label> </uibutton> </toolbar> </panel> </popup>';$('app').insertAdjacentHTML('beforeEnd',j);var k='#'+c;$(k).UIBlock('0.5');var l='#'+c+' uibutton';w(l).each(function(a){a.bind($.userAction,cancelClickPopup=function(e){if(a.getAttribute('ui-implements')==='continue'){i.call(i,this)}e.preventDefault();$.UIClosePopup('#'+c)});$.UIPopUpIsActive=false;$.UIPopUpIdentifier=null;a.bind('touchend',cancelTouchPopup=function(e){if(a.getAttribute('ui-implements')==='continue'){i.call(i,this)}e.preventDefault();$.UIClosePopup('#'+c)});$.UIPopUpIsActive=false;$.UIPopUpIdentifier=null})}})});$.extend({UIPopUpIsActive:false,UIPopUpIdentifier:null,UIShowPopUp:function(a){$.UIPopUp(a);$.UIPopUpIsActive=true;$.UIPopUpIdentifier='#'+a.id;var b=$('mask');b.bind('touchmove',function(e){e.preventDefault()});$.UIPositionPopUp('#'+a.id);b.setAttribute('ui-visible-state','visible');$('#'+a.id).setAttribute('ui-visible-state','visible')},UIPositionPopUp:function(a){$.UIPopUpIsActive=true;$.UIPopUpIdentifier=a;var b=$(a);var c='top:';c+=((window.innerHeight/2)+window.pageYOffset)-(b.clientHeight/2)+'px;';b.css(c);c='left:';c+=(window.innerWidth/2)-(b.clientWidth/2)+'px';b.css(c)},UIRepositionPopupOnOrientationChange:function(){$.body.bind('orientationchange',function(){if(window.orientation===90||window.orientation===-90){if($.UIPopUpIsActive){$.UIPositionPopUp($.UIPopUpIdentifier)}}else{if($.UIPopUpIsActive){$.UIPositionPopUp($.UIPopUpIdentifier)}}});window.addEventListener('resize',function(){if($.UIPopUpIsActive){$.UIPositionPopUp($.UIPopUpIdentifier)}},false)},UIClosePopup:function(a){$(a+' uibutton[ui-implements=cancel]').UIRemovePopupBtnEvents($.userAction,'cancelClickPopup');$(a+' uibutton[ui-implements=continue]').UIRemovePopupBtnEvents($.userAction,'cancelTouchPopup');$(a).UIUnblock();$(a).remove();$.UIPopUpIdentifier=null;$.UIPopUpIsActive=false}});$.extend(HTMLElement.prototype,{UIRemovePopupBtnEvents:function(a,b){this.removeEventListener(a,b,false)}});$(function(){$.UIRepositionPopupOnOrientationChange()});$.extend(HTMLElement.prototype,{UISelectionList:function(d){var e=$.slice.apply(this.children);e.each(function(b){if(b.nodeName.toLowerCase()==='tablecell'){var c='<checkmark>✓</checkmark>';b.insert(c);b.bind($.userAction,function(){e.each(function(a){a.removeClass('selected');a.removeClass('touched')});this.addClass('selected');this.UIHandleTouchState();this.find('input').checked=true;if(d){d.call(d,this.find('input'))}})}})}});$.extend(HTMLElement.prototype,{UICreateSwitchControl:function(a){var b=a.id;var c='';if(a.namePrefix){c="name='"+a.namePrefix+"."+a.id+"'"}else{c="name='"+b+"'"}var d=" ";d+=a.customClass?a.customClass:"";var e=a.status||"off";var f=a.kind?" ui-kind='"+a.kind+"'":"";var g="ON";var h="OFF";if(a.kind==="traditional"){if(!!a.labelValue){g=a.labelValue[0];h=a.labelValue[1]}}var i=a.value||"";var j=a.callback||function(){return false};var k=(a.kind==="traditional")?'<label ui-implements="on">'+g+'</label><thumb></thumb><label ui-implements="off">'+h+'</label>':"<thumb></thumb>";var l='<switchcontrol '+f+' class="'+e+" "+d+'" id="'+b+'"'+'>'+k+'<input type="checkbox" '+c+' style="display: none;" value="'+i+'"></switchcontrol>';if(this.css("position")!=="absolute"){this.css("position: relative;")}this.insert(l);var m='#'+b;$(m).find('input').checked=e==='on'?true:false;$(m).bind($.userAction,function(){this.UISwitchControl(j(this));this.UIHandleTouchState(400)})}});$.extend(HTMLElement.prototype,{UISwitchControl:function(a){a=a||function(){return false};if(this.nodeName.toLowerCase()==='switchcontrol'){a.call(this);if(this.hasClass('off')){this.toggleClass('on','off');this.find('input').checked=true;this.querySelector('thumb').focus()}else{this.toggleClass('on','off');this.find('input').checked=false}}else{return}}});$.extend(HTMLElement.prototype,{UIInitSwitchToggling:function(){w('switchcontrol',this).each(function(a){if(a.hasClass('on')){a.checked=true;a.find("input[type='checkbox']").checked=true}else{a.checked=false;a.find("input[type='checkbox']").checked=false}a.bind($.userAction,function(e){this.UIHandleTouchState(400);this.parentNode.style.backgroundImage='none';e.preventDefault();a.UISwitchControl()})})}});$(function(){$.app.UIInitSwitchToggling()});$.extend(HTMLElement.prototype,{UICreateSegmentedControl:function(a,b){b=b||null;var c="<segmentedcontrol";if(a.id){c+=" id='"+a.id+"'"}if(a.placement){c+=" ui-bar-align='"+a.placement+"'"}if(a.selectedSegment){c+=" ui-selected-index='"+a.selectedSegment+"'"}else{c+=" ui-selected-index=''"}if(a.container){c+=" ui-segmented-container='#"+a.container+"'"}var d=a.cssClass||"";c+=">";if(a.numberOfSegments){segments=a.numberOfSegments;var e=1;for(var i=0;i<segments;i++){c+="<uibutton";c+=" id='"+$.UIUuid()+"'";c+=" class='"+d[e-1];if(a.selectedSegment){if(a.selectedSegment===i){c+=" selected'"}}if(a.disabledSegment){if(a.disabledSegment===i){c+=" disabled'"}}c+="'";c+=" ui-kind='segmented'";if(a.placementOfIcons){c+=" ui-icon-alignment='"+a.placementOfIcons[e-1]+"'"}c+=">";if(a.iconsOfSegments){if(!!a.iconsOfSegments[i]){c+="<icon ui-implements='icon-mask' style='-webkit-mask-box-image: url(icons/"+a.iconsOfSegments[e-1]+"."+a.fileExtension[e-1]+")' ui-implements='icon-mask'></icon>"}}if(a.titlesOfSegments){c+="<label>"+a.titlesOfSegments[e-1]+"</label>"}c+="</uibutton>";e++}c+="</segmentedcontrol>";if(b){this.insert(c,b)}else{this.insert(c)}$("#"+a.id).UISegmentedControl()}}});$.extend(HTMLElement.prototype,{UISegmentedControl:function(k,l){var m=this;var n=null;l=l||function(){};var o=$.slice.apply(this.children);var p=$(k);var q=$.slice.apply(this.children);if(!this.hasAttribute('ui-selected-segment')){this.setAttribute('ui-selected-segment','')}if(this.getAttribute('ui-selected-index')){n=this.getAttribute('ui-selected-index');var r=this.children(n);try{r=r.getAttribute('id');this.setAttribute('ui-selected-segment',r);this.children[n].addClass('selected')}catch(e){}}else{var s=-1;for(var i=0,len=this.children.length;i<len;i++){if(this.children[i].hasClass('selected')){this.setAttribute('ui-selected-index',i)}else{s++}}if(s===this.children.length-1){this.setAttribute('ui-selected-index',0);this.firstElementChild.addClass('selected')}}if(k){k=$(k);if(n){k.setAttribute('ui-selected-index',n)}else{k.setAttribute('ui-selected-index',0)}var t=$.slice.apply(k.children);t.forEach(function(a){a.css('display: none;')});t[n].css('display','block');m.setAttribute('ui-segmented-container',('#'+k.id));var u=this.getAttribute('ui-selected-index');var v=k.ancestor('scrollpanel').getAttribute('ui-scroller');$.UIScrollers[v].refresh()}o.each(function(j){if(!j.hasAttribute('id')){j.setAttribute('id',$.UIUuid())}if(!m.getAttribute('ui-selected-segment')){if(j.hasClass('selected')){m.setAttribute('ui-selected-segment',j.getAttribute('id'))}}j.bind($.userAction,function(){if(j.hasClass('disabled'))return false;var a=m.getAttribute('ui-selected-segment');var b=m.getAttribute('ui-selected-index');var c=null;var d=null;var e=this.ancestor('segmentedcontrol');if(e.hasAttribute('ui-segmented-container')){d=e.getAttribute('ui-segmented-container')}var f=null;if(e.hasAttribute('ui-selected-index')){f=e.getAttribute('ui-selected-index')}var g=null;if(!a){g=this.getAttribute('ui-child-position');m.setAttribute('ui-selected-index',g);m.setAttribute('ui-selected-segment',this.getAttribute('id'));this.addClass('selected');c=this.getAttribute('ui-child-position');d.children[n].css('display: none;');d.children[c].css('display: none;')}if(a){g=this.getAttribute('ui-child-position');m.setAttribute('ui-selected-index',g);var h=$(('#'+a));h.removeClass('selected');m.setAttribute('ui-selected-segment',this.getAttribute('id'));this.addClass('selected');c=this.getAttribute('ui-child-position');if(m.getAttribute('ui-segmented-container')){d=$(m.getAttribute('ui-segmented-container'));d.children[f].css('display: none;');d.children[g].css('display: -webkit-box;');d.children[h.getAttribute('ui-child-position')].css('{display','none}');var i=d.ancestor('scrollpanel');v=i.getAttribute('ui-scroller');$.UIScrollers[v].refresh()}}this.addClass('selected');l.call(l,j)})});this.UIIdentifyChildNodes()}});$(function(){w('segmentedcontrol').each(function(a){if(a.getAttribute('ui-implements')!=='segmented-paging'){a.UISegmentedControl();var b=a.ancestor('scrollpanel').getAttribute('ui-scroller');$.UIScrollers[b].destroy();$.UIScrollers[b]=new iScroll(a.ancestor('scrollpanel').parentNode)}})});$.extend(HTMLElement.prototype,{UISegmentedPagingControl:function(){var e=$('segmentedcontrol[ui-implements=segmented-paging]');var f=e.getAttribute('ui-paging');e.setAttribute('ui-paged-subview',0);e.first().addClass('disabled');var g=w('subview',this);e.setAttribute('ui-pagable-subviews',g.length);var h=0;g.each(function(a){a.setAttribute('ui-navigation-status','upcoming');a.setAttribute('ui-child-position',h);h++;a.setAttribute('ui-paging-orient',f)});g[0].setAttribute('ui-navigation-status','current');e.delegate('uibutton',$.userAction,function(a){var b=a.ancestor('segmentedcontrol');if(a.isSameNode(a.parentNode.firstElementChild)){if(b.getAttribute('ui-paged-subview')===1){a.addClass('disabled');b.setAttribute('ui-paged-subview',0);g[0].setAttribute('ui-navigation-status','current');g[1].setAttribute('ui-navigation-status','upcoming')}else{g[b.getAttribute('ui-paged-subview')-1].setAttribute('ui-navigation-status','current');g[b.getAttribute('ui-paged-subview')].setAttribute('ui-navigation-status','upcoming');b.setAttribute('ui-paged-subview',b.getAttribute('ui-paged-subview')-1);a.next().removeClass('disabled');if(b.getAttribute('ui-paged-subview')<=0){a.addClass('disabled')}}}else{var c=b.getAttribute('ui-pagable-subviews');var d=b.getAttribute('ui-paged-subview');if(b.getAttribute('ui-paged-subview')==c-1){a.addClass('disabled')}else{a.previous().removeClass('disabled');g[d].setAttribute('ui-navigation-status','traversed');g[++d].setAttribute('ui-navigation-status','current');b.setAttribute('ui-paged-subview',(d));if(b.getAttribute('ui-paged-subview')==c-1){a.addClass('disabled')}}}})}});$.extend(HTMLElement.prototype,{UICreateTabBar:function(a){var b=a.id||$.UIUuid();var c=a.imagePath||'icons\/';var d=a.numberOfTabs||1;var e=a.tabLabels;var f=a.iconsOfTabs;var g=a.selectedTab||0;var h=a.disabledTab||null;var j="<tabbar ui-selected-tab='"+g+"'>";this.setAttribute("ui-tabbar-id",b);for(var i=0;i<d;i++){j+="<uibutton ui-implements='tab' ";if(i===g||i===h){j+="class='";if(i===g){j+="selected"}if(i===h){j+="disabled"}j+="'"}j+="><icon style='-webkit-mask-box-image: url("+c;j+=f[i]+".svg);'></icon>";j+="<label>"+e[i]+"</label></uibutton>"}j+="</tabbar>";this.insert(j);var k=w("subview",this);k[g].addClass("selected");this.UITabBar()},UITabBar:function(){var c=w('tabbar > uibutton[ui-implements=tab]',this);$('tabbar',this).UIIdentifyChildNodes();var d=$('tabbar',this);var e=w('subview',this);e.each(function(a){a.addClass('unselected')});var f=d.getAttribute('ui-selected-tab')||0;e[f].toggleClass('unselected','selected');c[f].addClass('selected');c.each(function(b){b.bind($.userAction,function(){if(b.hasClass('disabled')||b.hasClass('selected')){return}var a=b.ancestor('tabbar').getAttribute('ui-selected-tab');c[a].removeClass('selected');b.addClass('selected');e[a].removeClass('selected');e[a].addClass('unselected');e[b.getAttribute('ui-child-position')].addClass('selected');e[b.getAttribute('ui-child-position')].removeClass('unselected');d.setAttribute('ui-selected-tab',b.getAttribute('ui-child-position'))})})},UITabBarForViews:function(){var c=w('tabbar > uibutton[ui-implements=tab]',this);$('tabbar',this).UIIdentifyChildNodes();var d=$('tabbar',this);var e=w('view[ui-implements=tabbar-panel]',this);e.each(function(a){a.setAttribute('ui-navigation-status','upcoming')});var f=d.getAttribute('ui-selected-tab')||0;e[f].setAttribute('ui-navigation-status','current');c[f].addClass('selected');c.each(function(b){b.bind($.userAction,function(){if(b.hasClass('disabled')||b.hasClass('selected')){return}var a=b.ancestor('tabbar').getAttribute('ui-selected-tab');c[a].removeClass('selected');b.addClass('selected');e[a].setAttribute('ui-navigation-status','upcoming');e[b.getAttribute('ui-child-position')].setAttribute('ui-navigation-status','current');d.setAttribute('ui-selected-tab',b.getAttribute('ui-child-position'))})})}});$.extend(HTMLElement.prototype,{UIActionSheet:function(f){var g=this;var h=f.id;var i='undefined';if(!!f.color){i=f.color}var j='';if(f.title){j='<p>'+f.title+'</p>'}var k=function(){var c="<actionsheet id='"+h+"' class='hidden' ui-contains='action-buttons'";if(i){c+=" ui-action-sheet-color='"+i+"'"}c+="><scrollpanel ui-scroller='"+$.UIUuid()+"'><panel>";c+=j;var d="",uiButtonObj,uiButtonImplements,uiButtonTitle,uiButtonCallback;if(!!f.uiButtons){f.uiButtons.each(function(a,b){d+="<uibutton ui-kind='action' ";uiButtonTitle=a.title;uiButtonImplements=a.uiButtonImplements||"";uiButtonCallback=a.callback;h.trim();h.capitalize();d+=' ui-implements="'+uiButtonImplements+'" class="stretch" onclick="'+uiButtonCallback+'(\'#'+h+'\')"><label>';d+=uiButtonTitle;d+="</label></uibutton>"})}c+=d+"<uibutton ui-kind='action' ui-implements='cancel' class='stretch' onclick='$.UIHideActionSheet(\"#"+h+"\")'><label>Cancel</label></uibutton></panel></scrollpanel></actionsheet>";var e=$.make(c);g.insert(e,"last")};k();var l="#"+h+" uibutton";w(l).each(function(a){a.bind("click",function(){$.UIHideActionSheet()})});var m=new iScroll($("#"+h).find('scrollpanel'),{desktopCompatibility:true})}});$.extend({UIShowActionSheet:function(a){$.app.data('ui-action-sheet-id',a);$(a).UIBlock();var b=$('mask');b.css('width: '+window.innerWidth+'px; height: '+window.innerHeight+'px; opacity: .5;');b.setAttribute('ui-visible-state','visible');$(a).removeClass('hidden');b.addEventListener('touchmove',function(e){e.preventDefault()},false);var c=$(a).find('scrollpanel').getAttribute('ui-scroller');$.UIScrollers[c].refresh()},UIHideActionSheet:function(){var a=$.app.data('ui-action-sheet-id');try{$(a).addClass('hidden');$(a).UIUnblock()}catch(e){}$.app.removeData('ui-action-sheet-id')},UIReadjustActionSheet:function(){var a='';if($.app.data('ui-action-sheet-id')){a=$.app.data('ui-action-sheet-id');$(a).css('right: 0; bottom: 0; left: 0;');if($.iphone||$.ipod){if($.standalone){$(a).css('right: 0; bottom: 0px; left: 0;')}else{if(window.innerWidth>window.innerHeight){$(a).css('right: 0; bottom: 0; left: 0; -webkit-transform: translate3d(0,70px,0);')}else{$(a).css('right: 0; bottom: 0; left: 0; -webkit-transform: translate3d(0,0,0);')}}}else{$(a).css('right: 0; bottom: 0; left: 0;')}}$.UIPositionMask()}});document.addEventListener('orientationchange',function(){$.UIReadjustActionSheet()},false);$.extend(HTMLElement.prototype,{UIExpander:function(a){a=a||{};var b=a.status||'expanded';var c=a.title||'Open';var d=a.altTitle||'Close';var e=this;var f=$('panel',this);var g='<header><label></label></header>';this.insert(g,'first');f.setAttribute('ui-height',parseInt(f.css('height'),10));if(b==='expanded'){e.toggleClass('ui-status-expanded','ui-status-collapsed');$('label',this).text(d);f.style.height=f.getAttribute('ui-height')+'px';f.css('opacity: 1;')}else{$('label',this).text(c);f.css('height: 0px; opacity: 0;');e.toggleClass('ui-status-collapsed','ui-status-expanded')}$('header',e).bind($.userAction,function(){if(f.style.height==='0px'){f.style.height=f.getAttribute('ui-height')+'px';f.style.opacity=1;$('label',this).text(d);e.toggleClass('ui-status-collapsed','ui-status-expanded')}else{f.css('height: 0px; opacity: 0;');$('label',this).text(c);e.toggleClass('ui-status-expanded','ui-status-collapsed')}})}});$.extend(HTMLElement.prototype,{UICalculateNumberOfLines:function(){var a=parseInt(this.css('line-height'),10);var b=parseInt(this.css('height'),10);var c=Math.floor(b/a);return c},UIParagraphEllipsis:function(){var a=this.UICalculateNumberOfLines();this.css('-webkit-line-clamp:'+a)}});$.extend(HTMLElement.prototype,{UIProgressBar:function(a){a=a||{};var b=a.className||false;var c=a.width||100;var d=a.speed||5;var e=a.position||'after';var f=a.margin||'10px auto';var g='<progressbar';if(b){g+=" class='"+b+"'"}g+=" style='width: "+c+"px;";g+=" -webkit-animation-duration: "+d+"s;";g+=" margin: "+f+";'";g+="></progressbar>";this.insert(g)},UIHideNavBarHeader:function(){this.css('visibility: hidden; position: absolute;')},UIShowNavBarHeader:function(){this.css('visibility: visible; position: static;')}});$.extend({UIAdjustToolBarTitle:function(){w('navbar h1').each(function(a){var b=window.innerWidth-20;var c=0;var d=0;var e=0;c=a.previousElementSibling?a.previousElementSibling.clientWidth:0;d=a.nextElementSibling?a.nextElementSibling.clientWidth:0;if(c>d){e=c*2}else{e=d*2}if((b-e)<40){a.css('display: none;')}else{a.css('display: block; width: '+(b-e-20)+'px;')}})}});document.addEventListener('DOMContentLoaded',function(){if(!$('splitview')){$.UIAdjustToolBarTitle()}},false);document.addEventListener('orientationchange',function(){if(!$('splitview')){$.UIAdjustToolBarTitle()}},false);window.addEventListener('resize',function(){if(!$('splitview')){$.UIAdjustToolBarTitle()}},false);$.UIActivityIndicator=function(){};$.extend($.UIActivityIndicator.prototype,{id:null,color:null,shadow:null,container:null,size:null,init:function(a){if(a){this.id=a.id||'UIActivityIndicator';this.color=a.color||'gray';if(!!a.shadow){this.shadow=a.shadow}this.container=a.container;this.size=a.size||'75%'}$(this.container).css('background-position: center 70%; background-repeat: no-repeat; background-image: -webkit-canvas('+this.id+'); background-size: '+this.size+' '+this.size);this.context=document.getCSSCanvasContext('2d',this.id,37,37);this.context.lineWidth=3;this.context.lineCap='round';this.context.strokeStyle=this.color;if(this.shadow){this.context.shadowOffsetX=1;this.context.shadowOffsetY=1;this.context.shadowBlur=2;this.context.shadowColor=this.shadow}this.step=0;this.timer=null},draw:function(){this.context.clearRect(0,0,137,37);this.context.save();this.context.translate(18,18);this.context.rotate(this.step*Math.PI/180);for(var i=0;i<12;i++){this.context.rotate(30*Math.PI/180);this.drawLine(i)}this.context.restore();this.step+=30;if(this.step===360){this.step=0}},drawLine:function(i){this.context.beginPath();this.context.globalAlpha=i/12;this.context.moveTo(0,8+1);this.context.lineTo(0,16-1);this.context.stroke()},stop:function(){if(this.timer){this.context.clearRect(0,0,37,37);window.clearInterval(this.timer);this.timer=null}},animate:function(){if(this.timer){return}var a=this;this.timer=window.setInterval(function(){a.draw()},100)}});$.extend(HTMLElement.prototype,{UIInsertActivityIndicator:function(a){this.insert("<panel style='height: "+a.size+"; width: "+a.size+";"+a.style+"'></panel>");var b=new $.UIActivityIndicator();b.init(a);b.animate()}});$.extend({UICurX:null,UICurY:null,UISliderThumbWidth:null,UISliderValue:null,UISlider:function(b,c){var d=null;var e=c.callback||function(){};if(c.startValue){d=c.startValue}var f=$(b).clientWidth;if(d){$('thumb',b).css('left: '+d+'px;');$(b).css('background-size: '+(d+2)+'px 9px, 100% 9px;')}$(b).setAttribute('ui-slider-length',f);if('createTouch'in document){var g=$(b+' > thumb');g.bind('touchmove',function(a){this.UISliderTouch(event);this.UIUpdateSliderTouch(e)})}else{$.UISliderForMouse(b,c)}}});$.extend(HTMLElement.prototype,{UISliderTouch:function(a){a.preventDefault();var b=this.parentNode.getAttribute('ui-slider-length');var c=a.touches[0];$.UICurX=c.pageX-this.parentNode.offsetLeft-$.UISliderThumbWidth;var d=this.css('width');d=parseInt(d,10);$.UISliderValue=$.UICurX+d;if($.UICurX<=0-(d/2)){$.UICurX=0-(d/2)}if($.UICurX>b-12){$.UICurX=b-12}},UIUpdateSliderTouch:function(a){a=a||function(){};this.style.left=$.UICurX-$.UISliderThumbWidth+'px';a();this.parentNode.css('-webkit-background-size:'+($.UICurX+1)+'px 9px, 100% 9px;');this.parentNode.css('background-size:'+($.UICurX+1)+'px 9px, 100% 9px;')}});$.UIDrag={obj:null,init:function(a,b,c,d,e,f,g,h){a.onmousedown=$.UIDrag.start;a.hmode=g?false:true;a.vmode=h?false:true;a.root=b&&b!==null?b:a;if(a.hmode&&isNaN(parseInt(a.root.style.left,10))){a.root.style.left=a.root.css('left')}if(a.vmode&&isNaN(parseInt(a.root.style.top,10))){a.root.style.top=a.root.css('top')}if(!a.hmode&&isNaN(parseInt(a.root.style.right,10))){a.root.style.right=a.root.css('right')}if(!a.vmode&&isNaN(parseInt(a.root.style.bottom,10))){a.root.style.bottom=a.root.css('bottom')}a.minX=typeof c!=='undefined'?c:null;a.minY=typeof e!=='undefined'?e:null;a.maxX=typeof d!=='undefined'?d:null;a.maxY=typeof f!=='undefined'?f:null;a.root.onDragStart=function(){};a.root.onDragEnd=function(){};a.root.onDrag=function(){}},start:function(e){var a=$.UIDrag.obj=this;e=$.UIDrag.fixE(e);$.UIDrag.y=parseInt(a.vmode?a.root.style.top:a.root.style.bottom,10);$.UIDrag.x=parseInt(a.hmode?a.root.style.left:a.root.style.right,10);a.root.onDragStart($.UIDrag.x,$.UIDrag.y);a.lastMouseX=e.clientX;a.lastMouseY=e.clientY;if(a.hmode){if(a.minX!==null)a.minMouseX=e.clientX-$.UIDrag.x+a.minX;if(a.maxX!==null)a.maxMouseX=a.minMouseX+a.maxX-a.minX}else{if(a.minX!==null)a.maxMouseX=-a.minX+e.clientX+$.UIDrag.x;if(a.maxX!==null)a.minMouseX=-a.maxX+e.clientX+$.UIDrag.x}if(a.vmode){if(a.minY!==null)a.minMouseY=e.clientY-$.UIDrag.y+a.minY;if(a.maxY!==null)a.maxMouseY=a.minMouseY+a.maxY-a.minY}else{if(a.minY!==null)a.maxMouseY=-a.minY+e.clientY+$.UIDrag.y;if(a.maxY!==null)a.minMouseY=-a.maxY+e.clientY+$.UIDrag.y}document.onmousemove=$.UIDrag.drag;document.onmouseup=$.UIDrag.end;return false},drag:function(e){e=$.UIDrag.fixE(e);var a=$.UIDrag.obj;var b=e.clientY;var c=e.clientX;$.UIDrag.y=parseInt(a.vmode?a.root.style.top:a.root.style.bottom,10);$.UIDrag.x=parseInt(a.hmode?a.root.style.left:a.root.style.right,10);var d,ny;if(a.minX!==null)c=a.hmode?Math.max(c,a.minMouseX):Math.min(c,a.maxMouseX);if(a.maxX!==null)c=a.hmode?Math.min(c,a.maxMouseX):Math.max(c,a.minMouseX);if(a.minY!==null)b=a.vmode?Math.max(b,a.minMouseY):Math.min(b,a.maxMouseY);if(a.maxY!==null)b=a.vmode?Math.min(b,a.maxMouseY):Math.max(b,a.minMouseY);d=$.UIDrag.x+((c-a.lastMouseX)*(a.hmode?1:-1));ny=$.UIDrag.y+((b-a.lastMouseY)*(a.vmode?1:-1));$.UICurX=d;$.UISliderValue=d+(Math.round($.UISliderThumbWidth));$.UICurY=ny;$.UIDrag.obj.root.style[a.hmode?'left':'right']=d+'px';$.UIDrag.obj.root.style[a.vmode?'top':'bottom']=ny+'px';$.UIDrag.obj.lastMouseX=c;$.UIDrag.obj.lastMouseY=b;$.UIDrag.obj.root.onDrag(d,ny);$.UIDrag.updateSliderProgressIndicator($.UICurX);return false},end:function(){document.onmousemove=null;document.onmouseup=null;$.UIDrag.obj.root.onDragEnd(parseInt($.UIDrag.obj.root.style[$.UIDrag.obj.hmode?'left':'right'],10),parseInt($.UIDrag.obj.root.style[$.UIDrag.obj.vmode?'top':'bottom'],10));$.UIDrag.obj=null},fixE:function(e){if(typeof e.elemX==='undefined')e.elemX=e.offsetX;if(typeof e.elemY==='undefined')e.elemY=e.offsetY;return e},updateSliderProgressIndicator:function(){$.UIDrag.obj.parentNode.css('-webkit-background-size:'+($.UICurX+1)+'px 9px, 100% 9px;');$.UIDrag.obj.parentNode.css('background-size:'+($.UICurX+1)+'px 9px, 100% 9px;')}};$.extend({UISliderForMouse:function(a,b){b=b||{};var c=$('thumb',a);var d=$(a);var e=parseInt(c.css('width'),10);var f=parseInt(d.css('width'),10);var g=parseInt(d.css('height'),10);var h=parseInt(d.css('padding-right'),10);var i=parseInt(d.css('border-right-width'),10);f-=h;f-=i;f-=$.UISliderThumbWidth;var j=Math.round(e/2);$.UISliderThumbWidth=j;var k=(0-$.UISliderThumbWidth);$.UIDrag.init(c,null,-$.UISliderThumbWidth,f-(Math.round(e/2)),b.top,b.top);c.onDrag=function(){if(b.callback){b.callback();d.UIUpdateSliderTouch()}this.style.top=-g+'px'}}});$.extend(HTMLElement.prototype,{UISetTranstionType:function(a){this.setAttribute('ui-transition-type',a)},UIFlipSubview:function(a){var b=this.ancestor('view');b.UISetTranstionType('flip-'+a);this.bind($.userAction,function(){switch(a){case'right':$('subview:nth-of-type(1)',b).toggleClass('flip-right-front-in','flip-right-front-out');$('subview:nth-of-type(2)',b).toggleClass('flip-right-back-in','flip-right-back-out');break;case'left':$('subview:nth-of-type(1)',b).toggleClass('flip-left-front-in','flip-left-front-out');$('subview:nth-of-type(2)',b).toggleClass('flip-left-back-in','flip-left-back-out');break;case'top':$('subview:nth-of-type(2)',b).toggleClass('flip-top-front-in','flip-top-front-out');$('subview:nth-of-type(1)',b).toggleClass('flip-top-back-in','flip-top-back-out');break;case'bottom':$('subview:nth-of-type(2)',b).toggleClass('flip-bottom-front-in','flip-bottom-front-out');$('subview:nth-of-type(1)',b).toggleClass('flip-bottom-back-in','flip-bottom-back-out');break;default:$('subview:nth-of-type(1)',b).toggleClass('flip-right-front-in','flip-right-front-out');$('subview:nth-of-type(2)',b).toggleClass('flip-right-back-in','flip-right-back-out')}})},UIPopSubview:function(){var a=this.ancestor('view');a.UISetTranstionType('pop');this.bind($.userAction,function(){$('subview:nth-of-type(2)',a).toggleClass('pop-in','pop-out')})},UIFadeSubview:function(){var a=this.ancestor('view');a.UISetTranstionType('fade');a.setAttribute('ui-transition-type','fade');this.bind($.userAction,function(){$('subview:nth-of-type(2)',a).toggleClass('fade-in','fade-out')})},UISpinSubview:function(a){var b=this.ancestor('view');b.UISetTranstionType('spin');if(!a||a==='left'){this.UISetTranstionType('left');this.bind($.userAction,function(){$('subview:nth-of-type(2)',b).toggleClass('spin-left-in','spin-left-out')})}else if(a==='right'){this.UISetTranstionType('right');this.bind($.userAction,function(){$('subview:nth-of-type(2)',b).toggleClass('spin-right-in','spin-right-out')})}else{this.UISetTranstionType('left');this.bind($.userAction,function(){$('subview:nth-of-type(2)',b).toggleClass('spin-left-in','spin-left-out')})}}});$(function(){$.extend($,{UICancelSplitViewToggle:function(){$.body.addClass('SplitViewFixed')},UISplitViewScroller1:null,UISplitViewScroller2:null,rootview:$('rootview'),resizeEvt:('onorientationchange'in window?'orientationchange':'resize'),UISplitView:function(){if($.body.hasClass('SplitViewFixed')){return}$.UISplitViewScroller1=new iScroll('#scroller1 > scrollpanel');$.UISplitViewScroller2=new iScroll('#scroller2 > scrollpanel');var a=$('rootview > panel > view[ui-navigation-status=current] > navbar').text();$('detailview > navbar').insert("<uibutton id ='showRootView' class='navigation' ui-bar-align='left'>"+a+"</uibutton>","first");if(window.innerWidth>window.innerHeight){$.rootview.css("display: block; height: 100%; margin-bottom: 1px;");$("#scroller1").css("overflow: hidden; height: "+($.rootview.innerHeight-45)+"px;")}else{$.rootview.css("display: none; height: "+(window.innerHeight-100)+"px;");$("#scroller1").css("overflow: hidden; height: "+(window.innerHeight-155)+"px;")}$("detailview navbar h1").text($("tableview[ui-implements=detail-menu] > tablecell").text().trim())},UISetSplitviewOrientation:function(){if($.body.hasClass('SplitViewFixed')){return}if($.resizeEvt){if(window.innerWidth>window.innerHeight){$.app.UIUnblock();$.rootview.css('display: block; height: 100%; margin-bottom: 1px;');$('#scroller1').css('overflow: hidden; height: 100%;')}else{$.app.UIUnblock();$.rootview.css('display: none; height: '+(window.innerHeight-100)+'px;');$('#scroller1').css('overflow: hidden; height:'+(window.innerHeight-155)+'px;')}$.UIEnableScrolling({desktopCompatibility:true})}},UIToggleRootView:function(){if($.body.hasClass('SplitViewFixed')){return}if($.rootview.style.display==='none'){$.rootview.css('display: block;');$.rootview.UIBlock('.01');$.UISplitViewScroller1.refresh();$.UISplitViewScroller2.refresh()}else{$.rootview.style.display='none';$.rootview.UIUnblock();$.UISplitViewScroller1.refresh();$.UISplitViewScroller2.refresh()}},UICheckForSplitView:function(){if($.body.hasClass('SplitViewFixed')){return}if($('splitview')){$.UISplitView();$('#showRootView').bind($.userAction,function(){$.UIToggleRootView()});$.body.onorientationchange=function(){$.UISetSplitviewOrientation()};window.onresize=function(){$.UISetSplitviewOrientation()}}},UICurrentSplitViewDetail:null});$.UICheckForSplitView();if($('detailview > subview')){$.UICurrentSplitViewDetail='#';$.UICurrentSplitViewDetail+=$('detailview > subview').getAttribute('id');w('tableview[ui-implements=detail-menu] > tablecell').each(function(c){c.bind($.userAction,function(){var a=this.ancestor('rootview');if(a.css('position')==='absolute'){a.css('display: none;');$.app.UIUnblock()}var b=this.getAttribute('ui-href');b='#'+b;if(b===$.UICurrentSplitViewDetail){return}else{$($.UICurrentSplitViewDetail).css('display: none;');$(b).css('display: block;');$.UICurrentSplitViewDetail=b;$('detailview navbar h1').text(c.text().trim());$.UIEnableScrolling({desktopCompatibility:true})}})});$.app.delegate('mask',$.userAction,function(){$.rootview.css('display: none;');$.rootview.UIUnblock()})}});$.extend({determineMaxPopoverHeight:function(){var a=window.innerHeight;var b;if($('navbar')){b=$('navbar').clientHeight}if($('toolbar')){if(!$('toolbar').getAttribute('ui-placement')){b=$('toolbar').clientHeight}}a=a-b;return a},determinePopoverWidth:function(){var a=window.innerWidth},adjustPopoverHeight:function(a){var b=$.determineMaxPopoverHeight();$(a+" > section").css("max-height:"+(b-100)+"px; overflow: hidden;}");var c=a.split("#");c=c[1]},determinePopoverPosition:function(a,b,c){b=b.toLowerCase();c=c.toLowerCase();var d=$(a);var e='';var f=null;switch(b){case'top':if(c==='left'){f=d.offsetLeft;f='left: '+f}else if(c==='center'){f=(d.offsetLeft+(d.offsetWidth/2)-160);f='left: '+f}else{f=(d.offsetLeft+d.offsetWidth)-320;f='left: '+f}e=d.offsetTop+d.offsetHeight;e+=20;e=f+'px; top: '+e+'px;';break;case'right':if(c==='top'){f=d.getTop()+2;f='top: '+f+'px;'}else if(c==='center'){f=(d.getTop()-(d.offsetHeight/2)-20);f='top: '+f+'px;'}else{f=d.getTop()-d.offsetHeight-20;f='top: '+f+'px;'}e=d.getLeft()-330;e-=20;e=f+' left: '+e+'px';break;case'bottom':if(c==='left'){f=d.offsetLeft;f='left: '+f}else if(c==='center'){f=(d.offsetLeft+(d.offsetWidth/2)-160);f='left: '+f}else{f=(d.offsetLeft+d.offsetWidth)-320;f='left: '+f}e=d.offsetTop+d.offsetHeight;e+=20;e=f+'px; bottom: '+e+'px;';break;break;case'left':if(c==='top'){f=d.getTop()+2;f='top: '+f+'px;'}else if(c==='center'){f=(d.getTop()-(d.offsetHeight/2)-20);f='top: '+f+'px;'}else{f=d.getTop()-d.offsetHeight-20;f='top: '+f+'px;'}e=d.offsetLeft+d.offsetWidth;e+=20;e=f+' left: '+e+'px';break;default:e=d.getTop()+d.offsetHeight;f='left: '+f;e+=20;e=f+'px; top: '+e+'px;';break}return e},UIPopover:function(a){var b;var c=a.triggerElement;var d=a.popoverOrientation;var e=a.pointerOrientation;var f;if(a){f='id="'+a.id+'"'||$.UIUuid();b='<h3>'+a.title+'</h3>'||""}else{f="";b=""}var g=$(c);var h=this.determinePopoverPosition(c,d,e);h=" style='"+h+"'";var i='<popover '+f+' ui-pointer-position="'+d+'-'+e+'"'+h+' data-popover-trigger="#'+g.id+'" data-popover-orientation="'+d+'" data-popover-pointer-orientation="'+e+'">\n'+'<header>'+b+'</header>\n'+'<section><scrollpanel class="popover-content"></scrollpanel></section>\n'+'</popover>';var j=$.make(i);$.app.insert(j,"last");if(!!a.id){$.adjustPopoverHeight("#"+a.id);$("#"+a.id).adjustPopoverPosition()}},UICancelPopover:function(a){$.UIHidePopover(a)},UIHidePopover:function(a){$.UIPopover.activePopover=null;$(a).css("opacity: 0; -webkit-transform: scale(0);");a.UIUnblock()},UIEnablePopoverScrollpanels:function(c){try{var d=0;w("popover scrollpanel").each(function(a){a.setAttribute("ui-scroller",$.UIUuid());var b=a.getAttribute("ui-scroller");$.UIScrollers[b]=new iScroll(a.parentNode,c)})}catch(e){}}});$.extend($.UIPopover,{activePopover:null,show:function(a){if($.UIPopover.activePopover===null){a.UIBlock(".01");a.repositionPopover();a.css("opacity: 1; -webkit-transform: scale(1);");$.UIPopover.activePopover=a.id;$.UIEnableScrolling({desktopCompatibility:true})}else{return}$.UIEnablePopoverScrollpanels()},hide:function(a){if($.UIPopover.activePopover){a.css("opacity: 0; -webkit-transform: scale(0);");$.UIPopover.activePopover=null}}});$.extend(HTMLElement.prototype,{repositionPopover:function(){var a=this.getAttribute("data-popover-trigger");var b=this.getAttribute("data-popover-orientation");var c=this.getAttribute("data-popover-pointer-orientation");var d=$.determinePopoverPosition(a,b,c);this.css(d)},adjustPopoverPosition:function(){var a=window.innerHeight;var b=window.innerWidth;var c=this.offsetHeight;var d=this.offsetWidth;var e=this.getTop();var f=this.getLeft();var g=e+c;var h=f+d;if(g>a){this.style.top=a-c-10+"px"}if(h>b){this.style.left=b-10+"px"}},UIBlock:function(a){a=a?" style='opacity:"+a+"'":"";this.before($.make("<mask"+a+"></mask>"))},UIUnblock:function(){if($("mask")){$("mask").remove()}}});$.extend({UIPositionMask:function(){if($("mask")){$("mask").css("height:"+(window.innerHeight+window.pageYOffset)+"px; width: "+window.innerWidth+"px;")}}});window.addEventListener("orientationchange",function(){var b=$.determineMaxPopoverHeight();w("popover").each(function(a){a.find("section").css("max-height:"+(b-100)+"px;");a.repositionPopover();$.adjustPopoverHeight("#"+a.id)});if($("rootview")){$("rootview").UIUnblock()}},false);window.addEventListener("resize",function(){var b=$.determineMaxPopoverHeight();w("popover").each(function(a){a.find("section").css("max-height:"+(b-100)+"px;");a.repositionPopover()});$.UIPositionMask()},false);$(function(){$.app.delegate("mask","click",function(){if($.UIPopover.activePopover){$.UIPopover.hide($("#"+$.UIPopover.activePopover));if($("mask")){$("mask").UIUnblock()}}if($.rooview&&$.rootview.css("position")==="absolute"){$.rootview.style.display="none";$.rootview.UIUnblock()}})});$.extend({UIAlphabeticalList:function(){if($("tableview[ui-kind='titled-list alphabetical']")){var b=$("tableview[ui-kind='titled-list alphabetical']");var c=[];var d=$.UIUuidSeed();var e=0;var f='<stack ui-kind="alphabetical-list">';var g="";b.findAll("tableheader").each(function(a){c.push(a.text());e++;a.setAttribute("id","alpha_"+a.text()+d+e);g+='<span href="#alpha_'+a.text()+d+e+' ">'+a.text()+'</span>'});f+=g+'</stack>';b.ancestor("scrollpanel").after(f)}else{return}if($("stack[ui-kind='alphabetical-list']")){$("stack[ui-kind='alphabetical-list']").css({height:window.innerHeight-45+"px"});window.addEventListener("resize",function(){$("stack[ui-kind='alphabetical-list']").css({height:window.innerHeight-45+"px"})})}else{console.log("no alphabetic list!")}var h=$("tableview[ui-kind='titled-list alphabetical']").ancestor("scrollpanel");var i=h.getAttribute("ui-scroller");$.UIScrollers[i].destroy();$.UIScrollers[i]=new iScroll(h.parentNode,{snap:true});$.app.delegate("stack[ui-kind='alphabetical-list'] > span","click",function(a){$.UIScrollers[i].scrollToElement(a.getAttribute("href"))})}});$(function(){if("stack[ui-kind='titled-list alphabetical']"){$.UIAlphabeticalList()}})})($chocolatechip,$$chocolatechip);