Remove IIFE wrapper + explicitly import jQuery

This commit is contained in:
Andrea Gherardi 2016-12-20 17:31:54 +01:00
parent 816a3d47bf
commit cb01c3de8e
3 changed files with 91 additions and 261 deletions

180
index.js
View File

@ -12,14 +12,12 @@
* 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
* 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';
import $ from 'jquery';
var has3d,
@ -54,7 +52,7 @@ var has3d,
// First page
page: 1,
// Enables gradients
gradients: true,
@ -79,7 +77,7 @@ var has3d,
flipOptions = {
// Back page
folding: null,
// Corners
@ -88,7 +86,7 @@ var has3d,
// all: Activates all the corners
corners: 'forward',
// Size of the active zone of each corner
cornerSize: 100,
@ -109,7 +107,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 +134,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 +188,21 @@ var has3d,
// Adds gradients
gradient = function(obj, p0, p1, colors, numColors) {
var j, cols = [];
if (vendor=='-webkit-') {
for (j = 0; j<numColors; j++)
cols.push('color-stop('+colors[j][0]+', '+colors[j][1]+')');
obj.css({'background-image': '-webkit-gradient(linear, '+p0.x+'% '+p0.y+'%, '+p1.x+'% '+p1.y+'%, '+ cols.join(',') +' )'});
} else {
// This procedure makes the gradients for non-webkit browsers
// It will be reduced to one unique way for gradients in next versions
p0 = {x:p0.x/100 * obj.width(), y:p0.y/100 * obj.height()};
p1 = {x:p1.x/100 * obj.width(), y:p1.y/100 * obj.height()};
@ -223,7 +221,7 @@ var has3d,
for (j = 0; j<numColors; j++)
cols.push(' '+colors[j][1]+' '+(( segA + gradientDiagonal*colors[j][0] )*100/diagonal)+'%');
obj.css({'background-image': vendor+'linear-gradient(' + (-angle) + 'rad,' + cols.join(',') + ')'});
}
},
@ -242,7 +240,7 @@ turnMethods = {
}
var i, data = this.data(), ch = this.children();
opts = $.extend({width: this.width(), height: this.height()}, turnOptions, opts);
data.opts = opts;
data.pageObjs = {};
@ -264,10 +262,10 @@ turnMethods = {
if (has3d && !isTouch && opts.acceleration)
this.transform(translate(0, 0, true));
for (i = 0; i<ch.length; i++)
this.turn('addPage', ch[i], i+1);
this.turn('page', opts.page);
// allow setting active corners as an option
@ -280,7 +278,7 @@ turnMethods = {
if (has(page, data.pages) && flipMethods._eventStart.call(data.pages[page], e)===false)
return false;
});
$(document).bind(events.move, function(e) {
for (var page in data.pages)
if (has(page, data.pages))
@ -350,13 +348,13 @@ turnMethods = {
// Adds a page from internal data
_addPage: function(page) {
var data = this.data(),
element = data.pageObjs[page];
if (element)
if (turnMethods._necessPage.call(this, page)) {
if (!data.pageWrap[page]) {
var pageWidth = (data.display=='double') ? this.width()/2 : this.width(),
@ -386,7 +384,7 @@ turnMethods = {
// If the page is in the current view, create the flip effect
if (!page || turnMethods._setPageLoc.call(this, page)==1)
turnMethods._makeFlip.call(this, page);
} else {
// Place
@ -401,11 +399,11 @@ turnMethods = {
},
// Checks if a page is in memory
hasPage: function(page) {
return page in this.data().pageObjs;
},
// Prepares the flip effect for a page
@ -418,7 +416,7 @@ turnMethods = {
var single = data.display=='single',
even = page%2;
data.pages[page] = data.pageObjs[page].
css({width: (single) ? this.width() : this.width()/2, height: this.height()}).
flip({page: page,
@ -471,9 +469,9 @@ turnMethods = {
if (page<1 || page>data.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 +496,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 +515,7 @@ turnMethods = {
for (page in data.pageWrap)
if (has(page, data.pageWrap) && !turnMethods._necessPage.call(this, page))
turnMethods._removePageFromDOM.call(this, page);
},
@ -574,7 +572,7 @@ turnMethods = {
}
return this;
},
// Moves pages
@ -595,7 +593,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 +629,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 +660,7 @@ turnMethods = {
} else
return currentDisplay;
},
// Detects if the pages are being animated
@ -703,7 +701,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 +715,7 @@ turnMethods = {
return this;
} else {
return {width: this.width(), height: this.height()};
}
@ -746,7 +744,7 @@ turnMethods = {
_removeMv: function(page) {
var i, data = this.data();
for (i=0; i<data.pageMv.length; i++)
if (data.pageMv[i]==page) {
data.pageMv.splice(i, 1);
@ -758,7 +756,7 @@ turnMethods = {
},
// Adds an animation to the cache
_addMv: function(page) {
var data = this.data();
@ -771,7 +769,7 @@ turnMethods = {
// Gets indexes for a view
_view: function(page) {
var data = this.data();
page = page || data.page;
@ -812,7 +810,7 @@ turnMethods = {
flipMethods._moveFoldingPage.call(data.pages[pages[i]], null);
data.pages[pages[i]].flip('hideFoldedPage');
data.pagePlace[opts.next] = opts.next;
if (opts.force) {
opts.next = (opts.page%2===0) ? opts.page-1 : opts.page+1;
delete opts['force'];
@ -852,9 +850,9 @@ turnMethods = {
// Sets a page without effect
_fitPage: function(page, ok) {
var data = this.data(), newView = this.turn('view', page);
if (data.page!=page) {
this.trigger('turning', [page, newView]);
if ($.inArray(1, newView)!=-1) this.trigger('first');
@ -872,7 +870,7 @@ turnMethods = {
this.trigger('turned', [page, newView]);
},
// Turns to a page
_turnPage: function(page) {
@ -881,7 +879,7 @@ turnMethods = {
data = this.data(),
view = this.turn('view'),
newView = this.turn('view', page);
if (data.page!=page) {
this.trigger('turning', [page, newView]);
if ($.inArray(1, newView)!=-1) this.trigger('first');
@ -912,7 +910,7 @@ turnMethods = {
var opts = data.pages[current].data().f.opts;
data.tpage = next;
if (opts.next!=next) {
opts.next = next;
data.pagePlace[next] = opts.page;
@ -940,12 +938,12 @@ turnMethods = {
turnMethods._fitPage.call(this, page);
else
turnMethods._turnPage.call(this, page);
return this;
} else
return data.page;
},
// Turns to the next view
@ -954,13 +952,13 @@ turnMethods = {
var data = this.data();
return this.turn('page', turnMethods._view.call(this, data.page).pop() + 1);
},
// Turns to the previous view
previous: function() {
var data = this.data();
return this.turn('page', turnMethods._view.call(this, data.page).shift() - 1);
@ -996,7 +994,7 @@ turnMethods = {
e.preventDefault();
return;
}
if (data.display=='single') {
var left = corner.charAt(1)=='l';
@ -1018,7 +1016,7 @@ turnMethods = {
// This event is called in context of flip
_end: function(e, turned) {
var that = $(this),
data = that.data().f,
opts = data.opts,
@ -1038,9 +1036,9 @@ turnMethods = {
turnMethods._removeMv.call(turn, opts.pageMv);
turn.turn('update');
}
},
// This event is called in context of flip
_pressed: function() {
@ -1050,7 +1048,7 @@ turnMethods = {
data = that.data().f,
turn = data.opts.turn,
pages = turn.data().pages;
for (page in pages)
if (page!=data.opts.page)
pages[page].flip('disable', true);
@ -1062,7 +1060,7 @@ turnMethods = {
// This event is called in context of flip
_released: function(e, point) {
var that = $(this),
data = that.data().f;
@ -1078,7 +1076,7 @@ turnMethods = {
},
// This event is called in context of flip
_flip: function() {
var opts = $(this).data().f.opts;
@ -1103,7 +1101,7 @@ turnMethods = {
if (view[0]) r.pageV[view[0]] = true;
if (view[1]) r.pageV[view[1]] = true;
};
for (i = 0; i<mv.length; i++) {
page = mv[i];
nextPage = data.pages[page].data().f.opts.next;
@ -1132,10 +1130,10 @@ turnMethods = {
var apage,
pos = this.turn('calculateZ', data.pageMv),
view = this.turn('view', data.tpage);
if (data.pagePlace[view[0]]==view[0]) apage = view[0];
else if (data.pagePlace[view[1]]==view[1]) apage = view[1];
for (page in data.pageWrap) {
if (!has(page, data.pageWrap)) continue;
@ -1152,7 +1150,7 @@ turnMethods = {
data.pages[page].flip('disable', true); // data.disabled || page!=apage
}
}
} else {
// Update static pages
@ -1209,7 +1207,7 @@ flipMethods = {
},
setData: function(d) {
var data = this.data();
data.f = $.extend(data.f, d);
@ -1218,7 +1216,7 @@ flipMethods = {
},
options: function(opts) {
var data = this.data().f;
if (opts) {
@ -1247,7 +1245,7 @@ flipMethods = {
_cornerActivated: function(e) {
if (e.originalEvent === undefined) {
return false;
}
}
e = (isTouch) ? e.originalEvent.touches : [e];
@ -1264,7 +1262,7 @@ flipMethods = {
if (c.y<csz) c.corner = 't';
else if (c.y>=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 +1293,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 +1323,7 @@ flipMethods = {
},
resize: function(full) {
var data = this.data().f,
width = this.width(),
height = this.height(),
@ -1373,7 +1371,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 +1382,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 +1464,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 +1476,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 +1485,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 +1505,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 +1525,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 +1549,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 +1558,7 @@ flipMethods = {
[1, 'rgba(0,0,0,'+(0.3*gradientOpacity)+')'],
[1, 'rgba(0,0,0,0)']],
3);
};
switch (point.corner) {
@ -1596,7 +1594,7 @@ flipMethods = {
}
data.point = point;
},
_moveFoldingPage: function(bool) {
@ -1639,7 +1637,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 +1709,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 +1750,7 @@ flipMethods = {
corner.y = np.y;
flipMethods._showFoldedPage.call(that, corner);
},
complete: function() {
that.trigger('end', [true]);
},
@ -1766,13 +1764,13 @@ flipMethods = {
moving: function() {
return 'effect' in this.data();
},
isTurning: function() {
return this.flip('moving') && this.data().effect.turning;
},
_eventStart: function(e) {
@ -1797,7 +1795,7 @@ flipMethods = {
if (!data.disabled) {
e = (isTouch) ? e.originalEvent.touches : [e];
if (data.corner) {
var pos = data.parent.offset();
@ -1806,9 +1804,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 +1866,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 +1897,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 +1927,3 @@ $.extend($.fn, {
$.isTouch = isTouch;
})(jQuery);

125
readme.md
View File

@ -1,123 +1,4 @@
![Bilby Stampede](http://turnjs.com/pics/small-turnjs-letters.png)
**Get the turn.js 4th release on [turnjs.com](http://www.turnjs.com/)**
### 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
**CSS code:**
```css
#magazine{
width: 800px;
height: 400px;
}
#magazine .turn-page{
background-color:#ccc;
}
```
**HTML code:**
```html
<div id="magazine">
<div><span class="text">Page 1</span></div>
<div><span class="text">Page 2</span></div>
<div><span class="text">Page 3</span></div>
</div>
```
**JavaScript code:**
```javascript
$('#magazine').turn({gradients: true, acceleration: true});
```
#### Requirements
jQuery 1.7 or later
#### Browser support
* Chrome 12, Safari 5, Firefox 10, IE 9
#### License
Released under a non-commercial BSD license
[Full documentation](https://github.com/blasten/turn.js/wiki/Reference)
* * *
[turnjs.com](http://www.turnjs.com/)
A fork of [https://github.com/blasten/turn.js](https://github.com/blasten/turn.js)
with support for npm/yarn. Basically I just added a package.json file and
specified a main entry point + a dependency (jquery)

47
turn.min.js vendored
View File

@ -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;f<e;f++)C.push("color-stop("+d[f][0]+", "+d[f][1]+")");a.css({"background-image":"-webkit-gradient(linear, "+b.x+"% "+b.y+"%, "+c.x+"% "+c.y+"%, "+C.join(",")+" )"})}else{var b={x:b.x/100*a.width(),y:b.y/100*a.height()},c={x:c.x/100*a.width(),y:c.y/100*a.height()},i=c.x-b.x;f=c.y-
b.y;var h=Math.atan2(f,i),g=h-Math.PI/2,g=Math.abs(a.width()*Math.sin(g))+Math.abs(a.height()*Math.cos(g)),i=Math.sqrt(f*f+i*i),c=j(c.x<b.x?a.width():0,c.y<b.y?a.height():0),n=Math.tan(h);f=-1/n;n=(f*c.x-c.y-n*b.x+b.y)/(f-n);c=f*n-f*c.x+c.y;b=Math.sqrt(Math.pow(n-b.x,2)+Math.pow(c-b.y,2));for(f=0;f<e;f++)C.push(" "+d[f][1]+" "+100*(b+i*d[f][0])/g+"%");a.css({"background-image":y+"linear-gradient("+-h+"rad,"+C.join(",")+")"})}},g={init:function(a){void 0===x&&(x="WebKitCSSMatrix"in window||"MozPerspective"in
document.body.style,y=R());var b,c=this.data(),d=this.children(),a=h.extend({width:this.width(),height:this.height()},P,a);c.opts=a;c.pageObjs={};c.pages={};c.pageWrap={};c.pagePlace={};c.pageMv=[];c.totalPages=a.pages||0;if(a.when)for(b in a.when)p(b,a.when)&&this.bind(b,a.when[b]);this.css({position:"relative",width:a.width,height:a.height});this.turn("display",a.display);x&&!q&&a.acceleration&&this.transform(s(0,0,!0));for(b=0;b<d.length;b++)this.turn("addPage",d[b],b+1);this.turn("page",a.page);
J=h.extend({},J,a.corners);h(this).bind(I.start,function(a){for(var b in c.pages)if(p(b,c.pages)&&i._eventStart.call(c.pages[b],a)===false)return false});h(document).bind(I.move,function(a){for(var b in c.pages)p(b,c.pages)&&i._eventMove.call(c.pages[b],a)}).bind(I.end,function(a){for(var b in c.pages)p(b,c.pages)&&i._eventEnd.call(c.pages[b],a)});c.done=!0;return this},addPage:function(a,b){var c=!1,d=this.data(),e=d.totalPages+1;if(b)if(b==e)b=e,c=!0;else{if(b>e)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("<div/>",{"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<b)for(c=d.totalPages;c>=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("<div />",{"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 0<this.data().pageMv.length},disable:function(a){var b,c=this.data(),d=this.turn("view");c.disabled=void 0===a||!0===
a;for(b in c.pages)p(b,c.pages)&&c.pages[b].flip("disable",a?h.inArray(b,d):!1);return this},size:function(a,b){if(a&&b){var c=this.data(),d="double"==c.display?a/2:a,e;this.css({width:a,height:b});c.pageObjs[0]&&c.pageObjs[0].css({width:d,height:b});for(e in c.pageWrap)p(e,c.pageWrap)&&(c.pageObjs[e].css({width:d,height:b}),c.pageWrap[e].css({width:d,height:b}),c.pages[e]&&c.pages[e].css({width:d,height:b}));this.turn("resize");return this}return{width:this.width(),height:this.height()}},resize:function(){var a,
b=this.data();b.pages[0]&&(b.pageWrap[0].css({left:-this.width()}),b.pages[0].flip("resize",!0));for(a=1;a<=b.totalPages;a++)b.pages[a]&&b.pages[a].flip("resize",!0)},_removeMv:function(a){var b,c=this.data();for(b=0;b<c.pageMv.length;b++)if(c.pageMv[b]==a)return c.pageMv.splice(b,1),!0;return!1},_addMv:function(a){var b=this.data();g._removeMv.call(this,a);b.pageMv.push(a)},_view:function(a){var b=this.data(),a=a||b.page;return"double"==b.display?a%2?[a-1,a]:[a,a+1]:[a]},view:function(a){var b=this.data(),
a=g._view.call(this,a);return"double"==b.display?[0<a[0]?a[0]:0,a[1]<=b.totalPages?a[1]:0]:[0<a[0]&&a[0]<=b.totalPages?a[0]:0]},stop:function(){var a,b,c=this.data(),d=c.pageMv;c.pageMv=[];c.tpage&&(c.page=c.tpage,delete c.tpage);for(a in d)p(a,d)&&(b=c.pages[d[a]].data().f.opts,i._moveFoldingPage.call(c.pages[d[a]],null),c.pages[d[a]].flip("hideFoldedPage"),c.pagePlace[b.next]=b.next,b.force&&(b.next=0===b.page%2?b.page-1:b.page+1,delete b.force));this.turn("update");return this},pages:function(a){var b=
this.data();if(a){if(a<b.totalPages){for(var c=a+1;c<=b.totalPages;c++)this.turn("removePage",c);this.turn("page")>a&&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]&&a<e[0]&&(b=e[0],c=f[1]),d.pages[b]))a=d.pages[b].data().f.opts,d.tpage=c,a.next!=c&&(a.next=c,d.pagePlace[c]=a.page,a.force=!0),
"single"==d.display?d.pages[b].flip("turnPage",f[0]>e[0]?"br":"bl"):d.pages[b].flip("turnPage")},page:function(a){var a=parseInt(a,10),b=this.data();return 0<a&&a<=b.totalPages?(!b.done||-1!=h.inArray(a,this.turn("view"))?g._fitPage.call(this,a):g._turnPage.call(this,a),this):b.page},next:function(){var a=this.data();return this.turn("page",g._view.call(this,a.page).pop()+1)},previous:function(){var a=this.data();return this.turn("page",g._view.call(this,a.page).shift()-1)},_addMotionPage:function(){var a=
h(this).data().f.opts,b=a.turn,c=b.data();a.pageMv=a.page;g._addMv.call(b,a.pageMv);c.pagePlace[a.next]=a.page;b.turn("update")},_start:function(a,b,c){var d=b.turn.data(),e=h.Event("start");a.stopPropagation();b.turn.trigger(e,[b,c]);e.isDefaultPrevented()?a.preventDefault():("single"==d.display&&(c="l"==c.charAt(1),1==b.page&&c||b.page==d.totalPages&&!c?a.preventDefault():c?(b.next=b.next<b.page?b.next:b.page-1,b.force=!0):b.next=b.next>b.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.length;b++)c=a[b],d=i.pages[c].data().f.opts.next,e=i.pagePlace[c],j(c),j(d),c=i.pagePlace[d]==
d?d:c,g.pageZ[c]=i.totalPages-Math.abs(h-c),g.partZ[e]=2*i.totalPages+Math.abs(h-c);return g},update:function(){var a,b=this.data();if(b.pageMv.length&&0!==b.pageMv[0]){var c=this.turn("calculateZ",b.pageMv);this.turn("view",b.tpage);for(a in b.pageWrap)p(a,b.pageWrap)&&(b.pageWrap[a].css({display:c.pageV[a]?"":"none","z-index":c.pageZ[a]||0}),b.pages[a]&&(b.pages[a].flip("z",c.partZ[a]||null),c.pageV[a]&&b.pages[a].flip("resize"),b.tpage&&b.pages[a].flip("disable",!0)))}else for(a in b.pageWrap)p(a,
b.pageWrap)&&(c=g._setPageLoc.call(this,a),b.pages[a]&&b.pages[a].flip("disable",b.disabled||1!=c).flip("z",null))},_setPageLoc:function(a){var b=this.data(),c=this.turn("view");if(a==c[0]||a==c[1])return b.pageWrap[a].css({"z-index":b.totalPages,display:""}),1;if("single"==b.display&&a==c[0]+1||"double"==b.display&&a==c[0]-2||a==c[1]+2)return b.pageWrap[a].css({"z-index":b.totalPages-1,display:""}),2;b.pageWrap[a].css({"z-index":0,display:"none"});return 0}},i={init:function(a){a.gradients&&(a.frontGradient=
!0,a.backGradient=!0);this.data({f:{}});this.flip("options",a);i._addPageWrapper.call(this);return this},setData:function(a){var b=this.data();b.f=h.extend(b.f,a);return this},options:function(a){var b=this.data().f;return a?(i.setData.call(this,{opts:h.extend({},b.opts||Q,a)}),this):b.opts},z:function(a){var b=this.data().f;b.opts["z-index"]=a;b.fwrapper.css({"z-index":a||parseInt(b.parent.css("z-index"),10)||0});return this},_cAllowed:function(){return J[this.data().f.opts.corners]||this.data().f.opts.corners},
_cornerActivated:function(a){if(void 0===a.originalEvent)return!1;var a=q?a.originalEvent.touches:[a],b=this.data().f,c=b.parent.offset(),d=this.width(),e=this.height(),a={x:Math.max(0,a[0].pageX-c.left),y:Math.max(0,a[0].pageY-c.top)},b=b.opts.cornerSize,c=i._cAllowed.call(this);if(0>=a.x||0>=a.y||a.x>=d||a.y>=e)return!1;if(a.y<b)a.corner="t";else 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("<div/>",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("<div/>",{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("<div/>",l(0,0,this.css("z-index"))).appendTo(b).prepend(this);a.fwrapper=h("<div/>",l(b.offset().top,b.offset().left)).hide().appendTo(a.fparent);a.fpage=h("<div/>",{css:{cursor:"default"}}).appendTo(h("<div/>",l(0,0,0,"visible")).appendTo(a.fwrapper));a.opts.frontGradient&&(a.ashadow=h("<div/>",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))<u))return a.y=Math.sqrt(Math.pow(u,2)+2*z.x*m.x),D&&(a.y=u-a.y),F();if(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<r?m/r:1;if(o.opts.frontGradient&&(g=100<v?(v-100)/v:0,f=j(100*(v*
Math.sin(E-d)/u),100*(v*Math.cos(E-d)/r)),D&&(f.y=100-f.y),A))f.x=100-f.x;if(i._backGradient.call(b)&&(h=j(100*(v*Math.sin(d)/r),100*(v*Math.cos(d)/u)),A||(h.x=100-h.x),!D))h.y=100-h.y;k.x=Math.round(k.x);k.y=Math.round(k.y);return!0},x=function(a,c,e,k){var l=["0","auto"],v=(r-y)*e[0]/100,q=(u-y)*e[1]/100,c={left:l[c[0]],top:l[c[1]],right:l[c[2]],bottom:l[c[3]]},l=90!=k&&-90!=k?A?-1:1:0,e=e[0]+"% "+e[1]+"%";b.css(c).transform(t(k)+s(a.x+l,a.y,w),e);o.fpage.parent().css(c);o.wrapper.transform(s(-a.x+
v-l,-a.y+q,w)+t(-k),e);o.fwrapper.transform(s(-a.x+n.x+v,-a.y+n.y+q,w)+t(-k),e);o.fpage.parent().transform(t(k)+s(a.x+p.x-n.x,a.y+p.y-n.y,w),e);o.opts.frontGradient&&M(o.ashadow,j(A?100:0,D?100:0),j(f.x,f.y),[[g,"rgba(0,0,0,0)"],[0.8*(1-g)+g,"rgba(0,0,0,"+0.2*H+")"],[1,"rgba(255,255,255,"+0.2*H+")"]],3,d);i._backGradient.call(b)&&M(o.bshadow,j(A?0:100,D?0:100),j(h.x,h.y),[[0.8,"rgba(0,0,0,0)"],[1,"rgba(0,0,0,"+0.3*H+")"],[1,"rgba(0,0,0,0)"]],3)};switch(a.corner){case "tl":a.x=Math.max(a.x,1);F();
x(k,[1,0,0,1],[100,0],c);o.fpage.transform(s(-u,-r,w)+t(90-2*c),"100% 100%");l.transform(t(90)+s(0,-u,w),"0% 0%");break;case "tr":a.x=Math.min(a.x,r-1);F();x(j(-k.x,k.y),[0,0,0,1],[0,0],-c);o.fpage.transform(s(0,-r,w)+t(-90+2*c),"0% 100%");l.transform(t(270)+s(-r,0,w),"0% 0%");break;case "bl":a.x=Math.max(a.x,1);F();x(j(k.x,-k.y),[1,1,0,0],[100,100],-c);o.fpage.transform(s(-u,0,w)+t(-90+2*c),"100% 0%");l.transform(t(270)+s(-r,0,w),"0% 0%");break;case "br":a.x=Math.min(a.x,r-1),F(),x(j(-k.x,-k.y),
[0,1,1,0],[0,100],c),o.fpage.transform(t(90-2*c),"0% 0%"),l.transform(t(90)+s(0,-u,w),"0% 0%")}o.point=a},_moveFoldingPage:function(a){var b=this.data().f,c=i._foldingPage.call(this);if(c)if(a){if(!b.fpage.children()[b.ashadow?"1":"0"])i.setData.call(this,{backParent:c.parent()}),b.fpage.prepend(c)}else b.backParent&&b.backParent.prepend(c)},_showFoldedPage:function(a,b){var c=i._foldingPage.call(this),d=this.data(),e=d.f;if(!e.point||e.point.corner!=a.corner){var f=h.Event("start");this.trigger(f,
[e.opts,a.corner]);if(f.isDefaultPrevented())return!1}if(c){if(b){var g=this,c=e.point&&e.point.corner==a.corner?e.point:i._c.call(this,a.corner,1);this.animatef({from:[c.x,c.y],to:[a.x,a.y],duration:500,frame:function(b){a.x=Math.round(b[0]);a.y=Math.round(b[1]);i._fold.call(g,a)}})}else i._fold.call(this,a),d.effect&&!d.effect.turning&&this.animatef(!1);e.fwrapper.is(":visible")||(e.fparent.show().data().flips++,i._moveFoldingPage.call(this,!0),e.fwrapper.show(),e.bshadow&&e.bshadow.show());return!0}return!1},
hide:function(){var a=this.data().f,b=i._foldingPage.call(this);0===--a.fparent.data().flips&&a.fparent.hide();this.css({left:0,top:0,right:"auto",bottom:"auto"}).transform("","0% 100%");a.wrapper.transform("","0% 100%");a.fwrapper.hide();a.bshadow&&a.bshadow.hide();b.transform("","0% 0%");return this},hideFoldedPage:function(a){var b=this.data().f;if(b.point){var c=this,d=b.point,e=function(){b.point=null;c.flip("hide");c.trigger("end",[!1])};if(a){var f=i._c.call(this,d.corner),a="t"==d.corner.substr(0,
1)?Math.min(0,d.y-f.y)/2:Math.max(0,d.y-f.y)/2,h=j(d.x,d.y+a),g=j(f.x,f.y-a);this.animatef({from:0,to:1,frame:function(a){a=L(d,h,g,f,a);d.x=a.x;d.y=a.y;i._fold.call(c,d)},complete:e,duration:800,hiding:!0})}else this.animatef(!1),e()}},turnPage:function(a){var b=this,c=this.data().f,a={corner:c.corner?c.corner.corner:a||i._cAllowed.call(this)[0]},d=c.point||i._c.call(this,a.corner,c.opts.turn?c.opts.turn.data().opts.elevation:0),e=i._c2.call(this,a.corner);this.trigger("flip").animatef({from:0,to:1,
frame:function(c){c=L(d,d,e,e,c);a.x=c.x;a.y=c.y;i._showFoldedPage.call(b,a)},complete:function(){b.trigger("end",[!0])},duration:c.opts.duration,turning:!0});c.corner=null},moving:function(){return"effect"in this.data()},isTurning:function(){return this.flip("moving")&&this.data().effect.turning},_eventStart:function(a){var b=this.data().f;if(!b.disabled&&!this.flip("isTurning")){b.corner=i._cornerActivated.call(this,a);if(b.corner&&i._foldingPage.call(this,b.corner))return i._moveFoldingPage.call(this,
!0),this.trigger("pressed",[b.point]),!1;b.corner=null}},_eventMove:function(a){var b=this.data().f;if(!b.disabled)if(a=q?a.originalEvent.touches:[a],b.corner){var c=b.parent.offset();b.corner.x=a[0].pageX-c.left;b.corner.y=a[0].pageY-c.top;i._showFoldedPage.call(this,b.corner)}else!this.data().effect&&this.is(":visible")&&((a=i._cornerActivated.call(this,a[0]))?(b=i._c.call(this,a.corner,b.opts.cornerSize/2),a.x=b.x,a.y=b.y,i._showFoldedPage.call(this,a,!0)):i.hideFoldedPage.call(this,!0))},_eventEnd:function(){var a=
this.data().f;if(!a.disabled&&a.point){var b=h.Event("released");this.trigger(b,[a.point]);b.isDefaultPrevented()||i.hideFoldedPage.call(this,!0)}a.corner=null},disable:function(a){i.setData.call(this,{disabled:a});return this}},N=function(a,b,c){if(!c[0]||"object"==typeof c[0])return b.init.apply(a,c);if(b[c[0]]&&"_"!=c[0].toString().substr(0,1))return b[c[0]].apply(a,Array.prototype.slice.call(c,1));throw c[0]+" is an invalid value";};h.extend(h.fn,{flip:function(a,b){return N(this,i,arguments)},
turn:function(a){return N(this,g,arguments)},transform:function(a,b){var c={};b&&(c[y+"transform-origin"]=b);c[y+"transform"]=a;return this.css(c)},animatef:function(a){var b=this.data();b.effect&&clearInterval(b.effect.handle);if(a){a.to.length||(a.to=[a.to]);a.from.length||(a.from=[a.from]);a.easing||(a.easing=function(a,b,c,d,e){return d*Math.sqrt(1-(b=b/e-1)*b)+c});var c,d=[],e=a.to.length,f=this,h=a.fps||30,i=-h,g=function(){var c,g=[];i=Math.min(a.duration,i+h);for(c=0;c<e;c++)g.push(a.easing(1,
i,a.from[c],d[c],a.duration));a.frame(e==1?g[0]:g);if(i==a.duration){clearInterval(b.effect.handle);delete b.effect;f.data(b);a.complete&&a.complete()}};for(c=0;c<e;c++)d.push(a.to[c]-a.from[c]);b.effect=a;b.effect.handle=setInterval(g,h);this.data(b);g()}else delete b.effect}});h.isTouch=q})(jQuery);