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.File');
12 goog
.require('goog.Disposable');
13 goog
.require('goog.dom');
16 * A file in a directory listing.
17 * @param {string} File name.
20 armadillo
.File
= function(name
) {
21 goog
.Disposable
.call(this);
23 this.isDirectory_
= app
.isDirectory(name
);
25 goog
.inherits(armadillo
.File
, goog
.Disposable
);
31 goog
.Disposable
.prototype.disposeInternal
= function() {
32 armadillo
.File
.superClass_
.disposeInternal
.call(this);
34 goog
.events
.unlistenByKey(this.clickListener_
);
38 * Constructs the Elements that make up the UI.
39 * @returns {Element} An element ready for insertion into DOM.
41 armadillo
.File
.prototype.draw
= function() {
43 this.element_
= goog
.dom
.createElement('li');
44 this.element_
.representedObject
= this;
45 this.clickListener_
= goog
.events
.listen(this.element_
,
46 goog
.events
.EventType
.CLICK
, this.clickHandler_
, false, this);
48 goog
.dom
.removeChildren(this.element_
);
49 goog
.dom
.setTextContent(this.element_
, this.name_
);
54 * Click handler for the ist element.
57 armadillo
.File
.prototype.clickHandler_
= function(e
) {
58 if (this.isDirectory_
) {
59 app
.navigate(this.name_
);