return '/';
};
+/**
+ * Joins all the arguments together as a path.
+ * @param {string...} varargs Components to join
+ */
+armadillo.App.prototype.joinPath = function() {
+ var path = '';
+ var sep = '/';
+ var last = arguments.length - 1;
+ goog.array.forEach(arguments, function (c, i) {
+ if (c == sep && i != 0)
+ return;
+ path += c;
+ if (c[c.length - 1] != sep && i != last)
+ path += sep;
+ });
+ return path;
+};
+
/**
* Clears the error message.
*/
this.element_ = element;
var components = this.path_.split('/');
- if (components.length == 2) {
- // If this is an item that lives at the root, generate a special node for
- // moving between items at the top level.
- components[0] = '/';
- } else {
- // Otherwise, just remove it as the first node will list all items at the
- // root.
- goog.array.removeAt(components, 0);
- }
+ // If this is an item that lives at the root, generate a special node for
+ // moving between items at the top level.
+ components[0] = '/';
// If the last component is emtpy, do not use it because it means a directory
// is being moved.
goog.array.removeAt(components, components.length - 1);
}
- var path = '/';
+ var path = '';
goog.array.forEach(components, function (part, i) {
this.addChild(this.createComponentNode_(path, part), true);
- path += part + '/';
+ path = app.joinPath(path, part);
}, this);
if (this.editableLastComponent_) {
return;
}
var item = new goog.ui.MenuItem(caption);
- item.setValue(path + caption);
+ item.setValue(app.joinPath(path, name, caption));
menu.addItem(item);
if (caption == name) {
menu.setHighlighted(item);
}
});
};
- app.sendRequest('list', {'path':path}, callback);
+ app.sendRequest('list', {'path' : app.joinPath(path, name)}, callback);
};
/**