https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112451
Revision: 112451
Author: tstarling
Date: 2012-02-26 22:46:40 +0000 (Sun, 26 Feb 2012)
Log Message:
-----------
* Fix r111983 (bug 34662): make mw.toolbar.addButton() work even after DOM ready
* 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.
Modified Paths:
--------------
trunk/phase3/resources/mediawiki/mediawiki.js
trunk/phase3/resources/mediawiki.action/mediawiki.action.edit.js
Modified: trunk/phase3/resources/mediawiki/mediawiki.js
===================================================================
--- trunk/phase3/resources/mediawiki/mediawiki.js 2012-02-26 22:25:49 UTC
(rev 112450)
+++ trunk/phase3/resources/mediawiki/mediawiki.js 2012-02-26 22:46:40 UTC
(rev 112451)
@@ -630,6 +630,7 @@
j -= 1;
}
}
+ throw e;
}
}
@@ -785,7 +786,6 @@
console.log(
'mw.loader::execute> Exception thrown by ' + module + ': ' + e.message );
}
registry[module].state = 'error';
- throw e;
}
}
Modified: trunk/phase3/resources/mediawiki.action/mediawiki.action.edit.js
===================================================================
--- trunk/phase3/resources/mediawiki.action/mediawiki.action.edit.js
2012-02-26 22:25:49 UTC (rev 112450)
+++ trunk/phase3/resources/mediawiki.action/mediawiki.action.edit.js
2012-02-26 22:46:40 UTC (rev 112451)
@@ -3,12 +3,17 @@
var currentFocused = $( '#wpTextbox1' );
mw.toolbar = {
- $toolbar : [],
+ $toolbar : false,
buttons : [],
+ isReady : false,
// 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>', {
@@ -42,18 +47,20 @@
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
- mw.toolbar.insertButton.apply( this,
buttons[i] );
+ this.insertButton.apply( this,
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 );
}
}
return true;
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs