42 lines
No EOL
939 B
JavaScript
42 lines
No EOL
939 B
JavaScript
function Dialogue(data) {
|
|
// Define the parent element
|
|
this.parent = data.parent;
|
|
|
|
// Define default values
|
|
var def = {
|
|
width: 400,
|
|
height: 300,
|
|
canclose: true
|
|
};
|
|
|
|
// Create the dialogue element
|
|
this.ctrl = document.createElement("div");
|
|
with (this.ctrl) {
|
|
style.position = "absolute";
|
|
style.width = data.width != null ? data.width : def.width;
|
|
style.height = data.height != null ? data.height : def.height;
|
|
}
|
|
|
|
//Create the close button element
|
|
this.ctrl_close = document.createElement("button");
|
|
with (this.ctrl_close) {
|
|
style.width = 25;
|
|
style.height = 25;
|
|
style.display = data.canclose == true ? "none" : "initial";
|
|
}
|
|
|
|
// Add event listeners to the parent
|
|
this.parent.addEventListener("open", function() {
|
|
this.parent.onOpen();
|
|
}, false);
|
|
|
|
this.parent.addEventListener("close", function() {
|
|
this.parent.onClose();
|
|
}, false);
|
|
}
|
|
|
|
Dialogue.prototype.open = function() {
|
|
this.ctrl.show();
|
|
|
|
|
|
} |