summaryrefslogtreecommitdiff
path: root/addons/website/static/src
diff options
context:
space:
mode:
authorSamuel Degueldre <sad@odoo.com>2019-10-16 12:24:22 +0000
committerqsm-odoo <qsm@odoo.com>2019-11-18 09:56:08 +0000
commit7623f3ecf7bc9ab54d293430969c31ffdbfd313b (patch)
tree5f7d5cb46c1c4ba2be99c1367db45ab1108223db /addons/website/static/src
parentc213afab86d6d8bd0331a549f7fab4590c7569be (diff)
[IMP] website: add quick move buttons for sections and columns
This commit adds buttons to move sections up or down and to move columns left or right, which is more user-friendly than drag-and-drop in some cases. Part of https://github.com/odoo/odoo/pull/38959 maintask-2066614 task-2088265
Diffstat (limited to 'addons/website/static/src')
-rw-r--r--addons/website/static/src/js/editor/snippets.options.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js
index ea8e048b9fe..8d26b20038d 100644
--- a/addons/website/static/src/js/editor/snippets.options.js
+++ b/addons/website/static/src/js/editor/snippets.options.js
@@ -1848,4 +1848,37 @@ options.registry.SectionStretch = options.Class.extend({
this.$el.find('[data-toggle-container-fluid]').toggleClass('active', isFluid);
},
});
+
+/**
+ * Allows snippets to be moved before the preceding element or after the following.
+ */
+options.registry.SnippetMove = options.Class.extend({
+
+ /**
+ * @override
+ */
+ isTopOption: function () {
+ return true;
+ },
+
+ //--------------------------------------------------------------------------
+ // Options
+ //--------------------------------------------------------------------------
+
+ /**
+ * Moves the snippet around.
+ *
+ * @see this.selectClass for parameters
+ */
+ moveSnippet: function (previewMode, value, $opt) {
+ switch (value) {
+ case 'prev':
+ this.$target.prev().before(this.$target);
+ break;
+ case 'next':
+ this.$target.next().after(this.$target);
+ break;
+ }
+ },
+});
});