Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -61,7 +61,7 @@ |
62 | 62 | array( 'src' => 'js/plugins/jquery.browser.js', 'version' => 3 ), |
63 | 63 | array( 'src' => 'js/plugins/jquery.cookie.js', 'version' => 3 ), |
64 | 64 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ), |
65 | | - array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 2 ), |
| 65 | + array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 3 ), |
66 | 66 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 9 ), |
67 | 67 | array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 4 ), |
68 | 68 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 11 ), |
— | — | @@ -70,10 +70,10 @@ |
71 | 71 | array( 'src' => 'js/js2/jquery-ui-1.7.2.js', 'version' => '1.7.2x' ), |
72 | 72 | ), |
73 | 73 | 'combined' => array( |
74 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 20 ), |
| 74 | + array( 'src' => 'js/plugins.combined.js', 'version' => 21 ), |
75 | 75 | ), |
76 | 76 | 'minified' => array( |
77 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 20 ), |
| 77 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 21 ), |
78 | 78 | ), |
79 | 79 | ), |
80 | 80 | ); |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js |
— | — | @@ -716,14 +716,14 @@ |
717 | 717 | </tr><tr>\ |
718 | 718 | <td><label for="edittoolbar-link-int-text" rel="edittoolbar-tool-link-int-text"></label></td>\ |
719 | 719 | <td><input type="text" id="edittoolbar-link-int-text" /></td>\ |
720 | | - </table></fieldset></form></div>\ |
| 720 | + </table></fieldset><input type="submit" style="display: none;" /></form></div>\ |
721 | 721 | <div id="edittoolbar-link-dialog-tab-ext"><form><fieldset><table><tr>\ |
722 | 722 | <td><label for="edittoolbar-link-ext-target" rel="edittoolbar-tool-link-ext-target"></label></td>\ |
723 | 723 | <td><input type="text" id="edittoolbar-link-ext-target" /></td>\ |
724 | 724 | </tr><tr>\ |
725 | 725 | <td><label for="edittoolbar-link-ext-text" rel="edittoolbar-tool-link-ext-text"></label></td>\ |
726 | 726 | <td><input type="text" id="edittoolbar-link-ext-text" /></td>\ |
727 | | - </table></fieldset></form></div>\ |
| 727 | + </table></fieldset><input type="submit" style="display: none;" /></form></div>\ |
728 | 728 | </div>', |
729 | 729 | init: function() { |
730 | 730 | // Updates the UI to show if the page title being inputed by the user exists or not |
— | — | @@ -788,6 +788,15 @@ |
789 | 789 | $j(this).find( '[rel]' ).each( function() { |
790 | 790 | $j(this).text( gM( $j(this).attr( 'rel' ) ) ); |
791 | 791 | }); |
| 792 | + // Assign the proper action to the hidden submit buttons |
| 793 | + // triggered when the user presses Enter |
| 794 | + $j(this).find( 'form' ).submit( function( e ) { |
| 795 | + e.preventDefault(); |
| 796 | + $j(this) |
| 797 | + .closest( '.ui-dialog' ) |
| 798 | + .find( 'button:first' ) |
| 799 | + .click(); |
| 800 | + }); |
792 | 801 | // Build tabs |
793 | 802 | $j( '#edittoolbar-link-tabs' ).tabs(); |
794 | 803 | // Automatically copy the value of the internal link page title field to the link text field unless the user |
— | — | @@ -1022,11 +1031,20 @@ |
1023 | 1032 | <td class="label"><label for="edittoolbar-table-dimensions-rows"\ |
1024 | 1033 | rel="edittoolbar-tool-table-dimensions-rows"></label></td>\ |
1025 | 1034 | <td><input type="text" id="edittoolbar-table-dimensions-rows" size="2" /></td>\ |
1026 | | - </tr></table></fieldset></form>', |
| 1035 | + </tr></table></fieldset><input type="submit" style="display: none;" /></form>', |
1027 | 1036 | init: function() { |
1028 | 1037 | $j(this).find( '[rel]' ).each( function() { |
1029 | 1038 | $j(this).text( gM( $j(this).attr( 'rel' ) ) ); |
1030 | 1039 | }); |
| 1040 | + // Assign the proper action to the hidden submit buttons |
| 1041 | + // triggered when the user presses Enter |
| 1042 | + $j(this).find( 'form' ).submit( function( e ) { |
| 1043 | + e.preventDefault(); |
| 1044 | + $j(this) |
| 1045 | + .closest( '.ui-dialog' ) |
| 1046 | + .find( 'button:first' ) |
| 1047 | + .click(); |
| 1048 | + }); |
1031 | 1049 | $j( '#edittoolbar-table-dimensions-rows' ).val( 2 ); |
1032 | 1050 | $j( '#edittoolbar-table-dimensions-columns' ).val( 2 ); |
1033 | 1051 | }, |
— | — | @@ -1093,11 +1111,20 @@ |
1094 | 1112 | </tr><tr>\ |
1095 | 1113 | <td><input type="checkbox" id="edittoolbar-replace-all" /></td>\ |
1096 | 1114 | <td><label for="edittoolbar-replace-all" rel="edittoolbar-tool-replace-all"></label></td>\ |
1097 | | - </tr></table></fieldset></form>', |
| 1115 | + </tr></table></fieldset><input type="submit" style="display: none;" /></form>', |
1098 | 1116 | init: function() { |
1099 | 1117 | $j(this).find( '[rel]' ).each( function() { |
1100 | 1118 | $j(this).text( gM( $j(this).attr( 'rel' ) ) ); |
1101 | 1119 | }); |
| 1120 | + // Assign the proper action to the hidden submit buttons |
| 1121 | + // triggered when the user presses Enter |
| 1122 | + $j(this).find( 'form' ).submit( function( e ) { |
| 1123 | + e.preventDefault(); |
| 1124 | + $j(this) |
| 1125 | + .closest( '.ui-dialog' ) |
| 1126 | + .find( 'button:first' ) |
| 1127 | + .click(); |
| 1128 | + }); |
1102 | 1129 | }, |
1103 | 1130 | dialog: { |
1104 | 1131 | buttons: { |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | /* Configuration */ |
21 | 21 | |
22 | 22 | // Bump the version number every time you change any of the .css/.js files |
23 | | -$wgEditToolbarStyleVersion = 31; |
| 23 | +$wgEditToolbarStyleVersion = 32; |
24 | 24 | |
25 | 25 | // Set this to true to simply override the stock toolbar for everyone |
26 | 26 | $wgEditToolbarGlobalEnable = false; |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.suggestions.js |
— | — | @@ -199,23 +199,27 @@ |
200 | 200 | * Respond to keypress event |
201 | 201 | * @param {Integer} key Code of key pressed |
202 | 202 | */ |
203 | | - keypress: function( context, key ) { |
| 203 | + keypress: function( e, context, key ) { |
| 204 | + var wasVisible = context.data.$container.is( ':visible' ); |
| 205 | + var preventDefault = false; |
204 | 206 | switch ( key ) { |
205 | 207 | // Arrow down |
206 | 208 | case 40: |
207 | | - if ( context.data.$container.is( ':visible' ) ) { |
| 209 | + if ( wasVisible ) { |
208 | 210 | $.suggestions.highlight( context, 'next', true ); |
209 | 211 | } else { |
210 | 212 | $.suggestions.update( context, false ); |
211 | 213 | } |
212 | 214 | context.data.$textbox.trigger( 'change' ); |
| 215 | + preventDefault = true; |
213 | 216 | break; |
214 | 217 | // Arrow up |
215 | 218 | case 38: |
216 | | - if ( context.data.$container.is( ':visible' ) ) { |
| 219 | + if ( wasVisible ) { |
217 | 220 | $.suggestions.highlight( context, 'prev', true ); |
218 | 221 | } |
219 | 222 | context.data.$textbox.trigger( 'change' ); |
| 223 | + preventDefault = wasVisible; |
220 | 224 | break; |
221 | 225 | // Escape |
222 | 226 | case 27: |
— | — | @@ -223,15 +227,21 @@ |
224 | 228 | $.suggestions.restore( context ); |
225 | 229 | $.suggestions.cancel( context ); |
226 | 230 | context.data.$textbox.trigger( 'change' ); |
| 231 | + preventDefault = wasVisible; |
227 | 232 | break; |
228 | 233 | // Enter |
229 | 234 | case 13: |
230 | 235 | context.data.$container.hide(); |
| 236 | + preventDefault = wasVisible; |
231 | 237 | break; |
232 | 238 | default: |
233 | 239 | $.suggestions.update( context, true ); |
234 | 240 | break; |
235 | 241 | } |
| 242 | + if ( preventDefault ) { |
| 243 | + e.preventDefault(); |
| 244 | + e.stopImmediatePropagation(); |
| 245 | + } |
236 | 246 | } |
237 | 247 | }; |
238 | 248 | $.fn.suggestions = function() { |
— | — | @@ -357,16 +367,32 @@ |
358 | 368 | // Store key pressed to handle later |
359 | 369 | context.data.keypressed = ( e.keyCode == undefined ) ? e.which : e.keyCode; |
360 | 370 | context.data.keypressedCount = 0; |
| 371 | + |
| 372 | + switch ( context.data.keypressed ) { |
| 373 | + // This preventDefault logic is duplicated from |
| 374 | + // $.suggestions.keypress(), which sucks |
| 375 | + case 40: |
| 376 | + e.preventDefault(); |
| 377 | + e.stopImmediatePropagation(); |
| 378 | + break; |
| 379 | + case 38: |
| 380 | + case 27: |
| 381 | + case 13: |
| 382 | + if ( context.data.$container.is( ':visible' ) ) { |
| 383 | + e.preventDefault(); |
| 384 | + e.stopImmediatePropagation(); |
| 385 | + } |
| 386 | + } |
361 | 387 | } ) |
362 | | - .keypress( function() { |
| 388 | + .keypress( function( e ) { |
363 | 389 | context.data.keypressedCount++; |
364 | | - $.suggestions.keypress( context, context.data.keypressed ); |
| 390 | + $.suggestions.keypress( e, context, context.data.keypressed ); |
365 | 391 | } ) |
366 | 392 | .keyup( function() { |
367 | 393 | // Some browsers won't throw keypress() for arrow keys. If we got a keydown and a keyup without a |
368 | 394 | // keypress in between, solve it |
369 | 395 | if ( context.data.keypressedCount == 0 ) { |
370 | | - $.suggestions.keypress( context, context.data.keypressed ); |
| 396 | + $.suggestions.keypress( e, context, context.data.keypressed ); |
371 | 397 | } |
372 | 398 | } ) |
373 | 399 | .blur( function() { |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -496,23 +496,27 @@ |
497 | 497 | * Respond to keypress event |
498 | 498 | * @param {Integer} key Code of key pressed |
499 | 499 | */ |
500 | | - keypress: function( context, key ) { |
| 500 | + keypress: function( e, context, key ) { |
| 501 | + var wasVisible = context.data.$container.is( ':visible' ); |
| 502 | + var preventDefault = false; |
501 | 503 | switch ( key ) { |
502 | 504 | // Arrow down |
503 | 505 | case 40: |
504 | | - if ( context.data.$container.is( ':visible' ) ) { |
| 506 | + if ( wasVisible ) { |
505 | 507 | $.suggestions.highlight( context, 'next', true ); |
506 | 508 | } else { |
507 | 509 | $.suggestions.update( context, false ); |
508 | 510 | } |
509 | 511 | context.data.$textbox.trigger( 'change' ); |
| 512 | + preventDefault = true; |
510 | 513 | break; |
511 | 514 | // Arrow up |
512 | 515 | case 38: |
513 | | - if ( context.data.$container.is( ':visible' ) ) { |
| 516 | + if ( wasVisible ) { |
514 | 517 | $.suggestions.highlight( context, 'prev', true ); |
515 | 518 | } |
516 | 519 | context.data.$textbox.trigger( 'change' ); |
| 520 | + preventDefault = wasVisible; |
517 | 521 | break; |
518 | 522 | // Escape |
519 | 523 | case 27: |
— | — | @@ -520,15 +524,21 @@ |
521 | 525 | $.suggestions.restore( context ); |
522 | 526 | $.suggestions.cancel( context ); |
523 | 527 | context.data.$textbox.trigger( 'change' ); |
| 528 | + preventDefault = wasVisible; |
524 | 529 | break; |
525 | 530 | // Enter |
526 | 531 | case 13: |
527 | 532 | context.data.$container.hide(); |
| 533 | + preventDefault = wasVisible; |
528 | 534 | break; |
529 | 535 | default: |
530 | 536 | $.suggestions.update( context, true ); |
531 | 537 | break; |
532 | 538 | } |
| 539 | + if ( preventDefault ) { |
| 540 | + e.preventDefault(); |
| 541 | + e.stopImmediatePropagation(); |
| 542 | + } |
533 | 543 | } |
534 | 544 | }; |
535 | 545 | $.fn.suggestions = function() { |
— | — | @@ -654,16 +664,32 @@ |
655 | 665 | // Store key pressed to handle later |
656 | 666 | context.data.keypressed = ( e.keyCode == undefined ) ? e.which : e.keyCode; |
657 | 667 | context.data.keypressedCount = 0; |
| 668 | + |
| 669 | + switch ( context.data.keypressed ) { |
| 670 | + // This preventDefault logic is duplicated from |
| 671 | + // $.suggestions.keypress(), which sucks |
| 672 | + case 40: |
| 673 | + e.preventDefault(); |
| 674 | + e.stopImmediatePropagation(); |
| 675 | + break; |
| 676 | + case 38: |
| 677 | + case 27: |
| 678 | + case 13: |
| 679 | + if ( context.data.$container.is( ':visible' ) ) { |
| 680 | + e.preventDefault(); |
| 681 | + e.stopImmediatePropagation(); |
| 682 | + } |
| 683 | + } |
658 | 684 | } ) |
659 | | - .keypress( function() { |
| 685 | + .keypress( function( e ) { |
660 | 686 | context.data.keypressedCount++; |
661 | | - $.suggestions.keypress( context, context.data.keypressed ); |
| 687 | + $.suggestions.keypress( e, context, context.data.keypressed ); |
662 | 688 | } ) |
663 | 689 | .keyup( function() { |
664 | 690 | // Some browsers won't throw keypress() for arrow keys. If we got a keydown and a keyup without a |
665 | 691 | // keypress in between, solve it |
666 | 692 | if ( context.data.keypressedCount == 0 ) { |
667 | | - $.suggestions.keypress( context, context.data.keypressed ); |
| 693 | + $.suggestions.keypress( e, context, context.data.keypressed ); |
668 | 694 | } |
669 | 695 | } ) |
670 | 696 | .blur( function() { |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -32,15 +32,16 @@ |
33 | 33 | result=selected;}} |
34 | 34 | selected.removeClass('suggestions-result-current');result.addClass('suggestions-result-current');} |
35 | 35 | if(updateTextbox){if(result.size()==0){$.suggestions.restore(context);}else{context.data.$textbox.val(result.data('text'));context.data.$textbox.change();}} |
36 | | -$.suggestions.special(context);},keypress:function(context,key){switch(key){case 40:if(context.data.$container.is(':visible')){$.suggestions.highlight(context,'next',true);}else{$.suggestions.update(context,false);} |
37 | | -context.data.$textbox.trigger('change');break;case 38:if(context.data.$container.is(':visible')){$.suggestions.highlight(context,'prev',true);} |
38 | | -context.data.$textbox.trigger('change');break;case 27:context.data.$container.hide();$.suggestions.restore(context);$.suggestions.cancel(context);context.data.$textbox.trigger('change');break;case 13:context.data.$container.hide();break;default:$.suggestions.update(context,true);break;}}};$.fn.suggestions=function(){var returnValue=null;var args=arguments;$(this).each(function(){var context=$(this).data('suggestions-context');if(typeof context=='undefined'){context={config:{'fetch':function(){},'cancel':function(){},'special':{},'result':{},'$region':$(this),'suggestions':[],'maxRows':7,'delay':1200,'submitOnClick':false}};} |
| 36 | +$.suggestions.special(context);},keypress:function(e,context,key){var wasVisible=context.data.$container.is(':visible');var preventDefault=false;switch(key){case 40:if(wasVisible){$.suggestions.highlight(context,'next',true);}else{$.suggestions.update(context,false);} |
| 37 | +context.data.$textbox.trigger('change');preventDefault=true;break;case 38:if(wasVisible){$.suggestions.highlight(context,'prev',true);} |
| 38 | +context.data.$textbox.trigger('change');preventDefault=wasVisible;break;case 27:context.data.$container.hide();$.suggestions.restore(context);$.suggestions.cancel(context);context.data.$textbox.trigger('change');preventDefault=wasVisible;break;case 13:context.data.$container.hide();preventDefault=wasVisible;break;default:$.suggestions.update(context,true);break;} |
| 39 | +if(preventDefault){e.preventDefault();e.stopImmediatePropagation();}}};$.fn.suggestions=function(){var returnValue=null;var args=arguments;$(this).each(function(){var context=$(this).data('suggestions-context');if(typeof context=='undefined'){context={config:{'fetch':function(){},'cancel':function(){},'special':{},'result':{},'$region':$(this),'suggestions':[],'maxRows':7,'delay':1200,'submitOnClick':false}};} |
39 | 40 | if(args.length>0){if(typeof args[0]=='object'){for(key in args[0]){$.suggestions.configure(context,key,args[0][key]);}}else if(typeof args[0]=='string'){if(args.length>1){$.suggestions.configure(context,args[0],args[1]);}else if(returnValue==null){returnValue=(args[0]in context.config?undefined:context.config[args[0]]);}}} |
40 | 41 | if(typeof context.data=='undefined'){context.data={'timerID':null,'prevText':null,'visibleResults':0,'mouseDownOn':$([]),'$textbox':$(this)};context.data.$container=$('<div />').css({'top':Math.round(context.data.$textbox.offset().top+context.data.$textbox.outerHeight()),'left':Math.round(context.data.$textbox.offset().left),'width':context.data.$textbox.outerWidth(),'display':'none'}).mouseover(function(e){$.suggestions.highlight(context,$(e.target).closest('.suggestions-results div'),false);}).addClass('suggestions').append($('<div />').addClass('suggestions-results').mousedown(function(e){context.data.mouseDownOn=$(e.target).closest('.suggestions-results div');}).mouseup(function(e){var $result=$(e.target).closest('.suggestions-results div');var $other=context.data.mouseDownOn;context.data.mouseDownOn=$([]);if($result.get(0)!=$other.get(0)){return;} |
41 | 42 | $.suggestions.highlight(context,$result,true);context.data.$container.hide();if(typeof context.config.result.select=='function'){context.config.result.select.call($result,context.data.$textbox);} |
42 | 43 | context.data.$textbox.focus();})).append($('<div />').addClass('suggestions-special').mousedown(function(e){context.data.mouseDownOn=$(e.target).closest('.suggestions-special');}).mouseup(function(e){var $special=$(e.target).closest('.suggestions-special');var $other=context.data.mouseDownOn;context.data.mouseDownOn=$([]);if($special.get(0)!=$other.get(0)){return;} |
43 | 44 | context.data.$container.hide();if(typeof context.config.special.select=='function'){context.config.special.select.call($special,context.data.$textbox);} |
44 | | -context.data.$textbox.focus();})).appendTo($('body'));$(this).attr('autocomplete','off').keydown(function(e){context.data.keypressed=(e.keyCode==undefined)?e.which:e.keyCode;context.data.keypressedCount=0;}).keypress(function(){context.data.keypressedCount++;$.suggestions.keypress(context,context.data.keypressed);}).keyup(function(){if(context.data.keypressedCount==0){$.suggestions.keypress(context,context.data.keypressed);}}).blur(function(){if(context.data.mouseDownOn.size()>0){return;} |
| 45 | +context.data.$textbox.focus();})).appendTo($('body'));$(this).attr('autocomplete','off').keydown(function(e){context.data.keypressed=(e.keyCode==undefined)?e.which:e.keyCode;context.data.keypressedCount=0;switch(context.data.keypressed){case 40:e.preventDefault();e.stopImmediatePropagation();break;case 38:case 27:case 13:if(context.data.$container.is(':visible')){e.preventDefault();e.stopImmediatePropagation();}}}).keypress(function(e){context.data.keypressedCount++;$.suggestions.keypress(e,context,context.data.keypressed);}).keyup(function(){if(context.data.keypressedCount==0){$.suggestions.keypress(e,context,context.data.keypressed);}}).blur(function(){if(context.data.mouseDownOn.size()>0){return;} |
45 | 46 | context.data.$container.hide();$.suggestions.cancel(context);});} |
46 | 47 | $(this).data('suggestions-context',context);});return returnValue!==null?returnValue:$(this);};})(jQuery);(function($){$.fn.extend({getSelection:function(){var e=this.jquery?this[0]:this;var retval='';if(e.style.display=='none'){}else if(document.selection&&document.selection.createRange){var range=document.selection.createRange();retval=range.text;}else if(e.selectionStart||e.selectionStart=='0'){retval=e.value.substring(e.selectionStart,e.selectionEnd);} |
47 | 48 | return retval;},encapsulateSelection:function(pre,peri,post,ownline,replace){function checkSelectedText(){if(!selText){selText=peri;isSample=true;}else if(replace){selText=peri;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);post+=' '}} |