r57304 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57303‎ | r57304 | r57305 >
Date:19:26, 2 October 2009
Author:catrope
Status:ok
Tags:
Comment:
* NavigableTOC: (bug 20940) Previous header focused when cursor placed just before first = sign. Regression from r57211
* (bug 20942) Autoellipsed section titles too long when highlighted
* Fix a bug where a page with starting with two identical headers and an empty section 0 (i.e. first character is '=') would confuse highlighting
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
@@ -67,16 +67,16 @@
6868 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 9 ),
6969 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 11 ),
7070 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 4 ),
71 - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 16 ),
 71+ array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 17 ),
7272 // FIXME: jQuery UI doesn't belong here, should move to no_js2
7373 // once we figure out how to do jQuery UI properly in JS2
7474 array( 'src' => 'js/js2/jquery-ui-1.7.2.js', 'version' => '1.7.2y' ),
7575 ),
7676 'combined' => array(
77 - array( 'src' => 'js/plugins.combined.js', 'version' => 37 ),
 77+ array( 'src' => 'js/plugins.combined.js', 'version' => 38 ),
7878 ),
7979 'minified' => array(
80 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 37 ),
 80+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 38 ),
8181 ),
8282 ),
8383 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js
@@ -172,23 +172,22 @@
173173 }
174174 // Build outline from wikitext
175175 var outline = [];
176 - var wikitext = '\n' + $.wikiEditor.fixOperaBrokenness( context.$textarea.val() ) + '\n';
 176+ var wikitext = $.wikiEditor.fixOperaBrokenness( context.$textarea.val() );
177177 var headings = wikitext.match( /^={1,6}.+={1,6}\s*$/gm );
178178 var offset = 0;
179179 headings = $.makeArray( headings );
180180 for ( var h = 0; h < headings.length; h++ ) {
181 - text = headings[h];
 181+ text = $.trim( headings[h] );
182182 // Get position of first occurence
183183 var position = wikitext.indexOf( text, offset );
184184 // Update offset to avoid stumbling on duplicate headings
185 - if ( position > offset ) {
 185+ if ( position >= offset ) {
186186 offset = position + 1;
187187 } else if ( position == -1 ) {
188188 // Not sure this is possible, or what should happen
189189 continue;
190190 }
191 - // Trim off whitespace
192 - text = $.trim( text );
 191+
193192 // Detect the starting and ending heading levels
194193 var startLevel = 0;
195194 for ( var c = 0; c < text.length; c++ ) {
@@ -237,7 +236,13 @@
238237 if ( $( 'input[name=wpSection]' ).val() == '' )
239238 structure.unshift( { 'text': wgPageName.replace(/_/g, ' '), 'level': 1, 'index': 0, 'position': 0 } );
240239 context.modules.$toc.html( buildList( structure ) );
241 - context.modules.$toc.find( 'ul a' ).autoEllipse( { 'position': 'right', 'tooltip': true } );
 240+
 241+ var links = context.modules.$toc.find( 'ul a' );
 242+ // Highlighted links are wider; autoEllipse links in
 243+ // highlighted state
 244+ links.addClass( 'currentSelection' );
 245+ links.autoEllipse( { 'position': 'right', 'tooltip': true } );
 246+ links.removeClass( 'currentSelection' );
242247 // Cache the outline for later use
243248 context.data.outline = outline;
244249 }
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -2193,23 +2193,22 @@
21942194 }
21952195 // Build outline from wikitext
21962196 var outline = [];
2197 - var wikitext = '\n' + $.wikiEditor.fixOperaBrokenness( context.$textarea.val() ) + '\n';
 2197+ var wikitext = $.wikiEditor.fixOperaBrokenness( context.$textarea.val() );
21982198 var headings = wikitext.match( /^={1,6}.+={1,6}\s*$/gm );
21992199 var offset = 0;
22002200 headings = $.makeArray( headings );
22012201 for ( var h = 0; h < headings.length; h++ ) {
2202 - text = headings[h];
 2202+ text = $.trim( headings[h] );
22032203 // Get position of first occurence
22042204 var position = wikitext.indexOf( text, offset );
22052205 // Update offset to avoid stumbling on duplicate headings
2206 - if ( position > offset ) {
 2206+ if ( position >= offset ) {
22072207 offset = position + 1;
22082208 } else if ( position == -1 ) {
22092209 // Not sure this is possible, or what should happen
22102210 continue;
22112211 }
2212 - // Trim off whitespace
2213 - text = $.trim( text );
 2212+
22142213 // Detect the starting and ending heading levels
22152214 var startLevel = 0;
22162215 for ( var c = 0; c < text.length; c++ ) {
@@ -2258,7 +2257,13 @@
22592258 if ( $( 'input[name=wpSection]' ).val() == '' )
22602259 structure.unshift( { 'text': wgPageName.replace(/_/g, ' '), 'level': 1, 'index': 0, 'position': 0 } );
22612260 context.modules.$toc.html( buildList( structure ) );
2262 - context.modules.$toc.find( 'ul a' ).autoEllipse( { 'position': 'right', 'tooltip': true } );
 2261+
 2262+ var links = context.modules.$toc.find( 'ul a' );
 2263+ // Highlighted links are wider; autoEllipse links in
 2264+ // highlighted state
 2265+ links.addClass( 'currentSelection' );
 2266+ links.autoEllipse( { 'position': 'right', 'tooltip': true } );
 2267+ links.removeClass( 'currentSelection' );
22632268 // Cache the outline for later use
22642269 context.data.outline = outline;
22652270 }
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -148,8 +148,8 @@
149149 function buildList(structure){var list=$('<ul />');for(i in structure){var item=$('<li />').append($('<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(true);event.preventDefault();}).text(structure[i].text));if(structure[i].sections!==undefined){item.append(buildList(structure[i].sections));}
150150 list.append(item);}
151151 return list;}
152 -var outline=[];var wikitext='\n'+$.wikiEditor.fixOperaBrokenness(context.$textarea.val())+'\n';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=headings[h];var position=wikitext.indexOf(text,offset);if(position>offset){offset=position+1;}else if(position==-1){continue;}
153 -text=$.trim(text);var startLevel=0;for(var c=0;c<text.length;c++){if(text.charAt(c)=='='){startLevel++;}else{break;}}
 152+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+1;}else if(position==-1){continue;}
 153+var startLevel=0;for(var c=0;c<text.length;c++){if(text.charAt(c)=='='){startLevel++;}else{break;}}
154154 var endLevel=0;for(var c=text.length-1;c>=0;c--){if(text.charAt(c)=='='){endLevel++;}else{break;}}
155155 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};}
156156 var lastLevel=0;var nLevel=0;for(var i=0;i<outline.length;i++){if(outline[i].level>lastLevel){nLevel++;}
@@ -157,4 +157,4 @@
158158 if(nLevel<=0){nLevel=1;}
159159 outline[i].nLevel=nLevel;lastLevel=outline[i].level;}
160160 var structure=buildStructure(outline);if($('input[name=wpSection]').val()=='')
161 -structure.unshift({'text':wgPageName.replace(/_/g,' '),'level':1,'index':0,'position':0});context.modules.$toc.html(buildList(structure));context.modules.$toc.find('ul a').autoEllipse({'position':'right','tooltip':true});context.data.outline=outline;}}};})(jQuery);
\ No newline at end of file
 161+structure.unshift({'text':wgPageName.replace(/_/g,' '),'level':1,'index':0,'position':0});context.modules.$toc.html(buildList(structure));var links=context.modules.$toc.find('ul a');links.addClass('currentSelection');links.autoEllipse({'position':'right','tooltip':true});links.removeClass('currentSelection');context.data.outline=outline;}}};})(jQuery);
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r57719wmf-deployment: Merge babaco fixes from trunk...catrope20:20, 14 October 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r57211NavigableTOC: (bug 20918) Section headers with trailing spaces aren't shown i...catrope12:30, 1 October 2009

Status & tagging log