Skip to content

Instantly share code, notes, and snippets.

@m-engel
Last active March 3, 2017 10:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m-engel/60a107e14fe5b2cac285 to your computer and use it in GitHub Desktop.
Save m-engel/60a107e14fe5b2cac285 to your computer and use it in GitHub Desktop.
Disable Drag&Drop Resources out of Containers
// Event: OnManagerPageBeforeRender
$script = "<script>
var ResourceTreeHandleDrop = MODx.tree.Resource.prototype._handleDrop;
Ext.override(MODx.tree.Resource, {
_handleDrop:function(e){
var dropNode = e.dropNode;
var targetParent = e.target;
if(dropNode.getDepth() != targetParent.getDepth() || (e.point == 'append')) return false;
if(dropNode.parentNode.id != targetParent.parentNode.id) return false;
return ResourceTreeHandleDrop(e);
}
});
</script>";
$controller->head['html'][] = $script;
return true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment