mw.toolbar = {
$toolbar : $( '#toolbar' ),
- addButton : function( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId, selectText ) {
+ buttons : [],
+ // 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 ) );
+ },
+ insertButton : function( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId, selectText ) {
var image = $('<img>', {
width : 23,
height : 23,
currentFocused.textSelection(
'encapsulateSelection', { 'pre': tagOpen, 'peri': sampleText, 'post': tagClose }
);
- return;
}
},
init : function() {
// Legacy
- // Print out buttons from mwCustomEditButtons
- // If you want to add buttons, use
- // $( document ).ready( function () { mw.toolbar.addButton( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId, selectText ) } );
- var c;
- for ( var i = 0; i < window.mwCustomEditButtons.length; i++ ) {
- c = window.mwCustomEditButtons[i];
- mw.toolbar.addButton( c.imageFile, c.speedTip, c.tagOpen, c.tagClose, c.sampleText, c.imageId, c.selectText );
+ // Merge buttons from mwCustomEditButtons
+ var buttons = [].concat( this.buttons, window.mwCustomEditButtons );
+ for ( var i = 0; i < buttons.length; i++ ) {
+ if ( buttons[i] instanceof Array ) {
+ // Passes our button array as arguments
+ mw.toolbar.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 );
+ }
}
return true;
}
}
};
scrollEditBox();
-
+
+ // Create button bar
+ mw.toolbar.init();
+
$( '#wpSummary, #wpTextbox1' ).focus( function() {
currentFocused = $(this);
});