1/** Initial config values **/ 2const FLEXSLIDER_INIT_DELAY = 10000; 3window.sliderTimeouts = new Array(); 4var isSponsoredPost = false; 5var intervalPromises = []; 6 7if(typeof(googletag) != "object") { 8 googletag = {}; 9} 10 11;(function(jQuery,$,window, document, googletag ){ 12 window.readmoreClicked = 0; 13 var checkTitlesInterval = ""; 14 var delayedResizeTimeout = 0; 15 var scrollTimeOut = null; 16 17 function getVisibility(elem) { 18 elem = $(elem); 19 var visible = 0; 20 var elemTop = elem.offset().top; 21 var elemBottom = elemTop +elem.outerHeight(); 22 var screenTop = $(window).scrollTop(); 23 var screenBottom = screenTop + $(window).outerHeight(); 24 25 if(elemBottom <= screenTop || elemTop >= screenBottom) { 26 //If the element is completely outside of viewport 27 visible = 0; 28 } else if((elemTop >= screenTop && elemBottom <= screenBottom) || (elemTop <= screenTop && elemBottom >= screenBottom)) { 29 //If the element is completely within of viewport 30 //or if the top of element is above viewport and bottom of element is below viewport 31 visible = 100; 32 } else if((elemBottom - elemTop) > (screenBottom - screenTop)){ 33 //if the element is larger than viewport 34 if(elemTop > screenTop) { 35 //if top is within viewport 36 visible = ((screenBottom - elemTop) / (screenBottom - screenTop)) * 100; 37 } else { 38 //assuming bottom is within viewport 39 visible = ((elemBottom - screenTop) / (screenBottom - screenTop)) * 100; 40 } 41 } else if(elemTop < screenTop) { 42 //if the top of the element is above viewport, but assuming bottom is within viewport 43 visible = ((elemBottom - screenTop) / (elemBottom - elemTop)) * 100.0 44 } else if(elemBottom > screenBottom) { 45 //if the bottom of the element is below viewport, but assuming top is within viewport 46 visible = ((screenBottom - elemTop) / (elemBottom - elemTop)) * 100.0 47 } 48 49 return visible; 50 } 51 52 53 window.registerSidebarSlot = function( slot, key, interval ){ 54 if(!intervalPromises[interval]) { 55 intervalPromises[interval] = {slots: {}, promise: null}; 56 } else { 57 clearInterval(intervalPromises[interval].promise); 58 } 59 60 intervalPromises[interval].slots[key] = slot; 61 intervalPromises[interval].promise = buildSidebarInterval(interval,intervalPromises[interval].slots); 62 intervalPromises[interval].lastFetch = (new Date()).getTime(); 63 }; 64 65 window.buildSidebarInterval = function(interval,slots) { 66 return setInterval(function() { 67 var timestamp = (new Date()).getTime(); 68 69 if(!$(".right").is(":hidden") && document.hasFocus() && timestamp - intervalPromises[interval].lastFetch >= 30000) { 70 var items = []; 71 for(i in slots) { 72 if (getVisibility("#"+slots[i].getSlotElementId()) > 50){ 73 items.push(slots[i]); 74 } 75 } 76 77 if(items.length > 0) { 78 googletag.cmd.push(function () { 79 if (typeof(bidOnSlots) == "function") { 80 bidOnSlots(items); 81 } else if (typeof(queueAmazonSlots) == "function") { 82 queueAmazonSlots(items); 83 } else if (typeof(refreshSlots) == "function") { 84 refreshSlots(items); 85 } else { 86 headertag.pubads().refresh(items, {changeCorrelator: false}); 87 } 88 89 intervalPromises[interval].lastFetch = (new Date()).getTime(); 90 }); 91 } 92 } 93 }, interval); 94 }; 95 96 window.pauseSidebarInterval = function() { 97 isOverlayOpen = true; 98 }; 99 100 window.resetSidebarInterval = function() { 101 isOverlayOpen = false; 102 }; 103 104 window.refreshSidebarSlots = function(){ 105 if(typeof(intervalPromises.length) == "undefined" || intervalPromises.length == 0){ 106 return; 107 } 108 109 var timestamp = (new Date()).getTime(); 110 if(!$(".right").is(":hidden")) { 111 for(interval in intervalPromises) { 112 if(timestamp - intervalPromises[interval].lastFetch >= 30000) { 113 var items = []; 114 var slots = intervalPromises[interval].slots; 115 for(i in slots) { 116 if (getVisibility("#"+slots[i].getSlotElementId()) > 50){ 117 items.push(slots[i]); 118 } 119 } 120 121 if(items.length > 0) { 122 googletag.cmd.push(function() { 123 if (typeof(bidOnSlots) == "function") { 124 bidOnSlots(items); 125 } else if(typeof(queueAmazonSlots) == "function") { 126 queueAmazonSlots(items); 127 } else if(typeof(refreshSlots) == "function") { 128 refreshSlots(items); 129 } else { 130 headertag.pubads().refresh(items,{changeCorrelator:false}); 131 } 132 133 intervalPromises[interval].lastFetch = (new Date()).getTime(); 134 }); 135 } 136 } 137 } 138 } 139 }; 140 141 window.resetSidebarInterval = function() { 142 if(intervalPromises.length == 0) return; 143 144 for(interval in intervalPromises) { 145 clearInterval(intervalPromises[interval].promise); 146 intervalPromises[interval].promise = buildSidebarInterval(interval,intervalPromises[interval].slots); 147 } 148 }; 149 150 window.pauseSidebarInterval = function() { 151 if(intervalPromises.length == 0) return; 152 153 for(interval in intervalPromises) { 154 clearInterval(intervalPromises[interval].promise); 155 } 156 }; 157 158 window.refreshOverlaySlots = function() { 159 if (typeof(bidOnSlots) == "function") { 160 bidOnSlots(overlaySlots,150); 161 } else if(typeof(queueAmazonSlots) == "function") { 162 queueAmazonSlots(overlaySlots); 163 } else if(typeof(refreshSlots) == "function"){ 164 refreshSlots(overlaySlots,150); 165 } 166 167 }; 168 169 if(typeof(window.createOverlaySlots) != "function") { 170 window.createOverlaySlots = function() { 171 if(window.createOverlayPromise) {window.clearTimeout(window.createOverlayPromise);} 172 173 window.createOverlayPromise = setTimeout(function() { 174 googletag.cmd.push(function() { 175 var sections = $("#fancybox-outer .google-overlay-ad"); 176 if (sections.length > 0 ) { 177 var galleryCheck = $(".maincontent.gallery").length; 178 if(galleryCheck == 0) 179 overlaySlots = []; 180 window.block = true; 181 sections.each(function(i) { 182 var section = $(sections[i]); 183 var slotName = section.attr('id'); 184 if(slotName in slotNames) { 185 overlaySlots.push(slotNames[slotName]); 186 //if(typeof(refreshSlots) == "function") refreshSlots([slotNames[slotName]],150); 187 } else { 188 var site = section.data("site") ? section.data("site") : 'Inhabitat'+section.data('mobile'); 189 var passbackSlot = googletag.defineSlot('/2922/'+site+'/'+section.data('template')+'/'+section.data('prefix')+section.data('name')+section.data('additional'), section.data('sizes'),slotName).setConfig({targeting:{'kw':section.data('kw')}}).addService(googletag.pubads()); 190 //googletag.display(slotName); 191 headertag.display(slotName); 192 //if(typeof(refreshSlots) == "function") refreshSlots([passbackSlot],150); 193 slotNames[slotName] = passbackSlot; 194 overlaySlots.push(passbackSlot); 195 } 196 }); 197 if (typeof(bidOnSlots) == "function") { 198 bidOnSlots(overlaySlots); 199 } else if(typeof(queueAmazonSlots) == "function") { 200 queueAmazonSlots(overlaySlots); 201 } else if(typeof(refreshSlots) == "function"){ 202 refreshSlots(overlaySlots,150); 203 } 204 setTimeout(function(){window.block = false},200); 205 } 206 }); 207 }, 200); 208 }; 209 } 210 211 window.getIsSponsoredPost = function() { 212 return isSponsoredPost 213 } 214 215 window.slide = function(id,size) { 216 var ismobile=window.innerWidth; 217 var image="#ul-"+id+" .flex-active-slide"; 218 var indx=parseInt($(image+" .index").text());
219 var title=$(image+" .title").text(); 220 var content=$(image+" .content2").text(); 221 $("#counter-"+id).html(indx+"/"+size); 222 $("#title-"+id).html(title); 223 var text=$(image+" .content").text(); 224 $("#show-"+id).css("display","none"); 225 $("#content1-"+id).html(text); 226 }; 227 228 function checkTitles(){ 229 if($('body').find('.link-post-title').length == 0){ 230 clearInterval(checkTitlesInterval); 231 } 232 $('.link-post-title').each(function(i) { 233 var fitThisTitle = false; 234 235 $characters = $(this).text().length; 236 $totalInText = $characters * 10.6; 237 //When the title is bigger than the div container 238 if( $totalInText > ($(".top-content").width() * 2 ) ) { 239 $(this).addClass("fit-tittle"); 240 fitThisTitle = true; 241 }else{ 242 //When the title was fitted, just remove the special characters at the end of the word. 243 if($(this).hasClass("fit-tittle")){ 244 $(this).removeClass("fit-tittle"); 245 $(this).removeClass("link-post-title"); 246 var lastWord = $(this).text().split(" ").pop(); 247 var lastWordWithoutCharacters = lastWord.replace(/[^a-z-A-Z-0-9\s]/gi, '').replace(/[_\s]/g, ' '); 248 lastWordWithoutCharacters = $.trim(lastWordWithoutCharacters); 249 var titleWithoutLastWord = $(this).text().split(" ").slice(0, -1).join(" "); 250 $(this).text(titleWithoutLastWord+" "+lastWordWithoutCharacters+"..."); 251 }else{ 252 //When the title has a good sice, no changes are needed 253 $(this).removeClass("link-post-title"); 254 } 255 } 256 257 //Remove the last word 258 if(fitThisTitle){ 259 var str = $(this).text(); 260 var newTitle = str.split(" ").slice(0, -1).join(" "); 261 $(this).text(newTitle+"..."); 262 } 263 }); 264 } 265 266 /** 267 * This function will trigger the event $(window).resize 268 * with a delay of 250 miliseconds. this could be used to call the resize event only one, 269 * instead of multiple times.. 270 * @param time miliseconds to call resize 271 */ 272 window.delayedResize = function(){ 273 delay = 250; 274 clearTimeout(delayedResizeTimeout); 275 delayedResizeTimeout = setTimeout(function(){$(window).trigger('resize');},delay); 276 }; 277 278 window.showComment = function(elem) { 279 $("#view-comment"+elem).hide(); 280 $("#comment-container"+elem).show(); 281 } 282 283 var scrolled = false; 284 $(window).on('scroll', function(){ 285 var docTop = $(window).scrollTop(), 286 wpAdminBar = $('#wpadminbar') || false, 287 socialIcons = $('.single.post .single.author-info'), 288 recommended = $('#recommended-for-you'), 289 $AdBlock = $('.google-ad.google-ad-4'), 290 $AdjecentPosts = $('div.adjacent-posts'), 291 $TopAd = $('#header .google-ad'), 292 293 headerHeightAdjust = 135; 294 /*$('.search-form').removeClass('animated'); 295 if($(".search-form").hasClass("focused")){ 296 $(".search-form").addClass('noanimation'); 297 }*/ 298 299 if($AdBlock.length && $AdjecentPosts.length ){ 300 var top = $AdjecentPosts.offset().top, 301 adBottom = $AdBlock.offset().top + $AdBlock.height(); 302 303 if(top >= adBottom && !isDisabled){ 304 $('div.adjacent-posts.next-post').addClass('open'); 305 $('div.adjacent-posts.next-post .signal').hide(); 306 $('div.adjacent-posts.next-post .signal-close').show(); 307 } 308 309 if(top < adBottom){ 310 $('div.adjacent-posts.next-post').removeClass('open'); 311 $('div.adjacent-posts.next-post .signal').show(); 312 $('div.adjacent-posts.next-post .signal-close').hide(); 313 } 314 } 315 316 if( recommended && recommended.length){ 317 if ((docTop + $(window).height()/2 ) >= recommended.offset().top && $('body').hasClass('after-social')){ 318 $('body').removeClass('after-social'); 319 $('body').removeClass('after-header'); 320 } 321 } 322 323 headerHeightAdjust = 1; 324 325 326 if($TopAd && $TopAd.length && $TopAd.is(":visible")){ 327 headerHeightAdjust += $TopAd.height(); 328 } 329 330 if(wpAdminBar && wpAdminBar.length && headerHeightAdjust > 1){ 331 headerHeightAdjust -= wpAdminBar.height(); 332 } 333 334 if (docTop >= headerHeightAdjust){ 335 /* 5 seconds sticky ad */ 336 if(scrolled == false && ((typeof(Ib_Scroll_Config) != "undefined" && Ib_Scroll_Config.isMobile && !Ib_Scroll_Config.isTablet) || (typeof(Ib_Scroll_Config) == "undefined"))) { 337 $('.header-ad-container').addClass('scrolling'); 338 var adHeight = 119; 339 $('.maincontent').css('margin-top', adHeight); 340 setTimeout(function(){ 341 $('.header-ad-container').removeClass('scrolling'); 342 $('.maincontent').css('margin-top', ''); 343 scrolled = true; 344 },5000); 345 } 346 347 348 349 350 $('.header-ad-desktop > .google-ad').css({"display": "none", "visibility": "hidden"}); 351 $('#search-desktop,#background-desktop,#sidebar-desktop').addClass('scrolled'); 352 $('#header').addClass('scrolled'); 353 $('.container').addClass('scrolled'); 354 $('body').addClass('scrolled'); 355 $('#nav').addClass('scrolled'); 356 $('.search-form').addClass('scrolled');
357 $('.socials-list').addClass('scrolled'); 358 $('#header .logo').addClass('scrolled'); 359 $('#header .logo-owl').addClass('new-scrolled'); 360 $('.top-content .left').addClass('scrolled'); 361 $('.flexslider-one').addClass('scrolled'); 362 $('.maincontent.home.other').addClass('scrolled'); 363 } 364 365 if(docTop < headerHeightAdjust && $('#header').hasClass('scrolled') ){ 366 var topadHeight = $('.header-ad-desktop > .google-ad').height(); 367 $('.header-ad-desktop > .google-ad').css({"display": "block", "visibility": "visible"}); 368 $('#search-desktop,#background-desktop,#sidebar-desktop').removeClass('scrolled'); 369 $('.header-ad-container > .google-ad').removeClass('hidden'); 370 $('#header').removeClass('scrolled'); 371 $('.container').removeClass('scrolled'); 372 $('body').removeClass('scrolled'); 373 $('#nav').removeClass('scrolled'); 374 $('.search-form').removeClass('scrolled');
375 $('.socials-list').removeClass('scrolled'); 376 $('#header .logo').removeClass('scrolled'); 377 $('#header .logo-owl').removeClass('new-scrolled'); 378 $('.top-content .left').removeClass('scrolled'); 379 $('.flexslider-one').removeClass('scrolled'); 380 $('.maincontent.home.other').removeClass('scrolled'); 381 } 382 383 if( scrollTimeOut ) { 384 window.clearTimeout(scrollTimeOut); 385 } 386 387 if(typeof(startStopSliders) == "function") { 388 scrollTimeOut = window.setTimeout(startStopSliders,300); 389 } 390 }); 391 392 // GA Tracking 393 $(document).on('click','.ga-track',function(e){ 394 var self = $(this), 395 event = $(this).data('event'); 396 397 if(typeof event === "undefined"){ 398 console.log("GA Tracking Error: Please specify the event with the data-event attribute"); 399 return; 400 } 401 402 gtag('event',event,{ 403 'event_category': mainConfig.gaPage 404 }); 405 }); 406 407 //Speacial for Facebook Like 408 if(typeof(FB) != "undefined") { 409 $(window).load(function(){ 410 FB.Event.subscribe('edge.create', function(){ 411 gtag('event','Facebook Likes',{ 412 'event_category': mainConfig.gaPage 413 }); 414 }); 415 }); 416 } 417 418 $(window).on('resize', function(){ 419 if ($(window).height() < $('.sm_content.widget').outerHeight()) { 420 $('.slim_modal').css('align-items', 'self-start'); 421 } else { 422 $('.slim_modal').css('align-items', 'center'); 423 } 424 }); 425 426 $(document).ready(function(){ 427 428 $('body').on('click','.social-btn',function(e){ 429 e.preventDefault(); 430 //e.stopPropagation(); 431 var $this = $(this), 432 selectSN = function(SN){ 433 var sns = { 434 'facebook': function(){ 435 var galleryUrl = this.attr('data-permalink'); 436 window.open('https://www.facebook.com/sharer/sharer.php?u='+galleryUrl, '_blank', 'width=626,height=436'); 437 //console.log('facebook', this.data()); 438 }, 439 'twitter': function(){ 440 var data = this.data(); 441 var shortTitle = this.attr('data-short-title'); 442 var galleryUrl = this.attr('data-permalink'); 443 444 window.open('https://twitter.com/intent/tweet?original_referer='+galleryUrl+'&text='+shortTitle+'&tw_p=tweetbutton&url='+galleryUrl,'_blank','width=626,height=436'); 445 //console.log('twitter', this.data()); 446 }, 447 'pinterest': function(){ 448 var data = this.data(); 449 var imgUrl = this.attr('data-img-url'); 450 var imgDescription = this.attr('data-img-description'); 451 var galleryUrl = this.attr('data-permalink'); 452 window.open('https://pinterest.com/pin/create/button/?url='+galleryUrl+'&media='+imgUrl+'&description='+imgDescription,'_blank','width=626,height=436'); 453 //console.log('pinterest', this.data()); 454 }, 455 'comments': function(){ 456 var scrollTo = 0; 457 if ($('section.comments').length > 0){ 458 scrollTo = $('section.comments').offset().top - 120; 459 } 460 $('html, body').animate({ 461 scrollTop: scrollTo 462 },250); 463 console.log('comments'); 464 }, 465 'flipboard': function() { 466 window.open("https://share.flipboard.com/bookmarklet/popout?v=2&title="+this.attr('data-title')+"&url="+this.attr("data-permalink")+"&utm_medium=web&utm_campaign=widgets") 467 } 468 } 469 470 if(typeof sns[SN] === 'undefined'){ 471 return false;
472 } 473 474 return sns[SN]; 475 }; 476 477 478 if ($this.hasClass('facebook')){ 479 return selectSN('facebook').call($this); 480 } 481 482 if ($this.hasClass('twitter')){ 483 return selectSN('twitter').call($this); 484 } 485 486 if ($this.hasClass('pinterest')){ 487 return selectSN('pinterest').call($this); 488 } 489 490 if ($this.hasClass('comments')){ 491 return selectSN('comments').call($this); 492 } 493 494 if ($this.hasClass('flipboard')){ 495 return selectSN('flipboard').call($this); 496 } 497 }); 498 499 $('.search-cancel').bind('click', function(e){ 500 $('.search-form :input').each(function(){ 501 $(this).val(''); 502 }); 503 // $('.search-form').removeClass('focused'); 504 $('.search-form').removeClass('noanimation'); 505 $('.search-form').addClass('animated'); 506 507 $(this).removeClass('is-visible'); 508 }); 509 510 $('#search').bind('keypress', function(e){ 511 if ( !$('.search-cancel').hasClass('is-visible') ){ 512 $('.search-cancel').addClass('is-visible'); 513 } 514 }); 515 516 $('#search').bind('focus blur', function(e){ 517 var $SearchForm = $('.search-form'); 518 519 if(e.type === 'focus'){ 520 // $SearchForm.addClass('focused'); 521 }else{ 522 523 if($(this).val() === ''){ 524 $SearchForm.removeClass('focused'); 525 $('.search-form').addClass('animated'); 526 $('.search-form').removeClass('noanimation'); 527 $('.search-cancel').removeClass('is-visible'); 528 } 529 530 } 531 532 }); 533 534 $(".nav-area").css({ 535 "display":"inline-block" 536 }); 537 538 539 540 // INTAT 3178 541 // Flexbox modal for Login/signup 542 var loginmodal = $('.modal.login'); 543 var loginbtn = $('a.user-signup.popup'); 544 var flexOverlay = $('.flexOverlay'); 545 546 // Open flex modal 547 loginbtn.click(function(){ 548 loginmodal.css("display", "flex"); 549 550 if ($(window).height() < $('.sm_content.widget').outerHeight()) { 551 $('.slim_modal').css('align-items', 'self-start'); 552 } 553 554 flexOverlay.css('display', 'block'); 555 flexOverlay.css('background', 'rgba(0, 0, 0, 0.55)'); 556 557 }); 558 559 // Close flex modal 560 $(window).onclick = function(event) { 561 console.log('in here1', event, event.target); 562 if (event.target == $(".sm_content")) { 563 loginmodal.css("display", "none"); 564 flexOverlay.css('background', 'rgba(0, 0, 0, 0)'); 565 flexOverlay.css('display', 'none'); 566 } 567 } 568 569 // Close flex modal two 570 $('.sm_close_button').click(function(){ 571 loginmodal.css("display", "none"); 572 flexOverlay.css('background', 'rgba(0, 0, 0, 0)'); 573 flexOverlay.css('display', 'none'); 574 }); 575 576 $('#casl-checkbox-overlay').prop("checked", true); 577 578 579 580 $('div.signal-close').click(function(e){ 581 isDisabled = true; 582 $('div.adjacent-posts.next-post').removeClass('open'); 583 $('div.adjacent-posts.next-post .signal').show(); 584 $('div.adjacent-posts.next-post .signal-close').hide(); 585 $('div.adjacent-posts.next-post').addClass('disabled'); 586 setTimeout(function(){ 587 $('div.adjacent-posts.next-post').removeClass('disabled'); 588 },5000); 589 }); 590 591 $('#inhabitat-newsletter').newsletterInhabitat(); 592 593 $('.img-block .caption').on('click', function(e){ 594 e.preventDefault(); 595 e.stopPropagation(); 596 $this = $(this), 597 data = $this.data(); 598 top.location = '/'+data.category+'/'; 599 600 }); 601 602 $('#casl-open-overlay').click(function(event){ 603 event.preventDefault(); 604 //$("div.user-drop-holder a.user-signup.popup").click(); 605 }); 606 607 if(typeof(Ib_Scroll_Config) == "object" && Ib_Scroll_Config.isMobile == "1" && (window.location.pathname == "" || window.location.pathname == "/" || window.location.pathname == "/inhabitots/")){ 608 checkTitlesInterval = setInterval(function(){ checkTitles(); }, 300); 609 } 610 611 //A little patch for instagram embeds 612 var isDisabled = false;
613 614 $('.sticky-ads').stickyAd(); 615 616 if(user_is_logged){ 617 618 if(!$('#wpadminbar').length){ 619 $('body').removeClass('logged-in'); 620 } 621 622 var pluginsWidth = 0; 623 $("#wp-admin-bar-root-default").children().each(function(){ 624 pluginsWidth = pluginsWidth + $(this).outerWidth(true); 625 }); 626 var text = $("#wp-admin-bar-my-account a.ab-item").eq(0).html(); 627 text = text.replace("Howdy,","Howdy"); 628 $("#wp-admin-bar-my-account a.ab-item").eq(0).html(text); 629 630 function WP_bar_logic(){ 631 if((Math.ceil(pluginsWidth)+114) > $( window ).width() || $( window ).width() < 783){ 632 $("html").addClass("noTopMargin"); 633 $("html #wpadminbar").css("display", "none"); 634 $("#header").css("top", "0"); 635 }else if($( window ).width() > 783){ 636 $("html").removeClass("noTopMargin"); 637 $("html #wpadminbar").css("display", "block"); 638 $("#header").css("top", "32px"); 639 } 640 } 641 WP_bar_logic(); 642 643 $(window).resize(WP_bar_logic); 644 645} 646 }); // END OF $(document).ready 647})(jQuery,jQuery,window, document, googletag);
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.