Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -153,7 +153,7 @@ |
154 | 154 | array( |
155 | 155 | 'src' => 'js/plugins/jquery.wikiEditor.js', |
156 | 156 | 'class' => 'j.wikiEditor', |
157 | | - 'version' => 49 |
| 157 | + 'version' => 50 |
158 | 158 | ), |
159 | 159 | array( |
160 | 160 | 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', |
— | — | @@ -191,10 +191,10 @@ |
192 | 192 | 'version' => 1 ), |
193 | 193 | ), |
194 | 194 | 'combined' => array( |
195 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 149 ), |
| 195 | + array( 'src' => 'js/plugins.combined.js', 'version' => 150 ), |
196 | 196 | ), |
197 | 197 | 'minified' => array( |
198 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 149 ), |
| 198 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 150 ), |
199 | 199 | ), |
200 | 200 | ), |
201 | 201 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -474,7 +474,35 @@ |
475 | 475 | context.fn.scrollToTop( lastNode ); |
476 | 476 | } |
477 | 477 | } else if ( context.$iframe[0].contentWindow.document.selection ) { |
478 | | - // TODO: IE |
| 478 | + // IE |
| 479 | + context.$iframe[0].contentWindow.focus(); |
| 480 | + var range = context.$iframe[0].contentWindow.document.selection.createRange(); |
| 481 | + if ( options.ownline && range.moveStart ) { |
| 482 | + // Check if we're at the start of a line |
| 483 | + // If not, prepend a newline |
| 484 | + var range2 = document.selection.createRange(); |
| 485 | + range2.collapse(); |
| 486 | + range2.moveStart( 'character', -1 ); |
| 487 | + // FIXME: Which check is correct? |
| 488 | + if ( range2.text != "\r" && range2.text != "\n" && range2.text != "" ) { |
| 489 | + pre = "\n" + pre; |
| 490 | + } |
| 491 | + |
| 492 | + // Check if we're at the end of a line |
| 493 | + // If not, append a newline |
| 494 | + var range3 = document.selection.createRange(); |
| 495 | + range3.collapse( false ); |
| 496 | + range3.moveEnd( 'character', 1 ); |
| 497 | + if ( range3.text != "\r" && range3.text != "\n" && range3.text != "" ) { |
| 498 | + post += "\n"; |
| 499 | + } |
| 500 | + } |
| 501 | + // TODO: Maybe find a more elegant way of doing this like the Firefox code above? |
| 502 | + range.pasteHTML( ( pre + selText + post ) |
| 503 | + .replace( /\</g, '<' ) |
| 504 | + .replace( />/g, '>' ) |
| 505 | + .replace( /\r?\n/g, '<br />' ) |
| 506 | + ); |
479 | 507 | } |
480 | 508 | // Trigger the encapsulateSelection event (this might need to get named something else/done differently) |
481 | 509 | context.$content.trigger( |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -6836,7 +6836,35 @@ |
6837 | 6837 | context.fn.scrollToTop( lastNode ); |
6838 | 6838 | } |
6839 | 6839 | } else if ( context.$iframe[0].contentWindow.document.selection ) { |
6840 | | - // TODO: IE |
| 6840 | + // IE |
| 6841 | + context.$iframe[0].contentWindow.focus(); |
| 6842 | + var range = context.$iframe[0].contentWindow.document.selection.createRange(); |
| 6843 | + if ( options.ownline && range.moveStart ) { |
| 6844 | + // Check if we're at the start of a line |
| 6845 | + // If not, prepend a newline |
| 6846 | + var range2 = document.selection.createRange(); |
| 6847 | + range2.collapse(); |
| 6848 | + range2.moveStart( 'character', -1 ); |
| 6849 | + // FIXME: Which check is correct? |
| 6850 | + if ( range2.text != "\r" && range2.text != "\n" && range2.text != "" ) { |
| 6851 | + pre = "\n" + pre; |
| 6852 | + } |
| 6853 | + |
| 6854 | + // Check if we're at the end of a line |
| 6855 | + // If not, append a newline |
| 6856 | + var range3 = document.selection.createRange(); |
| 6857 | + range3.collapse( false ); |
| 6858 | + range3.moveEnd( 'character', 1 ); |
| 6859 | + if ( range3.text != "\r" && range3.text != "\n" && range3.text != "" ) { |
| 6860 | + post += "\n"; |
| 6861 | + } |
| 6862 | + } |
| 6863 | + // TODO: Maybe find a more elegant way of doing this like the Firefox code above? |
| 6864 | + range.pasteHTML( ( pre + selText + post ) |
| 6865 | + .replace( /\</g, '<' ) |
| 6866 | + .replace( />/g, '>' ) |
| 6867 | + .replace( /\r?\n/g, '<br />' ) |
| 6868 | + ); |
6841 | 6869 | } |
6842 | 6870 | // Trigger the encapsulateSelection event (this might need to get named something else/done differently) |
6843 | 6871 | context.$content.trigger( |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -449,7 +449,9 @@ |
450 | 450 | 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;} |
451 | 451 | if(range.endContainer==range.commonAncestorContainer){post+="\n";}} |
452 | 452 | 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'));}} |
453 | | -if(lastNode){context.fn.scrollToTop(lastNode);}}else if(context.$iframe[0].contentWindow.document.selection){} |
| 453 | +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;} |
| 454 | +var range3=document.selection.createRange();range3.collapse(false);range3.moveEnd('character',1);if(range3.text!="\r"&&range3.text!="\n"&&range3.text!=""){post+="\n";}} |
| 455 | +range.pasteHTML((pre+selText+post).replace(/\</g,'<').replace(/>/g,'>').replace(/\r?\n/g,'<br />'));} |
454 | 456 | 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;} |
455 | 457 | while(ec.firstChild&&ec.nodeName!='#text'){ec=ec.firstChild;} |
456 | 458 | var range=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);} |