r57906 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57905‎ | r57906 | r57907 >
Date:18:28, 19 October 2009
Author:catrope
Status:deferred
Tags:
Comment:
NavigableTOC: (bug 21177) Empty headers (like "====") treated weird. The NTOC now ignores such headers, while the parser interprets them as "= == ="; the latter form is still accepted by the NTOC.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -69,13 +69,13 @@
7070 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 12 ),
7171 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 12 ),
7272 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 5 ),
73 - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 20 ),
 73+ array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 21 ),
7474 ),
7575 'combined' => array(
76 - array( 'src' => 'js/plugins.combined.js', 'version' => 45 ),
 76+ array( 'src' => 'js/plugins.combined.js', 'version' => 46 ),
7777 ),
7878 'minified' => array(
79 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 45 ),
 79+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 46 ),
8080 ),
8181 ),
8282 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js
@@ -173,7 +173,7 @@
174174 // Build outline from wikitext
175175 var outline = [];
176176 var wikitext = $.wikiEditor.fixOperaBrokenness( context.$textarea.val() );
177 - var headings = wikitext.match( /^={1,6}.+={1,6}\s*$/gm );
 177+ var headings = wikitext.match( /^={1,6}[^=\n][^\n]*={1,6}\s*$/gm );
178178 var offset = 0;
179179 headings = $.makeArray( headings );
180180 for ( var h = 0; h < headings.length; h++ ) {
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -2362,7 +2362,7 @@
23632363 // Build outline from wikitext
23642364 var outline = [];
23652365 var wikitext = $.wikiEditor.fixOperaBrokenness( context.$textarea.val() );
2366 - var headings = wikitext.match( /^={1,6}.+={1,6}\s*$/gm );
 2366+ var headings = wikitext.match( /^={1,6}[^=\n][^\n]*={1,6}\s*$/gm );
23672367 var offset = 0;
23682368 headings = $.makeArray( headings );
23692369 for ( var h = 0; h < headings.length; h++ ) {
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -152,7 +152,7 @@
153153 $.trackAction('ntoc.heading');event.preventDefault();}).text(structure[i].text));if(structure[i].sections!==undefined){item.append(buildList(structure[i].sections));}
154154 list.append(item);}
155155 return list;}
156 -var outline=[];var wikitext=$.wikiEditor.fixOperaBrokenness(context.$textarea.val());var headings=wikitext.match(/^={1,6}.+={1,6}\s*$/gm);var offset=0;headings=$.makeArray(headings);for(var h=0;h<headings.length;h++){text=$.trim(headings[h]);var position=wikitext.indexOf(text,offset);if(position>=offset){offset=position+text.length;}else if(position==-1){continue;}
 156+var outline=[];var wikitext=$.wikiEditor.fixOperaBrokenness(context.$textarea.val());var headings=wikitext.match(/^={1,6}[^=\n][^\n]*={1,6}\s*$/gm);var offset=0;headings=$.makeArray(headings);for(var h=0;h<headings.length;h++){text=$.trim(headings[h]);var position=wikitext.indexOf(text,offset);if(position>=offset){offset=position+text.length;}else if(position==-1){continue;}
157157 var startLevel=0;for(var c=0;c<text.length;c++){if(text.charAt(c)=='='){startLevel++;}else{break;}}
158158 var endLevel=0;for(var c=text.length-1;c>=0;c--){if(text.charAt(c)=='='){endLevel++;}else{break;}}
159159 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};}

Follow-up revisions

RevisionCommit summaryAuthorDate
r58374NavigableTOC: (bug 21177) Empty headers show up weird (very small height)catrope20:19, 30 October 2009
r59204wmf-deployment: Merging usability changes from trunk...catrope18:53, 18 November 2009

Status & tagging log