Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -75,17 +75,17 @@ |
76 | 76 | array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 178 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 51 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 52 ), |
79 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 21 ), |
| 79 | + array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 22 ), |
80 | 80 | array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 97 ), |
81 | 81 | array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 11 ), |
82 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 67 ), |
| 82 | + array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 68 ), |
83 | 83 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 5 ), |
84 | 84 | ), |
85 | 85 | 'combined' => array( |
86 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 356 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 357 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 356 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 357 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.hooks.php |
— | — | @@ -16,14 +16,14 @@ |
17 | 17 | array( 'src' => 'Modules/Preview/Preview.js', 'version' => 6 ), |
18 | 18 | array( 'src' => 'Modules/Publish/Publish.js', 'version' => 6 ), |
19 | 19 | array( 'src' => 'Modules/Toc/Toc.js', 'version' => 7 ), |
20 | | - array( 'src' => 'Modules/Toolbar/Toolbar.js', 'version' => 65 ), |
| 20 | + array( 'src' => 'Modules/Toolbar/Toolbar.js', 'version' => 66 ), |
21 | 21 | array( 'src' => 'Modules/TemplateEditor/TemplateEditor.js', 'version' => 6 ), |
22 | 22 | ), |
23 | 23 | 'combined' => array( |
24 | | - array( 'src' => 'WikiEditor.combined.js', 'version' => 69 ), |
| 24 | + array( 'src' => 'WikiEditor.combined.js', 'version' => 70 ), |
25 | 25 | ), |
26 | 26 | 'minified' => array( |
27 | | - array( 'src' => 'WikiEditor.combined.min.js', 'version' => 69 ), |
| 27 | + array( 'src' => 'WikiEditor.combined.min.js', 'version' => 70 ), |
28 | 28 | ), |
29 | 29 | ); |
30 | 30 | static $messages = array( |
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.js |
— | — | @@ -1048,6 +1048,8 @@ |
1049 | 1049 | $j(this).find( '[rel]' ).each( function() { |
1050 | 1050 | $j(this).text( u.getMsg( $j(this).attr( 'rel' ) ) ); |
1051 | 1051 | }); |
| 1052 | + // Set tabindexes on form fields |
| 1053 | + $j.wikiEditor.modules.dialogs.fn.setTabindexes( $j(this).find( 'input' ).not( '[tabindex]' ) ); |
1052 | 1054 | // Setup the tooltips in the textboxes |
1053 | 1055 | $j( '#wikieditor-toolbar-link-int-target' ) |
1054 | 1056 | .data( 'tooltip', u.getMsg( 'wikieditor-toolbar-tool-link-int-target-tooltip' ) ); |
— | — | @@ -1487,6 +1489,9 @@ |
1488 | 1490 | $j(this).find( '[rel]' ).each( function() { |
1489 | 1491 | $j(this).text( mw.usability.getMsg( $j(this).attr( 'rel' ) ) ); |
1490 | 1492 | }); |
| 1493 | + // Set tabindexes on form fields |
| 1494 | + $j.wikiEditor.modules.dialogs.fn.setTabindexes( $j(this).find( 'input' ).not( '[tabindex]' ) ); |
| 1495 | + |
1491 | 1496 | $j( '#wikieditor-toolbar-table-dimensions-rows' ).val( 4 ); |
1492 | 1497 | $j( '#wikieditor-toolbar-table-dimensions-columns' ).val( 3 ); |
1493 | 1498 | $j( '#wikieditor-toolbar-table-wikitable' ).click( function() { |
— | — | @@ -1686,6 +1691,8 @@ |
1687 | 1692 | $j(this).find( '[rel]' ).each( function() { |
1688 | 1693 | $j(this).text( u.getMsg( $j(this).attr( 'rel' ) ) ); |
1689 | 1694 | }); |
| 1695 | + // Set tabindexes on form fields |
| 1696 | + $j.wikiEditor.modules.dialogs.fn.setTabindexes( $j(this).find( 'input' ).not( '[tabindex]' ) ); |
1690 | 1697 | |
1691 | 1698 | // TODO: Find a cleaner way to share this function |
1692 | 1699 | $j(this).data( 'replaceCallback', function( mode ) { |
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.min.js |
— | — | @@ -42,7 +42,7 @@ |
43 | 43 | $j('#wikieditor-toolbar-link-type-int, #wikieditor-toolbar-link-type-ext').click(function(){if($j('#wikieditor-toolbar-link-type-ext').is(':checked')){var request=$j('#wikieditor-toolbar-link-int-target-status').data('request');if(request){request.abort();} |
44 | 44 | updateWidget('external');} |
45 | 45 | if($j('#wikieditor-toolbar-link-type-int').is(':checked')) |
46 | | -updateExistence();});var u=mw.usability;$j(this).find('[rel]').each(function(){$j(this).text(u.getMsg($j(this).attr('rel')));});$j('#wikieditor-toolbar-link-int-target').data('tooltip',u.getMsg('wikieditor-toolbar-tool-link-int-target-tooltip'));$j('#wikieditor-toolbar-link-int-text').data('tooltip',u.getMsg('wikieditor-toolbar-tool-link-int-text-tooltip'));$j('#wikieditor-toolbar-link-int-target, #wikieditor-toolbar-link-int-text').each(function(){var tooltip=u.getMsg($j(this).attr('id')+'-tooltip');if($j(this).val()=='') |
| 46 | +updateExistence();});var u=mw.usability;$j(this).find('[rel]').each(function(){$j(this).text(u.getMsg($j(this).attr('rel')));});$j.wikiEditor.modules.dialogs.fn.setTabindexes($j(this).find('input').not('[tabindex]'));$j('#wikieditor-toolbar-link-int-target').data('tooltip',u.getMsg('wikieditor-toolbar-tool-link-int-target-tooltip'));$j('#wikieditor-toolbar-link-int-text').data('tooltip',u.getMsg('wikieditor-toolbar-tool-link-int-text-tooltip'));$j('#wikieditor-toolbar-link-int-target, #wikieditor-toolbar-link-int-text').each(function(){var tooltip=u.getMsg($j(this).attr('id')+'-tooltip');if($j(this).val()=='') |
47 | 47 | $j(this).addClass('wikieditor-toolbar-dialog-hint').val($j(this).data('tooltip')).data('tooltip-mode',true);}).focus(function(){if($j(this).val()==$j(this).data('tooltip')){$j(this).val('').removeClass('wikieditor-toolbar-dialog-hint').data('tooltip-mode',false);}}).bind('change',function(){if($j(this).val()!=$j(this).data('tooltip')){$j(this).removeClass('wikieditor-toolbar-dialog-hint').data('tooltip-mode',false);}}).bind('blur',function(){if($j(this).val()==''){$j(this).addClass('wikieditor-toolbar-dialog-hint').val($j(this).data('tooltip')).data('tooltip-mode',true);}});$j('#wikieditor-toolbar-link-int-target').bind('change keydown paste cut',function(){setTimeout(function(){if(isExternalLink($j('#wikieditor-toolbar-link-int-target').val())){$j('#wikieditor-toolbar-link-type-ext').attr('checked','checked');updateWidget('external');}else{$j('#wikieditor-toolbar-link-type-int').attr('checked','checked');updateExistence();} |
48 | 48 | if($j('#wikieditor-toolbar-link-int-text').data('untouched')) |
49 | 49 | if($j('#wikieditor-toolbar-link-int-target').val()==$j('#wikieditor-toolbar-link-int-target').data('tooltip')){$j('#wikieditor-toolbar-link-int-text').addClass('wikieditor-toolbar-dialog-hint').val($j('#wikieditor-toolbar-link-int-text').data('tooltip')).change();}else{$j('#wikieditor-toolbar-link-int-text').val($j('#wikieditor-toolbar-link-int-target').val()).change();}},0);});$j('#wikieditor-toolbar-link-int-text').bind('change keydown paste cut',function(){var oldVal=$j(this).val();var that=this;setTimeout(function(){if($j(that).val()!=oldVal) |
— | — | @@ -129,7 +129,7 @@ |
130 | 130 | </tr>\ |
131 | 131 | </table>\ |
132 | 132 | </div>\ |
133 | | - </div></div>',init:function(){$j(this).find('[rel]').each(function(){$j(this).text(mw.usability.getMsg($j(this).attr('rel')));});$j('#wikieditor-toolbar-table-dimensions-rows').val(4);$j('#wikieditor-toolbar-table-dimensions-columns').val(3);$j('#wikieditor-toolbar-table-wikitable').click(function(){$j('.wikieditor-toolbar-table-preview').toggleClass('wikitable');});$j('#wikieditor-toolbar-table-preview').clone().attr('id','wikieditor-toolbar-table-preview2').addClass('sortable').insertAfter($j('#wikieditor-toolbar-table-preview')).hide();if(typeof ts_makeSortable=='function') |
| 133 | + </div></div>',init:function(){$j(this).find('[rel]').each(function(){$j(this).text(mw.usability.getMsg($j(this).attr('rel')));});$j.wikiEditor.modules.dialogs.fn.setTabindexes($j(this).find('input').not('[tabindex]'));$j('#wikieditor-toolbar-table-dimensions-rows').val(4);$j('#wikieditor-toolbar-table-dimensions-columns').val(3);$j('#wikieditor-toolbar-table-wikitable').click(function(){$j('.wikieditor-toolbar-table-preview').toggleClass('wikitable');});$j('#wikieditor-toolbar-table-preview').clone().attr('id','wikieditor-toolbar-table-preview2').addClass('sortable').insertAfter($j('#wikieditor-toolbar-table-preview')).hide();if(typeof ts_makeSortable=='function') |
134 | 134 | ts_makeSortable($j('#wikieditor-toolbar-table-preview2').get(0));$j('#wikieditor-toolbar-table-sortable').click(function(){$j('#wikieditor-toolbar-table-preview').hide().attr('id','wikieditor-toolbar-table-preview3');$j('#wikieditor-toolbar-table-preview2').attr('id','wikieditor-toolbar-table-preview').show();$j('#wikieditor-toolbar-table-preview3').attr('id','wikieditor-toolbar-table-preview2');});$j('#wikieditor-toolbar-table-dimensions-header').click(function(){var headerHTML=$j('.wikieditor-toolbar-table-preview-header').html();var hiddenHTML=$j('.wikieditor-toolbar-table-preview-hidden').html();$j('.wikieditor-toolbar-table-preview-header').html(hiddenHTML);$j('.wikieditor-toolbar-table-preview-hidden').html(headerHTML);if(typeof ts_makeSortable=='function') |
135 | 135 | ts_makeSortable($j('#wikieditor-toolbar-table-preview, #wikieditor-toolbar-table-preview2').filter('.sortable').get(0));});},dialog:{resizable:false,dialogClass:'wikiEditor-toolbar-dialog',width:590,buttons:{'wikieditor-toolbar-tool-table-insert':function(){var rowsVal=$j('#wikieditor-toolbar-table-dimensions-rows').val();var colsVal=$j('#wikieditor-toolbar-table-dimensions-columns').val();var rows=parseInt(rowsVal,10);var cols=parseInt(colsVal,10);var header=$j('#wikieditor-toolbar-table-dimensions-header').is(':checked')?1:0;var u=mw.usability;if(isNaN(rows)||isNaN(cols)||rows!=rowsVal||cols!=colsVal){alert(u.getMsg('wikieditor-toolbar-tool-table-invalidnumber'));return;} |
136 | 136 | if(rows+header==0||cols==0){alert(u.getMsg('wikieditor-toolbar-tool-table-zero'));return;} |
— | — | @@ -166,7 +166,7 @@ |
167 | 167 | <input type="checkbox" id="wikieditor-toolbar-replace-regex" />\ |
168 | 168 | <label for="wikieditor-toolbar-replace-regex" rel="wikieditor-toolbar-tool-replace-regex"></label>\ |
169 | 169 | </div>\ |
170 | | - </fieldset>',init:function(){var u=mw.usability;$j(this).find('[rel]').each(function(){$j(this).text(u.getMsg($j(this).attr('rel')));});$j(this).data('replaceCallback',function(mode){$j('#wikieditor-toolbar-replace-nomatch, #wikieditor-toolbar-replace-success, #wikieditor-toolbar-replace-emptysearch, #wikieditor-toolbar-replace-invalidregex').hide();var searchStr=$j('#wikieditor-toolbar-replace-search').val();if(searchStr==''){$j('#wikieditor-toolbar-replace-emptysearch').show();return;} |
| 170 | + </fieldset>',init:function(){var u=mw.usability;$j(this).find('[rel]').each(function(){$j(this).text(u.getMsg($j(this).attr('rel')));});$j.wikiEditor.modules.dialogs.fn.setTabindexes($j(this).find('input').not('[tabindex]'));$j(this).data('replaceCallback',function(mode){$j('#wikieditor-toolbar-replace-nomatch, #wikieditor-toolbar-replace-success, #wikieditor-toolbar-replace-emptysearch, #wikieditor-toolbar-replace-invalidregex').hide();var searchStr=$j('#wikieditor-toolbar-replace-search').val();if(searchStr==''){$j('#wikieditor-toolbar-replace-emptysearch').show();return;} |
171 | 171 | var replaceStr=$j('#wikieditor-toolbar-replace-replace').val();var flags='m';var matchCase=$j('#wikieditor-toolbar-replace-case').is(':checked');var isRegex=$j('#wikieditor-toolbar-replace-regex').is(':checked');if(!matchCase){flags+='i';} |
172 | 172 | if(mode=='replaceAll'){flags+='g';} |
173 | 173 | if(!isRegex){searchStr=RegExp.escape(searchStr);} |
Index: trunk/extensions/UsabilityInitiative/WikiEditor/Modules/Toolbar/Toolbar.js |
— | — | @@ -999,6 +999,8 @@ |
1000 | 1000 | $j(this).find( '[rel]' ).each( function() { |
1001 | 1001 | $j(this).text( u.getMsg( $j(this).attr( 'rel' ) ) ); |
1002 | 1002 | }); |
| 1003 | + // Set tabindexes on form fields |
| 1004 | + $j.wikiEditor.modules.dialogs.fn.setTabindexes( $j(this).find( 'input' ).not( '[tabindex]' ) ); |
1003 | 1005 | // Setup the tooltips in the textboxes |
1004 | 1006 | $j( '#wikieditor-toolbar-link-int-target' ) |
1005 | 1007 | .data( 'tooltip', u.getMsg( 'wikieditor-toolbar-tool-link-int-target-tooltip' ) ); |
— | — | @@ -1438,6 +1440,9 @@ |
1439 | 1441 | $j(this).find( '[rel]' ).each( function() { |
1440 | 1442 | $j(this).text( mw.usability.getMsg( $j(this).attr( 'rel' ) ) ); |
1441 | 1443 | }); |
| 1444 | + // Set tabindexes on form fields |
| 1445 | + $j.wikiEditor.modules.dialogs.fn.setTabindexes( $j(this).find( 'input' ).not( '[tabindex]' ) ); |
| 1446 | + |
1442 | 1447 | $j( '#wikieditor-toolbar-table-dimensions-rows' ).val( 4 ); |
1443 | 1448 | $j( '#wikieditor-toolbar-table-dimensions-columns' ).val( 3 ); |
1444 | 1449 | $j( '#wikieditor-toolbar-table-wikitable' ).click( function() { |
— | — | @@ -1637,6 +1642,8 @@ |
1638 | 1643 | $j(this).find( '[rel]' ).each( function() { |
1639 | 1644 | $j(this).text( u.getMsg( $j(this).attr( 'rel' ) ) ); |
1640 | 1645 | }); |
| 1646 | + // Set tabindexes on form fields |
| 1647 | + $j.wikiEditor.modules.dialogs.fn.setTabindexes( $j(this).find( 'input' ).not( '[tabindex]' ) ); |
1641 | 1648 | |
1642 | 1649 | // TODO: Find a cleaner way to share this function |
1643 | 1650 | $j(this).data( 'replaceCallback', function( mode ) { |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.dialogs.js |
— | — | @@ -98,19 +98,22 @@ |
99 | 99 | configuration.title = $.wikiEditor.autoMsg( module, 'title' ); |
100 | 100 | // Transform messages in keys |
101 | 101 | // Stupid JS won't let us do stuff like |
102 | | - // foo = { mw.usability.getMsg ('bar'): baz } |
| 102 | + // foo = { mw.usability.getMsg( 'bar' ): baz } |
103 | 103 | configuration.newButtons = {}; |
104 | 104 | for ( msg in configuration.buttons ) |
105 | 105 | configuration.newButtons[mw.usability.getMsg( msg )] = configuration.buttons[msg]; |
106 | 106 | configuration.buttons = configuration.newButtons; |
107 | 107 | // Create the dialog <div> |
108 | | - var dialogDiv = $( '<div /> ' ) |
| 108 | + var dialogDiv = $( '<div />' ) |
109 | 109 | .attr( 'id', module.id ) |
110 | 110 | .html( module.html ) |
111 | 111 | .data( 'context', context ) |
112 | 112 | .appendTo( $( 'body' ) ) |
113 | 113 | .each( module.init ) |
114 | 114 | .dialog( configuration ); |
| 115 | + // Set tabindexes on buttons added by .dialog() |
| 116 | + $.wikiEditor.modules.dialogs.fn.setTabindexes( dialogDiv.closest( '.ui-dialog' ) |
| 117 | + .find( 'button' ).not( '[tabindex]' ) ); |
115 | 118 | if ( !( 'resizeme' in module ) || module.resizeme ) { |
116 | 119 | dialogDiv |
117 | 120 | .bind( 'dialogopen', $.wikiEditor.modules.dialogs.fn.resize ) |
— | — | @@ -122,22 +125,7 @@ |
123 | 126 | dialogDiv.bind( 'dialogclose', function() { |
124 | 127 | context.fn.restoreSelection(); |
125 | 128 | } ); |
126 | | - // Add tabindexes to dialog form elements |
127 | | - // Find the highest tabindex in use |
128 | | - var maxTI = 0; |
129 | | - $j( '[tabindex]' ).each( function() { |
130 | | - var ti = parseInt( $j(this).attr( 'tabindex' ) ); |
131 | | - if ( ti > maxTI ) |
132 | | - maxTI = ti; |
133 | | - }); |
134 | 129 | |
135 | | - var tabIndex = maxTI + 1; |
136 | | - $j( '.ui-dialog input, .ui-dialog button' ) |
137 | | - .not( '[tabindex]' ) |
138 | | - .each( function() { |
139 | | - $j(this).attr( 'tabindex', tabIndex++ ); |
140 | | - }); |
141 | | - |
142 | 130 | // Let the outside world know we set up this dialog |
143 | 131 | context.$textarea.trigger( 'wikiEditor-dialogs-loaded-' + mod ); |
144 | 132 | } |
— | — | @@ -181,6 +169,23 @@ |
182 | 170 | oldHidden.each( function() { |
183 | 171 | $(this).attr( 'style', $(this).data( 'oldstyle' ) ); |
184 | 172 | }); |
| 173 | + }, |
| 174 | + /** |
| 175 | + * Set the right tabindexes on elements in a dialog |
| 176 | + * @param $elements Elements to set tabindexes on. If they already have tabindexes, this function can behave a bit weird |
| 177 | + */ |
| 178 | + setTabindexes: function( $elements ) { |
| 179 | + // Find the highest tabindex in use |
| 180 | + var maxTI = 0; |
| 181 | + $j( '[tabindex]' ).each( function() { |
| 182 | + var ti = parseInt( $j(this).attr( 'tabindex' ) ); |
| 183 | + if ( ti > maxTI ) |
| 184 | + maxTI = ti; |
| 185 | + }); |
| 186 | + var tabIndex = maxTI + 1; |
| 187 | + $elements.each( function() { |
| 188 | + $j(this).attr( 'tabindex', tabIndex++ ); |
| 189 | + } ); |
185 | 190 | } |
186 | 191 | }, |
187 | 192 | // This stuff is just hanging here, perhaps we could come up with a better home for this stuff |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js |
— | — | @@ -392,6 +392,16 @@ |
393 | 393 | // Ensure our close button doesn't recieve the ui-state-focus class |
394 | 394 | $( this ).parent( '.ui-dialog' ).find( '.ui-dialog-titlebar-close' ) |
395 | 395 | .removeClass( 'ui-state-focus' ); |
| 396 | + |
| 397 | + // Set tabindexes on form fields if needed |
| 398 | + // First unset the tabindexes on the buttons and existing form fields |
| 399 | + // so the order doesn't get messed up |
| 400 | + var $needTabindex = $( this ).closest( '.ui-dialog' ).find( 'button, textarea' ); |
| 401 | + if ( $needTabindex.not( '[tabindex]' ).length ) { |
| 402 | + // Only do this if there actually are elements missing a tabindex |
| 403 | + $needTabindex.removeAttr( 'tabindex' ); |
| 404 | + $.wikiEditor.modules.dialogs.fn.setTabindexes( $needTabindex ); |
| 405 | + } |
396 | 406 | } |
397 | 407 | } |
398 | 408 | }; |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -8450,19 +8450,22 @@ |
8451 | 8451 | configuration.title = $.wikiEditor.autoMsg( module, 'title' ); |
8452 | 8452 | // Transform messages in keys |
8453 | 8453 | // Stupid JS won't let us do stuff like |
8454 | | - // foo = { mw.usability.getMsg ('bar'): baz } |
| 8454 | + // foo = { mw.usability.getMsg( 'bar' ): baz } |
8455 | 8455 | configuration.newButtons = {}; |
8456 | 8456 | for ( msg in configuration.buttons ) |
8457 | 8457 | configuration.newButtons[mw.usability.getMsg( msg )] = configuration.buttons[msg]; |
8458 | 8458 | configuration.buttons = configuration.newButtons; |
8459 | 8459 | // Create the dialog <div> |
8460 | | - var dialogDiv = $( '<div /> ' ) |
| 8460 | + var dialogDiv = $( '<div />' ) |
8461 | 8461 | .attr( 'id', module.id ) |
8462 | 8462 | .html( module.html ) |
8463 | 8463 | .data( 'context', context ) |
8464 | 8464 | .appendTo( $( 'body' ) ) |
8465 | 8465 | .each( module.init ) |
8466 | 8466 | .dialog( configuration ); |
| 8467 | + // Set tabindexes on buttons added by .dialog() |
| 8468 | + $.wikiEditor.modules.dialogs.fn.setTabindexes( dialogDiv.closest( '.ui-dialog' ) |
| 8469 | + .find( 'button' ).not( '[tabindex]' ) ); |
8467 | 8470 | if ( !( 'resizeme' in module ) || module.resizeme ) { |
8468 | 8471 | dialogDiv |
8469 | 8472 | .bind( 'dialogopen', $.wikiEditor.modules.dialogs.fn.resize ) |
— | — | @@ -8474,22 +8477,7 @@ |
8475 | 8478 | dialogDiv.bind( 'dialogclose', function() { |
8476 | 8479 | context.fn.restoreSelection(); |
8477 | 8480 | } ); |
8478 | | - // Add tabindexes to dialog form elements |
8479 | | - // Find the highest tabindex in use |
8480 | | - var maxTI = 0; |
8481 | | - $j( '[tabindex]' ).each( function() { |
8482 | | - var ti = parseInt( $j(this).attr( 'tabindex' ) ); |
8483 | | - if ( ti > maxTI ) |
8484 | | - maxTI = ti; |
8485 | | - }); |
8486 | 8481 | |
8487 | | - var tabIndex = maxTI + 1; |
8488 | | - $j( '.ui-dialog input, .ui-dialog button' ) |
8489 | | - .not( '[tabindex]' ) |
8490 | | - .each( function() { |
8491 | | - $j(this).attr( 'tabindex', tabIndex++ ); |
8492 | | - }); |
8493 | | - |
8494 | 8482 | // Let the outside world know we set up this dialog |
8495 | 8483 | context.$textarea.trigger( 'wikiEditor-dialogs-loaded-' + mod ); |
8496 | 8484 | } |
— | — | @@ -8533,6 +8521,23 @@ |
8534 | 8522 | oldHidden.each( function() { |
8535 | 8523 | $(this).attr( 'style', $(this).data( 'oldstyle' ) ); |
8536 | 8524 | }); |
| 8525 | + }, |
| 8526 | + /** |
| 8527 | + * Set the right tabindexes on elements in a dialog |
| 8528 | + * @param $elements Elements to set tabindexes on. If they already have tabindexes, this function can behave a bit weird |
| 8529 | + */ |
| 8530 | + setTabindexes: function( $elements ) { |
| 8531 | + // Find the highest tabindex in use |
| 8532 | + var maxTI = 0; |
| 8533 | + $j( '[tabindex]' ).each( function() { |
| 8534 | + var ti = parseInt( $j(this).attr( 'tabindex' ) ); |
| 8535 | + if ( ti > maxTI ) |
| 8536 | + maxTI = ti; |
| 8537 | + }); |
| 8538 | + var tabIndex = maxTI + 1; |
| 8539 | + $elements.each( function() { |
| 8540 | + $j(this).attr( 'tabindex', tabIndex++ ); |
| 8541 | + } ); |
8537 | 8542 | } |
8538 | 8543 | }, |
8539 | 8544 | // This stuff is just hanging here, perhaps we could come up with a better home for this stuff |
— | — | @@ -9696,6 +9701,16 @@ |
9697 | 9702 | // Ensure our close button doesn't recieve the ui-state-focus class |
9698 | 9703 | $( this ).parent( '.ui-dialog' ).find( '.ui-dialog-titlebar-close' ) |
9699 | 9704 | .removeClass( 'ui-state-focus' ); |
| 9705 | + |
| 9706 | + // Set tabindexes on form fields if needed |
| 9707 | + // First unset the tabindexes on the buttons and existing form fields |
| 9708 | + // so the order doesn't get messed up |
| 9709 | + var $needTabindex = $( this ).closest( '.ui-dialog' ).find( 'button, textarea' ); |
| 9710 | + if ( $needTabindex.not( '[tabindex]' ).length ) { |
| 9711 | + // Only do this if there actually are elements missing a tabindex |
| 9712 | + $needTabindex.removeAttr( 'tabindex' ); |
| 9713 | + $.wikiEditor.modules.dialogs.fn.setTabindexes( $needTabindex ); |
| 9714 | + } |
9700 | 9715 | } |
9701 | 9716 | } |
9702 | 9717 | }; |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -583,10 +583,10 @@ |
584 | 584 | mw.usability.load(['$j.ui','$j.ui.dialog','$j.ui.draggable','$j.ui.resizable'],function(){for(mod in $.wikiEditor.modules.dialogs.modules){var module=$.wikiEditor.modules.dialogs.modules[mod];var filtered=false;if(typeof module.filters!='undefined'){for(var i=0;i<module.filters.length;i++){if($(module.filters[i]).length==0){filtered=true;break;}}} |
585 | 585 | if(!filtered&&$.wikiEditor.isSupported(module)&&$('#'+module.id).size()==0){if(typeof context.$iframe=='undefined'&&$.wikiEditor.isRequired(module,'iframe')){context.fn.setupIframe();} |
586 | 586 | 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) |
587 | | -configuration.newButtons[mw.usability.getMsg(msg)]=configuration.buttons[msg];configuration.buttons=configuration.newButtons;var dialogDiv=$('<div /> ').attr('id',module.id).html(module.html).data('context',context).appendTo($('body')).each(module.init).dialog(configuration);if(!('resizeme'in module)||module.resizeme){dialogDiv.bind('dialogopen',$.wikiEditor.modules.dialogs.fn.resize).find('.ui-tabs').bind('tabsshow',function(){$(this).closest('.ui-dialog-content').each($.wikiEditor.modules.dialogs.fn.resize);});} |
588 | | -dialogDiv.bind('dialogclose',function(){context.fn.restoreSelection();});var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI) |
589 | | -maxTI=ti;});var tabIndex=maxTI+1;$j('.ui-dialog input, .ui-dialog button').not('[tabindex]').each(function(){$j(this).attr('tabindex',tabIndex++);});context.$textarea.trigger('wikiEditor-dialogs-loaded-'+mod);}}});},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){var thisWidth=$(this).data('thisWidth')?$(this).data('thisWidth'):0;thisWidth=Math.max($(this).get(0).scrollWidth,thisWidth);$(this).width(thisWidth);$(this).data('thisWidth',thisWidth);var wrapperWidth=$(this).data('wrapperWidth')?$(this).data('wrapperWidth'):0;wrapperWidth=Math.max(wrapper.get(0).scrollWidth,wrapperWidth);wrapper.width(wrapperWidth);$(this).data('wrapperWidth',wrapperWidth);$(this).dialog({'width':wrapper.width()});wrapper.css('left',parseInt(wrapper.css('left'))-(wrapper.width()-oldWidth)/2);} |
590 | | -$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={'req':['iframe'],cfg:{'styleVersion':3},evt:{delayedChange:function(context,event){$.wikiEditor.modules.highlight.currentScope=event.data.scope;if(event.data.scope=='realchange'){$.wikiEditor.modules.highlight.fn.scan(context,'');$.wikiEditor.modules.highlight.fn.mark(context,'realchange','');}},ready:function(context,event){$.wikiEditor.modules.highlight.currentScope='ready';$.wikiEditor.modules.highlight.fn.scan(context,'');$.wikiEditor.modules.highlight.fn.mark(context,'','');}},fn:{create:function(context,config){context.modules.highlight.markersStr='';},divide:function(context){},isolate:function(context){return[];},strip:function(context,division){return $('<div />').html(division.html().replace(/\<br[^\>]*\>/g,"\n")).text();},scan:function(context,division){function Token(offset,label,tokenStart,match){this.offset=offset;this.label=label;this.tokenStart=tokenStart;this.match=match;} |
| 587 | +configuration.newButtons[mw.usability.getMsg(msg)]=configuration.buttons[msg];configuration.buttons=configuration.newButtons;var dialogDiv=$('<div />').attr('id',module.id).html(module.html).data('context',context).appendTo($('body')).each(module.init).dialog(configuration);$.wikiEditor.modules.dialogs.fn.setTabindexes(dialogDiv.closest('.ui-dialog').find('button').not('[tabindex]'));if(!('resizeme'in module)||module.resizeme){dialogDiv.bind('dialogopen',$.wikiEditor.modules.dialogs.fn.resize).find('.ui-tabs').bind('tabsshow',function(){$(this).closest('.ui-dialog-content').each($.wikiEditor.modules.dialogs.fn.resize);});} |
| 588 | +dialogDiv.bind('dialogclose',function(){context.fn.restoreSelection();});context.$textarea.trigger('wikiEditor-dialogs-loaded-'+mod);}}});},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){var thisWidth=$(this).data('thisWidth')?$(this).data('thisWidth'):0;thisWidth=Math.max($(this).get(0).scrollWidth,thisWidth);$(this).width(thisWidth);$(this).data('thisWidth',thisWidth);var wrapperWidth=$(this).data('wrapperWidth')?$(this).data('wrapperWidth'):0;wrapperWidth=Math.max(wrapper.get(0).scrollWidth,wrapperWidth);wrapper.width(wrapperWidth);$(this).data('wrapperWidth',wrapperWidth);$(this).dialog({'width':wrapper.width()});wrapper.css('left',parseInt(wrapper.css('left'))-(wrapper.width()-oldWidth)/2);} |
| 589 | +$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});},setTabindexes:function($elements){var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI) |
| 590 | +maxTI=ti;});var tabIndex=maxTI+1;$elements.each(function(){$j(this).attr('tabindex',tabIndex++);});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={'req':['iframe'],cfg:{'styleVersion':3},evt:{delayedChange:function(context,event){$.wikiEditor.modules.highlight.currentScope=event.data.scope;if(event.data.scope=='realchange'){$.wikiEditor.modules.highlight.fn.scan(context,'');$.wikiEditor.modules.highlight.fn.mark(context,'realchange','');}},ready:function(context,event){$.wikiEditor.modules.highlight.currentScope='ready';$.wikiEditor.modules.highlight.fn.scan(context,'');$.wikiEditor.modules.highlight.fn.mark(context,'','');}},fn:{create:function(context,config){context.modules.highlight.markersStr='';},divide:function(context){},isolate:function(context){return[];},strip:function(context,division){return $('<div />').html(division.html().replace(/\<br[^\>]*\>/g,"\n")).text();},scan:function(context,division){function Token(offset,label,tokenStart,match){this.offset=offset;this.label=label;this.tokenStart=tokenStart;this.match=match;} |
591 | 591 | var tokenArray=context.modules.highlight.tokenArray=[];var text=context.fn.getContents();for(module in context.modules){if(module in $.wikiEditor.modules&&'exp'in $.wikiEditor.modules[module]){for(var i=0;i<$.wikiEditor.modules[module].exp.length;i++){var regex=$.wikiEditor.modules[module].exp[i].regex;var label=$.wikiEditor.modules[module].exp[i].label;var markAfter=false;if(typeof $.wikiEditor.modules[module].exp[i].markAfter!='undefined'){markAfter=true;} |
592 | 592 | match=text.match(regex);var oldOffset=0;while(match!=null){var markOffset=0;var tokenStart=match.index+oldOffset+markOffset;if(markAfter){markOffset+=match[0].length;} |
593 | 593 | tokenArray.push(new Token(match.index+oldOffset+markOffset,label,tokenStart,match));oldOffset+=match.index+match[0].length;newSubstring=text.substring(oldOffset);match=newSubstring.match(regex);}}}} |
— | — | @@ -665,7 +665,7 @@ |
666 | 666 | var params=templateModel.getAllInitialParams();var $fields=$(this).find('.wikiEditor-template-dialog-fields');var $rows=$fields.find('.wikiEditor-template-dialog-field-wrapper');for(var paramIndex in params){var param=params[paramIndex];if(typeof param.name=='undefined'){continue;} |
667 | 667 | var paramText=typeof param=='string'?param.name.replace(/[\_\-]/g,' '):param.name;var paramVal=templateModel.getValue(param.name);if($rows.length>0){var $row=$rows.eq(0);$row.children('label').text(paramText);$row.children('textarea').data('name',param.name).val(paramVal).each(function(){$(this).css('height',$(this).val().length>24?'4.5em':'1.5em');}) |
668 | 668 | $rows=$rows.not($row);}else{var $paramRow=$('<div />').addClass('wikiEditor-template-dialog-field-wrapper');$('<label />').text(paramText).appendTo($paramRow);$('<textarea />').data('name',param.name).val(paramVal).each(function(){$(this).css('height',$(this).val().length>24?'4.5em':'1.5em');}).data('expanded',false).bind('cut paste keypress click change',function(e){if(e.keyCode=='9')return true;var $this=$(this);setTimeout(function(){var expanded=$this.data('expanded');if($this.val().indexOf('\n')!=-1||$this.val().length>24){if(!expanded){$this.animate({'height':'4.5em'},'fast');$this.data('expanded',true);}}else{if(expanded){$this.animate({'height':'1.5em'},'fast');$this.data('expanded',false);}}},0);}).appendTo($paramRow);$paramRow.append('<div style="clear:both"></div>').appendTo($fields);}} |
669 | | -$rows.remove();$fields.find('label').autoEllipsis();$(this).parent('.ui-dialog').find('.ui-dialog-titlebar-close').removeClass('ui-state-focus');}}};context.$textarea.wikiEditor('addDialog',{'templateEditor':dialog});$('#'+dialog.id).data('templateDiv',$template).dialog('open');},updateModel:function($templateText,model){var context=$templateText.data('marker').context;var text;if(typeof model=='undefined'){text=context.fn.htmlToText($templateText.html());}else{text=model.getText();} |
| 669 | +$rows.remove();$fields.find('label').autoEllipsis();$(this).parent('.ui-dialog').find('.ui-dialog-titlebar-close').removeClass('ui-state-focus');var $needTabindex=$(this).closest('.ui-dialog').find('button, textarea');if($needTabindex.not('[tabindex]').length){$needTabindex.removeAttr('tabindex');$.wikiEditor.modules.dialogs.fn.setTabindexes($needTabindex);}}}};context.$textarea.wikiEditor('addDialog',{'templateEditor':dialog});$('#'+dialog.id).data('templateDiv',$template).dialog('open');},updateModel:function($templateText,model){var context=$templateText.data('marker').context;var text;if(typeof model=='undefined'){text=context.fn.htmlToText($templateText.html());}else{text=model.getText();} |
670 | 670 | $templateText.text(text);$templateText.html($templateText.html().replace(/\n/g,'<br />'));$templateText.data('oldHTML',$templateText.html());if(typeof model=='undefined'){model=new $.wikiEditor.modules.templateEditor.fn.model(text);$templateText.data('model',model);} |
671 | 671 | return model;},getTemplateDisplayName:function(model){var tName=model.getName();if(tName in $.wikiEditor.modules.templateEditor.nameMappings){return tName+': '+model.getValue($.wikiEditor.modules.templateEditor.nameMappings[tName]);}else if(model.getValue('name')!=''){return tName+': '+model.getValue('name');}else if(model.getValue('Name')!=''){return tName+': '+model.getValue('Name');} |
672 | 672 | return tName;},model:function(wikitext){var collapsible=true;function Param(name,value,number,nameIndex,equalsIndex,valueIndex){this.name=name;this.value=value;this.number=number;this.nameIndex=nameIndex;this.equalsIndex=equalsIndex;this.valueIndex=valueIndex;} |