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