-
-
Save lipusz/0f9280029b303d469037 to your computer and use it in GitHub Desktop.
alloy-ui/2.0.x | Proposed fix for https://issues.liferay.com/browse/LPS-40574
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/aui-tree/js/aui-tree-node.js b/src/aui-tree/js/aui-tree-node.js | |
index 494d1d7..1ee0f27 100644 | |
@@ -1205,8 +1210,9 @@ var TreeNodeIO = A.Component.create({ | |
* Expand the current TreeNodeIO. | |
* | |
* @method expand | |
+ * @param {function} fn callback Optional. | |
*/ | |
- expand: function() { | |
+ expand: function(fn) { | |
var instance = this; | |
var cache = instance.get(CACHE); | |
@@ -1231,6 +1237,10 @@ var TreeNodeIO = A.Component.create({ | |
else { | |
A.TreeNodeIO.superclass.expand.apply(this, arguments); | |
} | |
+ | |
+ if (fn) { | |
+ fn.call(); | |
+ } | |
}, | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/aui-tree/js/aui-tree-view.js b/src/aui-tree/js/aui-tree-view.js | |
index 00dc266..18fdf25 100644 | |
@@ -838,11 +838,11 @@ var TreeViewDD = A.Component.create({ | |
} | |
else if (dropAction === APPEND) { | |
if (dropTreeNode && !dropTreeNode.isLeaf()) { | |
- dropTreeNode.appendChild(dragTreeNode); | |
- | |
if (!dropTreeNode.get(EXPANDED)) { | |
// expand node when drop a child on it | |
- dropTreeNode.expand(); | |
+ dropTreeNode.expand(function() { | |
+ dropTreeNode.appendChild(dragTreeNode); | |
+ }); | |
} | |
instance.bubbleEvent('dropAppend', output); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
<link href="http://cdn.alloyui.com/2.0.0pr7/aui-css/css/bootstrap.min.css" rel="stylesheet"></link> | |
<script src="http://cdn.alloyui.com/2.0.0pr7/aui/aui-min.js"></script> | |
</head> | |
<body> | |
<h1>AlloyUI - Tree</h1> | |
<div class="container pull-left"> | |
<div class="row-fluid"> | |
<div class="span6"> | |
<h2>TreeView file with IO</h2> | |
<div id="treeio"></div> | |
</div> | |
</div> | |
</div> | |
<script> | |
YUI({ filter: 'raw' }).use('aui-tree', function(Y) { | |
var dragNode = new Y.TreeNodeTask({ | |
alwaysShowHitArea: true, | |
children: [], | |
draggable: true, | |
expanded: false, | |
label: 'Drag', | |
leaf: false | |
}); | |
var dropNode = new Y.TreeNodeTask({ | |
alwaysShowHitArea: true, | |
children: [], | |
draggable: true, | |
expanded: false, | |
io: 'assets/solar-system.html', | |
label: 'Drop', | |
leaf: false | |
}); | |
var treeViewDD = new Y.TreeViewDD({ | |
boundingBox: '#treeio', | |
children: [dragNode, dropNode], | |
type: 'file' | |
}).render(); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Tibor:
This isn't an AUI/YUI thing, this is a browser security policy. In order to run any ajax call (even XMLHttpRequest), you cannot point to the file system.
I don't know if you're on a mac or linux, but if you are, and have python (macs do by default, though not sure about linux), you can easily make a quick server to test out a demo. Just navigate to the directory and run this command:
python -m SimpleHTTPServer 8000
Just navigate to http://localhost:8000 and you're good to go :)
If you're on Windows, you have my condolences ;) and you might find something like ampss to be useful.