1(function ($) { 2 var supports = (function () { 3 var div = document.createElement("div"); 4 vendors = "Khtml Ms O Moz Webkit".split(" "); 5 len = vendors.length; 6 return function (prop) { 7 if (prop in div.style) { 8 return true 9 } 10 prop = prop.replace(/^[a-z]/, function (val) { 11 return val.toUpperCase() 12 }); 13 while (len--) { 14 if (vendors[len] + prop in div.style) { 15 return true 16 } 17 } 18 return false 19 } 20 })(); 21 if (supports("transform")) { 22 var fb = false 23 } else { 24 var fb = true 25 } 26 var increment, flipper, i, mouseDown, mouseDragging, bounce, touchDown, eX, eY, mouseX, mouseY, delta, lastDelta, moveDirection, direction, temp, currentPageSide, currentPageSidePage, nextPageSide, currentPageOverlay, nextPageOverlay, currentPage, nextPage, currentDirection, deg, startDeg, reachedHalf, cReachedHalf, animWidth, animDirection; 27 var animating = false; 28 var flipperPage = 'flipper-page' + Math.random().toString(16).substring(2, 7); 29 var flipperPager = 'flipper-pager' + Math.random().toString(16).substring(2, 7); 30 31 window.requestAnimFrame = (function () { 32 return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback, element) { 33 window.setTimeout(callback, 1000 / 60) 34 } 35 })(); 36 37 function Flipper() { 38 this.pages; 39 this.wrap; 40 this.currentPage = 0; 41 this.prevPage; 42 this.nextPage; 43 this.numPages; 44 } 45 Flipper.prototype.init = function (element) { 46 var root = this; 47 root.wrap = $(element); 48 root.pages = root.wrap.find(".flipper-page"); 49 if (!root.wrap.hasClass("flipper-wrap")) { 50 root.wrap.addClass("flipper-wrap") 51 } 52 if (fb) { 53 root.wrap.addClass("flipper-fb") 54 } 55 if (O.width != 800 || O.height != 400) { 56 root.wrap.css({ 57 width: O.width, 58 height: O.height 59 }) 60 } 61 if (fb) { 62 root.fb_initPages() 63 } else { 64 root.initPages() 65 } 66 var startPage = parseInt(O.startPage, 10) || 0; 67 if (startPage < 0) startPage = 0; 68 if (root.numPages && startPage > root.numPages - 1) { 69 startPage = root.numPages - 1 70 } 71 root.currentPage = startPage; 72 $(root.pages).css({ 73 "z-index": 1 74 }); 75 $(root.pages[root.currentPage]).css({ 76 "z-index": 99 77 }); 78 root.initUI(); 79 if (O.pager) { 80 $(root.wrap).find(".flipper-pager").on("click touchend", function () { 81 if (!animating) { 82 root.nextPage = parseInt($(this).attr("id").replace(flipperPager + "-", "")); 83 direction = (root.nextPage < root.currentPage) ? -1 : 1; 84 if (root.nextPage != root.currentPage) { 85 root.showPage(direction, 0) 86 } 87 } 88 }) 89 } 90 if (O.arrows) { 91 $(root.wrap).find(".flipper-next-page").on("click.flipper", function () { 92 root.showNextPage() 93 }); 94 $(root.wrap).find(".flipper-prev-page").on("click.flipper", function () { 95 root.showPrevPage() 96 }) 97 } 98 99 $(root.pages).on("mousedown.flipper", function (e) { 100 if (!animating) { 101 mouseDown = true 102 } 103 eX = e.pageX; 104 eY = e.pageY; 105 106 $('.close').addClass('fade'); 107 }); 108 $(root.pages).on("mousemove.flipper", function (e) { 109 if (mouseDown && !mouseDragging) { 110 mouseX = e.pageX; 111 mouseY = e.pageY; 112 if (!animating && mouseX - eX != 0) { 113 root.startDragging(); 114 mouseDragging = true 115 } 116 } 117 if (mouseDragging) { 118 mouseX = e.pageX; 119 mouseY = e.pageY; 120 if (!animating) { 121 root.drag() 122 } 123 } 124 }); 125 $(root.pages).on("mouseup.flipper", function (e) { 126 if (mouseDown) { 127 if (!animating && mouseDragging) { 128 root.finishDragging() 129 } 130 } 131 mouseDragging = false; 132 mouseDown = false; 133 134 $('.close').removeClass('fade'); 135 }); 136 if (!fb) { 137 if (O.pager) { 138 $(root.wrap).find(".flipper-pager").get(0).addEventListener("touchend", function () { 139 if (!animating) { 140 root.nextPage = parseInt($(this).attr("id").replace(flipperPager + "-", "")); 141 direction = (root.nextPage < root.currentPage) ? -1 : 1; 142 if (root.nextPage != root.currentPage) { 143 root.showPage(direction, 0); 144 } 145 } 146 }) 147 } 148 if (O.arrows) { 149 $(root.wrap).find(".flipper-next-page").get(0).addEventListener("touchend", function () { 150 root.showNextPage() 151 }); 152 $(root.wrap).find(".flipper-prev-page").get(0).addEventListener("touchend", function () { 153 root.showPrevPage() 154 }) 155 } 156 root.wrap.get(0).addEventListener("touchstart", function (e) { 157 e.preventDefault(); 158 if (!animating) { 159 mouseDown = true 160 } 161 eX = e.touches[0].pageX; 162 eY = e.touches[0].pageY 163 }); 164 root.wrap.get(0).addEventListener("touchmove", function (e) { 165 if (mouseDown && !mouseDragging) { 166 mouseX = e.touches[0].pageX; 167 mouseY = e.touches[0].pageY; 168 if (!animating && mouseX - eX != 0) { 169 root.startDragging(); 170 mouseDragging = true 171 } 172 e.preventDefault() 173 } 174 if (mouseDragging) { 175 e.preventDefault(); 176 mouseX = e.touches[0].pageX; 177 mouseY = e.touches[0].pageY; 178 if (!animating) { 179 root.drag() 180 } 181 } 182 }); 183 root.wrap.get(0).addEventListener("touchend", function () { 184 if (mouseDown) { 185 if (!animating && mouseDragging) { 186 root.finishDragging() 187 } 188 } 189 mouseDragging = false;
190 mouseDown = false 191 }) 192 } 193 setTimeout(function () { 194 if (!fb) { 195 root.bounce() 196 } else { 197 root.fb_bounce() 198 } 199 }, 500); 200 this.updatePagers() 201 }; 202 Flipper.prototype.initPages = function () { 203 var root = this; 204 root.numPages = root.pages.length; 205 var html, page, h; 206 for (i = 0; i < root.numPages; i++) { 207 page = $(root.pages[i]); 208 html = page.html(); 209 h = ' <div class="flipper-page-left"><div class="flipper-overlay"></div><div class="flipper-page">' + html + "</div></div>"; 210 h += ' <div class="flipper-page-right"><div class="flipper-overlay"></div><div class="flipper-page">' + html + "</div></div>"; 211 page.removeClass("flipper-page").addClass("flipper-page-wrap").html(h).attr("id", flipperPage + "-" + i) 212 } 213 $(root.pages).css({ 214 "z-index": 1 215 }); 216 $(root.pages[0]).css({ 217 "z-index": 99 218 }) 219 }; 220 Flipper.prototype.initUI = function () { 221 h = ""; 222 if (O.arrows) { 223 h = '<img src="' + O.imagesPath + 'arrow_next.png" class="flipper-next-page"><img src="' + O.imagesPath + 'arrow_prev.png" class="flipper-prev-page">' 224 } 225 if (O.pager) { 226 h += '<div class="flipper-pager-wrap">'; 227 for (i = 0; i < this.numPages; i++) { 228 h += '<a href="javascript:;" class="flipper-pager" id="' + flipperPager + '-' + i + '"></a>' 229 } 230 h += "</div>" 231 } 232 if (O.arrows || O.pager) { 233 this.wrap.prepend(h) 234 } 235 }; 236 Flipper.prototype.bounce = function () { 237 var root = this; 238 currentPageSide = $("#" + flipperPage + "-" + this.currentPage).find(".flipper-page-right"); 239 currentPageSideOverlay = currentPageSide.find(".flipper-overlay").show(); 240 deg = 1; 241 reachedHalf = false; 242 start = true; 243 bounce = true; 244 animate_bounce() 245 }; 246 Flipper.prototype.showPage = function (direction, animDeg) { 247 if (fb) { 248 this.fb_showPage(direction, animDeg); 249 return 250 } 251 if (bounce && direction == -1) { 252 this.setAngle(currentPageSide, currentPageSideOverlay, 0); 253 currentPageSideOverlay.hide(); 254 bounce = false 255 } else { 256 currentPageSideOverlay.hide(); 257 bounce = false 258 } 259 reachedHalf = false; 260 var root = this; 261 nextPage = root.wrap.find("#" + flipperPage + "-" + this.nextPage); 262 currentPage = root.wrap.find("#" + flipperPage + "-" + this.currentPage); 263 264 if (direction == 1) { 265 currentPageSide = currentPage.find(".flipper-page-right"); 266 nextPageSide = nextPage.find(".flipper-page-left"); 267 currentPageOverlay = currentPageSide.find(".flipper-overlay").show(); 268 nextPageOverlay = nextPageSide.find(".flipper-overlay").show() 269 } else { 270 currentPageSide = currentPage.find(".flipper-page-left"); 271 nextPageSide = nextPage.find(".flipper-page-right"); 272 currentPageOverlay = currentPageSide.find(".flipper-overlay").show(); 273 nextPageOverlay = nextPageSide.find(".flipper-overlay").show() 274 } 275 if (animating) { 276 return 277 } 278 deg = animDeg; 279 this.pages.css({ 280 "z-index": 0 281 }); 282 if (deg < 90) { 283 currentPage.css({ 284 "z-index": 999 285 }); 286 nextPage.css({ 287 "z-index": 99 288 }) 289 } else { 290 currentPage.css({ 291 "z-index": 99 292 }); 293 nextPage.css({ 294 "z-index": 999 295 }) 296 } 297 animDirection = direction; 298 animating = true; 299 animate(); 300 root.currentPage = root.nextPage; 301 root.updatePagers() 302 }; 303 Flipper.prototype.showNextPage = function (cb) { 304 if (animating) { 305 return 306 } 307 if (bounce) { 308 bounce = false 309 } else { 310 deg = 0 311 } 312 this.nextPage = (this.currentPage < this.numPages - 1) ? this.currentPage + 1 : 0; 313 this.showPage(1, deg) 314 }; 315 Flipper.prototype.showPrevPage = function () { 316 if (animating) { 317 return 318 } 319 this.nextPage = (this.currentPage > 0) ? this.currentPage - 1 : this.numPages - 1; 320 this.showPage(-1, 0) 321 }; 322 Flipper.prototype.startDragging = function () { 323 if (fb) { 324 this.fb_startDragging(); 325 return 326 } 327 var root = this; 328 delta = eX - mouseX; 329 currentDirection = (delta < 0) ? -1 : 1; 330 direction = currentDirection; 331 reachedHalf = false;
332 if (bounce && direction == 1) { 333 startDeg = deg; 334 bounce = false 335 } else { 336 startDeg = 0; 337 bounceReset(); 338 bounce = false 339 } 340 if (direction == 1) { 341 this.nextPage = (this.currentPage < this.numPages - 1) ? this.currentPage + 1 : 0; 342 nextPage = root.wrap.find("#" + flipperPage + "-" + this.nextPage); 343 currentPage = root.wrap.find("#" + flipperPage + "-" + this.currentPage); 344 currentPageSide = currentPage.find(".flipper-page-right"); 345 currentPageOverlay = currentPageSide.find(".flipper-overlay").show(); 346 nextPageSide = nextPage.find(".flipper-page-left"); 347 nextPageOverlay = nextPageSide.find(".flipper-overlay").show() 348 } else { 349 this.nextPage = (this.currentPage > 0) ? this.currentPage - 1 : this.numPages - 1; 350 nextPage = root.wrap.find("#" + flipperPage + "-" + this.nextPage); 351 currentPage = root.wrap.find("#" + flipperPage + "-" + this.currentPage); 352 currentPageSide = currentPage.find(".flipper-page-left"); 353 currentPageOverlay = currentPageSide.find(".flipper-overlay").show(); 354 nextPageSide = nextPage.find(".flipper-page-right"); 355 nextPageOverlay = nextPageSide.find(".flipper-overlay").show() 356 } 357 this.pages.css({ 358 "z-index": 0 359 }); 360 currentPage.css({ 361 "z-index": 999 362 }); 363 nextPage.css({ 364 "z-index": 99 365 }); 366 this.wrap.addClass("flipper-dragging"); 367 deg = 0 368 }; 369 Flipper.prototype.drag = function () { 370 if (fb) { 371 this.fb_drag(); 372 return 373 } 374 delta = eX - mouseX; 375 currentDirection = (delta < 0) ? -1 : 1; 376 if (lastDelta - delta < 0) { 377 moveDirection = 1 378 } else { 379 moveDirection = -1 380 } 381 lastDelta = delta; 382 deg = (delta / O.width * 180 * direction + startDeg < 0) ? 0 : (delta / O.width * 180 * direction + startDeg > 180) ? 180 : delta / O.width * 180 * direction + startDeg; 383 cReachedHalf = (deg > 90) ? true : false; 384 if (cReachedHalf != reachedHalf) { 385 if (deg > 90) { 386 currentPage.css({ 387 "z-index": 99 388 }); 389 nextPage.css({ 390 "z-index": 999 391 }) 392 } else { 393 currentPage.css({ 394 "z-index": 999 395 }); 396 nextPage.css({ 397 "z-index": 99 398 }) 399 } 400 reachedHalf = cReachedHalf 401 } 402 this.setAngle(currentPageSide, currentPageOverlay, deg * direction * -1); 403 this.setAngle(nextPageSide, nextPageOverlay, (180 - deg) * direction) 404 }; 405 Flipper.prototype.finishDragging = function () { 406 if (fb) { 407 this.fb_finishDragging(); 408 return 409 } 410 if (moveDirection != direction && deg > 0) { 411 this.resetState(direction, deg) 412 } else { 413 if (deg > 0) { 414 this.showPage(direction, deg) 415 } 416 } 417 this.wrap.removeClass("flipper-dragging") 418 }; 419 Flipper.prototype.resetState = function (direction, animDeg) { 420 var root = this; 421 deg = animDeg; 422 this.pages.css({ 423 "z-index": 0 424 }); 425 if (deg < 90) { 426 currentPage.css({ 427 "z-index": 999 428 }); 429 nextPage.css({ 430 "z-index": 99 431 }); 432 reachedHalf = true 433 } else { 434 currentPage.css({ 435 "z-index": 99 436 }); 437 nextPage.css({ 438 "z-index": 999 439 }); 440 reachedHalf = false 441 } 442 animating = true; 443 animDirection = direction; 444 animate_reset() 445 }; 446 Flipper.prototype.resetAngles = function () { 447 flipper.setAngle(flipper.wrap.find(".flipper-page-left").add(".flipper-page-right"), flipper.wrap.find(".flipper-overlay"), 0) 448 }; 449 Flipper.prototype.setAngle = function (el, overlay, deg) { 450 el.css({ 451 "-moz-transform": "perspective(1800px) rotateY(" + deg + "deg)", 452 "-webkit-transform": "perspective(1800px) rotateY(" + deg + "deg)", 453 "-ms-transform": "perspective(1800px) rotateY(" + deg + "deg)", 454 "-o-transform": "perspective(1800px) rotateY(" + deg + "deg)", 455 transform: "perspective(1800px) rotateY(" + deg + "deg)" 456 }); 457 overlay.css({ 458 opacity: Math.abs(deg) / 90 459 }) 460 }; 461 Flipper.prototype.updatePagers = function () { 462 var root = this; 463 // root.wrap.find(".flipper-pager").attr("src", "" + O.imagesPath + "pager.png"); 464 // root.wrap.find("#"+flipperPager+"-" + this.currentPage).attr("src", root.wrap.find("#"+flipperPager+"-" + this.currentPage).attr("src").replace(".png", "-active.png")) 465 root.wrap.find("#" + flipperPager + "-" + this.currentPage).addClass('cur').siblings().removeClass('cur'); 466 467 O.callback && O.callback(this.currentPage); 468 }; 469 Flipper.prototype.updateZ = function () { 470 $(this.pages).css({ 471 "z-index": 1 472 }); 473 $("#" + flipperPage + "-" + this.currentPage).css({ 474 "z-index": 999 475 }) 476 }; 477 Flipper.prototype.fb_initPages = function () { 478 var root = this; 479 root.numPages = root.pages.length; 480 for (i = 0; i < root.numPages; i++) { 481 page = $(root.pages[i]); 482 html = page.html(); 483 h = ' <div class="flipper-page-left"><div class="flipper-page">' + html + "</div></div>"; 484 h += ' <div class="flipper-page-right"><div class="flipper-page">' + html + "</div></div>"; 485 page.removeClass("flipper-page").addClass("flipper-page-wrap-fb").addClass("flipper-page-wrap").html(h).attr("id", flipperPage + "-" + i); 486 page.find(".flipper-page").css({ 487 width: O.width 488 }) 489 } 490 root.wraps = $(".flipper-page-wrap-fb"); 491 $(root.wraps).css({ 492 "z-index": 1 493 }); 494 $(root.wraps[0]).css({ 495 "z-index": 99 496 }); 497 root.currentPage = 0; 498 root.nextPage = 1; 499 root.prevPage = root.numPages - 1 500 }; 501 Flipper.prototype.fb_bounce = function () { 502 this.wrap.prepend('<div class="flipper-fb-bounce">Flick to change pages</div>'); 503 $(".flipper-fb-bounce").fadeIn(500); 504 setTimeout(function () { 505 $(".flipper-fb-bounce").fadeOut(500, function () { 506 $(this).remove() 507 }) 508 }, 3000) 509 }; 510 Flipper.prototype.fb_showPage = function (direction, width) { 511 if (animating) { 512 return 513 } 514 var root = this; 515 if (direction == 1) { 516 currentPage = root.wrap.find("#" + flipperPage + "-" + root.currentPage); 517 currentPageSide = currentPage.find(".flipper-page-right"); 518 nextPage = root.wrap.find("#" + flipperPage + "-" + root.nextPage); 519 nextPageSide = nextPage.find(".flipper-page-left") 520 } else { 521 currentPage = root.wrap.find("#" + flipperPage + "-" + root.currentPage); 522 currentPageSide = currentPage.find(".flipper-page-left"); 523 nextPage = root.wrap.find("#" + flipperPage + "-" + root.nextPage); 524 nextPageSide = nextPage.find(".flipper-page-right") 525 } 526 $(root.pages).css({ 527 "z-index": 0 528 }); 529 currentPage.css({ 530 "z-index": 999 531 }); 532 nextPage.css({ 533 "z-index": 99 534 }); 535 temp = nextPageSide.html(); 536 animating = true; 537 if (direction == 1) { 538 currentPage.append('<div class="flipper-temp flipper-page-left">' + temp + "</div>"); 539 temp = $(".flipper-temp"); 540 currentPageSide.css({ 541 right: "auto", 542 left: "50%" 543 }).find(".flipper-page").css({ 544 left: -O.width / 2, 545 right: "auto" 546 }); 547 temp.css({ 548 width: 0, 549 left: O.width 550 }); 551 currentPageSidePage = currentPageSide.find(".flipper-page") 552 } else { 553 currentPage.append('<div class="flipper-temp flipper-page-right">' + temp + "</div>"); 554 temp = $(".flipper-temp"); 555 currentPageSidePage = currentPageSide.find(".flipper-page") 556 } 557 animWidth = width; 558 animDirection = direction; 559 fb_animate(); 560 root.currentPage = root.nextPage; 561 root.updatePagers() 562 }; 563 Flipper.prototype.fb_startDragging = function () { 564 if (animating) { 565 return 566 } 567 this.wrap.addClass("flipper-dragging"); 568 var root = this; 569 delta = eX - mouseX; 570 currentDirection = (delta < 0) ? -1 : 1; 571 direction = currentDirection; 572 if (direction == 1) { 573 this.nextPage = (this.currentPage < this.numPages - 1) ? this.currentPage + 1 : 0; 574 currentPage = root.wrap.find("#" + flipperPage + "-" + root.currentPage); 575 currentPageSide = currentPage.find(".flipper-page-right"); 576 nextPage = root.wrap.find("#" + flipperPage + "-" + root.nextPage); 577 nextPageSide = nextPage.find(".flipper-page-left"); 578 temp = nextPageSide.html(); 579 currentPage.append('<div class="flipper-temp flipper-page-left">' + temp + "</div>"); 580 temp = $(".flipper-temp"); 581 currentPageSidePage = currentPageSide.find(".flipper-page"); 582 currentPageSide.css({ 583 right: "auto", 584 left: "50%" 585 }).find(".flipper-page").css({ 586 left: -O.width / 2, 587 right: "auto" 588 }); 589 temp.css({ 590 width: 0, 591 left: O.width, 592 height: O.height + 2 593 }) 594 } else { 595 this.nextPage = (this.currentPage > 0) ? this.currentPage - 1 : this.numPages - 1; 596 currentPage = root.wrap.find("#" + flipperPage + "-" + root.currentPage); 597 currentPageSide = currentPage.find(".flipper-page-left"); 598 nextPage = root.wrap.find("#" + flipperPage + "-" + root.nextPage); 599 nextPageSide = nextPage.find(".flipper-page-right"); 600 temp = nextPageSide.html(); 601 currentPage.append('<div class="flipper-temp flipper-page-right">' + temp + "</div>"); 602 temp = $(".flipper-temp"); 603 currentPageSidePage = currentPageSide.find(".flipper-page"); 604 temp.css({ 605 left: 0, 606 width: 0, 607 height: O.height + 2 608 }) 609 } 610 $(root.pages).css({ 611 "z-index": 0 612 }); 613 currentPage.css({ 614 "z-index": 999 615 }); 616 nextPage.css({ 617 "z-index": 99 618 }) 619 }; 620 Flipper.prototype.fb_drag = function () { 621 delta = eX - mouseX; 622 currentDirection = (delta < 0) ? -1 : 1; 623 if (lastDelta - delta < 0) { 624 moveDirection = 1 625 } else { 626 moveDirection = -1 627 } 628 lastDelta = delta; 629 delta = Math.abs(delta / 2); 630 delta = (delta > O.width / 2) ? O.width / 2 : delta; 631 if (direction == 1) { 632 temp.css({ 633 width: delta, 634 left: O.width - delta * 2 635 }); 636 currentPageSide.css({ 637 width: O.width / 2 - delta 638 }) 639 } else { 640 temp.css({ 641 width: delta, 642 left: delta 643 }); 644 currentPageSide.css({ 645 width: O.width / 2 - delta, 646 left: delta 647 }); 648 currentPageSidePage.css({ 649 left: -delta 650 }) 651 } 652 }; 653 Flipper.prototype.fb_finishDragging = function () { 654 if (moveDirection != direction && delta > 0 && delta < O.width / 2) { 655 this.fb_resetState(direction, delta) 656 } else { 657 if (delta > 0) { 658 this.fb_showPage(direction, delta) 659 } 660 } 661 this.wrap.removeClass("flipper-dragging") 662 }; 663 Flipper.prototype.fb_resetState = function (direction, width) { 664 var root = this; 665 animating = true; 666 animDirection = direction; 667 animWidth = width; 668 fb_animate_reset() 669 }; 670 671 function animate_bounce() { 672 if (deg > 0 && bounce) { 673 start = false;
674 requestAnimFrame(animate_bounce); 675 increment = (0.9 - Math.sin(deg / 40)) * 3; 676 if (deg >= 40) { 677 reachedHalf = true 678 } 679 flipper.setAngle(currentPageSide, currentPageSideOverlay, -deg); 680 if (!reachedHalf) { 681 deg = deg + increment 682 } else { 683 deg = deg - increment 684 } 685 } else { 686 if (!mouseDown) { 687 bounceReset() 688 } 689 bounce = false 690 } 691 } 692 693 function bounceReset() { 694 if (bounceReset) { 695 flipper.setAngle(currentPageSide, currentPageSideOverlay, 0); 696 currentPageSideOverlay.hide() 697 } 698 } 699 700 function animate() { 701 if (deg < 180) { 702 requestAnimFrame(animate); 703 deg += 4; 704 flipper.setAngle(currentPageSide, currentPageOverlay, deg * animDirection * -1); 705 flipper.setAngle(nextPageSide, nextPageOverlay, (180 - deg) * animDirection); 706 if (deg > 90 && !reachedHalf) { 707 reachedHalf = true; 708 currentPage.css({ 709 "z-index": 99 710 }); 711 nextPage.css({ 712 "z-index": 999 713 }) 714 } 715 } else { 716 flipper.resetAngles(); 717 currentPageOverlay.hide(); 718 nextPageOverlay.hide(); 719 animating = false; 720 reachedHalf = false 721 } 722 } 723 724 function animate_reset() { 725 if (deg > 0) { 726 requestAnimFrame(animate_reset); 727 deg -= 3; 728 flipper.setAngle(currentPageSide, currentPageOverlay, deg * animDirection * -1); 729 flipper.setAngle(nextPageSide, nextPageOverlay, (deg - 180) * animDirection * -1); 730 if (deg <= 90 && !reachedHalf) { 731 reachedHalf = true; 732 currentPage.css({ 733 "z-index": 999 734 }); 735 nextPage.css({ 736 "z-index": 99 737 }) 738 } 739 } else { 740 flipper.setAngle(currentPageSide, currentPageOverlay, 0); 741 flipper.setAngle(nextPageSide, nextPageOverlay, 0); 742 animating = false 743 } 744 } 745 746 function fb_animate() { 747 if (animWidth <= O.width / 2) { 748 requestAnimFrame(fb_animate); 749 if (animDirection == 1) { 750 temp.css({ 751 width: animWidth - 2, 752 left: O.width - animWidth * 2 - 1 753 }); 754 currentPageSide.css({ 755 width: O.width / 2 - animWidth 756 }) 757 } else { 758 temp.css({ 759 width: animWidth - 2, 760 left: animWidth - 1 761 }); 762 currentPageSide.css({ 763 width: O.width / 2 - animWidth, 764 left: animWidth 765 }); 766 currentPageSidePage.css({ 767 left: -animWidth 768 }) 769 } 770 animWidth += 10 771 } else { 772 $(flipper.wraps).css({ 773 "z-index": 1 774 }); 775 currentPage.css({ 776 "z-index": 99 777 }); 778 nextPage.css({ 779 "z-index": 999 780 }); 781 temp.remove(); 782 flipper.currentPage = flipper.nextPage; 783 if (animDirection == 1) { 784 currentPageSide.css({ 785 width: O.width / 2 786 }) 787 } else { 788 currentPageSide.css({ 789 width: O.width / 2, 790 left: 0 791 }) 792 } 793 if (animDirection == -1) { 794 currentPageSidePage.css({ 795 left: 0 796 }) 797 } 798 animating = false 799 } 800 } 801 802 function fb_animate_reset() { 803 if (animDirection == 1) { 804 if (animWidth > 0) { 805 requestAnimFrame(fb_animate_reset); 806 temp.css({ 807 width: animWidth - 2, 808 left: O.width - animWidth * 2 - 1 809 }); 810 currentPageSide.css({ 811 width: O.width / 2 - animWidth 812 }); 813 animWidth -= 10 814 } else { 815 currentPageSide.css({ 816 width: O.width / 2 817 }); 818 temp.remove(); 819 currentPageSide.css({ 820 width: O.width 821 }); 822 animating = false 823 } 824 } else { 825 if (animWidth > 0) { 826 requestAnimFrame(fb_animate_reset); 827 temp.css({ 828 width: animWidth - 2, 829 left: animWidth - 1 830 }); 831 currentPageSide.css({ 832 width: O.width / 2 - animWidth, 833 left: animWidth 834 }); 835 currentPageSidePage.css({ 836 left: -animWidth 837 }); 838 animWidth -= 10 839 } else { 840 temp.remove(); 841 currentPageSide.css({ 842 width: O.width / 2, 843 left: 0 844 }); 845 currentPageSidePage.css({ 846 left: 0 847 }); 848 animating = false 849 } 850 } 851 } 852 $.fn.flipper = function (options) { 853 var D = { 854 width: 800, 855 height: 400, 856 arrows: true, 857 pager: true, 858 imagesPath: "images/", 859 startPage: 0 860 }; 861 O = $.extend(true, D, options); 862 if (O.imagesPath[O.imagesPath.length - 1] != "/") { 863 O.imagesPath = O.imagesPath + "/" 864 } 865 return this.each(function () { 866 flipper = new Flipper(); 867 flipper.init($(this)) 868 }) 869 } 870})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.