Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ), |
74 | 74 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 7 ), |
75 | 75 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 27 ), |
76 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 155 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 156 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 35 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 52 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 19 ), |
— | — | @@ -82,10 +82,10 @@ |
83 | 83 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 3 ), |
84 | 84 | ), |
85 | 85 | 'combined' => array( |
86 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 292 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 293 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 292 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 293 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -1195,11 +1195,13 @@ |
1196 | 1196 | if ( !selText ) { |
1197 | 1197 | selText = options.peri; |
1198 | 1198 | selectAfter = true; |
1199 | | - } else if ( $.wikiEditor.autoMsg( options, 'peri' ) == selText.replace( /\s\s*$/, '' ) ) { |
| 1199 | + } else if ( options.peri == selText.replace( /\s+$/, '' ) ) { |
1200 | 1200 | // Probably a successive button press |
1201 | | - // strip any extra white space from selText and set variables we'll need for later |
1202 | | - selText = selText.replace( /\s\s*$/, '' ); |
| 1201 | + // strip any extra white space from selText |
| 1202 | + selText = selText.replace( /\s+$/, '' ); |
| 1203 | + // set the collapseToEnd flag to ensure our selection is collapsed to the end before any insertion is done |
1203 | 1204 | collapseToEnd = true; |
| 1205 | + // set selectAfter to true since we know we'll be populating with our default text |
1204 | 1206 | selectAfter = true; |
1205 | 1207 | } else if ( options.replace ) { |
1206 | 1208 | selText = options.peri; |
— | — | @@ -1216,6 +1218,8 @@ |
1217 | 1219 | if ( context.$iframe[0].contentWindow.getSelection ) { |
1218 | 1220 | // Firefox and Opera |
1219 | 1221 | var range = context.$iframe[0].contentWindow.getSelection().getRangeAt( 0 ); |
| 1222 | + // if our test above indicated that this was a sucessive button press, we need to collapse the |
| 1223 | + // selection to the end to avoid replacing text |
1220 | 1224 | if ( collapseToEnd ) { |
1221 | 1225 | // Make sure we're not collapsing ourselves into a BR tag |
1222 | 1226 | if ( range.endContainer.nodeName == 'BR' ) { |
— | — | @@ -1347,6 +1351,11 @@ |
1348 | 1352 | post += "\n"; |
1349 | 1353 | } |
1350 | 1354 | } |
| 1355 | + // if our test above indicated that this was a sucessive button press, we need to collapse the |
| 1356 | + // selection to the end to avoid replacing text |
| 1357 | + if ( collapseToEnd ) { |
| 1358 | + range.collapse( false ); |
| 1359 | + } |
1351 | 1360 | // TODO: Clean this up. Duplicate code due to the pre-existing browser specific structure of this |
1352 | 1361 | // function |
1353 | 1362 | var insertText = ""; |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -7632,11 +7632,13 @@ |
7633 | 7633 | if ( !selText ) { |
7634 | 7634 | selText = options.peri; |
7635 | 7635 | selectAfter = true; |
7636 | | - } else if ( $.wikiEditor.autoMsg( options, 'peri' ) == selText.replace( /\s\s*$/, '' ) ) { |
| 7636 | + } else if ( options.peri == selText.replace( /\s+$/, '' ) ) { |
7637 | 7637 | // Probably a successive button press |
7638 | | - // strip any extra white space from selText and set variables we'll need for later |
7639 | | - selText = selText.replace( /\s\s*$/, '' ); |
| 7638 | + // strip any extra white space from selText |
| 7639 | + selText = selText.replace( /\s+$/, '' ); |
| 7640 | + // set the collapseToEnd flag to ensure our selection is collapsed to the end before any insertion is done |
7640 | 7641 | collapseToEnd = true; |
| 7642 | + // set selectAfter to true since we know we'll be populating with our default text |
7641 | 7643 | selectAfter = true; |
7642 | 7644 | } else if ( options.replace ) { |
7643 | 7645 | selText = options.peri; |
— | — | @@ -7653,6 +7655,8 @@ |
7654 | 7656 | if ( context.$iframe[0].contentWindow.getSelection ) { |
7655 | 7657 | // Firefox and Opera |
7656 | 7658 | var range = context.$iframe[0].contentWindow.getSelection().getRangeAt( 0 ); |
| 7659 | + // if our test above indicated that this was a sucessive button press, we need to collapse the |
| 7660 | + // selection to the end to avoid replacing text |
7657 | 7661 | if ( collapseToEnd ) { |
7658 | 7662 | // Make sure we're not collapsing ourselves into a BR tag |
7659 | 7663 | if ( range.endContainer.nodeName == 'BR' ) { |
— | — | @@ -7784,6 +7788,11 @@ |
7785 | 7789 | post += "\n"; |
7786 | 7790 | } |
7787 | 7791 | } |
| 7792 | + // if our test above indicated that this was a sucessive button press, we need to collapse the |
| 7793 | + // selection to the end to avoid replacing text |
| 7794 | + if ( collapseToEnd ) { |
| 7795 | + range.collapse( false ); |
| 7796 | + } |
7788 | 7797 | // TODO: Clean this up. Duplicate code due to the pre-existing browser specific structure of this |
7789 | 7798 | // function |
7790 | 7799 | var insertText = ""; |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -516,7 +516,7 @@ |
517 | 517 | context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();context.fn.trigger('ready');context.oldHTML=context.oldDelayedHTML=context.$content.html();$(context.$iframe[0].contentWindow.document).bind('keydown',function(event){return context.fn.trigger('keydown',event);}).bind('paste',function(event){return context.fn.trigger('paste',event);}).bind('cut',function(event){return context.fn.trigger('cut',event);}).bind('keyup paste mouseup cut encapsulateSelection',function(event){return context.fn.trigger('change',event);}).delayedBind(250,'keyup paste mouseup cut encapsulateSelection',function(event){context.fn.trigger('delayedChange',event);});});context.$textarea.closest('form').submit(function(){context.$textarea.attr('disabled',false);context.$textarea.val(context.$textarea.textSelection('getContents'));});context.fallbackWindowOnBeforeUnload=window.onbeforeunload;window.onbeforeunload=function(){context.$textarea.val(context.$textarea.textSelection('getContents'));if(context.fallbackWindowOnBeforeUnload){return context.fallbackWindowOnBeforeUnload();}};},'getContents':function(){var html;if($.browser.msie){var $c=$(context.$content.get(0).cloneNode(true));$c.find('p').each(function(){if($(this).html()==''){$(this).replaceWith('<p></p>');}});html=$c.html();}else{html=context.$content.html();} |
518 | 518 | return context.fn.htmlToText(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();} |
519 | 519 | if(typeof retval.text!='undefined'){retval=context.fn.htmlToText(retval.htmlText);}else if(typeof retval.toString!='undefined'){retval=retval.toString();} |
520 | | -return retval;},'encapsulateSelection':function(options){var selText=$(this).textSelection('getSelection');var selTextArr;var collapseToEnd=false;var selectAfter=false;var setSelectionTo=null;var pre=options.pre,post=options.post;if(!selText){selText=options.peri;selectAfter=true;}else if($.wikiEditor.autoMsg(options,'peri')==selText.replace(/\s\s*$/,'')){selText=selText.replace(/\s\s*$/,'');collapseToEnd=true;selectAfter=true;}else if(options.replace){selText=options.peri;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);post+=' ';} |
| 520 | +return retval;},'encapsulateSelection':function(options){var selText=$(this).textSelection('getSelection');var selTextArr;var collapseToEnd=false;var selectAfter=false;var setSelectionTo=null;var pre=options.pre,post=options.post;if(!selText){selText=options.peri;selectAfter=true;}else if(options.peri==selText.replace(/\s+$/,'')){selText=selText.replace(/\s+$/,'');collapseToEnd=true;selectAfter=true;}else if(options.replace){selText=options.peri;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);post+=' ';} |
521 | 521 | if(options.splitlines){selTextArr=selText.split(/\n/);} |
522 | 522 | if(context.$iframe[0].contentWindow.getSelection){var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);if(collapseToEnd){if(range.endContainer.nodeName=='BR'){range.setEndBefore(range.endContainer);} |
523 | 523 | range.collapse(false);} |
— | — | @@ -533,6 +533,7 @@ |
534 | 534 | if(firstNode){context.fn.scrollToTop($(firstNode.parentNode));} |
535 | 535 | if(selectAfter){setSelectionTo={startContainer:selSC,endContainer:selEC,start:selSO,end:selEO};}else if(lastNode){setSelectionTo={startContainer:lastNode,endContainer:lastNode,start:lastNode.nodeValue.length,end:lastNode.nodeValue.length};}}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;} |
536 | 536 | 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";}} |
| 537 | +if(collapseToEnd){range.collapse(false);} |
537 | 538 | var insertText="";if(options.splitlines){for(var j=0;j<selTextArr.length;j++){insertText=insertText+pre+selTextArr[j]+post;if(j!=selTextArr.length-1){insertText+="\n";}}}else{insertText=pre+selText+post;} |
538 | 539 | range.pasteHTML(insertText.replace(/\</g,'<').replace(/>/g,'>').replace(/\r?\n/g,'<br />'));if(selectAfter){range.moveStart('character',-post.length-selText.length);range.moveEnd('character',-post.length);range.select();}} |
539 | 540 | if(setSelectionTo){context.fn.setSelection(setSelectionTo);} |