brouilleursdeblanc/assets/js/scripts.min.js

2 lines
33 KiB
JavaScript
Raw Normal View History

function initSearch(){getParameterByName("q")&&(q=decodeURIComponent(getParameterByName("q")),$searchInput.val(q),execSearch(q)),$(document).on("submit",$searchForm,function(a){a.preventDefault(),q=$searchInput.val(),execSearch(q)})}function execSearch(a){(""!=a||allowEmpty)&&(showLoader&&toggleLoadingClass(),getSearchResults(processData()))}function toggleLoadingClass(){$resultsPlaceholder.toggleClass(loadingClass),$foundContainer.toggleClass(loadingClass)}function getSearchResults(a){$.get(jsonFeedUrl,a,"json")}function processData(){return $results=[],function(a){var b=0,c="";$.each(a,function(a,d){if(d.excerpt.toLowerCase().indexOf(q.toLowerCase())>-1||d.title.toLowerCase().indexOf(q.toLowerCase())>-1){var e=populateResultContent($resultTemplate.html(),d);b++,c+=e}}),showLoader&&toggleLoadingClass(),populateResultsString(b),showSearchResults(c)}}function showSearchResults(a){$resultsPlaceholder.html(a)}function populateResultContent(a,b){return a=injectContent(a,b.title,"##Title##"),a=injectContent(a,b.link,"##Url##"),a=injectContent(a,b.excerpt,"##Excerpt##"),a=injectContent(a,b.date,"##Date##")}function populateResultsString(a){$foundTerm.text(q),$foundCount.text(a),$foundContainer.show()}function getParameterByName(a){var b=RegExp("[?&]"+a+"=([^&]*)").exec(window.location.search);return b&&decodeURIComponent(b[1].replace(/\+/g," "))}function injectContent(a,b,c){var d=new RegExp(c,"g");return a.replace(d,b)}!function(a){"use strict";a.fn.fitVids=function(b){var c={customSelector:null};if(!document.getElementById("fit-vids-style")){var d=document.createElement("div"),e=document.getElementsByTagName("base")[0]||document.getElementsByTagName("script")[0],f="&shy;<style>.fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}</style>";d.className="fit-vids-style",d.id="fit-vids-style",d.style.display="none",d.innerHTML=f,e.parentNode.insertBefore(d,e)}return b&&a.extend(c,b),this.each(function(){var b=["iframe[src*='player.vimeo.com']","iframe[src*='youtube.com']","iframe[src*='youtube-nocookie.com']","iframe[src*='kickstarter.com'][src*='video.html']","object","embed"];c.customSelector&&b.push(c.customSelector);var d=a(this).find(b.join(","));d=d.not("object object"),d.each(function(){var b=a(this);if(!("embed"===this.tagName.toLowerCase()&&b.parent("object").length||b.parent(".fluid-width-video-wrapper").length)){var c="object"===this.tagName.toLowerCase()||b.attr("height")&&!isNaN(parseInt(b.attr("height"),10))?parseInt(b.attr("height"),10):b.height(),d=isNaN(parseInt(b.attr("width"),10))?b.width():parseInt(b.attr("width"),10),e=c/d;if(!b.attr("id")){var f="fitvid"+Math.floor(999999*Math.random());b.attr("id",f)}b.wrap('<div class="fluid-width-video-wrapper"></div>').parent(".fluid-width-video-wrapper").css("padding-top",100*e+"%"),b.removeAttr("height").removeAttr("width")}})})}}(window.jQuery||window.Zepto),function(a){var b,c,d,e,f,g,h,i="Close",j="BeforeClose",k="AfterClose",l="BeforeAppend",m="MarkupParse",n="Open",o="Change",p="mfp",q="."+p,r="mfp-ready",s="mfp-removing",t="mfp-prevent-close",u=function(){},v=!!window.jQuery,w=a(window),x=function(a,c){b.ev.on(p+a+q,c)},y=function(b,c,d,e){var f=document.createElement("div");return f.className="mfp-"+b,d&&(f.innerHTML=d),e?c&&c.appendChild(f):(f=a(f),c&&f.appendTo(c)),f},z=function(c,d){b.ev.triggerHandler(p+c,d),b.st.callbacks&&(c=c.charAt(0).toLowerCase()+c.slice(1),b.st.callbacks[c]&&b.st.callbacks[c].apply(b,a.isArray(d)?d:[d]))},A=function(c){return c===h&&b.currTemplate.closeBtn||(b.currTemplate.closeBtn=a(b.st.closeMarkup.replace("%title%",b.st.tClose)),h=c),b.currTemplate.closeBtn},B=function(){a.magnificPopup.instance||(b=new u,b.init(),a.magnificPopup.instance=b)},C=function(){var a=document.createElement("p").style,b=["ms","O","Moz","Webkit"];if(void 0!==a.transition)return!0;for(;b.length;)if(b.pop()+"Transition"in a)return!0;return!1};u.prototype={constructor:u,init:function(){var
d&&(j.innerHTML=b,b="")},_resize:function(){"none"!==a.getComputedStyle(g,null).getPropertyValue("display")?(o(g,{"aria-hidden":"false"}),e.className.match(/(^|\s)closed(\s|$)/)&&(o(e,{"aria-hidden":"true"}),e.style.position="absolute"),this._createStyles(),this._calcHeight()):(o(g,{"aria-hidden":"true"}),o(e,{"aria-hidden":"false"}),e.style.position=f.openPos,this._removeStyles()),f.init()}};var s;return c}(window,document),q,jsonFeedUrl="/search.json",$searchForm=$("[data-search-form]"),$searchInput=$("[data-search-input]"),$resultTemplate=$("#search-result"),$resultsPlaceholder=$("[data-search-results]"),$foundContainer=$("[data-search-found]"),$foundTerm=$("[data-search-found-term]"),$foundCount=$("[data-search-found-count]"),allowEmpty=!0,showLoader=!0,loadingClass="is--loading";$(document).ready(function(){$foundContainer.hide(),initSearch()});var navigation=responsiveNav("#site-nav",{animate:!0,transition:200,label:"<i class='fa fa-bars'></i> Menu",insert:"before",customToggle:"",openPos:"relative",jsClass:"js",init:function(){},open:function(){},close:function(){}});$("html").click(function(){$(navigation.wrapper).hasClass("opened")&&navigation.toggle()}),$("#site-nav").click(function(a){a.stopPropagation()}),$(function(){$("article").fitVids()}),$("a[href$='.jpg'],a[href$='.jpeg'],a[href$='.JPG'],a[href$='.png'],a[href$='.gif']").addClass("image-popup"),$(document).ready(function(){$(".image-popup").magnificPopup({type:"image",tLoading:"Loading image #%curr%...",gallery:{enabled:!0,navigateByImgClick:!0,preload:[0,1]},image:{tError:'<a href="%url%">Image #%curr%</a> could not be loaded.'},removalDelay:300,mainClass:"mfp-fade"})});