1
function POPUP(cb, cbattr) {
2
this.popup_states = new Array();
3
this.popup_callback = new Array();
4
this.popup_rewidth_callback = new Array();
5
this.popup_on_callbacks = new Array();
6
this.popup_off_callbacks = new Array();
7
this.current_height = new Array();
8
this.popups = new Array();
9
this.popups_width = 300;
12
if (typeof cb != "undefined") this.RegisterCallback(cb,cbattr);
15
POPUP.prototype.RegisterOnCallback = function (module, cb, cbattr, call_once) {
16
if (typeof this.popup_on_callbacks[module] == "undefined")
17
this.popup_on_callbacks[module] = new Array();
19
if (typeof call_once == "undefined") call_once = false;
21
this.popup_on_callbacks[module].push({ 'cb': cb, 'cbattr': cbattr, 'once': call_once });
24
POPUP.prototype.RegisterOffCallback = function(module, cb, cbattr) {
25
if (typeof this.popup_off_callbacks[module] == "undefined")
26
this.popup_off_callbacks[module] = new Array();
28
this.popup_off_callbacks[module].push({ 'cb': cb, 'cbattr': cbattr });
31
POPUP.prototype.RegisterCallback = function(cb, cbattr) {
32
this.popup_callback.push ({ 'cb': cb, 'cbattr': cbattr });
35
POPUP.prototype.RegisterReWidthCallback = function(cb, cbattr) {
36
this.popup_rewidth_callback.push ({ 'cb': cb, 'cbattr': cbattr });
39
POPUP.prototype.GetEncompasingNode = function(node) {
40
// return node.parentNode.parentNode.parentNode.parentNode.parentNode;
41
return node.parentNode.parentNode.parentNode.parentNode;
44
POPUP.prototype.RunReWidthCallbacksFunction = function(self) {
46
for (var i = 0; i < self.popup_rewidth_callback.length; i++) {
47
var cb = self.popup_rewidth_callback[i];
53
POPUP.prototype.RunReWidthCallbacks = function() {
54
setTimeout(this.RunReWidthCallbacksFunction(this), adei.cfg.parse_delay);
58
POPUP.prototype.UpdateGeometry = function(module) {
60
var node = document.getElementById("popup_" + module);
61
var switch_node = document.getElementById("popup_switch_" + module);
63
/* Table fills not all available space, we can't fix it by width
64
attribute in HTML since it will prevent hiding. So, fixing here */
65
var tbl_node = this.GetEncompasingNode(node);
68
var cur_width_value = tbl_node.offsetWidth;
70
if (cur_width_value > this.popups_width) {
71
this.popups_width = cur_width_value;
73
// for (var popup in this.popup_states) {
74
for (var i = 0; i < this.popups.length; i++) {
75
var popup = this.popups[i];
76
if (this.popup_states[popup]) {
77
var popup_node = document.getElementById("popup_" + popup);
78
var popup_tbl_node = this.GetEncompasingNode(node);
80
// if (popup_tbl_node.offsetWidth < this.popups_width) {
81
domSetMinWidth(popup_node, this.popups_width, false, popup_tbl_node.parentNode);
87
if (this.num_opened) { /* otherwise calling in Open */
88
this.RunReWidthCallbacks();
90
} else if (cur_width_value < this.popups_width) {
91
domSetMinWidth(node, this.popups_width, false, tbl_node.parentNode);
95
if ((node)&&(switch_node)) {
96
var a = switch_node.getElementsByTagName("button")[0];
98
var new_height_value = node.parentNode.offsetHeight; // td
99
if (!this.current_height[module]) this.current_height[module] = a.offsetHeight;
101
if (this.current_height[module] < new_height_value) {
102
this.current_height[module] = new_height_value;
103
domSetMinHeight(a, new_height_value, false, a.parentNode); //td checking
111
POPUP.prototype.Switch = function (module) {
113
if (typeof this.popup_states[module] == "undefined") {
114
this.popup_states[module] = 0;
115
this.popups.push(module);
118
if (popup_states[module]) {
119
domHide("popup_" + module);
120
popup_states[module] = 0;
122
if (typeof this.popup_off_callbacks[module] != "undefined") {
123
for (var i = 0; i < this.popup_off_callbacks[module].length; i++) {
124
var cb = this.popup_off_callbacks[module][i];
125
cb.cb(cb.cbattr, false);
131
if (!this.num_opened) this.RunReWidthCallbacks();
133
domShow("popup_" + module);
134
this.UpdateGeometry(module);
135
popup_states[module] = 1;
137
if (typeof this.popup_on_callbacks[module] != "undefined") {
138
for (var i = 0; i < this.popup_on_callbacks[module].length; i++) {
139
var cb = this.popup_on_callbacks[module][i];
140
cb.cb(cb.cbattr, true);
142
this.popup_on_callbacks[module].splice(i,1);
150
if (!this.num_opened) this.RunReWidthCallbacks();
154
for (var i = 0; i < popup_callback.length; i++) {
155
var cb = popup_callback[i];
161
function popupUpdateGeometryCallback(me, submodule) {
162
me.popup.UpdateGeometry(me.module);