/****************************************************** * * * Async Google Maps - jQuery Plugin * * * * Purpose: This project contains a simple and * * full configurable jQuery plugin which * * asynchronously loads one or multiple * * Google Maps instances located on a * * page. The load is triggered when the * * map is scrolled into viewport. * * * * Author: Andreas Kar (thex) * * Repository: https://git.io/JvD8G * * * ******************************************************/ !function(a){var i;a.fn.asyncGoogleMaps=function(n){(i=a.extend(!0,{},a.fn.asyncGoogleMaps.defaults,n)).containers=this,i.setHeight(),i.attachSpinner(),i.triggerAsyncLoad(),i.checkAndLoad()},a.fn.asyncGoogleMaps.defaults={offset:0,fixHeight:!1,spinner:{attach:!1,remove:!1,type:"included",spinnerClass:"async-gmaps-spinner",bsSpinnerClass:"spinner-border",customSpinner:"",delay:1e4},isInViewport:function(){var n=a(this).offset().top,e=n+a(this).outerHeight(),t=a(window).scrollTop(),s=t+a(window).height();return t").addClass(e.bsSpinnerClass+" "+e.spinnerClass).attr("role","status")).prepend(a("").addClass("sr-only").html("Loading...")):"included"==e.type?n=a("
").addClass("simple-spinner "+e.spinnerClass).attr("role","status"):"custom"==e.type&&(n=a(e.customSpinner).addClass(e.spinnerClass)),a(this).parent().prepend(n)})},triggerAsyncLoad:function(){a(window).on("resize scroll",function(){i.checkAndLoad()})},checkAndLoad:function(){a(i.containers).each(function(){var n=a(this);!n.attr("src")&&n.attr("data-src")&&i.isInViewport.call(n)&&(i.beforeLoad.call(n),n.attr("src",n.attr("data-src")),i.spinner.remove&&i.removeSpinner.call(n),i.afterLoad.call(n))})},beforeLoad:function(){},afterLoad:function(){}}}(jQuery);