Free javascript Hosting


cro-multicolumn-desktop-1.js

Uploaded on Oct 07 2021 17:50 by saifulazr

(function(){


// Assuming the test will be done indepedently
// Cant rely on having other test (cro-filter-prominence) be available
var addStyling = function(){
var style =
'<style type="text/css">'+


// the padding 0 is just to remove px-4 later
'#pageToolbar div:nth-child(2){' +
'padding-left:0;' +
'padding-right:0;' +
'}' +

'#pageToolbar {' +
'text-align:left;' +
'}' +
'</style>';

vwo_$('head').append(style);
}

var overrideMultifacetFunctions = function(){


var simulateFakeScroll = function(){
window.scrollTo(window.pageXOffset, window.pageYOffset - 1);
window.scrollTo(window.pageXOffset, window.pageYOffset + 1);
}

/**
* Sets up the column view at start up. Has a different default based on whether the search is type mattress or not
* Overridden to wait for clone column button exist
*/
multifacet._initColumnView = function() {

simulateFakeScroll()

var path = vwo_$('#pageToolbar').length ? vwo_$('#pageToolbar').data('path') : null;

// if (path == "mattresses") {
// var defaultCol = multifacet.getSearchPref("col_mattress") || 3;
// }
// else {
// var defaultCol = multifacet.getSearchPref("col_default") || 3;
// }

var defaultCol = multifacet.getSearchPref("col_default") || 3;


// don't save cookie again
multifacet._applyColumnView(defaultCol, vwo_$("html"));

};

multifacet.updateSearchPref = function(key, value) {

try{
var searchPref = util.getCookie("FC_SearchPref");

if(!searchPref){ throw new Error('Cookie is empty'); }

searchPref = JSON.parse(searchPref);

}
catch(e){
searchPref = {}
}

searchPref['col_default'] = value;

searchPref = JSON.stringify(searchPref);

// ms s m h d
util.createCookie("FC_SearchPref", searchPref, 1000 * 60 * 60 * 24 * 365);
};
}

/*

Initialization

*/

// require module "multifacet" to call various override functions
moduleController.registerCRO(function(module) {

if(module.initialised){

if(module.name == 'Multifacet'){

vwo_$(document).ready(function(){
addStyling();
overrideMultifacetFunctions();
multifacet._initColumnView()
})


}

}
})

})();

Back to list