By default in SCA websites when clicked on header logo it triggers search button when page is in home page and in mobile view For this we need to extend header logo view and need to use functionality of search button, add required device. Already in source code property is given for desktop so again required device need br added along with that.
_.extend(HeaderView.prototype,initialize: function () {
this.application = this.options.application;
// console.log("test")
Backbone.history.on('all', this.verifyShowSiteSearch, this);
},
toggleSiteSearch: function(ev) {
ev && ev.preventDefault();
// This add a class 'active' to change button color
this.$('[data-action="show-itemsearcher"]').toggleClass('active');
const self = this;
this.application.getLayout().trigger('toggleItemSearcher');
},
verifyShowSiteSearch: function () {
let hash = Backbone.history.getFragment() || '';
hash = hash.indexOf('?') === -1 ? hash : hash.substring(0, hash.indexOf('?'));
var is_home = hash === '' || hash === '/';
// console.log("home", is_home)
if (Utils.getDeviceType() !== 'desktop' && is_home || Utils.getDeviceType() !== 'tablet' && is_home || Utils.getDeviceType() !== 'phone' && is_home) {
this.toggleSiteSearch(null, true);
} else {
// This hide sitesearch when navigate
this.application.getLayout().trigger('hideItemSearcher');
}
}
})