HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/lcc.kaunokolegija.lt/Skirtumai/assets/js/turn.min.js
/* turn.js | turnjs.com | (C) 2012 Emmanuel Garcia | MIT License | (mod by ajar) */
!function(t){var a,e="",r=Math.PI,i=r/2,n=(/iPad|iPhone|iPod/.test(navigator.platform)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1)&&!window.MSStream,s=navigator.userAgent.toLowerCase().indexOf("android")>-1,o="ontouchstart"in document.documentElement&&((window.PointerEvent?navigator.userAgent.match(/Windows Phone/i):0)||n||s),p=o?{start:"touchstart",move:"touchmove",end:"touchend"}:{start:"mousedown",move:"mousemove",end:"mouseup"},h={backward:["bl","tl"],forward:["br","tr"],all:["tl","bl","tr","br"]},l=["single","double"],g={page:1,gradients:!0,duration:600,acceleration:!0,display:"double",when:null},d={folding:null,corners:"forward",cornerSize:100,gradients:!0,duration:600,acceleration:!0},f={0:{top:0,left:0,right:"auto",bottom:"auto"},1:{top:0,right:0,left:"auto",bottom:"auto"}},c=function(t,a,e,r){return{css:{position:"absolute",top:t,left:a,overflow:r||"hidden","z-index":e||"auto"}}},u=function(t,a,e,r,i){var n=1-i,s=n*n*n,o=i*i*i;return v(Math.round(s*t.x+3*i*n*n*a.x+3*i*i*n*e.x+o*r.x),Math.round(s*t.y+3*i*n*n*a.y+3*i*i*n*e.y+o*r.y))},v=function(t,a){return{x:t,y:a}},w=function(t,e,r){return a&&r?" translate3d("+t+"px,"+e+"px, 0px) ":" translate("+t+"px, "+e+"px) "},b=function(t){return" rotate("+t+"deg) "},x=function(t,a){return Object.prototype.hasOwnProperty.call(a,t)},m=function(t,a,r,i,n){var s,o=[];if("-webkit-"==e){for(s=0;s<n;s++)o.push("color-stop("+i[s][0]+", "+i[s][1]+")");t.css({"background-image":"-webkit-gradient(linear, "+a.x+"% "+a.y+"%,  "+r.x+"% "+r.y+"%, "+o.join(",")+" )"})}else{a={x:a.x/100*t.width(),y:a.y/100*t.height()};var p=(r={x:r.x/100*t.width(),y:r.y/100*t.height()}).x-a.x,h=r.y-a.y,l=Math.atan2(h,p),g=l-Math.PI/2,d=Math.abs(t.width()*Math.sin(g))+Math.abs(t.height()*Math.cos(g)),f=Math.sqrt(h*h+p*p),c=v(r.x<a.x?t.width():0,r.y<a.y?t.height():0),u=Math.tan(l),w=-1/u,b=(w*c.x-c.y-u*a.x+a.y)/(w-u),x={x:b,y:w*b-w*c.x+c.y},m=Math.sqrt(Math.pow(x.x-a.x,2)+Math.pow(x.y-a.y,2));for(s=0;s<n;s++)o.push(" "+i[s][1]+" "+100*(m+f*i[s][0])/d+"%");t.css({"background-image":e+"linear-gradient("+-l+"rad,"+o.join(",")+")"})}},y={init:function(r){void 0===a&&(a="WebKitCSSMatrix"in window||"MozPerspective"in document.body.style,e=function(){for(var t=["Moz","Webkit","Khtml","O","ms"],a=t.length,e="";a--;)t[a]+"Transform"in document.body.style&&(e="-"+t[a].toLowerCase()+"-");return e}());var i,n=this.data(),s=this.children(),l="rtl"===n.dir;n.rtl=r.rtl=l,h={backward:l?["br","tr"]:["bl","tl"],forward:l?["bl","tl"]:["br","tr"],all:["tl","bl","tr","br"]};var d,c,u={left:{top:0,left:0,right:"auto",bottom:"auto"},right:{top:0,right:0,left:"auto",bottom:"auto"}};if(f={0:l?u.right:u.left,1:l?u.left:u.right},r=t.extend({width:this.width(),height:this.height()},g,r),n.opts=r,n.pageObjs={},n.pages={},n.pageWrap={},n.pagePlace={},n.pageMv=[],n.totalPages=r.pages||0,r.when)for(i in r.when)x(i,r.when)&&this.on(i,r.when[i]);for(this.css({position:"relative",width:r.width,height:r.height}),this.turn("display",r.display),a&&!o&&r.acceleration&&this.transform(w(0,0,!0)),i=0;i<s.length;i++)this.turn("addPage",s[i],i+1);return this.turn("page",r.page),h=t.extend({},h,r.corners),t(this).on(p.start,function(t){for(var a in c=!1,o&&(d=setTimeout(function(){for(var a in n.pages)x(a,n.pages)&&(c=!0,P._eventMove.call(n.pages[a],t,!0))},200)),n.pages)if(x(a,n.pages)&&!1===P._eventStart.call(n.pages[a],t))return!1}),t(document).on(p.move,function(t){for(var a in c=!1,clearTimeout(d),n.pages)x(a,n.pages)&&P._eventMove.call(n.pages[a],t)}).on(p.end,function(t){if(!c||!o)for(var a in clearTimeout(d),n.pages)x(a,n.pages)&&P._eventEnd.call(n.pages[a],t)}),n.done=!0,this},addPage:function(a,e){var r=!1,i=this.data(),n=i.totalPages+1;if(e){if(e==n)e=n,r=!0;else if(e>n)throw new Error('It is impossible to add the page "'+e+'", the maximum value is: "'+n+'"')}else e=n,r=!0;return e>=1&&e<=n&&(i.done&&this.turn("stop"),e in i.pageObjs&&y._movePages.call(this,e,1),r&&(i.totalPages=n),i.pageObjs[e]=t(a).addClass("turn-page p"+e),y._addPage.call(this,e),i.done&&this.turn("update"),y._removeFromDOM.call(this)),this},_addPage:function(a){var e=this.data(),r=e.pageObjs[a];if(r)if(y._necessPage.call(this,a)){if(!e.pageWrap[a]){var i="double"==e.display?this.width()/2:this.width(),n=this.height();r.css({width:i,height:n}),e.pagePlace[a]=a,e.pageWrap[a]=t("<div/>",{class:"turn-page-wrapper",page:a,css:{position:"absolute",overflow:"hidden",width:i,height:n}}).css(f["double"==e.display?a%2:0]),this.append(e.pageWrap[a]),e.pageWrap[a].prepend(e.pageObjs[a])}if(a&&1!=y._setPageLoc.call(this,a)||y._makeFlip.call(this,a),"double"===e.display){if(r.find(".turn-page-gutter").length)return;if(a>1&&(a!==e.totalPages||a%2)){var s=e.rtl&&!(a%2)||!e.rtl&&a%2,o=t("<div/>",{class:"turn-page-gutter",css:{position:"absolute","pointer-events":"none",width:30,height:"100%",zIndex:1}}).css(s?{left:0}:{right:0});m(o,{x:100,y:0},{x:0,y:0},s?[[0,"rgba(0,0,0,0)"],[1,"rgba(0,0,0,0.1)"]]:[[0,"rgba(0,0,0,0.1)"],[1,"rgba(0,0,0,0)"]],2),r.append(o)}}else t(".turn-page-gutter").remove()}else e.pagePlace[a]=0,e.pageObjs[a]&&e.pageObjs[a].remove()},hasPage:function(t){return t in this.data().pageObjs},_makeFlip:function(t){var a=this.data();if(!a.pages[t]&&a.pagePlace[t]==t){var e="single"==a.display,r=t%2;a.pages[t]=a.pageObjs[t].css({width:e?this.width():this.width()/2,height:this.height()}).flip({page:t,next:e&&t===a.totalPages?t-1:r||e?t+1:t-1,turn:this,duration:a.opts.duration,acceleration:a.opts.acceleration,corners:e?"all":r?"forward":"backward",backGradient:a.opts.gradients,frontGradient:a.opts.gradients}).flip("disable",a.disabled).on("pressed",y._pressed).on("released",y._released).on("start",y._start).on("end",y._end).on("flip",y._flip)}return a.pages[t]},_makeRange:function(){this.data();var t,a=this.turn("range");for(t=a[0];t<=a[1];t++)y._addPage.call(this,t)},range:function(t){var a,e,r,i=this.data();t=t||i.tpage||i.page;var n=y._view.call(this,t);if(t<1||t>i.totalPages)throw new Error('"'+t+'" is not a page for range');return n[1]=n[1]||n[0],n[0]>=1&&n[1]<=i.totalPages?(a=Math.floor(498.5),i.totalPages-n[1]>n[0]?r=2*a-(e=Math.min(n[0]-1,a)):e=2*a-(r=Math.min(i.totalPages-n[1],a))):(e=998,r=998),[Math.max(1,n[0]-e),Math.min(i.totalPages,n[1]+r)]},_necessPage:function(t){if(0===t)return!0;var a=this.turn("range");return t>=a[0]&&t<=a[1]},_removeFromDOM:function(){var t,a=this.data();for(t in a.pageWrap)x(t,a.pageWrap)&&!y._necessPage.call(this,t)&&y._removePageFromDOM.call(this,t)},_removePageFromDOM:function(t){var a=this.data();a.pages[t]&&(a.pages[t].remove(),delete a.pages[t]),a.pageObjs[t]&&a.pageObjs[t].remove(),a.pageWrap[t]&&(a.pageWrap[t].remove(),delete a.pageWrap[t]),delete a.pagePlace[t]},removePage:function(t){var a=this.data();return a.pageObjs[t]&&(this.turn("stop"),y._removePageFromDOM.call(this,t),delete a.pageObjs[t]),this},_movePages:function(t,a){var e,r=this.data(),i="single"==r.display,n=function(t){var e=t+a,n=e%2;r.pageObjs[t]&&(r.pageObjs[e]=r.pageObjs[t].removeClass("page"+t).addClass("page"+e)),r.pagePlace[t]&&r.pageWrap[t]&&(r.pagePlace[e]=e,r.pageWrap[e]=r.pageWrap[t].css(f[i?0:n]).attr("page",e),r.pages[t]&&(r.pages[e]=r.pages[t].flip("options",{page:e,next:i||n?e+1:e-1,corners:i?"all":n?"forward":"backward"})),a&&(delete r.pages[t],delete r.pagePlace[t],delete r.pageObjs[t],delete r.pageWrap[t],delete r.pageObjs[t]))};if(a>0)for(e=r.totalPages;e>=t;e--)n(e);else for(e=t;e<=r.totalPages;e++)n(e)},display:function(a){var e=this.data(),r=e.display;if(a){if(-1==t.inArray(a,l))throw new Error('"'+a+'" is not a value for display');if("single"==a?e.pageObjs[0]||(this.turn("stop").css({overflow:"hidden"}),e.pageObjs[0]=t("<div />",{class:"turn-page p-temporal"}).css({width:this.width(),height:this.height()}).appendTo(this)):e.pageObjs[0]&&(this.turn("stop").css({overflow:""}),e.pageObjs[0].remove(),delete e.pageObjs[0]),e.display=a,r){var i=this.turn("size");y._movePages.call(this,1,0),this.turn("size",i.width,i.height).turn("update")}return this}return r},animating:function(){return this.data().pageMv.length>0},disable:function(a){var e,r=this.data(),i=this.turn("view");for(e in r.disabled=void 0===a||!0===a,r.pages)x(e,r.pages)&&r.pages[e].flip("disable",!!a&&t.inArray(e,i));return this},size:function(t,a){if(t&&a){var e,r=this.data(),i="double"==r.display?t/2:t;for(e in this.css({width:t,height:a}),r.pageObjs[0]&&r.pageObjs[0].css({width:i,height:a}),r.pageWrap)x(e,r.pageWrap)&&(r.pageObjs[e].css({width:i,height:a}),r.pageWrap[e].css({width:i,height:a}),r.pages[e]&&r.pages[e].css({width:i,height:a}));return y._makeRange.call(this),this.turn("resize"),this}return{width:this.width(),height:this.height()}},resize:function(){var t,a=this.data();for(a.pages[0]&&(a.pageWrap[0].css({left:-this.width()}),a.pages[0].flip("resize",!0)),t=1;t<=a.totalPages;t++)a.pages[t]&&a.pages[t].flip("resize",!0)},_removeMv:function(t){var a,e=this.data();for(a=0;a<e.pageMv.length;a++)if(e.pageMv[a]==t)return e.pageMv.splice(a,1),!0;return!1},_addMv:function(t){var a=this.data();y._removeMv.call(this,t),a.pageMv.push(t)},_view:function(t){var a=this.data();return t=t||a.page,"double"==a.display?t%2?[t-1,t]:[t,t+1]:[t]},view:function(t){var a=this.data(),e=y._view.call(this,t);return"double"==a.display?[e[0]>0?e[0]:0,e[1]<=a.totalPages?e[1]:0]:[e[0]>0&&e[0]<=a.totalPages?e[0]:0]},stop:function(t){var a,e,r=this.data(),i=r.pageMv;for(a in r.pageMv=[],r.tpage&&(r.page=r.tpage,delete r.tpage),i)x(a,i)&&(e=r.pages[i[a]].data().f.opts,P._moveFoldingPage.call(r.pages[i[a]],null),r.pages[i[a]].flip("hideFoldedPage"),r.pagePlace[e.next]=e.next,e.force&&(e.next=e.page%2==0?e.page-1:e.page+1,delete e.force));return this.turn("update"),this},pages:function(t){var a=this.data();if(t){if(t<a.totalPages){for(var e=t+1;e<=a.totalPages;e++)this.turn("removePage",e);this.turn("page")>t&&this.turn("page",t)}return a.totalPages=t,this}return a.totalPages},_fitPage:function(a,e){var r=this.data(),i=this.turn("view",a);r.page!=a&&(this.trigger("turning",[a,i]),-1!=t.inArray(1,i)&&this.trigger("first"),-1!=t.inArray(r.totalPages,i)&&this.trigger("last")),r.pageObjs[a]&&(r.tpage=a,this.turn("stop",e),y._removeFromDOM.call(this),y._makeRange.call(this),this.trigger("turned",[a,i]))},_turnPage:function(a){var e,r,i=this.data(),n=this.turn("view"),s=this.turn("view",a);if(i.page!=a&&(this.trigger("turning",[a,s]),-1!=t.inArray(1,s)&&this.trigger("first"),-1!=t.inArray(i.totalPages,s)&&this.trigger("last")),i.pageObjs[a]&&(i.tpage=a,this.turn("stop"),y._makeRange.call(this),"single"==i.display?(e=n[0],r=s[0]):n[1]&&a>n[1]?(e=n[1],r=s[0]):n[0]&&a<n[0]&&(e=n[0],r=s[1]),i.pages[e])){var o=i.pages[e].data().f.opts;i.tpage=r,o.next!=r&&(o.next=r,i.pagePlace[r]=o.page,o.force=!0),"single"==i.display?i.pages[e].flip("turnPage",s[0]>n[0]?h.forward[0]:h.backward[0]):i.pages[e].flip("turnPage")}},page:function(a){a=parseInt(a,10);var e=this.data();return a>0&&a<=e.totalPages?(e.done&&-1==t.inArray(a,this.turn("view"))?y._turnPage.call(this,a):y._fitPage.call(this,a),this):e.page},next:function(){var t=this.data();return this.turn("page",y._view.call(this,t.page).pop()+1)},previous:function(){var t=this.data();return this.turn("page",y._view.call(this,t.page).shift()-1)},_addMotionPage:function(){var a=t(this).data().f.opts,e=a.turn,r=e.data();a.pageMv=a.page,y._addMv.call(e,a.pageMv),r.pagePlace[a.next]=a.page,e.turn("update")},_start:function(a,e,r){var i=e.turn.data(),n=t.Event("start");if(a.stopPropagation(),e.turn.trigger(n,[e,r]),n.isDefaultPrevented())a.preventDefault();else{if("single"==i.display){var s=h.backward[0].charAt(1)==r.charAt(1);1==e.page&&s||e.page==i.totalPages&&!s?a.preventDefault():s?(e.next=e.next<e.page?e.next:e.page-1,e.force=!0):e.next=e.next>e.page?e.next:e.page+1}y._addMotionPage.call(this)}},_end:function(a,e){var r=t(this).data().f.opts,i=r.turn,n=i.data();a.stopPropagation(),e||n.tpage?n.tpage!=r.next&&n.tpage!=r.page||(delete n.tpage,y._fitPage.call(i,n.tpage||r.next,!0)):(i.turn("update"),t(".turn-page-wrapper:not(:has(*))").css("z-index","-1"))},_pressed:function(){var a,e=t(this).data().f,r=e.opts.turn.data().pages;for(a in r)a!=e.opts.page&&r[a].flip("disable",!0);return e.time=(new Date).getTime()},_released:function(a,e){var r=t(this),i=r.data().f;a.stopPropagation();var n=r.width(),s=(e.corner,i.opts),o=s.turn.data(),p=s.page>s.next;o.rtl&&(p=!p),((new Date).getTime()-i.time<200||(p?e.x>.5*n:e.x<.5*n))&&(a.preventDefault(),i.opts.turn.data().tpage=i.opts.next,i.opts.turn.turn("update"),t(r).flip("turnPage"))},_flip:function(){var a=t(this).data().f.opts;a.turn.trigger("turn",[a.next])},calculateZ:function(t){var a,e,r,i,n,s=this,o=this.data(),p=this.turn("view"),h=p[0]||p[1],l={pageZ:{},partZ:{},pageV:{}},g=function(t){var a=s.turn("view",t);a[0]&&(l.pageV[a[0]]=!0),a[1]&&(l.pageV[a[1]]=!0)};for(a=0;a<t.length;a++)e=t[a],r=o.pages[e].data().f.opts.next,i=o.pagePlace[e],g(e),g(r),n=o.pagePlace[r]==r?r:e,l.pageZ[n]=o.totalPages-Math.abs(h-n),l.partZ[i]=2*o.totalPages+Math.abs(h-n);return l},update:function(){var t,a=this.data();if(a.pageMv.length&&0!==a.pageMv[0]){var e=this.turn("calculateZ",a.pageMv),r=this.turn("view",a.tpage);for(t in a.pagePlace[r[0]]==r[0]?r[0]:a.pagePlace[r[1]]==r[1]&&r[1],a.pageWrap)x(t,a.pageWrap)&&(a.pageWrap[t].css({display:e.pageV[t]?"":"none","z-index":e.pageZ[t]||0}),a.pages[t]&&(a.pages[t].flip("z",e.partZ[t]||null),e.pageV[t]&&a.pages[t].flip("resize"),a.tpage&&a.pages[t].flip("disable",!0)))}else for(t in a.pageWrap)if(x(t,a.pageWrap)){var i=y._setPageLoc.call(this,t);a.pages[t]&&a.pages[t].flip("disable",a.disabled||1!=i).flip("z",null)}},_setPageLoc:function(t){var a=this.data(),e=this.turn("view");return t==e[0]||t==e[1]?(a.pageWrap[t].css({"z-index":a.totalPages,display:""}),1):"single"==a.display&&t==e[0]+1||"double"==a.display&&t==e[0]-2||t==e[1]+2?(a.pageWrap[t].css({"z-index":a.totalPages-1,display:""}),2):(a.pageWrap[t].css({"z-index":0,display:"none"}),0)}},P={init:function(t){return t.gradients&&(t.frontGradient=!0,t.backGradient=!0),this.data({f:{}}),this.flip("options",t),P._addPageWrapper.call(this),this},setData:function(a){var e=this.data();return e.f=t.extend(e.f,a),this},options:function(a){var e=this.data().f;return a?(P.setData.call(this,{opts:t.extend({},e.opts||d,a)}),this):e.opts},z:function(t){var a=this.data().f;return a.opts["z-index"]=t,a.fwrapper.css({"z-index":t||parseInt(a.parent.css("z-index"),10)||0}),this},_cAllowed:function(){return h[this.data().f.opts.corners]||this.data().f.opts.corners},_cornerActivated:function(a){if(void 0===a.originalEvent)return!1;a=o?a.originalEvent.touches:[a];var e=this.data().f,r=e.parent.offset(),i=this.width(),n=this.height(),s={x:Math.max(0,a[0].pageX-r.left),y:Math.max(0,a[0].pageY-r.top)},p=e.opts.cornerSize,h=P._cAllowed.call(this);if(s.x<=0||s.y<=0||s.x>=i||s.y>=n)return!1;if(s.y<p)s.corner="t";else{if(!(s.y>=n-p))return!1;s.corner="b"}if(s.x<=p)s.corner+="l";else{if(!(s.x>=i-p))return!1;s.corner+="r"}return-1!=t.inArray(s.corner,h)&&s},_c:function(t,a){return{tl:v(a=a||0,a),tr:v(this.width()-a,a),bl:v(a,this.height()-a),br:v(this.width()-a,this.height()-a)}[t]},_c2:function(t){return{tl:v(2*this.width(),0),tr:v(-this.width(),0),bl:v(2*this.width(),this.height()),br:v(-this.width(),this.height())}[t]},_foldingPage:function(t){var a=this.data().f.opts;if(a.folding)return a.folding;if(a.turn){var e=a.turn.data();return"single"==e.display?e.pageObjs[a.next]?e.pageObjs[0]:null:e.pageObjs[a.next]}},_backGradient:function(){var a=this.data().f,e=a.opts.turn,r=a.opts.backGradient&&(!e||"single"==e.data().display||2!=a.opts.page&&a.opts.page!=e.data().totalPages-1);return r&&!a.bshadow&&(a.bshadow=t("<div/>",c(0,0,1)).css({position:"",width:this.width(),height:this.height()}).appendTo(a.parent)),r},resize:function(t){var a=this.data().f,e=this.width(),r=this.height(),i=Math.round(Math.sqrt(Math.pow(e,2)+Math.pow(r,2)));t&&(a.wrapper.css({width:i,height:i}),a.fwrapper.css({width:i,height:i}).children(":first-child").css({width:e,height:r}),a.fpage.css({width:r,height:e}),a.opts.frontGradient&&a.ashadow.css({width:r,height:e}),P._backGradient.call(this)&&a.bshadow.css({width:e,height:r})),a.parent.is(":visible")&&(a.fwrapper.css({top:a.parent.offset().top,left:a.parent.offset().left}),a.opts.turn&&a.fparent.css({top:-a.opts.turn.offset().top,left:-a.opts.turn.offset().left})),this.flip("z",a.opts["z-index"])},_addPageWrapper:function(){var a=this.data().f,e=this.parent();if(!a.wrapper){this.css("left"),this.css("top");var r=this.width(),i=this.height();Math.round(Math.sqrt(Math.pow(r,2)+Math.pow(i,2)));if(a.parent=e,a.fparent=a.opts.turn?a.opts.turn.data().fparent:t("#turn-fwrappers"),!a.fparent){var n=t("<div/>",{css:{"pointer-events":"none"}}).hide();n.data().flips=0,a.opts.turn?(n.css(c(-a.opts.turn.offset().top,-a.opts.turn.offset().left,"auto","visible").css).appendTo(a.opts.turn),a.opts.turn.data().fparent=n):n.css(c(0,0,"auto","visible").css).attr("id","turn-fwrappers").appendTo(t("body")),a.fparent=n}this.css({position:"absolute",top:0,left:0,bottom:"auto",right:"auto"}),a.wrapper=t("<div/>",c(0,0,this.css("z-index"))).appendTo(e).prepend(this),a.fwrapper=t("<div/>",c(e.offset().top,e.offset().left)).hide().appendTo(a.fparent),a.fpage=t("<div/>",{css:{cursor:"default","background-color":"#fff"}}).appendTo(t("<div/>",c(0,0,0,"visible")).appendTo(a.fwrapper)),a.opts.frontGradient&&(a.ashadow=t("<div/>",c(0,0,1)).appendTo(a.fpage)),P.setData.call(this,a),P.resize.call(this,!0)}},_fold:function(t){var a,e,n,s,o,p,h=this,l=0,g=0,d=v(0,0),f=v(0,0),c=v(0,0),u=this.width(),x=this.height(),y=P._foldingPage.call(this),M=(Math.tan(g),this.data().f),_=M.opts.acceleration,O=M.wrapper.height(),j=P._c.call(this,t.corner),z="t"==t.corner.substr(0,1),k="l"==t.corner.substr(1,1),W=function(){var w,b=v(j.x?j.x-t.x:t.x,j.y?j.y-t.y:t.y),m=Math.atan2(b.y,b.x);l=(g=i-m)/r*180,w=v(k?u-b.x/2:t.x+b.x/2,b.y/2);var y=g-Math.atan2(w.y,w.x),_=Math.max(0,Math.sin(y)*Math.sqrt(Math.pow(w.x,2)+Math.pow(w.y,2)));if(c=v(_*Math.sin(g),_*Math.cos(g)),g>i&&(c.x=c.x+Math.abs(c.y*Math.tan(m)),c.y=0,Math.round(c.x*Math.tan(r-g))<x))return t.y=Math.sqrt(Math.pow(x,2)+2*w.x*b.x),z&&(t.y=x-t.y),W();if(g>i){var F=r-g,A=O-x/Math.sin(F);d=v(Math.round(A*Math.cos(F)),Math.round(A*Math.sin(F))),k&&(d.x=-d.x),z&&(d.y=-d.y)}a=Math.round(c.y/Math.tan(g)+c.x);var D=u-a,T=D*Math.cos(2*g),E=D*Math.sin(2*g);f=v(Math.round(k?D-T:a+T),Math.round(z?E:x-E)),o=D*Math.sin(g);var G=P._c2.call(h,t.corner),I=Math.sqrt(Math.pow(G.x-t.x,2)+Math.pow(G.y-t.y,2));return p=I<u?I/u:1,M.opts.frontGradient&&(s=o>100?(o-100)/o:0,e=v(o*Math.sin(i-g)/x*100,o*Math.cos(i-g)/u*100),z&&(e.y=100-e.y),k&&(e.x=100-e.x)),P._backGradient.call(h)&&(n=v(o*Math.sin(g)/u*100,o*Math.cos(g)/x*100),k||(n.x=100-n.x),z||(n.y=100-n.y)),c.x=Math.round(c.x),c.y=Math.round(c.y),!0},F=function(t,a,r,i){var o=["0","auto"],l=(u-O)*r[0]/100,g=(x-O)*r[1]/100,c={left:o[a[0]],top:o[a[1]],right:o[a[2]],bottom:o[a[3]]},y=90!=i&&-90!=i?k?-1:1:0;r=r[0]+"% "+r[1]+"%",h.css(c).transform(b(i)+w(t.x+y,t.y,_),r),M.fpage.parent().css(c),M.wrapper.transform(w(-t.x+l-y,-t.y+g,_)+b(-i),r),M.fwrapper.transform(w(-t.x+d.x+l,-t.y+d.y+g,_)+b(-i),r),M.fpage.parent().transform(b(i)+w(t.x+f.x-d.x,t.y+f.y-d.y,_),r),M.opts.frontGradient&&m(M.ashadow,v(k?100:0,z?100:0),v(e.x,e.y),[[s,"rgba(0,0,0,0)"],[.8*(1-s)+s,"rgba(0,0,0,"+.2*p+")"],[1,"rgba(255,255,255,"+.2*p+")"]],3),P._backGradient.call(h)&&m(M.bshadow,v(k?0:100,z?0:100),v(n.x,n.y),[[.8,"rgba(0,0,0,0)"],[1,"rgba(0,0,0,"+.3*p+")"],[1,"rgba(0,0,0,0)"]],3)};switch(t.corner){case"tl":t.x=Math.max(t.x,1),W(),F(c,[1,0,0,1],[100,0],l),M.fpage.transform(w(-x,-u,_)+b(90-2*l),"100% 100%"),y.transform(b(90)+w(0,-x,_),"0% 0%");break;case"tr":t.x=Math.min(t.x,u-1),W(),F(v(-c.x,c.y),[0,0,0,1],[0,0],-l),M.fpage.transform(w(0,-u,_)+b(2*l-90),"0% 100%"),y.transform(b(270)+w(-u,0,_),"0% 0%");break;case"bl":t.x=Math.max(t.x,1),W(),F(v(c.x,-c.y),[1,1,0,0],[100,100],-l),M.fpage.transform(w(-x,0,_)+b(2*l-90),"100% 0%"),y.transform(b(270)+w(-u,0,_),"0% 0%");break;case"br":t.x=Math.min(t.x,u-1),W(),F(v(-c.x,-c.y),[0,1,1,0],[0,100],l),M.fpage.transform(b(90-2*l),"0% 0%"),y.transform(b(90)+w(0,-x,_),"0% 0%")}M.point=t},_moveFoldingPage:function(t){var a=this.data().f,e=P._foldingPage.call(this);e&&(t?a.fpage.children()[a.ashadow?"1":"0"]||(P.setData.call(this,{backParent:e.parent()}),a.fpage.prepend(e)):a.backParent&&a.backParent.prepend(e))},_showFoldedPage:function(a,e){var r=P._foldingPage.call(this),i=this.data(),n=i.f;if(!n.point||n.point.corner!=a.corner){var s=t.Event("start");if(this.trigger(s,[n.opts,a.corner]),s.isDefaultPrevented())return!1}if(r){if(e){var o=this,p=n.point&&n.point.corner==a.corner?n.point:P._c.call(this,a.corner,1);this.animatef({from:[p.x,p.y],to:[a.x,a.y],duration:500,frame:function(t){a.x=Math.round(t[0]),a.y=Math.round(t[1]),P._fold.call(o,a)}})}else P._fold.call(this,a),i.effect&&!i.effect.turning&&this.animatef(!1);return n.fwrapper.is(":visible")||(n.fparent.show().data().flips++,P._moveFoldingPage.call(this,!0),n.fwrapper.show(),n.bshadow&&n.bshadow.show()),!0}return!1},hide:function(){var t=this.data().f,a=P._foldingPage.call(this);return 0==--t.fparent.data().flips&&t.fparent.hide(),this.css({left:0,top:0,right:"auto",bottom:"auto"}).transform("","0% 100%"),t.wrapper.transform("","0% 100%"),t.fwrapper.hide(),t.bshadow&&t.bshadow.hide(),a.transform("","0% 0%"),this},hideFoldedPage:function(t){var a=this.data().f;if(a.point){var e=this,r=a.point,i=function(){a.point=null,e.flip("hide"),e.trigger("end",[!1])};if(t){var n=P._c.call(this,r.corner),s="t"==r.corner.substr(0,1)?Math.min(0,r.y-n.y)/2:Math.max(0,r.y-n.y)/2,o=v(r.x,r.y+s),p=v(n.x,n.y-s);this.animatef({from:0,to:1,frame:function(t){var a=u(r,o,p,n,t);r.x=a.x,r.y=a.y,P._fold.call(e,r)},complete:i,duration:800,hiding:!0})}else this.animatef(!1),i()}},turnPage:function(t){var a=this,e=this.data().f;t={corner:e.corner?e.corner.corner:t||P._cAllowed.call(this)[0]};var r=e.point||P._c.call(this,t.corner,e.opts.turn?e.opts.turn.data().opts.elevation:0),i=P._c2.call(this,t.corner);this.trigger("flip").animatef({from:0,to:1,frame:function(e){var n=u(r,r,i,i,e);t.x=n.x,t.y=n.y,P._showFoldedPage.call(a,t)},complete:function(){a.trigger("end",[!0])},duration:e.opts.duration,turning:!0}),e.corner=null},moving:function(){return"effect"in this.data()},isTurning:function(){return this.flip("moving")&&this.data().effect.turning},_eventStart:function(t){var a=this.data().f;if(!a.disabled&&!this.flip("isTurning")){if(a.corner=P._cornerActivated.call(this,t),a.corner&&P._foldingPage.call(this,a.corner))return P._moveFoldingPage.call(this,!0),this.trigger("pressed",[a.point]),!1;a.corner=null}},_eventMove:function(t,a){var e=this.data().f;if(!e.disabled)if(t=o&&!a?t.originalEvent.touches:[t],e.corner&&!a){var r=e.parent.offset();e.corner.x=t[0].pageX-r.left,e.corner.y=t[0].pageY-r.top,P._showFoldedPage.call(this,e.corner)}else if(!this.data().effect&&this.is(":visible")){var i=P._cornerActivated.call(this,t[0]);if(i){var n=P._c.call(this,i.corner,e.opts.cornerSize/2);i.x=n.x,i.y=n.y,P._showFoldedPage.call(this,i,!0)}else P.hideFoldedPage.call(this,!0)}},_eventEnd:function(){var a=this.data().f;if(!a.disabled&&a.point){var e=t.Event("released");this.trigger(e,[a.point]),e.isDefaultPrevented()||P.hideFoldedPage.call(this,!0)}a.corner=null},disable:function(t){return P.setData.call(this,{disabled:t}),this}},M=function(t,a,e){if(e[0]&&"object"!=typeof e[0]){if(a[e[0]])return a[e[0]].apply(t,Array.prototype.slice.call(e,1));throw e[0]+" is an invalid value"}return a.init.apply(t,e)};t.extend(t.fn,{flip:function(t,a){return M(this,P,arguments)},turn:function(t){return M(this,y,arguments)},transform:function(t,a){var r={};return a&&(r[e+"transform-origin"]=a),r[e+"transform"]=t,this.css(r)},animatef:function(t){var a=this.data();if(a.effect&&clearInterval(a.effect.handle),t){t.to.length||(t.to=[t.to]),t.from.length||(t.from=[t.from]),t.easing||(t.easing=function(t,a,e,r,i){return r*Math.sqrt(1-(a=a/i-1)*a)+e});var e,r=[],i=t.to.length,n=this,s=t.fps||30,o=-s,p=function(){var e,p=[];for(o=Math.min(t.duration,o+s),e=0;e<i;e++)p.push(t.easing(1,o,t.from[e],r[e],t.duration));t.frame(1==i?p[0]:p),o==t.duration&&(clearInterval(a.effect.handle),delete a.effect,n.data(a),t.complete&&t.complete())};for(e=0;e<i;e++)r.push(t.to[e]-t.from[e]);a.effect=t,a.effect.handle=setInterval(p,s),this.data(a),p()}else delete a.effect},peel:function(t){try{var a=t||h.forward[1],e=this.data(),r=e.pageObjs[e.page].flip("options").cornerSize,i=e.pageObjs[y._view.call(this,e.page).pop()],n=P._c.call(i,a,r/2);n.corner=a,i.flip("_showFoldedPage",n,!0)}catch(t){}}}),t.isTouch=o}(jQuery);