@pageboard/html 0.10.22 → 0.10.24
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/consent.js +18 -4
- package/elements/embed.js +4 -0
- package/elements/media.js +1 -1
- package/lib/nouislider.js +92 -5
- package/package.json +6 -7
- package/ui/card.css +0 -0
- package/ui/consent.js +25 -26
- package/ui/embed.js +3 -2
- package/ui/item.css +0 -0
- package/ui/rating.css +0 -0
package/elements/consent.js
CHANGED
|
@@ -26,20 +26,28 @@ exports.consent_form = {
|
|
|
26
26
|
stylesheets: ['../ui/consent.css']
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
+
const consents = [];
|
|
30
|
+
|
|
29
31
|
exports.input_radio_yes = {
|
|
30
32
|
title: 'Yes',
|
|
31
33
|
icon: '<i class="thumbs up icon"></i>',
|
|
32
34
|
menu: "form",
|
|
33
35
|
group: "block",
|
|
34
36
|
context: 'consent_form//',
|
|
37
|
+
properties: {
|
|
38
|
+
consent: {
|
|
39
|
+
title: 'Consent',
|
|
40
|
+
anyOf: consents
|
|
41
|
+
}
|
|
42
|
+
},
|
|
35
43
|
contents: {
|
|
36
44
|
id: 'label',
|
|
37
45
|
nodes: 'inline*'
|
|
38
46
|
},
|
|
39
47
|
html: `<div class="field">
|
|
40
48
|
<div class="ui radio checkbox">
|
|
41
|
-
<input type="radio" name="consent" value="yes" id="for-consent-yes" />
|
|
42
|
-
<label block-content="label" for="for-consent-yes">Yes</label>
|
|
49
|
+
<input type="radio" name="consent.[consent]" value="yes" id="for-consent-yes-[consent]" />
|
|
50
|
+
<label block-content="label" for="for-consent-yes-[consent]">Yes</label>
|
|
43
51
|
</div>
|
|
44
52
|
</div>`
|
|
45
53
|
};
|
|
@@ -50,14 +58,20 @@ exports.input_radio_no = {
|
|
|
50
58
|
menu: "form",
|
|
51
59
|
group: "block",
|
|
52
60
|
context: 'consent_form//',
|
|
61
|
+
properties: {
|
|
62
|
+
consent: {
|
|
63
|
+
title: 'Consent',
|
|
64
|
+
anyOf: consents
|
|
65
|
+
}
|
|
66
|
+
},
|
|
53
67
|
contents: {
|
|
54
68
|
id: 'label',
|
|
55
69
|
nodes: 'inline*'
|
|
56
70
|
},
|
|
57
71
|
html: `<div class="field">
|
|
58
72
|
<div class="ui radio checkbox">
|
|
59
|
-
<input type="radio" name="consent" value="no" id="for-consent-no" />
|
|
60
|
-
<label block-content="label" for="for-consent-no">No</label>
|
|
73
|
+
<input type="radio" name="consent.[consent]" value="no" id="for-consent-no-[consent]" />
|
|
74
|
+
<label block-content="label" for="for-consent-no-[consent]">No</label>
|
|
61
75
|
</div>
|
|
62
76
|
</div>`
|
|
63
77
|
};
|
package/elements/embed.js
CHANGED
package/elements/media.js
CHANGED
|
@@ -67,7 +67,7 @@ exports.video = {
|
|
|
67
67
|
},
|
|
68
68
|
html: `<video is="element-video" data-src="[url]" class="[display.fit|or:none]"
|
|
69
69
|
preload="metadata" autoplay="[autoplay]" loop="[loop]"
|
|
70
|
-
muted="[muted]" controls="[controls]"></video>`,
|
|
70
|
+
muted="[muted]" controls="[controls]" playsinline></video>`,
|
|
71
71
|
scripts: [
|
|
72
72
|
'../ui/media.js'
|
|
73
73
|
],
|
package/lib/nouislider.js
CHANGED
|
@@ -713,6 +713,7 @@
|
|
|
713
713
|
var snap = entry.indexOf("snap") >= 0;
|
|
714
714
|
var hover = entry.indexOf("hover") >= 0;
|
|
715
715
|
var unconstrained = entry.indexOf("unconstrained") >= 0;
|
|
716
|
+
var invertConnects = entry.indexOf("invert-connects") >= 0;
|
|
716
717
|
var dragAll = entry.indexOf("drag-all") >= 0;
|
|
717
718
|
var smoothSteps = entry.indexOf("smooth-steps") >= 0;
|
|
718
719
|
if (fixed) {
|
|
@@ -722,6 +723,9 @@
|
|
|
722
723
|
// Use margin to enforce fixed state
|
|
723
724
|
testMargin(parsed, parsed.start[1] - parsed.start[0]);
|
|
724
725
|
}
|
|
726
|
+
if (invertConnects && parsed.handles !== 2) {
|
|
727
|
+
throw new Error("noUiSlider: 'invert-connects' behaviour must be used with 2 handles");
|
|
728
|
+
}
|
|
725
729
|
if (unconstrained && (parsed.margin || parsed.limit)) {
|
|
726
730
|
throw new Error("noUiSlider: 'unconstrained' behaviour cannot be used with margin or limit");
|
|
727
731
|
}
|
|
@@ -734,6 +738,7 @@
|
|
|
734
738
|
snap: snap,
|
|
735
739
|
hover: hover,
|
|
736
740
|
unconstrained: unconstrained,
|
|
741
|
+
invertConnects: invertConnects,
|
|
737
742
|
};
|
|
738
743
|
}
|
|
739
744
|
function testTooltips(parsed, entry) {
|
|
@@ -904,6 +909,7 @@
|
|
|
904
909
|
// Slider DOM Nodes
|
|
905
910
|
var scope_Target = target;
|
|
906
911
|
var scope_Base;
|
|
912
|
+
var scope_ConnectBase;
|
|
907
913
|
var scope_Handles;
|
|
908
914
|
var scope_Connects;
|
|
909
915
|
var scope_Pips;
|
|
@@ -915,6 +921,7 @@
|
|
|
915
921
|
var scope_HandleNumbers = [];
|
|
916
922
|
var scope_ActiveHandlesCount = 0;
|
|
917
923
|
var scope_Events = {};
|
|
924
|
+
var scope_ConnectsInverted = false;
|
|
918
925
|
// Document Nodes
|
|
919
926
|
var scope_Document = target.ownerDocument;
|
|
920
927
|
var scope_DocumentElement = options.documentElement || scope_Document.documentElement;
|
|
@@ -959,6 +966,7 @@
|
|
|
959
966
|
else if (handleNumber === options.handles - 1) {
|
|
960
967
|
addClass(handle, options.cssClasses.handleUpper);
|
|
961
968
|
}
|
|
969
|
+
origin.handle = handle;
|
|
962
970
|
return origin;
|
|
963
971
|
}
|
|
964
972
|
// Insert nodes for connect elements
|
|
@@ -970,17 +978,17 @@
|
|
|
970
978
|
}
|
|
971
979
|
// Add handles to the slider base.
|
|
972
980
|
function addElements(connectOptions, base) {
|
|
973
|
-
|
|
981
|
+
scope_ConnectBase = addNodeTo(base, options.cssClasses.connects);
|
|
974
982
|
scope_Handles = [];
|
|
975
983
|
scope_Connects = [];
|
|
976
|
-
scope_Connects.push(addConnect(
|
|
984
|
+
scope_Connects.push(addConnect(scope_ConnectBase, connectOptions[0]));
|
|
977
985
|
// [::::O====O====O====]
|
|
978
986
|
// connectOptions = [0, 1, 1, 1]
|
|
979
987
|
for (var i = 0; i < options.handles; i++) {
|
|
980
988
|
// Keep a list of all added handles.
|
|
981
989
|
scope_Handles.push(addOrigin(base, i));
|
|
982
990
|
scope_HandleNumbers[i] = i;
|
|
983
|
-
scope_Connects.push(addConnect(
|
|
991
|
+
scope_Connects.push(addConnect(scope_ConnectBase, connectOptions[i + 1]));
|
|
984
992
|
}
|
|
985
993
|
}
|
|
986
994
|
// Initialize a single slider.
|
|
@@ -1022,6 +1030,31 @@
|
|
|
1022
1030
|
var handleOrigin = scope_Handles[handleNumber];
|
|
1023
1031
|
return handleOrigin.hasAttribute("disabled");
|
|
1024
1032
|
}
|
|
1033
|
+
function disable(handleNumber) {
|
|
1034
|
+
if (handleNumber !== null && handleNumber !== undefined) {
|
|
1035
|
+
scope_Handles[handleNumber].setAttribute("disabled", "");
|
|
1036
|
+
scope_Handles[handleNumber].handle.removeAttribute("tabindex");
|
|
1037
|
+
}
|
|
1038
|
+
else {
|
|
1039
|
+
scope_Target.setAttribute("disabled", "");
|
|
1040
|
+
scope_Handles.forEach(function (handle) {
|
|
1041
|
+
handle.handle.removeAttribute("tabindex");
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
function enable(handleNumber) {
|
|
1046
|
+
if (handleNumber !== null && handleNumber !== undefined) {
|
|
1047
|
+
scope_Handles[handleNumber].removeAttribute("disabled");
|
|
1048
|
+
scope_Handles[handleNumber].handle.setAttribute("tabindex", "0");
|
|
1049
|
+
}
|
|
1050
|
+
else {
|
|
1051
|
+
scope_Target.removeAttribute("disabled");
|
|
1052
|
+
scope_Handles.forEach(function (handle) {
|
|
1053
|
+
handle.removeAttribute("disabled");
|
|
1054
|
+
handle.handle.setAttribute("tabindex", "0");
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1025
1058
|
function removeTooltips() {
|
|
1026
1059
|
if (scope_Tooltips) {
|
|
1027
1060
|
removeEvent("update" + INTERNAL_EVENT_NS.tooltips);
|
|
@@ -1904,8 +1937,26 @@
|
|
|
1904
1937
|
var translation = transformDirection(to, 0) - scope_DirOffset;
|
|
1905
1938
|
var translateRule = "translate(" + inRuleOrder(translation + "%", "0") + ")";
|
|
1906
1939
|
scope_Handles[handleNumber].style[options.transformRule] = translateRule;
|
|
1940
|
+
// sanity check for at least 2 handles (e.g. during setup)
|
|
1941
|
+
if (options.events.invertConnects && scope_Locations.length > 1) {
|
|
1942
|
+
// check if handles passed each other, but don't match the ConnectsInverted state
|
|
1943
|
+
var handlesAreInOrder = scope_Locations.every(function (position, index, locations) {
|
|
1944
|
+
return index === 0 || position >= locations[index - 1];
|
|
1945
|
+
});
|
|
1946
|
+
if (scope_ConnectsInverted !== !handlesAreInOrder) {
|
|
1947
|
+
// invert connects when handles pass each other
|
|
1948
|
+
invertConnects();
|
|
1949
|
+
// invertConnects already updates all connect elements
|
|
1950
|
+
return;
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1907
1953
|
updateConnect(handleNumber);
|
|
1908
1954
|
updateConnect(handleNumber + 1);
|
|
1955
|
+
if (scope_ConnectsInverted) {
|
|
1956
|
+
// When connects are inverted, we also have to update adjacent connects
|
|
1957
|
+
updateConnect(handleNumber - 1);
|
|
1958
|
+
updateConnect(handleNumber + 2);
|
|
1959
|
+
}
|
|
1909
1960
|
}
|
|
1910
1961
|
// Handles before the slider middle are stacked later = higher,
|
|
1911
1962
|
// Handles after the middle later is lower
|
|
@@ -1935,13 +1986,20 @@
|
|
|
1935
1986
|
if (!scope_Connects[index]) {
|
|
1936
1987
|
return;
|
|
1937
1988
|
}
|
|
1989
|
+
// Create a copy of locations, so we can sort them for the local scope logic
|
|
1990
|
+
var locations = scope_Locations.slice();
|
|
1991
|
+
if (scope_ConnectsInverted) {
|
|
1992
|
+
locations.sort(function (a, b) {
|
|
1993
|
+
return a - b;
|
|
1994
|
+
});
|
|
1995
|
+
}
|
|
1938
1996
|
var l = 0;
|
|
1939
1997
|
var h = 100;
|
|
1940
1998
|
if (index !== 0) {
|
|
1941
|
-
l =
|
|
1999
|
+
l = locations[index - 1];
|
|
1942
2000
|
}
|
|
1943
2001
|
if (index !== scope_Connects.length - 1) {
|
|
1944
|
-
h =
|
|
2002
|
+
h = locations[index];
|
|
1945
2003
|
}
|
|
1946
2004
|
// We use two rules:
|
|
1947
2005
|
// 'translate' to change the left/top offset;
|
|
@@ -2133,6 +2191,7 @@
|
|
|
2133
2191
|
"format",
|
|
2134
2192
|
"pips",
|
|
2135
2193
|
"tooltips",
|
|
2194
|
+
"connect",
|
|
2136
2195
|
];
|
|
2137
2196
|
// Only change options that we're actually passed to update.
|
|
2138
2197
|
updateAble.forEach(function (name) {
|
|
@@ -2170,6 +2229,32 @@
|
|
|
2170
2229
|
// Invalidate the current positioning so valueSet forces an update.
|
|
2171
2230
|
scope_Locations = [];
|
|
2172
2231
|
valueSet(isSet(optionsToUpdate.start) ? optionsToUpdate.start : v, fireSetEvent);
|
|
2232
|
+
// Update connects only if it was set
|
|
2233
|
+
if (optionsToUpdate.connect) {
|
|
2234
|
+
updateConnectOption();
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
function updateConnectOption() {
|
|
2238
|
+
// IE supported way of removing children including event handlers
|
|
2239
|
+
while (scope_ConnectBase.firstChild) {
|
|
2240
|
+
scope_ConnectBase.removeChild(scope_ConnectBase.firstChild);
|
|
2241
|
+
}
|
|
2242
|
+
// Adding new connects according to the new connect options
|
|
2243
|
+
for (var i = 0; i <= options.handles; i++) {
|
|
2244
|
+
scope_Connects[i] = addConnect(scope_ConnectBase, options.connect[i]);
|
|
2245
|
+
updateConnect(i);
|
|
2246
|
+
}
|
|
2247
|
+
// re-adding drag events for the new connect elements
|
|
2248
|
+
// to ignore the other events we have to negate the 'if (!behaviour.fixed)' check
|
|
2249
|
+
bindSliderEvents({ drag: options.events.drag, fixed: true });
|
|
2250
|
+
}
|
|
2251
|
+
// Invert options for connect handles
|
|
2252
|
+
function invertConnects() {
|
|
2253
|
+
scope_ConnectsInverted = !scope_ConnectsInverted;
|
|
2254
|
+
testConnect(options,
|
|
2255
|
+
// inverse the connect boolean array
|
|
2256
|
+
options.connect.map(function (b) { return !b; }));
|
|
2257
|
+
updateConnectOption();
|
|
2173
2258
|
}
|
|
2174
2259
|
// Initialization steps
|
|
2175
2260
|
function setupSlider() {
|
|
@@ -2199,6 +2284,8 @@
|
|
|
2199
2284
|
set: valueSet,
|
|
2200
2285
|
setHandle: valueSetHandle,
|
|
2201
2286
|
reset: valueReset,
|
|
2287
|
+
disable: disable,
|
|
2288
|
+
enable: enable,
|
|
2202
2289
|
// Exposed for unit testing, don't use this in your application.
|
|
2203
2290
|
__moveHandles: function (upward, proposal, handleNumbers) {
|
|
2204
2291
|
moveHandles(upward, proposal, scope_Locations, handleNumbers);
|
package/package.json
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pageboard/html",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.24",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
-
"postinstall": "postinstall",
|
|
9
|
-
"prepare": "postinstall"
|
|
10
|
-
},
|
|
11
6
|
"repository": {
|
|
12
7
|
"type": "git",
|
|
13
8
|
"url": "git+https://github.com/pageboard/client.git"
|
|
@@ -48,5 +43,9 @@
|
|
|
48
43
|
"elements": [
|
|
49
44
|
"elements/"
|
|
50
45
|
]
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
49
|
+
"postinstall": "postinstall"
|
|
51
50
|
}
|
|
52
|
-
}
|
|
51
|
+
}
|
package/ui/card.css
CHANGED
|
File without changes
|
package/ui/consent.js
CHANGED
|
@@ -27,21 +27,17 @@ class HTMLCustomConsentElement extends HTMLFormElement {
|
|
|
27
27
|
state.consent(this);
|
|
28
28
|
}
|
|
29
29
|
chainConsent(state) {
|
|
30
|
-
window.HTMLCustomFormElement.prototype.fill.call(this,
|
|
31
|
-
consent: state.scope.$consent
|
|
32
|
-
});
|
|
30
|
+
window.HTMLCustomFormElement.prototype.fill.call(this, state.scope.$consent);
|
|
33
31
|
if (this.options.transient) this.classList.remove('visible');
|
|
34
32
|
}
|
|
35
33
|
handleSubmit(e, state) {
|
|
36
34
|
if (e.type == "submit") e.preventDefault();
|
|
37
35
|
if (this.isContentEditable) return;
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
return;
|
|
36
|
+
const consents = window.HTMLCustomFormElement.prototype.read.call(this);
|
|
37
|
+
for (const [key, val] of Object.entries(consents)) {
|
|
38
|
+
Page.storage.set('consent.' + key, val);
|
|
42
39
|
}
|
|
43
|
-
|
|
44
|
-
state.scope.$consent = consent;
|
|
40
|
+
state.scope.$consent = consents;
|
|
45
41
|
state.runChain('consent');
|
|
46
42
|
}
|
|
47
43
|
handleChange(e, state) {
|
|
@@ -67,29 +63,32 @@ Page.ready(() => {
|
|
|
67
63
|
VirtualHTMLElement.define(`element-consent`, HTMLCustomConsentElement, 'form');
|
|
68
64
|
});
|
|
69
65
|
|
|
70
|
-
Page.State.prototype.consent = function (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
this.scope.$consent =
|
|
75
|
-
this.chain('consent',
|
|
76
|
-
if (
|
|
66
|
+
Page.State.prototype.consent = function (listener) {
|
|
67
|
+
this.scope.$consent ??= {};
|
|
68
|
+
const { consent } = listener.constructor;
|
|
69
|
+
const val = Page.storage.get('consent.' + consent);
|
|
70
|
+
this.scope.$consent[consent] = val;
|
|
71
|
+
this.chain('consent', listener);
|
|
72
|
+
if (val === undefined) {
|
|
77
73
|
HTMLCustomConsentElement.waiting = true;
|
|
78
|
-
} else if (
|
|
74
|
+
} else if (val === null) {
|
|
79
75
|
// setup finished but no consent is done yet, ask consent
|
|
80
|
-
this.reconsent();
|
|
76
|
+
this.reconsent(listener);
|
|
81
77
|
}
|
|
82
78
|
};
|
|
83
79
|
|
|
84
|
-
Page.State.prototype.reconsent = function (
|
|
85
|
-
if (
|
|
86
|
-
const
|
|
80
|
+
Page.State.prototype.reconsent = function (listener) {
|
|
81
|
+
if (listener) this.consent(listener);
|
|
82
|
+
const consents = this.scope.$consent;
|
|
87
83
|
let asking = false;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
84
|
+
for (const [key, val] of Object.entries(consents)) {
|
|
85
|
+
if (listener && key != listener.constructor.consent) continue;
|
|
86
|
+
if (val != "yes") {
|
|
87
|
+
asking = HTMLCustomConsentElement.ask();
|
|
88
|
+
}
|
|
89
|
+
if (!asking) {
|
|
90
|
+
if (val == null) consents[key] = "yes";
|
|
91
|
+
}
|
|
93
92
|
}
|
|
94
93
|
return asking;
|
|
95
94
|
};
|
package/ui/embed.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
class HTMLElementEmbed extends VirtualHTMLElement {
|
|
2
|
+
static consent = "embed";
|
|
2
3
|
static defaults = {
|
|
3
4
|
src: null,
|
|
4
5
|
hash: null
|
|
@@ -18,7 +19,7 @@ class HTMLElementEmbed extends VirtualHTMLElement {
|
|
|
18
19
|
return this.promise;
|
|
19
20
|
}
|
|
20
21
|
consent(state) {
|
|
21
|
-
const consent = state.scope.$consent;
|
|
22
|
+
const consent = state.scope.$consent[this.constructor.consent];
|
|
22
23
|
this.classList.toggle('denied', consent == "no");
|
|
23
24
|
this.classList.toggle('waiting', consent == null);
|
|
24
25
|
|
|
@@ -56,7 +57,7 @@ class HTMLElementEmbed extends VirtualHTMLElement {
|
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
captureClick(e, state) {
|
|
59
|
-
if (this.matches('.denied')) state.reconsent();
|
|
60
|
+
if (this.matches('.denied')) state.reconsent(this);
|
|
60
61
|
}
|
|
61
62
|
captureLoad() {
|
|
62
63
|
this.promise.done();
|
package/ui/item.css
CHANGED
|
File without changes
|
package/ui/rating.css
CHANGED
|
File without changes
|