r61826 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61825‎ | r61826 | r61827 >
Date:22:23, 1 February 2010
Author:catrope
Status:deferred
Tags:
Comment:
UsabilityInitiative: Fix bug where getSelection() strips newlines in Opera. Thanks to Adam for reporting and confirming the fix
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.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.wikiEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -72,7 +72,7 @@
7373 array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ),
7474 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 7 ),
7575 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 26 ),
76 - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 93 ),
 76+ array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 94 ),
7777 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 29 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 46 ),
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 11 ),
@@ -82,10 +82,10 @@
8383 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 2 ),
8484 ),
8585 'combined' => array(
86 - array( 'src' => 'js/plugins.combined.js', 'version' => 210 ),
 86+ array( 'src' => 'js/plugins.combined.js', 'version' => 211 ),
8787 ),
8888 'minified' => array(
89 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 210 ),
 89+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 211 ),
9090 ),
9191 ),
9292 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -466,6 +466,17 @@
467467 if ( context.$iframe[0].contentWindow.getSelection ) {
468468 // Firefox and Opera
469469 retval = context.$iframe[0].contentWindow.getSelection();
 470+ if ( $.browser.opera ) {
 471+ // Opera strips newlines in getSelection(), so we need something more sophisticated
 472+ if ( retval.rangeCount > 0 ) {
 473+ retval = context.fn.htmlToText( $( '<pre />' )
 474+ .append( retval.getRangeAt( 0 ).cloneContents() )
 475+ .html()
 476+ );
 477+ } else {
 478+ retval = '';
 479+ }
 480+ }
470481 } else if ( context.$iframe[0].contentWindow.document.selection ) { // should come last; Opera!
471482 // IE
472483 retval = context.$iframe[0].contentWindow.document.selection.createRange();
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -6890,6 +6890,17 @@
68916891 if ( context.$iframe[0].contentWindow.getSelection ) {
68926892 // Firefox and Opera
68936893 retval = context.$iframe[0].contentWindow.getSelection();
 6894+ if ( $.browser.opera ) {
 6895+ // Opera strips newlines in getSelection(), so we need something more sophisticated
 6896+ if ( retval.rangeCount > 0 ) {
 6897+ retval = context.fn.htmlToText( $( '<pre />' )
 6898+ .append( retval.getRangeAt( 0 ).cloneContents() )
 6899+ .html()
 6900+ );
 6901+ } else {
 6902+ retval = '';
 6903+ }
 6904+ }
68946905 } else if ( context.$iframe[0].contentWindow.document.selection ) { // should come last; Opera!
68956906 // IE
68966907 retval = context.$iframe[0].contentWindow.document.selection.createRange();
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -456,7 +456,7 @@
457457 t=new context.fn.rawTraverser(this.lastChild,-10,this).next();while(t&&t.node.nodeName!='#text'&&t.node.nodeName!='BR'&&t.node.nodeName!='P'){t=t.next();}
458458 if(t&&!t.inP&&t.node.nodeName=='#text'&&t.node.nodeValue.charAt(0)!='\n'&&t.node.nodeValue.charAt(0)!='\r'){text+="\n";}
459459 $(this).text(text);}});var retval;if($.browser.msie){retval=$('<pre>'+$pre.html()+'</pre>').text().replace(/\r/g,'\n');}else{retval=$pre.text();}
460 -return context.htmlToTextMap[origHTML]=leading+retval+trailing;},'getContents':function(){return context.fn.htmlToText(context.$content.html());},'getSelection':function(){var retval;if(context.$iframe[0].contentWindow.getSelection){retval=context.$iframe[0].contentWindow.getSelection();}else if(context.$iframe[0].contentWindow.document.selection){retval=context.$iframe[0].contentWindow.document.selection.createRange();}
 460+return context.htmlToTextMap[origHTML]=leading+retval+trailing;},'getContents':function(){return context.fn.htmlToText(context.$content.html());},'getSelection':function(){var retval;if(context.$iframe[0].contentWindow.getSelection){retval=context.$iframe[0].contentWindow.getSelection();if($.browser.opera){if(retval.rangeCount>0){retval=context.fn.htmlToText($('<pre />').append(retval.getRangeAt(0).cloneContents()).html());}else{retval='';}}}else if(context.$iframe[0].contentWindow.document.selection){retval=context.$iframe[0].contentWindow.document.selection.createRange();}
461461 if(typeof retval.text!='undefined'){retval=context.fn.htmlToText(retval.htmlText);}else if(retval.toString){retval=retval.toString();}
462462 return retval;},'encapsulateSelection':function(options){var selText=$(this).textSelection('getSelection');var selTextArr;var selectAfter=false;var pre=options.pre,post=options.post;if(!selText){selText=options.peri;selectAfter=true;}else if(options.replace){selText=options.peri;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);post+=' ';}
463463 if(options.splitlines){selTextArr=selText.split(/\n/);}

Status & tagging log