https://bugzilla.wikimedia.org/show_bug.cgi?id=31511
Web browser: ---
Bug #: 31511
Summary: Unable to add/remove buttons from (classic) toolbar
from a gadget after MW update
Product: MediaWiki
Version: 1.18
Platform: All
OS/Version: All
Status: NEW
Keywords: javascript
Severity: normal
Priority: Unprioritized
Component: Javascript
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Blocks: 29876
Classification: Unclassified
Since the recent MediaWiki update, the user script
[[User:MarkS/extraeditbuttons.js]] (and its translation
[[pt:MediaWiki:Gadget-Extra-Editbuttons.js]]) is not working anymore.[1][2]
I was trying to fix the Portuguese version and make it into a
ResourceLoader-compatible gadget, but I wasn't capable of restoring its
previous behaviour because it is currently impossible (AFAIK) to force its
function "initButtons()" which depends on "mw.toolbar.addButton()" (from module
"mediawiki.action.edit"[3]) to be executed BEFORE the execution of
"mw.toolbar.init()"[4] BUT AFTER the default buttons[5] are added to the array
"mw.toolbar.buttons"[6] (a replacemente to the legacy
"window.mwCustomEditButtons") by the inline <script> tag in the botton of the
page.
This order is necessary because "initButtons()" needs to be capable to redefine
the content of the array "mw.toolbar.buttons" (adding and/or removing buttons)
before it is used by "mw.toolbar.init()" to insert the listed buttons in the
edit toolbar.
In its current state[7], the extra buttons are being added before the ones from
MediaWiki, and the user can't change the order of (neither remove) the default
MW buttons. This seems to be because those "mw.toolbar.addButton" from
MediaWiki is appending the default elements to the array AFTER it has already
being filled with user defined buttons (how can the user remove something which
is not there yet?).
If I change "initButtons()" to "$(document).ready(initButtons)", then MediaWiki
default buttons are added to the begining of the array and the gadget could
edit the array, but in this case the gadget is executed too late, after
"mw.toolbar.init()" happened, and so any changes made to "mw.toolbar.buttons"
will have no efect in the resulting toolbar.
Please provide some alternative to fix this kind of user scripts which worked
fine previously.
[1]
https://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_%28technical%29&diff=454228426&oldid=454227274&diffonly=1
[2]
https://secure.wikimedia.org/wikipedia/pt/w/index.php?title=Wikip%C3%A9dia%3ACaf%C3%A9_dos_programadores&action=historysubmit&diff=27182215&oldid=27174834
[3]
http://svn.wikimedia.org/viewvc/mediawiki/branches/REL1_18/phase3/resources/mediawiki.action/mediawiki.action.edit.js?view=markup#l8
[4]
http://svn.wikimedia.org/viewvc/mediawiki/branches/REL1_18/phase3/resources/mediawiki.action/mediawiki.action.edit.js?view=markup#l85
[5]
http://svn.wikimedia.org/viewvc/mediawiki/branches/REL1_18/phase3/includes/EditPage.php?view=markup#l2493
[6]
http://svn.wikimedia.org/viewvc/mediawiki/branches/REL1_18/phase3/resources/mediawiki.action/mediawiki.action.edit.js?view=markup#l41
--
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l