@themarioga/grid-editor 6.0.0-beta.5 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AUTO_SAVE.md +2 -2
- package/BUILDING.md +45 -29
- package/CHANGELOG.md +54 -0
- package/README.md +140 -89
- package/UPGRADING.md +146 -2
- package/dist/grideditor.bundle.min.js +14 -0
- package/dist/grideditor.d.ts +335 -0
- package/dist/grideditor.esm.js +3977 -0
- package/dist/grideditor.jquery.js +253 -0
- package/dist/grideditor.jquery.min.js +1 -0
- package/dist/grideditor.jquery.min.js.map +7 -0
- package/dist/grideditor.js +3983 -0
- package/dist/grideditor.min.js +6 -0
- package/dist/grideditor.min.js.map +7 -0
- package/dist/locales/grideditor.es.esm.js +158 -0
- package/dist/locales/grideditor.es.js +164 -170
- package/dist/locales/grideditor.es.min.js +6 -2
- package/dist/locales/grideditor.es.min.js.map +7 -1
- package/dist/plugins/grideditor.accordion.esm.js +294 -0
- package/dist/plugins/grideditor.accordion.js +286 -180
- package/dist/plugins/grideditor.accordion.min.js +1 -2
- package/dist/plugins/grideditor.accordion.min.js.map +7 -1
- package/dist/plugins/grideditor.alignment.esm.js +55 -0
- package/dist/plugins/grideditor.alignment.js +58 -77
- package/dist/plugins/grideditor.alignment.min.js +1 -2
- package/dist/plugins/grideditor.alignment.min.js.map +7 -1
- package/dist/plugins/grideditor.card.esm.js +73 -0
- package/dist/plugins/grideditor.card.js +74 -64
- package/dist/plugins/grideditor.card.min.js +1 -2
- package/dist/plugins/grideditor.card.min.js.map +7 -1
- package/dist/plugins/grideditor.ckeditor.esm.js +500 -0
- package/dist/plugins/grideditor.ckeditor.js +482 -493
- package/dist/plugins/grideditor.ckeditor.min.js +1 -2
- package/dist/plugins/grideditor.ckeditor.min.js.map +7 -1
- package/dist/plugins/grideditor.clipboard.esm.js +326 -0
- package/dist/plugins/grideditor.clipboard.js +298 -235
- package/dist/plugins/grideditor.clipboard.min.js +1 -2
- package/dist/plugins/grideditor.clipboard.min.js.map +7 -1
- package/dist/plugins/grideditor.codemirror-inline.esm.js +205 -0
- package/dist/plugins/grideditor.codemirror-inline.js +188 -168
- package/dist/plugins/grideditor.codemirror-inline.min.js +1 -2
- package/dist/plugins/grideditor.codemirror-inline.min.js.map +7 -1
- package/dist/plugins/grideditor.codemirror.esm.js +63 -0
- package/dist/plugins/grideditor.codemirror.js +60 -71
- package/dist/plugins/grideditor.codemirror.min.js +1 -2
- package/dist/plugins/grideditor.codemirror.min.js.map +7 -1
- package/dist/plugins/grideditor.elements.esm.js +271 -0
- package/dist/plugins/grideditor.elements.js +256 -149
- package/dist/plugins/grideditor.elements.min.js +1 -2
- package/dist/plugins/grideditor.elements.min.js.map +7 -1
- package/dist/plugins/grideditor.float.esm.js +34 -0
- package/dist/plugins/grideditor.float.js +37 -52
- package/dist/plugins/grideditor.float.min.js +1 -2
- package/dist/plugins/grideditor.float.min.js.map +7 -1
- package/dist/plugins/grideditor.gutters.esm.js +143 -0
- package/dist/plugins/grideditor.gutters.js +134 -131
- package/dist/plugins/grideditor.gutters.min.js +1 -2
- package/dist/plugins/grideditor.gutters.min.js.map +7 -1
- package/dist/plugins/grideditor.order.esm.js +189 -0
- package/dist/plugins/grideditor.order.js +170 -182
- package/dist/plugins/grideditor.order.min.js +1 -2
- package/dist/plugins/grideditor.order.min.js.map +7 -1
- package/dist/plugins/grideditor.popup.esm.js +187 -0
- package/dist/plugins/grideditor.popup.js +183 -134
- package/dist/plugins/grideditor.popup.min.js +1 -2
- package/dist/plugins/grideditor.popup.min.js.map +7 -1
- package/dist/plugins/grideditor.sections.esm.js +271 -0
- package/dist/plugins/grideditor.sections.js +250 -173
- package/dist/plugins/grideditor.sections.min.js +1 -2
- package/dist/plugins/grideditor.sections.min.js.map +7 -1
- package/dist/plugins/grideditor.spacing.esm.js +318 -0
- package/dist/plugins/grideditor.spacing.js +296 -272
- package/dist/plugins/grideditor.spacing.min.js +1 -2
- package/dist/plugins/grideditor.spacing.min.js.map +7 -1
- package/dist/plugins/grideditor.summernote.esm.js +509 -0
- package/dist/plugins/grideditor.summernote.js +491 -471
- package/dist/plugins/grideditor.summernote.min.js +1 -2
- package/dist/plugins/grideditor.summernote.min.js.map +7 -1
- package/dist/plugins/grideditor.tabs.esm.js +237 -0
- package/dist/plugins/grideditor.tabs.js +233 -139
- package/dist/plugins/grideditor.tabs.min.js +1 -2
- package/dist/plugins/grideditor.tabs.min.js.map +7 -1
- package/dist/plugins/grideditor.textalign.esm.js +40 -0
- package/dist/plugins/grideditor.textalign.js +43 -56
- package/dist/plugins/grideditor.textalign.min.js +1 -2
- package/dist/plugins/grideditor.textalign.min.js.map +7 -1
- package/dist/plugins/grideditor.tinymce.esm.js +519 -0
- package/dist/plugins/grideditor.tinymce.js +500 -534
- package/dist/plugins/grideditor.tinymce.min.js +1 -2
- package/dist/plugins/grideditor.tinymce.min.js.map +7 -1
- package/dist/plugins/grideditor.visibility.esm.js +158 -0
- package/dist/plugins/grideditor.visibility.js +140 -149
- package/dist/plugins/grideditor.visibility.min.js +1 -2
- package/dist/plugins/grideditor.visibility.min.js.map +7 -1
- package/docs/events.md +47 -21
- package/docs/locale-keys.md +7 -4
- package/docs/plugins.md +49 -27
- package/example/adapter.html +112 -0
- package/example/attributes.html +85 -61
- package/example/autocols.html +9 -9
- package/example/autosave.html +13 -14
- package/example/basic.html +4 -5
- package/example/breakpoints.html +5 -6
- package/example/ckeditor.html +4 -5
- package/example/clipboard.html +11 -10
- package/example/codemirror.html +9 -7
- package/example/containers.html +7 -8
- package/example/custom_editor.html +53 -34
- package/example/elements.html +10 -11
- package/example/index.html +16 -2
- package/example/locale.html +6 -7
- package/example/plugins.html +44 -29
- package/example/summernote.html +6 -5
- package/example/utilities.html +17 -13
- package/example/wrap_content.html +9 -9
- package/package.json +43 -12
- package/src/js/dom.js +401 -0
- package/src/js/grideditor.classic.js +16 -0
- package/src/js/grideditor.jquery.js +325 -0
- package/src/js/{jquery.grideditor.js → grideditor.js} +1284 -1124
- package/src/js/locales/grideditor.es.js +163 -158
- package/src/js/plugins/grideditor.accordion.js +97 -77
- package/src/js/plugins/grideditor.alignment.js +5 -7
- package/src/js/plugins/grideditor.card.js +23 -23
- package/src/js/plugins/grideditor.ckeditor.js +107 -106
- package/src/js/plugins/grideditor.clipboard.js +49 -37
- package/src/js/plugins/grideditor.codemirror-inline.js +50 -37
- package/src/js/plugins/grideditor.codemirror.js +9 -10
- package/src/js/plugins/grideditor.elements.js +57 -33
- package/src/js/plugins/grideditor.float.js +4 -6
- package/src/js/plugins/grideditor.gutters.js +20 -15
- package/src/js/plugins/grideditor.order.js +28 -25
- package/src/js/plugins/grideditor.popup.js +63 -51
- package/src/js/plugins/grideditor.sections.js +39 -32
- package/src/js/plugins/grideditor.spacing.js +42 -45
- package/src/js/plugins/grideditor.summernote.js +112 -76
- package/src/js/plugins/grideditor.tabs.js +65 -57
- package/src/js/plugins/grideditor.textalign.js +4 -6
- package/src/js/plugins/grideditor.tinymce.js +147 -139
- package/src/js/plugins/grideditor.visibility.js +24 -25
- package/src/js/register.js +18 -0
- package/src/js/text/grideditor.text.js +81 -106
- package/types/grideditor.d.ts +335 -0
- package/dist/jquery.grideditor.bundle.min.js +0 -10
- package/dist/jquery.grideditor.js +0 -4927
- package/dist/jquery.grideditor.min.js +0 -2
- package/dist/jquery.grideditor.min.js.map +0 -1
|
@@ -1,2 +1 @@
|
|
|
1
|
-
(
|
|
2
|
-
//# sourceMappingURL=grideditor.order.min.js.map
|
|
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 m(t,u){return t?Array.prototype.slice.call(t.querySelectorAll(u)):[]}function E(t,u){if(!t)return[];var a=m(t,u);return t.nodeType===1&&t.matches(u)&&a.unshift(t),a}function v(t,u){return t?Array.prototype.filter.call(t.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 c=["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(t){var u=Object.assign({drawer:!0},t.settings.utilities.order),a=!1,l=null;function h(e){return e===null?0:A[e]!==void 0?A[e]:parseInt(e,10)}function g(e){return e==="first"?t.t("utility.order_first"):e==="last"?t.t("utility.order_last"):e}function x(e,r){return e.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(e,r){return e.every(function(n,i){return n===r[i]})}function T(e){return e<=6?c.slice(1,1+e):e===7?c.slice(1):e===8?c.slice():null}function w(e,r){var n=t.view(),i=v(e.parentElement,".column"),o=x(i,function(p){return t.getUtility(p,"order",n)}),b=o.indexOf(e),d=b+r;if(!(d<0||d>=o.length)){o.splice(d,0,o.splice(b,1)[0]);var s=null;if((!y(o,i)||!C(i,n))&&(s=T(o.length),!s)){t.warn("a row of "+o.length+" columns cannot be reordered with Bootstrap's order classes, which have eight places");return}t.operate(function(){o.forEach(function(p,k){t.setUtility(p,"order",s?s[k]:null,{source:"tool"})})})}}function C(e,r){var n=t.breakpoints.indexOf(r);if(n<=0)return!0;var i=t.breakpoints[n-1];return y(x(e,function(o){return t.getUtility(o,"order",i)}),e)}function L(e){return v(e,".column").some(function(r){return t.getUtility(r,"order",t.view())!==null})}function S(e){E(e,".column").forEach(function(r){var n=U.test(r.getAttribute("class")||"")?t.getUtility(r,"order",t.view()):null;n===null?r.removeAttribute("data-ge-order"):r.setAttribute("data-ge-order",t.t("badge.order",{value:g(n)}))})}function O(e){var r=e.detail;a||r.kind!=="column"||!r.to||L(r.to.parent)&&(a=!0,t.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:c,appliesTo:["column"],labelKey:"utility.order",label:g,preview:function(e){return{order:h(e)}}}],drawerTools:function(e,r,n){!u.drawer||n!=="column"||(t.createTool(e,t.t("tool.order_earlier"),"ge-order-earlier","bi bi-chevron-left",function(){w(r,-1)}),t.createTool(e,t.t("tool.order_later"),"ge-order-later","bi bi-chevron-right",function(){w(r,1)}))},onInit:function(){l&&t.canvas.removeEventListener("grideditor:after-move",l),l=O,t.canvas.addEventListener("grideditor:after-move",l)},onRefresh:S,onDeinit:function(){l&&t.canvas.removeEventListener("grideditor:after-move",l),l=null,m(t.canvas,"[data-ge-order]").forEach(function(e){e.removeAttribute("data-ge-order")})}}};})();
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 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 the ones 6.x had through jQuery: 400 ms unless the\n * caller says otherwise. `done` runs once the node is out of sight, which is\n * when the caller removes it; a node that is already out of sight is done at\n * once, on the next task, as jQuery had it.\n * ------------------------------------------------------------------ */\n\nvar DEFAULT_DURATION = 400;\n\nfunction animateAway(node, frames, duration, done) {\n duration = duration === undefined ? DEFAULT_DURATION : duration;\n\n var finish = function() {\n hide(node);\n if (done) { done(); }\n };\n\n if (!visible(node) || !node.animate || duration <= 0) {\n window.setTimeout(finish, 0);\n return;\n }\n\n var animation = node.animate(frames(getComputedStyle(node)), {\n duration: duration,\n easing: 'ease-in-out',\n });\n var called = false;\n var once = function() {\n if (called) { return; }\n called = true;\n finish();\n };\n\n animation.onfinish = once;\n animation.oncancel = once;\n}\n\n/** Fold a node up to nothing, then hide it. */\nexport function slideUp(node, duration, done) {\n if (typeof duration === 'function') {\n done = duration;\n duration = undefined;\n }\n\n node.style.overflow = 'hidden';\n animateAway(node, function(style) {\n return [\n {\n height: style.height,\n paddingTop: style.paddingTop,\n paddingBottom: style.paddingBottom,\n marginTop: style.marginTop,\n marginBottom: style.marginBottom,\n },\n { height: '0px', paddingTop: '0px', paddingBottom: '0px', marginTop: '0px', marginBottom: '0px' },\n ];\n }, duration, function() {\n node.style.removeProperty('overflow');\n if (done) { done(); }\n });\n}\n\n/** Fade a node out, then hide it. */\nexport function fadeOut(node, duration, done) {\n animateAway(node, function(style) {\n return [{ opacity: style.opacity }, { opacity: 0 }];\n }, duration, done);\n}\n\n/** Fade and fold a node, in height and, with `width`, sideways too, then hide it. */\nexport function shrinkAway(node, duration, done, width) {\n node.style.overflow = 'hidden';\n animateAway(node, function(style) {\n var from = { opacity: style.opacity, height: style.height };\n var to = { opacity: 0, height: '0px' };\n\n if (width) {\n from.width = style.width;\n to.width = '0px';\n }\n return [from, to];\n }, duration, function() {\n node.style.removeProperty('overflow');\n if (done) { done(); }\n });\n}\n", "/**\n * 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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B,wBAAyBG,CAAS,CACjE,EAEA,UAAW6B,EAEX,SAAU,UAAW,CACb7B,GAAaH,EAAG,OAAO,oBAAoB,wBAAyBG,CAAS,EACjFA,EAAY,KACRqC,EAAIxC,EAAG,OAAQ,iBAAiB,EAAE,QAAQ,SAASmB,EAAK,CAAEA,EAAI,gBAAgB,eAAe,CAAG,CAAC,CACzG,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", "payload", "drawer", "node", "kind", "all"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// src/js/plugins/grideditor.popup.js
|
|
2
|
+
import { GridEditor } from "../grideditor.esm.js";
|
|
3
|
+
|
|
4
|
+
// src/js/dom.js
|
|
5
|
+
function all(root, selector) {
|
|
6
|
+
return root ? Array.prototype.slice.call(root.querySelectorAll(selector)) : [];
|
|
7
|
+
}
|
|
8
|
+
function parse(html) {
|
|
9
|
+
var template = document.createElement("template");
|
|
10
|
+
template.innerHTML = html;
|
|
11
|
+
return Array.prototype.slice.call(template.content.childNodes);
|
|
12
|
+
}
|
|
13
|
+
function create(html) {
|
|
14
|
+
var nodes = parse(html.trim());
|
|
15
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
16
|
+
if (nodes[i].nodeType === 1) {
|
|
17
|
+
return nodes[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
function element(tag, attributes, text) {
|
|
23
|
+
var node = document.createElement(tag);
|
|
24
|
+
Object.keys(attributes || {}).forEach(function(name) {
|
|
25
|
+
var value = attributes[name];
|
|
26
|
+
if (value !== null && value !== void 0 && value !== false) {
|
|
27
|
+
node.setAttribute(name, value);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
if (text !== void 0 && text !== null) {
|
|
31
|
+
node.textContent = text;
|
|
32
|
+
}
|
|
33
|
+
return node;
|
|
34
|
+
}
|
|
35
|
+
function addClass(node, names) {
|
|
36
|
+
split(names).forEach(function(name) {
|
|
37
|
+
node.classList.add(name);
|
|
38
|
+
});
|
|
39
|
+
return node;
|
|
40
|
+
}
|
|
41
|
+
function removeClass(node, names) {
|
|
42
|
+
split(names).forEach(function(name) {
|
|
43
|
+
node.classList.remove(name);
|
|
44
|
+
});
|
|
45
|
+
return node;
|
|
46
|
+
}
|
|
47
|
+
function toggleClass(node, names, state) {
|
|
48
|
+
split(names).forEach(function(name) {
|
|
49
|
+
if (state === void 0) {
|
|
50
|
+
node.classList.toggle(name);
|
|
51
|
+
} else {
|
|
52
|
+
node.classList.toggle(name, !!state);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return node;
|
|
56
|
+
}
|
|
57
|
+
function split(names) {
|
|
58
|
+
return String(names || "").split(/\s+/).filter(Boolean);
|
|
59
|
+
}
|
|
60
|
+
function dropEmptyClass(node) {
|
|
61
|
+
if (!node.getAttribute("class")) {
|
|
62
|
+
node.removeAttribute("class");
|
|
63
|
+
}
|
|
64
|
+
return node;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/js/plugins/grideditor.popup.js
|
|
68
|
+
Object.assign(GridEditor.locales.en, {
|
|
69
|
+
"container.add_popup": "Popup",
|
|
70
|
+
"container.popup_title": "Title",
|
|
71
|
+
"container.popup_trigger": "Open",
|
|
72
|
+
"tool.toggle_popup": "Fold this popup away while editing"
|
|
73
|
+
});
|
|
74
|
+
GridEditor.containers.popup = function(ge) {
|
|
75
|
+
function popupIdOf(container) {
|
|
76
|
+
return container.getAttribute("data-ge-popup-id");
|
|
77
|
+
}
|
|
78
|
+
function popupExists(id) {
|
|
79
|
+
return all(ge.canvas, "[data-ge-popup-id]").some(function(popup) {
|
|
80
|
+
return popupIdOf(popup) === id;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function wirePopupTriggers() {
|
|
84
|
+
all(ge.canvas, "[data-ge-popup-target]").forEach(function(trigger) {
|
|
85
|
+
addClass(trigger, "ge-popup-trigger");
|
|
86
|
+
var wanted = trigger.getAttribute("data-ge-popup-target");
|
|
87
|
+
trigger.removeAttribute("data-bs-toggle");
|
|
88
|
+
trigger.removeAttribute("data-bs-target");
|
|
89
|
+
if (popupExists(wanted)) {
|
|
90
|
+
removeClass(trigger, "ge-popup-orphan");
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
var column = trigger.closest(".column");
|
|
94
|
+
var nearby = column ? all(column, "[data-ge-popup-id]") : [];
|
|
95
|
+
if (nearby.length === 1) {
|
|
96
|
+
trigger.setAttribute("data-ge-popup-target", popupIdOf(nearby[0]));
|
|
97
|
+
removeClass(trigger, "ge-popup-orphan");
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
addClass(trigger, "ge-popup-orphan");
|
|
101
|
+
ge.operate(function() {
|
|
102
|
+
ge.emit("popup-orphan", ge.payloadFor("popup", trigger, {
|
|
103
|
+
parent: trigger.parentElement,
|
|
104
|
+
source: "api",
|
|
105
|
+
missing: wanted
|
|
106
|
+
}));
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function writePopupTriggerAttributes() {
|
|
111
|
+
all(ge.canvas, "[data-ge-popup-target]").forEach(function(trigger) {
|
|
112
|
+
var wanted = trigger.getAttribute("data-ge-popup-target");
|
|
113
|
+
removeClass(trigger, "ge-popup-orphan");
|
|
114
|
+
dropEmptyClass(trigger);
|
|
115
|
+
if (!popupExists(wanted)) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
trigger.setAttribute("data-bs-toggle", "modal");
|
|
119
|
+
trigger.setAttribute("data-bs-target", "#" + wanted);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
labelKey: "container.add_popup",
|
|
124
|
+
paneKind: "popup",
|
|
125
|
+
// Triggers are markup the host owns, anywhere in the canvas, so they
|
|
126
|
+
// are looked at whenever the canvas is initialized rather than only
|
|
127
|
+
// when a popup is touched
|
|
128
|
+
onInit: wirePopupTriggers,
|
|
129
|
+
onDeinit: writePopupTriggerAttributes,
|
|
130
|
+
create: function(options) {
|
|
131
|
+
var id = ge.containerId("popup");
|
|
132
|
+
var container = element("div", { "data-ge-container": "popup", "data-ge-popup-id": id });
|
|
133
|
+
if (options.trigger !== false) {
|
|
134
|
+
container.appendChild(element("button", {
|
|
135
|
+
type: "button",
|
|
136
|
+
"class": "btn btn-primary ge-popup-trigger",
|
|
137
|
+
"data-ge-popup-target": id
|
|
138
|
+
}, options.trigger_label || ge.t("container.popup_trigger")));
|
|
139
|
+
}
|
|
140
|
+
var modal = container.appendChild(element("div", {
|
|
141
|
+
"class": "modal fade",
|
|
142
|
+
tabindex: "-1",
|
|
143
|
+
"aria-hidden": "true",
|
|
144
|
+
id
|
|
145
|
+
}));
|
|
146
|
+
var dialog = modal.appendChild(element("div", { "class": "modal-dialog" }));
|
|
147
|
+
if (options.size) {
|
|
148
|
+
addClass(dialog, "modal-" + options.size);
|
|
149
|
+
}
|
|
150
|
+
var content = dialog.appendChild(element("div", { "class": "modal-content" }));
|
|
151
|
+
var header = content.appendChild(element("div", { "class": "modal-header" }));
|
|
152
|
+
header.appendChild(element("h5", { "class": "modal-title" })).appendChild(element(
|
|
153
|
+
"span",
|
|
154
|
+
{ "class": "ge-pane-label" },
|
|
155
|
+
options.title || ge.t("container.popup_title")
|
|
156
|
+
));
|
|
157
|
+
header.appendChild(create('<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>'));
|
|
158
|
+
content.appendChild(element("div", { "class": "modal-body" })).appendChild(ge.defaultRegion());
|
|
159
|
+
return container;
|
|
160
|
+
},
|
|
161
|
+
mark: function(container) {
|
|
162
|
+
all(container, "[data-bs-dismiss]").forEach(function(dismiss) {
|
|
163
|
+
ge.suspendToggles(dismiss);
|
|
164
|
+
});
|
|
165
|
+
all(container, ".modal-title").forEach(function(title) {
|
|
166
|
+
ge.makeLabelEditable(ge.labelIn(title));
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
unmark: function(container) {
|
|
170
|
+
ge.resumeToggles(container);
|
|
171
|
+
removeClass(container, "ge-popup-collapsed");
|
|
172
|
+
ge.unwrapLabels(container);
|
|
173
|
+
},
|
|
174
|
+
/** A page of unfolded modals stays workable if they can be folded away. */
|
|
175
|
+
tools: function(drawer, container) {
|
|
176
|
+
ge.createTool(
|
|
177
|
+
drawer,
|
|
178
|
+
ge.t("tool.toggle_popup"),
|
|
179
|
+
"ge-toggle-popup",
|
|
180
|
+
"bi bi-chevron-bar-contract",
|
|
181
|
+
function() {
|
|
182
|
+
toggleClass(container, "ge-popup-collapsed");
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
};
|
|
@@ -1,143 +1,192 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
(() => {
|
|
2
|
+
// src/js/register.js
|
|
3
|
+
var GridEditor = window.GridEditor;
|
|
4
|
+
if (!GridEditor || typeof GridEditor.get !== "function") {
|
|
5
|
+
throw new Error("grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, its locales and grideditor.jquery.js");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// src/js/dom.js
|
|
9
|
+
function all(root, selector) {
|
|
10
|
+
return root ? Array.prototype.slice.call(root.querySelectorAll(selector)) : [];
|
|
11
|
+
}
|
|
12
|
+
function parse(html) {
|
|
13
|
+
var template = document.createElement("template");
|
|
14
|
+
template.innerHTML = html;
|
|
15
|
+
return Array.prototype.slice.call(template.content.childNodes);
|
|
16
|
+
}
|
|
17
|
+
function create(html) {
|
|
18
|
+
var nodes = parse(html.trim());
|
|
19
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
20
|
+
if (nodes[i].nodeType === 1) {
|
|
21
|
+
return nodes[i];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
function element(tag, attributes, text) {
|
|
27
|
+
var node = document.createElement(tag);
|
|
28
|
+
Object.keys(attributes || {}).forEach(function(name) {
|
|
29
|
+
var value = attributes[name];
|
|
30
|
+
if (value !== null && value !== void 0 && value !== false) {
|
|
31
|
+
node.setAttribute(name, value);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
if (text !== void 0 && text !== null) {
|
|
35
|
+
node.textContent = text;
|
|
36
|
+
}
|
|
37
|
+
return node;
|
|
38
|
+
}
|
|
39
|
+
function addClass(node, names) {
|
|
40
|
+
split(names).forEach(function(name) {
|
|
41
|
+
node.classList.add(name);
|
|
42
|
+
});
|
|
43
|
+
return node;
|
|
44
|
+
}
|
|
45
|
+
function removeClass(node, names) {
|
|
46
|
+
split(names).forEach(function(name) {
|
|
47
|
+
node.classList.remove(name);
|
|
48
|
+
});
|
|
49
|
+
return node;
|
|
50
|
+
}
|
|
51
|
+
function toggleClass(node, names, state) {
|
|
52
|
+
split(names).forEach(function(name) {
|
|
53
|
+
if (state === void 0) {
|
|
54
|
+
node.classList.toggle(name);
|
|
55
|
+
} else {
|
|
56
|
+
node.classList.toggle(name, !!state);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return node;
|
|
60
|
+
}
|
|
61
|
+
function split(names) {
|
|
62
|
+
return String(names || "").split(/\s+/).filter(Boolean);
|
|
63
|
+
}
|
|
64
|
+
function dropEmptyClass(node) {
|
|
65
|
+
if (!node.getAttribute("class")) {
|
|
66
|
+
node.removeAttribute("class");
|
|
67
|
+
}
|
|
68
|
+
return node;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/js/plugins/grideditor.popup.js
|
|
72
|
+
Object.assign(GridEditor.locales.en, {
|
|
73
|
+
"container.add_popup": "Popup",
|
|
74
|
+
"container.popup_title": "Title",
|
|
75
|
+
"container.popup_trigger": "Open",
|
|
76
|
+
"tool.toggle_popup": "Fold this popup away while editing"
|
|
77
|
+
});
|
|
78
|
+
GridEditor.containers.popup = function(ge) {
|
|
22
79
|
function popupIdOf(container) {
|
|
23
|
-
|
|
80
|
+
return container.getAttribute("data-ge-popup-id");
|
|
81
|
+
}
|
|
82
|
+
function popupExists(id) {
|
|
83
|
+
return all(ge.canvas, "[data-ge-popup-id]").some(function(popup) {
|
|
84
|
+
return popupIdOf(popup) === id;
|
|
85
|
+
});
|
|
24
86
|
}
|
|
25
|
-
|
|
26
87
|
function wirePopupTriggers() {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
ge.emit('popup-orphan', ge.payloadFor('popup', trigger, {
|
|
51
|
-
parent: trigger.parent(),
|
|
52
|
-
source: 'api',
|
|
53
|
-
missing: wanted,
|
|
54
|
-
}));
|
|
55
|
-
});
|
|
88
|
+
all(ge.canvas, "[data-ge-popup-target]").forEach(function(trigger) {
|
|
89
|
+
addClass(trigger, "ge-popup-trigger");
|
|
90
|
+
var wanted = trigger.getAttribute("data-ge-popup-target");
|
|
91
|
+
trigger.removeAttribute("data-bs-toggle");
|
|
92
|
+
trigger.removeAttribute("data-bs-target");
|
|
93
|
+
if (popupExists(wanted)) {
|
|
94
|
+
removeClass(trigger, "ge-popup-orphan");
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
var column = trigger.closest(".column");
|
|
98
|
+
var nearby = column ? all(column, "[data-ge-popup-id]") : [];
|
|
99
|
+
if (nearby.length === 1) {
|
|
100
|
+
trigger.setAttribute("data-ge-popup-target", popupIdOf(nearby[0]));
|
|
101
|
+
removeClass(trigger, "ge-popup-orphan");
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
addClass(trigger, "ge-popup-orphan");
|
|
105
|
+
ge.operate(function() {
|
|
106
|
+
ge.emit("popup-orphan", ge.payloadFor("popup", trigger, {
|
|
107
|
+
parent: trigger.parentElement,
|
|
108
|
+
source: "api",
|
|
109
|
+
missing: wanted
|
|
110
|
+
}));
|
|
56
111
|
});
|
|
112
|
+
});
|
|
57
113
|
}
|
|
58
|
-
|
|
59
114
|
function writePopupTriggerAttributes() {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
trigger.attr('data-bs-toggle', 'modal').attr('data-bs-target', '#' + wanted);
|
|
72
|
-
});
|
|
115
|
+
all(ge.canvas, "[data-ge-popup-target]").forEach(function(trigger) {
|
|
116
|
+
var wanted = trigger.getAttribute("data-ge-popup-target");
|
|
117
|
+
removeClass(trigger, "ge-popup-orphan");
|
|
118
|
+
dropEmptyClass(trigger);
|
|
119
|
+
if (!popupExists(wanted)) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
trigger.setAttribute("data-bs-toggle", "modal");
|
|
123
|
+
trigger.setAttribute("data-bs-target", "#" + wanted);
|
|
124
|
+
});
|
|
73
125
|
}
|
|
74
|
-
|
|
75
126
|
return {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
},
|
|
127
|
+
labelKey: "container.add_popup",
|
|
128
|
+
paneKind: "popup",
|
|
129
|
+
// Triggers are markup the host owns, anywhere in the canvas, so they
|
|
130
|
+
// are looked at whenever the canvas is initialized rather than only
|
|
131
|
+
// when a popup is touched
|
|
132
|
+
onInit: wirePopupTriggers,
|
|
133
|
+
onDeinit: writePopupTriggerAttributes,
|
|
134
|
+
create: function(options) {
|
|
135
|
+
var id = ge.containerId("popup");
|
|
136
|
+
var container = element("div", { "data-ge-container": "popup", "data-ge-popup-id": id });
|
|
137
|
+
if (options.trigger !== false) {
|
|
138
|
+
container.appendChild(element("button", {
|
|
139
|
+
type: "button",
|
|
140
|
+
"class": "btn btn-primary ge-popup-trigger",
|
|
141
|
+
"data-ge-popup-target": id
|
|
142
|
+
}, options.trigger_label || ge.t("container.popup_trigger")));
|
|
143
|
+
}
|
|
144
|
+
var modal = container.appendChild(element("div", {
|
|
145
|
+
"class": "modal fade",
|
|
146
|
+
tabindex: "-1",
|
|
147
|
+
"aria-hidden": "true",
|
|
148
|
+
id
|
|
149
|
+
}));
|
|
150
|
+
var dialog = modal.appendChild(element("div", { "class": "modal-dialog" }));
|
|
151
|
+
if (options.size) {
|
|
152
|
+
addClass(dialog, "modal-" + options.size);
|
|
153
|
+
}
|
|
154
|
+
var content = dialog.appendChild(element("div", { "class": "modal-content" }));
|
|
155
|
+
var header = content.appendChild(element("div", { "class": "modal-header" }));
|
|
156
|
+
header.appendChild(element("h5", { "class": "modal-title" })).appendChild(element(
|
|
157
|
+
"span",
|
|
158
|
+
{ "class": "ge-pane-label" },
|
|
159
|
+
options.title || ge.t("container.popup_title")
|
|
160
|
+
));
|
|
161
|
+
header.appendChild(create('<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>'));
|
|
162
|
+
content.appendChild(element("div", { "class": "modal-body" })).appendChild(ge.defaultRegion());
|
|
163
|
+
return container;
|
|
164
|
+
},
|
|
165
|
+
mark: function(container) {
|
|
166
|
+
all(container, "[data-bs-dismiss]").forEach(function(dismiss) {
|
|
167
|
+
ge.suspendToggles(dismiss);
|
|
168
|
+
});
|
|
169
|
+
all(container, ".modal-title").forEach(function(title) {
|
|
170
|
+
ge.makeLabelEditable(ge.labelIn(title));
|
|
171
|
+
});
|
|
172
|
+
},
|
|
173
|
+
unmark: function(container) {
|
|
174
|
+
ge.resumeToggles(container);
|
|
175
|
+
removeClass(container, "ge-popup-collapsed");
|
|
176
|
+
ge.unwrapLabels(container);
|
|
177
|
+
},
|
|
178
|
+
/** A page of unfolded modals stays workable if they can be folded away. */
|
|
179
|
+
tools: function(drawer, container) {
|
|
180
|
+
ge.createTool(
|
|
181
|
+
drawer,
|
|
182
|
+
ge.t("tool.toggle_popup"),
|
|
183
|
+
"ge-toggle-popup",
|
|
184
|
+
"bi bi-chevron-bar-contract",
|
|
185
|
+
function() {
|
|
186
|
+
toggleClass(container, "ge-popup-collapsed");
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
}
|
|
140
190
|
};
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
})(jQuery);
|
|
191
|
+
};
|
|
192
|
+
})();
|