1/** 2 * BxSlider v4.1 - Fully loaded, responsive content slider 3 * http://bxslider.com 4 * 5 * Copyright 2012, Steven Wanderski - http://stevenwanderski.com - http://bxcreative.com 6 * Written while drinking Belgian ales and listening to jazz 7 * 8 * Released under the WTFPL license - http://sam.zoy.org/wtfpl/ 9 */ 10 11;(function($){ 12 13 var plugin = {}; 14 15 var defaults = { 16 17 // GENERAL 18 mode: 'horizontal', 19 slideSelector: '', 20 infiniteLoop: true, 21 hideControlOnEnd: false, 22 speed: 500, 23 easing: null, 24 slideMargin: 0, 25 startSlide: 0, 26 randomStart: false, 27 captions: false, 28 ticker: false, 29 tickerHover: false, 30 adaptiveHeight: false, 31 adaptiveHeightSpeed: 500, 32 video: false, 33 useCSS: true, 34 preloadImages: 'visible', 35 36 // TOUCH 37 touchEnabled: true, 38 swipeThreshold: 50, 39 oneToOneTouch: true, 40 preventDefaultSwipeX: true, 41 preventDefaultSwipeY: false, 42 43 // PAGER 44 pager: true, 45 pagerType: 'full', 46 pagerShortSeparator: ' / ', 47 pagerSelector: null, 48 buildPager: null, 49 pagerCustom: null, 50 51 // CONTROLS 52 controls: true, 53 nextText: 'Next', 54 prevText: 'Prev', 55 nextSelector: null, 56 prevSelector: null, 57 autoControls: false, 58 startText: 'Start', 59 stopText: 'Stop', 60 autoControlsCombine: false, 61 autoControlsSelector: null, 62 63 // AUTO 64 auto: false, 65 pause: 4000, 66 autoStart: true, 67 autoDirection: 'next', 68 autoHover: false, 69 autoDelay: 0, 70 71 // CAROUSEL 72 minSlides: 1, 73 maxSlides: 1, 74 moveSlides: 0, 75 slideWidth: 0, 76 77 // CALLBACKS 78 onSliderLoad: function() {}, 79 onSlideBefore: function() {}, 80 onSlideAfter: function() {}, 81 onSlideNext: function() {}, 82 onSlidePrev: function() {} 83 } 84 85 $.fn.bxSlider = function(options){ 86 87 if(this.length == 0) return; 88 89 // support mutltiple elements 90 if(this.length > 1){ 91 this.each(function(){$(this).bxSlider(options)}); 92 return this; 93 } 94 95 // create a namespace to be used throughout the plugin 96 var slider = {}; 97 // set a reference to our slider element 98 var el = this; 99 plugin.el = this; 100 101 /** 102 * Makes slideshow responsive 103 */ 104 // first get the original window dimens (thanks alot IE) 105 var windowWidth = $(window).width(); 106 var windowHeight = $(window).height(); 107 108 109 110 /** 111 * =================================================================================== 112 * = PRIVATE FUNCTIONS 113 * =================================================================================== 114 */ 115 116 /** 117 * Initializes namespace settings to be used throughout plugin 118 */ 119 var init = function(){ 120 // merge user-supplied options with the defaults 121 slider.settings = $.extend({}, defaults, options); 122 // parse slideWidth setting 123 slider.settings.slideWidth = parseInt(slider.settings.slideWidth); 124 // store the original children 125 slider.children = el.children(slider.settings.slideSelector); 126 // check if actual number of slides is less than minSlides / maxSlides 127 if(slider.children.length < slider.settings.minSlides) slider.settings.minSlides = slider.children.length; 128 if(slider.children.length < slider.settings.maxSlides) slider.settings.maxSlides = slider.children.length; 129 // if random start, set the startSlide setting to random number 130 if(slider.settings.randomStart) slider.settings.startSlide = Math.floor(Math.random() * slider.children.length); 131 // store active slide information 132 slider.active = { index: slider.settings.startSlide } 133 // store if the slider is in carousel mode (displaying / moving multiple slides) 134 slider.carousel = slider.settings.minSlides > 1 || slider.settings.maxSlides > 1; 135 // if carousel, force preloadImages = 'all' 136 if(slider.carousel) slider.settings.preloadImages = 'all'; 137 // calculate the min / max width thresholds based on min / max number of slides 138 // used to setup and update carousel slides dimensions 139 slider.minThreshold = (slider.settings.minSlides * slider.settings.slideWidth) + ((slider.settings.minSlides - 1) * slider.settings.slideMargin); 140 slider.maxThreshold = (slider.settings.maxSlides * slider.settings.slideWidth) + ((slider.settings.maxSlides - 1) * slider.settings.slideMargin); 141 // store the current state of the slider (if currently animating, working is true) 142 slider.working = false; 143 // initialize the controls object 144 slider.controls = {}; 145 // initialize an auto interval 146 slider.interval = null; 147 // determine which property to use for transitions 148 slider.animProp = slider.settings.mode == 'vertical' ? 'top' : 'left'; 149 // determine if hardware acceleration can be used 150 slider.usingCSS = slider.settings.useCSS && slider.settings.mode != 'fade' && (function(){ 151 // create our test div element 152 var div = document.createElement('div'); 153 // css transition properties 154 var props = ['WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective']; 155 // test for each property 156 for(var i in props){ 157 if(div.style[props[i]] !== undefined){ 158 slider.cssPrefix = props[i].replace('Perspective', '').toLowerCase(); 159 slider.animProp = '-' + slider.cssPrefix + '-transform'; 160 return true; 161 } 162 } 163 return false; 164 }()); 165 // if vertical mode always make maxSlides and minSlides equal 166 if(slider.settings.mode == 'vertical') slider.settings.maxSlides = slider.settings.minSlides; 167 // perform all DOM / CSS modifications 168 setup(); 169 } 170 171 /** 172 * Performs all DOM and CSS modifications 173 */ 174 var setup = function(){ 175 // wrap el in a wrapper 176 el.wrap('<div class="bx-wrapper"><div class="bx-viewport"></div></div>'); 177 // store a namspace reference to .bx-viewport 178 slider.viewport = el.parent(); 179 // add a loading div to display while images are loading
180 slider.loader = $('<div class="bx-loading" />'); 181 slider.viewport.prepend(slider.loader); 182 // set el to a massive width, to hold any needed slides 183 // also strip any margin and padding from el 184 el.css({ 185 width: slider.settings.mode == 'horizontal' ? slider.children.length * 215 + '%' : 'auto', 186 position: 'relative' 187 }); 188 // if using CSS, add the easing property 189 if(slider.usingCSS && slider.settings.easing){ 190 el.css('-' + slider.cssPrefix + '-transition-timing-function', slider.settings.easing); 191 // if not using CSS and no easing value was supplied, use the default JS animation easing (swing) 192 }else if(!slider.settings.easing){ 193 slider.settings.easing = 'swing'; 194 } 195 var slidesShowing = getNumberSlidesShowing(); 196 // make modifications to the viewport (.bx-viewport) 197 slider.viewport.css({ 198 width: '100%', /*it was 100%*/ 199 overflow: 'hidden', 200 position: 'relative' 201 }); 202 slider.viewport.parent().css({ 203 maxWidth: getViewportMaxWidth() 204 }); 205 // apply css to all slider children 206 slider.children.css({ 207 'float': slider.settings.mode == 'horizontal' ? 'left' : 'none', 208 listStyle: 'none', 209 position: 'relative' 210 }); 211 // apply the calculated width after the float is applied to prevent scrollbar interference 212 slider.children.width(getSlideWidth()); 213 // if slideMargin is supplied, add the css 214 if(slider.settings.mode == 'horizontal' && slider.settings.slideMargin > 0) slider.children.css('marginRight', slider.settings.slideMargin); 215 if(slider.settings.mode == 'vertical' && slider.settings.slideMargin > 0) slider.children.css('marginBottom', slider.settings.slideMargin); 216 // if "fade" mode, add positioning and z-index CSS 217 if(slider.settings.mode == 'fade'){ 218 slider.children.css({ 219 position: 'absolute', 220 zIndex: 0, 221 display: 'none' 222 }); 223 // prepare the z-index on the showing element 224 slider.children.eq(slider.settings.startSlide).css({zIndex: 50, display: 'block'}); 225 } 226 // create an element to contain all slider controls (pager, start / stop, etc) 227 slider.controls.el = $('<div class="bx-controls" />'); 228 // if captions are requested, add them 229 if(slider.settings.captions) appendCaptions(); 230 // if infinite loop, prepare additional slides 231 if(slider.settings.infiniteLoop && slider.settings.mode != 'fade' && !slider.settings.ticker){ 232 var slice = slider.settings.mode == 'vertical' ? slider.settings.minSlides : slider.settings.maxSlides; 233 var sliceAppend = slider.children.slice(0, slice).clone().addClass('bx-clone'); 234 var slicePrepend = slider.children.slice(-slice).clone().addClass('bx-clone'); 235 el.append(sliceAppend).prepend(slicePrepend); 236 } 237 // check if startSlide is last slide 238 slider.active.last = slider.settings.startSlide == getPagerQty() - 1; 239 // if video is true, set up the fitVids plugin 240 if(slider.settings.video) el.fitVids(); 241 // set the default preload selector (visible) 242 var preloadSelector = slider.children.eq(slider.settings.startSlide); 243 if (slider.settings.preloadImages == "all") preloadSelector = el.children();
244 // only check for control addition if not in "ticker" mode 245 if(!slider.settings.ticker){ 246 // if pager is requested, add it 247 if(slider.settings.pager) appendPager(); 248 // if controls are requested, add them 249 if(slider.settings.controls) appendControls(); 250 // if auto is true, and auto controls are requested, add them 251 if(slider.settings.auto && slider.settings.autoControls) appendControlsAuto(); 252 // if any control option is requested, add the controls wrapper 253 if(slider.settings.controls || slider.settings.autoControls || slider.settings.pager) slider.viewport.after(slider.controls.el); 254 } 255 // preload all images, then perform final DOM / CSS modifications that depend on images being loaded 256 preloadSelector.imagesLoaded(start); 257 } 258 259 /** 260 * Start the slider 261 */ 262 var start = function(){ 263 // remove the loading DOM element 264 slider.loader.remove(); 265 // set the left / top position of "el" 266 setSlidePosition(); 267 // if "vertical" mode, always use adaptiveHeight to prevent odd behavior 268 if (slider.settings.mode == 'vertical') slider.settings.adaptiveHeight = true; 269 // set the viewport height 270 slider.viewport.height(getViewportHeight()); 271 // make sure everything is positioned just right (same as a window resize) 272 el.redrawSlider(); 273 // onSliderLoad callback 274 slider.settings.onSliderLoad(slider.active.index); 275 // slider has been fully initialized 276 slider.initialized = true;
277 // bind the resize call to the window 278 $(window).bind('resize', resizeWindow); 279 // if auto is true, start the show 280 if (slider.settings.auto && slider.settings.autoStart) initAuto(); 281 // if ticker is true, start the ticker 282 if (slider.settings.ticker) initTicker(); 283 // if pager is requested, make the appropriate pager link active 284 if (slider.settings.pager) updatePagerActive(slider.settings.startSlide); 285 // check for any updates to the controls (like hideControlOnEnd updates) 286 if (slider.settings.controls) updateDirectionControls(); 287 // if touchEnabled is true, setup the touch events 288 if (slider.settings.touchEnabled && !slider.settings.ticker) initTouch(); 289 } 290 291 /** 292 * Returns the calculated height of the viewport, used to determine either adaptiveHeight or the maxHeight value 293 */ 294 var getViewportHeight = function(){ 295 var height = 0; 296 // first determine which children (slides) should be used in our height calculation 297 var children = $(); 298 // if mode is not "vertical" and adaptiveHeight is false, include all children 299 if(slider.settings.mode != 'vertical' && !slider.settings.adaptiveHeight){ 300 children = slider.children; 301 }else{ 302 // if not carousel, return the single active child 303 if(!slider.carousel){ 304 children = slider.children.eq(slider.active.index); 305 // if carousel, return a slice of children 306 }else{ 307 // get the individual slide index 308 var currentIndex = slider.settings.moveSlides == 1 ? slider.active.index : slider.active.index * getMoveBy(); 309 // add the current slide to the children 310 children = slider.children.eq(currentIndex); 311 // cycle through the remaining "showing" slides 312 for (i = 1; i <= slider.settings.maxSlides - 1; i++){ 313 // if looped back to the start 314 if(currentIndex + i >= slider.children.length){ 315 children = children.add(slider.children.eq(i - 1)); 316 }else{ 317 children = children.add(slider.children.eq(currentIndex + i)); 318 } 319 } 320 } 321 } 322 // if "vertical" mode, calculate the sum of the heights of the children 323 if(slider.settings.mode == 'vertical'){ 324 children.each(function(index) { 325 height += $(this).outerHeight(); 326 }); 327 // add user-supplied margins 328 if(slider.settings.slideMargin > 0){ 329 height += slider.settings.slideMargin * (slider.settings.minSlides - 1); 330 } 331 // if not "vertical" mode, calculate the max height of the children 332 }else{ 333 height = Math.max.apply(Math, children.map(function(){ 334 return $(this).outerHeight(false); 335 }).get()); 336 } 337 return height; 338 } 339 340 /** 341 * Returns the calculated width to be used for the outer wrapper / viewport 342 */ 343 var getViewportMaxWidth = function(){ 344 var width = '100%'; /*it was 100%*/ 345 if(slider.settings.slideWidth > 0){ 346 if(slider.settings.mode == 'horizontal'){ 347 width = (slider.settings.maxSlides * slider.settings.slideWidth) + ((slider.settings.maxSlides - 1) * slider.settings.slideMargin); 348 }else{ 349 width = slider.settings.slideWidth; 350 } 351 } 352 return width; 353 } 354 355 /** 356 * Returns the calculated width to be applied to each slide 357 */ 358 var getSlideWidth = function(){ 359 // start with any user-supplied slide width 360 var newElWidth = slider.settings.slideWidth; 361 // get the current viewport width 362 var wrapWidth = slider.viewport.width(); 363 // if slide width was not supplied, or is larger than the viewport use the viewport width 364 if(slider.settings.slideWidth == 0 || 365 (slider.settings.slideWidth > wrapWidth && !slider.carousel) || 366 slider.settings.mode == 'vertical'){ 367 newElWidth = wrapWidth; 368 // if carousel, use the thresholds to determine the width 369 }else if(slider.settings.maxSlides > 1 && slider.settings.mode == 'horizontal'){ 370 if(wrapWidth > slider.maxThreshold){ 371 // newElWidth = (wrapWidth - (slider.settings.slideMargin * (slider.settings.maxSlides - 1))) / slider.settings.maxSlides; 372 }else if(wrapWidth < slider.minThreshold){ 373 newElWidth = (wrapWidth - (slider.settings.slideMargin * (slider.settings.minSlides - 1))) / slider.settings.minSlides; 374 } 375 } 376 return newElWidth; 377 } 378 379 /** 380 * Returns the number of slides currently visible in the viewport (includes partially visible slides) 381 */ 382 var getNumberSlidesShowing = function(){ 383 var slidesShowing = 1; 384 if(slider.settings.mode == 'horizontal' && slider.settings.slideWidth > 0){ 385 // if viewport is smaller than minThreshold, return minSlides 386 if(slider.viewport.width() < slider.minThreshold){ 387 slidesShowing = slider.settings.minSlides; 388 // if viewport is larger than minThreshold, return maxSlides 389 }else if(slider.viewport.width() > slider.maxThreshold){ 390 slidesShowing = slider.settings.maxSlides; 391 // if viewport is between min / max thresholds, divide viewport width by first child width 392 }else{ 393 var childWidth = slider.children.first().width(); 394 slidesShowing = Math.floor(slider.viewport.width() / childWidth); 395 } 396 // if "vertical" mode, slides showing will always be minSlides 397 }else if(slider.settings.mode == 'vertical'){ 398 slidesShowing = slider.settings.minSlides; 399 } 400 return slidesShowing; 401 } 402 403 /** 404 * Returns the number of pages (one full viewport of slides is one "page") 405 */ 406 var getPagerQty = function(){ 407 var pagerQty = 0; 408 // if moveSlides is specified by the user 409 if(slider.settings.moveSlides > 0){ 410 if(slider.settings.infiniteLoop){ 411 pagerQty = slider.children.length / getMoveBy(); 412 }else{ 413 // use a while loop to determine pages 414 var breakPoint = 0; 415 var counter = 0 416 // when breakpoint goes above children length, counter is the number of pages 417 while (breakPoint < slider.children.length){ 418 ++pagerQty; 419 breakPoint = counter + getNumberSlidesShowing(); 420 counter += slider.settings.moveSlides <= getNumberSlidesShowing() ? slider.settings.moveSlides : getNumberSlidesShowing(); 421 } 422 }
423 // if moveSlides is 0 (auto) divide children length by sides showing, then round up 424 }else{ 425 pagerQty = Math.ceil(slider.children.length / getNumberSlidesShowing()); 426 } 427 return pagerQty; 428 } 429 430 /** 431 * Returns the number of indivual slides by which to shift the slider 432 */ 433 var getMoveBy = function(){ 434 // if moveSlides was set by the user and moveSlides is less than number of slides showing 435 if(slider.settings.moveSlides > 0 && slider.settings.moveSlides <= getNumberSlidesShowing()){ 436 return slider.settings.moveSlides; 437 } 438 // if moveSlides is 0 (auto) 439 return getNumberSlidesShowing(); 440 } 441 442 /** 443 * Sets the slider's (el) left or top position 444 */ 445 var setSlidePosition = function(){ 446 // if last slide, not infinite loop, and number of children is larger than specified maxSlides 447 if(slider.children.length > slider.settings.maxSlides && slider.active.last && !slider.settings.infiniteLoop){ 448 if (slider.settings.mode == 'horizontal'){ 449 // get the last child's position 450 var lastChild = slider.children.last(); 451 var position = lastChild.position(); 452 // set the left position 453 setPositionProperty(-(position.left - (slider.viewport.width() - lastChild.width())), 'reset', 0); 454 }else if(slider.settings.mode == 'vertical'){ 455 // get the last showing index's position 456 var lastShowingIndex = slider.children.length - slider.settings.minSlides; 457 var position = slider.children.eq(lastShowingIndex).position(); 458 // set the top position 459 setPositionProperty(-position.top, 'reset', 0); 460 } 461 // if not last slide 462 }else{ 463 // get the position of the first showing slide 464 var position = slider.children.eq(slider.active.index * getMoveBy()).position(); 465 // check for last slide 466 if (slider.active.index == getPagerQty() - 1) slider.active.last = true; 467 // set the repective position 468 if (position != undefined){ 469 if (slider.settings.mode == 'horizontal') setPositionProperty(-position.left, 'reset', 0); 470 else if (slider.settings.mode == 'vertical') setPositionProperty(-position.top, 'reset', 0); 471 } 472 } 473 } 474 475 /** 476 * Sets the el's animating property position (which in turn will sometimes animate el). 477 * If using CSS, sets the transform property. If not using CSS, sets the top / left property. 478 * 479 * @param value (int) 480 * - the animating property's value 481 * 482 * @param type (string) 'slider', 'reset', 'ticker' 483 * - the type of instance for which the function is being 484 * 485 * @param duration (int) 486 * - the amount of time (in ms) the transition should occupy 487 * 488 * @param params (array) optional 489 * - an optional parameter containing any variables that need to be passed in 490 */ 491 var setPositionProperty = function(value, type, duration, params){ 492 // use CSS transform 493 if(slider.usingCSS){ 494 // determine the translate3d value 495 var propValue = slider.settings.mode == 'vertical' ? 'translate3d(0, ' + value + 'px, 0)' : 'translate3d(' + value + 'px, 0, 0)'; 496 // add the CSS transition-duration 497 el.css('-' + slider.cssPrefix + '-transition-duration', duration / 1000 + 's'); 498 if(type == 'slide'){ 499 // set the property value 500 el.css(slider.animProp, propValue); 501 // bind a callback method - executes when CSS transition completes 502 el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){ 503 // unbind the callback 504 el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); 505 updateAfterSlideTransition(); 506 }); 507 }else if(type == 'reset'){ 508 el.css(slider.animProp, propValue); 509 }else if(type == 'ticker'){ 510 // make the transition use 'linear' 511 el.css('-' + slider.cssPrefix + '-transition-timing-function', 'linear'); 512 el.css(slider.animProp, propValue); 513 // bind a callback method - executes when CSS transition completes 514 el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){ 515 // unbind the callback 516 el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); 517 // reset the position 518 setPositionProperty(params['resetValue'], 'reset', 0); 519 // start the loop again 520 tickerLoop(); 521 });
522 } 523 // use JS animate 524 }else{ 525 var animateObj = {}; 526 animateObj[slider.animProp] = value; 527 if(type == 'slide'){ 528 el.animate(animateObj, duration, slider.settings.easing, function(){ 529 updateAfterSlideTransition(); 530 }); 531 }else if(type == 'reset'){ 532 el.css(slider.animProp, value) 533 }else if(type == 'ticker'){ 534 el.animate(animateObj, speed, 'linear', function(){ 535 setPositionProperty(params['resetValue'], 'reset', 0); 536 // run the recursive loop after animation 537 tickerLoop(); 538 }); 539 } 540 } 541 } 542 543 /** 544 * Populates the pager with proper amount of pages 545 */ 546 var populatePager = function(){ 547 var pagerHtml = ''; 548 pagerQty = getPagerQty(); 549 // loop through each pager item 550 for(var i=0; i < pagerQty; i++){ 551 var linkContent = ''; 552 // if a buildPager function is supplied, use it to get pager link value, else use index + 1 553 if(slider.settings.buildPager && $.isFunction(slider.settings.buildPager)){ 554 linkContent = slider.settings.buildPager(i); 555 slider.pagerEl.addClass('bx-custom-pager'); 556 }else{ 557 linkContent = i + 1; 558 slider.pagerEl.addClass('bx-default-pager'); 559 } 560 // var linkContent = slider.settings.buildPager && $.isFunction(slider.settings.buildPager) ? slider.settings.buildPager(i) : i + 1; 561 // add the markup to the string 562 pagerHtml += '<div class="bx-pager-item"><a href="" data-slide-index="' + i + '" class="bx-pager-link pager-' + i + '">' + linkContent + '</a></div>'; 563 //pagerHtml += '<div class="bx-pager-item"><span data-slide-index="' + i + '" class="bx-pager-link">' + linkContent + '</span></div>'; 564 }; 565 // populate the pager element with pager links 566 slider.pagerEl.html(pagerHtml); 567 } 568 569 /** 570 * Appends the pager to the controls element 571 */ 572 var appendPager = function(){ 573 if(!slider.settings.pagerCustom){ 574 // create the pager DOM element 575 slider.pagerEl = $('<div class="bx-pager" />'); 576 // if a pager selector was supplied, populate it with the pager 577 if(slider.settings.pagerSelector){ 578 $(slider.settings.pagerSelector).html(slider.pagerEl); 579 // if no pager selector was supplied, add it after the wrapper 580 }else{ 581 slider.controls.el.addClass('bx-has-pager').append(slider.pagerEl); 582 } 583 // populate the pager 584 populatePager(); 585 }else{ 586 slider.pagerEl = $(slider.settings.pagerCustom); 587 } 588 // assign the pager click binding 589 slider.pagerEl.delegate('a', 'click', clickPagerBind); 590 } 591 592 /** 593 * Appends prev / next controls to the controls element 594 */ 595 var appendControls = function(){ 596 slider.controls.next = $('<a class="bx-next" href="">' + slider.settings.nextText + '</a>'); 597 slider.controls.prev = $('<a class="bx-prev" href="">' + slider.settings.prevText + '</a>'); 598 // bind click actions to the controls 599 slider.controls.next.bind('touchend click', clickNextBind); 600 slider.controls.prev.bind('touchend click', clickPrevBind); 601 // if nextSlector was supplied, populate it 602 if(slider.settings.nextSelector){ 603 $(slider.settings.nextSelector).append(slider.controls.next); 604 } 605 // if prevSlector was supplied, populate it 606 if(slider.settings.prevSelector){ 607 $(slider.settings.prevSelector).append(slider.controls.prev); 608 } 609 // if no custom selectors were supplied 610 if(!slider.settings.nextSelector && !slider.settings.prevSelector){ 611 // add the controls to the DOM 612 slider.controls.directionEl = $('<div class="bx-controls-direction" />'); 613 // add the control elements to the directionEl 614 slider.controls.directionEl.append(slider.controls.prev).append(slider.controls.next); 615 // slider.viewport.append(slider.controls.directionEl); 616 slider.controls.el.addClass('bx-has-controls-direction').append(slider.controls.directionEl); 617 } 618 } 619 620 /** 621 * Appends start / stop auto controls to the controls element 622 */ 623 var appendControlsAuto = function(){ 624 slider.controls.start = $('<div class="bx-controls-auto-item"><a class="bx-start" href="">' + slider.settings.startText + '</a></div>'); 625 slider.controls.stop = $('<div class="bx-controls-auto-item"><a class="bx-stop" href="">' + slider.settings.stopText + '</a></div>'); 626 // add the controls to the DOM
627 slider.controls.autoEl = $('<div class="bx-controls-auto" />'); 628 // bind click actions to the controls 629 slider.controls.autoEl.delegate('.bx-start', 'click', clickStartBind); 630 slider.controls.autoEl.delegate('.bx-stop', 'click', clickStopBind); 631 // if autoControlsCombine, insert only the "start" control 632 if(slider.settings.autoControlsCombine){ 633 slider.controls.autoEl.append(slider.controls.start); 634 // if autoControlsCombine is false, insert both controls 635 }else{ 636 slider.controls.autoEl.append(slider.controls.start).append(slider.controls.stop); 637 } 638 // if auto controls selector was supplied, populate it with the controls 639 if(slider.settings.autoControlsSelector){ 640 $(slider.settings.autoControlsSelector).html(slider.controls.autoEl); 641 // if auto controls selector was not supplied, add it after the wrapper 642 }else{ 643 slider.controls.el.addClass('bx-has-controls-auto').append(slider.controls.autoEl); 644 } 645 // update the auto controls 646 updateAutoControls(sli
646der.settings.autoStart ? 'stop' : 'start'); 647 } 648 649 /** 650 * Appends image captions to the DOM 651 */ 652 var appendCaptions = function(){ 653 // cycle through each child 654 slider.children.each(function(index){ 655 // get the image title attribute 656 //modification starts @NIK 657 //var title = $(this).find('img:first').attr('title'); 658 var title = $(this).find('img:first').attr('alt'); 659 //modification ends @NIK 660 661 // append the caption 662 if (title != undefined) $(this).append('<div class="bx-caption"><span>' + title + '</span></div>'); 663 }); 664 } 665 666 /** 667 * Click next binding 668 * 669 * @param e (event) 670 * - DOM event object 671 */ 672 var clickNextBind = function(e){ 673 // if auto show is running, stop it 674 if (slider.settings.auto) el.stopAuto(); 675 el.goToNextSlide(); 676 e.preventDefault(); 677 } 678 679 /** 680 * Click prev binding 681 * 682 * @param e (event) 683 * - DOM event object 684 */ 685 var clickPrevBind = function(e){ 686 // if auto show is running, stop it 687 if (slider.settings.auto) el.stopAuto(); 688 el.goToPrevSlide(); 689 e.preventDefault(); 690 } 691 692 /** 693 * Click start binding 694 * 695 * @param e (event) 696 * - DOM event object 697 */ 698 var clickStartBind = function(e){ 699 el.startAuto(); 700 e.preventDefault(); 701 } 702 703 /** 704 * Click stop binding 705 * 706 * @param e (event) 707 * - DOM event object 708 */ 709 var clickStopBind = function(e){ 710 el.stopAuto(); 711 e.preventDefault(); 712 } 713 714 /** 715 * Click pager binding 716 * 717 * @param e (event) 718 * - DOM event object 719 */ 720 var clickPagerBind = function(e){ 721 // if auto show is running, stop it 722 if (slider.settings.auto) el.stopAuto(); 723 var pagerLink = $(e.currentTarget); 724 var pagerIndex = parseInt(pagerLink.attr('data-slide-index')); 725 // if clicked pager link is not active, continue with the goToSlide call 726 if(pagerIndex != slider.active.index) el.goToSlide(pagerIndex); 727 e.preventDefault(); 728 } 729 730 /** 731 * Updates the pager links with an active class 732 * 733 * @param slideIndex (int) 734 * - index of slide to make active 735 */ 736 var updatePagerActive = function(slideIndex){ 737 // if "short" pager type 738 if(slider.settings.pagerType == 'short'){ 739 slider.pagerEl.html((slideIndex + 1) + slider.settings.pagerShortSeparator + slider.children.length); 740 return; 741 } 742 // remove all pager active classes 743 slider.pagerEl.find('a').removeClass('active'); 744 //slider.pagerEl.find('span').removeClass('active'); 745 // apply the active class for all pagers 746 slider.pagerEl.each(function(i, el) { $(el).find('a').eq(slideIndex).addClass('active'); }); 747 //slider.pagerEl.each(function(i, el) { $(el).find('span').eq(slideIndex).addClass('active'); }); 748 } 749 750 /** 751 * Performs needed actions after a slide transition 752 */ 753 var updateAfterSlideTransition = function(){ 754 // if infinte loop is true 755 if(slider.settings.infiniteLoop){ 756 var position = ''; 757 // first slide 758 if(slider.active.index == 0){ 759 // set the new position 760 position = slider.children.eq(0).position(); 761 // carousel, last slide 762 }else if(slider.active.index == getPagerQty() - 1 && slider.carousel){ 763 position = slider.children.eq((getPagerQty() - 1) * getMoveBy()).position(); 764 // last slide 765 }else if(slider.active.index == slider.children.length - 1){ 766 position = slider.children.eq(slider.children.length - 1).position(); 767 } 768 if (slider.settings.mode == 'horizontal') { setPositionProperty(-position.left, 'reset', 0);; } 769 else if (slider.settings.mode == 'vertical') { setPositionProperty(-position.top, 'reset', 0);; } 770 } 771 // declare that the transition is complete 772 slider.working = false; 773 // onSlideAfter callback 774 slider.settings.onSlideAfter(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index); 775 } 776 777 /** 778 * Updates the auto controls state (either active, or combined switch) 779 * 780 * @param state (string) "start", "stop" 781 * - the new state of the auto show 782 */ 783 var updateAutoControls = function(state){ 784 // if autoControlsCombine is true, replace the current control with the new state 785 if(slider.settings.autoControlsCombine){
786 slider.controls.autoEl.html(slider.controls[state]); 787 // if autoControlsCombine is false, apply the "active" class to the appropriate control 788 }else{ 789 //slider.controls.autoEl.find('a').removeClass('active'); 790 //slider.controls.autoEl.find('a:not(.bx-' + state + ')').addClass('active'); 791 slider.controls.autoEl.find('div').removeClass('active'); 792 slider.controls.autoEl.find('a:not(.bx-' + state + ')').parent().addClass('active'); 793 } 794 } 795 796 /** 797 * Updates the direction controls (checks if either should be hidden) 798 */ 799 var updateDirectionControls = function(){ 800 // if infiniteLoop is false and hideControlOnEnd is true 801 if(!slider.settings.infiniteLoop && slider.settings.hideControlOnEnd){ 802 // if first slide 803 if (slider.active.index == 0){ 804 slider.controls.prev.addClass('disabled'); 805 slider.controls.next.removeClass('disabled'); 806 // if last slide 807 }else if(slider.active.index == getPagerQty() - 1){ 808 slider.controls.next.addClass('disabled'); 809 slider.controls.prev.removeClass('disabled'); 810 // if any slide in the middle 811 }else{ 812 slider.controls.prev.removeClass('disabled'); 813 slider.controls.next.removeClass('disabled'); 814 } 815 // if slider has only one page, disable controls 816 }else if(getPagerQty() == 1){ 817 slider.controls.prev.addClass('disabled'); 818 slider.controls.next.addClass('disabled'); 819 } 820 } 821 822 /** 823 * Initialzes the auto process 824 */ 825 var initAuto = function(){ 826 // if autoDelay was supplied, launch the auto show using a setTimeout() call 827 if(slider.settings.autoDelay > 0){ 828 var timeout = setTimeout(el.startAuto, slider.settings.autoDelay); 829 // if autoDelay was not supplied, start the auto show normally 830 }else{ 831 el.startAuto(); 832 } 833 // if autoHover is requested 834 if(slider.settings.autoHover){ 835 // on el hover 836 el.hover(function(){ 837 // if the auto show is currently playing (has an active interval) 838 if(slider.interval){ 839 // stop the auto show and pass true agument which will prevent control update 840 el.stopAuto(true); 841 // create a new autoPaused value which will be used by the relative "mouseout" event 842 slider.autoPaused = true; 843 } 844 }, function(){ 845 // if the autoPaused value was created be the prior "mouseover" event 846 if(slider.autoPaused){ 847 // start the auto show and pass true agument which will prevent control update 848 el.startAuto(true); 849 // reset the autoPaused value 850 slider.autoPaused = null; 851 } 852 }); 853 } 854 } 855 856 /** 857 * Initialzes the ticker process 858 */ 859 var initTicker = function(){ 860 var startPosition = 0; 861 // if autoDirection is "next", append a clone of the entire slider 862 if(slider.settings.autoDirection == 'next'){ 863 el.append(slider.children.clone().addClass('bx-clone')); 864 // if autoDirection is "prev", prepend a clone of the entire slider, and set the left position 865 }else{ 866 el.prepend(slider.children.clone().addClass('bx-clone')); 867 var position = slider.children.first().position(); 868 startPosition = slider.settings.mode == 'horizontal' ? -position.left : -position.top; 869 } 870 setPositionProperty(startPosition, 'reset', 0); 871 // do not allow controls in ticker mode 872 slider.settings.pager = false; 873 slider.settings.controls = false; 874 slider.settings.autoControls = false; 875 // if autoHover is requested 876 if(slider.settings.tickerHover && !slider.usingCSS){ 877 // on el hover 878 slider.viewport.hover(function(){ 879 el.stop(); 880 }, function(){ 881 // calculate the total width of children (used to calculate the speed ratio) 882 var totalDimens = 0; 883 slider.children.each(function(index){ 884 totalDimens += slider.settings.mode == 'horizontal' ? $(this).outerWidth(true) : $(this).outerHeight(true); 885 }); 886 // calculate the speed ratio (used to determine the new speed to finish the paused animation) 887 var ratio = slider.settings.speed / totalDimens; 888 // determine which property to use 889 var property = slider.settings.mode == 'horizontal' ? 'left' : 'top'; 890 // calculate the new speed 891 var newSpeed = ratio * (totalDimens - (Math.abs(parseInt(el.css(property))))); 892 tickerLoop(newSpeed); 893 }); 894 } 895 // start the ticker loop 896 tickerLoop(); 897 } 898 899 /** 900 * Runs a continuous loop, news ticker-style 901 */ 902 var tickerLoop = function(resumeSpeed){ 903 speed = resumeSpeed ? resumeSpeed : slider.settings.speed; 904 var position = {left: 0, top: 0};
905 var reset = {left: 0, top: 0}; 906 // if "next" animate left position to last child, then reset left to 0 907 if(slider.settings.autoDirection == 'next'){ 908 position = el.find('.bx-clone').first().position(); 909 // if "prev" animate left position to 0, then reset left to first non-clone child 910 }else{ 911 reset = slider.children.first().position(); 912 } 913 var animateProperty = slider.settings.mode == 'horizontal' ? -position.left : -position.top; 914 var resetValue = slider.settings.mode == 'horizontal' ? -reset.left : -reset.top; 915 var params = {resetValue: resetValue}; 916 setPositionProperty(animateProperty, 'ticker', speed, params); 917 } 918 919 /** 920 * Initializes touch events 921 */ 922 var initTouch = function(){ 923 // initialize object to contain all touch values 924 slider.touch = { 925 start: {x: 0, y: 0}, 926 end: {x: 0, y: 0} 927 } 928 slider.viewport.bind('touchstart', onTouchStart); 929 } 930 931 /** 932 * Event handler for "touchstart" 933 * 934 * @param e (event) 935 * - DOM event object 936 */ 937 var onTouchStart = function(e){ 938 if(slider.working){ 939 e.preventDefault(); 940 }else{ 941 // record the original position when touch starts 942 slider.touch.originalPos = el.position(); 943 var orig = e.originalEvent; 944 // record the starting touch x, y coordinates 945 slider.touch.start.x = orig.changedTouches[0].pageX; 946 slider.touch.start.y = orig.changedTouches[0].pageY; 947 // bind a "touchmove" event to the viewport 948 slider.viewport.bind('touchmove', onTouchMove); 949 // bind a "touchend" event to the viewport 950 slider.viewport.bind('touchend', onTouchEnd); 951 } 952 } 953 954 /** 955 * Event handler for "touchmove" 956 * 957 * @param e (event) 958 * - DOM event object 959 */ 960 var onTouchMove = function(e){ 961 var orig = e.originalEvent; 962 // if scrolling on y axis, do not prevent default 963 var xMovement = Math.abs(orig.changedTouches[0].pageX - slider.touch.start.x); 964 var yMovement = Math.abs(orig.changedTouches[0].pageY - slider.touch.start.y); 965 // x axis swipe 966 if((xMovement * 3) > yMovement && slider.settings.preventDefaultSwipeX){ 967 e.preventDefault(); 968 // y axis swipe 969 }else if((yMovement * 3) > xMovement && slider.settings.preventDefaultSwipeY){ 970 e.preventDefault(); 971 } 972 if(slider.settings.mode != 'fade' && slider.settings.oneToOneTouch){ 973 var value = 0; 974 // if horizontal, drag along x axis 975 if(slider.settings.mode == 'horizontal'){ 976 var change = orig.changedTouches[0].pageX - slider.touch.start.x; 977 value = slider.touch.originalPos.left + change; 978 // if vertical, drag along y axis 979 }else{ 980 var change = orig.changedTouches[0].pageY - slider.touch.start.y; 981 value = slider.touch.originalPos.top + change; 982 } 983 setPositionProperty(value, 'reset', 0); 984 } 985 } 986 987 /** 988 * Event handler for "touchend" 989 * 990 * @param e (event) 991 * - DOM event object 992 */ 993 var onTouchEnd = function(e){ 994 slider.viewport.unbind('touchmove', onTouchMove); 995 var orig = e.originalEvent; 996 var value = 0; 997 // record end x, y positions 998 slider.touch.end.x = orig.changedTouches[0].pageX; 999 slider.touch.end.y = orig.changedTouches[0].pageY; 1000 // if fade mode, check if absolute x distance clears the threshold 1001 if(slider.settings.mode == 'fade'){ 1002 var distance = Math.abs(slider.touch.start.x - slider.touch.end.x); 1003 if(distance >= slider.settings.swipeThreshold){ 1004 slider.touch.start.x > slider.touch.end.x ? el.goToNextSlide() : el.goToPrevSlide(); 1005 el.stopAuto(); 1006 } 1007 // not fade mode 1008 }else{ 1009 var distance = 0; 1010 // calculate distance and el's animate property 1011 if(slider.settings.mode == 'horizontal'){ 1012 distance = slider.touch.end.x - slider.touch.start.x; 1013 value = slider.touch.originalPos.left; 1014 }else{ 1015 distance = slider.touch.end.y - slider.touch.start.y; 1016 value = slider.touch.originalPos.top; 1017 } 1018 // if not infinite loop and first / last slide, do not attempt a slide transition 1019 if(!slider.settings.infiniteLoop && ((slider.active.index == 0 && distance > 0) || (slider.active.last && distance < 0))){ 1020 setPositionProperty(value, 'reset', 200);
1021 }else{ 1022 // check if distance clears threshold 1023 if(Math.abs(distance) >= slider.settings.swipeThreshold){ 1024 distance < 0 ? el.goToNextSlide() : el.goToPrevSlide(); 1025 el.stopAuto(); 1026 }else{ 1027 // el.animate(property, 200); 1028 setPositionProperty(value, 'reset', 200); 1029 } 1030 } 1031 } 1032 slider.viewport.unbind('touchend', onTouchEnd); 1033 } 1034 1035 /** 1036 * Window resize event callback 1037 */ 1038 var resizeWindow = function(e){ 1039 // get the new window dimens (again, thank you IE) 1040 var windowWidthNew = $(window).width(); 1041 var windowHeightNew = $(window).height(); 1042 // make sure that it is a true window resize 1043 // *we must check this because our dinosaur friend IE fires a window resize event when certain DOM elements 1044 // are resized. Can you just die already?* 1045 if(windowWidth != windowWidthNew || windowHeight != windowHeightNew){ 1046 // set the new window dimens 1047 windowWidth = windowWidthNew; 1048 windowHeight = windowHeightNew; 1049 // update all dynamic elements 1050 el.redrawSlider(); 1051 } 1052 } 1053 1054 /** 1055 * =================================================================================== 1056 * = PUBLIC FUNCTIONS 1057 * =================================================================================== 1058 */ 1059 1060 /** 1061 * Performs slide transition to the specified slide 1062 * 1063 * @param slideIndex (int) 1064 * - the destination slide's index (zero-based) 1065 * 1066 * @param direction (string) 1067 * - INTERNAL USE ONLY - the direction of travel ("prev" / "next") 1068 */ 1069 el.goToSlide = function(slideIndex, direction){ 1070 // if plugin is currently in motion, ignore request 1071 if(slider.working || slider.active.index == slideIndex) return; 1072 // declare that plugin is in motion 1073 slider.working = true; 1074 // store the old index 1075 slider.oldIndex = slider.active.index; 1076 // if slideIndex is less than zero, set active index to last child (this happens during infinite loop) 1077 if(slideIndex < 0){ 1078 slider.active.index = getPagerQty() - 1; 1079 // if slideIndex is greater than children length, set active index to 0 (this happens during infinite loop) 1080 }else if(slideIndex >= getPagerQty()){ 1081 slider.active.index = 0; 1082 // set active index to requested slide 1083 }else{ 1084 slider.active.index = slideIndex; 1085 } 1086 // onSlideBefore, onSlideNext, onSlidePrev callbacks 1087 slider.settings.onSlideBefore(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index); 1088 if(direction == 'next'){ 1089 slider.settings.onSlideNext(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index); 1090 }else if(direction == 'prev'){ 1091 slider.settings.onSlidePrev(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index); 1092 } 1093 // check if last slide 1094 slider.active.last = slider.active.index >= getPagerQty() - 1; 1095 // update the pager with active class 1096 if(slider.settings.pager) updatePagerActive(slider.active.index); 1097 // // check for direction control update 1098 if(slider.settings.controls) updateDirectionControls(); 1099 // if slider is set to mode: "fade" 1100 if(slider.settings.mode == 'fade'){ 1101 // if adaptiveHeight is true and next height is different from current height, animate to the new height 1102 if(slider.settings.adaptiveHeight && slider.viewport.height() != getViewportHeight()){ 1103 slider.viewport.animate({height: getViewportHeight()}, slider.settings.adaptiveHeightSpeed); 1104 } 1105 // fade out the visible child and reset its z-index value 1106 slider.children.filter(':visible').fadeOut(slider.settings.speed).css({zIndex: 0}); 1107 // fade in the newly requested slide 1108 slider.children.eq(slider.active.index).css('zIndex', 51).fadeIn(slider.settings.speed, function(){ 1109 $(this).css('zIndex', 50); 1110 updateAfterSlideTransition(); 1111 }); 1112 // slider mode is not "fade" 1113 }else{ 1114 // if adaptiveHeight is true and next height is different from current height, animate to the new height 1115 if(slider.settings.adaptiveHeight && slider.viewport.height() != getViewportHe
1115ight()){ 1116 slider.viewport.animate({height: getViewportHeight()}, slider.settings.adaptiveHeightSpeed); 1117 } 1118 var moveBy = 0; 1119 var position = {left: 0, top: 0}; 1120 // if carousel and not infinite loop 1121 if(!slider.settings.infiniteLoop && slider.carousel && slider.active.last){ 1122 if(slider.settings.mode == 'horizontal'){ 1123 // get the last child position 1124 var lastChild = slider.children.eq(slider.children.length - 1); 1125 position = lastChild.position(); 1126 // calculate the position of the last slide 1127 moveBy = slider.viewport.width() - lastChild.width(); 1128 }else{ 1129 // get last showing index position 1130 var lastShowingIndex = slider.children.length - slider.settings.minSlides; 1131 position = slider.children.eq(lastShowingIndex).position(); 1132 } 1133 // horizontal carousel, going previous while on first slide (infiniteLoop mode) 1134 }else if(slider.carousel && slider.active.last && direction == 'prev'){ 1135 // get the last child position 1136 var eq = slider.settings.moveSlides == 1 ? slider.settings.maxSlides - getMoveBy() : ((getPagerQty() - 1) * getMoveBy()) - (slider.children.length - slider.settings.maxSlides); 1137 var lastChild = el.children('.bx-clone').eq(eq); 1138 position = lastChild.position(); 1139 // if infinite loop and "Next" is clicked on the last slide 1140 }else if(direction == 'next' && slider.active.index == 0){ 1141 // get the last clone position 1142 position = el.find('.bx-clone').eq(slider.settings.maxSlides).position(); 1143 slider.active.last = false; 1144 // normal non-zero requests 1145 }else if(slideIndex >= 0){ 1146 var requestEl = slideIndex * getMoveBy(); 1147 position = slider.children.eq(requestEl).position(); 1148 } 1149 // plugin values to be animated 1150 var value = slider.settings.mode == 'horizontal' ? -(position.left - moveBy) : -position.top; 1151 setPositionProperty(value, 'slide', slider.settings.speed); 1152 } 1153 } 1154 1155 /** 1156 * Transitions to the next slide in the show 1157 */ 1158 el.goToNextSlide = function(){ 1159 // if infiniteLoop is false and last page is showing, disregard call 1160 if (!slider.settings.infiniteLoop && slider.active.last) return; 1161 var pagerIndex = parseInt(slider.active.index) + 1; 1162 el.goToSlide(pagerIndex, 'next'); 1163 } 1164 1165 /** 1166 * Transitions to the prev slide in the show 1167 */ 1168 el.goToPrevSlide = function(){ 1169 // if infiniteLoop is false and last page is showing, disregard call 1170 if (!slider.settings.infiniteLoop && slider.active.index == 0) return; 1171 var pagerIndex = parseInt(slider.active.index) - 1; 1172 el.goToSlide(pagerIndex, 'prev'); 1173 } 1174 1175 /** 1176 * Starts the auto show 1177 * 1178 * @param preventControlUpdate (boolean) 1179 * - if true, auto controls state will not be updated 1180 */ 1181 el.startAuto = function(preventControlUpdate){ 1182 // if an interval already exists, disregard call 1183 if(slider.interval) return; 1184 // create an interval 1185 slider.interval = setInterval(function(){ 1186 slider.settings.autoDirection == 'next' ? el.goToNextSlide() : el.goToPrevSlide(); 1187 }, slider.settings.pause); 1188 // if auto controls are displayed and preventControlUpdate is not true 1189 if (slider.settings.autoControls && preventControlUpdate != true) updateAutoControls('stop'); 1190 } 1191 1192 /** 1193 * Stops the auto show 1194 * 1195 * @param preventControlUpdate (boolean) 1196 * - if true, auto controls state will not be updated 1197 */ 1198 el.stopAuto = function(preventControlUpdate){ 1199 // if no interval exists, disregard call 1200 if(!slider.interval) return; 1201 // clear the interval 1202 clearInterval(slider.interval); 1203 slider.interval = null; 1204 // if auto controls are displayed and preventControlUpdate is not true 1205 if (slider.settings.autoControls && preventControlUpdate != true) updateAutoControls('start'); 1206 } 1207 1208 /** 1209 * Returns current slide index (zero-based) 1210 */ 1211 el.getCurrentSlide = function(){ 1212 return slider.active.index; 1213 } 1214 1215 /** 1216 * Returns number of slides in show 1217 */ 1218 el.getSlideCount = function(){ 1219 return slider.children.length; 1220 } 1221 1222 /** 1223 * Update all dynamic slider elements 1224 */ 1225 el.redrawSlider = function(){ 1226 // resize all children in ratio to new screen size 1227 slider.children.add(el.find('.bx-clone')).width(getSlideWidth()); 1228 // adjust the height
1229 slider.viewport.css('height', getViewportHeight()); 1230 // update the slide position 1231 if(!slider.settings.ticker) setSlidePosition(); 1232 // if active.last was true before the screen resize, we want 1233 // to keep it last no matter what screen size we end on 1234 if (slider.active.last) slider.active.index = getPagerQty() - 1; 1235 // if the active index (page) no longer exists due to the resize, simply set the index as last 1236 if (slider.active.index >= getPagerQty()) slider.active.last = true; 1237 // if a pager is being displayed and a custom pager is not being used, update it 1238 if(slider.settings.pager && !slider.settings.pagerCustom){ 1239 populatePager(); 1240 updatePagerActive(slider.active.index); 1241 } 1242 } 1243 1244 /** 1245 * Destroy the current instance of the slider (revert everything back to original state) 1246 */ 1247 el.destroySlider = function(){ 1248 // don't do anything if slider has already been destroyed 1249 if(!slider.initialized) return; 1250 slider.initialized = false; 1251 $('.bx-clone', this).remove(); 1252 slider.children.removeAttr('style'); 1253 this.removeAttr('style').unwrap().unwrap(); 1254 if(slider.controls.el) slider.controls.el.remove(); 1255 if(slider.controls.next) slider.controls.next.remove(); 1256 if(slider.controls.prev) slider.controls.prev.remove(); 1257 if(slider.pagerEl) slider.pagerEl.remove(); 1258 $('.bx-caption', this).remove(); 1259 if(slider.controls.autoEl) slider.controls.autoEl.remove(); 1260 clearInterval(slider.interval); 1261 $(window).unbind('resize', resizeWindow); 1262 } 1263 1264 /** 1265 * Reload the slider (revert all DOM changes, and re-initialize) 1266 */ 1267 el.reloadSlider = function(settings){ 1268 if (settings != undefined) options = settings; 1269 el.destroySlider(); 1270 init(); 1271 } 1272 1273 init(); 1274 1275 // returns the current jQuery object 1276 return this; 1277 } 1278 1279})(jQuery); 1280 1281/*! 1282 * jQuery imagesLoaded plugin v2.1.0 1283 * http://github.com/desandro/imagesloaded 1284 * 1285 * MIT License. by Paul Irish et al. 1286 */ 1287 1288/*jshint curly: true, eqeqeq: true, noempty: true, strict: true, undef: true, browser: true */ 1289/*global jQuery: false */ 1290 1291(function(c,n){var l="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";c.fn.imagesLoaded=function(f){function m(){var b=c(i),a=c(h);d&&(h.length?d.reject(e,b,a):d.resolve(e));c.isFunction(f)&&f.call(g,e,b,a)}function j(b,a){b.src===l||-1!==c.inArray(b,k)||(k.push(b),a?h.push(b):i.push(b),c.data(b,"imagesLoaded",{isBroken:a,src:b.src}),o&&d.notifyWith(c(b),[a,e,c(i),c(h)]),e.length===k.length&&(setTimeout(m),e.unbind(".imagesLoaded")))}var g=this,d=c.isFunction(c.Deferred)?c.Deferred(): 12920,o=c.isFunction(d.notify),e=g.find("img").add(g.filter("img")),k=[],i=[],h=[];c.isPlainObject(f)&&c.each(f,function(b,a){if("callback"===b)f=a;else if(d)d[b](a)});e.length?e.bind("load.imagesLoaded error.imagesLoaded",function(b){j(b.target,"error"===b.type)}).each(function(b,a){var d=a.src,e=c.data(a,"imagesLoaded");if(e&&e.src===d)j(a,e.isBroken);else if(a.complete&&a.naturalWidth!==n)j(a,0===a.naturalWidth||0===a.naturalHeight);else if(a.readyState||a.complete)a.src=l,a.src=d}):m();return d?d.promise(g): 1293g}})(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.