* Don't use an empty array as the default for $toolbar, use false which will throw an exception on a logic error.
* Fix exception handling in mw.loader: have handlePending() rethrow its exception so that the exception handler in execute() can run, so that the exception gets logged. But don't rethrow the exception in execute(), because that may break other modules.
var currentFocused = $( '#wpTextbox1' );
mw.toolbar = {
var currentFocused = $( '#wpTextbox1' );
mw.toolbar = {
// If you want to add buttons, use
// mw.toolbar.addButton( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId, selectText );
addButton : function() {
// If you want to add buttons, use
// mw.toolbar.addButton( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId, selectText );
addButton : function() {
- this.buttons.push( [].slice.call( arguments ) );
+ if ( isReady ) {
+ this.insertButton.apply( this, arguments );
+ } else {
+ this.buttons.push( [].slice.call( arguments ) );
+ }
},
insertButton : function( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId, selectText ) {
var image = $('<img>', {
},
insertButton : function( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId, selectText ) {
var image = $('<img>', {
init : function() {},
onReady : function() {
init : function() {},
onReady : function() {
- mw.toolbar.$toolbar = $( '#toolbar' );
+ this.$toolbar = $( '#toolbar' );
+ isReady = true;
// Legacy
// Merge buttons from mwCustomEditButtons
var buttons = [].concat( this.buttons, window.mwCustomEditButtons );
for ( var i = 0; i < buttons.length; i++ ) {
if ( $.isArray( buttons[i] ) ) {
// Passes our button array as arguments
// Legacy
// Merge buttons from mwCustomEditButtons
var buttons = [].concat( this.buttons, window.mwCustomEditButtons );
for ( var i = 0; i < buttons.length; i++ ) {
if ( $.isArray( buttons[i] ) ) {
// Passes our button array as arguments
- mw.toolbar.insertButton.apply( this, buttons[i] );
+ this.insertButton.apply( this, buttons[i] );
} else {
// Legacy mwCustomEditButtons is an object
var c = buttons[i];
} else {
// Legacy mwCustomEditButtons is an object
var c = buttons[i];
- mw.toolbar.insertButton( c.imageFile, c.speedTip, c.tagOpen, c.tagClose, c.sampleText, c.imageId, c.selectText );
+ this.insertButton( c.imageFile, c.speedTip, c.tagOpen,
+ c.tagClose, c.sampleText, c.imageId, c.selectText );
console.log( 'mw.loader::execute> Exception thrown by ' + module + ': ' + e.message );
}
registry[module].state = 'error';
console.log( 'mw.loader::execute> Exception thrown by ' + module + ': ' + e.message );
}
registry[module].state = 'error';