diff --git a/changelog.txt b/changelog.txt index b9aebeb..7e44092 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,33 +1,139 @@ -TURN.JS +Turn.js +www.turnjs.com + +------------------------------------------------------ +Turn.js 4.1.0 - 2012/11/65 +------------------------------------------------------ + ++ Added support to the Android's default browser ++ Fixed the hard page effect in IE9 ++ Fixed issue #220 + +------------------------------------------------------ +Turn.js 4.0.9 - 2012/08/03 ------------------------------------------------------ -Github: https://github.com/blasten/turn.js -Reference: https://github.com/blasten/turn.js/wiki/Reference -Website: www.turnjs.com + ++ Fixed issue when using the .own-size class ++ Event zoom.change now is preventable + +------------------------------------------------------ +Turn.js 4.0.8 - 2012/07/16 +------------------------------------------------------ + ++ Added option direction ++ Added method direction ++ Added property direction + +------------------------------------------------------ +Turn.js 4.0.7 - 2012/07/12 +------------------------------------------------------ + ++ Fixed a issue of the pages method ++ Fixed issue #112 ++ corner argument of the start event now returns null when using the methods next, previous and page ++ Fixed issue of certain samples in IE8 + +------------------------------------------------------ +Turn.js 4.0.6 - 2012/07/10 +------------------------------------------------------ + ++ Fixed a issue of the peel method when using the single display ++ Fixed issue of using all the corners in single display mode ++ Added method version ++ Added option turnCorner + +------------------------------------------------------ +Turn.js 4.0.5 - 2012/06/16 +------------------------------------------------------ + ++ Fixed some visualization issues of the zoom viewport + +------------------------------------------------------ +Turn.js 4.0.4 - 2012/06/16 +------------------------------------------------------ + ++ Fixed a problem of the method page and event start + +------------------------------------------------------ +Turn.js 4.0.3 - 2012/06/16 +------------------------------------------------------ + ++ Fixed minor issues of HTML4 version + +------------------------------------------------------ +Turn.js 4.0.2 - 2012/06/16 +------------------------------------------------------ + ++ New Zoom viewport ++ New magazine sample + +------------------------------------------------------ +Turn.js 4.0.1 - 2012/06/12 +------------------------------------------------------ + ++ Fixed some issues when calculating z-index of pages ++ Added method peel + +------------------------------------------------------ +Release 4 Commercial - 2012/06/07 +------------------------------------------------------ + ++ 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 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 + ------------------------------------------------------ Release 3 - 2012/03/01 ------------------------------------------------------ -- Added 'range' -- Added 'addPage' -- Added 'removePage' -- Added 'hasPage' -- Added 'pages' -- Added 'display' -- Added 'when' to the initial configuration -- Added 'pages' to the initial configuration -- Added 'inclination' to the initial configuration -- Added 'first' event -- Added 'last' event -- Added gradients for non-webkit browsers ++ Added 'range' ++ Added 'addPage' ++ Added 'removePage' ++ Added 'hasPage' ++ Added 'pages' ++ Added 'display' ++ Added 'when' to the initial configuration ++ Added 'pages' to the initial configuration ++ Added 'inclination' to the initial configuration ++ Added 'first' event ++ Added 'last' event ++ Added gradients for non-webkit browsers ------------------------------------------------------ Release 2 - 2012/02/15 ------------------------------------------------------ -- Added 'size'. -- Bug in Chrome 17-18 Beta about losing background-image was fixed. ++ Added 'size'. ++ Bug in Chrome 17-18 Beta about losing background-image was fixed. ------------------------------------------------------ Release 1 - 2012/02/05 ------------------------------------------------------ -- First alpha release \ No newline at end of file ++ First alpha release + diff --git a/extras/jGestures-license.txt b/extras/jGestures-license.txt new file mode 100644 index 0000000..ade750b --- /dev/null +++ b/extras/jGestures-license.txt @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/extras/jgestures.min.js b/extras/jgestures.min.js new file mode 100644 index 0000000..43484f7 --- /dev/null +++ b/extras/jgestures.min.js @@ -0,0 +1,18 @@ +/** + * jGestures: a jQuery plugin for gesture events + * Copyright 2010-2011 Neue Digitale / Razorfish GmbH + * Copyright 2011-2012, Razorfish GmbH + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * @copyright Razorfish GmbH + * @author martin.krause@razorfish.de + * @version 0.90-shake + * @requires jQuery JavaScript Library v1.4.2 - http://jquery.com/- Copyright 2010, John Resig- Dual licensed under the MIT or GPL Version 2 licenses. http://jquery.org/license + */ +(function(c){c.jGestures={};c.jGestures.defaults={};c.jGestures.defaults.thresholdShake={requiredShakes:10,freezeShakes:100,frontback:{sensitivity:10},leftright:{sensitivity:10},updown:{sensitivity:10}};c.jGestures.defaults.thresholdPinchopen=0.05;c.jGestures.defaults.thresholdPinchmove=0.05;c.jGestures.defaults.thresholdPinch=0.05;c.jGestures.defaults.thresholdPinchclose=0.05;c.jGestures.defaults.thresholdRotatecw=5;c.jGestures.defaults.thresholdRotateccw=5;c.jGestures.defaults.thresholdMove=20;c.jGestures.defaults.thresholdSwipe=100;c.jGestures.data={};c.jGestures.data.capableDevicesInUserAgentString=["iPad","iPhone","iPod","Mobile Safari"];c.jGestures.data.hasGestures=(function(){var k;for(k=0;k0)?+1:((n[0].lastX<0)?-1:0)),lastY:((n[0].lastY>0)?+1:((n[0].lastY<0)?-1:0)),startX:((n[0].startX>0)?+1:((n[0].startX<0)?-1:0)),startY:((n[0].startY>0)?+1:((n[0].startY<0)?-1:0))};n[0].moved=Math.sqrt(Math.pow(Math.abs(n[0].startX),2)+Math.pow(Math.abs(n[0].startY),2))}return{type:k.type||null,originalEvent:k.event||null,delta:n||null,direction:m||{orientation:window.orientation||null,vector:k.vector||null},duration:(k.duration)?k.duration:(k.startMove.timestamp)?l-k.timestamp:null,rotation:k.rotation||null,scale:k.scale||null,description:k.description||[k.type,":",k.touches,":",((n[0].lastX!=0)?((n[0].lastX>0)?"right":"left"):"steady"),":",((n[0].lastY!=0)?((n[0].lastY>0)?"down":"up"):"steady")].join("")}}function a(l){var k=["landscape:clockwise:","portrait:default:","landscape:counterclockwise:","portrait:upsidedown:"];c(window).triggerHandler("orientationchange",{direction:{orientation:window.orientation},description:["orientationchange:",k[((window.orientation/90)+1)],window.orientation].join("")})}function b(r){var k;var t=jQuery(window);var o=t.data("ojQueryGestures");var m=c.jGestures.defaults.thresholdShake;var n=o.oDeviceMotionLastDevicePosition||{accelerationIncludingGravity:{x:0,y:0,z:0},shake:{eventCount:0,intervalsPassed:0,intervalsFreeze:0},shakeleftright:{eventCount:0,intervalsPassed:0,intervalsFreeze:0},shakefrontback:{eventCount:0,intervalsPassed:0,intervalsFreeze:0},shakeupdown:{eventCount:0,intervalsPassed:0,intervalsFreeze:0}};var q={accelerationIncludingGravity:{x:r.accelerationIncludingGravity.x,y:r.accelerationIncludingGravity.y,z:r.accelerationIncludingGravity.z},shake:{eventCount:n.shake.eventCount,intervalsPassed:n.shake.intervalsPassed,intervalsFreeze:n.shake.intervalsFreeze},shakeleftright:{eventCount:n.shakeleftright.eventCount,intervalsPassed:n.shakeleftright.intervalsPassed,intervalsFreeze:n.shakeleftright.intervalsFreeze},shakefrontback:{eventCount:n.shakefrontback.eventCount,intervalsPassed:n.shakefrontback.intervalsPassed,intervalsFreeze:n.shakefrontback.intervalsFreeze},shakeupdown:{eventCount:n.shakeupdown.eventCount,intervalsPassed:n.shakeupdown.intervalsPassed,intervalsFreeze:n.shakeupdown.intervalsFreeze}};var p;var s;var l;for(k in o){switch(k){case"shake":case"shakeleftright":case"shakefrontback":case"shakeupdown":p=[];s=[];p.push(k);if(++q[k].intervalsFreeze>m.freezeShakes&&q[k].intervalsFreeze<(2*m.freezeShakes)){break}q[k].intervalsFreeze=0;q[k].intervalsPassed++;if((k==="shake"||k==="shakeleftright")&&(q.accelerationIncludingGravity.x>m.leftright.sensitivity||q.accelerationIncludingGravity.x<(-1*m.leftright.sensitivity))){p.push("leftright");p.push("x-axis")}if((k==="shake"||k==="shakefrontback")&&(q.accelerationIncludingGravity.y>m.frontback.sensitivity||q.accelerationIncludingGravity.y<(-1*m.frontback.sensitivity))){p.push("frontback");p.push("y-axis")}if((k==="shake"||k==="shakeupdown")&&(q.accelerationIncludingGravity.z+9.81>m.updown.sensitivity||q.accelerationIncludingGravity.z+9.81<(-1*m.updown.sensitivity))){p.push("updown");p.push("z-axis")}if(p.length>1){if(++q[k].eventCount==m.requiredShakes&&(q[k].intervalsPassed)m.freezeShakes){q[k].eventCount=0;q[k].intervalsPassed=0}}}break}l={};l.oDeviceMotionLastDevicePosition=q;t.data("ojQueryGestures",c.extend(true,o,l))}}function h(l){var k=jQuery(l.currentTarget);k.triggerHandler(c.jGestures.events.touchstart,l);if(c.hasGestures){l.currentTarget.addEventListener("touchmove",g,false);l.currentTarget.addEventListener("touchend",j,false)}else{k.bind("mousemove",g);k.bind("mouseup",j)}var n=k.data("ojQueryGestures");var m=(l.touches)?l.touches[0]:l;var o={};o.oLastSwipemove={screenX:m.screenX,screenY:m.screenY,timestamp:new Date().getTime()};o.oStartTouch={screenX:m.screenX,screenY:m.screenY,timestamp:new Date().getTime()};k.data("ojQueryGestures",c.extend(true,n,o))}function g(t){var v=jQuery(t.currentTarget);var s=v.data("ojQueryGestures");var q=!!t.touches;var l=(q)?t.changedTouches[0].screenX:t.screenX;var k=(q)?t.changedTouches[0].screenY:t.screenY;var r=s.oLastSwipemove;var o=l-r.screenX;var n=k-r.screenY;var u;if(!!s.oLastSwipemove){u=d({type:"swipemove",touches:(q)?t.touches.length:"1",screenY:k,screenX:l,deltaY:n,deltaX:o,startMove:r,event:t,timestamp:r.timestamp});v.triggerHandler(u.type,u)}var m={};var p=(t.touches)?t.touches[0]:t;m.oLastSwipemove={screenX:p.screenX,screenY:p.screenY,timestamp:new Date().getTime()};v.data("ojQueryGestures",c.extend(true,s,m))}function j(r){var v=jQuery(r.currentTarget);var x=!!r.changedTouches;var u=(x)?r.changedTouches.length:"1";var p=(x)?r.changedTouches[0].screenX:r.screenX;var o=(x)?r.changedTouches[0].screenY:r.screenY;v.triggerHandler(c.jGestures.events.touchendStart,r);if(c.hasGestures){r.currentTarget.removeEventListener("touchmove",g,false);r.currentTarget.removeEventListener("touchend",j,false)}else{v.unbind("mousemove",g);v.unbind("mouseup",j)}var m=v.data("ojQueryGestures");var y=(Math.abs(m.oStartTouch.screenX-p)>c.jGestures.defaults.thresholdMove||Math.abs(m.oStartTouch.screenY-o)>c.jGestures.defaults.thresholdMove)?true:false;var B=(Math.abs(m.oStartTouch.screenX-p)>c.jGestures.defaults.thresholdSwipe||Math.abs(m.oStartTouch.screenY-o)>c.jGestures.defaults.thresholdSwipe)?true:false;var A;var t;var n;var l;var k;var q;var w=["zero","one","two","three","four"];var s;for(A in m){t=m.oStartTouch;n={};p=(x)?r.changedTouches[0].screenX:r.screenX;o=(x)?r.changedTouches[0].screenY:r.screenY;l=p-t.screenX;k=o-t.screenY;q=d({type:"swipe",touches:u,screenY:o,screenX:p,deltaY:k,deltaX:l,startMove:t,event:r,timestamp:t.timestamp});s=false;switch(A){case"swipeone":if(x===false&&u==1&&y===false){break}if(x===false||(u==1&&y===true&&B===true)){s=true;q.type=["swipe",w[u]].join("");v.triggerHandler(q.type,q)}break;case"swipetwo":if((x&&u==2&&y===true&&B===true)){s=true;q.type=["swipe",w[u]].join("");v.triggerHandler(q.type,q)}break;case"swipethree":if((x&&u==3&&y===true&&B===true)){s=true;q.type=["swipe",w[u]].join("");v.triggerHandler(q.type,q)}break;case"swipefour":if((x&&u==4&&y===true&&B===true)){s=true;q.type=["swipe",w[u]].join("");v.triggerHandler(q.type,q)}break;case"swipeup":case"swiperightup":case"swiperight":case"swiperightdown":case"swipedown":case"swipeleftdown":case"swipeleft":case"swipeleftup":if(x&&y===true&&B===true){s=true;q.type=["swipe",((q.delta[0].lastX!=0)?((q.delta[0].lastX>0)?"right":"left"):""),((q.delta[0].lastY!=0)?((q.delta[0].lastY>0)?"down":"up"):"")].join("");v.triggerHandler(q.type,q)}break;case"tapone":case"taptwo":case"tapthree":case"tapfour":if((y!==true&&s!==true)&&(w[u]==A.slice(3))){q.description=["tap",w[u]].join("");q.type=["tap",w[u]].join("");v.triggerHandler(q.type,q)}break}var z={};v.data("ojQueryGestures",c.extend(true,m,z));v.data("ojQueryGestures",c.extend(true,m,z))}v.triggerHandler(c.jGestures.events.touchendProcessed,r)}function e(l){var k=jQuery(l.currentTarget);k.triggerHandler(c.jGestures.events.gesturestart,l);var m=k.data("ojQueryGestures");var n={};n.oStartTouch={timestamp:new Date().getTime()};k.data("ojQueryGestures",c.extend(true,m,n))}function f(l){var k=jQuery(l.currentTarget);var p,m,r,o;var q=k.data("ojQueryGestures");var n;for(n in q){switch(n){case"pinch":p=l.scale;if(((p<1)&&(p%1)<(1-c.jGestures.defaults.thresholdPinchclose))||((p>1)&&(p%1)>(c.jGestures.defaults.thresholdPinchopen))){m=(p<1)?-1:+1;o=d({type:"pinch",scale:p,touches:null,startMove:q.oStartTouch,event:l,timestamp:q.oStartTouch.timestamp,vector:m,description:["pinch:",m,":",((p<1)?"close":"open")].join("")});k.triggerHandler(o.type,o)}break;case"rotate":p=l.rotation;if(((p<1)&&(-1*(p)>c.jGestures.defaults.thresholdRotateccw))||((p>1)&&(p>c.jGestures.defaults.thresholdRotatecw))){m=(p<1)?-1:+1;o=d({type:"rotate",rotation:p,touches:null,startMove:q.oStartTouch,event:l,timestamp:q.oStartTouch.timestamp,vector:m,description:["rotate:",m,":",((p<1)?"counterclockwise":"clockwise")].join("")});k.triggerHandler(o.type,o)}break}}}function i(l){var k=jQuery(l.currentTarget);k.triggerHandler(c.jGestures.events.gestureendStart,l);var n;var o=k.data("ojQueryGestures");var m;for(m in o){switch(m){case"pinchclose":n=l.scale;if((n<1)&&(n%1)<(1-c.jGestures.defaults.thresholdPinchclose)){k.triggerHandler("pinchclose",d({type:"pinchclose",scale:n,vector:-1,touches:null,startMove:o.oStartTouch,event:l,timestamp:o.oStartTouch.timestamp,description:"pinch:-1:close"}))}break;case"pinchopen":n=l.scale;if((n>1)&&(n%1)>(c.jGestures.defaults.thresholdPinchopen)){k.triggerHandler("pinchopen",d({type:"pinchopen",scale:n,vector:+1,touches:null,startMove:o.oStartTouch,event:l,timestamp:o.oStartTouch.timestamp,description:"pinch:+1:open"}))}break;case"rotatecw":n=l.rotation;if((n>1)&&(n>c.jGestures.defaults.thresholdRotatecw)){k.triggerHandler("rotatecw",d({type:"rotatecw",rotation:n,vector:+1,touches:null,startMove:o.oStartTouch,event:l,timestamp:o.oStartTouch.timestamp,description:"rotate:+1:clockwise"}))}break;case"rotateccw":n=l.rotation;if((n<1)&&(-1*(n)>c.jGestures.defaults.thresholdRotateccw)){k.triggerHandler("rotateccw",d({type:"rotateccw",rotation:n,vector:-1,touches:null,startMove:o.oStartTouch,event:l,timestamp:o.oStartTouch.timestamp,description:"rotate:-1:counterclockwise"}))}break}}k.triggerHandler(c.jGestures.events.gestureendProcessed,l)}})(jQuery); \ No newline at end of file diff --git a/extras/jquery-ui-1.8.20.custom.min.js b/extras/jquery-ui-1.8.20.custom.min.js new file mode 100755 index 0000000..2c59389 --- /dev/null +++ b/extras/jquery-ui-1.8.20.custom.min.js @@ -0,0 +1,17 @@ +/*! jQuery UI - v1.8.20 - 2012-04-30 +* https://github.com/jquery/jquery-ui +* Includes: jquery.ui.core.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){function c(b,c){var e=b.nodeName.toLowerCase();if("area"===e){var f=b.parentNode,g=f.name,h;return!b.href||!g||f.nodeName.toLowerCase()!=="map"?!1:(h=a("img[usemap=#"+g+"]")[0],!!h&&d(h))}return(/input|select|textarea|button|object/.test(e)?!b.disabled:"a"==e?b.href||c:c)&&d(b)}function d(b){return!a(b).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}a.ui=a.ui||{};if(a.ui.version)return;a.extend(a.ui,{version:"1.8.20",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}}),a.fn.extend({propAttr:a.fn.prop||a.fn.attr,_focus:a.fn.focus,focus:function(b,c){return typeof b=="number"?this.each(function(){var d=this;setTimeout(function(){a(d).focus(),c&&c.call(d)},b)}):this._focus.apply(this,arguments)},scrollParent:function(){var b;return a.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?b=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(a.curCSS(this,"position",1))&&/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0):b=this.parents().filter(function(){return/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0),/fixed/.test(this.css("position"))||!b.length?a(document):b},zIndex:function(c){if(c!==b)return this.css("zIndex",c);if(this.length){var d=a(this[0]),e,f;while(d.length&&d[0]!==document){e=d.css("position");if(e==="absolute"||e==="relative"||e==="fixed"){f=parseInt(d.css("zIndex"),10);if(!isNaN(f)&&f!==0)return f}d=d.parent()}}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),a.each(["Width","Height"],function(c,d){function h(b,c,d,f){return a.each(e,function(){c-=parseFloat(a.curCSS(b,"padding"+this,!0))||0,d&&(c-=parseFloat(a.curCSS(b,"border"+this+"Width",!0))||0),f&&(c-=parseFloat(a.curCSS(b,"margin"+this,!0))||0)}),c}var e=d==="Width"?["Left","Right"]:["Top","Bottom"],f=d.toLowerCase(),g={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};a.fn["inner"+d]=function(c){return c===b?g["inner"+d].call(this):this.each(function(){a(this).css(f,h(this,c)+"px")})},a.fn["outer"+d]=function(b,c){return typeof b!="number"?g["outer"+d].call(this,b):this.each(function(){a(this).css(f,h(this,b,!0,c)+"px")})}}),a.extend(a.expr[":"],{data:function(b,c,d){return!!a.data(b,d[3])},focusable:function(b){return c(b,!isNaN(a.attr(b,"tabindex")))},tabbable:function(b){var d=a.attr(b,"tabindex"),e=isNaN(d);return(e||d>=0)&&c(b,!e)}}),a(function(){var b=document.body,c=b.appendChild(c=document.createElement("div"));c.offsetHeight,a.extend(c.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0}),a.support.minHeight=c.offsetHeight===100,a.support.selectstart="onselectstart"in c,b.removeChild(c).style.display="none"}),a.extend(a.ui,{plugin:{add:function(b,c,d){var e=a.ui[b].prototype;for(var f in d)e.plugins[f]=e.plugins[f]||[],e.plugins[f].push([c,d[f]])},call:function(a,b,c){var d=a.plugins[b];if(!d||!a.element[0].parentNode)return;for(var e=0;e0?!0:(b[d]=1,e=b[d]>0,b[d]=0,e)},isOverAxis:function(a,b,c){return a>b&&a=9||!!b.button?this._mouseStarted?(this._mouseDrag(b),b.preventDefault()):(this._mouseDistanceMet(b)&&this._mouseDelayMet(b)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,b)!==!1,this._mouseStarted?this._mouseDrag(b):this._mouseUp(b)),!this._mouseStarted):this._mouseUp(b)},_mouseUp:function(b){return a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,b.target==this._mouseDownEvent.target&&a.data(b.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(b)),!1},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(a){return this.mouseDelayMet},_mouseStart:function(a){},_mouseDrag:function(a){},_mouseStop:function(a){},_mouseCapture:function(a){return!0}})})(jQuery);;/*! jQuery UI - v1.8.20 - 2012-04-30 +* https://github.com/jquery/jquery-ui +* Includes: jquery.ui.slider.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){var c=5;a.widget("ui.slider",a.ui.mouse,{widgetEventPrefix:"slide",options:{animate:!1,distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null},_create:function(){var b=this,d=this.options,e=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),f="",g=d.values&&d.values.length||1,h=[];this._keySliding=!1,this._mouseSliding=!1,this._animateOff=!0,this._handleIndex=null,this._detectOrientation(),this._mouseInit(),this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget"+" ui-widget-content"+" ui-corner-all"+(d.disabled?" ui-slider-disabled ui-disabled":"")),this.range=a([]),d.range&&(d.range===!0&&(d.values||(d.values=[this._valueMin(),this._valueMin()]),d.values.length&&d.values.length!==2&&(d.values=[d.values[0],d.values[0]])),this.range=a("
").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(d.range==="min"||d.range==="max"?" ui-slider-range-"+d.range:"")));for(var i=e.length;ic&&(f=c,g=a(this),i=b)}),c.range===!0&&this.values(1)===c.min&&(i+=1,g=a(this.handles[i])),j=this._start(b,i),j===!1?!1:(this._mouseSliding=!0,h._handleIndex=i,g.addClass("ui-state-active").focus(),k=g.offset(),l=!a(b.target).parents().andSelf().is(".ui-slider-handle"),this._clickOffset=l?{left:0,top:0}:{left:b.pageX-k.left-g.width()/2,top:b.pageY-k.top-g.height()/2-(parseInt(g.css("borderTopWidth"),10)||0)-(parseInt(g.css("borderBottomWidth"),10)||0)+(parseInt(g.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(b,i,e),this._animateOff=!0,!0))},_mouseStart:function(a){return!0},_mouseDrag:function(a){var b={x:a.pageX,y:a.pageY},c=this._normValueFromMouse(b);return this._slide(a,this._handleIndex,c),!1},_mouseStop:function(a){return this.handles.removeClass("ui-state-active"),this._mouseSliding=!1,this._stop(a,this._handleIndex),this._change(a,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1,!1},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(a){var b,c,d,e,f;return this.orientation==="horizontal"?(b=this.elementSize.width,c=a.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(b=this.elementSize.height,c=a.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),d=c/b,d>1&&(d=1),d<0&&(d=0),this.orientation==="vertical"&&(d=1-d),e=this._valueMax()-this._valueMin(),f=this._valueMin()+d*e,this._trimAlignValue(f)},_start:function(a,b){var c={handle:this.handles[b],value:this.value()};return this.options.values&&this.options.values.length&&(c.value=this.values(b),c.values=this.values()),this._trigger("start",a,c)},_slide:function(a,b,c){var d,e,f;this.options.values&&this.options.values.length?(d=this.values(b?0:1),this.options.values.length===2&&this.options.range===!0&&(b===0&&c>d||b===1&&c1){this.options.values[b]=this._trimAlignValue(c),this._refreshValue(),this._change(null,b);return}if(!arguments.length)return this._values();if(!a.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(b):this.value();d=this.options.values,e=arguments[0];for(f=0;f=this._valueMax())return this._valueMax();var b=this.options.step>0?this.options.step:1,c=(a-this._valueMin())%b,d=a-c;return Math.abs(c)*2>=b&&(d+=c>0?b:-b),parseFloat(d.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var b=this.options.range,c=this.options,d=this,e=this._animateOff?!1:c.animate,f,g={},h,i,j,k;this.options.values&&this.options.values.length?this.handles.each(function(b,i){f=(d.values(b)-d._valueMin())/(d._valueMax()-d._valueMin())*100,g[d.orientation==="horizontal"?"left":"bottom"]=f+"%",a(this).stop(1,1)[e?"animate":"css"](g,c.animate),d.options.range===!0&&(d.orientation==="horizontal"?(b===0&&d.range.stop(1,1)[e?"animate":"css"]({left:f+"%"},c.animate),b===1&&d.range[e?"animate":"css"]({width:f-h+"%"},{queue:!1,duration:c.animate})):(b===0&&d.range.stop(1,1)[e?"animate":"css"]({bottom:f+"%"},c.animate),b===1&&d.range[e?"animate":"css"]({height:f-h+"%"},{queue:!1,duration:c.animate}))),h=f}):(i=this.value(),j=this._valueMin(),k=this._valueMax(),f=k!==j?(i-j)/(k-j)*100:0,g[d.orientation==="horizontal"?"left":"bottom"]=f+"%",this.handle.stop(1,1)[e?"animate":"css"](g,c.animate),b==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[e?"animate":"css"]({width:f+"%"},c.animate),b==="max"&&this.orientation==="horizontal"&&this.range[e?"animate":"css"]({width:100-f+"%"},{queue:!1,duration:c.animate}),b==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[e?"animate":"css"]({height:f+"%"},c.animate),b==="max"&&this.orientation==="vertical"&&this.range[e?"animate":"css"]({height:100-f+"%"},{queue:!1,duration:c.animate}))}}),a.extend(a.ui.slider,{version:"1.8.20"})})(jQuery);; \ No newline at end of file diff --git a/extras/jquery.min.1.7.js b/extras/jquery.min.1.7.js new file mode 100644 index 0000000..3ca5e0f --- /dev/null +++ b/extras/jquery.min.1.7.js @@ -0,0 +1,4 @@ +/*! jQuery v1.7 jquery.com | jquery.org/license */ +(function(a,b){function cA(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cx(a){if(!cm[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){cn||(cn=c.createElement("iframe"),cn.frameBorder=cn.width=cn.height=0),b.appendChild(cn);if(!co||!cn.createElement)co=(cn.contentWindow||cn.contentDocument).document,co.write((c.compatMode==="CSS1Compat"?"":"")+""),co.close();d=co.createElement(a),co.body.appendChild(d),e=f.css(d,"display"),b.removeChild(cn)}cm[a]=e}return cm[a]}function cw(a,b){var c={};f.each(cs.concat.apply([],cs.slice(0,b)),function(){c[this]=a});return c}function cv(){ct=b}function cu(){setTimeout(cv,0);return ct=f.now()}function cl(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ck(){try{return new a.XMLHttpRequest}catch(b){}}function ce(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){c!=="border"&&f.each(e,function(){c||(d-=parseFloat(f.css(a,"padding"+this))||0),c==="margin"?d+=parseFloat(f.css(a,c+this))||0:d-=parseFloat(f.css(a,"border"+this+"Width"))||0});return d+"px"}d=bB(a,b,b);if(d<0||d==null)d=a.style[b]||0;d=parseFloat(d)||0,c&&f.each(e,function(){d+=parseFloat(f.css(a,"padding"+this))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+this+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+this))||0)});return d+"px"}function br(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(bi,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function bq(a){var b=(a.nodeName||"").toLowerCase();b==="input"?bp(a):b!=="script"&&typeof a.getElementsByTagName!="undefined"&&f.grep(a.getElementsByTagName("input"),bp)}function bp(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bo(a){return typeof a.getElementsByTagName!="undefined"?a.getElementsByTagName("*"):typeof a.querySelectorAll!="undefined"?a.querySelectorAll("*"):[]}function bn(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bm(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c,d,e,g=f._data(a),h=f._data(b,g),i=g.events;if(i){delete h.handle,h.events={};for(c in i)for(d=0,e=i[c].length;d=0===c})}function V(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function N(){return!0}function M(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?parseFloat(d):j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=/-([a-z]|[0-9])/ig,x=/^-ms-/,y=function(a,b){return(b+"").toUpperCase()},z=d.userAgent,A,B,C,D=Object.prototype.toString,E=Object.prototype.hasOwnProperty,F=Array.prototype.push,G=Array.prototype.slice,H=String.prototype.trim,I=Array.prototype.indexOf,J={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7",length:0,size:function(){return this.length},toArray:function(){return G.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?F.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),B.add(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(G.apply(this,arguments),"slice",G.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:F,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;B.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!B){B=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",C,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",C),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&K()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNumeric:function(a){return a!=null&&m.test(a)&&!isNaN(a)},type:function(a){return a==null?String(a):J[D.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!E.call(a,"constructor")&&!E.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||E.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(x,"ms-").replace(w,y)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c
a",d=a.getElementsByTagName("*"),e=a.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=a.getElementsByTagName("input")[0],k={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getElementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,unknownElems:!!a.getElementsByTagName("nav").length,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:a.className!=="t",enctype:!!c.createElement("form").enctype,submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,k.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,k.optDisabled=!h.disabled;try{delete a.test}catch(v){k.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function(){k.noCloneEvent=!1}),a.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),k.radioValue=i.value==="t",i.setAttribute("checked","checked"),a.appendChild(i),l=c.createDocumentFragment(),l.appendChild(a.lastChild),k.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",m=c.getElementsByTagName("body")[0],o=c.createElement(m?"div":"body"),p={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},m&&f.extend(p,{position:"absolute",left:"-999px",top:"-999px"});for(t in p)o.style[t]=p[t];o.appendChild(a),n=m||b,n.insertBefore(o,n.firstChild),k.appendChecked=i.checked,k.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,k.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="
",k.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="
t
",q=a.getElementsByTagName("td"),u=q[0].offsetHeight===0,q[0].style.display="",q[1].style.display="none",k.reliableHiddenOffsets=u&&q[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",a.appendChild(j),k.reliableMarginRight=(parseInt((c.defaultView.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0);if(a.attachEvent)for(t in{submit:1,change:1,focusin:1})s="on"+t,u=s in a,u||(a.setAttribute(s,"return;"),u=typeof a[s]=="function"),k[t+"Bubbles"]=u;f(function(){var a,b,d,e,g,h,i=1,j="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",l="visibility:hidden;border:0;",n="style='"+j+"border:5px solid #000;padding:0;'",p="
"+""+"
";m=c.getElementsByTagName("body")[0];!m||(a=c.createElement("div"),a.style.cssText=l+"width:0;height:0;position:static;top:0;margin-top:"+i+"px",m.insertBefore(a,m.firstChild),o=c.createElement("div"),o.style.cssText=j+l,o.innerHTML=p,a.appendChild(o),b=o.firstChild,d=b.firstChild,g=b.nextSibling.firstChild.firstChild,h={doesNotAddBorder:d.offsetTop!==5,doesAddBorderForTableAndCells:g.offsetTop===5},d.style.position="fixed",d.style.top="20px",h.fixedPosition=d.offsetTop===20||d.offsetTop===15,d.style.position=d.style.top="",b.style.overflow="hidden",b.style.position="relative",h.subtractsBorderForOverflowNotVisible=d.offsetTop===-5,h.doesNotIncludeMarginInBodyOffset=m.offsetTop!==i,m.removeChild(a),o=a=null,f.extend(k,h))}),o.innerHTML="",n.removeChild(o),o=l=g=h=m=j=a=i=null;return k}(),f.boxModel=f.support.boxModel;var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[f.expando]:a[f.expando]&&f.expando,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[f.expando]=n=++f.uuid:n=f.expando),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[f.expando]:f.expando;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)?b=b:b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" "));for(e=0,g=b.length;e-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];if(!arguments.length){if(g){c=f.valHooks[g.nodeName.toLowerCase()]||f.valHooks[g.type];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}return b}e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!a||j===3||j===8||j===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);if(!("getAttribute"in a))return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return b}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g},removeAttr:function(a,b){var c,d,e,g,h=0;if(a.nodeType===1){d=(b||"").split(p),g=d.length;for(;h=0}})});var z=/\.(.*)$/,A=/^(?:textarea|input|select)$/i,B=/\./g,C=/ /g,D=/[^\w\s.|`]/g,E=/^([^\.]*)?(?:\.(.+))?$/,F=/\bhover(\.\S+)?/,G=/^key/,H=/^(?:mouse|contextmenu)|click/,I=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,J=function(a){var b=I.exec(a);b&& +(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},K=function(a,b){return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||a.id===b[2])&&(!b[3]||b[3].test(a.className))},L=function(a){return f.event.special.hover?a:a.replace(F,"mouseenter$1 mouseleave$1")};f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=L(c).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"",(g||!e)&&c.preventDefault();if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,n=null;for(m=e.parentNode;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;l=0:t===b&&(t=o[s]=r.quick?K(m,r.quick):f(m).is(s)),t&&q.push(r);q.length&&j.push({elem:m,matches:q})}d.length>e&&j.push({elem:this,matches:d.slice(e)});for(k=0;k0?this.bind(b,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),G.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),H.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(V(c[0])||V(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c),g=S.call(arguments);O.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!U[a]?f.unique(e):e,(this.length>1||Q.test(d))&&P.test(a)&&(e=e.reverse());return this.pushStack(e,a,g.join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var Y="abbr article aside audio canvas datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",Z=/ jQuery\d+="(?:\d+|null)"/g,$=/^\s+/,_=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,ba=/<([\w:]+)/,bb=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]},bk=X(c);bj.optgroup=bj.option,bj.tbody=bj.tfoot=bj.colgroup=bj.caption=bj.thead,bj.th=bj.td,f.support.htmlSerialize||(bj._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){f(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after" +,arguments);a.push.apply(a,f(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Z,""):null;if(typeof a=="string"&&!bd.test(a)&&(f.support.leadingWhitespace||!$.test(a))&&!bj[(ba.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(_,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bn(a,d),e=bo(a),g=bo(d);for(h=0;e[h];++h)g[h]&&bn(e[h],g[h])}if(b){bm(a,d);if(c){e=bo(a),g=bo(d);for(h=0;e[h];++h)bm(e[h],g[h])}}e=g=null;return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!bc.test(k))k=b.createTextNode(k);else{k=k.replace(_,"<$1>");var l=(ba.exec(k)||["",""])[1].toLowerCase(),m=bj[l]||bj._default,n=m[0],o=b.createElement("div");b===c?bk.appendChild(o):X(b).appendChild(o),o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=bb.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&$.test(k)&&o.insertBefore(b.createTextNode($.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bt.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bs,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bs.test(g)?g.replace(bs,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bB(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bC=function(a,c){var d,e,g;c=c.replace(bu,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bD=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f===null&&g&&(e=g[b])&&(f=e),!bv.test(f)&&bw.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f||0,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),bB=bC||bD,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bF=/%20/g,bG=/\[\]$/,bH=/\r?\n/g,bI=/#.*$/,bJ=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bK=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bL=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bM=/^(?:GET|HEAD)$/,bN=/^\/\//,bO=/\?/,bP=/)<[^<]*)*<\/script>/gi,bQ=/^(?:select|textarea)/i,bR=/\s+/,bS=/([?&])_=[^&]*/,bT=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bU=f.fn.load,bV={},bW={},bX,bY,bZ=["*/"]+["*"];try{bX=e.href}catch(b$){bX=c.createElement("a"),bX.href="",bX=bX.href}bY=bT.exec(bX.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bU)return bU.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bP,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bQ.test(this.nodeName)||bK.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bH,"\r\n")}}):{name:b.name,value:c.replace(bH,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.bind(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?cb(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),cb(a,b);return a},ajaxSettings:{url:bX,isLocal:bL.test(bY[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bZ},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:b_(bV),ajaxTransport:b_(bW),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?cd(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=ce(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bJ.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bI,"").replace(bN,bY[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bR),d.crossDomain==null&&(r=bT.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bY[1]&&r[2]==bY[2]&&(r[3]||(r[1]==="http:"?80:443))==(bY[3]||(bY[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),ca(bV,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bM.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bO.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bS,"$1_="+x);d.url=y+(y===d.url?(bO.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bZ+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=ca(bW,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){s<2?w(-1,z):f.error(z)}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)cc(g,a[g],c,e);return d.join("&").replace(bF,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cf=f.now(),cg=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cf++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(cg.test(b.url)||e&&cg.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(cg,l),b.url===j&&(e&&(k=k.replace(cg,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var ch=a.ActiveXObject?function(){for(var a in cj)cj[a](0,1)}:!1,ci=0,cj;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ck()||cl()}:ck,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,ch&&delete cj[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++ci,ch&&(cj||(cj={},f(a).unload(ch)),cj[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cm={},cn,co,cp=/^(?:toggle|show|hide)$/,cq=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cr,cs=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],ct;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cw("show",3),a,b,c);for(var g=0,h=this.length;g=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cz.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cz.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cA(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cA(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,d,"padding")):this[d]():null},f.fn["outer"+c]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,d,a?"margin":"border")):this[d]():null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNumeric(j)?j:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f})(window); \ No newline at end of file diff --git a/extras/jquery.mousewheel.min.js b/extras/jquery.mousewheel.min.js new file mode 100644 index 0000000..3390202 --- /dev/null +++ b/extras/jquery.mousewheel.min.js @@ -0,0 +1,12 @@ +/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net) + * Licensed under the MIT License (LICENSE.txt). + * + * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. + * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. + * Thanks to: Seamus Leahy for adding deltaX and deltaY + * + * Version: 3.0.6 + * + * Requires: 1.2.2+ + */ +(function(a){function d(b){var c=b||window.event,d=[].slice.call(arguments,1),e=0,f=!0,g=0,h=0;return b=a.event.fix(c),b.type="mousewheel",c.wheelDelta&&(e=c.wheelDelta/120),c.detail&&(e=-c.detail/3),h=e,c.axis!==undefined&&c.axis===c.HORIZONTAL_AXIS&&(h=0,g=-1*e),c.wheelDeltaY!==undefined&&(h=c.wheelDeltaY/120),c.wheelDeltaX!==undefined&&(g=-1*c.wheelDeltaX/120),d.unshift(b,e,g,h),(a.event.dispatch||a.event.handle).apply(this,d)}var b=["DOMMouseScroll","mousewheel"];if(a.event.fixHooks)for(var c=b.length;c;)a.event.fixHooks[b[--c]]=a.event.mouseHooks;a.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=b.length;a;)this.addEventListener(b[--a],d,!1);else this.onmousewheel=d},teardown:function(){if(this.removeEventListener)for(var a=b.length;a;)this.removeEventListener(b[--a],d,!1);else this.onmousewheel=null}},a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery) diff --git a/extras/modernizr.2.5.3.min.js b/extras/modernizr.2.5.3.min.js new file mode 100755 index 0000000..6716720 --- /dev/null +++ b/extras/modernizr.2.5.3.min.js @@ -0,0 +1,4 @@ +/* Modernizr 2.5.3 (Custom Build) | MIT & BSD + * Build: http://www.modernizr.com/download/#-csstransforms-csstransforms3d-shiv-cssclasses-teststyles-testprop-testallprops-prefixes-domprefixes-load + */ +;window.Modernizr=function(a,b,c){function z(a){j.cssText=a}function A(a,b){return z(m.join(a+";")+(b||""))}function B(a,b){return typeof a===b}function C(a,b){return!!~(""+a).indexOf(b)}function D(a,b){for(var d in a)if(j[a[d]]!==c)return b=="pfx"?a[d]:!0;return!1}function E(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:B(f,"function")?f.bind(d||b):f}return!1}function F(a,b,c){var d=a.charAt(0).toUpperCase()+a.substr(1),e=(a+" "+o.join(d+" ")+d).split(" ");return B(b,"string")||B(b,"undefined")?D(e,b):(e=(a+" "+p.join(d+" ")+d).split(" "),E(e,b,c))}var d="2.5.3",e={},f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k,l={}.toString,m=" -webkit- -moz- -o- -ms- ".split(" "),n="Webkit Moz O ms",o=n.split(" "),p=n.toLowerCase().split(" "),q={},r={},s={},t=[],u=t.slice,v,w=function(a,c,d,e){var f,i,j,k=b.createElement("div"),l=b.body,m=l?l:b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),k.appendChild(j);return f=["­",""].join(""),k.id=h,(l?k:m).innerHTML+=f,m.appendChild(k),l||(m.style.background="",g.appendChild(m)),i=c(k,a),l?k.parentNode.removeChild(k):m.parentNode.removeChild(m),!!i},x={}.hasOwnProperty,y;!B(x,"undefined")&&!B(x.call,"undefined")?y=function(a,b){return x.call(a,b)}:y=function(a,b){return b in a&&B(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=u.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(u.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(u.call(arguments)))};return e});var G=function(a,c){var d=a.join(""),f=c.length;w(d,function(a,c){var d=b.styleSheets[b.styleSheets.length-1],g=d?d.cssRules&&d.cssRules[0]?d.cssRules[0].cssText:d.cssText||"":"",h=a.childNodes,i={};while(f--)i[h[f].id]=h[f];e.csstransforms3d=(i.csstransforms3d&&i.csstransforms3d.offsetLeft)===9&&i.csstransforms3d.offsetHeight===3},f,c)}([,["@media (",m.join("transform-3d),("),h,")","{#csstransforms3d{left:9px;position:absolute;height:3px;}}"].join("")],[,"csstransforms3d"]);q.csstransforms=function(){return!!F("transform")},q.csstransforms3d=function(){var a=!!F("perspective");return a&&"webkitPerspective"in g.style&&(a=e.csstransforms3d),a};for(var H in q)y(q,H)&&(v=H.toLowerCase(),e[v]=q[H](),t.push((e[v]?"":"no-")+v));return z(""),i=k=null,function(a,b){function g(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function h(){var a=k.elements;return typeof a=="string"?a.split(" "):a}function i(a){var b={},c=a.createElement,e=a.createDocumentFragment,f=e();a.createElement=function(a){var e=(b[a]||(b[a]=c(a))).cloneNode();return k.shivMethods&&e.canHaveChildren&&!d.test(a)?f.appendChild(e):e},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+h().join().replace(/\w+/g,function(a){return b[a]=c(a),f.createElement(a),'c("'+a+'")'})+");return n}")(k,f)}function j(a){var b;return a.documentShived?a:(k.shivCSS&&!e&&(b=!!g(a,"article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio{display:none}canvas,video{display:inline-block;*display:inline;*zoom:1}[hidden]{display:none}audio[controls]{display:inline-block;*display:inline;*zoom:1}mark{background:#FF0;color:#000}")),f||(b=!i(a)),b&&(a.documentShived=b),a)}var c=a.html5||{},d=/^<|^(?:button|form|map|select|textarea)$/i,e,f;(function(){var a=b.createElement("a");a.innerHTML="",e="hidden"in a,f=a.childNodes.length==1||function(){try{b.createElement("a")}catch(a){return!0}var c=b.createDocumentFragment();return typeof c.cloneNode=="undefined"||typeof c.createDocumentFragment=="undefined"||typeof c.createElement=="undefined"}()})();var k={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:j};a.html5=k,j(b)}(this,b),e._version=d,e._prefixes=m,e._domPrefixes=p,e._cssomPrefixes=o,e.testProp=function(a){return D([a])},e.testAllProps=F,e.testStyles=w,g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+t.join(" "):""),e}(this,this.document),function(a,b,c){function d(a){return o.call(a)=="[object Function]"}function e(a){return typeof a=="string"}function f(){}function g(a){return!a||a=="loaded"||a=="complete"||a=="uninitialized"}function h(){var a=p.shift();q=1,a?a.t?m(function(){(a.t=="c"?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){a!="img"&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l={},o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};y[c]===1&&(r=1,y[c]=[],l=b.createElement(a)),a=="object"?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),a!="img"&&(r||y[c]===2?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i(b=="c"?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),p.length==1&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&o.call(a.opera)=="[object Opera]",l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return o.call(a)=="[object Array]"},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f comment.js + +if [ ! -f /tmp/compiler.jar ]; +then + echo "Downloading Google Closure Compiler..." + curl --silent -L http://closure-compiler.googlecode.com/files/compiler-latest.zip > /tmp/compiler-latest.zip + unzip -o /tmp/compiler-latest.zip -d /tmp + rm /tmp/compiler-latest.zip + chmod +x /tmp/compiler.jar +fi + + echo "Making Minimized files..." + +for (( i=0; i<${SCRIPTS_LEN}; i++ )); +do + java -jar "/tmp/compiler.jar" --js ${SCRIPTS[$i]}.js > ${SCRIPTS[$i]}.closure.js + + cat comment.js ${SCRIPTS[$i]}.closure.js > ${SCRIPTS[$i]}.min.js + + rm ${SCRIPTS[$i]}.closure.js + + m=$(ls -la ${SCRIPTS[$i]}.min.js | awk '{ print $5}') + gzip -nfc --best ${SCRIPTS[$i]}.min.js > ${SCRIPTS[$i]}.min.js.gz + g=$(ls -la ${SCRIPTS[$i]}.min.js.gz | awk '{ print $5}') + echo " ${SCRIPTS[$i]}.js: $m bytes minified, $g bytes gzipped" + + rm ${SCRIPTS[$i]}.min.js.gz + + if [ "--test" == "$1" ]; then + rm ${SCRIPTS[$i]}.min.js + fi + +done + +rm comment.js \ No newline at end of file diff --git a/lib/hash.js b/lib/hash.js new file mode 100644 index 0000000..26b5521 --- /dev/null +++ b/lib/hash.js @@ -0,0 +1,164 @@ +/** + * hash.js + * + * Copyright (C) 2012 Emmanuel Garcia + * MIT Licensed + * + * **************************************** + * + * Hash.pushState(true); + * + * Hash.on('/page/([0-9]+)$', + * {yep: function(path, parts) { }, nop: function() { }}, + * 'Page $1'); + * + * Hash.go('/page/1'); + **/ + +(function() { + +'use strict'; + +var hashes = {}, + regexp = {}, + history = [], + freq = 100, + num = 0, + pushState = false, + timer = null, + currentUrl = null, + + freeze = function(obj) { + if (Object.freeze) return Object.freeze(obj); + return obj; + }, + + getHashParts = function() { + return window.location.href.split('#'); + }, + + startTimer = function() { + + if (!timer) + timer = setInterval(function() { + if (num>0 && currentUrl!=window.location.href) { + currentUrl = window.location.href; + window.Hash.check(); + } + }, freq); + + }, + + stopTimer = function() { + + if (timer) { + clearInterval(timer); + timer = null; + } + + }; + +window.Hash = freeze({ + + pushState: function(yes) { + + if (window.history && window.history.pushState) + pushState = yes; + + return this; + }, + + fragment: function() { + + var hash = getHashParts(); + return (pushState) ? + window.location.pathname + ((hash[1]) ? '#' + hash[1] : '') + : hash[1] || ''; + + }, + + get: function(path, params) { + + var p, fragment = '', parameters = []; + + for(p in params) { + if (!Object.prototype.hasOwnProperty(p)) + continue; + parameters.push(encodeURIComponent(p) + '=' + encodeURIComponent(params[p])); + } + + if (parameters.length>0) + parameters = '?' + parameters.join('&'); + + return (pushState) ? path + parameters : + getHashParts()[0] + '#' + path + parameters; + + }, + + go: function(hash, params) { + + if (this.fragment()!=hash) { + var to = this.get(hash, params); + + if (pushState) + window.history.pushState(null, document.title, to); + else + window.location.href = to; + } + + return this; + }, + + update: function () { + + currentUrl = window.location.href; + return this; + + }, + + on: function(hash, callback, title) { + + if (!hashes[hash]) + hashes[hash] = {title: title, listeners: []}; + + hashes[hash].listeners.push(callback); + num++; + startTimer(); + + return this; + }, + + check: function() { + + var i, + hash, + parts, + fragment = this.fragment(); + + + for (hash in hashes) { + if (!Object.prototype.hasOwnProperty.call(hashes, hash)) + continue; + + hashes[hash].regexp = hashes[hash].regexp || new RegExp(hash); + + if ((parts = hashes[hash].regexp.exec(fragment))) { + if (hashes[hash].title) + document.title = hashes[hash].title; + + for (i = 0; i', {css: pageProperties}), + rightPage = $('
', {css: pageProperties}); + + element.after(leftPage); + leftPage.after(rightPage); + + element.css({ + marginLeft: 0 + }).appendTo(leftPage); + + newElement.css({ + marginLeft: -pageProperties.width + }).appendTo(rightPage); + + }); + + return this; + } +}); + +})(jQuery); diff --git a/lib/scissor.min.js b/lib/scissor.min.js new file mode 100644 index 0000000..259afe9 --- /dev/null +++ b/lib/scissor.min.js @@ -0,0 +1,3 @@ +/* turn.js 4.1.0 | Copyright (c) 2012 Emmanuel Garcia | turnjs.com | turnjs.com/license.txt */ + +(function(a){a.extend(a.fn,{scissor:function(){this.each(function(){var b=a(this),c={width:b.width()/2,height:b.height(),overflow:"hidden"},f=b.clone(!0),d=a("
",{css:c}),e=a("
",{css:c});b.after(d);d.after(e);b.css({marginLeft:0}).appendTo(d);f.css({marginLeft:-c.width}).appendTo(e)});return this}})})(jQuery); diff --git a/lib/turn.html4.js b/lib/turn.html4.js new file mode 100644 index 0000000..dcc0066 --- /dev/null +++ b/lib/turn.html4.js @@ -0,0 +1,2394 @@ +/** + * turn.js 4th release HTML4 version + * turnjs.com + * turnjs.com/license.txt + * + * Copyright (C) 2012 Emmanuel Garcia + * All rights reserved + **/ + +(function($) { + +'use strict'; + +var has3d, + + vendor = '', + + version = '4.1.0', + + isTouch = false, + + mouseEvents = + { + down: 'mousedown', + move: 'mousemove', + up: 'mouseup', + over: 'mouseover', + out: 'mouseout' + }, + + corners = { + backward: ['l'], + forward: ['r'], + all: ['l', 'r'] + }, + + // Display values + + displays = ['single', 'double'], + + // Direction values + + directions = ['ltr', 'rtl'], + + // Default options + + turnOptions = { + + // Enables hardware acceleration + + acceleration: true, + + // Display + + display: 'double', + + // Duration of transition in milliseconds + + duration: 600, + + // First page + + page: 1, + + // Enables gradients + + gradients: true, + + // Events + + when: null + }, + + flipOptions = { + + // Enables hardware acceleration + + acceleration: true, + + // Corners + // backward: Activates both tl and bl corners + // forward: Activates both tr and br corners + // all: Activates all the corners + + corners: 'forward', + + // Size of the active zone of each corner + + cornerSize: 100, + + + // Duration of transition in milliseconds + + duration: 600, + + // Enables gradients + + gradients: true + + }, + + // Number of pages in the DOM, minimum value: 6 + + pagesInDOM = 6, + + +turnMethods = { + + // Singleton constructor + // $('#selector').turn([options]); + + init: function(opts) { + + if (this.length>1) + throw turnError('This selector has more than 1 element'); + + // Define constants + + vendor = getPrefix(); + + var i, pageNum = 0, data = this.data(), ch = this.children(); + + // Set initial configuration + + opts = $.extend({ + width: this.width(), + height: this.height(), + direction: this.attr('dir') || this.css('direction') || 'ltr' + }, turnOptions, opts); + + data.opts = opts; + data.pageObjs = {}; + data.pages = {}; + data.pageWrap = {}; + data.pagePlace = {}; + data.pageMv = []; + data.zoom = 1; + data.totalPages = opts.pages || 0; + data.docEvents = { + mouseStart: function(e) { + for (var page in data.pages) + if (has(page, data.pages) && + flipMethods._eventStart.call(data.pages[page], e)===false) + return false; + }, + + mouseMove: function(e) { + for (var page in data.pages) + if (has(page, data.pages)) + flipMethods._eventMove.call(data.pages[page], e); + }, + + mouseEnd: function(e) { + for (var page in data.pages) + if (has(page, data.pages)) + flipMethods._eventEnd.call(data.pages[page], e); + } + }; + + // Add event listeners + + if (opts.when) + for (i in opts.when) + if (has(i, opts.when)) + this.bind(i, opts.when[i]); + + // Set the css + + this.css({position: 'relative', width: opts.width, height: opts.height}); + + // Set the initial display + + this.turn('display', opts.display); + + // Set the direction + + if (opts.direction!=='') + this.turn('direction', opts.direction); + + + // Add pages from the DOM + + for (i = 0; ilastPage) + throw turnError('Page "'+page+'" cannot be inserted'); + + } else { + + page = lastPage; + incPages = true; + + } + + if (page>=1 && page<=lastPage) { + + if (data.display=='double') + className = (page%2) ? ' odd' : ' even'; + else + className = ''; + + // Stop animations + if (data.done) + this.turn('stop'); + + // Move pages if it's necessary + if (page in data.pageObjs) + turnMethods._movePages.call(this, page, 1); + + // Increase the number of pages + if (incPages) + data.totalPages = lastPage; + + // Add element + data.pageObjs[page] = $(element). + css({'float': 'left'}). + addClass('page p' + page + className); + + // Add page + turnMethods._addPage.call(this, page); + + + // Update view + if (data.done) + this.turn('update'); + + + // Remove pages out of range + turnMethods._removeFromDOM.call(this); + } + + return this; + }, + + // Adds a page + + _addPage: function(page) { + + var data = this.data(), + element = data.pageObjs[page]; + + if (element) + if (turnMethods._necessPage.call(this, page)) { + + if (!data.pageWrap[page]) { + + var prop = turnMethods._pageSize.call(this, page, true); + + element.css({width: prop.width, height: prop.height}); + + // Place + data.pagePlace[page] = page; + + // Wrapper + data.pageWrap[page] = $('
', + {'class': 'turn-page-wrapper', + page: page, + css: {position: 'absolute', + overflow: 'hidden'}}). + css(prop); + + // Append to this + this.append(data.pageWrap[page]); + + // Move element to wrapper + data.pageWrap[page].prepend(data.pageObjs[page]); + + } + + // 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 + data.pagePlace[page] = 0; + + // Remove element from the DOM + if (data.pageObjs[page]) + data.pageObjs[page].remove(); + + } + + }, + + // Checks if a page is in memory + + hasPage: function(page) { + + return has(page, this.data().pageObjs); + + }, + + // Centers the flipbook + + center: function(page) { + + var data = this.data(), + size = $(this).turn('size'), + left = size.width/(data.zoom*2) -size.width/2; + + if (data.display=='double') { + var view = this.turn('view', page || data.tpage || data.page); + + if (data.direction=='ltr') { + if (!view[0]) + left -= size.width/4; + else if (!view[1]) + left += size.width/4; + } else { + if (!view[0]) + left += size.width/4; + else if (!view[1]) + left -= size.width/4; + } + } + + $(this).css({marginLeft: left}); + + return this; + + }, + + // Destroys the flipbook + + destroy: function () { + + var page, + data = this.data(); + + data.destroying = true; + + $(this).unbind(mouseEvents.down) + .unbind('end') + .unbind('first') + .unbind('flip') + .unbind('last') + .unbind('pressed') + .unbind('released') + .unbind('start') + .unbind('turning') + .unbind('turned') + .unbind('zooming'); + + $(document).unbind(mouseEvents.move, data.docEvents.mouseMove). + unbind(mouseEvents.up, data.docEvents.mouseEnd); + + while (data.totalPages!==0) { + this.turn('removePage', data.totalPages); + } + + if (data.fparent) + data.fparent.remove(); + + if (data.shadow) + data.shadow.remove(); + + this.removeData(); + data = null; + + return this; + + }, + + // Checks if this element is a flipbook + + is: function() { + + return typeof(this.data().pages)=='object'; + + }, + + // Sets and gets the zoom value + + zoom: function(newZoom) { + + var data = this.data(); + + if (typeof(newZoom)=='number') { + + if (newZoom<0.001 || newZoom>100) + throw turnError(newZoom+ ' is not a value for zoom'); + + var event = $.Event('zooming'); + this.trigger(event, [newZoom, data.zoom]); + + if (event.isDefaultPrevented()) + return this; + + var size = $(this).turn('size'), + iz = 1/data.zoom, + newWidth = Math.round(size.width * iz * newZoom), + newHeight = Math.round(size.height * iz * newZoom); + + data.zoom = newZoom; + + $(this).turn('stop'). + turn('size', newWidth, newHeight). + css({marginTop: size.height * iz / 2 - newHeight / 2}); + + if (data.opts.autoCenter) + this.turn('center'); + else + $(this).css({marginLeft: size.width * iz / 2 - newWidth / 2}); + + turnMethods._updateShadow.call(this); + + return this; + + } else + return data.zoom; + + }, + + // Gets the size of a page + + _pageSize: function(page, position) { + + var data = this.data(), + prop = {}; + + if (data.display=='single') { + + prop.width = this.width(); + prop.height = this.height(); + + if (position) { + prop.top = 0; + prop.left = 0; + prop.right = 'auto'; + } + + } else { + + var pageWidth = this.width()/2, + pageHeight = this.height(); + + if (data.pageObjs[page].hasClass('own-size')) { + prop.width = data.pageObjs[page].width(); + prop.height = data.pageObjs[page].height(); + } else { + prop.width = pageWidth; + prop.height = pageHeight; + } + + if (position) { + var odd = page%2; + prop.top = (pageHeight-prop.height)/2; + + if (data.direction=='ltr') { + + prop[(odd) ? 'right' : 'left'] = pageWidth-prop.width; + prop[(odd) ? 'left' : 'right'] = 'auto'; + + } else { + + prop[(odd) ? 'left' : 'right'] = pageWidth-prop.width; + prop[(odd) ? 'right' : 'left'] = 'auto'; + + } + + } + } + + return prop; + + }, + + // Prepares the flip effect for a page + + _makeFlip: function(page) { + + var data = this.data(); + + if (!data.pages[page] && data.pagePlace[page]==page) { + var corner, + single = data.display=='single', + odd = page%2; + + data.pages[page] = data.pageObjs[page]. + css(turnMethods._pageSize.call(this, page)). + flip({page: page, + next: (odd || single) ? page+1 : page-1, + turn: this, + duration: data.opts.duration, + acceleration : data.opts.acceleration, + gradients: data.opts.gradients + }). + flip('disable', data.disabled); + } + + return data.pages[page]; + }, + + // Makes pages within a range + + _makeRange: function() { + + var page, range, + data = this.data(); + + if (data.totalPages<1) + return; + + range = this.turn('range'); + + for (page = range[0]; page<=range[1]; page++) + turnMethods._addPage.call(this, page); + + }, + + // Returns a range of pages that should be in the DOM + // Example: + // - page in the current view, return true + // * page is in the range, return true + // Otherwise, return false + // + // 1 2-3 4-5 6-7 8-9 10-11 12-13 + // ** ** -- ** ** + + range: function(page) { + + var remainingPages, left, right, view, + data = this.data(); + + + page = page || data.tpage || data.page || 1; + view = turnMethods._view.call(this, page); + + if (page<1 || page>data.totalPages) + throw turnError('"'+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); + + if (data.totalPages-view[1] > view[0]) { + left = Math.min(view[0]-1, remainingPages); + right = 2*remainingPages-left; + } else { + right = Math.min(data.totalPages-view[1], remainingPages); + left = 2*remainingPages-right; + } + + } else { + left = pagesInDOM-1; + right = pagesInDOM-1; + } + + return [Math.max(1, view[0]-left), + Math.min(data.totalPages, view[1]+right)]; + + }, + + // Detects if a page is within the range of `pagesInDOM` from the current view + + _necessPage: function(page) { + + if (page===0) + return true; + + var data = this.data(), + range = this.turn('range'); + + return data.pageObjs[page].hasClass('fixed') || + (page>=range[0] && page<=range[1]); + + }, + + // Releases memory by removing pages from the DOM + + _removeFromDOM: function() { + + var page, data = this.data(); + + for (page in data.pageWrap) + if (has(page, data.pageWrap) && + !turnMethods._necessPage.call(this, page)) + turnMethods._removePageFromDOM.call(this, page); + + }, + + // Removes a page from DOM and its internal references + + _removePageFromDOM: function(page) { + + var data = this.data(); + + if (data.pages[page]) { + var dd = data.pages[page].data(); + + flipMethods._moveFoldingPage.call(data.pages[page], false); + + if (dd.f && dd.f.fwrapper) + dd.f.fwrapper.remove(); + + data.pages[page].removeData(); + data.pages[page].remove(); + delete data.pages[page]; + } + + if (data.pageObjs[page]) + data.pageObjs[page].remove(); + + if (data.pageWrap[page]) { + data.pageWrap[page].remove(); + delete data.pageWrap[page]; + } + + delete data.pagePlace[page]; + + }, + + // Removes a page + + removePage: function(page) { + + var data = this.data(); + + if (page<1 || page>data.totalPages) + throw turnError('The page '+ page + ' doesn\'t exist'); + + if (data.pageObjs[page]) { + + // Stop animations + this.turn('stop'); + + // Remove `page` + turnMethods._removePageFromDOM.call(this, page); + delete data.pageObjs[page]; + + } + + // Move the pages behind `page` + turnMethods._movePages.call(this, page, -1); + + // Resize the size of this flipbook + data.totalPages = data.totalPages-1; + + // Check the current view + + if (data.page>data.totalPages) + this.turn('page', data.totalPages); + else + turnMethods._makeRange.call(this); + + return this; + + }, + + // Moves pages + + _movePages: function(from, change) { + + var page, + that = this, + data = this.data(), + single = data.display=='single', + move = function(page) { + + var next = page + change, + odd = next%2, + className = (odd) ? ' odd ' : ' even '; + + if (data.pageObjs[page]) + data.pageObjs[next] = data.pageObjs[page] + .removeClass('p' + page + ' odd even') + .addClass('p' + next + className); + + if (data.pagePlace[page] && data.pageWrap[page]) { + data.pagePlace[next] = next; + + if (data.pageObjs[next].hasClass('fixed')) + data.pageWrap[next] = data.pageWrap[page] + .attr('page', next); + else + data.pageWrap[next] = data.pageWrap[page]. + css(turnMethods._pageSize.call(that, next, true)). + attr('page', next); + + if (data.pages[page]) + data.pages[next] = data.pages[page] + .flip('options', { + page: next, + next: (single || odd) ? next+1 : next-1, + corners: (single) ? 'all' : + ((odd) ? 'forward' : 'backward') + }); + + if (change) { + delete data.pages[page]; + delete data.pagePlace[page]; + delete data.pageObjs[page]; + delete data.pageWrap[page]; + delete data.pageObjs[page]; + } + } + }; + + if (change>0) + for (page=data.totalPages; page>=from; page--) + move(page); + else + for (page=from; page<=data.totalPages; page++) + move(page); + + }, + + // Sets or Gets the display mode + + display: function(display) { + + var data = this.data(), + currentDisplay = data.display; + + if (display) { + + if ($.inArray(display, displays)==-1) + throw turnError('"'+display + '" is not a value for display'); + + if (display=='single') { + if (!data.pageObjs[0]) { + + this.turn('stop'). + css({'overflow': 'hidden'}); + + data.pageObjs[0] = $('
', + {'class': 'page p-temporal'}). + css({width: this.width(), height: this.height()}). + appendTo(this); + + } + } else { + if (data.pageObjs[0]) { + this.turn('stop').css({'overflow': ''}); + data.pageObjs[0].remove(); + delete data.pageObjs[0]; + } + } + + data.display = display; + + if (currentDisplay) { + var size = this.turn('size'); + turnMethods._movePages.call(this, 1, 0); + this.turn('size', size.width, size.height). + turn('update'); + } + + return this; + + } else + return currentDisplay; + + }, + + // Gets and sets the direction of the flipbook + + direction: function(dir) { + + var data = this.data(); + + if (typeof(dir)=='undefined') { + + return data.direction; + + } else { + + dir = dir.toLowerCase(); + + if ($.inArray(dir, directions)==-1) + throw turnError('"' + dir + '" is not a value for direction'); + + if (dir=='rtl') { + $(this).attr('dir', 'ltr'). + css({direction: 'ltr'}); + } + + data.direction = dir; + + if (data.done) + this.turn('size', $(this).width(), $(this).height()); + + return this; + } + + }, + + // Detects if the pages are being animated + + animating: function() { + + return this.data().pageMv.length>0; + + }, + + // Disables and enables the effect + + disable: function(bool) { + + var page, + data = this.data(), + view = this.turn('view'); + + data.disabled = bool===undefined || bool===true; + + for (page in data.pages) + if (has(page, data.pages)) + data.pages[page].flip('disable', (bool) ? $.inArray(page, view) : false); + + return this; + + }, + + // Disables and enables the effect + + disabled: function(disable) { + + if (disable===undefined) { + return this.data().disabled===true; + } else { + return this.turn('disable', disable); + } + + }, + + // Gets and sets the size + + size: function(width, height) { + + if (width && height) { + + var page, prop, + data = this.data(), + pageWidth = (data.display=='double') ? width/2 : width; + + this.css({width: width, height: height}); + + if (data.pageObjs[0]) + data.pageObjs[0].css({width: pageWidth, height: height}); + + for (page in data.pageWrap) { + if (!has(page, data.pageWrap)) continue; + + prop = turnMethods._pageSize.call(this, page, true); + + data.pageObjs[page].css({width: prop.width, height: prop.height}); + data.pageWrap[page].css(prop); + + if (data.pages[page]) + data.pages[page].css({width: prop.width, height: prop.height}); + } + + this.turn('resize'); + + return this; + + } else { + + return {width: this.width(), height: this.height()}; + + } + }, + + // Resizes each page + + resize: function() { + + var page, data = this.data(); + + if (data.pages[0]) { + data.pageWrap[0].css({left: -this.width()}); + data.pages[0].flip('resize', true); + } + + for (page = 1; page <= data.totalPages; page++) + if (data.pages[page]) + data.pages[page].flip('resize', true); + + + }, + + // Removes an animation from the cache + + _removeMv: function(page) { + + var i, data = this.data(); + + for (i=0; i0) ? view[0] : 0, + (view[1]<=data.totalPages) ? view[1] : 0]; + else + return [(view[0]>0 && view[0]<=data.totalPages) ? view[0] : 0]; + + }, + + // Stops animations + + stop: function(ignore, animate) { + + if (this.turn('animating')) { + var i, opts, page, + data = this.data(), + pages = data.pageMv; + + data.pageMv = []; + + if (data.tpage) { + data.page = data.tpage; + delete data['tpage']; + } + + for (i = 0; ipages) + this.turn('page', pages); + } + + data.totalPages = pages; + + return this; + } else + return data.totalPages; + + }, + + // Checks missing pages + + _missing : function(page) { + + var p, + data = this.data(), + range = this.turn('range', page), + missing = []; + + for (p = range[0]; p<=range[1]; p++) { + if (!data.pageObjs[p]) + missing.push(p); + } + + if (missing.length>0) + this.trigger('missing', [missing]); + + }, + + // Sets a page without effect + + _fitPage: function(page) { + + var data = this.data(), + newView = this.turn('view', page); + + turnMethods._missing.call(this, page); + + if (!data.pageObjs[page]) + return; + + data.page = page; + + this.turn('stop'); + turnMethods._removeFromDOM.call(this); + turnMethods._makeRange.call(this); + turnMethods._updateShadow.call(this); + this.trigger('turned', [page, newView]); + + if (data.opts.autoCenter) + this.turn('center'); + + }, + + // Turns to a page + + _turnPage: function(page, fromMouseAction) { + + var current, next, + data = this.data(), + place = data.pagePlace[page], + view = this.turn('view'), + newView = this.turn('view', page); + + if (data.page!=page) { + + var event = $.Event('turning'); + this.trigger(event, [page, newView]); + + if (event.isDefaultPrevented()) + return; + + if ($.inArray(1, newView)!=-1) + this.trigger('first'); + if ($.inArray(data.totalPages, newView)!=-1) + this.trigger('last'); + + } + + + + if (fromMouseAction) { + + this.turn('stop', place); + + } else { + + turnMethods._missing.call(this, page); + + if (!data.pageObjs[page]) + return; + + this.turn('stop'); + data.page = page; + } + + + turnMethods._makeRange.call(this); + + if (data.display=='single') { + current = view[0]; + next = newView[0]; + } else if (view[1] && page>view[1]) { + current = view[1]; + next = newView[0]; + } else if (view[0] && page view[0]) ? 'r' : 'l'); + } else { + data.pages[current].flip('turnPage', + (newView[0] > view[0]) ? 'l' : 'r'); + } + + } else { + + data.pages[current].flip('turnPage'); + + } + } + + }, + + // Gets and sets a page + + page: function(page) { + + page = parseInt(page, 10); + + var data = this.data(); + + if (page>0 && page<=data.totalPages) { + if (!data.done || $.inArray(page, this.turn('view'))!=-1) + turnMethods._fitPage.call(this, page); + else + turnMethods._turnPage.call(this, page); + + return this; + + } else + return data.page; + + }, + + // Turns to the next view + + next: function() { + + return this.turn('page', + turnMethods._view.call(this, this.data().page).pop() + 1); + + }, + + // Turns to the previous view + + previous: function() { + + return this.turn('page', + turnMethods._view.call(this, this.data().page).shift() - 1); + + }, + + peel: function(corner, animate) { + + return this; + + }, + + // Adds a motion to the internal list + // This event is called in context of flip + + _addMotionPage: function() { + + var opts = $(this).data().f.opts, + turn = opts.turn, + dd = turn.data(); + + turnMethods._addMv.call(turn, opts.page); + dd.pagePlace[opts.next] = opts.page; + turn.turn('update'); + + }, + + // This event is called in context of flip + + _start: function(e, opts, corner) { + + var data = opts.turn.data(); + + if (e.isDefaultPrevented()) { + turnMethods._updateShadow.call(opts.turn); + return; + } + + if (data.display=='single' && corner) { + + if ((corner=='l' && data.direction=='ltr') + || + (corner=='r' && data.direction=='rtl')) + { + + opts.next = (opts.nextopts.page) ? opts.next : opts.page+1; + + } + + } + + turnMethods._addMotionPage.call(e.target); + turnMethods._updateShadow.call(opts.turn); + }, + + // This event is called in context of flip + + _end: function(e, opts, turned) { + + var that = $(e.target), + data = that.data().f, + turn = opts.turn, + dd = turn.data(); + + if (turned || dd.tpage) { + + if (dd.tpage==opts.next || dd.tpage==opts.page) { + delete dd['tpage']; + turnMethods._fitPage.call(turn, dd.tpage || opts.next, true); + } + + } else { + + turnMethods._removeMv.call(turn, opts.page); + turnMethods._updateShadow.call(turn); + turn.turn('update'); + + } + + }, + + // This event is called in context of flip + + _pressed: function(e) { + + e.stopPropagation(); + + var page, + data = $(e.target).data().f, + pages = data.opts.turn.data().pages; + + for (page in pages) + if (page!=data.opts.page) + pages[page].flip('disable', true); + + return data.time = new Date().getTime(); + + }, + + // This event is called in context of flip + + _released: function(e, point) { + + e.stopPropagation(); + + var outArea, + page = $(e.target), + data = page.data().f, + turn = data.opts.turn, + turnData = turn.data(); + + if (turnData.display=='single') { + outArea = (point.corner=='r') ? + point.xpage.width()/2; + } else { + outArea = point.x<0 || point.x>page.width(); + } + + if ((new Date()).getTime()-data.time<200 || outArea) { + + e.preventDefault(); + + turnMethods._turnPage.call( + turn, + data.opts.next, + flipMethods._cornerActivated.call(page, point, 1) === false + ); + + } + + turnData.mouseAction = false; + + }, + + // This event is called in context of flip + + _flip: function(e) { + + e.stopPropagation(); + + var opts = $(e.target).data().f.opts; + + opts.turn.trigger('turn', [opts.next]); + + if (opts.turn.data().opts.autoCenter) + opts.turn.turn('center', opts.next); + + }, + + // Calculate the z-index value for pages during the animation + + calculateZ: function(mv) { + + var i, page, nextPage, placePage, dpage, + that = this, + data = this.data(), + view = this.turn('view'), + currentPage = view[0] || view[1], + r = {pageZ: {}, partZ: {}, pageV: {}}, + + addView = function(page) { + var view = that.turn('view', page); + if (view[0]) r.pageV[view[0]] = true; + if (view[1]) r.pageV[view[1]] = true; + }; + + for (i = 0; i', + { + 'class': 'shadow', + 'css': divAtt(0, 0, 0).css + }). + appendTo(this); + } + + for (var i = 0; i=width || c.y>=height) + return false; + + var allowedCorners = flipMethods._cAllowed.call(this); + + if (c.x>width-csz) + c.corner = 'r'; + else if (c.x', divAtt(0, 0, 2)). + css(cssProperties). + appendTo(parent). + prepend(this); + + data.fpage = $('
', divAtt(0, 0, 1)). + css(cssProperties). + appendTo(parent); + + } + + // Set size + flipMethods.resize.call(this, true); + + }, + + // Takes a 2P point from the screen and applies the transformation + + _fold: function(point) { + + var data = this.data().f, + o = flipMethods._c.call(this, point.corner), + relX = (o.x) ? o.x - point.x : point.x, + width = this.width(), + height = this.height(); + + relX = Math.min(width*2, Math.max(0, relX)); + + + switch(point.corner) { + case 'r' : + data.wrapper.css({ + width: Math.max(0, width-relX) + }); + this.css({ + position: 'relative', + left: -relX + }); + + data.fpage.css({ + left: -relX + width, + width: Math.max(0, relX-width) + }); + break; + case 'l' : + + data.wrapper.css({ + width: width + }); + this.css({ + position: 'relative', + left: relX + }); + + data.fpage.css({ + left: width, + width: Math.max(0, relX-width) + }); + + if (data.folding) + data.folding.css({ + position: 'relative', + left: -width*2 + relX + }); + + break; + } + + data.parent.css({'overflow': 'visible'}); + + data.point = point; + + }, + + _moveFoldingPage: function(bool) { + + var data = this.data().f; + + if (bool) { + + var folding = flipMethods._foldingPage.call(this), + turn = data.opts.turn; + + if (folding) { + + if (data.folding) { + if (data.folding===folding) + return; + flipMethods._moveFoldingPage.call(this, false); + } + + flipMethods.setData.call(this, + {backParent: folding.parent(), + folding: folding}); + + data.fpage.prepend(folding); + + } + + turn.turn('update'); + + } else { + if (data.backParent) { + data.backParent.prepend(data.folding); + delete data.backParent; + delete data.folding; + } + } + }, + + _showFoldedPage: function(c, animate) { + + var folding = flipMethods._foldingPage.call(this), + dd = this.data(), + data = dd.f, + visible = data.visible; + + if (!visible || !data.point || data.point.corner!=c.corner) { + + var mAction = data.opts.turn.data().mouseAction; + + var event = $.Event('start'); + this.trigger(event, [data.opts, c.corner]); + visible = false; + + if (event.isDefaultPrevented()) + return false; + + } + + if (folding) { + + 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]); + flipMethods._fold.call(that, c); + }}); + + } else { + + flipMethods._fold.call(this, c); + if (dd.effect && !dd.effect.turning) + this.animatef(false); + + } + + if (!visible) { + + data.visible = true; + flipMethods._moveFoldingPage.call(this, true); + data.fpage.show(); + } + + return true; + } + + return false; + }, + + hide: function() { + + var data = this.data().f, + folding = flipMethods._foldingPage.call(this); + + this.css({ + position: '', + left: 'auto' + }); + + data.wrapper.css({ + width: this.width() + }); + + data.fpage.css({ + width: this.width() + }); + + if (data.folding) + data.folding.css({ + position: '', + left: 'auto' + }); + + data.fpage.hide(); + + data.visible = false; + + return this; + }, + + hideFoldedPage: function(animate) { + + var data = this.data().f; + + if (!data.point) return; + + var that = this, + p1 = data.point, + hide = function() { + data.point = null; + that.flip('hide'); + that.trigger('end', [data.opts, false]); + }; + + if (animate) { + var p4 = flipMethods._c.call(this, p1.corner), + top = (p1.corner.substr(0,1)=='t'), + 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, + frame: function(v) { + var np = bezier(p1, p2, p3, p4, v); + p1.x = np.x; + p1.y = np.y; + flipMethods._fold.call(that, p1); + }, + complete: hide, + duration: 800, + hiding: true + }); + + } else { + this.animatef(false); + hide(); + } + }, + + turnPage: function(corner) { + + var that = this, + data = this.data().f; + + corner = {corner: (data.corner) ? + data.corner.corner : + corner || flipMethods._cAllowed.call(this)[0]}; + + var p1 = data.point || + flipMethods._c.call(this, + corner.corner, + (data.opts.turn) ? data.opts.turn.data().opts.elevation : 0), + p4 = flipMethods._c2.call(this, corner.corner); + + this.trigger('flip'). + animatef({ + from: 0, + to: 1, + frame: function(v) { + var np = bezier(p1, p1, p4, p4, v); + corner.x = np.x; + corner.y = np.y; + + flipMethods._showFoldedPage.call(that, corner); + }, + + complete: function() { + that.trigger('end', [data.opts, true]); + }, + duration: data.opts.duration, + turning: true + }); + + data.corner = null; + }, + + moving: function() { + + return 'effect' in this.data(); + + }, + + isTurning: function() { + + return this.flip('moving') && this.data().effect.turning; + + }, + + _eventStart: function(e) { + + var data = this.data().f; + + if (!data.disabled && !this.flip('isTurning')) { + + data.corner = flipMethods._cornerActivated.call(this, e); + + if (data.corner && flipMethods._foldingPage.call(this, data.corner)) { + + if (flipMethods._showFoldedPage.call(this, data.corner)) + this.trigger('pressed', [data.point]); + + return false; + + } else + data.corner = null; + + } + + }, + + _eventMove: function(e) { + + var data = this.data().f; + + if (!data.disabled) { + + e = (isTouch) ? e.originalEvent.touches : [e]; + + if (data.corner) { + + var pos = data.parent.offset(); + data.corner.x = e[0].pageX-pos.left; + data.corner.y = e[0].pageY-pos.top; + flipMethods._showFoldedPage.call(this, data.corner); + + } else if (!this.data().effect && this.is(':visible')) { + + + var corner = flipMethods._cornerActivated.call(this, e[0]); + + if (corner) { + var origin = flipMethods._c.call(this, corner.corner, data.opts.cornerSize/2); + corner.x = origin.x; + corner.y = origin.y; + flipMethods._showFoldedPage.call(this, corner, true); + } else + flipMethods.hideFoldedPage.call(this, true); + + + } + } + }, + + _eventEnd: function() { + + var data = this.data().f; + + if (!data.disabled && data.point) { + var event = $.Event('released'); + this.trigger(event, [data.point]); + if (!event.isDefaultPrevented()) + flipMethods.hideFoldedPage.call(this, true); + } + + data.corner = null; + + }, + + disable: function(disable) { + + flipMethods.setData.call(this, {'disabled': disable}); + return this; + + } +}; + + + +// Processes classes + +function decorator(that, methods, args) { + + if (!args[0] || typeof(args[0])=='object') + return methods.init.apply(that, args); + + else if (methods[args[0]]) + return methods[args[0]].apply(that, Array.prototype.slice.call(args, 1)); + + else + throw turnError(args[0] + ' is an invalid value'); +} + + +// Attributes for a layer + +function divAtt(top, left, zIndex, overf) { + + return {'css': { + position: 'absolute', + top: top, + left: left, + 'overflow': overf || 'hidden', + 'z-index': zIndex || 'auto' + } + }; + +} + +// Gets a 2D point from a bezier curve of four points + +function bezier(p1, p2, p3, p4, t) { + + var a = 1 - t, + b = a * a * a, + c = t * t * t; + + return point2D(Math.round(b*p1.x + 3*t*a*a*p2.x + 3*t*t*a*p3.x + c*p4.x), + Math.round(b*p1.y + 3*t*a*a*p2.y + 3*t*t*a*p3.y + c*p4.y)); + +} + +// Gets a 2D point + +function point2D(x, y) { + + return {x: x, y: y}; + +} + +// Checks if a property belongs to an object + +function has(property, object) { + + return Object.prototype.hasOwnProperty.call(object, property); + +} + +// Gets the CSS3 vendor prefix + +function getPrefix() { + + var vendorPrefixes = ['Moz','Webkit','Khtml','O','ms'], + len = vendorPrefixes.length, + vendor = ''; + + while (len--) + if ((vendorPrefixes[len] + 'Transform') in document.body.style) + vendor='-'+vendorPrefixes[len].toLowerCase()+'-'; + + return vendor; + +} + +// JS Errors + +function turnError(message) { + + function TurnJsError(message) { + this.name = "TurnJsError"; + this.message = message; + } + + TurnJsError.prototype = new Error(); + TurnJsError.prototype.constructor = TurnJsError; + + return new TurnJsError(message); +} + +// Find the offset of an element discarding its transformation + +function findPos(obj) { + var offset = {top: 0, left: 0}; + + do{ + offset.left += obj.offsetLeft; + offset.top += obj.offsetTop; + } while ((obj = obj.offsetParent)); + + return offset; +} + + +// Request an animation + +window.requestAnim = function(callback) { + window.setTimeout(callback, 1000 / 60); +} + + +function emptyFunction() { + return ''; +} + + +// Extend $.fn + +$.extend($.fn, { + + flip: function(req, opts) { + return decorator(this, flipMethods, arguments); + }, + + turn: function(req) { + return decorator(this, turnMethods, arguments); + }, + + transform: function(transform, origin) { + + var properties = {}; + + if (origin) + properties[vendor+'transform-origin'] = origin; + + properties[vendor+'transform'] = transform; + + return this.css(properties); + + }, + + animatef: function(point) { + + var data = this.data(); + + if (data.effect) + data.effect.stop(); + + if (point) { + + if (!point.to.length) point.to = [point.to]; + if (!point.from.length) point.from = [point.from]; + + var diff = [], + len = point.to.length, + animating = true, + that = this, + time = (new Date()).getTime(), + frame = function() { + + if (!data.effect || !animating) + return; + + var v = [], + timeDiff = Math.min(point.duration, (new Date()).getTime() - time); + + for (var i = 0; i < len; i++) + v.push(data.effect.easing(1, timeDiff, point.from[i], diff[i], point.duration)); + + point.frame((len==1) ? v[0] : v); + + if (timeDiff==point.duration) { + delete data['effect']; + that.data(data); + if (point.complete) + point.complete(); + } else { + window.requestAnim(frame); + } + }; + + for (var i = 0; i < len; i++) + diff.push(point.to[i] - point.from[i]); + + data.effect = $.extend({ + stop: function() { + animating = false; + }, + easing: function (x, t, b, c, data) { + return c * Math.sqrt(1 - (t=t/data-1)*t) + b; + } + }, point); + + this.data(data); + + frame(); + + } else { + + delete data['effect']; + + } + } +}); + +// Export some globals + +$.isTouch = isTouch; +$.mouseEvents = mouseEvents; +$.cssPrefix = emptyFunction; +$.cssTransitionEnd = emptyFunction; +$.findPos = findPos; + +})(jQuery); \ No newline at end of file diff --git a/lib/turn.html4.min.js b/lib/turn.html4.min.js new file mode 100644 index 0000000..56d97a8 --- /dev/null +++ b/lib/turn.html4.min.js @@ -0,0 +1,48 @@ +/* turn.js 4.1.0 | Copyright (c) 2012 Emmanuel Garcia | turnjs.com | turnjs.com/license.txt */ + +(function(f){function s(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 k(c[0]+" is an invalid value");}function q(a,b,c,d){return{css:{position:"absolute",top:a,left:b,overflow:d||"hidden","z-index":c||"auto"}}}function t(a,b,c,d,e){var g=1-e,f=g*g*g,l=e*e*e;return m(Math.round(f*a.x+3*e*g*g*b.x+3*e*e*g*c.x+l*d.x),Math.round(f*a.y+3*e*g*g*b.y+3*e*e*g*c.y+l*d.y))}function m(a,b){return{x:a,y:b}}function j(a,b){return Object.prototype.hasOwnProperty.call(b, +a)}function k(a){function b(a){this.name="TurnJsError";this.message=a}b.prototype=Error();b.prototype.constructor=b;return new b(a)}function v(){return""}var r="",n={down:"mousedown",move:"mousemove",up:"mouseup",over:"mouseover",out:"mouseout"},p={backward:["l"],forward:["r"],all:["l","r"]},x=["single","double"],y=["ltr","rtl"],z={acceleration:!0,display:"double",duration:600,page:1,gradients:!0,when:null},A={acceleration:!0,corners:"forward",cornerSize:100,duration:600,gradients:!0},i={init:function(a){if(1< +this.length)throw k("This selector has more than 1 element");for(var b=["Moz","Webkit","Khtml","O","ms"],c=b.length,d="";c--;)b[c]+"Transform"in document.body.style&&(d="-"+b[c].toLowerCase()+"-");r=d;var e,b=0,g=this.data(),c=this.children(),a=f.extend({width:this.width(),height:this.height(),direction:this.attr("dir")||this.css("direction")||"ltr"},z,a);g.opts=a;g.pageObjs={};g.pages={};g.pageWrap={};g.pagePlace={};g.pageMv=[];g.zoom=1;g.totalPages=a.pages||0;g.docEvents={mouseStart:function(a){for(var b in g.pages)if(j(b, +g.pages)&&!1===h._eventStart.call(g.pages[b],a))return!1},mouseMove:function(a){for(var b in g.pages)j(b,g.pages)&&h._eventMove.call(g.pages[b],a)},mouseEnd:function(a){for(var b in g.pages)j(b,g.pages)&&h._eventEnd.call(g.pages[b],a)}};if(a.when)for(e in a.when)j(e,a.when)&&this.bind(e,a.when[e]);this.css({position:"relative",width:a.width,height:a.height});this.turn("display",a.display);""!==a.direction&&this.turn("direction",a.direction);for(e=0;eg)throw k('Page "'+ +b+'" cannot be inserted');}else b=g,d=!0;1<=b&&b<=g&&(c="double"==e.display?b%2?" odd":" even":"",e.done&&this.turn("stop"),b in e.pageObjs&&i._movePages.call(this,b,1),d&&(e.totalPages=g),e.pageObjs[b]=f(a).css({"float":"left"}).addClass("page p"+b+c),i._addPage.call(this,b),e.done&&this.turn("update"),i._removeFromDOM.call(this));return this},_addPage:function(a){var b=this.data(),c=b.pageObjs[a];if(c)if(i._necessPage.call(this,a)){if(!b.pageWrap[a]){var d=i._pageSize.call(this,a,!0);c.css({width:d.width, +height:d.height});b.pagePlace[a]=a;b.pageWrap[a]=f("
",{"class":"turn-page-wrapper",page:a,css:{position:"absolute",overflow:"hidden"}}).css(d);this.append(b.pageWrap[a]);b.pageWrap[a].prepend(b.pageObjs[a])}(!a||1==i._setPageLoc.call(this,a))&&i._makeFlip.call(this,a)}else b.pagePlace[a]=0,b.pageObjs[a]&&b.pageObjs[a].remove()},hasPage:function(a){return j(a,this.data().pageObjs)},center:function(a){var b=this.data(),c=f(this).turn("size"),d=c.width/(2*b.zoom)-c.width/2;"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.data();a.destroying=!0;f(this).unbind(n.down).unbind("end").unbind("first").unbind("flip").unbind("last").unbind("pressed").unbind("released").unbind("start").unbind("turning").unbind("turned").unbind("zooming");for(f(document).unbind(n.move,a.docEvents.mouseMove).unbind(n.up,a.docEvents.mouseEnd);0!== +a.totalPages;)this.turn("removePage",a.totalPages);a.fparent&&a.fparent.remove();a.shadow&&a.shadow.remove();this.removeData();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++)i._addPage.call(this,a)}},range:function(a){var b,c,d,e=this.data(),a=a||e.tpage||e.page||1;d=i._view.call(this,a);if(1>a||a>e.totalPages)throw k('"'+a+'" is not a page for range');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.data(),c=this.turn("range");return b.pageObjs[a].hasClass("fixed")||a>=c[0]&&a<=c[1]},_removeFromDOM:function(){var a,b=this.data();for(a in b.pageWrap)j(a,b.pageWrap)&&!i._necessPage.call(this,a)&&i._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]);delete b.pagePlace[a]},removePage:function(a){var b=this.data();if(1>a||a>b.totalPages)throw k("The page "+a+" doesn't exist");b.pageObjs[a]&&(this.turn("stop"),i._removePageFromDOM.call(this,a),delete b.pageObjs[a]);i._movePages.call(this,a,-1);b.totalPages-=1;b.page>b.totalPages?this.turn("page",b.totalPages):i._makeRange.call(this);return this},_movePages:function(a, +b){var c,d=this,e=this.data(),g="single"==e.display,f=function(a){var c=a+b,f=c%2,h=f?" odd ":" even ";e.pageObjs[a]&&(e.pageObjs[c]=e.pageObjs[a].removeClass("p"+a+" odd even").addClass("p"+c+h));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(i._pageSize.call(d,c,!0)).attr("page",c),e.pages[a]&&(e.pages[c]=e.pages[a].flip("options",{page:c,next:g||f?c+1:c-1,corners:g?"all":f?"forward":"backward"})),b&& +(delete e.pages[a],delete e.pagePlace[a],delete e.pageObjs[a],delete e.pageWrap[a],delete e.pageObjs[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(a){if(-1==f.inArray(a,x))throw k('"'+a+'" is not a value for display');"single"==a?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)):b.pageObjs[0]&& +(this.turn("stop").css({overflow:""}),b.pageObjs[0].remove(),delete b.pageObjs[0]);b.display=a;c&&(a=this.turn("size"),i._movePages.call(this,1,0),this.turn("size",a.width,a.height).turn("update"));return this}return c},direction:function(a){var b=this.data();if("undefined"==typeof a)return b.direction;a=a.toLowerCase();if(-1==f.inArray(a,y))throw k('"'+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&&this.turn("page",a)}b.totalPages=a;return this}return b.totalPages}, +_missing:function(a){for(var b=this.data(),c=this.turn("range",a),d=[],a=c[0];a<=c[1];a++)b.pageObjs[a]||d.push(a);0h[1]?(c=h[1],d=l[0]):h[0]&&ah[0]?"r":"l"):e.pages[c].flip("turnPage",l[0]>h[0]?"l":"r"):e.pages[c].flip("turnPage"))},page:function(a){var a=parseInt(a,10),b=this.data();return 0b.page?b.next:b.page+1),i._addMotionPage.call(a.target));i._updateShadow.call(b.turn)}, +_end:function(a,b,c){f(a.target).data();var a=b.turn,d=a.data();if(c||d.tpage){if(d.tpage==b.next||d.tpage==b.page)delete d.tpage,i._fitPage.call(a,d.tpage||b.next,!0)}else i._removeMv.call(a,b.page),i._updateShadow.call(a),a.turn("update")},_pressed:function(a){a.stopPropagation();var b,a=f(a.target).data().f,c=a.opts.turn.data().pages;for(b in c)b!=a.opts.page&&c[b].flip("disable",!0);return a.time=(new Date).getTime()},_released:function(a,b){a.stopPropagation();var c,d=f(a.target),e=d.data().f, +g=e.opts.turn,u=g.data();c="single"==u.display?"r"==b.corner?b.xd.width()/2:0>b.x||b.x>d.width();if(200>(new Date).getTime()-e.time||c)a.preventDefault(),i._turnPage.call(g,e.opts.next,!1===h._cornerActivated.call(d,b,1));u.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)},calculateZ:function(a){var b,c,d,e,g=this,f=this.data();b=this.turn("view");var h=b[0]|| +b[1],i={pageZ:{},partZ:{},pageV:{}},j=function(a){a=g.turn("view",a);a[0]&&(i.pageV[a[0]]=!0);a[1]&&(i.pageV[a[1]]=!0)};for(b=0;b",{"class":"shadow",css:q(0,0,0).css}).appendTo(this));for(var h=0;h=a.x||0>=a.y||a.x>=d||a.y>=e)return!1;e=h._cAllowed.call(this);if(a.x>d-b)a.corner="r";else if(a.x",q(0,0,2)).css(c).appendTo(b).prepend(this);a.fpage=f("
",q(0,0,1)).css(c).appendTo(b)}h.resize.call(this,!0)},_fold:function(a){var b=this.data().f,c=h._c.call(this,a.corner),c=c.x?c.x-a.x:a.x,d=this.width();this.height();c=Math.min(2*d,Math.max(0,c));switch(a.corner){case "r":b.wrapper.css({width:Math.max(0,d-c)});this.css({position:"relative", +left:-c});b.fpage.css({left:-c+d,width:Math.max(0,c-d)});break;case "l":b.wrapper.css({width:d}),this.css({position:"relative",left:c}),b.fpage.css({left:d,width:Math.max(0,c-d)}),b.folding&&b.folding.css({position:"relative",left:2*-d+c})}b.parent.css({overflow:"visible"});b.point=a},_moveFoldingPage:function(a){var b=this.data().f;if(a){var a=h._foldingPage.call(this),c=b.opts.turn;if(a){if(b.folding){if(b.folding===a)return;h._moveFoldingPage.call(this,!1)}h.setData.call(this,{backParent:a.parent(), +folding:a});b.fpage.prepend(a)}c.turn("update")}else b.backParent&&(b.backParent.prepend(b.folding),delete b.backParent,delete b.folding)},_showFoldedPage:function(a,b){var c=h._foldingPage.call(this),d=this.data(),e=d.f,g=e.visible;if(!g||!e.point||e.point.corner!=a.corner){e.opts.turn.data();var i=f.Event("start");this.trigger(i,[e.opts,a.corner]);g=!1;if(i.isDefaultPrevented())return!1}if(c){if(b){var l=this,c=e.point&&e.point.corner==a.corner?e.point:h._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]);h._fold.call(l,a)}})}else h._fold.call(this,a),d.effect&&!d.effect.turning&&this.animatef(!1);g||(e.visible=!0,h._moveFoldingPage.call(this,!0),e.fpage.show());return!0}return!1},hide:function(){var a=this.data().f;h._foldingPage.call(this);this.css({position:"",left:"auto"});a.wrapper.css({width:this.width()});a.fpage.css({width:this.width()});a.folding&&a.folding.css({position:"",left:"auto"});a.fpage.hide(); +a.visible=!1;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",[b.opts,!1])};if(a){var g=h._c.call(this,d.corner),a="t"==d.corner.substr(0,1)?Math.min(0,d.y-g.y)/2:Math.max(0,d.y-g.y)/2,f=m(d.x,d.y+a),i=m(g.x,g.y-a);this.animatef({from:0,to:1,frame:function(a){a=t(d,f,i,g,a);d.x=a.x;d.y=a.y;h._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||h._cAllowed.call(this)[0]},d=c.point||h._c.call(this,a.corner,c.opts.turn?c.opts.turn.data().opts.elevation:0),e=h._c2.call(this,a.corner);this.trigger("flip").animatef({from:0,to:1,frame:function(c){c=t(d,d,e,e,c);a.x=c.x;a.y=c.y;h._showFoldedPage.call(b,a)},complete:function(){b.trigger("end",[c.opts,!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=h._cornerActivated.call(this,a);if(b.corner&&h._foldingPage.call(this,b.corner))return h._showFoldedPage.call(this,b.corner)&&this.trigger("pressed",[b.point]),!1;b.corner=null}},_eventMove:function(a){var b=this.data().f;if(!b.disabled)if(a=[a],b.corner){var c=b.parent.offset();b.corner.x=a[0].pageX-c.left;b.corner.y=a[0].pageY-c.top;h._showFoldedPage.call(this,b.corner)}else!this.data().effect&& +this.is(":visible")&&((a=h._cornerActivated.call(this,a[0]))?(b=h._c.call(this,a.corner,b.opts.cornerSize/2),a.x=b.x,a.y=b.y,h._showFoldedPage.call(this,a,!0)):h.hideFoldedPage.call(this,!0))},_eventEnd:function(){var a=this.data().f;if(!a.disabled&&a.point){var b=f.Event("released");this.trigger(b,[a.point]);b.isDefaultPrevented()||h.hideFoldedPage.call(this,!0)}a.corner=null},disable:function(a){h.setData.call(this,{disabled:a});return this}};window.requestAnim=function(a){window.setTimeout(a,1E3/ +60)};f.extend(f.fn,{flip:function(a,b){return s(this,h,arguments)},turn:function(a){return s(this,i,arguments)},transform:function(a,b){var c={};b&&(c[r+"transform-origin"]=b);c[r+"transform"]=a;return this.css(c)},animatef:function(a){var b=this.data();b.effect&&b.effect.stop();if(a){a.to.length||(a.to=[a.to]);a.from.length||(a.from=[a.from]);for(var c=[],d=a.to.length,e=!0,g=this,h=(new Date).getTime(),i=function(){if(b.effect&&e){for(var f=[],j=Math.min(a.duration,(new Date).getTime()-h),k=0;k< +d;k++)f.push(b.effect.easing(1,j,a.from[k],c[k],a.duration));a.frame(1==d?f[0]:f);j==a.duration?(delete b.effect,g.data(b),a.complete&&a.complete()):window.requestAnim(i)}},j=0;jlastPage) + throw turnError('Page "'+page+'" cannot be inserted'); + + } else { + + page = lastPage; + incPages = true; + + } + + if (page>=1 && page<=lastPage) { + + if (data.display=='double') + className = (page%2) ? ' odd' : ' even'; + else + className = ''; + + // Stop animations + if (data.done) + this.turn('stop'); + + // Move pages if it's necessary + if (page in data.pageObjs) + turnMethods._movePages.call(this, page, 1); + + // Increase the number of pages + if (incPages) + data.totalPages = lastPage; + + // Add element + data.pageObjs[page] = $(element). + css({'float': 'left'}). + addClass('page p' + page + className); + + if (!hasHardPage() && data.pageObjs[page].hasClass('hard')) { + data.pageObjs[page].removeClass('hard'); + } + + // Add page + turnMethods._addPage.call(this, page); + + // Remove pages out of range + turnMethods._removeFromDOM.call(this); + } + + return this; + }, + + // Adds a page + + _addPage: function(page) { + + var data = this.data(), + element = data.pageObjs[page]; + + if (element) + if (turnMethods._necessPage.call(this, page)) { + + if (!data.pageWrap[page]) { + + // Wrapper + data.pageWrap[page] = $('
', + {'class': 'page-wrapper', + page: page, + css: {position: 'absolute', + overflow: 'hidden'}}); + + // Append to this flipbook + this.append(data.pageWrap[page]); + + if (!data.pagePlace[page]) { + + data.pagePlace[page] = page; + // Move `pageObjs[page]` to wrapper + data.pageObjs[page].appendTo(data.pageWrap[page]); + + } + + // Set the size of the page + var prop = turnMethods._pageSize.call(this, page, true); + element.css({width: prop.width, height: prop.height}); + data.pageWrap[page].css(prop); + + } + + if (data.pagePlace[page] == page) { + + // If the page isn't in another place, create the flip effect + turnMethods._makeFlip.call(this, page); + + } + + } else { + + // Place + data.pagePlace[page] = 0; + + // Remove element from the DOM + if (data.pageObjs[page]) + data.pageObjs[page].remove(); + + } + + }, + + // Checks if a page is in memory + + hasPage: function(page) { + + return has(page, this.data().pageObjs); + + }, + + // Centers the flipbook + + center: function(page) { + + var data = this.data(), + size = $(this).turn('size'), + left = 0; + + if (!data.noCenter) { + if (data.display=='double') { + var view = this.turn('view', page || data.tpage || data.page); + + if (data.direction=='ltr') { + if (!view[0]) + left -= size.width/4; + else if (!view[1]) + left += size.width/4; + } else { + if (!view[0]) + left += size.width/4; + else if (!view[1]) + left -= size.width/4; + } + + } + + $(this).css({marginLeft: left}); + } + + return this; + + }, + + // Destroys the flipbook + + destroy: function () { + + var page, + flipbook = this, + data = this.data(), + events = [ + 'end', 'first', 'flip', 'last', 'pressed', + 'released', 'start', 'turning', 'turned', + 'zooming', 'missing']; + + if (trigger('destroying', this)=='prevented') + return; + + data.destroying = true; + + $.each(events, function(index, eventName) { + flipbook.unbind(eventName); + }); + + this.parent().unbind('start', data.eventHandlers.start); + + $(document).unbind(mouseEvents.move, data.eventHandlers.touchMove). + unbind(mouseEvents.up, data.eventHandlers.touchEnd); + + while (data.totalPages!==0) { + this.turn('removePage', data.totalPages); + } + + if (data.fparent) + data.fparent.remove(); + + if (data.shadow) + data.shadow.remove(); + + this.removeData(); + data = null; + + return this; + + }, + + // Checks if this element is a flipbook + + is: function() { + + return typeof(this.data().pages)=='object'; + + }, + + // Sets and gets the zoom value + + zoom: function(newZoom) { + + var data = this.data(); + + if (typeof(newZoom)=='number') { + + if (newZoom<0.001 || newZoom>100) + throw turnError(newZoom+ ' is not a value for zoom'); + + if (trigger('zooming', this, [newZoom, data.zoom])=='prevented') + return this; + + var size = this.turn('size'), + currentView = this.turn('view'), + iz = 1/data.zoom, + newWidth = Math.round(size.width * iz * newZoom), + newHeight = Math.round(size.height * iz * newZoom); + + data.zoom = newZoom; + + $(this).turn('stop'). + turn('size', newWidth, newHeight); + /*. + css({marginTop: size.height * iz / 2 - newHeight / 2});*/ + + if (data.opts.autoCenter) + this.turn('center'); + /*else + $(this).css({marginLeft: size.width * iz / 2 - newWidth / 2});*/ + + turnMethods._updateShadow.call(this); + + for (var i = 0; idata.totalPages) + throw turnError('"'+page+'" is not a valid page'); + + + view[1] = view[1] || view[0]; + + if (view[0]>=1 && view[1]<=data.totalPages) { + + remainingPages = Math.floor((pagesInDOM-2)/2); + + if (data.totalPages-view[1] > view[0]) { + left = Math.min(view[0]-1, remainingPages); + right = 2*remainingPages-left; + } else { + right = Math.min(data.totalPages-view[1], remainingPages); + left = 2*remainingPages-right; + } + + } else { + left = pagesInDOM-1; + right = pagesInDOM-1; + } + + return [Math.max(1, view[0]-left), + Math.min(data.totalPages, view[1]+right)]; + + }, + + // 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 this.data().pageObjs[page].hasClass('fixed') || + (page>=range[0] && page<=range[1]); + + }, + + // Releases memory by removing pages from the DOM + + _removeFromDOM: function() { + + var page, data = this.data(); + + for (page in data.pageWrap) + if (has(page, data.pageWrap) && + !turnMethods._necessPage.call(this, page)) + turnMethods._removePageFromDOM.call(this, page); + + }, + + // Removes a page from DOM and its internal references + + _removePageFromDOM: function(page) { + + var data = this.data(); + + if (data.pages[page]) { + var dd = data.pages[page].data(); + + flipMethods._moveFoldingPage.call(data.pages[page], false); + + if (dd.f && dd.f.fwrapper) + dd.f.fwrapper.remove(); + + data.pages[page].removeData(); + data.pages[page].remove(); + delete data.pages[page]; + } + + if (data.pageObjs[page]) + data.pageObjs[page].remove(); + + if (data.pageWrap[page]) { + data.pageWrap[page].remove(); + delete data.pageWrap[page]; + } + + turnMethods._removeMv.call(this, page); + + delete data.pagePlace[page]; + delete data.pageZoom[page]; + + }, + + // Removes a page + + removePage: function(page) { + + var data = this.data(); + + // Delete all the pages + if (page=='*') { + + while (data.totalPages!==0) { + this.turn('removePage', data.totalPages); + } + + } else { + + if (page<1 || page>data.totalPages) + throw turnError('The page '+ page + ' doesn\'t exist'); + + if (data.pageObjs[page]) { + + // Stop animations + this.turn('stop'); + + // Remove `page` + turnMethods._removePageFromDOM.call(this, page); + + delete data.pageObjs[page]; + + } + + // Move the pages + turnMethods._movePages.call(this, page, -1); + + // Resize the size of this flipbook + data.totalPages = data.totalPages-1; + + // Check the current view + + if (data.page>data.totalPages) { + + data.page = null; + turnMethods._fitPage.call(this, data.totalPages); + + } else { + + turnMethods._makeRange.call(this); + this.turn('update'); + + } + } + + return this; + + }, + + // Moves pages + + _movePages: function(from, change) { + + var page, + that = this, + data = this.data(), + single = data.display=='single', + move = function(page) { + + var next = page + change, + odd = next%2, + className = (odd) ? ' odd ' : ' even '; + + if (data.pageObjs[page]) + data.pageObjs[next] = data.pageObjs[page]. + removeClass('p' + page + ' odd even'). + addClass('p' + next + className); + + if (data.pagePlace[page] && data.pageWrap[page]) { + + data.pagePlace[next] = next; + + if (data.pageObjs[next].hasClass('fixed')) + data.pageWrap[next] = data.pageWrap[page]. + attr('page', next); + else + data.pageWrap[next] = data.pageWrap[page]. + css(turnMethods._pageSize.call(that, next, true)). + attr('page', next); + + if (data.pages[page]) + data.pages[next] = data.pages[page]. + flip('options', { + page: next, + next: (single || odd) ? next+1 : next-1 + }); + + if (change) { + delete data.pages[page]; + delete data.pagePlace[page]; + delete data.pageZoom[page]; + delete data.pageObjs[page]; + delete data.pageWrap[page]; + } + + } + + }; + + if (change>0) + for (page=data.totalPages; page>=from; page--) + move(page); + else + for (page=from; page<=data.totalPages; page++) + move(page); + + }, + + // Sets or Gets the display mode + + display: function(display) { + + var data = this.data(), + currentDisplay = data.display; + + if (display===undefined) { + + return currentDisplay; + + } else { + + if ($.inArray(display, displays)==-1) + throw turnError('"'+display + '" is not a value for display'); + + switch(display) { + case 'single': + + // Create a temporal page to use as folded page + + if (!data.pageObjs[0]) { + this.turn('stop'). + css({'overflow': 'hidden'}); + + data.pageObjs[0] = $('
', + {'class': 'page p-temporal'}). + css({width: this.width(), height: this.height()}). + appendTo(this); + } + + this.addClass('shadow'); + + break; + case 'double': + + // Remove the temporal page + + if (data.pageObjs[0]) { + this.turn('stop').css({'overflow': ''}); + data.pageObjs[0].remove(); + delete data.pageObjs[0]; + } + + this.removeClass('shadow'); + + break; + } + + + data.display = display; + + if (currentDisplay) { + var size = this.turn('size'); + turnMethods._movePages.call(this, 1, 0); + this.turn('size', size.width, size.height). + turn('update'); + } + + return this; + + } + + }, + + // Gets and sets the direction of the flipbook + + direction: function(dir) { + + var data = this.data(); + + if (dir===undefined) { + + return data.direction; + + } else { + + dir = dir.toLowerCase(); + + if ($.inArray(dir, directions)==-1) + throw turnError('"' + dir + '" is not a value for direction'); + + if (dir=='rtl') { + $(this).attr('dir', 'ltr'). + css({direction: 'ltr'}); + } + + data.direction = dir; + + if (data.done) + this.turn('size', $(this).width(), $(this).height()); + + return this; + } + + }, + + // Detects animation + + animating: function() { + + return this.data().pageMv.length>0; + + }, + + // Gets the current activated corner + + corner: function() { + + var corner, + page, + data = this.data(); + + for (page in data.pages) { + if (has(page, data.pages)) + if ((corner = data.pages[page].flip('corner'))) { + return corner; + } + } + + return false; + }, + + // Gets the data stored in the flipbook + + data: function() { + + return this.data(); + + }, + + // Disables and enables the effect + + disable: function(disable) { + + var page, + data = this.data(), + view = this.turn('view'); + + data.disabled = disable===undefined || disable===true; + + for (page in data.pages) { + if (has(page, data.pages)) + data.pages[page].flip('disable', + (data.disabled) ? true : $.inArray(parseInt(page, 10), view)==-1); + } + + return this; + + }, + + // Disables and enables the effect + + disabled: function(disable) { + + if (disable===undefined) { + return this.data().disabled===true; + } else { + return this.turn('disable', disable); + } + + }, + + // Gets and sets the size + + size: function(width, height) { + + if (width===undefined || height===undefined) { + + return {width: this.width(), height: this.height()}; + + } else { + + this.turn('stop'); + + var page, prop, + data = this.data(), + pageWidth = (data.display=='double') ? width/2 : width; + + this.css({width: width, height: height}); + + if (data.pageObjs[0]) + data.pageObjs[0].css({width: pageWidth, height: height}); + + for (page in data.pageWrap) { + if (!has(page, data.pageWrap)) continue; + + prop = turnMethods._pageSize.call(this, page, true); + + data.pageObjs[page].css({width: prop.width, height: prop.height}); + data.pageWrap[page].css(prop); + + if (data.pages[page]) + data.pages[page].css({width: prop.width, height: prop.height}); + } + + this.turn('resize'); + + return this; + + } + }, + + // Resizes each page + + resize: function() { + + var page, data = this.data(); + + if (data.pages[0]) { + data.pageWrap[0].css({left: -this.width()}); + data.pages[0].flip('resize', true); + } + + for (page = 1; page <= data.totalPages; page++) + if (data.pages[page]) + data.pages[page].flip('resize', true); + + turnMethods._updateShadow.call(this); + + if (data.opts.autoCenter) + this.turn('center'); + + }, + + // Removes an animation from the cache + + _removeMv: function(page) { + + var i, data = this.data(); + + for (i=0; i0) ? view[0] : 0, + (view[1]<=data.totalPages) ? view[1] : 0]; + else + return [(view[0]>0 && view[0]<=data.totalPages) ? view[0] : 0]; + + }, + + // Stops animations + + stop: function(ignore, animate) { + + if (this.turn('animating')) { + + var i, opts, page, + data = this.data(); + + if (data.tpage) { + data.page = data.tpage; + delete data['tpage']; + } + + for (i = 0; ipages; page--) + this.turn('removePage', page); + + } + + data.totalPages = pages; + turnMethods._fitPage.call(this, data.page); + + return this; + + } else + return data.totalPages; + + }, + + // Checks missing pages + + _missing : function(page) { + + var data = this.data(); + + if (data.totalPages<1) + return; + + var p, + range = this.turn('range', page), + missing = []; + + for (p = range[0]; p<=range[1]; p++) { + if (!data.pageObjs[p]) + missing.push(p); + } + + if (missing.length>0) + this.trigger('missing', [missing]); + + }, + + // Sets a page without effect + + _fitPage: function(page) { + + var data = this.data(), + newView = this.turn('view', page); + + turnMethods._missing.call(this, page); + + if (!data.pageObjs[page]) + return; + + data.page = page; + + this.turn('stop'); + + for (var i = 0; iview[1]) { + current = view[1]; + next = newView[0]; + } else if (view[0] && pagecurrent) ? 'r' : 'l'); + else + data.pages[current].flip('turnPage', + (page>current) ? 'l' : 'r'); + else { + if (data.direction=='ltr') + data.pages[current].flip('turnPage', + optsCorners[(page>current) ? 1 : 0]); + else + data.pages[current].flip('turnPage', + optsCorners[(page>current) ? 0 : 1]); + } + + }, + + // Gets and sets a page + + page: function(page) { + + var data = this.data(); + + if (page===undefined) { + + return data.page; + + } else { + + if (!data.disabled && !data.destroying) { + + page = parseInt(page, 10); + + if (page>0 && page<=data.totalPages) { + + if (page!=data.page) { + if (!data.done || $.inArray(page, this.turn('view'))!=-1) + turnMethods._fitPage.call(this, page); + else + turnMethods._turnPage.call(this, page); + } + + return this; + + } else { + + throw turnError('The page ' + page + ' does not exist'); + + } + + } + + } + + }, + + // Turns to the next view + + next: function() { + + return this.turn('page', Math.min(this.data().totalPages, + turnMethods._view.call(this, this.data().page).pop() + 1)); + + }, + + // Turns to the previous view + + previous: function() { + + return this.turn('page', Math.max(1, + turnMethods._view.call(this, this.data().page).shift() - 1)); + + }, + + // Shows a peeling corner + + peel: function(corner, animate) { + + var data = this.data(), + view = this.turn('view'); + + animate = (animate===undefined) ? true : animate===true; + + if (corner===false) { + + this.turn('stop', null, animate); + + } else { + + if (data.display=='single') { + + data.pages[data.page].flip('peel', corner, animate); + + } else { + + var page; + + if (data.direction=='ltr') { + + page = (corner.indexOf('l')!=-1) ? view[0] : view[1]; + + } else { + + page = (corner.indexOf('l')!=-1) ? view[1] : view[0]; + + } + + if (data.pages[page]) + data.pages[page].flip('peel', corner, animate); + + } + } + + return this; + + }, + + // Adds a motion to the internal list + // This event is called in context of flip + + _addMotionPage: function() { + + var opts = $(this).data().f.opts, + turn = opts.turn, + dd = turn.data(); + + turnMethods._addMv.call(turn, opts.page); + + }, + + // This event is called in context of flip + + _eventStart: function(e, opts, corner) { + + var data = opts.turn.data(), + actualZoom = data.pageZoom[opts.page]; + + if (e.isDefaultPrevented()) { + turnMethods._updateShadow.call(opts.turn); + return; + } + + if (actualZoom && actualZoom!=data.zoom) { + + opts.turn.trigger('zoomed',[ + opts.page, + opts.turn.turn('view', opts.page), + actualZoom, + data.zoom]); + + data.pageZoom[opts.page] = data.zoom; + + } + + if (data.display=='single' && corner) { + + if ((corner.charAt(1)=='l' && data.direction=='ltr') || + (corner.charAt(1)=='r' && data.direction=='rtl')) + { + + opts.next = (opts.nextopts.page) ? opts.next : opts.page+1; + + } + + } + + turnMethods._addMotionPage.call(e.target); + turnMethods._updateShadow.call(opts.turn); + }, + + // This event is called in context of flip + + _eventEnd: function(e, opts, turned) { + + var that = $(e.target), + data = that.data().f, + turn = opts.turn, + dd = turn.data(); + + if (turned) { + + var tpage = dd.tpage || dd.page; + + if (tpage==opts.next || tpage==opts.page) { + delete dd.tpage; + + turnMethods._fitPage.call(turn, tpage || opts.next, true); + } + + } else { + + turnMethods._removeMv.call(turn, opts.page); + turnMethods._updateShadow.call(turn); + turn.turn('update'); + + } + + }, + + // This event is called in context of flip + + _eventPressed: function(e) { + + var page, + data = $(e.target).data().f, + turn = data.opts.turn, + turnData = turn.data(), + pages = turnData.pages; + + turnData.mouseAction = true; + + turn.turn('update'); + + return data.time = new Date().getTime(); + + }, + + // This event is called in context of flip + + _eventReleased: function(e, point) { + + var outArea, + page = $(e.target), + data = page.data().f, + turn = data.opts.turn, + turnData = turn.data(); + + if (turnData.display=='single') { + outArea = (point.corner=='br' || point.corner=='tr') ? + point.xpage.width()/2; + } else { + outArea = point.x<0 || point.x>page.width(); + } + + if ((new Date()).getTime()-data.time<200 || outArea) { + + e.preventDefault(); + turnMethods._turnPage.call(turn, data.opts.next); + + } + + turnData.mouseAction = false; + + }, + + // This event is called in context of flip + + _flip: function(e) { + + e.stopPropagation(); + + var opts = $(e.target).data().f.opts; + + opts.turn.trigger('turn', [opts.next]); + + if (opts.turn.data().opts.autoCenter) { + opts.turn.turn('center', opts.next); + } + + }, + + // + _touchStart: function() { + var data = this.data(); + for (var page in data.pages) { + if (has(page, data.pages) && + flipMethods._eventStart.apply(data.pages[page], arguments)===false) { + return false; + } + } + }, + + // + _touchMove: function() { + var data = this.data(); + for (var page in data.pages) { + if (has(page, data.pages)) { + flipMethods._eventMove.apply(data.pages[page], arguments); + } + } + }, + + // + _touchEnd: function() { + var data = this.data(); + for (var page in data.pages) { + if (has(page, data.pages)) { + flipMethods._eventEnd.apply(data.pages[page], arguments); + } + } + }, + + // Calculate the z-index value for pages during the animation + + calculateZ: function(mv) { + + var i, page, nextPage, placePage, dpage, + that = this, + data = this.data(), + view = this.turn('view'), + currentPage = view[0] || view[1], + total = mv.length-1, + r = {pageZ: {}, partZ: {}, pageV: {}}, + + addView = function(page) { + var view = that.turn('view', page); + if (view[0]) r.pageV[view[0]] = true; + if (view[1]) r.pageV[view[1]] = true; + }; + + for (i = 0; i<=total; i++) { + page = mv[i]; + nextPage = data.pages[page].data().f.opts.next; + placePage = data.pagePlace[page]; + addView(page); + addView(nextPage); + dpage = (data.pagePlace[nextPage]==nextPage) ? nextPage : page; + r.pageZ[dpage] = data.totalPages - Math.abs(currentPage-dpage); + r.partZ[placePage] = data.totalPages*2 - total + i; + } + + return r; + }, + + // Updates the z-index and display property of every page + + update: function() { + + var page, + data = this.data(); + + if (this.turn('animating') && data.pageMv[0]!==0) { + + // Update motion + + var p, apage, fixed, + pos = this.turn('calculateZ', data.pageMv), + corner = this.turn('corner'), + actualView = this.turn('view'), + newView = this.turn('view', data.tpage); + + for (page in data.pageWrap) { + + if (!has(page, data.pageWrap)) + continue; + + fixed = data.pageObjs[page].hasClass('fixed'); + + data.pageWrap[page].css({ + display: (pos.pageV[page] || fixed) ? '' : 'none', + zIndex: + (data.pageObjs[page].hasClass('hard') ? + pos.partZ[page] + : + pos.pageZ[page] + ) || (fixed ? -1 : 0) + }); + + if ((p = data.pages[page])) { + + p.flip('z', pos.partZ[page] || null); + + if (pos.pageV[page]) + p.flip('resize'); + + if (data.tpage) { // Is it turning the page to `tpage`? + + p.flip('hover', false). + flip('disable', + $.inArray(parseInt(page, 10), data.pageMv)==-1 && + page!=newView[0] && + page!=newView[1]); + + } else { + + p.flip('hover', corner===false). + flip('disable', page!=actualView[0] && page!=actualView[1]); + + } + + } + + } + + } else { + + // Update static pages + + for (page in data.pageWrap) { + + if (!has(page, data.pageWrap)) + continue; + + var pageLocation = turnMethods._setPageLoc.call(this, page); + + if (data.pages[page]) { + data.pages[page]. + flip('disable', data.disabled || pageLocation!=1). + flip('hover', true). + flip('z', null); + } + } + } + + return this; + }, + + // Updates the position and size of the flipbook's shadow + + _updateShadow: function() { + + var view, view2, shadow, + data = this.data(), + width = this.width(), + height = this.height(), + pageWidth = (data.display=='single') ? width : width/2; + + view = this.turn('view'); + + if (!data.shadow) { + data.shadow = $('
', { + 'class': 'shadow', + 'css': divAtt(0, 0, 0).css + }). + appendTo(this); + } + + for (var i = 0; i=width || point.y>=height) + return false; + + var allowedCorners = flipMethods._cAllowed.call(this); + + switch (data.effect) { + case 'hard': + + if (point.x>width-csz) + point.corner = 'r'; + else if (point.x=height-csz) + point.corner+= 'b'; + else + return false; + + if (point.x<=csz) + point.corner+= 'l'; + else if (point.x>=width-csz) + point.corner+= 'r'; + else + return false; + + break; + } + + return (!point.corner || $.inArray(point.corner, allowedCorners)==-1) ? + false : point; + + }, + + _isIArea: function(e) { + + var pos = this.data().f.parent.offset(); + + e = (isTouch && e.originalEvent) ? e.originalEvent.touches[0] : e; + + return flipMethods._cornerActivated.call(this, + { + x: e.pageX-pos.left, + y: e.pageY-pos.top + }); + + }, + + _c: function(corner, opts) { + + opts = opts || 0; + + switch (corner) { + case 'tl': + return point2D(opts, opts); + case 'tr': + return point2D(this.width()-opts, opts); + case 'bl': + return point2D(opts, this.height()-opts); + case 'br': + return point2D(this.width()-opts, this.height()-opts); + case 'l': + return point2D(opts, 0); + case 'r': + return point2D(this.width()-opts, 0); + } + + }, + + _c2: function(corner) { + + switch (corner) { + case 'tl': + return point2D(this.width()*2, 0); + case 'tr': + return point2D(-this.width(), 0); + case 'bl': + return point2D(this.width()*2, this.height()); + case 'br': + return point2D(-this.width(), this.height()); + case 'l': + return point2D(this.width()*2, 0); + case 'r': + return point2D(-this.width(), 0); + } + + }, + + _foldingPage: function() { + + var data = this.data().f; + + if (!data) + return; + + var opts = data.opts; + + if (opts.turn) { + data = opts.turn.data(); + if (data.display == 'single') + return (opts.next>1 || opts.page>1) ? data.pageObjs[0] : null; + else + return data.pageObjs[opts.next]; + } + + }, + + _backGradient: function() { + + var data = this.data().f, + turnData = data.opts.turn.data(), + gradient = turnData.opts.gradients && (turnData.display=='single' || + (data.opts.page!=2 && data.opts.page!=turnData.totalPages-1)); + + if (gradient && !data.bshadow) + data.bshadow = $('
', divAtt(0, 0, 1)). + css({'position': '', width: this.width(), height: this.height()}). + appendTo(data.parent); + + return gradient; + + }, + + type: function () { + + return this.data().f.effect; + + }, + + resize: function(full) { + + var data = this.data().f, + turnData = data.opts.turn.data(), + width = this.width(), + height = this.height(); + + switch (data.effect) { + case 'hard': + + if (full) { + data.wrapper.css({width: width, height: height}); + data.fpage.css({width: width, height: height}); + if (turnData.opts.gradients) { + data.ashadow.css({width: width, height: height}); + data.bshadow.css({width: width, height: height}); + } + } + + break; + case 'sheet': + + if (full) { + var size = Math.round(Math.sqrt(Math.pow(width, 2)+Math.pow(height, 2))); + + data.wrapper.css({width: size, height: size}); + data.fwrapper.css({width: size, height: size}). + children(':first-child'). + css({width: width, height: height}); + + data.fpage.css({width: width, height: height}); + + if (turnData.opts.gradients) + data.ashadow.css({width: width, height: height}); + + if (flipMethods._backGradient.call(this)) + data.bshadow.css({width: width, height: height}); + } + + if (data.parent.is(':visible')) { + var offset = findPos(data.parent[0]); + + data.fwrapper.css({top: offset.top, + left: offset.left}); + + //if (data.opts.turn) { + offset = findPos(data.opts.turn[0]); + data.fparent.css({top: -offset.top, left: -offset.left}); + //} + } + + this.flip('z', data.opts['z-index']); + + break; + } + + }, + + // Prepares the page by adding a general wrapper and another objects + + _addPageWrapper: function() { + + var att, + data = this.data().f, + turnData = data.opts.turn.data(), + parent = this.parent(); + + data.parent = parent; + + if (!data.wrapper) + switch (data.effect) { + case 'hard': + + var cssProperties = {}; + cssProperties[vendor + 'transform-style'] = 'preserve-3d'; + cssProperties[vendor + 'backface-visibility'] = 'hidden'; + + data.wrapper = $('
', divAtt(0, 0, 2)). + css(cssProperties). + appendTo(parent). + prepend(this); + + data.fpage = $('
', divAtt(0, 0, 1)). + css(cssProperties). + appendTo(parent); + + if (turnData.opts.gradients) { + data.ashadow = $('
', divAtt(0, 0, 0)). + hide(). + appendTo(parent); + + data.bshadow = $('
', divAtt(0, 0, 0)); + } + + break; + case 'sheet': + + var width = this.width(), + height = this.height(), + size = Math.round(Math.sqrt(Math.pow(width, 2)+Math.pow(height, 2))); + + data.fparent = data.opts.turn.data().fparent; + + if (!data.fparent) { + var fparent = $('
', {css: {'pointer-events': 'none'}}).hide(); + fparent.data().flips = 0; + fparent.css(divAtt(0, 0, 'auto', 'visible').css). + appendTo(data.opts.turn); + + data.opts.turn.data().fparent = fparent; + data.fparent = fparent; + } + + this.css({position: 'absolute', top: 0, left: 0, bottom: 'auto', right: 'auto'}); + + data.wrapper = $('
', divAtt(0, 0, this.css('z-index'))). + appendTo(parent). + prepend(this); + + data.fwrapper = $('
', divAtt(parent.offset().top, parent.offset().left)). + hide(). + appendTo(data.fparent); + + data.fpage = $('
', divAtt(0, 0, 0, 'visible')). + css({cursor: 'default'}). + appendTo(data.fwrapper); + + if (turnData.opts.gradients) + data.ashadow = $('
', divAtt(0, 0, 1)). + appendTo(data.fpage); + + flipMethods.setData.call(this, data); + + break; + } + + // Set size + flipMethods.resize.call(this, true); + + }, + + // Takes a 2P point from the screen and applies the transformation + + _fold: function(point) { + + var data = this.data().f, + turnData = data.opts.turn.data(), + o = flipMethods._c.call(this, point.corner), + width = this.width(), + height = this.height(); + + switch (data.effect) { + + case 'hard': + + if (point.corner=='l') + point.x = Math.min(Math.max(point.x, 0), width*2); + else + point.x = Math.max(Math.min(point.x, width), -width); + + var leftPos, + shadow, + gradientX, + fpageOrigin, + parentOrigin, + totalPages = turnData.totalPages, + zIndex = data.opts['z-index'] || totalPages, + parentCss = {'overflow': 'visible'}, + relX = (o.x) ? (o.x - point.x)/width : point.x/width, + angle = relX * 90, + half = angle<90; + + switch (point.corner) { + case 'l': + + fpageOrigin = '0% 50%'; + parentOrigin = '100% 50%'; + + if (half) { + leftPos = 0; + shadow = data.opts.next-1>0; + gradientX = 1; + } else { + leftPos = '100%'; + shadow = data.opts.page+1 A90) { + tr.x = tr.x + Math.abs(tr.y * rel.y/rel.x); + tr.y = 0; + if (Math.round(tr.x*Math.tan(PI-alpha)) < height) { + point.y = Math.sqrt(Math.pow(height, 2)+2 * middle.x * rel.x); + if (top) point.y = height - point.y; + return compute(); + } + } + + 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))); + if (left) mv.x = - mv.x; + if (top) mv.y = - mv.y; + } + + 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 + if (turnData.opts.gradients) { + + gradientSize = side*Math.sin(alpha); + + var endingPoint = flipMethods._c2.call(that, point.corner), + far = Math.sqrt(Math.pow(endingPoint.x-point.x, 2)+Math.pow(endingPoint.y-point.y, 2))/width; + + shadowVal = Math.sin(A90*((far>1) ? 2 - far : far)); + + gradientOpacity = Math.min(far, 1); + + + gradientStartVal = gradientSize>100 ? (gradientSize-100)/gradientSize : 0; + + gradientEndPointA = point2D( + gradientSize*Math.sin(alpha)/width*100, + gradientSize*Math.cos(alpha)/height*100); + + + if (flipMethods._backGradient.call(that)) { + + gradientEndPointB = point2D( + gradientSize*1.2*Math.sin(alpha)/width*100, + gradientSize*1.2*Math.cos(alpha)/height*100); + + if (!left) gradientEndPointB.x = 100-gradientEndPointB.x; + if (!top) gradientEndPointB.y = 100-gradientEndPointB.y; + + } + + } + + tr.x = Math.round(tr.x); + tr.y = Math.round(tr.y); + + return true; + }, + + transform = function(tr, c, x, a) { + + var f = ['0', 'auto'], mvW = (width-h)*x[0]/100, mvH = (height-h)*x[1]/100, + cssA = {left: f[c[0]], top: f[c[1]], right: f[c[2]], bottom: f[c[3]]}, + cssB = {}, + aliasingFk = (a!=90 && a!=-90) ? (left ? -1 : 1) : 0, + origin = x[0] + '% ' + x[1] + '%'; + + that.css(cssA). + transform(rotate(a) + translate(tr.x + aliasingFk, tr.y, ac), origin); + + data.fpage.css(cssA).transform( + rotate(a) + + translate(tr.x + df.x - mv.x - width*x[0]/100, tr.y + df.y - mv.y - height*x[1]/100, ac) + + rotate((180/a - 2)*a), + origin); + + data.wrapper.transform(translate(-tr.x + mvW-aliasingFk, -tr.y + mvH, ac) + rotate(-a), origin); + + data.fwrapper.transform(translate(-tr.x + mv.x + mvW, -tr.y + mv.y + mvH, ac) + rotate(-a), origin); + + if (turnData.opts.gradients) { + + if (x[0]) + gradientEndPointA.x = 100-gradientEndPointA.x; + + if (x[1]) + gradientEndPointA.y = (100-gradientEndPointA.y); + + cssB['box-shadow'] = '0 0 20px rgba(0,0,0,'+(0.5*shadowVal)+')'; + folding.css(cssB); + + gradient(data.ashadow, + point2D(left?100:0, top?0:100), + point2D(gradientEndPointA.x, gradientEndPointA.y), + [[gradientStartVal, 'rgba(0,0,0,0)'], + [((1-gradientStartVal)*0.8)+gradientStartVal, 'rgba(0,0,0,'+(0.2*gradientOpacity)+')'], + [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), + point2D(gradientEndPointB.x, gradientEndPointB.y), + [[0.6, 'rgba(0,0,0,0)'], + [0.8, 'rgba(0,0,0,'+(0.3*gradientOpacity)+')'], + [1, 'rgba(0,0,0,0)'] + ], + 3); + } + + }; + + switch (point.corner) { + case 'l' : + + + break; + case 'r' : + + + break; + case 'tl' : + point.x = Math.max(point.x, 1); + compute(); + transform(tr, [1,0,0,1], [100, 0], a); + break; + case 'tr' : + point.x = Math.min(point.x, width-1); + compute(); + transform(point2D(-tr.x, tr.y), [0,0,0,1], [0, 0], -a); + break; + case 'bl' : + point.x = Math.max(point.x, 1); + compute(); + transform(point2D(tr.x, -tr.y), [1,1,0,0], [100, 100], -a); + break; + case 'br' : + point.x = Math.min(point.x, width-1); + compute(); + transform(point2D(-tr.x, -tr.y), [0,1,1,0], [0, 100], a); + break; + } + + break; + } + + data.point = point; + + }, + + _moveFoldingPage: function(move) { + + var data = this.data().f; + + if (!data) + return; + + var turn = data.opts.turn, + turnData = turn.data(), + place = turnData.pagePlace; + + if (move) { + + var nextPage = data.opts.next; + + if (place[nextPage]!=data.opts.page) { + + if (data.folding) + flipMethods._moveFoldingPage.call(this, false); + + var folding = flipMethods._foldingPage.call(this); + + folding.appendTo(data.fpage); + place[nextPage] = data.opts.page; + data.folding = nextPage; + } + + turn.turn('update'); + + } else { + + if (data.folding) { + + if (turnData.pages[data.folding]) { + + // If we have flip available + + var flipData = turnData.pages[data.folding].data().f; + + turnData.pageObjs[data.folding]. + appendTo(flipData.wrapper); + + } else if (turnData.pageWrap[data.folding]) { + + // If we have the pageWrapper + + turnData.pageObjs[data.folding]. + appendTo(turnData.pageWrap[data.folding]); + + } + + if (data.folding in place) { + place[data.folding] = data.folding; + } + + delete data.folding; + + } + } + }, + + _showFoldedPage: function(c, animate) { + + var folding = flipMethods._foldingPage.call(this), + dd = this.data(), + data = dd.f, + visible = data.visible; + + if (folding) { + + if (!visible || !data.point || data.point.corner!=c.corner) { + + var corner = ( + data.status=='hover' || + data.status=='peel' || + data.opts.turn.data().mouseAction) ? + c.corner : null; + + visible = false; + + if (trigger('start', this, [data.opts, corner])=='prevented') + return false; + + } + + 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]); + flipMethods._fold.call(that, c); + } + }); + + } else { + + flipMethods._fold.call(this, c); + + if (dd.effect && !dd.effect.turning) + this.animatef(false); + + } + + if (!visible) { + + switch(data.effect) { + case 'hard': + + data.visible = true; + flipMethods._moveFoldingPage.call(this, true); + data.fpage.show(); + if (data.opts.shadows) + data.bshadow.show(); + + break; + case 'sheet': + + data.visible = true; + data.fparent.show().data().flips++; + flipMethods._moveFoldingPage.call(this, true); + data.fwrapper.show(); + if (data.bshadow) + data.bshadow.show(); + + break; + } + + } + + return true; + + } + + return false; + }, + + hide: function() { + + var data = this.data().f, + turnData = data.opts.turn.data(), + folding = flipMethods._foldingPage.call(this); + + switch (data.effect) { + case 'hard': + + if (turnData.opts.gradients) { + data.bshadowLoc = 0; + data.bshadow.remove(); + data.ashadow.hide(); + } + + data.wrapper.transform(''); + data.fpage.hide(); + + break; + case 'sheet': + + if ((--data.fparent.data().flips)===0) + data.fparent.hide(); + + this.css({left: 0, top: 0, right: 'auto', bottom: 'auto'}). + transform(''); + + data.wrapper.transform(''); + + data.fwrapper.hide(); + + if (data.bshadow) + data.bshadow.hide(); + + folding.transform(''); + + break; + } + + data.visible = false; + + return this; + }, + + hideFoldedPage: function(animate) { + + var data = this.data().f; + + if (!data.point) return; + + var that = this, + p1 = data.point, + hide = function() { + data.point = null; + data.status = ''; + that.flip('hide'); + that.trigger('end', [data.opts, false]); + }; + + if (animate) { + + var p4 = flipMethods._c.call(this, p1.corner), + top = (p1.corner.substr(0,1)=='t'), + 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, + frame: function(v) { + var np = bezier(p1, p2, p3, p4, v); + p1.x = np.x; + p1.y = np.y; + flipMethods._fold.call(that, p1); + }, + complete: hide, + duration: 800, + hiding: true + }); + + } else { + + this.animatef(false); + hide(); + + } + }, + + turnPage: function(corner) { + + var that = this, + data = this.data().f, + turnData = data.opts.turn.data(); + + corner = {corner: (data.corner) ? + data.corner.corner : + corner || flipMethods._cAllowed.call(this)[0]}; + + var p1 = data.point || + flipMethods._c.call(this, + corner.corner, + (data.opts.turn) ? turnData.opts.elevation : 0), + p4 = flipMethods._c2.call(this, corner.corner); + + this.trigger('flip'). + animatef({ + from: 0, + to: 1, + frame: function(v) { + + var np = bezier(p1, p1, p4, p4, v); + corner.x = np.x; + corner.y = np.y; + flipMethods._showFoldedPage.call(that, corner); + + }, + complete: function() { + + that.trigger('end', [data.opts, true]); + + }, + duration: turnData.opts.duration, + turning: true + }); + + data.corner = null; + }, + + moving: function() { + + return 'effect' in this.data(); + + }, + + isTurning: function() { + + return this.flip('moving') && this.data().effect.turning; + + }, + + corner: function() { + + return this.data().f.corner; + + }, + + _eventStart: function(e) { + + var data = this.data().f, + turn = data.opts.turn; + + if (!data.corner && !data.disabled && !this.flip('isTurning') && + data.opts.page==turn.data().pagePlace[data.opts.page]) + { + + data.corner = flipMethods._isIArea.call(this, e); + + if (data.corner && flipMethods._foldingPage.call(this)) { + + this.trigger('pressed', [data.point]); + flipMethods._showFoldedPage.call(this, data.corner); + + return false; + + } else + data.corner = null; + + } + + }, + + _eventMove: function(e) { + + var data = this.data().f; + + if (!data.disabled) { + + e = (isTouch) ? e.originalEvent.touches : [e]; + + if (data.corner) { + + var pos = data.parent.offset(); + data.corner.x = e[0].pageX-pos.left; + data.corner.y = e[0].pageY-pos.top; + flipMethods._showFoldedPage.call(this, data.corner); + + } else if (data.hover && !this.data().effect && this.is(':visible')) { + + var point = flipMethods._isIArea.call(this, e[0]); + + if (point) { + + if ((data.effect=='sheet' && point.corner.length==2) || data.effect=='hard') { + data.status = 'hover'; + var origin = flipMethods._c.call(this, point.corner, data.opts.cornerSize/2); + point.x = origin.x; + point.y = origin.y; + flipMethods._showFoldedPage.call(this, point, true); + } + + } else { + + if (data.status=='hover') { + data.status = ''; + flipMethods.hideFoldedPage.call(this, true); + } + + } + + } + + } + + }, + + _eventEnd: function() { + + var data = this.data().f, + corner = data.corner; + + if (!data.disabled && corner) { + if (trigger('released', this, [data.point || corner])!='prevented') { + flipMethods.hideFoldedPage.call(this, true); + } + } + + data.corner = null; + + }, + + disable: function(disable) { + + flipMethods.setData.call(this, {'disabled': disable}); + return this; + + }, + + hover: function(hover) { + + flipMethods.setData.call(this, {'hover': hover}); + return this; + + }, + + peel: function (corner, animate) { + + var data = this.data().f; + + if (corner) { + + if ($.inArray(corner, corners.all)==-1) + throw turnError('Corner '+corner+' is not permitted'); + + if ($.inArray(corner, flipMethods._cAllowed.call(this))!=-1) { + + var point = flipMethods._c.call(this, corner, data.opts.cornerSize/2); + + data.status = 'peel'; + + flipMethods._showFoldedPage.call(this, + { + corner: corner, + x: point.x, + y: point.y + }, animate); + + } + + + } else { + + data.status = ''; + + flipMethods.hideFoldedPage.call(this, animate); + + } + + return this; + } +}; + + +// Processes classes + +function dec(that, methods, args) { + + if (!args[0] || typeof(args[0])=='object') + return methods.init.apply(that, args); + + else if (methods[args[0]]) + return methods[args[0]].apply(that, Array.prototype.slice.call(args, 1)); + + else + throw turnError(args[0] + ' is not a method or property'); + +} + + +// Attributes for a layer + +function divAtt(top, left, zIndex, overf) { + + return {'css': { + position: 'absolute', + top: top, + left: left, + 'overflow': overf || 'hidden', + zIndex: zIndex || 'auto' + } +}; + +} + +// Gets a 2D point from a bezier curve of four points + +function bezier(p1, p2, p3, p4, t) { + + var a = 1 - t, + b = a * a * a, + c = t * t * t; + + return point2D(Math.round(b*p1.x + 3*t*a*a*p2.x + 3*t*t*a*p3.x + c*p4.x), + Math.round(b*p1.y + 3*t*a*a*p2.y + 3*t*t*a*p3.y + c*p4.y)); + +} + +// Converts an angle from degrees to radians + +function rad(degrees) { + + return degrees/180*PI; + +} + +// Converts an angle from radians to degrees + +function deg(radians) { + + return radians/PI*180; + +} + +// Gets a 2D point + +function point2D(x, y) { + + return {x: x, y: y}; + +} + +// Webkit 534.3 on Android wrongly repaints elements that use overflow:hidden + rotation + +function rotationAvailable() { + var parts; + + if ((parts = /AppleWebkit\/([0-9\.]+)/i.exec(navigator.userAgent))) { + var webkitVersion = parseFloat(parts[1]); + return (webkitVersion>534.3); + } else { + return true; + } +} + +// Returns the traslate value + +function translate(x, y, use3d) { + + return (has3d && use3d) ? ' translate3d(' + x + 'px,' + y + 'px, 0px) ' + : ' translate(' + x + 'px, ' + y + 'px) '; + +} + +// Returns the rotation value + +function rotate(degrees) { + + return ' rotate(' + degrees + 'deg) '; + +} + +// Checks if a property belongs to an object + +function has(property, object) { + + return Object.prototype.hasOwnProperty.call(object, property); + +} + +// Gets the CSS3 vendor prefix + +function getPrefix() { + + var vendorPrefixes = ['Moz','Webkit','Khtml','O','ms'], + len = vendorPrefixes.length, + vendor = ''; + + while (len--) + if ((vendorPrefixes[len] + 'Transform') in document.body.style) + vendor='-'+vendorPrefixes[len].toLowerCase()+'-'; + + return vendor; + +} + +// Detects the transitionEnd Event + +function getTransitionEnd() { + + var t, + el = document.createElement('fakeelement'), + transitions = { + 'transition':'transitionend', + 'OTransition':'oTransitionEnd', + 'MSTransition':'transitionend', + 'MozTransition':'transitionend', + 'WebkitTransition':'webkitTransitionEnd' + }; + + for (t in transitions) { + if (el.style[t] !== undefined) { + return transitions[t]; + } + } +} + +// Gradients + +function gradient(obj, p0, p1, colors, numColors) { + + var j, cols = []; + + if (vendor=='-webkit-') { + + for (j = 0; jh)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*(110) + data.eventQueue.splice(0, 1); + + }, + + _eventSeq: function() { + + var data = this.data().zoom, + list = data.eventQueue, + lastEvent = list.length-1; + + if (lastEvent>0 && + list[lastEvent].name=='tap' && + list[lastEvent-1].name=='tap' && + list[lastEvent].event.pageX == list[lastEvent-1].event.pageX && + list[lastEvent].event.pageY == list[lastEvent-1].event.pageY && + list[lastEvent].timestamp-list[lastEvent-1].timestamp < 200 && + list[lastEvent].timestamp-list[lastEvent-1].timestamp > 50) + { + + return $.extend(list[lastEvent].event, {type: 'zoom.doubleTap'}); + + } else if (list[lastEvent].name=='tap') { + + return $.extend(list[lastEvent].event, {type: 'zoom.tap'}); + + } + + }, + + _prepareZoom: function () { + + var flipPos, offsetLeft = 0, + data = this.data().zoom, + invz = 1/this.zoom('value'), + flip = data.opts.flipbook, + dir = flip.turn('direction'), + flipData = flip.data(), + flipOffset = flip.offset(), + thisOffset = this.offset(), + flipSize = {height: flip.height()}, + view = flip.turn('view'); + + if (flip.turn('display')=='double' && flip.data().opts.autoCenter) { + if (!view[0]) { + flipSize.width = flip.width()/2; + offsetLeft = (dir=='ltr') ? flipSize.width : 0; + flipPos = point2D( + (dir=='ltr') ? flipOffset.left-thisOffset.left+flipSize.width : flipOffset.left-thisOffset.left, + flipOffset.top-thisOffset.top + ); + + } else if (!view[1]) { + flipSize.width = flip.width()/2; + offsetLeft = (dir=='ltr') ? 0 : flipSize.width; + flipPos = point2D( + (dir=='ltr') ? flipOffset.left-thisOffset.left : flipOffset.left-thisOffset.left+flipSize.width, + flipOffset.top-thisOffset.top + ); + } else { + flipSize.width = flip.width(); + flipPos = point2D( + flipOffset.left-thisOffset.left, + flipOffset.top-thisOffset.top + ); + } + } else { + flipSize.width = flip.width(); + flipPos = point2D( + flipOffset.left-thisOffset.left, + flipOffset.top-thisOffset.top + ); + } + + if (!data.zoomer) { + data.zoomer = $('
', + {'class': 'zoomer', + css: { + overflow:'hidden', + position: 'absolute', + zIndex: '1000000' + } + }). + mousedown(function() { + return false; + }).appendTo(this); + } + + + data.zoomer.css({ + top: flipPos.y, + left: flipPos.x, + width: flipSize.width, + height: flipSize.height + }); + + var zoomerView = view.join(','); + + if (zoomerView!=data.zoomerView) { + + data.zoomerView = zoomerView; + data.zoomer.find('*').remove(); + + for (var p = 0; pbound.width || pos.y>bound.height) { + pos.x = center.x; + pos.y = center.y; + } + + + var compose = point2D( + (pos.x-center.x)*zoom + center.x, + (pos.y-center.y)*zoom + center.y + ), + move = point2D( + (bound.size.width*zoom>this.width()) ? pos.x-compose.x : 0, + (bound.size.height*zoom>this.height()) ? pos.y-compose.y : 0 + ), + maxMove = point2D( + Math.abs(bound.size.width*zoom-this.width()), + Math.abs(bound.size.height*zoom-this.height()) + ), + minMove = point2D( + Math.min(0, bound.size.width*zoom-this.width()), + Math.min(0, bound.size.height*zoom-this.height()) + ), + realPos = point2D( + center.x*zoom - center.x - flipPos.x - move.x, + center.y*zoom - center.y - flipPos.y - move.y + ); + + if (realPos.y>maxMove.y) + move.y = realPos.y - maxMove.y + move.y; + else if (realPos.ymaxMove.x) + move.x = realPos.x - maxMove.x + move.x; + else if (realPos.x', { + css: { + position: 'relative', + top: data.flipPosition.y, + left: data.flipPosition.x, + width: flip.width()*scaling, + height: flip.height()*scaling, + background: 'blue' + } + }).appendTo(flip.parent()); + + flipDesPos = point2D( + tmp.offset().left-thisOffset.left, + tmp.offset().top-thisOffset.top + ); + + + tmp.remove(); + + var autoCenter = flip.data().opts.autoCenter; + + if (autoCenter && flip.turn('display')=='double') { + + if (!flip.turn('view')[0]) + flipDesPos.x = (flip.turn('direction')=='ltr') ? + flipDesPos.x-tmp.width()/4 : + flipDesPos.x+tmp.width()/4; + else if (!flip.turn('view')[1]) + flipDesPos.x = (flip.turn('direction')=='ltr') ? + flipDesPos.x+tmp.width()/4 : + flipDesPos.x-tmp.width()/4; + } + + var flipRealPos = $.findPos(flip[0]); + + move = point2D( + -flip.width()/2 - flipRealPos.left + tmp.width()/2 + flipDesPos.x + thisOffset.left, + -flip.height()/2 - flipRealPos.top + tmp.height()/2 + flipDesPos.y + thisOffset.top); + + var transitionEndCallback = function() { + + if (flip[0].style.removeProperty) { + + flip[0].style.removeProperty(prefix+'transition'); + flip.transform( + (flip.turn('options').acceleration) ? translate(0, 0, true) : '').turn('zoom', 1); + flip[0].style.removeProperty('margin'); + flip.css({ + position: 'relative', + top: data.flipPosition.y, + left: data.flipPosition.x + }); + + } else { + + flip.transform('none'). + turn('zoom', 1). + css({ + margin: '', + top: data.flipPosition.y, + left: data.flipPosition.x, + position: 'relative' + }); + + } + + if (autoCenter) + flip.turn('center'); + + that.trigger('zoom.zoomOut'); + + }; + + if (duration===0) { + + transitionEndCallback(); + + } else if (transitionEnd) { + + flip.bind(transitionEnd, function() { + + $(this).unbind(transitionEnd); + transitionEndCallback(); + + }); + + flip.transform(translate(move.x, move.y, true) + scale(scaling, true)); + + } else { + + setTimeout(transitionEndCallback, duration); + flip.transform(translate(move.x, move.y, true) + scale(scaling, true)); + + } + + return this; + }, + + flipbookWidth: function() { + + var data = this.data().zoom, + flipbook = data.opts.flipbook, + view = flipbook.turn('view'); + + return (flipbook.turn('display')=='double' && (!view[0] || !view[1])) ? + flipbook.width()/2 + : + flipbook.width(); + + }, + + scroll: function(to, unlimited, animate) { + + var data = this.data().zoom, + flip = data.opts.flipbook, + flipWidth = this.zoom('flipbookWidth'), + prefix = $.cssPrefix(); + + if (has3d) { + + var css = {}; + + if (animate) { + css[prefix+'transition'] = prefix + 'transform 200ms'; + } else { + css[prefix+'transition'] = 'none'; + } + + flip.css(css); + flip.transform(translate(-data.axis.x - to.x, -data.axis.y - to.y, true)); + + } else { + + flip.css({top: -data.axis.y - to.y, left: -data.axis.x - to.x}); + + } + + if (!unlimited) { + + var out, + minBound = point2D( + Math.min(0, (flipWidth-this.width())/2), + Math.min(0, (flip.height()-this.height())/2)), + maxBound = point2D( + (flipWidth>this.width()) ? flipWidth-this.width() : (flipWidth-this.width())/2, + (flip.height()>this.height()) ? flip.height()-this.height() : (flip.height()-this.height())/2 + ); + + if (to.ymaxBound.y) { + to.y = maxBound.y; + out = true; + } + + if (to.xmaxBound.x) { + to.x = maxBound.x; + out = true; + } + + if (out) { + this.zoom('scroll', to, true, true); + } + + } + + data.scrollPos = point2D(to.x, to.y); + + }, + + resize: function() { + + var data = this.data().zoom, + flip = data.opts.flipbook; + + if (this.zoom('value')>1) { + + var flipOffset = flip.offset(), + thisOffset = this.offset(); + + data.axis = point2D( + (flipOffset.left - thisOffset.left) + (data.axis.x + data.scrollPos.x), + (flipOffset.top - thisOffset.top) + (data.axis.y + data.scrollPos.y) + ); + + if (flip.turn('display')=='double' && + flip.turn('direction')=='ltr' && + !flip.turn('view')[0]) + data.axis.x = data.axis.x + flip.width()/2; + + this.zoom('scroll', data.scrollPos); + } + + }, + + _eZoom: function() { + + var flipPos, + data = this.data().zoom, + flip = data.opts.flipbook, + view = flip.turn('view'); + + for (var p = 0; pdata.page) + this.zoom('scroll', + point2D(0, data.scrollPos.y), false, true); + + else if (page1 || data.touch.last.x-data.touch.initial.x>100)){ + + this.trigger('zoom.swipeRight'); + + } + + } + }, + + _eDestroying: function() { + + var that = this, + data = this.data().zoom, + flip = data.opts.flipbook, + events = [ + 'tap', + 'doubleTap', + 'resize', + 'zoomIn', + 'zoomOut', + 'swipeLeft', + 'swipeRight' + ]; + + this.zoom('zoomOut', 0); + + $.each(events, function(index, eventName) { + that.unbind('zoom.' + eventName); + }); + + for (var eventName in data.flipbookEvents) { + if (Object.prototype.hasOwnProperty.call(data.flipbookEvents, eventName)) { + flip.unbind(eventName, data.flipbookEvents[eventName]); + } + } + + flip.unbind('touchstart', data.eventTouchStart ). + unbind('touchmove', data.eventTouchMove). + unbind('touchend', data.eventTouchEnd); + + this.unbind('touchstart', zoomMethods._tap). + unbind('click', zoomMethods._tap); + + data = null; + this.data().zoom = null; + + } +}; + +function isPage(element, last) { + + if (element[0]==last[0]) + return false; + + if (element.attr('page')) + return true; + + return (element.parent()[0]) ? + isPage(element.parent(), last) + : + false; + +} + +function error(message) { + + function TurnJsError(message) { + this.name = "TurnJsError"; + this.message = message; + } + + TurnJsError.prototype = new Error(); + TurnJsError.prototype.constructor = TurnJsError; + return new TurnJsError(message); + +} + +function translate(x, y, use3d) { + + return (has3d && use3d) ? ' translate3d(' + x + 'px,' + y + 'px, 0px) ' + : ' translate(' + x + 'px, ' + y + 'px) '; + +} + +function scale(v, use3d) { + + return (has3d && use3d) ? ' scale3d(' + v + ', ' + v + ', 1) ' + : ' scale(' + v + ') '; + +} + +function point2D(x, y) { + + return {x: x, y: y}; + +} + +function bind(func, context) { + + return function() { + return func.apply(context, arguments); + }; + +} + +$.extend($.fn, { + zoom: function() { + + var args = arguments; + + if (!args[0] || typeof(args[0])=='object') + return zoomMethods.init.apply($(this[0]), args); + else if (zoomMethods[args[0]]) + return zoomMethods[args[0]].apply($(this[0]), Array.prototype.slice.call(args, 1)); + else + throw error(args[0] + ' is not a method'); + + } +}); + +})(jQuery); diff --git a/lib/zoom.min.js b/lib/zoom.min.js new file mode 100644 index 0000000..d4c3a8e --- /dev/null +++ b/lib/zoom.min.js @@ -0,0 +1,26 @@ +/* turn.js 4.1.0 | Copyright (c) 2012 Emmanuel Garcia | turnjs.com | turnjs.com/license.txt */ + +(function(f){function r(a,b){return a[0]==b[0]?!1:a.attr("page")?!0:a.parent()[0]?r(a.parent(),b):!1}function u(a){function b(a){this.name="TurnJsError";this.message=a}b.prototype=Error();b.prototype.constructor=b;return new b(a)}function t(a,b,d){return q&&d?" translate3d("+a+"px,"+b+"px, 0px) ":" translate("+a+"px, "+b+"px) "}function v(a,b){return q&&b?" scale3d("+a+", "+a+", 1) ":" scale("+a+") "}function h(a,b){return{x:a,y:b}}function m(a,b){return function(){return a.apply(b,arguments)}}var q, +w={max:2,flipbook:null,easeFunction:"ease-in-out",duration:500,when:{}},j={init:function(a){var b=this,d=this.data(),a=f.extend({},w,a);if(!a.flipbook||!a.flipbook.turn("is"))throw u("options.flipbook is required");q="WebKitCSSMatrix"in window||"MozPerspective"in document.body.style;if("function"!=typeof a.max){var e=a.max;a.max=function(){return e}}d.zoom={opts:a,axis:h(0,0),scrollPos:h(0,0),eventQueue:[],mouseupEvent:function(){return j._eMouseUp.apply(b,arguments)},eventTouchStart:m(j._eTouchStart, +b),eventTouchMove:m(j._eTouchMove,b),eventTouchEnd:m(j._eTouchEnd,b),flipbookEvents:{zooming:m(j._eZoom,b),pressed:m(j._ePressed,b),released:m(j._eReleased,b),start:m(j._eStart,b),turning:m(j._eTurning,b),turned:m(j._eTurned,b),destroying:m(j._eDestroying,b)}};for(var c in a.when)Object.prototype.hasOwnProperty.call(a.when,c)&&this.bind("zoom."+c,a.when[c]);for(c in d.zoom.flipbookEvents)Object.prototype.hasOwnProperty.call(d.zoom.flipbookEvents,c)&&a.flipbook.bind(c,d.zoom.flipbookEvents[c]);this.css({position:"relative", +overflow:"hidden"});f.isTouch?(a.flipbook.bind("touchstart",d.zoom.eventTouchStart).bind("touchmove",d.zoom.eventTouchMove).bind("touchend",d.zoom.eventTouchEnd),this.bind("touchstart",j._tap)):this.mousedown(j._mousedown).click(j._tap)},_tap:function(a){var b=f(this),d=b.data().zoom;!d.draggingCorner&&!d.dragging&&r(f(a.target),b)&&(j._addEvent.call(b,"tap",a),(a=j._eventSeq.call(b))&&b.trigger(a))},_addEvent:function(a,b){var d=this.data().zoom,e=(new Date).getTime();d.eventQueue.push({name:a,timestamp:e, +event:b});10a[b].timestamp-a[b-1].timestamp&&50",{"class":"zoomer",css:{overflow:"hidden",position:"absolute",zIndex:"1000000"}}).mousedown(function(){return!1}).appendTo(this));d.zoomer.css({top:a.y,left:a.x,width:g.width,height:g.height});c=k.join(",");if(c!=d.zoomerView){d.zoomerView=c;d.zoomer.find("*").remove();for(c=0;ca.x||0>a.y||a.x>i.width||a.y>i.height)a.x=k.x,a.y=k.y;var n=h((a.x-k.x)*c+k.x,(a.y-k.y)*c+k.y),a=h(i.size.width*c>this.width()?a.x-n.x:0,i.size.height*c>this.height()?a.y-n.y:0),n=h(Math.abs(i.size.width*c-this.width()),Math.abs(i.size.height*c-this.height())), +i=h(Math.min(0,i.size.width*c-this.width()),Math.min(0,i.size.height*c-this.height())),p=h(k.x*c-k.x-g.x-a.x,k.y*c-k.y-g.y-a.y);p.y>n.y?a.y=p.y-n.y+a.y:p.yn.x?a.x=p.x-n.x+a.x:p.x",{css:{position:"relative",top:e.flipPosition.y,left:e.flipPosition.x,width:c.width()*m,height:c.height()*m,background:"blue"}}).appendTo(c.parent()),g=h(k.offset().left-b.left,k.offset().top-b.top);k.remove();var q=c.data().opts.autoCenter;q&&"double"==c.turn("display")&& +(c.turn("view")[0]?c.turn("view")[1]||(g.x="ltr"==c.turn("direction")?g.x+k.width()/4:g.x-k.width()/4):g.x="ltr"==c.turn("direction")?g.x-k.width()/4:g.x+k.width()/4);var r=f.findPos(c[0]);b=h(-c.width()/2-r.left+k.width()/2+g.x+b.left,-c.height()/2-r.top+k.height()/2+g.y+b.top);var n=function(){c[0].style.removeProperty?(c[0].style.removeProperty(l+"transition"),c.transform(c.turn("options").acceleration?t(0,0,!0):"").turn("zoom",1),c[0].style.removeProperty("margin"),c.css({position:"relative", +top:e.flipPosition.y,left:e.flipPosition.x})):c.transform("none").turn("zoom",1).css({margin:"",top:e.flipPosition.y,left:e.flipPosition.x,position:"relative"});q&&c.turn("center");d.trigger("zoom.zoomOut")};0===a?n():(i?c.bind(i,function(){f(this).unbind(i);n()}):setTimeout(n,a),c.transform(t(b.x,b.y,!0)+v(m,!0)));return this}},flipbookWidth:function(){var a=this.data().zoom.opts.flipbook,b=a.turn("view");return"double"==a.turn("display")&&(!b[0]||!b[1])?a.width()/2:a.width()},scroll:function(a, +b,d){var e=this.data().zoom,c=e.opts.flipbook,j=this.zoom("flipbookWidth"),l=f.cssPrefix();if(q){var i={};i[l+"transition"]=d?l+"transform 200ms":"none";c.css(i);c.transform(t(-e.axis.x-a.x,-e.axis.y-a.y,!0))}else c.css({top:-e.axis.y-a.y,left:-e.axis.x-a.x});if(!b){var g,b=h(Math.min(0,(j-this.width())/2),Math.min(0,(c.height()-this.height())/2)),c=h(j>this.width()?j-this.width():(j-this.width())/2,c.height()>this.height()?c.height()-this.height():(c.height()-this.height())/2);a.yc.y&&(a.y=c.y,g=!0);a.xc.x&&(a.x=c.x,g=!0);g&&this.zoom("scroll",a,!0,!0)}e.scrollPos=h(a.x,a.y)},resize:function(){var a=this.data().zoom,b=a.opts.flipbook;if(1d.page?this.zoom("scroll",h(0,d.scrollPos.y),!1,!0):bb&&(-1>a.touch.speed.x||-100>a.touch.last.x-a.touch.initial.x)?this.trigger("zoom.swipeLeft"):50>b&&(1 + + + + + + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/samples/basic/js/basic.js b/samples/basic/js/basic.js new file mode 100644 index 0000000..12a3690 --- /dev/null +++ b/samples/basic/js/basic.js @@ -0,0 +1,94 @@ +/* + * Basic sample +*/ + +function addPage(page, book) { + + var id, pages = book.turn('pages'); + + // Create a new element for this page + var element = $('
', {}); + + // Add the page to the flipbook + if (book.turn('addPage', element, page)) { + + // Add the initial HTML + // It will contain a loader indicator and a gradient + element.html('
'); + + // Load the page + loadPage(page, element); + } + +} + +function loadPage(page, pageElement) { + + // Create an image element + + var img = $(''); + + img.mousedown(function(e) { + e.preventDefault(); + }); + + img.load(function() { + + // Set the size + $(this).css({width: '100%', height: '100%'}); + + // Add the image to the page after loaded + + $(this).appendTo(pageElement); + + // Remove the loader indicator + + pageElement.find('.loader').remove(); + }); + + // Load the page + + img.attr('src', 'pages/' + page + '.jpg'); + +} + + +function loadLargePage(page, pageElement) { + + var img = $(''); + + img.load(function() { + + var prevImg = pageElement.find('img'); + $(this).css({width: '100%', height: '100%'}); + $(this).appendTo(pageElement); + prevImg.remove(); + + }); + + // Loadnew page + + img.attr('src', 'pages/' + page + '-large.jpg'); +} + + +function loadSmallPage(page, pageElement) { + + var img = pageElement.find('img'); + + img.css({width: '100%', height: '100%'}); + + img.unbind('load'); + // Loadnew page + + img.attr('src', 'pages/' + page + '.jpg'); +} + + + +// http://code.google.com/p/chromium/issues/detail?id=128488 +function isChrome() { + + return navigator.userAgent.indexOf('Chrome')!=-1; + +} \ No newline at end of file diff --git a/samples/basic/pages/1.jpg b/samples/basic/pages/1.jpg new file mode 100644 index 0000000..0eec473 Binary files /dev/null and b/samples/basic/pages/1.jpg differ diff --git a/samples/basic/pages/10.jpg b/samples/basic/pages/10.jpg new file mode 100644 index 0000000..7a8c2dd Binary files /dev/null and b/samples/basic/pages/10.jpg differ diff --git a/samples/basic/pages/11.jpg b/samples/basic/pages/11.jpg new file mode 100644 index 0000000..cf6b6b2 Binary files /dev/null and b/samples/basic/pages/11.jpg differ diff --git a/samples/basic/pages/12.jpg b/samples/basic/pages/12.jpg new file mode 100644 index 0000000..df31ce8 Binary files /dev/null and b/samples/basic/pages/12.jpg differ diff --git a/samples/basic/pages/2.jpg b/samples/basic/pages/2.jpg new file mode 100644 index 0000000..e129724 Binary files /dev/null and b/samples/basic/pages/2.jpg differ diff --git a/samples/basic/pages/3.jpg b/samples/basic/pages/3.jpg new file mode 100644 index 0000000..2d49eba Binary files /dev/null and b/samples/basic/pages/3.jpg differ diff --git a/samples/basic/pages/4.jpg b/samples/basic/pages/4.jpg new file mode 100644 index 0000000..2dc32f4 Binary files /dev/null and b/samples/basic/pages/4.jpg differ diff --git a/samples/basic/pages/5.jpg b/samples/basic/pages/5.jpg new file mode 100644 index 0000000..e894f38 Binary files /dev/null and b/samples/basic/pages/5.jpg differ diff --git a/samples/basic/pages/6.jpg b/samples/basic/pages/6.jpg new file mode 100644 index 0000000..551ae32 Binary files /dev/null and b/samples/basic/pages/6.jpg differ diff --git a/samples/basic/pages/7.jpg b/samples/basic/pages/7.jpg new file mode 100644 index 0000000..14fbf1d Binary files /dev/null and b/samples/basic/pages/7.jpg differ diff --git a/samples/basic/pages/8.jpg b/samples/basic/pages/8.jpg new file mode 100644 index 0000000..0fc19f0 Binary files /dev/null and b/samples/basic/pages/8.jpg differ diff --git a/samples/basic/pages/9.jpg b/samples/basic/pages/9.jpg new file mode 100644 index 0000000..bf27014 Binary files /dev/null and b/samples/basic/pages/9.jpg differ diff --git a/samples/docs/css/docs.css b/samples/docs/css/docs.css new file mode 100644 index 0000000..3b62485 --- /dev/null +++ b/samples/docs/css/docs.css @@ -0,0 +1,175 @@ +/* Docs sample */ + +body{ + margin:0; + padding:0; + overflow:hidden; +} + +#canvas{ + width: 960px; + height: 600px; + margin: 100px auto; +} + +#book-zoom{ + -webkit-transition: -webkit-transform 1s; + -moz-transition: -moz-transform 1s; + -ms-transition: -ms-transform 1s; + -o-transition: -o-transform 1s; + transition: transform 1s; +} + +.animated{ + -webkit-transition:margin-left 0.2s ease-in-out; + -moz-transition:margin-left 0.2s ease-in-out; + -o-transition:margin-left 0.2s ease-in-out; + -ms-transition:margin-left 0.2s ease-in-out; + transition:margin-left 0.2s ease-in-out; +} + +.sample-docs{ + margin-top:20px; + width:942px; + height:600px; +} + +.sample-docs .page{ + width:471px; + height:600px; + background:white; + + -webkit-box-shadow:0 0 20px rgba(0,0,0,0.2); + -moz-box-shadow:0 0 20px rgba(0,0,0,0.2); + -ms-box-shadow:0 0 20px rgba(0,0,0,0.2); + -o-box-shadow:0 0 20px rgba(0,0,0,0.2); + box-shadow:0 0 20px rgba(0,0,0,0.2); +} + +.sample-docs .hard{ + background-image:url(../pics/covers.jpg); +} + +.sample-docs .p2{ + background-position:-471px 0; +} + +.sample-docs .p28{ + background:-webkit-gradient(linear, left top, right top, color-stop(0.95, #fff), color-stop(1, #dadada)); + background-image:-webkit-linear-gradient(left, #fff 95%, #dadada 100%); + background-image:-moz-linear-gradient(left, #fff 95%, #dadada 100%); + background-image:-ms-linear-gradient(left, #fff 95%, #dadada 100%); + background-image:-o-linear-gradient(left, #fff 95%, #dadada 100%); + background-image:linear-gradient(left, #fff 95%, #dadada 100%); +} + +.sample-docs .p29{ + background-position:-942px 0; +} + +.sample-docs .p30{ + background-position:-1413px 0; +} + +.sample-docs .even .gradient{ + position:absolute; + top:0; + left:0; + width:100%; + height:100%; + background-image:url(../pics/right-border.png); + background-position:right top; + background-repeat: repeat-y; +} + +.sample-docs .odd .gradient{ + position:absolute; + top:0; + left:0; + width:100%; + height:100%; + background-image:url(../pics/left-border.png); + background-position:left top; + background-repeat: repeat-y; +} + +.sample-docs .page-wrapper{ + -webkit-perspective:2000px; + -moz-perspective: 2000px; + -ms-perspective: 2000px; + perspective: 2000px; +} + + +.sample-docs .loader{ + background-image:url(../pics/loader.gif); + width:22px; + height:22px; + position:absolute; + top:280px; + left:219px; +} + +.sample-docs .shadow{ + -webkit-transition: -webkit-box-shadow 0.5s; + -moz-transition: -moz-box-shadow 0.5s; + -o-transition: -webkit-box-shadow 0.5s; + -ms-transition: -ms-box-shadow 0.5s; + + -webkit-box-shadow:0 0 20px #ccc; + -moz-box-shadow:0 0 20px #ccc; + -o-box-shadow:0 0 20px #ccc; + -ms-box-shadow:0 0 20px #ccc; + box-shadow:0 0 20px #ccc; +} + +.sample-docs .tabs{ + width:942px; + height:22px; + top:-22px; + position:relative; + z-index:1; +} + +.sample-docs .tabs > div{ + width:461px; + height:22px; + float:left; +} + +.sample-docs .tabs .left{ + text-align:left; + margin-left:10px; +} + + +.sample-docs .tabs .right{ + text-align:right; + margin-right:10px; +} + +.sample-docs .tabs a{ + color:black; + -webkit-border-image: url(../pics/tab-off.png) 5 20 5 20 repeat stretch; + border-width: 5px 20px 5px 20px; + display:inline-block; + font:bold 11px arial; + text-shadow:1px 1px 0 #ddd; + color:#333; + line-height:12px; + text-decoration:none; +} + +.sample-docs .tabs .on, +.sample-docs .tabs .on:hover{ + -webkit-border-image: url(../pics/tab-on.png) 5 20 5 20 repeat stretch; + cursor:default; +} + +.sample-docs .tabs a:hover{ + color:black; + text-decoration: none; + cursor:pointer; + -webkit-border-image: url(../pics/tab-hover.png) 5 20 5 20 repeat stretch; + +} \ No newline at end of file diff --git a/samples/docs/css/jquery.ui.css b/samples/docs/css/jquery.ui.css new file mode 100644 index 0000000..095b6ef --- /dev/null +++ b/samples/docs/css/jquery.ui.css @@ -0,0 +1,143 @@ +.turnjs-slider{ + width:600px; + height:8px; + background:rgba(0,0,0, 0.2); + -webkit-border-radius:5px; + -moz-border-radius:5px; + -o-border-radius:5px; + -ms-border-radius:5px; + border-radius:5px; + margin:20px auto; +} + +.turnjs-slider .thumbnail{ + width:115px; + height:85px; + position:absolute; + background:rgba(0,0,0, 0.5); + z-index:10000; + top:-100px; + left:-17px; + display:none; + + -webkit-transform:translate3d(0px, 50px, 0px) scale(0.1, 0.1); + -webkit-transition:all 0.2s; + -webkit-border-radius:5px; + + -moz-transform:translate3d(0px, 50px, 0px) scale(0.1, 0.1); + -moz-transition:all 0.2s; + -moz-border-radius:5px; + + -o-transform:translate3d(0px, 50px, 0px) scale(0.1, 0.1); + -o-transition:all 0.2s; + -o-border-radius:5px; + + -ms-transform:translate3d(0px, 50px, 0px) scale(0.1, 0.1); + -ms-transition:all 0.2s; + -ms-border-radius:5px; + + transform:translate3d(0px, 50px, 0px) scale(0.1, 0.1); + transition:all 0.2s; + border-radius:5px; +} + +.no-transition{ + -webkit-transition:none; + -moz-transition:none; + -o-transition:none; + -ms-transition:none; +} + +.turnjs-slider .thumbnail div{ + width:100px; + margin:7px; + height:70px; + background-color:white; +} + +.turnjs-slider .ui-state-hover .thumbnail{ + display:block; + opacity:0; +} + +.turnjs-slider .ui-state-active .thumbnail{ + display:block; + opacity:1; + -webkit-transform:scale(1, 1); + -moz-transform:scale(1, 1); + -o-transform:scale(1, 1); + -ms-transform:scale(1, 1); + transform:scale(1, 1); +} + +/* Layout helpers +----------------------------------*/ + +/* Interaction Cues +----------------------------------*/ +.ui-state-disabled { + cursor: default !important; +} + +/* Misc visuals +----------------------------------*/ + +/* Overlays */ +.turnjs-slider .ui-widget-overlay { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; +} + +.turnjs-slider .ui-slider { + position: relative; + text-align: left; +} + +.turnjs-slider .ui-slider-handle{ + position: absolute; + z-index:0; + width:80px; + height: 8px; + cursor: default; + -webkit-border-radius:5px; + -moz-border-radius:5px; + -ms-border-radius:5px; + border-radius:5px; +} + +.turnjs-slider .ui-slider-horizontal { + height: 8px; + width:520px; + margin-left:39px; +} + +.turnjs-slider .ui-slider-horizontal .ui-slider-handle { + margin-left:-40px; + margin-top:-1px; +} + +/* Interaction states +----------------------------------*/ +.turnjs-slider .ui-slider-handle{ + border:1px solid white; + background-color:black; + opacity:0.2; + display:block; + -webkit-transition:opacity 0.2s; + -moz-transition:opacity 0.2s; + -ms-transition:opacity 0.2s; + -o-transition:opacity 0.2s; + transition:opacity 0.2s; +} + +.turnjs-slider .ui-state-hover{ + opacity:0.4; +} + +.turnjs-slider .ui-state-active{ + opacity:1; +} + diff --git a/samples/docs/css/jquery.ui.html4.css b/samples/docs/css/jquery.ui.html4.css new file mode 100644 index 0000000..d9a0c40 --- /dev/null +++ b/samples/docs/css/jquery.ui.html4.css @@ -0,0 +1,16 @@ +.turnjs-slide{ + width:600px; + height:8px; + background-color:#B4B4B4; + border-radius:5px; + margin:20px auto; +} + +.turnjs-slide .ui-slider .ui-slider-handle{ + background-color:#8F8F8F; + z-index:10000; +} + +.turnjs-slide .thumbnail{ + background: #666; +} \ No newline at end of file diff --git a/samples/docs/index.html b/samples/docs/index.html new file mode 100644 index 0000000..e9db675 --- /dev/null +++ b/samples/docs/index.html @@ -0,0 +1,270 @@ + + + + + + + + + + + + + + + + +
+
+
+
+
+
+
+
+
+
+ + +
+
+
+
+ + + + + + \ No newline at end of file diff --git a/samples/docs/js/docs.js b/samples/docs/js/docs.js new file mode 100644 index 0000000..2292cfd --- /dev/null +++ b/samples/docs/js/docs.js @@ -0,0 +1,114 @@ +/* Documentation sample */ + +function loadPage(page) { + + var img = $(''); + img.load(function() { + var container = $('.sample-docs .p'+page); + img.css({width: container.width(), height: container.height()}); + img.appendTo($('.sample-docs .p'+page)); + container.find('.loader').remove(); + }); + + img.attr('src', 'pages/' + (page-2) + '.png'); + +} + +function addPage(page, book) { + + var id, pages = book.turn('pages'); + + var element = $('
', {}); + + if (book.turn('addPage', element, page)) { + if (page<28) { + element.html('
'); + loadPage(page); + } + } +} + +function updateTabs() { + + var tabs = {7: 'Clases', 12:'Constructor', 14:'Properties', 16:'Methods', 23:'Events'}, + left = [], + right = [], + book = $('.sample-docs'), + actualPage = book.turn('page'), + view = book.turn('view'); + + for (var page in tabs) { + var isHere = $.inArray(parseInt(page, 10), view)!=-1; + + if (page>actualPage && !isHere) + right.push('' + tabs[page] + ''); + else if (isHere) { + + if (page%2===0) + left.push('' + tabs[page] + ''); + else + right.push('' + tabs[page] + ''); + } else + left.push('' + tabs[page] + ''); + + } + + $('.sample-docs .tabs .left').html(left.join('')); + $('.sample-docs .tabs .right').html(right.join('')); + +} + + +function numberOfViews(book) { + return book.turn('pages') / 2 + 1; +} + + +function getViewNumber(book, page) { + return parseInt((page || book.turn('page'))/2 + 1, 10); +} + + +function moveBar(yes) { + if (Modernizr && Modernizr.csstransforms) { + $('#slider .ui-slider-handle').css({zIndex: yes ? -1 : 10000}); + } +} + +function setPreview(view) { + + var previewWidth = 115, + previewHeight = 73, + previewSrc = 'pics/preview.jpg', + preview = $(_thumbPreview.children(':first')), + numPages = (view==1 || view==$('#slider').slider('option', 'max')) ? 1 : 2, + width = (numPages==1) ? previewWidth/2 : previewWidth; + + _thumbPreview. + addClass('no-transition'). + css({width: width + 15, + height: previewHeight + 15, + top: -previewHeight - 30, + left: ($($('#slider').children(':first')).width() - width - 15)/2 + }); + + preview.css({ + width: width, + height: previewHeight + }); + + if (preview.css('background-image')==='' || + preview.css('background-image')=='none') { + + preview.css({backgroundImage: 'url(' + previewSrc + ')'}); + + setTimeout(function(){ + _thumbPreview.removeClass('no-transition'); + }, 0); + + } + + preview.css({backgroundPosition: + '0px -'+((view-1)*previewHeight)+'px' + }); +} diff --git a/samples/docs/pages/1.png b/samples/docs/pages/1.png new file mode 100644 index 0000000..6c7f790 Binary files /dev/null and b/samples/docs/pages/1.png differ diff --git a/samples/docs/pages/10.png b/samples/docs/pages/10.png new file mode 100644 index 0000000..6d6ab5d Binary files /dev/null and b/samples/docs/pages/10.png differ diff --git a/samples/docs/pages/11.png b/samples/docs/pages/11.png new file mode 100644 index 0000000..6464d24 Binary files /dev/null and b/samples/docs/pages/11.png differ diff --git a/samples/docs/pages/12.png b/samples/docs/pages/12.png new file mode 100644 index 0000000..e6b075b Binary files /dev/null and b/samples/docs/pages/12.png differ diff --git a/samples/docs/pages/13.png b/samples/docs/pages/13.png new file mode 100644 index 0000000..544b44a Binary files /dev/null and b/samples/docs/pages/13.png differ diff --git a/samples/docs/pages/14.png b/samples/docs/pages/14.png new file mode 100644 index 0000000..e8c34a1 Binary files /dev/null and b/samples/docs/pages/14.png differ diff --git a/samples/docs/pages/15.png b/samples/docs/pages/15.png new file mode 100644 index 0000000..eff52b5 Binary files /dev/null and b/samples/docs/pages/15.png differ diff --git a/samples/docs/pages/16.png b/samples/docs/pages/16.png new file mode 100644 index 0000000..71e878f Binary files /dev/null and b/samples/docs/pages/16.png differ diff --git a/samples/docs/pages/17.png b/samples/docs/pages/17.png new file mode 100644 index 0000000..e7a2c7b Binary files /dev/null and b/samples/docs/pages/17.png differ diff --git a/samples/docs/pages/18.png b/samples/docs/pages/18.png new file mode 100644 index 0000000..21f28df Binary files /dev/null and b/samples/docs/pages/18.png differ diff --git a/samples/docs/pages/19.png b/samples/docs/pages/19.png new file mode 100644 index 0000000..d870c8e Binary files /dev/null and b/samples/docs/pages/19.png differ diff --git a/samples/docs/pages/2.png b/samples/docs/pages/2.png new file mode 100644 index 0000000..8329e99 Binary files /dev/null and b/samples/docs/pages/2.png differ diff --git a/samples/docs/pages/20.png b/samples/docs/pages/20.png new file mode 100644 index 0000000..4e25003 Binary files /dev/null and b/samples/docs/pages/20.png differ diff --git a/samples/docs/pages/21.png b/samples/docs/pages/21.png new file mode 100644 index 0000000..a9149f7 Binary files /dev/null and b/samples/docs/pages/21.png differ diff --git a/samples/docs/pages/22.png b/samples/docs/pages/22.png new file mode 100644 index 0000000..7287ddb Binary files /dev/null and b/samples/docs/pages/22.png differ diff --git a/samples/docs/pages/23.png b/samples/docs/pages/23.png new file mode 100644 index 0000000..9b59f09 Binary files /dev/null and b/samples/docs/pages/23.png differ diff --git a/samples/docs/pages/24.png b/samples/docs/pages/24.png new file mode 100644 index 0000000..402cbaf Binary files /dev/null and b/samples/docs/pages/24.png differ diff --git a/samples/docs/pages/25.png b/samples/docs/pages/25.png new file mode 100644 index 0000000..4cfd0f4 Binary files /dev/null and b/samples/docs/pages/25.png differ diff --git a/samples/docs/pages/3.png b/samples/docs/pages/3.png new file mode 100644 index 0000000..3a551dc Binary files /dev/null and b/samples/docs/pages/3.png differ diff --git a/samples/docs/pages/4.png b/samples/docs/pages/4.png new file mode 100644 index 0000000..c172861 Binary files /dev/null and b/samples/docs/pages/4.png differ diff --git a/samples/docs/pages/5.png b/samples/docs/pages/5.png new file mode 100644 index 0000000..75a4a08 Binary files /dev/null and b/samples/docs/pages/5.png differ diff --git a/samples/docs/pages/6.png b/samples/docs/pages/6.png new file mode 100644 index 0000000..e9bae90 Binary files /dev/null and b/samples/docs/pages/6.png differ diff --git a/samples/docs/pages/7.png b/samples/docs/pages/7.png new file mode 100644 index 0000000..f97b295 Binary files /dev/null and b/samples/docs/pages/7.png differ diff --git a/samples/docs/pages/8.png b/samples/docs/pages/8.png new file mode 100644 index 0000000..dcdaee3 Binary files /dev/null and b/samples/docs/pages/8.png differ diff --git a/samples/docs/pages/9.png b/samples/docs/pages/9.png new file mode 100644 index 0000000..8c58d4a Binary files /dev/null and b/samples/docs/pages/9.png differ diff --git a/samples/docs/pics/covers.jpg b/samples/docs/pics/covers.jpg new file mode 100644 index 0000000..2aa6a56 Binary files /dev/null and b/samples/docs/pics/covers.jpg differ diff --git a/samples/docs/pics/covers.png b/samples/docs/pics/covers.png new file mode 100644 index 0000000..c1cf6d0 Binary files /dev/null and b/samples/docs/pics/covers.png differ diff --git a/samples/docs/pics/left-border.png b/samples/docs/pics/left-border.png new file mode 100644 index 0000000..2113eb6 Binary files /dev/null and b/samples/docs/pics/left-border.png differ diff --git a/samples/docs/pics/loader.gif b/samples/docs/pics/loader.gif new file mode 100644 index 0000000..53dd589 Binary files /dev/null and b/samples/docs/pics/loader.gif differ diff --git a/samples/docs/pics/preview.jpg b/samples/docs/pics/preview.jpg new file mode 100644 index 0000000..2602bd6 Binary files /dev/null and b/samples/docs/pics/preview.jpg differ diff --git a/samples/docs/pics/right-border.png b/samples/docs/pics/right-border.png new file mode 100644 index 0000000..cb609ad Binary files /dev/null and b/samples/docs/pics/right-border.png differ diff --git a/samples/docs/pics/tab-hover.png b/samples/docs/pics/tab-hover.png new file mode 100644 index 0000000..e581ce6 Binary files /dev/null and b/samples/docs/pics/tab-hover.png differ diff --git a/samples/docs/pics/tab-off.png b/samples/docs/pics/tab-off.png new file mode 100644 index 0000000..53b415f Binary files /dev/null and b/samples/docs/pics/tab-off.png differ diff --git a/samples/docs/pics/tab-on.png b/samples/docs/pics/tab-on.png new file mode 100644 index 0000000..4a799d7 Binary files /dev/null and b/samples/docs/pics/tab-on.png differ diff --git a/samples/double-page/css/double-page.css b/samples/double-page/css/double-page.css new file mode 100644 index 0000000..e202784 --- /dev/null +++ b/samples/double-page/css/double-page.css @@ -0,0 +1,73 @@ +/* Basic sample */ + +body{ + overflow:hidden; + background-color:#fcfcfc; + margin:0; + padding:0; +} + +.flipbook-viewport{ + overflow:hidden; + width:100%; + height:100%; +} + +.flipbook-viewport .container{ + position:absolute; + top:50%; + left:50%; + margin:auto; +} + +.flipbook-viewport .flipbook{ + width:800px; + height:400px; + left:-400px; + top:-200px; +} + +.flipbook-viewport .page{ + width:400px; + height:400px; + background-color:white; + background-repeat:no-repeat; + background-size:100% 100%; +} + +.flipbook .page{ + -webkit-box-shadow:0 0 20px rgba(0,0,0,0.2); + -moz-box-shadow:0 0 20px rgba(0,0,0,0.2); + -ms-box-shadow:0 0 20px rgba(0,0,0,0.2); + -o-box-shadow:0 0 20px rgba(0,0,0,0.2); + box-shadow:0 0 20px rgba(0,0,0,0.2); +} + +.flipbook-viewport .page img{ + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + margin:0; +} + +.flipbook-viewport .shadow{ + -webkit-transition: -webkit-box-shadow 0.5s; + -moz-transition: -moz-box-shadow 0.5s; + -o-transition: -webkit-box-shadow 0.5s; + -ms-transition: -ms-box-shadow 0.5s; + + -webkit-box-shadow:0 0 20px #ccc; + -moz-box-shadow:0 0 20px #ccc; + -o-box-shadow:0 0 20px #ccc; + -ms-box-shadow:0 0 20px #ccc; + box-shadow:0 0 20px #ccc; +} + +.flipbook-viewport .double{ + width:800px; + height:400px; + background-size:100% 100%; +} diff --git a/samples/double-page/index.html b/samples/double-page/index.html new file mode 100644 index 0000000..251cdde --- /dev/null +++ b/samples/double-page/index.html @@ -0,0 +1,75 @@ + + + + + + + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/samples/double-page/pages/1.jpg b/samples/double-page/pages/1.jpg new file mode 100644 index 0000000..83cec01 Binary files /dev/null and b/samples/double-page/pages/1.jpg differ diff --git a/samples/double-page/pages/2.jpg b/samples/double-page/pages/2.jpg new file mode 100644 index 0000000..33af94f Binary files /dev/null and b/samples/double-page/pages/2.jpg differ diff --git a/samples/double-page/pages/3.jpg b/samples/double-page/pages/3.jpg new file mode 100644 index 0000000..dc30398 Binary files /dev/null and b/samples/double-page/pages/3.jpg differ diff --git a/samples/double-page/pages/4.jpg b/samples/double-page/pages/4.jpg new file mode 100644 index 0000000..7e885d2 Binary files /dev/null and b/samples/double-page/pages/4.jpg differ diff --git a/samples/double-page/pages/5.jpg b/samples/double-page/pages/5.jpg new file mode 100644 index 0000000..3cfb6f0 Binary files /dev/null and b/samples/double-page/pages/5.jpg differ diff --git a/samples/double-page/pages/6.jpg b/samples/double-page/pages/6.jpg new file mode 100644 index 0000000..cac0c66 Binary files /dev/null and b/samples/double-page/pages/6.jpg differ diff --git a/samples/double-page/pages/7.jpg b/samples/double-page/pages/7.jpg new file mode 100644 index 0000000..31690f6 Binary files /dev/null and b/samples/double-page/pages/7.jpg differ diff --git a/samples/magazine/css/jquery.ui.css b/samples/magazine/css/jquery.ui.css new file mode 100644 index 0000000..6883f7e --- /dev/null +++ b/samples/magazine/css/jquery.ui.css @@ -0,0 +1,143 @@ +.turnjs-slider{ + width:600px; + height:8px; + background:rgba(0,0,0, 0.2); + -webkit-border-radius:5px; + -moz-border-radius:5px; + -o-border-radius:5px; + -ms-border-radius:5px; + border-radius:5px; + margin:20px auto; +} + +.turnjs-slider .thumbnail{ + width:115px; + height:85px; + position:absolute; + background:rgba(0,0,0, 0.5); + z-index:10000; + top:-100px; + left:-17px; + display:none; + + -webkit-transform:translate3d(0px, 50px, 0px) scale(0.1, 0.1); + -webkit-transition:-webkit-transform 0.2s; + -webkit-border-radius:5px; + + -moz-transform:translate3d(0px, 50px, 0px) scale(0.1, 0.1); + -moz-transition:-moz-transform 0.2s; + -moz-border-radius:5px; + + -o-transform:translate3d(0px, 50px, 0px) scale(0.1, 0.1); + -o-transition:-o-transform 0.2s; + -o-border-radius:5px; + + -ms-transform:translate3d(0px, 50px, 0px) scale(0.1, 0.1); + -ms-transition:-ms-transform 0.2s; + -ms-border-radius:5px; + + transform:translate3d(0px, 50px, 0px) scale(0.1, 0.1); + transition:transform: 0.2s; + border-radius:5px; +} + +.no-transition{ + -webkit-transition:none; + -moz-transition:none; + -o-transition:none; + -ms-transition:none; +} + +.turnjs-slider .thumbnail div{ + width:100px; + margin:7px; + height:70px; + background-color:white; +} + +.turnjs-slider .ui-state-hover .thumbnail{ + display:block; + opacity:0; +} + +.turnjs-slider .ui-state-active .thumbnail{ + display:block; + opacity:1; + -webkit-transform:scale(1, 1); + -moz-transform:scale(1, 1); + -o-transform:scale(1, 1); + -ms-transform:scale(1, 1); + transform:scale(1, 1); +} + +/* Layout helpers +----------------------------------*/ + +/* Interaction Cues +----------------------------------*/ +.ui-state-disabled { + cursor: default !important; +} + +/* Misc visuals +----------------------------------*/ + +/* Overlays */ +.turnjs-slider .ui-widget-overlay { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; +} + +.turnjs-slider .ui-slider { + position: relative; + text-align: left; +} + +.turnjs-slider .ui-slider-handle{ + position: absolute; + z-index:0; + width:80px; + height: 8px; + cursor: default; + -webkit-border-radius:5px; + -moz-border-radius:5px; + -ms-border-radius:5px; + border-radius:5px; +} + +.turnjs-slider .ui-slider-horizontal { + height: 8px; + width:520px; + margin-left:39px; +} + +.turnjs-slider .ui-slider-horizontal .ui-slider-handle { + margin-left:-40px; + margin-top:-1px; +} + +/* Interaction states +----------------------------------*/ +.turnjs-slider .ui-slider-handle{ + border:1px solid white; + background-color:black; + opacity:0.2; + display:block; + -webkit-transition:opacity 0.2s; + -moz-transition:opacity 0.2s; + -ms-transition:opacity 0.2s; + -o-transition:opacity 0.2s; + transition:opacity 0.2s; +} + +.turnjs-slider .ui-state-hover{ + opacity:0.4; +} + +.turnjs-slider .ui-state-active{ + opacity:1; +} + diff --git a/samples/magazine/css/jquery.ui.html4.css b/samples/magazine/css/jquery.ui.html4.css new file mode 100644 index 0000000..d9a0c40 --- /dev/null +++ b/samples/magazine/css/jquery.ui.html4.css @@ -0,0 +1,16 @@ +.turnjs-slide{ + width:600px; + height:8px; + background-color:#B4B4B4; + border-radius:5px; + margin:20px auto; +} + +.turnjs-slide .ui-slider .ui-slider-handle{ + background-color:#8F8F8F; + z-index:10000; +} + +.turnjs-slide .thumbnail{ + background: #666; +} \ No newline at end of file diff --git a/samples/magazine/css/magazine.css b/samples/magazine/css/magazine.css new file mode 100644 index 0000000..0595674 --- /dev/null +++ b/samples/magazine/css/magazine.css @@ -0,0 +1,384 @@ +body{ + overflow:hidden; + background-color:#fcfcfc; + margin:0; + padding:0; +} + +.magazine-viewport .container{ + position:absolute; + top:50%; + left:50%; + width:922px; + height:600px; + margin:auto; +} + +.magazine-viewport .magazine{ + width:922px; + height:600px; + left:-461px; + top:-300px; +} + +.magazine-viewport .page{ + width:461px; + height:600px; + background-color:white; + background-repeat:no-repeat; + background-size:100% 100%; +} + +.magazine-viewport .zoomer .region{ + display:none; +} + +.magazine .region{ + position:absolute; + overflow:hidden; + background:#0066FF; + opacity:0.2; + -webkit-border-radius:10px; + -moz-border-radius:10px; + -ms-border-radius:10px; + -o-border-radius:10px; + border-radius:10px; + cursor:pointer; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=20)"; + filter: alpha(opacity=20); +} + +.magazine .region:hover{ + opacity:0.5; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; + filter: alpha(opacity=50); +} + +.magazine .region.zoom{ + opacity:0.01; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=1)"; + filter: alpha(opacity=1); +} + +.magazine .region.zoom:hover{ + opacity:0.2; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=20)"; + filter: alpha(opacity=20); +} + +.magazine .page{ + -webkit-box-shadow:0 0 20px rgba(0,0,0,0.2); + -moz-box-shadow:0 0 20px rgba(0,0,0,0.2); + -ms-box-shadow:0 0 20px rgba(0,0,0,0.2); + -o-box-shadow:0 0 20px rgba(0,0,0,0.2); + box-shadow:0 0 20px rgba(0,0,0,0.2); +} + +.magazine-viewport .page img{ + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + margin:0; +} + +.magazine .even .gradient{ + position:absolute; + top:0; + left:0; + width:100%; + height:100%; + + background:-webkit-gradient(linear, left top, right top, color-stop(0.95, rgba(0,0,0,0)), color-stop(1, rgba(0,0,0,0.2))); + background-image:-webkit-linear-gradient(left, rgba(0,0,0,0) 95%, rgba(0,0,0,0.2) 100%); + background-image:-moz-linear-gradient(left, rgba(0,0,0,0) 95%, rgba(0,0,0,0.2) 100%); + background-image:-ms-linear-gradient(left, rgba(0,0,0,0) 95%, rgba(0,0,0,0.2) 100%); + background-image:-o-linear-gradient(left, rgba(0,0,0,0) 95%, rgba(0,0,0,0.2) 100%); + background-image:linear-gradient(left, rgba(0,0,0,0) 95%, rgba(0,0,0,0.2) 100%); +} + +.magazine .odd .gradient{ + position:absolute; + top:0; + left:0; + width:100%; + height:100%; + + background:-webkit-gradient(linear, right top, left top, color-stop(0.95, rgba(0,0,0,0)), color-stop(1, rgba(0,0,0,0.15))); + background-image:-webkit-linear-gradient(right, rgba(0,0,0,0) 95%, rgba(0,0,0,0.15) 100%); + background-image:-moz-linear-gradient(right, rgba(0,0,0,0) 95%, rgba(0,0,0,0.15) 100%); + background-image:-ms-linear-gradient(right, rgba(0,0,0,0) 95%, rgba(0,0,0,0.15) 100%); + background-image:-o-linear-gradient(right, rgba(0,0,0,0) 95%, rgba(0,0,0,0.15) 100%); + background-image:linear-gradient(right, rgba(0,0,0,0) 95%, rgba(0,0,0,0.15) 100%); +} + +.magazine-viewport .zoom-in .even .gradient, +.magazine-viewport .zoom-in .odd .gradient{ + + display:none; + +} + +.magazine-viewport .loader{ + background-image:url(../pics/loader.gif); + width:22px; + height:22px; + position:absolute; + top:280px; + left:219px; +} + +.magazine-viewport .shadow{ + -webkit-transition: -webkit-box-shadow 0.5s; + -moz-transition: -moz-box-shadow 0.5s; + -o-transition: -webkit-box-shadow 0.5s; + -ms-transition: -ms-box-shadow 0.5s; + + -webkit-box-shadow:0 0 20px #ccc; + -moz-box-shadow:0 0 20px #ccc; + -o-box-shadow:0 0 20px #ccc; + -ms-box-shadow:0 0 20px #ccc; + box-shadow:0 0 20px #ccc; +} + +.magazine-viewport .next-button, +.magazine-viewport .previous-button{ + width:22px; + height:600px; + position:absolute; + top:0; +} + +.magazine-viewport .next-button{ + right:-22px; + -webkit-border-radius:0 15px 15px 0; + -moz-border-radius:0 15px 15px 0; + -ms-border-radius:0 15px 15px 0; + -o-border-radius:0 15px 15px 0; + border-radius:0 15px 15px 0; +} + +.magazine-viewport .previous-button{ + left:-22px; + -webkit-border-radius:15px 0 0 15px; + -moz-border-radius:15px 0 0 15px; + -ms-border-radius:15px 0 0 15px; + -o-border-radius:15px 0 0 15px; + border-radius:15px 0 0 15px; +} + +.magazine-viewport .previous-button-hover, +.magazine-viewport .next-button-hover{ + background-color:rgba(0,0,0, 0.2); +} + +.magazine-viewport .previous-button-hover, +.magazine-viewport .previous-button-down{ + background-image:url(../pics/arrows.png); + background-position:-4px 284px; + background-repeat:no-repeat; +} + +.magazine-viewport .previous-button-down, +.magazine-viewport .next-button-down{ + background-color:rgba(0,0,0, 0.4); +} + +.magazine-viewport .next-button-hover, +.magazine-viewport .next-button-down{ + background-image:url(../pics/arrows.png); + background-position:-38px 284px; + background-repeat:no-repeat; +} + +.magazine-viewport .zoom-in .next-button, +.magazine-viewport .zoom-in .previous-button{ + display:none; +} + +.animated{ + -webkit-transition:margin-left 0.5s; + -moz-transition:margin-left 0.5s; + -ms-transition:margin-left 0.5s; + -o-transition:margin-left 0.5s; + transition:margin-left 0.5s; +} + +.thumbnails{ + position:absolute; + bottom:0; + left:0; + width:100%; + height:140px; + z-index:1; +} + +.thumbnails > div{ + width:1050px; + height:100px; + margin:20px auto; +} + +.thumbnails ul{ + margin:0; + padding:0; + text-align:center; + -webkit-transform:scale3d(0.5, 0.5, 1); + -moz-transform:scale3d(0.5, 0.5, 1); + -o-transform:scale3d(0.5, 0.5, 1); + -ms-transform:scale3d(0.5, 0.5, 1); + transform:scale3d(0.5, 0.5, 1); + -webkit-transition:-webkit-transform ease-in-out 100ms; + -moz-transition:-moz-transform ease-in-out 100ms; + -ms-transition:-ms-transform ease-in-out 100ms; + -o-transition:-o-transform ease-in-out 100ms; + transition:transform ease-in-out 100ms; +} + +.thumbanils-touch ul{ + -webkit-transform:none; + -moz-transform:none; + -o-transform:none; + -ms-transform:none; + transform:none; +} + +.thumbnails-hover ul{ + -webkit-transform:scale3d(0.6, 0.6, 1); + -moz-transform:scale3d(0.6, 0.6, 1); + -o-transform:scale3d(0.6, 0.6, 1); + -ms-transform:scale3d(0.6, 0.6, 1); + transform:scale3d(0.6, 0.6, 1); +} + +.thumbnails li{ + list-style:none; + display:inline-block; + margin:0 5px; + -webkit-box-shadow:0 0 10px #ccc; + -moz-box-shadow:0 0 10px #ccc; + -ms-box-shadow:0 0 10px #ccc; + -o-box-shadow:0 0 10px #ccc; + box-shadow:0 0 10px #ccc; + -webkit-transition:-webkit-transform 60ms; + -moz-transition:-webkit-transform 60ms; + -o-transition:-webkit-transform 60ms; + -ms-transition:-webkit-transform 60ms; + transition:-webkit-transform 60ms; +} + +.thumbnails li span{ + display:none; +} + +.thumbnails .current{ + -webkit-box-shadow:0 0 10px red; + -moz-box-shadow:0 0 10px red; + -ms-box-shadow:0 0 10px red; + -o-box-shadow:0 0 10px red; + box-shadow:0 0 10px red; +} + +.thumbnails .thumb-hover{ + -webkit-transform:scale3d(1.3, 1.3, 1); + -moz-transform:scale3d(1.3, 1.3, 1); + -o-transform:scale3d(1.3, 1.3, 1); + -ms-transform:scale3d(1.3, 1.3, 1); + transform:scale3d(1.3, 1.3, 1); + + -webkit-box-shadow:0 0 10px #666; + -moz-box-shadow:0 0 10px #666; + -ms-box-shadow:0 0 10px #666; + -o-box-shadow:0 0 10px #666; + box-shadow:0 0 10px #666; +} + +.thumbanils-touch .thumb-hover{ + -webkit-transform:none; + -moz-transform:none; + -o-transform:none; + -ms-transform:none; + transform:none; +} + +.thumbnails .thumb-hover span{ + position:absolute; + bottom:-30px; + left:0; + z-index:2; + width:100%; + height:30px; + font:bold 15px arial; + line-height:30px; + color:#666; + display:block; + cursor:default; +} + +.thumbnails img{ + float:left; +} + +.exit-message{ + position: absolute; + top:10px; + left:0; + width:100%; + height:40px; + z-index:10000; +} + +.exit-message > div{ + width:140px; + height:30px; + margin:auto; + background:rgba(0,0,0,0.5); + text-align:center; + font:12px arial; + line-height:30px; + color:white; + -webkit-border-radius:10px; + -moz-border-radius:10px; + -ms-border-radius:10px; + -o-border-radius:10px; + border-radius:10px; +} + +.zoom-icon{ + position:absolute; + z-index:1000; + width:22px; + height:22px; + top:10px; + right:10px; + background-image:url(../pics/zoom-icons.png); + background-size:88px 22px; +} + +.zoom-icon-in{ + background-position:0 0; + cursor: pointer; +} + +.zoom-icon-in.zoom-icon-in-hover{ + background-position:-22px 0; + cursor: pointer; +} + +.zoom-icon-out{ + background-position:-44px 0; +} + +.zoom-icon-out.zoom-icon-out-hover{ + background-position:-66px 0; + cursor: pointer; +} + +.bottom{ + position:absolute; + left:0; + bottom:0; + width:100%; +} \ No newline at end of file diff --git a/samples/magazine/index.html b/samples/magazine/index.html new file mode 100644 index 0000000..bce12ba --- /dev/null +++ b/samples/magazine/index.html @@ -0,0 +1,469 @@ + + + + + + + +Using turn.js and the new zoom feature + + + + + + + + +
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + +
+
+
    +
  • + + 1 +
  • +
  • + + + 2-3 +
  • +
  • + + + 4-5 +
  • +
  • + + + 6-7 +
  • +
  • + + + 8-9 +
  • +
  • + + + 10-11 +
  • +
  • + + 12 +
  • +
      +
      +
      +
+ + + + + \ No newline at end of file diff --git a/samples/magazine/js/magazine.js b/samples/magazine/js/magazine.js new file mode 100644 index 0000000..d6b22dc --- /dev/null +++ b/samples/magazine/js/magazine.js @@ -0,0 +1,385 @@ +/* + * Magazine sample +*/ + +function addPage(page, book) { + + var id, pages = book.turn('pages'); + + // Create a new element for this page + var element = $('
', {}); + + // Add the page to the flipbook + if (book.turn('addPage', element, page)) { + + // Add the initial HTML + // It will contain a loader indicator and a gradient + element.html('
'); + + // Load the page + loadPage(page, element); + } + +} + +function loadPage(page, pageElement) { + + // Create an image element + + var img = $(''); + + img.mousedown(function(e) { + e.preventDefault(); + }); + + img.load(function() { + + // Set the size + $(this).css({width: '100%', height: '100%'}); + + // Add the image to the page after loaded + + $(this).appendTo(pageElement); + + // Remove the loader indicator + + pageElement.find('.loader').remove(); + }); + + // Load the page + + img.attr('src', 'pages/' + page + '.jpg'); + + loadRegions(page, pageElement); + +} + +// Zoom in / Zoom out + +function zoomTo(event) { + + setTimeout(function() { + if ($('.magazine-viewport').data().regionClicked) { + $('.magazine-viewport').data().regionClicked = false; + } else { + if ($('.magazine-viewport').zoom('value')==1) { + $('.magazine-viewport').zoom('zoomIn', event); + } else { + $('.magazine-viewport').zoom('zoomOut'); + } + } + }, 1); + +} + + + +// Load regions + +function loadRegions(page, element) { + + $.getJSON('pages/'+page+'-regions.json'). + done(function(data) { + + $.each(data, function(key, region) { + addRegion(region, element); + }); + }); +} + +// Add region + +function addRegion(region, pageElement) { + + var reg = $('
', {'class': 'region ' + region['class']}), + options = $('.magazine').turn('options'), + pageWidth = options.width/2, + pageHeight = options.height; + + reg.css({ + top: Math.round(region.y/pageHeight*100)+'%', + left: Math.round(region.x/pageWidth*100)+'%', + width: Math.round(region.width/pageWidth*100)+'%', + height: Math.round(region.height/pageHeight*100)+'%' + }).attr('region-data', $.param(region.data||'')); + + + reg.appendTo(pageElement); +} + +// Process click on a region + +function regionClick(event) { + + var region = $(event.target); + + if (region.hasClass('region')) { + + $('.magazine-viewport').data().regionClicked = true; + + setTimeout(function() { + $('.magazine-viewport').data().regionClicked = false; + }, 100); + + var regionType = $.trim(region.attr('class').replace('region', '')); + + return processRegion(region, regionType); + + } + +} + +// Process the data of every region + +function processRegion(region, regionType) { + + data = decodeParams(region.attr('region-data')); + + switch (regionType) { + case 'link' : + + window.open(data.url); + + break; + case 'zoom' : + + var regionOffset = region.offset(), + viewportOffset = $('.magazine-viewport').offset(), + pos = { + x: regionOffset.left-viewportOffset.left, + y: regionOffset.top-viewportOffset.top + }; + + $('.magazine-viewport').zoom('zoomIn', pos); + + break; + case 'to-page' : + + $('.magazine').turn('page', data.page); + + break; + } + +} + +// Load large page + +function loadLargePage(page, pageElement) { + + var img = $(''); + + img.load(function() { + + var prevImg = pageElement.find('img'); + $(this).css({width: '100%', height: '100%'}); + $(this).appendTo(pageElement); + prevImg.remove(); + + }); + + // Loadnew page + + img.attr('src', 'pages/' + page + '-large.jpg'); +} + +// Load small page + +function loadSmallPage(page, pageElement) { + + var img = pageElement.find('img'); + + img.css({width: '100%', height: '100%'}); + + img.unbind('load'); + // Loadnew page + + img.attr('src', 'pages/' + page + '.jpg'); +} + +// http://code.google.com/p/chromium/issues/detail?id=128488 + +function isChrome() { + + return navigator.userAgent.indexOf('Chrome')!=-1; + +} + +function disableControls(page) { + if (page==1) + $('.previous-button').hide(); + else + $('.previous-button').show(); + + if (page==$('.magazine').turn('pages')) + $('.next-button').hide(); + else + $('.next-button').show(); +} + +// Set the width and height for the viewport + +function resizeViewport() { + + var width = $(window).width(), + height = $(window).height(), + options = $('.magazine').turn('options'); + + $('.magazine').removeClass('animated'); + + $('.magazine-viewport').css({ + width: width, + height: height + }). + zoom('resize'); + + + if ($('.magazine').turn('zoom')==1) { + var bound = calculateBound({ + width: options.width, + height: options.height, + boundWidth: Math.min(options.width, width), + boundHeight: Math.min(options.height, height) + }); + + if (bound.width%2!==0) + bound.width-=1; + + + if (bound.width!=$('.magazine').width() || bound.height!=$('.magazine').height()) { + + $('.magazine').turn('size', bound.width, bound.height); + + if ($('.magazine').turn('page')==1) + $('.magazine').turn('peel', 'br'); + + $('.next-button').css({height: bound.height, backgroundPosition: '-38px '+(bound.height/2-32/2)+'px'}); + $('.previous-button').css({height: bound.height, backgroundPosition: '-4px '+(bound.height/2-32/2)+'px'}); + } + + $('.magazine').css({top: -bound.height/2, left: -bound.width/2}); + } + + var magazineOffset = $('.magazine').offset(), + boundH = height - magazineOffset.top - $('.magazine').height(), + marginTop = (boundH - $('.thumbnails > div').height()) / 2; + + if (marginTop<0) { + $('.thumbnails').css({height:1}); + } else { + $('.thumbnails').css({height: boundH}); + $('.thumbnails > div').css({marginTop: marginTop}); + } + + if (magazineOffset.top<$('.made').height()) + $('.made').hide(); + else + $('.made').show(); + + $('.magazine').addClass('animated'); + +} + + +// Number of views in a flipbook + +function numberOfViews(book) { + return book.turn('pages') / 2 + 1; +} + +// Current view in a flipbook + +function getViewNumber(book, page) { + return parseInt((page || book.turn('page'))/2 + 1, 10); +} + +function moveBar(yes) { + if (Modernizr && Modernizr.csstransforms) { + $('#slider .ui-slider-handle').css({zIndex: yes ? -1 : 10000}); + } +} + +function setPreview(view) { + + var previewWidth = 112, + previewHeight = 73, + previewSrc = 'pages/preview.jpg', + preview = $(_thumbPreview.children(':first')), + numPages = (view==1 || view==$('#slider').slider('option', 'max')) ? 1 : 2, + width = (numPages==1) ? previewWidth/2 : previewWidth; + + _thumbPreview. + addClass('no-transition'). + css({width: width + 15, + height: previewHeight + 15, + top: -previewHeight - 30, + left: ($($('#slider').children(':first')).width() - width - 15)/2 + }); + + preview.css({ + width: width, + height: previewHeight + }); + + if (preview.css('background-image')==='' || + preview.css('background-image')=='none') { + + preview.css({backgroundImage: 'url(' + previewSrc + ')'}); + + setTimeout(function(){ + _thumbPreview.removeClass('no-transition'); + }, 0); + + } + + preview.css({backgroundPosition: + '0px -'+((view-1)*previewHeight)+'px' + }); +} + +// Width of the flipbook when zoomed in + +function largeMagazineWidth() { + + return 2214; + +} + +// decode URL Parameters + +function decodeParams(data) { + + var parts = data.split('&'), d, obj = {}; + + for (var i =0; id.boundWidth || bound.height>d.boundHeight) { + + var rel = bound.width/bound.height; + + if (d.boundWidth/rel>d.boundHeight && d.boundHeight*rel<=d.boundWidth) { + + bound.width = Math.round(d.boundHeight*rel); + bound.height = d.boundHeight; + + } else { + + bound.width = d.boundWidth; + bound.height = Math.round(d.boundWidth/rel); + + } + } + + return bound; +} \ No newline at end of file diff --git a/samples/magazine/pages/1-large.jpg b/samples/magazine/pages/1-large.jpg new file mode 100644 index 0000000..cbdffde Binary files /dev/null and b/samples/magazine/pages/1-large.jpg differ diff --git a/samples/magazine/pages/1-regions.json b/samples/magazine/pages/1-regions.json new file mode 100644 index 0000000..bf8ff3b --- /dev/null +++ b/samples/magazine/pages/1-regions.json @@ -0,0 +1,12 @@ +[{ + "x":22, + "y":568, + "width":130, + "height":12, + "class":"link", + "data": + { + "url": "http://latimes.com/shopping/vegas" + } +} +] \ No newline at end of file diff --git a/samples/magazine/pages/1-thumb.jpg b/samples/magazine/pages/1-thumb.jpg new file mode 100644 index 0000000..0503c16 Binary files /dev/null and b/samples/magazine/pages/1-thumb.jpg differ diff --git a/samples/magazine/pages/1.jpg b/samples/magazine/pages/1.jpg new file mode 100644 index 0000000..903286e Binary files /dev/null and b/samples/magazine/pages/1.jpg differ diff --git a/samples/magazine/pages/10-large.jpg b/samples/magazine/pages/10-large.jpg new file mode 100644 index 0000000..e166acd Binary files /dev/null and b/samples/magazine/pages/10-large.jpg differ diff --git a/samples/magazine/pages/10-regions.json b/samples/magazine/pages/10-regions.json new file mode 100644 index 0000000..55f1f15 --- /dev/null +++ b/samples/magazine/pages/10-regions.json @@ -0,0 +1,8 @@ +[{ + "x":0, + "y":135, + "width":423, + "height":182, + "class":"zoom" +} +] \ No newline at end of file diff --git a/samples/magazine/pages/10-thumb.jpg b/samples/magazine/pages/10-thumb.jpg new file mode 100644 index 0000000..38e167d Binary files /dev/null and b/samples/magazine/pages/10-thumb.jpg differ diff --git a/samples/magazine/pages/10.jpg b/samples/magazine/pages/10.jpg new file mode 100644 index 0000000..8fd263a Binary files /dev/null and b/samples/magazine/pages/10.jpg differ diff --git a/samples/magazine/pages/11-large.jpg b/samples/magazine/pages/11-large.jpg new file mode 100644 index 0000000..736f54a Binary files /dev/null and b/samples/magazine/pages/11-large.jpg differ diff --git a/samples/magazine/pages/11-regions.json b/samples/magazine/pages/11-regions.json new file mode 100644 index 0000000..72a2959 --- /dev/null +++ b/samples/magazine/pages/11-regions.json @@ -0,0 +1,15 @@ +[{ + "x":181, + "y":386, + "width":102, + "height":214, + "class":"zoom" +}, +{ + "x":289, + "y":253, + "width":173, + "height":312, + "class":"zoom" +} +] \ No newline at end of file diff --git a/samples/magazine/pages/11-thumb.jpg b/samples/magazine/pages/11-thumb.jpg new file mode 100644 index 0000000..fcc680f Binary files /dev/null and b/samples/magazine/pages/11-thumb.jpg differ diff --git a/samples/magazine/pages/11.jpg b/samples/magazine/pages/11.jpg new file mode 100644 index 0000000..b93324f Binary files /dev/null and b/samples/magazine/pages/11.jpg differ diff --git a/samples/magazine/pages/12-large.jpg b/samples/magazine/pages/12-large.jpg new file mode 100644 index 0000000..cf88aec Binary files /dev/null and b/samples/magazine/pages/12-large.jpg differ diff --git a/samples/magazine/pages/12-regions.json b/samples/magazine/pages/12-regions.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/samples/magazine/pages/12-regions.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/samples/magazine/pages/12-thumb.jpg b/samples/magazine/pages/12-thumb.jpg new file mode 100644 index 0000000..4bd2ba1 Binary files /dev/null and b/samples/magazine/pages/12-thumb.jpg differ diff --git a/samples/magazine/pages/12.jpg b/samples/magazine/pages/12.jpg new file mode 100644 index 0000000..13908a9 Binary files /dev/null and b/samples/magazine/pages/12.jpg differ diff --git a/samples/magazine/pages/2-large.jpg b/samples/magazine/pages/2-large.jpg new file mode 100644 index 0000000..962c8e2 Binary files /dev/null and b/samples/magazine/pages/2-large.jpg differ diff --git a/samples/magazine/pages/2-regions.json b/samples/magazine/pages/2-regions.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/samples/magazine/pages/2-regions.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/samples/magazine/pages/2-thumb.jpg b/samples/magazine/pages/2-thumb.jpg new file mode 100644 index 0000000..65c1a1d Binary files /dev/null and b/samples/magazine/pages/2-thumb.jpg differ diff --git a/samples/magazine/pages/2.jpg b/samples/magazine/pages/2.jpg new file mode 100644 index 0000000..a4f5e51 Binary files /dev/null and b/samples/magazine/pages/2.jpg differ diff --git a/samples/magazine/pages/3-large.jpg b/samples/magazine/pages/3-large.jpg new file mode 100644 index 0000000..3930b4c Binary files /dev/null and b/samples/magazine/pages/3-large.jpg differ diff --git a/samples/magazine/pages/3-regions.json b/samples/magazine/pages/3-regions.json new file mode 100644 index 0000000..9c3ae40 --- /dev/null +++ b/samples/magazine/pages/3-regions.json @@ -0,0 +1,45 @@ +[{ + "x":256, + "y":161, + "width":128, + "height":15, + "class":"to-page", + "data": + { + "page": 8 + } +}, +{ + "x":256, + "y":202, + "width":114, + "height":15, + "class":"to-page", + "data": + { + "page": 10 + } +}, +{ + "x":256, + "y":244, + "width":126, + "height":15, + "class":"to-page", + "data": + { + "page": 12 + } +}, +{ + "x":256, + "y":286, + "width":68, + "height":15, + "class":"to-page", + "data": + { + "page": 12 + } +} +] \ No newline at end of file diff --git a/samples/magazine/pages/3-thumb.jpg b/samples/magazine/pages/3-thumb.jpg new file mode 100644 index 0000000..63826ee Binary files /dev/null and b/samples/magazine/pages/3-thumb.jpg differ diff --git a/samples/magazine/pages/3.jpg b/samples/magazine/pages/3.jpg new file mode 100644 index 0000000..f4f662f Binary files /dev/null and b/samples/magazine/pages/3.jpg differ diff --git a/samples/magazine/pages/4-large.jpg b/samples/magazine/pages/4-large.jpg new file mode 100644 index 0000000..a8453b3 Binary files /dev/null and b/samples/magazine/pages/4-large.jpg differ diff --git a/samples/magazine/pages/4-regions.json b/samples/magazine/pages/4-regions.json new file mode 100644 index 0000000..d4bf79e --- /dev/null +++ b/samples/magazine/pages/4-regions.json @@ -0,0 +1,22 @@ +[{ + "x":287, + "y":0, + "width":171, + "height":143, + "class":"zoom" +}, +{ + "x":287, + "y":155, + "width":175, + "height":134, + "class":"zoom" +}, +{ + "x":0, + "y":264, + "width":177, + "height":123, + "class":"zoom" +} +] \ No newline at end of file diff --git a/samples/magazine/pages/4-thumb.jpg b/samples/magazine/pages/4-thumb.jpg new file mode 100644 index 0000000..c3d05db Binary files /dev/null and b/samples/magazine/pages/4-thumb.jpg differ diff --git a/samples/magazine/pages/4.jpg b/samples/magazine/pages/4.jpg new file mode 100644 index 0000000..fa1287a Binary files /dev/null and b/samples/magazine/pages/4.jpg differ diff --git a/samples/magazine/pages/5-large.jpg b/samples/magazine/pages/5-large.jpg new file mode 100644 index 0000000..cd943e1 Binary files /dev/null and b/samples/magazine/pages/5-large.jpg differ diff --git a/samples/magazine/pages/5-regions.json b/samples/magazine/pages/5-regions.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/samples/magazine/pages/5-regions.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/samples/magazine/pages/5-thumb.jpg b/samples/magazine/pages/5-thumb.jpg new file mode 100644 index 0000000..d051967 Binary files /dev/null and b/samples/magazine/pages/5-thumb.jpg differ diff --git a/samples/magazine/pages/5.jpg b/samples/magazine/pages/5.jpg new file mode 100644 index 0000000..b13d733 Binary files /dev/null and b/samples/magazine/pages/5.jpg differ diff --git a/samples/magazine/pages/6-large.jpg b/samples/magazine/pages/6-large.jpg new file mode 100644 index 0000000..56951a3 Binary files /dev/null and b/samples/magazine/pages/6-large.jpg differ diff --git a/samples/magazine/pages/6-regions.json b/samples/magazine/pages/6-regions.json new file mode 100644 index 0000000..abeea3a --- /dev/null +++ b/samples/magazine/pages/6-regions.json @@ -0,0 +1,22 @@ +[{ + "x":270, + "y":0, + "width":161, + "height":148, + "class":"zoom" +}, +{ + "x":51, + "y":77, + "width":174, + "height":141, + "class":"zoom" +}, +{ + "x":33, + "y":448, + "width":398, + "height":113, + "class":"zoom" +} +] \ No newline at end of file diff --git a/samples/magazine/pages/6-thumb.jpg b/samples/magazine/pages/6-thumb.jpg new file mode 100644 index 0000000..b574e6a Binary files /dev/null and b/samples/magazine/pages/6-thumb.jpg differ diff --git a/samples/magazine/pages/6.jpg b/samples/magazine/pages/6.jpg new file mode 100644 index 0000000..a10d7db Binary files /dev/null and b/samples/magazine/pages/6.jpg differ diff --git a/samples/magazine/pages/7-large.jpg b/samples/magazine/pages/7-large.jpg new file mode 100644 index 0000000..3e69a03 Binary files /dev/null and b/samples/magazine/pages/7-large.jpg differ diff --git a/samples/magazine/pages/7-regions.json b/samples/magazine/pages/7-regions.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/samples/magazine/pages/7-regions.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/samples/magazine/pages/7-thumb.jpg b/samples/magazine/pages/7-thumb.jpg new file mode 100644 index 0000000..8c6f467 Binary files /dev/null and b/samples/magazine/pages/7-thumb.jpg differ diff --git a/samples/magazine/pages/7.jpg b/samples/magazine/pages/7.jpg new file mode 100644 index 0000000..7a7c683 Binary files /dev/null and b/samples/magazine/pages/7.jpg differ diff --git a/samples/magazine/pages/8-large.jpg b/samples/magazine/pages/8-large.jpg new file mode 100644 index 0000000..bd40f71 Binary files /dev/null and b/samples/magazine/pages/8-large.jpg differ diff --git a/samples/magazine/pages/8-regions.json b/samples/magazine/pages/8-regions.json new file mode 100644 index 0000000..d1ba655 --- /dev/null +++ b/samples/magazine/pages/8-regions.json @@ -0,0 +1,29 @@ +[{ + "x":33, + "y":145, + "width":186, + "height":99, + "class":"zoom" +}, +{ + "x":33, + "y":247, + "width":186, + "height":99, + "class":"zoom" +}, +{ + "x":33, + "y":349, + "width":186, + "height":99, + "class":"zoom" +}, +{ + "x":33, + "y":450, + "width":186, + "height":99, + "class":"zoom" +} +] \ No newline at end of file diff --git a/samples/magazine/pages/8-thumb.jpg b/samples/magazine/pages/8-thumb.jpg new file mode 100644 index 0000000..3f8ec82 Binary files /dev/null and b/samples/magazine/pages/8-thumb.jpg differ diff --git a/samples/magazine/pages/8.jpg b/samples/magazine/pages/8.jpg new file mode 100644 index 0000000..ea805c4 Binary files /dev/null and b/samples/magazine/pages/8.jpg differ diff --git a/samples/magazine/pages/9-large.jpg b/samples/magazine/pages/9-large.jpg new file mode 100644 index 0000000..56af1db Binary files /dev/null and b/samples/magazine/pages/9-large.jpg differ diff --git a/samples/magazine/pages/9-regions.json b/samples/magazine/pages/9-regions.json new file mode 100644 index 0000000..69ff845 --- /dev/null +++ b/samples/magazine/pages/9-regions.json @@ -0,0 +1,12 @@ +[{ + "x":29, + "y":558, + "width":117, + "height":14, + "class":"link", + "data" : + { + "url": "http://www.celineinvegas.com" + } +} +] \ No newline at end of file diff --git a/samples/magazine/pages/9-thumb.jpg b/samples/magazine/pages/9-thumb.jpg new file mode 100644 index 0000000..5bf43da Binary files /dev/null and b/samples/magazine/pages/9-thumb.jpg differ diff --git a/samples/magazine/pages/9.jpg b/samples/magazine/pages/9.jpg new file mode 100644 index 0000000..7b3c75f Binary files /dev/null and b/samples/magazine/pages/9.jpg differ diff --git a/samples/magazine/pages/preview.jpg b/samples/magazine/pages/preview.jpg new file mode 100644 index 0000000..5d7670b Binary files /dev/null and b/samples/magazine/pages/preview.jpg differ diff --git a/samples/magazine/pics/arrows.png b/samples/magazine/pics/arrows.png new file mode 100644 index 0000000..6a1e426 Binary files /dev/null and b/samples/magazine/pics/arrows.png differ diff --git a/samples/magazine/pics/loader.gif b/samples/magazine/pics/loader.gif new file mode 100644 index 0000000..53dd589 Binary files /dev/null and b/samples/magazine/pics/loader.gif differ diff --git a/samples/magazine/pics/zoom-icons-editable.png b/samples/magazine/pics/zoom-icons-editable.png new file mode 100644 index 0000000..03ae9fe Binary files /dev/null and b/samples/magazine/pics/zoom-icons-editable.png differ diff --git a/samples/magazine/pics/zoom-icons.png b/samples/magazine/pics/zoom-icons.png new file mode 100644 index 0000000..4a02713 Binary files /dev/null and b/samples/magazine/pics/zoom-icons.png differ diff --git a/samples/magazine/pics/zoom.png b/samples/magazine/pics/zoom.png new file mode 100644 index 0000000..f9325eb Binary files /dev/null and b/samples/magazine/pics/zoom.png differ diff --git a/samples/magazine/slider.html b/samples/magazine/slider.html new file mode 100644 index 0000000..1db68ad --- /dev/null +++ b/samples/magazine/slider.html @@ -0,0 +1,400 @@ + + + +Using turn.js and the new zoom feature + + + + + + + + + +
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/samples/steve-jobs/css/jquery.ui.css b/samples/steve-jobs/css/jquery.ui.css new file mode 100644 index 0000000..2f1b638 --- /dev/null +++ b/samples/steve-jobs/css/jquery.ui.css @@ -0,0 +1,143 @@ +.turnjs-slider{ + width:600px; + height:8px; + background:rgba(0,0,0, 0.2); + -webkit-border-radius:5px; + -moz-border-radius:5px; + -o-border-radius:5px; + -ms-border-radius:5px; + border-radius:5px; + margin:20px auto; +} + +.turnjs-slider .thumbnail{ + width:115px; + height:85px; + position:absolute; + background:rgba(0,0,0, 0.5); + z-index:10000; + top:-100px; + left:-17px; + display:none; + + -webkit-transform:translate3d(0px, 50px, 0px) scale(0.1, 0.1); + -webkit-transition:-webkit-transform 0.2s; + -webkit-border-radius:5px; + + -moz-transform:translate3d(0px, 50px, 0px) scale(0.1, 0.1); + -moz-transition:-moz-transform 0.2s; + -moz-border-radius:5px; + + -o-transform:translate3d(0px, 50px, 0px) scale(0.1, 0.1); + -o-transition:-o-transform 0.2s; + -o-border-radius:5px; + + -ms-transform:translate3d(0px, 50px, 0px) scale(0.1, 0.1); + -ms-transition:-ms-transform 0.2s; + -ms-border-radius:5px; + + transform:translate3d(0px, 50px, 0px) scale(0.1, 0.1); + transition:transform 0.2s; + border-radius:5px; +} + +.no-transition{ + -webkit-transition:none; + -moz-transition:none; + -o-transition:none; + -ms-transition:none; +} + +.turnjs-slider .thumbnail div{ + width:100px; + margin:7px; + height:70px; + background-color:white; +} + +.turnjs-slider .ui-state-hover .thumbnail{ + display:block; + opacity:0; +} + +.turnjs-slider .ui-state-active .thumbnail{ + display:block; + opacity:1; + -webkit-transform:scale(1, 1); + -moz-transform:scale(1, 1); + -o-transform:scale(1, 1); + -ms-transform:scale(1, 1); + transform:scale(1, 1); +} + +/* Layout helpers +----------------------------------*/ + +/* Interaction Cues +----------------------------------*/ +.ui-state-disabled { + cursor: default !important; +} + +/* Misc visuals +----------------------------------*/ + +/* Overlays */ +.turnjs-slider .ui-widget-overlay { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; +} + +.turnjs-slider .ui-slider { + position: relative; + text-align: left; +} + +.turnjs-slider .ui-slider-handle{ + position: absolute; + z-index:0; + width:80px; + height: 8px; + cursor: default; + -webkit-border-radius:5px; + -moz-border-radius:5px; + -ms-border-radius:5px; + border-radius:5px; +} + +.turnjs-slider .ui-slider-horizontal { + height: 8px; + width:520px; + margin-left:39px; +} + +.turnjs-slider .ui-slider-horizontal .ui-slider-handle { + margin-left:-40px; + margin-top:-1px; +} + +/* Interaction states +----------------------------------*/ +.turnjs-slider .ui-slider-handle{ + border:1px solid white; + background-color:black; + opacity:0.2; + display:block; + -webkit-transition:opacity 0.2s; + -moz-transition:opacity 0.2s; + -ms-transition:opacity 0.2s; + -o-transition:opacity 0.2s; + transition:opacity 0.2s; +} + +.turnjs-slider .ui-state-hover{ + opacity:0.4; +} + +.turnjs-slider .ui-state-active{ + opacity:1; +} + diff --git a/samples/steve-jobs/css/jquery.ui.html4.css b/samples/steve-jobs/css/jquery.ui.html4.css new file mode 100644 index 0000000..d9a0c40 --- /dev/null +++ b/samples/steve-jobs/css/jquery.ui.html4.css @@ -0,0 +1,16 @@ +.turnjs-slide{ + width:600px; + height:8px; + background-color:#B4B4B4; + border-radius:5px; + margin:20px auto; +} + +.turnjs-slide .ui-slider .ui-slider-handle{ + background-color:#8F8F8F; + z-index:10000; +} + +.turnjs-slide .thumbnail{ + background: #666; +} \ No newline at end of file diff --git a/samples/steve-jobs/css/steve-jobs-html4.css b/samples/steve-jobs/css/steve-jobs-html4.css new file mode 100644 index 0000000..80c32c2 --- /dev/null +++ b/samples/steve-jobs/css/steve-jobs-html4.css @@ -0,0 +1,14 @@ +/* Steve jobs' book */ + +.sj-book .even{ + background-image:url(../pics/gradient-page-left.jpg); + background-position:right top; + background-repeat:repeat-y; +} + +.sj-book .odd{ + background-image:url(../pics/gradient-page-right.jpg); + background-position:left top; + background-repeat:repeat-y; +} + diff --git a/samples/steve-jobs/css/steve-jobs.css b/samples/steve-jobs/css/steve-jobs.css new file mode 100644 index 0000000..334bc2f --- /dev/null +++ b/samples/steve-jobs/css/steve-jobs.css @@ -0,0 +1,375 @@ +/* Steve jobs' book */ + +@font-face { + font-family: 'Stempel-Garamond-W01-Roman'; + font-style: normal; + font-weight: normal; + src: url('../fonts/Stempel-Garamond-W01-Roman.woff') format('woff'); +} + +body, ul, table, form{ + margin:0; + padding:0; + overflow:hidden; +} + +.animated{ + -webkit-transition:margin-left 0.2s ease-in-out; + -moz-transition:margin-left 0.2s ease-in-out; + -o-transition:margin-left 0.2s ease-in-out; + -ms-transition:margin-left 0.2s ease-in-out; + transition:margin-left 0.2s ease-in-out; +} + +#canvas{ + width: 960px; + height: 600px; + margin: 100px auto; +} + +#book-zoom{ + -webkit-transition: -webkit-transform 1s; + -moz-transition: -moz-transform 1s; + -ms-transition: -ms-transform 1s; + -o-transition: -o-transform 1s; + transition: transform 1s; +} + +.sj-book{ + width:960px; + height:600px; +} + +.sj-book h1{ + font-family: "Stempel-Garamond-W01-Roman"; + font-size: 38px; + font-weight: lighter; + margin: 20px 0; + color: #333; + -webkit-text-fill-color: #333; + -webkit-text-stroke-color: white; + -webkit-text-stroke-width: 0.005em; +} + +.sj-book h2{ + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + color:#444; + font-size:16px; + letter-spacing:2px; + font-weight: 400; +} + +.sj-book .book-content{ + font-family: "Stempel-Garamond-W01-Roman"; + font-size:16px; + margin:70px 40px; +} + +.sj-book blockquote{ + color:#586078; + margin:10px 0; + font-style:italic; +} + +.sj-book blockquote:before{ + content: "\201C"; + color:#333D53; + font-size:20px; +} + +.sj-book blockquote:after{ + content: "\201D"; + color:#333D53; + font-size:20px; +} + +.sj-book cite{ + font-family:"Helvetica Neue", Helvetica, Arial, sans-serif; + font-size:13px; + font-weight:200; + font-style:normal; + color:#666; +} + +.sj-book .book-content .center-pic{ + margin:0; + text-indent:0; + text-align:center; +} + +.sj-book .zoom-this:hover{ + opacity:0.9; + cursor:pointer; +} + +.sj-book .book-content p{ + text-indent: 18px; + margin: 20px 0; + line-height: 22px; +} + +.sj-book .left-pic{ + float:left; + margin-top:15px; + margin-right:15px; + margin-bottom:15px; +} + +.animated{ + -webkit-transition:margin-left 0.2s ease-in-out; + -moz-transition:margin-left 0.2s ease-in-out; + -o-transition:margin-left 0.2s ease-in-out; + -ms-transition:margin-left 0.2s ease-in-out; + transition:margin-left 0.2s ease-in-out; +} + +.sj-book .shadow{ + -webkit-transition: -webkit-box-shadow 0.5s; + -moz-transition: -moz-box-shadow 0.5s; + -o-transition: -webkit-box-shadow 0.5s; + -ms-transition: -ms-box-shadow 0.5s; + + -webkit-box-shadow:0 0 10px #999; + -moz-box-shadow:0 0 10px #999; + -ms-box-shadow:0 0 10px #999; + -o-box-shadow:0 0 10px #999; + box-shadow:0 0 10px #999; +} + +.sj-book .page{ + -webkit-box-shadow:0 0 20px rgba(0,0,0,0.2); + -moz-box-shadow:0 0 20px rgba(0,0,0,0.2); + -ms-box-shadow:0 0 20px rgba(0,0,0,0.2); + -o-box-shadow:0 0 20px rgba(0,0,0,0.2); + box-shadow:0 0 20px rgba(0,0,0,0.2); +} + +.zoom-pic{ + position:absolute; + top:0; + left:0; + width:100%; + height:100%; + background-color:rgba(0,0,0,0.2); + z-index:999; +} + +.zoom-pic img{ + -webkit-box-shadow:0 0 20px #999; + -moz-box-shadow:0 0 20px #999; + -o-box-shadow:0 0 20px #999; + -ms-box-shadow:0 0 20px #999; + box-shadow:0 0 20px #999; +} + +.sj-book .p1, +.sj-book .p2, +.sj-book .p3, +.sj-book .p111, +.sj-book .p112{ + background-color:white; + background-image:url(../pics/book-covers.jpg) !important; +} + +.sj-book .p1{ + background-position:0 0; +} + +.sj-book .p1 .side{ + width:5px; + height:600px; + position:absolute; + top:0; + left:475px; + + background:-webkit-gradient(linear, left top, left bottom, color-stop(0, #bbb), color-stop(0.5, #ddd), color-stop(1, #bbb)); + background-image:-webkit-linear-gradient(left, #bbb, #ddd, #bbb); + background-image:-moz-linear-gradient(left, #bbb, #ddd, #bbb); + background-image:-ms-linear-gradient(left, #bbb, #ddd, #bbb); + background-image:-o-linear-gradient(left, #bbb, #ddd, #bbb); + background-image:linear-gradient(left, #bbb, #ddd, #bbb); + + -webkit-transform:rotateY(-90deg); + -moz-transform:rotateY(-90deg); + -o-transform:rotateY(-90deg); + -ms-transform:rotateY(-90deg); + transform:rotateY(-90deg); + + -webkit-transform-origin:top right; + -moz-transform-origin:top right; + -o-transform-origin:top right; + -ms-transform-origin:top right; + transform-origin:top right; + z-index:100000; + +} + +.sj-book-transform div[page="1"] > div, .sj-book-transform div[page="2"] > div{ + overflow:visible !important; +} + +.sj-book .depth{ + background-image:url(../pics/pages-depth.png); + position:absolute; + top:7px; + width:16px; + height:590px; +} + +.sj-book .front-side .depth{ + left:4px; + background-position:0 0; +} + +.sj-book .back-side .depth{ + right:4px; + background-position:right 0; +} + + +.sj-book .p2{ + background-position:-480px 0 !important; +} + +.sj-book .p3{ + background-position:-1920px 0 !important; +} + +.sj-book .p111{ + background-position:-960px 0 !important; +} + +.sj-book .p112{ + background-position:-1440px 0 !important; +} + +.sj-book .hard{ + width:480px; + height:600px; + background-color:white; + -webkit-box-shadow:none; + -moz-box-shadow:none; + -ms-box-shadow:none; + box-shadow:none; +} + +.sj-book .page-wrapper{ + -webkit-perspective:2000px; + -moz-perspective: 2000px; + -ms-perspective: 2000px; + perspective: 2000px; +} + +.sj-book .own-size{ + width:460px; + height:582px; + background-color:white; + overflow:hidden; +} + +.sj-book .even{ + background:-webkit-gradient(linear, left top, right top, color-stop(0.95, #fff), color-stop(1, #dadada)); + background-image:-webkit-linear-gradient(left, #fff 95%, #dadada 100%); + background-image:-moz-linear-gradient(left, #fff 95%, #dadada 100%); + background-image:-ms-linear-gradient(left, #fff 95%, #dadada 100%); + background-image:-o-linear-gradient(left, #fff 95%, #dadada 100%); + background-image:linear-gradient(left, #fff 95%, #dadada 100%); +} + +.sj-book .odd{ + background:-webkit-gradient(linear, right top, left top, color-stop(0.95, #fff), color-stop(1, #cacaca)); + background-image:-webkit-linear-gradient(right, #fff 95%, #cacaca 100%); + background-image:-moz-linear-gradient(right, #fff 95%, #cacaca 100%); + background-image:-ms-linear-gradient(right, #fff 95%, #cacaca 100%); + background-image:-o-linear-gradient(right, #fff 95%, #cacaca 100%); + background-image:linear-gradient(right, #fff 95%, #cacaca 100%); +} + +.sj-book .loader{ + background-image:url(../pics/loader.gif); + width:22px; + height:22px; + position:absolute; + top:280px; + left:219px; +} + +.sj-book .page-number{ + color:#999; + width:100%; + bottom:25px; + position:absolute; + display:block; + text-align: center; + line-height:30px; + font-size:11px; +} + +.sj-book .table-contents{ + font-size:16px; + width:300px; + margin:80px auto; + color:#ccc; +} + +.sj-book .table-contents li{ + list-style:none; + line-height:25px; +} + +.sj-book .table-contents span{ + float:right; +} + +.sj-book .table-contents a{ + float:left; + width:100%; + clear:both; + text-decoration:none; + color:#333; + margin:2px 0; + padding:0 10px; +} + +.sj-book .table-contents a:hover{ + background:#CAD1EE; + float:left; + width:100%; + clear:both; + text-decoration:none; + -webkit-border-radius:10px; + -moz-border-radius:10px; + -o-border-radius:10px; + -ms-border-radius:10px; + border-radius:10px; +} + +.sj-book .book-content .capital, +.sj-book .book-content .no-indent{ + text-indent: 0; +} + +.sj-book .capital:first-letter { + display:block; + float:left; + font-size: 300%; + line-height: 70%; + margin-right: 6px; + margin-top: 7px; + margin-left:18px; +} + +.ie8 .sj-book .even, +.ie9 .sj-book .even{ + background-image:url(../pics/gradient-page-left.jpg); + background-position:right top; + background-repeat:repeat-y; +} + +.ie8 .sj-book .odd, +.ie9 .sj-book .odd{ + background-image:url(../pics/gradient-page-right.jpg); + background-position:left top; + background-repeat:repeat-y; +} + diff --git a/samples/steve-jobs/fonts/Stempel-Garamond-W01-Roman.woff b/samples/steve-jobs/fonts/Stempel-Garamond-W01-Roman.woff new file mode 100644 index 0000000..81be134 Binary files /dev/null and b/samples/steve-jobs/fonts/Stempel-Garamond-W01-Roman.woff differ diff --git a/samples/steve-jobs/index.html b/samples/steve-jobs/index.html new file mode 100644 index 0000000..b28236c --- /dev/null +++ b/samples/steve-jobs/index.html @@ -0,0 +1,292 @@ + + + + + + + + + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/samples/steve-jobs/js/steve-jobs.js b/samples/steve-jobs/js/steve-jobs.js new file mode 100644 index 0000000..5560fa6 --- /dev/null +++ b/samples/steve-jobs/js/steve-jobs.js @@ -0,0 +1,237 @@ +/* Steve jobs' book */ + +function updateDepth(book, newPage) { + + var page = book.turn('page'), + pages = book.turn('pages'), + depthWidth = 16*Math.min(1, page*2/pages); + + newPage = newPage || page; + + if (newPage>3) + $('.sj-book .p2 .depth').css({ + width: depthWidth, + left: 20 - depthWidth + }); + else + $('.sj-book .p2 .depth').css({width: 0}); + + depthWidth = 16*Math.min(1, (pages-page)*2/pages); + + if (newPage', + {'class': 'own-size', + css: {width: 460, height: 582} + }). + html('
'); + + if (book.turn('addPage', element, page)) { + loadPage(page); + } + + } +} + +function numberOfViews(book) { + + return book.turn('pages') / 2 + 1; + +} + +function getViewNumber(book, page) { + + return parseInt((page || book.turn('page'))/2 + 1, 10); + +} + +function zoomHandle(e) { + + if ($('.sj-book').data().zoomIn) + zoomOut(); + else if (e.target && $(e.target).hasClass('zoom-this')) { + zoomThis($(e.target)); + } + +} + +function zoomThis(pic) { + + var position, translate, + tmpContainer = $('
', {'class': 'zoom-pic'}), + transitionEnd = $.cssTransitionEnd(), + tmpPic = $(''), + zCenterX = $('#book-zoom').width()/2, + zCenterY = $('#book-zoom').height()/2, + bookPos = $('#book-zoom').offset(), + picPos = { + left: pic.offset().left - bookPos.left, + top: pic.offset().top - bookPos.top + }, + completeTransition = function() { + $('#book-zoom').unbind(transitionEnd); + + if ($('.sj-book').data().zoomIn) { + tmpContainer.appendTo($('body')); + + $('body').css({'overflow': 'hidden'}); + + tmpPic.css({ + margin: position.top + 'px ' + position.left+'px' + }). + appendTo(tmpContainer). + fadeOut(0). + fadeIn(500); + } + }; + + $('.sj-book').data().zoomIn = true; + + $('.sj-book').turn('disable', true); + + $(window).resize(zoomOut); + + tmpContainer.click(zoomOut); + + tmpPic.load(function() { + var realWidth = $(this)[0].width, + realHeight = $(this)[0].height, + zoomFactor = realWidth/pic.width(), + picPosition = { + top: (picPos.top - zCenterY)*zoomFactor + zCenterY + bookPos.top, + left: (picPos.left - zCenterX)*zoomFactor + zCenterX + bookPos.left + }; + + + position = { + top: ($(window).height()-realHeight)/2, + left: ($(window).width()-realWidth)/2 + }; + + translate = { + top: position.top-picPosition.top, + left: position.left-picPosition.left + }; + + $('.samples .bar').css({visibility: 'hidden'}); + $('#slider-bar').hide(); + + + $('#book-zoom').transform( + 'translate('+translate.left+'px, '+translate.top+'px)' + + 'scale('+zoomFactor+', '+zoomFactor+')'); + + if (transitionEnd) + $('#book-zoom').bind(transitionEnd, completeTransition); + else + setTimeout(completeTransition, 1000); + + }); + + tmpPic.attr('src', pic.attr('src')); + +} + +function zoomOut() { + + var transitionEnd = $.cssTransitionEnd(), + completeTransition = function(e) { + $('#book-zoom').unbind(transitionEnd); + $('.sj-book').turn('disable', false); + $('body').css({'overflow': 'auto'}); + moveBar(false); + }; + + $('.sj-book').data().zoomIn = false; + + $(window).unbind('resize', zoomOut); + + moveBar(true); + + $('.zoom-pic').remove(); + $('#book-zoom').transform('scale(1, 1)'); + $('.samples .bar').css({visibility: 'visible'}); + $('#slider-bar').show(); + + if (transitionEnd) + $('#book-zoom').bind(transitionEnd, completeTransition); + else + setTimeout(completeTransition, 1000); +} + + +function moveBar(yes) { + if (Modernizr && Modernizr.csstransforms) { + $('#slider .ui-slider-handle').css({zIndex: yes ? -1 : 10000}); + } +} + +function setPreview(view) { + + var previewWidth = 115, + previewHeight = 73, + previewSrc = 'pages/preview.jpg', + preview = $(_thumbPreview.children(':first')), + numPages = (view==1 || view==$('#slider').slider('option', 'max')) ? 1 : 2, + width = (numPages==1) ? previewWidth/2 : previewWidth; + + _thumbPreview. + addClass('no-transition'). + css({width: width + 15, + height: previewHeight + 15, + top: -previewHeight - 30, + left: ($($('#slider').children(':first')).width() - width - 15)/2 + }); + + preview.css({ + width: width, + height: previewHeight + }); + + if (preview.css('background-image')==='' || + preview.css('background-image')=='none') { + + preview.css({backgroundImage: 'url(' + previewSrc + ')'}); + + setTimeout(function(){ + _thumbPreview.removeClass('no-transition'); + }, 0); + + } + + preview.css({backgroundPosition: + '0px -'+((view-1)*previewHeight)+'px' + }); +} + +function isChrome() { + + // Chrome's unsolved bug + // http://code.google.com/p/chromium/issues/detail?id=128488 + + return navigator.userAgent.indexOf('Chrome')!=-1; + +} \ No newline at end of file diff --git a/samples/steve-jobs/pages/page10.html b/samples/steve-jobs/pages/page10.html new file mode 100644 index 0000000..b3d48b5 --- /dev/null +++ b/samples/steve-jobs/pages/page10.html @@ -0,0 +1,22 @@ +
+ +

Youth

+ +

The jobs family

+ +

+Steve Jobs was born on February 24, 1955, in the city of San Francisco. His biological mother was an unwed graduate student named Joanne Simpson, +and his biological father was either a political science or mathematics professor, a native Syrian named Abdulfattah John Jandali. +

+ + +

+Being born out of wedlock in the puritan America of the 1950s, the baby +was put up for adoption. Joanne had a college education, and she insisted that the future parents of her boy be just as well educated. Unfortunately, +the candidates, Paul and Clara Jobs, did not meet her expectations: they were a lower-middle class couple that had settled in the Bay Area after the +war. Paul was a machinist from the Midwest who had +

+ + +
+10 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page100.html b/samples/steve-jobs/pages/page100.html new file mode 100644 index 0000000..e99d6a4 --- /dev/null +++ b/samples/steve-jobs/pages/page100.html @@ -0,0 +1,14 @@ +
+ +

Yet, once again, the market proved the critics wrong, +and iPad turned out an amazing success. Apple sold 7.5 million of them as of September 2010, +representing close to 8% of its 2010 fiscal-year revenues (iPods amounted for 13%). +

+ +

+It is worth thinking about these comments for a minute. + +If we assume Steve Jobs is right about this, and almost everyone (but Microsoft’s Steve Ballmer) agrees he is, then he will be a unique case in history of someone who has been instrumental in both creating and putting an end to an industry. Indeed, Apple was a key player in starting of the personal computing revolution in the early 1980s, and there would not have been an Apple without Steve Jobs. But Apple will also likely be the company leading the transition away from the PC, and this time +

+
+100 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page101.html b/samples/steve-jobs/pages/page101.html new file mode 100644 index 0000000..5aa9107 --- /dev/null +++ b/samples/steve-jobs/pages/page101.html @@ -0,0 +1,11 @@ +
+ +

+ there’s no denying this would not have happened so quickly without the iOS mobile revolution... What other man can be credited for such a huge impact on a multibillion-dollar industry? +

+ +

+It is worth thinking about these comments for a minute. If we assume Steve Jobs is right about this, and almost everyone (but Microsoft’s Steve Ballmer) agrees he is, then he will be a unique case in history of someone who has been instrumental in both creating and putting an end to an industry. Indeed, Apple was a key player in starting of the personal computing revolution in the early 1980s, and there would not have been an Apple without Steve Jobs. But Apple will also likely be the company leading the transition away from the PC, and this time there’s no denying this would not have happened so quickly without the iOS mobile revolution... What other man can be credited for such a huge impact on a multibillion-dollar industry? +

+
+101 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page102.html b/samples/steve-jobs/pages/page102.html new file mode 100644 index 0000000..2d058f8 --- /dev/null +++ b/samples/steve-jobs/pages/page102.html @@ -0,0 +1,17 @@ +
+ +

Apple’s possible future

+

+2010 has seen Apple’s dominance in the high-tech industry reinforced. The company is the market leader or a dominant player in four huge and growing markets: digital music players (with iPod), digital music distribution (with iTunes), smartphones and mobile apps (with iPhone, iPod touch and the App Store), and tablet PCs (with iPad). +

+ +

+This unique position at the crossroads of the digital revolution, makes the fruit company the subject of many a fantasy. Two trends have constantly re- emerged when speculating on Apple’s future. +

+ +

+The first is its take on the television market. Steve Jobs himself has commented at length on it at D8 (again), saying it was impossible for Apple +to enter this market because of its structure. He talked about an insoluble go-to-market impossibility. +

+
+102 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page103.html b/samples/steve-jobs/pages/page103.html new file mode 100644 index 0000000..428fdfc --- /dev/null +++ b/samples/steve-jobs/pages/page103.html @@ -0,0 +1,19 @@ +
+ + +

+ +Yet only three months later, he introduced a revamped, network-based +Apple TV at the traditional September Apple Media Event. The new box is iOS-based and most people think it won’t be long before it runs iOS apps. +To speak more generally, it is very likely that, unlike what Steve Jobs has explained, Apple will try very hard to enter and revolutionize this “other” +consumer electronics space that is television, and the Living Room in general — following a strategy that was conceived some four years earlier +with iPod hi-fi. +

+ +

+Another controversial issue is that of Apple’s relation toward its new arch- rival, Google. This relation is controversial because for several years, Google +was not an enemy, but an ally in the war against the behemoth of Redmond, Microsoft. Google’s CEO Eric Schmidt even +

+ +
+103 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page104.html b/samples/steve-jobs/pages/page104.html new file mode 100644 index 0000000..c965c00 --- /dev/null +++ b/samples/steve-jobs/pages/page104.html @@ -0,0 +1,22 @@ +
+ +

+sat on Apple’s board +of directors for three whole years, from 2006 to 2009. But it’s no wonder he left in 2009: by entering the smartphone market with its Android mobile OS +(and its own app store!), Google had become a direct competitor of Apple. This confict of interest was as good a reason for him to leave, as Steve Jobs’ +shrinking tolerance for what he felt was a plain and simple betrayal. +

+ +

Has Steve changed?

+

+Finally, an old debate about Steve’s personality has also re-emerged in +2010: has he changed? Although some of his traits, such as his propensity to take the spotlight then and again to unveil insanely great products to the +world, have not changed... People have noticed two minor evolutions in his public persona. +

+ +

The first is his increasing habit of communicating by writing emails to +customers. +

+ +
+104 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page105.html b/samples/steve-jobs/pages/page105.html new file mode 100644 index 0000000..d7b2354 --- /dev/null +++ b/samples/steve-jobs/pages/page105.html @@ -0,0 +1,18 @@ +
+ +

+them, so often. Usually, he has used them to publicly respond to hot issues about Apple or to spread rumors himself. Some even pretend he has theorized this method, which is in essence a new way for CEOs to deal with PR, bypassing the traditional press. +

+ +

+ +Another change is more profound, and has to do with his implication on +charity issues. Steve’s reputation in Silicon Valley was not very positive on this particular topic, as he was often dismissed for basically being stingy. +Yet, in addition to large donations to charities, he spoke publicly twice for the defense of organ donations in 2010, and even played a critical role in +the creation of the nations’ first organ donor registry in October 2010. This was obviously a praiseworthy side effect of the liver transplant that had +saved his life one year earlier. +

+ + +
+105 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page106.html b/samples/steve-jobs/pages/page106.html new file mode 100644 index 0000000..e69de29 diff --git a/samples/steve-jobs/pages/page107.html b/samples/steve-jobs/pages/page107.html new file mode 100644 index 0000000..e69de29 diff --git a/samples/steve-jobs/pages/page108.html b/samples/steve-jobs/pages/page108.html new file mode 100644 index 0000000..e69de29 diff --git a/samples/steve-jobs/pages/page109.html b/samples/steve-jobs/pages/page109.html new file mode 100644 index 0000000..e69de29 diff --git a/samples/steve-jobs/pages/page11.html b/samples/steve-jobs/pages/page11.html new file mode 100644 index 0000000..a203efb --- /dev/null +++ b/samples/steve-jobs/pages/page11.html @@ -0,0 +1,22 @@ +
+ +

+not even graduated from high school. In the end, Joanne agreed to have her baby adopted by +them, under the firm condition that they later send him to college. +

+ +

+Paul and Clara called their new son Steven Paul. While Steve was still a toddler, the couple moved to the Santa Clara county, later to be known as +Silicon Valley. They adopted another baby, a girl called Patti, three years later in 1958. +

+ +

Childhood

+ +

+Steve was quite a turbulent child. He really didn’t care about school for +some time — until he reached the 4th grade, and had Imogene “Teddy” Hill as a teacher.

+ +

She did bribe him, with candy and $5 bills from her own money. He quickly became hooked — so

+ +
+11 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page110.html b/samples/steve-jobs/pages/page110.html new file mode 100644 index 0000000..e69de29 diff --git a/samples/steve-jobs/pages/page12.html b/samples/steve-jobs/pages/page12.html new file mode 100644 index 0000000..3642660 --- /dev/null +++ b/samples/steve-jobs/pages/page12.html @@ -0,0 +1,19 @@ +
+ +

+much so that he skipped the 5th grade and went straight to middle school, namely Crittenden Middle School. It was in a poor area. Most kids did not work much there, they were rather fond of bullying other kids, such as the young Steve. One day he came home and declared that if he wasn’t transferred to another school, he would stop going to school altogether. He was 11. Paul and Clara complied, and the Jobses moved to the cozier city of Los Altos, so that Steve could go to Cupertino Junior High. This proved to be decisive for Steve’s future. +

+ +

+As Steve was growing up in Los Altos, he became increasingly curious about the world of electronics that filled his neighbors’ garages. His own +father introduced him to Heathkits, which fascinated him. +

+ +

Homestead High

+ +

+When Steve arrived in Homestead High School, he enrolled in a popular electronics class. His teacher was +

+ +
+12 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page13.html b/samples/steve-jobs/pages/page13.html new file mode 100644 index 0000000..9224e4d --- /dev/null +++ b/samples/steve-jobs/pages/page13.html @@ -0,0 +1,13 @@ +
+ +

+Mr. McCollum. McCollum later recalled of one time when his pupil Steve called up David Hewlett himself, co-founder of HP, to get spare parts for his homework, and even a summer job at HP’s factory. Steve’s entrepreneurial skills showed up early in his life indeed. +

+ +

+ + +At Homestead, Steve befriended Bill Fernandez, a neighbor who shared his interests in electronics. It was Bill who first introduced him to another computer whiz kid, an older guy named Stephen Wozniak, or — as everybody used to call him — Woz. Steve and Woz met in 1969, when they were respectively 14 and 19. At the time, Woz was building a little computer board with Bill Fernandez that they called “the Cream Soda Computer”.

+ +
+13 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page14.html b/samples/steve-jobs/pages/page14.html new file mode 100644 index 0000000..2a8ec14 --- /dev/null +++ b/samples/steve-jobs/pages/page14.html @@ -0,0 +1,19 @@ +
+ +
+Typically, it was really hard for me to explain to people the kind of design stuff I worked on, but Steve got it right away. And I liked him. He was kind of skinny and wiry and full of energy. [...] Steve and I got close right away, even though he was still in high school [...]. We talked electronics, we talked about music we liked, and we traded stories about pranks we’d pulled. +
+ +Steve Wozniak in iWoz + +

+Woz and Steve later engaged in several pranks together, including putting a +huge middle finger on one of the high school’s building. +

+ +

+It was also at Homestead that Steve met Chris-Ann Brennan, his first steady girlfriend, with whom he stayed for several years. A couple of years later, Woz and Steve started their first entrepreneurial venture. It was 1972, and on US campuses, there was a lot of talk about “phone phreaks.” They were early computer +

+ +
+14 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page15.html b/samples/steve-jobs/pages/page15.html new file mode 100644 index 0000000..14e1f95 --- /dev/null +++ b/samples/steve-jobs/pages/page15.html @@ -0,0 +1,15 @@ +
+ +

+ hackers that managed to build “blue boxes” — little devices that fooled AT&T’s long-distance switching equipment, and allowed you to make phone calls for free. +

+ +

+ +Woz read about them in an article which he showed to Steve. + +They both tried to build one, and to their surprise, it worked! It was Steve who came up with the idea of selling them; he and Woz would go from room to room in Berkeley’s dorms, where Woz was a student, and sell them to interested students. However, this business was illegal and the two of them stopped after they almost got caught by the police. +

+ +
+15 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page16.html b/samples/steve-jobs/pages/page16.html new file mode 100644 index 0000000..8bd7309 --- /dev/null +++ b/samples/steve-jobs/pages/page16.html @@ -0,0 +1,18 @@ +
+ +

Reed College

+

+The following year, Steve finished high school and reached college age. He decided to go to the fancy Reed College, a private liberal arts college up in Oregon. However, the tuition for Reed was so expensive that Paul and Clara could hardly afford it. Yet they were bound by the promise they’d make to their son’s biological mother, so they spent almost their entire life’s savings on their son’s higher education. +

+ +

+Steve only officially stayed for a couple of months at Reed. He dropped out before Christmas. However, that allowed him to “drop in” on classes he was not supposed to attend. +

+ +

+It was at Reed that Steve started experimenting with Eastern mysticism. He delved into weird books and came to believe that if he ate only fruits, for example, he would eliminate all mucus and not need to shower +

+ + +
+16 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page17.html b/samples/steve-jobs/pages/page17.html new file mode 100644 index 0000000..ea0520a --- /dev/null +++ b/samples/steve-jobs/pages/page17.html @@ -0,0 +1,15 @@ +
+ + +

+anymore. He also started his habit of fasting for long periods of time (he would still do so ten years later, when he was a multi-millionaire). He occasionally used LSD, and became something of a laggard hippie. One of his best friends at Reed was Dan Kottke, who shared his interests in such philosophies. +

+ +

+ +The following year, in 1974, Steve desperately needed money, so he got a job at Atari. Atari was arguably the first video game company: it was created by Nolan Bushnell in 1972, and one of its ␣rst employees was Al Acorn, the inventor of Pong. Steve was hired although he would often call his co-workers names and smell pretty bad. That’s why he was soon moved to the night shift. +

+ + +
+17 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page18.html b/samples/steve-jobs/pages/page18.html new file mode 100644 index 0000000..76466bd --- /dev/null +++ b/samples/steve-jobs/pages/page18.html @@ -0,0 +1,27 @@ +
+ + +

The Apple I

+ + +

Homebrew

+ + + +

+While Steve had been away in India or Oregon, his geek friend Woz had +been hired by Hewlett-Packard. To him, it was a dream job: a company full of passionate engineers just like him, where he could work on products for +other engineers. However, in his spare time, he had cultivated his interest in designing computer circuits, and had joined a computer hobbyists +association called the Homebrew Computer Club. +

+ + + +

+ +Woz was impressed by the Altair (and by Microsoft’s BASIC interpreter), but +he knew from his almost life-long experience in circuit design that he could do a much better job. So he started work on his own computer — which he +decided to base on another +

+
+18 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page19.html b/samples/steve-jobs/pages/page19.html new file mode 100644 index 0000000..8e1ec44 --- /dev/null +++ b/samples/steve-jobs/pages/page19.html @@ -0,0 +1,17 @@ +
+ +

+ +

+ +

+microprocessor, MOS’s Technology 502. This was his new goal in life. While keeping his job at HP, he worked very hard at +this computer board, and came up with an impressive result; a powerful computer (for the time) which worked with a keyboard and screen, not one that flashed lights — and all with amazingly few chips. +

+ +

+Woz showed his computer design to his friend Steve +

+ +
+19 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page20.html b/samples/steve-jobs/pages/page20.html new file mode 100644 index 0000000..3c362a4 --- /dev/null +++ b/samples/steve-jobs/pages/page20.html @@ -0,0 +1,20 @@ +
+ + +

+Jobs. Steve was impressed. He did not know much about engineering, but he could see +there was a demand for having a computer to write software for, a computer for software hobbyists. He was especially excited to see that a lot +of the qualified engineers at Homebrew were talking about Woz’s computer with admiration. So he suggested to sell it to them. He and Woz would +assemble the computers themselves and sell the whole board at Homebrew meetings. +

+ +

“Our own company”

+ +
+Steve had a good argument. We were in his car and he said — and I can remember him saying this like it was yesterday: “Well, even if we lose money, we’ll have a company. For once in our lives, we’ll have a company.” That convinced me. And I was excited to think about us like that. To be two best friends starting a company. +
+ +Steve Wozniak in iWoz + +
+20 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page21.html b/samples/steve-jobs/pages/page21.html new file mode 100644 index 0000000..498c6ed --- /dev/null +++ b/samples/steve-jobs/pages/page21.html @@ -0,0 +1,17 @@ +
+ + +

+To get the necessary $1,000 to start building the first boards, Steve sold his Volkswagen van, and Woz his HP 65 calculator. They thought about how to call the new company, and couldn’t come up with a good name, until one day, Steve said that they would call it Apple if they didn’t and anything better. And they didn’t — so Apple Computer was born. +

+ +

+The two friends sought help, and they got it from one of Steve’s colleagues from Atari, Ron Wayne. Wayne basically wrote the necessary paperwork to start a corporation — and drew the company’s first logo. As a result, he got 10% of the company’s shares, while Steve and Woz split the rest (45% each). +

+ +

+Another problem was that Woz was still working for HP, and under the terms of his contract, all his work belonged to the corporation. The Apple computer was technically HP property. But Woz showed it to his bosses and they simply didn’t care about it. +

+ +
+21 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page22.html b/samples/steve-jobs/pages/page22.html new file mode 100644 index 0000000..23105e0 --- /dev/null +++ b/samples/steve-jobs/pages/page22.html @@ -0,0 +1,14 @@ +
+ + +

+Woz was disappointed as his goal was to work for HP his whole life. He would have been delighted if HP had done a personal computer based on his design. It wasn’t Steve Jobs’ intention though. +

+ +

+ +Apple Computer’s first order was from a Homebrew member called Paul Terrel. He was starting a new computer store called the Byte Shop, in Mountain View, and understood just like Steve that there was a demand for such fully-built computers. He ordered 50 of them, at $500 a piece. That was $25,000! It was a huge starting point for the young company, and got Steve and Woz very excited. They started putting together the parts in the Jobses’s garage, with help from +

+ +
+22 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page23.html b/samples/steve-jobs/pages/page23.html new file mode 100644 index 0000000..fc5547d --- /dev/null +++ b/samples/steve-jobs/pages/page23.html @@ -0,0 +1,21 @@ +
+ + +

+ Steve’s sister Patti and his friend from Reed, Dan Kottke. They paid them $1 a board. The parts for the Apple cost $220, while the computer was sold to Terrel for $500, who would usually put it in wooden boxes. +

+ +

+Steve and Woz also started selling the computer on their own. They agreed +on the retail price of $666.66 (note that his price was based on a simple calculation — a 33% margin — and had nothing to do with the Satanic +number of course). They showed it to the Homebrew folks in March 1976, but the response wasn’t that enthusiastic. So they went elsewhere, going +from store to store and trying to sell them. They sold a couple hundreds this way. +

+ +

+This was the start of Apple Computer. Steve and Woz had bought the other +co-founder Ron Wayne out for $800, and incorporated the company on April 1, 1976. +

+ +
+23 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page24.html b/samples/steve-jobs/pages/page24.html new file mode 100644 index 0000000..9ffe3a8 --- /dev/null +++ b/samples/steve-jobs/pages/page24.html @@ -0,0 +1,10 @@ +
+ + +

+ +

+ + +
+24 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page25.html b/samples/steve-jobs/pages/page25.html new file mode 100644 index 0000000..2745856 --- /dev/null +++ b/samples/steve-jobs/pages/page25.html @@ -0,0 +1,21 @@ +
+ +

Apple’s early days

+ +

+The day he finished work on his first computer, Woz started working on an improved design, the future Apple II. The Apple II was based on the Apple I’s design, but in many ways it was a huge breakthrough. +

+ +

+First, it ran a lot faster with half as many chips. It also was the first computer that could produce color, with any color TV you would plug it into. It could +handle high-resolution graphics and sound, and had a BASIC interpreter built-in. In short, it was the first computer that anybody who knew the +BASIC programming language could use: it had what it took to launch the personal computing revolution. +

+ +

+The prototype for the Apple II was almost ready when Steve and Woz +partook in the Personal Computer +

+ +
+25 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page26.html b/samples/steve-jobs/pages/page26.html new file mode 100644 index 0000000..6d54157 --- /dev/null +++ b/samples/steve-jobs/pages/page26.html @@ -0,0 +1,18 @@ +
+ +

+Festival, held in Atlantic City in the summer of 1976. But it was not ready enough to be shown to the public. +Steve and his friend Dan Kottke were trying to sell the Apple I from their Apple Computer booth, while Woz was working on finishing the Apple II. +The visitors were not impressed by the Apple I, a board sold by two amateur bearded young men, while MITS, which sold the Altair, had a huge +booth with music, dancers and business suits. Steve learned a lot that day. +

+ +

+After the Apple II was finished, Steve went looking for investors. He talked to several venture capitalists, who were already legions in the Valley. The +first to show up was Don Valentine. He turned Steve and Woz down, but he did give them a hand by passing them the name of another potential +investor, Mike Markkula. Mike was a former Intel employee who had made millions and retired early. He was 34 when he met with Woz and Steve, and +he bought into their vision. He was also quite aware of the potential returns on his +

+ +
+26 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page27.html b/samples/steve-jobs/pages/page27.html new file mode 100644 index 0000000..c696382 --- /dev/null +++ b/samples/steve-jobs/pages/page27.html @@ -0,0 +1,20 @@ +
+ +

+investment: +

+ +
+We’re going to be a Fortune 500 company in two years. This is the start of an industry. It happens once a decade. +
+Mike Markkula to Steve and Woz, quoted in iWoz + +

+ + +Mike drew up a business plan. He wanted to put in $250,000 to build 1,000 machines. This was a huge number by the young men’s standards. Woz was also told that for this to happen, he had to leave HP. At first he refused, since he was a huge admirer of HP and planned to work there his whole life. But Steve lobbied him hard into it, and in the end Woz relented. +

+ + +
+27 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page28.html b/samples/steve-jobs/pages/page28.html new file mode 100644 index 0000000..8e2d50d --- /dev/null +++ b/samples/steve-jobs/pages/page28.html @@ -0,0 +1,12 @@ +
+ +

+Mike Markkula also insisted that Apple advertise for its new computer. He called up one of his friends, Regis McKenna, who was one of the most renowned advertisers in the Valley. While they worked with Steve Jobs on Apple’s first ads, an art director called Rob Janoff designed a new logo for the company. The only thing Steve asked him was: “Don’t make it cute.” He was the one who came up with the bitten apple (so that it wouldn’t look like a tomato), as well as the striped colors — to emphasize the Apple II’s ability to display color. +

+ +

+Rod Holt, a friend of Steve Jobs’, was hired to build a switching power supply and design a mold for the Apple II’s plastic case. Mike Markkula later also hired a fourth guy, Mike Scott, to run the startup, whose first offices were moved to Stevens Creek Boulevard in Cupertino. +

+ +
+28 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page29.html b/samples/steve-jobs/pages/page29.html new file mode 100644 index 0000000..26e9024 --- /dev/null +++ b/samples/steve-jobs/pages/page29.html @@ -0,0 +1,22 @@ +
+ +

The West Coast Computer Faire

+

+The new company got ready to show off their product at the West Coast Computer Faire, a conference held in San Francisco in April 1977. It was only +a prototype, but the plastic case definitely made the Apple II look like a professional product. Steve negotiated a prime spot for Apple’s booth, and +took precious advice from both Mike Markkula and Regis McKenna. That’s why he bought his first suit for the occasion. +

+ +
+My recollection is we stole the show +
+ +Steve Jobs in Triumph of the Nerds + +

+Apple Computer received 300 orders for the Apple II on the show alone, +twice as much as the total number of Apple I’s ever sold! But this was just the beginning. +

+ +
+29 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page30.html b/samples/steve-jobs/pages/page30.html new file mode 100644 index 0000000..d46fdaf --- /dev/null +++ b/samples/steve-jobs/pages/page30.html @@ -0,0 +1,19 @@ +
+ +

Success and failures

+ +

The personal computing revolution

+

+In many ways, the Apple II was both the start and the symbol of the personal computer revolution of the early 1980s. Although there were +many competing personal computers on the market — such as the Commodore PET or Radio Schack’s TRS-80 — the Apple II clearly set itself +apart very early on, and soon embodied the personal computer in the public consciousness. It was all over the media, and its sales skyrocketed +throughout 1978, 1979 and 1980. +

+ +

+It was not only about the Apple II’s appealing design, its integrated keyboard, or its ability to plug into any TV to display color graphics or play +sounds. Its built-in BASIC interpreter was also critical to its success, as it made the writing of compatible software very easy. +

+ +
+30 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page31.html b/samples/steve-jobs/pages/page31.html new file mode 100644 index 0000000..1ee5fd5 --- /dev/null +++ b/samples/steve-jobs/pages/page31.html @@ -0,0 +1,19 @@ +
+ +

+

+ + +Woz used it himself to write the + +first program to ever run on the machine, a game called Breakout. The eight expansion slots in Apple II made a difference, too. Woz decided to +implement them against Steve Jobs’ will, and this proved a wise move, as they allowed for all kinds of new features and software to be added to the +machine. One of those features was Disk II, a floppy disk drive Apple started shipping in early 1978. It made the sharing and installing of new software +very easy — soon the supply of Apple II software was thriving. +

+ +

+But probably the most important push toward the +

+
+31 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page32.html b/samples/steve-jobs/pages/page32.html new file mode 100644 index 0000000..c46135c --- /dev/null +++ b/samples/steve-jobs/pages/page32.html @@ -0,0 +1,19 @@ +
+ +

+Apple II’s success was not from Apple. It was a piece of software called VisiCalc — the first +spreadsheet ever brought to market. VisiCalc worked only on the Apple II, and it was a revolution in itself. Millions of accountants, small businesses, or +even private individuals that cared about their money, could now do in minutes calculations that would have taken them weeks to perform by +hand. They rushed out to computer stores and bought Apple IIs en masse, making Apple one of the most profitable companies of its day. Only four +years after it was started in a garage, the company was well on its way to fullfil Mike Markkula’s vision of belonging to the Fortune 500 elite of +corporate America. +

+ +

Preparing for the future

+

+Apple Computer was growing at an incredibly fast rate. The numbers were +mind-blowing: from 2,500 Apple IIs sold in 1977, 8,000 were sold in 1978, and up to 35,000 in 1979. Remember there was no market for +

+ +
+32 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page33.html b/samples/steve-jobs/pages/page33.html new file mode 100644 index 0000000..8104928 --- /dev/null +++ b/samples/steve-jobs/pages/page33.html @@ -0,0 +1,17 @@ +
+ +

+personal computers before! The company earned $47 million in revenues in fiscal year 1979, making Steve Jobs a millionaire on paper (he owned $7 million +worth of private stock). The company’s board of directors, including its new members such as Arthur Rock and Don Valentine, began to discuss taking +Apple public. +

+

+Meanwhile, the engineers in Cupertino started working on Apple’s future. Several projects came into being in those early years. First, in late 1978, +there was the Apple III, which was supposed to build on Apple II’s legacy. Woz did not partake in the project and was critical of it early on. There was also an obscure project called Macintosh, headed by computer scientist Jef Raskin. He started to assemble a small team to work on a computer “as easy to use as a toaster”, that he named after his favorite apple. +

+ +

+Steve Jobs was not involved in any of those projects. +

+
+33 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page34.html b/samples/steve-jobs/pages/page34.html new file mode 100644 index 0000000..1a5894e --- /dev/null +++ b/samples/steve-jobs/pages/page34.html @@ -0,0 +1,20 @@ +
+ +

+He had another one in mind, called Lisa. And he hadn’t picked that name without a reason... +Indeed, in 1978, while he was dating an employee of McKenna’s PR agency, Steve’s ex-girlfriend from high school Chris-Ann Brennan reappeared +claiming she was bearing his baby. Steve denied the fatherhood, although everybody in his entourage knew he was the father. The baby girl was +named Lisa... there was a lot of perplexity around Steve’s behavior, especially since he had suffered greatly from having been abandoned +himself. He was going to do the same to his own daughter! Yet, at the very same time, he used the girl’s name for a project code name. +

+ +

+Project Lisa took a dramatic turn in late 1979, after Steve’s visit to Xerox PARC. +

+

+The Lisa team was briefed about Xerox PARC’s technologies by insiders, including Jef Raskin, the manager of the Macintosh project. Steve +negotiated a deal with Xerox to be given a complete tour of the +

+ +
+34 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page35.html b/samples/steve-jobs/pages/page35.html new file mode 100644 index 0000000..f5d23cd --- /dev/null +++ b/samples/steve-jobs/pages/page35.html @@ -0,0 +1,20 @@ +
+ +

+ facilities. Here’s how he described his experience later: +

+ +
+Within ten minutes, it was obvious to me that all computers would work like this someday. +
+ +Steve Jobs in Triumph of the Nerds + + +

+Several researchers and engineers were lured away from PARC by Apple, such as Larry Tesler and Bruce Horn, to develop a GUI for Lisa. The biggest challenge was trying to design an actual product, not a fancy prototype too expensive to build. After all, one of the reasons Xerox dismissed the Alto was its astronomical price tag: $20,000! That was twenty times as much as the Apple II. +

+ + +
+35 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page36.html b/samples/steve-jobs/pages/page36.html new file mode 100644 index 0000000..331ae89 --- /dev/null +++ b/samples/steve-jobs/pages/page36.html @@ -0,0 +1,16 @@ +
+ +

The biggest IPO since Ford

+ +

+In 1980, Apple Computer was preparing to go public. This move had several major implications for Steve Jobs, both professionally and personally. +

+ +

+ +First, the board was concerned about the potential bad publicity around Steve’s handling of his daughter Lisa. They insisted that he settled the case with Chris-Ann before the end of the year, as the IPO was scheduled for December 1980. Reluctantly, he agreed to reimburse the country’s welfare the money they had spent on the mother of his daughter, i.e. $20,000. +

+ + +
+36 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page37.html b/samples/steve-jobs/pages/page37.html new file mode 100644 index 0000000..9b8ecac --- /dev/null +++ b/samples/steve-jobs/pages/page37.html @@ -0,0 +1,12 @@ +
+ + +

+There was also a large re-organization at the top of the company. The Apple III, which came out in the spring of 1980, had turned out a disaster on the marketplace. + + +It was flawed and thousands of early models had to be returned to the company, whose only revenues still came from sales of Apple II. The next project, Lisa, became even more critical to the company’s future. As a result, Apple Computer was re-organized into three new departments: Accessories, Professional Office Systems (which included Lisa), and Personal Computer Systems (Apple II and Apple III). Steve expected to head the POS division, but the board chose the milder and more experienced John Couch. Steve was named chairman of the board instead.

+ + +
+37 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page38.html b/samples/steve-jobs/pages/page38.html new file mode 100644 index 0000000..795c724 --- /dev/null +++ b/samples/steve-jobs/pages/page38.html @@ -0,0 +1,17 @@ +
+ +

Macintosh

+

Better be a pirate than join the Navy

+ +

+Steve Jobs quickly left his mark on the Macintosh team. Part of his motivations were: 1. to have his own successful computer, unlike the Apple +II which was Woz’s brainchild; 2. to take revenge on Apple’s management for forcing him out of the Lisa project. When he took over, the Mac team +only consisted of a small number of engineers: Brian Howard, Burrell Smith and Bud Tribble, as well as a woman in marketing, Joanna Hoffman. He +soon hired several other members that would later form the core of the team, such as Andy Hertzfeld, Chris Espinosa, George Crow, Steve Capps +and Mike Boich. Other key players would follow later, like the brilliant software designer Bill Atkinson from the Lisa team, Mike Murray in +marketing, or Susan Kare, who designed the icons and several fonts for the +

+ + +
+38 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page39.html b/samples/steve-jobs/pages/page39.html new file mode 100644 index 0000000..b830977 --- /dev/null +++ b/samples/steve-jobs/pages/page39.html @@ -0,0 +1,16 @@ +
+ +

+system. For the box design, he hired Harmut Esslinger’s frogdesign, who +pioneered the so-called “Snow White” design language, that would dictate computer design for the next decade. +

+ +

+ +To Steve, the Macintosh project was going to save Apple from the bloated Lisa project and the bureaucracy of the company. He tried to insufflate the +team with entrepreneurial values, calling them rebels and artists, while the other Apple employees were bozos. The team was even in a separate +building on Bandley Drive, where Steve hung a pirate flag: “better be a pirate than join the Navy,” he said — meaning the Navy was the rest of Apple. +

+ +
+39 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page40.html b/samples/steve-jobs/pages/page40.html new file mode 100644 index 0000000..214fd25 --- /dev/null +++ b/samples/steve-jobs/pages/page40.html @@ -0,0 +1,18 @@ +
+ +

Steve leaves Apple

+ +

Tensions

+

+Steve could not deal with the market failure of his baby. He continued to +behave as if he had saved Apple, treating non-Mac employees with deference in Cupertino. People felt he spoiled the Mac team, buying them a +BMW motorcycle and a Bosendorfer grand piano with his personal money, while the company was still alive thanks only to Apple II sales (the truth was +that Macintosh engineers were paid the same or even less than their counterparts). +

+ +

+There was increasing resentment building up against Steve Jobs at Apple. The honeymoon with CEO John Sculley was over: the two men increasingly +criticized one another in their inner circles. Even Woz, who felt insulted by the treatment the Apple II team received, left +

+
+40 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page41.html b/samples/steve-jobs/pages/page41.html new file mode 100644 index 0000000..ccc8dd5 --- /dev/null +++ b/samples/steve-jobs/pages/page41.html @@ -0,0 +1,22 @@ +
+ + +

+ the company in February +1985. He openly criticized the management in Cupertino: this was a PR disaster for the firm. +

+ +

+ +In April 1985, the board discussed re-organization plans for the company. Everyone agreed there should be a new manager for the Mac team, namely +Apple France executive Jean-Louis Gassée. Jobs even accepted the idea for a while, thinking of running a new R&D department instead. But he was +outraged when Gassée asked for a written guarantee of his promotion. +

+ +

Experimentations

+

+During those four months, from May to September 1985, Steve was still chairman of the board — he was not +

+ +
+41 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page42.html b/samples/steve-jobs/pages/page42.html new file mode 100644 index 0000000..ec0a101 --- /dev/null +++ b/samples/steve-jobs/pages/page42.html @@ -0,0 +1,19 @@ +
+ + +

+fired from Apple, contrary to popular belief. But he had a lot of times on his hands, and tried hard to find what he was going to do next. +

+ +

A new venture

+ +

+As the story goes, Steve Jobs was still looking for new directions in life when he met with a friend of his, Nobel Prize Paul Berg, from Stanford +University. Berg told him of his work on DNA, and asked him whether the molecules could be simulated on computers. The answer was no, not yet +anyway... this gave Steve the idea of starting a new company. He would build a high-end computer aimed solely at the higher education and +research markets. He asked around and found out the general consensus was a need for a so-called 3M machine — a computer that could hold one +megabyte of memory, perform one million instructions per second, and display one million pixels on a screen. +

+ +
+42 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page43.html b/samples/steve-jobs/pages/page43.html new file mode 100644 index 0000000..00c64c0 --- /dev/null +++ b/samples/steve-jobs/pages/page43.html @@ -0,0 +1,17 @@ +
+ +

NeXT Inc.

+

+Next did not start easily. The minute it was created, the six co-founders found themselves sued by their former employer, Apple. The fruit company was accusing them of stealing their technology. +

+ +

+ +As a result, for its first year or so of existence, the new company could not work on any product in particular, since there was a chance they would lose +the trial and give all the technologies they had worked on back to Apple. In the meantime, Steve Jobs set up to build the perfect company. +

+ + + +
+43 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page44.html b/samples/steve-jobs/pages/page44.html new file mode 100644 index 0000000..383538f --- /dev/null +++ b/samples/steve-jobs/pages/page44.html @@ -0,0 +1,20 @@ +
+ +

The NeXT Cube

+

No detail was too small

+ +

+There is probably no product in Steve’s career that was hurt more by his perfectionism than the NeXT Cube. No detail seemed too trivial to be +overlooked; everything NeXT did had to be perfect. +

+ +

+ +First with software. When Steve started asking around to know what was the state of the art in computer operating system, he was told the most +stable, modern software was called UNIX. It was a very complex but very powerful OS used in universities and by large companies in their +mainframes. +

+ + +
+44 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page45.html b/samples/steve-jobs/pages/page45.html new file mode 100644 index 0000000..4c19c6d --- /dev/null +++ b/samples/steve-jobs/pages/page45.html @@ -0,0 +1,23 @@ +
+ +

+ + +The most advanced UNIX technology was being developed at Carnegie-Mellon, + + + +where Steve hired some of his best programmers, such as +Avie Tevanian. He was also told about object-oriented programming, a breakthrough from Xerox PARC which made software development very +fast and efficient. So Steve knew his priorities for the NeXT operating system: it would be a UNIX object-oriented system — on top of which +would be added a graphical user interface, to make it user-friendly. These were the very ambitious foundations of NeXTSTEP, so ambitious that it +would take several years before they would give birth to a stable operating system. +

+ +

+Second, of course, was hardware. Steve had been +

+ + +
+45 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page46.html b/samples/steve-jobs/pages/page46.html new file mode 100644 index 0000000..2c1d823 --- /dev/null +++ b/samples/steve-jobs/pages/page46.html @@ -0,0 +1,18 @@ +
+ +

+thrilled by the factory that was used to produce Macintosh — he wanted to do even better this time with NeXT. He set up to build the most advanced automated factory in +the world, in Fremont, not too far from the Mac factory itself. The NeXT computers would be built untouched by human hands, using robots +operated by other NeXT computers. The factory was designed to mass produce NeXT Cubes and bring the costs down with volume... a disastrous +choice for the future. +

+ +

+And finally, the design of the machine, of course, had to be a stunner as well. Steve hired frogdesign again, the same firm that had designed +Macintosh, and they came up with a perfect black cube built out of magnesium. Although the Cube clearly deserved its place at the SF MOMA, +many of its features made it a pain to build: from the perfect right angles to its materials to its color, it was extremely complicated — and expensive — +to put together. In addition, Steve had made a point on also designing a “beautiful” board for the Cube. +

+ +
+46 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page47.html b/samples/steve-jobs/pages/page47.html new file mode 100644 index 0000000..496ef84 --- /dev/null +++ b/samples/steve-jobs/pages/page47.html @@ -0,0 +1,19 @@ +
+ +

+All the electronic components, which are +usually on several different pieces of plastic, were melded on a single square board that the chairman considered as beautiful as the case itself. +However it was a strenuous problem for engineers to solve. +

+ +

The introduction

+

+Because of all its breakthroughs, in both hardware and software, the date of + +the NeXT computer’s introduction was constantly being put off. Originally, it was supposed to be out in spring 1987, since most universities shop for +the next academic year during springtime. But the computer was nowhere near ready at that time! It was rescheduled for fall 1987, then spring 1988, +and finally to fall 1988 — on October 12 to be precise. +

+ +
+47 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page48.html b/samples/steve-jobs/pages/page48.html new file mode 100644 index 0000000..4bb0d2f --- /dev/null +++ b/samples/steve-jobs/pages/page48.html @@ -0,0 +1,20 @@ +
+ +

Getting real

+ +

Hopes at NeXT

+ +

+There were a couple of events that led NeXT executives to falsely believe +that they were on the right track, instead of realizing they were heading to the wall. +

+ +

+First was a major deal with IBM that was signed in September 1988, just one month before the Cube’s introduction. As we explained before, NeXT’s +operating system, NeXTSTEP, was a revolution in software. It was the first UNIX ever to sport a graphical user interface, making an arcane piece of +software accessible to mere mortals. We also said that UNIX was used on several computer mainframes, the vast majority of which were still IBM- +made. That’s why Big Blue showed a substantial interest in the NeXT operating system: its +

+ +
+48 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page49.html b/samples/steve-jobs/pages/page49.html new file mode 100644 index 0000000..20006ba --- /dev/null +++ b/samples/steve-jobs/pages/page49.html @@ -0,0 +1,18 @@ +
+ +

+intention was to buy a right to license NeXTSTEP on its +mainframe systems, in order to add GUIs to its UNIX computers. Moreover, IBM was trying to find a way out of its morass with software developer +Microsoft. +

+ +

The NeXT Station

+

+Despite those signs of optimism, the NeXT Cube was a blatant failure on the + +marketplace. It simply did not sell: universities and students found it way too expensive. Firstly, by 1988, it was common for students to have a +Macintosh in their dorm rooms. The days when you had to go to the computer lab to use a workstation like the Cube +

+ +
+49 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page5.html b/samples/steve-jobs/pages/page5.html new file mode 100644 index 0000000..e037398 --- /dev/null +++ b/samples/steve-jobs/pages/page5.html @@ -0,0 +1,18 @@ + +5 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page50.html b/samples/steve-jobs/pages/page50.html new file mode 100644 index 0000000..943ff12 --- /dev/null +++ b/samples/steve-jobs/pages/page50.html @@ -0,0 +1,18 @@ +
+ +

+were long gone. There was +also the problem of donations — universities were used to be given, not sold, computers, in the hope that students would use the same computers +in their future corporate careers. Finally, the Cube was not as modern as it would have been had it come out the year before: it was monochrome at a +time where color started to appear, its magneto-optical drive was a pain to use, and above all, it had very limited software. +

+ +

Tough times for Pixar

+ +

As for Pixar, it was in a really painful situation by the early 1990s.

+

First of all, the computer animation department, headed by John Lasseter, had to fight regularly for its survival. Steve Jobs almost shut it down several +times throughout 1987 and 1988, until the team had the idea of making animation for TV commercials. That way +

+ +
+50 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page51.html b/samples/steve-jobs/pages/page51.html new file mode 100644 index 0000000..12bb8ad --- /dev/null +++ b/samples/steve-jobs/pages/page51.html @@ -0,0 +1,17 @@ +
+ +

+they could survive and keep all the +talents they had spent years to gather, while making some money. + +For all that, work on “artistic” movies did not stop: the team’s Tin Toy got an +Academy Award for Best Animated Short Film in 1988, and the following year, Lasseter earned critical acclaim for his short Luxo Jr. at the SIGGRAPH +convention. Steve allowed for the animation department to continue such work because the prestige could be used for selling more PICs — although, +ironically, Pixar only made one short movie on their computer in their entire history: Red’s Dream (in 1987). +

+

+However, sales of Pixar Image Computers were still extremely +disappointing. On April 30 1990, Steve Jobs announced he was shutting down all of the company’s +

+
+51 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page52.html b/samples/steve-jobs/pages/page52.html new file mode 100644 index 0000000..5310007 --- /dev/null +++ b/samples/steve-jobs/pages/page52.html @@ -0,0 +1,20 @@ +
+ +

+hardware operations, while the staff moved +away from Lucasfilm’s premises to new offices in Point Richmond — not far from a Chevron oil refinery. From then on, they would have to focus only on +their boss’s new vision: Steve thought that RenderMan was going to become the next PostScript, an open standard adopted by the masses to +make 3D renderings at home, just like PostScript had made desktop publishing possible. He was denying the reality of how hard it was to +master three-dimensional animation. +

+ +

+If costs were indeed cut a little by this move, it didn’t make Pixar more +profitable. The startup was still relying on Steve Jobs’ line of credit, and in 1990 alone, its net operating loss was over $8 million. +

+

+In March 1991, Steve went further in his drastic moves to make Pixar survive. He declared he would continue to keep funding it only if he were +given back all of the employees’ stock shares. +

+
+52 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page53.html b/samples/steve-jobs/pages/page53.html new file mode 100644 index 0000000..204cb63 --- /dev/null +++ b/samples/steve-jobs/pages/page53.html @@ -0,0 +1,17 @@ +
+ +

Wilderness years

+ +

Marriage

+

+ +The years of 1991 to 1994 were the worst in Steve’s career. + +Paradoxically, +they were some of the happiest years in his private life. In 1990, at age 35, after his girlfriend Tina Redse had turned down his proposal, he started +dating a young Stanford MBA student called Laurene Powell. Laurene was a leggy blonde in the mold of Steve’s taste in women, but she was also very +smart and independent — in addition to being a militant vegan. According to Steve, it was love at first +

+ +
+53 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page54.html b/samples/steve-jobs/pages/page54.html new file mode 100644 index 0000000..114435c --- /dev/null +++ b/samples/steve-jobs/pages/page54.html @@ -0,0 +1,18 @@ +
+

+sight: he canceled a business meeting to have +lunch with her, and the following year, on March 18 1991, they got married in Yosemite. Steve only brought along a couple of guests in the lodge’s +chapel, and the no-frills ceremony was conducted by his long-time Zen guru Kobun Chino. A few months later, Laurene gave birth to Steve’s second +child, a baby boy named Reed Paul, after Steve’s alma mater (Reed College) and his father (Paul Jobs). +

+ +

Troubles at NeXT

+

+Throughout 1990 and 1991, it became obvious to NeXT’s management that something was wrong with their computers. They believed it was a +strategic error; that they should position themselves as makers of an emerging kind of computers, personal workstations, i.e. computers as +powerful as workstations yet as easy to use as personal computers. Their competitors were not Apple or other PC brands anymore, but Sun, the + +

+ +
+54 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page55.html b/samples/steve-jobs/pages/page55.html new file mode 100644 index 0000000..0928ca0 --- /dev/null +++ b/samples/steve-jobs/pages/page55.html @@ -0,0 +1,22 @@ +
+

+dominant player in the workstation business. +

+ +

+The re-positioning came too late, and it did nothing to improve the +disastrous state of the company’s financials. They were still spending money like crazy, as exemplified by their new offices facing a marina in +Redwood City and its free-standing staircase designed by I.M. Pei’s architectural firm. But they were hardly selling: their revenues for 1990 were +as low as $28 million (in comparison, Sun made $2.5 billion that same year). In addition, NeXT’s deal with IBM was canceled, as it proved difficult for two +such radically different companies to cooperate. Steve was still suspicious of Big Blue: +

+ +
+I’m not stupid enough to give you everything I have, when you have 27,000 salespeople. +
+ +quoted in Randall E. Stross’ Steve Jobs and the NeXT Big Thing + + +
+55 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page56.html b/samples/steve-jobs/pages/page56.html new file mode 100644 index 0000000..24ffc61 --- /dev/null +++ b/samples/steve-jobs/pages/page56.html @@ -0,0 +1,18 @@ +
+ +

Saved by toys

+

Toy Story

+ +

+ +Fortunately enough, “it’s over” didn’t have the + +same meaning in Hollywood as it did in Silicon Valley. +John Lasseter and other Pixar employees worked +very hard at the script, and in February 1994, they turned out a new, +improved version that won Jeffrey Katzenberg’s approval: production could resume. Steve was not overwhelmed, as he kept trying to sell Pixar to +outside investors until late fall 1994. At the time he came very close to selling the animation studios to... +

+ +
+56 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page57.html b/samples/steve-jobs/pages/page57.html new file mode 100644 index 0000000..137f6e1 --- /dev/null +++ b/samples/steve-jobs/pages/page57.html @@ -0,0 +1,22 @@ +
+

+Apple’s arch-rival Microsoft. +

+ +

+But he progressively started to sense Pixar was going to be a lot more important to his career than he ever expected. According to many, the +revelation came in January 1995, when he was invited to a Disney event in New York. In the middle of Central Park, the movie studio had set up a +gigantic tent with a movie screen showing previews of the two upcoming Disney films, Pocahontas, to be released in the summer, and Toy Story, for +Thanksgiving 1995. +

+ +
+That was the moment Steve realized the Disney deal would materialize into something much bigger than he had ever imagined, and that Pixar was the way out of his morass with NeXT. +
+ + +Pixar’s Ralph Guggenheim quoted in Alan Deutschman's The Second Coming of Steve Jobs + + +
+57 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page58.html b/samples/steve-jobs/pages/page58.html new file mode 100644 index 0000000..5ab19ba --- /dev/null +++ b/samples/steve-jobs/pages/page58.html @@ -0,0 +1,12 @@ +
+

+When Toy Story finally came out on November 22, it exceeded all the hopes that Pixar and Disney had put into it. It made $28 million in the Thanksgiving 3-day weekend alone, and eventually reached $160 million in US box-office receipts — a great number for a $27 million production. +

+ +

But it wasn’t just about the movie.

+ +

+When Steve started envisioning the possible success of Toy Story, he talked about taking Pixar public. Wall Street analysts and experts laughed at his face, since Pixar still hadn’t made a single profit during its nine-year existence. But, in August 1995, a small startup that had existed for only a year and was also unprofitable had made a huge hit by going public: it was Netscape, the software developer of the eponymous Web browser. Suddenly Steve’s idea was not that ridiculous anymore.

+ +
+58 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page59.html b/samples/steve-jobs/pages/page59.html new file mode 100644 index 0000000..b2ff5f2 --- /dev/null +++ b/samples/steve-jobs/pages/page59.html @@ -0,0 +1,16 @@ +
+

The return to Apple

+ +

Apple in 1996

+

+To understand how Steve Jobs came back to the company he founded, it is necessary to have a look at Apple’s situation in the mid-1990s. +

+

+As we said before, Apple made healthy profits from 1986 to 1995, mainly thanks to its monopoly on both the GUI and the desktop publishing revolution. Everyone who wanted a user-friendly computer bought a Macintosh for approximately $2,000, half of which were pure profits to Cupertino. +

+ +

+But, starting in 1992, Apple felt threatened by an emerging super- power in the computer business: Microsoft. So far Microsoft was mostly known for providing MS-DOS to the IBM PC and its clones, +

+
+59 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page6.html b/samples/steve-jobs/pages/page6.html new file mode 100644 index 0000000..e69de29 diff --git a/samples/steve-jobs/pages/page60.html b/samples/steve-jobs/pages/page60.html new file mode 100644 index 0000000..44db3ad --- /dev/null +++ b/samples/steve-jobs/pages/page60.html @@ -0,0 +1,14 @@ +
+ +

+which accounted for something like 80% of the PC market — the remaining 20% being Apple. But the Redmond-based company was also an application developer, and it had actually worked on the Macintosh with Steve Jobs in the early 1980s to provide Mac software such as Multiplan. +

+ +

Taking over?

+

+The first talks of Steve Jobs going back to Apple started in 1995, even before Gil Amelio was named CEO. In December of that year, Steve’s friend +Larry Ellison, the founder and CEO of Oracle and one of the world’s richest men, talked about making a hostile takeover bid for Apple in the media and on his website. All the arrangements were made for Oracle and other investors to purchase the company for about $3 billion and install Steve as its new boss. Steve later explained that he was the one who decided against it at the last minute: +

+ +
+60 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page61.html b/samples/steve-jobs/pages/page61.html new file mode 100644 index 0000000..2ad5722 --- /dev/null +++ b/samples/steve-jobs/pages/page61.html @@ -0,0 +1,18 @@ +
+ +
+I decided I'm not a hostile-takeover kind of guy. If they had [asked] me to come back, it might have been different. +
+ + +Steve Jobs on the takeover bid, quoted in a Time article from December 1996 + + +

A new foundation for the Mac OS

+

+ +It was one year later that Steve’s return to Apple was set into motion. In November 1996, the company was looking for a new operating system for its future Macs. The Mac OS was bloated with old technologies, slow, and unadapted to modern computers. Apple had been working for some time on an internal project called Copland, yet it was constantly being +

+ +
+61 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page62.html b/samples/steve-jobs/pages/page62.html new file mode 100644 index 0000000..efd95f8 --- /dev/null +++ b/samples/steve-jobs/pages/page62.html @@ -0,0 +1,11 @@ +
+ +

+delayed and it soon became obvious it would not fit the bill. So CEO Gil Amelio started shopping around for a modern OS to buy, and after a while, a consensus started to emerge on Jean-Louis Gassée’s BeOS. Gassée was the former Apple France executive who was supposed to replace Steve Jobs as the head of the Macintosh division in 1985. He had since left Apple and started his own company, Be Inc., whose software had everything Apple needed, including the good taste of running natively on Apple’s products. +

+ +

+However some NeXT employees called up Apple and told them about their own system, the very advanced NeXTSTEP, that had always been regarded as one of the best software platforms on the planet. Steve Jobs learned about it later and he was stunned. But in December 1996, he showed up at Apple for the first time in eleven years and not only convinced the board of using his technology, but also to buy his company. Apple agreed to pay more than $400 million for NeXT, +

+
+62 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page63.html b/samples/steve-jobs/pages/page63.html new file mode 100644 index 0000000..13fa5d3 --- /dev/null +++ b/samples/steve-jobs/pages/page63.html @@ -0,0 +1,19 @@ +
+ +

+ whereas Be was only asking for $200 million. +

+ +

The interim CEO

+

Macworld Boston 1997

+ +

+ +

+ +

One of Steve’s first decisions was to make a deal with market leader +Microsoft. This was a hot issue as to many Apple customers, Microsoft was something of a personal enemy, the embodiment of evil in the computer +industry. Yet Steve Jobs came to his old acquaintance +

+
+63 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page64.html b/samples/steve-jobs/pages/page64.html new file mode 100644 index 0000000..4f9cbfc --- /dev/null +++ b/samples/steve-jobs/pages/page64.html @@ -0,0 +1,22 @@ +
+ +

+Bill Gates and proposed him to solve the several disputes between their respective +companies. The deal included the end of all patent lawsuits, a promise to keep releasing Mac versions of Microsoft Office for five years in exchange of +making Internet Explorer the default Web browser on the Mac, and a $150 million investment in Apple from Microsoft, in the form of non-voting +shares. +

+ +

+When Steve Jobs unveiled the deal in August at Macworld Boston 1997, the +Apple fans in the room welcomed the announcements with screams of reprehension. They were especially startled when Bill Gates’ face appeared +on the huge screen of the room, curiously reminiscent of the 1984 ad against IBM. After all, Steve himself had often called Microsoft “the IBM of +the 1990s.” +

+ +

+It was during that same keynote that Steve Jobs hinted at the new marketing strategy for Apple. He +

+ +
+64 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page65.html b/samples/steve-jobs/pages/page65.html new file mode 100644 index 0000000..557c0aa --- /dev/null +++ b/samples/steve-jobs/pages/page65.html @@ -0,0 +1,18 @@ +
+ +

+would leverage the incredible power of + +the Apple brand, focusing only on the company’s culture of rebellion and artistic creativity. This was the germ of the Think Different campaign. Steve +had come back to Lee Clow at TBWA Chiat/Day, the ad agency that was responsible for the original Macintosh’s advertising (especially the 1984 +commercial), to help him restore the company’s image in the public. The result was as Jobsian as it gets: huge black and white photographs, similar +to the ones he had at home, portraying great iconic people who were celebrated for having changed the world. +

+ +

+It is not surprising that the agency suggested Steve +

+ + +
+65 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page66.html b/samples/steve-jobs/pages/page66.html new file mode 100644 index 0000000..0c1d3da --- /dev/null +++ b/samples/steve-jobs/pages/page66.html @@ -0,0 +1,21 @@ +
+ +

+Jobs as one of the persons to be displayed in the ads, although he turned it down. +

+ +

New strategy

+

+Steve started working like crazy in that second half of 1997 to put Apple back on track. +

+ +

+He surveyed every single product team in the company, calling them in one by one in Apple’s conference room. Everybody had to convince him that +their product was essential to the company’s strategy. There was no sentimentality: if the product was not making a profit, it usually had to go, +however strategic it might seem to the engineers working on it. He soaked up a tremendous amount of information about all aspects of the business +before taking action. +

+ + +
+66 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page67.html b/samples/steve-jobs/pages/page67.html new file mode 100644 index 0000000..1b4677e --- /dev/null +++ b/samples/steve-jobs/pages/page67.html @@ -0,0 +1,20 @@ +
+ +

Insanely great products

+ + +

+The first product lines to be renovated by Steve Jobs were the pro products, +Power Mac and PowerBook, which he unveiled in November 1997, only eleven months after he came back. They were the first Macs to run the new +Power PC G3 family of processors, from Motorola. They were relatively fast machines designed for creative professionals, which outperformed their +Pentium-based competitors in many respects. +

+

+ +

+ + + + +
+67 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page68.html b/samples/steve-jobs/pages/page68.html new file mode 100644 index 0000000..8e5d45e --- /dev/null +++ b/samples/steve-jobs/pages/page68.html @@ -0,0 +1,19 @@ +
+ +

+The new pro Macs sold quite well, proving to Steve that he was right about Apple’s customer base. He knew that a lot of Mac users had refrained from +buying new computers throughout 1995 and 1996, not because they wanted to switch to Windows, but because they were afraid that Apple +would disappear. It was a widespread feeling within the Apple community while Cupertino kept releasing bad products and accumulating losses. +When Steve Jobs came back and insufflated the company with confidence in the future, sales started rising again. So much so that at Macworld 1998, +on January 8, he announced on stage that Apple was back to profitability. For the first time since 1996, it had made a $45 million profit in the last +quarter of 1997. +

+ +

+But Apple’s biggest hit was yet to come. When Steve came back at Apple, a +team was working on a so-called NC machine, for “network computer.” It was commonly thought at the time that personal computers were living their +last days before their complete +

+ +
+68 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page69.html b/samples/steve-jobs/pages/page69.html new file mode 100644 index 0000000..2c00614 --- /dev/null +++ b/samples/steve-jobs/pages/page69.html @@ -0,0 +1,22 @@ +
+ +

+replacement by so-called “network appliances”, stripped-down terminals that would get all their content from +the Internet. Steve kept the project internally but made it evolve into a new +consumer desktop computer, the iMac (the i stood for Internet). For the looks of the box, he turned to one of Apple’s in-house designer, a soft- +spoken Englishman named Jonathan Ive. Ive had joined the company before Steve came back, but it was the interim CEO who made him head of +the industrial design team. +

+ +

+But Apple’s biggest hit was yet to come. When Steve came back at Apple, a +team was working on a so-called NC machine, for “network computer.” It was commonly thought at the time that personal computers were living their +last days before their complete +

+ +

+Steve unveiled the iMac on May 6 1998, at the Flint Center auditorium in Cupertino, in the same room where he had unveiled Macintosh some +fourteen years +

+
+69 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page7.html b/samples/steve-jobs/pages/page7.html new file mode 100644 index 0000000..a200891 --- /dev/null +++ b/samples/steve-jobs/pages/page7.html @@ -0,0 +1,14 @@ +
+ +

The Book

+ +

+Steve Jobs is the authorized biography of Steve Jobs. The biography was written at the request of Jobs by acclaimed biographer Walter Isaacson, a former executive at CNN and Time who has written best-selling biographies about Benjamin Franklin and Albert Einstein. +

+ +

+Based on more than forty interviews with Jobs conducted over two years—in addition to interviews with more than one hundred family members, friends, adversaries, competitors, and colleagues—Isaacson was given "exclusive and unprecedented" access to Jobs's life. Jobs is said to have encouraged the people interviewed to speak honestly. Although Jobs cooperated with the book, he asked for no control over its content other than the book's cover, and waived the right to read it before it was published. +

+ +
+7 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page70.html b/samples/steve-jobs/pages/page70.html new file mode 100644 index 0000000..06d3e9d --- /dev/null +++ b/samples/steve-jobs/pages/page70.html @@ -0,0 +1,18 @@ +
+ +

+earlier. The choice was highly symbolic, just like the first +words that showed up on the computer’s screen: “hello (again)”, a reference to Macintosh’s original “hello”. Steve Jobs had put Apple back at the forefront of the consumer desktop scene, a market the company had invented. +

+ +

+The iMac proved one of Apple’s biggest hits, selling + +two million units in its first two years. But of course Steve Jobs didn’t stop there. +Only seven months later, in January 1999, he made two product +announcements at Macworld San Francisco. First was a brand new Power Mac G3 tower that was not only faster, but also featured a new, appealing +design inspired by the original iMac. And second was that the iMac would now come in several colors, hence its internal +

+ +
+70 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page71.html b/samples/steve-jobs/pages/page71.html new file mode 100644 index 0000000..a54c453 --- /dev/null +++ b/samples/steve-jobs/pages/page71.html @@ -0,0 +1,20 @@ +
+ +

+code name “lifesavers”... this was another breakthrough in computer design at the time. +

+ +

+ +However it would take another six months for Apple to fill its product matrix, until in July 1999, Steve unveiled the iBook at Macworld New York. +The company’s consumer notebook was introduced with the tag-line: “iMac to go”, as its design clearly evoked that of its desktop counterpart. It was a +sensation again to many industry observers. +

+ +

+During that same show, Apple also unveiled its first Wi-Fi product, the AirPort base station. Wireless connectivity was typical of an Apple +innovation. The company being and wishing to remain small, it usually +

+ +
+71 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page72.html b/samples/steve-jobs/pages/page72.html new file mode 100644 index 0000000..f7330c8 --- /dev/null +++ b/samples/steve-jobs/pages/page72.html @@ -0,0 +1,15 @@ +
+ +

+developed new technologies two or three at a time, not more, so that it +could keep its focus and put A teams on every project. By doing so, Apple could pioneer several technologies with a brilliance unmatched in hi-tech: +AirPort clearly set the standard for the future of WiFi. +

+ +

+After two years as interim CEO, Steve Jobs completely turned Apple around. He restored the company’s public image, implemented a successful and +focused new strategy, attracted software developers, and launched highly innovative and awe-inspiring products on the marketplace. +

+ +
+72 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page73.html b/samples/steve-jobs/pages/page73.html new file mode 100644 index 0000000..538c551 --- /dev/null +++ b/samples/steve-jobs/pages/page73.html @@ -0,0 +1,15 @@ +
+

A visionary

+

Apple’s CEO, at last

+ +

Steve Jobs’ keynote address at Macworld on January 5 2000 was a milestone for two reasons. +

+

+ +First, after a little over three years of managing Apple, he declared he had +accepted his de facto situation and become the company’s full-time CEO. Remember that he was only interim CEO up to this point, not wanting to +upset either Pixar’s or Apple’s shareholders by being simultaneously CEO of two public companies. Time had proven this wasn’t a problem: Pixar was +well managed by Ed Catmull and John Lasseter, and had released two successful movies +

+
+73 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page74.html b/samples/steve-jobs/pages/page74.html new file mode 100644 index 0000000..a89b04e --- /dev/null +++ b/samples/steve-jobs/pages/page74.html @@ -0,0 +1,19 @@ +
+

+ since Toy Story, A Bug’s Life and Toy Story 2. His main role +at Pixar was negotiating with Disney, which left him plenty of time to run Apple. He had turned the Cupertino firm into a leader in computer +innovation again, steadily refreshing its product line and pioneering new technologies. +

+

Mac OS X

+

+But the biggest news was probably the unveiling of Apple’s new operating system, Mac OS X. + + +Mac OS X was the result of three years of hard work by all of Apple’s software engineers to port NeXTSTEP to the Mac platform. The new system +felt like an evolved version of the Mac OS, but people familiar with NeXTSTEP felt home too. +

+ +

Let’s have a look at the system’s architecture to see what we mean.

+ +
+74 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page75.html b/samples/steve-jobs/pages/page75.html new file mode 100644 index 0000000..bcc8496 --- /dev/null +++ b/samples/steve-jobs/pages/page75.html @@ -0,0 +1,17 @@ +
+ +

+The system’s UNIX kernel was called Darwin, and it was based on Mach, the modern kernel technology developed by Avie Tevanian at Carnegie Mellon +and the foundation of NeXTSTEP. Darwin was why Mac OS X had protected memory and pre-emptive multi-tasking, which allowed for multiple +applications to run at the same time without ever bringing the system down. It also provided very advanced networking, unlike the old Mac OS. +

+

+2D graphics were based on PostScript, just like NeXTSTEP, which allowed for +nice font anti-aliasing and on the-fly PDF rendering. 3D graphics however, unlike NeXTSTEP, were based on the most widespread standard, OpenGL, +not on Pixar’s RenderMan. And the media core was Apple’s QuickTime, an old Mac technology ported to the new system. +

+

+Object-oriented application development, which was the raison d’être of NeXTSTEP and its true competitive +

+
+75 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page76.html b/samples/steve-jobs/pages/page76.html new file mode 100644 index 0000000..49f9c57 --- /dev/null +++ b/samples/steve-jobs/pages/page76.html @@ -0,0 +1,18 @@ +
+ +

+advantage, was of course possible in OS X, but it required entirely rewriting an application. So Apple provided an environment to which old Mac apps were easy to port, called Carbon — and OS X even supported those apps natively in a third environment, called Classic. Although Classic could not support any of OS X’s benefits, it was necessary to ease the radical transition from the old Mac OS to the brand new OS X. +

+ +

+Aqua was a revolutionary new user interface that visually took the Mac OS and even NeXTSTEP to a whole new level. It used translucent colors instead +of solid grays, circles instead of angles, and shadows and transparency aplenty. In fact the reason it was called Aqua is that “you wanted to lick it”. +

+ +

+Mac OS X shipped on March 24, 2001, and became the core of Apple’s resurgence and current success. What an incredible twist of fate: to make a +long history short, Apple was eventually saved by NeXT, a company +

+ +
+76 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page77.html b/samples/steve-jobs/pages/page77.html new file mode 100644 index 0000000..f73d34b --- /dev/null +++ b/samples/steve-jobs/pages/page77.html @@ -0,0 +1,20 @@ +
+ +

+that was created to defeat it by an angry Steve Jobs. +

+ +

The Digital Hub strategy

+ +

+ +Apple’s so-called Digital Hub strategy also emerged in 2000, although it was only disclosed a year later at Macworld San Francisco 2001. +

+

+The Digital Hub strategy was a take on the future of personal computing +that went against a common belief that had developed toward the end of the 1990s. Many analysts were so enthusiastic about the success of the +Internet that they were convinced the personal computer was soon to disappear. It would evolve into a mere terminal whose only purpose would +be to access all kinds of content on the Web. The consensus was that the current state of the PC was +

+
+77 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page78.html b/samples/steve-jobs/pages/page78.html new file mode 100644 index 0000000..1fc42ec --- /dev/null +++ b/samples/steve-jobs/pages/page78.html @@ -0,0 +1,16 @@ +
+ +

+a dull, boring box, and that any innovation had stopped in the industry. +

+ +

+Steve Jobs and Apple thought differently. They were among the very few +that professed quite the opposite: the PC had a very exciting future. As they put it, it had evolved throughout the years from the age of productivity, in +the 1980s, where people used it for spreadsheets and databases; to the age of networking, in the 1990s, where it connected to the Internet; and it was +now, in the early 2000s, entering its third age: that of the digital lifestyle. Consumers were increasingly starting to use all kinds of digital devices: +digital cameras, camcorders, music players, PDAs... But these devices didn’t +make sense without a computer. The personal computer was going to become the center or digital hub of this new digital lifestyle, making all its pieces — music, photos, movies, contacts, data — come together. +

+
+78 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page79.html b/samples/steve-jobs/pages/page79.html new file mode 100644 index 0000000..ce9d1fa --- /dev/null +++ b/samples/steve-jobs/pages/page79.html @@ -0,0 +1,21 @@ +
+ +

5 down, 95 to go

+ +

+The digital hub strategy itself was just one part of Steve’s greater plan to finally gain market share in the PC market. Since he had returned to Apple, +the Cupertino company was stuck at around 5% of the overall PC market, even though most industry analysts acknowledged the superiority of its +operating system, and the innovations in its hardware. +

+ +

+One other plan was an aggressive TV campaign called “Switchers”. Its ads +showed several former PC users who had switched to the Mac and were describing how it had made their life so much easier. The purpose of the +campaign was to encourage people who were thinking of switching but were a little afraid to do so, by showing them someone who had made the change and was happy with it. +

+ +

+Yet the riskiest strategic move Apple did to seduce +

+
+79 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page8.html b/samples/steve-jobs/pages/page8.html new file mode 100644 index 0000000..897fd14 --- /dev/null +++ b/samples/steve-jobs/pages/page8.html @@ -0,0 +1,13 @@ +
+ + +

+The book is described as "[chronicling] the roller-coaster life and searingly intense personality of a creative entrepreneur whose passion for perfection and ferocious drive revolutionized six industries: personal computers, animated movies, music, phones, tablet computing, and digital publishing." +

+ +

+In just over 600 pages, the book covers Jobs' entire life, from his childhood in his adoptive parents' home in California to his three bouts with pancreatic cancer. Early chapters include one on his relationship with Steve Wozniak and Jobs' brief stint at Hewlett-Packard, Reed College, Atari, and a formative trip to India to find himself. A chapter each is devoted to the development of the Apple I, Apple II, Lisa, and the classic Macintosh during his early years, the founding of NeXT and funding of Pixar when he was ousted from Apple, and Jobs' triumphant and incredibly productive return to Apple starting in 1997. Following the latter "second coming" of Jobs, Isaacson chronicles the development +

+ +
+8 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page80.html b/samples/steve-jobs/pages/page80.html new file mode 100644 index 0000000..9ddb7a0 --- /dev/null +++ b/samples/steve-jobs/pages/page80.html @@ -0,0 +1,22 @@ +
+ + +

+Windows users was to get into the retailing business. +

+ +

+It was far from an obvious choice. Once again, there was a consensus in the industry that brick-and-mortar computer retailing had had its day. The new +model was Dell, which only shipped computers directly to customers after they were purchased on its website. The one company that had their own +computer boutiques, Gateway, was actually closing them because they were huge money sinks. +

+ +

+But Steve’s vision was different. He understood that Windows users +wouldn’t even consider Apple unless they would actually see how Macs worked and could help them run their digital lives effortlessly. He +envisioned “lifestyle stores” that would showcase Apple’s products working with digital devices, that people could pick up and test drive on the spot. +The stores would be in very expensive locations, in popular malls or in the center of shopping districts. +

+ +
+80 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page81.html b/samples/steve-jobs/pages/page81.html new file mode 100644 index 0000000..e455927 --- /dev/null +++ b/samples/steve-jobs/pages/page81.html @@ -0,0 +1,17 @@ +
+ + +

+To help get into retailing, Steve had former Gap executive Mickey Drexler +join the Apple board as early as 1999, then hired Ron Johnson away from Target in late 2000. After months of experimentation, Apple inaugurated +their first Retail Store in May 2001, in the midst of the industry’s post-Internet bubble crisis. Almost every expert agreed they would turn out an +expensive mistake... +

+ +

+ +

+ + +
+81 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page82.html b/samples/steve-jobs/pages/page82.html new file mode 100644 index 0000000..54c0fa0 --- /dev/null +++ b/samples/steve-jobs/pages/page82.html @@ -0,0 +1,22 @@ +
+ +

+your Mac. That’s how the +idea of making such a device in-house arose, in early 2001, after iTunes was introduced and the company started focusing on the digital music +revolution. +

+ +

+The original iPod distinguished itself from its competition for several +reasons. Apart from its gorgeous look, its click wheel and user interface made browsing through one’s music collection very easy and fast; it had a +hard drive which could store up to 5GB, or “a thousand songs in your pocket”, which was Apple’s tag-line for the new product; it connected to your Mac +via FireWire, which was 30 times faster than your typical USB MP3 player; and it synced with iTunes seamlessly: you just had to plug it in, and the +software took care of the rest. +

+ +

+There was simply no other MP3 player that matched any one of those breakthrough features. iPod quickly became a very, very hot product for +music lovers... and +

+
+82 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page83.html b/samples/steve-jobs/pages/page83.html new file mode 100644 index 0000000..4ab9a32 --- /dev/null +++ b/samples/steve-jobs/pages/page83.html @@ -0,0 +1,19 @@ +
+ +

+ digital pirates. It was quickly acknowledged as “the Walkman of the digital age”, as even Windows users either hacked it or +moved to the Mac just so that they could use it. +

+ +

The iTunes Music Store

+ +

+ + +Once Apple had step foot in the music business with iPod, they started +looking at content. At the time, most people either ripped their CDs on their Macs or downloaded music illegally on peer-to-peer networks. +Recognizing they were in a unique position to do so, Apple decided to try and come up with a legal solution by building an online music store. They +had enough experience to do so thanks to their own popular online store on apple.com, +

+
+83 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page84.html b/samples/steve-jobs/pages/page84.html new file mode 100644 index 0000000..73e1c43 --- /dev/null +++ b/samples/steve-jobs/pages/page84.html @@ -0,0 +1,20 @@ +
+ +

+ as well as their QuickTime movie trailers, which had taught +them how to handle massive downloads on their servers. +

+ +

+Moreover, they were able to negotiate with the music companies because they were still a niche player. The majors were trying hard to fight Napster, +but they were reluctant to launch online stores, afraid that it would destroy their current business model. But iTunes could only run on Macs, which +were still a fraction of the PC market — so they viewed Apple’s proposal as an opportunity to try a new model with limited risks. +

+ +

+So, on April 28 2003, Steve unveiled the iTunes Music Store at a special Music event. The results quickly exceeded the company’s best hopes. Five +million songs were sold in just eight weeks, and another eight million in the following fifteen weeks, bringing iTunes’ share of legal music downloads to +70% — yet it was still only Mac-compatible! +

+
+84 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page85.html b/samples/steve-jobs/pages/page85.html new file mode 100644 index 0000000..91d5b0b --- /dev/null +++ b/samples/steve-jobs/pages/page85.html @@ -0,0 +1,20 @@ +
+ +

Unexpected success

+

+ + +It was the first viable business model for selling music online. + +Everybody +was happy: the labels, who finally saw a way to defeat Napster; Apple, whose sales of iPod were boosted; and of course the customers, who were +finally offered a seamless and legal way to acquire music. As a result, the labels agreed to let Apple extend its business, and on October 16 2003, +Steve Jobs introduced the company’s second app for Windows (the first was its QuickTime Player): iTunes, “the best Windows app ever written”. Windows +iPod users would finally be able to sync their device on Apple’s software, and, more importantly, every PC user could now purchase music on the +iTunes Store. +

+ +

It was the start of a revolution.

+ +
+85 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page86.html b/samples/steve-jobs/pages/page86.html new file mode 100644 index 0000000..f1a1a6f --- /dev/null +++ b/samples/steve-jobs/pages/page86.html @@ -0,0 +1,16 @@ +
+ +

Apple is strong

+

Revolution in Cupertino

+

Steve Jobs didn’t let Apple rest on its laurels.

+

+ +The iPod was a hot product, but it belonged to a niche market: the high- end hard-drive MP3 players. There were still zillions of little Flash players +that were a lot cheaper and got sold for that. Apple went after them as well: at Macworld in January 2004, Steve unveiled the iPod mini, a smaller +version of the iPod which came in colors and soon became the best selling MP3 player in the world. Exactly one year later, he introduced the iPod +shuffle, a cheap, Flash version of the iPod, to go after the rest of the competition. It worked: as of early 2006, Apple’s market +

+ + +
+86 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page87.html b/samples/steve-jobs/pages/page87.html new file mode 100644 index 0000000..10094d5 --- /dev/null +++ b/samples/steve-jobs/pages/page87.html @@ -0,0 +1,20 @@ +
+

+share in the music player space was around 70% — it still is today. The company improved its product line every year, introducing the iPod nano in September 2005, and +the iPod video the following month. Every year after that, the iPod line was refreshed every September. +

+ +

The day hell froze over

+

+The Mac business was starting to rise — finally. + +The risky Trojan horse concept — iPod would seduce Windows users into switching to the Mac — +seemed to be working, together with the unexpected success of the Apple Retail Stores. +

+ +

+The company expanded +

+ +
+87 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page88.html b/samples/steve-jobs/pages/page88.html new file mode 100644 index 0000000..795869b --- /dev/null +++ b/samples/steve-jobs/pages/page88.html @@ -0,0 +1,12 @@ +
+

+and adjusted its product line, careful to the market’s reaction. The days of the simple four-product matrix were long gone. First was the Power Mac G4 Cube, that we already talked about, halfway between the consumer and pro desktop lines. It was discontinued in 2001. Then came the eMac, a cheaper version of the iMac G4 with a CRT display, introduced especially for the education market in 2002, and discontinued in 2005. Finally, in January 2005, they released the Mac mini, a stripped-down Mac designed to appeal to switchers, the cheapest Mac ever at $499. +

+ +

+The move to Intel was decisive in Apple’s fight against the Windows supremacy. Given his company’s growing momentum, Steve appropriately +concluded his WWDC keynote address with the words: “Apple is strong”. +

+ +
+88 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page89.html b/samples/steve-jobs/pages/page89.html new file mode 100644 index 0000000..e6334e7 --- /dev/null +++ b/samples/steve-jobs/pages/page89.html @@ -0,0 +1,10 @@ +
+ + +

+ +

+ + +
+89 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page9.html b/samples/steve-jobs/pages/page9.html new file mode 100644 index 0000000..201d55b --- /dev/null +++ b/samples/steve-jobs/pages/page9.html @@ -0,0 +1,16 @@ +
+ +

+ +

+ +

+of the iMac, iPod, iTunes, Apple Stores, and iPad. +

+ + +

+Jobs' abrasive personality, which simultaneously inspired and intimidated those around him, is a recurrent theme throughout. Details of his personal life are also included, including early relationships, his marriage of twenty years, and his four children and his early life. + +

+9 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page90.html b/samples/steve-jobs/pages/page90.html new file mode 100644 index 0000000..e61e067 --- /dev/null +++ b/samples/steve-jobs/pages/page90.html @@ -0,0 +1,17 @@ +
+ +

Apple Inc.

+

Apple’s momentum

+ +

+ +The company’s decade-long fight to gain market share in the PC industry, + + +especially in the consumer market, was actually finally starting to pay off around 2006. The transition to Intel was rapid yet smooth. The entire +product line was ported in less than a year: it started with the iMac and the pro notebook, re-christened the MacBook Pro, in January 2006. Then came +the Mac mini in February, followed by the MacBook (replacing the venerable iBook) in May +

+ +
+90 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page91.html b/samples/steve-jobs/pages/page91.html new file mode 100644 index 0000000..a9863c5 --- /dev/null +++ b/samples/steve-jobs/pages/page91.html @@ -0,0 +1,22 @@ +
+ +

+and the Mac Pro (former Power Mac) and XServe in August. +

+ +

+In February 2006, Steve unveiled the iPod hi-fi, a stereo speaker system +designed to work only with iPods. He claimed its quality was rivaling with high-end, $10,000 audio systems, while it cost only $349. The market +thought otherwise, as the product flopped and was discontinued in September 2007. The company gave it another shot with the Apple TV, +originally known as iTV, a wireless set-top box that basically linked your Mac with the widescreen TV in your living room. The Apple TV was officially +released at Macworld 2007, but it has yet to prove itself as a successful product. +

+ +

iPhone

+

+Since you are such well-informed readers, you probably already know that Apple’s biggest move outside its computer and music businesses was + +

+ +
+91 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page92.html b/samples/steve-jobs/pages/page92.html new file mode 100644 index 0000000..9871486 --- /dev/null +++ b/samples/steve-jobs/pages/page92.html @@ -0,0 +1,18 @@ +
+ +

+announced at Macworld in January 2007: it is the iPhone. +

+ +

+ + +The iPhone project started in 2003 — although rumors about such a +product had circulated even before that, with the much-hyped Apple PDA. The basic idea was to build a digital convergence product, the ultimate +digital device that would combine a phone, PDA, and iPod. Actually, Apple had already moved into the phone business with the Motorola ROCKR in +late 2005 — a standard chipset that was compatible with iTunes. But the product was lame, and it was just a temporary solution before Apple came +up with its own phone. +

+ +
+92 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page93.html b/samples/steve-jobs/pages/page93.html new file mode 100644 index 0000000..cffe30e --- /dev/null +++ b/samples/steve-jobs/pages/page93.html @@ -0,0 +1,14 @@ +
+ +

+One of the first thing Steve Jobs did before developing iPhone was to go to the cell phone carriers. He talked to them separately in early 2005, promising to build a device “light-years ahead of anything else”. He soon made a deal with America’s #1 carrier, Cingular. The provider knew that the only way to increase its profits was not by competing on price, but by charging users for their increasing use of data online. Since the iPhone was going to surf the Web, it fit their strategy pretty well. +

+ +

+By looking at Apple’s deal with AT&T, one has once again to wonder at +Steve Jobs’ extraordinary negotiation skills. Before iPhone, wireless carriers treated handsets manufacturers like slaves. They used to dictate the +phone’s features, pricing and marketing, in exchange for the right to use their networks. The iPhone deal completely reversed this balance of power. +AT&T-Cingular begged Apple for five years of exclusivity and a 10% margin for sales in its stores, just so they could be +

+
+93 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page94.html b/samples/steve-jobs/pages/page94.html new file mode 100644 index 0000000..01363a3 --- /dev/null +++ b/samples/steve-jobs/pages/page94.html @@ -0,0 +1,18 @@ +
+ +

+the one carrier to support +iPhone. Apple kept complete control over design, manufacturing and marketing — and they even managed to garner $10 a month from every +iPhone Cingular plan. AT&T didn’t even see iPhone until a couple of weeks before it was introduced in January 2007: although such secrecy was +common at Apple, it was unheard of in the cell phone industry. +

+ +

+Work on the iPhone really intensified by early 2006. The product was, once +again, a tribute to Apple’s unique ability to innovate in the consumer electronics industry. It was a miracle of the marriage of hardware and +software, and Apple was the only company that excelled in both. On the software side, it used Mac OS X, the exact same system that was used on +Macs. This made iPhone potentially able to run any kind of Mac software. As for hardware, its most revolutionary feature was its touch-screen display, a +technology Apple originally developed for a tablet PC... that would eventually be introduced three years later (iPad, folks!). +

+
+94 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page95.html b/samples/steve-jobs/pages/page95.html new file mode 100644 index 0000000..bdc036c --- /dev/null +++ b/samples/steve-jobs/pages/page95.html @@ -0,0 +1,18 @@ +
+ +

+The development of +iPhone had its share of tough drawbacks, especially when it was almost restarted from scratch in fall 2006. But the prototype was eventually ready +for Macworld, on January 9 2007. +

+ +

+ +That day, when Steve took the stage at Moscone Center in San Francisco, he +told his audience they would making some history together. He knew iPhone would be one of the most important product in Apple’s history, one +that would set its destiny for decades to come. This little box less than half an inch thick was the ultimate digital pocket device, a computer/iPod/ +phone that allowed its owner to make calls, take photos, handle contacts and email, browse the Web, listen to music and watch movies in a powerful +yet incredibly easy fashion that was unmatched by any of its predecessors. +

+
+95 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page96.html b/samples/steve-jobs/pages/page96.html new file mode 100644 index 0000000..9b17ed1 --- /dev/null +++ b/samples/steve-jobs/pages/page96.html @@ -0,0 +1,8 @@ +
+ +

+ +

+ +
+96 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page97.html b/samples/steve-jobs/pages/page97.html new file mode 100644 index 0000000..f9ca65d --- /dev/null +++ b/samples/steve-jobs/pages/page97.html @@ -0,0 +1,17 @@ +
+ +

2010: Steve is back

+ +

+After an almost entire year of complete absence from the media scene, due to his health problems, Steve has made an impressive comeback in 2010. The charismatic CEO has taken the public spotlight several times during that year, often to make game-changing announcements. +

+ +

iPad

+ +

+The biggest of all was undeniably on January 27, when Steve Jobs finally introduced iPad, Apple’s much-anticipated tablet. There were rumors on an +Apple tablet even before there were rumors on an Apple phone, and for good reasons: the labs of Cupertino started working on a tablet years +before they worked on iPhone. +

+
+97 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page98.html b/samples/steve-jobs/pages/page98.html new file mode 100644 index 0000000..ab7ff2d --- /dev/null +++ b/samples/steve-jobs/pages/page98.html @@ -0,0 +1,13 @@ +
+ +
+I actually started on the tablet first. I had this idea of being able to get rid of the keyboard, type on a multitouch glass display. And I asked our folks, could we come up with a multitouch display? that I could rest my hands on, and actually type on. And about six months later, they called me in and showed me this prototype display. And it was amazing. This is in the early 2000s. And I gave it to one of our other, really brilliant UI folks, and he called me back a few weeks later and he had inertial scrolling working, and a few other things. Now we were thinking about building a phone at that time, and when I saw the rubber band, inertial scrolling and a few of the other things, I thought My God, we could build a phone out of this. And I put the tablet project on the shelf, because the phone was more important. And we took the next several years, and did the iPhone. +
+ +Steve Jobs at the D8 Conference, 1 June 2010 + +

+Throughout 2009, even before Steve Jobs came back from his medical leave of absence, the Apple rumor mill +

+
+98 \ No newline at end of file diff --git a/samples/steve-jobs/pages/page99.html b/samples/steve-jobs/pages/page99.html new file mode 100644 index 0000000..1db9d84 --- /dev/null +++ b/samples/steve-jobs/pages/page99.html @@ -0,0 +1,18 @@ +
+ +

+ + + + + started spinning again with increasing confidence about an upcoming incredible device, a handheld tablet halfway between a Mac and an iPhone. The rumors went even crazier after Steve Jobs presented a prototype of the device to several major US publishers, who couldn’t help talking about it off the record. +

+ +

+ +Then, on January 27, Steve Jobs finally took the stage and unveiled iPad to the world. +The presentation was bare, almost simplistic, with Steve sitting on a couch and demoing the device for most of his keynote. +iPad disappointed the majority of analysts at the time. It was deemed “a bigger iPod touch”, nothing else. Steve was being mocked for calling it “a magical device” during his keynote, and in Apple advertising too! +

+
+99 \ No newline at end of file diff --git a/samples/steve-jobs/pages/preview.jpg b/samples/steve-jobs/pages/preview.jpg new file mode 100644 index 0000000..45476b2 Binary files /dev/null and b/samples/steve-jobs/pages/preview.jpg differ diff --git a/samples/steve-jobs/pics/05.jpg b/samples/steve-jobs/pics/05.jpg new file mode 100644 index 0000000..7ff4cfb Binary files /dev/null and b/samples/steve-jobs/pics/05.jpg differ diff --git a/samples/steve-jobs/pics/06.jpg b/samples/steve-jobs/pics/06.jpg new file mode 100644 index 0000000..632d920 Binary files /dev/null and b/samples/steve-jobs/pics/06.jpg differ diff --git a/samples/steve-jobs/pics/07.jpg b/samples/steve-jobs/pics/07.jpg new file mode 100644 index 0000000..86927a4 Binary files /dev/null and b/samples/steve-jobs/pics/07.jpg differ diff --git a/samples/steve-jobs/pics/08.jpg b/samples/steve-jobs/pics/08.jpg new file mode 100644 index 0000000..9bc4578 Binary files /dev/null and b/samples/steve-jobs/pics/08.jpg differ diff --git a/samples/steve-jobs/pics/09.jpg b/samples/steve-jobs/pics/09.jpg new file mode 100644 index 0000000..f37dc31 Binary files /dev/null and b/samples/steve-jobs/pics/09.jpg differ diff --git a/samples/steve-jobs/pics/10.jpg b/samples/steve-jobs/pics/10.jpg new file mode 100644 index 0000000..9d82ea7 Binary files /dev/null and b/samples/steve-jobs/pics/10.jpg differ diff --git a/samples/steve-jobs/pics/11.jpg b/samples/steve-jobs/pics/11.jpg new file mode 100644 index 0000000..c25bcb8 Binary files /dev/null and b/samples/steve-jobs/pics/11.jpg differ diff --git a/samples/steve-jobs/pics/12.jpg b/samples/steve-jobs/pics/12.jpg new file mode 100644 index 0000000..6d7b7fe Binary files /dev/null and b/samples/steve-jobs/pics/12.jpg differ diff --git a/samples/steve-jobs/pics/13.jpg b/samples/steve-jobs/pics/13.jpg new file mode 100644 index 0000000..7190e9d Binary files /dev/null and b/samples/steve-jobs/pics/13.jpg differ diff --git a/samples/steve-jobs/pics/14.jpg b/samples/steve-jobs/pics/14.jpg new file mode 100644 index 0000000..a5dd362 Binary files /dev/null and b/samples/steve-jobs/pics/14.jpg differ diff --git a/samples/steve-jobs/pics/15.jpg b/samples/steve-jobs/pics/15.jpg new file mode 100644 index 0000000..1593fd0 Binary files /dev/null and b/samples/steve-jobs/pics/15.jpg differ diff --git a/samples/steve-jobs/pics/16.jpg b/samples/steve-jobs/pics/16.jpg new file mode 100644 index 0000000..8c1caf0 Binary files /dev/null and b/samples/steve-jobs/pics/16.jpg differ diff --git a/samples/steve-jobs/pics/17.jpg b/samples/steve-jobs/pics/17.jpg new file mode 100644 index 0000000..52165a6 Binary files /dev/null and b/samples/steve-jobs/pics/17.jpg differ diff --git a/samples/steve-jobs/pics/18.jpg b/samples/steve-jobs/pics/18.jpg new file mode 100644 index 0000000..5c85195 Binary files /dev/null and b/samples/steve-jobs/pics/18.jpg differ diff --git a/samples/steve-jobs/pics/19.jpg b/samples/steve-jobs/pics/19.jpg new file mode 100644 index 0000000..d2c1a96 Binary files /dev/null and b/samples/steve-jobs/pics/19.jpg differ diff --git a/samples/steve-jobs/pics/20.jpg b/samples/steve-jobs/pics/20.jpg new file mode 100644 index 0000000..6e4df41 Binary files /dev/null and b/samples/steve-jobs/pics/20.jpg differ diff --git a/samples/steve-jobs/pics/21.jpg b/samples/steve-jobs/pics/21.jpg new file mode 100644 index 0000000..97d412c Binary files /dev/null and b/samples/steve-jobs/pics/21.jpg differ diff --git a/samples/steve-jobs/pics/22.jpg b/samples/steve-jobs/pics/22.jpg new file mode 100644 index 0000000..30a7c95 Binary files /dev/null and b/samples/steve-jobs/pics/22.jpg differ diff --git a/samples/steve-jobs/pics/23.jpg b/samples/steve-jobs/pics/23.jpg new file mode 100644 index 0000000..7438331 Binary files /dev/null and b/samples/steve-jobs/pics/23.jpg differ diff --git a/samples/steve-jobs/pics/24.jpg b/samples/steve-jobs/pics/24.jpg new file mode 100644 index 0000000..c65481f Binary files /dev/null and b/samples/steve-jobs/pics/24.jpg differ diff --git a/samples/steve-jobs/pics/24.png b/samples/steve-jobs/pics/24.png new file mode 100644 index 0000000..1fbfb82 Binary files /dev/null and b/samples/steve-jobs/pics/24.png differ diff --git a/samples/steve-jobs/pics/25.jpg b/samples/steve-jobs/pics/25.jpg new file mode 100644 index 0000000..8dba2e3 Binary files /dev/null and b/samples/steve-jobs/pics/25.jpg differ diff --git a/samples/steve-jobs/pics/26.jpg b/samples/steve-jobs/pics/26.jpg new file mode 100644 index 0000000..3e238ee Binary files /dev/null and b/samples/steve-jobs/pics/26.jpg differ diff --git a/samples/steve-jobs/pics/27.jpg b/samples/steve-jobs/pics/27.jpg new file mode 100644 index 0000000..a7d1c06 Binary files /dev/null and b/samples/steve-jobs/pics/27.jpg differ diff --git a/samples/steve-jobs/pics/29.jpg b/samples/steve-jobs/pics/29.jpg new file mode 100644 index 0000000..b0544f0 Binary files /dev/null and b/samples/steve-jobs/pics/29.jpg differ diff --git a/samples/steve-jobs/pics/30.jpg b/samples/steve-jobs/pics/30.jpg new file mode 100644 index 0000000..dd4c4b6 Binary files /dev/null and b/samples/steve-jobs/pics/30.jpg differ diff --git a/samples/steve-jobs/pics/31.jpg b/samples/steve-jobs/pics/31.jpg new file mode 100644 index 0000000..e3a68ec Binary files /dev/null and b/samples/steve-jobs/pics/31.jpg differ diff --git a/samples/steve-jobs/pics/32.jpg b/samples/steve-jobs/pics/32.jpg new file mode 100644 index 0000000..1eefb82 Binary files /dev/null and b/samples/steve-jobs/pics/32.jpg differ diff --git a/samples/steve-jobs/pics/33.jpg b/samples/steve-jobs/pics/33.jpg new file mode 100644 index 0000000..af4023d Binary files /dev/null and b/samples/steve-jobs/pics/33.jpg differ diff --git a/samples/steve-jobs/pics/34.jpg b/samples/steve-jobs/pics/34.jpg new file mode 100644 index 0000000..526daf5 Binary files /dev/null and b/samples/steve-jobs/pics/34.jpg differ diff --git a/samples/steve-jobs/pics/35.jpg b/samples/steve-jobs/pics/35.jpg new file mode 100644 index 0000000..8ac2107 Binary files /dev/null and b/samples/steve-jobs/pics/35.jpg differ diff --git a/samples/steve-jobs/pics/36.jpg b/samples/steve-jobs/pics/36.jpg new file mode 100644 index 0000000..313b8e6 Binary files /dev/null and b/samples/steve-jobs/pics/36.jpg differ diff --git a/samples/steve-jobs/pics/37.jpg b/samples/steve-jobs/pics/37.jpg new file mode 100644 index 0000000..5944a14 Binary files /dev/null and b/samples/steve-jobs/pics/37.jpg differ diff --git a/samples/steve-jobs/pics/38.jpg b/samples/steve-jobs/pics/38.jpg new file mode 100644 index 0000000..1cc1dfc Binary files /dev/null and b/samples/steve-jobs/pics/38.jpg differ diff --git a/samples/steve-jobs/pics/39.jpg b/samples/steve-jobs/pics/39.jpg new file mode 100644 index 0000000..bec14c0 Binary files /dev/null and b/samples/steve-jobs/pics/39.jpg differ diff --git a/samples/steve-jobs/pics/40.jpg b/samples/steve-jobs/pics/40.jpg new file mode 100644 index 0000000..d792cf2 Binary files /dev/null and b/samples/steve-jobs/pics/40.jpg differ diff --git a/samples/steve-jobs/pics/41.jpg b/samples/steve-jobs/pics/41.jpg new file mode 100644 index 0000000..7e6c458 Binary files /dev/null and b/samples/steve-jobs/pics/41.jpg differ diff --git a/samples/steve-jobs/pics/42.jpg b/samples/steve-jobs/pics/42.jpg new file mode 100644 index 0000000..95a7308 Binary files /dev/null and b/samples/steve-jobs/pics/42.jpg differ diff --git a/samples/steve-jobs/pics/43.jpg b/samples/steve-jobs/pics/43.jpg new file mode 100644 index 0000000..06de541 Binary files /dev/null and b/samples/steve-jobs/pics/43.jpg differ diff --git a/samples/steve-jobs/pics/44.jpg b/samples/steve-jobs/pics/44.jpg new file mode 100644 index 0000000..f59177b Binary files /dev/null and b/samples/steve-jobs/pics/44.jpg differ diff --git a/samples/steve-jobs/pics/45.jpg b/samples/steve-jobs/pics/45.jpg new file mode 100644 index 0000000..d8eefdc Binary files /dev/null and b/samples/steve-jobs/pics/45.jpg differ diff --git a/samples/steve-jobs/pics/46.jpg b/samples/steve-jobs/pics/46.jpg new file mode 100644 index 0000000..e6ec7dc Binary files /dev/null and b/samples/steve-jobs/pics/46.jpg differ diff --git a/samples/steve-jobs/pics/47.jpg b/samples/steve-jobs/pics/47.jpg new file mode 100644 index 0000000..5a9a4c1 Binary files /dev/null and b/samples/steve-jobs/pics/47.jpg differ diff --git a/samples/steve-jobs/pics/48.jpg b/samples/steve-jobs/pics/48.jpg new file mode 100644 index 0000000..f871ddd Binary files /dev/null and b/samples/steve-jobs/pics/48.jpg differ diff --git a/samples/steve-jobs/pics/book-covers.jpg b/samples/steve-jobs/pics/book-covers.jpg new file mode 100644 index 0000000..179f068 Binary files /dev/null and b/samples/steve-jobs/pics/book-covers.jpg differ diff --git a/samples/steve-jobs/pics/book-covers.png b/samples/steve-jobs/pics/book-covers.png new file mode 100644 index 0000000..04bfd2c Binary files /dev/null and b/samples/steve-jobs/pics/book-covers.png differ diff --git a/samples/steve-jobs/pics/books.jpg b/samples/steve-jobs/pics/books.jpg new file mode 100644 index 0000000..e1e7794 Binary files /dev/null and b/samples/steve-jobs/pics/books.jpg differ diff --git a/samples/steve-jobs/pics/collegue.jpg b/samples/steve-jobs/pics/collegue.jpg new file mode 100644 index 0000000..799fa77 Binary files /dev/null and b/samples/steve-jobs/pics/collegue.jpg differ diff --git a/samples/steve-jobs/pics/gradient-page-left.jpg b/samples/steve-jobs/pics/gradient-page-left.jpg new file mode 100644 index 0000000..96e6bc0 Binary files /dev/null and b/samples/steve-jobs/pics/gradient-page-left.jpg differ diff --git a/samples/steve-jobs/pics/gradient-page-right.jpg b/samples/steve-jobs/pics/gradient-page-right.jpg new file mode 100644 index 0000000..0ec9a80 Binary files /dev/null and b/samples/steve-jobs/pics/gradient-page-right.jpg differ diff --git a/samples/steve-jobs/pics/highschool.jpg b/samples/steve-jobs/pics/highschool.jpg new file mode 100644 index 0000000..1c79659 Binary files /dev/null and b/samples/steve-jobs/pics/highschool.jpg differ diff --git a/samples/steve-jobs/pics/highschool2.jpg b/samples/steve-jobs/pics/highschool2.jpg new file mode 100644 index 0000000..cdb5a61 Binary files /dev/null and b/samples/steve-jobs/pics/highschool2.jpg differ diff --git a/samples/steve-jobs/pics/loader.gif b/samples/steve-jobs/pics/loader.gif new file mode 100644 index 0000000..53dd589 Binary files /dev/null and b/samples/steve-jobs/pics/loader.gif differ diff --git a/samples/steve-jobs/pics/pages-depth.png b/samples/steve-jobs/pics/pages-depth.png new file mode 100644 index 0000000..13810aa Binary files /dev/null and b/samples/steve-jobs/pics/pages-depth.png differ diff --git a/samples/steve-jobs/pics/preview.jpg b/samples/steve-jobs/pics/preview.jpg new file mode 100644 index 0000000..45476b2 Binary files /dev/null and b/samples/steve-jobs/pics/preview.jpg differ diff --git a/samples/steve-jobs/pics/spine.png b/samples/steve-jobs/pics/spine.png new file mode 100644 index 0000000..de4b5b3 Binary files /dev/null and b/samples/steve-jobs/pics/spine.png differ diff --git a/samples/steve-jobs/pics/thumb.png b/samples/steve-jobs/pics/thumb.png new file mode 100644 index 0000000..5cf3c3d Binary files /dev/null and b/samples/steve-jobs/pics/thumb.png differ diff --git a/samples/steve-jobs/pics/young.jpg b/samples/steve-jobs/pics/young.jpg new file mode 100644 index 0000000..4777a7a Binary files /dev/null and b/samples/steve-jobs/pics/young.jpg differ diff --git a/turn.js b/turn.js index d6feac9..1d51aa8 100644 --- a/turn.js +++ b/turn.js @@ -1,20 +1,10 @@ /** - * turn.js 3rd release - * www.turnjs.com + * turn.js 4th release + * turnjs.com + * turnjs.com/license.txt * - * 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. - * + * Copyright (C) 2012 Emmanuel Garcia + * All rights reserved **/ (function($) { @@ -22,1912 +12,3341 @@ 'use strict'; var has3d, + + hasRot, - vendor ='', + vendor = '', + + version = '4.1.0', - PI = Math.PI, + PI = Math.PI, - A90 = PI/2, + A90 = PI/2, - isTouch = 'ontouchstart' in window, + isTouch = 'ontouchstart' in window, - events = (isTouch) ? {start: 'touchstart', move: 'touchmove', end: 'touchend'} - : {start: 'mousedown', move: 'mousemove', end: 'mouseup'}, + mouseEvents = (isTouch) ? + { + down: 'touchstart', + move: 'touchmove', + up: 'touchend', + over: 'touchstart', + out: 'touchend' + } + : + { + down: 'mousedown', + move: 'mousemove', + up: 'mouseup', + over: 'mouseover', + out: 'mouseout' + }, - // Contansts used for each corner - // tl * tr - // * * - // bl * br + // Contansts used for each corner + // | tl * tr | + // l | * * | r + // | bl * br | - corners = { - backward: ['bl', 'tl'], - forward: ['br', 'tr'], - all: ['tl', 'bl', 'tr', 'br'] - }, + corners = { + backward: ['bl', 'tl'], + forward: ['br', 'tr'], + all: ['tl', 'bl', 'tr', 'br', 'l', 'r'] + }, - displays = ['single', 'double'], + // Display values - // Default options + displays = ['single', 'double'], - turnOptions = { + // Direction values - // First page + directions = ['ltr', 'rtl'], - page: 1, - - // Enables gradients + // Default options - gradients: true, + turnOptions = { - // Duration of transition in milliseconds + // Enables hardware acceleration - duration: 600, + acceleration: true, - // Enables hardware acceleration + // Display - acceleration: true, + display: 'double', - // Display + // Duration of transition in milliseconds - display: 'double', + duration: 600, - // Events + // First page - when: null - }, + page: 1, + + // Enables gradients - flipOptions = { + gradients: true, - // Back page - - folding: null, + // Corners used when turning the page - // Corners - // backward: Activates both tl and bl corners - // forward: Activates both tr and br corners - // all: Activates all the corners + turnCorners: 'bl,br', - corners: 'forward', - - // Size of the active zone of each corner + // Events - cornerSize: 100, + when: null + }, - // Enables gradients + flipOptions = { - gradients: true, + // Size of the active zone of each corner - // Duration of transition in milliseconds + cornerSize: 100 - duration: 600, + }, - // Enables hardware acceleration + // Number of pages in the DOM, minimum value: 6 - acceleration: true - }, + pagesInDOM = 6, + - // Number of pages in the DOM, minimum value: 6 +turnMethods = { - pagesInDOM = 6, - - pagePosition = {0: {top: 0, left: 0, right: 'auto', bottom: 'auto'}, - 1: {top: 0, right: 0, left: 'auto', bottom: 'auto'}}, + // Singleton constructor + // $('#selector').turn([options]); - // Gets basic attributes for a layer + init: function(options) { - divAtt = function(top, left, zIndex, overf) { - return {'css': { - position: 'absolute', - top: top, - left: left, - 'overflow': overf || 'hidden', - 'z-index': zIndex || 'auto' - } - }; - }, + // Define constants + + has3d = 'WebKitCSSMatrix' in window || 'MozPerspective' in document.body.style; + hasRot = rotationAvailable(); + vendor = getPrefix(); - // Gets a 2D point from a bezier curve of four points + var i, that = this, pageNum = 0, data = this.data(), ch = this.children(); - bezier = function(p1, p2, p3, p4, t) { - var mum1 = 1 - t, - mum13 = mum1 * mum1 * mum1, - mu3 = t * t * t; + // Set initial configuration - 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 + options = $.extend({ + width: this.width(), + height: this.height(), + direction: this.attr('dir') || this.css('direction') || 'ltr' + }, turnOptions, options); - rad = function(degrees) { - return degrees/180*PI; - }, + data.opts = options; + data.pageObjs = {}; + data.pages = {}; + data.pageWrap = {}; + data.pageZoom = {}; + data.pagePlace = {}; + data.pageMv = []; + data.zoom = 1; + data.totalPages = options.pages || 0; + data.eventHandlers = { + touchStart: $.proxy(turnMethods._touchStart, this), + touchMove: $.proxy(turnMethods._touchMove, this), + touchEnd: $.proxy(turnMethods._touchEnd, this), + start: $.proxy(turnMethods._eventStart, this) + }; - // Converts an angle from radians to degrees - deg = function(radians) { - return radians/PI*180; - }, - // Gets a 2D point + // Add event listeners - point2D = function(x, y) { - return {x: x, y: y}; - }, + if (options.when) + for (i in options.when) + if (has(i, options.when)) + this.bind(i, options.when[i]); - // Returns the traslate value + // Set the css - translate = function(x, y, use3d) { - return (has3d && use3d) ? ' translate3d(' + x + 'px,' + y + 'px, 0px) ' : ' translate(' + x + 'px, ' + y + 'px) '; - }, + this.css({position: 'relative', width: options.width, height: options.height}); - // Returns the rotation value + // Set the initial display - rotate = function(degrees) { - return ' rotate(' + degrees + 'deg) '; - }, + this.turn('display', options.display); - // Checks if a property belongs to an object + // Set the direction - has = function(property, object) { - return Object.prototype.hasOwnProperty.call(object, property); - }, + if (options.direction!=='') + this.turn('direction', options.direction); + + // Prevent blue screen problems of switching to hardware acceleration mode + // By forcing hardware acceleration for ever - // Gets the CSS3 vendor prefix + if (has3d && !isTouch && options.acceleration) + this.transform(translate(0, 0, true)); - getPrefix = function() { - var vendorPrefixes = ['Moz','Webkit','Khtml','O','ms'], - len = vendorPrefixes.length, - vendor = ''; + // Add pages from the DOM - while (len--) - if ((vendorPrefixes[len] + 'Transform') in document.body.style) - vendor='-'+vendorPrefixes[len].toLowerCase()+'-'; + for (i = 0; ilastPage) + throw turnError('Page "'+page+'" cannot be inserted'); + + } else { + + page = lastPage; + incPages = true; + + } + + if (page>=1 && page<=lastPage) { + + if (data.display=='double') + className = (page%2) ? ' odd' : ' even'; + else + className = ''; + + // Stop animations + if (data.done) + this.turn('stop'); + + // Move pages if it's necessary + if (page in data.pageObjs) + turnMethods._movePages.call(this, page, 1); + + // Increase the number of pages + if (incPages) + data.totalPages = lastPage; + + // Add element + data.pageObjs[page] = $(element). + css({'float': 'left'}). + addClass('page p' + page + className); + + if (!hasHardPage() && data.pageObjs[page].hasClass('hard')) { + data.pageObjs[page].removeClass('hard'); + } + + // Add page + turnMethods._addPage.call(this, page); + + // Remove pages out of range + turnMethods._removeFromDOM.call(this); + } + + return this; + }, + + // Adds a page + + _addPage: function(page) { + + var data = this.data(), + element = data.pageObjs[page]; + + if (element) + if (turnMethods._necessPage.call(this, page)) { + + if (!data.pageWrap[page]) { + + // Wrapper + data.pageWrap[page] = $('
', + {'class': 'page-wrapper', + page: page, + css: {position: 'absolute', + overflow: 'hidden'}}); + + // Append to this flipbook + this.append(data.pageWrap[page]); + + if (!data.pagePlace[page]) { + + data.pagePlace[page] = page; + // Move `pageObjs[page]` to wrapper + data.pageObjs[page].appendTo(data.pageWrap[page]); + + } + + // Set the size of the page + var prop = turnMethods._pageSize.call(this, page, true); + element.css({width: prop.width, height: prop.height}); + data.pageWrap[page].css(prop); + + } + + if (data.pagePlace[page] == page) { + + // If the page isn't in another place, create the flip effect + turnMethods._makeFlip.call(this, page); + + } + + } else { + + // Place + data.pagePlace[page] = 0; + + // Remove element from the DOM + if (data.pageObjs[page]) + data.pageObjs[page].remove(); + + } + + }, + + // Checks if a page is in memory + + hasPage: function(page) { + + return has(page, this.data().pageObjs); + + }, + + // Centers the flipbook + + center: function(page) { + + var data = this.data(), + size = $(this).turn('size'), + left = 0; + + if (!data.noCenter) { + if (data.display=='double') { + var view = this.turn('view', page || data.tpage || data.page); + + if (data.direction=='ltr') { + if (!view[0]) + left -= size.width/4; + else if (!view[1]) + left += size.width/4; + } else { + if (!view[0]) + left += size.width/4; + else if (!view[1]) + left -= size.width/4; + } + + } + + $(this).css({marginLeft: left}); + } + + return this; + + }, + + // Destroys the flipbook + + destroy: function () { + + var page, + flipbook = this, + data = this.data(), + events = [ + 'end', 'first', 'flip', 'last', 'pressed', + 'released', 'start', 'turning', 'turned', + 'zooming', 'missing']; + + if (trigger('destroying', this)=='prevented') + return; + + data.destroying = true; + + $.each(events, function(index, eventName) { + flipbook.unbind(eventName); + }); + + this.parent().unbind('start', data.eventHandlers.start); + + $(document).unbind(mouseEvents.move, data.eventHandlers.touchMove). + unbind(mouseEvents.up, data.eventHandlers.touchEnd); + + while (data.totalPages!==0) { + this.turn('removePage', data.totalPages); + } + + if (data.fparent) + data.fparent.remove(); + + if (data.shadow) + data.shadow.remove(); + + this.removeData(); + data = null; + + return this; + + }, + + // Checks if this element is a flipbook + + is: function() { + + return typeof(this.data().pages)=='object'; + + }, + + // Sets and gets the zoom value + + zoom: function(newZoom) { + + var data = this.data(); + + if (typeof(newZoom)=='number') { + + if (newZoom<0.001 || newZoom>100) + throw turnError(newZoom+ ' is not a value for zoom'); + + if (trigger('zooming', this, [newZoom, data.zoom])=='prevented') + return this; + + var size = this.turn('size'), + currentView = this.turn('view'), + iz = 1/data.zoom, + newWidth = Math.round(size.width * iz * newZoom), + newHeight = Math.round(size.height * iz * newZoom); + + data.zoom = newZoom; + + $(this).turn('stop'). + turn('size', newWidth, newHeight); + /*. + css({marginTop: size.height * iz / 2 - newHeight / 2});*/ + + if (data.opts.autoCenter) + this.turn('center'); + /*else + $(this).css({marginLeft: size.width * iz / 2 - newWidth / 2});*/ + + turnMethods._updateShadow.call(this); + + for (var i = 0; idata.totalPages) + throw turnError('"'+page+'" is not a valid page'); + + + view[1] = view[1] || view[0]; + + if (view[0]>=1 && view[1]<=data.totalPages) { + + remainingPages = Math.floor((pagesInDOM-2)/2); + + if (data.totalPages-view[1] > view[0]) { + left = Math.min(view[0]-1, remainingPages); + right = 2*remainingPages-left; + } else { + right = Math.min(data.totalPages-view[1], remainingPages); + left = 2*remainingPages-right; + } + + } else { + left = pagesInDOM-1; + right = pagesInDOM-1; + } + + return [Math.max(1, view[0]-left), + Math.min(data.totalPages, view[1]+right)]; + + }, + + // 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 this.data().pageObjs[page].hasClass('fixed') || + (page>=range[0] && page<=range[1]); + + }, + + // Releases memory by removing pages from the DOM + + _removeFromDOM: function() { + + var page, data = this.data(); + + for (page in data.pageWrap) + if (has(page, data.pageWrap) && + !turnMethods._necessPage.call(this, page)) + turnMethods._removePageFromDOM.call(this, page); + + }, + + // Removes a page from DOM and its internal references + + _removePageFromDOM: function(page) { + + var data = this.data(); + + if (data.pages[page]) { + var dd = data.pages[page].data(); + + flipMethods._moveFoldingPage.call(data.pages[page], false); + + if (dd.f && dd.f.fwrapper) + dd.f.fwrapper.remove(); + + data.pages[page].removeData(); + data.pages[page].remove(); + delete data.pages[page]; + } + + if (data.pageObjs[page]) + data.pageObjs[page].remove(); + + if (data.pageWrap[page]) { + data.pageWrap[page].remove(); + delete data.pageWrap[page]; + } + + turnMethods._removeMv.call(this, page); + + delete data.pagePlace[page]; + delete data.pageZoom[page]; + + }, + + // Removes a page + + removePage: function(page) { + + var data = this.data(); + + // Delete all the pages + if (page=='*') { + + while (data.totalPages!==0) { + this.turn('removePage', data.totalPages); + } + + } else { + + if (page<1 || page>data.totalPages) + throw turnError('The page '+ page + ' doesn\'t exist'); + + if (data.pageObjs[page]) { + + // Stop animations + this.turn('stop'); + + // Remove `page` + turnMethods._removePageFromDOM.call(this, page); + + delete data.pageObjs[page]; + + } + + // Move the pages + turnMethods._movePages.call(this, page, -1); + + // Resize the size of this flipbook + data.totalPages = data.totalPages-1; + + // Check the current view + + if (data.page>data.totalPages) { + + data.page = null; + turnMethods._fitPage.call(this, data.totalPages); + + } else { + + turnMethods._makeRange.call(this); + this.turn('update'); + + } + } + + return this; + + }, + + // Moves pages + + _movePages: function(from, change) { - // Singleton constructor - // $('#selector').turn([options]); - - init: function(opts) { + var page, + that = this, + data = this.data(), + single = data.display=='single', + move = function(page) { - // Define constants - if (has3d===undefined) { - has3d = 'WebKitCSSMatrix' in window || 'MozPerspective' in document.body.style; - vendor = getPrefix(); - } + var next = page + change, + odd = next%2, + className = (odd) ? ' odd ' : ' even '; - var i, data = this.data(), ch = this.children(); - - opts = $.extend({width: this.width(), height: this.height()}, turnOptions, opts); - data.opts = opts; - data.pageObjs = {}; - data.pages = {}; - data.pageWrap = {}; - data.pagePlace = {}; - data.pageMv = []; - data.totalPages = opts.pages || 0; + if (data.pageObjs[page]) + data.pageObjs[next] = data.pageObjs[page]. + removeClass('p' + page + ' odd even'). + addClass('p' + next + className); - if (opts.when) - for (i in opts.when) - if (has(i, opts.when)) - this.bind(i, opts.when[i]); + if (data.pagePlace[page] && data.pageWrap[page]) { + data.pagePlace[next] = next; + + if (data.pageObjs[next].hasClass('fixed')) + data.pageWrap[next] = data.pageWrap[page]. + attr('page', next); + else + data.pageWrap[next] = data.pageWrap[page]. + css(turnMethods._pageSize.call(that, next, true)). + attr('page', next); + + if (data.pages[page]) + data.pages[next] = data.pages[page]. + flip('options', { + page: next, + next: (single || odd) ? next+1 : next-1 + }); - this.css({position: 'relative', width: opts.width, height: opts.height}); + if (change) { + delete data.pages[page]; + delete data.pagePlace[page]; + delete data.pageZoom[page]; + delete data.pageObjs[page]; + delete data.pageWrap[page]; + } - this.turn('display', opts.display); + } - if (has3d && !isTouch && opts.acceleration) - this.transform(translate(0, 0, true)); - - for (i = 0; i0) + for (page=data.totalPages; page>=from; page--) + move(page); + else + for (page=from; page<=data.totalPages; page++) + move(page); - // Event listeners + }, - $(this).bind(events.start, function(e) { - for (var page in data.pages) - 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)) - flipMethods._eventMove.call(data.pages[page], e); - }). - bind(events.end, function(e) { - for (var page in data.pages) - if (has(page, data.pages)) - flipMethods._eventEnd.call(data.pages[page], e); + // Sets or Gets the display mode - }); + display: function(display) { - data.done = true; + var data = this.data(), + currentDisplay = data.display; - return this; - }, + if (display===undefined) { + + return currentDisplay; - // Adds a page from external data + } else { - addPage: function(element, page) { + if ($.inArray(display, displays)==-1) + throw turnError('"'+display + '" is not a value for display'); + + switch(display) { + case 'single': - var incPages = false, - data = this.data(), - lastPage = data.totalPages+1; + // Create a temporal page to use as folded page - if (page) { - if (page==lastPage) { - page = lastPage; - incPages = true; - } else if (page>lastPage) - throw new Error ('It is impossible to add the page "'+page+'", the maximum value is: "'+lastPage+'"'); + if (!data.pageObjs[0]) { + this.turn('stop'). + css({'overflow': 'hidden'}); - } else { - page = lastPage; - incPages = true; - } + data.pageObjs[0] = $('
', + {'class': 'page p-temporal'}). + css({width: this.width(), height: this.height()}). + appendTo(this); + } - if (page>=1 && page<=lastPage) { + this.addClass('shadow'); - // Stop animations - if (data.done) this.turn('stop'); + break; + case 'double': - // Move pages if it's necessary - if (page in data.pageObjs) - turnMethods._movePages.call(this, page, 1); + // Remove the temporal page - // Update number of pages - if (incPages) - data.totalPages = lastPage; - - // Add element - data.pageObjs[page] = $(element).addClass('turn-page p' + page); - - // Add page - turnMethods._addPage.call(this, page); - - // Update view - if (data.done) - this.turn('update'); - - turnMethods._removeFromDOM.call(this); - } - - return this; - }, - - // Adds a page from internal data + if (data.pageObjs[0]) { + this.turn('stop').css({'overflow': ''}); + data.pageObjs[0].remove(); + delete data.pageObjs[0]; + } - _addPage: function(page) { - - var data = this.data(), - element = data.pageObjs[page]; + this.removeClass('shadow'); - if (element) - if (turnMethods._necessPage.call(this, page)) { - - if (!data.pageWrap[page]) { - - var pageWidth = (data.display=='double') ? this.width()/2 : this.width(), - pageHeight = this.height(); - - element.css({width:pageWidth, height:pageHeight}); - - // Place - data.pagePlace[page] = page; - - // Wrapper - data.pageWrap[page] = $('
', {'class': 'turn-page-wrapper', - page: page, - css: {position: 'absolute', - overflow: 'hidden', - width: pageWidth, - height: pageHeight}}). - css(pagePosition[(data.display=='double') ? page%2 : 0]); - - // Append to this - this.append(data.pageWrap[page]); - - // Move data.pageObjs[page] (element) to wrapper - data.pageWrap[page].prepend(data.pageObjs[page]); - } - - // 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 { + break; + } + - // Place - data.pagePlace[page] = 0; + data.display = display; - // Remove element from the DOM - if (data.pageObjs[page]) - data.pageObjs[page].remove(); + if (currentDisplay) { + var size = this.turn('size'); + turnMethods._movePages.call(this, 1, 0); + this.turn('size', size.width, size.height). + turn('update'); + } - } + return this; - }, + } + + }, + + // Gets and sets the direction of the flipbook - // Checks if a page is in memory - - hasPage: function(page) { + direction: function(dir) { - return page in this.data().pageObjs; - - }, + var data = this.data(); - // Prepares the flip effect for a page + if (dir===undefined) { - _makeFlip: function(page) { + return data.direction; - var data = this.data(); + } else { - if (!data.pages[page] && data.pagePlace[page]==page) { + dir = dir.toLowerCase(); - 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, - next: (single && page === data.totalPages) ? page -1 : ((even || single) ? page+1 : page-1), - turn: this, - duration: data.opts.duration, - acceleration : data.opts.acceleration, - corners: (single) ? 'all' : ((even) ? 'forward' : 'backward'), - backGradient: data.opts.gradients, - frontGradient: data.opts.gradients - }). - flip('disable', data.disabled). - bind('pressed', turnMethods._pressed). - bind('released', turnMethods._released). - bind('start', turnMethods._start). - bind('end', turnMethods._end). - bind('flip', turnMethods._flip); - } - return data.pages[page]; - }, + if ($.inArray(dir, directions)==-1) + throw turnError('"' + dir + '" is not a value for direction'); - // Makes pages within a range + if (dir=='rtl') { + $(this).attr('dir', 'ltr'). + css({direction: 'ltr'}); + } - _makeRange: function() { + data.direction = dir; - var page, - data = this.data(), - range = this.turn('range'); + if (data.done) + this.turn('size', $(this).width(), $(this).height()); - for (page = range[0]; page<=range[1]; page++) - turnMethods._addPage.call(this, page); + return this; + } - }, + }, - // Returns a range of `pagesInDOM` pages that should be in the DOM - // Example: - // - page of the current view, return true - // * page is in the range, return true - // 0 page is not in the range, return false - // - // 1 2-3 4-5 6-7 8-9 10-11 12-13 - // ** ** -- ** ** + // Detects animation - range: function(page) { + animating: function() { - var remainingPages, left, right, - data = this.data(); - page = page || data.tpage || data.page; - var view = turnMethods._view.call(this, page); + return this.data().pageMv.length>0; - 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); + // Gets the current activated corner - if (data.totalPages-view[1] > view[0]) { - left = Math.min(view[0]-1, remainingPages); - right = 2*remainingPages-left; - } else { - right = Math.min(data.totalPages-view[1], remainingPages); - left = 2*remainingPages-right; - } + corner: function() { + + var corner, + page, + data = this.data(); - } else { - left = pagesInDOM-1; - right = pagesInDOM-1; - } + for (page in data.pages) { + if (has(page, data.pages)) + if ((corner = data.pages[page].flip('corner'))) { + return corner; + } + } - return [Math.max(1, view[0]-left), Math.min(data.totalPages, view[1]+right)]; + return false; + }, - }, + // Gets the data stored in the flipbook - // Detects if a page is within the range of `pagesInDOM` from the current view + data: function() { + + return this.data(); - _necessPage: function(page) { - - if (page===0) - return true; + }, - var range = this.turn('range'); + // Disables and enables the effect - return page>=range[0] && page<=range[1]; - - }, + disable: function(disable) { - // Releases memory by removing pages from the DOM + var page, + data = this.data(), + view = this.turn('view'); - _removeFromDOM: function() { + data.disabled = disable===undefined || disable===true; - var page, data = this.data(); + for (page in data.pages) { + if (has(page, data.pages)) + data.pages[page].flip('disable', + (data.disabled) ? true : $.inArray(parseInt(page, 10), view)==-1); + } - for (page in data.pageWrap) - if (has(page, data.pageWrap) && !turnMethods._necessPage.call(this, page)) - turnMethods._removePageFromDOM.call(this, page); - - - }, + return this; - // Removes a page from DOM and its internal references + }, - _removePageFromDOM: function(page) { + // Disables and enables the effect - var data = this.data(); + disabled: function(disable) { - if (data.pages[page]) { - var dd = data.pages[page].data(); - if (dd.f && dd.f.fwrapper) - dd.f.fwrapper.remove(); - data.pages[page].remove(); - delete data.pages[page]; - } + if (disable===undefined) { + return this.data().disabled===true; + } else { + return this.turn('disable', disable); + } - if (data.pageObjs[page]) - data.pageObjs[page].remove(); + }, - if (data.pageWrap[page]) { - data.pageWrap[page].remove(); - delete data.pageWrap[page]; - } + // Gets and sets the size - delete data.pagePlace[page]; + size: function(width, height) { - }, + if (width===undefined || height===undefined) { + + return {width: this.width(), height: this.height()}; - // Removes a page + } else { - removePage: function(page) { + this.turn('stop'); - var data = this.data(); + var page, prop, + data = this.data(), + pageWidth = (data.display=='double') ? width/2 : width; - if (data.pageObjs[page]) { - // Stop animations - this.turn('stop'); + this.css({width: width, height: height}); - // Remove `page` - turnMethods._removePageFromDOM.call(this, page); - delete data.pageObjs[page]; + if (data.pageObjs[0]) + data.pageObjs[0].css({width: pageWidth, height: height}); + + for (page in data.pageWrap) { + if (!has(page, data.pageWrap)) continue; - // Move the pages behind `page` - turnMethods._movePages.call(this, page, -1); + prop = turnMethods._pageSize.call(this, page, true); - // Resize the size of this magazine - data.totalPages = data.totalPages-1; - turnMethods._makeRange.call(this); + data.pageObjs[page].css({width: prop.width, height: prop.height}); + data.pageWrap[page].css(prop); + + if (data.pages[page]) + data.pages[page].css({width: prop.width, height: prop.height}); + } - // Check the current view - if (data.page>data.totalPages) - this.turn('page', data.totalPages); - } + this.turn('resize'); - return this; - - }, + return this; - // Moves pages + } + }, - _movePages: function(from, change) { + // Resizes each page - var page, - data = this.data(), - single = data.display=='single', - move = function(page) { + resize: function() { - var next = page + change, - odd = next%2; + var page, data = this.data(); - if (data.pageObjs[page]) - data.pageObjs[next] = data.pageObjs[page].removeClass('page' + page).addClass('page' + next); + if (data.pages[0]) { + data.pageWrap[0].css({left: -this.width()}); + data.pages[0].flip('resize', true); + } - 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, - next: (single || odd) ? next+1 : next-1, - corners: (single) ? 'all' : ((odd) ? 'forward' : 'backward') - }); + for (page = 1; page <= data.totalPages; page++) + if (data.pages[page]) + data.pages[page].flip('resize', true); - if (change) { - delete data.pages[page]; - delete data.pagePlace[page]; - delete data.pageObjs[page]; - delete data.pageWrap[page]; - delete data.pageObjs[page]; - } - } - }; + turnMethods._updateShadow.call(this); - if (change>0) - for (page=data.totalPages; page>=from; page--) move(page); - else - for (page=from; page<=data.totalPages; page++) move(page); + if (data.opts.autoCenter) + this.turn('center'); - }, + }, - // Sets or Gets the display mode + // Removes an animation from the cache - display: function(display) { + _removeMv: function(page) { - var data = this.data(), - currentDisplay = data.display; + var i, data = this.data(); + + for (i=0; i', {'class': 'turn-page p-temporal'}). - css({width: this.width(), height: this.height()}). - appendTo(this); - } - } else { - if (data.pageObjs[0]) { - this.turn('stop'). - css({'overflow': ''}); - data.pageObjs[0].remove(); - delete data.pageObjs[0]; - } - } + }, - data.display = display; + // Adds an animation to the cache + + _addMv: function(page) { - if (currentDisplay) { - var size = this.turn('size'); - turnMethods._movePages.call(this, 1, 0); - this.turn('size', size.width, size.height). - turn('update'); - } + var data = this.data(); - return this; + turnMethods._removeMv.call(this, page); + data.pageMv.push(page); - } else - return currentDisplay; - - }, + }, - // Detects if the pages are being animated + // Gets indexes for a view - animating: function() { + _view: function(page) { + + var data = this.data(); + + page = page || data.page; - return this.data().pageMv.length>0; + if (data.display=='double') + return (page%2) ? [page-1, page] : [page, page+1]; + else + return [page]; - }, + }, - // Disables and enables the effect + // Gets a view - disable: function(bool) { + view: function(page) { - var page, - data = this.data(), - view = this.turn('view'); + var data = this.data(), + view = turnMethods._view.call(this, page); - data.disabled = bool===undefined || bool===true; + if (data.display=='double') + return [(view[0]>0) ? view[0] : 0, + (view[1]<=data.totalPages) ? view[1] : 0]; + else + return [(view[0]>0 && view[0]<=data.totalPages) ? view[0] : 0]; - for (page in data.pages) - if (has(page, data.pages)) - data.pages[page].flip('disable', bool ? $.inArray(page, view) : false ); + }, - return this; + // Stops animations - }, + stop: function(ignore, animate) { - // Gets and sets the size + if (this.turn('animating')) { + + var i, opts, page, + data = this.data(); - size: function(width, height) { + if (data.tpage) { + data.page = data.tpage; + delete data['tpage']; + } - if (width && height) { + for (i = 0; ipages; page--) + this.turn('removePage', page); - }, + } - // Removes an animation from the cache + data.totalPages = pages; + turnMethods._fitPage.call(this, data.page); - _removeMv: function(page) { + return this; - var i, data = this.data(); - - for (i=0; i0) + this.trigger('missing', [missing]); - _view: function(page) { - - var data = this.data(); - page = page || data.page; + }, - if (data.display=='double') - return (page%2) ? [page-1, page] : [page, page+1]; - else - return [page]; + // Sets a page without effect - }, + _fitPage: function(page) { - // Gets a view + var data = this.data(), + newView = this.turn('view', page); - view: function(page) { + turnMethods._missing.call(this, page); + + if (!data.pageObjs[page]) + return; - var data = this.data(), view = turnMethods._view.call(this, page); + data.page = page; + + this.turn('stop'); - return (data.display=='double') ? [(view[0]>0) ? view[0] : 0, (view[1]<=data.totalPages) ? view[1] : 0] - : [(view[0]>0 && view[0]<=data.totalPages) ? view[0] : 0]; + for (var i = 0; ipages) - this.turn('page', pages); - } + } - data.totalPages = pages; + if (data.display=='single') { + current = view[0]; + next = newView[0]; + } else if (view[1] && page>view[1]) { + current = view[1]; + next = newView[0]; + } else if (view[0] && pagecurrent) ? 'r' : 'l'); + else + data.pages[current].flip('turnPage', + (page>current) ? 'l' : 'r'); + else { + if (data.direction=='ltr') + data.pages[current].flip('turnPage', + optsCorners[(page>current) ? 1 : 0]); + else + data.pages[current].flip('turnPage', + optsCorners[(page>current) ? 0 : 1]); + } - var current, next, - 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'); - if ($.inArray(data.totalPages, newView)!=-1) this.trigger('last'); - } + }, - if (!data.pageObjs[page]) - return; + // Gets and sets a page - data.tpage = page; + page: function(page) { - this.turn('stop'); + var data = this.data(); - turnMethods._makeRange.call(this); + if (page===undefined) { + + return data.page; - if (data.display=='single') { - current = view[0]; - next = newView[0]; - } else if (view[1] && page>view[1]) { - current = view[1]; - next = newView[0]; - } else if (view[0] && page view[0]) ? 'br' : 'bl'); - else - data.pages[current].flip('turnPage'); - } + if (page>0 && page<=data.totalPages) { - }, + if (page!=data.page) { + if (!data.done || $.inArray(page, this.turn('view'))!=-1) + turnMethods._fitPage.call(this, page); + else + turnMethods._turnPage.call(this, page); + } + + return this; - // Gets and sets a page + } else { + + throw turnError('The page ' + page + ' does not exist'); - page: function(page) { + } - page = parseInt(page, 10); + } - var data = this.data(); + } - if (page>0 && page<=data.totalPages) { - if (!data.done || $.inArray(page, this.turn('view'))!=-1) - turnMethods._fitPage.call(this, page); - else - turnMethods._turnPage.call(this, page); - - return this; + }, - } else - return data.page; - - }, + // Turns to the next view - // Turns to the next view + next: function() { - next: function() { - - var data = this.data(); - return this.turn('page', turnMethods._view.call(this, data.page).pop() + 1); - - }, + return this.turn('page', Math.min(this.data().totalPages, + turnMethods._view.call(this, this.data().page).pop() + 1)); + + }, - // Turns to the previous view + // Turns to the previous view - previous: function() { - - var data = this.data(); - return this.turn('page', turnMethods._view.call(this, data.page).shift() - 1); + previous: function() { - }, + return this.turn('page', Math.max(1, + turnMethods._view.call(this, this.data().page).shift() - 1)); - // Adds a motion to the internal list + }, - _addMotionPage: function() { + // Shows a peeling corner - var opts = $(this).data().f.opts, - turn = opts.turn, - dd = turn.data(); + peel: function(corner, animate) { + + var data = this.data(), + view = this.turn('view'); - opts.pageMv = opts.page; - turnMethods._addMv.call(turn, opts.pageMv); - dd.pagePlace[opts.next] = opts.page; - turn.turn('update'); + animate = (animate===undefined) ? true : animate===true; - }, + if (corner===false) { + + this.turn('stop', null, animate); - // This event is called in context of flip + } else { + + if (data.display=='single') { - _start: function(e, opts, corner) { + data.pages[data.page].flip('peel', corner, animate); - var data = opts.turn.data(), - event = $.Event('start'); + } else { - e.stopPropagation(); + var page; - opts.turn.trigger(event, [opts, corner]); + if (data.direction=='ltr') { + + page = (corner.indexOf('l')!=-1) ? view[0] : view[1]; - if (event.isDefaultPrevented()) { - e.preventDefault(); - return; - } - - if (data.display=='single') { + } else { + + page = (corner.indexOf('l')!=-1) ? view[1] : view[0]; - var left = corner.charAt(1)=='l'; - if ((opts.page==1 && left) || (opts.page==data.totalPages && !left)) - e.preventDefault(); - else { - if (left) { - opts.next = (opts.nextopts.page) ? opts.next : opts.page+1; - } + } + + if (data.pages[page]) + data.pages[page].flip('peel', corner, animate); - } + } + } - turnMethods._addMotionPage.call(this); - }, + return this; - // This event is called in context of flip + }, - _end: function(e, turned) { - - var that = $(this), - data = that.data().f, - opts = data.opts, - turn = opts.turn, - dd = turn.data(); + // Adds a motion to the internal list + // This event is called in context of flip - e.stopPropagation(); + _addMotionPage: function() { - if (turned || dd.tpage) { + var opts = $(this).data().f.opts, + turn = opts.turn, + dd = turn.data(); - if (dd.tpage==opts.next || dd.tpage==opts.page) { - delete dd['tpage']; - turnMethods._fitPage.call(turn, dd.tpage || opts.next, true); - } + turnMethods._addMv.call(turn, opts.page); - } else { - turnMethods._removeMv.call(turn, opts.pageMv); - turn.turn('update'); - } - - }, - - // This event is called in context of flip + }, - _pressed: function() { + // This event is called in context of flip - var page, - that = $(this), - 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); + _eventStart: function(e, opts, corner) { - return data.time = new Date().getTime(); + var data = opts.turn.data(), + actualZoom = data.pageZoom[opts.page]; - }, + if (e.isDefaultPrevented()) { + turnMethods._updateShadow.call(opts.turn); + return; + } - // This event is called in context of flip + if (actualZoom && actualZoom!=data.zoom) { + + opts.turn.trigger('zoomed',[ + opts.page, + opts.turn.turn('view', opts.page), + actualZoom, + data.zoom]); - _released: function(e, point) { - - var that = $(this), - data = that.data().f; + data.pageZoom[opts.page] = data.zoom; - e.stopPropagation(); + } - if ((new Date().getTime())-data.time<200 || point.x<0 || point.x>$(this).width()) { - e.preventDefault(); - data.opts.turn.data().tpage = data.opts.next; - data.opts.turn.turn('update'); - $(that).flip('turnPage'); - } + if (data.display=='single' && corner) { - }, + if ((corner.charAt(1)=='l' && data.direction=='ltr') || + (corner.charAt(1)=='r' && data.direction=='rtl')) + { + + opts.next = (opts.nextopts.page) ? opts.next : opts.page+1; - var opts = $(this).data().f.opts; - - opts.turn.trigger('turn', [opts.next]); - - }, - - // Calculate the z-index value for pages during the animation - - calculateZ: function(mv) { - - var i, page, nextPage, placePage, dpage, - that = this, - data = this.data(), - view = this.turn('view'), - currentPage = view[0] || view[1], - r = {pageZ: {}, partZ: {}, pageV: {}}, - - addView = function(page) { - var view = that.turn('view', page); - if (view[0]) r.pageV[view[0]] = true; - if (view[1]) r.pageV[view[1]] = true; - }; - - for (i = 0; ipage.width()/2; + } else { + outArea = point.x<0 || point.x>page.width(); + } + + if ((new Date()).getTime()-data.time<200 || outArea) { + + e.preventDefault(); + turnMethods._turnPage.call(turn, data.opts.next); + + } + + turnData.mouseAction = false; + + }, + + // This event is called in context of flip + + _flip: function(e) { + + e.stopPropagation(); + + var opts = $(e.target).data().f.opts; + + opts.turn.trigger('turn', [opts.next]); + + if (opts.turn.data().opts.autoCenter) { + opts.turn.turn('center', opts.next); + } + + }, + + // + _touchStart: function() { + var data = this.data(); + for (var page in data.pages) { + if (has(page, data.pages) && + flipMethods._eventStart.apply(data.pages[page], arguments)===false) { + return false; + } + } + }, + + // + _touchMove: function() { + var data = this.data(); + for (var page in data.pages) { + if (has(page, data.pages)) { + flipMethods._eventMove.apply(data.pages[page], arguments); + } + } + }, + + // + _touchEnd: function() { + var data = this.data(); + for (var page in data.pages) { + if (has(page, data.pages)) { + flipMethods._eventEnd.apply(data.pages[page], arguments); + } + } + }, + + // Calculate the z-index value for pages during the animation + + calculateZ: function(mv) { + + var i, page, nextPage, placePage, dpage, + that = this, + data = this.data(), + view = this.turn('view'), + currentPage = view[0] || view[1], + total = mv.length-1, + r = {pageZ: {}, partZ: {}, pageV: {}}, + + addView = function(page) { + var view = that.turn('view', page); + if (view[0]) r.pageV[view[0]] = true; + if (view[1]) r.pageV[view[1]] = true; + }; + + for (i = 0; i<=total; i++) { + page = mv[i]; + nextPage = data.pages[page].data().f.opts.next; + placePage = data.pagePlace[page]; + addView(page); + addView(nextPage); + dpage = (data.pagePlace[nextPage]==nextPage) ? nextPage : page; + r.pageZ[dpage] = data.totalPages - Math.abs(currentPage-dpage); + r.partZ[placePage] = data.totalPages*2 - total + i; + } + + return r; + }, + + // Updates the z-index and display property of every page + + update: function() { + + var page, + data = this.data(); + + if (this.turn('animating') && data.pageMv[0]!==0) { + + // Update motion + + var p, apage, fixed, + pos = this.turn('calculateZ', data.pageMv), + corner = this.turn('corner'), + actualView = this.turn('view'), + newView = this.turn('view', data.tpage); + + for (page in data.pageWrap) { + + if (!has(page, data.pageWrap)) + continue; + + fixed = data.pageObjs[page].hasClass('fixed'); + + data.pageWrap[page].css({ + display: (pos.pageV[page] || fixed) ? '' : 'none', + zIndex: + (data.pageObjs[page].hasClass('hard') ? + pos.partZ[page] + : + pos.pageZ[page] + ) || (fixed ? -1 : 0) + }); + + if ((p = data.pages[page])) { + + p.flip('z', pos.partZ[page] || null); + + if (pos.pageV[page]) + p.flip('resize'); + + if (data.tpage) { // Is it turning the page to `tpage`? + + p.flip('hover', false). + flip('disable', + $.inArray(parseInt(page, 10), data.pageMv)==-1 && + page!=newView[0] && + page!=newView[1]); + + } else { + + p.flip('hover', corner===false). + flip('disable', page!=actualView[0] && page!=actualView[1]); + + } + + } + + } + + } else { + + // Update static pages + + for (page in data.pageWrap) { + + if (!has(page, data.pageWrap)) + continue; + + var pageLocation = turnMethods._setPageLoc.call(this, page); + + if (data.pages[page]) { + data.pages[page]. + flip('disable', data.disabled || pageLocation!=1). + flip('hover', true). + flip('z', null); + } + } + } + + return this; + }, + + // Updates the position and size of the flipbook's shadow + + _updateShadow: function() { + + var view, view2, shadow, + data = this.data(), + width = this.width(), + height = this.height(), + pageWidth = (data.display=='single') ? width : width/2; + + view = this.turn('view'); + + if (!data.shadow) { + data.shadow = $('
', { + 'class': 'shadow', + 'css': divAtt(0, 0, 0).css + }). + appendTo(this); + } + + for (var i = 0; i=width || point.y>=height) + return false; + + var allowedCorners = flipMethods._cAllowed.call(this); + + switch (data.effect) { + case 'hard': + + if (point.x>width-csz) + point.corner = 'r'; + else if (point.x=height-csz) + point.corner+= 'b'; + else + return false; + + if (point.x<=csz) + point.corner+= 'l'; + else if (point.x>=width-csz) + point.corner+= 'r'; + else + return false; + + break; + } + + return (!point.corner || $.inArray(point.corner, allowedCorners)==-1) ? + false : point; + + }, + + _isIArea: function(e) { + + var pos = this.data().f.parent.offset(); + + e = (isTouch && e.originalEvent) ? e.originalEvent.touches[0] : e; + + return flipMethods._cornerActivated.call(this, + { + x: e.pageX-pos.left, + y: e.pageY-pos.top + }); + + }, + + _c: function(corner, opts) { + + opts = opts || 0; + + switch (corner) { + case 'tl': + return point2D(opts, opts); + case 'tr': + return point2D(this.width()-opts, opts); + case 'bl': + return point2D(opts, this.height()-opts); + case 'br': + return point2D(this.width()-opts, this.height()-opts); + case 'l': + return point2D(opts, 0); + case 'r': + return point2D(this.width()-opts, 0); + } + + }, + + _c2: function(corner) { + + switch (corner) { + case 'tl': + return point2D(this.width()*2, 0); + case 'tr': + return point2D(-this.width(), 0); + case 'bl': + return point2D(this.width()*2, this.height()); + case 'br': + return point2D(-this.width(), this.height()); + case 'l': + return point2D(this.width()*2, 0); + case 'r': + return point2D(-this.width(), 0); + } + + }, + + _foldingPage: function() { + + var data = this.data().f; + + if (!data) + return; + + var opts = data.opts; + + if (opts.turn) { + data = opts.turn.data(); + if (data.display == 'single') + return (opts.next>1 || opts.page>1) ? data.pageObjs[0] : null; + else + return data.pageObjs[opts.next]; + } + + }, + + _backGradient: function() { + + var data = this.data().f, + turnData = data.opts.turn.data(), + gradient = turnData.opts.gradients && (turnData.display=='single' || + (data.opts.page!=2 && data.opts.page!=turnData.totalPages-1)); + + if (gradient && !data.bshadow) + data.bshadow = $('
', divAtt(0, 0, 1)). + css({'position': '', width: this.width(), height: this.height()}). + appendTo(data.parent); + + return gradient; + + }, - data.f = $.extend(data.f, d); + type: function () { + + return this.data().f.effect; - return this; - }, + }, - options: function(opts) { - - var data = this.data().f; + resize: function(full) { + + var data = this.data().f, + turnData = data.opts.turn.data(), + width = this.width(), + height = this.height(); + + switch (data.effect) { + case 'hard': + + if (full) { + data.wrapper.css({width: width, height: height}); + data.fpage.css({width: width, height: height}); + if (turnData.opts.gradients) { + data.ashadow.css({width: width, height: height}); + data.bshadow.css({width: width, height: height}); + } + } + + break; + case 'sheet': + + if (full) { + var size = Math.round(Math.sqrt(Math.pow(width, 2)+Math.pow(height, 2))); + + data.wrapper.css({width: size, height: size}); + data.fwrapper.css({width: size, height: size}). + children(':first-child'). + css({width: width, height: height}); + + data.fpage.css({width: width, height: height}); + + if (turnData.opts.gradients) + data.ashadow.css({width: width, height: height}); + + if (flipMethods._backGradient.call(this)) + data.bshadow.css({width: width, height: height}); + } + + if (data.parent.is(':visible')) { + var offset = findPos(data.parent[0]); + + data.fwrapper.css({top: offset.top, + left: offset.left}); - if (opts) { - flipMethods.setData.call(this, {opts: $.extend({}, data.opts || flipOptions, opts) }); - return this; - } else - return data.opts; + //if (data.opts.turn) { + offset = findPos(data.opts.turn[0]); + data.fparent.css({top: -offset.top, left: -offset.left}); + //} + } - }, + this.flip('z', data.opts['z-index']); - z: function(z) { + break; + } - var data = this.data().f; - data.opts['z-index'] = z; - data.fwrapper.css({'z-index': z || parseInt(data.parent.css('z-index'), 10) || 0}); + }, - return this; - }, + // Prepares the page by adding a general wrapper and another objects - _cAllowed: function() { + _addPageWrapper: function() { - return corners[this.data().f.opts.corners] || this.data().f.opts.corners; + var att, + data = this.data().f, + turnData = data.opts.turn.data(), + parent = this.parent(); + + data.parent = parent; + + if (!data.wrapper) + switch (data.effect) { + case 'hard': + + var cssProperties = {}; + cssProperties[vendor + 'transform-style'] = 'preserve-3d'; + cssProperties[vendor + 'backface-visibility'] = 'hidden'; + + data.wrapper = $('
', divAtt(0, 0, 2)). + css(cssProperties). + appendTo(parent). + prepend(this); + + data.fpage = $('
', divAtt(0, 0, 1)). + css(cssProperties). + appendTo(parent); + + if (turnData.opts.gradients) { + data.ashadow = $('
', divAtt(0, 0, 0)). + hide(). + appendTo(parent); + + data.bshadow = $('
', divAtt(0, 0, 0)); + } + + break; + case 'sheet': + + var width = this.width(), + height = this.height(), + size = Math.round(Math.sqrt(Math.pow(width, 2)+Math.pow(height, 2))); + + data.fparent = data.opts.turn.data().fparent; + + if (!data.fparent) { + var fparent = $('
', {css: {'pointer-events': 'none'}}).hide(); + fparent.data().flips = 0; + fparent.css(divAtt(0, 0, 'auto', 'visible').css). + appendTo(data.opts.turn); + + data.opts.turn.data().fparent = fparent; + data.fparent = fparent; + } + + this.css({position: 'absolute', top: 0, left: 0, bottom: 'auto', right: 'auto'}); + + data.wrapper = $('
', divAtt(0, 0, this.css('z-index'))). + appendTo(parent). + prepend(this); - }, + data.fwrapper = $('
', divAtt(parent.offset().top, parent.offset().left)). + hide(). + appendTo(data.fparent); + + data.fpage = $('
', divAtt(0, 0, 0, 'visible')). + css({cursor: 'default'}). + appendTo(data.fwrapper); + + if (turnData.opts.gradients) + data.ashadow = $('
', divAtt(0, 0, 1)). + appendTo(data.fpage); + + flipMethods.setData.call(this, data); + + break; + } + + // Set size + flipMethods.resize.call(this, true); + + }, + + // Takes a 2P point from the screen and applies the transformation + + _fold: function(point) { + + var data = this.data().f, + turnData = data.opts.turn.data(), + o = flipMethods._c.call(this, point.corner), + width = this.width(), + height = this.height(); + + switch (data.effect) { + + case 'hard': + + if (point.corner=='l') + point.x = Math.min(Math.max(point.x, 0), width*2); + else + point.x = Math.max(Math.min(point.x, width), -width); + + var leftPos, + shadow, + gradientX, + fpageOrigin, + parentOrigin, + totalPages = turnData.totalPages, + zIndex = data.opts['z-index'] || totalPages, + parentCss = {'overflow': 'visible'}, + relX = (o.x) ? (o.x - point.x)/width : point.x/width, + angle = relX * 90, + half = angle<90; + + switch (point.corner) { + case 'l': + + fpageOrigin = '0% 50%'; + parentOrigin = '100% 50%'; + + if (half) { + leftPos = 0; + shadow = data.opts.next-1>0; + gradientX = 1; + } else { + leftPos = '100%'; + shadow = data.opts.page+1 A90) { + tr.x = tr.x + Math.abs(tr.y * rel.y/rel.x); + tr.y = 0; + if (Math.round(tr.x*Math.tan(PI-alpha)) < height) { + point.y = Math.sqrt(Math.pow(height, 2)+2 * middle.x * rel.x); + if (top) point.y = height - point.y; + return compute(); + } + } + + 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))); + if (left) mv.x = - mv.x; + if (top) mv.y = - mv.y; + } + + 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 + if (turnData.opts.gradients) { + + gradientSize = side*Math.sin(alpha); + + var endingPoint = flipMethods._c2.call(that, point.corner), + far = Math.sqrt(Math.pow(endingPoint.x-point.x, 2)+Math.pow(endingPoint.y-point.y, 2))/width; + + shadowVal = Math.sin(A90*((far>1) ? 2 - far : far)); + + gradientOpacity = Math.min(far, 1); + + + gradientStartVal = gradientSize>100 ? (gradientSize-100)/gradientSize : 0; + + gradientEndPointA = point2D( + gradientSize*Math.sin(alpha)/width*100, + gradientSize*Math.cos(alpha)/height*100); + + + if (flipMethods._backGradient.call(that)) { + + gradientEndPointB = point2D( + gradientSize*1.2*Math.sin(alpha)/width*100, + gradientSize*1.2*Math.cos(alpha)/height*100); + + if (!left) gradientEndPointB.x = 100-gradientEndPointB.x; + if (!top) gradientEndPointB.y = 100-gradientEndPointB.y; + + } + + } + + tr.x = Math.round(tr.x); + tr.y = Math.round(tr.y); + + return true; + }, + + transform = function(tr, c, x, a) { + + var f = ['0', 'auto'], mvW = (width-h)*x[0]/100, mvH = (height-h)*x[1]/100, + cssA = {left: f[c[0]], top: f[c[1]], right: f[c[2]], bottom: f[c[3]]}, + cssB = {}, + aliasingFk = (a!=90 && a!=-90) ? (left ? -1 : 1) : 0, + origin = x[0] + '% ' + x[1] + '%'; + + that.css(cssA). + transform(rotate(a) + translate(tr.x + aliasingFk, tr.y, ac), origin); + + data.fpage.css(cssA).transform( + rotate(a) + + translate(tr.x + df.x - mv.x - width*x[0]/100, tr.y + df.y - mv.y - height*x[1]/100, ac) + + rotate((180/a - 2)*a), + origin); + + data.wrapper.transform(translate(-tr.x + mvW-aliasingFk, -tr.y + mvH, ac) + rotate(-a), origin); + + data.fwrapper.transform(translate(-tr.x + mv.x + mvW, -tr.y + mv.y + mvH, ac) + rotate(-a), origin); + + if (turnData.opts.gradients) { + + if (x[0]) + gradientEndPointA.x = 100-gradientEndPointA.x; + + if (x[1]) + gradientEndPointA.y = (100-gradientEndPointA.y); + + cssB['box-shadow'] = '0 0 20px rgba(0,0,0,'+(0.5*shadowVal)+')'; + folding.css(cssB); + + gradient(data.ashadow, + point2D(left?100:0, top?0:100), + point2D(gradientEndPointA.x, gradientEndPointA.y), + [[gradientStartVal, 'rgba(0,0,0,0)'], + [((1-gradientStartVal)*0.8)+gradientStartVal, 'rgba(0,0,0,'+(0.2*gradientOpacity)+')'], + [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), + point2D(gradientEndPointB.x, gradientEndPointB.y), + [[0.6, 'rgba(0,0,0,0)'], + [0.8, 'rgba(0,0,0,'+(0.3*gradientOpacity)+')'], + [1, 'rgba(0,0,0,0)'] + ], + 3); + } - _cornerActivated: function(e) { - if (e.originalEvent === undefined) { - return false; - } + }; - e = (isTouch) ? e.originalEvent.touches : [e]; + switch (point.corner) { + case 'l' : - var data = this.data().f, - pos = data.parent.offset(), - width = this.width(), - height = this.height(), - c = {x: Math.max(0, e[0].pageX-pos.left), y: Math.max(0, e[0].pageY-pos.top)}, - csz = data.opts.cornerSize, - allowedCorners = flipMethods._cAllowed.call(this); - if (c.x<=0 || c.y<=0 || c.x>=width || c.y>=height) return false; + break; + case 'r' : - 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; - return ($.inArray(c.corner, allowedCorners)==-1) ? false : c; + break; + case 'tl' : + point.x = Math.max(point.x, 1); + compute(); + transform(tr, [1,0,0,1], [100, 0], a); + break; + case 'tr' : + point.x = Math.min(point.x, width-1); + compute(); + transform(point2D(-tr.x, tr.y), [0,0,0,1], [0, 0], -a); + break; + case 'bl' : + point.x = Math.max(point.x, 1); + compute(); + transform(point2D(tr.x, -tr.y), [1,1,0,0], [100, 100], -a); + break; + case 'br' : + point.x = Math.min(point.x, width-1); + compute(); + transform(point2D(-tr.x, -tr.y), [0,1,1,0], [0, 100], a); + break; + } - }, + break; + } + + data.point = point; + + }, + + _moveFoldingPage: function(move) { + + var data = this.data().f; + + if (!data) + return; + + var turn = data.opts.turn, + turnData = turn.data(), + place = turnData.pagePlace; + + if (move) { - _c: function(corner, opts) { + var nextPage = data.opts.next; + + if (place[nextPage]!=data.opts.page) { - opts = opts || 0; - return ({tl: point2D(opts, opts), - tr: point2D(this.width()-opts, opts), - bl: point2D(opts, this.height()-opts), - br: point2D(this.width()-opts, this.height()-opts)})[corner]; + if (data.folding) + flipMethods._moveFoldingPage.call(this, false); + + var folding = flipMethods._foldingPage.call(this); + + folding.appendTo(data.fpage); + place[nextPage] = data.opts.page; + data.folding = nextPage; + } - }, + turn.turn('update'); + + } else { + + if (data.folding) { + + if (turnData.pages[data.folding]) { + + // If we have flip available - _c2: function(corner) { + var flipData = turnData.pages[data.folding].data().f; + + turnData.pageObjs[data.folding]. + appendTo(flipData.wrapper); - return {tl: point2D(this.width()*2, 0), - tr: point2D(-this.width(), 0), - bl: point2D(this.width()*2, this.height()), - br: point2D(-this.width(), this.height())}[corner]; + } else if (turnData.pageWrap[data.folding]) { + + // If we have the pageWrapper - }, + turnData.pageObjs[data.folding]. + appendTo(turnData.pageWrap[data.folding]); - _foldingPage: function(corner) { + } - var opts = this.data().f.opts; - - if (opts.folding) return opts.folding; - else if(opts.turn) { - var data = opts.turn.data(); - if (data.display == 'single') - return (data.pageObjs[opts.next]) ? data.pageObjs[0] : null; - else - return data.pageObjs[opts.next]; - } + if (data.folding in place) { + place[data.folding] = data.folding; + } - }, + delete data.folding; - _backGradient: function() { + } + } + }, - var data = this.data().f, - turn = data.opts.turn, - gradient = data.opts.backGradient && - (!turn || turn.data().display=='single' || (data.opts.page!=2 && data.opts.page!=turn.data().totalPages-1) ); + _showFoldedPage: function(c, animate) { + var folding = flipMethods._foldingPage.call(this), + dd = this.data(), + data = dd.f, + visible = data.visible; - if (gradient && !data.bshadow) - data.bshadow = $('
', divAtt(0, 0, 1)). - css({'position': '', width: this.width(), height: this.height()}). - appendTo(data.parent); + if (folding) { - return gradient; + if (!visible || !data.point || data.point.corner!=c.corner) { - }, + var corner = ( + data.status=='hover' || + data.status=='peel' || + data.opts.turn.data().mouseAction) ? + c.corner : null; - resize: function(full) { - - var data = this.data().f, - width = this.width(), - height = this.height(), - size = Math.round(Math.sqrt(Math.pow(width, 2)+Math.pow(height, 2))); + visible = false; - if (full) { - data.wrapper.css({width: size, height: size}); - data.fwrapper.css({width: size, height: size}). - children(':first-child'). - css({width: width, height: height}); + if (trigger('start', this, [data.opts, corner])=='prevented') + return false; - data.fpage.css({width: height, height: width}); + } - if (data.opts.frontGradient) - data.ashadow.css({width: height, height: width}); + 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]); + flipMethods._fold.call(that, c); + } + }); - if (flipMethods._backGradient.call(this)) - data.bshadow.css({width: width, height: height}); - } + } else { - if (data.parent.is(':visible')) { - data.fwrapper.css({top: data.parent.offset().top, - left: data.parent.offset().left}); - - if (data.opts.turn) - data.fparent.css({top: -data.opts.turn.offset().top, left: -data.opts.turn.offset().left}); - } - - this.flip('z', data.opts['z-index']); + flipMethods._fold.call(this, c); - }, + if (dd.effect && !dd.effect.turning) + this.animatef(false); - // Prepares the page by adding a general wrapper and another objects + } - _addPageWrapper: function() { - - var att, - data = this.data().f, - parent = this.parent(); + if (!visible) { - if (!data.wrapper) { + switch(data.effect) { + case 'hard': - var left = this.css('left'), - top = this.css('top'), - 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'); + data.visible = true; + flipMethods._moveFoldingPage.call(this, true); + data.fpage.show(); + if (data.opts.shadows) + data.bshadow.show(); - if (!data.fparent) { - var fparent = $('
', {css: {'pointer-events': 'none'}}).hide(); - fparent.data().flips = 0; + break; + case 'sheet': - 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). - attr('id', 'turn-fwrappers'). - appendTo($('body')); - } - - data.fparent = fparent; - } - - this.css({position: 'absolute', top: 0, left: 0, bottom: 'auto', right: 'auto'}); - - data.wrapper = $('
', divAtt(0, 0, this.css('z-index'))). - appendTo(parent). - prepend(this); - - data.fwrapper = $('
', divAtt(parent.offset().top, parent.offset().left)). - hide(). - appendTo(data.fparent); + data.visible = true; + data.fparent.show().data().flips++; + flipMethods._moveFoldingPage.call(this, true); + data.fwrapper.show(); + if (data.bshadow) + data.bshadow.show(); - data.fpage = $('
', {css: {cursor: 'default'}}). - appendTo($('
', divAtt(0, 0, 0, 'visible')). - appendTo(data.fwrapper)); - - if (data.opts.frontGradient) - data.ashadow = $('
', divAtt(0, 0, 1)). - appendTo(data.fpage); - - // Save data - - flipMethods.setData.call(this, data); - - // Set size - flipMethods.resize.call(this, true); - } - - }, - - // Takes a 2P point from the screen and applies the transformation - - _fold: function(point) { - - var that = this, - a = 0, - alpha = 0, - beta, - px, - gradientEndPointA, - gradientEndPointB, - gradientStartV, - gradientSize, - gradientOpacity, - mv = point2D(0, 0), - df = point2D(0, 0), - tr = point2D(0, 0), - width = this.width(), - height = this.height(), - folding = flipMethods._foldingPage.call(this), - tan = Math.tan(alpha), - data = this.data().f, - ac = data.opts.acceleration, - h = data.wrapper.height(), - o = flipMethods._c.call(this, point.corner), - top = point.corner.substr(0, 1) == 't', - left = point.corner.substr(1, 1) == 'l', - - compute = function() { - var rel = point2D((o.x) ? o.x - point.x : point.x, (o.y) ? o.y - point.y : point.y), - tan = (Math.atan2(rel.y, rel.x)), - middle; - - alpha = A90 - tan; - a = deg(alpha); - middle = point2D((left) ? width - rel.x/2 : point.x + rel.x/2, rel.y/2); - - var gamma = alpha - Math.atan2(middle.y, middle.x), - distance = Math.max(0, Math.sin(gamma) * Math.sqrt(Math.pow(middle.x, 2) + Math.pow(middle.y, 2))); - - 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; - - if (Math.round(tr.x*Math.tan(PI-alpha)) < height) { - - point.y = Math.sqrt(Math.pow(height, 2)+2 * middle.x * rel.x); - if (top) point.y = height - point.y; - return compute(); - - } - } - - 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))); - if (left) mv.x = - mv.x; - if (top) mv.y = - mv.y; - } - - 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); - var endingPoint = flipMethods._c2.call(that, point.corner), - far = Math.sqrt(Math.pow(endingPoint.x-point.x, 2)+Math.pow(endingPoint.y-point.y, 2)); - - gradientOpacity = (far100 ? (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; - } - - if (flipMethods._backGradient.call(that)) { - - gradientEndPointB = point2D(gradientSize*Math.sin(alpha)/width*100, gradientSize*Math.cos(alpha)/height*100); - if (!left) gradientEndPointB.x = 100-gradientEndPointB.x; - if (!top) gradientEndPointB.y = 100-gradientEndPointB.y; - } - // - - tr.x = Math.round(tr.x); - tr.y = Math.round(tr.y); - - return true; - }, - - 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; - - x = x[0] + '% ' + x[1] + '%'; - - that.css(v).transform(rotate(a) + translate(tr.x + aliasingFk, tr.y, ac), x); - - data.fpage.parent().css(v); - data.wrapper.transform(translate(-tr.x + mvW-aliasingFk, -tr.y + mvH, ac) + rotate(-a), x); - - data.fwrapper.transform(translate(-tr.x + mv.x + mvW, -tr.y + mv.y + mvH, ac) + rotate(-a), x); - data.fpage.parent().transform(rotate(a) + translate(tr.x + df.x - mv.x, tr.y + df.y - mv.y, ac), x); - - if (data.opts.frontGradient) - gradient(data.ashadow, - point2D(left?100:0, top?100:0), - point2D(gradientEndPointA.x, gradientEndPointA.y), - [[gradientStartV, 'rgba(0,0,0,0)'], - [((1-gradientStartV)*0.8)+gradientStartV, 'rgba(0,0,0,'+(0.2*gradientOpacity)+')'], - [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), - point2D(gradientEndPointB.x, gradientEndPointB.y), - [[0.8, 'rgba(0,0,0,0)'], - [1, 'rgba(0,0,0,'+(0.3*gradientOpacity)+')'], - [1, 'rgba(0,0,0,0)']], - 3); - - }; - - switch (point.corner) { - case 'tl' : - point.x = Math.max(point.x, 1); - compute(); - transform(tr, [1,0,0,1], [100, 0], a); - data.fpage.transform(translate(-height, -width, ac) + rotate(90-a*2) , '100% 100%'); - folding.transform(rotate(90) + translate(0, -height, ac), '0% 0%'); - break; - case 'tr' : - point.x = Math.min(point.x, width-1); - compute(); - transform(point2D(-tr.x, tr.y), [0,0,0,1], [0, 0], -a); - data.fpage.transform(translate(0, -width, ac) + rotate(-90+a*2) , '0% 100%'); - folding.transform(rotate(270) + translate(-width, 0, ac), '0% 0%'); - break; - case 'bl' : - point.x = Math.max(point.x, 1); - compute(); - transform(point2D(tr.x, -tr.y), [1,1,0,0], [100, 100], -a); - data.fpage.transform(translate(-height, 0, ac) + rotate(-90+a*2), '100% 0%'); - folding.transform(rotate(270) + translate(-width, 0, ac), '0% 0%'); - break; - case 'br' : - point.x = Math.min(point.x, width-1); - compute(); - transform(point2D(-tr.x, -tr.y), [0,1,1,0], [0, 100], a); - data.fpage.transform(rotate(90-a*2), '0% 0%'); - folding.transform(rotate(90) + translate(0, -height, ac), '0% 0%'); - - break; - } + break; + } - data.point = point; - - }, + } - _moveFoldingPage: function(bool) { - - var data = this.data().f, - folding = flipMethods._foldingPage.call(this); - - if (folding) { - if (bool) { - if (!data.fpage.children()[data.ashadow? '1' : '0']) { - flipMethods.setData.call(this, {backParent: folding.parent()}); - data.fpage.prepend(folding); - } - } else { - if (data.backParent) - data.backParent.prepend(folding); - - } - } - - }, - - _showFoldedPage: function(c, animate) { - - var folding = flipMethods._foldingPage.call(this), - dd = this.data(), - data = dd.f; - - if (!data.point || data.point.corner!=c.corner) { - var event = $.Event('start'); - this.trigger(event, [data.opts, c.corner]); - - if (event.isDefaultPrevented()) - return false; - } - - - if (folding) { - - 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]); - flipMethods._fold.call(that, c); - }}); - - } else { - - flipMethods._fold.call(this, c); - if (dd.effect && !dd.effect.turning) - this.animatef(false); - - } - - if (!data.fwrapper.is(':visible')) { - data.fparent.show().data().flips++; - flipMethods._moveFoldingPage.call(this, true); - data.fwrapper.show(); - - if (data.bshadow) - data.bshadow.show(); - } - - return true; - } - - return false; - }, - - hide: function() { - - var data = this.data().f, - folding = flipMethods._foldingPage.call(this); - - if ((--data.fparent.data().flips)===0) - data.fparent.hide(); - - this.css({left: 0, top: 0, right: 'auto', bottom: 'auto'}).transform('', '0% 100%'); + return true; - data.wrapper.transform('', '0% 100%'); + } - data.fwrapper.hide(); + return false; + }, - if (data.bshadow) - data.bshadow.hide(); + hide: function() { - folding.transform('', '0% 0%'); + var data = this.data().f, + turnData = data.opts.turn.data(), + folding = flipMethods._foldingPage.call(this); - return this; - }, + switch (data.effect) { + case 'hard': + + if (turnData.opts.gradients) { + data.bshadowLoc = 0; + data.bshadow.remove(); + data.ashadow.hide(); + } - hideFoldedPage: function(animate) { + data.wrapper.transform(''); + data.fpage.hide(); - var data = this.data().f; + break; + case 'sheet': - if (!data.point) return; + if ((--data.fparent.data().flips)===0) + data.fparent.hide(); - var that = this, - p1 = data.point, - hide = function() { - data.point = null; - that.flip('hide'); - that.trigger('end', [false]); - }; + this.css({left: 0, top: 0, right: 'auto', bottom: 'auto'}). + transform(''); - if (animate) { - var p4 = flipMethods._c.call(this, p1.corner), - top = (p1.corner.substr(0,1)=='t'), - 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, - frame: function(v) { - var np = bezier(p1, p2, p3, p4, v); - p1.x = np.x; - p1.y = np.y; - flipMethods._fold.call(that, p1); - }, - complete: hide, - duration: 800, - hiding: true - }); + data.wrapper.transform(''); - } else { - this.animatef(false); - hide(); - } - }, + data.fwrapper.hide(); - turnPage: function(corner) { + if (data.bshadow) + data.bshadow.hide(); - var that = this, - data = this.data().f; + folding.transform(''); - corner = {corner: (data.corner) ? data.corner.corner : corner || flipMethods._cAllowed.call(this)[0]}; + break; + } - var p1 = data.point || flipMethods._c.call(this, corner.corner, (data.opts.turn) ? data.opts.turn.data().opts.elevation : 0), - p4 = flipMethods._c2.call(this, corner.corner); + data.visible = false; - this.trigger('flip'). - animatef({ - from: 0, - to: 1, - frame: function(v) { - var np = bezier(p1, p1, p4, p4, v); - corner.x = np.x; - corner.y = np.y; - flipMethods._showFoldedPage.call(that, corner); - }, - - complete: function() { - that.trigger('end', [true]); - }, - duration: data.opts.duration, - turning: true - }); + return this; + }, - data.corner = null; - }, + hideFoldedPage: function(animate) { - moving: function() { + var data = this.data().f; - return 'effect' in this.data(); - - }, + if (!data.point) return; - isTurning: function() { + var that = this, + p1 = data.point, + hide = function() { + data.point = null; + data.status = ''; + that.flip('hide'); + that.trigger('end', [data.opts, false]); + }; - return this.flip('moving') && this.data().effect.turning; - - }, - - _eventStart: function(e) { + if (animate) { - var data = this.data().f; - - if (!data.disabled && !this.flip('isTurning')) { - data.corner = flipMethods._cornerActivated.call(this, e); - if (data.corner && flipMethods._foldingPage.call(this, data.corner)) { - flipMethods._moveFoldingPage.call(this, true); - this.trigger('pressed', [data.point]); - return false; - } else - data.corner = null; - } - - }, - - _eventMove: function(e) { - - var data = this.data().f; - - if (!data.disabled) { - e = (isTouch) ? e.originalEvent.touches : [e]; - - if (data.corner) { - - var pos = data.parent.offset(); - - data.corner.x = e[0].pageX-pos.left; - 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); - corner.x = origin.x; - corner.y = origin.y; - flipMethods._showFoldedPage.call(this, corner, true); - } else - flipMethods.hideFoldedPage.call(this, true); - - } - } - }, + var p4 = flipMethods._c.call(this, p1.corner), + top = (p1.corner.substr(0,1)=='t'), + 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, + frame: function(v) { + var np = bezier(p1, p2, p3, p4, v); + p1.x = np.x; + p1.y = np.y; + flipMethods._fold.call(that, p1); + }, + complete: hide, + duration: 800, + hiding: true + }); - _eventEnd: function() { + } else { - var data = this.data().f; + this.animatef(false); + hide(); - if (!data.disabled && data.point) { - var event = $.Event('released'); - this.trigger(event, [data.point]); - if (!event.isDefaultPrevented()) - flipMethods.hideFoldedPage.call(this, true); - } + } + }, - data.corner = null; + turnPage: function(corner) { - }, + var that = this, + data = this.data().f, + turnData = data.opts.turn.data(); - disable: function(disable) { + corner = {corner: (data.corner) ? + data.corner.corner : + corner || flipMethods._cAllowed.call(this)[0]}; - flipMethods.setData.call(this, {'disabled': disable}); - return this; + var p1 = data.point || + flipMethods._c.call(this, + corner.corner, + (data.opts.turn) ? turnData.opts.elevation : 0), + p4 = flipMethods._c2.call(this, corner.corner); - } -}, + this.trigger('flip'). + animatef({ + from: 0, + to: 1, + frame: function(v) { + + var np = bezier(p1, p1, p4, p4, v); + corner.x = np.x; + corner.y = np.y; + flipMethods._showFoldedPage.call(that, corner); + + }, + complete: function() { + + that.trigger('end', [data.opts, true]); + + }, + duration: turnData.opts.duration, + turning: true + }); + + data.corner = null; + }, + + moving: function() { + + return 'effect' in this.data(); + + }, + + isTurning: function() { + + return this.flip('moving') && this.data().effect.turning; + + }, + + corner: function() { + + return this.data().f.corner; + + }, + + _eventStart: function(e) { + + var data = this.data().f, + turn = data.opts.turn; + + if (!data.corner && !data.disabled && !this.flip('isTurning') && + data.opts.page==turn.data().pagePlace[data.opts.page]) + { + + data.corner = flipMethods._isIArea.call(this, e); + + if (data.corner && flipMethods._foldingPage.call(this)) { + + this.trigger('pressed', [data.point]); + flipMethods._showFoldedPage.call(this, data.corner); + + return false; + + } else + data.corner = null; + + } + + }, + + _eventMove: function(e) { + + var data = this.data().f; + + if (!data.disabled) { + + e = (isTouch) ? e.originalEvent.touches : [e]; + + if (data.corner) { + + var pos = data.parent.offset(); + data.corner.x = e[0].pageX-pos.left; + data.corner.y = e[0].pageY-pos.top; + flipMethods._showFoldedPage.call(this, data.corner); + + } else if (data.hover && !this.data().effect && this.is(':visible')) { + + var point = flipMethods._isIArea.call(this, e[0]); + + if (point) { -cla = function(that, methods, args) { + if ((data.effect=='sheet' && point.corner.length==2) || data.effect=='hard') { + data.status = 'hover'; + var origin = flipMethods._c.call(this, point.corner, data.opts.cornerSize/2); + point.x = origin.x; + point.y = origin.y; + flipMethods._showFoldedPage.call(this, point, true); + } + + } else { + + if (data.status=='hover') { + data.status = ''; + flipMethods.hideFoldedPage.call(this, true); + } - if (!args[0] || typeof(args[0])=='object') - return methods.init.apply(that, args); - else if(methods[args[0]] && args[0].toString().substr(0, 1)!='_') - return methods[args[0]].apply(that, Array.prototype.slice.call(args, 1)); - else - throw args[0] + ' is an invalid value'; + } + + } + + } + + }, + + _eventEnd: function() { + + var data = this.data().f, + corner = data.corner; + + if (!data.disabled && corner) { + if (trigger('released', this, [data.point || corner])!='prevented') { + flipMethods.hideFoldedPage.call(this, true); + } + } + + data.corner = null; + + }, + + disable: function(disable) { + + flipMethods.setData.call(this, {'disabled': disable}); + return this; + + }, + + hover: function(hover) { + + flipMethods.setData.call(this, {'hover': hover}); + return this; + + }, + + peel: function (corner, animate) { + + var data = this.data().f; + + if (corner) { + + if ($.inArray(corner, corners.all)==-1) + throw turnError('Corner '+corner+' is not permitted'); + + if ($.inArray(corner, flipMethods._cAllowed.call(this))!=-1) { + + var point = flipMethods._c.call(this, corner, data.opts.cornerSize/2); + + data.status = 'peel'; + + flipMethods._showFoldedPage.call(this, + { + corner: corner, + x: point.x, + y: point.y + }, animate); + + } + + + } else { + + data.status = ''; + + flipMethods.hideFoldedPage.call(this, animate); + + } + + return this; + } +}; + + +// Processes classes + +function dec(that, methods, args) { + + if (!args[0] || typeof(args[0])=='object') + return methods.init.apply(that, args); + + else if (methods[args[0]]) + return methods[args[0]].apply(that, Array.prototype.slice.call(args, 1)); + + else + throw turnError(args[0] + ' is not a method or property'); + +} + + +// Attributes for a layer + +function divAtt(top, left, zIndex, overf) { + + return {'css': { + position: 'absolute', + top: top, + left: left, + 'overflow': overf || 'hidden', + zIndex: zIndex || 'auto' + } }; + +} + +// Gets a 2D point from a bezier curve of four points + +function bezier(p1, p2, p3, p4, t) { + + var a = 1 - t, + b = a * a * a, + c = t * t * t; + + return point2D(Math.round(b*p1.x + 3*t*a*a*p2.x + 3*t*t*a*p3.x + c*p4.x), + Math.round(b*p1.y + 3*t*a*a*p2.y + 3*t*t*a*p3.y + c*p4.y)); + +} + +// Converts an angle from degrees to radians + +function rad(degrees) { + + return degrees/180*PI; + +} + +// Converts an angle from radians to degrees + +function deg(radians) { + + return radians/PI*180; + +} + +// Gets a 2D point + +function point2D(x, y) { + + return {x: x, y: y}; + +} + +// Webkit 534.3 on Android wrongly repaints elements that use overflow:hidden + rotation + +function rotationAvailable() { + var parts; + + if ((parts = /AppleWebkit\/([0-9\.]+)/i.exec(navigator.userAgent))) { + var webkitVersion = parseFloat(parts[1]); + return (webkitVersion>534.3); + } else { + return true; + } +} + +// Returns the traslate value + +function translate(x, y, use3d) { + + return (has3d && use3d) ? ' translate3d(' + x + 'px,' + y + 'px, 0px) ' + : ' translate(' + x + 'px, ' + y + 'px) '; + +} + +// Returns the rotation value + +function rotate(degrees) { + + return ' rotate(' + degrees + 'deg) '; + +} + +// Checks if a property belongs to an object + +function has(property, object) { + + return Object.prototype.hasOwnProperty.call(object, property); + +} + +// Gets the CSS3 vendor prefix + +function getPrefix() { + + var vendorPrefixes = ['Moz','Webkit','Khtml','O','ms'], + len = vendorPrefixes.length, + vendor = ''; + + while (len--) + if ((vendorPrefixes[len] + 'Transform') in document.body.style) + vendor='-'+vendorPrefixes[len].toLowerCase()+'-'; + + return vendor; + +} + +// Detects the transitionEnd Event + +function getTransitionEnd() { + + var t, + el = document.createElement('fakeelement'), + transitions = { + 'transition':'transitionend', + 'OTransition':'oTransitionEnd', + 'MSTransition':'transitionend', + 'MozTransition':'transitionend', + 'WebkitTransition':'webkitTransitionEnd' + }; + + for (t in transitions) { + if (el.style[t] !== undefined) { + return transitions[t]; + } + } +} + +// Gradients + +function gradient(obj, p0, p1, colors, numColors) { + + var j, cols = []; + + if (vendor=='-webkit-') { + + for (j = 0; je)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=mh)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*(1