From aff1195c3256bb03aaa8b4980842d64a8fbf7580 Mon Sep 17 00:00:00 2001 From: BoHung Chiu Date: Fri, 21 Jul 2023 10:10:54 +0800 Subject: [PATCH] Update turn.js and fix margin-left calculation. --- .../javascripts/publications/turn.min.js | 132 +++++++++--------- 1 file changed, 65 insertions(+), 67 deletions(-) diff --git a/app/assets/javascripts/publications/turn.min.js b/app/assets/javascripts/publications/turn.min.js index 020832f..08962e5 100644 --- a/app/assets/javascripts/publications/turn.min.js +++ b/app/assets/javascripts/publications/turn.min.js @@ -1,68 +1,66 @@ -/* turn.js 4.1.0 | Copyright (c) 2012 Emmanuel Garcia | turnjs.com | turnjs.com/license.txt */ +/* turn.js 4.1.1 | Copyright (c) 2012 Emmanuel Garcia - 2019 Raffaele Morganti | turnjs.com | turnjs.com/license.txt */ -(function(f){function J(a,b,c){if(!c[0]||"object"==typeof c[0])return b.init.apply(a,c);if(b[c[0]])return b[c[0]].apply(a,Array.prototype.slice.call(c,1));throw q(c[0]+" is not a method or property");}function l(a,b,c,d){return{css:{position:"absolute",top:a,left:b,overflow:d||"hidden",zIndex:c||"auto"}}}function S(a,b,c,d,e){var h=1-e,f=h*h*h,g=e*e*e;return j(Math.round(f*a.x+3*e*h*h*b.x+3*e*e*h*c.x+g*d.x),Math.round(f*a.y+3*e*h*h*b.y+3*e*e*h*c.y+g*d.y))}function j(a,b){return{x:a,y:b}}function F(a, -b,c){return z&&c?" translate3d("+a+"px,"+b+"px, 0px) ":" translate("+a+"px, "+b+"px) "}function G(a){return" rotate("+a+"deg) "}function n(a,b){return Object.prototype.hasOwnProperty.call(b,a)}function T(){for(var a=["Moz","Webkit","Khtml","O","ms"],b=a.length,c="";b--;)a[b]+"Transform"in document.body.style&&(c="-"+a[b].toLowerCase()+"-");return c}function P(a,b,c,d,e){var h,f=[];if("-webkit-"==w){for(h=0;hh)throw q('Page "'+b+'" cannot be inserted');}else b=h,d=!0;1<=b&&b<=h&&(c="double"==e.display?b%2?" odd":" even":"",e.done&& -this.turn("stop"),b in e.pageObjs&&g._movePages.call(this,b,1),d&&(e.totalPages=h),e.pageObjs[b]=f(a).css({"float":"left"}).addClass("page p"+b+c),-1!=navigator.userAgent.indexOf("MSIE 9.0")&&e.pageObjs[b].hasClass("hard")&&e.pageObjs[b].removeClass("hard"),g._addPage.call(this,b),g._removeFromDOM.call(this));return this},_addPage:function(a){var b=this.data(),c=b.pageObjs[a];if(c)if(g._necessPage.call(this,a)){if(!b.pageWrap[a]){b.pageWrap[a]=f("
",{"class":"page-wrapper",page:a,css:{position:"absolute", -overflow:"hidden"}});this.append(b.pageWrap[a]);b.pagePlace[a]||(b.pagePlace[a]=a,b.pageObjs[a].appendTo(b.pageWrap[a]));var d=g._pageSize.call(this,a,!0);c.css({width:d.width,height:d.height});b.pageWrap[a].css(d)}b.pagePlace[a]==a&&g._makeFlip.call(this,a)}else b.pagePlace[a]=0,b.pageObjs[a]&&b.pageObjs[a].remove()},hasPage:function(a){return n(a,this.data().pageObjs)},center:function(a){var b=this.data(),c=f(this).turn("size"),d=0;b.noCenter||("double"==b.display&&(a=this.turn("view",a||b.tpage|| -b.page),"ltr"==b.direction?a[0]?a[1]||(d+=c.width/4):d-=c.width/4:a[0]?a[1]||(d-=c.width/4):d+=c.width/4),f(this).css({marginLeft:d}));return this},destroy:function(){var a=this,b=this.data(),c="end first flip last pressed released start turning turned zooming missing".split(" ");if("prevented"!=t("destroying",this)){b.destroying=!0;f.each(c,function(b,c){a.unbind(c)});this.parent().unbind("start",b.eventHandlers.start);for(f(document).unbind(r.move,b.eventHandlers.touchMove).unbind(r.up,b.eventHandlers.touchEnd);0!== -b.totalPages;)this.turn("removePage",b.totalPages);b.fparent&&b.fparent.remove();b.shadow&&b.shadow.remove();this.removeData();b=null;return this}},is:function(){return"object"==typeof this.data().pages},zoom:function(a){var b=this.data();if("number"==typeof a){if(0.0010>a||100this.data().totalPages)){b=this.turn("range");for(a=b[0];a<=b[1];a++)g._addPage.call(this,a)}},range:function(a){var b,c,d,e=this.data(),a=a||e.tpage||e.page||1;d=g._view.call(this,a);if(1>a||a>e.totalPages)throw q('"'+a+'" is not a valid page');d[1]=d[1]||d[0];1<=d[0]&&d[1]<=e.totalPages?(a=Math.floor(2),e.totalPages-d[1]>d[0]?(b=Math.min(d[0]-1,a),c=2*a-b):(c=Math.min(e.totalPages-d[1],a),b=2*a-c)):c=b=5;return[Math.max(1,d[0]-b),Math.min(e.totalPages, -d[1]+c)]},_necessPage:function(a){if(0===a)return!0;var b=this.turn("range");return this.data().pageObjs[a].hasClass("fixed")||a>=b[0]&&a<=b[1]},_removeFromDOM:function(){var a,b=this.data();for(a in b.pageWrap)n(a,b.pageWrap)&&!g._necessPage.call(this,a)&&g._removePageFromDOM.call(this,a)},_removePageFromDOM:function(a){var b=this.data();if(b.pages[a]){var c=b.pages[a].data();i._moveFoldingPage.call(b.pages[a],!1);c.f&&c.f.fwrapper&&c.f.fwrapper.remove();b.pages[a].removeData();b.pages[a].remove(); -delete b.pages[a]}b.pageObjs[a]&&b.pageObjs[a].remove();b.pageWrap[a]&&(b.pageWrap[a].remove(),delete b.pageWrap[a]);g._removeMv.call(this,a);delete b.pagePlace[a];delete b.pageZoom[a]},removePage:function(a){var b=this.data();if("*"==a)for(;0!==b.totalPages;)this.turn("removePage",b.totalPages);else{if(1>a||a>b.totalPages)throw q("The page "+a+" doesn't exist");b.pageObjs[a]&&(this.turn("stop"),g._removePageFromDOM.call(this,a),delete b.pageObjs[a]);g._movePages.call(this,a,-1);b.totalPages-=1;b.page> -b.totalPages?(b.page=null,g._fitPage.call(this,b.totalPages)):(g._makeRange.call(this),this.turn("update"))}return this},_movePages:function(a,b){var c,d=this,e=this.data(),h="single"==e.display,f=function(a){var c=a+b,f=c%2,i=f?" odd ":" even ";e.pageObjs[a]&&(e.pageObjs[c]=e.pageObjs[a].removeClass("p"+a+" odd even").addClass("p"+c+i));e.pagePlace[a]&&e.pageWrap[a]&&(e.pagePlace[c]=c,e.pageWrap[c]=e.pageObjs[c].hasClass("fixed")?e.pageWrap[a].attr("page",c):e.pageWrap[a].css(g._pageSize.call(d, -c,!0)).attr("page",c),e.pages[a]&&(e.pages[c]=e.pages[a].flip("options",{page:c,next:h||f?c+1:c-1})),b&&(delete e.pages[a],delete e.pagePlace[a],delete e.pageZoom[a],delete e.pageObjs[a],delete e.pageWrap[a]))};if(0=a;c--)f(c);else for(c=a;c<=e.totalPages;c++)f(c)},display:function(a){var b=this.data(),c=b.display;if(void 0===a)return c;if(-1==f.inArray(a,V))throw q('"'+a+'" is not a value for display');switch(a){case "single":b.pageObjs[0]||(this.turn("stop").css({overflow:"hidden"}), -b.pageObjs[0]=f("
",{"class":"page p-temporal"}).css({width:this.width(),height:this.height()}).appendTo(this));this.addClass("shadow");break;case "double":b.pageObjs[0]&&(this.turn("stop").css({overflow:""}),b.pageObjs[0].remove(),delete b.pageObjs[0]),this.removeClass("shadow")}b.display=a;c&&(a=this.turn("size"),g._movePages.call(this,1,0),this.turn("size",a.width,a.height).turn("update"));return this},direction:function(a){var b=this.data();if(void 0===a)return b.direction;a=a.toLowerCase(); -if(-1==f.inArray(a,W))throw q('"'+a+'" is not a value for direction');"rtl"==a&&f(this).attr("dir","ltr").css({direction:"ltr"});b.direction=a;b.done&&this.turn("size",f(this).width(),f(this).height());return this},animating:function(){return 0a;c--)this.turn("removePage",c);b.totalPages=a;g._fitPage.call(this,b.page);return this}return b.totalPages},_missing:function(a){var b= -this.data();if(!(1>b.totalPages)){for(var c=this.turn("range",a),d=[],a=c[0];a<=c[1];a++)b.pageObjs[a]||d.push(a);0h[1]?(b=h[1],c=i[0]): -h[0]&&ab?"r":"l"):d.pages[b].flip("turnPage",a>b?"l":"r"):"ltr"==d.direction?d.pages[b].flip("turnPage",e[a>b?1:0]):d.pages[b].flip("turnPage",e[a>b?0:1]))},page:function(a){var b= -this.data();if(void 0===a)return b.page;if(!b.disabled&&!b.destroying){a=parseInt(a,10);if(0b.page?b.next:b.page+1),g._addMotionPage.call(a.target));g._updateShadow.call(b.turn)},_eventEnd:function(a,b,c){f(a.target).data();var a=b.turn,d=a.data();if(c){if(c=d.tpage||d.page,c==b.next||c==b.page)delete d.tpage,g._fitPage.call(a,c||b.next,!0)}else g._removeMv.call(a, -b.page),g._updateShadow.call(a),a.turn("update")},_eventPressed:function(a){var a=f(a.target).data().f,b=a.opts.turn;b.data().mouseAction=!0;b.turn("update");return a.time=(new Date).getTime()},_eventReleased:function(a,b){var c;c=f(a.target);var d=c.data().f,e=d.opts.turn,h=e.data();c="single"==h.display?"br"==b.corner||"tr"==b.corner?b.xc.width()/2:0>b.x||b.x>c.width();if(200>(new Date).getTime()-d.time||c)a.preventDefault(),g._turnPage.call(e,d.opts.next);h.mouseAction=!1},_flip:function(a){a.stopPropagation(); -a=f(a.target).data().f.opts;a.turn.trigger("turn",[a.next]);a.turn.data().opts.autoCenter&&a.turn.turn("center",a.next)},_touchStart:function(){var a=this.data(),b;for(b in a.pages)if(n(b,a.pages)&&!1===i._eventStart.apply(a.pages[b],arguments))return!1},_touchMove:function(){var a=this.data(),b;for(b in a.pages)n(b,a.pages)&&i._eventMove.apply(a.pages[b],arguments)},_touchEnd:function(){var a=this.data(),b;for(b in a.pages)n(b,a.pages)&&i._eventEnd.apply(a.pages[b],arguments)},calculateZ:function(a){var b, -c,d,e,h=this,f=this.data();b=this.turn("view");var i=b[0]||b[1],g=a.length-1,j={pageZ:{},partZ:{},pageV:{}},k=function(a){a=h.turn("view",a);a[0]&&(j.pageV[a[0]]=!0);a[1]&&(j.pageV[a[1]]=!0)};for(b=0;b<=g;b++)c=a[b],d=f.pages[c].data().f.opts.next,e=f.pagePlace[c],k(c),k(d),c=f.pagePlace[d]==d?d:c,j.pageZ[c]=f.totalPages-Math.abs(i-c),j.partZ[e]=2*f.totalPages-g+b;return j},update:function(){var a,b=this.data();if(this.turn("animating")&&0!==b.pageMv[0]){var c,d=this.turn("calculateZ",b.pageMv),e= -this.turn("corner"),h=this.turn("view"),i=this.turn("view",b.tpage);for(a in b.pageWrap)if(n(a,b.pageWrap)&&(c=b.pageObjs[a].hasClass("fixed"),b.pageWrap[a].css({display:d.pageV[a]||c?"":"none",zIndex:(b.pageObjs[a].hasClass("hard")?d.partZ[a]:d.pageZ[a])||(c?-1:0)}),c=b.pages[a]))c.flip("z",d.partZ[a]||null),d.pageV[a]&&c.flip("resize"),b.tpage?c.flip("hover",!1).flip("disable",-1==f.inArray(parseInt(a,10),b.pageMv)&&a!=i[0]&&a!=i[1]):c.flip("hover",!1===e).flip("disable",a!=h[0]&&a!=h[1])}else for(a in b.pageWrap)n(a, -b.pageWrap)&&(d=g._setPageLoc.call(this,a),b.pages[a]&&b.pages[a].flip("disable",b.disabled||1!=d).flip("hover",!0).flip("z",null));return this},_updateShadow:function(){var a,b,c=this.data(),d=this.width(),e=this.height(),h="single"==c.display?d:d/2;a=this.turn("view");c.shadow||(c.shadow=f("
",{"class":"shadow",css:l(0,0,0).css}).appendTo(this));for(var i=0;i=a.x||0>=a.y||a.x>=c||a.y>=d)return!1;var h=i._cAllowed.call(this);switch(b.effect){case "hard":if(a.x>c-e)a.corner="r";else if(a.x=d-e)a.corner+="b";else return!1;if(a.x<=e)a.corner+="l";else if(a.x>=c-e)a.corner+="r";else return!1}return!a.corner||-1==f.inArray(a.corner,h)?!1:a},_isIArea:function(a){var b=this.data().f.parent.offset(),a=u&&a.originalEvent?a.originalEvent.touches[0]: -a;return i._cornerActivated.call(this,{x:a.pageX-b.left,y:a.pageY-b.top})},_c:function(a,b){b=b||0;switch(a){case "tl":return j(b,b);case "tr":return j(this.width()-b,b);case "bl":return j(b,this.height()-b);case "br":return j(this.width()-b,this.height()-b);case "l":return j(b,0);case "r":return j(this.width()-b,0)}},_c2:function(a){switch(a){case "tl":return j(2*this.width(),0);case "tr":return j(-this.width(),0);case "bl":return j(2*this.width(),this.height());case "br":return j(-this.width(), -this.height());case "l":return j(2*this.width(),0);case "r":return j(-this.width(),0)}},_foldingPage:function(){var a=this.data().f;if(a){var b=a.opts;if(b.turn)return a=b.turn.data(),"single"==a.display?1",l(0,0,1)).css({position:"",width:this.width(),height:this.height()}).appendTo(a.parent); -return b},type:function(){return this.data().f.effect},resize:function(a){var b=this.data().f,c=b.opts.turn.data(),d=this.width(),e=this.height();switch(b.effect){case "hard":a&&(b.wrapper.css({width:d,height:e}),b.fpage.css({width:d,height:e}),c.opts.gradients&&(b.ashadow.css({width:d,height:e}),b.bshadow.css({width:d,height:e})));break;case "sheet":a&&(a=Math.round(Math.sqrt(Math.pow(d,2)+Math.pow(e,2))),b.wrapper.css({width:a,height:a}),b.fwrapper.css({width:a,height:a}).children(":first-child").css({width:d, -height:e}),b.fpage.css({width:d,height:e}),c.opts.gradients&&b.ashadow.css({width:d,height:e}),i._backGradient.call(this)&&b.bshadow.css({width:d,height:e})),b.parent.is(":visible")&&(c=D(b.parent[0]),b.fwrapper.css({top:c.top,left:c.left}),c=D(b.opts.turn[0]),b.fparent.css({top:-c.top,left:-c.left})),this.flip("z",b.opts["z-index"])}},_addPageWrapper:function(){var a=this.data().f,b=a.opts.turn.data(),c=this.parent();a.parent=c;if(!a.wrapper)switch(a.effect){case "hard":var d={};d[w+"transform-style"]= -"preserve-3d";d[w+"backface-visibility"]="hidden";a.wrapper=f("
",l(0,0,2)).css(d).appendTo(c).prepend(this);a.fpage=f("
",l(0,0,1)).css(d).appendTo(c);b.opts.gradients&&(a.ashadow=f("
",l(0,0,0)).hide().appendTo(c),a.bshadow=f("
",l(0,0,0)));break;case "sheet":var d=this.width(),e=this.height();Math.round(Math.sqrt(Math.pow(d,2)+Math.pow(e,2)));a.fparent=a.opts.turn.data().fparent;a.fparent||(d=f("
",{css:{"pointer-events":"none"}}).hide(),d.data().flips=0,d.css(l(0,0,"auto", -"visible").css).appendTo(a.opts.turn),a.opts.turn.data().fparent=d,a.fparent=d);this.css({position:"absolute",top:0,left:0,bottom:"auto",right:"auto"});a.wrapper=f("
",l(0,0,this.css("z-index"))).appendTo(c).prepend(this);a.fwrapper=f("
",l(c.offset().top,c.offset().left)).hide().appendTo(a.fparent);a.fpage=f("
",l(0,0,0,"visible")).css({cursor:"default"}).appendTo(a.fwrapper);b.opts.gradients&&(a.ashadow=f("
",l(0,0,1)).appendTo(a.fpage));i.setData.call(this,a)}i.resize.call(this, -!0)},_fold:function(a){var b=this.data().f,c=b.opts.turn.data(),d=i._c.call(this,a.corner),e=this.width(),h=this.height();switch(b.effect){case "hard":a.x="l"==a.corner?Math.min(Math.max(a.x,0),2*e):Math.max(Math.min(a.x,e),-e);var f,g,s,x,k,n=c.totalPages,l=b.opts["z-index"]||n,q={overflow:"visible"},p=d.x?(d.x-a.x)/e:a.x/e,r=90*p,t=90>r;switch(a.corner){case "l":x="0% 50%";k="100% 50%";t?(f=0,g=0L&&(m.x+=Math.abs(m.y*b.y/b.x),m.y=0,Math.round(m.x*Math.tan(K-g))L&&(b=K-g,f=R-h/Math.sin(b),v=j(Math.round(f*Math.cos(b)),Math.round(f*Math.sin(b))),C&&(v.x=-v.x), -E&&(v.y=-v.y));z=Math.round(m.y/Math.tan(g)+m.x);b=e-z;f=b*Math.cos(2*g);k=b*Math.sin(2*g);Q=j(Math.round(C?b-f:z+f),Math.round(E?k:h-k));c.opts.gradients&&(y=b*Math.sin(g),b=i._c2.call(u,a.corner),b=Math.sqrt(Math.pow(b.x-a.x,2)+Math.pow(b.y-a.y,2))/e,D=Math.sin(L*(1k)throw t('Page "'+b+'" cannot be inserted');}else b=k,d=!0;1<=b&&b<=k&&(c="double"==e.display?b%2?" odd":" even":"",e.done&&this.turn("stop"),b in e.pageObjs&&f._movePages.call(this,b,1), +d&&(e.totalPages=k),e.pageObjs[b]=g(a).css({"float":"left"}).addClass("page p"+b+c),f._addPage.call(this,b),f._removeFromDOM.call(this));return this},_addPage:function(a){var b=this.data(),c=b.pageObjs[a];if(c)if(f._necessPage.call(this,a)){if(!b.pageWrap[a]){b.pageWrap[a]=g("
",{"class":"page-wrapper",page:a,css:{position:"absolute",overflow:"hidden"}});this.append(b.pageWrap[a]);b.pagePlace[a]||(b.pagePlace[a]=a,b.pageObjs[a].appendTo(b.pageWrap[a]));var d=f._pageSize.call(this,a,!0);c.css({width:d.width, +height:d.height});b.pageWrap[a].css(d)}b.pagePlace[a]==a&&f._makeFlip.call(this,a)}else b.pagePlace[a]=0,b.pageObjs[a]&&b.pageObjs[a].remove()},hasPage:function(a){return m(a,this.data().pageObjs)},center:function(a){var b=this.data(),c=g(this).turn("size"),d=0;b.noCenter||("double"==b.display&&(a=this.turn("view",a||b.tpage||b.page),"ltr"==b.direction?a[0]?a[1]||(d+=c.width/4):d-=c.width/4:a[0]?a[1]||(d-=c.width/4):d+=c.width/4),d==0?d='auto':d,g(this).css({marginLeft:d}));return this},destroy:function(){var a= +this,b=this.data();if("prevented"!=v("destroying",this)){b.destroying=!0;g.each("end first flip last pressed released start turning turned zooming missing".split(" "),function(b,d){a.off(d)});this.parent().off("start",b.eventHandlers.start);for(g(document).off(w.move,b.eventHandlers.touchMove).off(w.up,b.eventHandlers.touchEnd);0!==b.totalPages;)this.turn("removePage",b.totalPages);b.fparent&&b.fparent.remove();b.shadow&&b.shadow.remove();this.removeData();b=null;return this}},is:function(){return"object"== +typeof this.data().pages},zoom:function(a){var b=this.data();if("number"==typeof a){if(.001>a||100this.data().totalPages)){var b=this.turn("range");for(a=b[0];a<=b[1];a++)f._addPage.call(this,a)}}, +range:function(a){var b=this.data();a=a||b.tpage||b.page||1;var c=f._view.call(this,a);if(1>a||a>b.totalPages)throw t('"'+a+'" is not a valid page');c[1]=c[1]||c[0];if(1<=c[0]&&c[1]<=b.totalPages)if(b.totalPages-c[1]>c[0]){a=Math.min(c[0]-1,2);var d=4-a}else d=Math.min(b.totalPages-c[1],2),a=4-d;else d=a=5;return[Math.max(1,c[0]-a),Math.min(b.totalPages,c[1]+d)]},_necessPage:function(a){if(0===a)return!0;var b=this.turn("range");return this.data().pageObjs[a].hasClass("fixed")||a>=b[0]&&a<=b[1]}, +_removeFromDOM:function(){var a,b=this.data();for(a in b.pageWrap)m(a,b.pageWrap)&&!f._necessPage.call(this,a)&&f._removePageFromDOM.call(this,a)},_removePageFromDOM:function(a){var b=this.data();if(b.pages[a]){var c=b.pages[a].data();h._moveFoldingPage.call(b.pages[a],!1);c.f&&c.f.fwrapper&&c.f.fwrapper.remove();b.pages[a].removeData();b.pages[a].remove();delete b.pages[a]}b.pageObjs[a]&&b.pageObjs[a].remove();b.pageWrap[a]&&(b.pageWrap[a].remove(),delete b.pageWrap[a]);f._removeMv.call(this,a); +delete b.pagePlace[a];delete b.pageZoom[a]},removePage:function(a){var b=this.data();if("*"==a)for(;0!==b.totalPages;)this.turn("removePage",b.totalPages);else{if(1>a||a>b.totalPages)throw t("The page "+a+" doesn't exist");b.pageObjs[a]&&(this.turn("stop"),f._removePageFromDOM.call(this,a),delete b.pageObjs[a]);f._movePages.call(this,a,-1);--b.totalPages;b.page>b.totalPages?(b.page=null,f._fitPage.call(this,b.totalPages)):(f._makeRange.call(this),this.turn("update"))}return this},_movePages:function(a, +b){var c,d=this,e=this.data(),k="single"==e.display,h=function(a){var c=a+b,h=c%2,g=h?" odd ":" even ";e.pageObjs[a]&&(e.pageObjs[c]=e.pageObjs[a].removeClass("p"+a+" odd even").addClass("p"+c+g));e.pagePlace[a]&&e.pageWrap[a]&&(e.pagePlace[c]=c,e.pageObjs[c].hasClass("fixed")?e.pageWrap[c]=e.pageWrap[a].attr("page",c):e.pageWrap[c]=e.pageWrap[a].css(f._pageSize.call(d,c,!0)).attr("page",c),e.pages[a]&&(e.pages[c]=e.pages[a].flip("options",{page:c,next:k||h?c+1:c-1})),b&&(delete e.pages[a],delete e.pagePlace[a], +delete e.pageZoom[a],delete e.pageObjs[a],delete e.pageWrap[a]))};if(0=a;c--)h(c);else for(c=a;c<=e.totalPages;c++)h(c)},display:function(a){var b=this.data(),c=b.display;if(void 0===a)return c;if(-1==W.indexOf(a))throw t('"'+a+'" is not a value for display');switch(a){case "single":b.pageObjs[0]||(this.turn("stop").css({overflow:"hidden"}),b.pageObjs[0]=g("
",{"class":"page p-temporal"}).css({width:this.width(),height:this.height()}).appendTo(this));this.addClass("shadow"); +break;case "double":b.pageObjs[0]&&(this.turn("stop").css({overflow:""}),b.pageObjs[0].remove(),delete b.pageObjs[0]),this.removeClass("shadow")}b.display=a;c&&(a=this.turn("size"),f._movePages.call(this,1,0),this.turn("size",a.width,a.height).turn("update"));return this},direction:function(a){var b=this.data();if(void 0===a)return b.direction;a=a.toLowerCase();if(-1==X.indexOf(a))throw t('"'+a+'" is not a value for direction');"rtl"==a&&g(this).attr("dir","ltr").css({direction:"ltr"});b.direction= +a;b.done&&this.turn("size",g(this).width(),g(this).height());return this},animating:function(){return 0a;c--)this.turn("removePage",c);b.totalPages=a;f._fitPage.call(this,b.page);return this}return b.totalPages},_missing:function(a){var b=this.data();if(!(1>b.totalPages)){var c=this.turn("range",a),d=[];for(a=c[0];a<=c[1];a++)b.pageObjs[a]||d.push(a);0d[1]?(h=d[1],g=e[0]):d[0]&&ah?"r":"l"):b.pages[h].flip("turnPage",a>h?"l":"r"):"ltr"==b.direction?b.pages[h].flip("turnPage",c[a>h?1:0]):b.pages[h].flip("turnPage",c[a>h?0:1]))},page:function(a){var b=this.data();if(void 0===a)return b.page;if(!b.disabled&&!b.destroying){a=parseInt(a,10);if(0b.page?b.next:b.page+1),f._addMotionPage.call(a.target));f._updateShadow.call(b.turn)},_eventEnd:function(a,b,c){g(a.target).data();a=b.turn;var d=a.data();if(c){if(c=d.tpage||d.page,c==b.next||c==b.page)delete d.tpage,f._fitPage.call(a,c||b.next,!0)}else f._removeMv.call(a,b.page),f._updateShadow.call(a),a.turn("update")},_eventPressed:function(a){a=g(a.target).data().f;var b=a.opts.turn;b.data().mouseAction=!0;b.turn("update");return a.time= +(new Date).getTime()},_eventReleased:function(a,b){var c=g(a.target),d=c.data().f,e=d.opts.turn,k=e.data();b="single"==k.display?"br"==b.corner||"tr"==b.corner?b.xc.width()/2:0>b.x||b.x>c.width();if(200>(new Date).getTime()-d.time||b)a.preventDefault(),f._turnPage.call(e,d.opts.next);k.mouseAction=!1},_flip:function(a){a.stopPropagation();a=g(a.target).data().f.opts;a.turn.trigger("turn",[a.next]);a.turn.data().opts.autoCenter&&a.turn.turn("center",a.next)},_touchStart:function(){var a= +this.data(),b;for(b in a.pages)if(m(b,a.pages)&&!1===h._eventStart.apply(a.pages[b],arguments))return!1},_touchMove:function(){var a=this.data(),b;for(b in a.pages)m(b,a.pages)&&h._eventMove.apply(a.pages[b],arguments)},_touchEnd:function(){var a=this.data(),b;for(b in a.pages)m(b,a.pages)&&h._eventEnd.apply(a.pages[b],arguments)},calculateZ:function(a){var b=this,c=this.data();var d=this.turn("view");var e=d[0]||d[1],k=a.length-1,h={pageZ:{},partZ:{},pageV:{}},f=function(a){a=b.turn("view",a);a[0]&& +(h.pageV[a[0]]=!0);a[1]&&(h.pageV[a[1]]=!0)};for(d=0;d<=k;d++){var g=a[d];var l=c.pages[g].data().f.opts.next;var n=c.pagePlace[g];f(g);f(l);g=c.pagePlace[l]==l?l:g;h.pageZ[g]=c.totalPages-Math.abs(e-g);h.partZ[n]=2*c.totalPages-k+d}return h},update:function(){var a,b=this.data();if(this.turn("animating")&&0!==b.pageMv[0]){var c=this.turn("calculateZ",b.pageMv),d=this.turn("corner"),e=this.turn("view"),h=this.turn("view",b.tpage);for(a in b.pageWrap)if(m(a,b.pageWrap)){var g=b.pageObjs[a].hasClass("fixed"); +b.pageWrap[a].css({display:c.pageV[a]||g?"":"none",zIndex:(b.pageObjs[a].hasClass("hard")?c.partZ[a]:c.pageZ[a])||(g?-1:0)});if(g=b.pages[a])g.flip("z",c.partZ[a]||null),c.pageV[a]&&g.flip("resize"),b.tpage?g.flip("hover",!1).flip("disable",-1==b.pageMv.indexOf(parseInt(a,10))&&a!=h[0]&&a!=h[1]):g.flip("hover",!1===d).flip("disable",a!=e[0]&&a!=e[1])}}else for(a in b.pageWrap)m(a,b.pageWrap)&&(c=f._setPageLoc.call(this,a),b.pages[a]&&b.pages[a].flip("disable",b.disabled||1!=c).flip("hover",!0).flip("z", +null));return this},_updateShadow:function(){var a=this.data(),b=this.width(),c=this.height(),d="single"==a.display?b:b/2;var e=this.turn("view");a.shadow||(a.shadow=g("
",{"class":"shadow",css:q(0,0,0).css}).appendTo(this));for(var h=0;h=a.x||0>=a.y||a.x>=c||a.y>=d)return!1;var g=h._cAllowed.call(this);switch(b.effect){case "hard":if(a.x> +c-e)a.corner="r";else if(a.x=d-e)a.corner+="b";else return!1;if(a.x<=e)a.corner+="l";else if(a.x>=c-e)a.corner+="r";else return!1}return a.corner&&-1!=g.indexOf(a.corner)?a:!1},_isIArea:function(a){var b=this.data().f.parent.offset();a=x&&a.originalEvent?a.originalEvent.touches[0]:a;return h._cornerActivated.call(this,{x:a.pageX-b.left,y:a.pageY-b.top})},_c:function(a,b){b=b||0;switch(a){case "tl":return l(b,b);case "tr":return l(this.width()- +b,b);case "bl":return l(b,this.height()-b);case "br":return l(this.width()-b,this.height()-b);case "l":return l(b,0);case "r":return l(this.width()-b,0)}},_c2:function(a){switch(a){case "tl":return l(2*this.width(),0);case "tr":return l(-this.width(),0);case "bl":return l(2*this.width(),this.height());case "br":return l(-this.width(),this.height());case "l":return l(2*this.width(),0);case "r":return l(-this.width(),0)}},_foldingPage:function(){var a=this.data().f;if(a){var b=a.opts;if(b.turn)return a= +b.turn.data(),"single"==a.display?1",q(0,0,1)).css({position:"",width:this.width(),height:this.height()}).appendTo(a.parent));return b},type:function(){return this.data().f.effect},resize:function(a){var b=this.data().f,c=b.opts.turn.data(),d=this.width(), +e=this.height();switch(b.effect){case "hard":a&&(b.wrapper.css({width:d,height:e}),b.fpage.css({width:d,height:e}),c.opts.gradients&&(b.ashadow.css({width:d,height:e}),b.bshadow.css({width:d,height:e})));break;case "sheet":a&&(a=Math.round(Math.sqrt(Math.pow(d,2)+Math.pow(e,2))),b.wrapper.css({width:a,height:a}),b.fwrapper.css({width:a,height:a}).children(":first-child").css({width:d,height:e}),b.fpage.css({width:d,height:e}),c.opts.gradients&&b.ashadow.css({width:d,height:e}),h._backGradient.call(this)&& +b.bshadow.css({width:d,height:e})),b.parent.is(":visible")&&(c=B(b.parent[0]),b.fwrapper.css({top:c.top,left:c.left}),c=B(b.opts.turn[0]),b.fparent.css({top:-c.top,left:-c.left})),this.flip("z",b.opts["z-index"])}},_addPageWrapper:function(){var a=this.data().f,b=a.opts.turn.data(),c=this.parent();a.parent=c;if(!a.wrapper)switch(a.effect){case "hard":var d={"transform-style":"preserve-3d","backface-visibility":"hidden"};a.wrapper=g("
",q(0,0,2)).css(d).appendTo(c).prepend(this);a.fpage=g("
", +q(0,0,1)).css(d).appendTo(c);b.opts.gradients&&(a.ashadow=g("
",q(0,0,0)).hide().appendTo(c),a.bshadow=g("
",q(0,0,0)));break;case "sheet":this.width(),this.height(),a.fparent=a.opts.turn.data().fparent,a.fparent||(d=g("
",{css:{"pointer-events":"none"}}).hide(),d.data().flips=0,d.css(q(0,0,"auto","visible").css).appendTo(a.opts.turn),a.opts.turn.data().fparent=d,a.fparent=d),this.css({position:"absolute",top:0,left:0,bottom:"auto",right:"auto"}),a.wrapper=g("
",q(0,0,this.css("z-index"))).appendTo(c).prepend(this), +a.fwrapper=g("
",q(c.offset().top,c.offset().left)).hide().appendTo(a.fparent),a.fpage=g("
",q(0,0,0,"visible")).css({cursor:"default"}).appendTo(a.fwrapper),b.opts.gradients&&(a.ashadow=g("
",q(0,0,1)).appendTo(a.fpage)),h.setData.call(this,a)}h.resize.call(this,!0)},_fold:function(a){var b=this.data().f,c=b.opts.turn.data(),d=h._c.call(this,a.corner),e=this.width(),g=this.height();switch(b.effect){case "hard":a.x="l"==a.corner?Math.min(Math.max(a.x,0),2*e):Math.max(Math.min(a.x,e), +-e);var f=c.totalPages,m=b.opts["z-index"]||f,V={overflow:"visible"},r=d.x?(d.x-a.x)/e:a.x/e,n=90*r,q=90>n;switch(a.corner){case "l":var t="0% 50%";var u="100% 50%";if(q){var y=0;var w=0N&&(p.x+=Math.abs(p.y*b.y/b.x),p.y=0,Math.round(p.x*Math.tan(M-k))N&&(b=M-k,f=T-g/Math.sin(b),z=l(Math.round(f*Math.cos(b)),Math.round(f*Math.sin(b))),E&&(z.x=-z.x),F&&(z.y=-z.y));B=Math.round(p.y/Math.tan(k)+p.x);b=e-B;f=b*Math.cos(2*k);n=b*Math.sin(2*k);S=l(Math.round(E?b-f:B+f),Math.round(F?n:g-n));c.opts.gradients&&(A=b*Math.sin(k),b=h._c2.call(x,a.corner),b=Math.sqrt(Math.pow(b.x-a.x,2)+Math.pow(b.y- +a.y,2))/e,G=Math.sin(N*(1