Re: [Wikitech-l] Callback for mw.toolbar.addButton() executes on edit view load instead of on click

2014-04-23 Thread Krinkle
On 22 Apr 2014, at 02:37, Lego KTM legoktm.wikipe...@gmail.com wrote: On Mon, Apr 21, 2014 at 4:09 PM, Justin Folvarcik jfolvar...@gmail.com wrote: function removeDuplicateLinks(){ .. } if (wgAction == 'edit'){ mw.toolbar.addButton( { imageFile: '

Re: [Wikitech-l] Callback for mw.toolbar.addButton() executes on edit view load instead of on click

2014-04-23 Thread Justin Folvarcik
Am I correct in assuming that adding a check for mw.toolbar will help prevent the code from causing errors when in an edit view without a toolbar? On Wed, Apr 23, 2014 at 7:14 AM, Krinkle krinklem...@gmail.com wrote: On 22 Apr 2014, at 02:37, Lego KTM legoktm.wikipe...@gmail.com wrote: On

Re: [Wikitech-l] Callback for mw.toolbar.addButton() executes on edit view load instead of on click

2014-04-23 Thread Krinkle
Yes, it will ensure the code won't run if that particular toolbar isn't enabled. And it is also a safe guard for backwards compatibility (since the API used to have a different interface), and forwards compatibility (it might change). Usually you wouldn't need such guard and instead use a

Re: [Wikitech-l] Callback for mw.toolbar.addButton() executes on edit view load instead of on click

2014-04-23 Thread Justin Folvarcik
Good to know. Also, I must have read the wrong documentation when I went to use addButton. Not sure where I got that callback parameter from. So instead I just attached an event handler to the button on click, and now it does what I want. Thanks for clearing up the confusion, Krinkle! On Wed,

Re: [Wikitech-l] Callback for mw.toolbar.addButton() executes on edit view load instead of on click

2014-04-22 Thread Erwin Dokter
On 22-04-2014 05:35, Justin Folvarcik wrote: I've tried setting the callback to 'removeDuplicateLinks', removeDuplicateLinks, and I've even tried turning it into an anonymous function bound to a variable, which I then tried to pass as the callback. Am I misusing syntax, here? I have tried

[Wikitech-l] Callback for mw.toolbar.addButton() executes on edit view load instead of on click

2014-04-21 Thread Justin Folvarcik
I'm trying to write a script to remove duplicate links with the click of a button in the toolbar, yet when I set the function as the callback for the button, it runs the function on page load. This is what I've got: function removeDuplicateLinks(){ var box =$('[id^=wpTextbox]'); var text

Re: [Wikitech-l] Callback for mw.toolbar.addButton() executes on edit view load instead of on click

2014-04-21 Thread Lego KTM
On Mon, Apr 21, 2014 at 4:09 PM, Justin Folvarcik jfolvar...@gmail.com wrote: I'm trying to write a script to remove duplicate links with the click of a button in the toolbar, yet when I set the function as the callback for the button, it runs the function on page load. This is what I've got:

Re: [Wikitech-l] Callback for mw.toolbar.addButton() executes on edit view load instead of on click

2014-04-21 Thread Justin Folvarcik
Hi, LegoKTM, I tried your suggestion again, just to be sure, and I can confirm that this still does not load the callback properly. I set the value to callback: removeDuplicateLinks Now it does not load the function at all. On Mon, Apr 21, 2014 at 8:37 PM, Lego KTM