r73150 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73149‎ | r73150 | r73151 >
Date:21:11, 16 September 2010
Author:tparscal
Status:ok (Comments)
Tags:
Comment:
This extension now functions. iframe dependendt modules need more work still.
Modified paths:
  • /trunk/extensions/WikiEditor/WikiEditor.hooks.php (modified) (history)
  • /trunk/extensions/WikiEditor/WikiEditor.i18n.php (modified) (history)
  • /trunk/extensions/WikiEditor/WikiEditor.php (modified) (history)
  • /trunk/extensions/WikiEditor/modules/jquery.wikiEditor.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toc.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/wikiEditor.dialogs.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/wikiEditor.toc.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/wikiEditor.toolbar.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiEditor/WikiEditor.php
@@ -16,17 +16,17 @@
1717 /* Configuration */
1818
1919 // Each module may be configured individually to be globally on/off or user preference based
20 -$wgWikiEditorModules = array(
21 - // Order is significant: makes beta prefs appear before labs prefs
 20+$wgWikiEditorFeatures = array(
 21+ 'addMediaWizard' => array( 'global' => false, 'user' => false ),
 22+ 'dialogs' => array( 'global' => false, 'user' => true ),
 23+ 'highlight' => array( 'global' => false, 'user' => true ),
2224 'toolbar' => array( 'global' => false, 'user' => true ),
23 - 'highlight' => array( 'global' => false, 'user' => true ),
2425 'preview' => array( 'global' => false, 'user' => true ),
2526 'previewDialog' => array( 'global' => false, 'user' => true ),
2627 'publish' => array( 'global' => false, 'user' => true ),
27 - 'toc' => array( 'global' => false, 'user' => true ),
2828 'templateEditor' => array( 'global' => false, 'user' => true ),
2929 'templates' => array( 'global' => false, 'user' => true ),
30 - 'addMediaWizard' => array( 'global' => false, 'user' => false ),
 30+ 'toc' => array( 'global' => false, 'user' => true ),
3131 );
3232
3333 // Bump this each time you change an icon without renaming it
@@ -44,7 +44,7 @@
4545 );
4646 $wgAutoloadClasses['WikiEditorHooks'] = dirname( __FILE__ ) . '/WikiEditor.hooks.php';
4747 $wgExtensionMessagesFiles['WikiEditor'] = dirname( __FILE__ ) . '/WikiEditor.i18n.php';
48 -$wgHooks['BeforePageDisplay'][] = 'WikiEditorHooks::beforePageDisplay';
 48+$wgHooks['EditPage::showEditForm:initial'][] = 'WikiEditorHooks::editPageShowEditFormInitial';
4949 $wgHooks['GetPreferences'][] = 'WikiEditorHooks::getPreferences';
5050 $wgHooks['MakeGlobalVariablesScript'][] = 'WikiEditorHooks::makeGlobalVariablesScript';
5151 $wgHooks['ResourceLoaderRegisterModules'][] = 'WikiEditorHooks::resourceLoaderRegisterModules';
Index: trunk/extensions/WikiEditor/WikiEditor.hooks.php
@@ -10,7 +10,7 @@
1111
1212 /* Static Members */
1313
14 - static $resources = array(
 14+ static $modules = array(
1515
1616 /* WikiEditor jQuery plugin Resources */
1717
@@ -18,8 +18,12 @@
1919 'scripts' => 'extensions/WikiEditor/modules/jquery.wikiEditor.js',
2020 'styles' => 'extensions/WikiEditor/modules/jquery.wikiEditor.css',
2121 'dependencies' => array(
22 - 'jquery.client',
 22+ 'jquery.client', 'jquery.textSelection', 'jquery.delayedBind'
2323 ),
 24+ 'messages' => array(
 25+ 'wikieditor-wikitext-tab',
 26+ 'wikieditor-loading',
 27+ ),
2428 ),
2529 'jquery.wikiEditor.dialogs' => array(
2630 'scripts' => 'extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js',
@@ -99,39 +103,42 @@
100104 'scripts' => 'extensions/WikiEditor/modules/wikiEditor.dialogs.js',
101105 'styles' => 'extensions/WikiEditor/modules/wikiEditor.dialogs.css',
102106 'dependencies' => array(
103 - 'jquery.wikiEditor.dialogs',
 107+ 'wikiEditor', 'jquery.wikiEditor.dialogs', 'jquery.suggestions',
104108 ),
105109 ),
106110 'wikiEditor.highlight' => array(
107111 'scripts' => 'extensions/WikiEditor/modules/wikiEditor.highlight.js',
108112 'dependencies' => array(
109 - 'jquery.wikiEditor.highlight',
 113+ 'wikiEditor', 'jquery.wikiEditor.highlight',
110114 ),
111115 ),
112116 'wikiEditor.preview' => array(
113117 'scripts' => 'extensions/WikiEditor/modules/wikiEditor.preview.js',
 118+ 'dependencies' => array(
 119+ 'wikiEditor', 'jquery.wikiEditor.preview',
 120+ ),
114121 'messages' => array(
115122 'wikieditor-preview-tab',
116123 'wikieditor-preview-changes-tab',
117124 'wikieditor-preview-loading',
118125 ),
119 - 'dependencies' => array(
120 - 'jquery.wikiEditor.preview',
121 - ),
122126 ),
123127 'wikiEditor.previewDialog' => array(
124128 'scripts' => 'extensions/WikiEditor/modules/wikiEditor.previewDialog.js',
 129+ 'dependencies' => array(
 130+ 'wikiEditor', 'jquery.wikiEditor.previewDialog',
 131+ ),
125132 'messages' => array(
126133 'wikieditor-previewDialog-preference',
127134 'wikieditor-previewDialog-tab',
128135 'wikieditor-previewDialog-loading',
129136 ),
130 - 'dependencies' => array(
131 - 'jquery.wikiEditor.preivewDialog',
132 - ),
133137 ),
134138 'wikiEditor.publish' => array(
135139 'scripts' => 'extensions/WikiEditor/modules/wikiEditor.publish.js',
 140+ 'dependencies' => array(
 141+ 'wikiEditor', 'jquery.wikiEditor.publish',
 142+ ),
136143 'messages' => array(
137144 'wikieditor-publish-button-publish',
138145 'wikieditor-publish-button-cancel',
@@ -142,39 +149,39 @@
143150 'wikieditor-publish-dialog-publish',
144151 'wikieditor-publish-dialog-goback',
145152 ),
146 - 'dependencies' => array(
147 - 'jquery.wikiEditor.publish',
148 - ),
149153 ),
150154 'wikiEditor.templateEditor' => array(
151155 'scripts' => 'extensions/WikiEditor/modules/wikiEditor.templateEditor.js',
 156+ 'dependencies' => array(
 157+ 'wikiEditor', 'jquery.wikiEditor.templateEditor',
 158+ ),
152159 'messages' => array(
153160 'wikieditor-template-editor-dialog-title',
154161 'wikieditor-template-editor-dialog-submit',
155162 'wikieditor-template-editor-dialog-cancel',
156163 ),
157 - 'dependencies' => array(
158 - 'jquery.wikiEditor.templateEditor',
159 - ),
160164 ),
161165 'wikiEditor.templates' => array(
162166 'scripts' => 'extensions/WikiEditor/modules/wikiEditor.templates.js',
163167 'dependencies' => array(
164 - 'jquery.wikiEditor.templates',
 168+ 'wikiEditor', 'jquery.wikiEditor.templates',
165169 ),
166170 ),
167171 'wikiEditor.toc' => array(
168172 'scripts' => 'extensions/WikiEditor/modules/wikiEditor.toc.js',
 173+ 'dependencies' => array(
 174+ 'wikiEditor', 'jquery.wikiEditor.toc',
 175+ ),
169176 'messages' => array(
170177 'wikieditor-toc-show',
171178 'wikieditor-toc-hide',
172179 ),
173 - 'dependencies' => array(
174 - 'jquery.wikiEditor.toc',
175 - ),
176180 ),
177181 'wikiEditor.toolbar' => array(
178182 'scripts' => 'extensions/WikiEditor/modules/wikiEditor.toolbar.js',
 183+ 'dependencies' => array(
 184+ 'wikiEditor', 'jquery.wikiEditor.toolbar', 'jquery.cookie', 'jquery.async',
 185+ ),
179186 'messages' => array(
180187 // This is a mixed bunch that needs to be separated between dialog and toolbar messages, but since the
181188 // dialog module depends on the toolbar module, it's not an urgent matter
@@ -371,181 +378,227 @@
372379 'wikieditor-toolbar-help-content-indent-syntax',
373380 'wikieditor-toolbar-help-content-indent-result',
374381 ),
375 - 'dependencies' => array(
376 - 'jquery.wikiEditor.toolbar',
377 - ),
378382 ),
379383 );
380384
381 - static $modules = array(
 385+ static $features = array(
 386+
 387+ /* Special features; not listed in $wgWikiEditorFeatures thus always enabled */
 388+
382389 'global' => array(
383 - 'variables' => array(
 390+ 'configurations' => array(
384391 'wgWikiEditorIconVersion',
385392 ),
386393 ),
 394+
 395+ /* Beta Features */
 396+
 397+ 'toolbar' => array(
 398+ 'preferences' => array(
 399+ // Ideally this key would be 'wikieditor-toolbar'
 400+ 'usebetatoolbar' => array(
 401+ 'type' => 'toggle',
 402+ 'label-message' => 'wikieditor-toolbar-preference',
 403+ 'section' => 'editing/beta',
 404+ ),
 405+ ),
 406+ 'requirements' => array(
 407+ 'usebetatoolbar' => true,
 408+ ),
 409+ 'modules' => array(
 410+ 'wikiEditor.toolbar',
 411+ ),
 412+ ),
 413+ 'dialogs' => array(
 414+ 'preferences' => array(
 415+ // Ideally this key would be 'wikieditor-toolbar-dialogs'
 416+ 'usebetatoolbar-cgd' => array(
 417+ 'type' => 'toggle',
 418+ 'label-message' => 'wikieditor-toolbar-dialogs-preference',
 419+ 'section' => 'editing/beta',
 420+ ),
 421+ ),
 422+ 'requirements' => array(
 423+ 'usebetatoolbar-cgd' => true,
 424+ ),
 425+ 'modules' => array(
 426+ 'wikiEditor.dialogs',
 427+ ),
 428+ ),
 429+
 430+ /* Labs Features */
 431+
387432 'highlight' => array(
388 - 'preference' => array(
389 - 'key' => 'wikieditor-highlight',
390 - 'ui' => array(
 433+ 'preferences' => array(
 434+ 'wikieditor-highlight' => array(
391435 'type' => 'toggle',
392436 'label-message' => 'wikieditor-highlight-preference',
393437 'section' => 'editing/labs',
394438 ),
395439 ),
 440+ 'requirements' => array(
 441+ 'wikieditor-highlight' => true,
 442+ ),
 443+ 'modules' => array(
 444+ 'wikiEditor.highlight',
 445+ ),
396446 ),
397447 'templateEditor' => array(
398 - 'preference' => array(
399 - 'key' => 'wikieditor-template-editor',
400 - 'ui' => array(
 448+ 'preferences' => array(
 449+ 'wikieditor-template-editor' => array(
401450 'type' => 'toggle',
402451 'label-message' => 'wikieditor-template-editor-preference',
403452 'section' => 'editing/labs',
404453 ),
405454 ),
 455+ 'requirements' => array(
 456+ 'wikieditor-template-editor' => true,
 457+ ),
 458+ 'modules' => array(
 459+ 'wikiEditor.templateEditor',
 460+ ),
406461 ),
407462 'templates' => array(
408 - 'preference' => array(
409 - 'key' => 'wikieditor-templates',
410 - 'ui' => array(
 463+ 'preferences' => array(
 464+ 'wikieditor-templates' => array(
411465 'type' => 'toggle',
412466 'label-message' => 'wikieditor-templates-preference',
413467 'section' => 'editing/labs',
414468 ),
415469 ),
 470+ 'requirements' => array(
 471+ 'wikieditor-templates' => true,
 472+ ),
 473+ 'modules' => array(
 474+ 'wikiEditor.templates',
 475+ ),
416476 ),
417477 'addMediaWizard' => array(
418 - 'preference' => array(
419 - 'key' => 'addmediawizard-gadget',
420 - 'ui' => array(
 478+ 'preferences' => array(
 479+ 'addmediawizard-gadget' => array(
421480 'type' => 'toggle',
422481 'label-message' => 'wikieditor-addMediaWizard-preference',
423482 'section' => 'editing/labs',
424483 ),
425484 ),
 485+ 'requirements' => array(
 486+ 'addmediawizard-gadget' => true,
 487+ ),
 488+ 'modules' => array(
 489+ 'wikiEditor.addMediaWizard',
 490+ ),
426491 ),
427492 'preview' => array(
428 - 'preference' => array(
429 - 'key' => 'wikieditor-preview',
430 - 'ui' => array(
 493+ 'preferences' => array(
 494+ 'wikieditor-preview' => array(
431495 'type' => 'toggle',
432496 'label-message' => 'wikieditor-preview-preference',
433497 'section' => 'editing/labs',
434498 ),
435499 ),
436 - 'messages' => array(
437 - 'wikieditor-preview-tab',
438 - 'wikieditor-preview-changes-tab',
439 - 'wikieditor-preview-loading',
 500+ 'requirements' => array(
 501+ 'wikieditor-preview' => true,
440502 ),
 503+ 'modules' => array(
 504+ 'wikiEditor.preview',
 505+ ),
441506 ),
442507 'previewDialog' => array(
443 - 'preference' => array(
444 - 'key' => 'wikieditor-previewDialog',
445 - 'ui' => array(
 508+ 'preferences' => array(
 509+ 'wikieditor-previewDialog' => array(
446510 'type' => 'toggle',
447511 'label-message' => 'wikieditor-previewDialog-preference',
448512 'section' => 'editing/labs',
449513 ),
450514 ),
 515+ 'requirements' => array(
 516+ 'wikieditor-previewDialog' => true,
 517+ ),
 518+ 'modules' => array(
 519+ 'wikiEditor.previewDialog',
 520+ ),
451521 ),
452522 'publish' => array(
453 - 'preference' => array(
454 - 'key' => 'wikieditor-publish',
455 - 'ui' => array(
 523+ 'preferences' => array(
 524+ 'wikieditor-publish' => array(
456525 'type' => 'toggle',
457526 'label-message' => 'wikieditor-publish-preference',
458527 'section' => 'editing/labs',
459528 ),
460529 ),
 530+ 'requirements' => array(
 531+ 'wikieditor-publish' => true,
 532+ ),
 533+ 'modules' => array(
 534+ 'wikiEditor.publish',
 535+ ),
461536 ),
462537 'toc' => array(
463 - 'preference' => array(
 538+ 'preferences' => array(
464539 // Ideally this key would be 'wikieditor-toc'
465 - 'key' => 'usenavigabletoc',
466 - 'ui' => array(
 540+ 'usenavigabletoc' => array(
467541 'type' => 'toggle',
468542 'label-message' => 'wikieditor-toc-preference',
469543 'section' => 'editing/labs',
470544 ),
471545 ),
472 - 'variables' => array(
 546+ 'requirements' => array(
 547+ 'usenavigabletoc' => true,
 548+ ),
 549+ 'modules' => array(
 550+ 'wikiEditor.toc',
 551+ ),
 552+ 'configurations' => array(
473553 // These are probably only for testing purposes?
474554 'wgNavigableTOCCollapseEnable',
475555 'wgNavigableTOCResizable'
476556 ),
477557 ),
478 - 'toolbar' => array(
479 - 'preference' => array(
480 - // Ideally this key would be 'wikieditor-toolbar'
481 - 'key' => 'usebetatoolbar',
482 - 'ui' => array(
483 - 'type' => 'toggle',
484 - 'label-message' => 'wikieditor-toolbar-preference',
485 - 'section' => 'editing/beta',
486 - ),
487 - ),
488 - ),
489 - 'dialogs' => array(
490 - 'preference' => array(
491 - // Ideally this key would be 'wikieditor-toolbar-dialogs'
492 - 'key' => 'usebetatoolbar-cgd',
493 - 'ui' => array(
494 - 'type' => 'toggle',
495 - 'label-message' => 'wikieditor-toolbar-dialogs-preference',
496 - 'section' => 'editing/beta',
497 - ),
498 - ),
499 - ),
500558 );
501559
502560 /* Protected Static Methods */
503561
504 - protected static function isEnabled( $module ) {
505 - global $wgVectorModules, $wgUser;
 562+ protected static function isEnabled( $name ) {
 563+ global $wgWikiEditorFeatures, $wgUser;
506564
507 - $enabled =
508 - $wgVectorModules[$module]['global'] ||
509 - (
510 - $wgVectorModules[$module]['user'] &&
511 - isset( self::$modules[$module]['preferences']['key'] ) &&
512 - $wgUser->getOption( self::$modules[$module]['preferences']['key'] )
513 - );
514 - if ( !$enabled ) {
515 - return false;
 565+ // Features not being controlled by $wgWikiEditorFeatures are always enabled, features with global set to true are
 566+ // always enabled
 567+ if ( !isset( $wgWikiEditorFeatures[$name] ) || $wgWikiEditorFeatures[$name]['global'] ) {
 568+ return true;
516569 }
517 - if ( isset( self::$modules[$module]['preferences']['requirements'] ) ) {
518 - foreach ( self::$modules[$module]['preferences']['requirements'] as $requirement => $value ) {
519 - // Important! We really do want fuzzy evaluation here
520 - if ( $wgUser->getOption( $requirement ) != $value ) {
521 - return false;
 570+ // Features with user preference control can have any number of preferences to be specific values to be enabled
 571+ if ( $wgWikiEditorFeatures[$name]['user'] ) {
 572+ if ( isset( self::$features[$name]['requirements'] ) ) {
 573+ foreach ( self::$features[$name]['requirements'] as $requirement => $value ) {
 574+ // Important! We really do want fuzzy evaluation here
 575+ if ( $wgUser->getOption( $requirement ) != $value ) {
 576+ return false;
 577+ }
522578 }
523579 }
 580+ return true;
524581 }
525 - return true;
 582+ // Features controlled by $wgWikiEditorFeatures with both global and user set to false are awlways disabled
 583+ return false;
526584 }
527585
528586 /* Static Methods */
529587
530588 /**
531 - * BeforePageDisplay hook
 589+ * EditPage::showEditForm:initial hook
532590 *
533591 * Adds the modules to the edit form
534592 *
535593 * @param $out OutputPage output page
536594 * @param $skin Skin current skin
537595 */
538 - public static function beforePageDisplay( $out, $skin ) {
539 - global $wgVectorModules;
 596+ public static function editPageShowEditFormInitial( &$toolbar ) {
 597+ global $wgOut;
540598
541 - // Don't load Vector modules for non-Vector skins
542 - if ( !( $skin instanceof SkinVector ) ) {
543 - return true;
544 - }
545 -
546 - // Add enabled modules
547 - foreach ( $wgVectorModules as $module => $enable ) {
548 - if ( self::isEnabled( $module ) ) {
549 - $out->addModules( self::$modules[$module]['name'] );
 599+ // Add modules for enabled features
 600+ foreach ( self::$features as $name => $feature ) {
 601+ if ( isset( $feature['modules'] ) && self::isEnabled( $name ) ) {
 602+ $wgOut->addModules( $feature['modules'] );
550603 }
551604 }
552605 return true;
@@ -560,12 +613,15 @@
561614 * @param $skin array list of default user preference controls
562615 */
563616 public static function getPreferences( $user, &$defaultPreferences ) {
564 - global $wgVectorModules;
 617+ global $wgWikiEditorFeatures;
565618
566 - foreach ( $wgVectorModules as $module => $enable ) {
567 - if ( $enable['user'] && isset( self::$modules['preferences'][$module]['ui'] ) ) {
568 - $defaultPreferences[self::$modules['preferences'][$module]['key']] =
569 - self::$modules['preferences'][$module]['ui'];
 619+ foreach ( self::$features as $name => $feature ) {
 620+ if (
 621+ isset( $feature['preferences'] ) &&
 622+ ( !isset( $wgWikiEditorFeatures[$name] ) || $wgWikiEditorFeatures[$name]['user'] )
 623+ ) {
 624+ foreach ( $feature['preferences'] as $key => $options )
 625+ $defaultPreferences[$key] = $options;
570626 }
571627 }
572628 return true;
@@ -577,15 +633,15 @@
578634 * Adds enabled/disabled switches for Vector modules
579635 */
580636 public static function makeGlobalVariablesScript( &$vars ) {
581 - global $wgVectorModules;
 637+ global $wgWikiEditorFeatures;
582638
583639 $configurations = array();
584 - foreach ( $wgVectorModules as $module => $enable ) {
 640+ foreach ( self::$features as $name => $feature ) {
585641 if (
586 - isset( self::$modules[$module]['configurations'] ) &&
587 - is_array( self::$modules[$module]['configurations'] )
 642+ isset( $feature['configurations'] ) &&
 643+ ( !isset( $wgWikiEditorFeatures[$name] ) || self::isEnabled( $name ) )
588644 ) {
589 - foreach ( self::$modules[$module]['configurations'] as $configuration ) {
 645+ foreach ( $feature['configurations'] as $configuration ) {
590646 global $$configuration;
591647 $configurations[$configuration] = $$configuration;
592648 }
@@ -603,8 +659,8 @@
604660 * Adds modules to ResourceLoader
605661 */
606662 public static function resourceLoaderRegisterModules() {
607 - foreach ( self::$modules as $module ) {
608 - ResourceLoader::register( $module['name'], new ResourceLoaderFileModule( $module['resources'] ) );
 663+ foreach ( self::$modules as $name => $resources ) {
 664+ ResourceLoader::register( $name, new ResourceLoaderFileModule( $resources ) );
609665 }
610666 return true;
611667 }
Index: trunk/extensions/WikiEditor/modules/wikiEditor.toolbar.js
@@ -6,16 +6,6 @@
77 if ( !$.wikiEditor.isSupported( $.wikiEditor.modules.toolbar ) ) {
88 return;
99 }
10 - // Some of the tools we're about to add depend on knowing if dialogs have been enabled or not, this little hack will
11 - // add a class to the textarea that signals that they are or or not, so that the 'filters' property can be used
12 - if ( mediaWiki.user.options.get( 'usebetatoolbar-cgd' ) ) {
13 - if (
14 - typeof $.wikiEditor.modules.dialogs !== 'undefined' &&
15 - $.wikiEditor.isSupported( $.wikiEditor.modules.dialogs )
16 - ) {
17 - $( '#wpTextbox1' ).addClass( 'toolbar-dialogs' );
18 - }
19 - }
2010 // The old toolbar is still in place and needs to be removed so there aren't two toolbars
2111 $( '#toolbar' ).remove();
2212 // Add toolbar module
Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toc.js
@@ -55,20 +55,18 @@
5656 $.wikiEditor.modules.toc.fn.update( context );
5757 },
5858 ready: function( context, event ) {
59 - if ( 'module' in event && event.module === 'toc' ) {
60 - // Add the TOC to the document
61 - $.wikiEditor.modules.toc.fn.build( context );
62 - if ( !context.$content ) {
63 - return;
64 - }
65 - context.$content.parent()
66 - .blur( function() {
67 - var context = event.data.context;
68 - $.wikiEditor.modules.toc.fn.unhighlight( context );
69 - });
70 - $.wikiEditor.modules.toc.fn.improveUI();
71 - $.wikiEditor.modules.toc.evt.resize( context );
 59+ // Add the TOC to the document
 60+ $.wikiEditor.modules.toc.fn.build( context );
 61+ if ( !context.$content ) {
 62+ return;
7263 }
 64+ context.$content.parent()
 65+ .blur( function() {
 66+ var context = event.data.context;
 67+ $.wikiEditor.modules.toc.fn.unhighlight( context );
 68+ });
 69+ $.wikiEditor.modules.toc.fn.improveUI();
 70+ $.wikiEditor.modules.toc.evt.resize( context );
7371 },
7472 resize: function( context, event ) {
7573 var availableWidth = context.$wikitext.width() - parseFloat( $.wikiEditor.modules.toc.cfg.textMinimumWidth ),
Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.js
@@ -133,12 +133,12 @@
134134 if ( property in object ) {
135135 return object[property];
136136 } else if ( property + 'Msg' in object ) {
137 - var p = object[property + 'Msg' ];
138 - if ( typeof p == 'object' && typeof p.length !== undefined && p.length >= 2) {
 137+ var p = object[property + 'Msg'];
 138+ if ( p instanceof Array && p.length >= 2 ) {
139139 // [ messageKey, { 'parameters': ['arg1, arg2, ...] } ]
140140 return mediaWiki.msg.get( object[property + 'Msg' ][0], object[property + 'Msg' ][1] );
141141 } else {
142 - return mediaWiki.msg.get( object[property + 'Msg'] );
 142+ return mediaWiki.msg.get( p );
143143 }
144144 } else {
145145 return '';
@@ -170,7 +170,7 @@
171171 if ( src.substr( 0, 7 ) != 'http://' && src.substr( 0, 8 ) != 'https://' && src[0] != '/' ) {
172172 src = path + src;
173173 }
174 - return src + '?' + wikiEditor.config.get( 'wgWikiEditorIconVersion' );
 174+ return src + '?' + mediaWiki.config.get( 'wgWikiEditorIconVersion' );
175175 },
176176 /**
177177 * Get the sprite offset for a language if available, icon for a language if available, or the default offset or icon,
@@ -281,8 +281,6 @@
282282 context.modules[module] = {};
283283 // Tell the module to create itself on the context
284284 $.wikiEditor.modules[module].fn.create( context, modules[module] );
285 - // This is triggered each time a module is ready, the event will contain a module property
286 - context.fn.trigger( 'ready', { 'module': module } );
287285 }
288286 }
289287 }
Index: trunk/extensions/WikiEditor/modules/wikiEditor.dialogs.js
@@ -6,6 +6,16 @@
77 if ( !$.wikiEditor.isSupported( $.wikiEditor.modules.dialogs ) ) {
88 return;
99 }
 10+ // Some toolbar tools depend on knowing if dialogs have been enabled or not. By adding a class to the textarea, we
 11+ // provide a way that the the 'filters' property can be used.
 12+ if ( mediaWiki.user.options.get( 'usebetatoolbar-cgd' ) ) {
 13+ if (
 14+ typeof $.wikiEditor.modules.dialogs !== 'undefined' &&
 15+ $.wikiEditor.isSupported( $.wikiEditor.modules.dialogs )
 16+ ) {
 17+ $( '#wpTextbox1' ).addClass( 'toolbar-dialogs' );
 18+ }
 19+ }
1020 // Add dialogs module
1121 $( '#wpTextbox1' ).wikiEditor( 'addModule', { 'dialogs': {
1222 'insert-link': {
Index: trunk/extensions/WikiEditor/modules/wikiEditor.toc.js
@@ -4,5 +4,8 @@
55
66 $( document ).ready( function() {
77 // Add table of contents module
8 - $( '#wpTextbox1' ).wikiEditor( 'addModule', 'toc' )
9 -});
 8+ $( '#wpTextbox1' )
 9+ .wikiEditor( 'addModule', 'toc' )
 10+ // FIXME - should move the ready handler code to the create function so this isn't necissary
 11+ .data( 'wikiEditor-context' ).fn.trigger( 'ready' );
 12+} );
Index: trunk/extensions/WikiEditor/WikiEditor.i18n.php
@@ -12,6 +12,10 @@
1313 * @author Trevor Parscal
1414 */
1515 $messages['en'] = array(
 16+ /* Editing Preference Categories */
 17+ 'prefs-beta' => 'Beta features',
 18+ 'prefs-labs' => 'Labs features',
 19+ /* WikiEditor */
1620 'wikieditor' => 'Advanced wikitext editing interface',
1721 'wikieditor-desc' => 'Provides an extendable wikitext editing interface and many feature-providing modules',
1822 'wikieditor-wikitext-tab' => 'Wikitext',

Comments

#Comment by Catrope (talk | contribs)   17:36, 1 October 2010
-$wgWikiEditorModules = array(
+$wgWikiEditorFeatures = array(

Why are you breaking backwards compatibility like that?

+				foreach ( $feature['preferences'] as $key => $options )
+				$defaultPreferences[$key] = $options;

This is indented wrong.

+	// Some toolbar tools depend on knowing if dialogs have been enabled or not. By adding a class to the textarea, we
+	// provide a way that the the 'filters' property can be used.
+	if ( mediaWiki.user.options.get( 'usebetatoolbar-cgd' ) ) {
+		if (
+			typeof $.wikiEditor.modules.dialogs !== 'undefined' &&
+			$.wikiEditor.isSupported( $.wikiEditor.modules.dialogs )
+		) {
+			$( '#wpTextbox1' ).addClass( 'toolbar-dialogs' );
+		}
+	}

After having moved this code to the dialogs module, I can't help but think that this only works by accident, i.e. because the dialogs module is loaded before the toolbar module. If they're executed in reverse order, the toolbar module will make decisions based on the absence of the toolbar-dialogs class only to have the dialogs module add it after that. Could you test whether this does indeed depend on execution order?

#Comment by Trevor Parscal (WMF) (talk | contribs)   19:15, 1 October 2010

I'm not a fan of braking backwards compatibility, but since we used the word modules in ResourceLoader, it starts getting really confusing when we also use it within WikiEditor with a different meaning, especially when both concepts are intersecting. So, this was a carefully made decision which I hope will not cause too many problems. It's also a change that's well documented on Extension:WikiEditor.

The indentation and bracing issue is fixed in r74086.


OK, so I'm going to be re-factoring WikiEditor next week, and this will be solved. I'm also going to pull the iframe stuff into a module so there's not so much bloat.

#Comment by Catrope (talk | contribs)   19:16, 1 October 2010

Good point. Documenting it in the README is probably a good idea too. I guess it's fair to expect people to rename the config var i they have to change the ext path to include from anyway.

#Comment by Trevor Parscal (WMF) (talk | contribs)   21:59, 1 October 2010

r74114 addresses the timing issues by having the dialogs module replace the non-dialog buttons upon loading. I also brought back on-demand loading of jquery.ui stuff.

Status & tagging log