vendor: 9,834 bytes, lines 1-259
1/** 2 * bxSlider v4.2.1d 3 * Copyright 2013-2017 Steven Wanderski 4 * Written while drinking Belgian ales and listening to jazz 5 * Licensed under MIT (http://opensource.org/licenses/MIT) 6 */ 7 8;(function($) { 9 10 var defaults = { 11 12 // GENERAL 13 mode: 'horizontal', 14 slideSelector: '', 15 infiniteLoop: true, 16 hideControlOnEnd: false, 17 speed: 500, 18 easing: null, 19 slideMargin: 0, 20 startSlide: 0, 21 randomStart: false, 22 captions: false, 23 ticker: false, 24 tickerHover: false, 25 adaptiveHeight: false, 26 adaptiveHeightSpeed: 500, 27 video: false, 28 useCSS: true, 29 preloadImages: 'visible', 30 responsive: true, 31 slideZIndex: 50, 32 wrapperClass: 'bx-wrapper', 33 34 // TOUCH 35 touchEnabled: true, 36 swipeThreshold: 50, 37 oneToOneTouch: true, 38 preventDefaultSwipeX: true, 39 preventDefaultSwipeY: false, 40 41 // ACCESSIBILITY 42 ariaLive: true, 43 ariaHidden: true, 44 45 // KEYBOARD 46 keyboardEnabled: false, 47 48 // PAGER 49 pager: true, 50 pagerType: 'full', 51 pagerShortSeparator: ' / ', 52 pagerSelector: null, 53 buildPager: null, 54 pagerCustom: null, 55 56 // CONTROLS 57 controls: true, 58 nextText: 'Next', 59 prevText: 'Prev', 60 nextSelector: null, 61 prevSelector: null, 62 autoControls: false, 63 startText: 'Start', 64 stopText: 'Stop', 65 autoControlsCombine: false, 66 autoControlsSelector: null, 67 68 // AUTO 69 auto: false, 70 pause: 4000, 71 autoStart: true, 72 autoDirection: 'next', 73 stopAutoOnClick: false, 74 autoHover: false, 75 autoDelay: 0, 76 autoSlideForOnePage: false, 77 78 // CAROUSEL 79 minSlides: 1, 80 maxSlides: 1, 81 moveSlides: 0, 82 slideWidth: 0, 83 shrinkItems: false, 84 85 // CALLBACKS 86 onSliderLoad: function() { return true; }, 87 onSlideBefore: function() { return true; }, 88 onSlideAfter: function() { return true; }, 89 onSlideNext: function() { return true; }, 90 onSlidePrev: function() { return true; }, 91 onSliderResize: function() { return true; }, 92 onAutoChange: function() { return true; } //calls when auto slides starts and stops 93 }; 94 95 $.fn.bxSlider = function(options) { 96 97 if (this.length === 0) { 98 return this; 99 } 100 101 // support multiple elements 102 if (this.length > 1) { 103 this.each(function() { 104 $(this).bxSlider(options); 105 }); 106 return this; 107 } 108 109 // create a namespace to be used throughout the plugin 110 var slider = {}, 111 // set a reference to our slider element 112 el = this, 113 // get the original window dimens (thanks a lot IE) 114 windowWidth = $(window).width(), 115 windowHeight = $(window).height(); 116 117 // Return if slider is already initialized 118 if ($(el).data('bxSlider')) { return; } 119 120 /** 121 * =================================================================================== 122 * = PRIVATE FUNCTIONS 123 * =================================================================================== 124 */ 125 126 /** 127 * Initializes namespace settings to be used throughout plugin 128 */ 129 var init = function() { 130 // Return if slider is already initialized 131 if ($(el).data('bxSlider')) { return; } 132 // merge user-supplied options with the defaults 133 slider.settings = $.extend({}, defaults, options); 134 // parse slideWidth setting 135 slider.settings.slideWidth = parseInt(slider.settings.slideWidth); 136 // store the original children 137 slider.children = el.children(slider.settings.slideSelector); 138 // check if actual number of slides is less than minSlides / maxSlides 139 if (slider.children.length < slider.settings.minSlides) { slider.settings.minSlides = slider.children.length; } 140 if (slider.children.length < slider.settings.maxSlides) { slider.settings.maxSlides = slider.children.length; } 141 // if random start, set the startSlide setting to random number 142 if (slider.settings.randomStart) { slider.settings.startSlide = Math.floor(Math.random() * slider.children.length); } 143 // store active slide information 144 slider.active = { index: slider.settings.startSlide }; 145 // store if the slider is in carousel mode (displaying / moving multiple slides) 146 slider.carousel = slider.settings.minSlides > 1 || slider.settings.maxSlides > 1; 147 // if carousel, force preloadImages = 'all' 148 if (slider.carousel) { slider.settings.preloadImages = 'all'; } 149 // calculate the min / max width thresholds based on min / max number of slides 150 // used to setup and update carousel slides dimensions 151 slider.minThreshold = (slider.settings.minSlides * slider.settings.slideWidth) + ((slider.settings.minSlides - 1) * slider.settings.slideMargin); 152 slider.maxThreshold = (slider.settings.maxSlides * slider.settings.slideWidth) + ((slider.settings.maxSlides - 1) * slider.settings.slideMargin); 153 // store the current state of the slider (if currently animating, working is true) 154 slider.working = false; 155 // initialize the controls object 156 slider.controls = {}; 157 // initialize an auto interval 158 slider.interval = null; 159 // determine which property to use for transitions 160 slider.animProp = slider.settings.mode === 'vertical' ? 'top' : 'left'; 161 // determine if hardware acceleration can be used 162 slider.usingCSS = slider.settings.useCSS && slider.settings.mode !== 'fade' && (function() { 163 // create our test div element 164 var div = document.createElement('div'), 165 // css transition properties 166 props = ['WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective']; 167 // test for each property 168 for (var i = 0; i < props.length; i++) { 169 if (div.style[props[i]] !== undefined) { 170 slider.cssPrefix = props[i].replace('Perspective', '').toLowerCase(); 171 slider.animProp = '-' + slider.cssPrefix + '-transform'; 172 return true; 173 } 174 } 175 return false; 176 }()); 177 // if vertical mode always make maxSlides and minSlides equal 178 if (slider.settings.mode === 'vertical') { slider.settings.maxSlides = slider.settings.minSlides; } 179 // save original style data 180 el.data('origStyle', el.attr('style')); 181 el.children(slider.settings.slideSelector).each(function() { 182 $(this).data('origStyle', $(this).attr('style')); 183 }); 184 185 // perform all DOM / CSS modifications 186 setup(); 187 }; 188 189 /** 190 * Performs all DOM and CSS modifications 191 */ 192 var setup = function() { 193 var preloadSelector = slider.children.eq(slider.settings.startSlide); // set the default preload selector (visible) 194 195 // wrap el in a wrapper 196 el.wrap('<div class="' + slider.settings.wrapperClass + '"><div class="bx-viewport"></div></div>'); 197 // store a namespace reference to .bx-viewport 198 slider.viewport = el.parent(); 199 200 // add aria-live if the setting is enabled and ticker mode is disabled 201 if (slider.settings.ariaLive && !slider.settings.ticker) { 202 slider.viewport.attr('aria-live', 'polite'); 203 } 204 // add a loading div to display while images are loading 205 slider.loader = $('<div class="bx-loading" />'); 206 slider.viewport.prepend(slider.loader); 207 // set el to a massive width, to hold any needed slides 208 // also strip any margin and padding from el 209 el.css({ 210 width: slider.settings.mode === 'horizontal' ? (slider.children.length * 1000 + 215) + '%' : 'auto', 211 position: 'relative' 212 }); 213 // if using CSS, add the easing property 214 if (slider.usingCSS && slider.settings.easing) { 215 el.css('-' + slider.cssPrefix + '-transition-timing-function', slider.settings.easing); 216 // if not using CSS and no easing value was supplied, use the default JS animation easing (swing) 217 } else if (!slider.settings.easing) { 218 slider.settings.easing = 'swing'; 219 } 220 // make modifications to the viewport (.bx-viewport) 221 slider.viewport.css({ 222 width: '100%', 223 overflow: 'hidden', 224 position: 'relative' 225 }); 226 slider.viewport.parent().css({ 227 maxWidth: getViewportMaxWidth() 228 }); 229 // apply css to all slider children 230 slider.children.css({ 231 // the float attribute is a reserved word in compressors like YUI compressor and need to be quoted #48 232 'float': slider.settings.mode === 'horizontal' ? 'left' : 'none', 233 listStyle: 'none', 234 position: 'relative', 235 'background-position':slider.settings.bgPos, 236 'background-size':slider.settings.bgSize, 237 'background-repeat':'no-repeat' 238 }); 239 // apply the calculated width after the float is applied to prevent scrollbar interference 240 slider.children.css('width', getSlideWidth()); 241 // if slideMargin is supplied, add the css 242 if (slider.settings.mode === 'horizontal' && slider.settings.slideMargin > 0) { slider.children.css('marginRight', slider.settings.slideMargin); } 243 if (slider.settings.mode === 'vertical' && slider.settings.slideMargin > 0) { slider.children.css('marginBottom', slider.settings.slideMargin); } 244 // if "fade" mode, add positioning and z-index CSS 245 if (slider.settings.mode === 'fade') { 246 slider.children.css({ 247 position: 'absolute', 248 zIndex: 0, 249 display: 'none', 250 'background-position':slider.settings.bgPos, 251 'background-size':slider.settings.bgSize, 252 'background-repeat':'no-repeat' 253 }); 254 // prepare the z-index on the showing element 255 slider.children.eq(slider.settings.startSlide).css({zIndex: slider.settings.slideZIndex, display: 'block', position: 'absolute'}); 256 } 257 // create an element to contain all slider controls (pager, start / stop, etc) 258 slider.controls.el = $('<div class="bx-controls" />'); 259 // if captions are requested, add them
260 if (slider.settings.captions) { appendCaptions(); } 261 // check if startSlide is last slide 262 slider.active.last = slider.settings.startSlide === getPagerQty() - 1; 263 // if video is true, set up the fitVids plugin 264 if (slider.settings.video) { el.fitVids(); } 265 //preloadImages 266 if (slider.settings.preloadImages === 'none') { 267 preloadSelector = null; 268 } 269 else if (slider.settings.preloadImages === 'all' || slider.settings.ticker) { 270 preloadSelector = slider.children;
vendor: 34,850 bytes, lines 270-1110
270 271 } 272 // only check for control addition if not in "ticker" mode 273 if (!slider.settings.ticker) { 274 // if controls are requested, add them 275 if (slider.settings.controls) { appendControls(); } 276 // if auto is true, and auto controls are requested, add them 277 if (slider.settings.auto && slider.settings.autoControls) { appendControlsAuto(); } 278 // if pager is requested, add it 279 if (slider.settings.pager) { appendPager(); } 280 // if any control option is requested, add the controls wrapper 281 if (slider.settings.controls || slider.settings.autoControls || slider.settings.pager) { slider.viewport.after(slider.controls.el); } 282 // if ticker mode, do not allow a pager 283 } else { 284 slider.settings.pager = false; 285 } 286 if (preloadSelector === null) { 287 start(); 288 } else { 289 loadElements(preloadSelector, start); 290 } 291 }; 292 293 var loadElements = function(selector, callback) { 294 var total = selector.find('img:not([src=""]), iframe').length, 295 count = 0; 296 if (total === 0) { 297 callback(); 298 return; 299 } 300 selector.find('img:not([src=""]), iframe').each(function() { 301 $(this).one('load error', function() { 302 if (++count === total) { callback(); } 303 }).each(function() { 304 if (this.complete || this.src == '') { $(this).trigger('load'); } 305 }); 306 }); 307 }; 308 309 /** 310 * Start the slider 311 */ 312 var start = function() { 313 // if infinite loop, prepare additional slides 314 if (slider.settings.infiniteLoop && slider.settings.mode !== 'fade' && !slider.settings.ticker) { 315 var slice = slider.settings.mode === 'vertical' ? slider.settings.minSlides : slider.settings.maxSlides, 316 sliceAppend = slider.children.slice(0, slice).clone(true).addClass('bx-clone'), 317 slicePrepend = slider.children.slice(-slice).clone(true).addClass('bx-clone'); 318 if (slider.settings.ariaHidden) { 319 sliceAppend.attr('aria-hidden', true); 320 slicePrepend.attr('aria-hidden', true); 321 } 322 el.append(sliceAppend).prepend(slicePrepend); 323 } 324 // remove the loading DOM element 325 slider.loader.remove(); 326 // set the left / top position of "el" 327 setSlidePosition(); 328 // if "vertical" mode, always use adaptiveHeight to prevent odd behavior 329 if (slider.settings.mode === 'vertical') { slider.settings.adaptiveHeight = true; } 330 // set the viewport height 331 slider.viewport.height(getViewportHeight()); 332 // make sure everything is positioned just right (same as a window resize) 333 el.redrawSlider(); 334 // onSliderLoad callback 335 slider.settings.onSliderLoad.call(el, slider.active.index); 336 // slider has been fully initialized 337 slider.initialized = true; 338 // add the resize call to the window 339 if (slider.settings.responsive) { $(window).on('resize', resizeWindow); } 340 // if auto is true and has more than 1 page, start the show 341 if (slider.settings.auto && slider.settings.autoStart && (getPagerQty() > 1 || slider.settings.autoSlideForOnePage)) { initAuto(); } 342 // if ticker is true, start the ticker 343 if (slider.settings.ticker) { initTicker(); } 344 // if pager is requested, make the appropriate pager link active 345 if (slider.settings.pager) { updatePagerActive(slider.settings.startSlide); } 346 // check for any updates to the controls (like hideControlOnEnd updates) 347 if (slider.settings.controls) { updateDirectionControls(); } 348 // if touchEnabled is true, setup the touch events 349 if (slider.settings.touchEnabled && !slider.settings.ticker) { initTouch(); } 350 // if keyboardEnabled is true, setup the keyboard events 351 if (slider.settings.keyboardEnabled && !slider.settings.ticker) { 352 $(document).keydown(keyPress); 353 } 354 }; 355 356 /** 357 * Returns the calculated height of the viewport, used to determine either adaptiveHeight or the maxHeight value 358 */ 359 var getViewportHeight = function() { 360 var height = 0; 361 // first determine which children (slides) should be used in our height calculation 362 var children = $(); 363 // if mode is not "vertical" and adaptiveHeight is false, include all children 364 if (slider.settings.mode !== 'vertical' && !slider.settings.adaptiveHeight) { 365 children = slider.children; 366 } else { 367 // if not carousel, return the single active child 368 if (!slider.carousel) { 369 children = slider.children.eq(slider.active.index); 370 // if carousel, return a slice of children 371 } else { 372 // get the individual slide index 373 var currentIndex = slider.settings.moveSlides === 1 ? slider.active.index : slider.active.index * getMoveBy(); 374 // add the current slide to the children 375 children = slider.children.eq(currentIndex); 376 // cycle through the remaining "showing" slides 377 for (i = 1; i <= slider.settings.maxSlides - 1; i++) { 378 // if looped back to the start 379 if (currentIndex + i >= slider.children.length) { 380 children = children.add(slider.children.eq(i - 1)); 381 } else { 382 children = children.add(slider.children.eq(currentIndex + i)); 383 } 384 } 385 } 386 } 387 // if "vertical" mode, calculate the sum of the heights of the children 388 if (slider.settings.mode === 'vertical') { 389 children.each(function(index) { 390 height += $(this).outerHeight(); 391 }); 392 // add user-supplied margins 393 if (slider.settings.slideMargin > 0) { 394 height += slider.settings.slideMargin * (slider.settings.minSlides - 1); 395 } 396 // if not "vertical" mode, calculate the max height of the children 397 } else { 398 height = Math.max.apply(Math, children.map(function() { 399 return $(this).outerHeight(false); 400 }).get()); 401 } 402 403 if (slider.viewport.css('box-sizing') === 'border-box') { 404 height += parseFloat(slider.viewport.css('padding-top')) + parseFloat(slider.viewport.css('padding-bottom')) + 405 parseFloat(slider.viewport.css('border-top-width')) + parseFloat(slider.viewport.css('border-bottom-width')); 406 } else if (slider.viewport.css('box-sizing') === 'padding-box') { 407 height += parseFloat(slider.viewport.css('padding-top')) + parseFloat(slider.viewport.css('padding-bottom')); 408 } 409 410 return height; 411 }; 412 413 /** 414 * Returns the calculated width to be used for the outer wrapper / viewport 415 */ 416 var getViewportMaxWidth = function() { 417 var width = '100%'; 418 if (slider.settings.slideWidth > 0) { 419 if (slider.settings.mode === 'horizontal') { 420 width = (slider.settings.maxSlides * slider.settings.slideWidth) + ((slider.settings.maxSlides - 1) * slider.settings.slideMargin); 421 } else { 422 width = slider.settings.slideWidth; 423 } 424 } 425 return width; 426 }; 427 428 /** 429 * Returns the calculated width to be applied to each slide 430 */ 431 var getSlideWidth = function() { 432 var newElWidth = slider.settings.slideWidth, // start with any user-supplied slide width 433 wrapWidth = slider.viewport.width(); // get the current viewport width 434 // if slide width was not supplied, or is larger than the viewport use the viewport width 435 if (slider.settings.slideWidth === 0 || 436 (slider.settings.slideWidth > wrapWidth && !slider.carousel) || 437 slider.settings.mode === 'vertical') { 438 newElWidth = wrapWidth; 439 // if carousel, use the thresholds to determine the width 440 } else if (slider.settings.maxSlides > 1 && slider.settings.mode === 'horizontal') { 441 if (wrapWidth > slider.maxThreshold) { 442 return newElWidth; 443 } else if (wrapWidth < slider.minThreshold) { 444 newElWidth = (wrapWidth - (slider.settings.slideMargin * (slider.settings.minSlides - 1))) / slider.settings.minSlides; 445 } else if (slider.settings.shrinkItems) { 446 newElWidth = Math.floor((wrapWidth + slider.settings.slideMargin) / (Math.ceil((wrapWidth + slider.settings.slideMargin) / (newElWidth + slider.settings.slideMargin))) - slider.settings.slideMargin); 447 } 448 } 449 return newElWidth; 450 }; 451 452 /** 453 * Returns the number of slides currently visible in the viewport (includes partially visible slides) 454 */ 455 var getNumberSlidesShowing = function() { 456 var slidesShowing = 1, 457 childWidth = null; 458 if (slider.settings.mode === 'horizontal' && slider.settings.slideWidth > 0) { 459 // if viewport is smaller than minThreshold, return minSlides 460 if (slider.viewport.width() < slider.minThreshold) { 461 slidesShowing = slider.settings.minSlides; 462 // if viewport is larger than maxThreshold, return maxSlides 463 } else if (slider.viewport.width() > slider.maxThreshold) { 464 slidesShowing = slider.settings.maxSlides; 465 // if viewport is between min / max thresholds, divide viewport width by first child width 466 } else { 467 childWidth = slider.children.first().width() + slider.settings.slideMargin; 468 slidesShowing = Math.floor((slider.viewport.width() + 469 slider.settings.slideMargin) / childWidth) || 1; 470 } 471 // if "vertical" mode, slides showing will always be minSlides 472 } else if (slider.settings.mode === 'vertical') { 473 slidesShowing = slider.settings.minSlides; 474 } 475 return slidesShowing; 476 }; 477 478 /** 479 * Returns the number of pages (one full viewport of slides is one "page") 480 */ 481 var getPagerQty = function() { 482 var pagerQty = 0, 483 breakPoint = 0, 484 counter = 0; 485 // if moveSlides is specified by the user 486 if (slider.settings.moveSlides > 0) { 487 if (slider.settings.infiniteLoop) { 488 pagerQty = Math.ceil(slider.children.length / getMoveBy()); 489 } else { 490 // when breakpoint goes above children length, counter is the number of pages 491 while (breakPoint < slider.children.length) { 492 ++pagerQty; 493 breakPoint = counter + getNumberSlidesShowing(); 494 counter += slider.settings.moveSlides <= getNumberSlidesShowing() ? slider.settings.moveSlides : getNumberSlidesShowing(); 495 } 496 return counter; 497 } 498 // if moveSlides is 0 (auto) divide children length by sides showing, then round up 499 } else { 500 pagerQty = Math.ceil(slider.children.length / getNumberSlidesShowing()); 501 } 502 return pagerQty; 503 }; 504 505 /** 506 * Returns the number of individual slides by which to shift the slider 507 */ 508 var getMoveBy = function() { 509 // if moveSlides was set by the user and moveSlides is less than number of slides showing 510 if (slider.settings.moveSlides > 0 && slider.settings.moveSlides <= getNumberSlidesShowing()) { 511 return slider.settings.moveSlides; 512 } 513 // if moveSlides is 0 (auto) 514 return getNumberSlidesShowing(); 515 }; 516 517 /** 518 * Sets the slider's (el) left or top position 519 */ 520 var setSlidePosition = function() { 521 var position, lastChild, lastShowingIndex; 522 // if last slide, not infinite loop, and number of children is larger than specified maxSlides 523 if (slider.children.length > slider.settings.maxSlides && slider.active.last && !slider.settings.infiniteLoop) { 524 if (slider.settings.mode === 'horizontal') { 525 // get the last child's position 526 lastChild = slider.children.last(); 527 position = lastChild.position(); 528 // set the left position 529 setPositionProperty(-(position.left - (slider.viewport.width() - lastChild.outerWidth())), 'reset', 0); 530 } else if (slider.settings.mode === 'vertical') { 531 // get the last showing index's position 532 lastShowingIndex = slider.children.length - slider.settings.minSlides; 533 position = slider.children.eq(lastShowingIndex).position(); 534 // set the top position 535 setPositionProperty(-position.top, 'reset', 0); 536 } 537 // if not last slide 538 } else { 539 // get the position of the first showing slide 540 position = slider.children.eq(slider.active.index * getMoveBy()).position(); 541 // check for last slide 542 if (slider.active.index === getPagerQty() - 1) { slider.active.last = true; } 543 // set the respective position 544 if (position !== undefined) { 545 if (slider.settings.mode === 'horizontal') { setPositionProperty(-position.left, 'reset', 0); } 546 else if (slider.settings.mode === 'vertical') { setPositionProperty(-position.top, 'reset', 0); } 547 } 548 } 549 }; 550 551 /** 552 * Sets the el's animating property position (which in turn will sometimes animate el). 553 * If using CSS, sets the transform property. If not using CSS, sets the top / left property. 554 * 555 * @param value (int) 556 * - the animating property's value 557 * 558 * @param type (string) 'slide', 'reset', 'ticker' 559 * - the type of instance for which the function is being 560 * 561 * @param duration (int) 562 * - the amount of time (in ms) the transition should occupy 563 * 564 * @param params (array) optional 565 * - an optional parameter containing any variables that need to be passed in 566 */ 567 var setPositionProperty = function(value, type, duration, params) { 568 var animateObj, propValue; 569 // use CSS transform 570 if (slider.usingCSS) { 571 // determine the translate3d value 572 propValue = slider.settings.mode === 'vertical' ? 'translate3d(0, ' + value + 'px, 0)' : 'translate3d(' + value + 'px, 0, 0)'; 573 // add the CSS transition-duration 574 el.css('-' + slider.cssPrefix + '-transition-duration', duration / 1000 + 's'); 575 if (type === 'slide') { 576 // set the property value 577 el.css(slider.animProp, propValue); 578 if (duration !== 0) { 579 // add a callback method - executes when CSS transition completes 580 el.on('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(e) { 581 //make sure it's the correct one 582 if (!$(e.target).is(el)) { return; } 583 // remove the callback 584 el.off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); 585 updateAfterSlideTransition(); 586 }); 587 } else { //duration = 0 588 updateAfterSlideTransition(); 589 } 590 } else if (type === 'reset') { 591 el.css(slider.animProp, propValue); 592 } else if (type === 'ticker') { 593 // make the transition use 'linear' 594 el.css('-' + slider.cssPrefix + '-transition-timing-function', 'linear'); 595 el.css(slider.animProp, propValue); 596 if (duration !== 0) { 597 el.on('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(e) { 598 //make sure it's the correct one 599 if (!$(e.target).is(el)) { return; } 600 // remove the callback 601 el.off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); 602 // reset the position 603 setPositionProperty(params.resetValue, 'reset', 0); 604 // start the loop again 605 tickerLoop(); 606 }); 607 } else { //duration = 0 608 setPositionProperty(params.resetValue, 'reset', 0); 609 tickerLoop(); 610 } 611 } 612 // use JS animate 613 } else { 614 animateObj = {}; 615 animateObj[slider.animProp] = value; 616 if (type === 'slide') { 617 el.animate(animateObj, duration, slider.settings.easing, function() { 618 updateAfterSlideTransition(); 619 }); 620 } else if (type === 'reset') { 621 el.css(slider.animProp, value); 622 } else if (type === 'ticker') { 623 el.animate(animateObj, duration, 'linear', function() { 624 setPositionProperty(params.resetValue, 'reset', 0); 625 // run the recursive loop after animation 626 tickerLoop(); 627 }); 628 } 629 } 630 }; 631 632 /** 633 * Populates the pager with proper amount of pages 634 */ 635 var populatePager = function() { 636 var pagerHtml = '', 637 linkContent = '', 638 pagerQty = getPagerQty(); 639 // loop through each pager item 640 for (var i = 0; i < pagerQty; i++) { 641 linkContent = ''; 642 // if a buildPager function is supplied, use it to get pager link value, else use index + 1 643 if (slider.settings.buildPager && $.isFunction(slider.settings.buildPager) || slider.settings.pagerCustom) { 644 linkContent = slider.settings.buildPager(i); 645 slider.pagerEl.addClass('bx-custom-pager'); 646 } else { 647 linkContent = i + 1; 648 slider.pagerEl.addClass('bx-default-pager'); 649 } 650 // var linkContent = slider.settings.buildPager && $.isFunction(slider.settings.buildPager) ? slider.settings.buildPager(i) : i + 1; 651 // add the markup to the string 652 pagerHtml += '<div class="bx-pager-item"><a href="" data-slide-index="' + i + '" class="bx-pager-link">' + linkContent + '</a></div>'; 653 } 654 // populate the pager element with pager links 655 slider.pagerEl.html(pagerHtml); 656 }; 657 658 /** 659 * Appends the pager to the controls element 660 */ 661 var appendPager = function() { 662 if (!slider.settings.pagerCustom) { 663 // create the pager DOM element 664 slider.pagerEl = $('<div class="bx-pager" />'); 665 // if a pager selector was supplied, populate it with the pager 666 if (slider.settings.pagerSelector) { 667 $(slider.settings.pagerSelector).html(slider.pagerEl); 668 // if no pager selector was supplied, add it after the wrapper 669 } else { 670 slider.controls.el.addClass('bx-has-pager').append(slider.pagerEl); 671 } 672 // populate the pager 673 populatePager(); 674 } else { 675 slider.pagerEl = $(slider.settings.pagerCustom); 676 } 677 // assign the pager click binding 678 slider.pagerEl.on('click touchend', 'a', clickPagerBind); 679 }; 680 681 /** 682 * Appends prev / next controls to the controls element 683 */ 684 var appendControls = function() { 685 slider.controls.next = $('<a class="bx-next" href="">' + slider.settings.nextText + '</a>'); 686 slider.controls.prev = $('<a class="bx-prev" href="">' + slider.settings.prevText + '</a>'); 687 // add click actions to the controls 688 slider.controls.next.on('click touchend', clickNextBind); 689 slider.controls.prev.on('click touchend', clickPrevBind); 690 // if nextSelector was supplied, populate it 691 if (slider.settings.nextSelector) { 692 $(slider.settings.nextSelector).append(slider.controls.next); 693 } 694 // if prevSelector was supplied, populate it 695 if (slider.settings.prevSelector) { 696 $(slider.settings.prevSelector).append(slider.controls.prev); 697 } 698 // if no custom selectors were supplied 699 if (!slider.settings.nextSelector && !slider.settings.prevSelector) { 700 // add the controls to the DOM 701 slider.controls.directionEl = $('<div class="bx-controls-direction" />'); 702 // add the control elements to the directionEl 703 slider.controls.directionEl.append(slider.controls.prev).append(slider.controls.next); 704 // slider.viewport.append(slider.controls.directionEl); 705 slider.controls.el.addClass('bx-has-controls-direction').append(slider.controls.directionEl); 706 } 707 }; 708 709 /** 710 * Appends start / stop auto controls to the controls element 711 */ 712 var appendControlsAuto = function() { 713 slider.controls.start = $('<div class="bx-controls-auto-item"><a class="bx-start" href="">' + slider.settings.startText + '</a></div>'); 714 slider.controls.stop = $('<div class="bx-controls-auto-item"><a class="bx-stop" href="">' + slider.settings.stopText + '</a></div>'); 715 // add the controls to the DOM 716 slider.controls.autoEl = $('<div class="bx-controls-auto" />'); 717 // on click actions to the controls 718 slider.controls.autoEl.on('click', '.bx-start', clickStartBind); 719 slider.controls.autoEl.on('click', '.bx-stop', clickStopBind); 720 // if autoControlsCombine, insert only the "start" control 721 if (slider.settings.autoControlsCombine) { 722 slider.controls.autoEl.append(slider.controls.start); 723 // if autoControlsCombine is false, insert both controls 724 } else { 725 slider.controls.autoEl.append(slider.controls.start).append(slider.controls.stop); 726 } 727 // if auto controls selector was supplied, populate it with the controls 728 if (slider.settings.autoControlsSelector) { 729 $(slider.settings.autoControlsSelector).html(slider.controls.autoEl); 730 // if auto controls selector was not supplied, add it after the wrapper 731 } else { 732 slider.controls.el.addClass('bx-has-controls-auto').append(slider.controls.autoEl); 733 } 734 // update the auto controls 735 updateAutoControls(slider.settings.autoStart ? 'stop' : 'start'); 736 }; 737 738 /** 739 * Appends image captions to the DOM 740 */ 741 var appendCaptions = function() { 742 // cycle through each child 743 slider.children.each(function(index) { 744 // get the image title attribute 745 var title = $(this).find('img:first').attr('title'); 746 // append the caption 747 if (title !== undefined && ('' + title).length) { 748 $(this).append('<div class="bx-caption"><span>' + title + '</span></div>'); 749 } 750 }); 751 }; 752 753 /** 754 * Click next binding 755 * 756 * @param e (event) 757 * - DOM event object 758 */ 759 var clickNextBind = function(e) { 760 e.preventDefault(); 761 if (slider.controls.el.hasClass('disabled')) { return; } 762 // if auto show is running, stop it 763 if (slider.settings.auto && slider.settings.stopAutoOnClick) { el.stopAuto(); } 764 el.goToNextSlide(); 765 }; 766 767 /** 768 * Click prev binding 769 * 770 * @param e (event) 771 * - DOM event object 772 */ 773 var clickPrevBind = function(e) { 774 e.preventDefault(); 775 if (slider.controls.el.hasClass('disabled')) { return; } 776 // if auto show is running, stop it 777 if (slider.settings.auto && slider.settings.stopAutoOnClick) { el.stopAuto(); } 778 el.goToPrevSlide(); 779 }; 780 781 /** 782 * Click start binding 783 * 784 * @param e (event) 785 * - DOM event object 786 */ 787 var clickStartBind = function(e) { 788 el.startAuto(); 789 e.preventDefault(); 790 }; 791 792 /** 793 * Click stop binding 794 * 795 * @param e (event) 796 * - DOM event object 797 */ 798 var clickStopBind = function(e) { 799 el.stopAuto(); 800 e.preventDefault(); 801 }; 802 803 /** 804 * Click pager binding 805 * 806 * @param e (event) 807 * - DOM event object 808 */ 809 var clickPagerBind = function(e) { 810 var pagerLink, pagerIndex; 811 e.preventDefault(); 812 if (slider.controls.el.hasClass('disabled')) { 813 return; 814 } 815 // if auto show is running, stop it 816 if (slider.settings.auto && slider.settings.stopAutoOnClick) { el.stopAuto(); } 817 pagerLink = $(e.currentTarget); 818 if (pagerLink.attr('data-slide-index') !== undefined) { 819 pagerIndex = parseInt(pagerLink.attr('data-slide-index')); 820 // if clicked pager link is not active, continue with the goToSlide call 821 if (pagerIndex !== slider.active.index) { el.goToSlide(pagerIndex); } 822 } 823 }; 824 825 /** 826 * Updates the pager links with an active class 827 * 828 * @param slideIndex (int) 829 * - index of slide to make active 830 */ 831 var updatePagerActive = function(slideIndex) { 832 // if "short" pager type 833 var len = slider.children.length; // nb of children 834 if (slider.settings.pagerType === 'short') { 835 if (slider.settings.maxSlides > 1) { 836 len = Math.ceil(slider.children.length / slider.settings.maxSlides); 837 } 838 slider.pagerEl.html((slideIndex + 1) + slider.settings.pagerShortSeparator + len); 839 return; 840 } 841 // remove all pager active classes 842 slider.pagerEl.find('a').removeClass('active'); 843 // apply the active class for all pagers 844 slider.pagerEl.each(function(i, el) { $(el).find('a').eq(slideIndex).addClass('active'); }); 845 }; 846 847 /** 848 * Performs needed actions after a slide transition 849 */ 850 var updateAfterSlideTransition = function() { 851 // if infinite loop is true 852 if (slider.settings.infiniteLoop) { 853 var position = ''; 854 // first slide 855 if (slider.active.index === 0) { 856 // set the new position 857 position = slider.children.eq(0).position(); 858 // carousel, last slide 859 } else if (slider.active.index === getPagerQty() - 1 && slider.carousel) { 860 position = slider.children.eq((getPagerQty() - 1) * getMoveBy()).position(); 861 // last slide 862 } else if (slider.active.index === slider.children.length - 1) { 863 position = slider.children.eq(slider.children.length - 1).position(); 864 } 865 if (position) { 866 if (slider.settings.mode === 'horizontal') { setPositionProperty(-position.left, 'reset', 0); } 867 else if (slider.settings.mode === 'vertical') { setPositionProperty(-position.top, 'reset', 0); } 868 } 869 } 870 // declare that the transition is complete 871 slider.working = false; 872 // onSlideAfter callback 873 slider.settings.onSlideAfter.call(el, slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index); 874 }; 875 876 /** 877 * Updates the auto controls state (either active, or combined switch) 878 * 879 * @param state (string) "start", "stop" 880 * - the new state of the auto show 881 */ 882 var updateAutoControls = function(state) { 883 // if autoControlsCombine is true, replace the current control with the new state 884 if (slider.settings.autoControlsCombine) { 885 slider.controls.autoEl.html(slider.controls[state]); 886 // if autoControlsCombine is false, apply the "active" class to the appropriate control 887 } else { 888 slider.controls.autoEl.find('a').removeClass('active'); 889 slider.controls.autoEl.find('a:not(.bx-' + state + ')').addClass('active'); 890 } 891 }; 892 893 /** 894 * Updates the direction controls (checks if either should be hidden) 895 */ 896 var updateDirectionControls = function() { 897 if (getPagerQty() === 1) { 898 slider.controls.prev.addClass('disabled'); 899 slider.controls.next.addClass('disabled'); 900 } else if (!slider.settings.infiniteLoop && slider.settings.hideControlOnEnd) { 901 // if first slide 902 if (slider.active.index === 0) { 903 slider.controls.prev.addClass('disabled'); 904 slider.controls.next.removeClass('disabled'); 905 // if last slide 906 } else if (slider.active.index === getPagerQty() - 1) { 907 slider.controls.next.addClass('disabled'); 908 slider.controls.prev.removeClass('disabled'); 909 // if any slide in the middle 910 } else { 911 slider.controls.prev.removeClass('disabled'); 912 slider.controls.next.removeClass('disabled'); 913 } 914 } 915 }; 916 /* auto start and stop functions */ 917 var windowFocusHandler = function() { el.startAuto(); }; 918 var windowBlurHandler = function() { el.stopAuto(); }; 919 /** 920 * Initializes the auto process 921 */ 922 var initAuto = function() { 923 // if autoDelay was supplied, launch the auto show using a setTimeout() call 924 if (slider.settings.autoDelay > 0) { 925 setTimeout(el.startAuto, slider.settings.autoDelay); 926 // if autoDelay was not supplied, start the auto show normally 927 } else { 928 el.startAuto(); 929 930 //add focus and blur events to ensure its running if timeout gets paused 931 $(window).focus(windowFocusHandler).blur(windowBlurHandler); 932 } 933 // if autoHover is requested 934 if (slider.settings.autoHover) { 935 // on el hover 936 el.hover(function() { 937 // if the auto show is currently playing (has an active interval) 938 if (slider.interval) { 939 // stop the auto show and pass true argument which will prevent control update 940 el.stopAuto(true); 941 // create a new autoPaused value which will be used by the relative "mouseout" event 942 slider.autoPaused = true; 943 } 944 }, function() { 945 // if the autoPaused value was created be the prior "mouseover" event 946 if (slider.autoPaused) { 947 // start the auto show and pass true argument which will prevent control update 948 el.startAuto(true); 949 // reset the autoPaused value 950 slider.autoPaused = null; 951 } 952 }); 953 } 954 }; 955 956 /** 957 * Initializes the ticker process 958 */ 959 var initTicker = function() { 960 var startPosition = 0, 961 position, transform, value, idx, ratio, property, newSpeed, totalDimens; 962 // if autoDirection is "next", append a clone of the entire slider 963 if (slider.settings.autoDirection === 'next') { 964 el.append(slider.children.clone().addClass('bx-clone')); 965 // if autoDirection is "prev", prepend a clone of the entire slider, and set the left position 966 } else { 967 el.prepend(slider.children.clone().addClass('bx-clone')); 968 position = slider.children.first().position(); 969 startPosition = slider.settings.mode === 'horizontal' ? -position.left : -position.top; 970 } 971 setPositionProperty(startPosition, 'reset', 0); 972 // do not allow controls in ticker mode 973 slider.settings.pager = false; 974 slider.settings.controls = false; 975 slider.settings.autoControls = false; 976 // if autoHover is requested 977 if (slider.settings.tickerHover) { 978 if (slider.usingCSS) { 979 idx = slider.settings.mode === 'horizontal' ? 4 : 5; 980 slider.viewport.hover(function() { 981 transform = el.css('-' + slider.cssPrefix + '-transform'); 982 value = parseFloat(transform.split(',')[idx]); 983 setPositionProperty(value, 'reset', 0); 984 }, function() { 985 totalDimens = 0; 986 slider.children.each(function(index) { 987 totalDimens += slider.settings.mode === 'horizontal' ? $(this).outerWidth(true) : $(this).outerHeight(true); 988 }); 989 // calculate the speed ratio (used to determine the new speed to finish the paused animation) 990 ratio = slider.settings.speed / totalDimens; 991 // determine which property to use 992 property = slider.settings.mode === 'horizontal' ? 'left' : 'top'; 993 // calculate the new speed 994 newSpeed = ratio * (totalDimens - (Math.abs(parseInt(value)))); 995 tickerLoop(newSpeed); 996 }); 997 } else { 998 // on el hover 999 slider.viewport.hover(function() { 1000 el.stop(); 1001 }, function() { 1002 // calculate the total width of children (used to calculate the speed ratio) 1003 totalDimens = 0; 1004 slider.children.each(function(index) { 1005 totalDimens += slider.settings.mode === 'horizontal' ? $(this).outerWidth(true) : $(this).outerHeight(true); 1006 }); 1007 // calculate the speed ratio (used to determine the new speed to finish the paused animation) 1008 ratio = slider.settings.speed / totalDimens; 1009 // determine which property to use 1010 property = slider.settings.mode === 'horizontal' ? 'left' : 'top'; 1011 // calculate the new speed 1012 newSpeed = ratio * (totalDimens - (Math.abs(parseInt(el.css(property))))); 1013 tickerLoop(newSpeed); 1014 }); 1015 } 1016 } 1017 // start the ticker loop 1018 tickerLoop(); 1019 }; 1020 1021 /** 1022 * Runs a continuous loop, news ticker-style 1023 */ 1024 var tickerLoop = function(resumeSpeed) { 1025 var speed = resumeSpeed ? resumeSpeed : slider.settings.speed, 1026 position = {left: 0, top: 0}, 1027 reset = {left: 0, top: 0}, 1028 animateProperty, resetValue, params; 1029 1030 // if "next" animate left position to last child, then reset left to 0 1031 if (slider.settings.autoDirection === 'next') { 1032 position = el.find('.bx-clone').first().position(); 1033 // if "prev" animate left position to 0, then reset left to first non-clone child 1034 } else { 1035 reset = slider.children.first().position(); 1036 } 1037 animateProperty = slider.settings.mode === 'horizontal' ? -position.left : -position.top; 1038 resetValue = slider.settings.mode === 'horizontal' ? -reset.left : -reset.top; 1039 params = {resetValue: resetValue}; 1040 setPositionProperty(animateProperty, 'ticker', speed, params); 1041 }; 1042 1043 /** 1044 * Check if el is on screen 1045 */ 1046 var isOnScreen = function(el) { 1047 var win = $(window), 1048 viewport = { 1049 top: win.scrollTop(), 1050 left: win.scrollLeft() 1051 }, 1052 bounds = el.offset(); 1053 1054 viewport.right = viewport.left + win.width(); 1055 viewport.bottom = viewport.top + win.height(); 1056 bounds.right = bounds.left + el.outerWidth(); 1057 bounds.bottom = bounds.top + el.outerHeight(); 1058 1059 return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom)); 1060 }; 1061 1062 /** 1063 * Initializes keyboard events 1064 */ 1065 var keyPress = function(e) { 1066 var activeElementTag = document.activeElement.tagName.toLowerCase(), 1067 tagFilters = 'input|textarea', 1068 p = new RegExp(activeElementTag,['i']), 1069 result = p.exec(tagFilters); 1070 1071 if (result == null && isOnScreen(el)) { 1072 if (e.keyCode === 39) { 1073 clickNextBind(e); 1074 return false; 1075 } else if (e.keyCode === 37) { 1076 clickPrevBind(e); 1077 return false; 1078 } 1079 } 1080 }; 1081 1082 /** 1083 * Initializes touch events 1084 */ 1085 var initTouch = function() { 1086 // initialize object to contain all touch values 1087 slider.touch = { 1088 start: {x: 0, y: 0}, 1089 end: {x: 0, y: 0} 1090 }; 1091 slider.viewport.on('touchstart MSPointerDown pointerdown', onTouchStart); 1092 1093 //for browsers that have implemented pointer events and fire a click after 1094 //every pointerup regardless of whether pointerup is on same screen location as pointerdown or not 1095 slider.viewport.on('click', '.bxslider a', function(e) { 1096 if (slider.viewport.hasClass('click-disabled')) { 1097 e.preventDefault(); 1098 slider.viewport.removeClass('click-disabled'); 1099 } 1100 }); 1101 }; 1102 1103 /** 1104 * Event handler for "touchstart" 1105 * 1106 * @param e (event) 1107 * - DOM event object 1108 */ 1109 var onTouchStart = function(e) { 1110 //
vendor: 4,928 bytes, lines 1110-1234
1110watch only for left mouse, touch contact and pen contact 1111 // touchstart event object doesn`t have button property 1112 if (e.type !== 'touchstart' && e.button !== 0) { 1113 return; 1114 } 1115 // e.preventDefault(); 1116 //disable slider controls while user is interacting with slides to avoid slider freeze that happens on touch devices when a slide swipe happens immediately after interacting with slider controls 1117 slider.controls.el.addClass('disabled'); 1118 1119 if (slider.working) { 1120 slider.controls.el.removeClass('disabled'); 1121 } else { 1122 // record the original position when touch starts 1123 slider.touch.originalPos = el.position(); 1124 var orig = e.originalEvent, 1125 touchPoints = (typeof orig.changedTouches !== 'undefined') ? orig.changedTouches : [orig]; 1126 var chromePointerEvents = typeof PointerEvent === 'function'; 1127 if (chromePointerEvents) { 1128 if (orig.pointerId === undefined) { 1129 return; 1130 } 1131 } 1132 // record the starting touch x, y coordinates 1133 slider.touch.start.x = touchPoints[0].pageX; 1134 slider.touch.start.y = touchPoints[0].pageY; 1135 1136 if (slider.viewport.get(0).setPointerCapture) { 1137 slider.pointerId = orig.pointerId; 1138 slider.viewport.get(0).setPointerCapture(slider.pointerId); 1139 } 1140 // store original event data for click fixation 1141 slider.originalClickTarget = orig.originalTarget || orig.target; 1142 slider.originalClickButton = orig.button; 1143 slider.originalClickButtons = orig.buttons; 1144 slider.originalEventType = orig.type; 1145 // at this moment we don`t know what it is click or swipe 1146 slider.hasMove = false; 1147 // on a "touchmove" event to the viewport 1148 slider.viewport.on('touchmove MSPointerMove pointermove', onTouchMove); 1149 // on a "touchend" event to the viewport 1150 slider.viewport.on('touchend MSPointerUp pointerup', onTouchEnd); 1151 slider.viewport.on('MSPointerCancel pointercancel', onPointerCancel); 1152 } 1153 }; 1154 1155 /** 1156 * Cancel Pointer for Windows Phone 1157 * 1158 * @param e (event) 1159 * - DOM event object 1160 */ 1161 var onPointerCancel = function(e) { 1162 e.preventDefault(); 1163 /* onPointerCancel handler is needed to deal with situations when a touchend 1164 doesn't fire after a touchstart (this happens on windows phones only) */ 1165 setPositionProperty(slider.touch.originalPos.left, 'reset', 0); 1166 1167 //remove handlers 1168 slider.controls.el.removeClass('disabled'); 1169 slider.viewport.off('MSPointerCancel pointercancel', onPointerCancel); 1170 slider.viewport.off('touchmove MSPointerMove pointermove', onTouchMove); 1171 slider.viewport.off('touchend MSPointerUp pointerup', onTouchEnd); 1172 if (slider.viewport.get(0).releasePointerCapture) { 1173 slider.viewport.get(0).releasePointerCapture(slider.pointerId); 1174 } 1175 }; 1176 1177 /** 1178 * Event handler for "touchmove" 1179 * 1180 * @param e (event) 1181 * - DOM event object 1182 */ 1183 var onTouchMove = function(e) { 1184 var orig = e.originalEvent, 1185 touchPoints = (typeof orig.changedTouches !== 'undefined') ? orig.changedTouches : [orig], 1186 // if scrolling on y axis, do not prevent default 1187 xMovement = Math.abs(touchPoints[0].pageX - slider.touch.start.x), 1188 yMovement = Math.abs(touchPoints[0].pageY - slider.touch.start.y), 1189 value = 0, 1190 change = 0; 1191 // this is swipe 1192 slider.hasMove = true; 1193 1194 // x axis swipe 1195 if ((xMovement * 3) > yMovement && slider.settings.preventDefaultSwipeX) { 1196 e.preventDefault(); 1197 // y axis swipe 1198 } else if ((yMovement * 3) > xMovement && slider.settings.preventDefaultSwipeY) { 1199 e.preventDefault(); 1200 } 1201 if (e.type !== 'touchmove') { 1202 e.preventDefault(); 1203 } 1204 1205 if (slider.settings.mode !== 'fade' && slider.settings.oneToOneTouch) { 1206 // if horizontal, drag along x axis 1207 if (slider.settings.mode === 'horizontal') { 1208 change = touchPoints[0].pageX - slider.touch.start.x; 1209 value = slider.touch.originalPos.left + change; 1210 // if vertical, drag along y axis 1211 } else { 1212 change = touchPoints[0].pageY - slider.touch.start.y; 1213 value = slider.touch.originalPos.top + change; 1214 } 1215 setPositionProperty(value, 'reset', 0); 1216 } 1217 }; 1218 1219 /** 1220 * Event handler for "touchend" 1221 * 1222 * @param e (event) 1223 * - DOM event object 1224 */ 1225 var onTouchEnd = function(e) { 1226 var orig = e.originalEvent, 1227 touchPoints = (typeof orig.changedTouches !== 'undefined') ? orig.changedTouches : [orig], 1228 // if scrolling on y axis, do not prevent default 1229 xMovement = Math.abs(touchPoints[0].pageX - slider.touch.start.x), 1230 yMovement = Math.abs(touchPoints[0].pageY - slider.touch.start.y), 1231 value = 0, 1232 change = 0; 1233 // this is swipe 1234 slider.hasMove = true;
vendor: 18,127 bytes, lines 1235-1679
1235 1236 e.preventDefault(); 1237 slider.viewport.off('touchmove MSPointerMove pointermove', onTouchMove); 1238 //enable slider controls as soon as user stops interacing with slides 1239 slider.controls.el.removeClass('disabled'); 1240 var orig = e.originalEvent, 1241 touchPoints = (typeof orig.changedTouches !== 'undefined') ? orig.changedTouches : [orig], 1242 value = 0, 1243 distance = 0; 1244 // record end x, y positions 1245 slider.touch.end.x = touchPoints[0].pageX; 1246 slider.touch.end.y = touchPoints[0].pageY; 1247 // if fade mode, check if absolute x distance clears the threshold 1248 if (slider.settings.mode === 'fade') { 1249 distance = Math.abs(slider.touch.start.x - slider.touch.end.x); 1250 if (distance >= slider.settings.swipeThreshold) { 1251 if (slider.touch.start.x > slider.touch.end.x) { 1252 el.goToNextSlide(); 1253 } else { 1254 el.goToPrevSlide(); 1255 } 1256 el.stopAuto(); 1257 } 1258 // not fade mode 1259 } else { 1260 // calculate distance and el's animate property 1261 if (slider.settings.mode === 'horizontal') { 1262 distance = slider.touch.end.x - slider.touch.start.x; 1263 value = slider.touch.originalPos.left; 1264 } else { 1265 distance = slider.touch.end.y - slider.touch.start.y; 1266 value = slider.touch.originalPos.top; 1267 } 1268 // if not infinite loop and first / last slide, do not attempt a slide transition 1269 if (!slider.settings.infiniteLoop && ((slider.active.index === 0 && distance > 0) || (slider.active.last && distance < 0))) { 1270 setPositionProperty(value, 'reset', 200); 1271 } else { 1272 // check if distance clears threshold 1273 if (Math.abs(distance) >= slider.settings.swipeThreshold) { 1274 if (distance < 0) { 1275 el.goToNextSlide(); 1276 } else { 1277 el.goToPrevSlide(); 1278 } 1279 el.stopAuto(); 1280 } else { 1281 // el.animate(property, 200); 1282 setPositionProperty(value, 'reset', 200); 1283 } 1284 } 1285 } 1286 slider.viewport.off('touchend MSPointerUp pointerup', onTouchEnd); 1287 1288 if (slider.viewport.get(0).releasePointerCapture) { 1289 slider.viewport.get(0).releasePointerCapture(slider.pointerId); 1290 } 1291 // if slider had swipe with left mouse, touch contact and pen contact 1292 if (slider.hasMove === false && (slider.originalClickButton === 0 || slider.originalEventType === 'touchstart')) { 1293 // trigger click event (fix for Firefox59 and PointerEvent standard compatibility) 1294 $(slider.originalClickTarget).trigger({ 1295 type: 'click', 1296 button: slider.originalClickButton, 1297 buttons: slider.originalClickButtons 1298 }); 1299 } 1300 }; 1301 1302 /** 1303 * Window resize event callback 1304 */ 1305 var resizeWindow = function(e) { 1306 // don't do anything if slider isn't initialized. 1307 if (!slider.initialized) { return; } 1308 // Delay if slider working. 1309 if (slider.working) { 1310 window.setTimeout(resizeWindow, 10); 1311 } else { 1312 // get the new window dimens (again, thank you IE) 1313 var windowWidthNew = $(window).width(), 1314 windowHeightNew = $(window).height(); 1315 // make sure that it is a true window resize 1316 // *we must check this because our dinosaur friend IE fires a window resize event when certain DOM elements 1317 // are resized. Can you just die already?* 1318 if (windowWidth !== windowWidthNew || windowHeight !== windowHeightNew) { 1319 // set the new window dimens 1320 windowWidth = windowWidthNew; 1321 windowHeight = windowHeightNew; 1322 // update all dynamic elements 1323 el.redrawSlider(); 1324 // Call user resize handler 1325 slider.settings.onSliderResize.call(el, slider.active.index); 1326 } 1327 } 1328 }; 1329 1330 /** 1331 * Adds an aria-hidden=true attribute to each element 1332 * 1333 * @param startVisibleIndex (int) 1334 * - the first visible element's index 1335 */ 1336 var applyAriaHiddenAttributes = function(startVisibleIndex) { 1337 var numberOfSlidesShowing = getNumberSlidesShowing(); 1338 // only apply attributes if the setting is enabled and not in ticker mode 1339 if (slider.settings.ariaHidden && !slider.settings.ticker) { 1340 // add aria-hidden=true to all elements 1341 slider.children.attr('aria-hidden', 'true'); 1342 // get the visible elements and change to aria-hidden=false 1343 slider.children.slice(startVisibleIndex, startVisibleIndex + numberOfSlidesShowing).attr('aria-hidden', 'false'); 1344 } 1345 }; 1346 1347 /** 1348 * Returns index according to present page range 1349 * 1350 * @param slideOndex (int) 1351 * - the desired slide index 1352 */ 1353 var setSlideIndex = function(slideIndex) { 1354 if (slideIndex < 0) { 1355 if (slider.settings.infiniteLoop) { 1356 return getPagerQty() - 1; 1357 }else { 1358 //we don't go to undefined slides 1359 return slider.active.index; 1360 } 1361 // if slideIndex is greater than children length, set active index to 0 (this happens during infinite loop) 1362 } else if (slideIndex >= getPagerQty()) { 1363 if (slider.settings.infiniteLoop) { 1364 return 0; 1365 } else { 1366 //we don't move to undefined pages 1367 return slider.active.index; 1368 } 1369 // set active index to requested slide 1370 } else { 1371 return slideIndex; 1372 } 1373 }; 1374 1375 /** 1376 * =================================================================================== 1377 * = PUBLIC FUNCTIONS 1378 * =================================================================================== 1379 */ 1380 1381 /** 1382 * Performs slide transition to the specified slide 1383 * 1384 * @param slideIndex (int) 1385 * - the destination slide's index (zero-based) 1386 * 1387 * @param direction (string) 1388 * - INTERNAL USE ONLY - the direction of travel ("prev" / "next") 1389 */ 1390 el.goToSlide = function(slideIndex, direction) { 1391 // onSlideBefore, onSlideNext, onSlidePrev callbacks 1392 // Allow transition canceling based on returned value 1393 var performTransition = true, 1394 moveBy = 0, 1395 position = {left: 0, top: 0}, 1396 lastChild = null, 1397 lastShowingIndex, eq, value, requestEl; 1398 // store the old index 1399 slider.oldIndex = slider.active.index; 1400 //set new index 1401 slider.active.index = setSlideIndex(slideIndex); 1402 1403 // if plugin is currently in motion, ignore request 1404 if (slider.working || slider.active.index === slider.oldIndex) { return; } 1405 // declare that plugin is in motion 1406 slider.working = true; 1407 1408 performTransition = slider.settings.onSlideBefore.call(el, slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index); 1409 1410 // If transitions canceled, reset and return 1411 if (typeof (performTransition) !== 'undefined' && !performTransition) { 1412 slider.active.index = slider.oldIndex; // restore old index 1413 slider.working = false; // is not in motion 1414 return; 1415 } 1416 1417 if (direction === 'next') { 1418 // Prevent canceling in future functions or lack there-of from negating previous commands to cancel 1419 if (!slider.settings.onSlideNext.call(el, slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index)) { 1420 performTransition = false; 1421 } 1422 } else if (direction === 'prev') { 1423 // Prevent canceling in future functions or lack there-of from negating previous commands to cancel 1424 if (!slider.settings.onSlidePrev.call(el, slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index)) { 1425 performTransition = false; 1426 } 1427 } 1428 1429 // check if last slide 1430 slider.active.last = slider.active.index >= getPagerQty() - 1; 1431 // update the pager with active class 1432 if (slider.settings.pager || slider.settings.pagerCustom) { updatePagerActive(slider.active.index); } 1433 // // check for direction control update 1434 if (slider.settings.controls) { updateDirectionControls(); } 1435 // if slider is set to mode: "fade" 1436 if (slider.settings.mode === 'fade') { 1437 // if adaptiveHeight is true and next height is different from current height, animate to the new height 1438 if (slider.settings.adaptiveHeight && slider.viewport.height() !== getViewportHeight()) { 1439 slider.viewport.animate({height: getViewportHeight()}, slider.settings.adaptiveHeightSpeed); 1440 } 1441 // fade out the visible child and reset its z-index value 1442 slider.children.filter(':visible').fadeOut(slider.settings.speed).css({zIndex: 0}); 1443 // fade in the newly requested slide 1444 slider.children.eq(slider.active.index).css('zIndex', slider.settings.slideZIndex + 1).fadeIn(slider.settings.speed, function() { 1445 $(this).css('zIndex', slider.settings.slideZIndex); 1446 updateAfterSlideTransition(); 1447 }); 1448 // slider mode is not "fade" 1449 } else { 1450 // if adaptiveHeight is true and next height is different from current height, animate to the new height 1451 if (slider.settings.adaptiveHeight && slider.viewport.height() !== getViewportHeight()) { 1452 slider.viewport.animate({height: getViewportHeight()}, slider.settings.adaptiveHeightSpeed); 1453 } 1454 // if carousel and not infinite loop 1455 if (!slider.settings.infiniteLoop && slider.carousel && slider.active.last) { 1456 if (slider.settings.mode === 'horizontal') { 1457 // get the last child position 1458 lastChild = slider.children.eq(slider.children.length - 1); 1459 position = lastChild.position(); 1460 // calculate the position of the last slide 1461 moveBy = slider.viewport.width() - lastChild.outerWidth(); 1462 } else { 1463 // get last showing index position 1464 lastShowingIndex = slider.children.length - slider.settings.minSlides; 1465 position = slider.children.eq(lastShowingIndex).position(); 1466 } 1467 // horizontal carousel, going previous while on first slide (infiniteLoop mode) 1468 } else if (slider.carousel && slider.active.last && direction === 'prev') { 1469 // get the last child position 1470 eq = slider.settings.moveSlides === 1 ? slider.settings.maxSlides - getMoveBy() : ((getPagerQty() - 1) * getMoveBy()) - (slider.children.length - slider.settings.maxSlides); 1471 lastChild = el.children('.bx-clone').eq(eq); 1472 position = lastChild.position(); 1473 // if infinite loop and "Next" is clicked on the last slide 1474 } else if (direction === 'next' && slider.active.index === 0) { 1475 // get the last clone position 1476 position = el.find('> .bx-clone').eq(slider.settings.maxSlides).position(); 1477 slider.active.last = false; 1478 // normal non-zero requests 1479 } else if (slideIndex >= 0) { 1480 //parseInt is applied to allow floats for slides/page 1481 requestEl = slideIndex * parseInt(getMoveBy()); 1482 position = slider.children.eq(requestEl).position(); 1483 } 1484 1485 /* If the position doesn't exist 1486 * (e.g. if you destroy the slider on a next click), 1487 * it doesn't throw an error. 1488 */ 1489 if (typeof (position) !== 'undefined') { 1490 value = slider.settings.mode === 'horizontal' ? -(position.left - moveBy) : -position.top; 1491 // plugin values to be animated 1492 setPositionProperty(value, 'slide', slider.settings.speed); 1493 } 1494 slider.working = false; 1495 } 1496 if (slider.settings.ariaHidden) { applyAriaHiddenAttributes(slider.active.index * getMoveBy()); } 1497 }; 1498 1499 /** 1500 * Transitions to the next slide in the show 1501 */ 1502 el.goToNextSlide = function() { 1503 // if infiniteLoop is false and last page is showing, disregard call 1504 if (!slider.settings.infiniteLoop && slider.active.last) { return; } 1505 if (slider.working === true){ return ;} 1506 var pagerIndex = parseInt(slider.active.index) + 1; 1507 el.goToSlide(pagerIndex, 'next'); 1508 }; 1509 1510 /** 1511 * Transitions to the prev slide in the show 1512 */ 1513 el.goToPrevSlide = function() { 1514 // if infiniteLoop is false and last page is showing, disregard call 1515 if (!slider.settings.infiniteLoop && slider.active.index === 0) { return; } 1516 if (slider.working === true){ return ;} 1517 var pagerIndex = parseInt(slider.active.index) - 1; 1518 el.goToSlide(pagerIndex, 'prev'); 1519 }; 1520 1521 /** 1522 * Starts the auto show 1523 * 1524 * @param preventControlUpdate (boolean) 1525 * - if true, auto controls state will not be updated 1526 */ 1527 el.startAuto = function(preventControlUpdate) { 1528 // if an interval already exists, disregard call 1529 if (slider.interval) { return; } 1530 // create an interval 1531 slider.interval = setInterval(function() { 1532 if (slider.settings.autoDirection === 'next') { 1533 el.goToNextSlide(); 1534 } else { 1535 el.goToPrevSlide(); 1536 } 1537 }, slider.settings.pause); 1538 //allback for when the auto rotate status changes 1539 slider.settings.onAutoChange.call(el, true); 1540 // if auto controls are displayed and preventControlUpdate is not true 1541 if (slider.settings.autoControls && preventControlUpdate !== true) { updateAutoControls('stop'); } 1542 }; 1543 1544 /** 1545 * Stops the auto show 1546 * 1547 * @param preventControlUpdate (boolean) 1548 * - if true, auto controls state will not be updated 1549 */ 1550 el.stopAuto = function(preventControlUpdate) { 1551 // if slider is auto paused, just clear that state 1552 if (slider.autoPaused) slider.autoPaused = false; 1553 // if no interval exists, disregard call 1554 if (!slider.interval) { return; } 1555 // clear the interval 1556 clearInterval(slider.interval); 1557 slider.interval = null; 1558 //allback for when the auto rotate status changes 1559 slider.settings.onAutoChange.call(el, false); 1560 // if auto controls are displayed and preventControlUpdate is not true 1561 if (slider.settings.autoControls && preventControlUpdate !== true) { updateAutoControls('start'); } 1562 }; 1563 1564 /** 1565 * Returns current slide index (zero-based) 1566 */ 1567 el.getCurrentSlide = function() { 1568 return slider.active.index; 1569 }; 1570 1571 /** 1572 * Returns current slide element 1573 */ 1574 el.getCurrentSlideElement = function() { 1575 return slider.children.eq(slider.active.index); 1576 }; 1577 1578 /** 1579 * Returns a slide element 1580 * @param index (int) 1581 * - The index (zero-based) of the element you want returned. 1582 */ 1583 el.getSlideElement = function(index) { 1584 return slider.children.eq(index); 1585 }; 1586 1587 /** 1588 * Returns number of slides in show 1589 */ 1590 el.getSlideCount = function() { 1591 return slider.children.length; 1592 }; 1593 1594 /** 1595 * Return slider.working variable 1596 */ 1597 el.isWorking = function() { 1598 return slider.working; 1599 }; 1600 1601 /** 1602 * Update all dynamic slider elements 1603 */ 1604 el.redrawSlider = function() { 1605 // resize all children in ratio to new screen size 1606 slider.children.add(el.find('.bx-clone')).outerWidth(getSlideWidth()); 1607 // adjust the height 1608 slider.viewport.css('height', getViewportHeight()); 1609 // update the slide position 1610 if (!slider.settings.ticker) { setSlidePosition(); } 1611 // if active.last was true before the screen resize, we want 1612 // to keep it last no matter what screen size we end on 1613 if (slider.active.last) { slider.active.index = getPagerQty() - 1; } 1614 // if the active index (page) no longer exists due to the resize, simply set the index as last 1615 if (slider.active.index >= getPagerQty()) { slider.active.last = true; } 1616 // if a pager is being displayed and a custom pager is not being used, update it 1617 if (slider.settings.pager && !slider.settings.pagerCustom) { 1618 populatePager(); 1619 updatePagerActive(slider.active.index); 1620 } 1621 if (slider.settings.ariaHidden) { applyAriaHiddenAttributes(slider.active.index * getMoveBy()); } 1622 }; 1623 1624 /** 1625 * Destroy the current instance of the slider (revert everything back to original state) 1626 */ 1627 el.destroySlider = function() { 1628 // don't do anything if slider has already been destroyed 1629 if (!slider.initialized) { return; } 1630 slider.initialized = false; 1631 $('.bx-clone', this).remove(); 1632 slider.children.each(function() { 1633 if ($(this).data('origStyle') !== undefined) { 1634 $(this).attr('style', $(this).data('origStyle')); 1635 } else { 1636 $(this).removeAttr('style'); 1637 } 1638 }); 1639 if ($(this).data('origStyle') !== undefined) { 1640 this.attr('style', $(this).data('origStyle')); 1641 } else { 1642 $(this).removeAttr('style'); 1643 } 1644 $(this).unwrap().unwrap(); 1645 if (slider.controls.el) { slider.controls.el.remove(); } 1646 if (slider.controls.next) { slider.controls.next.remove(); } 1647 if (slider.controls.prev) { slider.controls.prev.remove(); } 1648 if (slider.pagerEl && slider.settings.controls && !slider.settings.pagerCustom) { slider.pagerEl.remove(); } 1649 $('.bx-caption', this).remove(); 1650 if (slider.controls.autoEl) { slider.controls.autoEl.remove(); } 1651 clearInterval(slider.interval); 1652 if (slider.settings.responsive) { $(window).off('resize', resizeWindow); } 1653 if (slider.settings.keyboardEnabled) { $(document).off('keydown', keyPress); } 1654 //remove self reference in data 1655 $(this).removeData('bxSlider'); 1656 // remove global window handlers 1657 $(window).off('blur', windowBlurHandler).off('focus', windowFocusHandler); 1658 }; 1659 1660 /** 1661 * Reload the slider (revert all DOM changes, and re-initialize) 1662 */ 1663 el.reloadSlider = function(settings) { 1664 if (settings !== undefined) { options = settings; } 1665 el.destroySlider(); 1666 init(); 1667 //store reference to self in order to access public functions later 1668 $(el).data('bxSlider', this); 1669 }; 1670 1671 init(); 1672 1673 $(el).data('bxSlider', this); 1674 1675 // returns the current jQuery object 1676 return this; 1677 }; 1678 1679})(jQuery);
1680 1681$(document).ready(function(){ 1682 $('.bxslider').each(function() { 1683 1684 //########################## 1685 //Check data-Attributes 1686 //########################## 1687 var options=new Object; 1688 //Type of transition between slides: 'horizontal', 'vertical', 'fade' 1689 if(attr=$(this).attr('data-mode')) { options.mode=attr; } else { options.mode='fade'; } 1690 //Slide transition duration (in ms) 1691 if(attr=$(this).attr('data-speed')) { options.speed=attr; } else { options.speed=3000; } 1692 //Margin between each slide 1693 if(attr=$(this).attr('data-slideMargin')) { options.slideMargin=attr; } else { options.slideMargin='0'; } 1694 //Starting slide index (zero-based) 1695 if(attr=$(this).attr('data-startSlide')) { options.startSlide=attr; } else { options.startSlide='0'; } 1696 //Start slider on a random slide: true/false 1697 if(attr=$(this).attr('data-randomStart')) { options.randomStart=attr; } else { options.randomStart=false; } 1698 //If true, clicking "Next" while on the last slide will transition to the first slide and vice-versa: true/false 1699 if(attr=$(this).attr('data-infiniteLoop')) { options.infiniteLoop=attr; } else { options.infiniteLoop=true; } 1700 //If true, "Next" control will be hidden on last slide and vice-versa: true/false 1701 if(attr=$(this).attr('data-hideControlOnEnd')) { options.hideControlOnEnd=attr; } else { options.hideControlOnEnd=false; } 1702 //The type of "easing" to use during transitions: 'linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out' 1703 if(attr=$(this).attr('data-easing')) { options.easing=attr; } else { options.easing='ease-out'; } 1704 //Include image captions. Captions are derived from the image's title attribute: true/false 1705 if(attr=$(this).attr('data-captions')) { options.captions=attr; } else { options.captions=false; } 1706 //Use slider in ticker mode (similar to a news ticker): true/false 1707 if(attr=$(this).attr('data-ticker')) { options.ticker=attr; } else { options.ticker=false; } 1708 //Ticker will pause when mouse hovers over slider. Note: this functionality does NOT work if using CSS transitions!: true/false 1709 if(attr=$(this).attr('data-tickerHover')) { options.tickerHover=attr; } else { options.tickerHover=false; } 1710 //Enable or disable auto resize of the slider. Useful if you need to use fixed width sliders.: true/false 1711 if(attr=$(this).attr('data-responsive')) { options.responsive=attr; } else { options.responsive=true; } 1712 //If 'all', preloads all images before starting the slider. If 'visible', preloads only images in the initially visible slides before starting the slider (tip: use 'visible' if all slides are identical dimensions): all, visible 1713 if(attr=$(this).attr('data-preloadImages')) { options.preloadImages=attr; } else { options.preloadImages='visible'; } 1714 //If true, a pager will be added: true/false 1715 if(attr=$(this).attr('data-pager')) { options.pager=attr; } else { options.pager=true; } 1716 //If true, "Next" / "Prev" controls will be added: true/false 1717 if(attr=$(this).attr('data-controls')) { options.controls=attr; } else { options.controls=true; } 1718 //Text to be used for the "Next" control 1719 if(attr=$(this).attr('data-nextText')) { options.nextText=attr; } else { options.nextText='weiter'; } 1720 //Text to be used for the "Prev" control 1721 if(attr=$(this).attr('data-prevText')) { options.prevText=attr; } else { options.prevText='zurück'; } 1722 //If true, "Start" / "Stop" controls will be added: true/false 1723 if(attr=$(this).attr('data-autoControls')) { options.autoControls=attr; } else { options.autoControls=true; } 1724 //If true, auto will stop on click 1725 if(attr=$(this).attr('data-stopAutoOnClick')) { options.stopAutoOnClick=attr; } else { options.stopAutoOnClick=false; } 1726 //Text to be used for the "Start" control 1727 if(attr=$(this).attr('data-startText')) { options.startText=attr; } else { options.startText='Start'; } 1728 //Text to be used for the "Stop" control 1729 if(attr=$(this).attr('data-stopText')) { options.stopText=attr; } else { options.stopText='Stop'; } 1730 //When slideshow is playing only "Stop" control is displayed and vice-versa: true/false 1731 if(attr=$(this).attr('data-autoControlsCombine')) { options.autoControlsCombine=attr; } else { options.autoControlsCombine=true; } 1732 //Slides will automatically transition: true/false 1733 if(attr=$(this).attr('data-auto')) { options.auto=attr; } else { options.auto=false; } 1734 //The amount of time (in ms) between each auto transition 1735 if(attr=$(this).attr('data-pause')) { options.pause=attr; } else { options.pause=12000; } 1736 //Auto show starts playing on load. If false, slideshow will start when the "Start" control is clicked 1737 if(attr=$(this).attr('data-autoStart')) { options.autoStart=attr; } else { options.autoStart=true; } 1738 //Auto show will pause when mouse hovers over slider: true/false 1739 if(attr=$(this).attr('data-autoHover')) { options.autoHover=attr; } else { options.autoHover=false; } 1740 //Time (in ms) auto show should wait before starting 1741 if(attr=$(this).attr('data-autoDelay')) { options.autoDelay=attr; } else { options.autoDelay=0; } 1742 //The minimum number of slides to be shown. Slides will be sized down if carousel becomes smaller than the original size.
1743 if(attr=$(this).attr('data-minSlides')) { options.minSlides=attr; } else { options.minSlides='1'; } 1744 //The maximum number of slides to be shown. Slides will be sized up if carousel becomes larger than the original size. 1745 if(attr=$(this).attr('data-maxSlides')) { options.maxSlides=attr; } else { options.maxSlides='1'; } 1746 //The number of slides to move on transition. This value must be >= minSlides, and <= maxSlides. If zero (default), the number of fully-visible slides will be used. 1747 if(attr=$(this).attr('data-moveSlides')) { options.moveSlides=attr; } else { options.moveSlides='0'; } 1748 //The width of each slide. This setting is required for all horizontal carousels! 1749 if(attr=$(this).attr('data-slideWidth')) { options.slideWidth=attr; } else { options.slideWidth='0'; } 1750 //TouchEnabled? 1751 if(attr=$(this).attr('data-touchEnabled')) { options.touchEnabled=attr; } else { options.touchEnabled=true; } 1752 //BGPos 1753 if(attr=$(this).attr('data-bgPos')) { options.bgPos=attr; } else { options.bgPos="center center"; } 1754 //OnSlideBefore 1755 if(attr=$(this).attr('data-beforechange')) { options.beforechange=attr; } else { options.beforechange=null; } 1756 1757 1758 function is_int(value){ 1759 if((parseFloat(value) == parseInt(value)) && !isNaN(value)){ 1760 return true; 1761 } else { 1762 return false; 1763 } 1764 } 1765 //console.log(options); 1766 $.each(options, function(index, value) { 1767 if(value=="true") { options[index]=true; } 1768 if(value=="false") { options[index]=false; } 1769 if(is_int(value)) { options[index]=value*1; } 1770 }); 1771 1772 if(options.beforechange!="" && typeof(window[options.beforechange])=="function") { 1773 options.onSlideBefore = function(currentSlideNumber, totalSlideQty, currentSlideHtmlObject) { 1774 window[options.beforechange](currentSlideNumber, totalSlideQty, currentSlideHtmlObject); 1775 }; 1776 } 1777 1778 //Funktion binden 1779 var slider=$(this).bxSlider(options); 1780 1781 //########################## 1782 //Bilder einlesen 1783 //########################## 1784 var bx = $(this); 1785 var bgSize=$(this).attr('data-bgSize'); 1786 var bgPos=$(this).attr('data-bgPos'); 1787 if(typeof(bgPos)=="undefined") { bgPos=options.bgPos; } 1788 if(attr=$(this).attr('data-src')) { 1789 var obj = {'src':attr}; 1790 $.post("core/json/picreader.php", obj, function(data, status) { 1791 var json = $.parseJSON(data); 1792 if(json.error) { 1793 bx.html(json.error); 1794 } 1795 else { 1796 var divs=""; 1797 for(var i=0;i<json.pics.length;i++) { 1798 //divs+="<div style=\"background-image:url('"+json.pics[i]+"');background-size:'"+bgSize+"'\"></div>"; 1799 // console.log(bgSize); 1800 divs+="<div style=\"background-image:url('"+json.pics[i]+"');background-repeat:no-repeat;background-size:"+bgSize+";background-position:"+bgPos+"\"></div>"; 1801 } 1802 bx.html(divs); 1803 1804 //zusätzliche option bgSize 1805 //Verhalten der Bilder im Hintergrund: cover/contain 1806 // if(attr=$(this).attr('data-bgSize')) { options.bgSize=attr; } else { options.bgSize='cover'; } 1807 if(bgSize) { options.bgSize=bgSize; } else { options.bgSize='cover'; } 1808 //Slider neu laden 1809 slider.destroySlider(); 1810 slider=bx.bxSlider(options); 1811 } 1812 }); 1813 } 1814 1815 1816 }) 1817});
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.