r61230 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61229‎ | r61230 | r61231 >
Date:01:21, 19 January 2010
Author:tparscal
Status:ok
Tags:
Comment:
Fixed more wrong document errors in Safari 4 - these were in encapsulateSelection.
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
@@ -153,7 +153,7 @@
154154 array(
155155 'src' => 'js/plugins/jquery.wikiEditor.js',
156156 'class' => 'j.wikiEditor',
157 - 'version' => 51
 157+ 'version' => 52
158158 ),
159159 array(
160160 'src' => 'js/plugins/jquery.wikiEditor.highlight.js',
@@ -191,10 +191,10 @@
192192 'version' => 1 ),
193193 ),
194194 'combined' => array(
195 - array( 'src' => 'js/plugins.combined.js', 'version' => 152 ),
 195+ array( 'src' => 'js/plugins.combined.js', 'version' => 153 ),
196196 ),
197197 'minified' => array(
198 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 152 ),
 198+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 153 ),
199199 ),
200200 ),
201201 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -451,9 +451,9 @@
452452 // in reverse order
453453 var lastNode;
454454 for ( var i = insertLines.length - 1; i >= 0; i-- ) {
455 - range.insertNode( document.createTextNode( insertLines[i] ) );
 455+ range.insertNode( context.$iframe[0].contentWindow.document.createTextNode( insertLines[i] ) );
456456 if ( i > 0 ) {
457 - lastNode = range.insertNode( document.createElement( 'br' ) );
 457+ lastNode = range.insertNode( context.$iframe[0].contentWindow.document.createElement( 'br' ) );
458458 }
459459 }
460460 if ( lastNode ) {
@@ -466,7 +466,7 @@
467467 if ( options.ownline && range.moveStart ) {
468468 // Check if we're at the start of a line
469469 // If not, prepend a newline
470 - var range2 = document.selection.createRange();
 470+ var range2 = context.$iframe[0].contentWindow.document.selection.createRange();
471471 range2.collapse();
472472 range2.moveStart( 'character', -1 );
473473 // FIXME: Which check is correct?
@@ -476,7 +476,7 @@
477477
478478 // Check if we're at the end of a line
479479 // If not, append a newline
480 - var range3 = document.selection.createRange();
 480+ var range3 = context.$iframe[0].contentWindow.document.selection.createRange();
481481 range3.collapse( false );
482482 range3.moveEnd( 'character', 1 );
483483 if ( range3.text != "\r" && range3.text != "\n" && range3.text != "" ) {
@@ -526,6 +526,7 @@
527527 ec = ec.firstChild;
528528 }
529529 var range = context.$iframe[0].contentWindow.document.createRange();
 530+ console.dir( [ range, sc, options.start ] );
530531 range.setStart( sc, options.start );
531532 range.setEnd( ec, options.end );
532533 sel.removeAllRanges();
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -6932,9 +6932,9 @@
69336933 // in reverse order
69346934 var lastNode;
69356935 for ( var i = insertLines.length - 1; i >= 0; i-- ) {
6936 - range.insertNode( document.createTextNode( insertLines[i] ) );
 6936+ range.insertNode( context.$iframe[0].contentWindow.document.createTextNode( insertLines[i] ) );
69376937 if ( i > 0 ) {
6938 - lastNode = range.insertNode( document.createElement( 'br' ) );
 6938+ lastNode = range.insertNode( context.$iframe[0].contentWindow.document.createElement( 'br' ) );
69396939 }
69406940 }
69416941 if ( lastNode ) {
@@ -6947,7 +6947,7 @@
69486948 if ( options.ownline && range.moveStart ) {
69496949 // Check if we're at the start of a line
69506950 // If not, prepend a newline
6951 - var range2 = document.selection.createRange();
 6951+ var range2 = context.$iframe[0].contentWindow.document.selection.createRange();
69526952 range2.collapse();
69536953 range2.moveStart( 'character', -1 );
69546954 // FIXME: Which check is correct?
@@ -6957,7 +6957,7 @@
69586958
69596959 // Check if we're at the end of a line
69606960 // If not, append a newline
6961 - var range3 = document.selection.createRange();
 6961+ var range3 = context.$iframe[0].contentWindow.document.selection.createRange();
69626962 range3.collapse( false );
69636963 range3.moveEnd( 'character', 1 );
69646964 if ( range3.text != "\r" && range3.text != "\n" && range3.text != "" ) {
@@ -7007,6 +7007,7 @@
70087008 ec = ec.firstChild;
70097009 }
70107010 var range = context.$iframe[0].contentWindow.document.createRange();
 7011+ console.dir( [ range, sc, options.start ] );
70117012 range.setStart( sc, options.start );
70127013 range.setEnd( ec, options.end );
70137014 sel.removeAllRanges();
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -454,13 +454,13 @@
455455 return retval;},'encapsulateSelection':function(options){var selText=$(this).textSelection('getSelection');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+=' ';}
456456 if(context.$iframe[0].contentWindow.getSelection){var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);if(options.ownline){if(range.startOffset!=0){pre="\n"+options.pre;}
457457 if(range.endContainer==range.commonAncestorContainer){post+="\n";}}
458 -var insertText=pre+selText+post;var insertLines=insertText.split("\n");range.extractContents();var lastNode;for(var i=insertLines.length-1;i>=0;i--){range.insertNode(document.createTextNode(insertLines[i]));if(i>0){lastNode=range.insertNode(document.createElement('br'));}}
459 -if(lastNode){context.fn.scrollToTop(lastNode);}}else if(context.$iframe[0].contentWindow.document.selection){context.$iframe[0].contentWindow.focus();var range=context.$iframe[0].contentWindow.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!=""){pre="\n"+pre;}
460 -var range3=document.selection.createRange();range3.collapse(false);range3.moveEnd('character',1);if(range3.text!="\r"&&range3.text!="\n"&&range3.text!=""){post+="\n";}}
 458+var insertText=pre+selText+post;var insertLines=insertText.split("\n");range.extractContents();var lastNode;for(var i=insertLines.length-1;i>=0;i--){range.insertNode(context.$iframe[0].contentWindow.document.createTextNode(insertLines[i]));if(i>0){lastNode=range.insertNode(context.$iframe[0].contentWindow.document.createElement('br'));}}
 459+if(lastNode){context.fn.scrollToTop(lastNode);}}else if(context.$iframe[0].contentWindow.document.selection){context.$iframe[0].contentWindow.focus();var range=context.$iframe[0].contentWindow.document.selection.createRange();if(options.ownline&&range.moveStart){var range2=context.$iframe[0].contentWindow.document.selection.createRange();range2.collapse();range2.moveStart('character',-1);if(range2.text!="\r"&&range2.text!="\n"&&range2.text!=""){pre="\n"+pre;}
 460+var range3=context.$iframe[0].contentWindow.document.selection.createRange();range3.collapse(false);range3.moveEnd('character',1);if(range3.text!="\r"&&range3.text!="\n"&&range3.text!=""){post+="\n";}}
461461 range.pasteHTML((pre+selText+post).replace(/\</g,'&lt;').replace(/>/g,'&gt;').replace(/\r?\n/g,'<br />'));}
462462 context.$content.trigger('encapsulateSelection',[pre,options.peri,post,options.ownline,options.replace]);return context.$textarea;},'getCaretPosition':function(options){},'setSelection':function(options){var sc=options.startContainer,ec=options.endContainer;sc=sc.jquery?sc[0]:sc;ec=ec.jquery?ec[0]:ec;if(context.$iframe[0].contentWindow.getSelection){var sel=context.$iframe[0].contentWindow.getSelection();while(sc.firstChild&&sc.nodeName!='#text'){sc=sc.firstChild;}
463463 while(ec.firstChild&&ec.nodeName!='#text'){ec=ec.firstChild;}
464 -var range=context.$iframe[0].contentWindow.document.createRange();range.setStart(sc,options.start);range.setEnd(ec,options.end);sel.removeAllRanges();sel.addRange(range);context.$iframe[0].contentWindow.focus();}else if(context.$iframe[0].contentWindow.document.body.createTextRange){var range=context.$iframe[0].contentWindow.document.body.createTextRange();range.moveToElementText(sc);range.moveStart('character',options.start);var range2=context.$iframe[0].contentWindow.document.body.createTextRange();range2.moveToElementText(ec);range2.collapse();range2.moveEnd('character',options.end);range.setEndPoint('EndToEnd',range2);range.select();}},'scrollToCaretPosition':function(options){},'scrollToTop':function($element,force){var html=context.$content.closest('html'),body=context.$content.closest('body'),parent=$('html');var y=$element.offset().top-context.$content.offset().top;y=parent.scrollTop()>0?y+html.scrollTop()-parent.scrollTop():y;if(force||y<html.scrollTop()||y>html.scrollTop()+context.$iframe.height()){html.scrollTop(y);}
 464+var range=context.$iframe[0].contentWindow.document.createRange();console.dir([range,sc,options.start]);range.setStart(sc,options.start);range.setEnd(ec,options.end);sel.removeAllRanges();sel.addRange(range);context.$iframe[0].contentWindow.focus();}else if(context.$iframe[0].contentWindow.document.body.createTextRange){var range=context.$iframe[0].contentWindow.document.body.createTextRange();range.moveToElementText(sc);range.moveStart('character',options.start);var range2=context.$iframe[0].contentWindow.document.body.createTextRange();range2.moveToElementText(ec);range2.collapse();range2.moveEnd('character',options.end);range.setEndPoint('EndToEnd',range2);range.select();}},'scrollToCaretPosition':function(options){},'scrollToTop':function($element,force){var html=context.$content.closest('html'),body=context.$content.closest('body'),parent=$('html');var y=$element.offset().top-context.$content.offset().top;y=parent.scrollTop()>0?y+html.scrollTop()-parent.scrollTop():y;if(force||y<html.scrollTop()||y>html.scrollTop()+context.$iframe.height()){html.scrollTop(y);}
465465 $element.trigger('scrollToTop');},'beforeSelection':function(selector,strict){if(typeof selector=='undefined'){selector='*';}
466466 var e;if(context.$iframe[0].contentWindow.getSelection){var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);e=range.startContainer;}else if(context.$iframe[0].contentWindow.document.selection){return $([]);}
467467 if(e.nodeName!='#text'){var newE=e.firstChild;for(var i=0;i<range.startOffset-1&&newE;i++){newE=newE.nextSibling;}

Status & tagging log