ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'Magento_Catalog/js/product/view/product-ids-resolver',
|
||||
'catalogAddToCart',
|
||||
'jquery-ui-modules/widget',
|
||||
'jquery-ui-modules/core',
|
||||
], function ($, idsResolver) {
|
||||
'use strict';
|
||||
|
||||
$.widget('mage.OxQuickviewcatalogAddToCart', $.mage.catalogAddToCart, {
|
||||
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;
|
||||
|
||||
$(window.parent.document.body).find(self.options.minicartSelector).trigger('contentLoading');
|
||||
self.disableAddToCartButton(form);
|
||||
formData = new FormData(form[0]);
|
||||
|
||||
window.parent.ajaxCartTransport = false;
|
||||
|
||||
window.parent.jQuery.ajax({
|
||||
url: form.attr('action'),
|
||||
data: formData,
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
|
||||
/** @inheritdoc */
|
||||
beforeSend: function () {
|
||||
if (self.isLoaderEnabled()) {
|
||||
$(window.parent.document.body).trigger(self.options.processStart);
|
||||
}
|
||||
},
|
||||
|
||||
/** @inheritdoc */
|
||||
success: function (res) {
|
||||
var eventData, parameters;
|
||||
|
||||
$(window.parent.document).trigger('ajax:addToCart', {
|
||||
'sku': form.data().productSku,
|
||||
'productIds': productIds,
|
||||
'form': form,
|
||||
'response': res
|
||||
});
|
||||
|
||||
if (self.isLoaderEnabled()) {
|
||||
$(window.parent.document.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
|
||||
$(window.parent.document.body).trigger('catalogCategoryAddToCartRedirect', eventData);
|
||||
|
||||
if (eventData.redirectParameters.length > 0) {
|
||||
parameters = res.backUrl.split('#');
|
||||
parameters.push(eventData.redirectParameters.join('&'));
|
||||
res.backUrl = parameters.join('#');
|
||||
}
|
||||
|
||||
self._redirect(res.backUrl);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (res.messages) {
|
||||
$(window.parent.document.body).find(self.options.messagesSelector).html(res.messages);
|
||||
}
|
||||
|
||||
if (res.minicart) {
|
||||
$(window.parent.document.body).find(self.options.minicartSelector).replaceWith(res.minicart);
|
||||
$(window.parent.document.body).find(self.options.minicartSelector).trigger('contentUpdated');
|
||||
}
|
||||
|
||||
if (res.product && res.product.statusText) {
|
||||
$(window.parent.document.body).find(self.options.productStatusSelector)
|
||||
.removeClass('available')
|
||||
.addClass('unavailable')
|
||||
.find('span')
|
||||
.html(res.product.statusText);
|
||||
}
|
||||
self.enableAddToCartButton(form);
|
||||
|
||||
window.parent.ajaxCartTransport = !window.OXAjaxNShowMCart;
|
||||
},
|
||||
|
||||
/** @inheritdoc */
|
||||
error: function (res) {
|
||||
$(window.parent.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') {
|
||||
window.parent.location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return $.mage.OxQuickviewcatalogAddToCart;
|
||||
});
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
define(['jquery', 'OxQuickview', 'OXmodal'], function ($, quickview) {
|
||||
"use strict";
|
||||
|
||||
$.widget('mage.OxQuickviewInit', {
|
||||
_create: function () {
|
||||
$('#ox_quickview_wrapper').OXmodal({
|
||||
defaultModalClass: 'ox-dialog ox-smallmodal',
|
||||
type: 'modal',
|
||||
overlayClass: "ox-slideout-shadow",
|
||||
closeButtonTrigger: '.ox-overlay-close-btn',
|
||||
"htmlClass": "ox-fixed",
|
||||
});
|
||||
|
||||
$(document.body).on('click.OxQuickview', '.ox-quickview-button', function (event) {
|
||||
event.preventDefault();
|
||||
var prodUrl = $(this).attr('data-quickview-url');
|
||||
if (prodUrl) {
|
||||
quickview.displayContent(prodUrl);
|
||||
}
|
||||
}).on('closeOxQuickview', function () {
|
||||
quickview.close();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return $.mage.OxQuickviewInit;
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
define( [
|
||||
'jquery',
|
||||
'OXmodal'
|
||||
], function ( $ ) {
|
||||
"use strict";
|
||||
|
||||
var oxquickview = {
|
||||
displayContent: function ( prodUrl ) {
|
||||
if ( !prodUrl.length ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var a = $( '#ox_quickview_wrapper' );
|
||||
if ( !a.length ) {
|
||||
a = $( '<div>' ).attr( 'id', 'ox_quickview_wrapper' );
|
||||
$( 'body' ).append( a );
|
||||
a.OXmodal( {
|
||||
defaultModalClass: 'ox-dialog ox-smallmodal',
|
||||
type: 'modal',
|
||||
overlayClass: "ox-slideout-shadow",
|
||||
closeButtonTrigger: '.ox-overlay-close-btn',
|
||||
"htmlClass": "ox-fixed",
|
||||
} );
|
||||
}
|
||||
a.find( '.ox_quickview-preloader' ).show();
|
||||
a.find( 'iframe' ).remove();
|
||||
a.append( $( '<iframe>' ).attr( {
|
||||
src: prodUrl,
|
||||
frameborder: 0,
|
||||
allowfullscreen: 0,
|
||||
style: 'opacity: 0;width: 100%;height: 100%;',
|
||||
} ) );
|
||||
(a.data( 'mageOXmodal' ) || a.data( 'mage-OXmodal' )).open();
|
||||
a.parent().on( 'click', function ( e ) {
|
||||
(a.data( 'mageOXmodal' ) || a.data( 'mage-OXmodal' )).close();
|
||||
} );
|
||||
},
|
||||
close:function () {
|
||||
let a = $( '#ox_quickview_wrapper' );
|
||||
(a.data( 'mageOXmodal' ) || a.data( 'mage-OXmodal' )).close();
|
||||
}
|
||||
};
|
||||
|
||||
window.oxquickview = oxquickview;
|
||||
return oxquickview;
|
||||
} );
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
define([
|
||||
'jquery',
|
||||
'mage/mage',
|
||||
'Magento_Catalog/product/view/validation',
|
||||
'OxQuickviewcatalogAddToCart'
|
||||
], function ($) {
|
||||
'use strict';
|
||||
|
||||
$.widget('mage.productValidate', {
|
||||
options: {
|
||||
bindSubmit: false,
|
||||
radioCheckboxClosest: '.nested'
|
||||
},
|
||||
|
||||
/**
|
||||
* 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 OxQuickviewcatalogAddToCart widget as submit handler.
|
||||
* @param {Object} form
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
submitHandler: function (form) {
|
||||
var jqForm = $(form).OxQuickviewcatalogAddToCart({
|
||||
bindSubmit: bindSubmit
|
||||
});
|
||||
|
||||
jqForm.OxQuickviewcatalogAddToCart('submitForm', jqForm);
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return $.mage.productValidate;
|
||||
});
|
||||
Reference in New Issue
Block a user