1(self.webpackChunkwordpress_template=self.webpackChunkwordpress_template||[]).push([[291],{2905:(t,e,i)=>{"use strict";i.r(e),i.d(e,{default:()=>n});var s=i(2313);function a(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}const n=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.element=e,this.bindVars(),this.bindEvents()}return function(t,e,i){e&&a(t.prototype,e),i&&a(t,i)}(t,[{key:"bindVars",value:function(){this.location=document.querySelectorAll(".js-news-grid-location"),this.activeFilter=this.element.dataset.activeFilter,this.activeLocation=this.element.dataset.activeLocation,this.activeLocationString=this.element.dataset.activeLocationName,this.offset=0,this.hasMore=this.element.dataset.hasMore,this.freshUpdate=!1,this.page=this.element.dataset.page||1,this.locationSelector=this.element.querySelector(".js-news-grid-location-selector"),this.activeLocationElement=this.element.querySelector(".js-news-grid-active-location"),this.locationsHolder=this.element.querySelector(".js-news-grid-locations-holder"),this.locationItems=this.element.querySelectorAll(".js-news-grid-location-item"),this.filterSelector=this.element.querySelector(".js-news-grid-filter-selector"),this.filterItems=this.element.querySelectorAll(".js-news-grid-filter-item"),this.newsLayout=this.element.querySelector(".js-news-grid-layout"),this.newsItems=this.element.querySelector(".js-news-grid-items"),this.loading=this.element.querySelector(".js-news-grid-loading"),this.showMoreButton=this.element.querySelector(".js-news-grid-show-more"),this.showMoreButtonHolder=this.element.querySelector(".js-news-grid-button-holder"),this.lang=this.element.getAttribute("data-lang"),this.reset=this.element.getAttribute("data-reset"),this.setTranslatedText()}},{key:"setTranslatedText",value:function(){this.readMoreText="Read Article","es"===this.lang&&(this.readMoreText="Leer ArtÃculo"),"pt-pt"===this.lang&&(this.readMoreText="Ler artigo")}},{key:"bindEvents",value:function(){this.locationSelector.addEventListener("change",this.handleLocationChange.bind(this)),this.filterSelector.addEventListener("change",this.handleFilterChange.bind(this)),this.activeLocationElement.addEventListener("click",this.handleActiveLocationClick.bind(this)),this.locationItems.forEach(this.bindLocationItemEvents.bind(this)),this.filterItems.forEach(this.bindFilterItemEvents.bind(this))}},{key:"bindFilterItemEvents",value:function(t){var e=this;t.addEventListener("click",(function(i){return e.handleFilterItemClick(t,i)}))}},{key:"bindLocationItemEvents",value:function(t){t.addEventListener("click",this.handleLocationItemClick.bind(this))}},{key:"handleLocationChange",value:function(){this.activeLocation=this.locationSelector.value;var t=this.locationSelector.selectedIndex,e=this.locationSelector[t].dataset.url;this.activeLocationString=this.locationSelector[t].text,this.activeLocation||(e=this.reset),this.page=1,this.updateUrl("".concat(e)),this.updateResults()}},{key:"handleFilterChange",value:function(){this.activeFilter=this.filterSelector.value;var t=this.filterSelector.selectedIndex,e=this.filterSelector[t].dataset.url;this.activeFilter||(e=this.reset),this.page=1,this.updateUrl("".concat(e)),this.updateResults()}},{key:"handleActiveLocationClick",value:function(){this.locationsHolder.classList.toggle("is-active")}},{key:"updateUrl",value:function(t){window.history.replaceState({},"",t)}},{key:"handleLocationItemClick",value:function(t){t.preventDefault();var e=t.target.href;this.activeLocation=t.target.dataset.location,this.activeLocationString=t.target.dataset.locationString,this.locationsHolder.classList.remove("is-active"),this.page=1,this.updateUrl("".concat(e)),this.updateResults()}},{key:"updateLocation",value:function(){for(var t=0;t<this.location.length;t++){var e=this.location[t].getAttribute("data-default");if(this.activeLocationString&&!["City Guides","GuÃas de la ciudad"].includes(this.activeLocationString))this.location[t].innerHTML="".concat(this.activeLocationString," ").concat(null!==e?e:"").concat(this.page>1?" - Page ".concat(this.page):"");else if(this.activeFilter){var i=this.filterSelector.selectedIndex,s=this.filterSelector[i].dataset.title;this.location[t].innerHTML="".concat(s).concat(this.page>1?" - Page ".concat(this.page):"")}else this.location[t].innerHTML="".concat(null!==e?e:"").concat(this.page>1?" - Page ".concat(this.page):"")}}},{key:"handleFilterItemClick",value:function(t,e){e.preventDefault();var i=t.href;
1this.activeFilter===t.dataset.filter?(this.activeFilter="",i=this.reset):this.activeFilter=t.dataset.filter,this.page=1,this.updateUrl("".concat(i)),this.updateResults()}},{key:"handleShowMoreClick",value:function(t){t.preventDefault(),this.freshUpdate=!1,this.offset=parseInt(this.element.dataset.offset,10),this.page++,this.updateLocation(),this.doAjax()}},{key:"addActiveStateToFilter",value:function(){this.filterItems.forEach(this.checkActiveFilter.bind(this))}},{key:"checkActiveFilter",value:function(t){t.dataset.filter===this.activeFilter?t.classList.add("is-active"):t.classList.remove("is-active")}},{key:"updateResults",value:function(){this.offset=0,this.activeLocationElement.innerHTML=this.activeLocationString?this.activeLocationString:"City Guides",this.locationSelector.value=this.activeLocation,this.filterSelector.value=this.activeFilter,this.addActiveStateToFilter(),this.updateLocation(),this.freshUpdate=!0,this.doAjax()}},{key:"doAjax",value:function(){this.loading.classList.add("is-active");var t=[];this.offset&&t.push("offset=".concat(this.offset)),this.activeLocation&&t.push("location=".concat(this.activeLocation)),this.activeFilter&&t.push("filter=".concat(this.activeFilter)),this.lang&&t.push("lang=".concat(this.lang));var e=t.join("&");fetch("/wp-json/news/get?".concat(e)).then((function(t){return t.json()})).then(this.handleAjaxResponse.bind(this))}},{key:"handleAjaxResponse",value:function(t){var e=window.pageYOffset||document.documentElement.scrollTop;this.loading.classList.remove("is-active"),this.freshUpdate&&(this.newsItems.innerHTML="",this.element.dataset.offset=0),this.element.dataset.offset=parseInt(this.element.dataset.offset,10)+parseInt(t.posts.length,10),12===t.posts.length?this.showMoreButtonHolder.classList.add("is-active"):this.showMoreButtonHolder.classList.remove("is-active"),this.newsLayout.innerHTML=t.components||"",this.param=this.element.dataset.offset,t.posts.forEach(this.addPostToDom.bind(this)),this.checkEmptyDom(e)}},{key:"checkEmptyDom",value:function(t){""===this.newsItems.innerHTML?this.newsItems.innerHTML="<p>No Posts Found</p>":s.Z.scroll(document.body,1e3,-t),this.updateParams()}},{key:"addPostToDom",value:function(t){this.newsItems.innerHTML+=this.constructHTMLFromPost(t)}},{key:"constructHTMLFromPost",value:function(t){var e=t.image?'<img src="'.concat(t.image,'?format=auto" class="c-news-grid__image" alt="').concat(t.image_alt,'" width="').concat(t.image_width,'" height="').concat(t.image_height,'" />'):"",i=t.description?'<div class="c-news-grid__description">\n '.concat(t.description.substr(0,100)," ...\n </div>"):"";return'\n <div class="c-news-grid__item">\n <div class="c-news-grid__image-holder">\n '.concat(e,'\n </div>\n <div class="c-news-grid__content">\n <div class="c-news-grid__title">\n <h3 class="t-heading--epsilon t-font--secondary t-font-weight--700">\n ').concat(t.title,"\n </h3>\n </div>\n <p>").concat(t.date,"</p>\n ").concat(i,'\n <a href="').concat(t.link,'" class="c-news-grid__cta c-btn--arrow c-btn--thin">\n <span>').concat(this.readMoreText,'</span>\n <svg><use xlink:href="#icon-long-arrow-right"></use></svg>\n </a>\n </div>\n </div>\n ')}},{key:"updateParams",value:function(){var t=window.location,e=t.host,i=t.protocol,s=window.location.pathname,a="".concat(i,"//").concat(e+s);s=(s=s.replace(/\/$/,"")).substring(s.lastIndexOf("/")+1),s=Number(s),Number.isNaN(s)&&this.page>1?this.updateUrl("".concat(a+this.page,"/")):(a=a.replace("/".concat(s,"/"),"/".concat(this.page,"/")),this.updateUrl(a)),this.showMoreButtonHolder.classList.contains("is-active")&&(a=Number.isNaN(s)?"".concat(a+(this.page+1),"/"):a.replace("/".concat(this.page,"/"),"/".concat(this.page+1,"/"))),this.showMoreButton.setAttribute("href",a)}}]),t}()}}]);
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.