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.events.EventHandler');
13 goog
.require('goog.ui.Container');
14 goog
.require('goog.ui.Control');
17 * A modal dialog that does not use iframe masks, but instead installs a global
18 * event listener to prevent events.
19 * @param {goog.ui.DomHelper} opt_domHelper
22 armadillo
.ModalDialog
= function(opt_domHelper
) {
23 goog
.ui
.Container
.call(this, null, null, opt_domHelper
);
28 this.eh_
= new goog
.events
.EventHandler();
30 goog
.inherits(armadillo
.ModalDialog
, goog
.ui
.Container
);
36 armadillo
.ModalDialog
.prototype.disposeInternal
= function() {
37 armadillo
.ModalDialog
.superClass_
.disposeInternal
.call(this);
45 armadillo
.ModalDialog
.prototype.createDom
= function() {
46 this.decorateInternal(this.dom_
.createElement('div'));
52 armadillo
.ModalDialog
.prototype.decorateInternal
= function(element
) {
53 this.element_
= element
;
55 var close
= new goog
.ui
.Control('Close Modal Dialog');
57 close
.handleMouseDown
= function(e
) {
61 this.addChild(close
, true);
67 armadillo
.ModalDialog
.prototype.enterDocument
= function() {
68 armadillo
.ModalDialog
.superClass_
.enterDocument
.call(this);
69 // Create an event sink that captures all browser event types.
70 var types
= new Array();
71 for (type
in goog
.events
.EventType
) {
72 types
.push(goog
.events
.EventType
[type]);
74 this.eventSinkKey_
= this.eh_
.listen(this.dom_
.getWindow(),
75 types
, this.eventSink_
, true, this);
81 armadillo
.ModalDialog
.prototype.exitDocument
= function() {
82 goog
.events
.unlistenByKey(this.eventSinkKey_
);
83 this.eventSinkKey_
= null;
87 * Every event that gets dispatched to the Window will first be evaluated by
88 * this memeber. If the event's target is not a child of the dialog, the event
90 * @param {Event} event
92 armadillo
.ModalDialog
.prototype.eventSink_
= function(event
) {
93 var target
= event
.target
;
95 if (target
== this.element_
) {
98 target
= target
.parentNode
;
100 event
.stopPropagation();