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' => 110 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 111 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 29 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 47 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 12 ), |
— | — | @@ -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' => 228 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 229 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 228 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 229 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -1201,25 +1201,26 @@ |
1202 | 1202 | // If we just do "context.$content.text( context.$textarea.val() )", Internet Explorer will strip out the |
1203 | 1203 | // whitespace charcters, specifically "\n" - so we must manually encode the text and append it |
1204 | 1204 | // TODO: Refactor this into a textToHtml() function |
1205 | | - // Because we're gonna insert instances of <br>, and <span class="wikiEditor-tab"></span>, |
1206 | | - // we have to escape existing instances first. This'll cause them to be double-escaped, which we |
1207 | | - // fix later on |
1208 | 1205 | var html = context.$textarea.val() |
1209 | | - .replace( / /g, '&nbsp;' ) |
1210 | | - .replace( /\<br\>/g, '<br>' ) |
1211 | | - .replace( /\<span class="wikiEditor-tab"\>\<\/span\>/g, '<span class="wikiEditor-tab"></span>' ); |
| 1206 | + // We're gonna use &esc; as an escape sequence |
| 1207 | + .replace( /&esc;/g, '&esc;&esc;' ) |
| 1208 | + // Escape existing uses of <p>, </p>, and <span class="wikiEditor-tab"></span> |
| 1209 | + .replace( /\<p\>/g, '&esc;<p>' ) |
| 1210 | + .replace (/\<\/p\>/g, '&esc;</p>' ) |
| 1211 | + .replace( /\<span class="wikiEditor-tab"\>\<\/span\>/g, '&esc;<span class="wikiEditor-tab"></span>' ) |
| 1212 | + .replace( / /g, '&esc;&nbsp;' ); |
1212 | 1213 | // We must do some extra processing on IE to avoid dirty diffs, specifically IE will collapse leading spaces |
| 1214 | + // Browser sniffing is not ideal, but executing this code on a non-broken browser doesn't cause harm |
1213 | 1215 | if ( $.browser.msie ) { |
1214 | | - // Browser sniffing is not ideal, but executing this code on a non-broken browser doesn't cause harm |
| 1216 | + html = html.replace( /\t/g, '<span class="wikiEditor-tab"></span>' ); |
1215 | 1217 | if ( $.browser.versionNumber <= 7 ) { |
1216 | 1218 | // Replace all spaces matching - IE <= 7 needs this because of its overzealous |
1217 | | - // whitespace collapsing; |
| 1219 | + // whitespace collapsing |
1218 | 1220 | html = html.replace( / /g, " " ); |
1219 | 1221 | } else { |
1220 | 1222 | // IE8 is happy if we just convert the first leading space to |
1221 | 1223 | html = html.replace( /(^|\n) /g, "$1 " ); |
1222 | 1224 | } |
1223 | | - html = html.replace( /\t/g, '<span class="wikiEditor-tab"></span>' ); |
1224 | 1225 | } |
1225 | 1226 | // Use a dummy div to escape all entities |
1226 | 1227 | // This'll also escape <br>, <span> and , so we unescape those after |
— | — | @@ -1231,10 +1232,12 @@ |
1232 | 1233 | .replace( /<\/p>/g, '</p>' ) |
1233 | 1234 | // Empty p tags should just be br tags |
1234 | 1235 | .replace( /<p><\/p>/g, '<br>' ) |
1235 | | - .replace( /<span class="wikiEditor-tab"><\/span>/g, '<span class="wikiEditor-tab"></span>' ) |
1236 | | - .replace( /&amp;nbsp;/g, '&nbsp;' ) |
1237 | | - .replace( /&lt;br&gt;/g, '<br>' ) |
1238 | | - .replace( /&lt;span class=&quot;wikiEditor-tab&quot;&gt;&lt;\/span&gt;/g, '<span class="wikiEditor-tab"></span>' ); |
| 1236 | + // Unescape &esc; stuff |
| 1237 | + .replace( /&esc;&amp;nbsp;/g, '&nbsp;' ) |
| 1238 | + .replace( /&esc;&lt;p&gt;/g, '<p>' ) |
| 1239 | + .replace( /&esc;&lt;\/p&gt;/g, '</p>' ) |
| 1240 | + .replace( /&esc;&lt;span class="wikiEditor-tab"&gt;&lt;\/span&gt;/g, '<span class="wikiEditor-tab"><\/span>' ) |
| 1241 | + .replace( /&esc;&esc;/g, '&esc;' ); |
1239 | 1242 | context.$content.html( html ); |
1240 | 1243 | context.oldHTML = html; |
1241 | 1244 | // FIXME: This needs to be merged somehow with the oldHTML thing |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -7634,25 +7634,26 @@ |
7635 | 7635 | // If we just do "context.$content.text( context.$textarea.val() )", Internet Explorer will strip out the |
7636 | 7636 | // whitespace charcters, specifically "\n" - so we must manually encode the text and append it |
7637 | 7637 | // TODO: Refactor this into a textToHtml() function |
7638 | | - // Because we're gonna insert instances of <br>, and <span class="wikiEditor-tab"></span>, |
7639 | | - // we have to escape existing instances first. This'll cause them to be double-escaped, which we |
7640 | | - // fix later on |
7641 | 7638 | var html = context.$textarea.val() |
7642 | | - .replace( / /g, '&nbsp;' ) |
7643 | | - .replace( /\<br\>/g, '<br>' ) |
7644 | | - .replace( /\<span class="wikiEditor-tab"\>\<\/span\>/g, '<span class="wikiEditor-tab"></span>' ); |
| 7639 | + // We're gonna use &esc; as an escape sequence |
| 7640 | + .replace( /&esc;/g, '&esc;&esc;' ) |
| 7641 | + // Escape existing uses of <p>, </p>, and <span class="wikiEditor-tab"></span> |
| 7642 | + .replace( /\<p\>/g, '&esc;<p>' ) |
| 7643 | + .replace (/\<\/p\>/g, '&esc;</p>' ) |
| 7644 | + .replace( /\<span class="wikiEditor-tab"\>\<\/span\>/g, '&esc;<span class="wikiEditor-tab"></span>' ) |
| 7645 | + .replace( / /g, '&esc;&nbsp;' ); |
7645 | 7646 | // We must do some extra processing on IE to avoid dirty diffs, specifically IE will collapse leading spaces |
| 7647 | + // Browser sniffing is not ideal, but executing this code on a non-broken browser doesn't cause harm |
7646 | 7648 | if ( $.browser.msie ) { |
7647 | | - // Browser sniffing is not ideal, but executing this code on a non-broken browser doesn't cause harm |
| 7649 | + html = html.replace( /\t/g, '<span class="wikiEditor-tab"></span>' ); |
7648 | 7650 | if ( $.browser.versionNumber <= 7 ) { |
7649 | 7651 | // Replace all spaces matching - IE <= 7 needs this because of its overzealous |
7650 | | - // whitespace collapsing; |
| 7652 | + // whitespace collapsing |
7651 | 7653 | html = html.replace( / /g, " " ); |
7652 | 7654 | } else { |
7653 | 7655 | // IE8 is happy if we just convert the first leading space to |
7654 | 7656 | html = html.replace( /(^|\n) /g, "$1 " ); |
7655 | 7657 | } |
7656 | | - html = html.replace( /\t/g, '<span class="wikiEditor-tab"></span>' ); |
7657 | 7658 | } |
7658 | 7659 | // Use a dummy div to escape all entities |
7659 | 7660 | // This'll also escape <br>, <span> and , so we unescape those after |
— | — | @@ -7664,10 +7665,12 @@ |
7665 | 7666 | .replace( /<\/p>/g, '</p>' ) |
7666 | 7667 | // Empty p tags should just be br tags |
7667 | 7668 | .replace( /<p><\/p>/g, '<br>' ) |
7668 | | - .replace( /<span class="wikiEditor-tab"><\/span>/g, '<span class="wikiEditor-tab"></span>' ) |
7669 | | - .replace( /&amp;nbsp;/g, '&nbsp;' ) |
7670 | | - .replace( /&lt;br&gt;/g, '<br>' ) |
7671 | | - .replace( /&lt;span class=&quot;wikiEditor-tab&quot;&gt;&lt;\/span&gt;/g, '<span class="wikiEditor-tab"></span>' ); |
| 7669 | + // Unescape &esc; stuff |
| 7670 | + .replace( /&esc;&amp;nbsp;/g, '&nbsp;' ) |
| 7671 | + .replace( /&esc;&lt;p&gt;/g, '<p>' ) |
| 7672 | + .replace( /&esc;&lt;\/p&gt;/g, '</p>' ) |
| 7673 | + .replace( /&esc;&lt;span class="wikiEditor-tab"&gt;&lt;\/span&gt;/g, '<span class="wikiEditor-tab"><\/span>' ) |
| 7674 | + .replace( /&esc;&esc;/g, '&esc;' ); |
7672 | 7675 | context.$content.html( html ); |
7673 | 7676 | context.oldHTML = html; |
7674 | 7677 | // FIXME: This needs to be merged somehow with the oldHTML thing |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -525,9 +525,8 @@ |
526 | 526 | t=nextT;}},'saveSelection':function(){if(!$.browser.msie){return;} |
527 | 527 | context.$iframe[0].contentWindow.focus();context.savedSelection=context.$iframe[0].contentWindow.document.selection.createRange();},'restoreSelection':function(){if(!$.browser.msie||context.savedSelection===null){return;} |
528 | 528 | context.$iframe[0].contentWindow.focus();context.savedSelection.select();context.savedSelection=null;}};context.$textarea.wrap($('<div></div>').addClass('wikiEditor-ui')).wrap($('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-wikitext')).wrap($('<div></div>').addClass('wikiEditor-ui-left')).wrap($('<div></div>').addClass('wikiEditor-ui-bottom')).wrap($('<div></div>').addClass('wikiEditor-ui-text'));context.$ui=context.$textarea.parent().parent().parent().parent().parent();context.$wikitext=context.$textarea.parent().parent().parent().parent();context.$wikitext.before($('<div></div>').addClass('wikiEditor-ui-controls').append($('<div></div>').addClass('wikiEditor-ui-tabs').hide()).append($('<div></div>').addClass('wikiEditor-ui-buttons'))).before($('<div style="clear:both;"></div>'));context.$controls=context.$ui.find('.wikiEditor-ui-buttons').hide();context.$buttons=context.$ui.find('.wikiEditor-ui-buttons');context.$tabs=context.$ui.find('.wikiEditor-ui-tabs');context.$ui.after($('<div style="clear:both;"></div>'));context.$wikitext.append($('<div></div>').addClass('wikiEditor-ui-right'));context.$wikitext.find('.wikiEditor-ui-left').prepend($('<div></div>').addClass('wikiEditor-ui-top'));context.view='wikitext';$(window).resize(function(event){context.fn.trigger('resize',event);});context.$iframe=$('<iframe></iframe>').attr({'frameBorder':0,'border':0,'tabindex':1,'src':wgScriptPath+'/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html?'+'instance='+context.instance+'&ts='+(new Date()).getTime(),'id':'wikiEditor-iframe-'+context.instance}).css({'backgroundColor':'white','width':'100%','height':context.$textarea.height(),'display':'none','overflow-y':'scroll','overflow-x':'hidden'}).insertAfter(context.$textarea).load(function(){if(!this.isSecondRun){context.$iframe[0].contentWindow.document.designMode='on';if($.browser.msie){this.isSecondRun=true;return;}} |
529 | | -context.$content=$(context.$iframe[0].contentWindow.document.body);var html=context.$textarea.val().replace(/ /g,'&nbsp;').replace(/\<br\>/g,'<br>').replace(/\<span class="wikiEditor-tab"\>\<\/span\>/g,'<span class="wikiEditor-tab"></span>');if($.browser.msie){if($.browser.versionNumber<=7){html=html.replace(/ /g," ");}else{html=html.replace(/(^|\n) /g,"$1 ");} |
530 | | -html=html.replace(/\t/g,'<span class="wikiEditor-tab"></span>');} |
531 | | -html=$('<div />').text('<p>'+html.replace(/\r?\n/g,'</p><p>')+'</p>').html().replace(/&nbsp;/g,' ').replace(/<p>/g,'<p>').replace(/<\/p>/g,'</p>').replace(/<p><\/p>/g,'<br>').replace(/<span class="wikiEditor-tab"><\/span>/g,'<span class="wikiEditor-tab"></span>').replace(/&amp;nbsp;/g,'&nbsp;').replace(/&lt;br&gt;/g,'<br>').replace(/&lt;span class=&quot;wikiEditor-tab&quot;&gt;&lt;\/span&gt;/g,'<span class="wikiEditor-tab"></span>');context.$content.html(html);context.oldHTML=html;context.history.push({'html':html});if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');} |
| 529 | +context.$content=$(context.$iframe[0].contentWindow.document.body);var html=context.$textarea.val().replace(/&esc;/g,'&esc;&esc;').replace(/\<p\>/g,'&esc;<p>').replace(/\<\/p\>/g,'&esc;</p>').replace(/\<span class="wikiEditor-tab"\>\<\/span\>/g,'&esc;<span class="wikiEditor-tab"></span>').replace(/ /g,'&esc;&nbsp;');if($.browser.msie){html=html.replace(/\t/g,'<span class="wikiEditor-tab"></span>');if($.browser.versionNumber<=7){html=html.replace(/ /g," ");}else{html=html.replace(/(^|\n) /g,"$1 ");}} |
| 530 | +html=$('<div />').text('<p>'+html.replace(/\r?\n/g,'</p><p>')+'</p>').html().replace(/&nbsp;/g,' ').replace(/<p>/g,'<p>').replace(/<\/p>/g,'</p>').replace(/<p><\/p>/g,'<br>').replace(/&esc;&amp;nbsp;/g,'&nbsp;').replace(/&esc;&lt;p&gt;/g,'<p>').replace(/&esc;&lt;\/p&gt;/g,'</p>').replace(/&esc;&lt;span class="wikiEditor-tab"&gt;&lt;\/span&gt;/g,'<span class="wikiEditor-tab"><\/span>').replace(/&esc;&esc;/g,'&esc;');context.$content.html(html);context.oldHTML=html;context.history.push({'html':html});if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');} |
532 | 531 | context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();context.fn.trigger('ready');$(context.$iframe[0].contentWindow.document).bind('keydown',function(event){return context.fn.trigger('keydown',event);}).bind('keyup mouseup paste cut encapsulateSelection',function(event){return context.fn.trigger('change',event);}).delayedBind(250,'keyup mouseup paste 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();}};} |
533 | 532 | var args=$.makeArray(arguments);if(args.length>0){var call=args.shift();if(call in context.api){context.api[call](context,typeof args[0]=='undefined'?{}:args[0]);}} |
534 | 533 | return $(this).data('wikiEditor-context',context);};})(jQuery);RegExp.escape=function(s){return s.replace(/([.*+?^${}()|\/\\[\]])/g,'\\$1');};(function($){$.wikiEditor.modules.dialogs={api:{addDialog:function(context,data){$.wikiEditor.modules.dialogs.fn.create(context,data)},openDialog:function(context,module){if(module in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[module].id).dialog('open');}},closeDialog:function(context,data){if(module in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[module].id).dialog('close');}}},fn:{create:function(context,config){for(module in config){$.wikiEditor.modules.dialogs.modules[module]=config[module];} |