Index: trunk/phase3/resources/mediawiki.action/mediawiki.action.edit.js |
— | — | @@ -3,12 +3,17 @@ |
4 | 4 | var currentFocused = $( '#wpTextbox1' ); |
5 | 5 | |
6 | 6 | mw.toolbar = { |
7 | | - $toolbar : [], |
| 7 | + $toolbar : false, |
8 | 8 | buttons : [], |
| 9 | + isReady : false, |
9 | 10 | // If you want to add buttons, use |
10 | 11 | // mw.toolbar.addButton( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId, selectText ); |
11 | 12 | addButton : function() { |
12 | | - this.buttons.push( [].slice.call( arguments ) ); |
| 13 | + if ( isReady ) { |
| 14 | + this.insertButton.apply( this, arguments ); |
| 15 | + } else { |
| 16 | + this.buttons.push( [].slice.call( arguments ) ); |
| 17 | + } |
13 | 18 | }, |
14 | 19 | insertButton : function( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId, selectText ) { |
15 | 20 | var image = $('<img>', { |
— | — | @@ -42,18 +47,20 @@ |
43 | 48 | init : function() {}, |
44 | 49 | |
45 | 50 | onReady : function() { |
46 | | - mw.toolbar.$toolbar = $( '#toolbar' ); |
| 51 | + this.$toolbar = $( '#toolbar' ); |
| 52 | + isReady = true; |
47 | 53 | // Legacy |
48 | 54 | // Merge buttons from mwCustomEditButtons |
49 | 55 | var buttons = [].concat( this.buttons, window.mwCustomEditButtons ); |
50 | 56 | for ( var i = 0; i < buttons.length; i++ ) { |
51 | 57 | if ( $.isArray( buttons[i] ) ) { |
52 | 58 | // Passes our button array as arguments |
53 | | - mw.toolbar.insertButton.apply( this, buttons[i] ); |
| 59 | + this.insertButton.apply( this, buttons[i] ); |
54 | 60 | } else { |
55 | 61 | // Legacy mwCustomEditButtons is an object |
56 | 62 | var c = buttons[i]; |
57 | | - mw.toolbar.insertButton( c.imageFile, c.speedTip, c.tagOpen, c.tagClose, c.sampleText, c.imageId, c.selectText ); |
| 63 | + this.insertButton( c.imageFile, c.speedTip, c.tagOpen, |
| 64 | + c.tagClose, c.sampleText, c.imageId, c.selectText ); |
58 | 65 | } |
59 | 66 | } |
60 | 67 | return true; |
Index: trunk/phase3/resources/mediawiki/mediawiki.js |
— | — | @@ -630,6 +630,7 @@ |
631 | 631 | j -= 1; |
632 | 632 | } |
633 | 633 | } |
| 634 | + throw e; |
634 | 635 | } |
635 | 636 | } |
636 | 637 | |
— | — | @@ -785,7 +786,6 @@ |
786 | 787 | console.log( 'mw.loader::execute> Exception thrown by ' + module + ': ' + e.message ); |
787 | 788 | } |
788 | 789 | registry[module].state = 'error'; |
789 | | - throw e; |
790 | 790 | } |
791 | 791 | } |
792 | 792 | |