From 5f59378c720539fd2023f966816cbb9fbabb4c7a Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 7 Sep 2010 22:47:16 -0400 Subject: [PATCH] Create the unhooked Move action interface. --- web_frontend/actor.js | 53 ++++++++++++++++++++++++++++++++++------- web_frontend/file.js | 9 +++++++ web_frontend/screen.css | 4 ++++ 3 files changed, 58 insertions(+), 8 deletions(-) diff --git a/web_frontend/actor.js b/web_frontend/actor.js index 763f1f9..c0f2a0a 100644 --- a/web_frontend/actor.js +++ b/web_frontend/actor.js @@ -148,26 +148,48 @@ armadillo.Actor.prototype.createElement_ = function() { * @param {Event} e */ armadillo.Actor.prototype.tileClickHandler_ = function(e) { - if (e.target.actorOption == armadillo.Actor.options_.OPEN) { + var option = e.target.actorOption; + if (option == armadillo.Actor.options_.OPEN) { // TODO: assert that this.file_.isDirectory(). app.navigate(this.file_.getName()); this.hide(); - } else if (e.target.actorOption == armadillo.Actor.options_.DELETE) { + } else if (option == armadillo.Actor.options_.MOVE) { + this.performMove_(); + } else if (option == armadillo.Actor.options_.DELETE) { this.performDelete_(); } }; +/** + * Subroutine to handle bringing up the move confirmation UI. + * @private + */ +armadillo.Actor.prototype.performMove_ = function() { + var dialog = this.createActionDialog_(); + dialog.setTitle('Move File'); + + var container = dialog.getContentElement(); + goog.dom.appendChild(container, + goog.dom.createDom('p', null, + 'Enter a new, absolute path for this file.')); + var field = goog.dom.createElement('input'); + field.type = 'text'; + goog.dom.setTextContent(field, this.file_.getParentPath()); + goog.dom.appendChild(container, field) + // TODO: Suck less. + goog.dom.appendChild(container, + goog.dom.createDom('p', 'smallfont', + '(Please pardon this interface. Armadillo is a work-in-progress.)')); + + dialog.setVisible(true); +}; + /** * Subroutine to handle bringing up the delete confirmation UI. * @private */ armadillo.Actor.prototype.performDelete_ = function() { - var confirm = new goog.ui.Dialog(); - confirm.setDisposeOnHide(true); - confirm.setEscapeToCancel(true); - confirm.setModal(true); - confirm.setDraggable(false); - confirm.setHasTitleCloseButton(false); + var confirm = this.createActionDialog_(); confirm.setTitle('Confirm Delete'); var container = confirm.getContentElement(); @@ -188,3 +210,18 @@ armadillo.Actor.prototype.performDelete_ = function() { confirm.setVisible(true); }; + +/** + * Creates a new instance of a Dialog that has some basic properties set that + * are common to performing actions. + * @private + */ +armadillo.Actor.prototype.createActionDialog_ = function() { + var confirm = new goog.ui.Dialog(); + confirm.setDisposeOnHide(true); + confirm.setEscapeToCancel(true); + confirm.setModal(true); + confirm.setDraggable(false); + confirm.setHasTitleCloseButton(false); + return confirm; +}; diff --git a/web_frontend/file.js b/web_frontend/file.js index 0801317..c6d99cb 100644 --- a/web_frontend/file.js +++ b/web_frontend/file.js @@ -49,6 +49,15 @@ armadillo.File.prototype.getName = function() { return this.name_; }; +/** + * Returns the path the file without the name. This is equivalent to calling + * dirname on the absolute path. + * @returns string + */ +armadillo.File.prototype.getParentPath = function() { + return this.path_; +}; + /** * Gets the fully qualified path of the file, from the root of the jail to the * name of the file. diff --git a/web_frontend/screen.css b/web_frontend/screen.css index 4c0826e..aa2e44e 100644 --- a/web_frontend/screen.css +++ b/web_frontend/screen.css @@ -18,6 +18,10 @@ h1 { font-size: 2em; } +.smallfont { + font-size: 0.7em; +} + #ls { list-style: none; } -- 2.22.5