1(function ($, undefined) { 2 'use strict'; 3 var defaults = { 4 item: 5, 5 autoWidth: false, 6 slideMove: 1, 7 slideMargin: 10, 8 addClass: '', 9 mode: 'slide', 10 useCSS: true, 11 cssEasing: 'ease', //'cubic-bezier(0.25, 0, 0.25, 1)', 12 easing: 'linear', //'for jquery animation',// 13 speed: 400, //ms' 14 auto: false, 15 pauseOnHover: false, 16 loop: false, 17 slideEndAnimation: true, 18 pause: 2000, 19 keyPress: false, 20 controls: true, 21 prevHtml: '', 22 nextHtml: '', 23 rtl: false, 24 centerSlide: false, 25 adaptiveHeight: false, 26 vertical: false, 27 verticalHeight: 500, 28 vThumbWidth: 125, 29 thumbItem: 10, 30 pager: true, 31 gallery: false, 32 galleryMargin: 15, 33 thumbMargin: 15, 34 currentPagerPosition: 'middle', 35 enableTouch: true, 36 enableDrag: true, 37 freeMove: true, 38 swipeThreshold: 40
vendor: 8,000 bytes, lines 38-234
38, 39 responsive: [], 40 /* jshint ignore:start */ 41 onBeforeStart: function ($el) {}, 42 onSliderLoad: function ($el) {}, 43 onBeforeSlide: function ($el, scene) {}, 44 onAfterSlide: function ($el, scene) {}, 45 onBeforeNextSlide: function ($el, scene) {}, 46 onBeforePrevSlide: function ($el, scene) {} 47 /* jshint ignore:end */ 48 }; 49 $.fn.lightSlider = function (options) { 50 if (this.length === 0) { 51 return this; 52 } 53 54 if (this.length > 1) { 55 this.each(function () { 56 $(this).lightSlider(options); 57 }); 58 return this; 59 } 60 61 var plugin = {}, 62 settings = $.extend(true, {}, defaults, options), 63 settingsTemp = {}, 64 $el = this; 65 plugin.$el = this; 66 67 if (settings.mode === 'fade') { 68 settings.vertical = false; 69 } 70 var $children = $el.children(), 71 windowW = $(window).width(), 72 breakpoint = null, 73 resposiveObj = null, 74 length = 0, 75 w = 0, 76 on = false, 77 elSize = 0, 78 $slide = '', 79 scene = 0, 80 property = (settings.vertical === true) ? 'height' : 'width', 81 gutter = (settings.vertical === true) ? 'margin-bottom' : 'margin-right', 82 slideValue = 0, 83 pagerWidth = 0, 84 slideWidth = 0, 85 thumbWidth = 0, 86 interval = null, 87 isTouch = ('ontouchstart' in document.documentElement); 88 var refresh = {}; 89 90 refresh.chbreakpoint = function () { 91 windowW = $(window).width(); 92 if (settings.responsive.length) { 93 var item; 94 if (settings.autoWidth === false) { 95 item = settings.item; 96 } 97 if (windowW < settings.responsive[0].breakpoint) { 98 for (var i = 0; i < settings.responsive.length; i++) { 99 if (windowW < settings.responsive[i].breakpoint) { 100 breakpoint = settings.responsive[i].breakpoint; 101 resposiveObj = settings.responsive[i]; 102 } 103 } 104 } 105 if (typeof resposiveObj !== 'undefined' && resposiveObj !== null) { 106 for (var j in resposiveObj.settings) { 107 if (resposiveObj.settings.hasOwnProperty(j)) { 108 if (typeof settingsTemp[j] === 'undefined' || settingsTemp[j] === null) { 109 settingsTemp[j] = settings[j]; 110 } 111 settings[j] = resposiveObj.settings[j]; 112 } 113 } 114 } 115 if (!$.isEmptyObject(settingsTemp) && windowW > settings.responsive[0].breakpoint) { 116 for (var k in settingsTemp) { 117 if (settingsTemp.hasOwnProperty(k)) { 118 settings[k] = settingsTemp[k]; 119 } 120 } 121 } 122 if (settings.autoWidth === false) { 123 if (slideValue > 0 && slideWidth > 0) { 124 if (item !== settings.item) { 125 scene = Math.round(slideValue / ((slideWidth + settings.slideMargin) * settings.slideMove)); 126 } 127 } 128 } 129 } 130 }; 131 132 refresh.calSW = function () { 133 if (settings.autoWidth === false) { 134 slideWidth = (elSize - ((settings.item * (settings.slideMargin)) - settings.slideMargin)) / settings.item; 135 } 136 }; 137 138 refresh.calWidth = function (cln) { 139 var ln = cln === true ? $slide.find('.lslide').length : $children.length; 140 if (settings.autoWidth === false) { 141 w = ln * (slideWidth + settings.slideMargin); 142 } else { 143 w = 0; 144 for (var i = 0; i < ln; i++) { 145 w += (parseInt($children.eq(i).width()) + settings.slideMargin); 146 } 147 } 148 return w; 149 }; 150 plugin = { 151 doCss: function () { 152 var support = function () { 153 var transition = ['transition', 'MozTransition', 'WebkitTransition', 'OTransition', 'msTransition', 'KhtmlTransition']; 154 var root = document.documentElement; 155 for (var i = 0; i < transition.length; i++) { 156 if (transition[i] in root.style) { 157 return true; 158 } 159 } 160 }; 161 if (settings.useCSS && support()) { 162 return true; 163 } 164 return false; 165 }, 166 keyPress: function () { 167 if (settings.keyPress) { 168 $(document).on('keyup.lightslider', function (e) { 169 if (!$(':focus').is('input, textarea')) { 170 if (e.preventDefault) { 171 e.preventDefault(); 172 } else { 173 e.returnValue = false; 174 } 175 if (e.keyCode === 37) { 176 $el.goToPrevSlide(); 177 } else if (e.keyCode === 39) { 178 $el.goToNextSlide(); 179 } 180 } 181 }); 182 } 183 }, 184 controls: function () { 185 if (settings.controls) { 186 $el.after('<div class="lSAction"><a class="lSPrev">' + settings.prevHtml + '</a><a class="lSNext">' + settings.nextHtml + '</a></div>'); 187 if (!settings.autoWidth) { 188 if (length <= settings.item) { 189 $slide.find('.lSAction').hide(); 190 } 191 } else { 192 if (refresh.calWidth(false) < elSize) { 193 $slide.find('.lSAction').hide(); 194 } 195 } 196 $slide.find('.lSAction a').on('click', function (e) { 197 if (e.preventDefault) { 198 e.preventDefault(); 199 } else { 200 e.returnValue = false; 201 } 202 if ($(this).attr('class') === 'lSPrev') { 203 $el.goToPrevSlide(); 204 } else { 205 $el.goToNextSlide(); 206 } 207 return false; 208 }); 209 } 210 }, 211 initialStyle: function () { 212 var $this = this; 213 if (settings.mode === 'fade') { 214 settings.autoWidth = false; 215 settings.slideEndAnimation = false; 216 } 217 if (settings.auto) { 218 settings.slideEndAnimation = false; 219 } 220 if (settings.autoWidth) { 221 settings.slideMove = 1; 222 settings.item = 1; 223 } 224 if (settings.loop) { 225 settings.slideMove = 1; 226 settings.freeMove = false; 227 } 228 settings.onBeforeStart.call(this, $el); 229 refresh.chbreakpoint(); 230 $el.addClass('lightSlider').wrap('<div class="lSSlideOuter ' + settings.addClass + '"><div class="lSSlideWrapper"></div></div>'); 231 $slide = $el.parent('.lSSlideWrapper'); 232 if (settings.rtl === true) { 233 $slide.parent().addClass('lSrtl'); 234 }
vendor: 14,075 bytes, lines 235-533
235 if (settings.centerSlide === true) { 236 $slide.parent().addClass('lScenterSlide'); 237 } 238 if (settings.vertical) { 239 $slide.parent().addClass('vertical'); 240 elSize = settings.verticalHeight; 241 $slide.css('height', elSize + 'px'); 242 } else { 243 elSize = $el.outerWidth(); 244 } 245 $children.addClass('lslide'); 246 if (settings.loop === true && settings.mode === 'slide') { 247 refresh.calSW(); 248 refresh.clone = function () { 249 if (refresh.calWidth(true) > elSize) { 250 /**/ 251 var tWr = 0, 252 tI = 0; 253 for (var k = 0; k < $children.length; k++) { 254 tWr += (parseInt($el.find('.lslide').eq(k).width()) + settings.slideMargin); 255 tI++; 256 if (tWr >= (elSize + settings.slideMargin)) { 257 break; 258 } 259 } 260 var tItem = settings.autoWidth === true ? tI : settings.item; 261 262 /**/ 263 if (tItem < $el.find('.clone.left').length) { 264 for (var i = 0; i < $el.find('.clone.left').length - tItem; i++) { 265 $children.eq(i).remove(); 266 } 267 } 268 if (tItem < $el.find('.clone.right').length) { 269 for (var j = $children.length - 1; j > ($children.length - 1 - $el.find('.clone.right').length); j--) { 270 scene--; 271 $children.eq(j).remove(); 272 } 273 } 274 /**/ 275 for (var n = $el.find('.clone.right').length; n < tItem; n++) { 276 $el.find('.lslide').eq(n).clone().removeClass('lslide').addClass('clone right').appendTo($el); 277 scene++; 278 } 279 for (var m = $el.find('.lslide').length - $el.find('.clone.left').length; m > ($el.find('.lslide').length - tItem); m--) { 280 $el.find('.lslide').eq(m - 1).clone().removeClass('lslide').addClass('clone left').prependTo($el); 281 } 282 $children = $el.children(); 283 } else { 284 if ($children.hasClass('clone')) { 285 $el.find('.clone').remove(); 286 $this.move($el, 0); 287 } 288 } 289 }; 290 refresh.clone(); 291 } 292 refresh.sSW = function () { 293 length = $children.length; 294 if (settings.rtl === true && settings.vertical === false) { 295 gutter = 'margin-left'; 296 } 297 if (settings.autoWidth === false) { 298 $children.css(property, slideWidth + 'px'); 299 } 300 $children.css(gutter, settings.slideMargin + 'px'); 301 w = refresh.calWidth(false); 302 $el.css(property, w + 'px'); 303 if (settings.loop === true && settings.mode === 'slide') { 304 if (on === false) { 305 scene = $el.find('.clone.left').length; 306 } 307 } 308 }; 309 refresh.calL = function () { 310 $children = $el.children(); 311 length = $children.length; 312 }; 313 if (this.doCss()) { 314 $slide.addClass('usingCss'); 315 } 316 refresh.calL(); 317 if (settings.mode === 'slide') { 318 refresh.calSW(); 319 refresh.sSW(); 320 if (settings.loop === true) { 321 slideValue = $this.slideValue(); 322 this.move($el, slideValue); 323 } 324 if (settings.vertical === false) { 325 this.setHeight($el, false); 326 } 327 328 } else { 329 this.setHeight($el, true); 330 $el.addClass('lSFade'); 331 if (!this.doCss()) { 332 $children.fadeOut(0); 333 $children.eq(scene).fadeIn(0); 334 } 335 } 336 if (settings.loop === true && settings.mode === 'slide') { 337 $children.eq(scene).addClass('active'); 338 } else { 339 $children.first().addClass('active'); 340 } 341 }, 342 pager: function () { 343 var $this = this; 344 refresh.createPager = function () { 345 thumbWidth = (elSize - ((settings.thumbItem * (settings.thumbMargin)) - settings.thumbMargin)) / settings.thumbItem; 346 var $children = $slide.find('.lslide'); 347 var length = $slide.find('.lslide').length; 348 var i = 0, 349 pagers = '', 350 v = 0; 351 for (i = 0; i < length; i++) { 352 if (settings.mode === 'slide') { 353 // calculate scene * slide value 354 if (!settings.autoWidth) { 355 v = i * ((slideWidth + settings.slideMargin) * settings.slideMove); 356 } else { 357 v += ((parseInt($children.eq(i).width()) + settings.slideMargin) * settings.slideMove); 358 } 359 } 360 var thumb = $children.eq(i * settings.slideMove).attr('data-thumb'); 361 if (settings.gallery === true) { 362 pagers += '<li style="width:100%;' + property + ':' + thumbWidth + 'px;' + gutter + ':' + settings.thumbMargin + 'px"><a href="#"><img src="' + thumb + '" /></a></li>'; 363 } else { 364 pagers += '<li><a href="#">' + (i + 1) + '</a></li>'; 365 } 366 if (settings.mode === 'slide') { 367 if ((v) >= w - elSize - settings.slideMargin) { 368 i = i + 1; 369 var minPgr = 2; 370 if (settings.autoWidth) { 371 pagers += '<li><a href="#">' + (i + 1) + '</a></li>'; 372 minPgr = 1; 373 } 374 if (i < minPgr) { 375 pagers = null; 376 $slide.parent().addClass('noPager'); 377 } else { 378 $slide.parent().removeClass('noPager'); 379 } 380 break; 381 } 382 } 383 } 384 var $cSouter = $slide.parent(); 385 $cSouter.find('.lSPager').html(pagers); 386 if (settings.gallery === true) { 387 if (settings.vertical === true) { 388 // set Gallery thumbnail width 389 $cSouter.find('.lSPager').css('width', settings.vThumbWidth + 'px'); 390 } 391 pagerWidth = (i * (settings.thumbMargin + thumbWidth)) + 0.5; 392 $cSouter.find('.lSPager').css({ 393 property: pagerWidth + 'px', 394 'transition-duration': settings.speed + 'ms' 395 }); 396 if (settings.vertical === true) { 397 $slide.parent().css('padding-right', (settings.vThumbWidth + settings.galleryMargin) + 'px'); 398 } 399 $cSouter.find('.lSPager').css(property, pagerWidth + 'px'); 400 } 401 var $pager = $cSouter.find('.lSPager').find('li'); 402 $pager.first().addClass('active'); 403 $pager.on('click', function () { 404 if (settings.loop === true && settings.mode === 'slide') { 405 scene = scene + ($pager.index(this) - $cSouter.find('.lSPager').find('li.active').index()); 406 } else { 407 scene = $pager.index(this); 408 } 409 $el.mode(false); 410 if (settings.gallery === true) { 411 $this.slideThumb(); 412 } 413 return false; 414 }); 415 }; 416 if (settings.pager) { 417 var cl = 'lSpg'; 418 if (settings.gallery) { 419 cl = 'lSGallery'; 420 } 421 $slide.after('<ul class="lSPager ' + cl + '"></ul>'); 422 var gMargin = (settings.vertical) ? 'margin-left' : 'margin-top'; 423 $slide.parent().find('.lSPager').css(gMargin, settings.galleryMargin + 'px'); 424 refresh.createPager(); 425 } 426 427 setTimeout(function () { 428 refresh.init(); 429 }, 0); 430 }, 431 setHeight: function (ob, fade) { 432 var obj = null, 433 $this = this; 434 if (settings.loop) { 435 obj = ob.children('.lslide ').first(); 436 } else { 437 obj = ob.children().first(); 438 } 439 var setCss = function () { 440 var tH = obj.outerHeight(), 441 tP = 0, 442 tHT = tH; 443 if (fade) { 444 tH = 0; 445 tP = ((tHT) * 100) / elSize; 446 } 447 ob.css({ 448 'height': tH + 'px', 449 'padding-bottom': tP + '%' 450 }); 451 }; 452 setCss(); 453 if (obj.find('img').length) { 454 if ( obj.find('img')[0].complete) { 455 setCss(); 456 if (!interval) { 457 $this.auto(); 458 } 459 }else{ 460 obj.find('img').on('load', function () { 461 setTimeout(function () { 462 setCss(); 463 if (!interval) { 464 $this.auto(); 465 } 466 }, 100); 467 }); 468 } 469 }else{ 470 if (!interval) { 471 $this.auto(); 472 } 473 } 474 }, 475 active: function (ob, t) { 476 if (this.doCss() && settings.mode === 'fade') { 477 $slide.addClass('on'); 478 } 479 var sc = 0; 480 if (scene * settings.slideMove < length) { 481 ob.removeClass('active'); 482 if (!this.doCss() && settings.mode === 'fade' && t === false) { 483 ob.fadeOut(settings.speed); 484 } 485 if (t === true) { 486 sc = scene; 487 } else { 488 sc = scene * settings.slideMove; 489 } 490 //t === true ? sc = scene : sc = scene * settings.slideMove; 491 var l, nl; 492 if (t === true) { 493 l = ob.length; 494 nl = l - 1; 495 if (sc + 1 >= l) { 496 sc = nl; 497 } 498 } 499 if (settings.loop === true && settings.mode === 'slide') { 500 //t === true ? sc = scene - $el.find('.clone.left').length : sc = scene * settings.slideMove; 501 if (t === true) { 502 sc = scene - $el.find('.clone.left').length; 503 } else { 504 sc = scene * settings.slideMove; 505 } 506 if (t === true) { 507 l = ob.length; 508 nl = l - 1; 509 if (sc + 1 === l) { 510 sc = nl; 511 } else if (sc + 1 > l) { 512 sc = 0; 513 } 514 } 515 } 516 517 if (!this.doCss() && settings.mode === 'fade' && t === false) { 518 ob.eq(sc).fadeIn(settings.speed); 519 } 520 ob.eq(sc).addClass('active'); 521 } else { 522 ob.removeClass('active'); 523 ob.eq(ob.length - 1).addClass('active'); 524 if (!this.doCss() && settings.mode === 'fade' && t === false) { 525 ob.fadeOut(settings.speed); 526 ob.eq(sc).fadeIn(settings.speed); 527 } 528 } 529 }, 530 move: function (ob, v) { 531 if (settings.centerSlide === true) { 532 v -= (windowW - slideWidth) / 2; 533 }
vendor: 25,211 bytes, lines 533-1143
533 534 if (settings.rtl === true) { 535 v = -v; 536 } 537 if (this.doCss()) { 538 if (settings.vertical === true) { 539 ob.css({ 540 'transform': 'translate3d(0px, ' + (-v) + 'px, 0px)', 541 '-webkit-transform': 'translate3d(0px, ' + (-v) + 'px, 0px)' 542 }); 543 } else { 544 ob.css({ 545 'transform': 'translate3d(' + (-v) + 'px, 0px, 0px)', 546 '-webkit-transform': 'translate3d(' + (-v) + 'px, 0px, 0px)', 547 }); 548 } 549 } else { 550 if (settings.vertical === true) { 551 ob.css('position', 'relative').animate({ 552 top: -v + 'px' 553 }, settings.speed, settings.easing); 554 } else { 555 ob.css('position', 'relative').animate({ 556 left: -v + 'px' 557 }, settings.speed, settings.easing); 558 } 559 } 560 var $thumb = $slide.parent().find('.lSPager').find('li'); 561 this.active($thumb, true); 562 }, 563 fade: function () { 564 this.active($children, false); 565 var $thumb = $slide.parent().find('.lSPager').find('li'); 566 this.active($thumb, true); 567 }, 568 slide: function () { 569 var $this = this; 570 refresh.calSlide = function () { 571 if (w > elSize) { 572 slideValue = $this.slideValue(); 573 $this.active($children, false); 574 if ((slideValue) > w - elSize - settings.slideMargin) { 575 slideValue = w - elSize - settings.slideMargin; 576 } else if (slideValue < 0) { 577 slideValue = 0; 578 } 579 $this.move($el, slideValue); 580 if (settings.loop === true && settings.mode === 'slide') { 581 if (scene >= (length - ($el.find('.clone.left').length / settings.slideMove))) { 582 $this.resetSlide($el.find('.clone.left').length); 583 } 584 if (scene === 0) { 585 $this.resetSlide($slide.find('.lslide').length); 586 } 587 } 588 } 589 }; 590 refresh.calSlide(); 591 }, 592 resetSlide: function (s) { 593 var $this = this; 594 $slide.find('.lSAction a').addClass('disabled'); 595 setTimeout(function () { 596 scene = s; 597 $slide.css('transition-duration', '0ms'); 598 slideValue = $this.slideValue(); 599 $this.active($children, false); 600 plugin.move($el, slideValue); 601 setTimeout(function () { 602 $slide.css('transition-duration', settings.speed + 'ms'); 603 $slide.find('.lSAction a').removeClass('disabled'); 604 }, 50); 605 }, settings.speed + 100); 606 }, 607 slideValue: function () { 608 var _sV = 0; 609 if (settings.autoWidth === false) { 610 _sV = scene * ((slideWidth + settings.slideMargin) * settings.slideMove); 611 } else { 612 _sV = 0; 613 for (var i = 0; i < scene; i++) { 614 _sV += (parseInt($children.eq(i).width()) + settings.slideMargin); 615 } 616 } 617 return _sV; 618 }, 619 slideThumb: function () { 620 var position; 621 switch (settings.currentPagerPosition) { 622 case 'left': 623 position = 0; 624 break; 625 case 'middle': 626 position = (elSize / 2) - (thumbWidth / 2); 627 break; 628 case 'right': 629 position = elSize - thumbWidth; 630 } 631 var sc = scene - $el.find('.clone.left').length; 632 var $pager = $slide.parent().find('.lSPager'); 633 if (settings.mode === 'slide' && settings.loop === true) { 634 if (sc >= $pager.children().length) { 635 sc = 0; 636 } else if (sc < 0) { 637 sc = $pager.children().length; 638 } 639 } 640 var thumbSlide = sc * ((thumbWidth + settings.thumbMargin)) - (position); 641 if ((thumbSlide + elSize) > pagerWidth) { 642 thumbSlide = pagerWidth - elSize - settings.thumbMargin; 643 } 644 if (thumbSlide < 0) { 645 thumbSlide = 0; 646 } 647 this.move($pager, thumbSlide); 648 }, 649 auto: function () { 650 if (settings.auto) { 651 clearInterval(interval); 652 interval = setInterval(function () { 653 $el.goToNextSlide(); 654 }, settings.pause); 655 } 656 }, 657 pauseOnHover: function(){ 658 var $this = this; 659 if (settings.auto && settings.pauseOnHover) { 660 $slide.on('mouseenter', function(){ 661 $(this).addClass('ls-hover'); 662 $el.pause(); 663 settings.auto = true; 664 }); 665 $slide.on('mouseleave',function(){ 666 $(this).removeClass('ls-hover'); 667 if (!$slide.find('.lightSlider').hasClass('lsGrabbing')) { 668 $this.auto(); 669 } 670 }); 671 } 672 }, 673 touchMove: function (endCoords, startCoords) { 674 $slide.css('transition-duration', '0ms'); 675 if (settings.mode === 'slide') { 676 var distance = endCoords - startCoords; 677 var swipeVal = slideValue - distance; 678 if ((swipeVal) >= w - elSize - settings.slideMargin) { 679 if (settings.freeMove === false) { 680 swipeVal = w - elSize - settings.slideMargin; 681 } else { 682 var swipeValT = w - elSize - settings.slideMargin; 683 swipeVal = swipeValT + ((swipeVal - swipeValT) / 5); 684 685 } 686 } else if (swipeVal < 0) { 687 if (settings.freeMove === false) { 688 swipeVal = 0; 689 } else { 690 swipeVal = swipeVal / 5; 691 } 692 } 693 this.move($el, swipeVal); 694 } 695 }, 696 697 touchEnd: function (distance) { 698 $slide.css('transition-duration', settings.speed + 'ms'); 699 if (settings.mode === 'slide') { 700 var mxVal = false; 701 var _next = true; 702 slideValue = slideValue - distance; 703 if ((slideValue) > w - elSize - settings.slideMargin) { 704 slideValue = w - elSize - settings.slideMargin; 705 if (settings.autoWidth === false) { 706 mxVal = true; 707 } 708 } else if (slideValue < 0) { 709 slideValue = 0; 710 } 711 var gC = function (next) { 712 var ad = 0; 713 if (!mxVal) { 714 if (next) { 715 ad = 1; 716 } 717 } 718 if (!settings.autoWidth) { 719 var num = slideValue / ((slideWidth + settings.slideMargin) * settings.slideMove); 720 scene = parseInt(num) + ad; 721 if (slideValue >= (w - elSize - settings.slideMargin)) { 722 if (num % 1 !== 0) { 723 scene++; 724 } 725 } 726 } else { 727 var tW = 0; 728 for (var i = 0; i < $children.length; i++) { 729 tW += (parseInt($children.eq(i).width()) + settings.slideMargin); 730 scene = i + ad; 731 if (tW >= slideValue) { 732 break; 733 } 734 } 735 } 736 }; 737 if (distance >= settings.swipeThreshold) { 738 gC(false); 739 _next = false; 740 } else if (distance <= -settings.swipeThreshold) { 741 gC(true); 742 _next = false; 743 } 744 $el.mode(_next); 745 this.slideThumb(); 746 } else { 747 if (distance >= settings.swipeThreshold) { 748 $el.goToPrevSlide(); 749 } else if (distance <= -settings.swipeThreshold) { 750 $el.goToNextSlide(); 751 } 752 } 753 }, 754 755 756 757 enableDrag: function () { 758 var $this = this; 759 if (!isTouch) { 760 var startCoords = 0, 761 endCoords = 0, 762 isDraging = false; 763 $slide.find('.lightSlider').addClass('lsGrab'); 764 $slide.on('mousedown', function (e) { 765 if (w < elSize) { 766 if (w !== 0) { 767 return false; 768 } 769 } 770 if ($(e.target).attr('class') !== ('lSPrev') && $(e.target).attr('class') !== ('lSNext')) { 771 startCoords = (settings.vertical === true) ? e.pageY : e.pageX; 772 isDraging = true; 773 if (e.preventDefault) { 774 e.preventDefault(); 775 } else { 776 e.returnValue = false; 777 } 778 // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723 779 $slide.scrollLeft += 1; 780 $slide.scrollLeft -= 1; 781 // * 782 $slide.find('.lightSlider').removeClass('lsGrab').addClass('lsGrabbing'); 783 clearInterval(interval); 784 } 785 }); 786 $(window).on('mousemove', function (e) { 787 if (isDraging) { 788 endCoords = (settings.vertical === true) ? e.pageY : e.pageX; 789 $this.touchMove(endCoords, startCoords); 790 } 791 }); 792 $(window).on('mouseup', function (e) { 793 if (isDraging) { 794 $slide.find('.lightSlider').removeClass('lsGrabbing').addClass('lsGrab'); 795 isDraging = false; 796 endCoords = (settings.vertical === true) ? e.pageY : e.pageX; 797 var distance = endCoords - startCoords; 798 if (Math.abs(distance) >= settings.swipeThreshold) { 799 $(window).on('click.ls', function (e) { 800 if (e.preventDefault) { 801 e.preventDefault(); 802 } else { 803 e.returnValue = false; 804 } 805 e.stopImmediatePropagation(); 806 e.stopPropagation(); 807 $(window).off('click.ls'); 808 }); 809 } 810 811 $this.touchEnd(distance); 812 813 } 814 }); 815 } 816 }, 817 818 819 820 821 enableTouch: function () { 822 var $this = this; 823 if (isTouch) { 824 var startCoords = {}, 825 endCoords = {}; 826 $slide.on('touchstart', function (e) { 827 endCoords = e.originalEvent.targetTouches[0]; 828 startCoords.pageX = e.originalEvent.targetTouches[0].pageX; 829 startCoords.pageY = e.originalEvent.targetTouches[0].pageY; 830 clearInterval(interval); 831 }); 832 $slide.on('touchmove', function (e) { 833 if (w < elSize) { 834 if (w !== 0) { 835 return false; 836 } 837 } 838 var orig = e.originalEvent; 839 endCoords = orig.targetTouches[0]; 840 var xMovement = Math.abs(endCoords.pageX - startCoords.pageX); 841 var yMovement = Math.abs(endCoords.pageY - startCoords.pageY); 842 if (settings.vertical === true) { 843 if ((yMovement * 3) > xMovement) { 844 e.preventDefault(); 845 } 846 $this.touchMove(endCoords.pageY, startCoords.pageY); 847 } else { 848 if ((xMovement * 3) > yMovement) { 849 e.preventDefault(); 850 } 851 $this.touchMove(endCoords.pageX, startCoords.pageX); 852 } 853 854 }); 855 $slide.on('touchend', function () { 856 if (w < elSize) { 857 if (w !== 0) { 858 return false; 859 } 860 } 861 var distance; 862 if (settings.vertical === true) { 863 distance = endCoords.pageY - startCoords.pageY; 864 } else { 865 distance = endCoords.pageX - startCoords.pageX; 866 } 867 $this.touchEnd(distance); 868 }); 869 } 870 }, 871 build: function () { 872 var $this = this; 873 $this.initialStyle(); 874 if (this.doCss()) { 875 876 if (settings.enableTouch === true) { 877 $this.enableTouch(); 878 } 879 if (settings.enableDrag === true) { 880 $this.enableDrag(); 881 } 882 } 883 884 $(window).on('focus', function(){ 885 $this.auto(); 886 }); 887 888 $(window).on('blur', function(){ 889 clearInterval(interval); 890 }); 891 892 $this.pager(); 893 $this.pauseOnHover(); 894 $this.controls(); 895 $this.keyPress(); 896 } 897 }; 898 plugin.build(); 899 refresh.init = function () { 900 refresh.chbreakpoint(); 901 if (settings.vertical === true) { 902 if (settings.item > 1) { 903 elSize = settings.verticalHeight; 904 } else { 905 elSize = $children.outerHeight(); 906 } 907 $slide.css('height', elSize + 'px'); 908 } else { 909 elSize = $slide.outerWidth(); 910 } 911 if (settings.loop === true && settings.mode === 'slide') { 912 refresh.clone(); 913 } 914 refresh.calL(); 915 if (settings.mode === 'slide') { 916 $el.removeClass('lSSlide'); 917 } 918 if (settings.mode === 'slide') { 919 refresh.calSW(); 920 refresh.sSW(); 921 } 922 setTimeout(function () { 923 if (settings.mode === 'slide') { 924 $el.addClass('lSSlide'); 925 } 926 }, 1000); 927 if (settings.pager) { 928 refresh.createPager(); 929 } 930 if (settings.adaptiveHeight === true && settings.vertical === false) { 931 $el.css('height', $children.eq(scene).outerHeight(true)); 932 } 933 if (settings.adaptiveHeight === false) { 934 if (settings.mode === 'slide') { 935 if (settings.vertical === false) { 936 plugin.setHeight($el, false); 937 }else{ 938 plugin.auto(); 939 } 940 } else { 941 plugin.setHeight($el, true); 942 } 943 } 944 if (settings.gallery === true) { 945 plugin.slideThumb(); 946 } 947 if (settings.mode === 'slide') { 948 plugin.slide(); 949 } 950 if (settings.autoWidth === false) { 951 if ($children.length <= settings.item) { 952 $slide.find('.lSAction').hide(); 953 } else { 954 $slide.find('.lSAction').show(); 955 } 956 } else { 957 if ((refresh.calWidth(false) < elSize) && (w !== 0)) { 958 $slide.find('.lSAction').hide(); 959 } else { 960 $slide.find('.lSAction').show(); 961 } 962 } 963 }; 964 $el.goToPrevSlide = function () { 965 if (scene > 0) { 966 settings.onBeforePrevSlide.call(this, $el, scene); 967 scene--; 968 $el.mode(false); 969 if (settings.gallery === true) { 970 plugin.slideThumb(); 971 } 972 } else { 973 if (settings.loop === true) { 974 settings.onBeforePrevSlide.call(this, $el, scene); 975 if (settings.mode === 'fade') { 976 var l = (length - 1); 977 scene = parseInt(l / settings.slideMove); 978 } 979 $el.mode(false); 980 if (settings.gallery === true) { 981 plugin.slideThumb(); 982 } 983 } else if (settings.slideEndAnimation === true) { 984 $el.addClass('leftEnd'); 985 setTimeout(function () { 986 $el.removeClass('leftEnd'); 987 }, 400); 988 } 989 } 990 }; 991 $el.goToNextSlide = function () { 992 var nextI = true; 993 if (settings.mode === 'slide') { 994 var _slideValue = plugin.slideValue(); 995 nextI = _slideValue < w - elSize - settings.slideMargin; 996 } 997 if (((scene * settings.slideMove) < length - settings.slideMove) && nextI) { 998 settings.onBeforeNextSlide.call(this, $el, scene); 999 scene++; 1000 $el.mode(false); 1001 if (settings.gallery === true) { 1002 plugin.slideThumb(); 1003 } 1004 } else { 1005 if (settings.loop === true) { 1006 settings.onBeforeNextSlide.call(this, $el, scene); 1007 scene = 0; 1008 $el.mode(false); 1009 if (settings.gallery === true) { 1010 plugin.slideThumb(); 1011 } 1012 } else if (settings.slideEndAnimation === true) { 1013 $el.addClass('rightEnd'); 1014 setTimeout(function () { 1015 $el.removeClass('rightEnd'); 1016 }, 400); 1017 } 1018 } 1019 }; 1020 $el.mode = function (_touch) { 1021 if (settings.adaptiveHeight === true && settings.vertical === false) { 1022 $el.css('height', $children.eq(scene).outerHeight(true)); 1023 } 1024 if (on === false) { 1025 if (settings.mode === 'slide') { 1026 if (plugin.doCss()) { 1027 $el.addClass('lSSlide'); 1028 if (settings.speed !== '') { 1029 $slide.css('transition-duration', settings.speed + 'ms'); 1030 } 1031 if (settings.cssEasing !== '') { 1032 $slide.css('transition-timing-function', settings.cssEasing); 1033 } 1034 } 1035 } else { 1036 if (plugin.doCss()) { 1037 if (settings.speed !== '') { 1038 $el.css('transition-duration', settings.speed + 'ms'); 1039 } 1040 if (settings.cssEasing !== '') { 1041 $el.css('transition-timing-function', settings.cssEasing); 1042 } 1043 } 1044 } 1045 } 1046 if (!_touch) { 1047 settings.onBeforeSlide.call(this, $el, scene); 1048 } 1049 if (settings.mode === 'slide') { 1050 plugin.slide(); 1051 } else { 1052 plugin.fade(); 1053 } 1054 if (!$slide.hasClass('ls-hover')) { 1055 plugin.auto(); 1056 } 1057 setTimeout(function () { 1058 if (!_touch) { 1059 settings.onAfterSlide.call(this, $el, scene); 1060 } 1061 }, settings.speed); 1062 on = true; 1063 }; 1064 $el.play = function () { 1065 $el.goToNextSlide(); 1066 settings.auto = true; 1067 plugin.auto(); 1068 }; 1069 $el.pause = function () { 1070 settings.auto = false; 1071 clearInterval(interval); 1072 }; 1073 $el.refresh = function () { 1074 refresh.init(); 1075 }; 1076 $el.getCurrentSlideCount = function () { 1077 var sc = scene; 1078 if (settings.loop) { 1079 var ln = $slide.find('.lslide').length, 1080 cl = $el.find('.clone.left').length; 1081 if (scene <= cl - 1) { 1082 sc = ln + (scene - cl); 1083 } else if (scene >= (ln + cl)) { 1084 sc = scene - ln - cl; 1085 } else { 1086 sc = scene - cl; 1087 } 1088 } 1089 return sc + 1; 1090 }; 1091 $el.getTotalSlideCount = function () { 1092 return $slide.find('.lslide').length; 1093 }; 1094 $el.goToSlide = function (s) { 1095 if (settings.loop) { 1096 scene = (s + $el.find('.clone.left').length - 1); 1097 } else { 1098 scene = s; 1099 } 1100 $el.mode(false); 1101 if (settings.gallery === true) { 1102 plugin.slideThumb(); 1103 } 1104 }; 1105 $el.destroy = function () { 1106 if ($el.lightSlider) { 1107 $el.goToPrevSlide = function(){}; 1108 $el.goToNextSlide = function(){}; 1109 $el.mode = function(){}; 1110 $el.play = function(){}; 1111 $el.pause = function(){}; 1112 $el.refresh = function(){}; 1113 $el.getCurrentSlideCount = function(){}; 1114 $el.getTotalSlideCount = function(){}; 1115 $el.goToSlide = function(){}; 1116 $el.lightSlider = null; 1117 refresh = { 1118 init : function(){} 1119 }; 1120 $el.parent().parent().find('.lSAction, .lSPager').remove(); 1121 $el.removeClass('lightSlider lSFade lSSlide lsGrab lsGrabbing leftEnd right').removeAttr('style').unwrap().unwrap(); 1122 $el.children().removeAttr('style'); 1123 $children.removeClass('lslide active'); 1124 $el.find('.clone').remove(); 1125 $children = null; 1126 interval = null; 1127 on = false; 1128 scene = 0; 1129 } 1130 1131 }; 1132 setTimeout(function () { 1133 settings.onSliderLoad.call(this, $el); 1134 }, 10); 1135 $(window).on('resize orientationchange', function (e) { 1136 setTimeout(function () { 1137 if (e.preventDefault) { 1138 e.preventDefault(); 1139 } else { 1140 e.returnValue = false; 1141 } 1142 refresh.init(); 1143 },
1143100); 1144 }); 1145 return this; 1146 }; 1147}(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.