Hello,
I'd like to use custom dialogs and buttons in the WikiEditor
(
https://www.mediawiki.org/wiki/Extension:WikiEditor). The customization are done via code
in the /index.php/MediaWiki:Common.js
I'm having trouble that sometimes my custom module is not added.
At the moment I use time-deferred check-function:
window.setTimeout(checkModule,500)
which than loads a function that checks if the module that defines the custom dialog has
actually been loaded:
var checkModule = function(){
if(!$.wikiEditor.modules.dialogs.modules.mytool){
$( '#wpTextbox1' ).wikiEditor( 'addModule', mytool());
//console.log("postLoad of module was needed!")
}
}
This seems to work fairly well in the real world, but seems rather hacky code wise.
The first attempt to add the module is done in a function which is executed on the jQuery
'wikiEditor-toolbar-doneInitialSections' event. (build-in-event in the current
1.21 Version of Wikieditor):
$( '#wpTextbox1' ).on( 'wikiEditor-toolbar-doneInitialSections',
customExtendEditor
in the customExtendEditor function, the module is defined, and the Module is added (not
always sucessfully):
var mytool = function(){
return { dialogs:{
mytool:{
[etc.]
$( '#wpTextbox1' ).wikiEditor( 'addModule', mytool());
a button is added via ` $('#wpTextbox1').wikiEditor( 'addToToolbar', { …
`
but that never caused me problems itself so far.
If you know a better, less hacky solution than the deferred check and re-addition, please
let me know.
Kind Regards,
Jan
PS.: full code (from my wiki's /index.php/MediaWiki:Common.js):
http://jsfiddle.net/RAHCg/