r66286 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66285‎ | r66286 | r66287 >
Date:19:40, 12 May 2010
Author:catrope
Status:deferred
Tags:
Comment:
UsabilityInitiative: (bug 23485) (bug 23061) Selection not getting picked up in IE. Save and restore cursor position in addition to scrollTop, and generalize that into context.fn.saveStuffForIE() and context.fn.restoreStuffForIE()
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/WikiEditor/Modules/Toolbar/Toolbar.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.hooks.php (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.textSelection.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -71,10 +71,10 @@
7272 array( 'src' => 'js/plugins/jquery.cookie.js', 'version' => 4 ),
7373 array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ),
7474 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 13 ),
75 - array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 31 ),
76 - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 186 ),
 75+ array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 32 ),
 76+ array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 187 ),
7777 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 53 ),
78 - array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 60 ),
 78+ array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 61 ),
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 24 ),
8080 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 98 ),
8181 array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 11 ),
@@ -83,10 +83,10 @@
8484 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 5 ),
8585 ),
8686 'combined' => array(
87 - array( 'src' => 'js/plugins.combined.js', 'version' => 392 ),
 87+ array( 'src' => 'js/plugins.combined.js', 'version' => 393 ),
8888 ),
8989 'minified' => array(
90 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 392 ),
 90+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 393 ),
9191 ),
9292 ),
9393 );
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.hooks.php
@@ -16,16 +16,16 @@
1717 array( 'src' => 'Modules/Preview/Preview.js', 'version' => 6 ),
1818 array( 'src' => 'Modules/Publish/Publish.js', 'version' => 6 ),
1919 array( 'src' => 'Modules/Toc/Toc.js', 'version' => 7 ),
20 - array( 'src' => 'Modules/Toolbar/Toolbar.js', 'version' => 84 ),
 20+ array( 'src' => 'Modules/Toolbar/Toolbar.js', 'version' => 85 ),
2121 array( 'src' => 'Modules/TemplateEditor/TemplateEditor.js', 'version' => 6 ),
2222 array( 'src' => 'Modules/Templates/Templates.js', 'version' => 1 ),
2323 array( 'src' => 'Modules/AddMediaWizard/AddMediaWizard.js', 'version' => 6 ),
2424 ),
2525 'combined' => array(
26 - array( 'src' => 'WikiEditor.combined.js', 'version' => 89 ),
 26+ array( 'src' => 'WikiEditor.combined.js', 'version' => 90 ),
2727 ),
2828 'minified' => array(
29 - array( 'src' => 'WikiEditor.combined.min.js', 'version' => 89 ),
 29+ array( 'src' => 'WikiEditor.combined.min.js', 'version' => 90 ),
3030 ),
3131 );
3232 static $messages = array(
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.js
@@ -1424,6 +1424,8 @@
14251425 $j( '#wikieditor-toolbar-link-type-int, #wikieditor-toolbar-link-type-ext' ).attr( 'checked', '' );
14261426 },
14271427 'wikieditor-toolbar-tool-link-cancel': function() {
 1428+ // Clear any saved selection state
 1429+ context.fn.restoreStuffForIE();
14281430 $j(this).dialog( 'close' );
14291431 }
14301432 },
@@ -1434,8 +1436,11 @@
14351437 .replace( /\\\$1/g, '(.*)' ) + '$'
14361438 ) );
14371439 // Pre-fill the text fields based on the current selection
1438 - var selection = $j(this).data( 'context' )
1439 - .$textarea.textSelection( 'getSelection' );
 1440+ var context = $j(this).data( 'context' );
 1441+ // Restore and immediately save selection state, needed for inserting stuff later
 1442+ context.fn.restoreStuffForIE();
 1443+ context.fn.saveStuffForIE();
 1444+ var selection = context.$textarea.textSelection( 'getSelection' );
14401445 $j( '#wikieditor-toolbar-link-int-target' ).focus();
14411446 // Trigger the change event, so the link status indicator is up to date
14421447 $j( '#wikieditor-toolbar-link-int-target' ).change();
@@ -1554,13 +1559,18 @@
15551560 $j( '#wikieditor-toolbar-reference-text' ).val( "" );
15561561 },
15571562 'wikieditor-toolbar-tool-reference-cancel': function() {
 1563+ // Clear any saved selection state
 1564+ context.fn.restoreStuffForIE();
15581565 $j( this ).dialog( 'close' );
15591566 }
15601567 },
15611568 open: function() {
15621569 // Pre-fill the text fields based on the current selection
1563 - var selection = $j(this).data( 'context' )
1564 - .$textarea.textSelection( 'getSelection' );
 1570+ var context = $j(this).data( 'context' );
 1571+ // Restore and immediately save selection state, needed for inserting stuff later
 1572+ context.fn.restoreStuffForIE();
 1573+ context.fn.saveStuffForIE();
 1574+ var selection = context.$textarea.textSelection( 'getSelection' );
15651575 // set focus
15661576 $j( '#wikieditor-toolbar-reference-text' ).focus();
15671577 $j( '#wikieditor-toolbar-reference-dialog' )
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.min.js
@@ -68,7 +68,7 @@
6969 insertText=escTarget;else if(text=='')
7070 insertText='['+escTarget+']';else
7171 insertText='['+escTarget+' '+escText+']';}
72 -if(whitespace)insertText=whitespace[0]+insertText+whitespace[1];$j(this).dialog('close');$j.wikiEditor.modules.toolbar.fn.doAction($j(this).data('context'),{type:'replace',options:{pre:insertText}},$j(this));$j('#wikieditor-toolbar-link-int-target, #wikieditor-toolbar-link-int-text').val('');$j('#wikieditor-toolbar-link-type-int, #wikieditor-toolbar-link-type-ext').attr('checked','');},'wikieditor-toolbar-tool-link-cancel':function(){$j(this).dialog('close');}},open:function(){$j(this).data('articlePathRegex',new RegExp('^'+RegExp.escape(wgServer+wgArticlePath).replace(/\\\$1/g,'(.*)')+'$'));var selection=$j(this).data('context').$textarea.textSelection('getSelection');$j('#wikieditor-toolbar-link-int-target').focus();$j('#wikieditor-toolbar-link-int-target').change();$j('#wikieditor-toolbar-link-dialog').data('whitespace',['','']);if(selection!=''){var target,text,type;var matches;if((matches=selection.match(/^(\s*)\[\[([^\]\|]+)(\|([^\]\|]*))?\]\](\s*)$/))){target=matches[2];text=(matches[4]?matches[4]:matches[2]);type='int';$j('#wikieditor-toolbar-link-dialog').data('whitespace',[matches[1],matches[5]]);}else if((matches=selection.match(/^(\s*)\[([^\] ]+)( ([^\]]+))?\](\s*)$/))){target=matches[2];text=(matches[4]?matches[4]:'');type='ext';$j('#wikieditor-toolbar-link-dialog').data('whitespace',[matches[1],matches[5]]);}else{target=text=selection;}
 72+if(whitespace)insertText=whitespace[0]+insertText+whitespace[1];$j(this).dialog('close');$j.wikiEditor.modules.toolbar.fn.doAction($j(this).data('context'),{type:'replace',options:{pre:insertText}},$j(this));$j('#wikieditor-toolbar-link-int-target, #wikieditor-toolbar-link-int-text').val('');$j('#wikieditor-toolbar-link-type-int, #wikieditor-toolbar-link-type-ext').attr('checked','');},'wikieditor-toolbar-tool-link-cancel':function(){context.fn.restoreStuffForIE();$j(this).dialog('close');}},open:function(){$j(this).data('articlePathRegex',new RegExp('^'+RegExp.escape(wgServer+wgArticlePath).replace(/\\\$1/g,'(.*)')+'$'));var context=$j(this).data('context');context.fn.restoreStuffForIE();context.fn.saveStuffForIE();var selection=context.$textarea.textSelection('getSelection');$j('#wikieditor-toolbar-link-int-target').focus();$j('#wikieditor-toolbar-link-int-target').change();$j('#wikieditor-toolbar-link-dialog').data('whitespace',['','']);if(selection!=''){var target,text,type;var matches;if((matches=selection.match(/^(\s*)\[\[([^\]\|]+)(\|([^\]\|]*))?\]\](\s*)$/))){target=matches[2];text=(matches[4]?matches[4]:matches[2]);type='int';$j('#wikieditor-toolbar-link-dialog').data('whitespace',[matches[1],matches[5]]);}else if((matches=selection.match(/^(\s*)\[([^\] ]+)( ([^\]]+))?\](\s*)$/))){target=matches[2];text=(matches[4]?matches[4]:'');type='ext';$j('#wikieditor-toolbar-link-dialog').data('whitespace',[matches[1],matches[5]]);}else{target=text=selection;}
7373 if(typeof text!='undefined')
7474 $j('#wikieditor-toolbar-link-int-text').val(text).change();if(typeof target!='undefined')
7575 $j('#wikieditor-toolbar-link-int-target').val(target).change();if(typeof type!='undefined')
@@ -84,7 +84,7 @@
8585 <input type="text" id="wikieditor-toolbar-reference-text" />\
8686 </div>\
8787 </div></fieldset>\
88 - </div>',init:function(){$j(this).find('[rel]').each(function(){$j(this).text(mw.usability.getMsg($j(this).attr('rel')));});},dialog:{dialogClass:'wikiEditor-toolbar-dialog',width:590,buttons:{'wikieditor-toolbar-tool-reference-insert':function(){var insertText=$j('#wikieditor-toolbar-reference-text').val();var whitespace=$j('#wikieditor-toolbar-reference-dialog').data('whitespace');var attributes=$j('#wikieditor-toolbar-reference-dialog').data('attributes');$j(this).dialog('close');$j.wikiEditor.modules.toolbar.fn.doAction($j(this).data('context'),{type:'replace',options:{pre:whitespace[0]+'<ref'+attributes+'>',peri:insertText,post:'</ref>'+whitespace[1]}},$j(this));$j('#wikieditor-toolbar-reference-text').val("");},'wikieditor-toolbar-tool-reference-cancel':function(){$j(this).dialog('close');}},open:function(){var selection=$j(this).data('context').$textarea.textSelection('getSelection');$j('#wikieditor-toolbar-reference-text').focus();$j('#wikieditor-toolbar-reference-dialog').data('whitespace',['','']).data('attributes','');if(selection!=''){var matches,text;if((matches=selection.match(/^(\s*)<ref([^\>]*)>([^\<]*)<\/ref\>(\s*)$/))){text=matches[3];$j('#wikieditor-toolbar-reference-dialog').data('whitespace',[matches[1],matches[4]]);$j('#wikieditor-toolbar-reference-dialog').data('attributes',matches[2]);}else{text=selection;}
 88+ </div>',init:function(){$j(this).find('[rel]').each(function(){$j(this).text(mw.usability.getMsg($j(this).attr('rel')));});},dialog:{dialogClass:'wikiEditor-toolbar-dialog',width:590,buttons:{'wikieditor-toolbar-tool-reference-insert':function(){var insertText=$j('#wikieditor-toolbar-reference-text').val();var whitespace=$j('#wikieditor-toolbar-reference-dialog').data('whitespace');var attributes=$j('#wikieditor-toolbar-reference-dialog').data('attributes');$j(this).dialog('close');$j.wikiEditor.modules.toolbar.fn.doAction($j(this).data('context'),{type:'replace',options:{pre:whitespace[0]+'<ref'+attributes+'>',peri:insertText,post:'</ref>'+whitespace[1]}},$j(this));$j('#wikieditor-toolbar-reference-text').val("");},'wikieditor-toolbar-tool-reference-cancel':function(){context.fn.restoreStuffForIE();$j(this).dialog('close');}},open:function(){var context=$j(this).data('context');context.fn.restoreStuffForIE();context.fn.saveStuffForIE();var selection=context.$textarea.textSelection('getSelection');$j('#wikieditor-toolbar-reference-text').focus();$j('#wikieditor-toolbar-reference-dialog').data('whitespace',['','']).data('attributes','');if(selection!=''){var matches,text;if((matches=selection.match(/^(\s*)<ref([^\>]*)>([^\<]*)<\/ref\>(\s*)$/))){text=matches[3];$j('#wikieditor-toolbar-reference-dialog').data('whitespace',[matches[1],matches[4]]);$j('#wikieditor-toolbar-reference-dialog').data('attributes',matches[2]);}else{text=selection;}
8989 $j('#wikieditor-toolbar-reference-text').val(text);}
9090 if(!($j(this).data('dialogkeypressset'))){$j(this).data('dialogkeypressset',true);$j(this).closest('.ui-dialog').keypress(function(e){if((e.keyCode||e.which)==13){var button=$j(this).data('dialogaction')||$j(this).find('button:first');button.click();e.preventDefault();}});$j(this).closest('.ui-dialog').find('button').focus(function(){$j(this).closest('.ui-dialog').data('dialogaction',this);});}}}},'insert-table':{filters:['#wpTextbox1.toolbar-dialogs'],titleMsg:'wikieditor-toolbar-tool-table-title',id:'wikieditor-toolbar-table-dialog',html:'\
9191 <div class="wikieditor-toolbar-dialog-wrapper">\
Index: trunk/extensions/UsabilityInitiative/WikiEditor/Modules/Toolbar/Toolbar.js
@@ -1375,6 +1375,8 @@
13761376 $j( '#wikieditor-toolbar-link-type-int, #wikieditor-toolbar-link-type-ext' ).attr( 'checked', '' );
13771377 },
13781378 'wikieditor-toolbar-tool-link-cancel': function() {
 1379+ // Clear any saved selection state
 1380+ context.fn.restoreStuffForIE();
13791381 $j(this).dialog( 'close' );
13801382 }
13811383 },
@@ -1385,8 +1387,11 @@
13861388 .replace( /\\\$1/g, '(.*)' ) + '$'
13871389 ) );
13881390 // Pre-fill the text fields based on the current selection
1389 - var selection = $j(this).data( 'context' )
1390 - .$textarea.textSelection( 'getSelection' );
 1391+ var context = $j(this).data( 'context' );
 1392+ // Restore and immediately save selection state, needed for inserting stuff later
 1393+ context.fn.restoreStuffForIE();
 1394+ context.fn.saveStuffForIE();
 1395+ var selection = context.$textarea.textSelection( 'getSelection' );
13911396 $j( '#wikieditor-toolbar-link-int-target' ).focus();
13921397 // Trigger the change event, so the link status indicator is up to date
13931398 $j( '#wikieditor-toolbar-link-int-target' ).change();
@@ -1505,13 +1510,18 @@
15061511 $j( '#wikieditor-toolbar-reference-text' ).val( "" );
15071512 },
15081513 'wikieditor-toolbar-tool-reference-cancel': function() {
 1514+ // Clear any saved selection state
 1515+ context.fn.restoreStuffForIE();
15091516 $j( this ).dialog( 'close' );
15101517 }
15111518 },
15121519 open: function() {
15131520 // Pre-fill the text fields based on the current selection
1514 - var selection = $j(this).data( 'context' )
1515 - .$textarea.textSelection( 'getSelection' );
 1521+ var context = $j(this).data( 'context' );
 1522+ // Restore and immediately save selection state, needed for inserting stuff later
 1523+ context.fn.restoreStuffForIE();
 1524+ context.fn.saveStuffForIE();
 1525+ var selection = context.$textarea.textSelection( 'getSelection' );
15161526 // set focus
15171527 $j( '#wikieditor-toolbar-reference-text' ).focus();
15181528 $j( '#wikieditor-toolbar-reference-dialog' )
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js
@@ -52,13 +52,13 @@
5353 options.post += ' ';
5454 }
5555 }
56 - var selText = $(this).textSelection( 'getSelection' );
5756 var isSample = false;
5857 if ( this.style.display == 'none' ) {
5958 // Do nothing
6059 } else if ( this.selectionStart || this.selectionStart == '0' ) {
6160 // Mozilla/Opera
6261 $(this).focus();
 62+ var selText = $(this).textSelection( 'getSelection' );
6363 var startPos = this.selectionStart;
6464 var endPos = this.selectionEnd;
6565 var scrollTop = this.scrollTop;
@@ -90,13 +90,10 @@
9191 }
9292 } else if ( document.selection && document.selection.createRange ) {
9393 // IE
94 - // For some mysterious reason, clicking a toolbar button is enough to make
95 - // the textarea scroll. Check if a toolbar button's mousedown handler saved
96 - // the scroll position and use it if available.
97 - var scrollTop = $(this).data( 'scrollTop' ) || this.scrollTop;
98 - $(this).data( 'scrollTop', null );
9994 $(this).focus();
100 - this.scrollTop = scrollTop;
 95+ context.fn.restoreStuffForIE();
 96+ var selText = $(this).textSelection( 'getSelection' );
 97+ var scrollTop = this.scrollTop;
10198 var range = document.selection.createRange();
10299 if ( options.ownline && range.moveStart ) {
103100 var range2 = document.selection.createRange();
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -1724,6 +1724,33 @@
17251725 body.scrollTop( y );
17261726 }
17271727 $element.trigger( 'scrollToTop' );
 1728+ },
 1729+ /**
 1730+ * Save scrollTop and cursor position for IE.
 1731+ */
 1732+ 'saveStuffForIE': function() {
 1733+ // Only need this for IE in textarea mode
 1734+ if ( !$.browser.msie || context.$iframe )
 1735+ return;
 1736+ var IHateIE = {
 1737+ 'scrollTop' : context.$textarea.scrollTop(),
 1738+ 'pos': context.$textarea.textSelection( 'getCaretPosition', { startAndEnd: true } )
 1739+ };
 1740+ context.$textarea.data( 'IHateIE', IHateIE );
 1741+ },
 1742+ /**
 1743+ * Restore scrollTo and cursor position for IE.
 1744+ */
 1745+ 'restoreStuffForIE': function() {
 1746+ // Only need this for IE in textarea mode
 1747+ if ( !$.browser.msie || context.$iframe )
 1748+ return;
 1749+ var IHateIE = context.$textarea.data( 'IHateIE' );
 1750+ if ( !IHateIE )
 1751+ return;
 1752+ context.$textarea.scrollTop( IHateIE.scrollTop );
 1753+ context.$textarea.textSelection( 'setSelection', { start: IHateIE.pos[0], end: IHateIE.pos[1] } );
 1754+ context.$textarea.data( 'IHateIE', null );
17281755 }
17291756 };
17301757
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js
@@ -111,8 +111,7 @@
112112 .append(
113113 $( $.wikiEditor.modules.toolbar.fn.buildCharacter( data[type][character], actions ) )
114114 .mousedown( function( e ) {
115 - // Save scroll position for IE
116 - context.$textarea.data( 'scrollTop', context.$textarea.scrollTop() );
 115+ context.fn.saveStuffForIE();
117116 // No dragging!
118117 e.preventDefault();
119118 return false;
@@ -344,8 +343,7 @@
345344 .data( 'action', tool.action )
346345 .data( 'context', context )
347346 .mousedown( function( e ) {
348 - // Save scroll position for IE
349 - context.$textarea.data( 'scrollTop', context.$textarea.scrollTop() );
 347+ context.fn.saveStuffForIE();
350348 // No dragging!
351349 e.preventDefault();
352350 return false;
@@ -382,8 +380,7 @@
383381 .data( 'action', tool.list[option].action )
384382 .data( 'context', context )
385383 .mousedown( function( e ) {
386 - // Save scroll position for IE
387 - context.$textarea.data( 'scrollTop', context.$textarea.scrollTop() );
 384+ context.fn.saveStuffForIE();
388385 // No dragging!
389386 e.preventDefault();
390387 return false;
@@ -499,8 +496,7 @@
500497 .html( html )
501498 .children()
502499 .mousedown( function( e ) {
503 - // Save scroll position for IE
504 - context.$textarea.data( 'scrollTop', context.$textarea.scrollTop() );
 500+ context.fn.saveStuffForIE();
505501 // No dragging!
506502 e.preventDefault();
507503 return false;
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -6254,13 +6254,13 @@
62556255 options.post += ' ';
62566256 }
62576257 }
6258 - var selText = $(this).textSelection( 'getSelection' );
62596258 var isSample = false;
62606259 if ( this.style.display == 'none' ) {
62616260 // Do nothing
62626261 } else if ( this.selectionStart || this.selectionStart == '0' ) {
62636262 // Mozilla/Opera
62646263 $(this).focus();
 6264+ var selText = $(this).textSelection( 'getSelection' );
62656265 var startPos = this.selectionStart;
62666266 var endPos = this.selectionEnd;
62676267 var scrollTop = this.scrollTop;
@@ -6292,13 +6292,10 @@
62936293 }
62946294 } else if ( document.selection && document.selection.createRange ) {
62956295 // IE
6296 - // For some mysterious reason, clicking a toolbar button is enough to make
6297 - // the textarea scroll. Check if a toolbar button's mousedown handler saved
6298 - // the scroll position and use it if available.
6299 - var scrollTop = $(this).data( 'scrollTop' ) || this.scrollTop;
6300 - $(this).data( 'scrollTop', null );
63016296 $(this).focus();
6302 - this.scrollTop = scrollTop;
 6297+ context.fn.restoreStuffForIE();
 6298+ var selText = $(this).textSelection( 'getSelection' );
 6299+ var scrollTop = this.scrollTop;
63036300 var range = document.selection.createRange();
63046301 if ( options.ownline && range.moveStart ) {
63056302 var range2 = document.selection.createRange();
@@ -8325,6 +8322,33 @@
83268323 body.scrollTop( y );
83278324 }
83288325 $element.trigger( 'scrollToTop' );
 8326+ },
 8327+ /**
 8328+ * Save scrollTop and cursor position for IE.
 8329+ */
 8330+ 'saveStuffForIE': function() {
 8331+ // Only need this for IE in textarea mode
 8332+ if ( !$.browser.msie || context.$iframe )
 8333+ return;
 8334+ var IHateIE = {
 8335+ 'scrollTop' : context.$textarea.scrollTop(),
 8336+ 'pos': context.$textarea.textSelection( 'getCaretPosition', { startAndEnd: true } )
 8337+ };
 8338+ context.$textarea.data( 'IHateIE', IHateIE );
 8339+ },
 8340+ /**
 8341+ * Restore scrollTo and cursor position for IE.
 8342+ */
 8343+ 'restoreStuffForIE': function() {
 8344+ // Only need this for IE in textarea mode
 8345+ if ( !$.browser.msie || context.$iframe )
 8346+ return;
 8347+ var IHateIE = context.$textarea.data( 'IHateIE' );
 8348+ if ( !IHateIE )
 8349+ return;
 8350+ context.$textarea.scrollTop( IHateIE.scrollTop );
 8351+ context.$textarea.textSelection( 'setSelection', { start: IHateIE.pos[0], end: IHateIE.pos[1] } );
 8352+ context.$textarea.data( 'IHateIE', null );
83298353 }
83308354 };
83318355
@@ -10935,8 +10959,7 @@
1093610960 .append(
1093710961 $( $.wikiEditor.modules.toolbar.fn.buildCharacter( data[type][character], actions ) )
1093810962 .mousedown( function( e ) {
10939 - // Save scroll position for IE
10940 - context.$textarea.data( 'scrollTop', context.$textarea.scrollTop() );
 10963+ context.fn.saveStuffForIE();
1094110964 // No dragging!
1094210965 e.preventDefault();
1094310966 return false;
@@ -11168,8 +11191,7 @@
1116911192 .data( 'action', tool.action )
1117011193 .data( 'context', context )
1117111194 .mousedown( function( e ) {
11172 - // Save scroll position for IE
11173 - context.$textarea.data( 'scrollTop', context.$textarea.scrollTop() );
 11195+ context.fn.saveStuffForIE();
1117411196 // No dragging!
1117511197 e.preventDefault();
1117611198 return false;
@@ -11206,8 +11228,7 @@
1120711229 .data( 'action', tool.list[option].action )
1120811230 .data( 'context', context )
1120911231 .mousedown( function( e ) {
11210 - // Save scroll position for IE
11211 - context.$textarea.data( 'scrollTop', context.$textarea.scrollTop() );
 11232+ context.fn.saveStuffForIE();
1121211233 // No dragging!
1121311234 e.preventDefault();
1121411235 return false;
@@ -11323,8 +11344,7 @@
1132411345 .html( html )
1132511346 .children()
1132611347 .mousedown( function( e ) {
11327 - // Save scroll position for IE
11328 - context.$textarea.data( 'scrollTop', context.$textarea.scrollTop() );
 11348+ context.fn.saveStuffForIE();
1132911349 // No dragging!
1133011350 e.preventDefault();
1133111351 return false;
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -414,12 +414,12 @@
415415 context.data.$container.hide();$.suggestions.cancel(context);});}
416416 $(this).data('suggestions-context',context);});return returnValue!==null?returnValue:$(this);};})(jQuery);(function($){$.fn.textSelection=function(command,options){var fn={getContents:function(){return this.val();},getSelection:function(){var e=this.get(0);var retval='';if($(e).is(':hidden')){}else if(document.selection&&document.selection.createRange){e.focus();var range=document.selection.createRange();retval=range.text;}else if(e.selectionStart||e.selectionStart=='0'){retval=e.value.substring(e.selectionStart,e.selectionEnd);}
417417 return retval;},encapsulateSelection:function(options){return this.each(function(){function checkSelectedText(){if(!selText){selText=options.peri;isSample=true;}else if(options.replace){selText=options.peri;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);options.post+=' ';}}
418 -var selText=$(this).textSelection('getSelection');var isSample=false;if(this.style.display=='none'){}else if(this.selectionStart||this.selectionStart=='0'){$(this).focus();var startPos=this.selectionStart;var endPos=this.selectionEnd;var scrollTop=this.scrollTop;checkSelectedText();if(options.ownline){if(startPos!=0&&this.value.charAt(startPos-1)!="\n"){options.pre="\n"+options.pre;}
 418+var isSample=false;if(this.style.display=='none'){}else if(this.selectionStart||this.selectionStart=='0'){$(this).focus();var selText=$(this).textSelection('getSelection');var startPos=this.selectionStart;var endPos=this.selectionEnd;var scrollTop=this.scrollTop;checkSelectedText();if(options.ownline){if(startPos!=0&&this.value.charAt(startPos-1)!="\n"){options.pre="\n"+options.pre;}
419419 if(this.value.charAt(endPos)!="\n"){options.post+="\n";}}
420420 this.value=this.value.substring(0,startPos)+options.pre+selText+options.post+
421421 this.value.substring(endPos,this.value.length);this.scrollTop=scrollTop;if(window.opera){options.pre=options.pre.replace(/\r?\n/g,"\r\n");selText=selText.replace(/\r?\n/g,"\r\n");options.post=options.post.replace(/\r?\n/g,"\r\n");}
422422 if(isSample){this.selectionStart=startPos+options.pre.length;this.selectionEnd=startPos+options.pre.length+selText.length;}else{this.selectionStart=startPos+options.pre.length+selText.length+
423 -options.post.length;this.selectionEnd=this.selectionStart;}}else if(document.selection&&document.selection.createRange){var scrollTop=$(this).data('scrollTop')||this.scrollTop;$(this).data('scrollTop',null);$(this).focus();this.scrollTop=scrollTop;var range=document.selection.createRange();if(options.ownline&&range.moveStart){var range2=document.selection.createRange();range2.collapse();range2.moveStart('character',-1);if(range2.text!="\r"&&range2.text!="\n"&&range2.text!=""){options.pre="\n"+options.pre;}
 423+options.post.length;this.selectionEnd=this.selectionStart;}}else if(document.selection&&document.selection.createRange){$(this).focus();context.fn.restoreStuffForIE();var selText=$(this).textSelection('getSelection');var scrollTop=this.scrollTop;var range=document.selection.createRange();if(options.ownline&&range.moveStart){var range2=document.selection.createRange();range2.collapse();range2.moveStart('character',-1);if(range2.text!="\r"&&range2.text!="\n"&&range2.text!=""){options.pre="\n"+options.pre;}
424424 var range3=document.selection.createRange();range3.collapse(false);range3.moveEnd('character',1);if(range3.text!="\r"&&range3.text!="\n"&&range3.text!=""){options.post+="\n";}}
425425 checkSelectedText();range.text=options.pre+selText+options.post;if(isSample&&range.moveStart){range.moveStart('character',-options.post.length-selText.length);range.moveEnd('character',-options.post.length);}
426426 range.select();this.scrollTop=scrollTop;}
@@ -576,7 +576,10 @@
577577 range2.setEndPoint('StartToEnd',range);range2.select();}
578578 return context.$textarea;},'scrollToCaretPosition':function(options){context.fn.scrollToTop(context.fn.getElementAtCursor(),true);},'scrollToTop':function($element,force){var html=context.$content.closest('html'),body=context.$content.closest('body'),parentHtml=$('html'),parentBody=$('body');var y=$element.offset().top;if(!$.browser.msie&&!$element.is('body')){y=parentHtml.scrollTop()>0?y+html.scrollTop()-parentHtml.scrollTop():y;y=parentBody.scrollTop()>0?y+body.scrollTop()-parentBody.scrollTop():y;}
579579 var topBound=html.scrollTop()>body.scrollTop()?html.scrollTop():body.scrollTop(),bottomBound=topBound+context.$iframe.height();if(force||y<topBound||y>bottomBound){html.scrollTop(y);body.scrollTop(y);}
580 -$element.trigger('scrollToTop');}};context.$textarea.wrapAll($('<div></div>').addClass('wikiEditor-ui')).wrapAll($('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-wikitext')).wrapAll($('<div></div>').addClass('wikiEditor-ui-left')).wrapAll($('<div></div>').addClass('wikiEditor-ui-bottom')).wrapAll($('<div></div>').addClass('wikiEditor-ui-text'));context.$ui=context.$textarea.parent().parent().parent().parent().parent();context.$wikitext=context.$textarea.parent().parent().parent().parent();context.$wikitext.before($('<div></div>').addClass('wikiEditor-ui-controls').append($('<div></div>').addClass('wikiEditor-ui-tabs').hide()).append($('<div></div>').addClass('wikiEditor-ui-buttons'))).before($('<div style="clear:both;"></div>'));context.$controls=context.$ui.find('.wikiEditor-ui-buttons').hide();context.$buttons=context.$ui.find('.wikiEditor-ui-buttons');context.$tabs=context.$ui.find('.wikiEditor-ui-tabs');context.$ui.after($('<div style="clear:both;"></div>'));context.$wikitext.append($('<div></div>').addClass('wikiEditor-ui-right'));context.$wikitext.find('.wikiEditor-ui-left').prepend($('<div></div>').addClass('wikiEditor-ui-top'));context.view='wikitext';$(window).resize(function(event){context.fn.trigger('resize',event);});}
 580+$element.trigger('scrollToTop');},'saveStuffForIE':function(){if(!$.browser.msie||context.$iframe)
 581+return;var IHateIE={'scrollTop':context.$textarea.scrollTop(),'pos':context.$textarea.textSelection('getCaretPosition',{startAndEnd:true})};context.$textarea.data('IHateIE',IHateIE);},'restoreStuffForIE':function(){if(!$.browser.msie||context.$iframe)
 582+return;var IHateIE=context.$textarea.data('IHateIE');if(!IHateIE)
 583+return;context.$textarea.scrollTop(IHateIE.scrollTop);context.$textarea.textSelection('setSelection',{start:IHateIE.pos[0],end:IHateIE.pos[1]});context.$textarea.data('IHateIE',null);}};context.$textarea.wrapAll($('<div></div>').addClass('wikiEditor-ui')).wrapAll($('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-wikitext')).wrapAll($('<div></div>').addClass('wikiEditor-ui-left')).wrapAll($('<div></div>').addClass('wikiEditor-ui-bottom')).wrapAll($('<div></div>').addClass('wikiEditor-ui-text'));context.$ui=context.$textarea.parent().parent().parent().parent().parent();context.$wikitext=context.$textarea.parent().parent().parent().parent();context.$wikitext.before($('<div></div>').addClass('wikiEditor-ui-controls').append($('<div></div>').addClass('wikiEditor-ui-tabs').hide()).append($('<div></div>').addClass('wikiEditor-ui-buttons'))).before($('<div style="clear:both;"></div>'));context.$controls=context.$ui.find('.wikiEditor-ui-buttons').hide();context.$buttons=context.$ui.find('.wikiEditor-ui-buttons');context.$tabs=context.$ui.find('.wikiEditor-ui-tabs');context.$ui.after($('<div style="clear:both;"></div>'));context.$wikitext.append($('<div></div>').addClass('wikiEditor-ui-right'));context.$wikitext.find('.wikiEditor-ui-left').prepend($('<div></div>').addClass('wikiEditor-ui-top'));context.view='wikitext';$(window).resize(function(event){context.fn.trigger('resize',event);});}
581584 var args=$.makeArray(arguments);if(typeof context.$iframe==='undefined'&&args[0]=='addModule'&&typeof args[1]!='undefined'){var modules=args[1];if(typeof modules!="object"){modules={};modules[args[1]]='';}
582585 for(module in modules){if(module in $.wikiEditor.modules&&$.wikiEditor.isSupported($.wikiEditor.modules[module])&&$.wikiEditor.isRequired($.wikiEditor.modules[module],'iframe')){context.fn.setupIframe();break;}}}
583586 if(args.length>0){var call=args.shift();if(call in context.api){context.api[call](context,typeof args[0]=='undefined'?{}:args[0]);}}
@@ -746,7 +749,7 @@
747750 $.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,page,$pages,$index);break;case'rows':if(!('section'in data&&'page'in data)){continue;}
748751 var $table=context.modules.toolbar.$toolbar.find('div[rel='+data.section+'].section '+'div[rel='+data.page+'].page table');for(row in data[type]){$table.append($.wikiEditor.modules.toolbar.fn.buildRow(context,data[type][row]));}
749752 break;case'characters':if(!('section'in data&&'page'in data)){continue;}
750 -$characters=context.modules.toolbar.$toolbar.find('div[rel='+data.section+'].section '+'div[rel='+data.page+'].page div');var actions=$characters.data('actions');for(character in data[type]){$characters.append($($.wikiEditor.modules.toolbar.fn.buildCharacter(data[type][character],actions)).mousedown(function(e){context.$textarea.data('scrollTop',context.$textarea.scrollTop());e.preventDefault();return false;}).click(function(e){$.wikiEditor.modules.toolbar.fn.doAction($(this).parent().data('context'),$(this).parent().data('actions')[$(this).attr('rel')]);e.preventDefault();return false;}));}
 753+$characters=context.modules.toolbar.$toolbar.find('div[rel='+data.section+'].section '+'div[rel='+data.page+'].page div');var actions=$characters.data('actions');for(character in data[type]){$characters.append($($.wikiEditor.modules.toolbar.fn.buildCharacter(data[type][character],actions)).mousedown(function(e){context.fn.saveStuffForIE();e.preventDefault();return false;}).click(function(e){$.wikiEditor.modules.toolbar.fn.doAction($(this).parent().data('context'),$(this).parent().data('actions')[$(this).attr('rel')]);e.preventDefault();return false;}));}
751754 break;default:break;}}},removeFromToolbar:function(context,data){if(typeof data.section=='string'){var tab='div.tabs span[rel='+data.section+'].tab';var target='div[rel='+data.section+'].section';var group=null;if(typeof data.group=='string'){target+=' div[rel='+data.group+'].group';if(typeof data.tool=='string'){group=target;target+=' div[rel='+data.tool+'].tool';}}else if(typeof data.page=='string'){var index=target+' div.index div[rel='+data.page+']';target+=' div.pages div[rel='+data.page+'].page';if(typeof data.character=='string'){target+=' a[rel='+data.character+']';}else if(typeof data.row=='number'){target+=' table tr:not(:has(th)):eq('+data.row+')';}else{context.modules.toolbar.$toolbar.find(index).remove();$.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,null,context.modules.toolbar.$toolbar.find(target),context.modules.toolbar.$toolbar.find(index));}}else{context.modules.toolbar.$toolbar.find(tab).remove();}
752755 context.modules.toolbar.$toolbar.find(target).remove();if(group){$group=context.modules.toolbar.$toolbar.find(group);if($group.children().length==0){$group.hide();}}}}},evt:{resize:function(context,event){context.$ui.find('.sections').height(context.$ui.find('.sections .section-visible').outerHeight());},tocCollapse:function(context,event){$.wikiEditor.modules.toolbar.evt.resize(context,event);},tocExpand:function(context,event){$.wikiEditor.modules.toolbar.evt.resize(context,event);}},fn:{create:function(context,config){if('$toolbar'in context.modules.toolbar){return;}
753756 context.modules.toolbar.$toolbar=$('<div />').addClass('wikiEditor-ui-toolbar').attr('id','wikiEditor-ui-toolbar');$.wikiEditor.modules.toolbar.fn.build(context,config);context.$ui.find('.wikiEditor-ui-top').append(context.modules.toolbar.$toolbar);},doAction:function(context,action,source){if($.trackAction!=undefined&&source.closest('.wikiEditor-ui-toolbar').size()){var rels=[];var step=source;var i=0;while(!step.hasClass('wikiEditor-ui-toolbar')){if(i>25){break;}
@@ -761,8 +764,8 @@
762765 if(empty){$group.hide();}
763766 return $group;},buildTool:function(context,id,tool){if('filters'in tool){for(filter in tool.filters){if($(tool.filters[filter]).size()==0){return null;}}}
764767 var label=$.wikiEditor.autoMsg(tool,'label');switch(tool.type){case'button':var src=$.wikiEditor.autoIcon(tool.icon,$.wikiEditor.imgPath+'toolbar/');var $button;if('offset'in tool){var offset=$.wikiEditor.autoLang(tool.offset);$button=$('<span />').attr({'alt':label,'title':label,'rel':id,'class':'wikiEditor-toolbar-spritedButton'}).text(label).css('backgroundPosition',offset[0]+'px '+offset[1]+'px');}else{$button=$('<img />').attr({'src':src,'width':22,'height':22,'alt':label,'title':label,'rel':id,'class':'tool tool-button'});}
765 -if('action'in tool){$button.data('action',tool.action).data('context',context).mousedown(function(e){context.$textarea.data('scrollTop',context.$textarea.scrollTop());e.preventDefault();return false;}).click(function(e){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'),$(this));e.preventDefault();return false;});if(tool.action.type=='dialog'&&!(tool.action.module in $.wikiEditor.modules.dialogs.modules)){$button.hide();context.$textarea.bind('wikiEditor-dialogs-setup-'+tool.action.module,{button:$button},function(event){event.data.button.show().parent().show();});}}
766 -return $button;case'select':var $select=$('<div />').attr({'rel':id,'class':'tool tool-select'});var $options=$('<div />').addClass('options');if('list'in tool){for(option in tool.list){var optionLabel=$.wikiEditor.autoMsg(tool.list[option],'label');$options.append($('<a />').data('action',tool.list[option].action).data('context',context).mousedown(function(e){context.$textarea.data('scrollTop',context.$textarea.scrollTop());e.preventDefault();return false;}).click(function(e){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'),$(this));if($(this).parent().is(':visible')){$(this).parent().animate({'opacity':'toggle'},'fast');}
 768+if('action'in tool){$button.data('action',tool.action).data('context',context).mousedown(function(e){context.fn.saveStuffForIE();e.preventDefault();return false;}).click(function(e){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'),$(this));e.preventDefault();return false;});if(tool.action.type=='dialog'&&!(tool.action.module in $.wikiEditor.modules.dialogs.modules)){$button.hide();context.$textarea.bind('wikiEditor-dialogs-setup-'+tool.action.module,{button:$button},function(event){event.data.button.show().parent().show();});}}
 769+return $button;case'select':var $select=$('<div />').attr({'rel':id,'class':'tool tool-select'});var $options=$('<div />').addClass('options');if('list'in tool){for(option in tool.list){var optionLabel=$.wikiEditor.autoMsg(tool.list[option],'label');$options.append($('<a />').data('action',tool.list[option].action).data('context',context).mousedown(function(e){context.fn.saveStuffForIE();e.preventDefault();return false;}).click(function(e){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'),$(this));if($(this).parent().is(':visible')){$(this).parent().animate({'opacity':'toggle'},'fast');}
767770 e.preventDefault();return false;}).text(optionLabel).addClass('option').attr({'rel':option,'href':'#'}));}}
768771 $select.append($('<div />').addClass('menu').append($options));$select.append($('<a />').addClass('label').text(label).data('options',$options).attr('href','#').mousedown(function(e){e.preventDefault();return false;}).click(function(e){$(this).data('options').animate({'opacity':'toggle'},'fast');e.preventDefault();return false;}));return $select;default:return null;}},buildBookmark:function(context,id,page){var label=$.wikiEditor.autoMsg(page,'label');return $('<div />').text(label).attr('rel',id).data('context',context).mousedown(function(e){e.preventDefault();return false;}).click(function(event){$(this).parent().parent().find('.page').hide();$(this).parent().parent().find('.page-'+$(this).attr('rel')).show();$(this).siblings().removeClass('current');$(this).addClass('current');var section=$(this).parent().parent().attr('rel');$.cookie('wikiEditor-'+$(this).data('context').instance+'-booklet-'+section+'-page',$(this).attr('rel'));if($.trackAction!=undefined){$.trackAction(section+'.'+$(this).attr('rel'));}
769772 event.preventDefault();return false;})},buildPage:function(context,id,page){var $page=$('<div />').attr({'class':'page page-'+id,'rel':id});switch(page.layout){case'table':$page.addClass('page-table');var html='<table cellpadding=0 cellspacing=0 '+'border=0 width="100%" class="table table-"'+id+'">';if('headings'in page){html+=$.wikiEditor.modules.toolbar.fn.buildHeading(context,page.headings)}
@@ -770,7 +773,7 @@
771774 $page.html(html);break;case'characters':$page.addClass('page-characters');$characters=$('<div />').data('context',context).data('actions',{});var actions=$characters.data('actions');if('language'in page){$characters.attr('lang',page.language);}
772775 if('direction'in page){$characters.attr('dir',page.direction);}
773776 if('characters'in page){var html='';for(character in page.characters){html+=$.wikiEditor.modules.toolbar.fn.buildCharacter(page.characters[character],actions);}
774 -$characters.html(html).children().mousedown(function(e){context.$textarea.data('scrollTop',context.$textarea.scrollTop());e.preventDefault();return false;}).click(function(e){$.wikiEditor.modules.toolbar.fn.doAction($(this).parent().data('context'),$(this).parent().data('actions')[$(this).attr('rel')],$(this));e.preventDefault();return false;});}
 777+$characters.html(html).children().mousedown(function(e){context.fn.saveStuffForIE();e.preventDefault();return false;}).click(function(e){$.wikiEditor.modules.toolbar.fn.doAction($(this).parent().data('context'),$(this).parent().data('actions')[$(this).attr('rel')],$(this));e.preventDefault();return false;});}
775778 $page.append($characters);break;}
776779 return $page;},buildHeading:function(context,headings){var html='<tr>';for(heading in headings){html+='<th>'+$.wikiEditor.autoMsg(headings[heading],['html','text'])+'</th>';}
777780 return html;},buildRow:function(context,row){var html='<tr>';for(cell in row){html+='<td class="cell cell-'+cell+'" valign="top"><span>'+

Follow-up revisions

RevisionCommit summaryAuthorDate
r66301Resolves regression caused in r66286 by not declaring the context var before ...tparscal21:08, 12 May 2010
r66321Fix r66286: another undeclared context varcatrope05:09, 13 May 2010

Status & tagging log