ltsecurityinc安防产品在线商城代码
This commit is contained in:
+22
File diff suppressed because one or more lines are too long
+61
@@ -0,0 +1,61 @@
|
||||
define([
|
||||
'jquery',
|
||||
'mage/translate',
|
||||
'jquery-ui-modules/widget',
|
||||
'jquery-ui-modules/core',
|
||||
], function ($, $t) {
|
||||
'use strict';
|
||||
|
||||
$.widget('mage.OXExpand', {
|
||||
options: {
|
||||
isMin: true,
|
||||
maxHeight: 90,
|
||||
more: $t('Show more'),
|
||||
less: $t('Show less'),
|
||||
checkCurrentSize: true
|
||||
},
|
||||
_create: function () {
|
||||
this._create_html();
|
||||
var $expand = this.element.children('.ox-expand'),
|
||||
$expandInner = $expand.children('.ox-expand__inner'),
|
||||
$expandLink = $expand.children('.ox-expand__link');
|
||||
|
||||
$expand.toggleClass('minimized', this.options.isMin).data({
|
||||
'max-height': this.options.maxHeight
|
||||
});
|
||||
$expandInner.attr('aria-expanded', this.options.isMin ? 'false' : 'true')
|
||||
.css('max-height', this.options.isMin ? this.options.maxHeight : '100%');
|
||||
$expandLink.find('.more').html(this.options.more);
|
||||
$expandLink.find('.less').html(this.options.less);
|
||||
},
|
||||
_create_html: function () {
|
||||
if (this.element.children('.ox-expand').length || (this.options.checkCurrentSize && this.options.maxHeight > this.element.height()))
|
||||
return;
|
||||
var content = this.element.html(),
|
||||
new_content = $('<div class="ox-expand">').append(
|
||||
$('<div class="ox-expand__inner">').html(content)
|
||||
).append('<div class="ox-expand__link"><span class="more"></span><span class="less"></span></div>');
|
||||
this.element.html('').append(new_content);
|
||||
},
|
||||
_init: function () {
|
||||
$('body').off('click.OXExpand').on('click.OXExpand', '.ox-expand .ox-expand__link', $.proxy(this._click, this));
|
||||
},
|
||||
_click: function (event) {
|
||||
event.preventDefault();
|
||||
var $this = $(event.currentTarget).closest('.ox-expand').eq(0);
|
||||
this.toggle($this);
|
||||
},
|
||||
toggle: function (expand) {
|
||||
var $expand = expand || this.element.children('.ox-expand'),
|
||||
$expandInner = $expand.children('.ox-expand__inner'),
|
||||
max_height = $expand.data('max-height') || 90,
|
||||
isMin = $expand.hasClass('minimized');
|
||||
|
||||
$expand.toggleClass('minimized', !isMin);
|
||||
$expandInner.attr("aria-expanded", isMin ? "true" : "false")
|
||||
.css('max-height', isMin ? '100%' : max_height);
|
||||
},
|
||||
});
|
||||
|
||||
return $.mage.OXExpand;
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
define([
|
||||
'jquery',
|
||||
'jquery-ui-modules/widget',
|
||||
'jquery-ui-modules/core',
|
||||
'catalogAddToCart'
|
||||
], function ($) {
|
||||
'use strict';
|
||||
|
||||
$.widget('ox.AtloopOwlAddtocart', {
|
||||
options: {
|
||||
},
|
||||
_create: function () {
|
||||
this.element.find('.cloned [data-role=tocart-form]').catalogAddToCart();
|
||||
this.element.on('initialize.owl.carousel initialized.owl.carousel', function (e) {
|
||||
$(this).find('.cloned [data-role=tocart-form]').catalogAddToCart();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return $.ox.AtloopOwlAddtocart;
|
||||
});
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
define([
|
||||
'jquery',
|
||||
'Cynoinfotech_FreeShippingMessage/js/freeshippingmessage',
|
||||
'Magento_Catalog/js/product/view/product-ids-resolver'
|
||||
], function ($, fsm, idsResolver) {
|
||||
return function (catalogAddToCart) {
|
||||
$.widget('mage.catalogAddToCart', catalogAddToCart, {
|
||||
options: {
|
||||
bindSubmit: true,
|
||||
selectorNewElements: "[data-role=tocart-form], .form.map.checkout"
|
||||
},
|
||||
_create: function () {
|
||||
this._super();
|
||||
if (!window.OXNAjaxCatalog) {
|
||||
var __select = this.options.selectorNewElements;
|
||||
$('body').off('contentUpdated.catalogAddToCart').on('contentUpdated.catalogAddToCart', function () {
|
||||
$(__select).catalogAddToCart();
|
||||
});
|
||||
}
|
||||
},
|
||||
_bindSubmit: function () {
|
||||
var self = this;
|
||||
|
||||
if (this.element.data('catalog-addtocart-initialized')) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.element.data('catalog-addtocart-initialized', 1);
|
||||
this.element.off('submit').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
self.submitForm($(this));
|
||||
});
|
||||
},
|
||||
|
||||
disableAddToCartButton: function (form) {
|
||||
this.element.addClass('ox-add-to-cart-loading');
|
||||
this._super(form);
|
||||
},
|
||||
enableAddToCartButton: function (form) {
|
||||
this.element.removeClass('ox-add-to-cart-loading');
|
||||
this._super(form);
|
||||
},
|
||||
/**
|
||||
* @param {jQuery} form
|
||||
*/
|
||||
ajaxSubmit: function (form) {
|
||||
var self = this,
|
||||
productIds = idsResolver(form),
|
||||
formData;
|
||||
|
||||
$(self.options.minicartSelector).trigger('contentLoading');
|
||||
self.disableAddToCartButton(form);
|
||||
formData = new FormData(form[0]);
|
||||
|
||||
window.ajaxCartTransport = false;
|
||||
$.ajax({
|
||||
url: form.attr('action'),
|
||||
data: formData,
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
|
||||
/** @inheritdoc */
|
||||
beforeSend: function () {
|
||||
if (self.isLoaderEnabled()) {
|
||||
$('body').trigger(self.options.processStart);
|
||||
}
|
||||
},
|
||||
|
||||
/** @inheritdoc */
|
||||
success: function (res) {
|
||||
var eventData, parameters;
|
||||
|
||||
$(document).trigger('ajax:addToCart', {
|
||||
'sku': form.data().productSku,
|
||||
'productIds': productIds,
|
||||
'form': form,
|
||||
'response': res
|
||||
});
|
||||
|
||||
if (self.isLoaderEnabled()) {
|
||||
$('body').trigger(self.options.processStop);
|
||||
}
|
||||
|
||||
if (res.backUrl) {
|
||||
eventData = {
|
||||
'form': form,
|
||||
'redirectParameters': []
|
||||
};
|
||||
// trigger global event, so other modules will be able add parameters to redirect url
|
||||
$('body').trigger('catalogCategoryAddToCartRedirect', eventData);
|
||||
|
||||
if (eventData.redirectParameters.length > 0 &&
|
||||
window.location.href.split(/[?#]/)[0] === res.backUrl
|
||||
) {
|
||||
parameters = res.backUrl.split('#');
|
||||
parameters.push(eventData.redirectParameters.join('&'));
|
||||
res.backUrl = parameters.join('#');
|
||||
}
|
||||
|
||||
self._redirect(res.backUrl);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (res.messages) {
|
||||
$(self.options.messagesSelector).html(res.messages);
|
||||
}
|
||||
|
||||
if (res.minicart) {
|
||||
$(self.options.minicartSelector).replaceWith(res.minicart);
|
||||
$(self.options.minicartSelector).trigger('contentUpdated');
|
||||
}
|
||||
|
||||
if (res.product && res.product.statusText) {
|
||||
$(self.options.productStatusSelector)
|
||||
.removeClass('available')
|
||||
.addClass('unavailable')
|
||||
.find('span')
|
||||
.html(res.product.statusText);
|
||||
}
|
||||
self.enableAddToCartButton(form);
|
||||
/*custom code here ajax_call_funtion call*/
|
||||
fsm.ajax_call_funtion();
|
||||
window.ajaxCartTransport = !window.OXAjaxNShowMCart;
|
||||
},
|
||||
|
||||
/** @inheritdoc */
|
||||
error: function (res) {
|
||||
$(document).trigger('ajax:addToCart:error', {
|
||||
'sku': form.data().productSku,
|
||||
'productIds': productIds,
|
||||
'form': form,
|
||||
'response': res
|
||||
});
|
||||
self.enableAddToCartButton(form);
|
||||
},
|
||||
|
||||
/** @inheritdoc */
|
||||
complete: function (res) {
|
||||
if (res.state() === 'rejected') {
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return $.mage.catalogAddToCart;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,154 @@
|
||||
define([
|
||||
'jquery',
|
||||
'Magento_Catalog/js/product/view/product-ids-resolver'
|
||||
], function ($, idsResolver) {
|
||||
return function (catalogAddToCart) {
|
||||
$.widget('mage.catalogAddToCart', catalogAddToCart, {
|
||||
options: {
|
||||
bindSubmit: true,
|
||||
selectorNewElements: "[data-role=tocart-form], .form.map.checkout"
|
||||
},
|
||||
_create: function () {
|
||||
this._super();
|
||||
if (!window.OXNAjaxCatalog) {
|
||||
var __select = this.options.selectorNewElements;
|
||||
$('body').off('contentUpdated.catalogAddToCart').on('contentUpdated.catalogAddToCart', function () {
|
||||
$(__select).catalogAddToCart();
|
||||
});
|
||||
}
|
||||
},
|
||||
_bindSubmit: function () {
|
||||
var self = this;
|
||||
|
||||
if (this.element.data('catalog-addtocart-initialized')) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.element.data('catalog-addtocart-initialized', 1);
|
||||
this.element.off('submit').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
self.submitForm($(this));
|
||||
});
|
||||
},
|
||||
|
||||
disableAddToCartButton: function (form) {
|
||||
this.element.addClass('ox-add-to-cart-loading');
|
||||
this._super(form);
|
||||
},
|
||||
enableAddToCartButton: function (form) {
|
||||
this.element.removeClass('ox-add-to-cart-loading');
|
||||
this._super(form);
|
||||
},
|
||||
/**
|
||||
* @param {jQuery} form
|
||||
*/
|
||||
ajaxSubmit: function (form) {
|
||||
var self = this,
|
||||
productIds = idsResolver(form),
|
||||
productInfo = self.options.productInfoResolver(form),
|
||||
formData;
|
||||
|
||||
$(self.options.minicartSelector).trigger('contentLoading');
|
||||
self.disableAddToCartButton(form);
|
||||
formData = new FormData(form[0]);
|
||||
|
||||
window.ajaxCartTransport = false;
|
||||
$.ajax({
|
||||
url: form.attr('action'),
|
||||
data: formData,
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
|
||||
/** @inheritdoc */
|
||||
beforeSend: function () {
|
||||
if (self.isLoaderEnabled()) {
|
||||
$('body').trigger(self.options.processStart);
|
||||
}
|
||||
},
|
||||
|
||||
/** @inheritdoc */
|
||||
success: function (res) {
|
||||
var eventData, parameters;
|
||||
|
||||
$(document).trigger('ajax:addToCart', {
|
||||
'sku': form.data().productSku,
|
||||
'productIds': productIds,
|
||||
'productInfo': productInfo,
|
||||
'form': form,
|
||||
'response': res
|
||||
});
|
||||
|
||||
if (self.isLoaderEnabled()) {
|
||||
$('body').trigger(self.options.processStop);
|
||||
}
|
||||
|
||||
if (res.backUrl) {
|
||||
eventData = {
|
||||
'form': form,
|
||||
'redirectParameters': []
|
||||
};
|
||||
// trigger global event, so other modules will be able add parameters to redirect url
|
||||
$('body').trigger('catalogCategoryAddToCartRedirect', eventData);
|
||||
|
||||
if (eventData.redirectParameters.length > 0 &&
|
||||
window.location.href.split(/[?#]/)[0] === res.backUrl
|
||||
) {
|
||||
parameters = res.backUrl.split('#');
|
||||
parameters.push(eventData.redirectParameters.join('&'));
|
||||
res.backUrl = parameters.join('#');
|
||||
}
|
||||
|
||||
self._redirect(res.backUrl);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (res.messages) {
|
||||
$(self.options.messagesSelector).html(res.messages);
|
||||
}
|
||||
|
||||
if (res.minicart) {
|
||||
$(self.options.minicartSelector).replaceWith(res.minicart);
|
||||
$(self.options.minicartSelector).trigger('contentUpdated');
|
||||
}
|
||||
|
||||
if (res.product && res.product.statusText) {
|
||||
$(self.options.productStatusSelector)
|
||||
.removeClass('available')
|
||||
.addClass('unavailable')
|
||||
.find('span')
|
||||
.html(res.product.statusText);
|
||||
}
|
||||
self.enableAddToCartButton(form);
|
||||
|
||||
window.ajaxCartTransport = !window.OXAjaxNShowMCart;
|
||||
},
|
||||
|
||||
/** @inheritdoc */
|
||||
error: function (res) {
|
||||
$(document).trigger('ajax:addToCart:error', {
|
||||
'sku': form.data().productSku,
|
||||
'productIds': productIds,
|
||||
'productInfo': productInfo,
|
||||
'form': form,
|
||||
'response': res
|
||||
});
|
||||
self.enableAddToCartButton(form);
|
||||
},
|
||||
|
||||
/** @inheritdoc */
|
||||
complete: function (res) {
|
||||
if (res.state() === 'rejected') {
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return $.mage.catalogAddToCart;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* @author Olegnax
|
||||
* @package Olegnax_Athlete2
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
define([
|
||||
'jquery'
|
||||
], function ($) {
|
||||
return function (orderReview) {
|
||||
$.widget('mage.orderReview', orderReview, {
|
||||
/**
|
||||
* hide ajax loader
|
||||
*/
|
||||
_ajaxComplete: function () {
|
||||
this._super();
|
||||
$('body').trigger('contentUpdated');
|
||||
},
|
||||
});
|
||||
|
||||
return $.mage.orderReview;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,97 @@
|
||||
define([
|
||||
'jquery',
|
||||
'matchMedia',
|
||||
'mage/template',
|
||||
'OXmodal'
|
||||
], function ($, mediaCheck, mageTemplate) {
|
||||
'use strict';
|
||||
|
||||
$.widget('mage.mobileMenu', $.mage.OXmodal, {
|
||||
options: {
|
||||
htmlClass: 'ox-fixed',
|
||||
closeOnEscape: true,
|
||||
overlayClass: 'ox-slideout-shadow',
|
||||
positionSlideout: 'left',
|
||||
triggerTarget: '[data-action="toggle-mobile-nav"]',
|
||||
type: 'slideout',
|
||||
mediaBreakpoint: '(min-width: 1025px)'
|
||||
},
|
||||
_init: function () {
|
||||
this._super();
|
||||
|
||||
mediaCheck({
|
||||
media: this.options.mediaBreakpoint,
|
||||
entry: $.proxy(function () {
|
||||
this._toggleDesktopMode();
|
||||
}, this),
|
||||
exit: $.proxy(function () {
|
||||
this._toggleMobileMode();
|
||||
}, this)
|
||||
});
|
||||
this._on(this.uiDialog, {
|
||||
'swipeleft': $.proxy(function () {
|
||||
this.close();
|
||||
}, this)
|
||||
});
|
||||
$('body').on('click', '.navigation a.ui-corner-all:not(.ui-state-active):not(.ui-state-focus)', function (e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
},
|
||||
open: function () {
|
||||
var wrapper = this.element;
|
||||
wrapper.find('.ox-nav-sections-item-content').each(function () {
|
||||
var $this = $(this),
|
||||
$control = wrapper.find('[aria-controls="' + $this.attr('id') + '"]'),
|
||||
trigger = 0 < $this.children().length;
|
||||
$control.toggleClass('no-display', !trigger).toggle(trigger);
|
||||
});
|
||||
wrapper.attr('data-count-tabs', wrapper.find('.ox-nav-sections-item-title:not(.no-display)').length)
|
||||
this._super();
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_toggleMobileMode: function () {
|
||||
$('.ox-move-item').each($.proxy(function (index, item) {
|
||||
var $this = $(item),
|
||||
_class = (($this.attr('class') || '').match(/ox-move-item-([^ ]{1,})/i) || ['', ''])[1],
|
||||
$mobile_parents = $('[data-move-mobile="' + _class + '"]'),
|
||||
$mobile_parent = $mobile_parents.eq(0);
|
||||
if (!_class || !$mobile_parent.length || $this.parent().is($mobile_parent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this.data('moveDesktopParent', $this.parent());
|
||||
$this.data('moveDesktopPosition', $this.parent().children().index($this));
|
||||
$this.appendTo($mobile_parent);
|
||||
}, this));
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_toggleDesktopMode: function () {
|
||||
if (this._isOpen) {
|
||||
this.close();
|
||||
}
|
||||
|
||||
$('.ox-move-item').each($.proxy(function (index, item) {
|
||||
var $this = $(item),
|
||||
$desktop_parent = $this.data('moveDesktopParent'),
|
||||
position = $this.data('moveDesktopPosition') || 0;
|
||||
if (!$desktop_parent || !$desktop_parent.length || $this.parent().is($desktop_parent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var prev = $desktop_parent.children().eq(position - 1);
|
||||
if (0 < position && prev.length) {
|
||||
var element = $this.detach();
|
||||
prev.after(element);
|
||||
} else {
|
||||
$this.prependTo($desktop_parent);
|
||||
}
|
||||
}, this));
|
||||
},
|
||||
});
|
||||
|
||||
return $.mage.mobileMenu;
|
||||
});
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* @author Olegnax
|
||||
* @package Olegnax_Athlete2
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'matchMedia',
|
||||
'owl.carousel',
|
||||
], function ($, mediaCheck) {
|
||||
'use strict';
|
||||
|
||||
$.widget('mage.OXmobileNoSlider', {
|
||||
options: {
|
||||
mediaBreakpoint: 768,
|
||||
items: 1,
|
||||
},
|
||||
_create: function () {
|
||||
this.zoom = '';
|
||||
mediaCheck({
|
||||
media: '(min-width:' + this.options.mediaBreakpoint + 'px)',
|
||||
entry: $.proxy(this._toggleDesktopMode, this),
|
||||
exit: $.proxy(this._toggleMobileMode, this),
|
||||
});
|
||||
this.element.off('toggleDesktopMode.OXmobileNoSlider').off('toggleMobileMode.OXmobileNoSlider')
|
||||
.on('toggleDisable.OXmobileNoSlider', $.proxy(this._toggleDesktopMode, this))
|
||||
.on('toggleEnable.OXmobileNoSlider', $.proxy(this._toggleEnable, this));
|
||||
},
|
||||
_toggleEnable:function(){
|
||||
if (window.matchMedia('(min-width:' + this.options.mediaBreakpoint + 'px)').matches)
|
||||
{
|
||||
console.warn('_toggleDesktopMode');
|
||||
this._toggleDesktopMode();
|
||||
} else {
|
||||
console.warn('_toggleMobileMode');
|
||||
this._toggleMobileMode();
|
||||
}
|
||||
},
|
||||
_toggleDesktopMode: function () {
|
||||
this.element.trigger('destroy.owl.carousel').removeClass('owl-carousel owl-loaded').find('.owl-stage-outer').children().unwrap();
|
||||
this.element.prepend(this.zoom);
|
||||
},
|
||||
_toggleMobileMode: function () {
|
||||
let $zoom = this.element.find('#ox-zoom-cursor');
|
||||
if ($zoom.length) {
|
||||
this.zoom = $zoom.detach()
|
||||
}
|
||||
let options = $.extend({}, this.options);
|
||||
this.element.addClass('owl-carousel').owlCarousel(options);
|
||||
},
|
||||
});
|
||||
|
||||
return $.mage.OXmobileNoSlider;
|
||||
});
|
||||
@@ -0,0 +1,73 @@
|
||||
define([
|
||||
'jquery',
|
||||
'jquery-ui-modules/widget',
|
||||
'jquery-ui-modules/core',
|
||||
'OXmodal'
|
||||
], function ($) {
|
||||
'use strict';
|
||||
|
||||
$.widget('mage.OXmodalMinicart', $.mage.OXmodal, {
|
||||
timerUH: null,
|
||||
/**
|
||||
* Extend default functionality to close the dropdown
|
||||
* with custom delay on mouse out and also to close when clicking outside
|
||||
*/
|
||||
_create: function () {
|
||||
this._super();
|
||||
$(this.element).off('calculatedHeight').on('calculatedHeight', $.proxy(function (event, target, counter) {
|
||||
if (this._isOpening || this._isOpen) {
|
||||
if (this.timerUH) {
|
||||
clearTimeout(this.timerUH);
|
||||
}
|
||||
var _self = this,
|
||||
_counter = 0;
|
||||
this.timerUH = setTimeout(function () {
|
||||
var height = 0,
|
||||
outerHeight;
|
||||
target.children().each(function () {
|
||||
|
||||
if ($(this).find('.options').length > 0) {
|
||||
$(this).collapsible();
|
||||
}
|
||||
outerHeight = $(this).outerHeight();
|
||||
|
||||
_counter++;
|
||||
if (counter > _counter) {
|
||||
height += outerHeight;
|
||||
}
|
||||
self.scrollHeight += outerHeight;
|
||||
});
|
||||
|
||||
target.parent().height(height);
|
||||
_self._updateHeigh()
|
||||
}, 300);
|
||||
}
|
||||
this._updateHeigh();
|
||||
}, this));
|
||||
},
|
||||
open: function (extra_class) {
|
||||
this._super(extra_class);
|
||||
this.updateHeigh();
|
||||
},
|
||||
close: function (forse) {
|
||||
this._super(forse);
|
||||
if (this.timerUH) {
|
||||
clearTimeout(this.timerUH);
|
||||
}
|
||||
},
|
||||
updateHeigh: function () {
|
||||
if (this.element.data('mageSidebar') || this.element.data('mage-Sidebar')) {
|
||||
this.element.sidebar('update');
|
||||
}
|
||||
},
|
||||
_updateHeigh: function () {
|
||||
var delta = this.uiDialog.offset().top - $(window).scrollTop() + this.uiDialog.outerHeight() - $(window).height(),
|
||||
$menu = $((this.element.data('mageSidebar') || this.element.data('mage-Sidebar')).options.minicart.list, this.element).parent();
|
||||
if (0 < delta) {
|
||||
$menu.height($menu.height() - delta);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return $.mage.OXmodalMinicart;
|
||||
});
|
||||
@@ -0,0 +1,73 @@
|
||||
define([
|
||||
'jquery',
|
||||
'jquery-ui-modules/widget',
|
||||
'jquery-ui-modules/core',
|
||||
'OXmodal'
|
||||
], function ($) {
|
||||
'use strict';
|
||||
|
||||
$.widget('mage.OXmodalPhotoswipe', $.mage.OXmodal, {
|
||||
|
||||
_create: function () {
|
||||
this.modalPrefix = '#image-';
|
||||
this._super();
|
||||
let hash = this.__curentHashTag();
|
||||
if (0 == hash.indexOf(this.modalPrefix)) {
|
||||
let index = hash.replace(this.modalPrefix, '');
|
||||
if (0 < index) {
|
||||
this.open();
|
||||
this._scrollModal(index);
|
||||
}
|
||||
}
|
||||
},
|
||||
_updateHistory: function (id) {
|
||||
if (typeof history.replaceState === 'function') {
|
||||
history.replaceState(null, null, this._getPostUrl(id));
|
||||
}
|
||||
},
|
||||
__curentHashTag: function () {
|
||||
return (new URL(window.location.href)).hash.toString();
|
||||
},
|
||||
_getPostUrl: function (id) {
|
||||
return window.location.href.replace(this.__curentHashTag(), '') + (id ? this.modalPrefix + id : '');
|
||||
},
|
||||
_scrollModal: function (index) {
|
||||
let _gallery = this.element.find('.gallery'),
|
||||
image = _gallery.find(this.modalPrefix + index),
|
||||
_nav = this.element.find('.lil-nav'),
|
||||
nav_item = _nav.find('[href="#image-' + index + '"]');
|
||||
if (image.length) {
|
||||
this._updateHistory(index);
|
||||
setTimeout(() => {
|
||||
let img_top = image[0].getBoundingClientRect().top,
|
||||
nav_top = nav_item[0].getBoundingClientRect().top;
|
||||
if (0 != img_top) {
|
||||
_gallery.animate({scrollTop: _gallery.scrollTop() + img_top});
|
||||
}
|
||||
if (0 != nav_top) {
|
||||
_nav.animate({scrollTop: _nav.scrollTop() + nav_top});
|
||||
}
|
||||
}, 600);
|
||||
}
|
||||
},
|
||||
update: function () {
|
||||
var _self = this;
|
||||
if (_self.options.triggerTarget) {
|
||||
$(_self.options.triggerTarget).off(_self.options.triggerEvent).on(_self.options.triggerEvent, function (event) {
|
||||
if (event.cancelable) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
if (!_self._isOpen) {
|
||||
_self.open();
|
||||
_self._scrollModal($(event.target).data('index')); // new code
|
||||
} else if (_self._isOpen + _self.options.timeoutOpen < new Date().getTime()) {
|
||||
_self.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
return $.mage.OXmodalPhotoswipe;
|
||||
});
|
||||
@@ -0,0 +1,44 @@
|
||||
define( [
|
||||
'jquery',
|
||||
'jquery-ui-modules/widget',
|
||||
'jquery-ui-modules/core',
|
||||
'OXmodal'
|
||||
], function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
$.widget( 'mage.OXmodalWishlist', $.mage.OXmodal, {
|
||||
timerUH: null,
|
||||
/**
|
||||
* Extend default functionality to close the dropdown
|
||||
* with custom delay on mouse out and also to close when clicking outside
|
||||
*/
|
||||
open: function ( extra_class ) {
|
||||
this._super( extra_class );
|
||||
this.updateHeigh();
|
||||
if (this._isOpening || this._isOpen) {
|
||||
if (this.timerUH) {
|
||||
clearTimeout(this.timerUH);
|
||||
}
|
||||
var _self = this;
|
||||
this.timerUH = setTimeout( function () {
|
||||
_self.updateHeigh()
|
||||
}, 300 );
|
||||
}
|
||||
},
|
||||
close: function (forse) {
|
||||
this._super( forse );
|
||||
if (this.timerUH) {
|
||||
clearTimeout(this.timerUH);
|
||||
}
|
||||
},
|
||||
updateHeigh: function () {
|
||||
var delta = this.uiDialog.offset().top - $( window ).scrollTop() + this.uiDialog.outerHeight() - $( window ).height(),
|
||||
$menu = $( '.product-items', this.element );
|
||||
if ( 0 < delta ) {
|
||||
$menu.height( $menu.height() - delta );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
return $.mage.OXmodalWishlist;
|
||||
} );
|
||||
+404
@@ -0,0 +1,404 @@
|
||||
define([
|
||||
'jquery',
|
||||
'jquery-ui-modules/widget',
|
||||
'jquery-ui-modules/core',
|
||||
'jquery-ui-modules/dialog',
|
||||
'matchMedia',
|
||||
// 'jquery/animation.transition.end',
|
||||
], function ($) {
|
||||
'use strict';
|
||||
|
||||
function debouncer(func, timeout) {
|
||||
var timeoutID,
|
||||
timeout = timeout || 500;
|
||||
return function () {
|
||||
var scope = this,
|
||||
args = arguments;
|
||||
clearTimeout(timeoutID);
|
||||
timeoutID = setTimeout(function () {
|
||||
func.apply(scope, Array.prototype.slice.call(args));
|
||||
}, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
$.widget('mage.OXmodal', $.ui.dialog, {
|
||||
options: {
|
||||
appendTo: '.ox-modals__holder',
|
||||
autoOpen: false,
|
||||
autoPosition: false,
|
||||
autoSize: false,
|
||||
htmlClass: 'ox-modal-showed',
|
||||
buttons: [],
|
||||
closeOnClickOutside: true,
|
||||
closeOnMouseLeave: false,
|
||||
closeButtonTrigger: null,
|
||||
createTitleBar: false,
|
||||
defaultModalClass: 'ox-dialog',
|
||||
draggable: false,
|
||||
hide: true,
|
||||
hoverOpen: false,
|
||||
minHeight: null,
|
||||
minWidth: null,
|
||||
modal: false,
|
||||
modalClass: 'active',
|
||||
modalCloseClass: 'close',
|
||||
modalContentClass: 'ox-modal-content',
|
||||
overlayClass: 'ox-modal-overlay',
|
||||
positionSlideout: null,
|
||||
resizable: false,
|
||||
timeout: null,
|
||||
triggerClass: 'active',
|
||||
triggerEvent: 'click',
|
||||
triggerTarget: null,
|
||||
type: 'dropdown',
|
||||
width: null,
|
||||
timeoutOpen: 200,
|
||||
},
|
||||
_isClosing: false,
|
||||
_isOpening: false,
|
||||
timer: null,
|
||||
_create: function () {
|
||||
var _self = this;
|
||||
switch (this.options.type) {
|
||||
case 'modal':
|
||||
this.options.modal = true;
|
||||
break;
|
||||
case 'overlay':
|
||||
case 'slideout':
|
||||
break;
|
||||
case 'dropdown':
|
||||
default:
|
||||
this.options.type = 'dropdown';
|
||||
this.options.modal = false;
|
||||
break;
|
||||
}
|
||||
this.extraClass = null;
|
||||
this._getScrollWidth();
|
||||
this._super();
|
||||
this._autoPositionSlideout();
|
||||
this.uiDialog.addClass(this.options.defaultModalClass).addClass('ox-' + this.options.type);
|
||||
if ('slideout' === this.options.type) {
|
||||
this.uiDialog.addClass('ox-' + this.options.type + '-' + this.options.positionSlideout);
|
||||
}
|
||||
if (_self.options.closeButtonTrigger) {
|
||||
this.element.on(_self.options.triggerEvent, _self.options.closeButtonTrigger, function () {
|
||||
_self.close();
|
||||
});
|
||||
}
|
||||
this.element.show();
|
||||
_self.options._type = window.matchMedia('(min-width: 1025px)').matches ? _self.options.type : 'slideout';
|
||||
if ('dropdown' === _self.options.type) {
|
||||
$(window).on('resize', function () {
|
||||
_self.options._type = window.matchMedia('(min-width: 1025px)').matches ? _self.options.type : 'slideout';
|
||||
_self._dropdownPosition();
|
||||
});
|
||||
}
|
||||
if (_self.options.closeOnMouseLeave) {
|
||||
this._mouseEnter(_self.uiDialog);
|
||||
this._mouseLeave(_self.uiDialog);
|
||||
if (_self.options.triggerTarget) {
|
||||
this._mouseLeave($(_self.options.triggerTarget));
|
||||
}
|
||||
}
|
||||
this.update();
|
||||
$('body').on('contentUpdated', $.proxy(_self.update, _self));
|
||||
},
|
||||
update: function () {
|
||||
var _self = this;
|
||||
if (_self.options.triggerTarget) {
|
||||
$(_self.options.triggerTarget).off(_self.options.triggerEvent).on(_self.options.triggerEvent, function (event) {
|
||||
if (event.cancelable) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
if (!_self._isOpen) {
|
||||
_self.open();
|
||||
} else if (_self._isOpen + _self.options.timeoutOpen < new Date().getTime()) {
|
||||
_self.close();
|
||||
}
|
||||
});
|
||||
if (_self.options.hoverOpen) {
|
||||
$(_self.options.triggerTarget).on('mouseenter', debouncer(function (event) {
|
||||
if (_self.timer) {
|
||||
clearTimeout(_self.timer);
|
||||
}
|
||||
if ('dropdown' === _self.options._type) {
|
||||
event.stopPropagation();
|
||||
_self.uiDialog.addClass('ox-' + _self.options.type + '-hover');
|
||||
if (_self._isOpening || _self._isOpen) {
|
||||
return;
|
||||
}
|
||||
_self.open();
|
||||
}
|
||||
}, 100));
|
||||
}
|
||||
}
|
||||
},
|
||||
_getScrollWidth: function () {
|
||||
var $tempElement = $('<div>').css({
|
||||
overflowY: 'scroll',
|
||||
width: '50px',
|
||||
height: '50px',
|
||||
visibility: 'hidden'
|
||||
});
|
||||
$('body').append($tempElement);
|
||||
this._scrollWidth = $tempElement[0].offsetWidth - $tempElement[0].clientWidth;
|
||||
$tempElement.remove();
|
||||
},
|
||||
_dropdownPosition: function () {
|
||||
var $triggerTarget = $(this.options.triggerTarget);
|
||||
if (window.matchMedia('(min-width: 1025px)').matches
|
||||
&& $triggerTarget.length
|
||||
&& ('body' === this.options.appendTo
|
||||
|| '.ox-modals__holder' === this.options.appendTo
|
||||
)
|
||||
) {
|
||||
var top = $triggerTarget.height() + $triggerTarget.offset().top - $(window).scrollTop();
|
||||
var left = $triggerTarget.offset().left + $triggerTarget.outerWidth() - this.uiDialog.outerWidth() + .5;
|
||||
this.uiDialog.css({
|
||||
top: top + 'px',
|
||||
left: left + 'px'
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.uiDialog.css({
|
||||
top: '',
|
||||
left: ''
|
||||
});
|
||||
},
|
||||
open: function (extra_class) {
|
||||
this.extraClass = extra_class || null;
|
||||
var _self = this;
|
||||
if (_self._isClosing || _self._isOpening || _self._isOpen) {
|
||||
return;
|
||||
}
|
||||
// _self.uiDialog.onAnimationStart(function () {
|
||||
// _self._isOpening = true;
|
||||
// }, 'ox-modal-active');
|
||||
_self._isOpening = true;
|
||||
// _self.uiDialog.onAnimationEnd(function () {
|
||||
// _self._isOpening = false;
|
||||
// }, 'ox-modal-active');
|
||||
setTimeout(function () {
|
||||
_self._isOpening = false;
|
||||
}, 200);
|
||||
var modalList = ['mageOXmodal', 'mageOXmodalMinicart', 'mageOXmodalWishlist', 'mage-OXmodal', 'mage-OXmodalMinicart', 'mage-OXmodalWishlist'];
|
||||
$.each(_self.options.defaultModalClass.split(' ').filter(a => 0 < a.length), function (index, element) {
|
||||
$('.' + element + ' > .ui-dialog-content').not(_self.element).each(function () {
|
||||
var $this = $(this);
|
||||
for (var i = 0; i < modalList.length; i++)
|
||||
if ('undefined' !== typeof $(this).data(modalList[i])) {
|
||||
$(this).data(modalList[i]).close(1);
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
if ('dropdown' === this.options.type) {
|
||||
_self._dropdownPosition();
|
||||
}
|
||||
this._super();
|
||||
this._createOverlay();
|
||||
if (_self.options.modalContentClass) {
|
||||
_self.element.addClass(_self.options.modalContentClass);
|
||||
}
|
||||
if (_self.options.triggerClass) {
|
||||
$(_self.options.triggerTarget).addClass(_self.options.triggerClass);
|
||||
}
|
||||
if (_self.options.htmlClass && 'dropdown' !== _self.options._type) {
|
||||
var $html = $('html');
|
||||
$html.addClass(_self.options.htmlClass).addClass(_self.options.htmlClass + '-' + _self.options.type);
|
||||
if ('slideout' === _self.options._type) {
|
||||
$html.addClass(_self.options.htmlClass + '-' + _self.options._type + '-' + _self.options.positionSlideout);
|
||||
if ('right' === _self.options.positionSlideout || 'top' === _self.options.positionSlideout ) {
|
||||
$html.find('.page-wrapper, .sticky .sticky-wrapper').css('padding-right', this._scrollWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_self.extraClass) {
|
||||
_self.element.addClass(_self.extraClass);
|
||||
}
|
||||
if (_self.options.modalCloseClass) {
|
||||
_self.uiDialog.removeClass(_self.options.modalCloseClass).removeClass('ox-' + this.options.type + '-' + _self.options.modalCloseClass);
|
||||
}
|
||||
if (_self.options.modalClass) {
|
||||
_self.uiDialog.addClass(_self.options.modalClass).addClass('ox-' + this.options.type + '-' + _self.options.modalClass);
|
||||
$('body').addClass('ox-modal-opened');
|
||||
}
|
||||
if (_self.options.closeOnClickOutside) {
|
||||
$('body').on('click.outsideDropdown', function (event) {
|
||||
if (_self._isOpen && !$(event.target).closest('.ui-dialog').length && !$(event.target).is('input')) {
|
||||
if (_self.timer) {
|
||||
clearTimeout(_self.timer);
|
||||
}
|
||||
_self.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
$('body').trigger('modal_opened.OXmodal');
|
||||
this._isOpen = new Date().getTime();
|
||||
},
|
||||
close: function (forse) {
|
||||
var forse = forse || false,
|
||||
_self = this,
|
||||
close_func = function () {
|
||||
if (_self._isClosing) {
|
||||
_self._isClosing = false;
|
||||
if (_self.extraClass) {
|
||||
_self.element.removeClass(_self.extraClass);
|
||||
_self.extraClass = null;
|
||||
}
|
||||
if (_self.options.hide) {
|
||||
_self.uiDialog.hide();
|
||||
}
|
||||
}
|
||||
};
|
||||
if (forse) {
|
||||
_self._isClosing = true;
|
||||
_self._isOpening = false;
|
||||
close_func();
|
||||
} else {
|
||||
if (_self._isOpening || _self._isClosing || !_self._isOpen) {
|
||||
return;
|
||||
}
|
||||
// _self.uiDialog.onAnimationStart(function () {
|
||||
// _self._isClosing = true;
|
||||
// }, 'ox-modal-close');
|
||||
_self._isClosing = true;
|
||||
// _self.uiDialog.onAnimationEnd(close_func, 'ox-modal-close');
|
||||
setTimeout(close_func, 200);
|
||||
}
|
||||
if (this.options.modalContentClass) {
|
||||
this.element.removeClass(this.options.modalContentClass);
|
||||
}
|
||||
if (_self.options.modalClass) {
|
||||
_self.uiDialog.removeClass(_self.options.modalClass).removeClass('ox-' + this.options.type + '-' + _self.options.modalClass);
|
||||
$('body').removeClass('ox-modal-opened');
|
||||
}
|
||||
if (_self.options.modalCloseClass) {
|
||||
_self.uiDialog.addClass(_self.options.modalCloseClass).addClass('ox-' + this.options.type + '-' + _self.options.modalCloseClass);
|
||||
}
|
||||
if (this.options.triggerClass) {
|
||||
$(this.options.triggerTarget).removeClass(this.options.triggerClass);
|
||||
}
|
||||
if (this.options.htmlClass) {
|
||||
var $html = $('html');
|
||||
$html.removeClass(this.options.htmlClass).removeClass(this.options.htmlClass + '-' + this.options.type).removeClass(_self.options.htmlClass + '-' + _self.options._type + '-' + _self.options.positionSlideout);
|
||||
if ('right' === _self.options.positionSlideout || 'top' === _self.options.positionSlideout) {
|
||||
$html.find('.page-wrapper, .sticky .sticky-wrapper').css('padding-right', '');
|
||||
}
|
||||
}
|
||||
if (_self.timer) {
|
||||
clearTimeout(_self.timer);
|
||||
}
|
||||
$('body').off('click.outsideDropdown');
|
||||
$('body').trigger('modal_closed.OXmodal');
|
||||
_self._isOpen = false;
|
||||
},
|
||||
_position: function () {
|
||||
if (this.options.autoPosition) {
|
||||
this._super();
|
||||
}
|
||||
},
|
||||
_createTitlebar: function () {
|
||||
if (this.options.createTitleBar) {
|
||||
this._super();
|
||||
} else {
|
||||
this.uiDialogTitlebarClose = $('<div>');
|
||||
}
|
||||
},
|
||||
_size: function () {
|
||||
if (this.options.autoSize) {
|
||||
this._super();
|
||||
}
|
||||
},
|
||||
_mouseLeave: function (handler) {
|
||||
var _self = this;
|
||||
handler.on('mouseleave', function (event) {
|
||||
event.stopPropagation();
|
||||
if (_self._isOpen && !_self._isOpening && 'dropdown' === _self.options._type && !$(event.target).is('input')) {
|
||||
if (_self.timer) {
|
||||
clearTimeout(_self.timer);
|
||||
}
|
||||
_self.timer = setTimeout(function () {
|
||||
_self.close();
|
||||
}, _self.options.timeout);
|
||||
}
|
||||
});
|
||||
},
|
||||
_mouseEnter: function (handler) {
|
||||
var _self = this;
|
||||
handler.on('mouseenter', function (event) {
|
||||
event.stopPropagation();
|
||||
if (!_self._isOpening) {
|
||||
clearTimeout(_self.timer);
|
||||
}
|
||||
});
|
||||
},
|
||||
_setOption: function (key, value) {
|
||||
this._super(key, value);
|
||||
if (key === 'triggerTarget') {
|
||||
this.options.triggerTarget = value;
|
||||
}
|
||||
},
|
||||
_createOverlay: function () {
|
||||
if (!this.options.overlayClass) {
|
||||
return;
|
||||
}
|
||||
var isOpening = true;
|
||||
this._delay(function () {
|
||||
isOpening = false;
|
||||
});
|
||||
if (!this.overlay) {
|
||||
var $body = $('body');
|
||||
if ($body.children('.' + this.options.overlayClass).length) {
|
||||
this.overlay = $body.children('.' + this.options.overlayClass).eq(0);
|
||||
} else {
|
||||
this.overlay = $('<div>').addClass(this.options.overlayClass).appendTo($('body').eq(0));
|
||||
}
|
||||
this._on(this.overlay, {
|
||||
mousedown: "_keepFocus"
|
||||
});
|
||||
if (this.options.closeOnClickOutside) {
|
||||
this.overlay.on('click', $.proxy(function () {
|
||||
if (this._isOpen) {
|
||||
this.close();
|
||||
}
|
||||
}, this));
|
||||
}
|
||||
}
|
||||
},
|
||||
_destroyOverlay: function () {
|
||||
if (this.overlay) {
|
||||
this.overlay.remove();
|
||||
this.overlay = null;
|
||||
}
|
||||
},
|
||||
_autoPositionSlideout: function () {
|
||||
if ('slideout' !== this.options.type || this.options.positionSlideout) {
|
||||
return;
|
||||
}
|
||||
if (0 < $(this.options.triggerTarget).closest('.modal__right').length) {
|
||||
this.options.positionSlideout = 'right';
|
||||
} else if (0 < $(this.options.triggerTarget).closest('.modal__left').length) {
|
||||
this.options.positionSlideout = 'left';
|
||||
}
|
||||
},
|
||||
_focusTabbable: function () {
|
||||
var hasFocus = this._focusedElement;
|
||||
if (!hasFocus) {
|
||||
hasFocus = this.element.find("[autofocus]");
|
||||
}
|
||||
if (!hasFocus.length) {
|
||||
hasFocus = this.uiDialogButtonPane.find(":tabbable");
|
||||
}
|
||||
if (!hasFocus.length) {
|
||||
hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
|
||||
}
|
||||
if (!hasFocus.length) {
|
||||
hasFocus = this.uiDialog;
|
||||
}
|
||||
hasFocus.eq(0).trigger("focus");
|
||||
}
|
||||
});
|
||||
return $.mage.OXmodal;
|
||||
});
|
||||
@@ -0,0 +1,56 @@
|
||||
require(['jquery', 'domReady!'], function ($) {
|
||||
(function () {
|
||||
if ($('body').hasClass('page-layout-1column') || $('body').hasClass('page-layout-1column-fullwidth')) {
|
||||
var $this = $('.ox-move-item-filtersslideout, .ox-block-filter, .sidebar-additional'),
|
||||
$parent = $('[data-move-mobile="filtersslideout"]').eq(0);
|
||||
if (!$this.length || !$parent.length || $this.parent().is($parent)) {
|
||||
return;
|
||||
}
|
||||
var element = $this.detach();
|
||||
$parent.append(element);
|
||||
$('body').addClass('ox-show-filter');
|
||||
}
|
||||
})();
|
||||
});
|
||||
|
||||
require([
|
||||
'jquery',
|
||||
], function ($) {
|
||||
'use strict';
|
||||
|
||||
function init() {
|
||||
$('.js-toolbar-switch').off('mouseenter').on('mouseenter', function (e) {
|
||||
var $this = $(this),
|
||||
$dropdown = $('.js-toolbar-dropdown', $this),
|
||||
width;
|
||||
$this.addClass('over');
|
||||
if ($this.closest('.sorter').length) {
|
||||
width = $this.width() + 50;
|
||||
} else {
|
||||
width = $this.width() - parseInt($dropdown.css('padding-left')) * 2;
|
||||
}
|
||||
$dropdown
|
||||
.css('width', width)
|
||||
.stop(true, true)
|
||||
.hide()
|
||||
.animate({
|
||||
opacity: 1,
|
||||
height: 'toggle'
|
||||
}, 100);
|
||||
}).off('mouseleave').on('mouseleave', function (e) {
|
||||
var $this = $(this),
|
||||
$dropdown = $('.js-toolbar-dropdown', $this);
|
||||
$dropdown.stop(true, true).animate({
|
||||
opacity: 0,
|
||||
height: 'toggle'
|
||||
}, 100, function () {
|
||||
$this.removeClass('over');
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$(init);
|
||||
$('body').on('contentUpdated', init);
|
||||
|
||||
});
|
||||
@@ -0,0 +1,45 @@
|
||||
require([
|
||||
'jquery',
|
||||
'domReady!'
|
||||
], function ($) {
|
||||
'use strict';
|
||||
|
||||
/*Social share open/close */
|
||||
var socialShare = $('.social-share__action');
|
||||
if (socialShare.length) {
|
||||
socialShare.on('click', function (e) {
|
||||
$('.social-share__content').addClass('opened');
|
||||
e.stopPropagation();
|
||||
});
|
||||
$('body').on('click', function () {
|
||||
$('.social-share__content').removeClass('opened');
|
||||
});
|
||||
}
|
||||
/* social share new window size */
|
||||
$('body').on('click', '.ox-social-button', function (e) {
|
||||
var newWind = window.open($(this).attr('href'), $(this).attr('title'), "width=420,height=320,resizable=yes,scrollbars=yes,status=yes");
|
||||
if (newWind) {
|
||||
newWind.focus();
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
/* product gallery custom cursor */
|
||||
if ($('body').hasClass('custom-gallery-cursor')) {
|
||||
$('body').addClass('custom-gallery-cursor-loaded');
|
||||
let ns = '.OXA2Cursor',
|
||||
media_block = '.product.media .gallery-placeholder .fotorama__stage';
|
||||
$('body')
|
||||
.on('mouseenter' + ns, media_block, async function () {
|
||||
$(this).off('mouseenter' + ns);
|
||||
if (!$('#ox-zoom-cursor').length) {
|
||||
$('<div id="ox-zoom-cursor"><span></span></div>').appendTo($(this));
|
||||
}
|
||||
}).on('mousemove' + ns, media_block, function (e) {
|
||||
var parentOffset = this.getBoundingClientRect();
|
||||
var relX = e.pageX - parentOffset.left;
|
||||
var relY = e.pageY - (window.scrollY + parentOffset.top);
|
||||
$('#ox-zoom-cursor').css({left: relX, top: relY});
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
require(["jquery"], function ($) {
|
||||
"use strict";
|
||||
$(function () {
|
||||
let ns = ".OXA2Video",
|
||||
s_hover = ".product-item";
|
||||
$("body")
|
||||
.on("mouseenter" + ns, s_hover, async function () {
|
||||
let $wrapper = $(this).find(".ox-product-hover-image-container");
|
||||
let video = $wrapper.find("video").get(0);
|
||||
if (video) {
|
||||
try {
|
||||
await video.play();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
})
|
||||
.on("mouseleave" + ns, s_hover, function () {
|
||||
let $wrapper = $(this).find(".ox-product-hover-image-container");
|
||||
let video = $wrapper.find("video").get(0);
|
||||
if (video && video.currentTime > 0 && !video.paused && !video.ended && video.readyState > 2) {
|
||||
video.pause();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
+211
File diff suppressed because one or more lines are too long
+2
File diff suppressed because one or more lines are too long
@@ -0,0 +1,190 @@
|
||||
define(['jquery'], function ($) {
|
||||
'use strict';
|
||||
// Sticky sidebars and content
|
||||
var stickySidebar = function (so) {
|
||||
$(function () {
|
||||
var sd = {
|
||||
wrapper: "",
|
||||
sticky: ""
|
||||
},
|
||||
s = $.extend(true, {}, sd, so),
|
||||
$body = $("body");
|
||||
if (s.wrapper && s.sticky) {
|
||||
/* merge two sidebar block in one div */
|
||||
var wrapSidebar = function () {
|
||||
var $ox;
|
||||
if ($(window).width() >= 1025 || !$("body.catalog-product-view").length) {
|
||||
if (($(".page-layout-2columns-left").length || $(".page-layout-2columns-right").length)) {
|
||||
$('div:not(.ox-sticky-sidebar) > .sidebar').wrapAll('<div class="ox-sticky-sidebar">');
|
||||
}
|
||||
/* wrap left sidebar for 3 cols and set sidebar width to wrapper, because content block jumps left when sidebar became sticky */
|
||||
if ($(".page-layout-3columns").length) {
|
||||
$ox = $(".sidebar-main");
|
||||
var $sm_ow = $ox.outerWidth(true);
|
||||
if (!$ox.parent().is(".ox-3col-sticky-wrapper")) {
|
||||
$ox.wrapAll('<div class="ox-3col-sticky-wrapper">');
|
||||
$(".ox-3col-sticky-wrapper").css({
|
||||
width: $sm_ow
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$ox = $(".ox-sticky-sidebar");
|
||||
if ($ox.length) {
|
||||
$ox.contents().unwrap();
|
||||
}
|
||||
$ox = $(".ox-3col-sticky-wrapper");
|
||||
if ($ox.length) {
|
||||
$ox.contents().unwrap();
|
||||
}
|
||||
}
|
||||
},
|
||||
_spacing = 40,
|
||||
stickyItems = [],
|
||||
stickyItem = function (item) {
|
||||
this.$item = $(item);
|
||||
this.getVals = function () {
|
||||
this.outerWidth = this.$item.outerWidth(true);
|
||||
this.offsetLeft = this.$item.offset().left;
|
||||
this.positionLeft = this.$item.position().left;
|
||||
this.alwaysTop = this.$item.hasClass('ox-sticky-always-top');
|
||||
return this;
|
||||
};
|
||||
this.reset = function () {
|
||||
this.clearStyles().getVals();
|
||||
};
|
||||
this.outerHeightNew = function () {
|
||||
return this.outerHeight = this.$item.outerHeight(true);
|
||||
};
|
||||
this.addClass = function (_class) {
|
||||
return this.$item.addClass(_class);
|
||||
};
|
||||
this.removeClass = function (_class) {
|
||||
return this.$item.removeClass(_class);
|
||||
};
|
||||
this.css = function (style) {
|
||||
return this.$item.css(style);
|
||||
};
|
||||
this.clearStyles = function () {
|
||||
this.$item.removeClass("ox-sticky-static ox-sticky-fixed").css({
|
||||
bottom: "",
|
||||
top: "",
|
||||
left: "",
|
||||
width: ""
|
||||
});
|
||||
return this;
|
||||
};
|
||||
this.getVals();
|
||||
};
|
||||
wrapSidebar();
|
||||
$(s.sticky).each(function () {
|
||||
stickyItems.push(new stickyItem(this));
|
||||
});
|
||||
if (stickyItems.length) {
|
||||
if(!$(s.wrapper).length) {
|
||||
return;
|
||||
}
|
||||
var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame,
|
||||
$window = $(window),
|
||||
windowHeight = $window.height(),
|
||||
$wrapper = $(s.wrapper),
|
||||
wrapperTop = $wrapper.offset().top,
|
||||
stickyItemsReset = function () {
|
||||
wrapperTop = $wrapper.offset().top;
|
||||
for (var i = 0; i < stickyItems.length; i++) {
|
||||
stickyItems[i].reset();
|
||||
}
|
||||
},
|
||||
update = function () {
|
||||
if (0 > wrapperTop) {
|
||||
wrapperTop = $(s.wrapper).offset().top;
|
||||
}
|
||||
var wrapperHeight = $wrapper.height(),
|
||||
scrollTo = wrapperTop + wrapperHeight,
|
||||
isSmall = $(window).width() < 1025,
|
||||
isEdg = window.navigator.userAgent.indexOf(" Edg/") > -1, // @todo use for Edge browser
|
||||
scrollTop,
|
||||
scrollBottom,
|
||||
_height,
|
||||
__height, // @todo original:
|
||||
topOffset,
|
||||
$ox,
|
||||
_is,
|
||||
_static = "ox-sticky-static",
|
||||
_fixed = "ox-sticky-fixed";
|
||||
for (var i = 0; i < stickyItems.length; i++) {
|
||||
var _stickyItem = stickyItems[i];
|
||||
if (isSmall || wrapperHeight <= _stickyItem.outerHeightNew() + 100) {
|
||||
_stickyItem.clearStyles();
|
||||
} else {
|
||||
scrollTop = scrollTop || $window.scrollTop();
|
||||
scrollBottom = scrollBottom || scrollTop + windowHeight;
|
||||
topOffset = _stickyItem.outerHeight + wrapperTop;
|
||||
if (windowHeight > topOffset || _stickyItem.alwaysTop) {
|
||||
$ox = $ox || $(".ox-sticky");
|
||||
_height = _height || _spacing + ($ox.length > 0 ? $ox.height() : 0);
|
||||
if (scrollTop >= scrollTo - _stickyItem.outerHeight - _height) {
|
||||
_stickyItem.addClass(_static).removeClass(_fixed).css({
|
||||
top: "auto",
|
||||
left: _stickyItem.positionLeft,
|
||||
bottom: "",
|
||||
width: ""
|
||||
});
|
||||
} else {
|
||||
_is = scrollTop + _height >= wrapperTop;
|
||||
//_stickyItem.removeClass(_static).toggleClass(_fixed, _is);
|
||||
if (_is) {
|
||||
_stickyItem.css({
|
||||
top: _height,
|
||||
width: _stickyItem.outerWidth,
|
||||
left: _stickyItem.offsetLeft
|
||||
});
|
||||
} else {
|
||||
_stickyItem.clearStyles();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (scrollBottom >= scrollTo + _spacing) {
|
||||
_stickyItem.addClass(_static).removeClass(_fixed).css({
|
||||
top: "",
|
||||
left: _stickyItem.positionLeft,
|
||||
bottom: 0,
|
||||
width: ""
|
||||
});
|
||||
} else {
|
||||
_is = scrollBottom >= topOffset + _spacing;
|
||||
//_stickyItem.removeClass(_static).toggleClass(_fixed, _is);
|
||||
if (_is) {
|
||||
_stickyItem.css({
|
||||
bottom: _spacing,
|
||||
width: _stickyItem.outerWidth,
|
||||
left: _stickyItem.offsetLeft,
|
||||
top: ""
|
||||
});
|
||||
} else {
|
||||
_stickyItem.clearStyles();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
requestAnimationFrame(update);
|
||||
$body.on("contentUpdated oxToggleUpdated", function () {
|
||||
stickyItemsReset();
|
||||
requestAnimationFrame(update);
|
||||
});
|
||||
$window.on("scroll", function () {
|
||||
requestAnimationFrame(update);
|
||||
}).on("resize", function () {
|
||||
wrapSidebar();
|
||||
windowHeight = $window.height();
|
||||
stickyItemsReset();
|
||||
requestAnimationFrame(update);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
return stickySidebar;
|
||||
});
|
||||
+452
@@ -0,0 +1,452 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
define( [
|
||||
'jquery',
|
||||
'matchMedia',
|
||||
'jquery-ui-modules/widget',
|
||||
'jquery-ui-modules/core',
|
||||
'jquery-ui-modules/effect',
|
||||
], function ( $, mediaCheck ) {
|
||||
'use strict';
|
||||
var timer;
|
||||
var showtime;
|
||||
function debouncer( func, timeout ) {
|
||||
var timeoutID, timeout = timeout || 500;
|
||||
return function () {
|
||||
var scope = this,
|
||||
args = arguments;
|
||||
clearTimeout( timeoutID );
|
||||
timeoutID = setTimeout( function () {
|
||||
func.apply( scope, Array.prototype.slice.call( args ) );
|
||||
}, timeout );
|
||||
}
|
||||
}
|
||||
;
|
||||
$.widget( 'mage.OXsticky', {
|
||||
options: {
|
||||
stickyTarget: null,
|
||||
scrollStart: null,
|
||||
defaultClass: 'ox-sticky',
|
||||
stickyClass: 'sticky',
|
||||
scrollUpShow: false,
|
||||
scrollUpClass: 'sticky-scroll-up',
|
||||
scrollDownShow: false,
|
||||
scrollDownClass: 'sticky-scroll-down',
|
||||
scrollSmartStart: 'height',
|
||||
scrollSmart: null,
|
||||
maxHeight: null,
|
||||
addMargin: false,
|
||||
margin: 0,
|
||||
marginTarget: null,
|
||||
timeout: 0,
|
||||
interval: 10,
|
||||
mediaBreakpoint: '(min-width: 1025px)',
|
||||
searchOver: false,
|
||||
resizedHeight: 64
|
||||
},
|
||||
_create: function () {
|
||||
if ( null === this.options.scrollSmart ) {
|
||||
this.options.scrollSmart = $( 'body' ).hasClass( 'sticky-smart' );
|
||||
}
|
||||
this.status = null;
|
||||
mediaCheck( {
|
||||
media: this.options.mediaBreakpoint,
|
||||
entry: $.proxy( function () {
|
||||
this.minimize = true
|
||||
}, this ),
|
||||
exit: $.proxy( function () {
|
||||
this.minimize = false
|
||||
}, this ),
|
||||
} );
|
||||
if ( this.options.scrollSmart ) {
|
||||
this.options.scrollDownShow = this.options.scrollUpShow = true;
|
||||
}
|
||||
if ( this.options.stickyTarget ) {
|
||||
this.target = this.element.find( this.options.stickyTarget );
|
||||
} else {
|
||||
this.target = this.element;
|
||||
}
|
||||
if ( !this.target.length ) {
|
||||
this.target = this.element;
|
||||
}
|
||||
this.element.trigger( 'initsticky.ox' );
|
||||
this._updateHeight();
|
||||
if ( this.options.addMargin ) {
|
||||
if ( this.options.marginTarget ) {
|
||||
this.marginTarget = $( this.options.marginTarget );
|
||||
} else {
|
||||
this.marginTarget = this.element.next();
|
||||
}
|
||||
this.marginTarget.data( 'margin-top', this.marginTarget.css( 'margin-top' ) );
|
||||
this.margin_outerHeight = this.target.outerHeight();
|
||||
}
|
||||
this.margin__outerHeight = 0;
|
||||
if ( this.options.defaultClass ) {
|
||||
this.target.addClass( this.options.defaultClass );
|
||||
}
|
||||
|
||||
if ( !this.options.scrollStart ) {
|
||||
this.options.scrollStart = 0;
|
||||
}
|
||||
if ( !this.options.scrollSmartStart ) {
|
||||
this.options.scrollSmartStart = 0;
|
||||
}
|
||||
if ( 'height' == this.options.scrollStart ) {
|
||||
this.options.scrollStart = this.target.outerHeight();
|
||||
}
|
||||
if (this.element.offset().top) {
|
||||
this.options.scrollStart += this.target.offset().top;
|
||||
}
|
||||
this.lastPosition = $( window ).scrollTop();
|
||||
this.lastSmartPosition = 0;
|
||||
if ( this.options.scrollUpShow ) {
|
||||
this._mouseLeave( this.target );
|
||||
this._mouseEnter( this.target );
|
||||
}
|
||||
this.delt_minimize = this.target.children( '.sticky-wrapper' ).height() - this.options.resizedHeight;
|
||||
|
||||
var _self = this;
|
||||
$( window ).on( 'scroll', function () {
|
||||
debouncer( _self.refresh(), _self.options.interval );
|
||||
} );
|
||||
var win_size = $( window ).innerWidth();
|
||||
$( window ).on( 'resize', function () {
|
||||
var new_size = $( window ).innerWidth();
|
||||
if ( win_size == new_size ) {
|
||||
return;
|
||||
}
|
||||
debouncer( _self._updateHeight() );
|
||||
setTimeout( function () {
|
||||
debouncer( _self._updateHeight() );
|
||||
}, 310 );
|
||||
} );
|
||||
|
||||
if ( $( 'body.sticky-minimized' ).length ) {
|
||||
this._toggleSearch();
|
||||
}
|
||||
this.refresh();
|
||||
this.element.trigger( 'initedsticky.ox' );
|
||||
|
||||
},
|
||||
hide: function () {
|
||||
this.target.removeClass( this.options.scrollUpClass ).removeClass( this.options.scrollDownClass );
|
||||
this.element.trigger( 'hidesticky.ox' );
|
||||
},
|
||||
showUp: function ( status ) {
|
||||
if ( !this.options.scrollUpShow )
|
||||
return;
|
||||
this.target.toggleClass( this.options.scrollUpClass, status );
|
||||
this.element.trigger( 'upsticky.ox' );
|
||||
this._resetTimer();
|
||||
},
|
||||
showDown: function ( status ) {
|
||||
if ( !this.options.scrollDownShow )
|
||||
return;
|
||||
this.target.toggleClass( this.options.scrollDownClass, status )
|
||||
this.element.trigger( 'downsticky.ox' );
|
||||
this._resetTimer();
|
||||
},
|
||||
addMargin: function ( status ) {
|
||||
if ( !this.options.addMargin )
|
||||
return;
|
||||
var margin = 0;
|
||||
if ( status ) {
|
||||
if ( this.options.margin ) {
|
||||
margin = this.options.margin;
|
||||
} else {
|
||||
if ( !this.margin__outerHeight && !status ) {
|
||||
this.margin__outerHeight = this.target.outerHeight();
|
||||
}
|
||||
margin = this.margin__outerHeight ? this.margin__outerHeight : this.margin_outerHeight;
|
||||
}
|
||||
this.marginTarget.css( 'margin-top', margin );
|
||||
} else {
|
||||
margin = this.marginTarget.data( 'margin-top' );
|
||||
if ( margin ) {
|
||||
this.marginTarget.css( 'margin-top', margin );
|
||||
} else {
|
||||
this.marginTarget.css( 'margin-top', null );
|
||||
}
|
||||
}
|
||||
},
|
||||
refresh: function () {
|
||||
var scrollPosition = $( window ).scrollTop();
|
||||
var direction = scrollPosition - this.lastPosition;
|
||||
/*
|
||||
if (0 === direction) {
|
||||
return;
|
||||
}
|
||||
*/
|
||||
this.lastPosition = scrollPosition;
|
||||
var minimizeEnabled = $( 'body.sticky-minimized' ).length;
|
||||
var scroll_start = this.options.scrollStart;
|
||||
if ( this.options.scrollSmart && minimizeEnabled ) {
|
||||
scroll_start += parseFloat( ( this.target.css( 'min-height' ) || '' ).replace( /[^0-9\.,]+/ig, '' ) || this.target.height() );
|
||||
}
|
||||
var status = scroll_start < scrollPosition;
|
||||
if ( 0 > direction ) {
|
||||
scroll_start = /*minimizeEnabled ? this.delt_minimize :*/ this.target.offset().top;
|
||||
status = scroll_start < scrollPosition;
|
||||
}
|
||||
// Margin
|
||||
this.addMargin( status );
|
||||
// Sticky Class
|
||||
this.target.toggleClass( this.options.stickyClass, status );
|
||||
|
||||
// Smart Scroll
|
||||
if ( 0 > direction ) {
|
||||
this.lastSmartPosition = scrollPosition;
|
||||
}
|
||||
|
||||
var status_minimize = this.options.scrollStart + this.delt_minimize < scrollPosition;
|
||||
if ( this.options.scrollSmart && minimizeEnabled && 0 < direction ) {
|
||||
status_minimize = this.options.scrollStart + scroll_start < scrollPosition;
|
||||
}
|
||||
if ( minimizeEnabled && !window.matchMedia( '(max-width: 1024px)' ).matches ) {
|
||||
this._hideSearch( status );
|
||||
}
|
||||
if ( status ) {
|
||||
var scrollStart = ( 'height' == this.options.scrollSmartStart ) ? this.target.height() : parseInt( this.options.scrollSmartStart );
|
||||
if ( 0 < scrollStart ) {
|
||||
this.showUp( 0 > direction );
|
||||
this.showDown( 0 < direction && scrollStart < scrollPosition );
|
||||
} else {
|
||||
this.showUp( 0 > direction );
|
||||
this.showDown( 0 < direction );
|
||||
}
|
||||
this.element.trigger( 'setsticky.ox' );
|
||||
} else {
|
||||
this.hide();
|
||||
this.element.trigger( 'removesticky.ox' );
|
||||
}
|
||||
if ( this.options.scrollSmart ) {
|
||||
var _status = this.options.scrollUpShow && ( 0 > direction && ( ( 0 >= direction && minimizeEnabled ) ? this.delt_minimize < scrollPosition : status ) );
|
||||
if ( this.status != _status ) {
|
||||
if ( _status ) {
|
||||
this._updateHeight_logo( _status );
|
||||
} else {
|
||||
setTimeout( $.proxy( function () {
|
||||
this.target.children( '.sticky-wrapper' ).css( { 'transform': '' } );
|
||||
}, this ), 50 );
|
||||
}
|
||||
}
|
||||
this.status = _status;
|
||||
|
||||
} else {
|
||||
if ( this.status != status ) {
|
||||
this._updateHeight_logo();
|
||||
}
|
||||
this.status = status;
|
||||
}
|
||||
if ( minimizeEnabled && this.minimize ) {
|
||||
if ( status_minimize ) {
|
||||
this._stickyMinimize();
|
||||
} else {
|
||||
this._stickyMaximize();
|
||||
}
|
||||
}
|
||||
if ( minimizeEnabled ) {
|
||||
this.target.toggleClass( 'resize', status_minimize );
|
||||
}
|
||||
},
|
||||
_removeTimer: function () {
|
||||
if ( timer ) {
|
||||
clearTimeout( timer );
|
||||
}
|
||||
},
|
||||
_resetTimer: function () {
|
||||
var _self = this;
|
||||
_self._removeTimer();
|
||||
if ( _self.options.timeout ) {
|
||||
timer = setTimeout( function () {
|
||||
_self.hide();
|
||||
}, _self.options.timeout );
|
||||
}
|
||||
|
||||
},
|
||||
_mouseLeave: function ( handler ) {
|
||||
var _self = this;
|
||||
handler.on( 'mouseleave', function ( event ) {
|
||||
event.stopPropagation();
|
||||
_self._resetTimer();
|
||||
} );
|
||||
},
|
||||
_mouseEnter: function ( handler ) {
|
||||
var _self = this;
|
||||
handler.on( 'mouseenter', function ( event ) {
|
||||
event.stopPropagation();
|
||||
_self._removeTimer();
|
||||
} );
|
||||
},
|
||||
_updateHeight: function () {
|
||||
var topbar = this.target.children( '.sticky-wrapper' ).find( '.top-bar' );
|
||||
var topbar_height = topbar.height();
|
||||
topbar.css( 'height', topbar_height );
|
||||
this.target.css( 'min-height', '' );
|
||||
var height = this.target.children( '.sticky-wrapper' ).height();
|
||||
if ( 0 < height ) {
|
||||
this.target.css( 'min-height', height );
|
||||
}
|
||||
|
||||
},
|
||||
_updateHeight_logo: function ( _status ) {
|
||||
if ( window.matchMedia( '(max-width: 1025px)' ).matches && $( 'body.sticky-minimized.mobile-header--layout-2' ).length && this.target.hasClass( this.options.stickyClass ) ) {
|
||||
/*this.target.css('min-height', '');*/
|
||||
var height = this.target.children( '.sticky-wrapper' ).height();
|
||||
var $logo = this.target.find( '.logo__container' );
|
||||
if ( $logo.length ) {
|
||||
var logo_height = $logo.outerHeight();
|
||||
height -= logo_height;
|
||||
this.target.children( '.sticky-wrapper' ).css( { 'transform': 'translateY(-' + logo_height + 'px)' } );
|
||||
}
|
||||
if ( 0 < height && !_status ) {
|
||||
this.target.css( 'min-height', height );
|
||||
}
|
||||
} else {
|
||||
this.target.children( '.sticky-wrapper' ).css( { 'transform': '' } );
|
||||
}
|
||||
},
|
||||
_itemMove: function ($item, _info) {
|
||||
$item.each( $.proxy( function ( index, item ) {
|
||||
var $this = $( item ),
|
||||
_class = ( ( $this.attr( 'class' ) || '' ).match( /ox-move-sticky-([^ ]{1,})/i ) || [ '', '' ] )[1],
|
||||
$sticky_parent = $( '[data-move-sticky="' + _class + '"]' ).eq( 0 );
|
||||
if ( !_class || !$sticky_parent.length || $this.parent().is( $sticky_parent ) ) {
|
||||
return;
|
||||
}
|
||||
if ( !$( '[data-move-back="' + _class + '"]' ).length ) {
|
||||
$this.parent().attr( 'data-move-back', _class );
|
||||
}
|
||||
$this.data( 'moveBackPosition', $this.parent().children().index( $this ) );
|
||||
var element = $this.detach();
|
||||
$sticky_parent.append( element );
|
||||
if(_info){
|
||||
$('html').addClass(_info + '-moved');
|
||||
}
|
||||
}, this ) );
|
||||
},
|
||||
_itemMoveBack: function ($item, _info) {
|
||||
$item.each( $.proxy( function ( index, item ) {
|
||||
var $this = $( item ),
|
||||
_class = ( ( $this.attr( 'class' ) || '' ).match( /ox-move-sticky-([^ ]{1,})/i ) || [ '', '' ] )[1],
|
||||
$back_parent = $( '[data-move-back="' + _class + '"]' ).eq( 0 ),
|
||||
position = $this.data( 'moveBackPosition' ) || 0;
|
||||
if ( !_class || !$back_parent.length || $this.parent().is( $back_parent ) ) {
|
||||
return;
|
||||
}
|
||||
var element = $this.detach();
|
||||
if ( 0 < position ) {
|
||||
var prev = $back_parent.children().eq( position - 1 );
|
||||
|
||||
if ( prev.length ) {
|
||||
prev.after( element );
|
||||
} else {
|
||||
$back_parent.prepend( element );
|
||||
}
|
||||
} else {
|
||||
$back_parent.prepend( element );
|
||||
}
|
||||
if(_info){
|
||||
$('html').removeClass(_info + '-moved');
|
||||
}
|
||||
}, this ) );
|
||||
},
|
||||
_stickyMinimize: function () {
|
||||
this._itemMove($( '.ox-move-sticky' ));
|
||||
this._itemMove($( '.ox-move-search' ), 'search');
|
||||
if (this._searchInOverlay()) {
|
||||
var $searchModal = $('.ox-move-search').parent(),
|
||||
searchModal = $searchModal.data('mageOXmodal') || $searchModal.data('mage-OXmodal');
|
||||
if (searchModal) {
|
||||
$searchModal.find(searchModal.options.closeButtonTrigger)
|
||||
.off('click.moveSearchOX')
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_stickyMaximize: function () {
|
||||
this._itemMoveBack($( '.ox-move-sticky' ));
|
||||
if (this._searchInOverlay()) {
|
||||
var $searchModal = $('.ox-move-search').parent(),
|
||||
searchModal = $searchModal.data('mageOXmodal') || $searchModal.data('mage-OXmodal');
|
||||
if (searchModal) {
|
||||
$searchModal.find(searchModal.options.closeButtonTrigger)
|
||||
.off('click.moveSearchOX')
|
||||
.one('click.moveSearchOX', $.proxy(function () {
|
||||
this._itemMoveBack($('.ox-move-search'), 'search');
|
||||
}, this));
|
||||
}
|
||||
} else {
|
||||
this._itemMoveBack($('.ox-move-search'), 'search');
|
||||
}
|
||||
|
||||
},
|
||||
_searchInOverlay: function () {
|
||||
return $('html').hasClass('ox-fixed') && 0 < $('.ox-dialog .ox-move-search').length;
|
||||
},
|
||||
/*_searchInOverlay: function () {
|
||||
if($('html').hasClass('.ox-fixed, .search-moved')){
|
||||
return true;
|
||||
} else{
|
||||
return false;
|
||||
}
|
||||
},*/
|
||||
_hideSearch: function ( status ) {
|
||||
this.options.searchOver = false;
|
||||
var search_mini_form = this.target.find( '.block-search--type-panel' ).find( '#search_mini_form' ).find('.search_form_wrap');
|
||||
$( 'body' ).addClass('form-search-over');
|
||||
if ( status ) {
|
||||
search_mini_form.find( '#search' ).css( { 'opacity': 0 } );
|
||||
} else {
|
||||
search_mini_form.find( '#search' ).removeAttr( 'style' );
|
||||
}
|
||||
},
|
||||
_toggleSearch: function () {
|
||||
var _this = this;
|
||||
var search_mini_form = this.target.find( '.block-search--type-panel' ).find( '#search_mini_form' ).find('.search_form_wrap');
|
||||
|
||||
if ( search_mini_form.length ) {
|
||||
|
||||
this.target.on( 'click', '.block-search--type-panel #search_mini_form .search_form_wrap', function ( event ) {
|
||||
if ( window.matchMedia( '(max-width: 1025px)' ).matches || $( 'body.ox-slideout-active' ).length ) {
|
||||
return
|
||||
}
|
||||
event.stopPropagation();
|
||||
if ( _this.options.searchOver ) {
|
||||
return true;
|
||||
}
|
||||
var $this = $( this );
|
||||
$( 'body' ).addClass('ox-search-opened form-search-over');
|
||||
$this.find( '#search' ).addClass( 'animate' );
|
||||
$this.find( '#search' ).stop( true, false ).css( 'opacity', 0 ).animate( { opacity: 1 }, 400, 'easeOutExpo', function () {
|
||||
_this.options.searchOver = true;
|
||||
} );
|
||||
return false;
|
||||
|
||||
} );
|
||||
//Hide search if visible
|
||||
$( 'body' ).on( 'click', function ( event ) {
|
||||
if ( window.matchMedia( '(max-width: 1025px)' ).matches || $( 'body.ox-slideout-active' ).length || _this.options.scrollStart + _this.delt_minimize >= $( window ).scrollTop() ) {
|
||||
return
|
||||
}
|
||||
if ( _this.options.searchOver ) {
|
||||
_this.options.searchOver = false;
|
||||
search_mini_form.find( '#search' ).removeClass( 'animate' );
|
||||
search_mini_form.find( '#search' ).stop( true, false ).animate( { opacity: 0 }, 400, 'easeInExpo', function () {
|
||||
$( 'body' ).removeClass('ox-search-opened form-search-over');
|
||||
} );
|
||||
}
|
||||
|
||||
} );
|
||||
search_mini_form.find( '#search' ).on( "touchend", function ( e ) {
|
||||
e.stopPropagation();
|
||||
} );
|
||||
}
|
||||
}
|
||||
} );
|
||||
} );
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
define([
|
||||
'jquery',
|
||||
'jquery-ui-modules/widget',
|
||||
'jquery-ui-modules/core',
|
||||
'Magento_Catalog/product/view/validation',
|
||||
'catalogAddToCart'
|
||||
], function ($) {
|
||||
'use strict';
|
||||
|
||||
$.widget('ox.AtProductValidate', {
|
||||
options: {
|
||||
bindSubmit: true,
|
||||
radioCheckboxClosest: '.nested',
|
||||
addToCartButtonSelector: '.action.tocart'
|
||||
},
|
||||
|
||||
/**
|
||||
* Uses Magento's validation widget for the form object.
|
||||
* @private
|
||||
*/
|
||||
_create: function () {
|
||||
var bindSubmit = this.options.bindSubmit;
|
||||
|
||||
this.element.validation({
|
||||
radioCheckboxClosest: this.options.radioCheckboxClosest,
|
||||
|
||||
/**
|
||||
* Uses catalogAddToCart widget as submit handler.
|
||||
* @param {Object} form
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
submitHandler: function (form) {
|
||||
var jqForm = $(form).catalogAddToCart({
|
||||
bindSubmit: bindSubmit
|
||||
});
|
||||
|
||||
jqForm.catalogAddToCart('submitForm', jqForm);
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
$(this.options.addToCartButtonSelector).attr('disabled', false);
|
||||
}
|
||||
});
|
||||
|
||||
return $.ox.AtProductValidate;
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
require(['jquery', 'domReady!', 'js/waypoints'], function ($) {
|
||||
$('.ox-animate:not(.animated)').waypoint({
|
||||
handler: function () {
|
||||
var $this = $(this.element),
|
||||
delay = $this.data('animdelay') || 1;
|
||||
if ($this.hasClass('animated')) {
|
||||
return;
|
||||
}
|
||||
if (this.hasOwnProperty('element')) {
|
||||
$this = $(this.element);
|
||||
} else {
|
||||
$this = $(this);
|
||||
}
|
||||
setTimeout(function () {
|
||||
$this.addClass('animated');
|
||||
}, delay);
|
||||
},
|
||||
offset: '80%'
|
||||
});
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user