He quitado muchas de las líneas comentadas porque me paso de longitud.
principal.js
Código Javascript:
Ver original
var tNormal = 500; var omiteAjustes = false; $(document).ready(function(){ ajustaPaginas(); }); function ajustaPaginas() { var alto = $('.pageContent').first().height(); var ancho = $('.pageContent').first().width(); $('.pageContent').each(function(oP) { var $pc = $(this); var $p1 = $pc.children('div').children('p').first(); if(typeof $p1.html() !== 'undefined' && $p1.html() !== false) { var text = $p1.html().trim(); var first = text.charAt(0); if(first!='<') { $p1.html('<span class="inicial">'+first+'</span>'+text.substring(1)); } } $pc.css({'overflow':'visible','visibility':'hidden','display':'block'}); var rAlt = $pc.children('div').first().height(); $pc.css({'overflow':'hidden','visibility':'visible','display':'block'}); while($pc.height() < rAlt) { var copy = $pc.clone().attr('id', 'copia'+oP).css( { 'margin-top':'-'+(alto-20)+'px', 'height':alto*2+'px', 'background-position-y':(alto-20)+'px'}); $pc.css('clip','rect(0px '+ancho+'px '+(alto-5)+'px 0px)') $pc.after(copy); $pc = $pc.next('.pageContent'); alto = alto*2; } }); if($('.pageContent').length % 2 != 0){ $('#pagesContainer').append('<div class="pageContent"><div></div></div>'); } var totPags = $('.pageContent').length; $('.pageContent').each(function(i,p) { if(i % 2 == 0) { $(p).append('<div class="pagIzda">'+(i+1)+'</div>').css({ 'background-image':'url(\''+rutaDef+'imagenes/fondoLibroImpar2.jpg\')', 'background-position-y':'left','background-size':'100%'}); if(parseInt($(p).css('background-position-y')) != 0) { $(p).children('.pagIzda').css('top',(parseInt($(p).css('background-position-y'))*2)-5);} if(i != 0) { //$(this).children(':last').prepend('< ').css({'cursor':'pointer'}).click(function() { previousPage(); }); //$('#pagPrev').show().click(function() { previousPage(); }); } else { //$('#pagPrev').hide(); } } else { $(p).append('<div class="pagDcha">'+(i+1)+'</div>').css({ 'background-image':'url(\''+rutaDef+'imagenes/fondoLibroPar2.jpg\')', 'background-position-y':'right','background-size':'100%'}); if(i != (totPags-1) ) { //$(this).children(':last').append(' >').css({'cursor':'pointer'}).click(function() { nextPage(); }); //$('#pagSig').show().click(function() { nextPage(); }); } else { //$('#pagSig').hide(); } } }); pageWidth = $(".pageContent:first").width(); pageHeight = $(".pageContent:first").height(); $("#pagesContainer").css("width", 2 * pageWidth).css("height", pageHeight); $(".pageContent > div:first-child").css("width", pageWidth).css("height", pageHeight); pageLayout(); } function pasaPaginas() { $('#pagesContainer').html(''); //pageLayout(); $('#pagesContainer').append('<div class="pageContent"><div></div></div>'); $('#pagesContainer').append('<div class="pageContent"><div></div></div>'); $('#pagesContainer').append('<div class="pageContent"><div></div></div>'); $('#pagesContainer').append('<div class="pageContent"><div></div></div>'); pageIndex = $('.pageContent').length - 2; //omiteAjustes = true; pageLayout(); var q = new Queue(); for(var n = 0; n < 10; n++) { q.add(function(proxy) { nextPage(1000); proxy.end(); }); q.add(function(proxy) { espera(); proxy.end(); }); //q.add(function(proxy) { pageLayout(); proxy.end(); }); q.add(function(proxy) { previousPage(0); proxy.end(); }); q.add(function(proxy) { espera(); proxy.end(); }); //q.add(function(proxy) { pageLayout(); proxy.end(); }); } q.process(); return; omiteAjustes = false; } function espera() { setTimeout('',1000); var d = new Date(); } var Queue = function() { this._tasks = []; }; Queue.prototype.add = function(fn, scope) { this._tasks.push({ fn: fn, scope: scope }); return this; }; Queue.prototype.process = function() { var proxy, self = this; task = this._tasks.shift(); if(!task) { return; } proxy = { end: function() { self.process(); } }; task.fn.call(task.scope, proxy); return this; }; Queue.prototype.clear = function() { this._tasks = []; return this; }; /* Javascript Pageflip v0.3.2 by Charles Mangin ([email protected]) Creative Commons License ... */ var page1, page2, page3, page4, page0, pageN1; var pageIndex = 0; var pageWidth; var pageHeight; function pageLayout() { page1 = $(".pageContent:eq(" + pageIndex + ")"); page1.addClass("page1").css("zIndex", 1); page2 = $(".pageContent:eq(" + parseInt(pageIndex + 1) + ")"); page2.addClass("page2").css({"left": pageWidth,"zIndex": 3,"paddingRight":0,"width": pageWidth}); if( $(".pageContent").length > parseInt(pageIndex + 2) ) { // if there's a next page... if(!omiteAjustes) {$('#pagSig div').show().unbind('click').click(function() { nextPage(tNormal); });} page3 = $(".pageContent:eq(" + parseInt(pageIndex + 2) + ")"); page3.addClass("page3").css({"left": pageWidth * 2,"zIndex": 4,"width":0,"marginLeft":0,"paddingLeft":0}); page4 = $(".pageContent:eq(" + parseInt(pageIndex + 3) + ")"); page4.addClass("page4").css({"left": pageWidth,"zIndex": 2}); } else { $('#pagSig div').hide(); } if(pageIndex > 1) { if(!omiteAjustes) {$('#pagPrev div').show().unbind('click').click(function() { previousPage(tNormal); });} page0 = $(".pageContent:eq(" + parseInt(pageIndex - 1) + ")"); page0.addClass("page0").css({"left": 0,"zIndex": 0}); pageN1 = $(".pageContent:eq(" + parseInt(pageIndex - 2) + ")"); pageN1.addClass("pageN1").css({"left": 0,"zIndex": 0}); } else { $('#pagPrev div').hide(); } } function previousPage(flipTime) { page0.css("zIndex", 6).css("paddingRight",0); page0.children("div:first").css("marginLeft",-1 * pageWidth) pageN1.css("zIndex", 5).css("width",0); page0.children("div:first").animate({marginLeft: 0}, flipTime); page0.animate( {left: pageWidth,width: pageWidth,paddingRight: 30}, {duration: flipTime,specialEasing: {left: "swing",width: "swing",paddingRight: "linear"} } ); pageN1.animate( {width: pageWidth}, flipTime, "swing", function() { page1.removeClass("page1").unbind('click'); page2.removeClass("page2").unbind('click'); page3.removeClass("page3"); page4.removeClass("page4"); page0.removeClass("page0"); pageN1.removeClass("pageN1"); pageIndex -= 2; pageLayout(); $(this).dequeue(); } ); if(omiteAjustes) {pageLayout();} } function nextPage(flipTime) { page3.animate( {left: 0,width: pageWidth},{duration: flipTime},{easing: "swing"}); page2.animate({width: 0}, flipTime, "swing", function() { page1.removeClass("page1").unbind('click'); page2.removeClass("page2").unbind('click'); page3.removeClass("page3"); page4.removeClass("page4"); if(pageIndex > 1) { page0.removeClass("page0"); pageN1.removeClass("pageN1"); } pageIndex += 2; pageLayout(); $(this).dequeue(); } ); if(omiteAjustes) {pageLayout();} }
Y las estructura HTML:
Código HTML:
Ver original
Muchas gracias.