PageSourceSearch

https://www.structure1.com/wp-content/plugins/easy-facebook-likebo…/assets/js/esf-insta-public.js?ver=1

js structure1.com collected 2026-10-06 13:19:00 UTC 18,157 bytes, 640 lines download raw bytes

1jQuery(function( $ ) {
2  // Lazy load inline images
3  $('img.esf-lazyload').each(function() {
4    $(this).attr('imgsrc', $(this).data('imgsrc'));
5    $(this).removeClass('esf-lazyload');
6  });
7
8  // Lazy load background images
9  var lazyloadBackgrounds = $('.esf-lazyload');
10  lazyloadBackgrounds.each(function() {
11    var dataSrc = $(this).data('imgsrc');
12    $(this).css('background-image', 'url(' + dataSrc + ')');
13    $(this).removeClass('esf-lazyload');
14  });
15
16  // Lazy load new elements added to the page
17  var observer = new MutationObserver(function(mutations) {
18    mutations.forEach(function(mutation) {
19      var newElements = $(mutation.addedNodes).find('.esf-lazyload');
20      newElements.each(function() {
21        var dataSrc = $(this).data('imgsrc');
22        $(this).css('background-image', 'url(' + dataSrc + ')');
23        $(this).removeClass('esf-lazyload');
24      });
25    });
26  });
27  var config = { childList: true, subtree: true };
28  observer.observe(document.body, config);
29});
30
31/* <fs_premium_only> */
32/**
33 * Init Masonry layout
34 */
35function esf_insta_init_masonry(){
36  jQuery('.esf_insta_load_more_btns_wrap').hide();
37  jQuery('.esf-insta-masonry-wrapper .esf_insta_feed_fancy_popup'). imagesLoaded(function() {
38        jQuery('.esf_insta_feeds_holder .esf-insta-load-opacity').fadeIn('slow').css('display', 'inline-block');
39        jQuery('.esf_insta_load_more_btns_wrap').slideDown();
40        jQuery('.esf_insta_feeds_holder .esf-insta-load-opacity').removeClass('esf-insta-load-opacity');
41  });
42}
43/* </fs_premium_only> */
44
45/**
46 * Init Grid layout
47 */
48function esf_insta_init_grid(){
49  jQuery('.esf_insta_load_more_btns_wrap').hide();
50  jQuery('.esf-insta-grid-wrapper .esf_insta_feed_fancy_popup').imagesLoaded(function() {
51        jQuery('.esf_insta_feeds_holder .esf-insta-load-opacity').fadeIn('slow');
52        jQuery('.esf_insta_load_more_btns_wrap').slideDown();
53        jQuery('.esf_insta_feeds_holder .esf-insta-load-opacity').removeClass('esf-insta-load-opacity');
54  });
55}
56
57
58/* <fs_premium_only> */
59/**
60 * Init carousel layout
61 *
62 * @param current
63 */
64function esf_insta_init_carousel(current){
65  current.on('initialized.owl.carousel resized.owl.carousel', function(event) {
66
67    let item_width = event.relatedTarget._widths[0];
68
69    let item_half = parseInt(item_width / 2);
70
71    current.find('.esf_insta_feed_fancy_popup').css('height', item_width + 'px');
72
73    current.children('.owl-nav').children('button').css('top', item_half + 'px');
74  }).owlCarousel({
75    loop: current.data('loop'),
76    autoplay: current.data('autoplay'),
77    margin: current.data('margin'),
78    responsiveClass: true,
79    nav: true,
80    responsive: {
81      0: {
82        items: 1,
83      },
84      600: {
85        items: current.data('items'),
86      },
87      1000: {
88        items: current.data('items'),
89      },
90    },
91    navText: [
92      '<i class=\'icon icon-esf-angle-left\'></i>',
93      '<i class=\'icon icon-esf-angle-right\'></i>'],
94  });
95}
96
97function esf_insta_feed_popup() {
98  jQuery('.esf_insta_feed_fancy_popup.esf_insta_popup').fancybox({
99    infobar: false,
100    toolbar: true,
101    afterShow: esf_insta_popup_after_load,
102    baseClass: 'esf_insta_feed_popup_container',
103    showCloseButton: false,
104    autoDimensions: true,
105    autoScale: true,
106    buttons: [
107      'zoom',
108      'slideShow',
109      'fullScreen',
110      'thumbs',
111      'close',
112    ],
113    image: { preload: true },
114    animationEffect: 'zoom-in-out',
115    transitionEffect: 'zoom-in-out',
116    slideShow: { autoStart: false, speed: 3000 },
117    touch: false,
118    hash: false,
119    iframe: { autoDimensions: true },
120
121    // Disable captions
122    caption: function (instance, item) {
123      return '';
124    },
125
126    // Sanitize data attributes
127    beforeLoad: function (instance, slide) {
128      if (slide.opts.$orig) {
129        // Sanitize 'data-src'
130        var unsafeSrc = slide.opts.$orig.attr('data-src') || '';
131        var safeSrc = sanitizeUrl(unsafeSrc);
132        slide.opts.src = safeSrc;
133
134        // Validate 'data-type'
135        var type = slide.opts.$orig.attr('data-type') || '';
136        var allowedTypes = ['image', 'iframe', 'ajax', 'inline'];
137        if (allowedTypes.includes(type)) {
138          slide.opts.type = type;
139        } else {
140          slide.opts.type = 'ajax';
141        }
142
143        // Sanitize 'data-fancybox'
144        var unsafeFancybox = slide.opts.$orig.attr('data-fancybox') || '';
145        var safeFancybox = sanitizeText(unsafeFancybox);
146        slide.opts.$orig.attr('data-fancybox', safeFancybox);
147
148        // Sanitize 'data-imgsrc'
149        var unsafeImgSrc = slide.opts.$orig.attr('data-imgsrc') || '';
150        var safeImgSrc = sanitizeUrl(unsafeImgSrc);
151        slide.opts.$orig.attr('data-imgsrc', safeImgSrc);
152
153        // Sanitize 'style' attribute
154        var unsafeStyle = slide.opts.$orig.attr('style') || '';
155        var safeStyle = sanitizeStyle(unsafeStyle);
156        slide.opts.$orig.attr('style', safeStyle);
157
158        // Remove any other data attributes not needed
159        slide.opts.$orig.removeAttr('data-caption');
160        slide.opts.$orig.removeAttr('data-options');
161        // Add any other attributes to remove as needed
162      }
163    }
164  });
165}
166
167function sanitizeUrl(url) {
168  var safeUrl = url.replace(/^\s*(javascript|data):/gi, '');
169  return safeUrl;
170}
171
172function sanitizeText(text) {
173  return jQuery('<div>').text(text).html();
174}
175
176function sanitizeStyle(style) {
177  var safeStyle = style.replace(/expression\([^)]*\)/gi, '')
178    .replace(/url\(['"]?javascript:[^'"]*['"]?\)/gi, '');
179  return safeStyle;
180}
181// For Popup Carousel Image
182function esfInstacarouselImages() {
183  // Changing Images Function starts here
184  var imgFront = jQuery('.esf-insta-popup .esf-insta-media-item img');
185
186  jQuery(document).on('click', '.esf-insta-media-thumbnail', function(event) {
187    if (jQuery(this).attr('data-type') == 'VIDEO') {
188
189      var vidoUrl = jQuery(this).attr('data-v-url');
190
191      jQuery(imgFront).addClass('esf-insta-carousel-hide');
192
193      jQuery('.esf-insta-popup .esf-insta-media-item .esf-insta-carousel-video').
194          attr('src', vidoUrl);
195
196      jQuery('.esf-insta-popup .esf-insta-media-item .esf-insta-carousel-video').
197          get(0).
198          play();
199
200      jQuery('.esf-insta-popup .esf-insta-media-item .esf-insta-carousel-video').
201          removeClass('esf-insta-carousel-hide');
202
203    }
204    else {
205      var imgTo = jQuery(this).attr('style');
206      imgTo = imgTo.replace('background:url(\'', '').
207          replace('\');', '').
208          replace(/\"/gi, '');
209      jQuery('.esf-insta-popup .esf-insta-media-item .esf-insta-carousel-video').
210          addClass('esf-insta-carousel-hide');
211      jQuery(imgFront).attr('src', imgTo);
212      jQuery('.esf-insta-popup .esf-insta-media-item .esf-insta-carousel-video').
213          get(0).
214          pause();
215      jQuery(imgFront).removeClass('esf-insta-carousel-hide');
216
217    }
218  });
219  // Changing Images Function ends here
220
221  // next prev button for function for thumbs starts here
222  var thumbSec = jQuery('.esf-insta-popup .esf-insta-media-thumbn
222ail-section');
223  var thumbSecOuter = jQuery('.esf-insta-popup .esf-insta-media-carousel');
224  jQuery(thumbSecOuter).
225      prepend('<span class="esf-insta-scrollbtn esf-insta-lsbtn"></span>');
226  jQuery(thumbSecOuter).
227      append('<span class="esf-insta-scrollbtn esf-insta-rsbtn"></span>');
228  var thumbLBtn = jQuery(
229      '.esf-insta-popup .esf-insta-scrollbtn.esf-insta-lsbtn');
230  var thumbRBtn = jQuery(
231      '.esf-insta-popup .esf-insta-scrollbtn.esf-insta-rsbtn');
232  thumbLBtn.fadeOut();
233  var view = jQuery('.esf-insta-popup .esf-insta-media-thumbnail-section-inner');
234  var move = jQuery(thumbSec).width();
235  var limWidth = jQuery(view).width();
236  var sliderLimit = jQuery(thumbSec).width() - limWidth;
237
238  if (jQuery(view).width() <= jQuery(thumbSec).width()) {
239    thumbRBtn.fadeOut();
240    thumbLBtn.fadeOut();
241  }
242
243  jQuery(thumbRBtn).click(function() {
244    var currentPosition = parseInt(view.css('left'));
245    if (currentPosition > sliderLimit) {
246      view.stop(false, true).
247          animate({left: '-=' + move}, {duration: 400});
248    }
249    thumbLBtn.fadeIn();
250    var currentPositionP = Math.abs(currentPosition);
251    var curNewPositionP = currentPositionP;
252    var rLimitPositionP = Math.abs(sliderLimit + jQuery(thumbSec).width());
253    if (curNewPositionP >= rLimitPositionP) {
254      jQuery(this).fadeOut();
255    }
256  });
257
258  jQuery(thumbLBtn).click(function() {
259
260    var currentPosition = parseInt(view.css('left'));
261    if (currentPosition < 0) {
262      view.stop(false, true).
263          animate({left: '+=' + move}, {duration: 400});
264    }
265    var currentStopPos = Math.abs(currentPosition);
266    var stopPos = jQuery(thumbSec).width();
267    if (currentStopPos == stopPos) {
268      jQuery(this).fadeOut();
269    }
270    thumbRBtn.fadeIn();
271
272  });
273  // next prev button for function for thumbs ends here
274
275}
276
277function esf_insta_popup_after_load(instance, slide) {
278  esfInstacarouselImages();
279  // When popup content has GDPR placeholders, run consent check so real images load if consent already given.
280  var $container = jQuery('.esf_insta_feed_popup_container .esf-insta-popup[data-esf-flags]');
281  if ($container.length && typeof window.ESFGDPR !== 'undefined' && window.ESFGDPR.checkConsent($container) && window.ESFGDPR.enableFullFeatures) {
282    window.ESFGDPR.enableFullFeatures($container);
283  }
284}
285
286/* </fs_premium_only> */
287
288jQuery(document).ready(function($) {
289  if (jQuery('.esf_insta_feeds_grid').length) {
290    esf_insta_init_grid();
291  }
292
293  /* <fs_premium_only> */
294
295  if (jQuery('.esf_insta_feeds_masonary').length) {
296    esf_insta_init_masonry();
297  }
298  if (esf_insta.version === 'pro') {
299
300    // Equal height script starts
301    equalheight = function(container) {
302
303      var currentTallest = 0,
304          currentRowStart = 0,
305          rowDivs = new Array(),
306          jQueryel,
307          topPosition = 0;
308      jQuery(container).each(function() {
309
310        jQueryel = jQuery(this);
311        jQuery(jQueryel).height('auto');
312        topPostion = jQueryel.position().top;
313
314        if (currentRowStart != topPostion) {
315          for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) {
316            rowDivs[currentDiv].height(currentTallest);
317          }
318          rowDivs.length = 0; // empty the array
319          currentRowStart = topPostion;
320          currentTallest = jQueryel.height();
321          rowDivs.push(jQueryel);
322        }
323        else {
324          rowDivs.push(jQueryel);
325          currentTallest = (currentTallest < jQueryel.height())
326              ? (jQueryel.height())
327              : (currentTallest);
328        }
329        for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) {
330          rowDivs[currentDiv].height(currentTallest);
331        }
332      });
333    };
334
335    jQuery(window).resize(function() {
336      equalheight('.e-outer .e-inner');
337    });
338
339    jQuery(window).resize(function() {
340      jQuery('.esf-insta-grid-box').each(function() {
341      });
342    }).resize();
343
344    jQuery('.esf_insta_feeds_carousel').each(function(index) {
345      esf_insta_init_carousel(jQuery('.esf_insta_feeds_carousel'));
346    });
347
348
349    jQuery('.esf_insta_stories_popup').fancybox({
350      infobar: false,
351      toolbar: true,
352      baseClass: 'esf_insta_feed_popup_container',
353      showCloseButton: false,
354      autoDimensions: true,
355      autoScale: true,
356      buttons: [
357        'zoom',
358        'slideShow',
359        'fullScreen',
360        'thumbs',
361        'close',
362      ],
363      image: {
364        preload: true,
365      },
366      animationEffect: 'zoom-in-out',
367      transitionEffect: 'zoom-in-out',
368      slideShow: {
369        autoStart: true,
370        speed: 5000,
371      },
372      touch: true, // Allow to drag content vertically
373      hash: false,
374      iframe: {
375        autoDimensions: true,
376      },
377      afterShow: function(instance, current) {
378        if (current.index  ===  instance.group.length - 1) {
379          setTimeout(function(){ parent.jQuery.fancybox.getInstance().close(); }, 5000);
380        }
381      }
382    });
383
384    function esf_insta_popup_after_load(instance, slide) {
385      esfInstacarouselImages();
386      var $container = jQuery('.esf_insta_feed_popup_container .esf-insta-popup[data-esf-flags]');
387      if ($container.length && typeof window.ESFGDPR !== 'undefined' && window.ESFGDPR.checkConsent($container) && window.ESFGDPR.enableFullFeatures) {
388        window.ESFGDPR.enableFullFeatures($container);
389      }
390    }
391
392    esf_insta_feed_popup();
393
394    //See more and less descrption
395    jQuery(document).on('click', '.esf-insta-see-more-btn', function(event) {
396
397      event.preventDefault();
398
399      jQuery(this).attr('disabled', true);
400
401      var status = jQuery(this).attr('data-status');
402
403      var  action = jQuery(this).data('action');
404
405      if( !action ){
406        action = 'esf_insta_load_more_description';
407      }
408
409      if (!status) {
410
411        status = 'more';
412      }
413
414      var outer_this = jQuery(this);
415
416      jQuery.ajax({
417
418        url: esf_insta.ajax_url,
419
420        type: 'post',
421
422        dataType: 'json',
423
424        data: {
425
426          action: action,
427
428          post_id: jQuery(this).data('id'),
429
430          words_limit: jQuery(this).data('words-limit'),
431
432          transient_name: jQuery(this).data('transient-name'),
433
434          status: status,
435
436          nonce: esf_insta.nonce,
437
438        },
439
440        success: function(response) {
441
442          jQuery(outer_this).attr('disabled', false);
443
444          if (response.success) {
445
446            jQuery(outer_this).
447                siblings('.esf-insta-description-wrap').
448                html(' ');
449
450            jQuery(outer_this).
451                siblings('.esf-insta-description-wrap').
452                html(response.data[0]);
453
454            jQuery(outer_this).attr('data-status', response.data[1]);
455
456            jQuery(outer_this).html(' ');
457
458            jQuery(outer_this).html(response.data[2]);
459
460          }
461          else {
462
463            console.log(response.data);
464            return false;
465          }
466        },
467      });
468
469    });
470  }
471
472  jQuery(document).on('click', '.esf_insta_load_more_btn', function(event) {
473
474    event.preventDefault();
475
476    var outer_this = jQuery(this);
477
478    var selected_template = jQuery(this).data('selected-template');
479
480    var load_more_outer = jQuery(this).parent().parent().parent();
481
482    var is_disabled = jQuery(this).hasClass('no-more');
483
484    if (is_disabled) { return; }
485
486    jQuery(outer_this).addClass('loading');
487
488    var transient_name = jQuery(this).data('transient-name');
489
490    var current_items = jQuery(this).attr('data-current_items');
491
492    var shortcode_atts = jQuery(this).data('shortcode_atts');
493
494    jQuery.ajax({
495
496      url: esf_insta.ajax_url,
497
498      type: 'post',
499
500      dataType: 'json',
501
502      data: {
503
504        action: 'esf_insta_load_more_feeds',
505
506        current_items: current_items,
507
508        shortcode_atts: shortcode_atts,
509
510        transient_name: transient_name,
511
512        selected_template: selected_template,
513
514        nonce: esf_insta.nonce,
515
516      },
517
518      success: function(response) {
519
520        if (response.success) {
521
522          var html = response.data.html;
523
524          var total_items = response.data.total_items;
525
526          jQuery(outer_this).attr('data-current_items', ' ');
527
528          jQuery(outer_this).attr('data-current_items', total_items);
529
530          if (selected_template === 'masonary') {
531
532            var $container = jQuery('.esf-insta-masonry-wrapper a');
533
534            var $items = jQuery(html);
535
536            jQuery(outer_this).
537                parent().
538                parent().
539                parent().
540                parent().
541                find('.esf-insta-masonry').
542                append(html);
543            jQuery('.esf-insta-masonry-wrapper .esf_insta_feed_fancy_popup').
544                imagesLoaded(function() {
545
546                  jQuery('.esf_insta_feeds_holder .esf-insta-load-opacity').
547                      fadeIn('slow').
548                      css('display', 'inline-block');
549
550                  jQuery(outer_this).removeClass('loading');
551
552                  jQuery('.esf_insta_feeds_holder .esf-insta-load-opacity').
553                      removeClass('esf-insta-load-opacity');
554
555                });
556
557          }
558          else if (selected_template === 'grid') {
559
560            jQuery(outer_this).
561                parent().
562                parent().
563                parent().
564                parent().
565                find('.esf-insta-row').
566                append(html);
567
568            jQuery('.esf-insta-grid-wrapper .esf_insta_feed_fancy_popup').
569                imagesLoaded(function() {
570
571                  jQuery('.esf_insta_feeds_holder .esf-insta-load-opacity').
572                      fadeIn('slow');
573
574                  jQuery(outer_this).removeClass('loading');
575
576                  jQuery('.esf_insta_feeds_holder .esf-insta-load-opacity').
577                      removeClass('esf-insta-load-opacity');
578
579                });
580
581            jQuery(outer_this).removeClass('loading');
582
583          }
584          else {
585
586            jQuery(outer_this).
587                parent().
588                parent().
589                parent().
590                siblings('.esf_insta_feeds_holder').
591                append(html);
592
593            jQuery(outer_this).removeClass('loading');
594
595          }
596
597
598          if (esf_insta.version === 'pro') {
599
600            esf_insta_feed_popup();
601
602          }
603        }
604        else {
605
606          jQuery(outer_this).removeClass('loading');
607
608          jQuery(outer_this).addClass('no-more');
609          console.log('ESF Error: ' + response.data);
610
611        }
612
613      },
614
615    });
616
617  });
618
619  /* </fs_premium_only> */
620
621});
622
623function esf_insta_init_layouts(){
624  esf_insta_init_grid();
625  /* <fs_premium_only> */
626  esf_insta_init_masonry();
627  esf_insta_init_carousel(jQuery('.esf_insta_feeds_carousel'));
628  esf_insta_feed_popup();
629  esf_insta_popup_after_load();
630  /* </fs_premium_only> */
631}
632
633jQuery( window ).on( 'elementor/frontend/init', function() {
634  elementorFrontend.hooks.addAction( 'frontend/element_ready/shortcode.default', function(){
635    esf_insta_init_layouts();
636  });
637  elementorFrontend.hooks.addAction( 'frontend/element_ready/esf_instagram_feed.default', function(){
638    esf_insta_init_layouts();
639  });
640} );

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.