1
var currnet_module = null;
2
var module_callback = null;
4
function MODULE(name, callback, callback_attr) {
5
if (typeof callback == "undefined") callback = null;
6
if (typeof callback_attr == "undefined") callback_attr = null;
8
this.module_name = name;
9
this.current_module = null;
10
this.module_callback = callback;
11
this.attr = callback_attr;
13
this.module_height = 0;
15
this.module = new Array();
16
this.names = new Array();
17
this.geometry_callback = new Array();
21
MODULE.prototype.Register = function(module, module_class) {
23
this.names.push(module);
24
this.module[module] = module_class;
30
MODULE.prototype.RegisterCallback = function(callback, callback_attr) {
31
this.module_callback = callback;
32
this.attr = callback_attr;
35
MODULE.prototype.RegisterGeometryCallback = function(cb, cbattr) {
36
this.geometry_callback.push ({ 'cb': cb, 'cbattr': cbattr });
40
MODULE.prototype.GetModule = function(m) {
41
return this.module[m];
44
MODULE.prototype.GetOpenModule = function() {
45
if (this.current_module)
46
return this.GetModule(this.current_module);
51
MODULE.prototype.SetCurrent = function(module) {
53
if (module.length > 0) {
54
current_module = module;
56
} else current_module = null;
61
MODULE.prototype.Open = function(mod) {
64
if (mod != this.current_module) {
65
this.UpdateGeometry(); // Updating just current height
67
if (this.module_name) prefix = this.module_name + "_";
70
if (this.current_module) {
71
domHide("module_" + prefix + this.current_module);
72
cssSetClass("module_link_" + prefix + this.current_module, "module_" + prefix + "link");
74
domShow("module_" + prefix + mod);
75
cssSetClass("module_link_" + prefix + mod, "module_" + prefix + "link_current");
78
this.current_module = mod;
80
if (this.module_callback) this.module_callback(this.attr, this.current_module);
81
this.UpdateGeometry();
87
MODULE.prototype.RunGeometryCallbacks = function() {
88
for (var i = 0; i < this.geometry_callback.length; i++) {
89
var cb = this.geometry_callback[i];
95
The problem: offsetHeight includes 'borders' and style.heigh - not. So insert
96
borders inside of the main divs.
98
MODULE.prototype.UpdateGeometry = function() {
100
if (module_name) prefix = module_name + "_";
103
var node = document.getElementById("module_" + prefix + current_module);
105
var cur_height_value = node.offsetHeight;
108
if (node.scrollHeight) {
109
var full_height = node.scrollHeight;
110
if (full_height > cur_height_value) {
111
if (full_height > module_height) {
112
module_height = full_height;
115
cur_height_value = 0;
119
if (cur_height_value > module_height) {
120
module_height = cur_height_value;
122
// We still should increase, window so it could not be decreased back
123
domSetMinHeight(node, module_height);
125
this.RunGeometryCallbacks();
126
} else if (module_height > 0) {
127
domSetMinHeight(node, module_height);
128
this.RunGeometryCallbacks();
136
var default_module = new MODULE(null);
138
function moduleSetCurrent(module) {
139
default_module.SetCurrent(module);
142
function moduleOpen(module) {
143
default_module.Open(module);
146
function moduleUpdateGeometry(module) {
147
module.UpdateGeometry();
151
function moduleGetElement(module, mclass_name) {
152
if (typeof mclass_name == "undefined") prefix = "";
153
else prefix = mclass_name + "_";
155
return document.getElementById("module_" + prefix + module);