Skip to content

Commit 3efbe15

Browse files
authored
Merge pull request #5000 from magento-obsessive-owls/PB-76
[Owls] Product List Template Swatches
2 parents bec9025 + d814e72 commit 3efbe15

File tree

4 files changed

+83
-7
lines changed

4 files changed

+83
-7
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
var config = {
7+
map: {
8+
'*': {
9+
priceBox: 'Magento_Catalog/js/price-box',
10+
priceOptionDate: 'Magento_Catalog/js/price-option-date',
11+
priceOptionFile: 'Magento_Catalog/js/price-option-file',
12+
priceOptions: 'Magento_Catalog/js/price-options',
13+
priceUtils: 'Magento_Catalog/js/price-utils'
14+
}
15+
}
16+
};

app/code/Magento/Catalog/view/frontend/requirejs-config.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ var config = {
1111
upsellProducts: 'Magento_Catalog/js/upsell-products',
1212
productListToolbarForm: 'Magento_Catalog/js/product/list/toolbar',
1313
catalogGallery: 'Magento_Catalog/js/gallery',
14-
priceBox: 'Magento_Catalog/js/price-box',
15-
priceOptionDate: 'Magento_Catalog/js/price-option-date',
16-
priceOptionFile: 'Magento_Catalog/js/price-option-file',
17-
priceOptions: 'Magento_Catalog/js/price-options',
18-
priceUtils: 'Magento_Catalog/js/price-utils',
1914
catalogAddToCart: 'Magento_Catalog/js/catalog-add-to-cart'
2015
}
2116
},

app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js renamed to app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,12 @@ define([
296296
* @private
297297
*/
298298
_init: function () {
299+
// Don't render the same set of swatches twice
300+
if ($(this.element).attr('data-rendered')) {
301+
return;
302+
}
303+
$(this.element).attr('data-rendered', true);
304+
299305
if (_.isEmpty(this.options.jsonConfig.images)) {
300306
this.options.useAjax = true;
301307
// creates debounced variant of _LoadProductMedia()

lib/web/mage/requirejs/static.js

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,66 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
var storageShim = {
6+
_data: {},
7+
8+
/**
9+
* Sets value of the specified item.
10+
*
11+
* @param {String} key - Key of the property.
12+
* @param {*} value - Properties' value.
13+
*/
14+
setItem: function (key, value) {
15+
'use strict';
16+
17+
this._data[key] = value + '';
18+
},
19+
20+
/**
21+
* Retrieves specified item.
22+
*
23+
* @param {String} key - Key of the property to be retrieved.
24+
*/
25+
getItem: function (key) {
26+
'use strict';
27+
28+
return this._data[key];
29+
},
30+
31+
/**
32+
* Removes specified item.
33+
*
34+
* @param {String} key - Key of the property to be removed.
35+
*/
36+
removeItem: function (key) {
37+
'use strict';
38+
39+
delete this._data[key];
40+
},
41+
42+
/**
43+
* Removes all items.
44+
*/
45+
clear: function () {
46+
'use strict';
47+
48+
this._data = {};
49+
}
50+
};
51+
552
define('buildTools', [
653
], function () {
754
'use strict';
855

9-
var storage = window.localStorage,
56+
var storage,
1057
storeName = 'buildDisabled';
1158

59+
try {
60+
storage = window.localStorage;
61+
} catch (e) {
62+
storage = storageShim;
63+
}
64+
1265
return {
1366
isEnabled: storage.getItem(storeName) === null,
1467

@@ -70,9 +123,15 @@ define('statistician', [
70123
], function () {
71124
'use strict';
72125

73-
var storage = window.localStorage,
126+
var storage,
74127
stringify = JSON.stringify.bind(JSON);
75128

129+
try {
130+
storage = window.localStorage;
131+
} catch (e) {
132+
storage = storageShim;
133+
}
134+
76135
/**
77136
* Removes duplicated entries of array, returning new one.
78137
*

0 commit comments

Comments
 (0)