From 798a0da4f8426b26edd1bc71f5fdf3dd73940f6e Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 6 Sep 2010 18:01:11 -0400 Subject: [PATCH] Pass the File to the Actor on construction. --- web_frontend/actor.js | 8 ++++++-- web_frontend/file.js | 12 ++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/web_frontend/actor.js b/web_frontend/actor.js index 3a4b6a7..4e19729 100644 --- a/web_frontend/actor.js +++ b/web_frontend/actor.js @@ -19,10 +19,12 @@ goog.require('goog.ui.Popup'); /** * The Actor is a popup that displays the various actions that can be performed * on a given File. + * @param {armadillo.File} file The file to act on. * @constructor */ -armadillo.Actor = function() { +armadillo.Actor = function(file) { goog.Disposable.call(this); + this.file_ = file; this.element_ = this.createElement_(); this.popup_ = new goog.ui.Popup(this.element_); armadillo.Actor.actors_.push(this); @@ -89,6 +91,8 @@ armadillo.Actor.prototype.disposeInternal = function() { // Remove the actor from the list. goog.array.remove(armadillo.Actor.actors_, this); + + this.file_ = null; }; /** @@ -140,7 +144,7 @@ armadillo.Actor.prototype.createElement_ = function() { */ armadillo.Actor.prototype.tileClickHandler_ = function(e) { if (e.target.actorOption == armadillo.Actor.options_.DELETE) { - console.log("DELETE DELETE DELETE"); + console.log("DELETE DELETE DELETE " + this.file_.getName()); } console.log('You clicked ' + e.target.actorOption); }; diff --git a/web_frontend/file.js b/web_frontend/file.js index 09f7c76..2e9de77 100644 --- a/web_frontend/file.js +++ b/web_frontend/file.js @@ -29,7 +29,7 @@ goog.inherits(armadillo.File, goog.Disposable); * Disposer * @protected */ -goog.Disposable.prototype.disposeInternal = function() { +armadillo.File.prototype.disposeInternal = function() { armadillo.File.superClass_.disposeInternal.call(this); this.element_ = null; goog.events.unlistenByKey(this.clickListener_); @@ -39,6 +39,14 @@ goog.Disposable.prototype.disposeInternal = function() { goog.events.unlistenByKey(this.buttonListener_); }; +/** + * Returns the name of the file. + * @returns string + */ +armadillo.File.prototype.getName = function() { + return this.name_; +}; + /** * Constructs the Elements that make up the UI. * @returns {Element} An element ready for insertion into DOM. @@ -108,7 +116,7 @@ armadillo.File.prototype.buttonClickHandler_ = function(e) { if (armadillo.Actor.isModal()) return; e.stopPropagation(); - var actor = new armadillo.Actor(); + var actor = new armadillo.Actor(this); actor.show(e.clientX, e.clientY); }; -- 2.43.5