Roundcube Community Forum

Miscellaneous => Roundcube Discussion => Topic started by: pratik_1712 on February 07, 2011, 02:42:55 AM

Title: Compose Window Javascript Function
Post by: pratik_1712 on February 07, 2011, 02:42:55 AM
I want a function to be executed every time the compose window loads up..
I am using the following code but unable to link it to the desired event..

Kindly guide which event to hook up to..??


// In the Plugin
public $task = 'mail';
function init() {
$rcmail = rcmail::get_instance();
if (($rcmail->task == 'mail') && ($rcmail->action == 'compose')) {
$this->include_script('myscript.js');
}
}




document.onLoad = myfunc();

function myfunc()
{
alert('works');
var link = document.createElement('a');
link.setAttribute('href', '#');
link.setAttribute('title','Something');
document.getElementById('messagetoolbar').appendChild(link);
}


This is just coz i am not sure which event to call up..
I tried with 'init' but that didn't worked..

I am looking to add a label or button in the toolbar..

Any help is appreciated..

Thanks and Regards,
Pratik
Title: Compose Window Javascript Function
Post by: rosali on February 07, 2011, 02:51:36 AM
Look into compose_addressbook plugin.

Roundcube Plugins | Underwater World (http://underwa.ter.net/roundcube-plugins/)
Title: Compose Window Javascript Function
Post by: pratik_1712 on February 07, 2011, 04:05:27 AM
Thanks a lot.. thats exactly what i needed..
Regards,
Pratik
Title: Compose Window Javascript Function
Post by: pratik_1712 on February 07, 2011, 04:19:14 AM

$this->add_button(array(
'command' => 'mycommand',
'label' => 'mylabel',
'title' => 'mytitle,
'id' => 'rcmbtn_compose_myid'), 'toolbar');


On the UI the lable value is coming in the [] brackets..
How to remove them..??


[mylabel]


This is the HTML being generated..
I want innerHTML without brackets..
Title: Compose Window Javascript Function
Post by: rosali on February 07, 2011, 04:39:57 AM
Brackets indicate that the label is undefined in the plugin localization.
Title: Compose Window Javascript Function
Post by: pratik_1712 on February 07, 2011, 04:51:08 AM
thanks.. was happening due to a typo with the name in localization..
Fixed it..