vendor: 15,231 bytes, lines 1-454
1/*! lightgallery - v1.2.21 - 2016-06-28 2* http://sachinchoolur.github.io/lightGallery/ 3* Copyright (c) 2016 Sachin N; Licensed Apache 2.0 */ 4(function($, window, document, undefined) { 5 6 'use strict'; 7 8 var defaults = { 9 thumbnail: true, 10 11 animateThumb: true, 12 currentPagerPosition: 'middle', 13 14 thumbWidth: 100, 15 thumbContHeight: 100, 16 thumbMargin: 5, 17 18 exThumbImage: false, 19 showThumbByDefault: true, 20 toogleThumb: true, 21 pullCaptionUp: true, 22 23 enableThumbDrag: true, 24 enableThumbSwipe: true, 25 swipeThreshold: 50, 26 27 loadYoutubeThumbnail: true, 28 youtubeThumbSize: 1, 29 30 loadVimeoThumbnail: true, 31 vimeoThumbSize: 'thumbnail_small', 32 33 loadDailymotionThumbnail: true 34 }; 35 36 var Thumbnail = function(element) { 37 38 // get lightGallery core plugin data 39 this.core = $(element).data('lightGallery'); 40 41 // extend module default settings with lightGallery core settings 42 this.core.s = $.extend({}, defaults, this.core.s); 43 44 this.$el = $(element); 45 this.$thumbOuter = null; 46 this.thumbOuterWidth = 0; 47 this.thumbTotalWidth = (this.core.$items.length * (this.core.s.thumbWidth + this.core.s.thumbMargin)); 48 this.thumbIndex = this.core.index; 49 50 // Thumbnail animation value 51 this.left = 0; 52 53 this.init(); 54 55 return this; 56 }; 57 58 Thumbnail.prototype.init = function() { 59 var _this = this; 60 if (this.core.s.thumbnail && this.core.$items.length > 1) { 61 if (this.core.s.showThumbByDefault) { 62 setTimeout(function(){ 63 _this.core.$outer.addClass('lg-thumb-open'); 64 }, 700); 65 } 66 67 if (this.core.s.pullCaptionUp) { 68 this.core.$outer.addClass('lg-pull-caption-up'); 69 } 70 71 this.build(); 72 if (this.core.s.animateThumb) { 73 if (this.core.s.enableThumbDrag && !this.core.isTouch && this.core.doCss()) { 74 this.enableThumbDrag(); 75 } 76 77 if (this.core.s.enableThumbSwipe && this.core.isTouch && this.core.doCss()) { 78 this.enableThumbSwipe(); 79 } 80 81 this.thumbClickable = false; 82 } else { 83 this.thumbClickable = true; 84 } 85 86 this.toogle(); 87 this.thumbkeyPress(); 88 } 89 }; 90 91 Thumbnail.prototype.build = function() { 92 var _this = this; 93 var thumbList = ''; 94 var vimeoErrorThumbSize = ''; 95 var $thumb; 96 var html = '<div class="lg-thumb-outer">' + 97 '<div class="lg-thumb group">' + 98 '</div>' + 99 '</div>'; 100 101 switch (this.core.s.vimeoThumbSize) { 102 case 'thumbnail_large': 103 vimeoErrorThumbSize = '640'; 104 break; 105 case 'thumbnail_medium': 106 vimeoErrorThumbSize = '200x150'; 107 break; 108 case 'thumbnail_small': 109 vimeoErrorThumbSize = '100x75'; 110 } 111 112 _this.core.$outer.addClass('lg-has-thumb'); 113 114 _this.core.$outer.find('.lg').append(html); 115 116 _this.$thumbOuter = _this.core.$outer.find('.lg-thumb-outer'); 117 _this.thumbOuterWidth = _this.$thumbOuter.width(); 118 119 if (_this.core.s.animateThumb) { 120 _this.core.$outer.find('.lg-thumb').css({ 121 width: _this.thumbTotalWidth + 'px', 122 position: 'relative' 123 }); 124 } 125 126 if (this.core.s.animateThumb) { 127 _this.$thumbOuter.css('height', _this.core.s.thumbContHeight + 'px'); 128 } 129 130 function getThumb(src, thumb, index) { 131 var isVideo = _this.core.isVideo(src, index) || {}; 132 var thumbImg; 133 var vimeoId = ''; 134 135 if (isVideo.youtube || isVideo.vimeo || isVideo.dailymotion) { 136 if (isVideo.youtube) { 137 if (_this.core.s.loadYoutubeThumbnail) { 138 thumbImg = '//img.youtube.com/vi/' + isVideo.youtube[1] + '/' + _this.core.s.youtubeThumbSize + '.jpg'; 139 } else { 140 thumbImg = thumb; 141 } 142 } else if (isVideo.vimeo) { 143 if (_this.core.s.loadVimeoThumbnail) { 144 thumbImg = '//i.vimeocdn.com/video/error_' + vimeoErrorThumbSize + '.jpg'; 145 vimeoId = isVideo.vimeo[1]; 146 } else { 147 thumbImg = thumb; 148 } 149 } else if (isVideo.dailymotion) { 150 if (_this.core.s.loadDailymotionThumbnail) { 151 thumbImg = '//www.dailymotion.com/thumbnail/video/' + isVideo.dailymotion[1]; 152 } else { 153 thumbImg = thumb; 154 } 155 } 156 } else { 157 thumbImg = thumb; 158 } 159 160 thumbList += '<div data-vimeo-id="' + vimeoId + '" class="lg-thumb-item" style="width:' + _this.core.s.thumbWidth + 'px; margin-right: ' + _this.core.s.thumbMargin + 'px"><img src="' + thumbImg + '" /></div>'; 161 vimeoId = ''; 162 } 163 164 if (_this.core.s.dynamic) { 165 for (var i = 0; i < _this.core.s.dynamicEl.length; i++) { 166 getThumb(_this.core.s.dynamicEl[i].src, _this.core.s.dynamicEl[i].thumb, i); 167 } 168 } else { 169 _this.core.$items.each(function(i) { 170 171 if (!_this.core.s.exThumbImage) { 172 getThumb($(this).attr('href') || $(this).attr('data-src'), $(this).find('img').attr('src'), i); 173 } else { 174 getThumb($(this).attr('href') || $(this).attr('data-src'), $(this).attr(_this.core.s.exThumbImage), i); 175 } 176 177 }); 178 } 179 180 _this.core.$outer.find('.lg-thumb').html(thumbList); 181 182 $thumb = _this.core.$outer.find('.lg-thumb-item'); 183 184 // Load vimeo thumbnails 185 $thumb.each(function() { 186 var $this = $(this); 187 var vimeoVideoId = $this.attr('data-vimeo-id'); 188 189 if (vimeoVideoId) { 190 $.getJSON('//www.vimeo.com/api/v2/video/' + vimeoVideoId + '.json?callback=?', { 191 format: 'json' 192 }, function(data) { 193 $this.find('img').attr('src', data[0][_this.core.s.vimeoThumbSize]); 194 }); 195 } 196 }); 197 198 // manage active class for thumbnail 199 $thumb.eq(_this.core.index).addClass('active'); 200 _this.core.$el.on('onBeforeSlide.lg.tm', function() { 201 $thumb.removeClass('active'); 202 $thumb.eq(_this.core.index).addClass('active'); 203 }); 204 205 $thumb.on('click.lg touchend.lg', function() { 206 var _$this = $(this); 207 setTimeout(function() { 208 209 // In IE9 and bellow touch does not support 210 // Go to slide if browser does not support css transitions 211 if ((_this.thumbClickable && !_this.core.lgBusy) || !_this.core.doCss()) { 212 _this.core.index = _$this.index(); 213 _this.core.slide(_this.core.index, false, true); 214 } 215 }, 50); 216 }); 217 218 _this.core.$el.on('onBeforeSlide.lg.tm', function() { 219 _this.animateThumb(_this.core.index); 220 }); 221 222 $(window).on('resize.lg.thumb orientationchange.lg.thumb', function() { 223 setTimeout(function() { 224 _this.animateThumb(_this.core.index); 225 _this.thumbOuterWidth = _this.$thumbOuter.width(); 226 }, 200); 227 }); 228 229 }; 230 231 Thumbnail.prototype.setTranslate = function(value) { 232 // jQuery supports Automatic CSS prefixing since jQuery 1.8.0 233 this.core.$outer.find('.lg-thumb').css({ 234 transform: 'translate3d(-' + (value) + 'px, 0px, 0px)' 235 }); 236 }; 237 238 Thumbnail.prototype.animateThumb = function(index) { 239 var $thumb = this.core.$outer.find('.lg-thumb'); 240 if (this.core.s.animateThumb) { 241 var position; 242 switch (this.core.s.currentPagerPosition) { 243 case 'left': 244 position = 0; 245 break; 246 case 'middle': 247 position = (this.thumbOuterWidth / 2) - (this.core.s.thumbWidth / 2); 248 break; 249 case 'right': 250 position = this.thumbOuterWidth - this.core.s.thumbWidth; 251 } 252 this.left = ((this.core.s.thumbWidth + this.core.s.thumbMargin) * index - 1) - position; 253 if (this.left > (this.thumbTotalWidth - this.thumbOuterWidth)) { 254 this.left = this.thumbTotalWidth - this.thumbOuterWidth; 255 } 256 257 if (this.left < 0) { 258 this.left = 0; 259 } 260 261 if (this.core.lGalleryOn) { 262 if (!$thumb.hasClass('on')) { 263 this.core.$outer.find('.lg-thumb').css('transition-duration', this.core.s.speed + 'ms'); 264 } 265 266 if (!this.core.doCss()) { 267 $thumb.animate({ 268 left: -this.left + 'px' 269 }, this.core.s.speed); 270 } 271 } else { 272 if (!this.core.doCss()) { 273 $thumb.css('left', -this.left + 'px'); 274 } 275 } 276 277 this.setTranslate(this.left); 278 279 } 280 }; 281 282 // Enable thumbnail dragging and swiping 283 Thumbnail.prototype.enableThumbDrag = function() { 284 285 var _this = this; 286 var startCoords = 0; 287 var endCoords = 0; 288 var isDraging = false; 289 var isMoved = false; 290 var tempLeft = 0; 291 292 _this.$thumbOuter.addClass('lg-grab'); 293 294 _this.core.$outer.find('.lg-thumb').on('mousedown.lg.thumb', function(e) { 295 if (_this.thumbTotalWidth > _this.thumbOuterWidth) { 296 // execute only on .lg-object 297 e.preventDefault(); 298 startCoords = e.pageX; 299 isDraging = true; 300 301 // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723 302 _this.core.$outer.scrollLeft += 1; 303 _this.core.$outer.scrollLeft -= 1; 304 305 // * 306 _this.thumbClickable = false; 307 _this.$thumbOuter.removeClass('lg-grab').addClass('lg-grabbing'); 308 } 309 }); 310 311 $(window).on('mousemove.lg.thumb', function(e) { 312 if (isDraging) { 313 tempLeft = _this.left; 314 isMoved = true; 315 endCoords = e.pageX; 316 317 _this.$thumbOuter.addClass('lg-dragging'); 318 319 tempLeft = tempLeft - (endCoords - startCoords); 320 321 if (tempLeft > (_this.thumbTotalWidth - _this.thumbOuterWidth)) { 322 tempLeft = _this.thumbTotalWidth - _this.thumbOuterWidth; 323 } 324 325 if (tempLeft < 0) { 326 tempLeft = 0; 327 } 328 329 // move current slide 330 _this.setTranslate(tempLeft); 331 332 } 333 }); 334 335 $(window).on('mouseup.lg.thumb', function() { 336 if (isMoved) { 337 isMoved = false; 338 _this.$thumbOuter.removeClass('lg-dragging'); 339 340 _this.left = tempLeft; 341 342 if (Math.abs(endCoords - startCoords) < _this.core.s.swipeThreshold) { 343 _this.thumbClickable = true; 344 } 345 346 } else { 347 _this.thumbClickable = true; 348 } 349 350 if (isDraging) { 351 isDraging = false; 352 _this.$thumbOuter.removeClass('lg-grabbing').addClass('lg-grab'); 353 } 354 }); 355 356 }; 357 358 Thumbnail.prototype.enableThumbSwipe = function() { 359 var _this = this; 360 var startCoords = 0; 361 var endCoords = 0; 362 var isMoved = false; 363 var tempLeft = 0; 364 365 _this.core.$outer.find('.lg-thumb').on('touchstart.lg', function(e) { 366 if (_this.thumbTotalWidth > _this.thumbOuterWidth) { 367 e.preventDefault(); 368 startCoords = e.originalEvent.targetTouches[0].pageX; 369 _this.thumbClickable = false; 370 } 371 }); 372 373 _this.core.$outer.find('.lg-thumb').on('touchmove.lg', function(e) { 374 if (_this.thumbTotalWidth > _this.thumbOuterWidth) { 375 e.preventDefault(); 376 endCoords = e.originalEvent.targetTouches[0].pageX; 377 isMoved = true; 378 379 _this.$thumbOuter.addClass('lg-dragging'); 380 381 tempLeft = _this.left; 382 383 tempLeft = tempLeft - (endCoords - startCoords); 384 385 if (tempLeft > (_this.thumbTotalWidth - _this.thumbOuterWidth)) { 386 tempLeft = _this.thumbTotalWidth - _this.thumbOuterWidth; 387 } 388 389 if (tempLeft < 0) { 390 tempLeft = 0; 391 } 392 393 // move current slide 394 _this.setTranslate(tempLeft); 395 396 } 397 }); 398 399 _this.core.$outer.find('.lg-thumb').on('touchend.lg', function() { 400 if (_this.thumbTotalWidth > _this.thumbOuterWidth) { 401 402 if (isMoved) { 403 isMoved = false; 404 _this.$thumbOuter.removeClass('lg-dragging'); 405 if (Math.abs(endCoords - startCoords) < _this.core.s.swipeThreshold) { 406 _this.thumbClickable = true; 407 } 408 409 _this.left = tempLeft; 410 } else { 411 _this.thumbClickable = true; 412 } 413 } else { 414 _this.thumbClickable = true; 415 } 416 }); 417 418 }; 419 420 Thumbnail.prototype.toogle = function() { 421 var _this = this; 422 if (_this.core.s.toogleThumb) { 423 _this.core.$outer.addClass('lg-can-toggle'); 424 _this.$thumbOuter.append('<span class="lg-toogle-thumb lg-icon"></span>'); 425 _this.core.$outer.find('.lg-toogle-thumb').on('click.lg', function() { 426 _this.core.$outer.toggleClass('lg-thumb-open'); 427 }); 428 } 429 }; 430 431 Thumbnail.prototype.thumbkeyPress = function() { 432 var _this = this; 433 $(window).on('keydown.lg.thumb', function(e) { 434 if (e.keyCode === 38) { 435 e.preventDefault(); 436 _this.core.$outer.addClass('lg-thumb-open'); 437 } else if (e.keyCode === 40) { 438 e.preventDefault(); 439 _this.core.$outer.removeClass('lg-thumb-open'); 440 } 441 }); 442 }; 443 444 Thumbnail.prototype.destroy = function() { 445 if (this.core.s.thumbnail && this.core.$items.length > 1) { 446 $(window).off('resize.lg.thumb orientationchange.lg.thumb keydown.lg.thumb'); 447 this.$thumbOuter.remove(); 448 this.core.$outer.removeClass('lg-has-thumb'); 449 } 450 }; 451 452 $.fn.lightGallery.modules.Thumbnail = Thumbnail; 453 454})(jQuery, window, document);
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.