r79573 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79572‎ | r79573 | r79574 >
Date:12:53, 4 January 2011
Author:catrope
Status:ok
Tags:
Comment:
WikiEditor: Fix templateEditor dialogs, which were broken by lazy creation in the dialogs module, by allowing them to specify they need immediate creation. Also add a few missing var keywords and explicitly pass a variable that was previously passed by accident because it leaked into the global scope without the var on it.
Modified paths:
  • /trunk/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/jquery.wikiEditor.templateEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.templateEditor.js
@@ -319,6 +319,7 @@
320320 $(this).text( mediaWiki.msg( $(this).attr( 'rel' ) ) );
321321 } );
322322 },
 323+ immediateCreate: true,
323324 dialog: {
324325 width: 600,
325326 height: 400,
Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js
@@ -42,7 +42,7 @@
4343 var mod = $.wikiEditor.modules.dialogs.modules[module];
4444 var $dialog = $( '#' + mod.id );
4545 if ( $dialog.length == 0 ) {
46 - $.wikiEditor.modules.dialogs.fn.reallyCreate( context, mod );
 46+ $.wikiEditor.modules.dialogs.fn.reallyCreate( context, mod, module );
4747 $dialog = $( '#' + mod.id );
4848 }
4949
@@ -72,7 +72,7 @@
7373 */
7474 create: function( context, config ) {
7575 // Defer building of modules, but do check whether they need the iframe rightaway
76 - for ( mod in config ) {
 76+ for ( var mod in config ) {
7777 var module = config[mod];
7878 // Only create the dialog if it's supported, isn't filtered and doesn't exist yet
7979 var filtered = false;
@@ -91,6 +91,10 @@
9292 context.fn.setupIframe();
9393 }
9494 context.$textarea.trigger( 'wikiEditor-dialogs-setup-' + mod );
 95+ // If this dialog requires immediate creation, create it now
 96+ if ( typeof module.immediateCreate !== 'undefined' && module.immediateCreate ) {
 97+ $.wikiEditor.modules.dialogs.fn.reallyCreate( context, module, mod );
 98+ }
9599 }
96100 }
97101 },
@@ -98,8 +102,9 @@
99103 * Build the actual dialog. This done on-demand rather than in create()
100104 * @param {Object} context Context object of editor dialog belongs to
101105 * @param {Object} module Dialog module object
 106+ * @param {String} name Dialog name (key in $.wikiEditor.modules.dialogs.modules)
102107 */
103 - reallyCreate: function( context, module ) {
 108+ reallyCreate: function( context, module, name ) {
104109 var configuration = module.dialog;
105110 // Add some stuff to configuration
106111 configuration.bgiframe = true;
@@ -110,7 +115,7 @@
111116 // Stupid JS won't let us do stuff like
112117 // foo = { mediaWiki.msg( 'bar' ): baz }
113118 configuration.newButtons = {};
114 - for ( msg in configuration.buttons )
 119+ for ( var msg in configuration.buttons )
115120 configuration.newButtons[mediaWiki.msg( msg )] = configuration.buttons[msg];
116121 configuration.buttons = configuration.newButtons;
117122 // Create the dialog <div>
@@ -137,7 +142,7 @@
138143 } );
139144
140145 // Let the outside world know we set up this dialog
141 - context.$textarea.trigger( 'wikiEditor-dialogs-loaded-' + mod );
 146+ context.$textarea.trigger( 'wikiEditor-dialogs-loaded-' + name );
142147 },
143148 /**
144149 * Resize a dialog so its contents fit

Follow-up revisions

RevisionCommit summaryAuthorDate
r798131.17: MFT r78093, r79245, r79570, r79571, r79573, r79574, r79581, r79582, r79...catrope13:20, 7 January 2011

Status & tagging log