1var sbi_js_exists = (typeof sbi_js_exists !== 'undefined') ? true : false; 2if(!sbi_js_exists) { 3 (function($){ 4 5 function sbiAddImgLiquid() { 6 /*! imgLiquid v0.9.944 / 03-05-2013 https://github.com/karacas/imgLiquid */ 7 var sbi_imgLiquid = sbi_imgLiquid || {VER: "0.9.944"}; 8 sbi_imgLiquid.bgs_Available = !1, sbi_imgLiquid.bgs_CheckRunned = !1, function (i) { 9 function t() { 10 if (!sbi_imgLiquid.bgs_CheckRunned) { 11 sbi_imgLiquid.bgs_CheckRunned = !0; 12 var t = i('<span style="background-size:cover" />'); 13 i("body").append(t), !function () { 14 var i = t[0]; 15 if (i && window.getComputedStyle) { 16 var e = window.getComputedStyle(i, null); 17 e && e.backgroundSize && (sbi_imgLiquid.bgs_Available = "cover" === e.backgroundSize) 18 } 19 }(), t.remove() 20 } 21 } 22 23 i.fn.extend({ 24 sbi_imgLiquid: function (e) { 25 this.defaults = { 26 fill: !0, 27 verticalAlign: "center", 28 horizontalAlign: "center", 29 useBackgroundSize: !0, 30 useDataHtmlAttr: !0, 31 responsive: !0, 32 delay: 0, 33 fadeInTime: 0, 34 removeBoxBackground: !0, 35 hardPixels: !0, 36 responsiveCheckTime: 500, 37 timecheckvisibility: 500, 38 onStart: null, 39 onFinish: null, 40 onItemStart: null, 41 onItemFinish: null, 42 onItemError: null 43 }, t(); 44 var a = this; 45 return this.options = e, this.settings = i.extend({}, this.defaults, this.options), this.settings.onStart && this.settings.onStart(), this.each(function (t) { 46 function e() { 47 -1 === u.css("background-image").indexOf(encodeURI(c.attr("src"))) && u.css({"background-image": 'url("' + encodeURI(c.attr("src")) + '")'}), u.css({ 48 "background-size": g.fill ? "cover" : "contain", 49 "background-position": (g.horizontalAlign + " " + g.verticalAlign).toLowerCase(), 50 "background-repeat": "no-repeat" 51 }), i("a:first", u).css({ 52 display: "block", 53 width: "100%", 54 height: "100%" 55 }), i("img", u).css({display: "none"}), g.onItemFinish && g.onItemFinish(t, u, c), u.addClass("sbi_imgLiquid_bgSize"), u.addClass("sbi_imgLiquid_ready"), l() 56 } 57 58 function o() { 59 function e() { 60 c.data("sbi_imgLiquid_error") || c.data("sbi_imgLiquid_loaded") || c.data("sbi_imgLiquid_oldProcessed") || (u.is(":visible") && c[0].complete && c[0].width > 0 && c[0].height > 0 ? (c.data("sbi_imgLiquid_loaded", !0), setTimeout(r, t * g.delay)) : setTimeout(e, g.timecheckvisibility)) 61 } 62 63 if (c.data("oldSrc") && c.data("oldSrc") !== c.attr("src")) { 64 var a = c.clone().removeAttr("style"); 65 return a.data("sbi_imgLiquid_settings", c.data("sbi_imgLiquid_settings")), c.parent().prepend(a), c.remove(), c = a, c[0].width = 0, void setTimeout(o, 10) 66 } 67 return c.data("sbi_imgLiquid_oldProcessed") ? void r() : (c.data("sbi_imgLiquid_oldProcessed", !1), c.data("oldSrc", c.attr("src")), i("img:not(:first)", u).css("display", "none"), u.css({overflow: "hidden"}), c.fadeTo(0, 0).removeAttr("width").removeAttr("height").css({ 68 visibility: "visible", 69 "max-width": "none", 70 "max-height": "none", 71 width: "auto", 72 height: "auto", 73 display: "block" 74 }), c.on("error", n), c[0].onerror = n, e(), void d()) 75 } 76 77 function d() { 78 (g.responsive || c.data("sbi_imgLiquid_oldProcessed")) && c.data("sbi_imgLiquid_settings") && (g = c.data("sbi_imgLiquid_settings"), u.actualSize = u.get(0).offsetWidth + u.get(0).offsetHeight / 1e4, u.sizeOld && u.actualSize !== u.sizeOld && r(), u.sizeOld = u.actualSize, setTimeout(d, g.responsiveCheckTime)) 79 } 80 81 function n() { 82 c.data("sbi_imgLiquid_error", !0), u.addClass("sbi_imgLiquid_error"), g.onItemError && g.onItemError(t, u, c), l() 83 } 84 85 function s() { 86 var i = {}; 87 if (a.settings.useDataHtmlAttr) { 88 var t = u.attr("data-sbi_imgLiquid-fill"), 89 e = u.attr("data-sbi_imgLiquid-horizontalAlign"), 90 o = u.attr("data-sbi_imgLiquid-verticalAlign"); 91 ("true" === t || "false" === t) && (i.fill = Boolean("true" === t)), void 0 === e || "left" !== e && "center" !== e && "right" !== e && -1 === e.indexOf("%") || (i.horizontalAlign = e), void 0 === o || "top" !== o && "bottom" !== o && "center" !== o && -1 === o.indexOf("%") || (i.verticalAlign = o) 92 } 93 return sbi_imgLiquid.isIE && a.settings.ieFadeInDisabled && (i.fadeInTime = 0), i 94 } 95 96 function r() { 97 var i, e, a, o, d, n, s, r, m = 0, h = 0, f = u.width(), v = u.height(); 98 void 0 === c.data("owidth") && c.data("owidth", c[0].width), void 0 === c.data("oheight") && c.data("oheight", c[0].height), g.fill === f / v >= c.data("owidth") / c.data("oheight") ? (i = "100%", e = "auto", a = Math.floor(f), o = Math.floor(f * (c.data("oheight") / c.data("owidth")))) : (i = "auto", e = "100%", a = Math.floor(v * (c.data("owidth") / c.data("oheight"))), o = Math.floor(v)), d = g.horizontalAlign.toLowerCase(), s = f - a, "left" === d && (h = 0), "center" === d && (h = .5 * s), "right" === d && (h = s), -1 !== d.indexOf("%") && (d = parseInt(d.replace("%", ""), 10), d > 0 && (h = s * d * .01)), n = g.verticalAlign.toLowerCase(), r = v - o, "left" === n && (m = 0), "center" === n && (m = .5 * r), "bottom" === n && (m = r), -1 !== n.indexOf("%") && (n = parseInt(n.replace("%", ""), 10), n > 0 && (m = r * n * .01)), g.hardPixels && (i = a, e = o), c.css({ 99 width: i, 100 height: e, 101 "margin-left": Math.floor(h), 102 "margin-top": Math.floor(m) 103 }), c.data("sbi_imgLiquid_oldProcessed") || (c.fadeTo(g.fadeInTime, 1), c.data("sbi_imgLiquid_oldProcessed", !0), g.removeBoxBackgroun
103d && u.css("background-image", "none"), u.addClass("sbi_imgLiquid_nobgSize"), u.addClass("sbi_imgLiquid_ready")), g.onItemFinish && g.onItemFinish(t, u, c), l() 104 } 105 106 function l() { 107 t === a.length - 1 && a.settings.onFinish && a.settings.onFinish() 108 } 109 110 var g = a.settings, u = i(this), c = i("img:first", u); 111 return c.length ? (c.data("sbi_imgLiquid_settings") ? (u.removeClass("sbi_imgLiquid_error").removeClass("sbi_imgLiquid_ready"), g = i.extend({}, c.data("sbi_imgLiquid_settings"), a.options)) : g = i.extend({}, a.settings, s()), c.data("sbi_imgLiquid_settings", g), g.onItemStart && g.onItemStart(t, u, c), void (sbi_imgLiquid.bgs_Available && g.useBackgroundSize ? e() : o())) : void n() 112 }) 113 } 114 }) 115 }(jQuery); 116 117 // Use imagefill to set the images as backgrounds so they can be square 118 !function () { 119 var css = sbi_imgLiquid.injectCss, 120 head = document.getElementsByTagName('head')[0], 121 style = document.createElement('style'); 122 style.type = 'text/css'; 123 if (style.styleSheet) { 124 style.styleSheet.cssText = css; 125 } else { 126 style.appendChild(document.createTextNode(css)); 127 } 128 head.appendChild(style); 129 }(); 130 } 131 132 function sbiAddVisibilityListener() { 133 /* Detect when element becomes visible. Used for when the feed is initially hidden, in a tab for example. https://github.com/shaunbowe/jquery.visibilityChanged */ 134 !function (i) { 135 var n = { 136 callback: function () { 137 }, runOnLoad: !0, frequency: 100, sbiPreviousVisibility: null 138 }, c = {}; 139 c.sbiCheckVisibility = function (i, n) { 140 if (jQuery.contains(document, i[0])) { 141 var e = n.sbiPreviousVisibility, t = i.is(":visible"); 142 n.sbiPreviousVisibility = t, null == e ? n.runOnLoad && n.callback(i, t) : e !== t && n.callback(i, t), setTimeout(function () { 143 c.sbiCheckVisibility(i, n) 144 }, n.frequency) 145 } 146 }, i.fn.sbiVisibilityChanged = function (e) { 147 var t = i.extend({}, n, e); 148 return this.each(function () { 149 c.sbiCheckVisibility(i(this), t) 150 }) 151 } 152 }(jQuery); 153 } 154 155 function Sbi() { 156 this.feeds = {}; 157 this.options = sb_instagram_js_options; 158 } 159 160 Sbi.prototype = { 161 createPage: function (createFeeds, createFeedsArgs) { 162 if (typeof window.sbiajaxurl === 'undefined' || window.sbiajaxurl.indexOf(window.location.hostname) === -1) { 163 window.sbiajaxurl = window.location.hostname + '/wp-admin/admin-ajax.php'; 164 } 165 166 $('.sbi_no_js_error_message').remove(); 167 $('.sbi_no_js').removeClass('sbi_no_js'); 168 createFeeds(createFeedsArgs); 169 }, 170 createFeeds: function (args) { 171 args.whenFeedsCreated( 172 $('.sbi').each(function (index) { 173 $(this).attr('data-sbi-index', index + 1); 174 var $self = $(this), 175 flags = typeof $self.attr('data-sbi-flags') !== 'undefined' ? $self.attr('data-sbi-flags').split(',') : [], 176 general = typeof $self.attr('data-options') !== 'undefined' ? JSON.parse($self.attr('data-options')) : {}; 177 if (flags.indexOf('testAjax') > -1) { 178 window.sbi.triggeredTest = true; 179 var submitData = { 180 'action' : 'sbi_on_ajax_test_trigger' 181 }, 182 onSuccess = function(data) { 183 console.log('did test'); 184 }; 185 sbiAjax(submitData,onSuccess) 186 } 187 var feedOptions = { 188 cols : $self.attr('data-cols'), 189 colsmobile : $self.attr('data-colsmobile') !== 'same' ? $self.attr('data-colsmobile') : $self.attr('data-cols'), 190 num : $self.attr('data-num'), 191 imgRes : $self.attr('data-res'), 192 feedID : $self.attr('data-feedid'), 193 shortCodeAtts : $self.attr('data-shortcode-atts'), 194 resizingEnabled : (flags.indexOf('resizeDisable') === -1), 195 imageLoadEnabled : (flags.indexOf('imageLoadDisable') === -1), 196 debugEnabled : (flags.indexOf('debug') > -1), 197 favorLocal : (flags.indexOf('favorLocal') > -1), 198 ajaxPostLoad : (flags.indexOf('ajaxPostLoad') > -1), 199 autoMinRes : 1, 200 general : general 201 }; 202 203 window.sbi.feeds[index] = sbiGetNewFeed(this, index, feedOptions); 204 window.sbi.feeds[index].setResizedImages(); 205 window.sbi.feeds[index].init(); 206 207 var evt = jQuery.Event('sbiafterfeedcreate'); 208 evt.feed = window.sbi.feeds[index]; 209 jQuery(window).trigger(evt); 210 211 }) 212 ); 213 }, 214 afterFeedsCreated: function () { 215 // enable header hover action 216 $('.sb_instagram_header').each(function () { 217 var $thisHeader = $(this); 218 $thisHeader.find('.sbi_header_link').hover(function () { 219 $thisHeader.find('.sbi_header_img_hover').addClass('sbi_fade_in'); 220 }, function () { 221 $thisHeader.find('.sbi_header_img_hover').removeClass('sbi_fade_in'); 222 }); 223 }); 224 225 }, 226 encodeHTML: function(raw) { 227 // make sure passed variable is defined 228 if (typeof raw === 'undefined') { 229 return ''; 230 } 231 // replace greater than and less than symbols with html entity to disallow html in comments 232 var encoded = raw.replace(/(>)/g,'>'), 233 encoded = encoded.replace(/(<)/g,'<'); 234 encoded = encoded.replace(/(<br\/>)/g,'<br>'); 235 encoded = encoded.replace(/(<br>)/g,'<br>'); 236 237 return encoded; 238 }, 239 urlDetect: function(text) { 240 var urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g; 241 return text.match(urlRegex); 242 } 243 }; 244 245 function SbiFeed(el, index, settings) { 246 this.el = el; 247 this.index = index; 248 this.settings = settings; 249 this.minImageWidth = 0; 250 this.imageResolution = 150; 251 this.resizedImages = {}; 252 this.needsResizing = []; 253 this.outOfPages = false; 254 this.isInitialized = false; 255 } 256 257 SbiFeed.prototype = { 258 init: function() { 259 var feed = this; 260 if (this.settings.ajaxPostLoad) { 261 this.getNewPostSet(); 262 } else { 263 this.afterInitialImagesLoaded(); 264 //Only check the width once the resize event is over 265 } 266 var sbi_delay = (function () { 267 var sbi_timer = 0; 268 return function (sbi_callback, sbi_ms) { 269 clearTimeout(sbi_timer); 270 sbi_timer = setTimeout(sbi_callback, sbi_ms); 271 }; 272 })(); 273 jQuery(window).resize(function () { 274 sbi_delay(function () { 275 feed.afterResize(); 276 }, 500); 277 }); 278 279 }, 280 initLayout: function() { 281 282 }, 283 afterInitialImagesLoaded: function() { 284 this.initLayout(); 285 this.loadMoreButtonInit(); 286 this.hideExtraImagesForWidth(); 287 this.beforeNewImagesRevealed(); 288 this.revealNewImages(); 289 this.afterNewImagesRevealed(); 290 }, 291 afterResize: function() { 292 this.setImageHeight(); 293 this.setImageResolution(); 294 this.maybeRaiseImageResolution(); 295 this.setImageSizeClass(); 296 }, 297 afterLoadMoreClicked: function($button) { 298 $button.find('.sbi_loader').removeClass('sbi_hidden'); 299 $button.find('.sbi_btn_text').addClass('sbi_hidden'); 300 $button.closest('.sbi').find('.sbi_num_diff_hide').addClass('sbi_transition').removeClass('sbi_num_diff_hide'); 301 }, 302 afterNewImagesLoaded: function() { 303 var $self = $(this.el), 304 feed = this; 305 this.beforeNewImagesRevealed(); 306 this.revealNewImages(); 307 this.afterNewImagesRevealed(); 308 setTimeout(function () { 309 //Hide the loader in the load more button 310 $self.find('.sbi_loader').addClass('sbi_hidden'); 311 $self.find('.sbi_btn_text').removeClass('sbi_hidden'); 312 }, 500); 313 }, 314 beforeNewImagesRevealed: function() { 315 this.setImageHeight(); 316 this.maybeRaiseImageResolution(true); 317 this.setImageSizeClass(); 318 }, 319 revealNewImages: function() { 320 var $self = $(this.el), 321 feed = this; 322 323 // Call Custom JS if it exists 324 if (typeof sbi_custom_js == 'function') setTimeout(function(){ sbi_custom_js(); }, 100); 325 326 this.applyImageLiquid(); 327 $self.find('.sbi_item').each(function (index) { 328 var $self = jQuery(this); 329 330 //Photo links 331 //If lightbox is disabled 332 $self.find('.sbi_photo').hover(function () { 333 jQuery(this).fadeTo(200, 0.85); 334 }, function () { 335 jQuery(this).stop().fadeTo(500, 1); 336 }); 337 338 }); //End .sbi_item each 339 340 //Remove the new class after 500ms, once the sorting is done 341 setTimeout(function () { 342 jQuery('#sbi_images .sbi_item.sbi_new').removeClass('sbi_new'); 343 //Loop through items and remove class to reveal them 344 var time = 10; 345 $self.find('.sbi_transition').each(function() { 346 var $sbi_item_transition_el = jQuery(this); 347 348 setTimeout( function(){ 349 $sbi_item_transition_el.removeClass('sbi_transition'); 350 }, time); 351 time += 10; 352 }); 353 }, 500); 354 }, 355 afterNewImagesRevealed: function() { 356 this.listenForVisibilityChange(); 357 this.sendNeedsResizingToServer(); 358 359 var evt = $.Event('sbiafterimagesloaded'); 360 evt.el = $(this.el); 361 $(window).trigger(evt); 362 }, 363 setResizedImages: function () { 364 if ($(this.el).find('.sbi_resized_image_data').length 365 && typeof $(this.el).find('.sbi_resized_image_data').attr('data-resized') !== 'undefined' 366 && $(this.el).find('.sbi_resized_image_data').attr('data-resized').indexOf('{"') === 0) { 367 this.resizedImages = JSON.parse($(this.el).find('.sbi_resized_image_data').attr('data-resized')); 368 $(this.el).find('.sbi_resized_image_data').remove(); 369 } 370 }, 371 sendNeedsResizingToServer: function() { 372 var feed = this; 373 if (feed.needsResizing.length > 0 && feed.settings.resizingEnabled) { 374 var itemOffset = $(this.el).find('.sbi_item').length; 375 376 var submitData = { 377 action: 'sbi_resized_images_submit', 378 needs_resizing: feed.needsResizing, 379 offset: itemOffset, 380 feed_id: feed.settings.feedID, 381 atts: feed.settings.shortCodeAtts, 382 }; 383 var onSuccess = function(data) { 384 if (data.trim().indexOf('{') === 0) { 385 var response = JSON.parse(data); 386 if (feed.settings.debugEnabled) { 387 console.log(response); 388 } 389 } 390 }; 391 sbiAjax(submitData,onSuccess); 392 } 393 },
394 loadMoreButtonInit: function () { 395 var $self = $(this.el), 396 feed = this; 397 $self.find('#sbi_load .sbi_load_btn').off().on('click', function () { 398 399 feed.afterLoadMoreClicked(jQuery(this)); 400 feed.getNewPostSet(); 401 402 }); //End click event 403 }, 404 getNewPostSet: function () { 405 var $self = $(this.el), 406 feed = this; 407 var itemOffset = $self.find('.sbi_item').length, 408 submitData = { 409 action: 'sbi_load_more_clicked', 410 offset: itemOffset, 411 feed_id: feed.settings.feedID, 412 atts: feed.settings.shortCodeAtts, 413 current_resolution: feed.imageResolution 414 }; 415 var onSuccess = function (data) { 416 if (data.trim().indexOf('{') === 0) { 417 var response = JSON.parse(data); 418 if (feed.settings.debugEnabled) { 419 console.log(response); 420 } 421 feed.appendNewPosts(response.html); 422 feed.addResizedImages(response.resizedImages); 423 if (feed.settings.ajaxPostLoad) { 424 feed.settings.ajaxPostLoad = false; 425 feed.afterInitialImagesLoaded(); 426 } else { 427 feed.afterNewImagesLoaded(); 428 } 429 430 if (!response.feedStatus.shouldPaginate) { 431 feed.outOfPages = true; 432 $self.find('.sbi_load_btn').hide(); 433 } else { 434 feed.outOfPages = false; 435 } 436 } 437 438 }; 439 sbiAjax(submitData, onSuccess); 440 }, 441 appendNewPosts: function (newPostsHtml) { 442 var $self = $(this.el), 443 feed = this; 444 if ($self.find('#sbi_images .sbi_item').length) { 445 $self.find('#sbi_images .sbi_item').last().after(newPostsHtml); 446 } else { 447 $self.find('#sbi_images').append(newPostsHtml); 448 } 449 }, 450 addResizedImages: function (resizedImagesToAdd) { 451 for (var imageID in resizedImagesToAdd) { 452 this.resizedImages[imageID] = resizedImagesToAdd[imageID]; 453 } 454 }, 455 setImageHeight: function() { 456 var $self = $(this.el); 457 458 var sbi_photo_width = $self.find('.sbi_photo').eq(0).innerWidth(); 459 460 //Figure out number of columns for either desktop or mobile 461 var sbi_num_cols = this.getColumnCount(); 462 463 //Figure out what the width should be using the number of cols 464 //Figure out what the width should be using the number of cols 465 var imagesPadding = $self.find('#sbi_images').innerWidth() - $self.find('#sbi_images').width(), 466 imagepadding = imagesPadding / 2; 467 sbi_photo_width_manual = ( $self.find('#sbi_images').width() / sbi_num_cols ) - imagesPadding; 468 //If the width is less than it should be then set it manually 469 //if( sbi_photo_width <= (sbi_photo_width_manual) ) sbi_photo_width = sbi_photo_width_manual; 470 471 $self.find('.sbi_photo').css('height', sbi_photo_width); 472 473 //Set the position of the carousel arrows 474 if ($self.find('.sbi-owl-nav').length) { 475 setTimeout(function(){ 476 //If there's 2 rows then adjust position 477 var sbi_ratio = 2; 478 if( $self.find('.sbi_owl2row-item').length ) sbi_ratio = 1; 479 480 var sbi_arrows_top = ($self.find('.sbi_photo').eq(0).innerWidth()/sbi_ratio); 481 sbi_arrows_top += parseInt(imagepadding)*(2+(2-sbi_ratio)); 482 $self.find('.sbi-owl-nav div').css('top', sbi_arrows_top); 483 }, 100); 484 } 485 486 }, 487 maybeRaiseSingleImageResolution: function ($item, index, forceChange) { 488 var feed = this, 489 imgSrcSet = feed.getImageUrls($item), 490 currentUrl = $item.find('.sbi_photo img').attr('src'), 491 currentRes = 150, 492 imagEl = $item.find('img').get(0), 493 aspectRatio = currentUrl === window.sbi.options.placeholder ? 1 : imagEl.naturalWi
493dth/imagEl.naturalHeight, 494 forceChange = typeof forceChange !== 'undefined' ? forceChange : false; 495 496 $.each(imgSrcSet, function (index, value) { 497 if (value === currentUrl) { 498 currentRes = parseInt(index); 499 // If the image has already been changed to an existing real source, don't force the change 500 forceChange = false; 501 } 502 }); 503 //Image res 504 var newRes = 640; 505 switch (feed.settings.imgRes) { 506 case 'thumb': 507 newRes = 150; 508 break; 509 case 'medium': 510 newRes = 320; 511 break; 512 case 'full': 513 newRes = 640; 514 break; 515 default: 516 var minImageWidth = Math.max(feed.settings.autoMinRes,$item.find('.sbi_photo').innerWidth()), 517 thisImageReplace = feed.getBestResolutionForAuto(minImageWidth, aspectRatio, $item); 518 switch (thisImageReplace) { 519 case 320: 520 newRes = 320; 521 break; 522 case 150: 523 newRes = 150; 524 break; 525 } 526 break; 527 } 528 529 if (newRes > currentRes || currentUrl === window.sbi.options.placeholder || forceChange) { 530 if (feed.settings.debugEnabled) { 531 var reason = currentUrl === window.sbi.options.placeholder ? 'was placeholder' : 'too small'; 532 console.log('rais res for ' + currentUrl, reason); 533 } 534 var newUrl = imgSrcSet[newRes].split("?ig_cache_key")[0]; 535 $item.find('.sbi_photo img').attr('src', newUrl); 536 $item.find('.sbi_photo').css('background-image', 'url("' + newUrl + '")'); 537 538 var checked = false; 539 $item.find('.sbi_photo img').on('load', function () { 540 541 var $this_image = $(this); 542 var newAspectRatio = ($this_image.get(0).naturalWidth / $this_image.get(0).naturalHeight); 543 544 if ($this_image.get(0).naturalWidth !== 1000 && newAspectRatio > aspectRatio && !checked) { 545 if (feed.settings.debugEnabled) { 546 console.log('rais res again for aspect ratio change ' + currentUrl); 547 } 548 checked = true; 549 minImageWidth = $item.find('.sbi_photo').innerWidth(); 550 thisImageReplace = feed.getBestResolutionForAuto(minImageWidth, newAspectRatio, $item); 551 newRes = 640; 552 553 switch (thisImageReplace) { 554 case 320: 555 newRes = 320; 556 break; 557 case 150: 558 newRes = 150; 559 break; 560 } 561 562 if (newRes > currentRes) { 563 newUrl = imgSrcSet[newRes].split("?ig_cache_key")[0]; 564 $this_image.attr('src', newUrl); 565 $this_image.closest('.sbi_photo').css('background-image', 'url("' + newUrl + '")'); 566 } 567 if (feed.layout === 'masonry' || feed.layout === 'highlight') { 568 $(feed.el).find('#sbi_images').smashotope(feed.isotopeArgs); 569 setTimeout(function() { 570 $(feed.el).find('#sbi_images').smashotope(feed.isotopeArgs); 571 },500) 572 } 573 } else { 574 if (feed.settings.debugEnabled) { 575 var reason = checked ? 'already checked' : 'no aspect ratio change'; 576 console.log('not raising res for replacement ' + currentUrl, reason); 577 } 578 } 579 }); 580 581 } 582 583 $item.find('img').on('error', function () { 584 if (!$(this).hasClass('sbi_img_error')) { 585 $(this).addClass('sbi_img_error'); 586 var sourceFromAPI = ($(this).attr('src').indexOf('media?size=') > -1 || $(this).attr('src').indexOf('cdninstagram') > -1 || $(this).attr('src').indexOf('fbcdn') > -1) 587 588 if (!sourceFromAPI) { 589 if (typeof $(this).closest('.sbi_photo').attr('data-full-res') !== 'undefined') { 590 $(this).attr('src', $(this).closest('.sbi_photo').attr('data-full-res')); 591 $(this).closest('.sbi_photo').css('background-image', 'url(' + $(this).closest('.sbi_photo').attr('data-full-res') + ')'); 592 } else if ($(this).closest('.sbi_photo').attr('href') !== 'undefined') { 593 $(this).attr('src', $(this).closest('.sbi_photo').attr('href') + 'media?size=l'); 594 $(this).closest('.sbi_photo').css('background-image', 'url(' + $(this).closest('.sbi_photo').attr('href') + 'media?size=l)'); 595 } 596 } else { 597 feed.settings.favorLocal = true; 598 var srcSet = feed.getImageUrls($(this).closest('.sbi_item')); 599 if (typeof srcSet[640] !== 'undefined') { 600 $(this).attr('src', srcSet[640]); 601 $(this).closest('.sbi_photo').css('background-image', 'url(' + srcSet[640] + ')'); 602 } 603 } 604 setTimeout(function() { 605 feed.afterResize(); 606 }, 1500) 607 } else { 608 console.log('unfixed error ' + $(this).attr('src')); 609 } 610 }); 611 }, 612 maybeRaiseImageResolution: function (justNew) { 613 var feed = this, 614 itemsSelector = typeof justNew !== 'undefined' && justNew === true ? '.sbi_item.sbi_new' : '.sbi_item', 615 forceChange = !feed.isInitialized ? true : false; 616 $(feed.el).find(itemsSelector).each(function (index) { 617 if (!$(this).hasClass('sbi_num_diff_hide') 618 && $(this).find('.sbi_photo').length 619 && typeof $(this).find('.sbi_photo').attr('data-img-src-set') !== 'undefined') { 620 feed.maybeRaiseSingleImageResolution($(this),index,forceChange); 621 } 622 }); //End .sbi_item each 623 feed.isInitialized = true; 624 }, 625 getBestResolutionForAuto: function(colWidth, aspectRatio, $item) { 626 if (isNaN(aspectRatio) || aspectRatio < 1) { 627 aspectRatio = 1; 628 } 629 var bestWidth = colWidth * aspectRatio, 630 bestWidthRounded = Math.ceil(bestWidth / 10) * 10, 631 customSizes = [150, 320, 640]; 632 633 if ($item.hasClass('sbi_highlighted')) { 634 bestWidthRounded = bestWidthRounded *2; 635 } 636 637 if (customSizes.indexOf(parseInt(bestWidthRounded)) === -1) { 638 var done = false; 639 $.each(customSizes, function (index, item) { 640 if (item > parseInt(bestWidthRounded) && !done) { 641 bestWidthRounded = item; 642 643 done = true; 644 } 645 }); 646 } 647 648 return bestWidthRounded; 649 }, 650 hideExtraImagesForWidth: function() { 651 if (this.layout === 'carousel') { 652 return; 653 } 654 var $self = $(this.el), 655 num = typeof $self.attr('data-num') !== 'undefined' && $self.attr('data-num') !== '' ? parseInt($self.attr('data-num')) : 1, 656 nummobile = typeof $self.attr('data-nummobile') !== 'undefined' && $self.attr('data-nummobile') !== '' ? parseInt($self.attr('data-nummobile')) : num; 657 658 if ($(window).width() < 480) { 659 if (nummobile < $self.find('.sbi_item').length) { 660 $self.find('.sbi_item').slice(nummobile - $self.find('.sbi_item').length).addClass('sbi_num_diff_hide'); 661 } 662 } else { 663 if (num < $self.find('.sbi_item').length) { 664 $self.find('.sbi_item').slice(num - $self.find('.sbi_item').length).addClass('sbi_num_diff_hide'); 665 } 666 } 667 }, 668 setImageSizeClass: function () { 669 var $self = $(this.el); 670 $self.removeClass('sbi_small sbi_medium'); 671 var feedWidth = $self.innerWidth(), 672 photoPadding = parseInt(($self.find('#sbi_images').outerWidth() - $self.find('#sbi_images').width())) / 2, 673 cols = this.getColumnCount(), 674 feedWidthSansPadding = feedWidth - (photoPadding * (cols+2)), 675 colWidth = (feedWidthSansPadding / cols); 676 if (colWidth > 120 && colWidth < 240) { 677 $self.addClass('sbi_medium'); 678 } else if (colWidth <= 120) { 679 $self.addClass('sbi_small'); 680 } 681 }, 682 setMinImageWidth: function () { 683 if ($(this.el).find('.sbi_item .sbi_photo').first().length) { 684 this.minImageWidth = $(this.el).find('.sbi_item .sbi_photo').first().innerWidth(); 685 } else { 686 this.minImageWidth = 150; 687 } 688 }, 689 setImageResolution: function () { 690 if (this.settings.imgRes === 'auto') { 691 this.imageResolution = 'auto'; 692 } else { 693 switch (this.settings.imgRes) { 694 case 'thumb': 695 this.imageResolution = 150; 696 break; 697 case 'medium': 698 this.imageResolution = 320; 699 break; 700 default: 701 this.imageResolution = 640; 702 } 703 } 704 }, 705 getImageUrls: function ($item) { 706 var srcSet = JSON.parse($item.find('.sbi_photo').attr('data-img-src-set').replace(/\\\//g, '/')), 707 id = $item.attr('id').replace('sbi_', ''); 708 if (typeof this.resizedImages[id] !== 'undefined' 709 && this.resizedImages[id] !== 'video' 710 && this.resizedImages[id] !== 'pending' 711 && this.resizedImages[id].id !== 'error' 712 && this.resizedImages[id].id !== 'video' 713 && this.resizedImages[id].id !== 'pending') { 714 if (typeof this.resizedImages[id]['sizes'] !== 'undefined') { 715 var foundSizes = []; 716 if (typeof this.resizedImages[id]['sizes']['full'] !== 'undefined') { 717 foundSizes.push(640); 718 srcSet[640] = sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'full.jpg'; 719 $item.find('.sbi_link_area').attr( 'href', sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'full.jpg' ); 720 $item.find('.sbi_photo').attr( 'data-full-res', sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'full.jpg' ); 721 } 722 if (typeof this.resizedImages[id]['sizes']['low'] !== 'undefined') { 723 foundSizes.push(320); 724 srcSet[320] = sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'low.jpg'; 725 if (this.settings.favorLocal && typeof this.resizedImages[id]['sizes']['full'] === 'undefined') { 726 $item.find('.sbi_link_area').attr( 'href', sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'low.jpg' ); 727 $item.find('.sbi_photo').attr( 'data-full-res', sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'low.jpg' ); 728 } 729 } 730 if (typeof this.resizedImages[id]['sizes']['thumb'] !== 'undefined') { 731 foundSizes.push(150); 732 srcSet[150] = sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'thumb.jpg'; 733 } 734 if (this.settings.favorLocal) { 735 if (foundSizes.indexOf(640) === -1) { 736 if (foundSizes.indexOf(320) > -1) { 737 srcSet[640] = sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'low.jpg'; 738 } 739 } 740 if (foundSizes.indexOf(320) === -1) { 741 if (foundSizes.indexOf(640) > -1) { 742 srcSet[320] = sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'full.jpg'; 743 } else if (foundSizes.indexOf(150) > -1) { 744 srcSet[320] = sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'thumb.jpg'; 745 } 746 } 747 if (foundSizes.indexOf(150) === -1) { 748 if (foundSizes.indexOf(320) > -1) { 749 srcSet[150] = sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'low.jpg'; 750 } else if (foundSizes.indexOf(640) > -1) { 751 srcSet[150] = sb_instagram_js_options.resized_url + this.resizedImages[id].id + 'full.jpg'; 752 } 753 } 754 } 755 } 756 } else if (typeof this.resizedImages[id] === 'undefined' 757 || this.resizedImages[id] !== 'pending') { 758 this.addToNeedsResizing(id); 759 } 760 761 return srcSet; 762 }, 763 getAvatarUrl: function (username,favorType) { 764 if (username === '') { 765 return ''; 766 } 767 768 var availableAvatars = this.settings.general.avatars, 769 favorType = typeof favorType !== 'undefined' ? favorType : 'local'; 770 771 if (favorType === 'local') { 772 if (typeof availableAvatars['LCL'+username] !== 'undefined' && parseInt(availableAvatars['LCL'+username]) === 1) { 773 return sb_instagram_js_options.resized_url + username + '.jpg'; 774 } else if (typeof availableAvatars[username] !== 'undefined') { 775 return availableAvatars[username]; 776 } else { 777 return ''; 778 } 779 } else { 780 if (typeof availableAvatars[username] !== 'undefined') { 781 retur
781n availableAvatars[username]; 782 } else if (typeof availableAvatars['LCL'+username] !== 'undefined' && parseInt(availableAvatars['LCL'+username]) === 1) { 783 return sb_instagram_js_options.resized_url + username + '.jpg'; 784 } else { 785 return ''; 786 } 787 } 788 }, 789 addToNeedsResizing: function (id) { 790 if (this.needsResizing.indexOf(id) === -1) { 791 this.needsResizing.push(id); 792 } 793 }, 794 applyImageLiquid: function () { 795 var $self = $(this.el), 796 feed = this; 797 sbiAddImgLiquid(); 798 if (typeof $self.find(".sbi_photo").sbi_imgLiquid == 'function') { 799 $self.find(".sbi_photo").sbi_imgLiquid({fill: true}); 800 } 801 }, 802 listenForVisibilityChange: function() { 803 var feed = this; 804 sbiAddVisibilityListener(); 805 if (typeof $(this.el).filter(':hidden').sbiVisibilityChanged == 'function') { 806 //If the feed is initially hidden (in a tab for example) then check for when it becomes visible and set then set the height 807 $(this.el).filter(':hidden').sbiVisibilityChanged({ 808 callback: function (element, visible) { 809 feed.afterResize(); 810 }, 811 runOnLoad: false 812 }); 813 } 814 }, 815 getColumnCount: function() { 816 var $self = $(this.el), 817 cols = this.settings.cols, 818 colsmobile = this.settings.colsmobile, 819 returnCols = cols; 820 821 sbiWindowWidth = window.innerWidth; 822 823 if ($self.hasClass('sbi_mob_col_auto')) { 824 if (sbiWindowWidth < 640 && (parseInt(cols) > 2 && parseInt(cols) < 7)) returnCols = 2; 825 if (sbiWindowWidth < 640 && (parseInt(cols) > 6 && parseInt(cols) < 11)) returnCols = 4; 826 if (sbiWindowWidth <= 480 && parseInt(cols) > 2) returnCols = 1; 827 } else if (sbiWindowWidth <= 480) { 828 returnCols = colsmobile; 829 } 830 831 return parseInt(returnCols); 832 } 833 }; 834 835 window.sbi_init = function() { 836 window.sbi = new Sbi(); 837 window.sbi.createPage( window.sbi.createFeeds, {whenFeedsCreated: window.sbi.afterFeedsCreated}); 838 }; 839 840 function sbiGetNewFeed(feed,index,feedOptions) { 841 return new SbiFeed(feed,index,feedOptions); 842 } 843 844 function sbiAjax(submitData,onSuccess) { 845 $.ajax({
846 url: sbiajaxurl, 847 type: 'post', 848 data: submitData, 849 success: onSuccess 850 }); 851 } 852 853 })(jQuery); 854 855 jQuery(document).ready(function($) { 856 if (typeof window.sb_instagram_js_options.resized_url !== 'undefined' && window.sb_instagram_js_options.resized_url.indexOf(location.protocol) === -1) { 857 if (location.protocol === 'http:') { 858 window.sb_instagram_js_options.resized_url = window.sb_instagram_js_options.resized_url.replace('http:','https:'); 859 } else { 860 window.sb_instagram_js_options.resized_url = window.sb_instagram_js_options.resized_url.replace('https:','http:'); 861 } 862 } 863 sbi_init(); 864 }); 865 866} // 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.