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' => 77 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 78 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 25 ), |
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' => 190 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 191 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 190 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 191 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -796,7 +796,7 @@ |
797 | 797 | var base = context.offsets[lowerBound]; |
798 | 798 | return context.offsets[offset] = { |
799 | 799 | 'node': base.node, |
800 | | - 'offset': base.offset + offset - o, |
| 800 | + 'offset': base.offset + offset - lowerBound, |
801 | 801 | 'length': base.length, |
802 | 802 | 'depth': base.depth, |
803 | 803 | 'lastTextNode': base.lastTextNode, |
— | — | @@ -923,7 +923,13 @@ |
924 | 924 | // If we just do "context.$content.text( context.$textarea.val() )", Internet Explorer will strip out the |
925 | 925 | // whitespace charcters, specifically "\n" - so we must manually encode the text and append it |
926 | 926 | // TODO: Refactor this into a textToHtml() function |
927 | | - var html = context.$textarea.val(); |
| 927 | + // Because we're gonna insert instances of <br>, and <span class="wikiEditor-tab"></span>, |
| 928 | + // we have to escape existing instances first. This'll cause them to be double-escaped, which we |
| 929 | + // fix later on |
| 930 | + var html = context.$textarea.val() |
| 931 | + .replace( / /g, '&nbsp;' ) |
| 932 | + .replace( /\<br\>/g, '<br>' ) |
| 933 | + .replace( /\<span class="wikiEditor-tab"\>\<\/span\>/g, '<span class="wikiEditor-tab"></span>' ); |
928 | 934 | // We must do some extra processing on IE to avoid dirty diffs, specifically IE will collapse leading spaces |
929 | 935 | if ( $.browser.msie ) { |
930 | 936 | // Browser sniffing is not ideal, but executing this code on a non-broken browser doesn't cause harm |
— | — | @@ -939,10 +945,14 @@ |
940 | 946 | } |
941 | 947 | // Use a dummy div to escape all entities |
942 | 948 | // This'll also escape <br>, <span> and , so we unescape those after |
| 949 | + // We also need to unescape the doubly-escaped things mentioned above |
943 | 950 | html = $( '<div />' ).text( html.replace( /\r?\n/g, '<br>' ) ).html() |
944 | 951 | .replace( /&nbsp;/g, ' ' ) |
945 | 952 | .replace( /<br>/g, '<br>' ) |
946 | | - .replace( /<span class="wikiEditor-tab"><\/span>/g, '<span class="wikiEditor-tab"></span>' ); |
| 953 | + .replace( /<span class="wikiEditor-tab"><\/span>/g, '<span class="wikiEditor-tab"></span>' ) |
| 954 | + .replace( /&amp;nbsp;/g, '&nbsp;' ) |
| 955 | + .replace( /&lt;br&gt;/g, '<br>' ) |
| 956 | + .replace( /&lt;span class=&quot;wikiEditor-tab&quot;&gt;&lt;\/span&gt;/g, '<span class="wikiEditor-tab"></span>' ); |
947 | 957 | context.$content.html( html ); |
948 | 958 | |
949 | 959 | // Reflect direction of parent frame into child |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -7220,7 +7220,7 @@ |
7221 | 7221 | var base = context.offsets[lowerBound]; |
7222 | 7222 | return context.offsets[offset] = { |
7223 | 7223 | 'node': base.node, |
7224 | | - 'offset': base.offset + offset - o, |
| 7224 | + 'offset': base.offset + offset - lowerBound, |
7225 | 7225 | 'length': base.length, |
7226 | 7226 | 'depth': base.depth, |
7227 | 7227 | 'lastTextNode': base.lastTextNode, |
— | — | @@ -7347,7 +7347,13 @@ |
7348 | 7348 | // If we just do "context.$content.text( context.$textarea.val() )", Internet Explorer will strip out the |
7349 | 7349 | // whitespace charcters, specifically "\n" - so we must manually encode the text and append it |
7350 | 7350 | // TODO: Refactor this into a textToHtml() function |
7351 | | - var html = context.$textarea.val(); |
| 7351 | + // Because we're gonna insert instances of <br>, and <span class="wikiEditor-tab"></span>, |
| 7352 | + // we have to escape existing instances first. This'll cause them to be double-escaped, which we |
| 7353 | + // fix later on |
| 7354 | + var html = context.$textarea.val() |
| 7355 | + .replace( / /g, '&nbsp;' ) |
| 7356 | + .replace( /\<br\>/g, '<br>' ) |
| 7357 | + .replace( /\<span class="wikiEditor-tab"\>\<\/span\>/g, '<span class="wikiEditor-tab"></span>' ); |
7352 | 7358 | // We must do some extra processing on IE to avoid dirty diffs, specifically IE will collapse leading spaces |
7353 | 7359 | if ( $.browser.msie ) { |
7354 | 7360 | // Browser sniffing is not ideal, but executing this code on a non-broken browser doesn't cause harm |
— | — | @@ -7363,10 +7369,14 @@ |
7364 | 7370 | } |
7365 | 7371 | // Use a dummy div to escape all entities |
7366 | 7372 | // This'll also escape <br>, <span> and , so we unescape those after |
| 7373 | + // We also need to unescape the doubly-escaped things mentioned above |
7367 | 7374 | html = $( '<div />' ).text( html.replace( /\r?\n/g, '<br>' ) ).html() |
7368 | 7375 | .replace( /&nbsp;/g, ' ' ) |
7369 | 7376 | .replace( /<br>/g, '<br>' ) |
7370 | | - .replace( /<span class="wikiEditor-tab"><\/span>/g, '<span class="wikiEditor-tab"></span>' ); |
| 7377 | + .replace( /<span class="wikiEditor-tab"><\/span>/g, '<span class="wikiEditor-tab"></span>' ) |
| 7378 | + .replace( /&amp;nbsp;/g, '&nbsp;' ) |
| 7379 | + .replace( /&lt;br&gt;/g, '<br>' ) |
| 7380 | + .replace( /&lt;span class=&quot;wikiEditor-tab&quot;&gt;&lt;\/span&gt;/g, '<span class="wikiEditor-tab"></span>' ); |
7371 | 7381 | context.$content.html( html ); |
7372 | 7382 | |
7373 | 7383 | // Reflect direction of parent frame into child |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -490,13 +490,13 @@ |
491 | 491 | var lowerBound=-1;for(var o in context.offsets){if(o>offset){break;} |
492 | 492 | lowerBound=o;} |
493 | 493 | if(!(lowerBound in context.offsets)){return null;} |
494 | | -var base=context.offsets[lowerBound];return context.offsets[offset]={'node':base.node,'offset':base.offset+offset-o,'length':base.length,'depth':base.depth,'lastTextNode':base.lastTextNode,'lastTextNodeDepth':base.lastTextNodeDepth};},'purgeOffsets':function(){context.offsets=null;},'refreshOffsets':function(){context.offsets=[];var t=context.fn.traverser(context.$content);var pos=0,lastTextNode=null,lastTextNodeDepth=null;while(t){if(t.node.nodeName!='#text'&&t.node.nodeName!='BR'){t=t.next();continue;} |
| 494 | +var base=context.offsets[lowerBound];return context.offsets[offset]={'node':base.node,'offset':base.offset+offset-lowerBound,'length':base.length,'depth':base.depth,'lastTextNode':base.lastTextNode,'lastTextNodeDepth':base.lastTextNodeDepth};},'purgeOffsets':function(){context.offsets=null;},'refreshOffsets':function(){context.offsets=[];var t=context.fn.traverser(context.$content);var pos=0,lastTextNode=null,lastTextNodeDepth=null;while(t){if(t.node.nodeName!='#text'&&t.node.nodeName!='BR'){t=t.next();continue;} |
495 | 495 | var nextPos=t.node.nodeName=='#text'?pos+t.node.nodeValue.length:pos+1;var nextT=t.next();var leavingP=t.inP&&nextT&&!nextT.inP;context.offsets[pos]={'node':t.node,'offset':0,'length':nextPos-pos+(leavingP?1:0),'depth':t.depth,'lastTextNode':lastTextNode,'lastTextNodeDepth':lastTextNodeDepth};if(leavingP){context.offsets[nextPos]={'node':t.node,'offset':nextPos-pos,'length':nextPos-pos+1,'depth':t.depth,'lastTextNode':lastTextNode,'lastTextNodeDepth':lastTextNodeDepth};} |
496 | 496 | pos=nextPos+(leavingP?1:0);if(t.node.nodeName=='#text'){lastTextNode=t.node;lastTextNodeDepth=t.depth;} |
497 | 497 | t=nextT;}}};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,'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;}} |
498 | | -context.$content=$(context.$iframe[0].contentWindow.document.body);var html=context.$textarea.val();if($.browser.msie){if($.browser.versionNumber<=7){html=html.replace(/ /g," ");}else{html=html.replace(/(^|\n) /g,"$1 ");} |
| 498 | +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 ");} |
499 | 499 | html=html.replace(/\t/g,'<span class="wikiEditor-tab"></span>');} |
500 | | -html=$('<div />').text(html.replace(/\r?\n/g,'<br>')).html().replace(/&nbsp;/g,' ').replace(/<br>/g,'<br>').replace(/<span class="wikiEditor-tab"><\/span>/g,'<span class="wikiEditor-tab"></span>');context.$content.html(html);if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');} |
| 500 | +html=$('<div />').text(html.replace(/\r?\n/g,'<br>')).html().replace(/&nbsp;/g,' ').replace(/<br>/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);if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');} |
501 | 501 | context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();context.fn.trigger('ready');$(context.$iframe[0].contentWindow.document).bind('keyup mouseup paste cut encapsulateSelection',function(event){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'));return context.fallbackWindowOnBeforeUnload?context.fallbackWindowOnBeforeUnload():null;}} |
502 | 502 | arguments=$.makeArray(arguments);if(arguments.length>0){var call=arguments.shift();if(call in context.api){context.api[call](context,typeof arguments[0]=='undefined'?{}:arguments[0]);}} |
503 | 503 | 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];} |