1var sbi_js_exists = (typeof sbi_js_exists !== 'undefined') ? true : false; 2if (!sbi_js_exists) { 3 (function ($) { 4 function sbiAddVisibilityListener() { 5 /* Detect when element becomes visible. Used for when the feed is initially hidden, in a tab for example. https://github.com/shaunbowe/jquery.visibilityChanged */ 6 !function (i) { 7 var n = { 8 callback: function () { 9 }, runOnLoad: !0, frequency: 100, sbiPreviousVisibility: null 10 }, c = {}; 11 c.sbiCheckVisibility = function (i, n) { 12 if (jQuery.contains(document, i[0])) { 13 var e = n.sbiPreviousVisibility, t = i.is(":visible"); 14 n.sbiPreviousVisibility = t, null == e ? n.runOnLoad && n.callback(i, t) : e !== t && n.callback(i, t), setTimeout(function () { 15 c.sbiCheckVisibility(i, n) 16 }, n.frequency) 17 } 18 }, i.fn.sbiVisibilityChanged = function (e) { 19 var t = i.extend({}, n, e); 20 return this.each(function () { 21 c.sbiCheckVisibility(i(this), t) 22 }) 23 } 24 }(jQuery); 25 } 26 27 function Sbi() { 28 this.feeds = {}; 29 this.options = sb_instagram_js_options; 30 } 31 32 Sbi.prototype = { 33 createPage: function (createFeeds, createFeedsArgs) { 34 if (typeof sb_instagram_js_options.ajax_url !== 'undefined' && typeof window.sbiajaxurl === 'undefined') { 35 window.sbiajaxurl = sb_instagram_js_options.ajax_url; 36 } 37 if (typeof window.sbiajaxurl === 'undefined' || window.sbiajaxurl.indexOf(window.location.hostname) === -1) { 38 window.sbiajaxurl = location.protocol + '//' + window.location.hostname + '/wp-admin/admin-ajax.php'; 39 } 40 41 if ($('#sbi-builder-app').length && typeof window.sbiresizedImages === 'undefined') { 42 if ($('.sbi_resized_image_data').length 43 && typeof $('.sbi_resized_image_data').attr('data-resized') !== 'undefined' 44 && $('.sbi_resized_image_data').attr('data-resized').indexOf('{"') === 0) { 45 window.sbiresizedImages = JSON.parse($('.sbi_resized_image_data').attr('data-resized')); 46 $('.sbi_resized_image_data').remove(); 47 } 48 } 49 50 $('.sbi_no_js_error_message').remove(); 51 $('.sbi_no_js').removeClass('sbi_no_js'); 52 createFeeds(createFeedsArgs); 53 }, 54 createFeeds: function (args) { 55 args.whenFeedsCreated( 56 $('.sbi').each(function (index) { 57 $(this).attr('data-sbi-index', index + 1); 58 var $self = $(this), 59 flags = typeof $self.attr('data-sbi-flags') !== 'undefined' ? $self.attr('data-sbi-flags').split(',') : [], 60 general = typeof $self.attr('data-options') !== 'undefined' ? JSON.parse($self.attr('data-options')) : {}; 61 if (flags.indexOf('testAjax') > -1) { 62 window.sbi.triggeredTest = true; 63 var submitData = { 64 'action': 'sbi_on_ajax_test_trigger' 65 }, 66 onSuccess = function (data) { 67 console.log('did test'); 68 }; 69 sbiAjax(submitData, onSuccess) 70 } 71 var feedOptions = { 72 cols: $self.attr('data-cols'), 73 colsmobile: typeof $self.attr('data-colsmobile') !== 'undefined' && $self.attr('data-colsmobile') !== 'same' ? $self.attr('data-colsmobile') : $self.attr('data-cols'), 74 colstablet: typeof $self.attr('data-colstablet') !== 'undefined' && $self.attr('data-colstablet') !== 'same' ? $self.attr('data-colstablet') : $self.attr('data-cols'), 75 num: $self.attr('data-num'), 76 imgRes: $self.attr('data-res'), 77 feedID: $self.attr('data-feedid'), 78 postID: typeof $self.attr('data-postid') !== 'undefined' ? $self.attr('data-postid') : 'unknown', 79 imageaspectratio: typeof $self.attr('data-imageaspectratio') !== 'undefined' ? $self.attr('data-imageaspectratio') : '1:1', 80 shortCodeAtts: $self.attr('data-shortcode-atts'), 81 resizingEnabled: (flags.indexOf('resizeDisable') === -1), 82 imageLoadEnabled: (flags.indexOf('imageLoadDisable') === -1), 83 debugEnabled: (flags.indexOf('debug') > -1), 84 favorLocal: (flags.indexOf('favorLocal') > -1), 85 ajaxPostLoad: (flags.indexOf('ajaxPostLoad') > -1), 86 gdpr: (flags.indexOf('gdpr') > -1), 87 overrideBlockCDN: (flags.indexOf('overrideBlockCDN') > -1), 88 consentGiven: false, 89 locator: (flags.indexOf('locator') > -1), 90 autoMinRes: 1, 91 general: general 92 }; 93 94 window.sbi.feeds[index] = sbiGetNewFeed(this, index, feedOptions); 95 window.sbi.feeds[index].setResizedImages(); 96 window.sbi.feeds[index].init(); 97 98 var evt = jQuery.Event('sbiafterfeedcreate'); 99 evt.feed = window.sbi.feeds[index]; 100 jQuery(window).trigger(evt); 101 102 }) 103 ); 104 }, 105 afterFeedsCreated: function () { 106 // enable header hover action 107 $('.sb_instagram_header').each(function () { 108 var $thisHeader = $(this); 109 $thisHeader.find('.sbi_header_link').on('mouseenter mouseleave', function (e) { 110 switch (e.type) { 111 case 'mouseenter': 112 $thisHeader.find('.sbi_header_img_hover').addClass('sbi_fade_in'); 113 break; 114 case 'mouseleave': 115 $thisHeader.find('.sbi_header_img_hover').removeClass('sbi_fade_in'); 116 break; 117 } 118 }); 119 }); 120 121 }, 122 encodeHTML: function (raw) { 123 // make sure passed variable is defined 124 if (typeof raw === 'undefined') { 125 return ''; 126 } 127 // replace greater than and less than symbols with html entity to disallow html in comments 128 var encoded = raw.replace(/(>)/g, '>'), 129 encoded = encoded.replace(/(<)/g, '<'); 130 encoded = encoded.replace(/(<br\/>)/g, '<br>'); 131 encoded = encoded.replace(/(<br>)/g, '<br>'); 132 133 return encoded; 134 }, 135 urlDetect: function (text) { 136 var urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g; 137 return text.match(urlRegex); 138 } 139 }; 140 141 function SbiFeed(el, index, settings) { 142 this.el = el; 143 this.index = index; 144 this.settings = settings; 145 this.minImageWidth = 0; 146 this.imageResolution = 150; 147 this.resizedImages = {}; 148 this.needsResizing = []; 149 this.outOfPages = false;
150 this.page = 1; 151 this.isInitialized = false; 152 } 153 154 SbiFeed.prototype = { 155 init: function () { 156 var feed = this; 157 feed.settings.consentGiven = feed.checkConsent(); 158 if ($(this.el).find('.sbi_photo').parent('p').length) { 159 $(this.el).addClass('sbi_no_autop'); 160 } 161 if ($(this.el).find('#sbi_mod_error').length) { 162 $(this.el).prepend($(this.el).find('#sbi_mod_error')); 163 } 164 if (this.settings.ajaxPostLoad) { 165 this.getNewPostSet(); 166 } else { 167 this.afterInitialImagesLoaded(); 168 //Only check the width once the resize event is over 169 } 170 var sbi_delay = (function () { 171 var sbi_timer = 0; 172 return function (sbi_callback, sbi_ms) { 173 clearTimeout(sbi_timer); 174 sbi_timer = setTimeout(sbi_callback, sbi_ms); 175 }; 176 })(); 177 jQuery(window).on('resize', function () { 178 sbi_delay(function () { 179 feed.afterResize(); 180 }, 500); 181 }); 182 183 $(this.el).find('.sbi_item').each(function () { 184 feed.lazyLoadCheck($(this)); 185 }); 186 }, 187 initLayout: function () { 188 189 }, 190 afterInitialImagesLoaded: function () { 191 this.initLayout(); 192 this.loadMoreButtonInit(); 193 this.hideExtraImagesForWidth(); 194 this.beforeNewImagesRevealed(); 195 this.revealNewImages(); 196 this.afterNewImagesRevealed(); 197 }, 198 afterResize: function () { 199 this.setImageHeight(); 200 this.setImageResolution(); 201 this.maybeRaiseImageResolution(); 202 this.setImageSizeClass(); 203 }, 204 afterLoadMoreClicked: function ($button) { 205 $button.find('.sbi_loader').removeClass('sbi_hidden'); 206 $button.find('.sbi_btn_text').addClass('sbi_hidden'); 207 $button.closest('.sbi').find('.sbi_num_diff_hide').addClass('sbi_transition').removeClass('sbi_num_diff_hide'); 208 }, 209 afterNewImagesLoaded: function () { 210 var $self = $(this.el), 211 feed = this; 212 this.beforeNewImagesRevealed(); 213 this.revealNewImages(); 214 this.afterNewImagesRevealed(); 215 setTimeout(function () { 216 //Hide the loader in the load more button 217 $self.find('.sbi_loader').addClass('sbi_hidden'); 218 $self.find('.sbi_btn_text').removeClass('sbi_hidden'); 219 feed.maybeRaiseImageResolution(); 220 }, 500); 221 }, 222 beforeNewImagesRevealed: function () { 223 this.setImageHeight(); 224 this.maybeRaiseImageResolution(true); 225 this.setImageSizeClass(); 226 }, 227 revealNewImages: function () { 228 var $self = $(this.el), 229 feed = this; 230 231 $self.find('.sbi-screenreader').each(function () { 232 $(this).find('img').remove(); 233 }); 234 235 // Call Custom JS if it exists 236 if (typeof sbi_custom_js == 'function') setTimeout(function () { sbi_custom_js(); }, 100); 237 238 $self.find('.sbi_item').each(function (index) { 239 var $self = jQuery(this); 240 241 //Photo links 242 $self.find('.sbi_photo').on('mouseenter mouseleave', function (e) { 243 switch (e.type) { 244 case 'mouseenter': 245 jQuery(this).fadeTo(200, 0.85); 246 break; 247 case 'mouseleave': 248 jQuery(this).stop().fadeTo(500, 1); 249 break; 250 } 251 }); 252 }); //End .sbi_item each 253 254 //Remove the new class after 500ms, once the sorting is done 255 setTimeout(function () { 256 jQuery('#sbi_images .sbi_item.sbi_new').removeClass('sbi_new'); 257 //Loop through items and remove class to reveal them 258 var time = 10; 259 $self.find('.sbi_transition').each(function () { 260 var $sbi_item_transition_el = jQuery(this); 261 262 setTimeout(function () { 263 $sbi_item_transition_el.removeClass('sbi_transition'); 264 }, time); 265 time += 10; 266 }); 267 }, 500); 268 }, 269 lazyLoadCheck: function ($item) { 270 var feed = this; 271 if ($item.find('.sbi_photo').length && !$item.closest('.sbi').hasClass('sbi-no-ll-check')) { 272 var imgSrcSet = feed.getImageUrls($item), 273 maxResImage = typeof imgSrcSet[640] !== 'undefined' ? imgSrcSet[640] : $item.find('.sbi_photo').attr('data-full-res'); 274 275 if (!feed.settings.consentGiven) { 276 if (maxResImage.indexOf('scontent') > -1) { 277 return; 278 } 279 } 280 281 $item.find('.sbi_photo img').each(function () { 282 if (maxResImage && typeof $(this).attr('data-src') !== 'undefined') { 283 $(this).attr('data-src', maxResImage); 284 } 285 if (maxResImage && typeof $(this).attr('data-orig-src') !== 'undefined') { 286 $(this).attr('data-orig-src', maxResImage); 287 } 288 $(this).on('load', function () { 289 if (!$(this).hasClass('sbi-replaced') 290 && $(this).attr('src').indexOf('placeholder') > -1) { 291 $(this).addClass('sbi-replaced'); 292 if (maxResImage) { 293 $(this).attr('src', maxResImage); 294 if ($(this).closest('.sbi_imgLiquid_bgSize').length) { 295 $(this).closest('.sbi_imgLiquid_bgSize').css('background-image', 'url(' + maxResImage
295+ ')'); 296 } 297 } 298 } 299 }); 300 }); 301 } 302 }, 303 afterNewImagesRevealed: function () { 304 this.listenForVisibilityChange(); 305 this.sendNeedsResizingToServer(); 306 if (!this.settings.imageLoadEnabled) { 307 $('.sbi_no_resraise').removeClass('sbi_no_resraise'); 308 } 309 310 var evt = $.Event('sbiafterimagesloaded'); 311 evt.el = $(this.el); 312 $(window).trigger(evt); 313 }, 314 setResizedImages: function () { 315 if ($(this.el).find('.sbi_resized_image_data').length 316 && typeof $(this.el).find('.sbi_resized_image_data').attr('data-resized') !== 'undefined' 317 && $(this.el).find('.sbi_resized_image_data').attr('data-resized').indexOf('{"') === 0) { 318 this.resizedImages = JSON.parse($(this.el).find('.sbi_resized_image_data').attr('data-resized')); 319 $(this.el).find('.sbi_resized_image_data').remove(); 320 } else if (typeof window.sbiresizedImages !== 'undefined') { 321 this.resizedImages = window.sbiresizedImages; 322 } 323 }, 324 sendNeedsResizingToServer: function () { 325 var feed = this, 326 $self = $(this.el); 327 if (feed.needsResizing.length > 0 && feed.settings.resizingEnabled) { 328 var itemOffset = $(this.el).find('.sbi_item').length, 329 cacheAll = typeof feed.settings.general.cache_all !== 'undefined' ? feed.settings.general.cache_all : false; 330 var locatorNonce = ''; 331 if (typeof $self.attr('data-locatornonce') !== 'undefined') { 332 locatorNonce = $self.attr('data-locatornonce'); 333 } 334 335 if ($('#sbi-builder-app').length) { 336 if (typeof window.sbiresizeTriggered !== 'undefined' && window.sbiresizeTriggered) { 337 return; 338 } else { 339 window.sbiresizeTriggered = true; 340 } 341 } 342 343 var submitData = { 344 action: 'sbi_resized_images_submit', 345 needs_resizing: feed.needsResizing, 346 offset: itemOffset, 347 feed_id: feed.settings.feedID, 348 atts: feed.settings.shortCodeAtts, 349 location: feed.locationGuess(), 350 post_id: feed.settings.postID, 351 cache_all: cacheAll, 352 locator_nonce: locatorNonce 353 }; 354 var onSuccess = function (data) { 355 var response = data?.data; 356 357 if (typeof data !== 'object' && data.trim().indexOf('{') === 0) { 358 response = JSON.parse(data.trim()); 359 } 360 if (feed.settings.debugEnabled) { 361 console.log(response); 362 } 363 for (var property in response) { 364 if (response.hasOwnProperty(property)) { 365 feed.resizedImages[property] = response[property]; 366 } 367 } 368 feed.maybeRaiseImageResolution(); 369 370 setTimeout(function () { 371 feed.afterResize(); 372 }, 500); 373 if ($('#sbi-builder-app').length) { 374 window.sbiresizeTriggered = false; 375 } 376 }; 377 sbiAjax(submitData, onSuccess); 378 } else if (feed.settings.locator) { 379 var locatorNonce = ''; 380 if (typeof $self.attr('data-locatornonce') !== 'undefined') { 381 locatorNonce = $self.attr('data-locatornonce'); 382 } 383 var submitData = { 384 action: 'sbi_do_locator', 385 feed_id: feed.settings.feedID, 386 atts: feed.settings.shortCodeAtts, 387 location: feed.locationGuess(), 388 post_id: feed.settings.postID, 389 locator_nonce: locatorNonce 390 }; 391 var onSuccess = function (data) { 392 393 }; 394 sbiAjax(submitData, onSuccess); 395 } 396 },
397 loadMoreButtonInit: function () { 398 var $self = $(this.el), 399 feed = this; 400 $self.find('#sbi_load .sbi_load_btn').off().on('click', function () { 401 402 feed.afterLoadMoreClicked(jQuery(this)); 403 feed.getNewPostSet(); 404 405 }); //End click event 406 }, 407 getNewPostSet: function () { 408 var $self = $(this.el), 409 feed = this; 410 feed.page++; 411 // Each request starts from a clean status region, so an earlier failure 412 // message can't linger into this request's own announcement. 413 feed.postSetRequest = (feed.postSetRequest || 0) + 1; 414 var sbiRequestId = feed.postSetRequest; 415 $self.find('[data-sbi-feed-status]').text(''); 416 417 var locatorNonce = ''; 418 if (typeof $self.attr('data-locatornonce') !== 'undefined') { 419 locatorNonce = $self.attr('data-locatornonce'); 420 } 421 422 var itemOffset = $self.find('.sbi_item').length, 423 submitData = { 424 action: 'sbi_load_more_clicked', 425 offset: itemOffset, 426 page: feed.page, 427 feed_id: feed.settings.feedID, 428 atts: feed.settings.shortCodeAtts, 429 location: feed.locationGuess(), 430 post_id: feed.settings.postID, 431 current_resolution: feed.imageResolution, 432 locator_nonce: locatorNonce 433 }; 434 var onSuccess = function (data) { 435 var payload = data; 436 437 if (typeof payload === 'string' && payload.trim().indexOf('{') === 0) { 438 try { 439 payload = JSON.parse(payload.trim()); 440 } catch (e) { 441 payload = data; 442 } 443 } 444 445 // A rejected request (e.g. a stale locator token in cached HTML) 446 // returns {success: false} with no feedStatus; never read into it. 447 if (!feed.isValidPostSetResponse(payload)) { 448 feed.handlePostSetFailure(payload, false, sbiRequestId); 449 return; 450 } 451 452 var response = payload.data; 453 if (feed.settings.debugEnabled) { 454 console.log(response); 455 } 456 var sbiPrevCount = $self.find('#sbi_images .sbi_item').length; 457 feed.appendNewPosts(response.html); 458 var sbiNewCount = $self.find('#sbi_images .sbi_item').length - sbiPrevCount; 459 if (sbiNewCount > 0) { 460 var sbiStatusEl = $self.find('[data-sbi-feed-status]'); 461 var sbiAnnounceText = typeof sbiTranslate === 'function' 462 ? sbiTranslate('new posts loaded') 463 : 'new posts loaded'; 464 if (sbiStatusEl.length) { 465 sbiStatusEl.text(sbiNewCount + ' ' + sbiAnnounceText); 466 } 467 } 468 feed.addResizedImages(response.resizedImages); 469 if (feed.settings.ajaxPostLoad) { 470 feed.settings.ajaxPostLoad = false; 471 feed.afterInitialImagesLoaded(); 472 } else { 473 feed.afterNewImagesLoaded(); 474 } 475 476 if (!response.feedStatus.shouldPaginate) { 477 feed.outOfPages = true; 478 var sbiLoadBtn = $self.find('.sbi_load_btn'); 479 var sbiLoadBtnFocused = sbiLoadBtn.is(document.activeElement); 480 sbiLoadBtn.hide(); 481 var sbiEndStatusEl = $self.find('[data-sbi-feed-status]'); 482 if (sbiEndStatusEl.length) { 483 var sbiEndText = typeof sbiTranslate === 'function' 484 ? sbiTranslate('All posts loaded') 485 : 'All posts loaded'; 486 sbiEndStatusEl.text(sbiNewCount > 0 ? sbiNewCount + ' ' + sbiAnnounceText + '. ' + sbiEndText : sbiEndText); 487 } 488 if (sbiLoadBtnFocused) { 489 var sbiFirstNew = sbiNewCount > 0 ? $self.find('#sbi_images .sbi_item').eq(sbiPrevCount) : $(); 490 if (sbiFirstNew.length) { 491 sbiFirstNew.attr('tabindex', '-1').focus(); 492 } else { 493 var sbiFocusFallback = sbiEndStatusEl.length ? sbiEndStatusEl : $self; 494 sbiFocusFallback.attr('tabindex', '-1').focus(); 495 } 496 } 497 } else { 498 feed.outOfPages = false;
499 } 500 $('.sbi_no_js').removeClass('sbi_no_js'); 501 502 }; 503 var onError = function (jqXHR) { 504 feed.handlePostSetFailure(jqXHR, true, sbiRequestId); 505 }; 506 sbiAjax(submitData, onSuccess, onError); 507 }, 508 isValidPostSetResponse: function (payload) { 509 return !!(payload 510 && typeof payload === 'object' 511 && payload.success === true 512 && payload.data 513 && typeof payload.data === 'object' 514 && payload.data.feedStatus 515 && typeof payload.data.feedStatus === 'object'); 516 }, 517 handlePostSetFailure: function (payload, isTransportError, requestId) { 518 var $self = $(this.el), 519 feed = this; 520 521 try { 522 if (typeof requestId === 'undefined') { 523 requestId = feed.postSetRequest; 524 } 525 526 // A newer request (e.g. a double click) has started since this one was 527 // sent; its own outcome owns the page counter, button, status and focus. 528 if (requestId !== feed.postSetRequest) { 529 if (feed.settings.debugEnabled) { 530 console.log('Instagram Feed: ignoring superseded post request failure', payload); 531 } 532 return; 533 } 534 535 if (feed.settings.debugEnabled) { 536 console.log('Instagram Feed: could not load posts', payload); 537 } 538 539 var sbiLoadBtn = $self.find('.sbi_load_btn'); 540 var sbiLoadBtnFocused = sbiLoadBtn.is(document.activeElement); 541 var sbiStatusEl = $self.find('[data-sbi-feed-status]'); 542 var sbiFailText; 543 $self.find('.sbi_loader').addClass('sbi_hidden'); 544 $self.find('.sbi_btn_text').removeClass('sbi_hidden'); 545 546 // Load More moved held-back posts to .sbi_transition before the request; 547 // reveal them as a successful load would, so they don't stay blank. 548 if (!feed.settings.ajaxPostLoad) { 549 try { 550 feed.afterNewImagesLoaded(); 551 } catch (e) { 552 if (feed.settings.debugEnabled) { 553 console.log(e); 554 } 555 } 556 } 557 558 // A transport error (timeout, 5xx, network) on a Load More click can be 559 // retried: keep the button and give the page number back. A rejected 560 // request, or a failed AJAX initial load, ends pagination. 561 if (isTransportError === true && !feed.settings.ajaxPostLoad) { 562 feed.page = Math.max(1, feed.page - 1); 563 feed.outOfPages = false; 564 sbiFailText = typeof sbiTranslate === 'function' 565 ? sbiTranslate('Couldn\'t load more posts. Please try again.') 566 : 'Couldn\'t load more posts. Please try again.'; 567 if (sbiLoadBtnFocused) { 568 sbiLoadBtn.focus(); 569 } 570 } else { 571 feed.outOfPages = true; 572 sbiLoadBtn.hide(); 573 574 if (feed.settings.ajaxPostLoad) { 575 feed.settings.ajaxPostLoad = false; 576 try { 577 feed.afterInitialImagesLoaded(); 578 } catch (e) { 579 if (feed.settings.debugEnabled) { 580 console.log(e); 581 } 582 } 583 } 584 585 sbiFailText = typeof sbiTranslate === 'function' 586 ? sbiTranslate('Couldn\'t load more posts.') 587 : 'Couldn\'t load more posts.';
588 if (sbiLoadBtnFocused) { 589 // The status region is visually hidden; focus the last post that is 590 // actually rendered (not collapsed or still faded out), else the feed. 591 var sbiFocusTarget = $self; 592 var sbiItems = $self.find('#sbi_images .sbi_item'); 593 for (var sbiIndex = sbiItems.length - 1; sbiIndex >= 0; sbiIndex--) { 594 var sbiItemEl = sbiItems[sbiIndex]; 595 var sbiOpacity = ''; 596 try { 597 sbiOpacity = window.getComputedStyle(sbiItemEl).opacity; 598 } catch (e) { 599 sbiOpacity = ''; 600 } 601 if (sbiItemEl.offsetHeight > 0 && sbiOpacity !== '0') { 602 sbiFocusTarget = $(sbiItemEl); 603 break; 604 } 605 } 606 sbiFocusTarget.attr('tabindex', '-1').focus(); 607 } 608 } 609 610 if (sbiStatusEl.length) { 611 // Clear first so a repeated failure is announced again; skip the write 612 // if a newer request has started or already announced its own result. 613 sbiStatusEl.text(''); 614 setTimeout(function () { 615 try { 616 if (feed.postSetRequest === requestId && sbiStatusEl.text() === '') { 617 sbiStatusEl.text(sbiFailText); 618 } 619 } catch (e) { 620 } 621 }, 100); 622 } 623 624 $('.sbi_no_js').removeClass('sbi_no_js'); 625 } catch (e) { 626 if (feed.settings && feed.settings.debugEnabled) { 627 console.log(e); 628 } 629 } 630 }, 631 appendNewPosts: function (newPostsHtml) { 632 var $self = $(this.el), 633 feed = this; 634 if ($self.find('#sbi_images .sbi_item').length) { 635 $self.find('#sbi_images .sbi_item').last().after(newPostsHtml); 636 } else { 637 $self.find('#sbi_images').append(newPostsHtml); 638 } 639 }, 640 addResizedImages: function (resizedImagesToAdd) { 641 for (var imageID in resizedImagesToAdd) { 642 this.resizedImages[imageID] = resizedImagesToAdd[imageID]; 643 } 644 }, 645 setImageHeight: function () { 646 var $self = $(this.el); 647 648 var sbi_photo_width = $self.find('.sbi_photo').eq(0).innerWidth(); 649 650 //Figure out number of columns for either desktop or mobile 651 var sbi_num_cols = this.getColumnCount(); 652 653 //Figure out what the width should be using the number of cols 654 //Figure out what the width should be using the number of cols 655 var imagesPadding = $self.find('#sbi_images').innerWidth() - $self.find('#sbi_images').width(), 656 imagepadding = imagesPadding / 2; 657 sbi_photo_width_manual = ($self.find('#sbi_images').width() / sbi_num_cols) - imagesPadding; 658 //If the width is less than it should be then set it manually 659 //if( sbi_photo_width <= (sbi_photo_width_manual) ) sbi_photo_width = sbi_photo_width_manual; 660 661 // Get the selected aspect ratio from settings 662 var aspectRatio = '1:1'; // Default to square 663 if (typeof this.settings.imageaspectratio !== 'undefined') { 664 aspectRatio = this.settings.imageaspectratio; 665 } 666 667 // Calculate height based on aspect ratio 668 var height; 669 if (aspectRatio === '4:5') { 670 height = sbi_photo_width * 1.25; // 4:5 ratio (1.25) 671 } else if (aspectRatio === '3:4') { 672 height = sbi_photo_width * 1.33; // 3:4 ratio (1.33) 673 } else { 674 height = sbi_photo_width; // 1:1 ratio (square) 675 } 676 677 $self.find('.sbi_photo').css('height', height); 678 679 //Set the position of the carousel arrows 680 if ($self.find('.sbi-owl-nav').length) { 681 setTimeout(function () { 682 //If there's 2 rows then adjust position 683 var sbi_ratio = 2; 684 if ($self.find('.sbi_owl2row-item').length) sbi_ratio = 1; 685 686 var sbi_arrows_top = ($self.find('.sbi_photo').eq(0).innerWidth() / sbi_ratio); 687 sbi_arrows_top += parseInt(imagepadding) * (2 + (2 - sbi_ratio)); 688 $self.find('.sbi-owl-nav div').css('top', sbi_arrows_top); 689 }, 100); 690 } 691 692 }, 693 maybeRaiseSingleImageResolution: function ($item, index, forceChange) { 694 var feed = this, 695 imgSrcSet = feed.getImageUrls($item), 696 currentUrl = $item.find('.sbi_photo img').attr('src'), 697 currentRes = 150, 698 imagEl = $item.find('img').get(0), 699 aspectRatio = currentUrl === window.sbi.options.placeholder ? 1 : imagEl.naturalWi
699dth / imagEl.naturalHeight, 700 forceChange = typeof forceChange !== 'undefined' ? forceChange : false; 701 702 if ($item.hasClass('sbi_no_resraise') || $item.hasClass('sbi_had_error') || ($item.find('.sbi_link_area').length && $item.find('.sbi_link_area').hasClass('sbi_had_error'))) { 703 return; 704 } 705 706 if (imgSrcSet.length < 1) { 707 if ($item.find('.sbi_link_area').length) { 708 $item.find('.sbi_link_area').attr('href', window.sbi.options.placeholder.replace('placeholder.png', 'thumb-placeholder.png')) 709 } 710 return; 711 } else if ($item.find('.sbi_link_area').length && $item.find('.sbi_link_area').attr('href') === window.sbi.options.placeholder.replace('placeholder.png', 'thumb-placeholder.png') 712 || !feed.settings.consentGiven) { 713 $item.find('.sbi_link_area').attr('href', imgSrcSet[imgSrcSet.length - 1]) 714 } 715 if (typeof imgSrcSet[640] !== 'undefined') { 716 $item.find('.sbi_photo').attr('data-full-res', imgSrcSet[640]); 717 } 718 719 $.each(imgSrcSet, function (index, value) { 720 if (value === currentUrl) { 721 currentRes = parseInt(index); 722 // If the image has already been changed to an existing real source, don't force the change 723 forceChange = false; 724 } 725 }); 726 //Image res 727 var newRes = 640; 728 switch (feed.settings.imgRes) { 729 case 'thumb': 730 newRes = 150; 731 break; 732 case 'medium': 733 newRes = 320; 734 break; 735 case 'full': 736 newRes = 640; 737 break; 738 default: 739 var minImageWidth = Math.max(feed.settings.autoMinRes, $item.find('.sbi_photo').innerWidth()), 740 thisImageReplace = feed.getBestResolutionForAuto(minImageWidth, aspectRatio, $item); 741 switch (thisImageReplace) { 742 case 320: 743 newRes = 320; 744 break; 745 case 150: 746 newRes = 150; 747 break; 748 } 749 break; 750 } 751 752 if (newRes > currentRes || currentUrl === window.sbi.options.placeholder || forceChange) { 753 if (feed.settings.debugEnabled) { 754 var reason = currentUrl === window.sbi.options.placeholder ? 'was placeholder' : 'too small'; 755 console.log('rais res for ' + currentUrl, reason); 756 } 757 var newUrl = imgSrcSet[newRes].split("?ig_cache_key")[0]; 758 if (currentUrl !== newUrl) { 759 $item.find('.sbi_photo img').attr('src', newUrl); 760 } 761 currentRes = newRes; 762 763 if (feed.settings.imgRes === 'auto') { 764 var checked = false; 765 $item.find('.sbi_photo img').on('load', function () { 766 767 var $this_image = $(this); 768 var newAspectRatio = ($this_image.get(0).naturalWidth / $this_image.get(0).naturalHeight); 769 770 if ($this_image.get(0).naturalWidth !== 1000 && newAspectRatio > aspectRatio && !checked) { 771 if (feed.settings.debugEnabled) { 772 console.log('rais res again for aspect ratio change ' + currentUrl); 773 } 774 checked = true; 775 minImageWidth = $item.find('.sbi_photo').innerWidth(); 776 thisImageReplace = feed.getBestResolutionForAuto(minImageWidth, newAspectRatio, $item); 777 newRes = 640; 778 779 switch (thisImageReplace) { 780 case 320: 781 newRes = 320; 782 break; 783 case 150: 784 newRes = 150; 785 break; 786 } 787 788 if (newRes > currentRes) { 789 newUrl = imgSrcSet[newRes].split("?ig_cache_key")[0]; 790 $this_image.attr('src', newUrl); 791 } 792 if (feed.layout === 'masonry' || feed.layout === 'highlight') { 793 $(feed.el).find('#sbi_images').smashotope(feed.isotopeArgs); 794 setTimeout(function () { 795 $(feed.el).find('#sbi_images').smashotope(feed.isotopeArgs); 796 }, 500) 797 } 798 } else { 799 if (feed.settings.debugEnabled) { 800 var reason = checked ? 'already checked' : 'no aspect ratio change'; 801 console.log('not raising res for replacement ' + currentUrl, reason); 802 } 803 } 804 }); 805 } 806 807 808 } 809 810 $item.find('img').on('error', function () { 811 if (!$(this).hasClass('sbi_img_error')) { 812 $(this).addClass('sbi_img_error'); 813 var sourceFromAPI = ($(this).attr('src').indexOf('media/?size=') > -1 || $(this).attr('src').indexOf('cdninstagram') > -1 || $(this).attr('src').indexOf('fbcdn') > -1) 814 815 if (!sourceFromAPI && feed.settings.consentGiven) { 816 817 if ($(this).closest('.sbi_photo').attr('data-img-src-set') !== 'undefined') { 818 var srcSet = JSON.parse($(this).closest('.sbi_photo').attr('data-img-src-set').replace(/\\\//g, '/')); 819 if (typeof srcSet.d !== 'undefined') { 820 $(this).attr('src', srcSet.d); 821 $(this).closest('.sbi_item').addClass('sbi_had_error').find('.sbi_link_area').attr('href', srcSet[640]).addClass('sbi_had_error'); 822 } 823 } 824 } else { 825 feed.settings.favorLocal = true; 826 var srcSet = feed.getImageUrls($(this).closest('.sbi_item')); 827 if (typeof srcSet[640] !== 'undefined') { 828 $(this).attr('src', srcSet[640]); 829 $(this).closest('.sbi_item').addClass('sbi_had_error').find('.sbi_link_area').attr('href', srcSet[640]).addClass('sbi_had_error'); 830 } 831 } 832 setTimeout(function () { 833 feed.afterResize(); 834 }, 1500) 835 } else { 836 console.log('unfixed error ' + $(this).attr('src')); 837 } 838 }); 839 }, 840 maybeRaiseImageResolution: function (justNew) { 841 var feed = this, 842 itemsSelector = typeof justNew !== 'undefined' && justNew === true ? '.sbi_item.sbi_new' : '.sbi_item', 843 forceChange = !feed.isInitialized ? true : false;
844 $(feed.el).find(itemsSelector).each(function (index) { 845 if (!$(this).hasClass('sbi_num_diff_hide') 846 && $(this).find('.sbi_photo').length 847 && typeof $(this).find('.sbi_photo').attr('data-img-src-set') !== 'undefined') { 848 feed.maybeRaiseSingleImageResolution($(this), index, forceChange); 849 } 850 }); //End .sbi_item each 851 feed.isInitialized = true; 852 }, 853 getBestResolutionForAuto: function (colWidth, aspectRatio, $item) { 854 if (isNaN(aspectRatio) || aspectRatio < 1) { 855 aspectRatio = 1; 856 } 857 var bestWidth = colWidth * aspectRatio, 858 bestWidthRounded = Math.ceil(bestWidth / 10) * 10, 859 customSizes = [150, 320, 640]; 860 861 if ($item.hasClass('sbi_highlighted')) { 862 bestWidthRounded = bestWidthRounded * 2; 863 } 864 865 if (customSizes.indexOf(parseInt(bestWidthRounded)) === -1) { 866 var done = false; 867 $.each(customSizes, function (index, item) { 868 if (item > parseInt(bestWidthRounded) && !done) { 869 bestWidthRounded = item; 870 871 done = true; 872 } 873 }); 874 } 875 876 return bestWidthRounded; 877 }, 878 hideExtraImagesForWidth: function () { 879 if (this.layout === 'carousel') { 880 return; 881 } 882 var $self = $(this.el), 883 num = typeof $self.attr('data-num') !== 'undefined' && $self.attr('data-num') !== '' ? parseInt($self.attr('data-num')) : 1, 884 nummobile = typeof $self.attr('data-nummobile') !== 'undefined' && $self.attr('data-nummobile') !== '' ? parseInt($self.attr('data-nummobile')) : num; 885 886 if ($(window).width() < 480 || window.sbi_preview_device === 'mobile') { 887 if (nummobile < $self.find('.sbi_item').length) { 888 $self.find('.sbi_item').slice(nummobile - $self.find('.sbi_item').length).addClass('sbi_num_diff_hide'); 889 } 890 } else { 891 if (num < $self.find('.sbi_item').length) { 892 $self.find('.sbi_item').slice(num - $self.find('.sbi_item').length).addClass('sbi_num_diff_hide'); 893 } 894 } 895 }, 896 setImageSizeClass: function () { 897 var $self = $(this.el); 898 $self.removeClass('sbi_small sbi_medium'); 899 var feedWidth = $self.innerWidth(), 900 photoPadding = parseInt(($self.find('#sbi_images').outerWidth() - $self.find('#sbi_images').width())) / 2, 901 cols = this.getColumnCount(), 902 feedWidthSansPadding = feedWidth - (photoPadding * (cols + 2)), 903 colWidth = (feedWidthSansPadding / cols); 904 if (colWidth > 120 && colWidth < 240) { 905 $self.addClass('sbi_medium'); 906 } else if (colWidth <= 120) { 907 $self.addClass('sbi_small'); 908 } 909 }, 910 setMinImageWidth: function () { 911 if ($(this.el).find('.sbi_item .sbi_photo').first().length) { 912 this.minImageWidth = $(this.el).find('.sbi_item .sbi_photo').first().innerWidth(); 913 } else { 914 this.minImageWidth = 150; 915 } 916 }, 917 setImageResolution: function () { 918 if (this.settings.imgRes === 'auto') { 919 this.imageResolution = 'auto'; 920 } else { 921 switch (this.settings.imgRes) { 922 case 'thumb': 923 this.imageResolution = 150; 924 break; 925 case 'medium': 926 this.imageResolution = 320; 927 break; 928 default: 929 this.imageResolution = 640; 930 } 931 } 932 }, 933 getImageUrls: function ($item) { 934 var srcSet = JSON.parse($item.find('.sbi_photo').attr('data-img-src-set').replace(/\\\//g, '/')), 935 id = $item.attr('id').replace('sbi_', ''); 936 if (!this.settings.consentGiven && !this.settings.overrideBlockCDN) { 937 srcSet = []; 938 } 939 if (typeof this.resizedImages[id] !== 'undefined' 940 && this.resizedImages[id] !== 'video' 941 && this.resizedImages[id] !== 'pending' 942 && this.resizedImages[id].id !== 'error' 943 && this.resizedImages[id].id !== 'video' 944 && this.resizedImages[id].id !== 'pending') { 945 946 if (typeof this.resizedImages[id]['sizes'] !== 'undefined') { 947 var foundSizes = []; 948 var extension = (typeof this.resizedImages[id]['extension'] !== 'undefined') ? this.resizedImages[id]['extension'] : '.jpg'; 949 if (typeof this.resizedImages[id]['sizes']['full'] !== 'undefined') { 950 srcSet[640] = sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'full' + extension; 951 foundSizes.push(640); 952 } 953 if (typeof this.resizedImages[id]['sizes']['low'] !== 'undefined') { 954 srcSet[320] = sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'low' + extension; 955 foundSizes.push(320); 956 } 957 if (typeof this.resizedImages[id]['sizes']['thumb'] !== 'undefined') { 958 foundSizes.push(150); 959 srcSet[150] = sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'thumb' + extension; 960 } 961 if (this.settings.favorLocal) { 962 if (foundSizes.indexOf(640) === -1) { 963 if (foundSizes.indexOf(320) > -1) { 964 srcSet[640] = sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'low' + extension; 965 } 966 } 967 if (foundSizes.indexOf(320) === -1) { 968 if (foundSizes.indexOf(640) > -1) { 969 srcSet[320] = sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'full' + extension; 970 } else if (foundSizes.indexOf(150) > -1) { 971 srcSet[320] = sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'thumb' + extension; 972 } 973 } 974 if (foundSizes.indexOf(150) === -1) { 975 if (foundSizes.indexOf(320) > -1) { 976 srcSet[150] = sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'low' + extension; 977 } else if (foundSizes.indexOf(640) > -1) { 978 srcSet[150] = sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'full' + extension; 979 } 980 } 981 } 982 } 983 } else if (typeof this.resizedImages[id] === 'undefined' 984 || (typeof this.resizedImages[id]['id'] !== 'undefined' && this.resizedImages[id]['id'] !== 'pending' && this.resizedImages[id]['id'] !== 'error')) { 985 this.addToNeedsResizing(id); 986 } 987 988 return srcSet; 989 }, 990 getAvatarUrl: function (username, favorType) { 991 if (username === '') { 992 return ''; 993 } 994 995 var availableAvatars = this.settings.general.avatars, 996 favorType = typeof favorType !== 'undefined' ? favorType : 'local'; 997 998 if (favorType === 'local') { 999 if (typeof availableAvatars['LCL' + username] !== 'undefined' && parseInt(availableAvatars['LCL' + username]) === 1) { 1000 return sb_instagram_js_options.resized_url + username + '.jpg'; 1001 } else if (typeof availableAvatars[username] !== 'undefined') { 1002 return availableAvatars[username]; 1003 } else { 1004 return ''; 1005 } 1006 } else { 1007 if (typeof availableAvatars[username] !== 'undefined') { 1008 return availableAvatars[username]; 1009 } else if (typeof availableAvatars['LCL' + username] !== 'undefined' && parseInt(availableAvatars['LCL' + username]) === 1) { 1010 return sb_instagram_js_options.resized_url + username + '.jpg'; 1011 } else { 1012 return ''; 1013 } 1014 } 1015 }, 1016 addToNeedsResizing: function (id) { 1017 if (this.needsResizing.indexOf(id) === -1) { 1018 this.needsResizing.push(id); 1019 } 1020 }, 1021 listenForVisibilityChange: function () { 1022 var feed = this; 1023 sbiAddVisibilityListener(); 1024 if (typeof $(this.el).filter(':hidden').sbiVisibilityChanged == 'function') {
1025 //If the feed is initially hidden (in a tab for example) then check for when it becomes visible and set then set the height 1026 $(this.el).filter(':hidden').sbiVisibilityChanged({ 1027 callback: function (element, visible) { 1028 feed.afterResize(); 1029 }, 1030 runOnLoad: false 1031 }); 1032 } 1033 }, 1034 getColumnCount: function () { 1035 var $self = $(this.el), 1036 cols = this.settings.cols, 1037 colsmobile = this.settings.colsmobile, 1038 colstablet = this.settings.colstablet, 1039 returnCols = cols; 1040 1041 sbiWindowWidth = window.innerWidth; 1042 1043 if ($self.hasClass('sbi_mob_col_auto')) { 1044 if (sbiWindowWidth < 640 && (parseInt(cols) > 2 && parseInt(cols) < 7)) returnCols = 2; 1045 if (sbiWindowWidth < 640 && (parseInt(cols) > 6 && parseInt(cols) < 11)) returnCols = 4; 1046 if (sbiWindowWidth <= 480 && parseInt(cols) > 2) returnCols = 1; 1047 } else if (sbiWindowWidth > 480 && sbiWindowWidth <= 800) { 1048 returnCols = colstablet; 1049 } else if (sbiWindowWidth <= 480) { 1050 returnCols = colsmobile; 1051 } 1052 1053 return parseInt(returnCols); 1054 }, 1055 checkConsent: function () { 1056 if (this.settings.consentGiven || !this.settings.gdpr) { 1057 return true; 1058 } 1059 if (typeof window.WPConsent !== 'undefined') { 1060 if (window.WPConsent.hasConsent('marketing')) { 1061 try { 1062 this.settings.consentGiven = true; 1063 } catch (e) { 1064 // Fallback to window object if cookie parsing fails 1065 this.settings.consentGiven = false; 1066 } 1067 } else { 1068 // Fallback to window object if cookie not found 1069 this.settings.consentGiven = false; 1070 } 1071 } else if (typeof window.cookieyes !== "undefined") { // CookieYes | GDPR Cookie Consent by CookieYes 1072 if (typeof window.cookieyes._ckyConsentStore.get !== 'undefined') { 1073 this.settings.consentGiven = window.cookieyes._ckyConsentStore.get('functional') === 'yes'; 1074 } 1075 } else if (typeof CLI_Cookie !== "undefined") { // GDPR Cookie Consent by WebToffee 1076 if (CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME) !== null) { 1077 1078 // WebToffee no longer uses this cookie but being left here to maintain backwards compatibility 1079 if (CLI_Cookie.read('cookielawinfo-checkbox-non-necessary') !== null) { 1080 this.settings.consentGiven = CLI_Cookie.read('cookielawinfo-checkbox-non-necessary') === 'yes'; 1081 } 1082 1083 if (CLI_Cookie.read('cookielawinfo-checkbox-necessary') !== null) { 1084 this.settings.consentGiven = CLI_Cookie.read('cookielawinfo-checkbox-necessary') === 'yes'; 1085 } 1086 } 1087 1088 } else if (typeof window.cnArgs !== "undefined") { // Cookie Notice by dFactory 1089 var value = "; " + document.cookie, 1090 parts = value.split('; cookie_notice_accepted='); 1091 1092 if (parts.length === 2) { 1093 var val = parts.pop().split(';').shift(); 1094 1095 this.settings.consentGiven = (val === 'true'); 1096 } 1097 } else if (typeof window.cookieconsent !== 'undefined' || typeof window.cmplz_has_consent === 'function') { // Complianz by Really Simple Plugins 1098 // Check for Complianz v6+ using cmplz_has_consent function 1099 if (typeof window.cmplz_has_consent === 'function') { 1100 this.settings.consentGiven = cmplz_has_consent('marketing'); 1101 } else { 1102 this.settings.consentGiven = sbiCmplzGetCookie('cmplz_consent_status') === 'allow'; 1103 } 1104 } else if (typeof window.Cookiebot !== "undefined") { // Cookiebot by Cybot A/S 1105 this.settings.consentGiven = Cookiebot.consented; 1106 } else if (typeof window.BorlabsCookie !== 'undefined') { // Borlabs Cookie by Borlabs 1107 this.settings.consentGiven = typeof window.BorlabsCookie.Consents !== 'undefined' ? window.BorlabsCookie.Consents.hasConsent('instagram') : window.BorlabsCookie.checkCookieConsent('instagram'); 1108 } else if (sbiCmplzGetCookie('moove_gdpr_popup')) { // Moove GDPR Popup 1109 var moove_gdpr_popup = JSON.parse(decodeURIComponent(sbiCmplzGetCookie('moove_gdpr_popup'))); 1110 this.settings.consentGiven = typeof moove_gdpr_popup.thirdparty !== "undefined" && moove_gdpr_popup.thirdparty === "1"; 1111 } 1112 1113 var evt = jQuery.Event('sbicheckconsent'); 1114 evt.feed = this; 1115 jQuery(window).trigger(evt); 1116 1117 return this.settings.consentGiven; // GDPR not enabled 1118 }, 1119 afterConsentToggled: function () { 1120 if (this.checkConsent()) { 1121 var feed = this; 1122 feed.maybeRaiseImageResolution(); 1123 1124 setTimeout(function () { 1125 feed.afterResize(); 1126 }, 500); 1127 } 1128 }, 1129 locationGuess: function () { 1130 var $feed = $(this.el), 1131 location = 'content'; 1132 1133 if ($feed.closest('footer').length) { 1134 location = 'footer'; 1135 } else if ($feed.closest('.header').length 1136 || $feed.closest('header').length) { 1137 location = 'header'; 1138 } else if ($feed.closest('.sidebar').length 1139 || $feed.closest('aside').length) { 1140 location = 'sidebar'; 1141 } 1142 1143 return location; 1144 }, 1145 }; 1146 1147 window.sbi_init = function () { 1148 window.sbi = new Sbi(); 1149 window.sbi.createPage(window.sbi.createFeeds, { whenFeedsCreated: window.sbi.afterFeedsCreated }); 1150 }; 1151 1152 function sbiGetNewFeed(feed, index, feedOptions) { 1153 return new SbiFeed(feed, index, feedOptions); 1154 } 1155 1156 function sbiAjax(submitData, onSuccess, onError) { 1157 var ajaxArgs = { 1158 url: sbiajaxurl, 1159 type: 'post', 1160 data: submitData, 1161 success: onSuccess 1162 }; 1163 if (typeof onError === 'function') { 1164 ajaxArgs.error = onError; 1165 } 1166 $.ajax(ajaxArgs); 1167 } 1168 1169 function sbiCmplzGetCookie(cname) { 1170 var name = cname + "="; //Create the cookie name variable with cookie name concatenate with = sign 1171 var cArr = window.document.cookie.split(';'); //Create cookie array by split the cookie by ';' 1172 1173 //Loop through the cookies and return the cookie value if it find the cookie name 1174 for (var i = 0; i < cArr.length; i++) { 1175 var c = cArr[i].trim(); 1176 //If the name is the cookie string at position 0, we found the cookie and return the cookie value 1177 if (c.indexOf(name) == 0) 1178 return c.substring(name.length, c.length); 1179 } 1180 1181 return ""; 1182 } 1183 1184 })(jQuery); 1185 1186 jQuery(document).ready(function ($) { 1187 if (typeof window.sb_instagram_js_options === 'undefined') { 1188 window.sb_instagram_js_options = { 1189 font_method: "svg", 1190 resized_url: location.protocol + '//' + window.location.hostname + "/wp-content/uploads/sb-instagram-feed-images/", 1191 placeholder: location.protocol + '//' + window.location.hostname + "/wp-content/plugins/instagram-feed/img/placeholder.png" 1192 }; 1193 } 1194 if (typeof window.sb_instagram_js_options.resized_url !== 'undefined' && window.sb_instagram_js_options.resized_url.indexOf(location.protocol) === -1) { 1195 if (location.protocol === 'http:') { 1196 window.sb_instagram_js_options.resized_url = window.sb_instagram_js_options.resized_url.replace('https:', 'http:'); 1197 } else { 1198 window.sb_instagram_js_options.resized_url = window.sb_instagram_js_options.resized_url.replace('http:', 'https:'); 1199 } 1200 } 1201 sbi_init(); 1202 1203 // Cookie Notice by dFactory 1204 $('#cookie-notice a').on('click', function () { 1205 setTimeout(function () { 1206 $.each(window.sbi.feeds, function (index) { 1207 window.sbi.feeds[index].afterConsentToggled(); 1208 }); 1209 }, 1000); 1210 }); 1211 1212 // GDPR Cookie Consent by WebToffee 1213 $('#cookie-law-info-bar a').on('click', function () { 1214 setTimeout(function () { 1215 $.each(window.sbi.feeds, function (index) { 1216 window.sbi.feeds[index].afterConsentToggled(); 1217 }); 1218 }, 1000); 1219 }); 1220 1221 // GDPR Cookie Consent by WebToffee
1222 $('.cli-user-preference-checkbox, .cky-notice button').on('click', function () { 1223 setTimeout(function () { 1224 $.each(window.sbi.feeds, function (index) { 1225 window.sbi.feeds[index].checkConsent(); 1226 window.sbi.feeds[index].afterConsentToggled(); 1227 }); 1228 }, 1000); 1229 }); 1230 1231 // Cookiebot 1232 $(window).on('CookiebotOnAccept', function (event) { 1233 $.each(window.sbi.feeds, function (index) { 1234 window.sbi.feeds[index].settings.consentGiven = true; 1235 window.sbi.feeds[index].afterConsentToggled(); 1236 }); 1237 }); 1238 1239 // Complianz by Really Simple Plugins - Legacy events (v5 and earlier) 1240 $(document).on('cmplzAcceptAll', function (event) { 1241 $.each(window.sbi.feeds, function (index) { 1242 window.sbi.feeds[index].settings.consentGiven = true; 1243 window.sbi.feeds[index].afterConsentToggled(); 1244 }); 1245 }); 1246 1247 // Complianz by Really Simple Plugins - Legacy events (v5 and earlier) 1248 $(document).on('cmplzRevoke', function (event) { 1249 $.each(window.sbi.feeds, function (index) { 1250 window.sbi.feeds[index].settings.consentGiven = false; 1251 window.sbi.feeds[index].afterConsentToggled(); 1252 }); 1253 }); 1254 1255 // Complianz by Really Simple Plugins - v6+ using native event listener 1256 document.addEventListener('cmplz_status_change', function (event) { 1257 if (typeof window.cmplz_has_consent === 'function') { 1258 $.each(window.sbi.feeds, function (index) { 1259 var hasMarketingConsent = cmplz_has_consent('marketing'); 1260 window.sbi.feeds[index].settings.consentGiven = hasMarketingConsent; 1261 window.sbi.feeds[index].afterConsentToggled(); 1262 }); 1263 } 1264 }); 1265 1266 // Borlabs Cookie by Borlabs 1267 $(document).on('borlabs-cookie-consent-saved', function (event) { 1268 $.each(window.sbi.feeds, function (index) { 1269 window.sbi.feeds[index].settings.consentGiven = false; 1270 window.sbi.feeds[index].afterConsentToggled(); 1271 }); 1272 }); 1273 1274 // Real Cookie Banner by Devowl.io 1275 if (typeof window.consentApi !== 'undefined') { 1276 window.consentApi?.consent("smash-balloon-social-photo-feed").then(() => { 1277 try { 1278 // applies full features to feed 1279 $.each(window.sbi.feeds, function (index) { 1280 window.sbi.feeds[index].settings.consentGiven = true; 1281 window.sbi.feeds[index].afterConsentToggled(); 1282 }); 1283 } 1284 catch (error) { 1285 // do nothing 1286 } 1287 }); 1288 } 1289 1290 // Moove 1291 $('.moove-gdpr-infobar-allow-all').on('click', function () { 1292 setTimeout(function () { 1293 $.each(window.sbi.feeds, function (index) { 1294 window.sbi.feeds[index].afterConsentToggled(); 1295 }); 1296 }, 1000); 1297 }); 1298 }); 1299 1300 // WPConsent 1301 window.addEventListener('wpconsent_consent_saved', function (event) { 1302 $.each(window.sbi.feeds, function (index) { 1303 window.sbi.feeds[index].afterConsentToggled(); 1304 }); 1305 }); 1306 1307 window.addEventListener('wpconsent_consent_updated', function (event) { 1308 $.each(window.sbi.feeds, function (index) { 1309 window.sbi.feeds[index].afterConsentToggled(); 1310 }); 1311 }); 1312 1313 1314} // if sbi_js_exists
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.