wickes-css2 2.106.0-develop.4 → 2.106.0-develop.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/js/basket.min.js +1 -1
- package/build/js/bundle.min.js +1 -1
- package/build/js/checkout.min.js +1 -1
- package/build/js/merged-checkout.min.js +1 -1
- package/build/js/page/filters/plp-filters-mobile.js +4 -7
- package/build/js/page/filters/plp-filters-utils.js +9 -0
- package/build/js/page/filters/plp-filters.js +11 -3
- package/build/js/page/share-project-list.js +151 -33
- package/build/js/plp-filters.min.js +2 -2
- package/build/js/project-list.min.js +1 -1
- package/build/js/share-project-list.min.js +1 -1
- package/package.json +1 -1
- package/src/js/page/filters/plp-filters-mobile.js +4 -7
- package/src/js/page/filters/plp-filters-utils.js +9 -0
- package/src/js/page/filters/plp-filters.js +11 -3
- package/src/js/page/share-project-list.js +151 -33
- package/src/js/components/share-project-list.js +0 -56
|
@@ -1 +1 @@
|
|
|
1
|
-
!function t(r,
|
|
1
|
+
!function t(i,r,c){function l(n,e){if(!r[n]){if(!i[n]){var o="function"==typeof require&&require;if(!e&&o)return o(n,!0);if(u)return u(n,!0);throw(e=new Error("Cannot find module '"+n+"'")).code="MODULE_NOT_FOUND",e}o=r[n]={exports:{}},i[n][0].call(o.exports,function(e){return l(i[n][1][e]||e)},o,o.exports,t,i,r,c)}return r[n].exports}for(var u="function"==typeof require&&require,e=0;e<c.length;e++)l(c[e]);return l}({1:[function(e,n,o){"use strict";var t,i,r=e("./utils/copy-to-clipboard"),e=window.Wick||{};function c(){document.activeElement}function l(e,n){if(e.length){var o=e.get(0),t=(o.value||"").length;c(),e.removeAttr("disabled");try{o.focus()}catch(e){console.error("[ShareProjectList] input.focus() failed",{source:n,error:e})}c();try{"function"==typeof o.setSelectionRange?o.setSelectionRange(0,t):"function"==typeof o.select&&o.select()}catch(e){console.error("[ShareProjectList] selection failed",{source:n,error:e})}c(),setTimeout(function(){c()},0),setTimeout(function(){c()},50),setTimeout(function(){c()},150)}}function u(e){var n=e.$input,o=e.$linkContainer,t=e.$link;n.on("focus",function(){c()}),n.on("blur",function(){c()}),t.on("click",function(e){e.preventDefault()}),o.on("mousedown",function(){c()}),o.on("click",function(e){c(),e.preventDefault(),l(n,"linkContainer click"),(e=String(n.val()||"").trim())&&(0,r.copyToClipboard)(e,o.get(0),{noUpperCase:!0}).then(function(){t.addClass(i.copied),c(),l(n,"copy success refocus"),setTimeout(function(){l(n,"copy success refocus timeout 0")},0),setTimeout(function(){l(n,"copy success refocus timeout 50")},50)}).catch(function(e){console.error("[ShareProjectList] Failed to copy shopping list link",e),c(),l(n,"copy error refocus")})}),n.on("click",function(){l(n,"input click"),t.removeClass(i.copied)})}e.ShareProjectList=(t={input:"#share-list-modal #shopping-list-link",linkContainer:"#copy-link",link:"a"},i={copied:"copy-link_hovered"},{init:function(){o=$(t.input),e=$(t.linkContainer),n=e.find(t.link);var e,n,o={$input:o,$linkContainer:e,$link:n};o.$input.length&&o.$linkContainer.length&&o.$link.length&&u(o)}}),e.ShareProjectList.init()},{"./utils/copy-to-clipboard":2}],2:[function(e,n,o){"use strict";Object.defineProperty(o,"__esModule",{value:!0}),o.copyToClipboard=function(e,n){var o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},e=function(e,n){e=null==e?"":e+"";return(n.noUpperCase?e:e.replace(/(^\w|\s\w)/g,function(e){return e.toUpperCase()})).split(" ").filter(function(e){return""!==e}).join(" ").trim()}(e,o);if(!e)return Promise.reject(new Error("Empty text"));if(null!=(o=window.webkit)&&null!=(o=o.messageHandlers)&&o.copy)try{return window.webkit.messageHandlers.copy.postMessage(e),Promise.resolve(!0)}catch(e){console.error(e)}if(null!=(o=window.Android)&&o.copyToClipboard&&"function"==typeof window.Android.copyToClipboard)try{return window.Android.copyToClipboard(e),Promise.resolve(!0)}catch(e){console.error(e)}if(null!=(o=navigator.clipboard)&&o.writeText)return navigator.clipboard.writeText(e).then(function(){return!0});return function(u,s){return new Promise(function(e,n){try{var o,t=$(s).parent(),i=$("<textarea>").val(u).attr("readonly","readonly").css({position:"fixed",top:0,left:"-9999px",opacity:0,width:"1px",height:"1px",padding:0,border:0,margin:0}),r=(t.append(i),i.get(0)),c=(r.focus(),(r.value||"").length),l=("function"==typeof r.setSelectionRange?r.setSelectionRange(0,c):i.select(),document.execCommand("copy"));i.remove(),window.getSelection&&(o=window.getSelection())&&o.removeAllRanges&&o.removeAllRanges(),l?e(!0):n(new Error("execCommand failed"))}catch(e){n(e)}})}(e,n)}},{}]},{},[1]);
|
package/package.json
CHANGED
|
@@ -65,11 +65,6 @@ Wick.PLPFiltersMobile = {
|
|
|
65
65
|
$btn.text(total > 0 ? `View results (${total})` : 'View results');
|
|
66
66
|
},
|
|
67
67
|
|
|
68
|
-
hideAccordions() {
|
|
69
|
-
$(Wick.PLPFiltersMobile.$ACCORDION).addClass(Wick.PLPFiltersMobile.ACCORDION_COLLAPSED);
|
|
70
|
-
$(Wick.PLPFiltersMobile.$ACCORDION_CONTENT).hide();
|
|
71
|
-
},
|
|
72
|
-
|
|
73
68
|
init() {
|
|
74
69
|
// two-way binding for input between desktop and modal
|
|
75
70
|
$(document)
|
|
@@ -86,13 +81,14 @@ Wick.PLPFiltersMobile = {
|
|
|
86
81
|
$(document)
|
|
87
82
|
.off('shown.bs.modal.plpFiltersMobile', Wick.PLPFiltersMobile.MODAL_SEL)
|
|
88
83
|
.on('shown.bs.modal.plpFiltersMobile', Wick.PLPFiltersMobile.MODAL_SEL, function () {
|
|
89
|
-
Wick.PLPFilters.setDOMFromState($(this), Wick.PLPFilters.
|
|
84
|
+
Wick.PLPFilters.setDOMFromState($(this), Wick.PLPFilters.draftState);
|
|
90
85
|
});
|
|
91
86
|
|
|
92
87
|
$(document)
|
|
93
88
|
.off('hide.bs.modal.plpFiltersMobile', Wick.PLPFiltersMobile.MODAL_SEL)
|
|
94
89
|
.on('hide.bs.modal.plpFiltersMobile', Wick.PLPFiltersMobile.MODAL_SEL, function () {
|
|
95
|
-
Wick.PLPFiltersMobile.
|
|
90
|
+
const scope = $(Wick.PLPFiltersMobile.ROOT_WRAPPER).add($(this));
|
|
91
|
+
Wick.PLPFilters.draftState = Wick.PLPFilters.collectStateFromDOM(scope);
|
|
96
92
|
});
|
|
97
93
|
|
|
98
94
|
// mobile "View results" button in modal
|
|
@@ -126,6 +122,7 @@ Wick.PLPFiltersMobile = {
|
|
|
126
122
|
|
|
127
123
|
e.preventDefault();
|
|
128
124
|
|
|
125
|
+
Wick.PLPFilters.draftState = {};
|
|
129
126
|
Wick.PLPFilters.appliedState = {};
|
|
130
127
|
Wick.PLPFilters.writeStateToURL(Wick.PLPFilters.appliedState, false);
|
|
131
128
|
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
var Wick = window.Wick || {};
|
|
2
2
|
|
|
3
3
|
Wick.PLPUtils = (function () {
|
|
4
|
+
function cloneState(state) {
|
|
5
|
+
const out = {};
|
|
6
|
+
Object.keys(state).forEach((k) => {
|
|
7
|
+
out[k] = new Set(state[k]);
|
|
8
|
+
});
|
|
9
|
+
return out;
|
|
10
|
+
}
|
|
11
|
+
|
|
4
12
|
function syncTwinInputsByName(name, checked, source) {
|
|
5
13
|
const all = $('.filter-card__checkbox, .swatch__checkbox, .checkbox__input').filter(
|
|
6
14
|
function () {
|
|
@@ -57,6 +65,7 @@ Wick.PLPUtils = (function () {
|
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
return {
|
|
68
|
+
cloneState,
|
|
60
69
|
syncTwinInputsByName,
|
|
61
70
|
getPanelType,
|
|
62
71
|
countItems,
|
|
@@ -6,6 +6,7 @@ Wick.PLPFilters = {
|
|
|
6
6
|
ROOT: '.plp-filters',
|
|
7
7
|
GROUP: '.plp-filters__group',
|
|
8
8
|
APPLY_BTN: '.plp-filters__apply',
|
|
9
|
+
draftState: null,
|
|
9
10
|
|
|
10
11
|
INPUTS: '.filter-card__checkbox, .swatch__checkbox, .checkbox__input',
|
|
11
12
|
|
|
@@ -24,6 +25,7 @@ Wick.PLPFilters = {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
Wick.PLPFilters.appliedState = Wick.PLPFilters.readStateFromURL(rootWrapper);
|
|
28
|
+
Wick.PLPFilters.draftState = Wick.PLPUtils.cloneState(Wick.PLPFilters.appliedState);
|
|
27
29
|
Wick.PLPFilters.setDOMFromState(rootWrapper, Wick.PLPFilters.appliedState);
|
|
28
30
|
|
|
29
31
|
// 3) chips
|
|
@@ -43,8 +45,11 @@ Wick.PLPFilters = {
|
|
|
43
45
|
handlePageShow() {
|
|
44
46
|
window.addEventListener('pageshow', function () {
|
|
45
47
|
const rootWrapper = $(Wick.PLPFilters.ROOT_WRAPPER);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
const stateScope = rootWrapper.add($(Wick.PLPFiltersMobile.MODAL_SEL));
|
|
49
|
+
|
|
50
|
+
Wick.PLPFilters.appliedState = Wick.PLPFilters.readStateFromURL(stateScope);
|
|
51
|
+
Wick.PLPFilters.draftState = Wick.PLPFilters.appliedState;
|
|
52
|
+
Wick.PLPFilters.setDOMFromState(stateScope, Wick.PLPFilters.appliedState);
|
|
48
53
|
});
|
|
49
54
|
},
|
|
50
55
|
|
|
@@ -187,7 +192,10 @@ Wick.PLPFilters = {
|
|
|
187
192
|
|
|
188
193
|
// ===== APPLY
|
|
189
194
|
applyFromScopes(scopeForCollect, push) {
|
|
190
|
-
|
|
195
|
+
const nextState = Wick.PLPFilters.collectStateFromDOM(scopeForCollect);
|
|
196
|
+
|
|
197
|
+
Wick.PLPFilters.draftState = nextState;
|
|
198
|
+
Wick.PLPFilters.appliedState = nextState;
|
|
191
199
|
Wick.PLPFilters.writeStateToURL(Wick.PLPFilters.appliedState, !!push);
|
|
192
200
|
},
|
|
193
201
|
|
|
@@ -1,57 +1,175 @@
|
|
|
1
1
|
import { copyToClipboard } from './utils/copy-to-clipboard';
|
|
2
2
|
|
|
3
|
-
var Wick = Wick || {};
|
|
3
|
+
var Wick = window.Wick || {};
|
|
4
|
+
|
|
4
5
|
Wick.ShareProjectList = (function () {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const SELECTORS = {
|
|
7
|
+
input: '#share-list-modal #shopping-list-link',
|
|
8
|
+
linkContainer: '#copy-link',
|
|
9
|
+
link: 'a',
|
|
10
|
+
};
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const CLASSES = {
|
|
13
|
+
copied: 'copy-link_hovered',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function logActiveElement() {
|
|
17
|
+
const active = document.activeElement;
|
|
18
|
+
|
|
19
|
+
if (!active) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function getElements() {
|
|
25
|
+
const $input = $(SELECTORS.input);
|
|
26
|
+
const $linkContainer = $(SELECTORS.linkContainer);
|
|
27
|
+
const $link = $linkContainer.find(SELECTORS.link);
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
$input: $input,
|
|
31
|
+
$linkContainer: $linkContainer,
|
|
32
|
+
$link: $link,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function enableFocusAndSelect($input, source) {
|
|
37
|
+
if (!$input.length) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
14
40
|
|
|
15
|
-
|
|
16
|
-
|
|
41
|
+
const input = $input.get(0);
|
|
42
|
+
const value = input.value || '';
|
|
43
|
+
const valueLength = value.length;
|
|
17
44
|
|
|
18
|
-
|
|
45
|
+
logActiveElement('[ShareProjectList] before removeAttr disabled');
|
|
19
46
|
|
|
20
|
-
|
|
47
|
+
$input.removeAttr('disabled');
|
|
21
48
|
|
|
22
|
-
|
|
49
|
+
try {
|
|
50
|
+
input.focus();
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error('[ShareProjectList] input.focus() failed', {
|
|
53
|
+
source: source,
|
|
54
|
+
error: error,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
logActiveElement('[ShareProjectList] after input.focus()');
|
|
23
59
|
|
|
24
|
-
|
|
25
|
-
if (typeof
|
|
26
|
-
|
|
27
|
-
} else if (typeof
|
|
28
|
-
|
|
60
|
+
try {
|
|
61
|
+
if (typeof input.setSelectionRange === 'function') {
|
|
62
|
+
input.setSelectionRange(0, valueLength);
|
|
63
|
+
} else if (typeof input.select === 'function') {
|
|
64
|
+
input.select();
|
|
29
65
|
}
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error('[ShareProjectList] selection failed', {
|
|
68
|
+
source: source,
|
|
69
|
+
error: error,
|
|
70
|
+
});
|
|
30
71
|
}
|
|
31
72
|
|
|
32
|
-
|
|
33
|
-
|
|
73
|
+
logActiveElement('[ShareProjectList] after selection');
|
|
74
|
+
|
|
75
|
+
setTimeout(function () {
|
|
76
|
+
logActiveElement('[ShareProjectList] after 0ms timeout');
|
|
77
|
+
}, 0);
|
|
78
|
+
|
|
79
|
+
setTimeout(function () {
|
|
80
|
+
logActiveElement('[ShareProjectList] after 50ms timeout');
|
|
81
|
+
}, 50);
|
|
82
|
+
|
|
83
|
+
setTimeout(function () {
|
|
84
|
+
logActiveElement('[ShareProjectList] after 150ms timeout');
|
|
85
|
+
}, 150);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function getInputValue($input) {
|
|
89
|
+
const value = String($input.val() || '').trim();
|
|
90
|
+
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function bindEvents(elements) {
|
|
95
|
+
const $input = elements.$input;
|
|
96
|
+
const $linkContainer = elements.$linkContainer;
|
|
97
|
+
const $link = elements.$link;
|
|
34
98
|
|
|
35
|
-
|
|
99
|
+
$input.on('focus', function () {
|
|
100
|
+
logActiveElement('[ShareProjectList] on input focus');
|
|
101
|
+
});
|
|
36
102
|
|
|
37
|
-
|
|
38
|
-
|
|
103
|
+
$input.on('blur', function () {
|
|
104
|
+
logActiveElement('[ShareProjectList] on input blur');
|
|
105
|
+
});
|
|
39
106
|
|
|
40
|
-
|
|
107
|
+
$link.on('click', function (event) {
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
$linkContainer.on('mousedown', function () {
|
|
112
|
+
logActiveElement('[ShareProjectList] on mousedown before focus');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
$linkContainer.on('click', function (event) {
|
|
116
|
+
let value;
|
|
117
|
+
|
|
118
|
+
logActiveElement('[ShareProjectList] before click preventDefault');
|
|
119
|
+
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
|
|
122
|
+
enableFocusAndSelect($input, 'linkContainer click');
|
|
123
|
+
|
|
124
|
+
value = getInputValue($input);
|
|
125
|
+
if (!value) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
copyToClipboard(value, $linkContainer.get(0), { noUpperCase: true })
|
|
41
130
|
.then(function () {
|
|
42
|
-
$
|
|
131
|
+
$link.addClass(CLASSES.copied);
|
|
132
|
+
|
|
133
|
+
logActiveElement('[ShareProjectList] after copy success before refocus');
|
|
134
|
+
|
|
135
|
+
enableFocusAndSelect($input, 'copy success refocus');
|
|
136
|
+
|
|
137
|
+
setTimeout(function () {
|
|
138
|
+
enableFocusAndSelect($input, 'copy success refocus timeout 0');
|
|
139
|
+
}, 0);
|
|
140
|
+
|
|
141
|
+
setTimeout(function () {
|
|
142
|
+
enableFocusAndSelect($input, 'copy success refocus timeout 50');
|
|
143
|
+
}, 50);
|
|
43
144
|
})
|
|
44
|
-
.catch(function (
|
|
45
|
-
console.error(
|
|
145
|
+
.catch(function (error) {
|
|
146
|
+
console.error('[ShareProjectList] Failed to copy shopping list link', error);
|
|
147
|
+
|
|
148
|
+
logActiveElement('[ShareProjectList] after copy error before refocus');
|
|
149
|
+
|
|
150
|
+
enableFocusAndSelect($input, 'copy error refocus');
|
|
46
151
|
});
|
|
47
152
|
});
|
|
48
153
|
|
|
49
|
-
$input.on('click', function (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
$actualLink.removeClass(copyClass);
|
|
154
|
+
$input.on('click', function () {
|
|
155
|
+
enableFocusAndSelect($input, 'input click');
|
|
156
|
+
$link.removeClass(CLASSES.copied);
|
|
53
157
|
});
|
|
54
158
|
}
|
|
55
159
|
|
|
56
|
-
init()
|
|
160
|
+
function init() {
|
|
161
|
+
var elements = getElements();
|
|
162
|
+
|
|
163
|
+
if (!elements.$input.length || !elements.$linkContainer.length || !elements.$link.length) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
bindEvents(elements);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
init: init,
|
|
172
|
+
};
|
|
57
173
|
})();
|
|
174
|
+
|
|
175
|
+
Wick.ShareProjectList.init();
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// this file should be delete after <script defer="defer" src="./js/share-project-list.min.js"></script>
|
|
2
|
-
// implementation on backend (IC-1182 comment https://wickesit.atlassian.net/browse/IC-1182?focusedCommentId=312018)
|
|
3
|
-
|
|
4
|
-
var Wick = Wick || {};
|
|
5
|
-
|
|
6
|
-
Wick.ShareProjectList = (function () {
|
|
7
|
-
function init() {
|
|
8
|
-
var shoppingListLinkInput = $('#share-list-modal #shopping-list-link'),
|
|
9
|
-
shoppingListLinkEl = shoppingListLinkInput[0],
|
|
10
|
-
linkContainer = $('#copy-link'),
|
|
11
|
-
actualLink = linkContainer.find('a'),
|
|
12
|
-
copyClass = 'copy-link_hovered';
|
|
13
|
-
|
|
14
|
-
actualLink.click(function (e) {
|
|
15
|
-
e.preventDefault();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
linkContainer.click(function () {
|
|
19
|
-
if (navigator.userAgent.match(/TradeProMobile_iOS|DIYMobile_iOS/i)) {
|
|
20
|
-
iosCopyToClipboard(shoppingListLinkInput);
|
|
21
|
-
} else if (navigator.userAgent.match(/ipad|ipod|iphone/i)) {
|
|
22
|
-
shoppingListLinkEl.select();
|
|
23
|
-
shoppingListLinkEl.setSelectionRange(0, 999999);
|
|
24
|
-
} else {
|
|
25
|
-
shoppingListLinkEl.select();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
document.execCommand('copy');
|
|
29
|
-
actualLink.addClass(copyClass);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
shoppingListLinkInput.click(function () {
|
|
33
|
-
linkContainer.click();
|
|
34
|
-
actualLink.removeClass(copyClass);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function iosCopyToClipboard($input) {
|
|
39
|
-
var el = $input.get(0);
|
|
40
|
-
var editable = el.contentEditable;
|
|
41
|
-
var readOnly = el.readOnly;
|
|
42
|
-
|
|
43
|
-
el.contentEditable = true;
|
|
44
|
-
el.readOnly = false;
|
|
45
|
-
var range = document.createRange();
|
|
46
|
-
range.selectNodeContents(el);
|
|
47
|
-
var sel = window.getSelection();
|
|
48
|
-
sel.removeAllRanges();
|
|
49
|
-
sel.addRange(range);
|
|
50
|
-
el.setSelectionRange(0, 999999);
|
|
51
|
-
el.contentEditable = editable;
|
|
52
|
-
el.readOnly = readOnly;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
init();
|
|
56
|
-
})();
|