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