r57645 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57644‎ | r57645 | r57646 >
Date:19:44, 11 October 2009
Author:catrope
Status:ok
Tags:
Comment:
UsabilityInitiative: (bug 20893) Toolbar dialogs break when JS2 is enabled
Modified paths:
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/js2.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/js2.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/js2/js2.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.dialogs.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -44,13 +44,14 @@
4545 'no_js2' => array(
4646 'raw' => array(
4747 array( 'src' => 'js/js2/jquery-1.3.2.js', 'version' => '1.3.2' ),
48 - array( 'src' => 'js/js2/js2.js', 'version' => 3 ),
 48+ array( 'src' => 'js/js2/jquery-ui-1.7.2.js', 'version' => '1.7.2y' ),
 49+ array( 'src' => 'js/js2/js2.js', 'version' => 4 ),
4950 ),
5051 'combined' => array(
51 - array( 'src' => 'js/js2.combined.js', 'version' => 6 ),
 52+ array( 'src' => 'js/js2.combined.js', 'version' => 7 ),
5253 ),
5354 'minified' => array(
54 - array( 'src' => 'js/js2.combined.min.js', 'version' => 6 ),
 55+ array( 'src' => 'js/js2.combined.min.js', 'version' => 7 ),
5556 ),
5657 ),
5758 // Core functionality of extension
@@ -66,17 +67,14 @@
6768 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 16 ),
6869 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 12 ),
6970 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 12 ),
70 - array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 4 ),
 71+ array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 5 ),
7172 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 19 ),
72 - // FIXME: jQuery UI doesn't belong here, should move to no_js2
73 - // once we figure out how to do jQuery UI properly in JS2
74 - array( 'src' => 'js/js2/jquery-ui-1.7.2.js', 'version' => '1.7.2y' ),
7573 ),
7674 'combined' => array(
77 - array( 'src' => 'js/plugins.combined.js', 'version' => 42 ),
 75+ array( 'src' => 'js/plugins.combined.js', 'version' => 43 ),
7876 ),
7977 'minified' => array(
80 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 42 ),
 78+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 43 ),
8179 ),
8280 ),
8381 );
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js
@@ -839,7 +839,9 @@
840840 $j(this).text( gM( $j(this).attr( 'rel' ) ) );
841841 });
842842 // Build tabs
843 - $j( '#edittoolbar-link-tabs' ).tabs();
 843+ mvJsLoader.doLoad( [ '$j.ui', '$j.ui.tabs' ], function() {
 844+ $j( '#edittoolbar-link-tabs' ).tabs();
 845+ });
844846 // Automatically copy the value of the internal link page title field to the link text field unless the user
845847 // has changed the link text field - this is a convience thing since most link texts are going to be the
846848 // the same as the page title
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php
@@ -19,7 +19,7 @@
2020 /* Configuration */
2121
2222 // Bump the version number every time you change any of the .css/.js files
23 -$wgEditToolbarStyleVersion = 56;
 23+$wgEditToolbarStyleVersion = 57;
2424
2525 // Set this to true to simply override the stock toolbar for everyone
2626 $wgEditToolbarGlobalEnable = false;
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.dialogs.js
@@ -43,60 +43,63 @@
4444 $.wikiEditor.modules.dialogs.modules[module] = config[module];
4545 }
4646 // Build out modules immediately
47 - for ( module in $.wikiEditor.modules.dialogs.modules ) {
48 - var module = $.wikiEditor.modules.dialogs.modules[module];
49 - // Only create the dialog if it doesn't exist yet
50 - if ( $( '#' + module.id ).size() == 0 ) {
51 - var configuration = module.dialog;
52 - // Add some stuff to configuration
53 - configuration.bgiframe = true;
54 - configuration.autoOpen = false;
55 - configuration.modal = true;
56 - configuration.title = $.wikiEditor.autoMsg( module, 'title' );
57 - // Transform messages in keys
58 - // Stupid JS won't let us do stuff like
59 - // foo = { gM ('bar'): baz }
60 - configuration.newButtons = {};
61 - for ( msg in configuration.buttons )
62 - configuration.newButtons[gM( msg )] = configuration.buttons[msg];
63 - configuration.buttons = configuration.newButtons;
64 - // Create the dialog <div>
65 - $( '<div /> ' )
66 - .attr( 'id', module.id )
67 - .html( module.html )
68 - .data( 'context', context )
69 - .appendTo( $( 'body' ) )
70 - .each( module.init )
71 - .dialog( configuration )
72 - .bind( 'dialogopen', $.wikiEditor.modules.dialogs.fn.resize )
73 - .find( '.ui-tabs' ).bind( 'tabsshow', function() {
74 - $(this).closest( '.ui-dialog-content' ).each(
75 - $.wikiEditor.modules.dialogs.fn.resize );
 47+ mvJsLoader.doLoad( ['$j.ui', '$j.ui.dialog', '$j.ui.draggable', '$j.ui.resizable' ], function() {
 48+ for ( module in $.wikiEditor.modules.dialogs.modules ) {
 49+ var module = $.wikiEditor.modules.dialogs.modules[module];
 50+ // Only create the dialog if it doesn't exist yet
 51+ if ( $( '#' + module.id ).size() == 0 ) {
 52+ var configuration = module.dialog;
 53+ // Add some stuff to configuration
 54+ configuration.bgiframe = true;
 55+ configuration.autoOpen = false;
 56+ configuration.modal = true;
 57+ configuration.title = $.wikiEditor.autoMsg( module, 'title' );
 58+ // Transform messages in keys
 59+ // Stupid JS won't let us do stuff like
 60+ // foo = { gM ('bar'): baz }
 61+ configuration.newButtons = {};
 62+ for ( msg in configuration.buttons )
 63+ configuration.newButtons[gM( msg )] = configuration.buttons[msg];
 64+ configuration.buttons = configuration.newButtons;
 65+ // Create the dialog <div>
 66+ $( '<div /> ' )
 67+ .attr( 'id', module.id )
 68+ .html( module.html )
 69+ .data( 'context', context )
 70+ .appendTo( $( 'body' ) )
 71+ .each( module.init )
 72+ .dialog( configuration )
 73+ .bind( 'dialogopen', $.wikiEditor.modules.dialogs.fn.resize )
 74+ .find( '.ui-tabs' ).bind( 'tabsshow', function() {
 75+ $(this).closest( '.ui-dialog-content' ).each(
 76+ $.wikiEditor.modules.dialogs.fn.resize );
 77+ });
 78+
 79+ // Add tabindexes to dialog form elements
 80+ // Find the highest tabindex in use
 81+ var maxTI = 0;
 82+ $j( '[tabindex]' ).each( function() {
 83+ var ti = parseInt( $j(this).attr( 'tabindex' ) );
 84+ if ( ti > maxTI )
 85+ maxTI = ti;
7686 });
77 -
78 - // Add tabindexes to dialog form elements
79 - // Find the highest tabindex in use
80 - var maxTI = 0;
81 - $j( '[tabindex]' ).each( function() {
82 - var ti = parseInt( $j(this).attr( 'tabindex' ) );
83 - if ( ti > maxTI )
84 - maxTI = ti;
85 - });
86 -
87 - var tabIndex = maxTI + 1;
88 - $j( '.ui-dialog input, .ui-dialog button' )
89 - .not( '[tabindex]' )
90 - .each( function() {
91 - $j(this).attr( 'tabindex', tabIndex++ );
92 - });
 87+
 88+ var tabIndex = maxTI + 1;
 89+ $j( '.ui-dialog input, .ui-dialog button' )
 90+ .not( '[tabindex]' )
 91+ .each( function() {
 92+ $j(this).attr( 'tabindex', tabIndex++ );
 93+ });
 94+ }
9395 }
94 - }
 96+ });
9597 },
9698
9799 /**
98100 * Resize a dialog so its contents fit
99101 *
100102 * Usage: dialog.each( resize ); or dialog.bind( 'blah', resize );
 103+ * NOTE: This function assumes $j.ui.dialog has already been loaded
101104 */
102105 resize: function() {
103106 var wrapper = $(this).closest( '.ui-dialog' );
Index: trunk/extensions/UsabilityInitiative/js/js2.combined.js
@@ -9503,4 +9503,7 @@
95049504 */
95059505 function js2AddOnloadHook( func ) {
95069506 $j(document).ready( func );
9507 -}
\ No newline at end of file
 9507+}
 9508+
 9509+// Define a dummy mvJsLoader.doLoad() function
 9510+mvJsLoader = { doLoad: function( deps, callback ) { callback(); } };
\ No newline at end of file
Index: trunk/extensions/UsabilityInitiative/js/js2.combined.min.js
@@ -778,4 +778,5 @@
779779 return $.datepicker['_'+options+'Datepicker'].apply($.datepicker,[this[0]].concat(otherArgs));return this.each(function(){typeof options=='string'?$.datepicker['_'+options+'Datepicker'].apply($.datepicker,[this].concat(otherArgs)):$.datepicker._attachDatepicker(this,options);});};$.datepicker=new Datepicker();$.datepicker.initialized=false;$.datepicker.uuid=new Date().getTime();$.datepicker.version="1.7.2";window.DP_jQuery=$;})(jQuery);if(!gMsg)var gMsg={};function loadGM(msgSet){for(var i in msgSet){gMsg[i]=msgSet[i];}}
780780 function gM(key,args){var ms='';if(key in gMsg){ms=gMsg[key];if(typeof args=='object'||typeof args=='array'){for(var v in args){var rep='\$'+(parseInt(v)+1);ms=ms.replace(rep,args[v]);}}else if(typeof args=='string'||typeof args=='number'){ms=ms.replace(/\$1/,args);}
781781 return ms;}else{return'['+key+']';}}
782 -$j=jQuery.noConflict();function js2AddOnloadHook(func){$j(document).ready(func);}
\ No newline at end of file
 782+$j=jQuery.noConflict();function js2AddOnloadHook(func){$j(document).ready(func);}
 783+mvJsLoader={doLoad:function(deps,callback){callback();}};
\ No newline at end of file
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -1424,60 +1424,63 @@
14251425 $.wikiEditor.modules.dialogs.modules[module] = config[module];
14261426 }
14271427 // Build out modules immediately
1428 - for ( module in $.wikiEditor.modules.dialogs.modules ) {
1429 - var module = $.wikiEditor.modules.dialogs.modules[module];
1430 - // Only create the dialog if it doesn't exist yet
1431 - if ( $( '#' + module.id ).size() == 0 ) {
1432 - var configuration = module.dialog;
1433 - // Add some stuff to configuration
1434 - configuration.bgiframe = true;
1435 - configuration.autoOpen = false;
1436 - configuration.modal = true;
1437 - configuration.title = $.wikiEditor.autoMsg( module, 'title' );
1438 - // Transform messages in keys
1439 - // Stupid JS won't let us do stuff like
1440 - // foo = { gM ('bar'): baz }
1441 - configuration.newButtons = {};
1442 - for ( msg in configuration.buttons )
1443 - configuration.newButtons[gM( msg )] = configuration.buttons[msg];
1444 - configuration.buttons = configuration.newButtons;
1445 - // Create the dialog <div>
1446 - $( '<div /> ' )
1447 - .attr( 'id', module.id )
1448 - .html( module.html )
1449 - .data( 'context', context )
1450 - .appendTo( $( 'body' ) )
1451 - .each( module.init )
1452 - .dialog( configuration )
1453 - .bind( 'dialogopen', $.wikiEditor.modules.dialogs.fn.resize )
1454 - .find( '.ui-tabs' ).bind( 'tabsshow', function() {
1455 - $(this).closest( '.ui-dialog-content' ).each(
1456 - $.wikiEditor.modules.dialogs.fn.resize );
 1428+ mvJsLoader.doLoad( ['$j.ui', '$j.ui.dialog', '$j.ui.draggable', '$j.ui.resizable' ], function() {
 1429+ for ( module in $.wikiEditor.modules.dialogs.modules ) {
 1430+ var module = $.wikiEditor.modules.dialogs.modules[module];
 1431+ // Only create the dialog if it doesn't exist yet
 1432+ if ( $( '#' + module.id ).size() == 0 ) {
 1433+ var configuration = module.dialog;
 1434+ // Add some stuff to configuration
 1435+ configuration.bgiframe = true;
 1436+ configuration.autoOpen = false;
 1437+ configuration.modal = true;
 1438+ configuration.title = $.wikiEditor.autoMsg( module, 'title' );
 1439+ // Transform messages in keys
 1440+ // Stupid JS won't let us do stuff like
 1441+ // foo = { gM ('bar'): baz }
 1442+ configuration.newButtons = {};
 1443+ for ( msg in configuration.buttons )
 1444+ configuration.newButtons[gM( msg )] = configuration.buttons[msg];
 1445+ configuration.buttons = configuration.newButtons;
 1446+ // Create the dialog <div>
 1447+ $( '<div /> ' )
 1448+ .attr( 'id', module.id )
 1449+ .html( module.html )
 1450+ .data( 'context', context )
 1451+ .appendTo( $( 'body' ) )
 1452+ .each( module.init )
 1453+ .dialog( configuration )
 1454+ .bind( 'dialogopen', $.wikiEditor.modules.dialogs.fn.resize )
 1455+ .find( '.ui-tabs' ).bind( 'tabsshow', function() {
 1456+ $(this).closest( '.ui-dialog-content' ).each(
 1457+ $.wikiEditor.modules.dialogs.fn.resize );
 1458+ });
 1459+
 1460+ // Add tabindexes to dialog form elements
 1461+ // Find the highest tabindex in use
 1462+ var maxTI = 0;
 1463+ $j( '[tabindex]' ).each( function() {
 1464+ var ti = parseInt( $j(this).attr( 'tabindex' ) );
 1465+ if ( ti > maxTI )
 1466+ maxTI = ti;
14571467 });
1458 -
1459 - // Add tabindexes to dialog form elements
1460 - // Find the highest tabindex in use
1461 - var maxTI = 0;
1462 - $j( '[tabindex]' ).each( function() {
1463 - var ti = parseInt( $j(this).attr( 'tabindex' ) );
1464 - if ( ti > maxTI )
1465 - maxTI = ti;
1466 - });
1467 -
1468 - var tabIndex = maxTI + 1;
1469 - $j( '.ui-dialog input, .ui-dialog button' )
1470 - .not( '[tabindex]' )
1471 - .each( function() {
1472 - $j(this).attr( 'tabindex', tabIndex++ );
1473 - });
 1468+
 1469+ var tabIndex = maxTI + 1;
 1470+ $j( '.ui-dialog input, .ui-dialog button' )
 1471+ .not( '[tabindex]' )
 1472+ .each( function() {
 1473+ $j(this).attr( 'tabindex', tabIndex++ );
 1474+ });
 1475+ }
14741476 }
1475 - }
 1477+ });
14761478 },
14771479
14781480 /**
14791481 * Resize a dialog so its contents fit
14801482 *
14811483 * Usage: dialog.each( resize ); or dialog.bind( 'blah', resize );
 1484+ * NOTE: This function assumes $j.ui.dialog has already been loaded
14821485 */
14831486 resize: function() {
14841487 var wrapper = $(this).closest( '.ui-dialog' );
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -90,9 +90,9 @@
9191 if(typeof data=='string'){callModuleApi(data,'create',{});}else if(typeof data=='object'){for(module in data){if(typeof module=='string'){callModuleApi(module,'create',data[module]);}}}}};for(module in $.wikiEditor.modules){if('api'in $.wikiEditor.modules[module]){for(call in $.wikiEditor.modules[module].api){if(!(call in context.api)){context.api[call]=$.wikiEditor.modules[module].api[call];}}}}}
9292 if(arguments.length>0&&typeof arguments[0]=='object'){context.api.addModule(context,arguments[0]);}else{arguments=$.makeArray(arguments);if(arguments.length>0){var call=arguments.shift();if(call in context.api){context.api[call](context,arguments[0]==undefined?{}:arguments[0]);}}}
9393 return $(this).data('wikiEditor-context',context);};})(jQuery);RegExp.escape=function(s){return s.replace(/([.*+?^${}()|\/\\[\]])/g,'\\$1');};(function($){$.wikiEditor.modules.dialogs={api:{addDialog:function(context,data){$.wikiEditor.modules.dialogs.fn.create(context,{'modules':data})},openDialog:function(context,data){if(data.dialog in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[data.dialog].id).dialog('open');}},closeDialog:function(context,data){if(data.dialog in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[data.dialog].id).dialog('close');}}},fn:{create:function(context,config){for(module in config){$.wikiEditor.modules.dialogs.modules[module]=config[module];}
94 -for(module in $.wikiEditor.modules.dialogs.modules){var module=$.wikiEditor.modules.dialogs.modules[module];if($('#'+module.id).size()==0){var configuration=module.dialog;configuration.bgiframe=true;configuration.autoOpen=false;configuration.modal=true;configuration.title=$.wikiEditor.autoMsg(module,'title');configuration.newButtons={};for(msg in configuration.buttons)
 94+mvJsLoader.doLoad(['$j.ui','$j.ui.dialog','$j.ui.draggable','$j.ui.resizable'],function(){for(module in $.wikiEditor.modules.dialogs.modules){var module=$.wikiEditor.modules.dialogs.modules[module];if($('#'+module.id).size()==0){var configuration=module.dialog;configuration.bgiframe=true;configuration.autoOpen=false;configuration.modal=true;configuration.title=$.wikiEditor.autoMsg(module,'title');configuration.newButtons={};for(msg in configuration.buttons)
9595 configuration.newButtons[gM(msg)]=configuration.buttons[msg];configuration.buttons=configuration.newButtons;$('<div /> ').attr('id',module.id).html(module.html).data('context',context).appendTo($('body')).each(module.init).dialog(configuration).bind('dialogopen',$.wikiEditor.modules.dialogs.fn.resize).find('.ui-tabs').bind('tabsshow',function(){$(this).closest('.ui-dialog-content').each($.wikiEditor.modules.dialogs.fn.resize);});var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI)
96 -maxTI=ti;});var tabIndex=maxTI+1;$j('.ui-dialog input, .ui-dialog button').not('[tabindex]').each(function(){$j(this).attr('tabindex',tabIndex++);});}}},resize:function(){var wrapper=$(this).closest('.ui-dialog');var oldWidth=wrapper.width();var oldHidden=$(this).find('*').not(':visible');oldHidden.each(function(){$(this).data('oldstyle',$(this).attr('style'));});oldHidden.show();var oldWS=$(this).css('white-space');$(this).css('white-space','nowrap');if(wrapper.width()<=$(this).get(0).scrollWidth){$(this).width($(this).get(0).scrollWidth);wrapper.width(wrapper.get(0).scrollWidth);$(this).dialog({'width':wrapper.width()});wrapper.css('left',parseInt(wrapper.css('left'))-
 96+maxTI=ti;});var tabIndex=maxTI+1;$j('.ui-dialog input, .ui-dialog button').not('[tabindex]').each(function(){$j(this).attr('tabindex',tabIndex++);});}}});},resize:function(){var wrapper=$(this).closest('.ui-dialog');var oldWidth=wrapper.width();var oldHidden=$(this).find('*').not(':visible');oldHidden.each(function(){$(this).data('oldstyle',$(this).attr('style'));});oldHidden.show();var oldWS=$(this).css('white-space');$(this).css('white-space','nowrap');if(wrapper.width()<=$(this).get(0).scrollWidth){$(this).width($(this).get(0).scrollWidth);wrapper.width(wrapper.get(0).scrollWidth);$(this).dialog({'width':wrapper.width()});wrapper.css('left',parseInt(wrapper.css('left'))-
9797 (wrapper.width()-oldWidth)/2);}
9898 $(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},'modules':{}};})(jQuery);(function($){$.wikiEditor.modules.toolbar={api:{addToToolbar:function(context,data){for(type in data){switch(type){case'sections':var $sections=context.modules.$toolbar.find('div.sections');var $tabs=context.modules.$toolbar.find('div.tabs');for(section in data[type]){if(section=='main'){context.modules.$toolbar.prepend($.wikiEditor.modules.toolbar.fn.buildSection(context,section,data[type][section]));continue;}
9999 $sections.append($.wikiEditor.modules.toolbar.fn.buildSection(context,section,data[type][section]));$tabs.append($.wikiEditor.modules.toolbar.fn.buildTab(context,section,data[type][section]));$section=$sections.find('.section:visible');if($section.size()){$sections.animate({'height':$section.outerHeight()},'fast');}}
Index: trunk/extensions/UsabilityInitiative/js/js2/js2.js
@@ -50,4 +50,7 @@
5151 */
5252 function js2AddOnloadHook( func ) {
5353 $j(document).ready( func );
54 -}
\ No newline at end of file
 54+}
 55+
 56+// Define a dummy mvJsLoader.doLoad() function
 57+mvJsLoader = { doLoad: function( deps, callback ) { callback(); } };
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r57719wmf-deployment: Merge babaco fixes from trunk...catrope20:20, 14 October 2009

Status & tagging log