From dddd057513513711ad6e472475b1ded6a974a2fa Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 7 Sep 2010 22:12:42 -0400 Subject: [PATCH] Implement the Open action. --- web_frontend/actor.js | 64 +++++++++++++++++++++++++------------------ web_frontend/file.js | 9 ++++++ 2 files changed, 47 insertions(+), 26 deletions(-) diff --git a/web_frontend/actor.js b/web_frontend/actor.js index 9f31a88..763f1f9 100644 --- a/web_frontend/actor.js +++ b/web_frontend/actor.js @@ -148,31 +148,43 @@ armadillo.Actor.prototype.createElement_ = function() { * @param {Event} e */ armadillo.Actor.prototype.tileClickHandler_ = function(e) { - if (e.target.actorOption == armadillo.Actor.options_.DELETE) { - var confirm = new goog.ui.Dialog(); - confirm.setDisposeOnHide(true); - confirm.setEscapeToCancel(true); - confirm.setModal(true); - confirm.setDraggable(false); - confirm.setHasTitleCloseButton(false); - confirm.setTitle('Confirm Delete'); - - var container = confirm.getContentElement(); - var content = goog.dom.createDom('span', null, - 'Are you sure you want to delete:', - goog.dom.createElement('br'), - goog.dom.createDom('strong', null, this.file_.getName())); - goog.dom.appendChild(container, content); - - var closeCallback = function(e) { - if (e.key != goog.ui.Dialog.DefaultButtonKeys.CANCEL) { - this.file_.delete(); - } - }; - // Will be removed when the event source closes. - goog.events.listen(confirm, goog.ui.Dialog.SELECT_EVENT, - closeCallback, false, this); - - confirm.setVisible(true); + if (e.target.actorOption == 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) { + this.performDelete_(); } }; + +/** + * 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); + confirm.setTitle('Confirm Delete'); + + var container = confirm.getContentElement(); + var content = goog.dom.createDom('span', null, + 'Are you sure you want to delete:', + goog.dom.createElement('br'), + goog.dom.createDom('strong', null, this.file_.getName())); + goog.dom.appendChild(container, content); + + var closeCallback = function(e) { + if (e.key != goog.ui.Dialog.DefaultButtonKeys.CANCEL) { + this.file_.delete(); + } + }; + // Will be removed when the event source closes. + goog.events.listen(confirm, goog.ui.Dialog.SELECT_EVENT, + closeCallback, false, this); + + confirm.setVisible(true); +}; diff --git a/web_frontend/file.js b/web_frontend/file.js index 557523e..0801317 100644 --- a/web_frontend/file.js +++ b/web_frontend/file.js @@ -49,6 +49,15 @@ armadillo.File.prototype.getName = function() { return this.name_; }; +/** + * Gets the fully qualified path of the file, from the root of the jail to the + * name of the file. + * @returns string + */ +armadillo.File.prototype.getFullPath = function() { + return this.path_ + this.name_; +}; + /** * Returns whether or not this is a directory. * @returns boolean -- 2.43.5