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.ModalDialog');
12 goog
.require('goog.dom.classes');
13 goog
.require('goog.events.EventHandler');
14 goog
.require('goog.ui.Container');
15 goog
.require('goog.ui.Control');
18 * A modal dialog that does not use iframe masks, but instead installs a global
19 * event listener to prevent events.
20 * @param {goog.ui.DomHelper} opt_domHelper
23 armadillo
.ModalDialog
= function(opt_domHelper
) {
24 goog
.ui
.Container
.call(this, null, null, opt_domHelper
);
29 this.eh_
= new goog
.events
.EventHandler();
31 goog
.inherits(armadillo
.ModalDialog
, goog
.ui
.Container
);
37 armadillo
.ModalDialog
.prototype.disposeInternal
= function() {
38 armadillo
.ModalDialog
.superClass_
.disposeInternal
.call(this);
46 armadillo
.ModalDialog
.prototype.createDom
= function() {
47 this.decorateInternal(this.dom_
.createElement('div'));
53 armadillo
.ModalDialog
.prototype.decorateInternal
= function(element
) {
54 this.element_
= element
;
55 goog
.dom
.classes
.set(this.element_
, 'modalDialog');
57 var close
= new goog
.ui
.Control('Close Modal Dialog');
59 close
.handleMouseDown
= function(e
) {
63 this.addChild(close
, true);
69 armadillo
.ModalDialog
.prototype.enterDocument
= function() {
70 armadillo
.ModalDialog
.superClass_
.enterDocument
.call(this);
71 // Create an event sink that captures all browser event types.
72 var types
= new Array();
73 for (type
in goog
.events
.EventType
) {
74 types
.push(goog
.events
.EventType
[type]);
76 this.eventSinkKey_
= this.eh_
.listen(this.dom_
.getWindow(),
77 types
, this.eventSink_
, true, this);
83 armadillo
.ModalDialog
.prototype.exitDocument
= function() {
84 goog
.events
.unlistenByKey(this.eventSinkKey_
);
85 this.eventSinkKey_
= null;
89 * Every event that gets dispatched to the Window will first be evaluated by
90 * this memeber. If the event's target is not a child of the dialog, the event
92 * @param {Event} event
94 armadillo
.ModalDialog
.prototype.eventSink_
= function(event
) {
95 var target
= event
.target
;
97 if (target
== this.element_
) {
100 target
= target
.parentNode
;
102 event
.stopPropagation();