I have the following that works fine for one page but I want to make it available for 2 more pages:
var dynamicPropertyOverviewController = (function(){
var currentPage = $('#dynamicPropertyOverview');
function init(){
if(checkMobileAndTabletVisibility.isTabletView()){
if(dynamicPropertyController.isDynamicPropertyOverviewWithAvailability(currentPage)){
dynamicPropertyController.addSearchModalMobileTrigger();
if(dynamicPropertyController.isSearchBarNotHidden()){
dynamicPropertyController.hideSearchBarDisplayPill(currentPage);
}
}
}
else{
dynamicPropertyController.addSearchBarDesktopTrigger();
}
}
return{
init: init
}
})();
"currentPage" var will determine where this init is going to be applied.
This is just to have a better idea of where all these functions come from:
var dynamicPropertyController = (function() {
var searchBarModalTrigger = 'js-open-mobile-search';
function isDynamicPropertyOverviewWithAvailability(page){
return page.length && !$('.property-not-available').length;
}
function hideSearchBarDisplayPill(page){
page.addClass('hide-search-form');
$('.check-prices').addClass('display-pill');
}
function addSearchModalMobileTrigger(){
$('.edit-search-link').removeClass('display-searchBar').addClass(searchBarModalTrigger);
}
How can I make
function addSearchBarDesktopTrigger(){
$('.edit-search-link').removeClass(searchBarModalTrigger).addClass('display-searchBar');
}
function isSearchBarNotHidden(){
return !$('.hide-search-form').length;
}
return {
isDynamicPropertyOverviewWithAvailability: isDynamicPropertyOverviewWithAvailability,
hideSearchBarDisplayPill: hideSearchBarDisplayPill,
addSearchModalMobileTrigger: addSearchModalMobileTrigger,
addSearchBarDesktopTrigger: addSearchBarDesktopTrigger,
isSearchBarNotHidden: isSearchBarNotHidden
}
})();
How can I make "dynamicPropertyOverviewController" so that I can just pass one variable and use it across 3 different pages?
Aucun commentaire:
Enregistrer un commentaire