[FIX] web_editor, *: ease understanding of snippet drag, not click
*: web, website Make the empty oe_structure messages "wizz" when the user clicks on a snippet to drag instead of dragging it. Note: also rename the "_onSnippetMouseDown" handler to not confuse it with this new "_onSnippetClick" and add the missing documentation comment for it. Part of https://github.com/odoo/odoo/pull/60837 Related to task-2363616 closes odoo/odoo#61724 X-original-commit: bdfddace29b16404c06a7ebfc0cc242463a0e768 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
+8
-8
@@ -92,15 +92,15 @@ $.fn.extend({
|
||||
},
|
||||
/**
|
||||
* Makes DOM elements bounce the way Odoo decided it.
|
||||
*
|
||||
* @param {string} [extraClass]
|
||||
*/
|
||||
odooBounce: function () {
|
||||
return this.each(function () {
|
||||
var $el = $(this);
|
||||
$el.addClass('o_catch_attention');
|
||||
setTimeout(function () {
|
||||
$el.removeClass('o_catch_attention');
|
||||
}, 400);
|
||||
});
|
||||
odooBounce: function (extraClass) {
|
||||
for (const el of this) {
|
||||
el.classList.add('o_catch_attention', extraClass);
|
||||
setTimeout(() => el.classList.remove('o_catch_attention', extraClass), 400);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
/**
|
||||
* Allows to bind events to a handler just as the standard `$.on` function
|
||||
|
||||
@@ -960,6 +960,7 @@ var SnippetsMenu = Widget.extend({
|
||||
id: 'oe_snippets',
|
||||
cacheSnippetTemplate: {},
|
||||
events: {
|
||||
'click .oe_snippet': '_onSnippetClick',
|
||||
'click .o_install_btn': '_onInstallBtnClick',
|
||||
'click .o_we_add_snippet_btn': '_onBlocksTabClick',
|
||||
'click .o_we_invisible_entry': '_onInvisibleEntryClick',
|
||||
@@ -1130,8 +1131,8 @@ var SnippetsMenu = Widget.extend({
|
||||
|
||||
core.bus.on('deactivate_snippet', this, this._onDeactivateSnippet);
|
||||
|
||||
this.$window.on('mousedown.snippets_menu', this._onSnippetMouseDown.bind(this));
|
||||
this.$window.on('mousedown-iframe.snippets_menu', this._onSnippetMouseDown.bind(this));
|
||||
this.$window.on('mousedown.snippets_menu', this._onContentMouseDown.bind(this));
|
||||
this.$window.on('mousedown-iframe.snippets_menu', this._onContentMouseDown.bind(this));
|
||||
|
||||
// Adapt overlay covering when the window is resized / content changes
|
||||
var throttledCoverUpdate = _.throttle(() => {
|
||||
@@ -2034,7 +2035,6 @@ var SnippetsMenu = Widget.extend({
|
||||
const smoothScrollOptions = this._getScrollOptions({
|
||||
jQueryDraggableOptions: {
|
||||
iframeFix: true,
|
||||
distance: 0,
|
||||
handle: '.oe_snippet_thumbnail:not(.o_we_already_dragging)',
|
||||
helper: function () {
|
||||
const dragSnip = this.cloneNode(true);
|
||||
@@ -2634,7 +2634,11 @@ var SnippetsMenu = Widget.extend({
|
||||
reenable();
|
||||
});
|
||||
},
|
||||
_onSnippetMouseDown: function (ev) {
|
||||
/**
|
||||
* @private
|
||||
* @param {Event}
|
||||
*/
|
||||
_onContentMouseDown: function (ev) {
|
||||
const el = this.editorHelpers.elementFromPoint(ev.clientX, ev.clientY);
|
||||
|
||||
const editable = el && el.closest('.note-editable');
|
||||
@@ -2732,6 +2736,17 @@ var SnippetsMenu = Widget.extend({
|
||||
this.trigger_up('request_save', data);
|
||||
}, true);
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_onSnippetClick() {
|
||||
const $els = this.getEditableArea().find('.oe_structure.oe_empty').addBack('.oe_structure.oe_empty');
|
||||
for (const el of $els) {
|
||||
if (!el.children.length) {
|
||||
$(el).odooBounce('o_we_snippet_area_animation');
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @param {OdooEvent} ev
|
||||
|
||||
@@ -11,12 +11,21 @@ $-editor-messages-margin-x: 2%;
|
||||
content: attr(data-editor-message);
|
||||
display: block;
|
||||
font-size: 20px;
|
||||
line-height: 50px; // Useful for the "wizz" animation on snippet click to be more visible
|
||||
}
|
||||
&:after {
|
||||
content: attr(data-editor-sub-message);
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
.o_we_snippet_area_animation {
|
||||
animation-delay: 999ms; // Disable it but allow to inherit the animation
|
||||
|
||||
&::before {
|
||||
animation: inherit;
|
||||
animation-delay: 0ms;
|
||||
}
|
||||
}
|
||||
|
||||
.o_editable {
|
||||
&:not(:empty), &[data-oe-type] {
|
||||
|
||||
Reference in New Issue
Block a user