{"version":3,"sources":["../assets/scripts/template.js"],"names":["$","sortTheEvents","$response","sort","a","b","Date","start_date","createFilterButtons","selector","target","filterArray","buttonContainer","each","theText","this","innerText","inArray","push","i","value","buttonNode","html","appendTo","getCookie","name","cookie","document","prefix","begin","indexOf","end","length","unescape","substring","$loading","hide","ajaxStart","show","ajaxStop","results","feeds","f","feed","ajax","type","url","dataType","error","console","log","success","when","apply","done","blogPosts","arguments","values","merged","merge","events","len","theTemplateScript","theTemplate","Handlebars","compile","theCompiledHtml","addClass","on","removeClass","delegate","theFilter","find","closest","toggleClass","expirationDate","setMonth","getMonth","toGMTString","jQuery"],"mappings":"CAAA,SAAAA,GAmBA,QAAAC,GAAAC,GACAA,EAAAC,KAAA,SAAAC,EAAAC,GAGA,MAFA,IAAAC,MAAAF,EAAAG,YACA,GAAAD,MAAAD,EAAAE,cA2FA,QAAAC,GAAAC,EAAAC,GACA,GAAAC,MACAC,EAAAZ,EAAA,IAAAU,EAGAV,GAAAa,KAAAb,EAAAS,GAAA,WACA,GAAAK,GAAAd,EAAAe,MAAA,GAAAC,WAEA,IAAAhB,EAAAiB,QAAAH,EAAAH,IAAAA,EAAAO,KAAAJ,KAIAd,EAAAa,KAAAF,EAAA,SAAAQ,EAAAC,GACA,GAAAC,GAAArB,EAAA,yCAAAoB,EAAA,KACAC,GAAAC,KAAAF,GACAC,EAAAE,SAAAX,KAqCA,QAAAY,GAAAC,GACA,GAAAC,GAAAC,SAAAD,OACAE,EAAAH,EAAA,IACAI,EAAAH,EAAAI,QAAA,KAAAF,EACA,KAAA,GAAAC,GAEA,GAAA,IADAA,EAAAH,EAAAI,QAAAF,IACA,MAAA,UACA,CACAC,GAAA,CACA,IAAAE,GAAAJ,SAAAD,OAAAI,QAAA,IAAAD,IACA,GAAAE,IACAA,EAAAL,EAAAM,QAGA,MAAAC,UAAAP,EAAAQ,UAAAL,EAAAD,EAAAI,OAAAD,KA5KA,WACA,GAAAI,GAAAnC,EAAA,YAAAoC,MACApC,GAAA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aAKAxB,EAAA,QAAAmE,SAAA,gBAGAnE,EAAA,iBAAAoE,GAAA,QAAA,WACA,IAAA,GAAAzC,SAAAD,OAAAI,QAAA,YAAA,CACAmB,QAAAC,IAAA,aACA,IAAAyB,GAAA,GAAArE,KACAqE,GAAAC,SAAAD,EAAAE,WAAA,GACAlD,SAAAD,OAAA,gCAAAiD,EAAAG,cAKA,MAFAtD,EAAA,aAKAxB,EAAA,QAAAmE,SAAA,oBAGA,CACAlB,QAAAC,IAAA,YACA,IAAAyB,GAAA,GAAArE,KACAqE,GAAAC,SAAAD,EAAAE,WAAA,GACAlD,SAAAD,OAAA,6BAAAiD,EAAAG,iBAIA9E,EAAA,iBAAAoE,GAAA,QAAA,WACA,GAAAO,GAAA,GAAArE,KACAqE,GAAAC,SAAAD,EAAAE,WAAA,GACAlD,SAAAD,OAAA,6BAAAiD,EAAAG,cACA9E,EAAA,QAAAqE,YAAA,mBAkBAU","file":"template.js","sourcesContent":["(function($) {\r\n\r\n\r\n\r\n\r\n\r\n// Loading Animation\r\nfunction loadingAnimation() {\r\n var $loading = $('.lds-css').hide();\r\n $(document)\r\n .ajaxStart(function () {\r\n $loading.show();\r\n })\r\n .ajaxStop(function () {\r\n $loading.hide();\r\n });\r\n}\r\nloadingAnimation();\r\n// Sorting the events for starting date\r\nfunction sortTheEvents($response) {\r\n $response.sort(function compare(a, b) {\r\n var dateA = new Date(a.start_date);\r\n var dateB = new Date(b.start_date);\r\n return dateA - dateB;\r\n });\r\n}\r\n\r\n \r\n// calls the provided url and returns a reference to the Ajax call\r\nfunction fetchBlogPosts(feed) {\r\n return $.ajax({\r\n type: 'GET',\r\n url: (feed),\r\n dataType: 'json',\r\n error: function () {\r\n console.log('Unable to load feed, Incorrect path or invalid feed');\r\n },\r\n success: function () {}\r\n });\r\n }\r\n \r\n var results = [];\r\n var feeds = [\r\n 'https://de.safestart.com/wp-json/tribe/events/v1/events/?per_page=50',\r\n 'https://fr.safestart.com/wp-json/tribe/events/v1/events/?per_page=50',\r\n 'https://es.safestart.com/wp-json/tribe/events/v1/events/?per_page=50',\r\n 'https://it.safestart.com/wp-json/tribe/events/v1/events/?per_page=50',\r\n 'https://uk.safestart.com/wp-json/tribe/events/v1/events/?per_page=50'\r\n ];\r\n \r\n // store the reference to the Ajax feed for later usage\r\n for (f in feeds) {\r\n results.push(fetchBlogPosts(feeds[f])); \r\n }\r\n\r\n \r\n // invoke each function stored in the result array and proceed when they are all done\r\n $.when.apply(this, results).done(function () {\r\n \r\n var blogPosts = [];\r\n \r\n // fetch the result from each arg\r\n // each arg contains the result of one succes ajax function.\r\n // in this case, three arguments exist, one for each ajax call.\r\n for (var i = 0; i < arguments.length; i++) {\r\n \r\n // retrieve the entries from the argument parameter\r\n values = arguments[i][0];\r\n\r\n \r\n // push the retrieved value to a global function variable, which we can.\r\n // this function is processed synchronously, when all ajax calls have been completed\r\n blogPosts.push(values);\r\n\r\n };\r\n\r\n var merged = [];\r\n // merge the arrays\r\n for (var i = 0; i < blogPosts.length; i++) {\r\n $.merge(merged, blogPosts[i].events);\r\n };\r\n\r\n var obj = {};\r\n len = merged.length;\r\n // for ( var i=0; i < len; i++ ) {\r\n // obj[merged[i]['title']] = merged[i];\r\n // }\r\n //\r\n var thingsNew = [];\r\n // for ( var key in obj )\r\n // thingsNew.push(obj[key]);\r\n\r\n sortTheEvents(merged);\r\n console.log(merged);\r\n var theTemplateScript = $(\"#address-template\").html();\r\n\r\n // Compile the template\r\n var theTemplate = Handlebars.compile(theTemplateScript);\r\n\r\n // Pass our data to the template\r\n var theCompiledHtml = theTemplate(merged);\r\n\r\n // Add the compiled html to the page\r\n $('.content-placeholder').html(theCompiledHtml);\r\n\r\n \r\n });\r\n\r\n\r\n\r\n \r\n\r\n // Create Filterbuttons\r\n function createFilterButtons(selector, target) {\r\n var filterArray = [],\r\n buttonContainer = $('.' + target);\r\n \r\n \r\n $.each($(selector), function() {\r\n var theText = $(this)[0].innerText;\r\n //filterArray.push(theText);\r\n if($.inArray(theText, filterArray) === -1) filterArray.push(theText);\r\n })\r\n //return filterArray;\r\n //console.log(filterArray);\r\n $.each( filterArray, function(i, value){\r\n var buttonNode = $( '
  • ' );\r\n buttonNode.html( value );\r\n buttonNode.appendTo( buttonContainer ); \r\n })\r\n }\r\n\r\n$(document).ajaxStop(function () {\r\n // Get all Categories in an array\r\n // Collect all filterable items\r\n createFilterButtons('.categories.filterable span', 'categoriebuttons'); \r\n createFilterButtons('.country.filterable span', 'countrybuttons'); \r\n $('.hiddenbutton').addClass('showthebutton');\r\n});\r\n\r\n// Click function for showing all\r\n$('.hiddenbutton').on('click', function(){\r\n $('.eventlist li').show();\r\n $('.filterbutton').removeClass('activefilterbutton');\r\n})\r\n// Click function for filtering\r\n$(document).delegate('.filterbutton','click',function() {\r\n var theFilter = $(this)[0].innerText;\r\n $('.filterbutton').removeClass('activefilterbutton');\r\n $('.eventlist li').show();\r\n $('.eventlist li').hide();\r\n $('.eventlist li').find(\"[data-filtertarget='\" + theFilter + \"']\").closest('li').show();\r\n $('.filterbutton').removeClass('activebutton');\r\n $(this).toggleClass('activefilterbutton');\r\n\r\n});\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n// Cookie and Layout Stuff\r\n\r\nfunction getCookie(name) {\r\n var cookie = document.cookie;\r\n var prefix = name + \"=\";\r\n var begin = cookie.indexOf(\"; \" + prefix);\r\n if (begin == -1) {\r\n begin = cookie.indexOf(prefix);\r\n if (begin != 0) return null;\r\n } else {\r\n begin += 2;\r\n var end = document.cookie.indexOf(\";\", begin);\r\n if (end == -1) {\r\n end = cookie.length;\r\n }\r\n }\r\n return unescape(cookie.substring(begin + prefix.length, end));\r\n} \r\n\r\nvar myCookie = getCookie(\"yourName\");\r\n \r\n if (myCookie == null) {\r\n \r\n } else {\r\n $('body').addClass('listenlayout');\r\n }\r\n\r\n$('#listenlayout').on('click', function() { \r\n if (document.cookie.indexOf('yourName') == -1 ) {\r\n console.log('Yes Cookie');\r\n var expirationDate = new Date;\r\n expirationDate.setMonth(expirationDate.getMonth()+1);\r\n document.cookie = \"yourName=listactive; expires=\" + expirationDate.toGMTString();\r\n //window.location.reload();\r\n \r\n var myCookie = getCookie(\"yourName\");\r\n \r\n if (myCookie == null) {\r\n \r\n } else {\r\n $('body').addClass('listenlayout');\r\n }\r\n }\r\n else {\r\n console.log('No cookie');\r\n var expirationDate = new Date;\r\n expirationDate.setMonth(expirationDate.getMonth()-1);\r\n document.cookie = \"yourName=expired; expires=\" + expirationDate.toGMTString();\r\n }\r\n})\r\n\r\n$('#kachellayout').on('click', function() { \r\n var expirationDate = new Date;\r\n expirationDate.setMonth(expirationDate.getMonth()-1);\r\n document.cookie = \"yourName=expired; expires=\" + expirationDate.toGMTString();\r\n $('body').removeClass('listenlayout');\r\n})\r\n\r\n\r\n/* var eventlist = $('.eventlist');\r\neventlist.addClass('listenlayout'); */\r\n\r\n/* function whichLayout() {\r\n \r\n if (document.cookie.indexOf('yourName') > -1 ) {\r\n console.log('Its here');\r\n \r\n //eventlist.addClass('listenlayout');\r\n }\r\n}\r\nwhichLayout(); */\r\n\r\n\r\n})( jQuery );\r\n\r\n \r\n\r\n"],"sourceRoot":"assets/scripts/"}