Skip to content

Instantly share code, notes, and snippets.

@lipusz
Last active December 25, 2015 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lipusz/0f9280029b303d469037 to your computer and use it in GitHub Desktop.
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
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();
+ }
},
/**
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);
<!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>
@lipusz
Copy link
Author

lipusz commented Oct 10, 2013

Finally, I could manage to get it work:

  1. Copied demos/io under ${TOMCAT_HOME}/webapps
  2. Modified the links to aui-min.js & bootstrap.min.css to point to

Then, I navigated to http://localhost:6211/io/index.html (where 6211 represents 6.2.x :) )

Voila, it works! :-)

Maybe these steps are trivial for cores, shouldn't we update our docs to contain a step-by-step guide about how-to run demos?
Or at least add some "usage notes" into the affected index.html files.

@lipusz
Copy link
Author

lipusz commented Oct 10, 2013

@natecavanaugh
Copy link

Hi Tibor:

Can AUI/YUI IO handle requests that point to a local (file) resource at all?

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment