1$(document).ready(function ($) { 2 var count = 2, 3 openfirst = 0, 4 $slide = $('#ss-holder section'); 5 scrollinit = function (themeselect, pages, slidenum, keys, buttons, slidegestures, clicks, mousewheel) { 6 var themeselect = themeselect, 7 total = pages, 8 slidenum = slidenum, 9 keys = keys, 10 buttons = buttons, 11 slidegestures = slidegestures, 12 clicks = clicks, 13 mousewheel = mousewheel, 14 whait = 0; 15 16 deck = bespoke.from('#ss-holder article'); 17 initThemeSwitching(themeselect, slidenum, keys, buttons, slidegestures, clicks, mousewheel); 18 19 if (!total) { 20 total = 0; 21 } 22 window.initajax = function () { 23 if (count > total) { 24 return false; 25 } else { 26 if (whait !== 1) { 27 loadArticle(count); 28 whait = 1 29 } else { 30 return false; 31 } 32 } 33 count++; 34 }; 35 36 function loadArticle(pageNumber) { 37 $('.inifiniteLoader').removeClass('fadeOutDown').addClass("fadeInUp"); 38 $('.numpostinfi').removeClass('fadeInUp').addClass("fadeOutDown"); 39 $.ajax({ 40 url: "load_page.php", 41 type: 'POST', 42 data: 'page=pages/' + count, 43 dataType: "html", 44 45 success: function (html) { 46 $('.inifiniteLoader').removeClass('fadeInUp').addClass("fadeOutDown"); 47 $('.numpostinfi').removeClass('fadeOutDown').addClass("fadeInUp"); 48 $("#articlehold").append(html); 49 whait = 0; 50 scrollinit(themeselect, pages, slidenum, keys, buttons, slidegestures, clicks, mousewheel); 51 52 53 //pretty Photo settings( ! Don't change ) 54 //================================================== 55 // $("a[rel^='prettyPhoto']").prettyPhoto({allow_resize: false}); 56 // $("a[rel^='prettyPhotoImages']").prettyPhoto({theme: 'pp_default', allow_resize: true}); 57 58 //Img roll over effect settings 59 //================================================== 60 61 const imgholder = document.getElementsByClassName("hover-effect"); 62 for (let i = 0, j = imgholder.length; i < j; i++) { 63 imgholder[i].addEventListener("mouseover", function () { 64 const imgtoanimate = this.getElementsByTagName("img")[0]; 65 if (imgtoanimate) { 66 move(imgtoanimate) 67 .rotate(10) 68 .scale(1) 69 .duration('1s') 70 .end(); 71 } 72 }); 73 imgholder[i].addEventListener("mouseout", function () { 74 const imgtoanimate = this.getElementsByTagName("img")[0]; 75 if (imgtoanimate) { 76 move(imgtoanimate) 77 .rotate(0) 78 .scale(1.0) 79 .duration('1s') 80 .end(); 81 } 82 }); 83 } 84 85 86 const contentholder2 = document.getElementsByClassName("go-anim"); 87 if (contentholder2.length > 0) { 88 for (let i = 0, j = contentholder2.length; i < j; i++) { 89 contentholder2[i].addEventListener("mouseover", function () { 90 var holdertoanimate = this.getElementsByClassName("ss-container")[0]; 91 var ribbon = this.getElementsByClassName("ribbon")[0]; 92 if (holdertoanimate) { 93 move(this) 94 .set('margin-top', -20) 95 .duration('0.7s') 96 .end(); 97 if (ribbon) { 98 move(ribbon) 99 .set('margin-top', -15) 100 .duration('0.7s') 101 .end(); 102 } 103 } else { 104 move(this) 105 .set('margin-top', -20) 106 .duration('0.7s') 107 .end(); 108 } 109 });
110 contentholder2[i].addEventListener("mouseout", function () { 111 let holdertoanimate = this.getElementsByClassName("ss-container")[0], 112 ribbon = this.getElementsByClassName("ribbon")[0]; 113 if (holdertoanimate) { 114 move(this) 115 .set('margin-top', 0) 116 .duration('0.7s') 117 .end(); 118 if (ribbon) { 119 move(ribbon) 120 .set('margin-top', -0) 121 .duration('0.7s') 122 .end(); 123 } 124 } else { 125 move(this) 126 .set('margin-top', 0) 127 .duration('0.7s') 128 .end(); 129 } 130 }); 131 } 132 } 133 } 134 }); 135 return false; 136 } 137 138 var themes, 139 selectedThemeIndex, 140 instructionsTimeout, 141 deck; 142 143 function initThemeSwitching(themeselect, slidenum, keys, buttons, slidegestures, clicks, mousewheel) { 144 145 themes = [ 146 'classic', 147 'cube', 148 'carousel', 149 'concave', 150 'coverflow', 151 'spiraltop', 152 'spiralbottom', 153 'classictilt' 154 ]; 155 if (!themeselect) { 156 themeselect = 'carousel'; 157 } 158 159 $('#effects').removeClass().addClass(themeselect); 160 161 162 selectedThemeIndex = 0; 163 if (window.lastslide !== '') { 164 deck.slide(window.lastslide - 1); 165 } else { 166 deck.slide(0); 167 } 168 if (openfirst !== 1) { 169 deck.slide(slidenum); 170 openfirst = 1; 171 } 172 if (keys !== false) { 173 initKeys(); 174 } else { 175 window.gokb = ''; 176 } 177 if (buttons !== false) { 178 initButtons(); 179 } 180 if (slidegestures !== false) { 181 initSlideGestures(); 182 } else { 183 window.remvoetuch = function () { 184 }; 185 } 186 if (clicks !== false) { 187 initClickInactive(); 188 } 189 190 191 //If browser doesn't support trasnforms3d swich scroll effect to classic 192 //================================================== 193 //$('#effects').removeClass().addClass("classic"); 194 195 } 196 197 //Navigation 198 //================================================== 199 function initButtons() { 200 document.getElementById('next-arrow').addEventListener('click', gonext); 201 document.getElementById('prev-arrow').addEventListener('click', deck.prev); 202 } 203 204 function gonext() { 205 206 deck.next(); 207 208 $slide.each(function () { 209 let n = $slide.length; 210 if ($(this).hasClass('bespoke-active') && Number($(this).attr('rel')) + 1 === n) { 211 212 if (window.initajax() !== false) { 213 document.removeEventListener('keydown', gokb); 214 215 document.getElementById('next-arrow').removeEventListener('click', gonext); 216 } 217 } 218 }); 219 220 221 } 222 223 //Keyboard navigation 224 //================================================== 225 226 function initKeys() { 227 document.getElementById('next-arrow').removeEventListener('click', gonext); 228 if (/Firefox/.test(navigator.userAgent)) { 229 document.addEventListener('keydown', function (e) { 230 if (e.which >= 37 && e.which <= 40) { 231 e.preventDefault(); 232 } 233 }); 234 } 235 window.gokb = function (e) { 236 if (window.bopen === 1) { 237 hideInstructions(); 238 window.bopen = 2; 239 } 240 let key = e.which; 241 if (key === 37) { 242 deck.prev(); 243 } 244 if (key === 32 || key === 39) { 245 deck.next(); 246 } 247 if (key === 38) { 248 if (Modernizr.csstransforms3d !== false) { 249 prevTheme(); 250 } 251 } 252 if (key === 40) { 253 if (Modernizr.csstransforms3d !== false) { 254 nextTheme(); 255 } 256 } 257 258 259 $slide.each(function () { 260 let n = $slide.length; 261 if ($(this).hasClass('bespoke-active') && Number($(this).attr('rel')) + 1 === n) { 262 if (window.initajax() !== false) { 263 document.removeEventListener('keydown', gokb); 264 } 265 } 266 }); 267 }; 268 document.addEventListener('keydown', gokb); 269 } 270 271 function extractDelta(e) { 272 if (e.wheelDelta) { 273 return e.wheelDelta; 274 } 275 if (e.originalEvent.detail) { 276 return e.originalEvent.detail * -40; 277 } 278 if (e.originalEvent && e.originalEvent.wheelDelta) { 279 return e.originalEvent.wheelDelta; 280 } 281 } 282 283 //Mouse wheel navigation 284 //================================================== 285 window.gomouse = function gomousewheel() { 286 let n = $slide.length; 287 $slide.each(function () { 288 if ($(this).hasClass('bespoke-active') && Number($(this).attr('rel')) + 1 === n && $(document).width() > 30) { 289 if (window.initajax() === false) { 290 document.addEventListener('keydown', gokb); 291 } else { 292 document.removeEventListener('keydown', gokb); 293 $("#ss-holder").unbind("mousewheel DOMMouseScroll"); 294 } 295 } 296 }); 297 $('#ss-holder').bind('mousewheel DOMMouseScroll', function (e) { 298 if (extractDelta(e) > 0) { 299 $("#ss-holder").unbind("mousewheel DOMMouseScroll"); 300 setTimeout(prevp, 200); 301 } 302 if (extractDelta(e) < 0) { 303 $("#ss-holder").unbind("mousewheel DOMMouseScroll"); 304 setTimeout(nextp, 200); 305 } 306 }); 307 308 function prevp() { 309 deck.prev(); 310 setTimeout(gomousewheel, 200); 311 } 312 313 function nextp() { 314 deck.next(); 315 setTimeout(gomousewheel, 200); 316 } 317 }; 318 319 if (mousewheel !== false) { 320 window.gomouse(); 321 } 322 323 //Navigation for touch devices 324 //================================================== 325 function initSlideGestures() { 326 var start = 0; 327 var main = document.getElementById('ss-holder'), 328 startPosition, 329 delta, 330 singleTouch = function (fn, preventDefault) { 331 return function (e) { 332 if (e.touches.length === 1) { 333 fn(e.touches[0].pageX); 334 } 335 }; 336 }, 337 touchstart = singleTouch(function (position) { 338 startPosition = position; 339 delta = 0; 340 start = 0; 341 main.addEventListener('touchend', touchend); 342 }), 343 touchmove = singleTouch(function (position) { 344 delta = position - startPosition; 345 }, true), 346 touchend = function () {
347 if ($(document).width() < 30) { 348 if ($(window).scrollTop() > $(document).height() - $(window).height() - 80) { 349 if (window.initajax() === false) { 350 main.addEventListener('touchstart', touchstart); 351 main.addEventListener('touchmove', touchmove); 352 main.addEventListener('touchend', touchend); 353 } else { 354 main.removeEventListener('touchstart', touchstart); 355 main.removeEventListener('touchmove', touchmove); 356 main.removeEventListener('touchend', touchend); 357 } 358 } 359 } 360 if (Math.abs(delta) < 50) { 361 return; 362 } 363 if (delta > 0) { 364 deck.prev(); 365 } else { 366 deck.next(); 367 } 368 369 $slide.each(function () { 370 let n = $slide.length; 371 if ($(this).hasClass('bespoke-active') && Number($(this).attr('rel')) + 1 === n && jQuery(document).width() > 530) { 372 if (window.initajax() === false) { 373 main.addEventListener('touchstart', touchstart); 374 main.addEventListener('touchmove', touchmove); 375 main.addEventListener('touchend', touchend); 376 } else { 377 main.removeEventListener('touchstart', touchstart); 378 main.removeEventListener('touchmove', touchmove); 379 main.removeEventListener('touchend', touchend); 380 } 381 } 382 }); 383 }; 384 window.remvoetuch = function () { 385 main.removeEventListener('touchstart', touchstart); 386 main.removeEventListener('touchmove', touchmove); 387 main.removeEventListener('touchend', touchend); 388 }; 389 window.addtuch = function () { 390 main.addEventListener('touchstart', touchstart); 391 main.addEventListener('touchmove', touchmove); 392 main.addEventListener('touchend', touchend); 393 }; 394 window.addtuch(); 395 } 396 397 function selectTheme(index) { 398 var theme = themes[index]; 399 $('#effects').removeClass().addClass(theme); 400 selectedThemeIndex = index; 401 } 402 403 function nextTheme() { 404 offsetSelectedTheme(1); 405 if (window.bopen === 1) { 406 hideInstructions(); 407 window.bopen = 2; 408 } 409 } 410 411 function prevTheme() { 412 offsetSelectedTheme(-1); 413 if (window.bopen === 1) { 414 hideInstructions(); 415 window.bopen = 2; 416 } 417 } 418 419 function offsetSelectedTheme(n) { 420 selectTheme(modulo(selectedThemeIndex + n, themes.length)); 421 } 422 423 function isTouch() { 424 return !!('ontouchstart' in window) || navigator.msMaxTouchPoints; 425 } 426 427 function modulo(num, n) { 428 return ((num % n) + n) % n; 429 } 430 431 //Mouse click navigation 432 //================================================== 433 var n = $slide.length; 434 window.lastslide = n; 435 436 function initClickInactive() { 437 438 $slide.unbind("click"); 439 var main = document.getElementById('main'); 440 441 $('#ss-holder section').on('click',function () { 442 443 var page = $(this).attr('rel'); 444 var count = Number(page) + 1; 445 if ($(this).hasClass('bespoke-inactive')) { 446 if (count === n) { 447 if (window.initajax() === false) { 448 document.addEventListener('keydown', gokb); 449 window.remvoetuch(); 450 initSlideGestures(); 451 } else { 452 document.removeEventListener('keydown', gokb); 453 window.remvoetuch(); 454 } 455 } 456 deck.slide(page); 457 } 458 }); 459 } 460 461 var contentholder2 = document.getElementsByClassName("go-anim"); 462 if (contentholder2.length > 0) { 463 for (var i = 0, j = contentholder2.length; i < j; i++) {
464 contentholder2[i].addEventListener("mouseover", function () { 465 var holdertoanimate = this.getElementsByClassName("ss-container")[0]; 466 var ribbon = this.getElementsByClassName("ribbon")[0]; 467 if (holdertoanimate) { 468 move(this) 469 .set('margin-top', -0) 470 .duration('0.7s') 471 .end(); 472 if (ribbon) { 473 move(ribbon) 474 .set('margin-top', -0) 475 .duration('0.7s') 476 .end(); 477 } 478 } else { 479 move(this) 480 .set('margin-top', -0) 481 .duration('0.7s') 482 .end(); 483 } 484 }); 485 contentholder2[i].addEventListener("mouseout", function () { 486 var holdertoanimate = this.getElementsByClassName("ss-container")[0]; 487 var ribbon = this.getElementsByClassName("ribbon")[0]; 488 if (holdertoanimate) { 489 move(this) 490 .set('margin-top', 0) 491 .duration('0.7s') 492 .end(); 493 if (ribbon) { 494 move(ribbon) 495 .set('margin-top', -0) 496 .duration('0.7s') 497 .end(); 498 } 499 } else { 500 move(this) 501 .set('margin-top', 0) 502 .duration('0.7s') 503 .end(); 504 } 505 }); 506 } 507 } 508 }; 509 510 511 512 //Show / hide loading bar 513 //================================================== 514 $('.inifiniteLoaderP').removeClass('fadeOutDown').addClass("fadeInUp"); 515 $(window).bind("load", function () { 516 $('.inifiniteLoaderP').removeClass('fadeInUp').addClass("fadeOutDown"); 517 $('.numpostinfi').removeClass('fadeOutDown').addClass("fadeInUp"); 518 }); 519 520 521//pretty Photo settings( ! Don't change ) 522//================================================== 523 524 // $("a[rel^='prettyPhoto']").prettyPhoto({allow_resize: false}); 525 // $("a[rel^='prettyPhotoImages']").prettyPhoto({theme: 'pp_default', allow_resize: true}); 526 527 528//Img roll over effect settings 529//================================================== 530 531 532 var imgholder = document.getElementsByClassName("hover-effect"); 533 for (var i = 0, j = imgholder.length; i < j; i++) { 534 imgholder[i].addEventListener("mouseover", function () { 535 var imgtoanimate = this.getElementsByTagName("img")[0]; 536 if (imgtoanimate) { 537 move(imgtoanimate) 538 // .rotate(10) 539 .scale(1) 540 .duration('1s') 541 .end(); 542 } 543 }); 544 imgholder[i].addEventListener("mouseout", function () { 545 var imgtoanimate = this.getElementsByTagName("img")[0]; 546 if (imgtoanimate) { 547 move(imgtoanimate) 548 .rotate(0) 549 .scale(1.0) 550 .duration('1s') 551 .end(); 552 } 553 }); 554 } 555 556}); 557;(function (exports) { 558 559 /** 560 * Computed style. 561 */ 562 563 var current = window.getComputedStyle || window.currentStyle; 564 565 /** 566 * Map of prop -> type for numeric values. 567 */ 568 569 var map = { 570 'top': 'px' 571 , 'bottom': 'px' 572 , 'left': 'px' 573 , 'right': 'px' 574 , 'width': 'px' 575 , 'height': 'px' 576 , 'font-size': 'px' 577 , 'margin': 'px' 578 , 'margin-top': 'px' 579 , 'margin-bottom': 'px' 580 , 'margin-left': 'px' 581 , 'margin-right': 'px' 582 , 'padding': 'px' 583 , 'padding-top': 'px' 584 , 'padding-bottom': 'px' 585 , 'padding-left': 'px' 586 , 'padding-right': 'px' 587 }; 588 589 /** 590 * Initialize a `Move` instance with the given `selector`. 591 * 592 * @param {String} selector 593 * @return {Move} 594 * @api public 595 */ 596 597 exports.move = function (selector) { 598 return new Move(move.select(selector)); 599 }; 600 601 /** 602 * Library version. 603 */ 604 605 exports.move.version = '0.0.3'; 606 607 /** 608 * Defaults. 609 * 610 * `duration` - default duration of 500ms 611 * 612 */ 613 614 move.defaults = { 615 duration: 500 616 }; 617 618 /** 619 * Easing functions. 620 */ 621 622 move.ease = { 623 'in': 'ease-in' 624 , 'out': 'ease-out' 625 , 'in-out': 'ease-in-out' 626 , 'snap': 'cubic-bezier(0,1,.5,1)' 627 , 'linear': 'cubic-bezier(0.250, 0.250, 0.750, 0.750)' 628 , 'ease-in-quad': 'cubic-bezier(0.550, 0.085, 0.680, 0.530)' 629 , 'ease-in-cubic': 'cubic-bezier(0.550, 0.055, 0.675, 0.190)' 630 , 'ease-in-quart': 'cubic-bezier(0.895, 0.030, 0.685, 0.220)' 631 , 'ease-in-quint': 'cubic-bezier(0.755, 0.050, 0.855, 0.060)' 632 , 'ease-in-sine': 'cubic-bezier(0.470, 0.000, 0.745, 0.715)' 633 , 'ease-in-expo': 'cubic-bezier(0.950, 0.050, 0.795, 0.035)' 634 , 'ease-in-circ': 'cubic-bezier(0.600, 0.040, 0.980, 0.335)' 635 , 'ease-in-back': 'cubic-bezier(0.600, -0.280, 0.735, 0.045)' 636 , 'ease-out-quad': 'cubic-bezier(0.250, 0.460, 0.450, 0.940)' 637 , 'ease-out-cubic': 'cubic-bezier(0.215, 0.610, 0.355, 1.000)' 638 , 'ease-out-quart': 'cubic-bezier(0.165, 0.840, 0.440, 1.000)' 639 , 'ease-out-quint': 'cubic-bezier(0.230, 1.000, 0.320, 1.000)' 640 , 'ease-out-sine': 'cubic-bezier(0.390, 0.575, 0.565, 1.000)' 641 , 'ease-out-expo': 'cubic-bezier(0.190, 1.000, 0.220, 1.000)' 642 , 'ease-out-circ': 'cubic-bezier(0.075, 0.820, 0.165, 1.000)' 643 , 'ease-out-back': 'cubic-bezier(0.175, 0.885, 0.320, 1.275)' 644 , 'ease-in-out-quart': 'cubic-bezier(0.770, 0.000, 0.175, 1.000)' 645 , 'ease-in-out-quint': 'cubic-bezier(0.860, 0.000, 0.070, 1.000)' 646 , 'ease-in-out-sine': 'cubic-bezier(0.445, 0.050, 0.550, 0.950)' 647 , 'ease-in-out-expo': 'cubic-bezier(1.000, 0.000, 0.000, 1.000)' 648 , 'ease-in-out-circ': 'cubic-bezier(0.785, 0.135, 0.150, 0.860)' 649 , 'ease-in-out-back': 'cubic-bezier(0.680, -0.550, 0.265, 1.550)' 650 }; 651 652 /** 653 * Default element selection utilized by `move(selector)`. 654 * 655 * Override to implement your own selection, for example 656 * with jQuery one might write: 657 * 658 * move.select = function(selector) { 659 * return jQuery(selector).get(0); 660 * }; 661 * 662 * @param {Object|String} selector 663 * @return {Element} 664 * @api public 665 */ 666 667 move.select = function (selector) { 668 if ('string' != typeof selector) return selector; 669 return document.getElementById(selector) 670 || document.querySelectorAll(selector)[0]; 671 }; 672 673 /** 674 * EventEmitter. 675 */ 676 677 function EventEmitter() { 678 this.callbacks = {}; 679 } 680 681 /** 682 * Listen on the given `event` with `fn`. 683 * 684 * @param {String} event 685 * @param {Function} fn 686 */ 687 688 EventEmitter.prototype.on = function (event, fn) { 689 (this.callbacks[event] = this.callbacks[event] || []) 690 .push(fn); 691 return this; 692 }; 693 694 /** 695 * Emit `event` with the given args. 696 * 697 * @param {String} event 698 * @param {Mixed} ... 699 */ 700 701 EventEmitter.prototype.emit = function (event) { 702 var args = Array.prototype.slice.call(arguments, 1) 703 , callbacks = this.callbacks[event] 704 , len; 705 706 if (callbacks) { 707 len = callbacks.length; 708 for (var i = 0; i < len; ++i) { 709 callbacks[i].apply(this, args) 710 } 711 } 712 713 return this; 714 }; 715 716 /** 717 * Initialize a new `Move` with the given `el`. 718 * 719 * @param {Element} el 720 * @api public 721 */ 722 723 exports.Move = function Move(el) { 724 if (!(this instanceof Move)) return new Move(el); 725 EventEmitter.call(this); 726 this.el = el; 727 this._props = {}; 728 this._rotate = 0; 729 this._transitionProps = []; 730 this._transforms = []; 731 this.duration(move.defaults.duration) 732 }; 733 734 /** 735 * Inherit from `EventEmitter.prototype`. 736 */ 737 738 Move.prototype = new EventEmitter; 739 Move.prototype.constructor = Move; 740 741 /** 742 * Buffer `transform`. 743 * 744 * @param {String} transform 745 * @return {Move} for chaining 746 * @api private 747 */ 748 749 Move.prototype.transform = function (transform) { 750 this._transforms.push(transform); 751 return this; 752 }; 753 754 /** 755 * Skew `x` and `y`. 756 * 757 * @param {Number} x 758 * @param {Number} y 759 * @return {Move} for chaining 760 * @api public 761 */ 762 763 Move.prototype.skew = function (x, y) { 764 y = y || 0; 765 return this.transform('skew(' 766 + x + 'deg, ' 767 + y + 'deg)'); 768 }; 769 770 /** 771 * Skew x by `n`. 772 * 773 * @param {Number} n 774 * @return {Move} for chaining 775 * @api public 776 */ 777
778 Move.prototype.skewX = function (n) { 779 return this.transform('skewX(' + n + 'deg)'); 780 }; 781 782 /** 783 * Skew y by `n`. 784 * 785 * @param {Number} n 786 * @return {Move} for chaining 787 * @api public 788 */ 789 790 Move.prototype.skewY = function (n) { 791 return this.transform('skewY(' + n + 'deg)'); 792 }; 793 794 /** 795 * Translate `x` and `y` axis. 796 * 797 * @param {Number} x 798 * @param {Number} y 799 * @return {Move} for chaining 800 * @api public 801 */ 802 803 Move.prototype.translate = 804 Move.prototype.to = function (x, y) { 805 y = y || 0; 806 return this.transform('translate(' 807 + x + 'px, ' 808 + y + 'px)'); 809 }; 810 811 /** 812 * Translate on the x axis to `n`. 813 * 814 * @param {Number} n 815 * @return {Move} for chaining 816 * @api public 817 */ 818 819 Move.prototype.translateX = 820 Move.prototype.x = function (n) { 821 return this.transform('translateX(' + n + 'px)'); 822 }; 823 824 /** 825 * Translate on the y axis to `n`. 826 * 827 * @param {Number} n 828 * @return {Move} for chaining 829 * @api public 830 */ 831 832 Move.prototype.translateY = 833 Move.prototype.y = function (n) { 834 return this.transform('translateY(' + n + 'px)'); 835 }; 836 837 /** 838 * Scale the x and y axis by `x`, or 839 * individually scale `x` and `y`. 840 * 841 * @param {Number} x 842 * @return {Move} for chaining 843 * @api public 844 */ 845 846 Move.prototype.scale = function (x) { 847 var y = null == y ? x : y; 848 return this.transform('scale(' 849 + x + ', ' 850 + y + ')'); 851 }; 852 853 /** 854 * Scale x axis by `n`. 855 * 856 * @param {Number} n 857 * @return {Move} for chaining 858 * @api public 859 */ 860 861 Move.prototype.scaleX = function (n) { 862 return this.transform('scaleX(' + n + ')') 863 }; 864 865 /** 866 * Scale y axis by `n`. 867 * 868 * @param {Number} n 869 * @return {Move} for chaining 870 * @api public 871 */ 872 873 Move.prototype.scaleY = function (n) { 874 return this.transform('scaleY(' + n + ')') 875 }; 876 877 /** 878 * Rotate `n` degrees. 879 * 880 * @param {Number} n 881 * @return {Move} for chaining 882 * @api public 883 */ 884 885 Move.prototype.rotate = function (n) { 886 return this.transform('rotate(' + n + 'deg)'); 887 }; 888 889 890 /** 891 * Set transition easing function to to `fn` string. 892 * 893 * When: 894 * 895 * - null "ease" is used 896 * - "in" "ease-in" is used 897 * - "out" "ease-out" is used 898 * - "in-out" "ease-in-out" is used 899 * 900 * @param {String} fn 901 * @return {Move} for chaining 902 * @api public 903 */ 904 905 Move.prototype.ease = function (fn) { 906 fn = move.ease[fn] || fn || 'ease'; 907 return this.setVendorProperty('transition-timing-function', fn); 908 }; 909 910 /** 911 * Set animation properties 912 * 913 * @param {String} name 914 * @param {Object} props 915 * @return {Move} for chaining 916 * @api public 917 */ 918 919 Move.prototype.animate = function (name, props) { 920 for (var i in props) { 921 if (props.hasOwnProperty(i)) { 922 this.setVendorProperty('animation-' + i, props[i]) 923 } 924 } 925 return this.setVendorProperty('animation-name', name); 926 }; 927 928 /** 929 * Set duration to `n`. 930 * 931 * @param {Number|String} n 932 * @return {Move} for chaining 933 * @api public 934 */ 935 936 Move.prototype.duration = function (n) { 937 n = this._duration = 'string' == typeof n 938 ? parseFloat(n) * 1000 939 : n; 940 return this.setVendorProperty('transition-duration', n + 'ms'); 941 }; 942 943 /** 944 * Delay the animation by `n`. 945 * 946 * @param {Number|String} n 947 * @return {Move} for chaining 948 * @api public 949 */ 950 951 Move.prototype.delay = function (n) { 952 n = 'string' == typeof n 953 ? parseFloat(n) * 1000 954 : n; 955 return this.setVendorProperty('transition-delay', n + 'ms'); 956 }; 957 958 /** 959 * Set `prop` to `val`, deferred until `.end()` is invoked. 960 * 961 * @param {String} prop 962 * @param {String} val 963 * @return {Move} for chaining 964 * @api public 965 */ 966 967 Move.prototype.setProperty = function (prop, val) { 968 this._props[prop] = val; 969 return this; 970 }; 971 972 /** 973 * Set a vendor prefixed `prop` with the given `val`. 974 * 975 * @param {String} prop 976 * @param {String} val 977 * @return {Move} for chaining 978 * @api public 979 */ 980 981 Move.prototype.setVendorProperty = function (prop, val) { 982 this.setProperty('-webkit-' + prop, val); 983 this.setProperty('-moz-' + prop, val); 984 this.setProperty('-ms-' + prop, val); 985 this.setProperty('-o-' + prop, val); 986 return this; 987 }; 988 989 /** 990 * Set `prop` to `value`, deferred until `.end()` is invoked 991 * and adds the property to the list of transition props. 992 * 993 * @param {String} prop 994 * @param {number} val 995 * @return {Move} for chaining 996 * @api public 997 */ 998 999 Move.prototype.set = function (prop, val) { 1000 this.transition(prop); 1001 if ('number' == typeof val && map[prop]) val += map[prop]; 1002 this._props[prop] = val; 1003 return this; 1004 }; 1005 1006 /** 1007 * Increment `prop` by `val`, deferred until `.end()` is invoked 1008 * and adds the property to the list of transition props. 1009 * 1010 * @param {String} prop 1011 * @param {Number} val 1012 * @return {Move} for chaining 1013 * @api public 1014 */ 1015 1016 Move.prototype.add = function (prop, val) { 1017 if (!current) return; 1018 var self = this; 1019 return this.on('start', function () { 1020 var curr = parseInt(self.current(prop), 10); 1021 self.set(prop, curr + val + 'px'); 1022 }); 1023 }; 1024 1025 /** 1026 * Decrement `prop` by `val`, deferred until `.end()` is invoked 1027 * and adds the property to the list of transition props. 1028 * 1029 * @param {String} prop 1030 * @param {Number} val 1031 * @return {Move} for chaining 1032 * @api public 1033 */ 1034 1035 Move.prototype.sub = function (prop, val) { 1036 if (!current) return; 1037 var self = this; 1038 return this.on('start', function () { 1039 var curr = parseInt(self.current(prop), 10); 1040 self.set(prop, curr - val + 'px'); 1041 }); 1042 }; 1043 1044 /** 1045 * Get computed or "current" value of `prop`. 1046 * 1047 * @param {String} prop 1048 * @return {String} 1049 * @api public 1050 */ 1051 1052 Move.prototype.current = function (prop) { 1053 return current(this.el).getPropertyValue(prop); 1054 }; 1055 1056 /** 1057 * Add `prop` to the list of internal transition properties. 1058 * 1059 * @param {String} prop 1060 * @return {Move} for chaining 1061 * @api private 1062 */ 1063 1064 Move.prototype.transition = function (prop) { 1065 if (!this._transitionProps.indexOf(prop)) return this; 1066 this._transitionProps.push(prop); 1067 return this; 1068 }; 1069 1070 /** 1071 * Commit style properties, aka apply them to `el.style`. 1072 * 1073 * @return {Move} for chaining 1074 * @see Move.end#end() 1075 * @api private 1076 */ 1077 1078 Move.prototype.applyProperties = function () { 1079 var props = this._props 1080 , el = this.el; 1081 1082 for (var prop in props) { 1083 if (props.hasOwnProperty(prop)) { 1084 el.style.setProperty(prop, props[prop], ''); 1085 } 1086 } 1087 1088 return this; 1089 }; 1090 1091 /** 1092 * Re-select element via `selector`, replacing 1093 * the current element. 1094 * 1095 * @param {String} selector 1096 * @return {Move} for chaining 1097 * @api public 1098 */ 1099 1100 Move.prototype.move = 1101 Move.prototype.select = function (selector) { 1102 this.el = move.select(selector); 1103 return this; 1104 }; 1105 1106 /** 1107 * Defer the given `fn` until the animation 1108 * is complete. `fn` may be one of the following: 1109 * 1110 * - a function to invoke 1111 * - an instanceof `Move` to call `.end()` 1112 * - nothing, to return a clone of this `Move` instance for chaining 1113 * 1114 * @param {Function|Move} fn 1115 * @return {Move} for chaining 1116 * @api public 1117 */ 1118 1119 Move.prototype.then = function (fn) { 1120 // invoke .end() 1121 if (fn instanceof Move) { 1122 this.on('end', function () { 1123 fn.end(); 1124 }); 1125 // callback 1126 } else if ('function' == typeof fn) { 1127 this.on('end', fn); 1128 // chain 1129 } else { 1130 let clone = new Move(this.el); 1131 clone._transforms = this._transforms.slice(0); 1132 this.then(clone); 1133 clone.parent = this; 1134 return clone; 1135 } 1136 1137 return this; 1138 }; 1139 1140 /** 1141 * Pop the move context. 1142 * 1143 * @return {Move} parent Move 1144 * @api public 1145 */ 1146 1147 Move.prototype.pop = function () { 1148 return this.parent; 1149 }; 1150 1151 /** 1152 * Start animation, optionally calling `fn` when complete. 1153 * 1154 * @return {Move} for chaining 1155 * @api public 1156 */ 1157 1158 Move.prototype.end = function () { 1159 let self = this; 1160 1161 // emit "start" event
1162 this.emit('start'); 1163 1164 // transforms 1165 if (this._transforms.length) { 1166 this.setVendorProperty('transform', this._transforms.join(' ')); 1167 } 1168 1169 // transition properties 1170 this.setVendorProperty('transition-properties', this._transitionProps.join(', ')); 1171 this.applyProperties(); 1172 1173 // callback given 1174 let fn; 1175 if (fn) this.then(fn); 1176 1177 // emit "end" when complete 1178 setTimeout(function () { 1179 self.emit('end'); 1180 }, this._duration); 1181 1182 return this; 1183 }; 1184 1185})(this); 1186(function(moduleName, window, document) { 1187 var from = function(selector, selectedPlugins) { 1188 1189 var parent = document.querySelector(selector), 1190 slides = [].slice.call(parent.children, 0), 1191 activeSlide = slides[0], 1192 deckListeners = {}, 1193 relnum = 0, 1194 1195 1196 activate = function(index, customData) { 1197 if (!slides[index]) { 1198 return; 1199 } 1200 1201 fire(deckListeners, 'deactivate', createEventData(activeSlide, customData)); 1202 1203 activeSlide = slides[index]; 1204 1205 1206 slides.map(deactivate); 1207 1208 fire(deckListeners, 'activate', createEventData(activeSlide, customData)); 1209 addClass(activeSlide, 'active'); 1210 removeClass(activeSlide, 'inactive'); 1211 }, 1212 1213 deactivate = function(slide, index) { 1214 let offset = index - slides.indexOf(activeSlide), 1215 offsetClass = offset > 0 ? 'after' : 'before'; 1216 1217 ['before(-\\d+)?', 'after(-\\d+)?', 'active', 'inactive'].map(removeClass.bind(null, slide)); 1218 slide !== activeSlide && 1219 ['inactive', offsetClass, offsetClass + '-' + Math.abs(offset)].map(addClass.bind(null, slide)); 1220 1221 }, 1222 1223 slide = function(index, customData) { 1224 fire(deckListeners, 'slide', createEventData(slides[index], customData)) && activate(index, customData); 1225 }, 1226 1227 next = function(customData) { 1228 let nextSlideIndex = slides.indexOf(activeSlide) + 1; 1229 1230 if (nextSlideIndex === slides.length) { 1231 nextSlideIndex=0; 1232 } 1233 1234 fire( 1235 deckListeners, 'next', 1236 createEventData(activeSlide, customData)) && activate(nextSlideIndex, customData); 1237 }, 1238 1239 prev = function(customData) { 1240 var prevSlideIndex = slides.indexOf(activeSlide) - 1; 1241 1242 1243 fire(deckListeners, 'prev', createEventData(activeSlide, customData)) && activate(prevSlideIndex, customData); 1244 }, 1245 1246 createEventData = function(slide, eventData) { 1247 eventData = eventData || {}; 1248 eventData.index = slides.indexOf(slide); 1249 eventData.slide = slide; 1250 return eventData; 1251 }, 1252 1253 deck = { 1254 on: on.bind(null, deckListeners), 1255 off: off.bind(null, deckListeners), 1256 fire: fire.bind(null, deckListeners), 1257 slide: slide, 1258 next: next, 1259 prev: prev, 1260 parent: parent, 1261 slides: slides 1262 }; 1263 1264 addClass(parent, 'parent'); 1265 1266 slides.map(function(slide) { 1267 1268 addClass(slide, 'slide'); 1269 $(slide).attr('rel', relnum); 1270 relnum++; 1271 }); 1272 1273 Object.keys(selectedPlugins || {}).map(function(pluginName) { 1274 var config = selectedPlugins[pluginName]; 1275 config && plugins[pluginName](deck, config === true ? {} : config); 1276 1277 }); 1278 1279 activate(0); 1280 1281 decks.push(deck); 1282 1283 return deck; 1284 }, 1285 1286 decks = [], 1287 1288 bespokeListeners = {}, 1289 1290 on = function(listeners, eventName, callback) { 1291 (listeners[eventName] || (listeners[eventName] = [])).push(callback); 1292 }, 1293 1294 off = function(listeners, eventName, callback) { 1295 listeners[eventName] = (listeners[eventName] || []).filter(function(listener) { 1296 return listener !== callback; 1297 }); 1298 }, 1299 1300 fire = function(listeners, eventName, eventData) { 1301 return (listeners[eventName] || []) 1302 .concat((listeners !== bespokeListeners && bespokeListeners[eventName]) || []) 1303 .reduce(function(notCancelled, callback) { 1304 return notCancelled && callback(eventData) !== false; 1305 }, true); 1306 }, 1307 1308 addClass = function(el, cls) { 1309 el.classList.add(moduleName + '-' + cls); 1310 }, 1311 1312 removeClass = function(el, cls) { 1313 el.className = el.className 1314 .replace(new RegExp(moduleName + '-' + cls +'(\\s|$)', 'g'), ' ') 1315 .replace(/^\s+|\s+$/g, ''); 1316 }, 1317 1318 callOnAllInstances = function(method) { 1319 return function(arg) { 1320 decks.map(function(deck) { 1321 deck[method].call(null, arg); 1322 }); 1323 }; 1324 }, 1325 1326 bindPlugin = function(pluginName) { 1327 return { 1328 from: function(selector, selectedPlugins) { 1329 (selectedPlugins = selectedPlugins || {})[pluginName] = true; 1330 return from(selector, selectedPlugins); 1331 } 1332 }; 1333 }, 1334 1335 makePluginForAxis = function(axis) { 1336 return function(deck) { 1337 var startPosition, 1338 delta; 1339 1340 document.addEventListener('keydown', function(e) { 1341 var key = e.which; 1342 1343 if (axis === 'X') { 1344 key === 37 && deck.prev(); 1345 (key === 32 || key === 39) && deck.next(); 1346 } else { 1347 key === 38 && deck.prev(); 1348 (key === 32 || key === 40) && deck.next(); 1349 } 1350 }); 1351 1352 deck.parent.addEventListener('touchstart', function(e) { 1353 if (e.touches.length) { 1354 startPosition = e.touches[0]['page' + axis]; 1355 delta = 0; 1356 } 1357 }); 1358 1359 deck.parent.addEventListener('touchmove', function(e) { 1360 if (e.touches.length) { 1361 e.preventDefault(); 1362 delta = e.touches[0]['page' + axis] - startPosition; 1363 } 1364 }); 1365 1366 deck.parent.addEventListener('touchend', function() { 1367 Math.abs(delta) > 50 && (delta > 0 ? deck.prev() : deck.next()); 1368 }); 1369 }; 1370 }, 1371 1372 plugins = { 1373 horizontal: makePluginForAxis('X'), 1374 vertical: makePluginForAxis('Y') 1375 }; 1376 1377 window[moduleName] = { 1378 from: from, 1379 slide: callOnAllInstances('slide'), 1380 next: callOnAllInstances('next'), 1381 prev: callOnAllInstances('prev'), 1382 horizontal: bindPlugin('horizontal'), 1383 vertical: bindPlugin('vertical'), 1384 on: on.bind(null, bespokeListeners), 1385 off: off.bind(null, bespokeListeners), 1386 plugins: plugins 1387 }; 1388 1389}('bespoke', this, document));
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.