@themarioga/grid-editor 8.4.0 → 8.6.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/CHANGELOG.md +51 -0
- package/README.md +105 -5
- package/dist/grideditor.bundle.min.js +3 -3
- package/dist/grideditor.css +15 -4
- package/dist/grideditor.d.ts +76 -4
- package/dist/grideditor.esm.js +212 -38
- package/dist/grideditor.js +212 -38
- package/dist/grideditor.min.css +1 -1
- package/dist/grideditor.min.css.map +1 -1
- package/dist/grideditor.min.js +2 -2
- package/dist/grideditor.min.js.map +3 -3
- package/dist/locales/grideditor.es.esm.js +5 -0
- package/dist/locales/grideditor.es.js +5 -0
- package/dist/locales/grideditor.es.min.js +1 -1
- package/dist/locales/grideditor.es.min.js.map +2 -2
- package/dist/plugins/grideditor.accordion.esm.js +7 -0
- package/dist/plugins/grideditor.accordion.js +7 -0
- package/dist/plugins/grideditor.accordion.min.js +1 -1
- package/dist/plugins/grideditor.accordion.min.js.map +3 -3
- package/dist/plugins/grideditor.autosave.esm.js +309 -0
- package/dist/plugins/grideditor.autosave.js +316 -0
- package/dist/plugins/grideditor.autosave.min.js +1 -0
- package/dist/plugins/grideditor.autosave.min.js.map +7 -0
- package/dist/plugins/grideditor.card.esm.js +10 -0
- package/dist/plugins/grideditor.card.js +10 -0
- package/dist/plugins/grideditor.card.min.js +1 -1
- package/dist/plugins/grideditor.card.min.js.map +3 -3
- package/dist/plugins/grideditor.ckeditor.esm.js +30 -1
- package/dist/plugins/grideditor.ckeditor.js +30 -1
- package/dist/plugins/grideditor.ckeditor.min.js +1 -1
- package/dist/plugins/grideditor.ckeditor.min.js.map +3 -3
- package/dist/plugins/grideditor.clipboard.esm.js +3 -0
- package/dist/plugins/grideditor.clipboard.js +3 -0
- package/dist/plugins/grideditor.clipboard.min.js +1 -1
- package/dist/plugins/grideditor.clipboard.min.js.map +2 -2
- package/dist/plugins/grideditor.codemirror-inline.esm.js +11 -0
- package/dist/plugins/grideditor.codemirror-inline.js +11 -0
- package/dist/plugins/grideditor.codemirror-inline.min.js +1 -1
- package/dist/plugins/grideditor.codemirror-inline.min.js.map +3 -3
- package/dist/plugins/grideditor.elements.esm.js +78 -4
- package/dist/plugins/grideditor.elements.js +78 -4
- package/dist/plugins/grideditor.elements.min.js +1 -1
- package/dist/plugins/grideditor.elements.min.js.map +3 -3
- package/dist/plugins/grideditor.gutters.esm.js +5 -0
- package/dist/plugins/grideditor.gutters.js +5 -0
- package/dist/plugins/grideditor.gutters.min.js +1 -1
- package/dist/plugins/grideditor.gutters.min.js.map +3 -3
- package/dist/plugins/grideditor.inline-style.esm.js +18 -10
- package/dist/plugins/grideditor.inline-style.js +18 -10
- package/dist/plugins/grideditor.inline-style.min.js +3 -3
- package/dist/plugins/grideditor.inline-style.min.js.map +3 -3
- package/dist/plugins/grideditor.order.esm.js +5 -0
- package/dist/plugins/grideditor.order.js +5 -0
- package/dist/plugins/grideditor.order.min.js +1 -1
- package/dist/plugins/grideditor.order.min.js.map +3 -3
- package/dist/plugins/grideditor.popup.esm.js +17 -6
- package/dist/plugins/grideditor.popup.js +17 -6
- package/dist/plugins/grideditor.popup.min.js +1 -1
- package/dist/plugins/grideditor.popup.min.js.map +3 -3
- package/dist/plugins/grideditor.sections.esm.js +6 -3
- package/dist/plugins/grideditor.sections.js +6 -3
- package/dist/plugins/grideditor.sections.min.js +1 -1
- package/dist/plugins/grideditor.sections.min.js.map +3 -3
- package/dist/plugins/grideditor.summernote.esm.js +40 -1
- package/dist/plugins/grideditor.summernote.js +40 -1
- package/dist/plugins/grideditor.summernote.min.js +1 -1
- package/dist/plugins/grideditor.summernote.min.js.map +3 -3
- package/dist/plugins/grideditor.tabs.esm.js +7 -0
- package/dist/plugins/grideditor.tabs.js +7 -0
- package/dist/plugins/grideditor.tabs.min.js +1 -1
- package/dist/plugins/grideditor.tabs.min.js.map +3 -3
- package/dist/plugins/grideditor.tinymce.esm.js +32 -1
- package/dist/plugins/grideditor.tinymce.js +32 -1
- package/dist/plugins/grideditor.tinymce.min.js +1 -1
- package/dist/plugins/grideditor.tinymce.min.js.map +3 -3
- package/docs/events.md +8 -0
- package/docs/locale-keys.md +16 -1
- package/docs/plugins.md +60 -7
- package/example/autosave.html +39 -22
- package/example/index.html +1 -1
- package/example/plugins.html +10 -0
- package/package.json +1 -2
- package/src/js/grideditor.js +248 -28
- package/src/js/inline-style/display.js +4 -3
- package/src/js/inline-style/drawerflow.js +10 -5
- package/src/js/locales/grideditor.es.js +5 -0
- package/src/js/plugins/grideditor.accordion.js +6 -0
- package/src/js/plugins/grideditor.autosave.js +349 -0
- package/src/js/plugins/grideditor.card.js +6 -0
- package/src/js/plugins/grideditor.ckeditor.js +6 -0
- package/src/js/plugins/grideditor.clipboard.js +3 -0
- package/src/js/plugins/grideditor.codemirror-inline.js +7 -0
- package/src/js/plugins/grideditor.elements.js +98 -4
- package/src/js/plugins/grideditor.gutters.js +4 -0
- package/src/js/plugins/grideditor.inline-style.js +2 -0
- package/src/js/plugins/grideditor.order.js +4 -0
- package/src/js/plugins/grideditor.popup.js +15 -6
- package/src/js/plugins/grideditor.sections.js +4 -3
- package/src/js/plugins/grideditor.summernote.js +14 -0
- package/src/js/plugins/grideditor.tabs.js +6 -0
- package/src/js/plugins/grideditor.tinymce.js +8 -0
- package/src/js/text/grideditor.text.js +27 -1
- package/src/less/grideditor.less +16 -8
- package/types/grideditor.d.ts +76 -4
- package/AUTO_SAVE.md +0 -30
|
@@ -184,6 +184,11 @@ GridEditor.utilities.order = function(ge) {
|
|
|
184
184
|
all(ge.canvas, "[data-ge-order]").forEach(function(col) {
|
|
185
185
|
col.removeAttribute("data-ge-order");
|
|
186
186
|
});
|
|
187
|
+
},
|
|
188
|
+
cleanMarkup: function(root) {
|
|
189
|
+
all(root, "[data-ge-order]").forEach(function(col) {
|
|
190
|
+
col.removeAttribute("data-ge-order");
|
|
191
|
+
});
|
|
187
192
|
}
|
|
188
193
|
};
|
|
189
194
|
};
|
|
@@ -188,6 +188,11 @@
|
|
|
188
188
|
all(ge.canvas, "[data-ge-order]").forEach(function(col) {
|
|
189
189
|
col.removeAttribute("data-ge-order");
|
|
190
190
|
});
|
|
191
|
+
},
|
|
192
|
+
cleanMarkup: function(root) {
|
|
193
|
+
all(root, "[data-ge-order]").forEach(function(col) {
|
|
194
|
+
col.removeAttribute("data-ge-order");
|
|
195
|
+
});
|
|
191
196
|
}
|
|
192
197
|
};
|
|
193
198
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var f=window.GridEditor;if(!f||typeof f.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
|
|
1
|
+
(()=>{var f=window.GridEditor;if(!f||typeof f.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 c(e,u){return e?Array.prototype.slice.call(e.querySelectorAll(u)):[]}function E(e,u){if(!e)return[];var a=c(e,u);return e.nodeType===1&&e.matches(u)&&a.unshift(e),a}function v(e,u){return e?Array.prototype.filter.call(e.children,function(a){return!u||a.matches(u)}):[]}Object.assign(f.locales.en,{"utility.order":"Order","utility.order_first":"First","utility.order_last":"Last","tool.order_earlier":"Earlier in this view","tool.order_later":"Later in this view","badge.order":"Order: {value}"});var d=["first","0","1","2","3","4","5","last"],A={first:-1,last:6},U=/(?:^|\s)order-(?:(?:sm|md|lg|xl|xxl)-)?(?:first|last|[0-5])(?:\s|$)/;f.utilities.order=function(e){var u=Object.assign({drawer:!0},e.settings.utilities.order),a=!1,l=null;function h(t){return t===null?0:A[t]!==void 0?A[t]:parseInt(t,10)}function g(t){return t==="first"?e.t("utility.order_first"):t==="last"?e.t("utility.order_last"):t}function x(t,r){return t.map(function(n,i){return{element:n,index:i,rank:h(r(n))}}).sort(function(n,i){return n.rank-i.rank||n.index-i.index}).map(function(n){return n.element})}function y(t,r){return t.every(function(n,i){return n===r[i]})}function T(t){return t<=6?d.slice(1,1+t):t===7?d.slice(1):t===8?d.slice():null}function w(t,r){var n=e.view(),i=v(t.parentElement,".column"),o=x(i,function(m){return e.getUtility(m,"order",n)}),b=o.indexOf(t),p=b+r;if(!(p<0||p>=o.length)){o.splice(p,0,o.splice(b,1)[0]);var s=null;if((!y(o,i)||!C(i,n))&&(s=T(o.length),!s)){e.warn("a row of "+o.length+" columns cannot be reordered with Bootstrap's order classes, which have eight places");return}e.operate(function(){o.forEach(function(m,O){e.setUtility(m,"order",s?s[O]:null,{source:"tool"})})})}}function C(t,r){var n=e.breakpoints.indexOf(r);if(n<=0)return!0;var i=e.breakpoints[n-1];return y(x(t,function(o){return e.getUtility(o,"order",i)}),t)}function L(t){return v(t,".column").some(function(r){return e.getUtility(r,"order",e.view())!==null})}function S(t){E(t,".column").forEach(function(r){var n=U.test(r.getAttribute("class")||"")?e.getUtility(r,"order",e.view()):null;n===null?r.removeAttribute("data-ge-order"):r.setAttribute("data-ge-order",e.t("badge.order",{value:g(n)}))})}function k(t){var r=t.detail;a||r.kind!=="column"||!r.to||L(r.to.parent)&&(a=!0,e.warn("a column was dropped in a row whose columns carry order classes in this view: where it shows is set by those classes, not by where it sits in the markup"))}return{families:[{name:"order",prefix:"order",values:d,appliesTo:["column"],labelKey:"utility.order",label:g,preview:function(t){return{order:h(t)}}}],drawerTools:function(t,r,n){!u.drawer||n!=="column"||(e.createTool(t,e.t("tool.order_earlier"),"ge-order-earlier","bi bi-chevron-left",function(){w(r,-1)}),e.createTool(t,e.t("tool.order_later"),"ge-order-later","bi bi-chevron-right",function(){w(r,1)}))},onInit:function(){l&&e.canvas.removeEventListener("grideditor:after-move",l),l=k,e.canvas.addEventListener("grideditor:after-move",l)},onRefresh:S,onDeinit:function(){l&&e.canvas.removeEventListener("grideditor:after-move",l),l=null,c(e.canvas,"[data-ge-order]").forEach(function(t){t.removeAttribute("data-ge-order")})},cleanMarkup:function(t){c(t,"[data-ge-order]").forEach(function(r){r.removeAttribute("data-ge-order")})}}};})();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/js/register.js", "../../src/js/dom.js", "../../src/js/plugins/grideditor.order.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 jQuery's: 400 ms unless the 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 * Column order for grid-editor.\n *\n * A utility plugin: load this file after the editor and a column's place in\n * its row can differ per breakpoint, with Bootstrap's order-{breakpoint}-*\n * classes. What it can ask the editor for is the handle its factory is called\n * with, described in docs/plugins.md.\n *\n * <script src=\"dist/grideditor.min.js\"></script>\n * <script src=\"dist/plugins/grideditor.order.min.js\"></script>\n *\n * Two arrows in each column's drawer move it one place earlier or later in\n * the view being edited, by numbering the row's columns; the markup does not\n * move. Dragging still moves the markup, as it always has.\n *\n * utilities.order.drawer: false leaves the arrows out, and the panel field is\n * the only control.\n */\nimport { GridEditor } from '../grideditor.js';\nimport * as dom from '../dom.js';\n\nObject.assign(GridEditor.locales.en, {\n 'utility.order': 'Order',\n 'utility.order_first': 'First',\n 'utility.order_last': 'Last',\n 'tool.order_earlier': 'Earlier in this view',\n 'tool.order_later': 'Later in this view',\n 'badge.order': 'Order: {value}',\n});\n\nvar VALUES = ['first', '0', '1', '2', '3', '4', '5', 'last'];\n\n/** Where each value puts a column, as Bootstrap's css has it. */\nvar RANK = { first: -1, last: 6 };\n\n/** A column that carries any class of the family, at any breakpoint. */\nvar CLASS_PATTERN = /(?:^|\\s)order-(?:(?:sm|md|lg|xl|xxl)-)?(?:first|last|[0-5])(?:\\s|$)/;\n\nGridEditor.utilities.order = function(ge) {\n\n var options = Object.assign({ drawer: true }, ge.settings.utilities.order);\n var warnedAboutDrag = false;\n var listening = null; // The after-move listener, while editing\n\n function rank(value) {\n if (value === null) { return 0; }\n\n return RANK[value] !== undefined ? RANK[value] : parseInt(value, 10);\n }\n\n function label(value) {\n if (value === 'first') { return ge.t('utility.order_first'); }\n if (value === 'last') { return ge.t('utility.order_last'); }\n\n return value;\n }\n\n /** The columns of a row in the order a view shows them, given what each one's order is. */\n function visualOrder(columns, read) {\n return columns\n .map(function(element, index) {\n return { element: element, index: index, rank: rank(read(element)) };\n })\n .sort(function(a, b) { return a.rank - b.rank || a.index - b.index; })\n .map(function(entry) { return entry.element; });\n }\n\n function sameOrder(a, b) {\n return a.every(function(element, index) { return element === b[index]; });\n }\n\n /**\n * The values that put n columns in n places, or null past eight: that\n * is how many places Bootstrap's order classes have.\n */\n function slots(count) {\n if (count <= 6) { return VALUES.slice(1, 1 + count); }\n if (count === 7) { return VALUES.slice(1); }\n if (count === 8) { return VALUES.slice(); }\n\n return null;\n }\n\n /**\n * Move a column one place earlier or later in the view being edited.\n *\n * The row's columns are numbered in their new order. When that order is\n * the markup's own, the numbers are taken off instead - unless what is\n * left underneath, the breakpoint below, would then order them some other\n * way, and the numbers are what keep them in the markup's order.\n */\n function move(col, direction) {\n var view = ge.view();\n var columns = dom.children(col.parentElement, '.column');\n var shown = visualOrder(columns, function(column) { return ge.getUtility(column, 'order', view); });\n var from = shown.indexOf(col);\n var to = from + direction;\n\n if (to < 0 || to >= shown.length) { return; }\n\n shown.splice(to, 0, shown.splice(from, 1)[0]);\n\n var values = null;\n if (!sameOrder(shown, columns) || !inheritsMarkupOrder(columns, view)) {\n values = slots(shown.length);\n\n if (!values) {\n ge.warn('a row of ' + shown.length + ' columns cannot be reordered with Bootstrap\\'s ' +\n 'order classes, which have eight places');\n return;\n }\n }\n\n ge.operate(function() {\n shown.forEach(function(element, index) {\n ge.setUtility(element, 'order', values ? values[index] : null, { source: 'tool' });\n });\n });\n }\n\n /** Whether taking this view's classes off leaves the columns in the markup's order. */\n function inheritsMarkupOrder(columns, view) {\n var index = ge.breakpoints.indexOf(view);\n if (index <= 0) { return true; }\n\n var below = ge.breakpoints[index - 1];\n\n return sameOrder(visualOrder(columns, function(column) {\n return ge.getUtility(column, 'order', below);\n }), columns);\n }\n\n /** Whether a row's columns are ordered by class, rather than by the markup, in this view. */\n function ordered(row) {\n return dom.children(row, '.column').some(function(element) {\n return ge.getUtility(element, 'order', ge.view()) !== null;\n });\n }\n\n /** The badge: a column ordered by class in this view says where. */\n function mark(scope) {\n dom.selfAndAll(scope, '.column').forEach(function(col) {\n var value = CLASS_PATTERN.test(col.getAttribute('class') || '')\n ? ge.getUtility(col, 'order', ge.view())\n : null;\n\n if (value === null) {\n col.removeAttribute('data-ge-order');\n } else {\n col.setAttribute('data-ge-order', ge.t('badge.order', { value: label(value) }));\n }\n });\n }\n\n /**\n * A column dropped in a row ordered by class lands where the markup puts\n * it, and shows up where its order does, which is worth saying once.\n */\n function afterMove(e) {\n var payload = e.detail;\n if (warnedAboutDrag || payload.kind !== 'column' || !payload.to) { return; }\n if (!ordered(payload.to.parent)) { return; }\n\n warnedAboutDrag = true;\n ge.warn('a column was dropped in a row whose columns carry order classes in this view: ' +\n 'where it shows is set by those classes, not by where it sits in the markup');\n }\n\n return {\n families: [{\n name: 'order',\n prefix: 'order',\n values: VALUES,\n appliesTo: ['column'],\n labelKey: 'utility.order',\n label: label,\n preview: function(value) {\n return { order: rank(value) };\n },\n }],\n\n drawerTools: function(drawer, node, kind) {\n if (!options.drawer || kind !== 'column') { return; }\n\n ge.createTool(drawer, ge.t('tool.order_earlier'), 'ge-order-earlier', 'bi bi-chevron-left', function() {\n move(node, -1);\n });\n ge.createTool(drawer, ge.t('tool.order_later'), 'ge-order-later', 'bi bi-chevron-right', function() {\n move(node, 1);\n });\n },\n\n // init runs again whenever a node is added, without a deinit\n // between, so the listener is replaced rather than stacked\n onInit: function() {\n if (listening) { ge.canvas.removeEventListener('grideditor:after-move', listening); }\n listening = afterMove;\n ge.canvas.addEventListener('grideditor:after-move', listening);\n },\n\n onRefresh: mark,\n\n onDeinit: function() {\n if (listening) { ge.canvas.removeEventListener('grideditor:after-move', listening); }\n listening = null;\n dom.all(ge.canvas, '[data-ge-order]').forEach(function(col) { col.removeAttribute('data-ge-order'); });\n },\n };\n};\n"],
|
|
5
|
-
"mappings": "MASA,IAAIA,EAAa,OAAO,WAExB,GAAI,CAACA,GAAc,OAAOA,EAAW,KAAQ,WACzC,MAAM,IAAI,MAAM,wHAC0B,ECCvC,SAASC,EAAIC,EAAMC,EAAU,CAChC,OAAOD,EAAO,MAAM,UAAU,MAAM,KAAKA,EAAK,iBAAiBC,CAAQ,CAAC,EAAI,CAAC,CACjF,CAQO,SAASC,EAAWC,EAAMC,EAAU,CACvC,GAAI,CAACD,EAAQ,MAAO,CAAC,EAErB,IAAIE,EAAQC,EAAIH,EAAMC,CAAQ,EAC9B,OAAID,EAAK,WAAa,GAAKA,EAAK,QAAQC,CAAQ,GAAKC,EAAM,QAAQF,CAAI,EAChEE,CACX,CAGO,SAASE,EAASC,EAAMJ,EAAU,CACrC,OAAKI,EAEE,MAAM,UAAU,OAAO,KAAKA,EAAK,SAAU,SAASC,EAAM,CAC7D,MAAO,CAACL,GAAYK,EAAK,QAAQL,CAAQ,CAC7C,CAAC,EAJmB,CAAC,CAKzB,CClBA,OAAO,OAAOM,EAAW,QAAQ,GAAI,CACjC,gBAAiB,QACjB,sBAAuB,QACvB,qBAAsB,OACtB,qBAAsB,uBACtB,mBAAoB,qBACpB,cAAe,gBACnB,CAAC,EAED,IAAIC,EAAS,CAAC,QAAS,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,MAAM,EAGvDC,EAAO,CAAE,MAAO,GAAI,KAAM,CAAE,EAG5BC,EAAgB,sEAEpBH,EAAW,UAAU,MAAQ,SAASI,EAAI,CAEtC,IAAIC,EAAU,OAAO,OAAO,CAAE,OAAQ,EAAK,EAAGD,EAAG,SAAS,UAAU,KAAK,EACrEE,EAAkB,GAClBC,EAAY,KAEhB,SAASC,EAAKC,EAAO,CACjB,OAAIA,IAAU,KAAe,EAEtBP,EAAKO,CAAK,IAAM,O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"selector", "selfAndAll", "root", "selector", "found", "all", "children", "node", "each", "GridEditor", "VALUES", "RANK", "CLASS_PATTERN", "ge", "options", "warnedAboutDrag", "listening", "rank", "value", "label", "visualOrder", "columns", "read", "element", "index", "a", "b", "entry", "sameOrder", "slots", "count", "move", "col", "direction", "view", "children", "shown", "column", "from", "to", "values", "inheritsMarkupOrder", "below", "ordered", "row", "mark", "scope", "selfAndAll", "afterMove", "payload", "drawer", "node", "kind", "all"]
|
|
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 jQuery's: 400 ms unless the 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 * Column order for grid-editor.\n *\n * A utility plugin: load this file after the editor and a column's place in\n * its row can differ per breakpoint, with Bootstrap's order-{breakpoint}-*\n * classes. What it can ask the editor for is the handle its factory is called\n * with, described in docs/plugins.md.\n *\n * <script src=\"dist/grideditor.min.js\"></script>\n * <script src=\"dist/plugins/grideditor.order.min.js\"></script>\n *\n * Two arrows in each column's drawer move it one place earlier or later in\n * the view being edited, by numbering the row's columns; the markup does not\n * move. Dragging still moves the markup, as it always has.\n *\n * utilities.order.drawer: false leaves the arrows out, and the panel field is\n * the only control.\n */\nimport { GridEditor } from '../grideditor.js';\nimport * as dom from '../dom.js';\n\nObject.assign(GridEditor.locales.en, {\n 'utility.order': 'Order',\n 'utility.order_first': 'First',\n 'utility.order_last': 'Last',\n 'tool.order_earlier': 'Earlier in this view',\n 'tool.order_later': 'Later in this view',\n 'badge.order': 'Order: {value}',\n});\n\nvar VALUES = ['first', '0', '1', '2', '3', '4', '5', 'last'];\n\n/** Where each value puts a column, as Bootstrap's css has it. */\nvar RANK = { first: -1, last: 6 };\n\n/** A column that carries any class of the family, at any breakpoint. */\nvar CLASS_PATTERN = /(?:^|\\s)order-(?:(?:sm|md|lg|xl|xxl)-)?(?:first|last|[0-5])(?:\\s|$)/;\n\nGridEditor.utilities.order = function(ge) {\n\n var options = Object.assign({ drawer: true }, ge.settings.utilities.order);\n var warnedAboutDrag = false;\n var listening = null; // The after-move listener, while editing\n\n function rank(value) {\n if (value === null) { return 0; }\n\n return RANK[value] !== undefined ? RANK[value] : parseInt(value, 10);\n }\n\n function label(value) {\n if (value === 'first') { return ge.t('utility.order_first'); }\n if (value === 'last') { return ge.t('utility.order_last'); }\n\n return value;\n }\n\n /** The columns of a row in the order a view shows them, given what each one's order is. */\n function visualOrder(columns, read) {\n return columns\n .map(function(element, index) {\n return { element: element, index: index, rank: rank(read(element)) };\n })\n .sort(function(a, b) { return a.rank - b.rank || a.index - b.index; })\n .map(function(entry) { return entry.element; });\n }\n\n function sameOrder(a, b) {\n return a.every(function(element, index) { return element === b[index]; });\n }\n\n /**\n * The values that put n columns in n places, or null past eight: that\n * is how many places Bootstrap's order classes have.\n */\n function slots(count) {\n if (count <= 6) { return VALUES.slice(1, 1 + count); }\n if (count === 7) { return VALUES.slice(1); }\n if (count === 8) { return VALUES.slice(); }\n\n return null;\n }\n\n /**\n * Move a column one place earlier or later in the view being edited.\n *\n * The row's columns are numbered in their new order. When that order is\n * the markup's own, the numbers are taken off instead - unless what is\n * left underneath, the breakpoint below, would then order them some other\n * way, and the numbers are what keep them in the markup's order.\n */\n function move(col, direction) {\n var view = ge.view();\n var columns = dom.children(col.parentElement, '.column');\n var shown = visualOrder(columns, function(column) { return ge.getUtility(column, 'order', view); });\n var from = shown.indexOf(col);\n var to = from + direction;\n\n if (to < 0 || to >= shown.length) { return; }\n\n shown.splice(to, 0, shown.splice(from, 1)[0]);\n\n var values = null;\n if (!sameOrder(shown, columns) || !inheritsMarkupOrder(columns, view)) {\n values = slots(shown.length);\n\n if (!values) {\n ge.warn('a row of ' + shown.length + ' columns cannot be reordered with Bootstrap\\'s ' +\n 'order classes, which have eight places');\n return;\n }\n }\n\n ge.operate(function() {\n shown.forEach(function(element, index) {\n ge.setUtility(element, 'order', values ? values[index] : null, { source: 'tool' });\n });\n });\n }\n\n /** Whether taking this view's classes off leaves the columns in the markup's order. */\n function inheritsMarkupOrder(columns, view) {\n var index = ge.breakpoints.indexOf(view);\n if (index <= 0) { return true; }\n\n var below = ge.breakpoints[index - 1];\n\n return sameOrder(visualOrder(columns, function(column) {\n return ge.getUtility(column, 'order', below);\n }), columns);\n }\n\n /** Whether a row's columns are ordered by class, rather than by the markup, in this view. */\n function ordered(row) {\n return dom.children(row, '.column').some(function(element) {\n return ge.getUtility(element, 'order', ge.view()) !== null;\n });\n }\n\n /** The badge: a column ordered by class in this view says where. */\n function mark(scope) {\n dom.selfAndAll(scope, '.column').forEach(function(col) {\n var value = CLASS_PATTERN.test(col.getAttribute('class') || '')\n ? ge.getUtility(col, 'order', ge.view())\n : null;\n\n if (value === null) {\n col.removeAttribute('data-ge-order');\n } else {\n col.setAttribute('data-ge-order', ge.t('badge.order', { value: label(value) }));\n }\n });\n }\n\n /**\n * A column dropped in a row ordered by class lands where the markup puts\n * it, and shows up where its order does, which is worth saying once.\n */\n function afterMove(e) {\n var payload = e.detail;\n if (warnedAboutDrag || payload.kind !== 'column' || !payload.to) { return; }\n if (!ordered(payload.to.parent)) { return; }\n\n warnedAboutDrag = true;\n ge.warn('a column was dropped in a row whose columns carry order classes in this view: ' +\n 'where it shows is set by those classes, not by where it sits in the markup');\n }\n\n return {\n families: [{\n name: 'order',\n prefix: 'order',\n values: VALUES,\n appliesTo: ['column'],\n labelKey: 'utility.order',\n label: label,\n preview: function(value) {\n return { order: rank(value) };\n },\n }],\n\n drawerTools: function(drawer, node, kind) {\n if (!options.drawer || kind !== 'column') { return; }\n\n ge.createTool(drawer, ge.t('tool.order_earlier'), 'ge-order-earlier', 'bi bi-chevron-left', function() {\n move(node, -1);\n });\n ge.createTool(drawer, ge.t('tool.order_later'), 'ge-order-later', 'bi bi-chevron-right', function() {\n move(node, 1);\n });\n },\n\n // init runs again whenever a node is added, without a deinit\n // between, so the listener is replaced rather than stacked\n onInit: function() {\n if (listening) { ge.canvas.removeEventListener('grideditor:after-move', listening); }\n listening = afterMove;\n ge.canvas.addEventListener('grideditor:after-move', listening);\n },\n\n onRefresh: mark,\n\n onDeinit: function() {\n if (listening) { ge.canvas.removeEventListener('grideditor:after-move', listening); }\n listening = null;\n dom.all(ge.canvas, '[data-ge-order]').forEach(function(col) { col.removeAttribute('data-ge-order'); });\n },\n\n cleanMarkup: function(root) {\n dom.all(root, '[data-ge-order]').forEach(function(col) { col.removeAttribute('data-ge-order'); });\n },\n };\n};\n"],
|
|
5
|
+
"mappings": "MASA,IAAIA,EAAa,OAAO,WAExB,GAAI,CAACA,GAAc,OAAOA,EAAW,KAAQ,WACzC,MAAM,IAAI,MAAM,wHAC0B,ECCvC,SAASC,EAAIC,EAAMC,EAAU,CAChC,OAAOD,EAAO,MAAM,UAAU,MAAM,KAAKA,EAAK,iBAAiBC,CAAQ,CAAC,EAAI,CAAC,CACjF,CAQO,SAASC,EAAWC,EAAMC,EAAU,CACvC,GAAI,CAACD,EAAQ,MAAO,CAAC,EAErB,IAAIE,EAAQC,EAAIH,EAAMC,CAAQ,EAC9B,OAAID,EAAK,WAAa,GAAKA,EAAK,QAAQC,CAAQ,GAAKC,EAAM,QAAQF,CAAI,EAChEE,CACX,CAGO,SAASE,EAASC,EAAMJ,EAAU,CACrC,OAAKI,EAEE,MAAM,UAAU,OAAO,KAAKA,EAAK,SAAU,SAASC,EAAM,CAC7D,MAAO,CAACL,GAAYK,EAAK,QAAQL,CAAQ,CAC7C,CAAC,EAJmB,CAAC,CAKzB,CClBA,OAAO,OAAOM,EAAW,QAAQ,GAAI,CACjC,gBAAiB,QACjB,sBAAuB,QACvB,qBAAsB,OACtB,qBAAsB,uBACtB,mBAAoB,qBACpB,cAAe,gBACnB,CAAC,EAED,IAAIC,EAAS,CAAC,QAAS,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,MAAM,EAGvDC,EAAO,CAAE,MAAO,GAAI,KAAM,CAAE,EAG5BC,EA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zG,EAEA,YAAa,SAASuB,EAAM,CACpBD,EAAIC,EAAM,iBAAiB,EAAE,QAAQ,SAASvB,EAAK,CAAEA,EAAI,gBAAgB,eAAe,CAAG,CAAC,CACpG,CACJ,CACJ",
|
|
6
|
+
"names": ["GridEditor", "all", "root", "selector", "selfAndAll", "root", "selector", "found", "all", "children", "node", "each", "GridEditor", "VALUES", "RANK", "CLASS_PATTERN", "ge", "options", "warnedAboutDrag", "listening", "rank", "value", "label", "visualOrder", "columns", "read", "element", "index", "a", "b", "entry", "sameOrder", "slots", "count", "move", "col", "direction", "view", "children", "shown", "column", "from", "to", "values", "inheritsMarkupOrder", "below", "ordered", "row", "mark", "scope", "selfAndAll", "afterMove", "e", "payload", "drawer", "node", "kind", "all", "root"]
|
|
7
7
|
}
|
|
@@ -75,8 +75,8 @@ GridEditor.containers.popup = function(ge) {
|
|
|
75
75
|
function popupIdOf(container) {
|
|
76
76
|
return container.getAttribute("data-ge-popup-id");
|
|
77
77
|
}
|
|
78
|
-
function popupExists(id) {
|
|
79
|
-
return all(ge.canvas, "[data-ge-popup-id]").some(function(popup) {
|
|
78
|
+
function popupExists(id, root) {
|
|
79
|
+
return all(root || ge.canvas, "[data-ge-popup-id]").some(function(popup) {
|
|
80
80
|
return popupIdOf(popup) === id;
|
|
81
81
|
});
|
|
82
82
|
}
|
|
@@ -107,12 +107,13 @@ GridEditor.containers.popup = function(ge) {
|
|
|
107
107
|
});
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
function writePopupTriggerAttributes() {
|
|
111
|
-
|
|
110
|
+
function writePopupTriggerAttributes(root) {
|
|
111
|
+
root = root || ge.canvas;
|
|
112
|
+
all(root, "[data-ge-popup-target]").forEach(function(trigger) {
|
|
112
113
|
var wanted = trigger.getAttribute("data-ge-popup-target");
|
|
113
114
|
removeClass(trigger, "ge-popup-orphan");
|
|
114
115
|
dropEmptyClass(trigger);
|
|
115
|
-
if (!popupExists(wanted)) {
|
|
116
|
+
if (!popupExists(wanted, root)) {
|
|
116
117
|
return;
|
|
117
118
|
}
|
|
118
119
|
trigger.setAttribute("data-bs-toggle", "modal");
|
|
@@ -126,7 +127,17 @@ GridEditor.containers.popup = function(ge) {
|
|
|
126
127
|
// are looked at whenever the canvas is initialized rather than only
|
|
127
128
|
// when a popup is touched
|
|
128
129
|
onInit: wirePopupTriggers,
|
|
129
|
-
onDeinit:
|
|
130
|
+
onDeinit: function() {
|
|
131
|
+
writePopupTriggerAttributes();
|
|
132
|
+
},
|
|
133
|
+
// What onDeinit and unmark do, on a copy of the canvas
|
|
134
|
+
cleanMarkup: function(root) {
|
|
135
|
+
var definition = this;
|
|
136
|
+
writePopupTriggerAttributes(root);
|
|
137
|
+
all(root, '[data-ge-container="popup"]').forEach(function(container) {
|
|
138
|
+
definition.unmark(container);
|
|
139
|
+
});
|
|
140
|
+
},
|
|
130
141
|
create: function(options) {
|
|
131
142
|
var id = ge.containerId("popup");
|
|
132
143
|
var container = element("div", { "data-ge-container": "popup", "data-ge-popup-id": id });
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
function popupIdOf(container) {
|
|
80
80
|
return container.getAttribute("data-ge-popup-id");
|
|
81
81
|
}
|
|
82
|
-
function popupExists(id) {
|
|
83
|
-
return all(ge.canvas, "[data-ge-popup-id]").some(function(popup) {
|
|
82
|
+
function popupExists(id, root) {
|
|
83
|
+
return all(root || ge.canvas, "[data-ge-popup-id]").some(function(popup) {
|
|
84
84
|
return popupIdOf(popup) === id;
|
|
85
85
|
});
|
|
86
86
|
}
|
|
@@ -111,12 +111,13 @@
|
|
|
111
111
|
});
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
|
-
function writePopupTriggerAttributes() {
|
|
115
|
-
|
|
114
|
+
function writePopupTriggerAttributes(root) {
|
|
115
|
+
root = root || ge.canvas;
|
|
116
|
+
all(root, "[data-ge-popup-target]").forEach(function(trigger) {
|
|
116
117
|
var wanted = trigger.getAttribute("data-ge-popup-target");
|
|
117
118
|
removeClass(trigger, "ge-popup-orphan");
|
|
118
119
|
dropEmptyClass(trigger);
|
|
119
|
-
if (!popupExists(wanted)) {
|
|
120
|
+
if (!popupExists(wanted, root)) {
|
|
120
121
|
return;
|
|
121
122
|
}
|
|
122
123
|
trigger.setAttribute("data-bs-toggle", "modal");
|
|
@@ -130,7 +131,17 @@
|
|
|
130
131
|
// are looked at whenever the canvas is initialized rather than only
|
|
131
132
|
// when a popup is touched
|
|
132
133
|
onInit: wirePopupTriggers,
|
|
133
|
-
onDeinit:
|
|
134
|
+
onDeinit: function() {
|
|
135
|
+
writePopupTriggerAttributes();
|
|
136
|
+
},
|
|
137
|
+
// What onDeinit and unmark do, on a copy of the canvas
|
|
138
|
+
cleanMarkup: function(root) {
|
|
139
|
+
var definition = this;
|
|
140
|
+
writePopupTriggerAttributes(root);
|
|
141
|
+
all(root, '[data-ge-container="popup"]').forEach(function(container) {
|
|
142
|
+
definition.unmark(container);
|
|
143
|
+
});
|
|
144
|
+
},
|
|
134
145
|
create: function(options) {
|
|
135
146
|
var id = ge.containerId("popup");
|
|
136
147
|
var container = element("div", { "data-ge-container": "popup", "data-ge-popup-id": id });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var
|
|
1
|
+
(()=>{var d=window.GridEditor;if(!d||typeof d.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 u(e,r){return e?Array.prototype.slice.call(e.querySelectorAll(r)):[]}function E(e){var r=document.createElement("template");return r.innerHTML=e,Array.prototype.slice.call(r.content.childNodes)}function b(e){for(var r=E(e.trim()),o=0;o<r.length;o++)if(r[o].nodeType===1)return r[o];return null}function a(e,r,o){var p=document.createElement(e);return Object.keys(r||{}).forEach(function(l){var t=r[l];t!=null&&t!==!1&&p.setAttribute(l,t)}),o!=null&&(p.textContent=o),p}function s(e,r){return m(r).forEach(function(o){e.classList.add(o)}),e}function c(e,r){return m(r).forEach(function(o){e.classList.remove(o)}),e}function x(e,r,o){return m(r).forEach(function(p){o===void 0?e.classList.toggle(p):e.classList.toggle(p,!!o)}),e}function m(e){return String(e||"").split(/\s+/).filter(Boolean)}function y(e){return e.getAttribute("class")||e.removeAttribute("class"),e}Object.assign(d.locales.en,{"container.add_popup":"Popup","container.popup_title":"Title","container.popup_trigger":"Open","tool.toggle_popup":"Fold this popup away while editing"});d.containers.popup=function(e){function r(t){return t.getAttribute("data-ge-popup-id")}function o(t,n){return u(n||e.canvas,"[data-ge-popup-id]").some(function(i){return r(i)===t})}function p(){u(e.canvas,"[data-ge-popup-target]").forEach(function(t){s(t,"ge-popup-trigger");var n=t.getAttribute("data-ge-popup-target");if(t.removeAttribute("data-bs-toggle"),t.removeAttribute("data-bs-target"),o(n)){c(t,"ge-popup-orphan");return}var i=t.closest(".column"),f=i?u(i,"[data-ge-popup-id]"):[];if(f.length===1){t.setAttribute("data-ge-popup-target",r(f[0])),c(t,"ge-popup-orphan");return}s(t,"ge-popup-orphan"),e.operate(function(){e.emit("popup-orphan",e.payloadFor("popup",t,{parent:t.parentElement,source:"api",missing:n}))})})}function l(t){t=t||e.canvas,u(t,"[data-ge-popup-target]").forEach(function(n){var i=n.getAttribute("data-ge-popup-target");c(n,"ge-popup-orphan"),y(n),o(i,t)&&(n.setAttribute("data-bs-toggle","modal"),n.setAttribute("data-bs-target","#"+i))})}return{labelKey:"container.add_popup",paneKind:"popup",onInit:p,onDeinit:function(){l()},cleanMarkup:function(t){var n=this;l(t),u(t,'[data-ge-container="popup"]').forEach(function(i){n.unmark(i)})},create:function(t){var n=e.containerId("popup"),i=a("div",{"data-ge-container":"popup","data-ge-popup-id":n});t.trigger!==!1&&i.appendChild(a("button",{type:"button",class:"btn btn-primary ge-popup-trigger","data-ge-popup-target":n},t.trigger_label||e.t("container.popup_trigger")));var f=i.appendChild(a("div",{class:"modal fade",tabindex:"-1","aria-hidden":"true",id:n})),g=f.appendChild(a("div",{class:"modal-dialog"}));t.size&&s(g,"modal-"+t.size);var h=g.appendChild(a("div",{class:"modal-content"})),v=h.appendChild(a("div",{class:"modal-header"}));return v.appendChild(a("h5",{class:"modal-title"})).appendChild(a("span",{class:"ge-pane-label"},t.title||e.t("container.popup_title"))),v.appendChild(b('<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>')),h.appendChild(a("div",{class:"modal-body"})).appendChild(e.defaultRegion()),i},mark:function(t){u(t,"[data-bs-dismiss]").forEach(function(n){e.suspendToggles(n)}),u(t,".modal-title").forEach(function(n){e.makeLabelEditable(e.labelIn(n))})},unmark:function(t){e.resumeToggles(t),c(t,"ge-popup-collapsed"),e.unwrapLabels(t)},tools:function(t,n){e.createTool(t,e.t("tool.toggle_popup"),"ge-toggle-popup","bi bi-chevron-bar-contract",function(){x(n,"ge-popup-collapsed")})}}};})();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/js/register.js", "../../src/js/dom.js", "../../src/js/plugins/grideditor.popup.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 jQuery's: 400 ms unless the 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 * Popups for grid-editor.\n *\n * A container plugin: load this file after the editor and the toolbar offers\n * a popup: a bootstrap modal and its trigger. 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.popup.min.js\"></script>\n */\nimport { GridEditor } from '../grideditor.js';\nimport * as dom from '../dom.js';\n\nObject.assign(GridEditor.locales.en, {\n 'container.add_popup': 'Popup',\n 'container.popup_title': 'Title',\n 'container.popup_trigger': 'Open',\n 'tool.toggle_popup': 'Fold this popup away while editing',\n});\n\nGridEditor.containers.popup = function(ge) {\n\n function popupIdOf(container) {\n return container.getAttribute('data-ge-popup-id');\n }\n\n /** Whether a popup with this id is on the canvas. */\n function popupExists(id) {\n return dom.all(ge.canvas, '[data-ge-popup-id]').some(function(popup) {\n return popupIdOf(popup) === id;\n });\n }\n\n function wirePopupTriggers() {\n dom.all(ge.canvas, '[data-ge-popup-target]').forEach(function(trigger) {\n dom.addClass(trigger, 'ge-popup-trigger');\n var wanted = trigger.getAttribute('data-ge-popup-target');\n\n // Bootstrap's own attributes are written at getHtml time, not\n // while editing, so a click here cannot open a real modal\n trigger.removeAttribute('data-bs-toggle');\n trigger.removeAttribute('data-bs-target');\n\n if (popupExists(wanted)) {\n dom.removeClass(trigger, 'ge-popup-orphan');\n return;\n }\n\n var column = trigger.closest('.column');\n var nearby = column ? dom.all(column, '[data-ge-popup-id]') : [];\n\n if (nearby.length === 1) {\n trigger.setAttribute('data-ge-popup-target', popupIdOf(nearby[0]));\n dom.removeClass(trigger, 'ge-popup-orphan');\n return;\n }\n\n dom.addClass(trigger, 'ge-popup-orphan');\n\n ge.operate(function() {\n ge.emit('popup-orphan', ge.payloadFor('popup', trigger, {\n parent: trigger.parentElement,\n source: 'api',\n missing: wanted,\n }));\n });\n });\n }\n\n function writePopupTriggerAttributes() {\n dom.all(ge.canvas, '[data-ge-popup-target]').forEach(function(trigger) {\n var wanted = trigger.getAttribute('data-ge-popup-target');\n\n // The warning marking is editing furniture, whether or not\n // the trigger can be wired up\n dom.removeClass(trigger, 'ge-popup-orphan');\n dom.dropEmptyClass(trigger);\n\n if (!popupExists(wanted)) { return; }\n\n trigger.setAttribute('data-bs-toggle', 'modal');\n trigger.setAttribute('data-bs-target', '#' + wanted);\n });\n }\n\n return {\n labelKey: 'container.add_popup',\n paneKind: 'popup',\n\n // Triggers are markup the host owns, anywhere in the canvas, so they\n // are looked at whenever the canvas is initialized rather than only\n // when a popup is touched\n onInit: wirePopupTriggers,\n onDeinit: writePopupTriggerAttributes,\n\n create: function(options) {\n var id = ge.containerId('popup');\n var container = dom.element('div', { 'data-ge-container': 'popup', 'data-ge-popup-id': id });\n\n if (options.trigger !== false) {\n container.appendChild(dom.element('button', {\n type: 'button',\n 'class': 'btn btn-primary ge-popup-trigger',\n 'data-ge-popup-target': id,\n }, options.trigger_label || ge.t('container.popup_trigger')));\n }\n\n var modal = container.appendChild(dom.element('div', {\n 'class': 'modal fade',\n tabindex: '-1',\n 'aria-hidden': 'true',\n id: id,\n }));\n var dialog = modal.appendChild(dom.element('div', { 'class': 'modal-dialog' }));\n if (options.size) { dom.addClass(dialog, 'modal-' + options.size); }\n\n var content = dialog.appendChild(dom.element('div', { 'class': 'modal-content' }));\n var header = content.appendChild(dom.element('div', { 'class': 'modal-header' }));\n header.appendChild(dom.element('h5', { 'class': 'modal-title' }))\n .appendChild(dom.element('span', { 'class': 'ge-pane-label' },\n options.title || ge.t('container.popup_title')));\n header.appendChild(dom.create('<button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"modal\" aria-label=\"Close\"></button>'));\n content.appendChild(dom.element('div', { 'class': 'modal-body' })).appendChild(ge.defaultRegion());\n\n return container;\n },\n\n mark: function(container) {\n // Nothing in a popup may reach Bootstrap while editing:\n // the modal is rendered unfolded and static, and a real\n // modal opening over it would be the editor fighting\n // itself\n dom.all(container, '[data-bs-dismiss]').forEach(function(dismiss) {\n ge.suspendToggles(dismiss);\n });\n dom.all(container, '.modal-title').forEach(function(title) {\n ge.makeLabelEditable(ge.labelIn(title));\n });\n },\n\n unmark: function(container) {\n ge.resumeToggles(container);\n dom.removeClass(container, 'ge-popup-collapsed');\n ge.unwrapLabels(container);\n },\n\n /** A page of unfolded modals stays workable if they can be folded away. */\n tools: function(drawer, container) {\n ge.createTool(drawer, ge.t('tool.toggle_popup'), 'ge-toggle-popup', 'bi bi-chevron-bar-contract',\n function() {\n dom.toggleClass(container, 'ge-popup-collapsed');\n });\n },\n };\n};\n"],
|
|
5
|
-
"mappings": "MASA,IAAIA,EAAa,OAAO,WAExB,GAAI,CAACA,GAAc,OAAOA,EAAW,KAAQ,WACzC,MAAM,IAAI,MA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CAAC,CAACG,CAAK,CAE3C,CAAC,EACMN,CACX,CAMA,SAASO,EAAMC,EAAO,CAClB,OAAO,OAAOA,GAAS,EAAE,EAAE,MAAM,KAAK,EAAE,OAAO,OAAO,CAC1D,CAGO,SAASC,EAAeC,EAAM,CACjC,OAAKA,EAAK,aAAa,OAAO,GAAKA,EAAK,gBAAgB,OAAO,EACxDA,CACX,CCjJA,OAAO,OAAOC,EAAW,QAAQ,GAAI,CACjC,sBAAuB,QACvB,wBAAyB,QACzB,0BAA2B,OAC3B,oBAAqB,oCACzB,CAAC,EAEDA,EAAW,WAAW,MAAQ,SAASC,EAAI,CAEvC,SAASC,EAAUC,EAAW,CAC1B,OAAOA,EAAU,aAAa,kBAAkB,CACpD,CAGA,SAASC,EAAYC,
|
|
6
|
-
"names": ["GridEditor", "all", "root", "selector", "parse", "html", "template", "create", "nodes", "i", "element", "tag", "attributes", "text", "node", "name", "value", "addClass", "node", "names", "split", "name", "removeClass", "toggleClass", "state", "split", "names", "dropEmptyClass", "node", "GridEditor", "ge", "popupIdOf", "container", "popupExists", "id", "all", "popup", "wirePopupTriggers", "trigger", "addClass", "wanted", "removeClass", "column", "nearby", "writePopupTriggerAttributes", "dropEmptyClass", "options", "element", "modal", "dialog", "content", "header", "create", "dismiss", "title", "drawer", "toggleClass"]
|
|
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 jQuery's: 400 ms unless the 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 * Popups for grid-editor.\n *\n * A container plugin: load this file after the editor and the toolbar offers\n * a popup: a bootstrap modal and its trigger. 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.popup.min.js\"></script>\n */\nimport { GridEditor } from '../grideditor.js';\nimport * as dom from '../dom.js';\n\nObject.assign(GridEditor.locales.en, {\n 'container.add_popup': 'Popup',\n 'container.popup_title': 'Title',\n 'container.popup_trigger': 'Open',\n 'tool.toggle_popup': 'Fold this popup away while editing',\n});\n\nGridEditor.containers.popup = function(ge) {\n\n function popupIdOf(container) {\n return container.getAttribute('data-ge-popup-id');\n }\n\n /** Whether a popup with this id is on the canvas. */\n function popupExists(id, root) {\n return dom.all(root || ge.canvas, '[data-ge-popup-id]').some(function(popup) {\n return popupIdOf(popup) === id;\n });\n }\n\n function wirePopupTriggers() {\n dom.all(ge.canvas, '[data-ge-popup-target]').forEach(function(trigger) {\n dom.addClass(trigger, 'ge-popup-trigger');\n var wanted = trigger.getAttribute('data-ge-popup-target');\n\n // Bootstrap's own attributes are written at getHtml time, not\n // while editing, so a click here cannot open a real modal\n trigger.removeAttribute('data-bs-toggle');\n trigger.removeAttribute('data-bs-target');\n\n if (popupExists(wanted)) {\n dom.removeClass(trigger, 'ge-popup-orphan');\n return;\n }\n\n var column = trigger.closest('.column');\n var nearby = column ? dom.all(column, '[data-ge-popup-id]') : [];\n\n if (nearby.length === 1) {\n trigger.setAttribute('data-ge-popup-target', popupIdOf(nearby[0]));\n dom.removeClass(trigger, 'ge-popup-orphan');\n return;\n }\n\n dom.addClass(trigger, 'ge-popup-orphan');\n\n ge.operate(function() {\n ge.emit('popup-orphan', ge.payloadFor('popup', trigger, {\n parent: trigger.parentElement,\n source: 'api',\n missing: wanted,\n }));\n });\n });\n }\n\n function writePopupTriggerAttributes(root) {\n root = root || ge.canvas;\n\n dom.all(root, '[data-ge-popup-target]').forEach(function(trigger) {\n var wanted = trigger.getAttribute('data-ge-popup-target');\n\n // The warning marking is editing furniture, whether or not\n // the trigger can be wired up\n dom.removeClass(trigger, 'ge-popup-orphan');\n dom.dropEmptyClass(trigger);\n\n if (!popupExists(wanted, root)) { return; }\n\n trigger.setAttribute('data-bs-toggle', 'modal');\n trigger.setAttribute('data-bs-target', '#' + wanted);\n });\n }\n\n return {\n labelKey: 'container.add_popup',\n paneKind: 'popup',\n\n // Triggers are markup the host owns, anywhere in the canvas, so they\n // are looked at whenever the canvas is initialized rather than only\n // when a popup is touched\n onInit: wirePopupTriggers,\n onDeinit: function() { writePopupTriggerAttributes(); },\n\n // What onDeinit and unmark do, on a copy of the canvas\n cleanMarkup: function(root) {\n var definition = this;\n writePopupTriggerAttributes(root);\n dom.all(root, '[data-ge-container=\"popup\"]').forEach(function(container) { definition.unmark(container); });\n },\n\n create: function(options) {\n var id = ge.containerId('popup');\n var container = dom.element('div', { 'data-ge-container': 'popup', 'data-ge-popup-id': id });\n\n if (options.trigger !== false) {\n container.appendChild(dom.element('button', {\n type: 'button',\n 'class': 'btn btn-primary ge-popup-trigger',\n 'data-ge-popup-target': id,\n }, options.trigger_label || ge.t('container.popup_trigger')));\n }\n\n var modal = container.appendChild(dom.element('div', {\n 'class': 'modal fade',\n tabindex: '-1',\n 'aria-hidden': 'true',\n id: id,\n }));\n var dialog = modal.appendChild(dom.element('div', { 'class': 'modal-dialog' }));\n if (options.size) { dom.addClass(dialog, 'modal-' + options.size); }\n\n var content = dialog.appendChild(dom.element('div', { 'class': 'modal-content' }));\n var header = content.appendChild(dom.element('div', { 'class': 'modal-header' }));\n header.appendChild(dom.element('h5', { 'class': 'modal-title' }))\n .appendChild(dom.element('span', { 'class': 'ge-pane-label' },\n options.title || ge.t('container.popup_title')));\n header.appendChild(dom.create('<button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"modal\" aria-label=\"Close\"></button>'));\n content.appendChild(dom.element('div', { 'class': 'modal-body' })).appendChild(ge.defaultRegion());\n\n return container;\n },\n\n mark: function(container) {\n // Nothing in a popup may reach Bootstrap while editing:\n // the modal is rendered unfolded and static, and a real\n // modal opening over it would be the editor fighting\n // itself\n dom.all(container, '[data-bs-dismiss]').forEach(function(dismiss) {\n ge.suspendToggles(dismiss);\n });\n dom.all(container, '.modal-title').forEach(function(title) {\n ge.makeLabelEditable(ge.labelIn(title));\n });\n },\n\n unmark: function(container) {\n ge.resumeToggles(container);\n dom.removeClass(container, 'ge-popup-collapsed');\n ge.unwrapLabels(container);\n },\n\n /** A page of unfolded modals stays workable if they can be folded away. */\n tools: function(drawer, container) {\n ge.createTool(drawer, ge.t('tool.toggle_popup'), 'ge-toggle-popup', 'bi bi-chevron-bar-contract',\n function() {\n dom.toggleClass(container, 'ge-popup-collapsed');\n });\n },\n };\n};\n"],
|
|
5
|
+
"mappings": "MASA,IAAIA,EAAa,OAAO,WAExB,GAAI,CAACA,GAAc,OAAOA,EAAW,KAAQ,WACzC,MAAM,IAAI,MAAM,wHAC0B,ECCvC,SAASC,EAAIC,EAAMC,EAAU,CAChC,OAAOD,EAAO,MAAM,UAAU,MAAM,KAAKA,EAAK,iBAAiBC,CAAQ,CAAC,EAAI,CAAC,CACjF,CAwEO,SAASC,EAAMC,EAAM,CACxB,IAAIC,EAAW,SAAS,cAAc,UAAU,EAChD,OAAAA,EAAS,UAAYD,EACd,MAAM,UAAU,MAAM,KAAKC,EAAS,QAAQ,UAAU,CACjE,CAGO,SAASC,EAAOF,EAAM,CAGzB,QAFIG,EAAQJ,EAAMC,EAAK,KAAK,CAAC,EAEpBI,EAAI,EAAGA,EAAID,EAAM,OAAQC,IAC9B,GAAID,EAAMC,CAAC,EAAE,WAAa,EAAK,OAAOD,EAAMC,CAAC,EAEjD,OAAO,IACX,CAGO,SAASC,EAAQC,EAAKC,EAAYC,EAAM,CAC3C,IAAIC,EAAO,SAAS,cAAcH,CAAG,EAErC,cAAO,KAAKC,GAAc,CAAC,CAAC,EAAE,QAAQ,SAASG,EAAM,CACjD,IAAIC,EAAQJ,EAAWG,CAAI,EACvBC,GAAU,MAA+BA,IAAU,IAASF,EAAK,aAAaC,EAAMC,CAAK,CACjG,CAAC,EACyBH,GAAS,OAAQC,EAAK,YAAcD,GAEvDC,CACX,CASO,SAASG,EAASC,EAAMC,EAAO,CAClC,OAAAC,EAAMD,CAAK,EAAE,QAAQ,SAASE,EAAM,CAAEH,EAAK,UAA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,EAAG,WAAW2B,EAAQ3B,EAAG,EAAE,mBAAmB,EAAG,kBAAmB,6BAChE,UAAW,CACH4B,EAAY1B,EAAW,oBAAoB,CACnD,CAAC,CACT,CACJ,CACJ",
|
|
6
|
+
"names": ["GridEditor", "all", "root", "selector", "parse", "html", "template", "create", "nodes", "i", "element", "tag", "attributes", "text", "node", "name", "value", "addClass", "node", "names", "split", "name", "removeClass", "toggleClass", "state", "split", "names", "dropEmptyClass", "node", "GridEditor", "ge", "popupIdOf", "container", "popupExists", "id", "root", "all", "popup", "wirePopupTriggers", "trigger", "addClass", "wanted", "removeClass", "column", "nearby", "writePopupTriggerAttributes", "dropEmptyClass", "definition", "options", "element", "modal", "dialog", "content", "header", "create", "dismiss", "title", "drawer", "toggleClass"]
|
|
7
7
|
}
|
|
@@ -222,8 +222,8 @@ GridEditor.features.sections = function(ge) {
|
|
|
222
222
|
}
|
|
223
223
|
});
|
|
224
224
|
}
|
|
225
|
-
function unmark() {
|
|
226
|
-
children(ge.canvas, ".ge-section").forEach(function(section) {
|
|
225
|
+
function unmark(root) {
|
|
226
|
+
children(root || ge.canvas, ".ge-section").forEach(function(section) {
|
|
227
227
|
removeClass(section, "ge-section");
|
|
228
228
|
});
|
|
229
229
|
}
|
|
@@ -264,7 +264,10 @@ GridEditor.features.sections = function(ge) {
|
|
|
264
264
|
}
|
|
265
265
|
}],
|
|
266
266
|
onInit: mark,
|
|
267
|
-
onDeinit:
|
|
267
|
+
onDeinit: function() {
|
|
268
|
+
unmark();
|
|
269
|
+
},
|
|
270
|
+
cleanMarkup: unmark
|
|
268
271
|
};
|
|
269
272
|
function isSectionMade(node) {
|
|
270
273
|
return !node.parentElement && widthOf(node) !== null;
|
|
@@ -226,8 +226,8 @@
|
|
|
226
226
|
}
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
|
-
function unmark() {
|
|
230
|
-
children(ge.canvas, ".ge-section").forEach(function(section) {
|
|
229
|
+
function unmark(root) {
|
|
230
|
+
children(root || ge.canvas, ".ge-section").forEach(function(section) {
|
|
231
231
|
removeClass(section, "ge-section");
|
|
232
232
|
});
|
|
233
233
|
}
|
|
@@ -268,7 +268,10 @@
|
|
|
268
268
|
}
|
|
269
269
|
}],
|
|
270
270
|
onInit: mark,
|
|
271
|
-
onDeinit:
|
|
271
|
+
onDeinit: function() {
|
|
272
|
+
unmark();
|
|
273
|
+
},
|
|
274
|
+
cleanMarkup: unmark
|
|
272
275
|
};
|
|
273
276
|
function isSectionMade(node) {
|
|
274
277
|
return !node.parentElement && widthOf(node) !== null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var h=window.GridEditor;if(!h||typeof h.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
|
|
1
|
+
(()=>{var h=window.GridEditor;if(!h||typeof h.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 C(t,r){return t?t.querySelector(r):null}function g(t,r){return t?Array.prototype.filter.call(t.children,function(i){return!r||i.matches(r)}):[]}function T(t,r){return g(t,r)[0]||null}function c(t,r,i){var o=document.createElement(t);return Object.keys(r||{}).forEach(function(u){var l=r[u];l!=null&&l!==!1&&o.setAttribute(u,l)}),i!=null&&(o.textContent=i),o}function y(t,r){return S(r).forEach(function(i){t.classList.add(i)}),t}function w(t,r){return S(r).forEach(function(i){t.classList.remove(i)}),t}function m(t,r){return!!t&&t.nodeType===1&&t.classList.contains(r)}function S(t){return String(t||"").split(/\s+/).filter(Boolean)}function _(t){return t.style.display="none",t}function j(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)}var F=400;function D(t,r,i,o){i=i===void 0?F:i;var u=function(){_(t),o&&o()};if(!j(t)||!t.animate||i<=0){window.setTimeout(u,0);return}var l=t.animate(r(getComputedStyle(t)),{duration:i,easing:"ease-in-out"}),v=!1,x=function(){v||(v=!0,u())};l.onfinish=x,l.oncancel=x}function A(t,r,i){typeof r=="function"&&(i=r,r=void 0),t.style.overflow="hidden",D(t,function(o){return[{height:o.height,paddingTop:o.paddingTop,paddingBottom:o.paddingBottom,marginTop:o.marginTop,marginBottom:o.marginBottom},{height:"0px",paddingTop:"0px",paddingBottom:"0px",marginTop:"0px",marginBottom:"0px"}]},r,function(){t.style.removeProperty("overflow"),i&&i()})}Object.assign(h.locales.en,{"section.add":"Section","section.width":"Width","section.fixed":"Fixed","section.fluid":"Full width","section.from":"Fixed from {breakpoint}","tool.add_row_to_section":"Add row","tool.delete_section":"Remove section","confirm.delete_section":"Delete this section and everything in it?"});var f={fixed:"container",fluid:"container-fluid",sm:"container-sm",md:"container-md",lg:"container-lg",xl:"container-xl",xxl:"container-xxl"},O=["fixed","sm","md","lg","xl","xxl","fluid"];h.features.sections=function(t){var r=Object.assign({widths:O},t.settings.sections);function i(e){var n=null;return Object.keys(f).forEach(function(a){!n&&m(e,f[a])&&(n=a)}),n}function o(e){return e.parentElement===t.canvas&&i(e)!==null}function u(){return g(t.canvas).filter(o)}function l(e){return e==="fixed"?t.t("section.fixed"):e==="fluid"?t.t("section.fluid"):t.t("section.from",{breakpoint:e})}function v(e,n,a){var s=i(e);return s===n||!f[n]?!1:t.operate(function(){var d=t.payloadFor("section",e,{family:"section",breakpoint:"all",tiers:[],from:s,to:n,source:a||"api"});if(!t.emit("before-utility",d)){var p=C(t.detailsOf(e),".ge-section-width select");return p&&(p.value=s),!1}return w(e,f[s]),y(e,f[n]),t.emit("after-utility",d),!0})}function x(e){var n=c("select",{class:"form-select form-select-sm"}),a=i(e),s=r.widths.indexOf(a)===-1?r.widths.concat([a]):r.widths;O.forEach(function(p){s.indexOf(p)!==-1&&n.appendChild(c("option",{value:p},l(p)))}),n.value=a,n.addEventListener("change",function(){v(e,this.value,"panel")});var d=c("label",{class:"ge-utility ge-section-width"});return d.appendChild(c("span",{class:"ge-utility-label"},t.t("section.width"))),d.appendChild(n),d}function k(e){var n=c("div",{class:"ge-tools-drawer ge-section-drawer"});e.insertBefore(n,e.firstChild),t.createMoveTool(n),t.addSettingsTool(n,e,t.settings.section_classes||[]).appendChild(x(e)),t.createTool(n,t.t("tool.delete_section"),"ge-delete-section","bi bi-trash",function(){t.deleteNode("section",e,t.t("confirm.delete_section"),function(a){A(e,a)})}),t.createTool(n,t.t("tool.add_row_to_section"),"ge-add-row","bi bi-plus-circle",function(){t.place(t.rowFromLayout([12]),"row",{appendTo:e})})}function B(){u().forEach(function(e){y(e,"ge-section"),T(e,".ge-tools-drawer")||k(e)})}function E(e){g(e||t.canvas,".ge-section").forEach(function(n){w(n,"ge-section")})}function b(e){e=e||{};var n=c("div",{class:f[e.width]||f.fixed});return(e.rows||[[12]]).forEach(function(a){n.appendChild(t.rowFromLayout(a))}),t.place(n,"section",e)}return{methods:{createSection:b},kindOf:function(e){return m(e,"ge-section")?"section":null},blocks:".ge-section",regions:".ge-section",accepts:function(e,n){return m(n,"ge-section")||L(n)?e===t.canvas:m(e,"ge-section")?m(n,"row"):!0},toolbar:[{labelKey:"section.add",kind:"section",group:"content",create:function(){return b()}}],onInit:B,onDeinit:function(){E()},cleanMarkup:E};function L(e){return!e.parentElement&&i(e)!==null}};})();
|