From 6d6feb06d75270d85e3b5cd553c4d9cf50022cb8 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Thu, 11 Apr 2013 12:53:23 +0000 Subject: [PATCH] Fix droppables to accept dragged if one of the types match --- phpgwapi/js/egw_action/egw_action_dragdrop.js | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/phpgwapi/js/egw_action/egw_action_dragdrop.js b/phpgwapi/js/egw_action/egw_action_dragdrop.js index 7ee008662e..a5e7778bb0 100644 --- a/phpgwapi/js/egw_action/egw_action_dragdrop.js +++ b/phpgwapi/js/egw_action/egw_action_dragdrop.js @@ -173,10 +173,13 @@ function egwDragActionImplementation() // Push the dragType of the associated action object onto the // drag type list - this allows an element to support multiple // drag/drop types. - var type = _links[k].actionObj.dragType; - if (this.ddTypes.indexOf(type) == -1) + var type = $j.isArray(_links[k].actionObj.dragType) ? _links[k].actionObj.dragType : [_links[k].actionObj.dragType]; + for(var i = 0; i < type.length; i++) { - this.ddTypes.push(_links[k].actionObj.dragType); + if (this.ddTypes.indexOf(type[i]) == -1) + { + this.ddTypes.push(type[i]); + } } } } @@ -286,13 +289,13 @@ function egwDropActionImplementation() for (var i = 0; i < ddTypes.length; i++) { - if (accepted.indexOf(ddTypes[i]) == -1) + if (accepted.indexOf(ddTypes[i]) != -1) { - return false; + return true; } } - return true; + return false; } }, "drop": function(event, ui) { @@ -308,15 +311,20 @@ function egwDropActionImplementation() { var accepted = links[k].actionObj.acceptedTypes; + var enabled = false for (var i = 0; i < ddTypes.length; i++) { - if (accepted.indexOf(ddTypes[i]) == -1) + if (accepted.indexOf(ddTypes[i]) != -1) { - links[k].enabled = false; - if (links[k].actionObj.hideOnDisabled) - { - links[k].visible = true; - } + enabled = true; + } + } + if(!enabled) + { + links[k].enabled = false; + if (links[k].actionObj.hideOnDisabled) + { + links[k].visible = true; } } } @@ -364,7 +372,9 @@ function egwDropActionImplementation() "out": function() { _aoi.triggerEvent(EGW_AI_DRAG_OUT); }, - "tolerance": "pointer" + "tolerance": "pointer", + activeClass: "ui-state-hover", + hoverClass: "ui-state-active" } );