XA.component.locationService=function(){"use strict";var u={},f,e,o,n=!1,t=[],i=[],r;return f=function(u,f){var o;(t.push(f),i.push(u),n)||(n=!0,navigator.geolocation?navigator.geolocation.getCurrentPosition(function(t){for(o=0;o]+)>)/ig,""),u=i!==""?i:t.html;switch(r){case"ShowPredictions":case"ShowSearchResultsAsPredictions":return'
'+u+"<\/div>";default:return'
'+t.html+"<\/div>"}}}}).on("typeahead:selected",this.suggestionSelected.bind(t));this.model.set({typeahead:i});this.model.set({valueProvider:function(){return t.$el.find(".search-box-input.tt-input").val()}});XA.component.search.vent.on("hashChanged",this.updateSearchBoxValue.bind(this))},events:{"click .search-box-button":"updateQueryModelClick","click .search-box-button-with-redirect":"updateQueryWithRedirect","keypress .search-box-input.tt-input":"predictiveSearch","keydown .search-box-input.tt-input":"predictiveSearch"},loading:function(){this.$el.toggleClass("loading-in-progress")},suggestionSelected:function(t,i){var f,r,e,u;t.preventDefault();f=this.model.get("dataProperties").suggestionsMode;try{r=n(i.html).text()}catch(o){r=""}e=r!=""?r:i.html;switch(f){case"ShowPredictions":case"ShowSearchResultsAsPredictions":this.performSearch(e);break;default:u=n(i.html).find("a");u.length&&(window.location.href=n(u[0]).attr("href"))}},updateQueryWithRedirect:function(n){n.preventDefault();var f=this.model.get("dataProperties").resultPage,i=this.model.get("dataProperties").targetSignature,e=this.model.get("dataProperties").searchResultsSignature,r=encodeURIComponent(this.$el.find(".search-box-input.tt-input").val()),o=this.model.get("sig"),u={};u=i!==""?this.updateSignaturesHash([i+"_q"],r,this.createOffsetObject()):this.updateSignaturesHash(o,r,this.createOffsetObject());window.location.href=t.createRedirectSearchUrl(f,u,e,i)},updateQueryModelClick:function(n){n.preventDefault();var t=this.$el.find(".search-box-input.tt-input").val();this.closeDropdown();this.updateQueryModel(t)},updateQueryModel:function(n){for(var i={},f=this.translateSignatures(this.model.get("dataProperties").searchResultsSignature,"e"),u=this.model.get("sig"),t=0;t0&&XA.component.search.ajax.getData({callback:function(n){XA.component.search.vent.trigger("facet-data-loaded",n)},url:XA.component.search.url.createMultiFacetUrl({endpoint:r.endpoint,s:r.s,l:u},n,t)}))},filterFacetData:function(t){var f=this.getFacetRequestData(t),r=f.data,u,e,o,h,s;for(var i in r)r.hasOwnProperty(i)&&(e=this.getSearchResultsLanguage(i),o=this.getSearchResultsScope(i),h=this.getSearchResultsModelBySignature(i),s=h.get("dataProperties").itemid,r[i].normalFiltering.length>0&&(u=n.extend({endpoint:f.endpoint,s:o,l:e},t),XA.component.search.ajax.getData({callback:function(n){XA.component.search.vent.trigger("facet-data-filtered",n)},url:XA.component.search.url.createMultiFacetUrl(u,r[i].normalFiltering,i,s)})),r[i].partialFiltering.length>0&&_.each(r[i].partialFiltering,function(r){var h=n.extend({},t);delete h[i!==""?i+"_"+r:r];delete h[i!==""?i+"_"+r.toLowerCase():r.toLowerCase()];u=n.extend({endpoint:f.endpoint,s:o,l:e},h);XA.component.search.ajax.getData({callback:function(n){XA.component.search.vent.trigger("facet-data-partial-filtered",n)},url:XA.component.search.url.createMultiFacetUrl(u,[r],i,s)})}))},getFacetRequestData:function(n){var o=this,f=[],t={},e,i,r,u;for(e in XA.component.search.facet)i=XA.component.search.facet[e],typeof i.getFacetDataRequestInfo=="function"&&(f=i.getFacetDataRequestInfo(),_.each(f,function(i){u=i.signature!==""?i.signature+"_"+i.facetName:i.facetName;t.hasOwnProperty(i.signature)||o.initRequestObject(t,i);i.filterWithoutMe&&(n===undefined||n.hasOwnProperty(u)||n.hasOwnProperty(u.toLowerCase()))?(t[i.signature].partialFiltering.push(i.facetName),r=i.endpoint):(t[i.signature].normalFiltering.push(i.facetName),r=i.endpoint)}));return{endpoint:r,data:t}},initRequestObject:function(n,t){n[t.signature]={};n[t.signature].normalFiltering=[];n[t.signature].partialFiltering=[]},getSearchResultsLanguage:function(n){var t=this.getSearchResultsModelBySignature(n);return typeof t!="undefined"?t.get("dataProperties").l:""},getSearchResultsScope:function(n){var t=this.getSearchResultsModelBySignature(n);return typeof t!="undefined"?t.get("dataProperties").s:""},getSearchResultsModelBySignature:function(n){var t=XA.component.search.results.searchResultModels;return t.filter(function(t){return t.get("dataProperties").sig===n})[0]}});return new t}(jQuery,document);XA.component.search.facet.summary=function(n){var i={},r=XA.component.search.url,t=XA.component.search.query,u=XA.component.search.ajax,f="summary",e=Backbone.Model.extend({defaults:{dataProperties:{},sig:[],hash:""},initialize:function(){var n=this;this.set("resultData",{});XA.component.search.vent.on("facet-data-loaded",n.processData.bind(n));XA.component.search.vent.on("facet-data-partial-filtered",n.processData.bind(n));XA.component.search.vent.on("facet-data-filtered",n.processData.bind(n))},requestFacetData:function(n,t){return _.find(n,function(n){return n.Key.toLowerCase()===t.facetName.toLowerCase()})},translateSignatures:function(n,t){var i,r;if(t=t.toLowerCase(),typeof n=="undefined"||n===null)return[t];if(i=n.split(","),n==="")return[t];for(r=0;r
"+"<% _.forEach(resultData, function(obj,key){ %>"+"
"+"<%= key %>:<\/span> "+"<%= renderFacetValues(obj.value) %>"+"<\/div>"+"<% }); %>"+"<\/div><% }%>",renderFacetValues:function(n){var t=n.split("||");return t.map(function(n){return"

"+n+"<\/p>x<\/span><\/div>"}).join(" ")},clearButtons:function(t){var i=n(t.currentTarget),r=i.closest(".facet-summary");r.find(".clear-all-active-facets").trigger("click")},initialize:function(){var n=this.$el.data(),t=this,i=n.properties,r;Backbone.$(".facet-summary .clear-filter").on("click",function(n){t.clearButtons(n)});Backbone.$(".facet-summary .bottom-remove-filter").on("click",function(n){t.clearButtons(n)});r=this.translateSignatures(i.searchResultsSignature,f);this.model.set("sig",i.searchResultsSignature);n=this.$el.data("properties");this.model.on("change",this.render,this);this.render()},events:{"click .removeFacetValue":"removeFacetValue","click .clear-filter":"clearAllActiveFacets","click .bottom-remove-filter button":"clearAllActiveFacets"},createHash:function(n){var t="#";for(option in n)t+=option+"="+n[option]+"&";return t},updateLocation:function(n){XA.component.search.query.updateHash(n)},getFacetParams:function(t){var i=n(t).closest(".active-facet-summary-element");return{key:i.data("key"),signature:i.data("signature")}},clearAllActiveFacets:function(){var i=this,r=t.parseHashParameters(window.location.hash);this.$el.find(".active-facet-summary-element").each(function(){var t=i.getFacetParams(n(this)),u=i.translateSignatures(t.signature,t.key);_.each(u,function(n){r[n]=""})});i.updateLocation(r)},removeFacetValue:function(i){var f=n(i.currentTarget).closest(".facet-summary-value"),e=decodeURIComponent(f.data("value")),u=this.getFacetParams(i.currentTarget),r=t.parseHashParameters(window.location.hash),o=this.translateSignatures(u.signature,u.key),s=function(n){r[n]=r[n].split("||").filter(function(n){return n!==e}).join("||")};_.each(o,s);this.updateLocation(r)},render:function(){var r=this,n=this.model.get("resultData"),t,i,u=this.$el.data();(this.properties=u.properties,this.manageVisibilityByData(this.$el,n),this.model&&(this.model.set({dataProperties:this.properties}),this.model.set("sig",this.properties.searchResultsSignature)),window.location.href.startsWith("file://"))||(n!==undefined&&(t=_.template(this.template,{imports:{renderFacetValues:this.renderFacetValues}}),i=t({resultData:n})),r.$el.find(".facet-summary-placeholder").html(i))}});return i.init=function(){if(!n("body").hasClass("on-page-editor")){t=XA.component.search.query;u=XA.component.search.ajax;r=XA.component.search.url;var i=n(".facet-summary:not(.initialized)");_.each(i,function(t){var i=n(t),r=new e,u=new o({el:i,model:r});i.addClass("initialized")})}},i}(jQuery,document);XA.register("facetSummary",XA.component.search.facet.summary);XA.component.search.facet.dropdown=function(n){"use strict";var i={},r,t,u=XA.component.search.baseModel.extend({defaults:{template:"<% _.forEach(results, function(result){"+"%>

").addClass("slider-value"),l=this.$el.find(".slider");t=XA.component.search.query;r=XA.component.search.url;isNaN(f)&&(f=0);isNaN(e)&&(e=0);isNaN(o)&&(o=1);isNaN(u)&&(u=0);l.slider({min:f,max:e,step:o,value:u,slide:_.debounce(function(n,t){s.updateModel(s.updateSignaturesHash(a,t.value,{}))},500)});n(".slider-value").remove();c.html(i.formatingString.replace("{value}",u));l.after(c)},removeFacet:function(){var n=this.$el,u=this.model.get("sig"),f=this.$el.find(".slider"),e=this.$el.find(".slider-value"),o=n.find(".facet-heading > span"),i=this.model.get("dataProperties"),r=n.data("properties"),s=r.f;o.removeClass("has-active-facet");e.html("");f.slider("value",r.minValue);i[s]="";t.updateHash(this.updateSignaturesHash(u,"",{}));this.model.set({dataProperties:i})},updateModel:function(n){var e=this.model.get("sig"),r,u,f,i;for(n||(n=t.parseHashParameters(window.location.hash)),i=0;i span").addClass("has-active-facet");t.updateHash(this.updateSignaturesHash(e,n,{}))}});return i.init=function(){t=XA.component.search.query;r=XA.component.search.url;var i=n(".facet-slider:not(.initialized)");_.each(i,function(t){var i=n(t),r=new u,e=new f({el:i,model:r});i.addClass("initialized")})},i}(jQuery,document);XA.register("searchFacetSlider",XA.component.search.facet.slider);XA.component.search.loadMore=function(n){var t={},i,r;return i=Backbone.Model.extend({defaults:{dataProperties:{},sig:[]}}),r=Backbone.View.extend({initialize:function(){var n=this.$el.data(),t=this;n.properties.searchResultsSignature===null&&(n.properties.searchResultsSignature="");this.model&&this.model.set("sig",n.properties.searchResultsSignature.split(","));XA.component.search.vent.on("results-loaded",function(n){for(var r=t.model.get("sig"),u=typeof n.offset!="undefined"?n.offset:0,i=0;i=n.dataCount||u+n.pageSize>=n.dataCount?t.$el.hide():t.$el.show())})},events:{"mousedown input":"loadMore"},loadMore:function(){for(var t=this.model.get("sig"),n=0;n0&&(t=new Bloodhound({datumTokenizer:Bloodhound.tokenizers.obj.whitespace("name"),queryTokenizer:Bloodhound.tokenizers.whitespace,limit:n.get("dataProperties").p,remote:{url:"-",replace:function(){return Date.now().toString()},transport:function(t,i,r){var u=n.get("queryParams");if(!u.text){i([]);return}f.locationAutocomplete(u,function(n){var t=n.map(function(n){return n.hasOwnProperty("text")?n.text:n});i(t)},function(){r("Could not autocomplete")})}}}),t.initialize(),this.set({searchEngine:t}))}}),s=XA.component.search.baseView.extend({initialize:function(){var u=this,n=this.$el.data(),i=this.$el.find(".location-search-box-input"),t=n.properties.searchResultsSignature.split(","),r;if(n.properties.searchResultsSignature===null&&(n.properties.searchResultsSignature=""),this.model.set({dataProperties:n.properties}),this.model.set({sig:t}),this.model.set({queryParams:{maxResults:n.p,text:""}}),this.model.initAutocompleteEngine(),r=this.model.get("searchEngine"),r)i.typeahead({hint:!0,minLength:2},{source:r.ttAdapter(),templates:{suggestion:function(n){return'
'+n+"<\/div>"}}}).on("typeahead:selected",function(n,t){u.translateUserLocation(t);i.typeahead("val",t)});this.addressLookup(!0);XA.component.search.vent.on("hashChanged",function(n){var r=n[t.length>0&&t[0]!==""?t[0]+"_a":"a"];typeof r!="undefined"&&r!==null&&r!==""&&i.val(r)})},events:{"click .location-search-box-button":"addressLookup","keypress .location-search-box-input":"searchTextChanges","keyup .location-search-box-input":"autocomplete"},addressLookup:function(n){var i=this.model.get("dataProperties"),t={text:this.getAddress(n),maxResults:1},r;t.text===""&&(r=this.createHashObject("","",""),this.updateHash(r,i));switch(i.mode){case"Location":this.detectLocation();break;case"UserProvided":this.translateUserLocation(t);break;case"Mixed":typeof t.text=="undefined"||t.text===""?this.detectLocation():this.translateUserLocation(t)}},getAddress:function(n){var f=this.$el.find(".location-search-box-input.tt-input"),i=f.length!==0?f.val():this.$el.find(".location-search-box-input").val(),e=t.parseHashParameters(window.location.hash),r=this.model.get("sig"),u;return n!==!0&&(i===""||typeof i=="undefined")?"":((i===""||typeof i=="undefined")&&(u=e[r.length>0&&r[0]!==""?r[0]+"_a":"a"],u!==""&&(i=u),typeof i=="undefined"&&(i="")),i)},autocomplete:function(n){var t,i,r=this.model.get("dataProperties");(n.stopPropagation(),n.keyCode!==13)&&(t=this.$el.find(".location-search-box-input.tt-input"),i={text:t.length!==0?t.val():this.$el.find(".location-search-box-input").val(),maxResults:r.p},this.model.set({queryParams:i}))},searchTextChanges:function(n){return(n.stopPropagation(),n.keyCode===13)?(this.addressLookup(!1),!1):!0},translateUserLocation:function(n){var r=this,u=this.model.get("dataProperties"),t=typeof n.text!="undefined"?n.text:n,i=this.$el.find(".location-search-box-input.tt-input"),e={};t!==""&&(f.addressLookup({text:t},function(n){e=r.createHashObject(n[0]+"|"+n[1],u.f+",Ascending");r.updateHash(e,u)},function(){console.error("Error while getting '"+t+"' location")}),i.blur(),i.val()===""&&i.val(t))},detectLocation:function(){var n=this.model.get("dataProperties"),r=this.$el.find(".location-search-box-input"),f=this.model.get("sig"),e=t.parseHashParameters(window.location.hash),u={},i=this;XA.component.locationService.detectLocation(function(t){u=i.createHashObject(t[0]+"|"+t[1],n.f+",Ascending");i.updateHash.call(i,u,n);r.length>0&&r.attr("placeholder",n.myLocationText)},function(n){console.log(n)})},updateHash:function(n,i){for(var u=this.model.get("sig"),f,o=typeof XA.component.search!="undefined"?XA.component.search.results.searchResultModels:[],h=this.$el.find(".location-search-box-input.tt-input"),s=h.length!==0?h.val():this.$el.find(".location-search-box-input").val(),e,r=0;r "+"
  • <%= data.first %><\/a><\/li>"+"
  • <%= data.previous %><\/a><\/li>"+"<% var beforePage = 0; %>"+"<% _.each(data.pages, function(page){ %>"+"<% if((beforePage+1) != page.number){ %>"+"
  • ...<\/span><\/li>"+"<% } %>"+"<% beforePage = page.number; %>"+"<% if(data.selectedValue === page.number){ %>"+"<% active = 'active'; %>"+"<% }else { active = '' } %>"+"
  • <%= page.number %><\/a><\/li>"+"<% }); %>"+"
  • <%= data.next %><\/a><\/li>"+"
  • <%= data.last %><\/a><\/li>"+"<\/ul>",sig:[],timeStamp:(new Date).getTime()}}),u=XA.component.search.baseView.extend({initialize:function(){var n=this.$el.data();n.properties.searchResultsSignature===null&&(n.properties.searchResultsSignature="");this.model.set("dataProperties",n);this.model.set("sig",this.translateSignatures(n.properties.searchResultsSignature,facetName));this.model.on("change",this.render,this);XA.component.search.vent.on("results-loaded",this.handleLoadedData.bind(this));window.location.href.startsWith("file://")&&this.model.set({resultsCount:10,pageSize:2,selectedValue:2})},events:{"click .page-selector-item-link":"updateSelectedValue","click .page-selector-item-first a":"showFirstPage","click .page-selector-item-last a":"showLastPage","click .page-selector-item-previous a":"showPrevPage","click .page-selector-item-next a":"showNextPage"},updateModelAfterSearch:function(n,t){this.model.set({pageSize:parseInt(n.pageSize),resultsCount:parseInt(n.dataCount),offset:parseInt(n.offset),selectedValue:parseInt(t)});this.model.set("timeStamp",(new Date).getTime());this.updateElementCssClass(n)},updateElementCssClass:function(n){this.el.classList.remove("page-selector-empty");this.el.classList.remove("page-selector-single-page");n.dataCount===0?this.el.classList.add("page-selector-empty"):(n.pageSize>n.dataCount||n.offset>n.dataCount)&&this.el.classList.add("page-selector-single-page")},updateSelectedValue:function(i){i.preventDefault();var r=this.model.get("sig"),u=n(i.target).data();t.updateHash(this.updateSignaturesHash(r,u.offset,{}))},showFirstPage:function(i){i.preventDefault();var r=this.model.get("sig"),u=n(i.target).data();t.updateHash(this.updateSignaturesHash(r,0,{}))},showLastPage:function(n){n.preventDefault();var i=this.model.get("resultsCount")%this.model.get("pageSize"),r=this.model.get("resultsCount")-(i===0?this.model.get("pageSize"):i),u=this.model.get("sig");t.updateHash(this.updateSignaturesHash(u,r,{}))},showNextPage:function(n){n.preventDefault();var i=this.model.get("offset"),r=this.model.get("sig");i+this.model.get("pageSize")=0&&(r-=this.model.get("pageSize"));t.updateHash(this.updateSignaturesHash(u,r,{}))},render:function(){var l=this,t=this.model.get("dataProperties").properties,a=this.model.get("resultsCount"),r=this.model.get("pageSize"),u=this.model.get("selectedValue"),i=Math.ceil(a/r),f=[],e=u-t.treshold/2,o=u+t.treshold/2,s,n,h,c;if(e<0&&(o+=Math.abs(e)),o>i&&(e-=o-i),t.treshold>=i)for(n=0;n=e&&n<=o&&f.push({number:n,offset:(n-1)*r});s={previous:t.previous,first:t.first,next:t.next,last:t.last,pages:f,selectedValue:u};h=_.template(l.model.get("template"));c=h({data:s});this.$el.html(c);this.handleButtonState(u,i)},handleButtonState:function(n,t){this.$el.find(".page-selector-item-last, .page-selector-item-next").removeClass("inactive");this.$el.find(".page-selector-item-first, .page-selector-item-previous").removeClass("inactive");t==0?(this.$el.find(".page-selector-item-first, .page-selector-item-previous").addClass("inactive"),this.$el.find(".page-selector-item-last, .page-selector-item-next").addClass("inactive")):(n==1&&this.$el.find(".page-selector-item-first, .page-selector-item-previous").addClass("inactive"),n==t&&this.$el.find(".page-selector-item-last, .page-selector-item-next").addClass("inactive"))},handleLoadedData:function(n){var o=this,f=this.model.get("dataProperties").properties.searchResultsSignature.split(","),s=t.parseHashParameters(window.location.hash),e,r,u,i;for(typeof n.offset=="undefined"&&(n.offset=0),i=0;in.dataCount||n.offset>n.dataCount?(this.updateModelAfterSearch(n,1),setTimeout(function(){u=t.parseHashParameters(window.location.hash);r=n.searchResultsSignature!==""?n.searchResultsSignature+"_e":"e";s[r]!=="0"&&(u[r]=0,Backbone.history.navigate(o.createFirstPageUrlHash(u),{trigger:!0,replace:!0}))},100)):(e=Math.ceil(n.offset/n.pageSize)+1,this.updateModelAfterSearch(n,e)))},createFirstPageUrlHash:function(n){var t="",i=0;return _.each(n,function(n,r){i>0&&(t+="&");i++;t+=r+"="+n}),t}}),i.init=function(){if(!n("body").hasClass("on-page-editor")){t=XA.component.search.query;var i=n(".page-selector:not(.initialized)");_.each(i,function(t){var i=n(t);new u({el:i,model:new r});i.addClass("initialized")})}},i}(jQuery,document);XA.register("searchPageSelector",XA.component.search.pageSelector);XA.component.search.pageSize=function(n){var t={},i,r,u,f="p",e=Backbone.Model.extend({defaults:{sig:[]}}),o=XA.component.search.baseView.extend({clicks:0,initialize:function(){var n=this,i=this.getCurrentPageSize(),t=this.$el.data().properties;this.model.set("sig",this.translateSignatures(t.searchResultsSignature,f));this.selectOption(i);typeof i=="undefined"&&t.defaultPageSize!==""&&n.selectOption(t.defaultPageSize);XA.component.search.vent.on("hashChanged",function(t){for(var r=n.model.get("sig"),i=0;i0){for(t=0;t1?decodeURIComponent(r[1].replace(/[+]/g," ")):null;return u},updateHash:function(n,t){var f=this,i="#",r=this.parseHashParameters(window.location.hash),u;_.each(n,function(n,t){n!==""?r[t]=n:delete r[t]});(t==="#"||t==undefined)&&(t=window.location.pathname);u=0;_.each(r,function(n,t){u>0&&(i+="&");u++;i+=t+"="+encodeURIComponent(n).replace(/%7C/g,"|")});Backbone.history.navigate(i,{trigger:!0});i.length&&(this.set({hash:i}),this.createHashObj())},isSignaturePresentInHash:function(n,t){for(var r=Object.keys(n),u=!1,f=r.length,i=0;i=1&&n(t[0]).addClass("selected"))},updateHash:function(n){var t=this.model.get("sig");n=n==-1?"":n;f.updateHash(this.updateSignaturesHash(t,n,{}))},radiusClick:function(t){var i=this,r=n(t.currentTarget);i.updateHash(r.data("value"));i.model.set({selected:r})},deselect:function(){var n=this;n.updateHash("");n.model.set({selected:undefined})},hashChanged:function(t){for(var f=this,o=this.model.get("sig"),e,i,r,u=0;u=1?f.model.set({selected:n(r[0])}):f.model.set({selected:undefined}))}}),i=function(n){var t=new r,i=new u({el:n[0],model:t});n.addClass("initialized")},t.init=function(){if(!n("body").hasClass("on-page-editor")){var t=n(".radius-filter:not(.initialized)");_.each(t,function(t){i(n(t))});f=XA.component.search.query;e=XA.component.search.url}},t}(jQuery,document);XA.register("radiusFilter",XA.component.search.radiusFilter);XA.component.search.results=function(n){"use strict";var t={},u=[],i=[],f,r,e,o=Backbone.Model.extend({defaults:{template:"<% if(!results.length){ %>
    <%= noResultsText %><\/div> <% }else { %>"+"
      "+"<% _.forEach(results, function(result){ %>"+"
    • data-id='<%= result.Id %>' data-longitude='<%= result.Geospatial.Longitude %>' data-latitude='<%= result.Geospatial.Latitude %>'<% } %>"+"><%= result.Html %><\/li>"+"<% }); %>"+"<\/ul>"+"<% } %>"+"
      ",templateItems:"<% _.forEach(results, function(result){ %>"+"
    • data-id='<%= result.Id %>' data-longitude='<%= result.Geospatial.Longitude %>' data-latitude='<%= result.Geospatial.Latitude %>'<% } %>"+"><%= result.Html %><\/li>"+"<% }); %>",dataProperties:{},blockNextRequest:!1,noResultsText:"",resultData:{},loadingInProgress:!1,loadingMoreInProgress:!1,resultDataMore:{},loadMoreOffset:0,loadMore:!1},initialize:function(){var n=r.parseHashParameters(window.location.hash),t=encodeURIComponent(this.get("dataProperties").sig),i="e_"+t;n.hasOwnProperty("e")&&t===""&&this.set("loadMoreOffset",parseInt(n.e));n.hasOwnProperty(i)&&this.set("loadMoreOffset",parseInt(n[i]));XA.component.search.vent.on("results-loaded",this.resultsLoaded.bind(this));XA.component.search.vent.on("results-loading",this.resultsLoading.bind(this))},blockRequests:function(n){this.set("blockNextRequest",n)},checkBlockingRequest:function(){return this.get("blockNextRequest")},getMyOffset:function(){var n=r.parseHashParameters(window.location.hash),t=encodeURIComponent(this.get("dataProperties").sig);return n.hasOwnProperty("e_"+t)?n["e_"+t]:0},resultsLoaded:function(n){var t=encodeURIComponent(this.get("dataProperties").sig);t===n.searchResultsSignature&&(this.get("loadMore")?(this.set({resultDataMore:n}),this.set({loadingMoreInProgress:!1}),this.unset("loadMore",{silent:!0})):(this.set({resultData:n}),this.set({loadingInProgress:!1})),this.blockRequests(!1))},resultsLoading:function(n){this.cid==n&&(this.get("loadMore")?this.set({loadingMoreInProgress:!0}):this.set({loadingInProgress:!0}))}}),s=Backbone.View.extend({initialize:function(){var t=this.$el.data(),f=this.$el.find(".no-results").html(),r=XA.component.search.router,u=r?r.routerInstance:undefined,n=this;t.properties.sig===null&&(t.properties.sig="");this.model&&this.model.set({dataProperties:t.properties,noResultsText:f});this.model.on("change:loadingInProgress",this.loading,this);this.model.on("change:loadingMoreInProgress",this.loadingMore,this);this.model.on("change:resultData",this.render,this);this.model.on("change:resultDataMore",this.renderPart,this);this.$el.on("remove",function(){i=i.filter(function(t){return t.cid!==n.model.cid})});XA.component.search.vent.on("add-variant-class",function(t){var i=n.model.get("dataProperties").sig;t.sig===i&&(n.$el.removeClass(n.$el.attr("data-class-variant")),n.$el.attr("data-class-variant",t.classes),n.$el.addClass(t.classes))});XA.component.search.vent.on("loadMore",function(t){var i=n.model.get("dataProperties").sig;t.sig===i&&XA.component.search.service.getData({loadMore:"true",p:n.model.get("dataProperties").p,singleRequestMode:i})});XA.component.search.vent.on("my-location-coordinates-changed",function(t){t.sig===n.model.get("dataProperties").sig&&n.model.get("loadMore")&&n.$el.find(".search-result-list").html("")});u&&t.properties.autoFireSearch&&this.$el.closest(".overlay-inner").length&&u.checkUrl(window.location.hash,!0);this.render()},events:{"click .search-result-list > li[data-longitude][data-latitude]":"poiClick"},loading:function(){this.model.get("loadingInProgress")?this.$el.addClass("loading-in-progress"):this.$el.removeClass("loading-in-progress")},loadingMore:function(){this.model.get("loadingMoreInProgress")?this.$el.addClass("loading-more-in-progress"):this.$el.removeClass("loading-more-in-progress")},renderPart:function(){var n=_.template(this.model.get("templateItems")),t=n({results:this.model.get("resultDataMore").data});this.$el.find(".search-result-list").append(t)},render:function(){var n=this,t=n.model.get("resultData").data,i,r;window.location.href.startsWith("file://")||(typeof t=="undefined"&&(t=[]),i=_.template(n.model.get("template")),r=i({results:t,noResultsText:n.model.get("noResultsText")}),this.$el.html(r))},poiClick:function(t){var i=n(t.currentTarget);XA.component.search.vent.trigger("center-map",{sig:this.model.get("dataProperties").sig,coordinates:[i.data("latitude"),i.data("longitude")],id:i.data("id")})}});return t.init=function(){if(!n("body").hasClass("on-page-editor")){f=XA.component.search.url;r=XA.component.search.query;e=XA.component.search.ajax;var t=n(".search-results:not(.initialized)");_.each(t,function(t){var r=n(t),f=new o;i.push(f);u.push(new s({el:r,model:f}));r.addClass("initialized")})}},t.searchResultViews=u,t.searchResultModels=i,t}(jQuery,document);XA.register("searchResults",XA.component.search.results);XA.component.search.results.count=function(n){var t={},i=Backbone.View.extend({initialize:function(){var i=this.$el.data(),t=this.$el.find(".results-count"),n=this;if(this.resultsCountText=t.html(),window.location.href.startsWith("file://")){t.html(n.resultsCountText.replace("{count}",1));n.$el.find(".results-count").show();return}XA.component.search.vent.on("results-loaded",function(i){if(n.$el.find(".results-count").length>0){var r=n.$el.data("properties").targetSignature;if(r!=""&&r!=i.searchResultsSignature)return;t.html(n.resultsCountText.replace("{count}",i.dataCount));n.$el.find(".results-count").show()}})}});return t.init=function(){if(!n("body").hasClass("on-page-editor")){var t=n(".search-results-count:not(.initialized)");_.each(t,function(t){var r=n(t),u=new i({el:r});r.addClass("initialized")})}},t}(jQuery,document);XA.register("searchResultsCount",XA.component.search.results.count);XA.component.search.facet.resultsfilter=function(n){var r={},u,t,f,e=XA.component.search.baseModel.extend({defaults:{template:"
      <% "+"_.forEach(facet.Values, function(value,key){"+"%>

      '>"+"<%= value.Name !== '' ? value.Name : emptyText %> "+"(<%= value.Count %>)<\/span>"+"<\/span><\/p><% }); %>"+"<% if(highlightBehaviour>=1 && resultsCount>highlightBehaviour){ %>"+"

      <% if(showAllFacets){ %><%=showLessText%><%}else{%><%=showMoreText%><%} %><\/div>"+"<%}%>"+"<\/div>",templateMulti:"
      <% "+"_.forEach(facet.Values, function(value,key){"+"%>

      '>"+""+"

      <% if(showAllFacets){ %><%=showLessText%><%}else{%><%=showMoreText%><%} %><\/div>"+"<%}%>"+"<\/div>",dataProperties:{},blockNextRequest:!1,resultData:{},timeStamp:"",showAllFacets:!1,sig:[]},initialize:function(){XA.component.search.vent.on("facet-data-loaded",this.processData.bind(this));XA.component.search.vent.on("facet-data-partial-filtered",this.processData.bind(this));XA.component.search.vent.on("facet-data-filtered",this.processData.bind(this));XA.component.search.vent.on("hashChanged",this.updateComponent.bind(this));this.set({facetArray:[]})},toggleBlockRequests:function(){var n=this.get("blockNextRequest");this.set(this.get("blockNextRequest"),!n)},processData:function(n){var r=this,u=this.get("dataProperties"),f=u.searchResultsSignature.split(","),e=u.sortOrder,t,i;for(n.Signature===null&&(n.Signature=""),t=0;t0&&n.Signature===f[t]?(i=_.find(n.Facets,function(n){return n.Key.toLowerCase()===r.get("dataProperties").f.toLowerCase()}),i!==undefined&&(this.sortFacetArray(e,i.Values),r.set({resultData:i}))):r.set({resultData:[]})},updateFacetArray:function(n){var i,r,t;if(n){for(i=n.split("||"),r=[],t=0;t button":"removeFacet","click .toogle-facet-visibility":"toogleFacetVisibility"},toogleFacetVisibility:function(){var n=this.model.get("showAllFacets");this.model.set("showAllFacets",!n)},updateFacet:function(i){var u=n(i.currentTarget),e=this.model.get("facetArray"),l=this.model.get("dataProperties"),v=this.$el.find(".facet-heading > span"),y=u.parents(".component-content").find(".facet-search-filter"),a=l.f.toLowerCase(),h=u.data("facetvalue"),f=typeof h!="undefined"?decodeURIComponent(h):h,s=this.model.get("sig"),c,o={},r;if(l.multi){if(f&&(u.is(":not(.active-facet)")?(this.setActiveFacet(a,f),e.push(f)):(u.removeClass("active-facet"),u.find("[type=checkbox]").prop("checked",!1),u.find("[type=checkbox] + label:after").css({background:"#fff"}),c=e.indexOf(f),c>-1&&e.splice(c,1),e.length==0&&v.removeClass("has-active-facet")),this.model.set({facetArray:e})),u[0].type=="button"){for(r=0;r span"),f=r.find(".facet-value"),e=this.model.get("sig");t.updateHash(this.updateSignaturesHash(e,"",{}));u.removeClass("has-active-facet");_.each(f,function(t){var i=n(t);i.hasClass("active-facet")&&(i.removeClass("active-facet"),i.find("[type=checkbox]").prop("checked",!1),i.find("[type=checkbox] + label:after").css({background:"#fff"}))});this.model.set({facetArray:[]})},render:function(){var n=this,i=this.model.get("resultData"),u=this.$el.find(".facet-heading > span"),c=this.model.get("dataProperties").f.split("|"),l=this.model.get("dataProperties").emptyValueText,f=this.model.get("dataProperties").highlightThreshold,a=this.model.get("dataProperties").showLessText,v=this.model.get("dataProperties").showMoreText,y=parseInt(this.model.get("dataProperties").highlightBehaviour),p=this.model.get("showAllFacets"),e=t.parseHashParameters(window.location.hash),r=this.model.get("sig"),o,s,h;window.location.href.startsWith("file://")||(this.manageVisibilityByData(this.$el,i),i!==undefined&&(o=n.model.get("dataProperties").multi===!0?_.template(n.model.get("templateMulti")):_.template(n.model.get("template")),h=o({facet:i,emptyText:l,showLessText:a,showMoreText:v,highlightBehaviour:y,showAllFacets:p,resultsCount:i.Values?i.Values.length:-1})),n.$el.find(".contentContainer").html(h),_.each(c,function(t){var i,u;for(s=t.toLowerCase(),i=0;i span"),s=this,r,u;if(i=i.toString().toLowerCase(),r=this.$el.find("[data-facetvalue]").filter(function(){return decodeURIComponent(n(this).attr("data-facetvalue").toLowerCase())===i}),typeof i!="undefined"&&i!==null)u=i.split("||");else return;u.length>1&&(f.multi=!0);f.multi?_.each(e,function(t){if(u.length>1)for(var i=0,f=u.length;it&&r.addClass("highlighted")})}});return r.init=function(){if(!n("body").hasClass("on-page-editor")){t=XA.component.search.query;f=XA.component.search.ajax;u=XA.component.search.url;var i=n(".facet-single-selection-list:not(.initialized)");_.each(i,function(t){var i=n(t),r=new e,u=new o({el:i,model:r});i.addClass("initialized")})}},r.getFacetDataRequestInfo=function(){var i=n(".facet-single-selection-list"),t=[];return _.each(i,function(i){for(var r=n(i).data().properties,f=r.searchResultsSignature.split(","),u=0;u div":"changeVariant"},changeVariant:function(t){var i=n(t.currentTarget),r=this.model.get("sig"),f=i.data();this.$el.find(".active-variant").removeClass("active-variant");i.addClass("active-variant");u.updateHash(this.updateSignaturesHash(r,f.variantindex,{}));this.triggerAddVariant(n(t.currentTarget).attr("class"))},triggerAddVariant:function(n,t){XA.component.search.vent.trigger("add-variant-class",{classes:n,sig:t})},selectVariantIcon:function(n){this.$el.find("div[data-variantIndex]").removeClass("active-variant");this.$el.find("div[data-variantIndex="+n+"]").addClass("active-variant")}});return i.init=function(){if(!n("body").hasClass("on-page-editor")){r=XA.component.search.query;u=XA.component.search.parameters;var t=n(".variant-selector:not(.initialized)");_.each(t,function(t){var i=n(t),r=new e({el:i,model:new f});i.addClass("initialized")})}},i.getVariantMappings=function(i){var u=n(".variant-selector"),f={},e,o=[],s,r;if(!t.hasOwnProperty(i))for(r=0;r0?this.getSearchResultsData(n):this.getEndpointAndSearch(n)},getSearchResultsData:function(i){var s=t.parseHashParameters(window.location.hash),h=this,a,c,v,y,o,e,l;_.each(r,function(r){if((o=r.get("dataProperties").sig!==null?encodeURIComponent(r.get("dataProperties").sig):"",c=o!==""?o+"_e":"e",r.get("dataProperties").autoFireSearch||s&&t.isSignaturePresentInHash(s,o))&&(a=r.get("dataProperties").defaultSortOrder,v=r.get("dataProperties").p,y=r.get("dataProperties").v,typeof i=="undefined"||!i.hasOwnProperty("singleRequestMode")||i.singleRequestMode==o)){if(s=h.getDefaultDefaultPageSize(o,v,s),s.hasOwnProperty("l")&&s.l===""&&(s.l=r.get("dataProperties").l),e=n.extend({},r.get("dataProperties"),s),e=n.extend(e,i),e.hasOwnProperty("loadMore")){r.set("loadMore",!0);delete e.loadMore;var p=r.get("loadMoreOffset")+e.p;r.set("loadMoreOffset",p);e[c]=p}else r.get("loadMoreOffset")&&(e.p!==0&&(e.p=e.p*(1+r.get("loadMoreOffset")/e.p),e[c]=0,r.set("loadMoreOffset",0)),delete e.variantChanged);(e=h.getSortOrder(o,e,a),e=h.setVariant(o,e,y),l=u.createSearchUrl(e,o),l)&&(r.checkBlockingRequest()||(r.blockRequests(!0),XA.component.search.vent.trigger("results-loading",r.cid),f.getData({callback:function(n){n.Signature=n.Signature!==null?n.Signature:"";XA.component.search.vent.trigger("results-loaded",{dataCount:n.Count,data:n.Results,pageSize:n.Signature!==""&&e.hasOwnProperty(n.Signature+"_p")?e[n.Signature+"_p"]:e.p,offset:n.Signature!==""&&e.hasOwnProperty(n.Signature+"_e")?e[n.Signature+"_e"]:e.e,searchResultsSignature:n.Signature,loadMore:r.get("loadMore")})},url:l})))}})},getSearchData:function(i){var c=t.parseHashParameters(window.location.hash),r=n.extend({},c,r,i),o=[],s,h,e;for(r=this.getDefaultDefaultPageSize("",0,r),r.hasOwnProperty("o")||typeof XA.component.search.sort=="undefined"||(s=XA.component.search.sort.getFirstSortingOption(),s!==-1&&(r.o=s)),r.endpoint=XA.component.map.getSearchEndpoint(),o=XA.component.map.getSignatures(),e=0;e0&&(r[u]=f[0].defaultPageSize)),r.hasOwnProperty(u)||t==0||(r[u]=t),e={},e[u]=t,i.registerDefault(e),r},setVariant:function(t,r,u){var e=XA.component.search.variantFilter.getVariantMappings(t),f=t!==""?t+"_v":"v",o;return t===""&&n.isEmptyObject(e)||(t===""&&r.hasOwnProperty(f)&&e.hasOwnProperty(r[f])?r[f]=e[r[f]].id:t===""&&e.hasOwnProperty(0)?r[f]=e[0].id:(delete r.v,r[f]=r.hasOwnProperty(f)?e[r[f]].id:e.hasOwnProperty(0)?e[0].id:u)),o={},o[f]=0,i.registerDefault(o),r}}),new e}(jQuery,document);XA.component.search.router=function(n){"use strict";var t={},i,r=!1,u,f;return f=Backbone.Router.extend({routes:{"*params":"checkUrl"},checkUrl:function(n,t){var r=i.parseHashParameters(window.location.hash);XA.component.search.service.getData();r?(t||JSON.stringify(r)!==JSON.stringify(u))&&(XA.component.search.facet.data.filterFacetData(r),u=r,XA.component.search.vent.trigger("hashChanged",r)):(XA.component.search.facet.data.getInitialFacetData(),XA.component.search.vent.trigger("hashChanged",r))}}),t.init=function(){n("body").hasClass("on-page-editor")||r||(i=XA.component.search.query,this.api.routerInstance=new f,Backbone.History.started||Backbone.history.start(),r=!0)},t}(jQuery,document);XA.register("searchRouter",XA.component.search.router);XA.component.search.facet.daterange=function(n){var u={},t,o,i,r,f,e;return i=function(t){return t!==null&&t!==""?n.datepicker.formatDate("yymmdd",t):""},r=function(n){var i=n.substr(0,4),r=n.substr(4,2)-1,u=n.substr(6,2),t=new Date(i,r,u);if(n!==""){if(t.getFullYear()==i&&t.getMonth()==r&&t.getDate()==u)return t;throw"Invalid date: "+n;}},f=Backbone.Model.extend({defaults:{dataProperties:{},sig:[]}}),e=XA.component.search.baseView.extend({initialize:function(){this.properties=this.$el.data().properties;this.model&&(this.model.set({dataProperties:this.properties}),this.model.set("sig",this.translateSignatures(this.properties.searchResultsSignature,this.properties.f)));this.model.on("change",this.render,this);XA.component.search.vent.on("hashChanged",this.updateComponent.bind(this))},events:{"change .startDate":"updateFacet","change .endDate":"updateFacet","click .bottom-remove-filter, .clear-filter":"clearFilter"},render:function(){var h=parseInt(this.model.get("dataProperties").fromDateDefaultOffset),c=parseInt(this.model.get("dataProperties").toDateDefaultOffset),u=this.model.get("dataProperties").fromDateDisplayFormat,f=this.model.get("dataProperties").toDateDisplayFormat,l=this.model.get("dataProperties").fromDateMonthsShown,a=this.model.get("dataProperties").toDateMonthsShown,w=this.model.get("dataProperties").fromDatePastDays,b=this.model.get("dataProperties").toDateFutureDays,k=this.model.get("dataProperties").fromDateVisible,d=this.model.get("dataProperties").toDateVisible,v=this.$el.find(".startDate"),y=this.$el.find(".endDate"),o=t.parseHashParameters(window.location.hash),e=this.model.get("sig"),g=n("html").attr("lang")?n("html").attr("lang"):"",p=this.$el.closest(".overlay-inner").length,s,i;for(f&&(f=f.replace(/yy/g,"y")),u&&(u=u.replace(/yy/g,"y")),k&&v.datepicker({dateFormat:u,changeMonth:l,changeYear:l,minDate:w?h!=""?-1*h:new Date(1900,1,1):new Date,beforeShow:p?this.overrideZIndex:undefined}),d&&y.datepicker({dateFormat:f,changeMonth:a,changeYear:a,maxDate:b?c!=""?c:new Date(2100,1,1):new Date,beforeShow:p?this.overrideZIndex:undefined}),$xa.datepicker.setDefaults($xa.datepicker.regional[g]),i=0;i span"),n=this.$el.find(".startDate"),r=this.$el.find(".endDate"),f=n.length>0?n.datepicker("getDate"):null,e=r.length>0?r.datepicker("getDate"):null,o=this.model.get("sig");t.updateHash(this.updateSignaturesHash(o,i(f)+"|"+i(e),{}));u.addClass("has-active-facet")},clearFilter:function(){var f=this.model.get("dataProperties"),o=this.$el.find(".facet-heading > span"),r=t.parseHashParameters(window.location.hash),u=this.model.get("sig"),e=!1,n,i;for(o.removeClass("has-active-facet"),i=0;i span");n.length!==0&&i(n.datepicker("getDate"))!==t?(n.datepicker("setDate",r(t)),u.addClass("has-active-facet")):t===""&&n.datepicker("setDate",null)},overrideZIndex:function(){setTimeout(function(){var t=n(".ui-datepicker"),i=t.attr("style");t.attr("style",i+"z-index: 10000 !important")},0)}}),u.init=function(){if(!n("body").hasClass("on-page-editor")){t=XA.component.search.query;o=XA.component.search.url;var i=n(".facet-date-range:not(.initialized)");_.each(i,function(t){var i=n(t),r=new f,u=new e({el:i,model:r});u.render();i.addClass("initialized")})}},u}(jQuery,document);XA.register("facetDateRange",XA.component.search.facet.daterange)