Author Topic: Compose Window Javascript Function  (Read 6235 times)

Offline pratik_1712

  • Jr. Member
  • **
  • Posts: 43
Compose Window Javascript Function
« 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..??

Code: [Select]

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


Code: [Select]


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

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
Compose Window Javascript Function
« Reply #1 on: February 07, 2011, 02:51:36 AM »
Look into compose_addressbook plugin.

Roundcube Plugins | Underwater World
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline pratik_1712

  • Jr. Member
  • **
  • Posts: 43
Compose Window Javascript Function
« Reply #2 on: February 07, 2011, 04:05:27 AM »
Thanks a lot.. thats exactly what i needed..
Regards,
Pratik

Offline pratik_1712

  • Jr. Member
  • **
  • Posts: 43
Compose Window Javascript Function
« Reply #3 on: February 07, 2011, 04:19:14 AM »
Code: [Select]

$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..??

Code: [Select]

[mylabel]


This is the HTML being generated..
I want innerHTML without brackets..

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
Compose Window Javascript Function
« Reply #4 on: February 07, 2011, 04:39:57 AM »
Brackets indicate that the label is undefined in the plugin localization.
« Last Edit: February 07, 2011, 05:04:32 AM by rosali »
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline pratik_1712

  • Jr. Member
  • **
  • Posts: 43
Compose Window Javascript Function
« Reply #5 on: February 07, 2011, 04:51:08 AM »
thanks.. was happening due to a typo with the name in localization..
Fixed it..