r61808 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61807‎ | r61808 | r61809 >
Date:18:14, 1 February 2010
Author:catrope
Status:deferred
Tags:
Comment:
UsabilityInitiative: Fix bug where TOC jump to section broke due to aggressive caching
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/js/plugins/jquery.wikiEditor.toc.js
@@ -391,17 +391,18 @@
392392 function buildList( structure ) {
393393 var list = $( '<ul />' );
394394 for ( i in structure ) {
395 - var wrapper = context.$content.find( '.wikiEditor-toc-section-' + structure[i].index );
396 - if ( wrapper.size() == 0 )
397 - wrapper = context.$content;
398395 var div = $( '<div />' )
399396 .addClass( 'section-' + structure[i].index )
400 - .data( 'wrapper', wrapper )
 397+ .data( 'index', structure[i].index )
401398 .click( function( event ) {
402 - context.fn.scrollToTop( $( this ).data( 'wrapper' ), true );
 399+ var wrapper = context.$content.find(
 400+ '.wikiEditor-toc-section-' + $( this ).data( 'index' ) );
 401+ if ( wrapper.size() == 0 )
 402+ wrapper = context.$content;
 403+ context.fn.scrollToTop( wrapper, true );
403404 context.$textarea.textSelection( 'setSelection', {
404405 'start': 0,
405 - 'startContainer': $(this).data( 'wrapper' )
 406+ 'startContainer': wrapper
406407 } );
407408 // Highlight the clicked link
408409 $.wikiEditor.modules.toc.fn.unhighlight( context );
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -9312,17 +9312,18 @@
93139313 function buildList( structure ) {
93149314 var list = $( '<ul />' );
93159315 for ( i in structure ) {
9316 - var wrapper = context.$content.find( '.wikiEditor-toc-section-' + structure[i].index );
9317 - if ( wrapper.size() == 0 )
9318 - wrapper = context.$content;
93199316 var div = $( '<div />' )
93209317 .addClass( 'section-' + structure[i].index )
9321 - .data( 'wrapper', wrapper )
 9318+ .data( 'index', structure[i].index )
93229319 .click( function( event ) {
9323 - context.fn.scrollToTop( $( this ).data( 'wrapper' ), true );
 9320+ var wrapper = context.$content.find(
 9321+ '.wikiEditor-toc-section-' + $( this ).data( 'index' ) );
 9322+ if ( wrapper.size() == 0 )
 9323+ wrapper = context.$content;
 9324+ context.fn.scrollToTop( wrapper, true );
93249325 context.$textarea.textSelection( 'setSelection', {
93259326 'start': 0,
9326 - 'startContainer': $(this).data( 'wrapper' )
 9327+ 'startContainer': wrapper
93279328 } );
93289329 // Highlight the clicked link
93299330 $.wikiEditor.modules.toc.fn.unhighlight( context );
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -622,8 +622,8 @@
623623 var pT=$this.parent().position().top-1;context.modules.toc.$toc.data('collapsed',true);context.$ui.find('.wikiEditor-ui-left').animate({'marginRight':'-1px'},'fast',function(){$(this).css('marginRight',0);}).children().animate({'marginRight':'1px'},'fast',function(){$(this).css('marginRight',0);});context.$ui.find('.wikiEditor-ui-right').css({'marginTop':'1px','position':'absolute','left':$.wikiEditor.modules.toc.cfg.rtl?0:'auto','right':$.wikiEditor.modules.toc.cfg.rtl?'auto':0,'top':pT}).fadeOut('fast',function(){$(this).hide().css({'marginTop':'0','width':'1px'});context.$ui.find('.wikiEditor-ui-toc-expandControl').fadeIn('fast');context.fn.trigger('tocCollapse');context.fn.trigger('resize');});$.cookie('wikiEditor-'+context.instance+'-toc-width',0);return false;},expand:function(event){var $this=$(this),context=$this.data('context'),openWidth=parseFloat(context.modules.toc.$toc.data('openWidth')),availableSpace=context.$wikitext.width()-parseFloat($.wikiEditor.modules.toc.cfg.textMinimumWidth);if(availableSpace<$.wikiEditor.modules.toc.cfg.textMinmumWidth)return false;context.modules.toc.$toc.data('collapsed',false);if(availableSpace<openWidth)openWidth=availableSpace;context.$ui.find('.wikiEditor-ui-toc-expandControl').hide();context.$ui.find('.wikiEditor-ui-left').animate({'marginRight':(parseFloat(openWidth)*-1)},'fast').children().animate({'marginRight':openWidth},'fast');context.$ui.find('.wikiEditor-ui-right').show().css('marginTop','1px').animate({'width':openWidth},'fast',function(){context.$content.trigger('mouseup');$(this).css({'marginTop':'0','position':'relative','right':'auto','left':'auto','top':'auto'});context.fn.trigger('tocExpand');context.fn.trigger('resize');});$.cookie('wikiEditor-'+context.instance+'-toc-width',context.modules.toc.$toc.data('openWidth'));return false;},build:function(context){function buildStructure(outline,offset,level){if(offset==undefined)offset=0;if(level==undefined)level=1;var sections=[];for(var i=offset;i<outline.length;i++){if(outline[i].nLevel==level){var sub=buildStructure(outline,i+1,level+1);if(sub.length){outline[i].sections=sub;}
624624 sections[sections.length]=outline[i];}else if(outline[i].nLevel<level){break;}}
625625 return sections;}
626 -function buildList(structure){var list=$('<ul />');for(i in structure){var wrapper=context.$content.find('.wikiEditor-toc-section-'+structure[i].index);if(wrapper.size()==0)
627 -wrapper=context.$content;var div=$('<div />').addClass('section-'+structure[i].index).data('wrapper',wrapper).click(function(event){context.fn.scrollToTop($(this).data('wrapper'),true);context.$textarea.textSelection('setSelection',{'start':0,'startContainer':$(this).data('wrapper')});$.wikiEditor.modules.toc.fn.unhighlight(context);$(this).addClass('current');if(typeof $.trackAction!='undefined')
 626+function buildList(structure){var list=$('<ul />');for(i in structure){var div=$('<div />').addClass('section-'+structure[i].index).data('index',structure[i].index).click(function(event){var wrapper=context.$content.find('.wikiEditor-toc-section-'+$(this).data('index'));if(wrapper.size()==0)
 627+wrapper=context.$content;context.fn.scrollToTop(wrapper,true);context.$textarea.textSelection('setSelection',{'start':0,'startContainer':wrapper});$.wikiEditor.modules.toc.fn.unhighlight(context);$(this).addClass('current');if(typeof $.trackAction!='undefined')
628628 $.trackAction('ntoc.heading');event.preventDefault();}).text(structure[i].text);if(structure[i].text=='')
629629 div.html('&nbsp;');var item=$('<li />').append(div);if(structure[i].sections!==undefined){item.append(buildList(structure[i].sections));}
630630 list.append(item);}
Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -76,16 +76,16 @@
7777 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 27 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 45 ),
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 11 ),
80 - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 76 ),
 80+ array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 77 ),
8181 array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 10 ),
8282 array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 17 ),
8383 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 2 ),
8484 ),
8585 'combined' => array(
86 - array( 'src' => 'js/plugins.combined.js', 'version' => 205 ),
 86+ array( 'src' => 'js/plugins.combined.js', 'version' => 206 ),
8787 ),
8888 'minified' => array(
89 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 205 ),
 89+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 206 ),
9090 ),
9191 ),
9292 );

Status & tagging log