Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -64,19 +64,19 @@ |
65 | 65 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ), |
66 | 66 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 4 ), |
67 | 67 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 12 ), |
68 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 6 ), |
| 68 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 7 ), |
69 | 69 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 11 ), |
70 | 70 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 3 ), |
71 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 10 ), |
| 71 | + array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 11 ), |
72 | 72 | // FIXME: jQuery UI doesn't belong here, should move to no_js2 |
73 | 73 | // once we figure out how to do jQuery UI properly in JS2 |
74 | 74 | array( 'src' => 'js/js2/jquery-ui-1.7.2.js', 'version' => '1.7.2y' ), |
75 | 75 | ), |
76 | 76 | 'combined' => array( |
77 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 29 ), |
| 77 | + array( 'src' => 'js/plugins.combined.js', 'version' => 30 ), |
78 | 78 | ), |
79 | 79 | 'minified' => array( |
80 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 29 ), |
| 80 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 30 ), |
81 | 81 | ), |
82 | 82 | ), |
83 | 83 | ); |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js |
— | — | @@ -1217,40 +1217,6 @@ |
1218 | 1218 | dialog: { |
1219 | 1219 | buttons: { |
1220 | 1220 | 'edittoolbar-tool-replace-button': function() { |
1221 | | - function fixOperaBrokenness( s ) { |
1222 | | - // This function works around Opera's |
1223 | | - // broken newline handling in textareas. |
1224 | | - // .val() has \n while selection functions |
1225 | | - // treat newlines as \r\n |
1226 | | - |
1227 | | - if ( typeof $j.isOperaBroken == 'undefined' ) { |
1228 | | - // Create a textarea inside a div |
1229 | | - // with zero area, to hide it properly |
1230 | | - var div = $j( '<div />' ) |
1231 | | - .height( 0 ) |
1232 | | - .width( 0 ) |
1233 | | - .insertBefore( $textarea ); |
1234 | | - var textarea = $j( '<textarea></textarea' ) |
1235 | | - .height( 0 ) |
1236 | | - .appendTo( div ) |
1237 | | - .val( "foo\r\nbar" ); |
1238 | | - |
1239 | | - // Try to search&replace bar --> BAR |
1240 | | - var index = textarea.val().indexOf( 'bar' ); |
1241 | | - textarea.select(); |
1242 | | - textarea.setSelection( index, index + 3 ); |
1243 | | - textarea.encapsulateSelection( '', 'BAR', '', false, true ); |
1244 | | - if ( textarea.val().substr( -1 ) == 'R' ) |
1245 | | - $j.isOperaBroken = false; |
1246 | | - else |
1247 | | - $j.isOperaBroken = true; |
1248 | | - div.remove(); |
1249 | | - } |
1250 | | - if ( $j.isOperaBroken ) |
1251 | | - s = s.replace( /\n/g, "\r\n" ); |
1252 | | - return s; |
1253 | | - } |
1254 | | - |
1255 | 1221 | $j( '#edittoolbar-replace-nomatch, #edittoolbar-replace-success' ).hide(); |
1256 | 1222 | var searchStr = $j( '#edittoolbar-replace-search' ).val(); |
1257 | 1223 | var replaceStr = $j( '#edittoolbar-replace-replace' ).val(); |
— | — | @@ -1267,7 +1233,7 @@ |
1268 | 1234 | } |
1269 | 1235 | var regex = new RegExp( searchStr, flags ); |
1270 | 1236 | var $textarea = $j(this).data( 'context' ).$textarea; |
1271 | | - var text = fixOperaBrokenness( $textarea.val() ); |
| 1237 | + var text = $j.wikiEditor.fixOperaBrokenness( $textarea.val() ); |
1272 | 1238 | var matches = text.match( regex ); |
1273 | 1239 | if ( !matches ) { |
1274 | 1240 | $j( '#edittoolbar-replace-nomatch' ).show(); |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | /* Configuration */ |
21 | 21 | |
22 | 22 | // Bump the version number every time you change any of the .css/.js files |
23 | | -$wgEditToolbarStyleVersion = 43; |
| 23 | +$wgEditToolbarStyleVersion = 44; |
24 | 24 | |
25 | 25 | // Set this to true to simply override the stock toolbar for everyone |
26 | 26 | $wgEditToolbarGlobalEnable = false; |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -57,6 +57,40 @@ |
58 | 58 | } |
59 | 59 | }; |
60 | 60 | |
| 61 | +$.wikiEditor.fixOperaBrokenness = function( s ) { |
| 62 | + // This function works around Opera's |
| 63 | + // broken newline handling in textareas. |
| 64 | + // .val() has \n while selection functions |
| 65 | + // treat newlines as \r\n |
| 66 | + |
| 67 | + if ( typeof $.isOperaBroken == 'undefined' && $.wikiEditor.instances.length > 0 ) { |
| 68 | + // Create a textarea inside a div |
| 69 | + // with zero area, to hide it properly |
| 70 | + var div = $( '<div />' ) |
| 71 | + .height( 0 ) |
| 72 | + .width( 0 ) |
| 73 | + .insertBefore( $.wikiEditor.instances[0] ); |
| 74 | + var textarea = $( '<textarea></textarea' ) |
| 75 | + .height( 0 ) |
| 76 | + .appendTo( div ) |
| 77 | + .val( "foo\r\nbar" ); |
| 78 | + |
| 79 | + // Try to search&replace bar --> BAR |
| 80 | + var index = textarea.val().indexOf( 'bar' ); |
| 81 | + textarea.select(); |
| 82 | + textarea.setSelection( index, index + 3 ); |
| 83 | + textarea.encapsulateSelection( '', 'BAR', '', false, true ); |
| 84 | + if ( textarea.val().substr( -1 ) == 'R' ) |
| 85 | + $.isOperaBroken = false; |
| 86 | + else |
| 87 | + $.isOperaBroken = true; |
| 88 | + div.remove(); |
| 89 | + } |
| 90 | + if ( $.isOperaBroken ) |
| 91 | + s = s.replace( /\n/g, "\r\n" ); |
| 92 | + return s; |
| 93 | +}; |
| 94 | + |
61 | 95 | $.fn.wikiEditor = function() { |
62 | 96 | |
63 | 97 | /* Initialization */ |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js |
— | — | @@ -173,8 +173,8 @@ |
174 | 174 | } |
175 | 175 | // Build outline from wikitext |
176 | 176 | var outline = []; |
177 | | - var wikitext = '\n' + context.$textarea.val() + '\n'; |
178 | | - var headings = wikitext.match( /\n={1,5}.*={1,5}(?=\n)/g ); |
| 177 | + var wikitext = '\n' + $.wikiEditor.fixOperaBrokenness( context.$textarea.val() ) + '\n'; |
| 178 | + var headings = wikitext.match( /(\r|\n)={1,5}.*={1,5}(?=(\r|\n))/g ); |
179 | 179 | var offset = 0; |
180 | 180 | headings = $.makeArray( headings ); |
181 | 181 | for ( var h = 0; h < headings.length; h++ ) { |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -1168,6 +1168,40 @@ |
1169 | 1169 | } |
1170 | 1170 | }; |
1171 | 1171 | |
| 1172 | +$.wikiEditor.fixOperaBrokenness = function( s ) { |
| 1173 | + // This function works around Opera's |
| 1174 | + // broken newline handling in textareas. |
| 1175 | + // .val() has \n while selection functions |
| 1176 | + // treat newlines as \r\n |
| 1177 | + |
| 1178 | + if ( typeof $.isOperaBroken == 'undefined' && $.wikiEditor.instances.length > 0 ) { |
| 1179 | + // Create a textarea inside a div |
| 1180 | + // with zero area, to hide it properly |
| 1181 | + var div = $( '<div />' ) |
| 1182 | + .height( 0 ) |
| 1183 | + .width( 0 ) |
| 1184 | + .insertBefore( $.wikiEditor.instances[0] ); |
| 1185 | + var textarea = $( '<textarea></textarea' ) |
| 1186 | + .height( 0 ) |
| 1187 | + .appendTo( div ) |
| 1188 | + .val( "foo\r\nbar" ); |
| 1189 | + |
| 1190 | + // Try to search&replace bar --> BAR |
| 1191 | + var index = textarea.val().indexOf( 'bar' ); |
| 1192 | + textarea.select(); |
| 1193 | + textarea.setSelection( index, index + 3 ); |
| 1194 | + textarea.encapsulateSelection( '', 'BAR', '', false, true ); |
| 1195 | + if ( textarea.val().substr( -1 ) == 'R' ) |
| 1196 | + $.isOperaBroken = false; |
| 1197 | + else |
| 1198 | + $.isOperaBroken = true; |
| 1199 | + div.remove(); |
| 1200 | + } |
| 1201 | + if ( $.isOperaBroken ) |
| 1202 | + s = s.replace( /\n/g, "\r\n" ); |
| 1203 | + return s; |
| 1204 | +}; |
| 1205 | + |
1172 | 1206 | $.fn.wikiEditor = function() { |
1173 | 1207 | |
1174 | 1208 | /* Initialization */ |
— | — | @@ -2137,8 +2171,8 @@ |
2138 | 2172 | } |
2139 | 2173 | // Build outline from wikitext |
2140 | 2174 | var outline = []; |
2141 | | - var wikitext = '\n' + context.$textarea.val() + '\n'; |
2142 | | - var headings = wikitext.match( /\n={1,5}.*={1,5}(?=\n)/g ); |
| 2175 | + var wikitext = '\n' + $.wikiEditor.fixOperaBrokenness( context.$textarea.val() ) + '\n'; |
| 2176 | + var headings = wikitext.match( /(\r|\n)={1,5}.*={1,5}(?=(\r|\n))/g ); |
2143 | 2177 | var offset = 0; |
2144 | 2178 | headings = $.makeArray( headings ); |
2145 | 2179 | for ( var h = 0; h < headings.length; h++ ) { |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -76,7 +76,11 @@ |
77 | 77 | return($.os.name=='mac'?13:($.os.name=='linux'?15:16))*row;} |
78 | 78 | return this.each(function(){$(this).focus();if(this.selectionStart||this.selectionStart=='0'){$(this).scrollTop(getCaretScrollPosition(this));}else if(document.selection&&document.selection.createRange){var range=document.selection.createRange();var pos=$(this).getCaretPosition();range.moveToElementText(this);range.collapse();range.move('character',pos+1);range.select();this.scrollTop+=range.offsetTop;range.move('character',-1);range.select();} |
79 | 79 | $(this).trigger('scrollToPosition');});}});})(jQuery);(function($){$.wikiEditor={'modules':{},'instances':[],'supportedBrowsers':{'ltr':{'msie':7,'firefox':2,'opera':9,'safari':3,'chrome':1,'camino':1},'rtl':{'msie':8,'firefox':2,'opera':9,'safari':3,'chrome':1,'camino':1}},imgPath:wgScriptPath+'/extensions/UsabilityInitiative/images/wikiEditor/'};$.wikiEditor.isSupportKnown=function(){return(function(supportedBrowsers){return $.browser.name in supportedBrowsers;})($.wikiEditor.supportedBrowsers[$('body.rtl').size()?'rtl':'ltr']);};$.wikiEditor.isSupported=function(){return(function(supportedBrowsers){return $.browser.name in supportedBrowsers&&$.browser.versionNumber>=supportedBrowsers[$.browser.name];})($.wikiEditor.supportedBrowsers[$('body.rtl').size()?'rtl':'ltr']);};$.wikiEditor.autoMsg=function(object,property){if(typeof property=='object'){for(i in property){if(property[i]in object||property[i]+'Msg'in object){property=property[i];break;}}} |
80 | | -if(property in object){return object[property];}else if(property+'Msg'in object){return gM(object[property+'Msg']);}else{return'';}};$.fn.wikiEditor=function(){var context=$(this).data('wikiEditor-context');if(typeof context=='undefined'){var instance=$.wikiEditor.instances.length;context={'$textarea':$(this),'modules':{},'data':{},'instance':instance};$.wikiEditor.instances[instance]=$(this);$(this).wrap($('<div></div>').addClass('wikiEditor-ui').attr('id','wikiEditor-ui')).wrap($('<div></div>').addClass('wikiEditor-ui-bottom').attr('id','wikiEditor-ui-bottom')).wrap($('<div></div>').addClass('wikiEditor-ui-text').attr('id','wikiEditor-ui-text'));context.$ui=$(this).parent().parent().parent();context.$ui.after($('<div style="clear:both;"></div>'));context.$ui.prepend($('<div></div>').addClass('wikiEditor-ui-top').attr('id','wikiEditor-ui-top'));context.api={addModule:function(context,data){function callModuleApi(module,call,data){if(module in $.wikiEditor.modules&&'fn'in $.wikiEditor.modules[module]&&call in $.wikiEditor.modules[module].fn){$.wikiEditor.modules[module].fn[call](context,data);}} |
| 80 | +if(property in object){return object[property];}else if(property+'Msg'in object){return gM(object[property+'Msg']);}else{return'';}};$.wikiEditor.fixOperaBrokenness=function(s){if(typeof $.isOperaBroken=='undefined'&&$.wikiEditor.instances.length>0){var div=$('<div />').height(0).width(0).insertBefore($.wikiEditor.instances[0]);var textarea=$('<textarea></textarea').height(0).appendTo(div).val("foo\r\nbar");var index=textarea.val().indexOf('bar');textarea.select();textarea.setSelection(index,index+3);textarea.encapsulateSelection('','BAR','',false,true);if(textarea.val().substr(-1)=='R') |
| 81 | +$.isOperaBroken=false;else |
| 82 | +$.isOperaBroken=true;div.remove();} |
| 83 | +if($.isOperaBroken) |
| 84 | +s=s.replace(/\n/g,"\r\n");return s;};$.fn.wikiEditor=function(){var context=$(this).data('wikiEditor-context');if(typeof context=='undefined'){var instance=$.wikiEditor.instances.length;context={'$textarea':$(this),'modules':{},'data':{},'instance':instance};$.wikiEditor.instances[instance]=$(this);$(this).wrap($('<div></div>').addClass('wikiEditor-ui').attr('id','wikiEditor-ui')).wrap($('<div></div>').addClass('wikiEditor-ui-bottom').attr('id','wikiEditor-ui-bottom')).wrap($('<div></div>').addClass('wikiEditor-ui-text').attr('id','wikiEditor-ui-text'));context.$ui=$(this).parent().parent().parent();context.$ui.after($('<div style="clear:both;"></div>'));context.$ui.prepend($('<div></div>').addClass('wikiEditor-ui-top').attr('id','wikiEditor-ui-top'));context.api={addModule:function(context,data){function callModuleApi(module,call,data){if(module in $.wikiEditor.modules&&'fn'in $.wikiEditor.modules[module]&&call in $.wikiEditor.modules[module].fn){$.wikiEditor.modules[module].fn[call](context,data);}} |
81 | 85 | if(typeof data=='string'){callModuleApi(data,'create',{});}else if(typeof data=='object'){for(module in data){if(typeof module=='string'){callModuleApi(module,'create',data[module]);}}}}};for(module in $.wikiEditor.modules){if('api'in $.wikiEditor.modules[module]){for(call in $.wikiEditor.modules[module].api){if(!(call in context.api)){context.api[call]=$.wikiEditor.modules[module].api[call];}}}} |
82 | 86 | context.$textarea.setSelection(0).scrollToCaretPosition();} |
83 | 87 | if(arguments.length>0&&typeof arguments[0]=='object'){context.api.addModule(context,arguments[0]);}else{arguments=$.makeArray(arguments);if(arguments.length>0){var call=arguments.shift();if(call in context.api){context.api[call](context,arguments[0]==undefined?{}:arguments[0]);}}} |
— | — | @@ -141,7 +145,7 @@ |
142 | 146 | function buildList(structure){var list=$('<ul></ul>');for(i in structure){var item=$('<li></li>').append($('<a></a>').attr('href','#').addClass('section-'+structure[i].index).data('textbox',context.$textarea).data('position',structure[i].position).click(function(event){$(this).data('textbox').setSelection($(this).data('position')).scrollToCaretPosition();event.preventDefault();}).text(structure[i].text));if(structure[i].sections!==undefined){item.append(buildList(structure[i].sections));} |
143 | 147 | list.append(item);} |
144 | 148 | return list;} |
145 | | -var outline=[];var wikitext='\n'+context.$textarea.val()+'\n';var headings=wikitext.match(/\n={1,5}.*={1,5}(?=\n)/g);var offset=0;headings=$.makeArray(headings);for(var h=0;h<headings.length;h++){text=headings[h];var position=wikitext.indexOf(text,offset);if(position>offset){offset=position+1;}else if(position==-1){continue;} |
| 149 | +var outline=[];var wikitext='\n'+$.wikiEditor.fixOperaBrokenness(context.$textarea.val())+'\n';var headings=wikitext.match(/(\r|\n)={1,5}.*={1,5}(?=(\r|\n))/g);var offset=0;headings=$.makeArray(headings);for(var h=0;h<headings.length;h++){text=headings[h];var position=wikitext.indexOf(text,offset);if(position>offset){offset=position+1;}else if(position==-1){continue;} |
146 | 150 | text=$.trim(text);var startLevel=0;for(var c=0;c<text.length;c++){if(text.charAt(c)=='='){startLevel++;}else{break;}} |
147 | 151 | var endLevel=0;for(var c=text.length-1;c>=0;c--){if(text.charAt(c)=='='){endLevel++;}else{break;}} |
148 | 152 | var level=Math.min(startLevel,endLevel);text=$.trim(text.substr(level,text.length-(level*2)));outline[h]={'text':text,'position':position,'level':level,'index':h+1};} |