1var DEG_elastic_gallery = new function() { 2 3 'use strict'; 4 5 /* 6 * Private variables 7 */ 8 var $ = jQuery.noConflict(); 9 var loadIndex = 0; 10 11 this.init = false; 12 13 this.__construct = function() { 14 var _self = this; 15 $(document).ready(function() { 16 $(window).resize(function() { 17 DEG_elastic_gallery.layout(); 18 }); 19 20 $(document).on('lazyloaded', function(e) { 21 var $gallery = $(e.target).parents('.deg-gallery-container'); 22 if ($gallery.length) { 23 DEG_elastic_gallery.layout(); 24 } 25 }); 26 27 $('.deg-gallery-filter').on('click', function(e) { 28 e.preventDefault(); 29 var $this = $(this), 30 value = $this.attr('data-value'), 31 $wrapper = $this.parents('.deg-gallery-wrapper'), 32 $filter = $wrapper.find('.deg-gallery-filter-categories'); 33 34 if ($this.hasClass('deg-filter-active')) 35 return; 36 37 $filter.attr('data-value', value); 38 $filter.find('.deg-filter-active').removeClass('deg-filter-active'); 39 $this.addClass('deg-filter-active'); 40 41 DEG_elastic_gallery.executeFilter('category', $wrapper); 42 43 }); 44 45 $('.deg-gallery-page-button').on('click', function(e) { 46 e.preventDefault(); 47 var $this = $(this), 48 page = $this.attr('data-value'), 49 $wrapper = $this.parents('.deg-gallery-wrapper'), 50 $paginator = $wrapper.find('.deg-gallery-pagination'), 51 excludeMovement = false, 52 max = Number($paginator.attr('data-max')), 53 current = Number($paginator.attr('data-value')); 54 55 56 if ( page == 'more') { 57 page = 1; 58 excludeMovement = true; 59 var pageSize = Number($paginator.attr('data-page-size')), 60 more = Number($paginator.attr('data-more')); 61 $paginator.attr('data-page-size', pageSize + more); 62 if ( pageSize >= more * (max-1)) { 63 $this.addClass('deg-page-disabled'); 64 } 65 } else if (page == 'prev') { 66 if ( current > 1) 67 page = current - 1; 68 else 69 return; 70 } else if ( page == 'next') { 71 if ( current < max) 72 page = current + 1; 73 else 74 return; 75 } else if (page == $paginator.attr('data-value')) 76 return; 77 78 $paginator.attr('data-value', page); 79 $paginator.find('.deg-gallery-page-button-active').removeClass('deg-gallery-page-button-active'); 80 $paginator.find('.deg-gallery-page-button[data-value="' + page + '"]').addClass('deg-gallery-page-button-active'); 81 82 DEG_elastic_gallery.executeFilter('page', $wrapper, excludeMovement); 83 }); 84 85 $('img.deg-lazyload').on('load', function(e) { 86 var $img = $(e.target); 87 $img.addClass('deg-loaded'); 88 $img.removeClass('deg-lazyload'); 89 DEG_elastic_gallery.layout(); 90 _self.updateMonarch(e.target); 91 }); 92 93 $('picture.deg-lazyload img').on('load', function(e) { 94 var $img = $(e.target); 95 var $picture = $img.parents('picture').eq(0); 96 $picture.addClass('deg-loaded'); 97 $picture.removeClass('deg-lazyload'); 98 DEG_elastic_gallery.layout(); 99 _self.updateMonarch(e.target); 100 }); 101 102 _self.layout(); 103 _self.doLazyload(); 104 }); 105 }; 106 107 /** 108 * Creates de lightbox 109 */ 110 this.lightbox = function($gallery) { 111 if ($gallery.hasClass('deg-modal-gallery')) { 112 var legend = $gallery.hasClass('deg-modal-gallery-with-title'); 113 $gallery.find('.deg-gallery-item').not('.deg-out-filter').not('.deg-minimized-link').magnificPopup({ 114 type: 'image', 115 closeOnContentClick: false, 116 closeBtnInside: false, 117 mainClass: 'mfp-with-zoom mfp-img-mobile', 118 disableOn: function() { 119 if ( $gallery.hasClass('deg-disable-modal-tablet') && $(window).width() < 981 ) 120 return false;
121 else if ( $gallery.hasClass('deg-disable-modal-phone') && $(window).width() < 768 ) 122 return false; 123 124 return true; 125 }, 126 image : { 127 titleSrc : function(item) { 128 if ( legend ) { 129 var title = '<span>' + item.el.attr('data-title') + '</small>' || '' ; 130 var caption = item.el.attr('data-caption') || '' ; 131 if ( $gallery.hasClass('deg-modal-title__title_caption')) { 132 return title + '<br><small>' + caption + '</small>'; 133 } else if ( $gallery.hasClass('deg-modal-title__in_title')) { 134 return title + '<br><small>' + caption + '</small>'; 135 } else if ( $gallery.hasClass('deg-modal-title__in_title_caption')) { 136 return title + '<br><small>' + caption + '</small>'; 137 } else 138 return title; 139 } 140 } 141 }, 142 gallery: { 143 enabled: true, 144 tPrev: '', 145 tNext: '', 146 tCounter: '' 147 }, 148 zoom: { 149 enabled: true, 150 duration: 300, // don't foget to change the duration also in CSS 151 opener: function(element) { 152 return element.find('img'); 153 } 154 }, 155 callbacks: { 156 change: function() { 157 if (this.isOpen) { 158 this.wrap.addClass('mfp-open'); 159 } 160 }, 161 elementParse: function(item) { 162 item.src = $(item.el).attr('data-original'); }, 163 open: function() { 164 if ( $gallery.hasClass('deg-modal-title__in_title') || $gallery.hasClass('deg-modal-title__in_title_caption') ) { 165 $(this.container).addClass('deg-modal-in-data'); 166 } 167 168 try { 169 var $module = $(this.ev[0]).parents('.destaca_elastic_gallery'), 170 classes = $module && $module.length ? $module[0].className.split(' ') : []; 171 classes.forEach(c => { 172 if ( c.match(/^destaca_elastic_gallery_\d+$/g) ) { 173 $(this.bgOverlay).addClass('mfp-deg-elastic-gallery ' + c); 174 $(this.wrap).addClass('mfp-deg-elastic-gallery ' + c); 175 } 176 }); 177 } catch(ex) { 178 179 } 180 } 181 } 182 }); 183 } 184 } 185 186 this.layout = function() { 187 var _self = this; 188 $.each($('.deg-gallery-container'), function(index, el) { 189 var $gallery = $(el); 190 var images = $gallery.find('.deg-gallery-item').not('.deg-out-page').not('.deg-out-minified'), 191 sizing = $gallery.length ? $gallery.attr('data-sizes').split(',') : [], 192 spacing = $gallery.length ? $gallery.attr('data-space').split(',') : [], 193 rowMinImages = $gallery.length ? $gallery.attr('data-min-images').split(',') : [], 194 galleryWidth = $gallery.width(), 195 rows = [], 196 currentRow = []; 197 198 var winWidth = $(window).width(), 199 space = 0, 200 minHeigth = 175, 201 minImages = 1, 202 maxImageHeight = _self.maxHeight($, images); 203 204 if ( sizing.length && winWidth < 768) { 205 minHeigth = Number(sizing[2]); 206 } else if ( sizing.length && winWidth < 981) { 207 minHeigth = Number(sizing[1]); 208 } else if ( sizing.length ) { 209 minHeigth = Number(sizing[0]); 210 } 211 212 if ( spacing.length && winWidth < 768) { 213 space = Number(spacing[2]); 214 } else if ( spacing.length && winWidth < 981) { 215 space = Number(spacing[1]); 216 } else if ( spacing.length ) { 217 space = Number(spacing[0]); 218 } 219 220 if ( rowMinImages.length && winWidth < 768) { 221 minImages = Number(rowMinImages[2]); 222 } else if ( rowMinImages.length && winWidth < 981) { 223 minImages = Number(rowMinImages[1]); 224 } else if ( rowMinImages.length ) { 225 minImages = Number(rowMinImages[0]); 226 } 227 228 229 for (var i = 0; i < images.length; i++) { 230 var $img = $(images[i]).find('img'); 231 if ($img.attr('data-src') || $img.attr('src')) { 232 if (currentRow.length == 0) 233 currentRow.push(images[i]); 234 else if (_self.addToRow($, currentRow, $img, galleryWidth, minHeigth, space, maxImageHeight)) { 235 currentRow.push(images[i]); 236 } else { 237 rows.push(currentRow); 238 currentRow = []; 239 currentRow.push(images[i]); 240 } 241 } 242 } 243 244 rows.push(currentRow); 245 246 rows = _self.checkMinInRows($, minImages, rows); 247 var top = 0; 248 for (var i = 0; i < rows.length; i++) { 249 var total = 0, 250 totalBorder = 0; 251 for (var j = 0; j < rows[i].length; j++) { 252 var currentSizes = _self.imageSizes($, maxImageHeight, $(rows[i][j]).find('img'), $(rows[i][j])); 253 total += currentSizes.w 254 totalBorder += currentSizes.bl + currentSizes.br; 255 } 256 257 var left = 0, 258 totalSpace = 0; 259 var widthRatio = total / (galleryWidth - totalBorder); 260 if (space) { 261 totalSpace = space * (rows[i].length - 1); 262 widthRatio = total / (galleryWidth - totalSpace - totalBorder); 263 } 264 265 for (var j = 0; j < rows[i].length; j++) { 266 var sizes = _self.imageSizes($, maxImageHeight, $(rows[i][j]).find('img'), $(rows[i][j])); 267 var percentageInRow = sizes.w / total; 268 var pixelsWidth = percentageInRow * (galleryWidth - totalSpace - totalBorder); 269 270 if (j == 0) { 271 $(rows[i][j]).css('left', 0); 272 } else { 273 $(rows[i][j]).css('left', left + 'px'); 274 275 } 276 $(rows[i][j]).css('width', (pixelsWidth + sizes.bl + sizes.br) + 'px'); 277 left = left + pixelsWidth + space + sizes.bl + sizes.br; 278 279 $(rows[i][j]).css('top', top + 'px'); 280 281 if (j == rows[i].length - 1) 282 top = top + (sizes.h / widthRatio) + space + sizes.bb + sizes.bt; 283 } 284 285 } 286 287 $gallery.css('height', (top - space) + 'px'); 288 $gallery.addClass('deg-loaded'); 289 290 if (!_self.init) { 291 _self.lightbox( $gallery ); 292 } 293 294 }); 295 296 if (!_self.init) { 297 $(window).trigger("scroll"); 298 _self.init = true; 299 } 300 } 301 302 this.addToRow = function($, currentRow, $image, galleryWidth, minHeigth, space, maxImageHeight) { 303 var sizes = this.imageSizes($, maxImageHeight, $image, $image.parent()), 304 total = sizes.w; 305 for (var i = 0; i < currentRow.length; i++) { 306 var currentSizes = this.imageSizes($, maxImageHeight, $(currentRow[i]).find('img'), $(currentRow[i])); 307 total += currentSizes.w; 308 if (i > 0) 309 total += space; 310 } 311 312 var widthRatio = total / galleryWidth; 313 314 var heigth = sizes.h / widthRatio; 315 316 if (heigth > minHeigth) 317 return true; 318 else 319 return false;
320 } 321 322 this.maxHeight = function($, images) { 323 var heigth = 0; 324 for (var i = 0; i < images.length; i++) { 325 var $img = $(images[i]).find('img'); 326 if ( $img.attr('height') > heigth ) 327 heigth = $img.attr('height'); 328 } 329 330 return heigth; 331 332 } 333 334 this.imageSizes = function($, heigth, $img, $figure) { 335 var ratio = heigth / $img.attr('height'); 336 return { 337 h: $img.attr('height') * ratio, 338 w: $img.attr('width') * ratio, 339 r: ratio, 340 bt: Number($figure.css('borderTopWidth').replace(/[^0-9]/g, '')), 341 br: Number($figure.css('borderRightWidth').replace(/[^0-9]/g, '')), 342 bb: Number($figure.css('borderBottomWidth').replace(/[^0-9]/g, '')), 343 bl: Number($figure.css('borderLeftWidth').replace(/[^0-9]/g, '')) 344 }; 345 } 346 347 this.checkMinInRows = function($, minImages, rows) { 348 rows = this.clearEmptyRows(rows); 349 for (var i = rows.length -1; i > 0; i--) { 350 if (rows[i].length < minImages) { 351 if (this.canTakeFromRow(minImages, rows, i - 1)) { 352 var el = rows[ i - 1].pop(); 353 rows[ i ] = [el].concat(rows[i]); 354 return this.checkMinInRows($, minImages, rows); 355 } 356 } 357 } 358 359 if ( minImages > 1 && rows.length > 1 && rows[0].length == 1 ) { 360 var el = rows[0].pop(); 361 rows[1] = [el].concat(rows[1]); 362 rows = this.clearEmptyRows(rows); 363 } 364 365 return rows; 366 } 367 368 this.clearEmptyRows = function(rows) { 369 return rows.filter(function(r) { 370 return r && r.length > 0; 371 }); 372 } 373 374 this.canTakeFromRow = function(minImages, rows, index) { 375 return rows[index].length > 0; 376 } 377 378 this.doLazyload = function() { 379 $('.deg-gallery-item').not('.deg-out-page').not('.deg-out-minified').find('.deg-lazyload').lazyload(); 380 $('.deg-gallery-item').not('.deg-out-page').not('.deg-out-minified').find('picture.deg-lazyload img').lazyload(); 381 } 382 383 this.executeFilter = function(type, $wrapper, excludeMovement) { 384 var $filter = $wrapper.find('.deg-gallery-filter-categories'), 385 withFilter = $filter.length > 0, 386 category = null, 387 388 $paginator = $wrapper.find('.deg-gallery-pagination'), 389 withPagination = $paginator.length > 0, 390 page = 0, 391 pageSize = 0, 392 393 $gallery = $wrapper.find('.deg-gallery-container'), 394 items = $gallery.find('.deg-gallery-item'); 395 396 $gallery.find('.deg-out-page').removeClass('deg-out-page'); 397 $gallery.find('.deg-out-filter').removeClass('deg-out-filter'); 398 items.addClass('deg-in-filter'); 399 400 if (withFilter) { 401 category = $filter.attr('data-value'); 402 $.each(items, function(index, item) { 403 var $item = $(item); 404 var categories = $item.attr('data-categories') 405 if (category && categories.split(',').indexOf(category) < 0) { 406 $item.removeClass('deg-in-filter'); 407 $item.addClass('deg-out-filter'); 408 } 409 }); 410 } 411 412 if (withPagination) { 413 414 pageSize = $paginator.attr('data-page-size'); 415 416 if (type == 'category') { 417 $paginator.attr('data-value', 1); 418 $paginator.find('.deg-page-disabled').removeClass('deg-page-disabled'); 419 $paginator.find('.deg-gallery-page-button-active').removeClass('deg-gallery-page-button-active'); 420 $paginator.find('.deg-gallery-page-button') 421 .not('.deg-gallery-page-button-prev') 422 .not('.deg-gallery-page-button-next') 423 .not('.deg-gallery-page-button-more') 424 .eq(0).addClass('deg-gallery-page-button-active'); 425 426 var categoryTotal = $gallery.find('.deg-in-filter').length, 427 categoryPages = Math.ceil(categoryTotal/pageSize); 428 $paginator.attr('data-max', categoryPages); 429 $paginator.find('.deg-gallery-page-button') 430 .not('.deg-gallery-page-button-prev') 431 .not('.deg-gallery-page-button-next') 432 .not('.deg-gallery-page-button-more') 433 .each(function(i, button) { 434 if (i >= categoryPages) 435 $(button).addClass('deg-page-disabled'); 436 }); 437 } 438 439 page = $paginator.attr('data-value'); 440 var min = pageSize * (page - 1), 441 max = pageSize * page, 442 filteredItems = []; 443 if (category) { 444 filteredItems = items.filter('.deg-in-filter'); 445 } else { 446 filteredItems = items; 447 } 448 449 if ( page == 1 ) { 450 $paginator.find('.deg-gallery-page-button-prev').addClass('deg-page-disabled'); 451 } else { 452 $paginator.find('.deg-gallery-page-button-prev').removeClass('deg-page-disabled'); 453 } 454 455 if ( page == $paginator.attr('data-max') ) { 456 $paginator.find('.deg-gallery-page-button-next').addClass('deg-page-disabled'); 457 } else { 458 $paginator.find('.deg-gallery-page-button-next').removeClass('deg-page-disabled'); 459 } 460 461 $.each(filteredItems, function(index, item) { 462 if (index < min || index >= max)
463 $(item).addClass('deg-out-page'); 464 }); 465 } 466 if ( type == 'page' && !excludeMovement) { 467 $([document.documentElement, document.body]).animate({ 468 scrollTop: $wrapper.offset().top - 150 469 }, 350, function() { 470 DEG_elastic_gallery.doLazyload(); 471 }); 472 } else { 473 DEG_elastic_gallery.doLazyload(); 474 } 475 476 $gallery.find('.deg-gallery-item').not('.deg-in-filter').addClass('deg-out-page'); 477 478 DEG_elastic_gallery.layout(); 479 DEG_elastic_gallery.lightbox( $gallery ); 480 481 } 482 483 this.updateMonarch = function(img) { 484 setTimeout(function() { 485 $('.et_social_icon img[src="undefined"]').parents('.et_social_pin_image').remove(); 486 487 var pin_container = $( '.et_social_pin_images' ), 488 permalink = pin_container.data( 'permalink' ), 489 title = pin_container.data( 'title' ), 490 post_id = pin_container.data( 'post_id' ); 491 492 if ( pin_container.length ) { 493 var this_img = $( img ).attr( 'src' ), 494 this_alt = $( img ).attr( 'alt' ); 495 496 if ( '' != this_img && $('.et_social_pin_image img[src="' + this_img + '"]').length == 0 ) { 497 var pin_link = 'http://www.pinterest.com/pin/create/button/?url=' + permalink + '&media=' + this_img + '&description=' + title, 498 this_img_container = '<div class="et_social_pin_image"><a href="' + pin_link + '" rel="nofollow" class="et_social_icon et_social_share" data-social_name="pinterest" data-post_id="' + post_id + '" data-social_type="share"><img src="' + this_img + '" alt="' + this_alt + '"/><span class="et_social_pin_overlay et_social_icon"></span></a></div>'; 499 $( '.et_social_pin_images' ).append( this_img_container ); 500 } 501 } 502 }, 1500); 503 } 504 505 return this.__construct(); 506}
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.