1/* 2 Slidertron 1.3.1: A flexible slider plugin for jQuery 3 By n33 | http://n33.co | @n33co 4 Dual licensed under the MIT or GPLv2 license. 5 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 6 MIT LICENSE: 7 Copyright (c) 2012 n33, http://n33.co 8 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation 9 files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, 10 copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 11 Software is furnished to do so, subject to the following conditions: 12 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 14 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 15 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 16 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 18 GPLv2 LICENSE: 19 Copyright (c) 2012 n33, http://n33.co 20 This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 21 published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This program is 22 distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 23 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of 24 the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. 25 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26*/ 27 28(function(jQuery) { 29 30 jQuery.fn.disableSelection_slidertron = function() { return jQuery(this).css('user-select', 'none').css('-khtml-user-select', 'none').css('-moz-user-select', 'none').css('-o-user-select', 'none').css('-webkit-user-select', 'none'); } 31 32 jQuery.fn.slidertron = function(options) { 33 34 var settings = jQuery.extend({ 35 selectorParent: jQuery(this) 36 }, options); 37 38 return jQuery.slidertron(settings); 39 } 40 41 jQuery.slidertron = function(options) { 42 43 // Settings 44 45 var settings = jQuery.extend({ 46 47 selectorParent: null, // If a jQuery object, all selectors will be restricted to its scope. Otherwise, all selectors will be global. 48 49 // Selectors 50 51 viewerSelector: null, // Viewer selector 52 reelSelector: null, // Reel selector 53 slidesSelector: null, // Slides selector 54 indicatorSelector: null, // Indicator selector 55 jumpLinksSelector: null, // Jump links selector 56 navNextSelector: null, // 'Next' selector 57 navPreviousSelector: null, // 'Previous' selector 58 navFirstSelector: null, // 'First' selector 59 navLastSelector: null, // 'Last' selector 60 navStopAdvanceSelector: null, // 'Stop Advance' selector 61 navPlayAdvanceSelector: null, // 'Play Advance' selector 62 captionLineSelector: null, // 'Caption Line' selector 63 slideLinkSelector: null, // 'Slide Link' selector 64 slideCaptionSelector: null, // 'Slide Caption' selector 65 66 // General settings 67 68 mode: 'slide', // Slider mode ('slide', 'fade', 'fadeIn') 69 speed: 'fast', // Transition speed (0 for instant, 'slow', 'fast', or a custom duration in ms) 70 fadeInSpeed: 'slow', // Speed at which to fade in the reel on page load (0 for instant, 'slow', 'fast', or a custom duration in ms) 71 navWrap: true, // Wrap navigation when we navigate past the first or last slide 72 seamlessWrap: true, // Seamlessly wrap slides 73 advanceDelay: 0, // Time to wait (in ms) before automatically advancing to the next slide (0 disables advancement entirely) 74 advanceWait: 0, // Time to wait before starting automatic advancement 75 advanceNavActiveClass: 'active', // Class applied to active stop/play navigation control 76 advanceDirection: 'forward', // Direction to advance ('forward', 'backward', 'random') 77 viewerOffset: false, // Viewer offset amount (+ = shift right, - = shift left, 0 = do nothing, false = disable) 78 activeSlideClass: 'active', // Class applied to the active slide 79 disabledNavClass: 'disabled', // Class applied to disabled navigation controls 80 clickToNav: false, // Navigate to a slide when clicked (used in conjunction with viewerOffset)
81 captionLines: 0, // Number of caption lines. If this is > 1, the plugin will look for additional caption elements using the captionSelector setting + a number (eg. '.caption2', '.caption3', etc.) 82 autoHideNav: false, // Automatically hides the navigation buttons if they're not needed 83 autoFit: false, // Automatically sets the width and height of the slider based on available space (requires autoFitAspectRatio) 84 autoFitAspectRatio: 0.5, // Used by autoFit to determine the slider's dimensions (value is width / height) 85 initialSlide: 1, // Initial slide (a number or 'random' for a random slide) 86 hashJump: false, // If true, slider will start at the slide pointed to by the ID given by the URL hashmark (eg. #something) 87 hashJumpStopAdvance: true, // If true (and hashJump is enabled), slider will begin in a stopped state when a hashmark is detected 88 activeJumpLinkClass: 'active', // Class applied to the active jump link 89 arrowsToNav: false, // If true, the left/right arrow keys will be used for navigation 90 blurOnChange: false, // If true, defocuses any input elements on slide change 91 navSize: 1, // ... 92 93 // Callbacks 94 95 onSlideSwitch: false 96 97 }, options); 98 99 // Variables 100 101 // Operational stuff 102 103 var isConfigured = true, 104 isLocked = false, 105 isAdvancing = false, 106 isSeamless = false, 107 list = new Array(), 108 currentIndex = false, 109 timeoutID, 110 pFirst, 111 pLast; 112 113 var _isTouch = !!('ontouchstart' in window), _eventType = (_isTouch ? 'touchend' : 'click'); 114 115 // jQuery objects 116 117 var __slides, 118 __viewer, 119 __reel, 120 __indicator, 121 __navFirst, 122 __navLast, 123 __navNext, 124 __navPrevious, 125 __navStopAdvance, 126 __navPlayAdvance, 127 __captionLines, 128 __navControls = new Array(), 129 __jumpLinks; 130 131 // Functions 132 133 function getElement(selector, required, global) 134 { 135 var x; 136 137 try 138 { 139 if (selector == null) 140 throw 'is undefined'; 141 142 if (settings.selectorParent && !global) 143 x = settings.selectorParent.find(selector); 144 else 145 x = jQuery(selector); 146 147 if (x.length == 0) 148 throw 'does not exist'; 149 150 x.disableSelection_slidertron(); 151 152 return x; 153 } 154 catch (error) 155 { 156 if (required == true) 157 { 158 alert('Error: Required selector "' + selector + '" ' + error + '.'); 159 isConfigured = false; 160 } 161 } 162 163 return null; 164 } 165 166 function advance() 167 { 168 if (settings.advanceDelay == 0) 169 return; 170 171 if (!isLocked) 172 { 173 switch (settings.advanceDirection) 174 { 175 case 'random': 176 177 var x = __slides.length - 1, y; 178 179 if (settings.seamlessWrap && settings.mode == 'slide') 180 x -= 3; 181 182 if (x < 2) 183 break; 184 185 while ( (y = Math.ceil(Math.random() * x)) == currentIndex ) { } 186 187 switchSlide(y); 188 189 break; 190 191 case 'backward': 192 previousSlide(); 193 break; 194 195 case 'forward': 196 default: 197 nextSlide(); 198 break; 199 } 200 } 201 202 timeoutID = window.setTimeout(advance, settings.advanceDelay); 203 } 204 205 function initializeAdvance() 206 { 207 if (settings.advanceDelay == 0) 208 return; 209 210 if (__navStopAdvance) 211 __navStopAdvance.addClass(settings.advanceNavActiveClass); 212 213 if (__navPlayAdvance) 214 __navPlayAdvance.removeClass(settings.advanceNavActiveClass); 215 216 isAdvancing = true; 217 timeoutID = window.setTimeout(advance, settings.advanceDelay); 218 } 219 220 function interruptAdvance() 221 { 222 stopAdvance(); 223 } 224 225 function stopAdvance() 226 { 227 if (settings.advanceDelay == 0) 228 return; 229 230 if (!isAdvancing) 231 return; 232 233 if (__navStopAdvance && __navPlayAdvance) 234 { 235 __navStopAdvance.removeClass(settings.advanceNavActiveClass); 236 __navPlayAdvance.addClass(settings.advanceNavActiveClass); 237 } 238 239 isAdvancing = false; 240 window.clearTimeout(timeoutID); 241 } 242 243 function playAdvance(skip) 244 { 245 if (settings.advanceDelay == 0) 246 return; 247 248 if (isAdvancing) 249 return; 250 251 isAdvancing = true; 252 253 if (__navStopAdvance && __navPlayAdvance) 254 { 255 __navPlayAdvance.removeClass(settings.advanceNavActiveClass); 256 __navStopAdvance.addClass(settings.advanceNavActiveClass); 257 } 258 259 if (skip) 260 timeoutID = window.setTimeout(advance, settings.advanceDelay); 261 else 262 advance(); 263 } 264 265 function getSlideById(id) 266 { 267 var x; 268 269 for (x in list) 270 { 271 if (list[x].id == id) 272 return x; 273 } 274 275 return false;
276 } 277 278 function firstSlide() 279 { 280 switchSlide(pFirst); 281 } 282 283 function lastSlide() 284 { 285 switchSlide(pLast); 286 } 287 288 function nextSlide() 289 { 290 var x = false; 291 292 if ((isSeamless && currentIndex <= pLast) 293 || (!isSeamless && currentIndex < pLast)) 294 x = parseInt(currentIndex) + settings.navSize; 295 else if (settings.navWrap || isAdvancing) 296 x = pFirst; 297 298 if (x !== false) 299 switchSlide(x); 300 } 301 302 function previousSlide() 303 { 304 var x = false; 305 306 if ((isSeamless && currentIndex >= pFirst) 307 || (!isSeamless && currentIndex > pFirst)) 308 x = parseInt(currentIndex) - settings.navSize; 309 else if (settings.navWrap) 310 x = pLast; 311 312 if (x !== false) 313 switchSlide(x); 314 } 315 316 function updateJumpLink(index) 317 { 318 if (!__jumpLinks 319 || !list[index].jumpLink) 320 return; 321 322 __jumpLinks.removeClass(settings.activeJumpLinkClass); 323 list[index].jumpLink.addClass(settings.activeJumpLinkClass); 324 } 325 326 function updateURL() 327 { 328 if (!settings.hashJump 329 || !list[currentIndex].id) 330 return; 331 332 if (currentIndex != pFirst) 333 window.location.replace('#' + list[currentIndex].id); 334 else 335 window.location.replace('#'); 336 } 337 338 function updateNavControls() 339 { 340 if (settings.disabledNavClass === false 341 || settings.navWrap === true) 342 return; 343 344 for (x in __navControls) 345 if (__navControls[x]) 346 __navControls[x].removeClass(settings.disabledNavClass).css('cursor', 'pointer'); 347 348 var tmp = new Array(); 349 350 if (currentIndex == pFirst) 351 { 352 tmp.push(__navFirst); 353 tmp.push(__navPrevious); 354 } 355 356 if (currentIndex == pLast) 357 { 358 tmp.push(__navLast); 359 tmp.push(__navNext); 360 } 361 362 for (x in tmp) 363 if (tmp[x]) 364 tmp[x].addClass(settings.disabledNavClass).css('cursor', 'default'); 365 } 366 367 function switchSlide(index) 368 { 369 var x; 370 371 if (isLocked || currentIndex === index) 372 return false; 373 374 if (__jumpLinks) 375 __jumpLinks.removeClass(settings.activeJumpLinkClass); 376 377 if (settings.blurOnChange) 378 jQuery('input, textarea, select').blur(); 379 380 isLocked = true; 381 382 if (currentIndex === false) 383 { 384 currentIndex = index; 385 __reel.css('left', -1 * list[currentIndex].x); 386 isLocked = false; 387 388 // Indicator 389 if (__indicator) 390 { 391 __indicator.removeClass('active'); 392 jQuery(__indicator.get(currentIndex - pFirst)).addClass('active'); 393 } 394 395 // Active slide 396 if (settings.activeSlideClass) 397 list[currentIndex].object 398 .addClass(settings.activeSlideClass) 399 400 // Link 401 if (settings.clickToNav && !list[currentIndex].link) 402 list[currentIndex].object 403 .css('cursor', 'default'); 404 405 // Captions 406 if (__captionLines) 407 { 408 if (list[currentIndex].captions) 409 for (x in __captionLines) 410 __captionLines[x].html(list[currentIndex].captions[x]); 411 else 412 for (x in __captionLines) 413 __captionLines[x].html(''); 414 } 415 416 // Nav controls 417 updateNavControls(); 418 419 // Update jump link 420 updateJumpLink(currentIndex); 421 422 // Callback 423 if (settings.onSlideSwitch) 424 { 425 window.setTimeout(function() { 426 (settings.onSlideSwitch(list[currentIndex].object)); 427 }, 500); 428 } 429 } 430 else 431 { 432 var diff, currentX, newX, realIndex; 433 434 if (settings.activeSlideClass) 435 list[currentIndex].object 436 .removeClass(settings.activeSlideClass); 437 438 if (settings.clickToNav) 439 list[currentIndex].object 440 .css('cursor', 'pointer'); 441 442 currentX = list[currentIndex].x; 443 444 newX = list[index].x; 445 diff = currentX - newX; 446 447 // Get real index 448 if (list[index].realIndex !== false) 449 realIndex = list[index].realIndex; 450 else 451 realIndex = index; 452 453 // Indicator 454 if (__indicator) 455 { 456 __indicator.removeClass('active'); 457 jQuery(__indicator.get(realIndex - pFirst)).addClass('active'); 458 } 459 460 // Captions 461 if (__captionLines) 462 {
463 if (list[realIndex].captions) 464 for (x in __captionLines) 465 __captionLines[x].html(list[realIndex].captions[x]); 466 else 467 for (x in __captionLines) 468 __captionLines[x].html(''); 469 } 470 471 // Update jump link 472 updateJumpLink(realIndex); 473 474 // Transition 475 switch (settings.mode) 476 { 477 case 'fadeIn': 478 // Clone active slide 479 x = list[currentIndex].object.clone(); 480 x 481 .appendTo(__viewer) 482 .css('left', 0) 483 .css('top', 0); 484 485 // Switch slide 486 currentIndex = index; 487 __reel.css('left', -1 * list[currentIndex].x); 488 489 // Get real index and adjust reel position 490 if (list[currentIndex].realIndex !== false) 491 { 492 currentIndex = list[currentIndex].realIndex; 493 __reel.css('left', -1 * list[currentIndex].x); 494 } 495 496 // Active slide 497 if (settings.activeSlideClass) 498 list[currentIndex].object 499 .addClass(settings.activeSlideClass); 500 501 // Link 502 if (settings.clickToNav && !list[currentIndex].link) 503 list[currentIndex].object 504 .css('cursor', 'default'); 505 506 // Nav controls 507 updateNavControls(); 508 509 // Update URL 510 updateURL(); 511 512 // Callback 513 if (settings.onSlideSwitch) 514 (settings.onSlideSwitch(list[currentIndex].object)); 515 516 // Fade out and remove itcloned slide 517 x.fadeOut(settings.speed, function() { 518 isLocked = false; 519 x.remove(); 520 }); 521 522 break; 523 524 case 'fade': 525 __reel.fadeTo(settings.speed, 0.001, function() { 526 currentIndex = index; 527 __reel.css('left', -1 * list[currentIndex].x); 528 529 // Get real index and adjust reel position 530 if (list[currentIndex].realIndex !== false) 531 { 532 currentIndex = list[currentIndex].realIndex; 533 __reel.css('left', -1 * list[currentIndex].x); 534 } 535 536 __reel.fadeTo(settings.speed, 1, function() { 537 // Active slide 538 if (settings.activeSlideClass) 539 list[currentIndex].object 540 .addClass(settings.activeSlideClass); 541 542 // Link 543 if (settings.clickToNav && !list[currentIndex].link) 544 list[currentIndex].object 545 .css('cursor', 'default'); 546 547 // Nav controls 548 updateNavControls(); 549 550 // Update URL 551 updateURL(); 552 553 // Callback 554 if (settings.onSlideSwitch) 555 (settings.onSlideSwitch(list[currentIndex].object)); 556 557 isLocked = false; 558 }); 559 }); 560 break; 561 562 case 'slide': 563 default: 564 565 __reel.animate({ left: '+=' + diff }, settings.speed, 'swing', function() { 566 currentIndex = index; 567 568 // Get real index and adjust reel position 569 if (list[currentIndex].realIndex !== false) 570 { 571 currentIndex = list[currentIndex].realIndex; 572 __reel.css('left', -1 * list[currentIndex].x); 573 } 574 575 // Active slide 576 if (settings.activeSlideClass) 577 list[currentIndex].object 578 .addClass(settings.activeSlideClass); 579 580 // Link 581 if (settings.clickToNav && !list[currentIndex].link) 582 list[currentIndex].object 583 .css('cursor', 'default'); 584 585 // Nav controls 586 updateNavControls(); 587 588 // Update URL 589 updateURL(); 590 591 // Callback 592 if (settings.onSlideSwitch) 593 (settings.onSlideSwitch(list[currentIndex].object)); 594 595 isLocked = false; 596 }); 597 598 break; 599 } 600 } 601 } 602 603 function initialize() 604 { 605 var tmp, a, s; 606 607 list = new Array(); 608 609 // Slides, viewer, reel, indicator 610 __viewer = getElement(settings.viewerSelector, true); 611 __reel = getElement(settings.reelSelector, true); 612 __slides = getElement(settings.slidesSelector, true); 613 __indicator = getElement(settings.indicatorSelector, false); 614 __jumpLinks = getElement(settings.jumpLinksSelector, false, true); 615 616 if (settings.autoFit) 617 { 618 __viewer.height(Math.floor(__viewer.width() / settings.autoFitAspectRatio)); 619 620 __slides 621 .width(__viewer.width()) 622 .height(__viewer.height()); 623 } 624 625 // Caption lines 626 a = new Array(); 627 628 for (i = 1;
628 i <= settings.captionLines; i++) 629 { 630 s = settings.captionLineSelector; 631 632 if (settings.captionLines > 1) 633 s = s + i; 634 635 tmp = getElement(s, false); 636 637 if (tmp == null) 638 { 639 a = null; 640 break; 641 } 642 643 a.push(tmp); 644 } 645 646 __captionLines = a; 647 648 // Navigation 649 __navFirst = getElement(settings.navFirstSelector); 650 __navLast = getElement(settings.navLastSelector); 651 __navNext = getElement(settings.navNextSelector); 652 __navPrevious = getElement(settings.navPreviousSelector); 653 __navStopAdvance = getElement(settings.navStopAdvanceSelector); 654 __navPlayAdvance = getElement(settings.navPlayAdvanceSelector); 655 656 if (__navFirst) __navControls.push(__navFirst); 657 if (__navLast) __navControls.push(__navLast); 658 if (__navNext) __navControls.push(__navNext); 659 if (__navPrevious) __navControls.push(__navPrevious); 660 661 if (settings.autoHideNav 662 && __slides.length < 2) 663 { 664 for (x in __navControls) 665 __navControls[x].remove(); 666 } 667 668 // Check configuration status 669 670 // ClickToNav only works when viewerOffset != false 671 if (settings.viewerOffset === false 672 && settings.clickToNav) 673 { 674 alert('Error: clickToNav only works when viewerOffset is in use.'); 675 return false; 676 } 677 678 // When using the indicator, it must have as many items as there are slides 679 if (__indicator) 680 { 681 if (__indicator.length != __slides.length) 682 { 683 alert('Error: Indicator needs to have as many items as there are slides.'); 684 return false; 685 } 686 } 687 688 // Final check 689 if (isConfigured == false) 690 { 691 alert('Error: One or more configuration errors detected. Aborting.'); 692 return false; 693 } 694 695 if (settings.viewerOffset == false) 696 settings.viewerOffset = 0; 697 698 if (settings.initialSlide == 'random') 699 settings.initialSlide = Math.ceil(Math.random() * __slides.length); 700 else if (isNaN(parseInt(settings.initialSlide)) == true || settings.initialSlide < 1 || settings.initialSlide > __slides.length) 701 settings.initialSlide = 1; 702 703 // Set up 704 705 // Viewer 706 __viewer.css('position', 'relative'); 707 __viewer.css('overflow', 'hidden'); 708 709 // Reel 710 __reel.css('position', 'absolute'); 711 __reel.css('left', 0); 712 __reel.css('top', 0); 713 __reel.hide(); 714 715 // Slides 716 var cx = 0, length = __slides.length; 717 718 if (settings.seamlessWrap && settings.mode == 'slide') 719 { 720 isSeamless = true; 721 722 var L1 = __slides.eq(0); 723 var L2 = __slides.eq(Math.min(length - 1, 1)); 724 var R2 = __slides.eq(Math.max(length - 2, 0)); 725 var R1 = __slides.eq(Math.max(length - 1, 0)); 726 727 var realFirst = L1; 728 var realLast = R1; 729 730 var CL1 = L1.clone(), 731 CL2 = L2.clone(), 732 CR1 = R1.clone(), 733 CR2 = R2.clone(); 734 735 CL1.attr('id', ''); 736 CL2.attr('id', ''); 737 CR1.attr('id', ''); 738 CR2.attr('id', ''); 739 740 CR2.insertBefore(realFirst); 741 CR1.insertBefore(realFirst); 742 CL2.insertAfter(realLast); 743 CL1.insertAfter(realLast); 744 745 __slides = getElement(settings.slidesSelector, true); 746 747 pFirst = 2; 748 pLast = __slides.length - 3; 749 } 750 else 751 { 752 pFirst = 0; 753 pLast = length - 1; 754 } 755 756 __slides.each(function(index) { 757 758 var y = jQuery(this), link = false, captions = new Array(); 759 var l, i, tmp, s, id, p; 760 761 // click to nav? 762 if (settings.clickToNav) 763 { 764 y 765 .css('cursor', 'pointer') 766 .click(function(e) { 767 if (currentIndex != index) 768 { 769 e.stopPropagation(); 770 771 if (isAdvancing) 772 interruptAdvance(); 773 774 switchSlide(index); 775 } 776 }); 777 } 778 779 // Link? 780 var l = y.find(settings.slideLinkSelector); 781 782 if (l.length > 0) 783 { 784 link = l.attr('href'); 785 l.remove(); 786 y 787 .css('cursor', 'pointer') 788 .click(function(e) { 789 if (currentIndex == index) 790 window.location = link; 791 }); 792 } 793 794 // Caption(s)? 795 for (i = 1;
795 i <= settings.captionLines; i++) 796 { 797 s = settings.slideCaptionSelector; 798 799 if (settings.captionLines > 1) 800 s = s + i; 801 802 tmp = y.find(s); 803 804 if (tmp.length > 0) 805 { 806 captions.push(tmp.html()); 807 tmp.remove(); 808 } 809 } 810 811 if (captions.length != settings.captionLines) 812 captions = false; 813 814 // id 815 id = y.attr('id'); 816 817 if (!id) 818 id = null; 819 820 y.attr('id', ''); 821 822 list[index] = { 823 object: y, 824 x: cx - settings.viewerOffset, 825 realIndex: false, 826 link: link, 827 captions: captions, 828 id: id, 829 jumpLink: false 830 }; 831 832 y.css('position', 'absolute'); 833 y.css('left', cx); 834 y.css('top', 0); 835 836 cx += y.width(); 837 }); 838 839 if (isSeamless) 840 { 841 list[pFirst - 1].realIndex = pLast; 842 list[pLast + 1].realIndex = pFirst; 843 } 844 845 // Indicator 846 if (__indicator) 847 { 848 __indicator.each(function() { 849 var t = jQuery(this); 850 851 t 852 .css('cursor', 'pointer') 853 .bind(_eventType, function(event) { 854 event.preventDefault(); 855 856 if (isLocked) 857 return false; 858 859 if (isAdvancing) 860 interruptAdvance(); 861 862 switchSlide(t.index() + pFirst); 863 }); 864 865 if (_eventType != 'click') 866 t.click(function(e) { e.preventDefault(); }); 867 }); 868 } 869 870 // Jump links 871 if (__jumpLinks) 872 { 873 __jumpLinks.each(function() { 874 var i, t = jQuery(this), slideId = t.attr('href').split('#')[1]; 875 876 if ((i = getSlideById(slideId)) !== false) 877 { 878 list[i].jumpLink = t; 879 880 t.click(function(e) { 881 e.preventDefault(); 882 883 if (isAdvancing) 884 interruptAdvance(); 885 886 switchSlide(i); 887 }); 888 } 889 else 890 t.click(function(e) { 891 e.preventDefault(); 892 }); 893 }); 894 } 895 896 // Navigation 897 if (__navFirst) 898 { 899 __navFirst.bind(_eventType, function(event) { 900 event.preventDefault(); 901 902 if (isLocked) 903 return false; 904 905 if (isAdvancing) 906 interruptAdvance(); 907 908 firstSlide(); 909 }); 910 911 if (_eventType != 'click') 912 __navFirst.click(function(e) { e.preventDefault(); }); 913 } 914 915 if (__navLast) 916 { 917 __navLast.bind(_eventType, function(event) { 918 event.preventDefault(); 919 920 if (isLocked) 921 return false; 922 923 if (isAdvancing) 924 interruptAdvance(); 925 926 lastSlide(); 927 }); 928 929 if (_eventType != 'click') 930 __navLast.click(function(e) { e.preventDefault(); }); 931 } 932 933 if (__navNext) 934 { 935 __navNext.bind(_eventType, function(event) { 936 event.preventDefault(); 937 938 if (isLocked) 939 return false; 940 941 if (isAdvancing) 942 interruptAdvance(); 943 944 nextSlide(); 945 }); 946 947 if (_eventType != 'click') 948 __navNext.click(function(e) { e.preventDefault(); }); 949 } 950 951 if (__navPrevious) 952 { 953 __navPrevious.bind(_eventType, function(event) { 954 event.preventDefault(); 955 956 if (isLocked) 957 return false; 958 959 if (isAdvancing) 960 interruptAdvance(); 961 962 previousSlide(); 963 }); 964 965 if (_eventType != 'click') 966 __navPrevious.click(function(e) { e.preventDefault(); }); 967 } 968 969 if (__navStopAdvance) 970 { 971 __navStopAdvance.bind(_eventType, function(event) { 972 event.preventDefault(); 973 974 if (isLocked) 975 return false; 976 977 if (!isAdvancing) 978 return false; 979 980 stopAdvance(); 981 }); 982 983 if (_eventType != 'click') 984 __navStopAdvance.click(function(e) { e.preventDefault(); }); 985 } 986 987 if (__navPlayAdvance) 988 { 989 __navPlayAdvance.bind(_eventType, function(event) { 990 event.preventDefault(); 991 992 if (isLocked) 993 return false; 994 995 if (isAdvancing) 996 return false;
997 998 playAdvance(); 999 }); 1000 1001 if (_eventType != 'click') 1002 __navPlayAdvance.click(function(e) { e.preventDefault(); }); 1003 } 1004 1005 // Arrow navigation 1006 1007 if (settings.arrowsToNav) 1008 { 1009 jQuery(document).keydown(function(e) { 1010 switch (e.keyCode) 1011 { 1012 case 37: 1013 if (isLocked) 1014 return false; 1015 1016 if (isAdvancing) 1017 interruptAdvance(); 1018 1019 previousSlide(); 1020 1021 break; 1022 1023 case 39: 1024 if (isLocked) 1025 return false; 1026 1027 if (isAdvancing) 1028 interruptAdvance(); 1029 1030 nextSlide(); 1031 1032 break; 1033 1034 default: 1035 break; 1036 } 1037 }); 1038 } 1039 1040 __reel.fadeIn(settings.fadeInSpeed); 1041 1042 return true; 1043 } 1044 1045 // Bind events 1046 var o = (settings.selectorParent ? settings.selectorParent : settings.viewerSelector); 1047 1048 if (o) 1049 { 1050 o 1051 .bind('previousSlide', function() { if (isAdvancing) interruptAdvance(); previousSlide(); }) 1052 .bind('nextSlide', function() { if (isAdvancing) interruptAdvance(); nextSlide(); }) 1053 .bind('firstSlide', function() { if (isAdvancing) interruptAdvance(); firstSlide(); }) 1054 .bind('lastSlide', function() { if (isAdvancing) interruptAdvance(); lastSlide(); }) 1055 .bind('slidertron_onSwitchSlide', function() { 1056 }) 1057 .bind('slidertron_reFit', function() { 1058 var cx = 0; 1059 1060 if (isAdvancing) 1061 interruptAdvance(); 1062 1063 window.setTimeout(function() { 1064 for (x in list) 1065 { 1066 list[x].object.width(__viewer.width()); 1067 list[x].x = cx - settings.viewerOffset; 1068 list[x].object.css('left', cx); 1069 cx += list[x].object.width(); 1070 } 1071 __reel.css('left', -1 * list[currentIndex].x); 1072 __viewer.height(Math.floor(__viewer.width() / settings.autoFitAspectRatio)); 1073 }, 100); 1074 }) 1075 .bind('slidertron_stopAdvance', function() { 1076 if (isAdvancing) 1077 stopAdvance(); 1078 }); 1079 } 1080 1081 // Ready 1082 jQuery().ready(function() { 1083 var id = window.location.hash.split('#')[1], x, y = true; 1084 if (id) 1085 window.location.hash = ''; 1086 1087 if (initialize()) 1088 { 1089 if (settings.hashJump && id && (x = getSlideById(id)) !== false) 1090 { 1091 setTimeout(function() { window.scrollTo(0,0); }, 0); 1092 switchSlide(x); 1093 if (x != pFirst) 1094 window.location.hash = '#' + id; 1095 if (settings.hashJumpStopAdvance) 1096 y = false; 1097 } 1098 else 1099 { 1100 if (settings.seamlessWrap) 1101 switchSlide(settings.initialSlide + 1); 1102 else 1103 switchSlide(settings.initialSlide - 1); 1104 } 1105 1106 if (y) 1107 timeoutID = window.setTimeout(function() { 1108 initializeAdvance(); 1109 }, settings.advanceWait); 1110 } 1111 }); 1112 }; 1113 1114})(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.