Index: trunk/phase3/resources/mediawiki.action/mediawiki.action.edit.js |
— | — | @@ -4,7 +4,13 @@ |
5 | 5 | |
6 | 6 | mw.toolbar = { |
7 | 7 | $toolbar : $( '#toolbar' ), |
8 | | - addButton : function( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId, selectText ) { |
| 8 | + buttons : [], |
| 9 | + // If you want to add buttons, use |
| 10 | + // mw.toolbar.addButton( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId, selectText ); |
| 11 | + addButton : function() { |
| 12 | + this.buttons.push( [].slice.call( arguments ) ); |
| 13 | + }, |
| 14 | + insertButton : function( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId, selectText ) { |
9 | 15 | var image = $('<img>', { |
10 | 16 | width : 23, |
11 | 17 | height : 23, |
— | — | @@ -29,18 +35,21 @@ |
30 | 36 | currentFocused.textSelection( |
31 | 37 | 'encapsulateSelection', { 'pre': tagOpen, 'peri': sampleText, 'post': tagClose } |
32 | 38 | ); |
33 | | - return; |
34 | 39 | } |
35 | 40 | }, |
36 | 41 | init : function() { |
37 | 42 | // Legacy |
38 | | - // Print out buttons from mwCustomEditButtons |
39 | | - // If you want to add buttons, use |
40 | | - // $( document ).ready( function () { mw.toolbar.addButton( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId, selectText ) } ); |
41 | | - var c; |
42 | | - for ( var i = 0; i < window.mwCustomEditButtons.length; i++ ) { |
43 | | - c = window.mwCustomEditButtons[i]; |
44 | | - mw.toolbar.addButton( c.imageFile, c.speedTip, c.tagOpen, c.tagClose, c.sampleText, c.imageId, c.selectText ); |
| 43 | + // Merge buttons from mwCustomEditButtons |
| 44 | + var buttons = [].concat( this.buttons, window.mwCustomEditButtons ); |
| 45 | + for ( var i = 0; i < buttons.length; i++ ) { |
| 46 | + if ( buttons[i] instanceof Array ) { |
| 47 | + // Passes our button array as arguments |
| 48 | + mw.toolbar.insertButton.apply( this, buttons[i] ); |
| 49 | + } else { |
| 50 | + // Legacy mwCustomEditButtons is an object |
| 51 | + var c = buttons[i]; |
| 52 | + mw.toolbar.insertButton( c.imageFile, c.speedTip, c.tagOpen, c.tagClose, c.sampleText, c.imageId, c.selectText ); |
| 53 | + } |
45 | 54 | } |
46 | 55 | return true; |
47 | 56 | } |
— | — | @@ -72,7 +81,10 @@ |
73 | 82 | } |
74 | 83 | }; |
75 | 84 | scrollEditBox(); |
76 | | - |
| 85 | + |
| 86 | + // Create button bar |
| 87 | + mw.toolbar.init(); |
| 88 | + |
77 | 89 | $( '#wpSummary, #wpTextbox1' ).focus( function() { |
78 | 90 | currentFocused = $(this); |
79 | 91 | }); |
Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -2414,9 +2414,8 @@ |
2415 | 2415 | array_map( array( 'Xml', 'encodeJsVar' ), $params ) ); |
2416 | 2416 | $script .= "mw.toolbar.addButton($paramList);\n"; |
2417 | 2417 | } |
2418 | | - $script .= "mw.toolbar.init();\n"; |
2419 | 2418 | $wgOut->addScript( Html::inlineScript( |
2420 | | - "if ( window.mediaWiki ) { jQuery(function(){{$script}}); }" |
| 2419 | + "if ( window.mediaWiki ) {{$script}}" |
2421 | 2420 | ) ); |
2422 | 2421 | |
2423 | 2422 | $toolbar .= "\n</div>"; |