[IMP] web: Add disableDrop option to dragAndDrop

In some situations, it would be desirable to be able to attempt a drag
and drop, without actually triggering the dropping action. As an
example, we would like to see whether dragging a new field in studio
ensures that a class 'o_web_studio_nearest_hook' be assigned. This can
only be tested *before* the new field is dropped.

This commit adds an optional argument 'disableDrop' to the
dragAndDrop method, and sets it by default to false. The dropping action
will then only be triggered if the aforementioned parameter is set to
false.
This commit is contained in:
Khoi Nguyen
2017-07-06 11:50:35 +02:00
parent 70e1efd41e
commit 5854bb7d12
@@ -369,6 +369,7 @@ function createModel(params) {
* @param {jqueryElement} $to
* @param {Object} [options]
* @param {string} [options.position=center] target position
* @param {string} [options.disableDrop=false] whether to trigger the drop action
*/
function dragAndDrop($el, $to, options) {
var position = (options && options.position) || 'center';
@@ -396,11 +397,13 @@ function dragAndDrop($el, $to, options) {
pageY: toOffset.top
}));
$el.trigger($.Event("mouseup", {
which: 1,
pageX: toOffset.left,
pageY: toOffset.top
}));
if (!(options && options.disableDrop)) {
$el.trigger($.Event("mouseup", {
which: 1,
pageX: toOffset.left,
pageY: toOffset.top
}));
}
}
/**