File: D:/HostingSpaces/ZelfVerkopen/zelfverkopen.nl/resources/assets/js/site/tipsHandler.js
var TipsHandler = {
tipDescriptionRow : '',
tipGroupDescriptions : '',
tipSelectors : '',
tipListRow : '',
tipLists : '',
tipActiveSlug : '',
/*
* Initialize Property Filter Handling
* If view has Property Filters Form add the event event listeners and add the filters
*/
init : function () {
TipsHandler.tipDescriptionRow = document.getElementById('tips-description-row');
TipsHandler.tipListRow = document.getElementById('tip-lists-row');
if(isset(TipsHandler.tipDescriptionRow) && isset(TipsHandler.tipListRow)){
TipsHandler.tipSelectors = TipsHandler.tipDescriptionRow.querySelectorAll('.tip-group-selector ul li');
TipsHandler.tipGroupDescriptions = TipsHandler.tipDescriptionRow.querySelectorAll('.tip-group-descriptions .tip-group-description');
TipsHandler.tipLists = TipsHandler.tipListRow.querySelectorAll('.tip-list');
var tipSelectorsLength = TipsHandler.tipSelectors.length;
for(var i = 0; i < tipSelectorsLength; i++){
TipsHandler.tipSelectors[i].addEventListener('click', function () {
TipsHandler.tipActiveSlug = this.getAttribute('data-slug');
TipsHandler.setTipGroup(this.getAttribute('data-tips-group'));
});
}
}
},
setTipGroup : function (tipGroup) {
var tipSelectorsLength = TipsHandler.tipSelectors.length;
for(var t = 0; t < tipSelectorsLength; t++){
var loopTipSelector = TipsHandler.tipSelectors[t];
if(loopTipSelector.getAttribute('data-tips-group') === tipGroup) loopTipSelector.classList.add('active');
else loopTipSelector.classList.remove('active');
}
// Set tip group description
var tipGroupDescriptionsLength = TipsHandler.tipGroupDescriptions.length;
for(var i = 0; i < tipGroupDescriptionsLength; i++){
var loopTipGroup = TipsHandler.tipGroupDescriptions[i];
if(loopTipGroup.getAttribute('data-tips-group') === tipGroup) loopTipGroup.classList.add('active');
else loopTipGroup.classList.remove('active');
}
// Set tip list
var tipListsLength = TipsHandler.tipLists.length;
for(var j = 0; j < tipListsLength; j++){
var loopTipList = TipsHandler.tipLists[j];
if(loopTipList.getAttribute('data-tips-group') === tipGroup) loopTipList.classList.add('active');
else loopTipList.classList.remove('active');
}
var newUrl = updateQueryString('tip', TipsHandler.tipActiveSlug, null);
// window.location.href = newUrl;
window.history.pushState("", "", newUrl);
// console.log(newUrl);
}
};
TipsHandler.init();