diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/turn.js b/index.js similarity index 98% rename from turn.js rename to index.js index d6feac9..e6780de 100644 --- a/turn.js +++ b/index.js @@ -1,25 +1,4 @@ -/** - * turn.js 3rd release - * www.turnjs.com - * - * Copyright (C) 2012, Emmanuel Garcia. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Any redistribution, use, or modification is done solely for personal - * benefit and not for any commercial purpose or for monetary gain. - * - **/ - -(function($) { - -'use strict'; +var $ = require('jquery'); var has3d, @@ -54,7 +33,7 @@ var has3d, // First page page: 1, - + // Enables gradients gradients: true, @@ -79,7 +58,7 @@ var has3d, flipOptions = { // Back page - + folding: null, // Corners @@ -88,7 +67,7 @@ var has3d, // all: Activates all the corners corners: 'forward', - + // Size of the active zone of each corner cornerSize: 100, @@ -109,7 +88,7 @@ var has3d, // Number of pages in the DOM, minimum value: 6 pagesInDOM = 6, - + pagePosition = {0: {top: 0, left: 0, right: 'auto', bottom: 'auto'}, 1: {top: 0, right: 0, left: 'auto', bottom: 'auto'}}, @@ -136,7 +115,7 @@ var has3d, return point2D(Math.round(mum13*p1.x + 3*t*mum1*mum1*p2.x + 3*t*t*mum1*p3.x + mu3*p4.x), Math.round(mum13*p1.y + 3*t*mum1*mum1*p2.y + 3*t*t*mum1*p3.y + mu3*p4.y)); }, - + // Converts an angle from degrees to radians rad = function(degrees) { @@ -190,21 +169,21 @@ var has3d, // Adds gradients gradient = function(obj, p0, p1, colors, numColors) { - + var j, cols = []; if (vendor=='-webkit-') { - + for (j = 0; jdata.totalPages) throw new Error ('"'+page+'" is not a page for range'); - + view[1] = view[1] || view[0]; - + if (view[0]>=1 && view[1]<=data.totalPages) { remainingPages = Math.floor((pagesInDOM-2)/2); @@ -498,14 +477,14 @@ turnMethods = { // Detects if a page is within the range of `pagesInDOM` from the current view _necessPage: function(page) { - + if (page===0) return true; var range = this.turn('range'); return page>=range[0] && page<=range[1]; - + }, // Releases memory by removing pages from the DOM @@ -517,7 +496,7 @@ turnMethods = { for (page in data.pageWrap) if (has(page, data.pageWrap) && !turnMethods._necessPage.call(this, page)) turnMethods._removePageFromDOM.call(this, page); - + }, @@ -574,7 +553,7 @@ turnMethods = { } return this; - + }, // Moves pages @@ -595,7 +574,7 @@ turnMethods = { if (data.pagePlace[page] && data.pageWrap[page]) { data.pagePlace[next] = next; data.pageWrap[next] = data.pageWrap[page].css(pagePosition[(single) ? 0 : odd]).attr('page', next); - + if (data.pages[page]) data.pages[next] = data.pages[page].flip('options', { page: next, @@ -631,7 +610,7 @@ turnMethods = { if ($.inArray(display, displays)==-1) throw new Error ('"'+display + '" is not a value for display'); - + if (display=='single') { if (!data.pageObjs[0]) { this.turn('stop'). @@ -662,7 +641,7 @@ turnMethods = { } else return currentDisplay; - + }, // Detects if the pages are being animated @@ -703,7 +682,7 @@ turnMethods = { if (data.pageObjs[0]) data.pageObjs[0].css({width: pageWidth, height: height}); - + for (page in data.pageWrap) { if (!has(page, data.pageWrap)) continue; data.pageObjs[page].css({width: pageWidth, height: height}); @@ -717,7 +696,7 @@ turnMethods = { return this; } else { - + return {width: this.width(), height: this.height()}; } @@ -746,7 +725,7 @@ turnMethods = { _removeMv: function(page) { var i, data = this.data(); - + for (i=0; i=height-csz) c.corner = 'b'; else return false; - + if (c.x<=csz) c.corner+= 'l'; else if (c.x>=width-csz) c.corner+= 'r'; else return false; @@ -1295,7 +1274,7 @@ flipMethods = { _foldingPage: function(corner) { var opts = this.data().f.opts; - + if (opts.folding) return opts.folding; else if(opts.turn) { var data = opts.turn.data(); @@ -1325,7 +1304,7 @@ flipMethods = { }, resize: function(full) { - + var data = this.data().f, width = this.width(), height = this.height(), @@ -1373,7 +1352,7 @@ flipMethods = { width = this.width(), height = this.height(), size = Math.round(Math.sqrt(Math.pow(width, 2)+Math.pow(height, 2))); - + data.parent = parent; data.fparent = (data.opts.turn) ? data.opts.turn.data().fparent : $('#turn-fwrappers'); @@ -1384,7 +1363,7 @@ flipMethods = { if (data.opts.turn) { fparent.css(divAtt(-data.opts.turn.offset().top, -data.opts.turn.offset().left, 'auto', 'visible').css). appendTo(data.opts.turn); - + data.opts.turn.data().fparent = fparent; } else { fparent.css(divAtt(0, 0, 'auto', 'visible').css). @@ -1466,7 +1445,7 @@ flipMethods = { tr = point2D(distance * Math.sin(alpha), distance * Math.cos(alpha)); if (alpha > A90) { - + tr.x = tr.x + Math.abs(tr.y * Math.tan(tan)); tr.y = 0; @@ -1478,7 +1457,7 @@ flipMethods = { } } - + if (alpha>A90) { var beta = PI-alpha, dd = h - height/Math.sin(beta); mv = point2D(Math.round(dd*Math.cos(beta)), Math.round(dd*Math.sin(beta))); @@ -1487,13 +1466,13 @@ flipMethods = { } px = Math.round(tr.y/Math.tan(alpha) + tr.x); - + var side = width - px, sideX = side*Math.cos(alpha*2), sideY = side*Math.sin(alpha*2); df = point2D(Math.round( (left ? side -sideX : px+sideX)), Math.round((top) ? sideY : height - sideY)); - - + + // GRADIENTS gradientSize = side*Math.sin(alpha); @@ -1507,7 +1486,7 @@ flipMethods = { gradientStartV = gradientSize>100 ? (gradientSize-100)/gradientSize : 0; gradientEndPointA = point2D(gradientSize*Math.sin(A90-alpha)/height*100, gradientSize*Math.cos(A90-alpha)/width*100); - + if (top) gradientEndPointA.y = 100-gradientEndPointA.y; if (left) gradientEndPointA.x = 100-gradientEndPointA.x; } @@ -1527,7 +1506,7 @@ flipMethods = { }, transform = function(tr, c, x, a) { - + var f = ['0', 'auto'], mvW = (width-h)*x[0]/100, mvH = (height-h)*x[1]/100, v = {left: f[c[0]], top: f[c[1]], right: f[c[2]], bottom: f[c[3]]}, aliasingFk = (a!=90 && a!=-90) ? (left ? -1 : 1) : 0; @@ -1551,7 +1530,7 @@ flipMethods = { [1, 'rgba(255,255,255,'+(0.2*gradientOpacity)+')']], 3, alpha); - + if (flipMethods._backGradient.call(that)) gradient(data.bshadow, point2D(left?0:100, top?0:100), @@ -1560,7 +1539,7 @@ flipMethods = { [1, 'rgba(0,0,0,'+(0.3*gradientOpacity)+')'], [1, 'rgba(0,0,0,0)']], 3); - + }; switch (point.corner) { @@ -1596,7 +1575,7 @@ flipMethods = { } data.point = point; - + }, _moveFoldingPage: function(bool) { @@ -1639,7 +1618,7 @@ flipMethods = { if (animate) { var that = this, point = (data.point && data.point.corner==c.corner) ? data.point : flipMethods._c.call(this, c.corner, 1); - + this.animatef({from: [point.x, point.y], to:[c.x, c.y], duration: 500, frame: function(v) { c.x = Math.round(v[0]); c.y = Math.round(v[1]); @@ -1711,7 +1690,7 @@ flipMethods = { delta = (top) ? Math.min(0, p1.y-p4.y)/2 : Math.max(0, p1.y-p4.y)/2, p2 = point2D(p1.x, p1.y+delta), p3 = point2D(p4.x, p4.y-delta); - + this.animatef({ from: 0, to: 1, @@ -1752,7 +1731,7 @@ flipMethods = { corner.y = np.y; flipMethods._showFoldedPage.call(that, corner); }, - + complete: function() { that.trigger('end', [true]); }, @@ -1766,13 +1745,13 @@ flipMethods = { moving: function() { return 'effect' in this.data(); - + }, isTurning: function() { return this.flip('moving') && this.data().effect.turning; - + }, _eventStart: function(e) { @@ -1797,7 +1776,7 @@ flipMethods = { if (!data.disabled) { e = (isTouch) ? e.originalEvent.touches : [e]; - + if (data.corner) { var pos = data.parent.offset(); @@ -1806,9 +1785,9 @@ flipMethods = { data.corner.y = e[0].pageY-pos.top; flipMethods._showFoldedPage.call(this, data.corner); - + } else if (!this.data().effect && this.is(':visible')) { // roll over - + var corner = flipMethods._cornerActivated.call(this, e[0]); if (corner) { var origin = flipMethods._c.call(this, corner.corner, data.opts.cornerSize/2); @@ -1868,12 +1847,12 @@ $.extend($.fn, { transform: function(transform, origin) { var properties = {}; - + if (origin) properties[vendor+'transform-origin'] = origin; - + properties[vendor+'transform'] = transform; - + return this.css(properties); }, @@ -1899,7 +1878,7 @@ $.extend($.fn, { f = function() { var j, v = []; time = Math.min(point.duration, time + fps); - + for (j = 0; j < len; j++) v.push(point.easing(1, time, point.from[j], diff[j], point.duration)); @@ -1929,5 +1908,3 @@ $.extend($.fn, { $.isTouch = isTouch; - -})(jQuery); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..a43d23e --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "name": "turn.js", + "version": "1.0.5", + "description": "Web page flipper", + "main": "index.js", + "repository": "https://github.com/igghera/turn.js.git", + "author": "Andrea Gherardi ", + "license": "MIT", + "dependencies": { + "jquery": "1.12.0" + } +} diff --git a/readme.md b/readme.md index 2ce1883..71075c5 100755 --- a/readme.md +++ b/readme.md @@ -1,123 +1,54 @@ +A fork of [https://github.com/blasten/turn.js](https://github.com/blasten/turn.js) +with support for npm/yarn. -![Bilby Stampede](http://turnjs.com/pics/small-turnjs-letters.png) +## Usage -**Get the turn.js 4th release on [turnjs.com](http://www.turnjs.com/)** +### JS +``` +import $ from 'jquery'; +import 'turn.js'; + +$('#magazine').turn({ + width: 800, + height: 600, + autoCenter: true + // ... plus any extra option you need +}); +``` -### What's new in turn.js 4th release? - -- Added option `autoCenter` - -- Added option `zoom` - -- Added property `animating` - -- Added property `zoom` - -- Added method `center` - -- Added method `destroy` - -- Added method `is` - -- Added method `zoom` - -- Added event `missing` - -- Added event `zooming` - -- Added class `.even` - -- Added class `.fixed` - -- Added class `.hard` - -- Added class `.odd` - -- Added class `.own-size` - -- Added class `.sheet` - -- Added the ignore attribute - -- New turn.html4.js - -- New scissors.js - -- Changed the class `.turn-page` to `.page` - -- Improved the animation frame generator with requestAnimationFrame - -- Improved the animation speed for hard pages with CSS3 transitions - -- Redesigned the event sequence to listen to only three events - -- Fixed issue #79 - -- Fixed issue #91 - -- Fixed issue about the event order turning + turned - -- Fixed issue about appending pages in wrong locations - -Available only on [turnjs.com](http://www.turnjs.com/) - -* * * - -turn.js 3rd release -========= - -### Make a flip book with HTML5 - -Turn.js is a plugin for jQuery that adds a beautiful transition similar to real pages in a book or magazine. It works in all modern browsers including touch devices. - -### What's new? - -- New `addPage` for creating pages dynamically. - -- New `display` for single and double pages. - -- Gradients for non-webkit browsers. - -#### Usage +### HTML -**CSS code:** -```css -#magazine{ - width: 800px; - height: 400px; -} -#magazine .turn-page{ - background-color:#ccc; -} ``` - -**HTML code:** -```html
-
Page 1
-
Page 2
-
Page 3
+
Page 1
+
Page 2
+
Page 3
``` -**JavaScript code:** -```javascript -$('#magazine').turn({gradients: true, acceleration: true}); -``` - -#### Requirements +### CSS -jQuery 1.7 or later +``` +#magazine{ + width: 800px; + height: 400px; +} -#### Browser support -* Chrome 12, Safari 5, Firefox 10, IE 9 +#magazine .turn-page{ + background-color:#ccc; +} +``` -#### License -Released under a non-commercial BSD license +For the full documentation on the library and all available options, please +refer to [https://github.com/blasten/turn.js](https://github.com/blasten/turn.js). -[Full documentation](https://github.com/blasten/turn.js/wiki/Reference) +Basically I just added a package.json file, specified a main entry point + a +dependency (jquery) and fixed a couple of things to make turn.js installable via npm/yarn +and loadable via Webpack in my React project. -* * * +I have submitted a PR to the authors of the original libray, but in the meantime +you can use this one, as they don't seem to update their repo regularly. -[turnjs.com](http://www.turnjs.com/) +Latest version uses jQuery 1.12.0 because jQuery 3.x was breaking the page +flipper. diff --git a/turn.min.js b/turn.min.js deleted file mode 100644 index eab9eee..0000000 --- a/turn.min.js +++ /dev/null @@ -1,47 +0,0 @@ -/* turn.js r3 | turnjs.com/license.txt */ -(function(h){var x,y="",G=Math.PI,E=G/2,q="Touch"in window,I=q?{start:"touchstart",move:"touchmove",end:"touchend"}:{start:"mousedown",move:"mousemove",end:"mouseup"},J={backward:["bl","tl"],forward:["br","tr"],all:["tl","bl","tr","br"]},O=["single","double"],P={page:1,gradients:!0,duration:600,acceleration:!0,display:"double",when:null},Q={folding:null,corners:"forward",cornerSize:100,gradients:!0,duration:600,acceleration:!0},K={"0":{top:0,left:0,right:"auto",bottom:"auto"},1:{top:0,right:0,left:"auto", -bottom:"auto"}},l=function(a,b,c,d){return{css:{position:"absolute",top:a,left:b,overflow:d||"hidden","z-index":c||"auto"}}},L=function(a,b,c,d,e){var f=1-e,C=f*f*f,i=e*e*e;return j(Math.round(C*a.x+3*e*f*f*b.x+3*e*e*f*c.x+i*d.x),Math.round(C*a.y+3*e*f*f*b.y+3*e*e*f*c.y+i*d.y))},j=function(a,b){return{x:a,y:b}},s=function(a,b,c){return x&&c?" translate3d("+a+"px,"+b+"px, 0px) ":" translate("+a+"px, "+b+"px) "},t=function(a){return" rotate("+a+"deg) "},p=function(a,b){return Object.prototype.hasOwnProperty.call(b, -a)},R=function(){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},M=function(a,b,c,d,e){var f,C=[];if("-webkit-"==y){for(f=0;fe)throw Error('It is impossible to add the page "'+ -b+'", the maximum value is: "'+e+'"');}else b=e,c=!0;1<=b&&b<=e&&(d.done&&this.turn("stop"),b in d.pageObjs&&g._movePages.call(this,b,1),c&&(d.totalPages=e),d.pageObjs[b]=h(a).addClass("turn-page p"+b),g._addPage.call(this,b),d.done&&this.turn("update"),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]){var d="double"==b.display?this.width()/2:this.width(),e=this.height();c.css({width:d,height:e}); -b.pagePlace[a]=a;b.pageWrap[a]=h("
",{"class":"turn-page-wrapper",page:a,css:{position:"absolute",overflow:"hidden",width:d,height:e}}).css(K["double"==b.display?a%2:0]);this.append(b.pageWrap[a]);b.pageWrap[a].prepend(b.pageObjs[a])}(!a||1==g._setPageLoc.call(this,a))&&g._makeFlip.call(this,a)}else b.pagePlace[a]=0,b.pageObjs[a]&&b.pageObjs[a].remove()},hasPage:function(a){return a in this.data().pageObjs},_makeFlip:function(a){var b=this.data();if(!b.pages[a]&&b.pagePlace[a]==a){var c="single"== -b.display,d=a%2;b.pages[a]=b.pageObjs[a].css({width:c?this.width():this.width()/2,height:this.height()}).flip({page:a,next:c&&a===b.totalPages?a-1:d||c?a+1:a-1,turn:this,duration:b.opts.duration,acceleration:b.opts.acceleration,corners:c?"all":d?"forward":"backward",backGradient:b.opts.gradients,frontGradient:b.opts.gradients}).flip("disable",b.disabled).bind("pressed",g._pressed).bind("released",g._released).bind("start",g._start).bind("end",g._end).bind("flip",g._flip)}return b.pages[a]},_makeRange:function(){var a; -this.data();var b=this.turn("range");for(a=b[0];a<=b[1];a++)g._addPage.call(this,a)},range:function(a){var b,c,d=this.data(),a=a||d.tpage||d.page,e=g._view.call(this,a);if(1>a||a>d.totalPages)throw Error('"'+a+'" is not a page for range');e[1]=e[1]||e[0];1<=e[0]&&e[1]<=d.totalPages?(a=Math.floor(2),d.totalPages-e[1]>e[0]?(b=Math.min(e[0]-1,a),c=2*a-b):(c=Math.min(d.totalPages-e[1],a),b=2*a-c)):c=b=5;return[Math.max(1,e[0]-b),Math.min(d.totalPages,e[1]+c)]},_necessPage:function(a){if(0===a)return!0; -var b=this.turn("range");return a>=b[0]&&a<=b[1]},_removeFromDOM:function(){var a,b=this.data();for(a in b.pageWrap)p(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();c.f&&c.f.fwrapper&&c.f.fwrapper.remove();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]);delete b.pagePlace[a]},removePage:function(a){var b= -this.data();b.pageObjs[a]&&(this.turn("stop"),g._removePageFromDOM.call(this,a),delete b.pageObjs[a],g._movePages.call(this,a,-1),b.totalPages-=1,g._makeRange.call(this),b.page>b.totalPages&&this.turn("page",b.totalPages));return this},_movePages:function(a,b){var c,d=this.data(),e="single"==d.display,f=function(a){var c=a+b,f=c%2;d.pageObjs[a]&&(d.pageObjs[c]=d.pageObjs[a].removeClass("page"+a).addClass("page"+c));d.pagePlace[a]&&d.pageWrap[a]&&(d.pagePlace[c]=c,d.pageWrap[c]=d.pageWrap[a].css(K[e? -0:f]).attr("page",c),d.pages[a]&&(d.pages[c]=d.pages[a].flip("options",{page:c,next:e||f?c+1:c-1,corners:e?"all":f?"forward":"backward"})),b&&(delete d.pages[a],delete d.pagePlace[a],delete d.pageObjs[a],delete d.pageWrap[a],delete d.pageObjs[a]))};if(0=a;c--)f(c);else for(c=a;c<=d.totalPages;c++)f(c)},display:function(a){var b=this.data(),c=b.display;if(a){if(-1==h.inArray(a,O))throw Error('"'+a+'" is not a value for display');"single"==a?b.pageObjs[0]||(this.turn("stop").css({overflow:"hidden"}), -b.pageObjs[0]=h("
",{"class":"turn-page p-temporal"}).css({width:this.width(),height:this.height()}).appendTo(this)):b.pageObjs[0]&&(this.turn("stop").css({overflow:""}),b.pageObjs[0].remove(),delete b.pageObjs[0]);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}return c},animating:function(){return 0a&&this.turn("page",a)}b.totalPages=a;return this}return b.totalPages},_fitPage:function(a,b){var c=this.data(),d=this.turn("view",a);c.page!=a&&(this.trigger("turning",[a,d]),-1!=h.inArray(1,d)&&this.trigger("first"),-1!=h.inArray(c.totalPages,d)&&this.trigger("last"));c.pageObjs[a]&&(c.tpage=a,this.turn("stop",b),g._removeFromDOM.call(this),g._makeRange.call(this),this.trigger("turned", -[a,d]))},_turnPage:function(a){var b,c,d=this.data(),e=this.turn("view"),f=this.turn("view",a);d.page!=a&&(this.trigger("turning",[a,f]),-1!=h.inArray(1,f)&&this.trigger("first"),-1!=h.inArray(d.totalPages,f)&&this.trigger("last"));if(d.pageObjs[a]&&(d.tpage=a,this.turn("stop"),g._makeRange.call(this),"single"==d.display?(b=e[0],c=f[0]):e[1]&&a>e[1]?(b=e[1],c=f[0]):e[0]&&ae[0]?"br":"bl"):d.pages[b].flip("turnPage")},page:function(a){var a=parseInt(a,10),b=this.data();return 0b.page?b.next:b.page+1),g._addMotionPage.call(this))},_end:function(a, -b){var c=h(this).data().f.opts,d=c.turn,e=d.data();a.stopPropagation();if(b||e.tpage){if(e.tpage==c.next||e.tpage==c.page)delete e.tpage,g._fitPage.call(d,e.tpage||c.next,!0)}else g._removeMv.call(d,c.pageMv),d.turn("update")},_pressed:function(){var a,b=h(this).data().f,c=b.opts.turn.data().pages;for(a in c)a!=b.opts.page&&c[a].flip("disable",!0);return b.time=(new Date).getTime()},_released:function(a,b){var c=h(this),d=c.data().f;a.stopPropagation();if(200>(new Date).getTime()-d.time||0>b.x||b.x> -h(this).width())a.preventDefault(),d.opts.turn.data().tpage=d.opts.next,d.opts.turn.turn("update"),h(c).flip("turnPage")},_flip:function(){var a=h(this).data().f.opts;a.turn.trigger("turn",[a.next])},calculateZ:function(a){var b,c,d,e,f=this,i=this.data();b=this.turn("view");var h=b[0]||b[1],g={pageZ:{},partZ:{},pageV:{}},j=function(a){a=f.turn("view",a);a[0]&&(g.pageV[a[0]]=!0);a[1]&&(g.pageV[a[1]]=!0)};for(b=0;b=a.x||0>=a.y||a.x>=d||a.y>=e)return!1;if(a.y=e-b)a.corner="b";else return!1;if(a.x<=b)a.corner+="l";else if(a.x>=d-b)a.corner+="r";else return!1;return-1==h.inArray(a.corner,c)?!1:a},_c:function(a, -b){b=b||0;return{tl:j(b,b),tr:j(this.width()-b,b),bl:j(b,this.height()-b),br:j(this.width()-b,this.height()-b)}[a]},_c2:function(a){return{tl:j(2*this.width(),0),tr:j(-this.width(),0),bl:j(2*this.width(),this.height()),br:j(-this.width(),this.height())}[a]},_foldingPage:function(){var a=this.data().f.opts;if(a.folding)return a.folding;if(a.turn){var b=a.turn.data();return"single"==b.display?b.pageObjs[a.next]?b.pageObjs[0]:null:b.pageObjs[a.next]}},_backGradient:function(){var a=this.data().f,b=a.opts.turn; -if((b=a.opts.backGradient&&(!b||"single"==b.data().display||2!=a.opts.page&&a.opts.page!=b.data().totalPages-1))&&!a.bshadow)a.bshadow=h("
",l(0,0,1)).css({position:"",width:this.width(),height:this.height()}).appendTo(a.parent);return b},resize:function(a){var b=this.data().f,c=this.width(),d=this.height(),e=Math.round(Math.sqrt(Math.pow(c,2)+Math.pow(d,2)));a&&(b.wrapper.css({width:e,height:e}),b.fwrapper.css({width:e,height:e}).children(":first-child").css({width:c,height:d}),b.fpage.css({width:d, -height:c}),b.opts.frontGradient&&b.ashadow.css({width:d,height:c}),i._backGradient.call(this)&&b.bshadow.css({width:c,height:d}));b.parent.is(":visible")&&(b.fwrapper.css({top:b.parent.offset().top,left:b.parent.offset().left}),b.opts.turn&&b.fparent.css({top:-b.opts.turn.offset().top,left:-b.opts.turn.offset().left}));this.flip("z",b.opts["z-index"])},_addPageWrapper:function(){var a=this.data().f,b=this.parent();if(!a.wrapper){this.css("left");this.css("top");var c=this.width(),d=this.height(); -Math.round(Math.sqrt(Math.pow(c,2)+Math.pow(d,2)));a.parent=b;a.fparent=a.opts.turn?a.opts.turn.data().fparent:h("#turn-fwrappers");a.fparent||(c=h("
",{css:{"pointer-events":"none"}}).hide(),c.data().flips=0,a.opts.turn?(c.css(l(-a.opts.turn.offset().top,-a.opts.turn.offset().left,"auto","visible").css).appendTo(a.opts.turn),a.opts.turn.data().fparent=c):c.css(l(0,0,"auto","visible").css).attr("id","turn-fwrappers").appendTo(h("body")),a.fparent=c);this.css({position:"absolute",top:0,left:0, -bottom:"auto",right:"auto"});a.wrapper=h("
",l(0,0,this.css("z-index"))).appendTo(b).prepend(this);a.fwrapper=h("
",l(b.offset().top,b.offset().left)).hide().appendTo(a.fparent);a.fpage=h("
",{css:{cursor:"default"}}).appendTo(h("
",l(0,0,0,"visible")).appendTo(a.fwrapper));a.opts.frontGradient&&(a.ashadow=h("
",l(0,0,1)).appendTo(a.fpage));i.setData.call(this,a);i.resize.call(this,!0)}},_fold:function(a){var b=this,c=0,d=0,e,f,h,g,v,H,n=j(0,0),p=j(0,0),k=j(0,0),r=this.width(), -u=this.height(),l=i._foldingPage.call(this);Math.tan(d);var o=this.data().f,w=o.opts.acceleration,y=o.wrapper.height(),q=i._c.call(this,a.corner),D="t"==a.corner.substr(0,1),A="l"==a.corner.substr(1,1),F=function(){var m=j(q.x?q.x-a.x:a.x,q.y?q.y-a.y:a.y),B=Math.atan2(m.y,m.x),z;d=E-B;c=180*(d/G);z=j(A?r-m.x/2:a.x+m.x/2,m.y/2);var l=d-Math.atan2(z.y,z.x),l=Math.max(0,Math.sin(l)*Math.sqrt(Math.pow(z.x,2)+Math.pow(z.y,2)));k=j(l*Math.sin(d),l*Math.cos(d));if(d>E&&(k.x+=Math.abs(k.y*Math.tan(B)),k.y= -0,Math.round(k.x*Math.tan(G-d))E&&(m=G-d,B=y-u/Math.sin(m),n=j(Math.round(B*Math.cos(m)),Math.round(B*Math.sin(m))),A&&(n.x=-n.x),D))n.y=-n.y;e=Math.round(k.y/Math.tan(d)+k.x);m=r-e;B=m*Math.cos(2*d);z=m*Math.sin(2*d);p=j(Math.round(A?m-B:e+B),Math.round(D?z:u-z));v=m*Math.sin(d);m=i._c2.call(b,a.corner);m=Math.sqrt(Math.pow(m.x-a.x,2)+Math.pow(m.y-a.y,2));H=m