UNPKG

@ecomplus/storefront-template

Version:

Reusable & upgradable views and scripts for E-Com Plus storefront

27 lines (22 loc) 589 B
import { isScreenLg, $ } from '@ecomplus/storefront-twbs' const $searchBar = $('#search-bar') if ($searchBar) { $searchBar.on('shown.bs.collapse', () => { $('#search-input').trigger('focus') }) let resizeState const onResize = () => { if (resizeState !== isScreenLg) { if (isScreenLg) { $searchBar.addClass('d-none') $searchBar.collapse('show') } else { $searchBar.collapse('hide') $searchBar.removeClass('d-none') } resizeState = isScreenLg } } window.addEventListener('resize', onResize) onResize() }