goog.require('goog.dom');
goog.require('goog.events');
goog.require('goog.events.EventHandler');
-goog.require('goog.positioning.ClientPosition');
-goog.require('goog.positioning.Corner');
goog.require('goog.style');
goog.require('goog.ui.Container');
goog.require('goog.ui.Dialog');
-goog.require('goog.ui.Popup');
/**
* The Actor is a popup that displays the various actions that can be performed
*/
this.eh_ = new goog.events.EventHandler();
- /**
- * The Container that holds the display element.
- * @type {goog.ui.Popup}
- */
- this.popup_ = new goog.ui.Popup(this.element_);
- this.eh_.listenOnce(this.popup_, goog.ui.PopupBase.EventType.HIDE,
- this.onPopupClosed_, false, this);
-
/**
* The UI element used for a specific action.
* @type {goog.Disposable}
*/
this.actionObject_ = null;
-
- armadillo.Actor.actors_.push(this);
}
goog.inherits(armadillo.Actor, goog.ui.Container);
-/**
- * An array of all the Actors that have been created.
- */
-armadillo.Actor.actors_ = new Array();
-
/**
* The different options that the Actor can perform.
*/
'delete' : 'Delete'
};
-/**
- * A global property that should be checked to see if an actor is present,
- * creating a modal session.
- */
-armadillo.Actor.isModal = function() {
- var isVisible = false;
- goog.array.forEach(armadillo.Actor.actors_, function (e) {
- isVisible |= e.popup_.isVisible();
- });
- return isVisible;
-};
-
/**
* Disposer
* @protected
goog.dom.removeNode(this.element_);
this.element_ = null;
- // Kill the popup.
- this.popup_.dispose();
- this.popup_ = null;
-
if (this.actionObject_) {
this.actionObject_.dispose();
this.actionObject_ = null;
}
- // Remove the actor from the list.
- goog.array.remove(armadillo.Actor.actors_, this);
-
this.file_ = null;
};
-/**
- * Shows the popup.
- * @param {int} x The X position to show at
- * @param {int} y The Y position to show at
- */
-armadillo.Actor.prototype.show = function(x, y) {
- if (armadillo.Actor.isModal())
- return;
- this.popup_.setPinnedCorner(goog.positioning.Corner.TOP_LEFT);
- this.popup_.setPosition(new goog.positioning.ClientPosition(x, y));
- this.popup_.setHideOnEscape(true);
- this.render();
- this.popup_.setVisible(true);
- this.file_.setHighlight(armadillo.File.Highlight.ACTIVE);
-};
-
-/**
- * Hides the popup.
- */
-armadillo.Actor.prototype.hide = function() {
- this.file_.setHighlight(armadillo.File.Highlight.SELECTED);
- this.popup_.setVisible(false);
-};
-
-
-/**
- * Creates a new path control object.
- */
-armadillo.Actor.prototype.createDom = function() {
- this.decorateInternal(this.dom_.createDom('div', 'actor'));
- this.popup_.setElement(this.element_);
-};
-
-/**
- * @inheritDoc
- */
-armadillo.Actor.prototype.canDecorate = function() {
- return false;
-};
-
/**
* Decorates the given element into a path control.
* @param {Element} element
*/
armadillo.Actor.prototype.decorateInternal = function(element) {
this.element_ = element;
+ goog.dom.classes.add(this.element_, 'actor');
this.dom_.removeChildren(this.element_);
for (var option in armadillo.Actor.options_) {
var tile = this.createTile_(option);
* @param {goog.ui.Control} control Control to render.
* @return {Element} Root element for the control.
*/
-goog.ui.ControlRenderer.prototype.createDom = function(control) {
+armadillo.Actor.TileControlRenderer_.prototype.createDom = function(control) {
// Create and return DIV wrapping contents.
return control.getDomHelper().createDom('div', 'tile', control.getContent());
};
goog.require('armadillo.Actor');
goog.require('goog.Disposable');
goog.require('goog.dom');
+goog.require('goog.ui.AnimatedZippy');
/**
* A file in a directory listing.
this.path_ = path;
this.highlight_ = '';
this.isDirectory_ = app.isDirectory(name);
+ this.actor_ = new armadillo.Actor(this);
+ this.zippy_ = null;
};
goog.inherits(armadillo.File, goog.Disposable);
this.link_ = null;
goog.events.unlistenByKey(this.linkListener_);
goog.events.unlistenByKey(this.actorListener_);
+ this.actor_.dispose();
+ if (this.zippy_)
+ this.zippy_.dispose();
};
/**
* @param {Event} e
*/
armadillo.File.prototype.clickHandler_ = function(e) {
- if (armadillo.Actor.isModal()) {
- return;
- }
if (this.isDirectory_) {
app.navigate(this.name_);
}
* @param {Event} e
*/
armadillo.File.prototype.actorHandler_ = function(e) {
- if (armadillo.Actor.isModal())
- return;
e.stopPropagation();
- var actor = new armadillo.Actor(this);
- // Adjust the mouse position so that if "Open" is the first tile, it is easy
- // to navigate.
- var x = e.clientX;
- var y = e.clientY;
- if (this.isDirectory()) {
- x -= 20;
- y -= 20;
+ if (!this.actor_.isInDocument()) {
+ this.actor_.render(this.element_);
+ this.actor_.setVisible(true);
}
- actor.show(x, y);
+ if (!this.zippy_)
+ this.zippy_ = new goog.ui.AnimatedZippy(this.element_,
+ this.actor_.getElement(), false);
+ this.zippy_.toggle();
};
/**