//>>built
define("dojox/mobile/pageTurningUtils","dojo/_base/kernel dojo/_base/array dojo/_base/connect dojo/_base/event dojo/dom-class dojo/dom-construct dojo/dom-style ./_css3".split(" "),function(y,w,x,z,q,A,h,e){y.experimental("dojox.mobile.pageTurningUtils");return function(){this.h=this.w=0;this.turnfrom="top";this.dogear=this.page=1;this.duration=2;this.alwaysDogeared=!1;this._styleParams={};this._transitionEndHandle=this._currentPageNode=this._catalogNode=null;this.init=function(a,b,d,g,c,f,p){this.w=
a;this.h=b;this.turnfrom=d?d:this.turnfrom;this.page=g?g:this.page;this.dogear="undefined"!==typeof c?c:this.dogear;this.duration="undefined"!==typeof f?f:this.duration;this.alwaysDogeared="undefined"!==typeof p?p:this.alwaysDogeared;"bottom"===this.turnfrom&&(this.alwaysDogeared=!0);this._calcStyleParams()};this._calcStyleParams=function(){var a=Math.tan(58*Math.PI/180),b=Math.cos(32*Math.PI/180),d=Math.sin(32*Math.PI/180),g=Math.tan(32*Math.PI/180),c=this.w,f=this.h,p=this.page,B=this.turnfrom,
m=this._styleParams,n=c*a,k=n*d+n*b*a;n=n+c+c/a;var v=.11*c*this.dogear,r=c-v,l=r*b;switch(this.turnfrom){case "top":var t=k-l;l*=a;var u=k-v;a=l+r/a-7;b=l/b;m.init={page:e.add({top:-b+"px",left:-k+(2===p?c:0)+"px",width:k+"px",height:n+"px"},{transformOrigin:"100% 0%"}),front:e.add({width:c+"px",height:f+"px"},{boxShadow:"0 0"}),back:e.add({width:c+"px",height:f+"px"},{boxShadow:"0 0"}),shadow:{display:"",left:k+"px",height:1.5*f+"px"}};m.turnForward={page:e.add({},{transform:"rotate(0deg)"}),front:e.add({},
{transform:"translate("+k+"px,"+b+"px) rotate(0deg)",transformOrigin:"-110px -18px"}),back:e.add({},{transform:"translate("+(k-c)+"px,"+b+"px) rotate(0deg)",transformOrigin:"0px 0px"})};m.turnBackward={page:e.add({},{transform:"rotate(-32deg)"}),front:e.add({},{transform:"translate("+t+"px,"+l+"px) rotate(32deg)",transformOrigin:"0px 0px"}),back:e.add({},{transform:"translate("+u+"px,"+a+"px) rotate(-32deg)",transformOrigin:"0px 0px"})};break;case "bottom":t=k-(f*d+c*b)-2;l=n-(f+c/g)*b;u=k;a=n-c/
d-f;b=n-c/g-f;m.init={page:e.add({top:-b+50+"px",left:-k+(2===p?c:0)+"px",width:k+"px",height:n+"px"},{transformOrigin:"100% 100%"}),front:e.add({width:c+"px",height:f+"px"},{boxShadow:"0 0"}),back:e.add({width:c+"px",height:f+"px"},{boxShadow:"0 0"}),shadow:{display:"none"}};m.turnForward={page:e.add({},{transform:"rotate(0deg)"}),front:e.add({},{transform:"translate("+k+"px,"+b+"px) rotate(0deg)",transformOrigin:"-220px 35px"}),back:e.add({},{transform:"translate("+2*c+"px,"+b+"px) rotate(0deg)",
transformOrigin:"0px 0px"})};m.turnBackward={page:e.add({},{transform:"rotate(32deg)"}),front:e.add({},{transform:"translate("+t+"px,"+l+"px) rotate(-32deg)",transformOrigin:"0px 0px"}),back:e.add({},{transform:"translate("+u+"px,"+a+"px) rotate(0deg)",transformOrigin:"0px 0px"})};break;case "left":t=-c,l=r/g-2,u=-r,a=b=r/d+v*d,m.init={page:e.add({top:-l+"px",left:c+"px",width:k+"px",height:n+"px"},{transformOrigin:"0% 0%"}),front:e.add({width:c+"px",height:f+"px"},{boxShadow:"0 0"}),back:e.add({width:c+
"px",height:f+"px"},{boxShadow:"0 0"}),shadow:{display:"",left:"-4px",height:(2===p?1.5*f:f)+50+"px"}},m.turnForward={page:e.add({},{transform:"rotate(0deg)"}),front:e.add({},{transform:"translate("+t+"px,"+l+"px) rotate(0deg)",transformOrigin:"160px 68px"}),back:e.add({},{transform:"translate(0px,"+l+"px) rotate(0deg)",transformOrigin:"0px 0px"})},m.turnBackward={page:e.add({},{transform:"rotate(32deg)"}),front:e.add({},{transform:"translate("+-v+"px,"+a+"px) rotate(-32deg)",transformOrigin:"0px 0px"}),
back:e.add({},{transform:"translate("+u+"px,"+a+"px) rotate(32deg)",transformOrigin:"top right"})}}m.init.catalog={width:(2===p?2*c:c)+"px",height:(2===p?1.5*f:f)+("top"==B?0:50)+"px"}};this.getChildren=function(a){return w.filter(a.childNodes,function(b){return 1===b.nodeType})};this.getPages=function(){return this._catalogNode?this.getChildren(this._catalogNode):null};this.getCurrentPage=function(){return this._currentPageNode};this.getIndexOfPage=function(a,b){b||(b=this.getPages());for(var d=
0;d<b.length;d++)if(a===b[d])return d;return-1};this.getNextPage=function(a){for(a=a.nextSibling;a;a=a.nextSibling)if(1===a.nodeType)return a;return null};this.getPreviousPage=function(a){for(a=a.previousSibling;a;a=a.previousSibling)if(1===a.nodeType)return a;return null};this.isPageTurned=function(a){return"rotate(0deg)"==a.style[e.name("transform")]};this._onPageTurned=function(a){z.stop(a);if(q.contains(a.target,"mblPageTurningPage"))this.onPageTurned(a.target)};this.onPageTurned=function(){};
this.initCatalog=function(a){this._catalogNode!=a&&(this._transitionEndHandle&&x.disconnect(this._transitionEndHandle),this._transitionEndHandle=x.connect(a,e.name("transitionEnd"),this,"_onPageTurned"),this._catalogNode=a);q.add(a,"mblPageTurningCatalog");h.set(a,this._styleParams.init.catalog);a=this.getPages();w.forEach(a,function(b){this.initPage(b)},this);this.resetCatalog()};this._getBaseZIndex=function(){return this._catalogNode.style.zIndex||0};this.resetCatalog=function(){for(var a=this.getPages(),
b=a.length,d=this._getBaseZIndex(),g=b-1;0<=g;g--){var c=a[g];this.showDogear(c);this.isPageTurned(c)?c.style.zIndex=d+b+1:(c.style.zIndex=d+b-g,!this.alwaysDogeared&&this.hideDogear(c),this._currentPageNode=c)}this.alwaysDogeared||this._currentPageNode==a[b-1]||this.showDogear(this._currentPageNode)};this.initPage=function(a,b){for(var d=this.getChildren(a);3>d.length;)a.appendChild(A.create("div",null)),d=this.getChildren(a);var g=!q.contains(a,"mblPageTurningPage");q.add(a,"mblPageTurningPage");
q.add(d[0],"mblPageTurningFront");q.add(d[1],"mblPageTurningBack");q.add(d[2],"mblPageTurningShadow");var c=this._styleParams.init;h.set(a,c.page);h.set(d[0],c.front);h.set(d[1],c.back);c.shadow&&h.set(d[2],c.shadow);b||(g&&this._currentPageNode?(this.getPages(),b=this.getIndexOfPage(a)<this.getIndexOfPage(this._currentPageNode)?1:-1):b=this.isPageTurned(a)?1:-1);this._turnPage(a,b,0)};this.turnToNext=function(a){var b=this.getNextPage(this._currentPageNode);b&&(this._turnPage(this._currentPageNode,
1,a),this._currentPageNode=b)};this.turnToPrev=function(a){var b=this.getPreviousPage(this._currentPageNode);b&&(this._turnPage(b,-1,a),this._currentPageNode=b)};this.goTo=function(a){var b=this.getPages();if(!(this._currentPageNode===b[a]||b.length<=a))for(var d=a<this.getIndexOfPage(this._currentPageNode,b);this._currentPageNode!==b[a];)d?this.turnToPrev(0):this.turnToNext(0)};this._turnPage=function(a,b,d){var g=this.getChildren(a);d=("undefined"!==typeof d?d:this.duration)+"s";var c=1===b?this._styleParams.turnForward:
this._styleParams.turnBackward;c.page[e.name("transitionDuration")]=d;h.set(a,c.page);c.front[e.name("transitionDuration")]=d;h.set(g[0],c.front);c.back[e.name("transitionDuration")]=d;h.set(g[1],c.back);g=this.getPages();d=this.getNextPage(a);c=g.length;var f=this._getBaseZIndex();1===b?(a.style.zIndex=f+c+1,!this.alwaysDogeared&&d&&this.getNextPage(d)&&this.showDogear(d)):d&&(d.style.zIndex=f+c-this.getIndexOfPage(d,g),!this.alwaysDogeared&&this.hideDogear(d))};this.showDogear=function(a){var b=
this.getChildren(a);h.set(a,"overflow","");b[1]&&h.set(b[1],"display","");b[2]&&h.set(b[2],"display","bottom"===this.turnfrom?"none":"")};this.hideDogear=function(a){if("bottom"!==this.turnfrom){var b=this.getChildren(a);h.set(a,"overflow","visible");b[1]&&h.set(b[1],"display","none");b[2]&&h.set(b[2],"display","none")}}}});