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