A medical eye patch is a bandage that covers one eye as a treatment for a variety of eye concerns, such as amblyopia, a condition in which one eye is weaker than the other. For this and similar cases, the patch is placed over the stronger eye, forcing the brain to use the weaker eye in hopes of strengthening the nerve pathways and correcting muscle imbalances or an uneven surface curve.1 While amblyopia may be the most common reason to wear an ey
...
+ Read More
'; productList.after(div); this.replaceWithUpdate( data.bottomCmsBlock, this.qs('.amshopby-filters-bottom-cms'), 'amshopby-filters-bottom-cms' ); } //top nav already exist into categoryProducts if (!data.categoryProducts || data.categoryProducts.indexOf('block-filter-top') === -1) { if (!this.qs(this.selectors.top_navigation)) { const navNode = document.createElement('div'), topNavNode = document.createElement('div'), maincontent = this.qs('.column.main'); let childNode; navNode.className = 'catalog-topnav amasty-catalog-topnav'; topNavNode.className = 'block-filter-top'; navNode.appendChild(topNavNode); if (this.qs('.search.results')) { childNode = this.qs('.search.results'); } else { childNode = this.qs('#amasty-shopby-product-list'); } if (childNode.parentElement !== maincontent) { return; } maincontent.insertBefore(navNode, childNode); } this.replaceWithUpdate( data.navigationTop, this.qs(this.selectors.top_navigation), 'top_navigation' ); } }, replaceWithUpdate(content, $element, className) { if (content && $element) { const parent = $element.parentNode, regex = /
'+ ''; if (this.qs('.amwidget-children-categories')) { childNode = this.qs('.amwidget-children-categories').parentNode; } maincontent.insertBefore(catNode, childNode); } } const imageElement = this.qs('.category-image'), descrElement = this.qs('.category-description'); if (data.image) { this.replaceWithUpdate( data.image, imageElement, 'category-image' ); } else { if (imageElement) { imageElement.innerHTML = ''; } } if (data.description) { this.replaceWithUpdate( data.description, descrElement, 'category-description' ); } else { if (descrElement) { descrElement.innerHTML = ''; } } this.qs('title').innerHTML = data.title; if (data.categoryData) { let categoryViewSelector = '.category-view'; const nodeT = document.createElement('div'); nodeT.innerHTML = data.categoryData; this.qs(categoryViewSelector).innerHTML = ''; this.replaceWithUpdate( nodeT.querySelector(categoryViewSelector).innerHTML, this.qs(categoryViewSelector + ' div'), 'category-view-data' ); } }, /** * @public * @return {Object} */ getProductBlock() { let $productsWrappers = this.qsa(this.selectors.products_wrapper), $productsWrapper = $productsWrappers[$productsWrappers.length - 1]; if ($productsWrapper.closest('.search.results')) { $productsWrapper = $productsWrapper.closest('.search.results'); } return $productsWrapper; }, scrollUpEvent() { const productList = this.qs(this.selectors.products_wrapper), topNavBlock = this.qs(this.selectors.top_nav); if (this.scrollUp && productList) { const top = this.scrollUp === 1 ? (topNavBlock ? topNavBlock.offsetTop : productList.offsetTop) : 0; window.scrollTo({ top: top, behavior: 'smooth' }) } }, moveTopFiltersToSidebar() { if (!this.qs(this.selectors_top_filters.sidebarList)) { const blockClass = this.qs(this.selectors_top_filters.layeredFilter) ? this.selectors_top_filters.layeredFilter : this.selectors_top_filters.blockFilter, $element = document.querySelector(this.selectors.topNav + ' ' + blockClass); if ($element) { const $sidebar = this.qs(this.selectors_top_filters.sidebar), filterOptions = $element.querySelectorAll('.filter-option'); filterOptions.forEach(filter => { const el = filter.cloneNode(true), input = el.querySelector('[type="radio"], [type="checkbox"]'); if (input) { const name = input.getAttribute('name'); el.classList.add('from-top'); if (!$sidebar.querySelectorAll('[name="'+ name +'"]').length) { $sidebar.querySelector('#layered-filter-block-content').append(el); } } }); } return; } }, /** * @public * @returns {void} */ removeTopFiltersFromSidebar() { const $sidebar = this.qs(this.selectors_top_filters.sidebar); if ($sidebar) { $sidebar.querySelectorAll('.from-top').forEach(filter => { filter.remove(); }); } }, qs(selector) { return document.querySelector(selector); }, qsa(selector) { return document.querySelectorAll(selector); }, stopEvents(e) { e.stopPropagation(); e.preventDefault(); }, serializeForm(form) { const data = new FormData(form) let array = []; for (let [key, value] of data) { array.push({ name: key, value: value }); } return array; }, excludingElement(elements, excluded) { let clearing = [], excludedSelector = this.qs(excluded); elements.forEach(element => { if (element !== excludedSelector) { clearing.push(element); } }); return clearing; }, /** * @public * @param {String} text * @return {String} */ escapeHtml(text) { var map = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }; return text.replace(/[&<>"']/g, (m) => { return map[m]; }); }, /** * @public * @param {String} link * @param {Boolean} [clearFilter] * @return {void} */ apply(link, clearFilter) { let linkParam; try { this.response = null; this.options.isAjax = true; linkParam = clearFilter ? link : null; link = this.element?.closest('.price-ranges') && link.includes('?') ? link + '&price-ranges=1' : link; if (!this.options.collectFilters && this.options.isAjax === true) { this.prepareTriggerAjax(this.element, linkParam, clearFilter); } else { // eslint-disable-next-line no-lonely-if if (this.options.collectFilters === 1) { this.prepareTriggerAjax(this.element, linkParam); } else { window.location = link; } } } catch (e) { window.location = link; } }, fixDubbleValue(link) { let input = link.closest('div').querySelector('input'); if (this.qsa('*[value="'+input.value+'"][name="'+input.getAttribute('name')+'"]').length > 1) { this.qsa('*[value="'+input.value+'"][name="'+input.getAttribute('name')+'"]').forEach(filter => { if (filter !== input) { if (filter.getAttribute('type') === 'radio') { filter.closest('.am-filter').querySelectorAll('input').forEach(option => { option.checked = false; }); } else { filter.checked = false; } } }); } if (input.getAttribute('type') !== 'radio' && !input.checked && !this.submitByClick) { let value = input.getAttribute('value'), name = input.getAttribute('name').replace('amshopby[',''); name = name.replace('][]', ''); let removeItem = this.qs('.amshopby-remove-item[data-container="'+ name +'"][data-value="'+ value +'"]'); if (removeItem) { removeItem.remove(); } } }, setSwatchToProducts(swatchId, attributeID) { setTimeout(() => { const productList = document.getElementById('amasty-shopby-product-list'); if (productList) { const swatches = productList.querySelectorAll('[name="super_attribute['+ attributeID +']"][value="' + swatchId + '"]'), event = new Event('change'); swatches.forEach(swatch => { if (!swatch.checked) { swatch.dispatchEvent(event); } }); } }, 1500); }, setSwatchMassToProducts(swatchIds, attributeID) { const swatches = swatchIds.split(','); this.massSwatchSet(swatches, attributeID); window.onload = () => { setTimeout(() => { this.massSwatchSet(swatches, attributeID); }, 1000); } }, massSwatchSet(swatches, attributeID) { swatches.map(swatch => { this.setSwatchToProducts(swatch, attributeID); }); }, insertAfter(newNode, existingNode) { existingNode.parentNode.insertBefore(newNode, existingNode.nextSibling); }, removeInputByName(input) { let name = input.getAttribute('name').replace('amshopby[',''); name = name.replace('][]', ''); this.qs('.amshopby-remove-item[data-container="'+ name +'"]').remove(); }, eventListeners: { ['@amshopby-submit-filters.window'](event) { let self = this, data = event.detail.data, clearUrl = self.options.clearUrl, isSorting = event.detail.isSorting, pushState = !self.submitByClick; if (typeof data.clearUrl !== 'undefined') { clearUrl = data.clearUrl; delete data.clearUrl; } if (self.prevCall) { this.controller.abort(); this.signal = null; this.controller = new AbortController(); this.signal = this.controller.signal; } let dataAndUrl = data.slice(0); dataAndUrl.push(clearUrl ? clearUrl : self.clearUrl); const cacheKey = JSON.stringify(dataAndUrl); self.cacheKey = cacheKey; if (self.cached[cacheKey]) { let response = self.cached[cacheKey]; if (pushState || isSorting) { if (response.newClearUrl && response.newClearUrl.indexOf('?p=') == -1 && response.newClearUrl.indexOf('&p=') == -1 ) { self.options.clearUrl = response.newClearUrl; } window.history.pushState({url: response.url}, '', response.url); self.reloadHtml(response); } else { window.dispatchEvent(new CustomEvent('amApplyButtonData', { detail: { count: response.productsCount, disabled: false } })); } return; } self.prevCall = self.callAjax(clearUrl, data, pushState, cacheKey, isSorting); }, ['@amSliderValuesUpdated.window'](event) { this.apply(event.detail.searchParams); }, ['@amApplyButton.window'](event) { let valid = true, element = event.detail.element, navigationSelector = event.detail.navigationSelector, navigation = element.closest(navigationSelector), cachedValues = this.cached[this.cacheKey], cachedKey = this.response, response = cachedValues ? cachedValues : cachedKey; if (!response) { return } if (response.isDisplayModePage || (!this.isAjaxSettingEnabled && this.submitByClick)) { window.location.href = response.url; return; } if (!response && this.startAjax) { this.showButtonClick = true; window.dispatchEvent(new CustomEvent('amApplyButtonData', { detail: { count: '', disabled: false } })); } if (valid && response) { window.dispatchEvent(new CustomEvent('amApplyButtonData', { detail: { count: '', disabled: false } })); window.history.pushState({url: response.url}, '', response.url); this.reloadHtml(response); this.response = false; this.showButtonClick = false; } window.onpopstate = function () { location.reload(); }; }, ['@amRemoveElement.window'](event) { const link = event.detail.element; if (this.isAjax) { const currentFilterItem = link.closest('.amshopby-remove-item'), filter = { attribute: currentFilterItem.getAttribute('data-container'), value: this.escapeHtml(currentFilterItem.getAttribute('data-value')) }; this.currentFilters.push(filter); this.element = undefined; try { window.dispatchEvent( new CustomEvent( 'amSetButtonPosition', { detail: { element: link } } ) ); this.setDefault(filter.attribute, filter.value); if (!this.submitByClick) { link.closest('.amshopby-remove-item').remove(); } this.prepareTriggerAjax(null, null, true); } catch (e) { window.location = link.getAttribute('href'); } } else { window.location.href = link.getAttribute('href'); } }, ['@amSwatchClick.window'](event) { const link = event.detail.element; if (this.isAjax) { const href = link.getAttribute('href'), input = link.closest('div').querySelector('input'); this.element = link; input.checked = !input.checked; if (input.getAttribute('type') === 'radio') { let ring = link.closest('.am-shopby-form').querySelector('.ring'); if (ring) { this.setSwatchBorder(ring); if (!this.submitByClick) { this.removeInputByName(input); } if (input.checked) { this.setSwatchBorder(link); } } else { this.setSwatchBorder(link); } } else { this.setSwatchBorder(link); } if (this.isFinderAndCategory(link)) { location.href = href; return; } setTimeout(() => { this.fixDubbleValue(link); window.dispatchEvent( new CustomEvent( 'amSetButtonPosition', { detail: { element: link } } ) ); this.apply(href); }, 10); } else { window.location.href = link.getAttribute('href'); } }, ['@amFilterElementClick.window'](event) { let filterElement = event.detail.element; if (!filterElement.classList.contains('item')) { filterElement = filterElement.closest('div'); } const checkbox = filterElement.querySelector('input'), checkboxLink = filterElement.querySelector('a'), href = checkboxLink.getAttribute('href'); if (!this.submitByClick && checkbox.checked && checkbox.getAttribute('type') === 'radio') { this.removeInputByName(checkbox); } this.element = checkboxLink; setTimeout(() => { this.fixDubbleValue(checkboxLink); window.dispatchEvent( new CustomEvent( 'amSetButtonPosition', { detail: { element: checkboxLink } } ) ); if (this.isFinderAndCategory(checkbox)) { location.href = href; return; } this.apply(href); }, 10); }, ['@googleTag.window'](e) { } } } }