mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
fixed not working hideOnDisabled when building popup menu for multiple drop actions, also fixed tons of IDE warnings
This commit is contained in:
parent
531673f21e
commit
589a6e2e96
@ -21,21 +21,29 @@
|
||||
* Register the drag and drop handlers
|
||||
*/
|
||||
if (typeof window._egwActionClasses == "undefined")
|
||||
window._egwActionClasses = {}
|
||||
window._egwActionClasses = {};
|
||||
_egwActionClasses["drag"] = {
|
||||
"actionConstructor": egwDragAction,
|
||||
"implementation": getDragImplementation
|
||||
}
|
||||
};
|
||||
_egwActionClasses["drop"] = {
|
||||
"actionConstructor": egwDropAction,
|
||||
"implementation": getDropImplementation
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The egwDragAction class overwrites the egwAction class and adds the new
|
||||
* "dragType" propery. The "onExecute" event of the drag action will be called
|
||||
* whenever dragging starts. The onExecute JS handler should return the
|
||||
* drag-drop helper object - otherwise an default helper will be generated.
|
||||
*
|
||||
* @param {egwAction} _id
|
||||
* @param {string} _handler
|
||||
* @param {string} _caption
|
||||
* @param {string} _icon
|
||||
* @param {(string|function)} _onExecute
|
||||
* @param {bool} _allowOnMultiple
|
||||
* @returns {egwDragAction}
|
||||
*/
|
||||
function egwDragAction(_id, _handler, _caption, _icon, _onExecute, _allowOnMultiple)
|
||||
{
|
||||
@ -47,7 +55,7 @@ function egwDragAction(_id, _handler, _caption, _icon, _onExecute, _allowOnMulti
|
||||
|
||||
action.set_dragType = function(_value) {
|
||||
action.dragType = _value;
|
||||
}
|
||||
};
|
||||
|
||||
return action;
|
||||
}
|
||||
@ -62,7 +70,7 @@ function getDragImplementation()
|
||||
{
|
||||
_dragActionImpl = new egwDragActionImplementation();
|
||||
}
|
||||
return _dragActionImpl
|
||||
return _dragActionImpl;
|
||||
}
|
||||
|
||||
function egwDragActionImplementation()
|
||||
@ -126,7 +134,7 @@ function egwDragActionImplementation()
|
||||
$j(node).off("mousedown")
|
||||
.on("mousedown", function(event) {
|
||||
$j(node).draggable("option","disabled",event.ctrlKey || event.metaKey);
|
||||
$j(this).attr("draggable", event.ctrlKey || event.metaKey ? "true" : "")
|
||||
$j(this).attr("draggable", event.ctrlKey || event.metaKey ? "true" : "");
|
||||
|
||||
// Disabling draggable adds some UI classes, but we don't care so remove them
|
||||
$j(node).removeClass("ui-draggable-disabled ui-state-disabled");
|
||||
@ -240,7 +248,7 @@ function egwDragActionImplementation()
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
ai.doUnregisterAction = function(_aoi)
|
||||
{
|
||||
@ -249,10 +257,14 @@ function egwDragActionImplementation()
|
||||
if (node && $j(node).data("uiDraggable")){
|
||||
$j(node).draggable("destroy");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Builds the context menu and shows it at the given position/DOM-Node.
|
||||
*
|
||||
* @param {string} _context
|
||||
* @param {array} _selected
|
||||
* @param {object} _links
|
||||
*/
|
||||
ai.doExecuteImplementation = function(_context, _selected, _links)
|
||||
{
|
||||
@ -301,7 +313,7 @@ function egwDragActionImplementation()
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
return ai;
|
||||
}
|
||||
@ -310,8 +322,15 @@ function egwDragActionImplementation()
|
||||
|
||||
/**
|
||||
* The egwDropAction class overwrites the egwAction class and adds the "acceptedTypes"
|
||||
* property. This array should contain all "dragTypes" the drop action is allowed
|
||||
* to
|
||||
* property. This array should contain all "dragTypes" the drop action is allowed to
|
||||
*
|
||||
* @param {egwAction} _id
|
||||
* @param {string} _handler
|
||||
* @param {string} _caption
|
||||
* @param {string} _icon
|
||||
* @param {(string|function)} _onExecute
|
||||
* @param {bool} _allowOnMultiple
|
||||
* @returns {egwDropAction}
|
||||
*/
|
||||
function egwDropAction(_id, _handler, _caption, _icon, _onExecute, _allowOnMultiple)
|
||||
{
|
||||
@ -326,19 +345,21 @@ function egwDropAction(_id, _handler, _caption, _icon, _onExecute, _allowOnMulti
|
||||
|
||||
action.set_default = function(_value) {
|
||||
action["default"] = _value;
|
||||
}
|
||||
};
|
||||
|
||||
action.set_order = function(_value) {
|
||||
action.order = _value;
|
||||
}
|
||||
};
|
||||
|
||||
action.set_group = function(_value) {
|
||||
action.group = _value;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The acceptType property allows strings as well as arrays - strings are
|
||||
* automatically included in an array.
|
||||
*
|
||||
* @param {(string|array)} _value
|
||||
*/
|
||||
action.set_acceptedTypes = function(_value) {
|
||||
if (_value instanceof Array)
|
||||
@ -349,7 +370,7 @@ function egwDropAction(_id, _handler, _caption, _icon, _onExecute, _allowOnMulti
|
||||
{
|
||||
action.acceptedTypes = [_value];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return action;
|
||||
}
|
||||
@ -363,7 +384,7 @@ function getDropImplementation()
|
||||
{
|
||||
_dropActionImpl = new egwDropActionImplementation();
|
||||
}
|
||||
return _dropActionImpl
|
||||
return _dropActionImpl;
|
||||
}
|
||||
|
||||
var EGW_AI_DRAG = 0x0100; // Use the first byte as mask for event types - 01 is for events used with drag stuff
|
||||
@ -419,12 +440,13 @@ function egwDropActionImplementation()
|
||||
{
|
||||
var accepted = links[k].actionObj.acceptedTypes;
|
||||
|
||||
var enabled = false
|
||||
var enabled = false;
|
||||
for (var i = 0; i < ddTypes.length; i++)
|
||||
{
|
||||
if (accepted.indexOf(ddTypes[i]) != -1)
|
||||
{
|
||||
enabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Check for allowing multiple selected
|
||||
@ -435,10 +457,7 @@ function egwDropActionImplementation()
|
||||
if(!enabled)
|
||||
{
|
||||
links[k].enabled = false;
|
||||
if (links[k].actionObj.hideOnDisabled)
|
||||
{
|
||||
links[k].visible = true;
|
||||
}
|
||||
links[k].visible = !links[k].actionObj.hideOnDisabled;
|
||||
}
|
||||
}
|
||||
|
||||
@ -493,14 +512,14 @@ function egwDropActionImplementation()
|
||||
activeClass: "ui-state-hover",
|
||||
hoverClass: "ui-state-active",
|
||||
// Greedy is for nested droppables - children consume the action
|
||||
greedy: true,
|
||||
greedy: true
|
||||
}
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
ai.doUnregisterAction = function(_aoi)
|
||||
{
|
||||
@ -509,7 +528,7 @@ function egwDropActionImplementation()
|
||||
if (node && $j(node).data("uiDroppable")) {
|
||||
$j(node).droppable("destroy");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ai._fetchAccepted = function(_links)
|
||||
{
|
||||
@ -529,10 +548,14 @@ function egwDropActionImplementation()
|
||||
}
|
||||
|
||||
return accepted;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Builds the context menu and shows it at the given position/DOM-Node.
|
||||
*
|
||||
* @param {string} _context
|
||||
* @param {array} _selected
|
||||
* @param {object} _links
|
||||
*/
|
||||
ai.doExecuteImplementation = function(_context, _selected, _links)
|
||||
{
|
||||
@ -540,8 +563,7 @@ function egwDropActionImplementation()
|
||||
{
|
||||
return _links;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return ai;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user