Skip to content

Commit

Permalink
Merge pull request #5000 from magento-obsessive-owls/PB-76
Browse files Browse the repository at this point in the history
[Owls] Product List Template Swatches
  • Loading branch information
davemacaulay authored Nov 10, 2019
2 parents bec9025 + d814e72 commit 3efbe15
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 7 deletions.
16 changes: 16 additions & 0 deletions app/code/Magento/Catalog/view/base/requirejs-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

var config = {
map: {
'*': {
priceBox: 'Magento_Catalog/js/price-box',
priceOptionDate: 'Magento_Catalog/js/price-option-date',
priceOptionFile: 'Magento_Catalog/js/price-option-file',
priceOptions: 'Magento_Catalog/js/price-options',
priceUtils: 'Magento_Catalog/js/price-utils'
}
}
};
5 changes: 0 additions & 5 deletions app/code/Magento/Catalog/view/frontend/requirejs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ var config = {
upsellProducts: 'Magento_Catalog/js/upsell-products',
productListToolbarForm: 'Magento_Catalog/js/product/list/toolbar',
catalogGallery: 'Magento_Catalog/js/gallery',
priceBox: 'Magento_Catalog/js/price-box',
priceOptionDate: 'Magento_Catalog/js/price-option-date',
priceOptionFile: 'Magento_Catalog/js/price-option-file',
priceOptions: 'Magento_Catalog/js/price-options',
priceUtils: 'Magento_Catalog/js/price-utils',
catalogAddToCart: 'Magento_Catalog/js/catalog-add-to-cart'
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,12 @@ define([
* @private
*/
_init: function () {
// Don't render the same set of swatches twice
if ($(this.element).attr('data-rendered')) {
return;
}
$(this.element).attr('data-rendered', true);

if (_.isEmpty(this.options.jsonConfig.images)) {
this.options.useAjax = true;
// creates debounced variant of _LoadProductMedia()
Expand Down
63 changes: 61 additions & 2 deletions lib/web/mage/requirejs/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,66 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
var storageShim = {
_data: {},

/**
* Sets value of the specified item.
*
* @param {String} key - Key of the property.
* @param {*} value - Properties' value.
*/
setItem: function (key, value) {
'use strict';

this._data[key] = value + '';
},

/**
* Retrieves specified item.
*
* @param {String} key - Key of the property to be retrieved.
*/
getItem: function (key) {
'use strict';

return this._data[key];
},

/**
* Removes specified item.
*
* @param {String} key - Key of the property to be removed.
*/
removeItem: function (key) {
'use strict';

delete this._data[key];
},

/**
* Removes all items.
*/
clear: function () {
'use strict';

this._data = {};
}
};

define('buildTools', [
], function () {
'use strict';

var storage = window.localStorage,
var storage,
storeName = 'buildDisabled';

try {
storage = window.localStorage;
} catch (e) {
storage = storageShim;
}

return {
isEnabled: storage.getItem(storeName) === null,

Expand Down Expand Up @@ -70,9 +123,15 @@ define('statistician', [
], function () {
'use strict';

var storage = window.localStorage,
var storage,
stringify = JSON.stringify.bind(JSON);

try {
storage = window.localStorage;
} catch (e) {
storage = storageShim;
}

/**
* Removes duplicated entries of array, returning new one.
*
Expand Down

0 comments on commit 3efbe15

Please sign in to comment.