2 // Armadillo File Manager
3 // Copyright (c) 2010, Robert Sesek <http://www.bluestatic.org>
5 // This program is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free Software
7 // Foundation, either version 3 of the License, or any later version.
10 goog
.provide('armadillo.Actor');
12 goog
.require('goog.array');
13 goog
.require('goog.dom');
14 goog
.require('goog.positioning.ClientPosition');
15 goog
.require('goog.positioning.Corner');
16 goog
.require('goog.ui.Popup');
19 * The Actor is a popup that displays the various actions that can be performed
23 armadillo
.Actor
= function() {
24 goog
.Disposable
.call(this);
25 this.element_
= this.createElement_();
26 this.popup_
= new goog
.ui
.Popup(this.element_
);
27 armadillo
.Actor
.actors_
.push(this);
29 goog
.inherits(armadillo
.Actor
, goog
.Disposable
);
32 * An array of all the Actors that have been created.
34 armadillo
.Actor
.actors_
= new Array();
37 * A global property that should be checked to see if an actor is present,
38 * creating a modal session.
40 armadillo
.Actor
.isModal
= function() {
41 var isVisible
= false;
42 goog
.array
.forEach(armadillo
.Actor
.actors_
, function (e
) {
43 isVisible
|= e
.popup_
.isVisible();
52 armadillo
.Actor
.prototype.disposeInternal
= function() {
53 armadillo
.Actor
.superClass_
.disposeInternal
.call(this);
54 goog
.dom
.removeNode(this.element_
);
56 this.popup_
.dispose();
58 goog
.array
.remove(armadillo
.Actor
.actors_
, this);
63 * @param {int} x The X position to show at
64 * @param {int} y The Y position to show at
66 armadillo
.Actor
.prototype.show
= function(x
, y
) {
67 if (armadillo
.Actor
.isModal())
69 var firstBodyElement
= goog
.dom
.getFirstElementChild(document
.body
);
70 goog
.dom
.insertSiblingBefore(this.element_
, firstBodyElement
);
71 this.popup_
.setPinnedCorner(goog
.positioning
.Corner
.TOP_LEFT
);
72 this.popup_
.setPosition(new goog
.positioning
.ClientPosition(x
, y
));
73 this.popup_
.setVisible(true);
79 armadillo
.Actor
.prototype.hide
= function() {
80 this.popup_
.setVisible(false);
84 * Creates the DOM Element that is inserted into the popup.
87 armadillo
.Actor
.prototype.createElement_
= function() {
88 var root
= goog
.dom
.createDom('div', 'actor');
89 goog
.dom
.setTextContent(root
, 'foo bar');