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' => 26 ), |
76 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 90 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 91 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 26 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 45 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 11 ), |
— | — | @@ -82,10 +82,10 @@ |
83 | 83 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 2 ), |
84 | 84 | ), |
85 | 85 | 'combined' => array( |
86 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 203 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 204 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 203 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 204 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -364,15 +364,18 @@ |
365 | 365 | // IE does overzealous whitespace collapsing for $( '<pre />' ).html( html ); |
366 | 366 | // We also do the easy cases for <p> and <br> conversion here, complicated cases are handled |
367 | 367 | // later |
368 | | - var $pre = $( '<pre>' + |
369 | | - html |
| 368 | + html = html |
370 | 369 | .replace( /\r?\n/g, "" ) // IE7 inserts newlines before block elements |
371 | 370 | .replace( / /g, " " ) // We inserted these to prevent IE from collapsing spaces |
372 | | - // Don't convert <br>s at the very start or end to prevent newline collapsing |
373 | | - .replace( /(?!^)\<br[^\>]*\>(?!$)/gi, "\n" ) // Easy case for <br> conversion |
| 371 | + .replace( /\<br[^\>]*\>/gi, "\n" ) // Easy case for <br> conversion |
374 | 372 | .replace( /\<\/p\>\<p\>/gi, "\n" ) // Easy case for <p> conversion |
375 | | - .replace( /\<\/p\>(\n*)\<p\>/gi, "$1\n" ) |
376 | | - + '</pre>' ); |
| 373 | + .replace( /\<\/p\>(\n*)\<p\>/gi, "$1\n" ); |
| 374 | + // Save leading and trailing whitespace now and restore it later. IE eats it all, and even Firefox |
| 375 | + // won't leave everything alone |
| 376 | + var leading = html.match( /^\s*/ )[0]; |
| 377 | + var trailing = html.match( /\s*$/ )[0]; |
| 378 | + html = html.substr( leading.length, html.length - leading.length - trailing.length ); |
| 379 | + var $pre = $( '<pre>' + html + '</pre>' ); |
377 | 380 | // TODO: Optimize this, maybe by converting <br>->\n when not at the beginning or end |
378 | 381 | $pre.find( '.wikiEditor-noinclude' ).each( function() { $( this ).remove(); } ); |
379 | 382 | // Convert tabs, <p>s and <br>s back |
— | — | @@ -409,13 +412,15 @@ |
410 | 413 | $( this ).text( text ); |
411 | 414 | } |
412 | 415 | } ); |
413 | | - // IE aggressively collapses whitespace in .text() after having done DOM manipulation, |
414 | | - // but for some crazy reason this does work |
| 416 | + var retval; |
415 | 417 | if ( $.browser.msie ) { |
416 | | - return $( '<pre>' + $pre.html() + '</pre>' ).text().replace( /\r/g, '\n' ); |
| 418 | + // IE aggressively collapses whitespace in .text() after having done DOM manipulation, |
| 419 | + // but for some crazy reason this does work. Also convert \r back to \n |
| 420 | + retval = $( '<pre>' + $pre.html() + '</pre>' ).text().replace( /\r/g, '\n' ); |
417 | 421 | } else { |
418 | | - return $pre.text(); |
| 422 | + retval = $pre.text(); |
419 | 423 | } |
| 424 | + return leading + retval + trailing; |
420 | 425 | }, |
421 | 426 | |
422 | 427 | /* |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -6788,15 +6788,18 @@ |
6789 | 6789 | // IE does overzealous whitespace collapsing for $( '<pre />' ).html( html ); |
6790 | 6790 | // We also do the easy cases for <p> and <br> conversion here, complicated cases are handled |
6791 | 6791 | // later |
6792 | | - var $pre = $( '<pre>' + |
6793 | | - html |
| 6792 | + html = html |
6794 | 6793 | .replace( /\r?\n/g, "" ) // IE7 inserts newlines before block elements |
6795 | 6794 | .replace( / /g, " " ) // We inserted these to prevent IE from collapsing spaces |
6796 | | - // Don't convert <br>s at the very start or end to prevent newline collapsing |
6797 | | - .replace( /(?!^)\<br[^\>]*\>(?!$)/gi, "\n" ) // Easy case for <br> conversion |
| 6795 | + .replace( /\<br[^\>]*\>/gi, "\n" ) // Easy case for <br> conversion |
6798 | 6796 | .replace( /\<\/p\>\<p\>/gi, "\n" ) // Easy case for <p> conversion |
6799 | | - .replace( /\<\/p\>(\n*)\<p\>/gi, "$1\n" ) |
6800 | | - + '</pre>' ); |
| 6797 | + .replace( /\<\/p\>(\n*)\<p\>/gi, "$1\n" ); |
| 6798 | + // Save leading and trailing whitespace now and restore it later. IE eats it all, and even Firefox |
| 6799 | + // won't leave everything alone |
| 6800 | + var leading = html.match( /^\s*/ )[0]; |
| 6801 | + var trailing = html.match( /\s*$/ )[0]; |
| 6802 | + html = html.substr( leading.length, html.length - leading.length - trailing.length ); |
| 6803 | + var $pre = $( '<pre>' + html + '</pre>' ); |
6801 | 6804 | // TODO: Optimize this, maybe by converting <br>->\n when not at the beginning or end |
6802 | 6805 | $pre.find( '.wikiEditor-noinclude' ).each( function() { $( this ).remove(); } ); |
6803 | 6806 | // Convert tabs, <p>s and <br>s back |
— | — | @@ -6833,13 +6836,15 @@ |
6834 | 6837 | $( this ).text( text ); |
6835 | 6838 | } |
6836 | 6839 | } ); |
6837 | | - // IE aggressively collapses whitespace in .text() after having done DOM manipulation, |
6838 | | - // but for some crazy reason this does work |
| 6840 | + var retval; |
6839 | 6841 | if ( $.browser.msie ) { |
6840 | | - return $( '<pre>' + $pre.html() + '</pre>' ).text().replace( /\r/g, '\n' ); |
| 6842 | + // IE aggressively collapses whitespace in .text() after having done DOM manipulation, |
| 6843 | + // but for some crazy reason this does work. Also convert \r back to \n |
| 6844 | + retval = $( '<pre>' + $pre.html() + '</pre>' ).text().replace( /\r/g, '\n' ); |
6841 | 6845 | } else { |
6842 | | - return $pre.text(); |
| 6846 | + retval = $pre.text(); |
6843 | 6847 | } |
| 6848 | + return leading + retval + trailing; |
6844 | 6849 | }, |
6845 | 6850 | |
6846 | 6851 | /* |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -448,13 +448,12 @@ |
449 | 449 | for(module in context.modules){if(module in $.wikiEditor.modules&&'evt'in $.wikiEditor.modules[module]&&name in $.wikiEditor.modules[module].evt){$.wikiEditor.modules[module].evt[name](context,event);}}},'addButton':function(options){context.$controls.show();context.$buttons.show();return $('<button />').text($.wikiEditor.autoMsg(options,'caption')).click(options.action).appendTo(context.$buttons);},'addView':function(options){function addTab(options){context.$controls.show();context.$tabs.show();return $('<div></div>').attr('rel','wikiEditor-ui-view-'+options.name).addClass(context.view==options.name?'current':null).append($('<a></a>').attr('href','#').click(function(event){context.$ui.find('.wikiEditor-ui-view').hide();context.$ui.find('.'+$(this).parent().attr('rel')).show();context.$tabs.find('div').removeClass('current');$(this).parent().addClass('current');$(this).blur();if('init'in options&&typeof options.init=='function'){options.init(context);} |
450 | 450 | event.preventDefault();return false;}).text($.wikiEditor.autoMsg(options,'title'))).appendTo(context.$tabs);} |
451 | 451 | if(!context.$tabs.children().size()){addTab({'name':'wikitext','titleMsg':'wikieditor-wikitext-tab'});} |
452 | | -addTab(options);return $('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-'+options.name).hide().appendTo(context.$ui);},'htmlToText':function(html){var $pre=$('<pre>'+ |
453 | | -html.replace(/\r?\n/g,"").replace(/ /g," ").replace(/(?!^)\<br[^\>]*\>(?!$)/gi,"\n").replace(/\<\/p\>\<p\>/gi,"\n").replace(/\<\/p\>(\n*)\<p\>/gi,"$1\n") |
454 | | -+'</pre>');$pre.find('.wikiEditor-noinclude').each(function(){$(this).remove();});$pre.find('.wikiEditor-tab').each(function(){$(this).text("\t")});$pre.find('br').each(function(){$(this).replaceWith("\n");});$pre.find('p').each(function(){if(this.previousSibling||this.parentNode!=$pre.get(0)){var text=$(this).text();var t=new context.fn.rawTraverser(this.firstChild,-10,this).prev();while(t&&t.node.nodeName!='#text'&&t.node.nodeName!='BR'&&t.node.nodeName!='P'){t=t.prev();} |
| 452 | +addTab(options);return $('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-'+options.name).hide().appendTo(context.$ui);},'htmlToText':function(html){html=html.replace(/\r?\n/g,"").replace(/ /g," ").replace(/\<br[^\>]*\>/gi,"\n").replace(/\<\/p\>\<p\>/gi,"\n").replace(/\<\/p\>(\n*)\<p\>/gi,"$1\n");var leading=html.match(/^\s*/)[0];var trailing=html.match(/\s*$/)[0];html=html.substr(leading.length,html.length-leading.length-trailing.length);var $pre=$('<pre>'+html+'</pre>');$pre.find('.wikiEditor-noinclude').each(function(){$(this).remove();});$pre.find('.wikiEditor-tab').each(function(){$(this).text("\t")});$pre.find('br').each(function(){$(this).replaceWith("\n");});$pre.find('p').each(function(){if(this.previousSibling||this.parentNode!=$pre.get(0)){var text=$(this).text();var t=new context.fn.rawTraverser(this.firstChild,-10,this).prev();while(t&&t.node.nodeName!='#text'&&t.node.nodeName!='BR'&&t.node.nodeName!='P'){t=t.prev();} |
455 | 453 | if(t){text="\n"+text;} |
456 | 454 | 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();} |
457 | 455 | if(t&&!t.inP&&t.node.nodeName=='#text'&&t.node.nodeValue.charAt(0)!='\n'&&t.node.nodeValue.charAt(0)!='\r'){text+="\n";} |
458 | | -$(this).text(text);}});if($.browser.msie){return $('<pre>'+$pre.html()+'</pre>').text().replace(/\r/g,'\n');}else{return $pre.text();}},'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();} |
| 456 | +$(this).text(text);}});var retval;if($.browser.msie){retval=$('<pre>'+$pre.html()+'</pre>').text().replace(/\r/g,'\n');}else{retval=$pre.text();} |
| 457 | +return 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();} |
459 | 458 | if(typeof retval.text!='undefined'){retval=context.fn.htmlToText(retval.htmlText);}else if(retval.toString){retval=retval.toString();} |
460 | 459 | 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+=' ';} |
461 | 460 | if(options.splitlines){selTextArr=selText.split(/\n/);} |