@pageboard/html 0.12.28 → 0.13.0
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/elements/card.js +0 -2
- package/elements/fieldsets.js +0 -1
- package/elements/list.js +0 -1
- package/elements/tab.js +0 -1
- package/lib/stickyfill.js +546 -0
- package/package.json +1 -1
- package/ui/fieldset-list.js +1 -4
- package/ui/form.js +3 -10
- package/ui/input-range.js +2 -8
- package/ui/query-tags.js +4 -7
- package/ui/select.js +2 -8
package/elements/card.js
CHANGED
|
@@ -155,7 +155,6 @@ exports.card_header = {
|
|
|
155
155
|
menu: 'widget',
|
|
156
156
|
context: 'card//',
|
|
157
157
|
icon: '<b class="icon">H</b>',
|
|
158
|
-
inplace: true,
|
|
159
158
|
contents: "inline*",
|
|
160
159
|
html: '<div class="header">Header</div>'
|
|
161
160
|
};
|
|
@@ -173,7 +172,6 @@ exports.card_meta = {
|
|
|
173
172
|
menu: 'widget',
|
|
174
173
|
context: 'card//',
|
|
175
174
|
icon: '<em class="icon">M</em>',
|
|
176
|
-
inplace: true,
|
|
177
175
|
contents: "inline*",
|
|
178
176
|
html: '<div class="meta">Meta</div>'
|
|
179
177
|
};
|
package/elements/fieldsets.js
CHANGED
package/elements/list.js
CHANGED
package/elements/tab.js
CHANGED
|
@@ -38,7 +38,6 @@ exports.tab_item = {
|
|
|
38
38
|
title: "Item",
|
|
39
39
|
icon: '<i class="icons"><b class="icon">Tab</b><i class="corner add icon"></i></i>',
|
|
40
40
|
menu: 'widget',
|
|
41
|
-
inplace: true,
|
|
42
41
|
context: 'tabs_container_items/',
|
|
43
42
|
contents: "inline*",
|
|
44
43
|
html: '<a class="item">Tab Item</a>'
|
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Stickyfill – `position: sticky` polyfill
|
|
3
|
+
* v. 2.1.0 | https://github.com/wilddeer/stickyfill
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
;(function(window, document) {
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* 1. Check if the browser supports `position: sticky` natively or is too old to run the polyfill.
|
|
12
|
+
* If either of these is the case set `seppuku` flag. It will be checked later to disable key features
|
|
13
|
+
* of the polyfill, but the API will remain functional to avoid breaking things.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
17
|
+
|
|
18
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
19
|
+
|
|
20
|
+
var seppuku = false;
|
|
21
|
+
|
|
22
|
+
var isWindowDefined = typeof window !== 'undefined';
|
|
23
|
+
|
|
24
|
+
// The polyfill can’t function properly without `window` or `window.getComputedStyle`.
|
|
25
|
+
if (!isWindowDefined || !window.getComputedStyle) seppuku = true;
|
|
26
|
+
// Dont’t get in a way if the browser supports `position: sticky` natively.
|
|
27
|
+
else {
|
|
28
|
+
(function () {
|
|
29
|
+
var testNode = document.createElement('div');
|
|
30
|
+
|
|
31
|
+
if (['', '-webkit-', '-moz-', '-ms-'].some(function (prefix) {
|
|
32
|
+
try {
|
|
33
|
+
testNode.style.position = prefix + 'sticky';
|
|
34
|
+
} catch (e) {}
|
|
35
|
+
|
|
36
|
+
return testNode.style.position != '';
|
|
37
|
+
})) seppuku = true;
|
|
38
|
+
})();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
* 2. “Global” vars used across the polyfill
|
|
43
|
+
*/
|
|
44
|
+
var isInitialized = false;
|
|
45
|
+
|
|
46
|
+
// Check if Shadow Root constructor exists to make further checks simpler
|
|
47
|
+
var shadowRootExists = typeof ShadowRoot !== 'undefined';
|
|
48
|
+
|
|
49
|
+
// Last saved scroll position
|
|
50
|
+
var scroll = {
|
|
51
|
+
top: null,
|
|
52
|
+
left: null
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// Array of created Sticky instances
|
|
56
|
+
var stickies = [];
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
* 3. Utility functions
|
|
60
|
+
*/
|
|
61
|
+
function extend(targetObj, sourceObject) {
|
|
62
|
+
for (var key in sourceObject) {
|
|
63
|
+
if (sourceObject.hasOwnProperty(key)) {
|
|
64
|
+
targetObj[key] = sourceObject[key];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function parseNumeric(val) {
|
|
70
|
+
return parseFloat(val) || 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function getDocOffsetTop(node) {
|
|
74
|
+
var docOffsetTop = 0;
|
|
75
|
+
|
|
76
|
+
while (node) {
|
|
77
|
+
docOffsetTop += node.offsetTop;
|
|
78
|
+
node = node.offsetParent;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return docOffsetTop;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/*
|
|
85
|
+
* 4. Sticky class
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
var Sticky = function () {
|
|
89
|
+
function Sticky(node) {
|
|
90
|
+
_classCallCheck(this, Sticky);
|
|
91
|
+
|
|
92
|
+
if (!(node instanceof HTMLElement)) throw new Error('First argument must be HTMLElement');
|
|
93
|
+
if (stickies.some(function (sticky) {
|
|
94
|
+
return sticky._node === node;
|
|
95
|
+
})) throw new Error('Stickyfill is already applied to this node');
|
|
96
|
+
|
|
97
|
+
this._node = node;
|
|
98
|
+
this._stickyMode = null;
|
|
99
|
+
this._active = false;
|
|
100
|
+
|
|
101
|
+
stickies.push(this);
|
|
102
|
+
|
|
103
|
+
this.refresh();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
_createClass(Sticky, [{
|
|
107
|
+
key: 'refresh',
|
|
108
|
+
value: function refresh() {
|
|
109
|
+
if (seppuku || this._removed) return;
|
|
110
|
+
if (this._active) this._deactivate();
|
|
111
|
+
|
|
112
|
+
var node = this._node;
|
|
113
|
+
|
|
114
|
+
/*
|
|
115
|
+
* 1. Save node computed props
|
|
116
|
+
*/
|
|
117
|
+
var nodeComputedStyle = getComputedStyle(node);
|
|
118
|
+
var nodeComputedProps = {
|
|
119
|
+
position: nodeComputedStyle.position,
|
|
120
|
+
top: nodeComputedStyle.top,
|
|
121
|
+
display: nodeComputedStyle.display,
|
|
122
|
+
marginTop: nodeComputedStyle.marginTop,
|
|
123
|
+
marginBottom: nodeComputedStyle.marginBottom,
|
|
124
|
+
marginLeft: nodeComputedStyle.marginLeft,
|
|
125
|
+
marginRight: nodeComputedStyle.marginRight,
|
|
126
|
+
cssFloat: nodeComputedStyle.cssFloat
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/*
|
|
130
|
+
* 2. Check if the node can be activated
|
|
131
|
+
*/
|
|
132
|
+
if (isNaN(parseFloat(nodeComputedProps.top)) || nodeComputedProps.display == 'table-cell' || nodeComputedProps.display == 'none') return;
|
|
133
|
+
|
|
134
|
+
this._active = true;
|
|
135
|
+
|
|
136
|
+
/*
|
|
137
|
+
* 3. Check if the current node position is `sticky`. If it is, it means that the browser supports sticky positioning,
|
|
138
|
+
* but the polyfill was force-enabled. We set the node’s position to `static` before continuing, so that the node
|
|
139
|
+
* is in it’s initial position when we gather its params.
|
|
140
|
+
*/
|
|
141
|
+
var originalPosition = node.style.position;
|
|
142
|
+
if (nodeComputedStyle.position == 'sticky' || nodeComputedStyle.position == '-webkit-sticky') node.style.position = 'static';
|
|
143
|
+
|
|
144
|
+
/*
|
|
145
|
+
* 4. Get necessary node parameters
|
|
146
|
+
*/
|
|
147
|
+
var referenceNode = node.parentNode;
|
|
148
|
+
var parentNode = shadowRootExists && referenceNode instanceof ShadowRoot ? referenceNode.host : referenceNode;
|
|
149
|
+
var nodeWinOffset = node.getBoundingClientRect();
|
|
150
|
+
var parentWinOffset = parentNode.getBoundingClientRect();
|
|
151
|
+
var parentComputedStyle = getComputedStyle(parentNode);
|
|
152
|
+
|
|
153
|
+
this._parent = {
|
|
154
|
+
node: parentNode,
|
|
155
|
+
styles: {
|
|
156
|
+
position: parentNode.style.position
|
|
157
|
+
},
|
|
158
|
+
offsetHeight: parentNode.offsetHeight
|
|
159
|
+
};
|
|
160
|
+
this._offsetToWindow = {
|
|
161
|
+
left: nodeWinOffset.left,
|
|
162
|
+
right: document.documentElement.clientWidth - nodeWinOffset.right
|
|
163
|
+
};
|
|
164
|
+
this._offsetToParent = {
|
|
165
|
+
top: nodeWinOffset.top - parentWinOffset.top - parseNumeric(parentComputedStyle.borderTopWidth),
|
|
166
|
+
left: nodeWinOffset.left - parentWinOffset.left - parseNumeric(parentComputedStyle.borderLeftWidth),
|
|
167
|
+
right: -nodeWinOffset.right + parentWinOffset.right - parseNumeric(parentComputedStyle.borderRightWidth)
|
|
168
|
+
};
|
|
169
|
+
this._styles = {
|
|
170
|
+
position: originalPosition,
|
|
171
|
+
top: node.style.top,
|
|
172
|
+
bottom: node.style.bottom,
|
|
173
|
+
left: node.style.left,
|
|
174
|
+
right: node.style.right,
|
|
175
|
+
width: node.style.width,
|
|
176
|
+
marginTop: node.style.marginTop,
|
|
177
|
+
marginLeft: node.style.marginLeft,
|
|
178
|
+
marginRight: node.style.marginRight
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
var nodeTopValue = parseNumeric(nodeComputedProps.top);
|
|
182
|
+
this._limits = {
|
|
183
|
+
start: nodeWinOffset.top + window.pageYOffset - nodeTopValue,
|
|
184
|
+
end: parentWinOffset.top + window.pageYOffset + parentNode.offsetHeight - parseNumeric(parentComputedStyle.borderBottomWidth) - node.offsetHeight - nodeTopValue - parseNumeric(nodeComputedProps.marginBottom)
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/*
|
|
188
|
+
* 5. Ensure that the node will be positioned relatively to the parent node
|
|
189
|
+
*/
|
|
190
|
+
var parentPosition = parentComputedStyle.position;
|
|
191
|
+
|
|
192
|
+
if (parentPosition != 'absolute' && parentPosition != 'relative') {
|
|
193
|
+
parentNode.style.position = 'relative';
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/*
|
|
197
|
+
* 6. Recalc node position.
|
|
198
|
+
* It’s important to do this before clone injection to avoid scrolling bug in Chrome.
|
|
199
|
+
*/
|
|
200
|
+
this._recalcPosition();
|
|
201
|
+
|
|
202
|
+
/*
|
|
203
|
+
* 7. Create a clone
|
|
204
|
+
*/
|
|
205
|
+
var clone = this._clone = {};
|
|
206
|
+
clone.node = document.createElement('div');
|
|
207
|
+
|
|
208
|
+
// Apply styles to the clone
|
|
209
|
+
extend(clone.node.style, {
|
|
210
|
+
width: nodeWinOffset.right - nodeWinOffset.left + 'px',
|
|
211
|
+
height: nodeWinOffset.bottom - nodeWinOffset.top + 'px',
|
|
212
|
+
marginTop: nodeComputedProps.marginTop,
|
|
213
|
+
marginBottom: nodeComputedProps.marginBottom,
|
|
214
|
+
marginLeft: nodeComputedProps.marginLeft,
|
|
215
|
+
marginRight: nodeComputedProps.marginRight,
|
|
216
|
+
cssFloat: nodeComputedProps.cssFloat,
|
|
217
|
+
padding: 0,
|
|
218
|
+
border: 0,
|
|
219
|
+
borderSpacing: 0,
|
|
220
|
+
fontSize: '1em',
|
|
221
|
+
position: 'static'
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
referenceNode.insertBefore(clone.node, node);
|
|
225
|
+
clone.docOffsetTop = getDocOffsetTop(clone.node);
|
|
226
|
+
}
|
|
227
|
+
}, {
|
|
228
|
+
key: '_recalcPosition',
|
|
229
|
+
value: function _recalcPosition() {
|
|
230
|
+
if (!this._active || this._removed) return;
|
|
231
|
+
|
|
232
|
+
var stickyMode = scroll.top <= this._limits.start ? 'start' : scroll.top >= this._limits.end ? 'end' : 'middle';
|
|
233
|
+
|
|
234
|
+
if (this._stickyMode == stickyMode) return;
|
|
235
|
+
|
|
236
|
+
switch (stickyMode) {
|
|
237
|
+
case 'start':
|
|
238
|
+
extend(this._node.style, {
|
|
239
|
+
position: 'absolute',
|
|
240
|
+
left: this._offsetToParent.left + 'px',
|
|
241
|
+
right: this._offsetToParent.right + 'px',
|
|
242
|
+
top: this._offsetToParent.top + 'px',
|
|
243
|
+
bottom: 'auto',
|
|
244
|
+
width: 'auto',
|
|
245
|
+
marginLeft: 0,
|
|
246
|
+
marginRight: 0,
|
|
247
|
+
marginTop: 0
|
|
248
|
+
});
|
|
249
|
+
break;
|
|
250
|
+
|
|
251
|
+
case 'middle':
|
|
252
|
+
extend(this._node.style, {
|
|
253
|
+
position: 'fixed',
|
|
254
|
+
left: this._offsetToWindow.left + 'px',
|
|
255
|
+
right: this._offsetToWindow.right + 'px',
|
|
256
|
+
top: this._styles.top,
|
|
257
|
+
bottom: 'auto',
|
|
258
|
+
width: 'auto',
|
|
259
|
+
marginLeft: 0,
|
|
260
|
+
marginRight: 0,
|
|
261
|
+
marginTop: 0
|
|
262
|
+
});
|
|
263
|
+
break;
|
|
264
|
+
|
|
265
|
+
case 'end':
|
|
266
|
+
extend(this._node.style, {
|
|
267
|
+
position: 'absolute',
|
|
268
|
+
left: this._offsetToParent.left + 'px',
|
|
269
|
+
right: this._offsetToParent.right + 'px',
|
|
270
|
+
top: 'auto',
|
|
271
|
+
bottom: 0,
|
|
272
|
+
width: 'auto',
|
|
273
|
+
marginLeft: 0,
|
|
274
|
+
marginRight: 0
|
|
275
|
+
});
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
this._stickyMode = stickyMode;
|
|
280
|
+
}
|
|
281
|
+
}, {
|
|
282
|
+
key: '_fastCheck',
|
|
283
|
+
value: function _fastCheck() {
|
|
284
|
+
if (!this._active || this._removed) return;
|
|
285
|
+
|
|
286
|
+
if (Math.abs(getDocOffsetTop(this._clone.node) - this._clone.docOffsetTop) > 1 || Math.abs(this._parent.node.offsetHeight - this._parent.offsetHeight) > 1) this.refresh();
|
|
287
|
+
}
|
|
288
|
+
}, {
|
|
289
|
+
key: '_deactivate',
|
|
290
|
+
value: function _deactivate() {
|
|
291
|
+
var _this = this;
|
|
292
|
+
|
|
293
|
+
if (!this._active || this._removed) return;
|
|
294
|
+
|
|
295
|
+
this._clone.node.parentNode.removeChild(this._clone.node);
|
|
296
|
+
delete this._clone;
|
|
297
|
+
|
|
298
|
+
extend(this._node.style, this._styles);
|
|
299
|
+
delete this._styles;
|
|
300
|
+
|
|
301
|
+
// Check whether element’s parent node is used by other stickies.
|
|
302
|
+
// If not, restore parent node’s styles.
|
|
303
|
+
if (!stickies.some(function (sticky) {
|
|
304
|
+
return sticky !== _this && sticky._parent && sticky._parent.node === _this._parent.node;
|
|
305
|
+
})) {
|
|
306
|
+
extend(this._parent.node.style, this._parent.styles);
|
|
307
|
+
}
|
|
308
|
+
delete this._parent;
|
|
309
|
+
|
|
310
|
+
this._stickyMode = null;
|
|
311
|
+
this._active = false;
|
|
312
|
+
|
|
313
|
+
delete this._offsetToWindow;
|
|
314
|
+
delete this._offsetToParent;
|
|
315
|
+
delete this._limits;
|
|
316
|
+
}
|
|
317
|
+
}, {
|
|
318
|
+
key: 'remove',
|
|
319
|
+
value: function remove() {
|
|
320
|
+
var _this2 = this;
|
|
321
|
+
|
|
322
|
+
this._deactivate();
|
|
323
|
+
|
|
324
|
+
stickies.some(function (sticky, index) {
|
|
325
|
+
if (sticky._node === _this2._node) {
|
|
326
|
+
stickies.splice(index, 1);
|
|
327
|
+
return true;
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
this._removed = true;
|
|
332
|
+
}
|
|
333
|
+
}]);
|
|
334
|
+
|
|
335
|
+
return Sticky;
|
|
336
|
+
}();
|
|
337
|
+
|
|
338
|
+
/*
|
|
339
|
+
* 5. Stickyfill API
|
|
340
|
+
*/
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
var Stickyfill = {
|
|
344
|
+
stickies: stickies,
|
|
345
|
+
Sticky: Sticky,
|
|
346
|
+
|
|
347
|
+
forceSticky: function forceSticky() {
|
|
348
|
+
seppuku = false;
|
|
349
|
+
init();
|
|
350
|
+
|
|
351
|
+
this.refreshAll();
|
|
352
|
+
},
|
|
353
|
+
addOne: function addOne(node) {
|
|
354
|
+
// Check whether it’s a node
|
|
355
|
+
if (!(node instanceof HTMLElement)) {
|
|
356
|
+
// Maybe it’s a node list of some sort?
|
|
357
|
+
// Take first node from the list then
|
|
358
|
+
if (node.length && node[0]) node = node[0];else return;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// Check if Stickyfill is already applied to the node
|
|
362
|
+
// and return existing sticky
|
|
363
|
+
for (var i = 0; i < stickies.length; i++) {
|
|
364
|
+
if (stickies[i]._node === node) return stickies[i];
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// Create and return new sticky
|
|
368
|
+
return new Sticky(node);
|
|
369
|
+
},
|
|
370
|
+
add: function add(nodeList) {
|
|
371
|
+
// If it’s a node make an array of one node
|
|
372
|
+
if (nodeList instanceof HTMLElement) nodeList = [nodeList];
|
|
373
|
+
// Check if the argument is an iterable of some sort
|
|
374
|
+
if (!nodeList.length) return;
|
|
375
|
+
|
|
376
|
+
// Add every element as a sticky and return an array of created Sticky instances
|
|
377
|
+
var addedStickies = [];
|
|
378
|
+
|
|
379
|
+
var _loop = function _loop(i) {
|
|
380
|
+
var node = nodeList[i];
|
|
381
|
+
|
|
382
|
+
// If it’s not an HTMLElement – create an empty element to preserve 1-to-1
|
|
383
|
+
// correlation with input list
|
|
384
|
+
if (!(node instanceof HTMLElement)) {
|
|
385
|
+
addedStickies.push(void 0);
|
|
386
|
+
return 'continue';
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// If Stickyfill is already applied to the node
|
|
390
|
+
// add existing sticky
|
|
391
|
+
if (stickies.some(function (sticky) {
|
|
392
|
+
if (sticky._node === node) {
|
|
393
|
+
addedStickies.push(sticky);
|
|
394
|
+
return true;
|
|
395
|
+
}
|
|
396
|
+
})) return 'continue';
|
|
397
|
+
|
|
398
|
+
// Create and add new sticky
|
|
399
|
+
addedStickies.push(new Sticky(node));
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
for (var i = 0; i < nodeList.length; i++) {
|
|
403
|
+
var _ret2 = _loop(i);
|
|
404
|
+
|
|
405
|
+
if (_ret2 === 'continue') continue;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
return addedStickies;
|
|
409
|
+
},
|
|
410
|
+
refreshAll: function refreshAll() {
|
|
411
|
+
stickies.forEach(function (sticky) {
|
|
412
|
+
return sticky.refresh();
|
|
413
|
+
});
|
|
414
|
+
},
|
|
415
|
+
removeOne: function removeOne(node) {
|
|
416
|
+
// Check whether it’s a node
|
|
417
|
+
if (!(node instanceof HTMLElement)) {
|
|
418
|
+
// Maybe it’s a node list of some sort?
|
|
419
|
+
// Take first node from the list then
|
|
420
|
+
if (node.length && node[0]) node = node[0];else return;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// Remove the stickies bound to the nodes in the list
|
|
424
|
+
stickies.some(function (sticky) {
|
|
425
|
+
if (sticky._node === node) {
|
|
426
|
+
sticky.remove();
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
},
|
|
431
|
+
remove: function remove(nodeList) {
|
|
432
|
+
// If it’s a node make an array of one node
|
|
433
|
+
if (nodeList instanceof HTMLElement) nodeList = [nodeList];
|
|
434
|
+
// Check if the argument is an iterable of some sort
|
|
435
|
+
if (!nodeList.length) return;
|
|
436
|
+
|
|
437
|
+
// Remove the stickies bound to the nodes in the list
|
|
438
|
+
|
|
439
|
+
var _loop2 = function _loop2(i) {
|
|
440
|
+
var node = nodeList[i];
|
|
441
|
+
|
|
442
|
+
stickies.some(function (sticky) {
|
|
443
|
+
if (sticky._node === node) {
|
|
444
|
+
sticky.remove();
|
|
445
|
+
return true;
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
for (var i = 0; i < nodeList.length; i++) {
|
|
451
|
+
_loop2(i);
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
removeAll: function removeAll() {
|
|
455
|
+
while (stickies.length) {
|
|
456
|
+
stickies[0].remove();
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
/*
|
|
462
|
+
* 6. Setup events (unless the polyfill was disabled)
|
|
463
|
+
*/
|
|
464
|
+
function init() {
|
|
465
|
+
if (isInitialized) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
isInitialized = true;
|
|
470
|
+
|
|
471
|
+
// Watch for scroll position changes and trigger recalc/refresh if needed
|
|
472
|
+
function checkScroll() {
|
|
473
|
+
if (window.pageXOffset != scroll.left) {
|
|
474
|
+
scroll.top = window.pageYOffset;
|
|
475
|
+
scroll.left = window.pageXOffset;
|
|
476
|
+
|
|
477
|
+
Stickyfill.refreshAll();
|
|
478
|
+
} else if (window.pageYOffset != scroll.top) {
|
|
479
|
+
scroll.top = window.pageYOffset;
|
|
480
|
+
scroll.left = window.pageXOffset;
|
|
481
|
+
|
|
482
|
+
// recalc position for all stickies
|
|
483
|
+
stickies.forEach(function (sticky) {
|
|
484
|
+
return sticky._recalcPosition();
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
checkScroll();
|
|
490
|
+
window.addEventListener('scroll', checkScroll);
|
|
491
|
+
|
|
492
|
+
// Watch for window resizes and device orientation changes and trigger refresh
|
|
493
|
+
window.addEventListener('resize', Stickyfill.refreshAll);
|
|
494
|
+
window.addEventListener('orientationchange', Stickyfill.refreshAll);
|
|
495
|
+
|
|
496
|
+
//Fast dirty check for layout changes every 500ms
|
|
497
|
+
var fastCheckTimer = void 0;
|
|
498
|
+
|
|
499
|
+
function startFastCheckTimer() {
|
|
500
|
+
fastCheckTimer = setInterval(function () {
|
|
501
|
+
stickies.forEach(function (sticky) {
|
|
502
|
+
return sticky._fastCheck();
|
|
503
|
+
});
|
|
504
|
+
}, 500);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function stopFastCheckTimer() {
|
|
508
|
+
clearInterval(fastCheckTimer);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
var docHiddenKey = void 0;
|
|
512
|
+
var visibilityChangeEventName = void 0;
|
|
513
|
+
|
|
514
|
+
if ('hidden' in document) {
|
|
515
|
+
docHiddenKey = 'hidden';
|
|
516
|
+
visibilityChangeEventName = 'visibilitychange';
|
|
517
|
+
} else if ('webkitHidden' in document) {
|
|
518
|
+
docHiddenKey = 'webkitHidden';
|
|
519
|
+
visibilityChangeEventName = 'webkitvisibilitychange';
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
if (visibilityChangeEventName) {
|
|
523
|
+
if (!document[docHiddenKey]) startFastCheckTimer();
|
|
524
|
+
|
|
525
|
+
document.addEventListener(visibilityChangeEventName, function () {
|
|
526
|
+
if (document[docHiddenKey]) {
|
|
527
|
+
stopFastCheckTimer();
|
|
528
|
+
} else {
|
|
529
|
+
startFastCheckTimer();
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
} else startFastCheckTimer();
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
if (!seppuku) init();
|
|
536
|
+
|
|
537
|
+
/*
|
|
538
|
+
* 7. Expose Stickyfill
|
|
539
|
+
*/
|
|
540
|
+
if (typeof module != 'undefined' && module.exports) {
|
|
541
|
+
module.exports = Stickyfill;
|
|
542
|
+
} else if (isWindowDefined) {
|
|
543
|
+
window.Stickyfill = Stickyfill;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
})(window, document);
|
package/package.json
CHANGED
package/ui/fieldset-list.js
CHANGED
|
@@ -283,10 +283,7 @@ class HTMLElementFieldsetList extends Page.Element {
|
|
|
283
283
|
live.replaceWith(node);
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
|
|
287
|
-
bubbles: true,
|
|
288
|
-
cancelable: true
|
|
289
|
-
}));
|
|
286
|
+
state.dispatch(this, 'change');
|
|
290
287
|
}
|
|
291
288
|
|
|
292
289
|
#parseName(name) {
|
package/ui/form.js
CHANGED
|
@@ -91,10 +91,6 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
#isPureButtons() {
|
|
95
|
-
return this.elements.every(item => item.type == "submit");
|
|
96
|
-
}
|
|
97
|
-
|
|
98
94
|
toggleMessages(status) {
|
|
99
95
|
return window.HTMLElementTemplate.prototype.toggleMessages.call(this, status, this);
|
|
100
96
|
}
|
|
@@ -121,7 +117,6 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
|
|
|
121
117
|
this.setAttribute('data-' + key, val);
|
|
122
118
|
}
|
|
123
119
|
this.restore(state.scope);
|
|
124
|
-
if (this.#isPureButtons()) this.classList.add('unsaved');
|
|
125
120
|
} else {
|
|
126
121
|
for (const name of this.fill(state.query, state.scope)) {
|
|
127
122
|
state.vars[name] = true;
|
|
@@ -144,10 +139,7 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
|
|
|
144
139
|
delete state.query.submit;
|
|
145
140
|
state.finish(() => {
|
|
146
141
|
if (state.status != 200) return;
|
|
147
|
-
|
|
148
|
-
bubbles: true,
|
|
149
|
-
cancelable: true
|
|
150
|
-
}));
|
|
142
|
+
state.dispatch(this, 'submit');
|
|
151
143
|
});
|
|
152
144
|
}
|
|
153
145
|
read(withDefaults = false) {
|
|
@@ -250,6 +242,7 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
|
|
|
250
242
|
return vars;
|
|
251
243
|
}
|
|
252
244
|
save() {
|
|
245
|
+
this.classList.remove('unsaved');
|
|
253
246
|
for (const node of this.querySelectorAll("element-fieldset-list")) {
|
|
254
247
|
node.save();
|
|
255
248
|
}
|
|
@@ -258,6 +251,7 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
|
|
|
258
251
|
}
|
|
259
252
|
}
|
|
260
253
|
reset() {
|
|
254
|
+
this.classList.remove('unsaved');
|
|
261
255
|
for (const node of this.querySelectorAll("element-fieldset-list")) {
|
|
262
256
|
node.reset();
|
|
263
257
|
}
|
|
@@ -344,7 +338,6 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
|
|
|
344
338
|
async postMethod(e, state) {
|
|
345
339
|
if (e.type != "submit") return;
|
|
346
340
|
const form = this;
|
|
347
|
-
if (!this.#isPureButtons()) form.classList.remove('unsaved');
|
|
348
341
|
form.classList.add('loading');
|
|
349
342
|
|
|
350
343
|
await Promise.all(
|
package/ui/input-range.js
CHANGED
|
@@ -87,10 +87,7 @@ class HTMLElementInputRange extends Page.create(HTMLInputElement) {
|
|
|
87
87
|
helper.classList.remove('indeterminate');
|
|
88
88
|
if (isInt) values = values.map(n => parseInt(n));
|
|
89
89
|
this.rangeValue = values;
|
|
90
|
-
|
|
91
|
-
bubbles: true,
|
|
92
|
-
cancelable: true
|
|
93
|
-
}));
|
|
90
|
+
state.dispatch(this, 'change');
|
|
94
91
|
});
|
|
95
92
|
helper.addEventListener('keydown', this, true);
|
|
96
93
|
helper.addEventListener('dblclick', this, true);
|
|
@@ -100,10 +97,7 @@ class HTMLElementInputRange extends Page.create(HTMLInputElement) {
|
|
|
100
97
|
if (state.scope.$write) return;
|
|
101
98
|
if (e.type == "dblclick" || e.keyCode == 8 || e.keyCode == 46) {
|
|
102
99
|
this.fill();
|
|
103
|
-
|
|
104
|
-
bubbles: true,
|
|
105
|
-
cancelable: true
|
|
106
|
-
}));
|
|
100
|
+
state.dispatch(this, 'change');
|
|
107
101
|
}
|
|
108
102
|
}
|
|
109
103
|
|
package/ui/query-tags.js
CHANGED
|
@@ -79,10 +79,10 @@ class HTMLElementQueryTags extends Page.Element {
|
|
|
79
79
|
this.insertLabel(name, control.value, `${prefix}${txt}${suffix}`);
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
-
handleClick(e) {
|
|
83
|
-
this.remove(e.target.closest('[data-name]'));
|
|
82
|
+
handleClick(e, state) {
|
|
83
|
+
this.remove(e.target.closest('[data-name]'), state);
|
|
84
84
|
}
|
|
85
|
-
remove(label) {
|
|
85
|
+
remove(label, state) {
|
|
86
86
|
if (!label) return;
|
|
87
87
|
for (const control of this.find(label.dataset.name, label.dataset.value)) {
|
|
88
88
|
if (control.type == "hidden") continue;
|
|
@@ -90,10 +90,7 @@ class HTMLElementQueryTags extends Page.Element {
|
|
|
90
90
|
else if (control.selected) control.selected = false;
|
|
91
91
|
else if (control.reset) control.reset();
|
|
92
92
|
else if (control.value) control.value = "";
|
|
93
|
-
control.form
|
|
94
|
-
bubbles: true,
|
|
95
|
-
cancelable: true
|
|
96
|
-
}));
|
|
93
|
+
state.dispatch(control.form, 'submit');
|
|
97
94
|
}
|
|
98
95
|
label.remove();
|
|
99
96
|
}
|
package/ui/select.js
CHANGED
|
@@ -31,10 +31,7 @@ class HTMLElementSelect extends Page.Element {
|
|
|
31
31
|
const opt = this.#selectOption(item.dataset.value);
|
|
32
32
|
if (opt) {
|
|
33
33
|
opt.selected = true;
|
|
34
|
-
|
|
35
|
-
bubbles: true,
|
|
36
|
-
cancelable: true
|
|
37
|
-
}));
|
|
34
|
+
state.dispatch(opt, 'change');
|
|
38
35
|
this.#toggleMenu(false);
|
|
39
36
|
}
|
|
40
37
|
return;
|
|
@@ -44,10 +41,7 @@ class HTMLElementSelect extends Page.Element {
|
|
|
44
41
|
const opt = this.#selectOption(label.dataset.value);
|
|
45
42
|
if (opt) {
|
|
46
43
|
opt.selected = false;
|
|
47
|
-
|
|
48
|
-
bubbles: true,
|
|
49
|
-
cancelable: true
|
|
50
|
-
}));
|
|
44
|
+
state.dispatch(opt, 'change');
|
|
51
45
|
}
|
|
52
46
|
return;
|
|
53
47
|
}
|