Skip to content
Snippets Groups Projects
Commit c77452a4 authored by srosse's avatar srosse
Browse files

OO-2732: better per click selection, pointer use to drop the items, better handling of images

parent 52ec96e5
No related branches found
No related tags found
No related merge requests found
Showing
with 32 additions and 21 deletions
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
initializeSourcePanelEvents = function(containerId, settings) { initializeSourcePanelEvents = function(containerId, settings) {
jQuery("#" + containerId + " .o_match_dnd_sources").droppable({ jQuery("#" + containerId + " .o_match_dnd_sources").droppable({
tolerance: 'pointer',
over: function(event, ui) { over: function(event, ui) {
jQuery(this).addClass('oo-accepted'); jQuery(this).addClass('oo-accepted');
}, },
...@@ -92,6 +93,9 @@ ...@@ -92,6 +93,9 @@
jElements.on('click', function(e, el) { jElements.on('click', function(e, el) {
var itemEl = jQuery(this); var itemEl = jQuery(this);
if(!itemEl.hasClass('oo-choosed') && !itemEl.hasClass('oo-selected')) { if(!itemEl.hasClass('oo-choosed') && !itemEl.hasClass('oo-selected')) {
jQuery("#" + containerId + " .o_match_dnd_sources .o_match_dnd_source").each(function(index, el) {
jQuery(el).removeClass('oo-selected');
});
itemEl.addClass('oo-selected'); itemEl.addClass('oo-selected');
} else if(itemEl.parents(".o_match_dnd_targets").size() > 0 && !itemEl.hasClass('oo-dropped-mrk')) { } else if(itemEl.parents(".o_match_dnd_targets").size() > 0 && !itemEl.hasClass('oo-dropped-mrk')) {
removeSourceFromTarget(itemEl, containerId); removeSourceFromTarget(itemEl, containerId);
...@@ -102,11 +106,12 @@ ...@@ -102,11 +106,12 @@
containment: "#" + containerId, containment: "#" + containerId,
scroll: false, scroll: false,
revert: "invalid", revert: "invalid",
cursorAt: { left: 5, top: 5 },
start: function(event, ui) { start: function(event, ui) {
jQuery(ui.helper).removeClass('oo-dropped-mrk'); jQuery(ui.helper).removeClass('oo-dropped-mrk');
}, },
stop: function(event, ui) { stop: function(event, ui) {
jQuery(this).css({'left': '0px', 'top': '0px' }); jQuery(this).css({'left': '0px', 'top': '0px', 'z-index': '' });
jQuery(ui.helper).removeClass('oo-drag'); jQuery(ui.helper).removeClass('oo-drag');
}, },
helper: function() { helper: function() {
...@@ -119,12 +124,16 @@ ...@@ -119,12 +124,16 @@
.attr('id', 'n' + guid()) .attr('id', 'n' + guid())
.data('qti-cloned','true') .data('qti-cloned','true')
.addClass('oo-drag') .addClass('oo-drag')
.addClass('oo-drag-mrk'); .addClass('oo-drag-mrk')
.css('z-index', 10)
.css('width', choiceEl.width())
.css('height', choiceEl.height());
return cloned; return cloned;
} }
choiceEl choiceEl
.addClass('oo-drag') .addClass('oo-drag')
.addClass('oo-drag-mrk'); .addClass('oo-drag-mrk')
.css('z-index', 10);
return choiceEl; return choiceEl;
} }
}).on('click', {formId: settings.formDispatchFieldId}, setFlexiFormDirtyByListener); }).on('click', {formId: settings.formDispatchFieldId}, setFlexiFormDirtyByListener);
...@@ -159,6 +168,7 @@ ...@@ -159,6 +168,7 @@
recalculate(containerId, settings); recalculate(containerId, settings);
setFlexiFormDirty(settings.formDispatchFieldId, false); setFlexiFormDirty(settings.formDispatchFieldId, false);
}).droppable({ }).droppable({
tolerance: "pointer",
accept: function(el) { accept: function(el) {
var choiceQtiId = jQuery(el).data('qti-id'); var choiceQtiId = jQuery(el).data('qti-id');
//check if the source is already in the target //check if the source is already in the target
...@@ -221,7 +231,7 @@ ...@@ -221,7 +231,7 @@
var container = box.find("ul.o_match_dnd_target_drop_zone"); var container = box.find("ul.o_match_dnd_target_drop_zone");
sourceEl sourceEl
.removeClass('oo-selected') .removeClass('oo-selected')
.css({'width' : 'auto', 'left': '0px', 'top': '0px' }) .css({'width' : 'auto', 'left': '0px', 'top': '0px', 'z-index': '' })
.addClass('oo-choosed') .addClass('oo-choosed')
.appendTo(container); .appendTo(container);
box.addClass('oo-filled'); box.addClass('oo-filled');
...@@ -236,7 +246,7 @@ ...@@ -236,7 +246,7 @@
var availableSources = jQuery("#" + containerId + " .o_match_dnd_sources li[data-qti-id='" + gapId + "']").size(); var availableSources = jQuery("#" + containerId + " .o_match_dnd_sources li[data-qti-id='" + gapId + "']").size();
if(availableSources == 0) { if(availableSources == 0) {
jSelectedEl jSelectedEl
.css({'width' : 'auto', 'left': '0px', 'top': '0px' }) .css({'width' : 'auto', 'left': '0px', 'top': '0px', 'z-index': '' })
.appendTo(jQuery('#' + containerId +' .o_match_dnd_sources')); .appendTo(jQuery('#' + containerId +' .o_match_dnd_sources'));
} else { } else {
jSelectedEl.remove(); jSelectedEl.remove();
......
...@@ -424,7 +424,7 @@ $o-qti-match-source-bg : $state-warning-bg !default; ...@@ -424,7 +424,7 @@ $o-qti-match-source-bg : $state-warning-bg !default;
$o-qti-match-source-border-style : dashed !default; $o-qti-match-source-border-style : dashed !default;
$o-qti-match-selected-border-color : $brand-warning !default; $o-qti-match-selected-border-color : $brand-warning !default;
$o-qti-match-selected-bg : lighten($brand-warning, 25%) !default; $o-qti-match-selected-bg : lighten($brand-warning, 25%) !default;
$o-qti-match-drop-accept-border-color : $brand-info !default; $o-qti-match-drop-accept-border-color : darken($brand-info, 25%) !default;
$o-qti-match-target-border-color : $brand-info !default; $o-qti-match-target-border-color : $brand-info !default;
$o-qti-match-target-bg : $state-info-bg !default; $o-qti-match-target-bg : $state-info-bg !default;
$o-qti-match-border-radius : $panel-border-radius !default; $o-qti-match-border-radius : $panel-border-radius !default;
......
This diff is collapsed.
This diff is collapsed.
...@@ -688,7 +688,7 @@ tr.choiceinteraction { ...@@ -688,7 +688,7 @@ tr.choiceinteraction {
border-radius: $o-qti-match-border-radius; border-radius: $o-qti-match-border-radius;
background-color: #ffffff; background-color: #ffffff;
background: $o-qti-match-source-bg; background: $o-qti-match-source-bg;
@include clearfix;
&.oo-selected { &.oo-selected {
border: 2px $o-qti-match-source-border-style $o-qti-match-selected-border-color; border: 2px $o-qti-match-source-border-style $o-qti-match-selected-border-color;
...@@ -720,6 +720,7 @@ tr.choiceinteraction { ...@@ -720,6 +720,7 @@ tr.choiceinteraction {
border: 2px solid $o-qti-match-target-border-color; border: 2px solid $o-qti-match-target-border-color;
border-radius: $o-qti-match-border-radius; border-radius: $o-qti-match-border-radius;
background: $o-qti-match-target-bg; background: $o-qti-match-target-bg;
@include clearfix;
.o_match_dnd_target_drop_zone { .o_match_dnd_target_drop_zone {
margin: 0; margin: 0;
......
This diff is collapsed.
This diff is collapsed.
source diff could not be displayed: it is too large. Options to address this: view the blob.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment