1jQuery(function($) { 2 var updateOnScroll = false; 3 4 $('body').on('divipasswords', function(a, b, c) { 5 dmg_initialize(); 6 }); 7 8 /** 9 * Inicializa los controles de la galerÃa 10 */ 11 function dmg_initialize() { 12 13 //Creación de la galerÃa 14 $('.dmg-gallery').each(function(i, el) { 15 var $gallery = $(el); 16 $gallery.isotope({ 17 itemSelector: '.dmg_masonry_gallery_item', 18 masonry : { 19 columnWidth: '.dmg-gallery-sizer', 20 gutter : '.dmg-gutter-sizer', 21 percentPosition: true 22 } 23 }); 24 25 $gallery.imagesLoaded(function() { 26 $gallery.isotope('layout'); 27 }); 28 29 $gallery.imagesLoaded().progress( function() { 30 $gallery.isotope('layout'); 31 }); 32 33 $gallery.on('layoutComplete', function(){ 34 $(window).trigger("scroll"); 35 }); 36 37 38 try { 39 $('img.lazyload').on('load', function() { 40 $gallery.isotope('layout'); 41 }); 42 } catch(e) { 43 console.log("Skip masonry ll"); 44 } 45 46 47 dmg_lightbox( $gallery ); 48 49 var $module = $gallery.parents('.dmg_masonry_gallery'); 50 if ( $module && $module.length && $module.attr('id') ) { 51 var module_id = $module.attr('id'), 52 params = new URLSearchParams(window.location.search); 53 if ( params.get(module_id) ) { 54 $module.find('.dmg-gallery-filter[data-slug="' + params.get(module_id) + '"]').click(); 55 } 56 } 57 }); 58 59 if (updateOnScroll) { 60 var scrollTO = null; 61 $(window).scroll(function() { 62 clearTimeout(scrollTO); 63 scrollTO = setTimeout(function() { 64 $('.dmg-gallery').isotope('layout'); 65 }, 300); 66 }); 67 } 68 69 //Evento del filtro 70 $('.dmg-gallery-filter').on('click', function() { 71 var $this = $(this), 72 value = $this.attr('data-value'), 73 $wrapper = $this.parents('.dmg-gallery-wrapper'), 74 $filter = $wrapper.find('.dmg-gallery-filter-categories'); 75 76 if ($this.hasClass('dmg-filter-active')) 77 return; 78 79 $filter.attr('data-value', value); 80 $filter.find('.dmg-filter-active').removeClass('dmg-filter-active'); 81 $this.addClass('dmg-filter-active'); 82 83 executeFilter('category', $wrapper); 84 }); 85 86 //Evento del paginado 87 $('.dmg-gallery-page-button').on('click', function() { 88 var $this = $(this), 89 page = $this.attr('data-value'), 90 $wrapper = $this.parents('.dmg-gallery-wrapper'), 91 $paginator = $wrapper.find('.dmg-gallery-pagination'), 92 excludeMovement = false, 93 max = Number($paginator.attr('data-max')), 94 current = Number($paginator.attr('data-value')); 95 96 if ( page == 'more') { 97 page = 1; 98 excludeMovement = true; 99 var pageSize = Number($paginator.attr('data-page-size')), 100 more = Number($paginator.attr('data-more')); 101 $paginator.attr('data-page-size', pageSize + more); 102 if ( pageSize >= more * (max-1)) { 103 $this.addClass('dmg-page-disabled'); 104 } 105 } else if (page == 'prev') { 106 if ( current > 1) 107 page = current - 1; 108 else 109 return; 110 } else if ( page == 'next') { 111 if ( current < max) 112 page = current + 1; 113 else 114 return; 115 } else if (page == $paginator.attr('data-value')) 116 return; 117 118 $paginator.attr('data-value', page); 119 $paginator.find('.dmg-gallery-page-button-active').removeClass('dmg-gallery-page-button-active'); 120 $paginator.find('.dmg-gallery-page-button[data-value="' + page + '"]').addClass('dmg-gallery-page-button-active'); 121 122 executeFilter('page', $wrapper, excludeMovement); 123 }); 124 125 //Eventos de la carga lazyload 126 $("img.dmg-lazyload").lazyload(); 127 128 if ( $('picture.dmg-lazyload img').length ) { 129 $('picture.dmg-lazyload img').lazyload(); 130 131 $("picture.dmg-lazyload img").on("load", function() { 132 $(this).parents('.dmg-gallery').isotope('layout'); 133 updateMonarch(this); 134 }); 135 } 136 137 $("img.dmg-lazyload").on("load", function() { 138 $(this).parents('.dmg-gallery').isotope('layout'); 139 updateMonarch(this); 140 }); 141 } 142 143 $(document).on('lazyloaded', function(e) { 144 var $gallery = $(e.target).parents('.dmg-gallery'); 145 if ($gallery.length) { 146 $gallery.isotope('layout'); 147 } 148 updateMonarch(e.target); 149 }); 150 151 /** 152 * Genera el control del popup 153 * @param {*} $gallery Div de la galerÃa 154 */ 155 function dmg_lightbox( $gallery ) { 156 if ($gallery.hasClass('dmg-modal-gallery')) { 157 var legend = $gallery.hasClass('dmg-modal-gallery-with-title'); 158 $gallery.find('a.dmg_masonry_gallery_item').not('.dmg-minimized-link').on('click', function(e) { 159 e.preventDefault(); 160 }); 161 162 //Habilitamos el html en la galerÃa para el title/caption 163 if ( jQuery.magnificPopup && jQuery.magnificPopup.defaults ) 164 jQuery.magnificPopup.defaults.allowHTMLInTemplate = true; 165 166 $gallery.find('a.dmg_masonry_gallery_item').not('.dmg-minimized-link').not('.dmg-out-filter').magnificPopup({ 167 type: 'image', 168 closeOnContentClick: false, 169 closeBtnInside: false, 170 mainClass: 'mfp-with-zoom mfp-img-mobile', 171 disableOn: function(a, b, c) { 172 if ( $gallery.hasClass('dmg-disable-modal-tablet') && $(window).width() < 981 ) 173 return false;
174 else if ( $gallery.hasClass('dmg-disable-modal-phone') && $(window).width() < 768 ) 175 return false; 176 177 return true; 178 }, 179 image : { 180 titleSrc : function(item) { 181 if ( legend ) { 182 var title = '<span>' + item.el.attr('data-title') + '</span>' || '' ; 183 var caption = item.el.attr('data-caption') || '' ; 184 if ( $gallery.hasClass('dmg-modal-title__title_caption')) { 185 return '<span>' + title + '</span><br><small>' + caption + '</small>'; 186 } else if ( $gallery.hasClass('dmg-modal-title__caption')) { 187 return '<small>' + caption + '</small>'; 188 } else if ( $gallery.hasClass('dmg-modal-title__in_title')) { 189 return '<span>' + title + '</span><br><small>' + caption + '</small>'; 190 } else if ( $gallery.hasClass('dmg-modal-title__in_title_caption')) { 191 return '<span>' + title + '</span><br><small>' + caption + '</small>'; 192 } else if ( $gallery.hasClass('dmg-modal-title__in_caption')) { 193 return '<small>' + caption + '</small>'; 194 } else 195 return title; 196 } 197 } 198 }, 199 gallery: { 200 enabled: true, 201 tPrev: '', 202 tNext: '', 203 tCounter: '' 204 }, 205 zoom: { 206 enabled: true, 207 duration: 300, // don't foget to change the duration also in CSS 208 opener: function(element) { 209 return element.find('img'); 210 } 211 }, 212 callbacks: { 213 change: function() { 214 if (this.isOpen) { 215 this.wrap.addClass('mfp-open'); 216 } 217 }, 218 open: function() { 219 if ( $gallery.hasClass('dmg-modal-title__in_title') || $gallery.hasClass('dmg-modal-title__in_title_caption') || $gallery.hasClass('dmg-modal-title__in_caption') ) { 220 $(this.container).addClass('dmg-modal-in-data'); 221 } 222 223 var $module = $(this.ev[0]).parents('.dmg_masonry_gallery'), 224 classes = $module && $module.length ? $module[0].className.split(' ') : []; 225 226 //Divi 5 fallback 227 if ( !classes.length ) { 228 $module = $(this.ev[0]).parents('.destaca_masonry_gallery'); 229 classes = $module && $module.length ? $module[0].className.split(' ') : []; 230 classes.forEach(c => { 231 if ( c.match(/^destaca_masonry_gallery_\d+$/g) ) { 232 $(this.bgOverlay).addClass('mfp-dmg-masonry-gallery ' + c); 233 $(this.wrap).addClass('mfp-dmg-masonry-gallery ' + c); 234 } 235 }); 236 } else { 237 classes.forEach(c => { 238 if ( c.match(/^dmg_masonry_gallery_\d+$/g) ) { 239 $(this.bgOverlay).addClass('mfp-dmg-masonry-gallery ' + c); 240 $(this.wrap).addClass('mfp-dmg-masonry-gallery ' + c); 241 } 242 }); 243 } 244 } 245 } 246 }); 247 } 248 } 249 250 251 /** 252 * Ejecuta el filtro/paginado 253 * 254 * @param {*} type Si es por categorÃa o por página 255 * @param {*} $wrapper Div que contiene la galerÃa 256 * @param {*} excludeMovement Cierto si no hay que hacer scroll al comienzo de la galerÃa 257 */ 258 function executeFilter(type, $wrapper, excludeMovement) { 259 var $filter = $wrapper.find('.dmg-gallery-filter-categories'), 260 withFilter = $filter.length > 0, 261 category = null, 262 263 $paginator = $wrapper.find('.dmg-gallery-pagination'), 264 withPagination = $paginator.length > 0, 265 page = 0, 266 pageSize = 0, 267 268 $gallery = $wrapper.find('.dmg-gallery'), 269 items = $gallery.find('.dmg_masonry_gallery_item'), 270 hasSideFilter = $gallery.parents('.dmg_masonry_gallery').find('.dmg-gallery-filter-side').length > 0; 271 272 $gallery.find('.dmg-out-page').removeClass('dmg-out-page'); 273 $gallery.find('.dmg-out-filter').removeClass('dmg-out-filter'); 274 items.addClass('dmg-in-filter'); 275 276 if (withFilter) { 277 category = $filter.attr('data-value'); 278 $.each(items, function(index, item) { 279 var $item = $(item); 280 var categories = $item.attr('data-categories') 281 if (category && categories.split(',').indexOf(category) < 0) { 282 $item.removeClass('dmg-in-filter'); 283 $item.addClass('dmg-out-filter'); 284 } 285 }); 286 } 287 288 if (withPagination) { 289 290 pageSize = $paginator.attr('data-page-size'); 291 292 if (type == 'category') { 293 $paginator.attr('data-value', 1); 294 $paginator.attr('data-page-size', $paginator.attr('data-more')); 295 $paginator.find('.dmg-page-disabled').removeClass('dmg-page-disabled'); 296 $paginator.find('.dmg-gallery-page-button-active').removeClass('dmg-gallery-page-button-active'); 297 $paginator.find('.dmg-gallery-page-button') 298 .not('.dmg-gallery-page-button-prev') 299 .not('.dmg-gallery-page-button-next') 300 .not('.dmg-gallery-page-button-more') 301 .eq(0).addClass('dmg-gallery-page-button-active'); 302 303 var categoryTotal = $gallery.find('.dmg-in-filter').length, 304 categoryPages = Math.ceil(categoryTotal/pageSize); 305 $paginator.attr('data-max', categoryPages); 306 $paginator.find('.dmg-gallery-page-button') 307 .not('.dmg-gallery-page-button-prev') 308 .not('.dmg-gallery-page-button-next') 309 .not('.dmg-gallery-page-button-more') 310 .each(function(i, button) { 311 if (i >= categoryPages) 312 $(button).addClass('dmg-page-disabled'); 313 }); 314 315 if ( categoryPages <= 1 ) { 316 $paginator.find('.dmg-gallery-page-button-more').addClass('dmg-page-disabled'); 317 } else { 318 $paginator.find('.dmg-gallery-page-button-next').removeClass('dmg-page-disabled'); 319 } 320 } 321 322 page = $paginator.attr('data-value'); 323 var min = pageSize * (page - 1), 324 max = pageSize * page; 325 filteredItems = []; 326 if (category) { 327 filteredItems = items.filter('.dmg-in-filter'); 328 } else { 329 filteredItems = items; 330 } 331 332 if ( page == 1 ) { 333 $paginator.find('.dmg-gallery-page-button-prev').addClass('dmg-page-disabled'); 334 } else { 335 $paginator.find('.dmg-gallery-page-button-prev').removeClass('dmg-page-disabled'); 336 } 337 338 if ( page == $paginator.attr('data-max') ) { 339 $paginator.find('.dmg-gallery-page-button-next').addClass('dmg-page-disabled'); 340 } else { 341 $paginator.find('.dmg-gallery-page-button-next').removeClass('dmg-page-disabled'); 342 } 343 344 $.each(filteredItems, function(index, item) { 345 if (index < min || index >= max) 346 $(item).addClass('dmg-out-page'); 347 }); 348 } 349 350 if (( type == 'page' && !excludeMovement && $paginator.hasClass('dmg-gallery-pagination-scrollable')) || (hasSideFilter && type != 'page')) { 351 var offset = Number($paginator.attr('data-offset')); 352 if ( isNaN(offset) || offset < 0 ) 353 offset = 0; 354 $([document.documentElement, document.body]).animate({ 355 scrollTop: $gallery.offset().top - offset 356 }, 750); 357 } 358 359 $gallery.addClass('execute-filter'); 360 361 $gallery.isotope({ filter: function() { 362 return $(this).hasClass('dmg-in-filter') && !$(this).hasClass('dmg-out-page'); 363 } 364 }); 365 366 dmg_lightbox( $gallery ); 367 } 368 369 /** 370 * Actualiza las url para la ventana de compartir de Monarch 371 * @param {*} img 372 */ 373 function updateMonarch(img) { 374 setTimeout(function() { 375 $('.et_social_icon img[src="undefined"]').parents('.et_social_pin_image').remove(); 376 377 var pin_container = $( '.et_social_pin_images' ), 378 permalink = pin_container.data( 'permalink' ), 379 title = pin_container.data( 'title' ), 380 post_id = pin_container.data( 'post_id' ); 381 382 if ( pin_container.length ) { 383 var this_img = $( img ).attr( 'src' ), 384 this_alt = $( img ).attr( 'alt' ); 385
386 if ( '' != this_img && $('.et_social_pin_image img[src="' + this_img + '"]').length == 0 ) { 387 var pin_link = 'http://www.pinterest.com/pin/create/button/?url=' + permalink + '&media=' + this_img + '&description=' + title, 388 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>'; 389 $( '.et_social_pin_images' ).append( this_img_container ); 390 } 391 } 392 }, 1500); 393 } 394 395 //Control del evento scroll 396 $(window).on('scroll', function() { 397 var top = $(window).scrollTop(); 398 $('.dmg_masonry_gallery').each(function(i, el) { 399 var $gallery = $(el), 400 sideFilters = $gallery.find('.dmg-gallery-filter-side').eq(0); 401 if ( sideFilters.length ) { 402 var menuHeight = 0, 403 $menu = $('#main-header'); 404 if ( $menu.length ) 405 menuHeight = $menu.outerHeight(); 406 407 var galleryTop = $gallery.offset().top 408 var max = $gallery.outerHeight() - sideFilters.outerHeight(); 409 if ( top + menuHeight > galleryTop ) { 410 if ( (top - menuHeight) > max ) { 411 sideFilters.css('top', max + 'px'); 412 } else { 413 sideFilters.css('top', (top - menuHeight) + 'px'); 414 } 415 } else { 416 sideFilters.css('top', '0'); 417 } 418 $gallery.find('.dmg-gallery').css('min-height', sideFilters.outerHeight() + 'px'); 419 } 420 }); 421 }); 422 423 dmg_initialize(); 424});
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.