-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from magento-mpi/MAGETWO-33035
[MPI] Multi-tenant mode and DI configuration optimization
- Loading branch information
Showing
69 changed files
with
2,010 additions
and
642 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
define([ | ||
'jquery', | ||
'jquery/ui' | ||
], function($) { | ||
"use strict"; | ||
|
||
$.widget('mage.catalogAddToCart', { | ||
|
||
options: { | ||
processStart: null, | ||
processStop: null, | ||
bindSubmit: true, | ||
minicartSelector: '[data-block="minicart"]', | ||
messagesSelector: '[data-placeholder="messages"]', | ||
productStatusSelector: '.stock.available' | ||
}, | ||
|
||
_create: function() { | ||
if (this.options.bindSubmit) { | ||
this._bindSubmit(); | ||
} | ||
}, | ||
|
||
_bindSubmit: function() { | ||
var self = this; | ||
this.element.on('submit', function(e) { | ||
e.preventDefault(); | ||
self.submitForm($(this)); | ||
}); | ||
}, | ||
|
||
isLoaderEnabled: function() { | ||
return this.options.processStart && this.options.processStop; | ||
}, | ||
|
||
submitForm: function(form) { | ||
var self = this; | ||
$.ajax({ | ||
url: form.attr('action'), | ||
data: form.serialize(), | ||
type: 'post', | ||
dataType: 'json', | ||
beforeSend: function() { | ||
if (self.isLoaderEnabled()) { | ||
$('body').trigger(self.options.processStart); | ||
} | ||
}, | ||
success: function(res) { | ||
if (self.isLoaderEnabled()) { | ||
$('body').trigger(self.options.processStop); | ||
} | ||
|
||
if (res.backUrl) { | ||
window.location = res.backUrl; | ||
return; | ||
} | ||
if (res.messages) { | ||
$(self.options.messagesSelector).html(res.messages); | ||
} | ||
if (res.minicart) { | ||
$(self.options.minicartSelector).replaceWith(res.minicart); | ||
} | ||
if (res.product && res.product.statusText) { | ||
$(self.options.productStatusSelector) | ||
.removeClass('available') | ||
.addClass('unavailable') | ||
.find('span') | ||
.html(res.product.statusText); | ||
} | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
return $.mage.catalogAddToCart; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.