Skip to content

Commit 5fdad59

Browse files
committed
Updated the Alert and Confirm classes to leverage the alert() and confirm() methods in Utils.js from the javaxt-webcontrols library.
1 parent 6bcb90f commit 5fdad59

File tree

2 files changed

+4
-142
lines changed

2 files changed

+4
-142
lines changed

ui/javascript/widgets/Alert.js

Lines changed: 3 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,10 @@
1-
if(!javaxt) var javaxt={};
2-
if(!javaxt.express) javaxt.express={};
3-
javaxt.express.Alert = null;
41

52
//**************************************************************************
63
//** alert
74
//**************************************************************************
8-
/** Overrides the native javascript alert() method by creating a
9-
* javaxt.express.Alert window.
5+
/** Overrides the native javascript alert() method by creating a custom
6+
* Alert window.
107
*/
118
var alert = function(msg){
12-
13-
if (msg==null) msg = "";
14-
15-
16-
//Special case for ajax request
17-
if (!(typeof(msg) === 'string' || msg instanceof String)){
18-
if (typeof msg.responseText !== 'undefined'){
19-
msg = (msg.responseText.length>0 ? msg.responseText : msg.statusText);
20-
if (!msg) msg = "Unknown Server Error";
21-
}
22-
}
23-
24-
var win = javaxt.express.Alert;
25-
26-
if (!win){
27-
28-
var body = document.getElementsByTagName("body")[0];
29-
30-
31-
var outerDiv = document.createElement('div');
32-
outerDiv.style.width = "100%";
33-
outerDiv.style.height = "100%";
34-
outerDiv.style.position = "relative";
35-
outerDiv.style.cursor = "inherit";
36-
var innerDiv = document.createElement('div');
37-
innerDiv.style.width = "100%";
38-
innerDiv.style.height = "100%";
39-
innerDiv.style.position = "absolute";
40-
innerDiv.style.overflowX = 'hidden';
41-
innerDiv.style.cursor = "inherit";
42-
outerDiv.appendChild(innerDiv);
43-
44-
45-
win = javaxt.express.Alert = new javaxt.dhtml.Window(body, {
46-
width: 450,
47-
height: 200,
48-
valign: "top",
49-
modal: true,
50-
title: "Alert",
51-
body: outerDiv,
52-
style: {
53-
panel: "window",
54-
header: "window-header alert-header",
55-
title: "window-title",
56-
buttonBar: "window-header-button-bar",
57-
button: "window-header-button",
58-
body: "window-body alert-body"
59-
}
60-
});
61-
win.div = innerDiv;
62-
}
63-
64-
65-
win.div.innerHTML = msg;
66-
win.show();
67-
9+
javaxt.dhtml.utils.alert(msg);
6810
};

ui/javascript/widgets/Confirm.js

Lines changed: 1 addition & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
if(!javaxt) var javaxt={};
2-
if(!javaxt.express) javaxt.express={};
3-
javaxt.express.Confirm = null;
41

52
//**************************************************************************
63
//** confirm
@@ -9,83 +6,6 @@ javaxt.express.Confirm = null;
96
* javaxt.express.Confirm window.
107
*/
118
var confirm = function(msg, config){
12-
13-
if (!(typeof(msg) === 'string' || msg instanceof String)){
14-
config = msg;
15-
}
16-
17-
18-
javaxt.dhtml.utils.merge(config, {
19-
title: "Confirm",
20-
text: msg
21-
});
22-
23-
24-
var win = javaxt.express.Confirm;
25-
if (!win){
26-
var body = document.getElementsByTagName("body")[0];
27-
28-
var buttonDiv = document.createElement("div");
29-
buttonDiv.className = "button-div";
30-
31-
var createButton = function(label, result){
32-
var input = document.createElement("input");
33-
input.type = "button";
34-
input.className = "form-button";
35-
input.onclick = function(){
36-
win.result = this.result;
37-
win.close();
38-
};
39-
input.setLabel = function(label){
40-
if (label) this.name = this.value = label;
41-
};
42-
input.setValue = function(b){
43-
if (b===true || b===false) this.result = b;
44-
};
45-
input.update = function(config){
46-
if (config){
47-
this.setLabel(config.label);
48-
this.setValue(config.value);
49-
}
50-
};
51-
input.setLabel(label);
52-
input.setValue(result);
53-
buttonDiv.appendChild(input);
54-
return input;
55-
};
56-
57-
58-
win = javaxt.express.Confirm = new javaxt.dhtml.Window(body, {
59-
width: 450,
60-
height: 150,
61-
valign: "top",
62-
modal: true,
63-
footer: buttonDiv,
64-
style: {
65-
panel: "window",
66-
header: "window-header",
67-
title: "window-title",
68-
buttonBar: "window-header-button-bar",
69-
button: "window-header-button",
70-
body: "window-body confirm-body"
71-
}
72-
});
73-
74-
75-
win.leftButton = createButton("OK", true);
76-
win.rightButton = createButton("Cancel", false);
77-
}
78-
79-
80-
win.setTitle(config.title);
81-
win.setContent(config.text.replace("\n","<p></p>"));
82-
win.leftButton.update(config.leftButton);
83-
win.rightButton.update(config.rightButton);
84-
win.result = false;
85-
win.onClose = function(){
86-
var callback = config.callback;
87-
if (callback) callback.apply(win, [win.result]);
88-
};
89-
win.show();
9+
javaxt.dhtml.utils.confirm(msg, config);
9010
return false;
9111
};

0 commit comments

Comments
 (0)