Initialize GUI objects which are added after init

release-0.7
thomascube 13 years ago
parent bd3891145b
commit e639c5da21

@ -86,12 +86,15 @@ function rcube_webmail()
if (over) button_prop.over = over;
this.buttons[command].push(button_prop);
if (this.loaded)
init_button(command, button_prop);
};
// register a specific gui object
this.gui_object = function(name, id)
{
this.gui_objects[name] = id;
this.gui_objects[name] = this.loaded ? rcube_find_object(id) : id;
};
// register a container object
@ -4916,6 +4919,34 @@ function rcube_webmail()
/********* GUI functionality *********/
/*********************************************************/
var init_button = function(cmd, prop)
{
var elm = document.getElementById(prop.id);
if (!elm)
return;
var preload = false;
if (prop.type == 'image') {
elm = elm.parentNode;
preload = true;
}
elm._command = cmd;
elm._id = prop.id;
if (prop.sel) {
elm.onmousedown = function(e){ return rcmail.button_sel(this._command, this._id); };
elm.onmouseup = function(e){ return rcmail.button_out(this._command, this._id); };
if (preload)
new Image().src = prop.sel;
}
if (prop.over) {
elm.onmouseover = function(e){ return rcmail.button_over(this._command, this._id); };
elm.onmouseout = function(e){ return rcmail.button_out(this._command, this._id); };
if (preload)
new Image().src = prop.over;
}
};
// enable/disable buttons for page shifting
this.set_page_buttons = function()
{
@ -4931,31 +4962,7 @@ function rcube_webmail()
continue;
for (var i=0; i< this.buttons[cmd].length; i++) {
var prop = this.buttons[cmd][i];
var elm = document.getElementById(prop.id);
if (!elm)
continue;
var preload = false;
if (prop.type == 'image') {
elm = elm.parentNode;
preload = true;
}
elm._command = cmd;
elm._id = prop.id;
if (prop.sel) {
elm.onmousedown = function(e){ return rcmail.button_sel(this._command, this._id); };
elm.onmouseup = function(e){ return rcmail.button_out(this._command, this._id); };
if (preload)
new Image().src = prop.sel;
}
if (prop.over) {
elm.onmouseover = function(e){ return rcmail.button_over(this._command, this._id); };
elm.onmouseout = function(e){ return rcmail.button_out(this._command, this._id); };
if (preload)
new Image().src = prop.over;
}
init_button(cmd, this.buttons[cmd][i]);
}
}
};
@ -5568,7 +5575,7 @@ function rcube_webmail()
var base = this.env.comm_path;
// overwrite task name
if (query._action.match(/([a-z]+)\/([a-z-_]+)/)) {
if (query._action.match(/([a-z]+)\/([a-z-_.]+)/)) {
query._action = RegExp.$2;
base = base.replace(/\_task=[a-z]+/, '_task='+RegExp.$1);
}

Loading…
Cancel
Save