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