@themarioga/grid-editor 6.0.0 → 7.0.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/AUTO_SAVE.md +2 -2
- package/BUILDING.md +45 -29
- package/CHANGELOG.md +47 -0
- package/README.md +137 -85
- package/UPGRADING.md +119 -0
- package/dist/grideditor.bundle.min.js +14 -0
- package/dist/grideditor.d.ts +335 -0
- package/dist/grideditor.esm.js +3977 -0
- package/dist/grideditor.jquery.js +253 -0
- package/dist/grideditor.jquery.min.js +1 -0
- package/dist/grideditor.jquery.min.js.map +7 -0
- package/dist/grideditor.js +3983 -0
- package/dist/grideditor.min.js +6 -0
- package/dist/grideditor.min.js.map +7 -0
- package/dist/locales/grideditor.es.esm.js +158 -0
- package/dist/locales/grideditor.es.js +164 -168
- package/dist/locales/grideditor.es.min.js +6 -2
- package/dist/locales/grideditor.es.min.js.map +7 -1
- package/dist/plugins/grideditor.accordion.esm.js +294 -0
- package/dist/plugins/grideditor.accordion.js +286 -180
- package/dist/plugins/grideditor.accordion.min.js +1 -2
- package/dist/plugins/grideditor.accordion.min.js.map +7 -1
- package/dist/plugins/grideditor.alignment.esm.js +55 -0
- package/dist/plugins/grideditor.alignment.js +58 -77
- package/dist/plugins/grideditor.alignment.min.js +1 -2
- package/dist/plugins/grideditor.alignment.min.js.map +7 -1
- package/dist/plugins/grideditor.card.esm.js +73 -0
- package/dist/plugins/grideditor.card.js +74 -64
- package/dist/plugins/grideditor.card.min.js +1 -2
- package/dist/plugins/grideditor.card.min.js.map +7 -1
- package/dist/plugins/grideditor.ckeditor.esm.js +500 -0
- package/dist/plugins/grideditor.ckeditor.js +484 -449
- package/dist/plugins/grideditor.ckeditor.min.js +1 -2
- package/dist/plugins/grideditor.ckeditor.min.js.map +7 -1
- package/dist/plugins/grideditor.clipboard.esm.js +326 -0
- package/dist/plugins/grideditor.clipboard.js +298 -235
- package/dist/plugins/grideditor.clipboard.min.js +1 -2
- package/dist/plugins/grideditor.clipboard.min.js.map +7 -1
- package/dist/plugins/grideditor.codemirror-inline.esm.js +205 -0
- package/dist/plugins/grideditor.codemirror-inline.js +188 -168
- package/dist/plugins/grideditor.codemirror-inline.min.js +1 -2
- package/dist/plugins/grideditor.codemirror-inline.min.js.map +7 -1
- package/dist/plugins/grideditor.codemirror.esm.js +63 -0
- package/dist/plugins/grideditor.codemirror.js +60 -71
- package/dist/plugins/grideditor.codemirror.min.js +1 -2
- package/dist/plugins/grideditor.codemirror.min.js.map +7 -1
- package/dist/plugins/grideditor.elements.esm.js +271 -0
- package/dist/plugins/grideditor.elements.js +256 -149
- package/dist/plugins/grideditor.elements.min.js +1 -2
- package/dist/plugins/grideditor.elements.min.js.map +7 -1
- package/dist/plugins/grideditor.float.esm.js +34 -0
- package/dist/plugins/grideditor.float.js +37 -52
- package/dist/plugins/grideditor.float.min.js +1 -2
- package/dist/plugins/grideditor.float.min.js.map +7 -1
- package/dist/plugins/grideditor.gutters.esm.js +143 -0
- package/dist/plugins/grideditor.gutters.js +134 -131
- package/dist/plugins/grideditor.gutters.min.js +1 -2
- package/dist/plugins/grideditor.gutters.min.js.map +7 -1
- package/dist/plugins/grideditor.order.esm.js +189 -0
- package/dist/plugins/grideditor.order.js +170 -182
- package/dist/plugins/grideditor.order.min.js +1 -2
- package/dist/plugins/grideditor.order.min.js.map +7 -1
- package/dist/plugins/grideditor.popup.esm.js +187 -0
- package/dist/plugins/grideditor.popup.js +183 -134
- package/dist/plugins/grideditor.popup.min.js +1 -2
- package/dist/plugins/grideditor.popup.min.js.map +7 -1
- package/dist/plugins/grideditor.sections.esm.js +271 -0
- package/dist/plugins/grideditor.sections.js +250 -173
- package/dist/plugins/grideditor.sections.min.js +1 -2
- package/dist/plugins/grideditor.sections.min.js.map +7 -1
- package/dist/plugins/grideditor.spacing.esm.js +318 -0
- package/dist/plugins/grideditor.spacing.js +296 -272
- package/dist/plugins/grideditor.spacing.min.js +1 -2
- package/dist/plugins/grideditor.spacing.min.js.map +7 -1
- package/dist/plugins/grideditor.summernote.esm.js +509 -0
- package/dist/plugins/grideditor.summernote.js +493 -427
- package/dist/plugins/grideditor.summernote.min.js +1 -2
- package/dist/plugins/grideditor.summernote.min.js.map +7 -1
- package/dist/plugins/grideditor.tabs.esm.js +237 -0
- package/dist/plugins/grideditor.tabs.js +233 -139
- package/dist/plugins/grideditor.tabs.min.js +1 -2
- package/dist/plugins/grideditor.tabs.min.js.map +7 -1
- package/dist/plugins/grideditor.textalign.esm.js +40 -0
- package/dist/plugins/grideditor.textalign.js +43 -56
- package/dist/plugins/grideditor.textalign.min.js +1 -2
- package/dist/plugins/grideditor.textalign.min.js.map +7 -1
- package/dist/plugins/grideditor.tinymce.esm.js +519 -0
- package/dist/plugins/grideditor.tinymce.js +502 -490
- package/dist/plugins/grideditor.tinymce.min.js +1 -2
- package/dist/plugins/grideditor.tinymce.min.js.map +7 -1
- package/dist/plugins/grideditor.visibility.esm.js +158 -0
- package/dist/plugins/grideditor.visibility.js +140 -149
- package/dist/plugins/grideditor.visibility.min.js +1 -2
- package/dist/plugins/grideditor.visibility.min.js.map +7 -1
- package/docs/events.md +47 -21
- package/docs/locale-keys.md +6 -0
- package/docs/plugins.md +47 -25
- package/example/adapter.html +112 -0
- package/example/attributes.html +85 -61
- package/example/autocols.html +9 -9
- package/example/autosave.html +13 -14
- package/example/basic.html +4 -5
- package/example/breakpoints.html +5 -6
- package/example/ckeditor.html +4 -5
- package/example/clipboard.html +11 -10
- package/example/codemirror.html +9 -7
- package/example/containers.html +7 -8
- package/example/custom_editor.html +53 -34
- package/example/elements.html +10 -11
- package/example/index.html +16 -2
- package/example/locale.html +6 -7
- package/example/plugins.html +44 -29
- package/example/summernote.html +6 -5
- package/example/utilities.html +17 -13
- package/example/wrap_content.html +9 -9
- package/package.json +43 -12
- package/src/js/dom.js +401 -0
- package/src/js/grideditor.classic.js +16 -0
- package/src/js/grideditor.jquery.js +325 -0
- package/src/js/{jquery.grideditor.js → grideditor.js} +1284 -1124
- package/src/js/locales/grideditor.es.js +163 -156
- package/src/js/plugins/grideditor.accordion.js +97 -77
- package/src/js/plugins/grideditor.alignment.js +5 -7
- package/src/js/plugins/grideditor.card.js +23 -23
- package/src/js/plugins/grideditor.ckeditor.js +107 -106
- package/src/js/plugins/grideditor.clipboard.js +49 -37
- package/src/js/plugins/grideditor.codemirror-inline.js +50 -37
- package/src/js/plugins/grideditor.codemirror.js +9 -10
- package/src/js/plugins/grideditor.elements.js +57 -33
- package/src/js/plugins/grideditor.float.js +4 -6
- package/src/js/plugins/grideditor.gutters.js +20 -15
- package/src/js/plugins/grideditor.order.js +28 -25
- package/src/js/plugins/grideditor.popup.js +63 -51
- package/src/js/plugins/grideditor.sections.js +39 -32
- package/src/js/plugins/grideditor.spacing.js +42 -45
- package/src/js/plugins/grideditor.summernote.js +112 -76
- package/src/js/plugins/grideditor.tabs.js +65 -57
- package/src/js/plugins/grideditor.textalign.js +4 -6
- package/src/js/plugins/grideditor.tinymce.js +147 -139
- package/src/js/plugins/grideditor.visibility.js +24 -25
- package/src/js/register.js +18 -0
- package/src/js/text/grideditor.text.js +77 -56
- package/types/grideditor.d.ts +335 -0
- package/dist/jquery.grideditor.bundle.min.js +0 -10
- package/dist/jquery.grideditor.js +0 -4927
- package/dist/jquery.grideditor.min.js +0 -2
- package/dist/jquery.grideditor.min.js.map +0 -1
|
@@ -1,193 +1,299 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
(() => {
|
|
2
|
+
// src/js/register.js
|
|
3
|
+
var GridEditor = window.GridEditor;
|
|
4
|
+
if (!GridEditor || typeof GridEditor.get !== "function") {
|
|
5
|
+
throw new Error("grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, its locales and grideditor.jquery.js");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// src/js/dom.js
|
|
9
|
+
function all(root, selector) {
|
|
10
|
+
return root ? Array.prototype.slice.call(root.querySelectorAll(selector)) : [];
|
|
11
|
+
}
|
|
12
|
+
function one(root, selector) {
|
|
13
|
+
return root ? root.querySelector(selector) : null;
|
|
14
|
+
}
|
|
15
|
+
function children(node, selector) {
|
|
16
|
+
if (!node) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
return Array.prototype.filter.call(node.children, function(each) {
|
|
20
|
+
return !selector || each.matches(selector);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function child(node, selector) {
|
|
24
|
+
return children(node, selector)[0] || null;
|
|
25
|
+
}
|
|
26
|
+
function element(tag, attributes, text) {
|
|
27
|
+
var node = document.createElement(tag);
|
|
28
|
+
Object.keys(attributes || {}).forEach(function(name) {
|
|
29
|
+
var value = attributes[name];
|
|
30
|
+
if (value !== null && value !== void 0 && value !== false) {
|
|
31
|
+
node.setAttribute(name, value);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
if (text !== void 0 && text !== null) {
|
|
35
|
+
node.textContent = text;
|
|
36
|
+
}
|
|
37
|
+
return node;
|
|
38
|
+
}
|
|
39
|
+
function addClass(node, names) {
|
|
40
|
+
split(names).forEach(function(name) {
|
|
41
|
+
node.classList.add(name);
|
|
42
|
+
});
|
|
43
|
+
return node;
|
|
44
|
+
}
|
|
45
|
+
function removeClass(node, names) {
|
|
46
|
+
split(names).forEach(function(name) {
|
|
47
|
+
node.classList.remove(name);
|
|
48
|
+
});
|
|
49
|
+
return node;
|
|
50
|
+
}
|
|
51
|
+
function toggleClass(node, names, state) {
|
|
52
|
+
split(names).forEach(function(name) {
|
|
53
|
+
if (state === void 0) {
|
|
54
|
+
node.classList.toggle(name);
|
|
55
|
+
} else {
|
|
56
|
+
node.classList.toggle(name, !!state);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return node;
|
|
60
|
+
}
|
|
61
|
+
function hasClass(node, name) {
|
|
62
|
+
return !!node && node.nodeType === 1 && node.classList.contains(name);
|
|
63
|
+
}
|
|
64
|
+
function split(names) {
|
|
65
|
+
return String(names || "").split(/\s+/).filter(Boolean);
|
|
66
|
+
}
|
|
67
|
+
function hide(node) {
|
|
68
|
+
node.style.display = "none";
|
|
69
|
+
return node;
|
|
70
|
+
}
|
|
71
|
+
function visible(node) {
|
|
72
|
+
return !!(node.offsetWidth || node.offsetHeight || node.getClientRects().length);
|
|
73
|
+
}
|
|
74
|
+
var DEFAULT_DURATION = 400;
|
|
75
|
+
function animateAway(node, frames, duration, done) {
|
|
76
|
+
duration = duration === void 0 ? DEFAULT_DURATION : duration;
|
|
77
|
+
var finish = function() {
|
|
78
|
+
hide(node);
|
|
79
|
+
if (done) {
|
|
80
|
+
done();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
if (!visible(node) || !node.animate || duration <= 0) {
|
|
84
|
+
window.setTimeout(finish, 0);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
var animation = node.animate(frames(getComputedStyle(node)), {
|
|
88
|
+
duration,
|
|
89
|
+
easing: "ease-in-out"
|
|
90
|
+
});
|
|
91
|
+
var called = false;
|
|
92
|
+
var once = function() {
|
|
93
|
+
if (called) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
called = true;
|
|
97
|
+
finish();
|
|
98
|
+
};
|
|
99
|
+
animation.onfinish = once;
|
|
100
|
+
animation.oncancel = once;
|
|
101
|
+
}
|
|
102
|
+
function slideUp(node, duration, done) {
|
|
103
|
+
if (typeof duration === "function") {
|
|
104
|
+
done = duration;
|
|
105
|
+
duration = void 0;
|
|
106
|
+
}
|
|
107
|
+
node.style.overflow = "hidden";
|
|
108
|
+
animateAway(node, function(style) {
|
|
109
|
+
return [
|
|
110
|
+
{
|
|
111
|
+
height: style.height,
|
|
112
|
+
paddingTop: style.paddingTop,
|
|
113
|
+
paddingBottom: style.paddingBottom,
|
|
114
|
+
marginTop: style.marginTop,
|
|
115
|
+
marginBottom: style.marginBottom
|
|
116
|
+
},
|
|
117
|
+
{ height: "0px", paddingTop: "0px", paddingBottom: "0px", marginTop: "0px", marginBottom: "0px" }
|
|
118
|
+
];
|
|
119
|
+
}, duration, function() {
|
|
120
|
+
node.style.removeProperty("overflow");
|
|
121
|
+
if (done) {
|
|
122
|
+
done();
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// src/js/plugins/grideditor.accordion.js
|
|
128
|
+
Object.assign(GridEditor.locales.en, {
|
|
129
|
+
"container.add_accordion": "Accordion",
|
|
130
|
+
"container.add_accordion_item": "Add item",
|
|
131
|
+
"container.accordion_label": "Item {number}",
|
|
132
|
+
"confirm.delete_accordion_item": "Delete this item and everything in it?"
|
|
133
|
+
});
|
|
134
|
+
GridEditor.containers.accordion = function(ge) {
|
|
135
|
+
var answered = /* @__PURE__ */ new WeakSet();
|
|
136
|
+
function collapseOf(item) {
|
|
137
|
+
return child(item, ".accordion-collapse");
|
|
138
|
+
}
|
|
22
139
|
function staysOpen(container, ignore) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
140
|
+
var items = all(container, ":scope > .accordion > .accordion-item > .accordion-collapse");
|
|
141
|
+
if (ignore) {
|
|
142
|
+
var ignored = collapseOf(ignore);
|
|
143
|
+
items = items.filter(function(collapse) {
|
|
144
|
+
return collapse !== ignored;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return items.length > 0 && !items.filter(function(collapse) {
|
|
148
|
+
return collapse.hasAttribute("data-bs-parent");
|
|
149
|
+
}).length;
|
|
28
150
|
}
|
|
29
|
-
|
|
30
151
|
function addAccordionItemTo(container, options) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
152
|
+
options = options || {};
|
|
153
|
+
var accordion = child(container, ".accordion");
|
|
154
|
+
var id = ge.containerId("acc-item");
|
|
155
|
+
var number = children(accordion, ".accordion-item").length + 1;
|
|
156
|
+
var open = options.open === void 0 ? number === 1 : !!options.open;
|
|
157
|
+
var stayOpen = options.stay_open === void 0 ? staysOpen(container) : !!options.stay_open;
|
|
158
|
+
var item = accordion.appendChild(element("div", { "class": "accordion-item ge-accordion-item" }));
|
|
159
|
+
var header = item.appendChild(element("h2", { "class": "accordion-header" }));
|
|
160
|
+
var button = header.appendChild(element("button", {
|
|
161
|
+
"class": "accordion-button",
|
|
162
|
+
type: "button",
|
|
163
|
+
"data-bs-toggle": "collapse",
|
|
164
|
+
"data-bs-target": "#" + id,
|
|
165
|
+
"aria-expanded": open ? "true" : "false"
|
|
166
|
+
}));
|
|
167
|
+
toggleClass(button, "collapsed", !open);
|
|
168
|
+
button.appendChild(element(
|
|
169
|
+
"span",
|
|
170
|
+
{ "class": "ge-pane-label" },
|
|
171
|
+
options.label || ge.t("container.accordion_label", { number })
|
|
172
|
+
));
|
|
173
|
+
var collapse = item.appendChild(element("div", {
|
|
174
|
+
"class": "accordion-collapse collapse",
|
|
175
|
+
id,
|
|
176
|
+
"data-ge-open": open ? "true" : "false"
|
|
177
|
+
}));
|
|
178
|
+
toggleClass(collapse, "show", open);
|
|
179
|
+
if (!stayOpen) {
|
|
180
|
+
collapse.setAttribute("data-bs-parent", "#" + accordion.getAttribute("id"));
|
|
181
|
+
}
|
|
182
|
+
var body = collapse.appendChild(element("div", { "class": "accordion-body" }));
|
|
183
|
+
body.appendChild(ge.defaultRegion());
|
|
184
|
+
return body;
|
|
61
185
|
}
|
|
62
|
-
|
|
63
186
|
function toggleAccordionItem(container, item) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
187
|
+
var collapse = collapseOf(item);
|
|
188
|
+
var opening = collapse.getAttribute("data-ge-open") !== "true";
|
|
189
|
+
if (opening && !staysOpen(container)) {
|
|
190
|
+
all(container, ":scope > .accordion > .accordion-item").forEach(function(other) {
|
|
191
|
+
if (other !== item) {
|
|
192
|
+
setAccordionItemOpen(other, false);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
setAccordionItemOpen(item, opening);
|
|
74
197
|
}
|
|
75
|
-
|
|
76
198
|
function setAccordionItemOpen(item, open) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
;
|
|
199
|
+
var collapse = collapseOf(item);
|
|
200
|
+
if (collapse) {
|
|
201
|
+
collapse.setAttribute("data-ge-open", open ? "true" : "false");
|
|
202
|
+
toggleClass(collapse, "show", open);
|
|
203
|
+
}
|
|
204
|
+
all(item, ":scope > .accordion-header .accordion-button").forEach(function(button) {
|
|
205
|
+
toggleClass(button, "collapsed", !open);
|
|
206
|
+
button.setAttribute("aria-expanded", open ? "true" : "false");
|
|
207
|
+
});
|
|
85
208
|
}
|
|
86
|
-
|
|
87
209
|
function reparentAccordionItem(container, item) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
210
|
+
var accordion = item.closest(".accordion");
|
|
211
|
+
var collapse = collapseOf(item);
|
|
212
|
+
if (!collapse) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (staysOpen(container, item)) {
|
|
216
|
+
collapse.removeAttribute("data-bs-parent");
|
|
217
|
+
} else {
|
|
218
|
+
collapse.setAttribute("data-bs-parent", "#" + accordion.getAttribute("id"));
|
|
219
|
+
}
|
|
98
220
|
}
|
|
99
|
-
|
|
100
221
|
return {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
// toggles get a chance to change it while editing.
|
|
143
|
-
// Every item is shown while editing (the stylesheet
|
|
144
|
-
// does that), so this is the only record of it.
|
|
145
|
-
if (collapse.attr('data-ge-open') === undefined) {
|
|
146
|
-
collapse.attr('data-ge-open', collapse.hasClass('show') ? 'true' : 'false');
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
var button = item.find('> .accordion-header .accordion-button');
|
|
150
|
-
|
|
151
|
-
// Bootstrap's collapse stays out of it, and the editor
|
|
152
|
-
// answers the click itself
|
|
153
|
-
ge.suspendToggles(button);
|
|
154
|
-
ge.makeLabelEditable(ge.labelIn(button));
|
|
155
|
-
|
|
156
|
-
if (!button.data('ge-toggles')) {
|
|
157
|
-
button.data('ge-toggles', true).on('click', function(e) {
|
|
158
|
-
if (ge.labelIn(button).attr('contenteditable') === 'true') { return; }
|
|
159
|
-
|
|
160
|
-
e.preventDefault();
|
|
161
|
-
toggleAccordionItem(container, item);
|
|
162
|
-
});
|
|
222
|
+
labelKey: "container.add_accordion",
|
|
223
|
+
// Items sort within their accordion and into any other one
|
|
224
|
+
onSortable: function(sortable) {
|
|
225
|
+
sortable(all(ge.canvas, ".ge-container-accordion > .accordion"), {
|
|
226
|
+
draggable: ".ge-accordion-item",
|
|
227
|
+
group: "accordion"
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
addPaneKey: "container.add_accordion_item",
|
|
231
|
+
paneKind: "accordion-item",
|
|
232
|
+
create: function(options) {
|
|
233
|
+
var container = element("div", { "data-ge-container": "accordion" });
|
|
234
|
+
var labels = options.labels || [];
|
|
235
|
+
var count = options.items || labels.length || 2;
|
|
236
|
+
container.appendChild(element("div", { "class": "accordion", id: ge.containerId("accordion") }));
|
|
237
|
+
for (var i = 0; i < count; i++) {
|
|
238
|
+
addAccordionItemTo(container, {
|
|
239
|
+
label: labels[i],
|
|
240
|
+
open: i === 0,
|
|
241
|
+
stay_open: options.stay_open
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return container;
|
|
245
|
+
},
|
|
246
|
+
addPane: addAccordionItemTo,
|
|
247
|
+
mark: function(container) {
|
|
248
|
+
all(container, ":scope > .accordion > .accordion-item").forEach(function(item) {
|
|
249
|
+
addClass(item, "ge-accordion-item");
|
|
250
|
+
var collapse = collapseOf(item);
|
|
251
|
+
if (collapse && !collapse.hasAttribute("data-ge-open")) {
|
|
252
|
+
collapse.setAttribute("data-ge-open", hasClass(collapse, "show") ? "true" : "false");
|
|
253
|
+
}
|
|
254
|
+
var button = one(item, ":scope > .accordion-header .accordion-button");
|
|
255
|
+
if (button) {
|
|
256
|
+
ge.suspendToggles(button);
|
|
257
|
+
ge.makeLabelEditable(ge.labelIn(button));
|
|
258
|
+
if (!answered.has(button)) {
|
|
259
|
+
answered.add(button);
|
|
260
|
+
button.addEventListener("click", function(e) {
|
|
261
|
+
if (ge.labelIn(button).getAttribute("contenteditable") === "true") {
|
|
262
|
+
return;
|
|
163
263
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
ge.
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
264
|
+
e.preventDefault();
|
|
265
|
+
toggleAccordionItem(container, item);
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (child(item, ".ge-tools-drawer")) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
ge.createPaneControls(
|
|
273
|
+
item,
|
|
274
|
+
"accordion-item",
|
|
275
|
+
ge.settings.accordion_tools,
|
|
276
|
+
ge.t("confirm.delete_accordion_item"),
|
|
277
|
+
function(removed) {
|
|
278
|
+
slideUp(item, 200, removed);
|
|
279
|
+
}
|
|
280
|
+
);
|
|
281
|
+
});
|
|
282
|
+
},
|
|
283
|
+
unmark: function(container) {
|
|
284
|
+
ge.resumeToggles(container);
|
|
285
|
+
all(container, ":scope > .accordion > .accordion-item").forEach(function(item) {
|
|
286
|
+
var collapse = collapseOf(item);
|
|
287
|
+
setAccordionItemOpen(item, !!collapse && collapse.getAttribute("data-ge-open") === "true");
|
|
288
|
+
});
|
|
289
|
+
all(container, ".ge-accordion-item").forEach(function(item) {
|
|
290
|
+
removeClass(item, "ge-accordion-item");
|
|
291
|
+
});
|
|
292
|
+
ge.unwrapLabels(container);
|
|
293
|
+
},
|
|
294
|
+
afterPaneMove: function(container, item) {
|
|
295
|
+
reparentAccordionItem(container, item);
|
|
296
|
+
}
|
|
190
297
|
};
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
})(jQuery);
|
|
298
|
+
};
|
|
299
|
+
})();
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
(
|
|
2
|
-
//# sourceMappingURL=grideditor.accordion.min.js.map
|
|
1
|
+
(()=>{var m=window.GridEditor;if(!m||typeof m.get!="function")throw new Error("grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, its locales and grideditor.jquery.js");function s(e,r){return e?Array.prototype.slice.call(e.querySelectorAll(r)):[]}function T(e,r){return e?e.querySelector(r):null}function x(e,r){return e?Array.prototype.filter.call(e.children,function(o){return!r||o.matches(r)}):[]}function b(e,r){return x(e,r)[0]||null}function u(e,r,o){var c=document.createElement(e);return Object.keys(r||{}).forEach(function(f){var d=r[f];d!=null&&d!==!1&&c.setAttribute(f,d)}),o!=null&&(c.textContent=o),c}function _(e,r){return E(r).forEach(function(o){e.classList.add(o)}),e}function S(e,r){return E(r).forEach(function(o){e.classList.remove(o)}),e}function g(e,r,o){return E(r).forEach(function(c){o===void 0?e.classList.toggle(c):e.classList.toggle(c,!!o)}),e}function L(e,r){return!!e&&e.nodeType===1&&e.classList.contains(r)}function E(e){return String(e||"").split(/\s+/).filter(Boolean)}function k(e){return e.style.display="none",e}function j(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}var P=400;function H(e,r,o,c){o=o===void 0?P:o;var f=function(){k(e),c&&c()};if(!j(e)||!e.animate||o<=0){window.setTimeout(f,0);return}var d=e.animate(r(getComputedStyle(e)),{duration:o,easing:"ease-in-out"}),p=!1,h=function(){p||(p=!0,f())};d.onfinish=h,d.oncancel=h}function B(e,r,o){typeof r=="function"&&(o=r,r=void 0),e.style.overflow="hidden",H(e,function(c){return[{height:c.height,paddingTop:c.paddingTop,paddingBottom:c.paddingBottom,marginTop:c.marginTop,marginBottom:c.marginBottom},{height:"0px",paddingTop:"0px",paddingBottom:"0px",marginTop:"0px",marginBottom:"0px"}]},r,function(){e.style.removeProperty("overflow"),o&&o()})}Object.assign(m.locales.en,{"container.add_accordion":"Accordion","container.add_accordion_item":"Add item","container.accordion_label":"Item {number}","confirm.delete_accordion_item":"Delete this item and everything in it?"});m.containers.accordion=function(e){var r=new WeakSet;function o(n){return b(n,".accordion-collapse")}function c(n,t){var i=s(n,":scope > .accordion > .accordion-item > .accordion-collapse");if(t){var a=o(t);i=i.filter(function(l){return l!==a})}return i.length>0&&!i.filter(function(l){return l.hasAttribute("data-bs-parent")}).length}function f(n,t){t=t||{};var i=b(n,".accordion"),a=e.containerId("acc-item"),l=x(i,".accordion-item").length+1,v=t.open===void 0?l===1:!!t.open,O=t.stay_open===void 0?c(n):!!t.stay_open,A=i.appendChild(u("div",{class:"accordion-item ge-accordion-item"})),I=A.appendChild(u("h2",{class:"accordion-header"})),C=I.appendChild(u("button",{class:"accordion-button",type:"button","data-bs-toggle":"collapse","data-bs-target":"#"+a,"aria-expanded":v?"true":"false"}));g(C,"collapsed",!v),C.appendChild(u("span",{class:"ge-pane-label"},t.label||e.t("container.accordion_label",{number:l})));var y=A.appendChild(u("div",{class:"accordion-collapse collapse",id:a,"data-ge-open":v?"true":"false"}));g(y,"show",v),O||y.setAttribute("data-bs-parent","#"+i.getAttribute("id"));var w=y.appendChild(u("div",{class:"accordion-body"}));return w.appendChild(e.defaultRegion()),w}function d(n,t){var i=o(t),a=i.getAttribute("data-ge-open")!=="true";a&&!c(n)&&s(n,":scope > .accordion > .accordion-item").forEach(function(l){l!==t&&p(l,!1)}),p(t,a)}function p(n,t){var i=o(n);i&&(i.setAttribute("data-ge-open",t?"true":"false"),g(i,"show",t)),s(n,":scope > .accordion-header .accordion-button").forEach(function(a){g(a,"collapsed",!t),a.setAttribute("aria-expanded",t?"true":"false")})}function h(n,t){var i=t.closest(".accordion"),a=o(t);a&&(c(n,t)?a.removeAttribute("data-bs-parent"):a.setAttribute("data-bs-parent","#"+i.getAttribute("id")))}return{labelKey:"container.add_accordion",onSortable:function(n){n(s(e.canvas,".ge-container-accordion > .accordion"),{draggable:".ge-accordion-item",group:"accordion"})},addPaneKey:"container.add_accordion_item",paneKind:"accordion-item",create:function(n){var t=u("div",{"data-ge-container":"accordion"}),i=n.labels||[],a=n.items||i.length||2;t.appendChild(u("div",{class:"accordion",id:e.containerId("accordion")}));for(var l=0;l<a;l++)f(t,{label:i[l],open:l===0,stay_open:n.stay_open});return t},addPane:f,mark:function(n){s(n,":scope > .accordion > .accordion-item").forEach(function(t){_(t,"ge-accordion-item");var i=o(t);i&&!i.hasAttribute("data-ge-open")&&i.setAttribute("data-ge-open",L(i,"show")?"true":"false");var a=T(t,":scope > .accordion-header .accordion-button");a&&(e.suspendToggles(a),e.makeLabelEditable(e.labelIn(a)),r.has(a)||(r.add(a),a.addEventListener("click",function(l){e.labelIn(a).getAttribute("contenteditable")!=="true"&&(l.preventDefault(),d(n,t))}))),!b(t,".ge-tools-drawer")&&e.createPaneControls(t,"accordion-item",e.settings.accordion_tools,e.t("confirm.delete_accordion_item"),function(l){B(t,200,l)})})},unmark:function(n){e.resumeToggles(n),s(n,":scope > .accordion > .accordion-item").forEach(function(t){var i=o(t);p(t,!!i&&i.getAttribute("data-ge-open")==="true")}),s(n,".ge-accordion-item").forEach(function(t){S(t,"ge-accordion-item")}),e.unwrapLabels(n)},afterPaneMove:function(n,t){h(n,t)}}};})();
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/js/register.js", "../../src/js/dom.js", "../../src/js/plugins/grideditor.accordion.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * What a plugin's or a locale's classic script imports in place of the\n * editor: the GridEditor the page already loaded.\n *\n * The build points `import { GridEditor } from '../grideditor.js'` here for\n * the classic scripts, so each registers on the editor the page has rather\n * than bringing its own. Loaded before the editor there is nothing to\n * register on, and saying so is better than a TypeError three calls later.\n */\nvar GridEditor = window.GridEditor;\n\nif (!GridEditor || typeof GridEditor.get !== 'function') {\n throw new Error('grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, ' +\n 'its locales and grideditor.jquery.js');\n}\n\nexport { GridEditor };\nexport default GridEditor;\n", "/**\n * The DOM, the way grid-editor uses it.\n *\n * Small helpers over the browser's own API, for the core and the shipped\n * plugins. Not a public API: a plugin of a host's own is free to write its\n * DOM code however it likes, and this file makes no promise to it.\n *\n * Stateless on purpose. The build puts a copy of this file in each plugin's\n * classic script, so anything kept here would be kept once per copy; a\n * module that needs to remember something about a node keeps its own\n * WeakMap.\n */\n\n/** Every element under `root` matching `selector`, as an array. */\nexport function all(root, selector) {\n return root ? Array.prototype.slice.call(root.querySelectorAll(selector)) : [];\n}\n\n/** The first element under `root` matching `selector`, or null. */\nexport function one(root, selector) {\n return root ? root.querySelector(selector) : null;\n}\n\n/** `root` itself when it matches, then every element under it that does. */\nexport function selfAndAll(root, selector) {\n if (!root) { return []; }\n\n var found = all(root, selector);\n if (root.nodeType === 1 && root.matches(selector)) { found.unshift(root); }\n return found;\n}\n\n/** The element children of `node`, those matching `selector` if one is given. */\nexport function children(node, selector) {\n if (!node) { return []; }\n\n return Array.prototype.filter.call(node.children, function(each) {\n return !selector || each.matches(selector);\n });\n}\n\n/** The first element child matching `selector`, or null. */\nexport function child(node, selector) {\n return children(node, selector)[0] || null;\n}\n\n/** The nearest ancestor-or-self matching `selector` below `stopAt`, or null. */\nexport function closest(node, selector, stopAt) {\n var found = node && node.nodeType === 1 ? node.closest(selector) : null;\n\n if (found && stopAt && found !== stopAt && !stopAt.contains(found)) { return null; }\n return found;\n}\n\n/** Whether `node` is an element matching `selector`. */\nexport function is(node, selector) {\n return !!node && node.nodeType === 1 && node.matches(selector);\n}\n\n/** Whether `node` is in the document. */\nexport function attached(node) {\n return !!node && document.documentElement.contains(node);\n}\n\n/** The element siblings after `node` that match `selector`. */\nexport function nextAll(node, selector) {\n var found = [];\n\n for (var next = node.nextElementSibling; next; next = next.nextElementSibling) {\n if (!selector || next.matches(selector)) { found.push(next); }\n }\n return found;\n}\n\n/** The ancestors of `node` up to, and not including, `stop`, nearest first. */\nexport function parentsUntil(node, stop) {\n var found = [];\n\n for (var parent = node.parentElement; parent && parent !== stop; parent = parent.parentElement) {\n found.push(parent);\n }\n return found;\n}\n\n/**\n * The nodes the html parses into, detached. Parsed the way innerHTML parses,\n * so a <script> in it never runs, here or once it is in the page.\n */\nexport function parse(html) {\n var template = document.createElement('template');\n template.innerHTML = html;\n return Array.prototype.slice.call(template.content.childNodes);\n}\n\n/** The one element the html is, detached. */\nexport function create(html) {\n var nodes = parse(html.trim());\n\n for (var i = 0; i < nodes.length; i++) {\n if (nodes[i].nodeType === 1) { return nodes[i]; }\n }\n return null;\n}\n\n/** An element of `tag`, with `attributes` and `text`. */\nexport function element(tag, attributes, text) {\n var node = document.createElement(tag);\n\n Object.keys(attributes || {}).forEach(function(name) {\n var value = attributes[name];\n if (value !== null && value !== undefined && value !== false) { node.setAttribute(name, value); }\n });\n if (text !== undefined && text !== null) { node.textContent = text; }\n\n return node;\n}\n\n/** Replace what `node` holds with `html`. A <script> in it does not run. */\nexport function setHtml(node, html) {\n node.innerHTML = html === undefined || html === null ? '' : String(html);\n return node;\n}\n\n/** Add one or several space separated classes. */\nexport function addClass(node, names) {\n split(names).forEach(function(name) { node.classList.add(name); });\n return node;\n}\n\nexport function removeClass(node, names) {\n split(names).forEach(function(name) { node.classList.remove(name); });\n return node;\n}\n\n/** Each class on, or off, or flipped when `on` is not given. */\nexport function toggleClass(node, names, state) {\n split(names).forEach(function(name) {\n if (state === undefined) {\n node.classList.toggle(name);\n } else {\n node.classList.toggle(name, !!state);\n }\n });\n return node;\n}\n\nexport function hasClass(node, name) {\n return !!node && node.nodeType === 1 && node.classList.contains(name);\n}\n\nfunction split(names) {\n return String(names || '').split(/\\s+/).filter(Boolean);\n}\n\n/** Take the class attribute off when there is nothing left in it. */\nexport function dropEmptyClass(node) {\n if (!node.getAttribute('class')) { node.removeAttribute('class'); }\n return node;\n}\n\n/** Take the style attribute off when there is nothing left in it. */\nexport function dropEmptyStyle(node) {\n if (!node.getAttribute('style')) { node.removeAttribute('style'); }\n return node;\n}\n\n/** Set attributes; a null or undefined value takes the attribute off. */\nexport function attr(node, attributes) {\n Object.keys(attributes).forEach(function(name) {\n var value = attributes[name];\n\n if (value === null || value === undefined) {\n node.removeAttribute(name);\n } else {\n node.setAttribute(name, value);\n }\n });\n return node;\n}\n\n/**\n * Inline styles, by css property name. A number is pixels for the properties\n * that take a length, as jQuery had it; an empty string takes one off.\n */\nexport function css(node, styles) {\n Object.keys(styles).forEach(function(property) {\n var value = styles[property];\n\n if (typeof value === 'number' && !UNITLESS[property]) { value = value + 'px'; }\n node.style.setProperty(property, value === null || value === undefined ? '' : String(value));\n });\n return node;\n}\n\nvar UNITLESS = { opacity: true, 'z-index': true, 'flex-grow': true, 'flex-shrink': true, order: true };\n\n/** What an element of this tag shows as when nothing hides it. */\nvar defaultDisplays = {};\n\nfunction defaultDisplay(node) {\n var tag = node.nodeName;\n\n if (!defaultDisplays[tag]) {\n var probe = document.body.appendChild(document.createElement(tag));\n defaultDisplays[tag] = getComputedStyle(probe).display;\n probe.remove();\n if (defaultDisplays[tag] === 'none') { defaultDisplays[tag] = 'block'; }\n }\n return defaultDisplays[tag];\n}\n\n/** Show a node: its inline display:none off, and a display of its own if a stylesheet hides it. */\nexport function show(node) {\n node.style.removeProperty('display');\n if (getComputedStyle(node).display === 'none') { node.style.display = defaultDisplay(node); }\n return node;\n}\n\nexport function hide(node) {\n node.style.display = 'none';\n return node;\n}\n\n/** Show or hide; flip when `on` is not given. */\nexport function toggle(node, state) {\n if (state === undefined) { state = !visible(node); }\n return state ? show(node) : hide(node);\n}\n\n/** Whether a node takes up room: what jQuery's :visible meant. */\nexport function visible(node) {\n return !!(node.offsetWidth || node.offsetHeight || node.getClientRects().length);\n}\n\n/** The border box's width, fractions included. */\nexport function outerWidth(node) {\n return node.getBoundingClientRect().width;\n}\n\nexport function outerHeight(node) {\n return node.getBoundingClientRect().height;\n}\n\n/** The content box's height, which is what jQuery's height() gave. */\nexport function contentHeight(node) {\n var style = getComputedStyle(node);\n return node.clientHeight - parseFloat(style.paddingTop) - parseFloat(style.paddingBottom);\n}\n\n/** Where a node is on the page, not in the window. */\nexport function offset(node) {\n var box = node.getBoundingClientRect();\n return { top: box.top + window.pageYOffset, left: box.left + window.pageXOffset };\n}\n\n/** Its index among its parent's element children, those matching `selector` if given. */\nexport function indexIn(node, selector) {\n return children(node.parentElement, selector).indexOf(node);\n}\n\n/** Put `node` right after `reference`. */\nexport function insertAfter(node, reference) {\n reference.parentNode.insertBefore(node, reference.nextSibling);\n return node;\n}\n\n/** Replace `node` with what it holds. */\nexport function unwrap(node) {\n var parent = node.parentNode;\n\n while (node.firstChild) { parent.insertBefore(node.firstChild, node); }\n node.remove();\n}\n\n/** Put `node` inside `wrapper`, where `node` was. */\nexport function wrap(node, wrapper) {\n node.parentNode.insertBefore(wrapper, node);\n wrapper.appendChild(node);\n return wrapper;\n}\n\n/**\n * Listen on `root` for `types` (space separated) on descendants that match\n * `selector`, with `this` the matched element, as jQuery's delegated\n * handlers had it. Hands back the listener, for removeEventListener; a\n * signal in `options` removes it too.\n */\nexport function delegate(root, types, selector, handler, options) {\n var listener = function(event) {\n var match = closest(event.target, selector, root);\n if (match && root.contains(match)) { return handler.call(match, event); }\n return undefined;\n };\n\n split(types).forEach(function(type) { root.addEventListener(type, listener, options); });\n return listener;\n}\n\n/** Listen for several space separated event types with one handler. */\nexport function on(target, types, handler, options) {\n split(types).forEach(function(type) { target.addEventListener(type, handler, options); });\n return handler;\n}\n\nexport function off(target, types, handler, options) {\n split(types).forEach(function(type) { target.removeEventListener(type, handler, options); });\n}\n\n/** A mouse event of `type` sent to `node`, the way a pointer would. */\nexport function fire(node, type) {\n node.dispatchEvent(new MouseEvent(type, { bubbles: type !== 'mouseenter' && type !== 'mouseleave' }));\n}\n\n/* ------------------------------------------------------------------\n * Taking a node away, visibly.\n *\n * The durations are the ones 6.x had through jQuery: 400 ms unless the\n * caller says otherwise. `done` runs once the node is out of sight, which is\n * when the caller removes it; a node that is already out of sight is done at\n * once, on the next task, as jQuery had it.\n * ------------------------------------------------------------------ */\n\nvar DEFAULT_DURATION = 400;\n\nfunction animateAway(node, frames, duration, done) {\n duration = duration === undefined ? DEFAULT_DURATION : duration;\n\n var finish = function() {\n hide(node);\n if (done) { done(); }\n };\n\n if (!visible(node) || !node.animate || duration <= 0) {\n window.setTimeout(finish, 0);\n return;\n }\n\n var animation = node.animate(frames(getComputedStyle(node)), {\n duration: duration,\n easing: 'ease-in-out',\n });\n var called = false;\n var once = function() {\n if (called) { return; }\n called = true;\n finish();\n };\n\n animation.onfinish = once;\n animation.oncancel = once;\n}\n\n/** Fold a node up to nothing, then hide it. */\nexport function slideUp(node, duration, done) {\n if (typeof duration === 'function') {\n done = duration;\n duration = undefined;\n }\n\n node.style.overflow = 'hidden';\n animateAway(node, function(style) {\n return [\n {\n height: style.height,\n paddingTop: style.paddingTop,\n paddingBottom: style.paddingBottom,\n marginTop: style.marginTop,\n marginBottom: style.marginBottom,\n },\n { height: '0px', paddingTop: '0px', paddingBottom: '0px', marginTop: '0px', marginBottom: '0px' },\n ];\n }, duration, function() {\n node.style.removeProperty('overflow');\n if (done) { done(); }\n });\n}\n\n/** Fade a node out, then hide it. */\nexport function fadeOut(node, duration, done) {\n animateAway(node, function(style) {\n return [{ opacity: style.opacity }, { opacity: 0 }];\n }, duration, done);\n}\n\n/** Fade and fold a node, in height and, with `width`, sideways too, then hide it. */\nexport function shrinkAway(node, duration, done, width) {\n node.style.overflow = 'hidden';\n animateAway(node, function(style) {\n var from = { opacity: style.opacity, height: style.height };\n var to = { opacity: 0, height: '0px' };\n\n if (width) {\n from.width = style.width;\n to.width = '0px';\n }\n return [from, to];\n }, duration, function() {\n node.style.removeProperty('overflow');\n if (done) { done(); }\n });\n}\n", "/**\n * Accordions for grid-editor.\n *\n * A container plugin: load this file after the editor and the toolbar offers\n * an accordion. What it can ask the editor for is the handle its factory is\n * called with, described in docs/plugins.md.\n *\n * <script src=\"dist/grideditor.min.js\"></script>\n * <script src=\"dist/plugins/grideditor.accordion.min.js\"></script>\n */\nimport { GridEditor } from '../grideditor.js';\nimport * as dom from '../dom.js';\n\nObject.assign(GridEditor.locales.en, {\n 'container.add_accordion': 'Accordion',\n 'container.add_accordion_item': 'Add item',\n 'container.accordion_label': 'Item {number}',\n 'confirm.delete_accordion_item': 'Delete this item and everything in it?',\n});\n\nGridEditor.containers.accordion = function(ge) {\n\n // The buttons whose clicks the editor answers itself, bound once each\n var answered = new WeakSet();\n\n function collapseOf(item) {\n return dom.child(item, '.accordion-collapse');\n }\n\n function staysOpen(container, ignore) {\n var items = dom.all(container, ':scope > .accordion > .accordion-item > .accordion-collapse');\n\n if (ignore) {\n var ignored = collapseOf(ignore);\n items = items.filter(function(collapse) { return collapse !== ignored; });\n }\n\n return items.length > 0 && !items.filter(function(collapse) {\n return collapse.hasAttribute('data-bs-parent');\n }).length;\n }\n\n function addAccordionItemTo(container, options) {\n options = options || {};\n\n var accordion = dom.child(container, '.accordion');\n var id = ge.containerId('acc-item');\n var number = dom.children(accordion, '.accordion-item').length + 1;\n var open = options.open === undefined ? number === 1 : !!options.open;\n var stayOpen = options.stay_open === undefined ? staysOpen(container) : !!options.stay_open;\n\n var item = accordion.appendChild(dom.element('div', { 'class': 'accordion-item ge-accordion-item' }));\n\n var header = item.appendChild(dom.element('h2', { 'class': 'accordion-header' }));\n var button = header.appendChild(dom.element('button', {\n 'class': 'accordion-button',\n type: 'button',\n 'data-bs-toggle': 'collapse',\n 'data-bs-target': '#' + id,\n 'aria-expanded': open ? 'true' : 'false',\n }));\n dom.toggleClass(button, 'collapsed', !open);\n button.appendChild(dom.element('span', { 'class': 'ge-pane-label' },\n options.label || ge.t('container.accordion_label', { number: number })));\n\n var collapse = item.appendChild(dom.element('div', {\n 'class': 'accordion-collapse collapse',\n id: id,\n 'data-ge-open': open ? 'true' : 'false',\n }));\n dom.toggleClass(collapse, 'show', open);\n\n if (!stayOpen) { collapse.setAttribute('data-bs-parent', '#' + accordion.getAttribute('id')); }\n\n var body = collapse.appendChild(dom.element('div', { 'class': 'accordion-body' }));\n body.appendChild(ge.defaultRegion());\n return body;\n }\n\n function toggleAccordionItem(container, item) {\n var collapse = collapseOf(item);\n var opening = collapse.getAttribute('data-ge-open') !== 'true';\n\n if (opening && !staysOpen(container)) {\n dom.all(container, ':scope > .accordion > .accordion-item').forEach(function(other) {\n if (other !== item) { setAccordionItemOpen(other, false); }\n });\n }\n\n setAccordionItemOpen(item, opening);\n }\n\n function setAccordionItemOpen(item, open) {\n var collapse = collapseOf(item);\n if (collapse) {\n collapse.setAttribute('data-ge-open', open ? 'true' : 'false');\n dom.toggleClass(collapse, 'show', open);\n }\n\n dom.all(item, ':scope > .accordion-header .accordion-button').forEach(function(button) {\n dom.toggleClass(button, 'collapsed', !open);\n button.setAttribute('aria-expanded', open ? 'true' : 'false');\n });\n }\n\n function reparentAccordionItem(container, item) {\n var accordion = item.closest('.accordion');\n var collapse = collapseOf(item);\n if (!collapse) { return; }\n\n // The item that just arrived still carries the parent it had\n // where it came from, so it is not asked what this accordion does\n if (staysOpen(container, item)) {\n collapse.removeAttribute('data-bs-parent');\n } else {\n collapse.setAttribute('data-bs-parent', '#' + accordion.getAttribute('id'));\n }\n }\n\n return {\n labelKey: 'container.add_accordion',\n\n // Items sort within their accordion and into any other one\n onSortable: function(sortable) {\n sortable(dom.all(ge.canvas, '.ge-container-accordion > .accordion'), {\n draggable: '.ge-accordion-item',\n group: 'accordion',\n });\n },\n addPaneKey: 'container.add_accordion_item',\n paneKind: 'accordion-item',\n\n create: function(options) {\n var container = dom.element('div', { 'data-ge-container': 'accordion' });\n var labels = options.labels || [];\n var count = options.items || labels.length || 2;\n\n container.appendChild(dom.element('div', { 'class': 'accordion', id: ge.containerId('accordion') }));\n\n for (var i = 0; i < count; i++) {\n addAccordionItemTo(container, {\n label: labels[i],\n open: i === 0,\n stay_open: options.stay_open,\n });\n }\n\n return container;\n },\n\n addPane: addAccordionItemTo,\n\n mark: function(container) {\n dom.all(container, ':scope > .accordion > .accordion-item').forEach(function(item) {\n dom.addClass(item, 'ge-accordion-item');\n var collapse = collapseOf(item);\n\n // What the author wanted, before Bootstrap's own\n // toggles get a chance to change it while editing.\n // Every item is shown while editing (the stylesheet\n // does that), so this is the only record of it.\n if (collapse && !collapse.hasAttribute('data-ge-open')) {\n collapse.setAttribute('data-ge-open', dom.hasClass(collapse, 'show') ? 'true' : 'false');\n }\n\n var button = dom.one(item, ':scope > .accordion-header .accordion-button');\n\n if (button) {\n // Bootstrap's collapse stays out of it, and the editor\n // answers the click itself\n ge.suspendToggles(button);\n ge.makeLabelEditable(ge.labelIn(button));\n\n if (!answered.has(button)) {\n answered.add(button);\n button.addEventListener('click', function(e) {\n if (ge.labelIn(button).getAttribute('contenteditable') === 'true') { return; }\n\n e.preventDefault();\n toggleAccordionItem(container, item);\n });\n }\n }\n\n if (dom.child(item, '.ge-tools-drawer')) { return; }\n\n ge.createPaneControls(item, 'accordion-item', ge.settings.accordion_tools,\n ge.t('confirm.delete_accordion_item'), function(removed) {\n dom.slideUp(item, 200, removed);\n });\n });\n },\n\n unmark: function(container) {\n ge.resumeToggles(container);\n\n // What the canvas was showing is what the page ships\n dom.all(container, ':scope > .accordion > .accordion-item').forEach(function(item) {\n var collapse = collapseOf(item);\n setAccordionItemOpen(item, !!collapse && collapse.getAttribute('data-ge-open') === 'true');\n });\n\n dom.all(container, '.ge-accordion-item').forEach(function(item) {\n dom.removeClass(item, 'ge-accordion-item');\n });\n ge.unwrapLabels(container);\n },\n\n afterPaneMove: function(container, item) {\n reparentAccordionItem(container, item);\n },\n };\n};\n"],
|
|
5
|
+
"mappings": "MASA,IAAIA,EAAa,OAAO,WAExB,GAAI,CAACA,GAAc,OAAOA,EAAW,KAAQ,WACzC,MAA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AM,EACxBtB,EAAG,kBAAkBA,EAAG,QAAQsB,CAAM,CAAC,EAElCrB,EAAS,IAAIqB,CAAM,IACpBrB,EAAS,IAAIqB,CAAM,EACnBA,EAAO,iBAAiB,QAAS,SAASe,EAAG,CACrCrC,EAAG,QAAQsB,CAAM,EAAE,aAAa,iBAAiB,IAAM,SAE3De,EAAE,eAAe,EACjBZ,EAAoBnB,EAAWH,CAAI,EACvC,CAAC,IAIL,CAAIC,EAAMD,EAAM,kBAAkB,GAEtCH,EAAG,mBAAmBG,EAAM,iBAAkBH,EAAG,SAAS,gBACtDA,EAAG,EAAE,+BAA+B,EAAG,SAASsC,EAAS,CACjDC,EAAQpC,EAAM,IAAKmC,CAAO,CAClC,CAAC,CACT,CAAC,CACL,EAEA,OAAQ,SAAShC,EAAW,CACxBN,EAAG,cAAcM,CAAS,EAGtBG,EAAIH,EAAW,uCAAuC,EAAE,QAAQ,SAASH,EAAM,CAC/E,IAAIQ,EAAWT,EAAWC,CAAI,EAC9ByB,EAAqBzB,EAAM,CAAC,CAACQ,GAAYA,EAAS,aAAa,cAAc,IAAM,MAAM,CAC7F,CAAC,EAEGF,EAAIH,EAAW,oBAAoB,EAAE,QAAQ,SAASH,EAAM,CACxDqC,EAAYrC,EAAM,mBAAmB,CAC7C,CAAC,EACDH,EAAG,aAAaM,CAAS,CAC7B,EAEA,cAAe,SAASA,EAAWH,EAAM,CACrC0B,EAAsBvB,EAAWH,CAAI,CACzC,CACJ,CACJ",
|
|
6
|
+
"names": ["GridEditor", "all", "root", "selector", "one", "children", "node", "selector", "each", "child", "element", "tag", "attributes", "text", "node", "name", "value", "addClass", "node", "names", "split", "name", "removeClass", "toggleClass", "state", "hasClass", "hide", "node", "visible", "node", "DEFAULT_DURATION", "animateAway", "node", "frames", "duration", "done", "finish", "hide", "visible", "animation", "called", "once", "slideUp", "style", "GridEditor", "ge", "answered", "collapseOf", "item", "child", "staysOpen", "container", "ignore", "items", "all", "ignored", "collapse", "addAccordionItemTo", "options", "accordion", "id", "number", "children", "open", "stayOpen", "element", "header", "button", "toggleClass", "body", "toggleAccordionItem", "opening", "other", "setAccordionItemOpen", "reparentAccordionItem", "sortable", "labels", "count", "i", "addClass", "hasClass", "one", "e", "removed", "slideUp", "removeClass"]
|
|
7
|
+
}
|