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