*/
armadillo.App.prototype.navigate = function(target) {
if (target == '../') {
- this.list(this.stripLastPathComponent_(this.currentPath_));
+ this.list(this.stripLastPathComponent(this.currentPath_));
} else {
this.list(this.currentPath_ + target);
}
* @param {string} path
* @returns string
*/
-armadillo.App.prototype.stripLastPathComponent_ = function(path) {
+armadillo.App.prototype.stripLastPathComponent = function(path) {
for (var i = path.length - 1; i >= 0; --i) {
if (path[i] == '/') {
if (i != path.length - 1) {
* Full path of the control.
* @type {string}
*/
- this.path_ = path;
+ this.path_ = null;
+
+ /**
+ * The name of the file at the |path_|.
+ * @type {string}
+ */
+ this.name_ = null;
+
+ this.setPath(path);
/**
* Whether or not the last component is editable.
this.components_ = null;
};
+/**
+ * Sets the path.
+ * @param {string} path
+ */
+armadillo.PathControl.prototype.setPath = function(path) {
+ this.path_ = app.stripLastPathComponent(path);
+ this.name_ = path.substr(this.path_.length);
+ console.log(this.path_ + ' = ' + this.name_);
+};
+
/**
* Creates a new path control object.
*/
var path = '/';
goog.array.forEach(components, function (part, i) {
- if (i != components.length - 1) {
- this.addChild(this.createComponentNode_(path, part), true);
- } else {
- var input = new goog.ui.LabelInput(part, this.dom_);
- this.addChild(input, true);
- input.setEnabled(this.editableLastComponent_);
- input.setValue(part);
- }
+ this.addChild(this.createComponentNode_(path, part), true);
path += part + '/';
}, this);
+
+ if (this.editableLastComponent_) {
+ var input = new goog.ui.Control(this.dom_.createDom('input'));
+ input.getElement().value = this.name_;
+ this.addChild(input, true);
+ } else {
+ var label = new goog.ui.Control(this.name_);
+ this.addChild(label, true);
+ goog.dom.classes.add(label.getElement(), 'goog-inline-block');
+ }
};
/**
*/
armadillo.PathControl.prototype.componentChanged_ = function(e) {
console.log(e.target.getValue());
+ this.path_ = e.target.getValue();
+ this.removeChildren(true);
+ this.decorateInternal(this.element_);
};