r58096 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58095‎ | r58096 | r58097 >
Date:19:44, 24 October 2009
Author:catrope
Status:deferred
Tags:
Comment:
NavigableTOC: (bug 21153) Highlighting gets confused when a header is made longer. Solve this by only highlighting after updating the TOC, and doing this more frequently (250 ms after the user stops typing, rather than 1000 ms)
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
@@ -72,13 +72,13 @@
7373 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 12 ),
7474 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 12 ),
7575 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 6 ),
76 - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 21 ),
 76+ array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 22 ),
7777 ),
7878 'combined' => array(
79 - array( 'src' => 'js/plugins.combined.js', 'version' => 47 ),
 79+ array( 'src' => 'js/plugins.combined.js', 'version' => 48 ),
8080 ),
8181 'minified' => array(
82 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 47 ),
 82+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 48 ),
8383 ),
8484 ),
8585 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js
@@ -39,7 +39,7 @@
4040 // Add the TOC to the document
4141 $.wikiEditor.modules.toc.fn.build( context, config );
4242 context.$textarea
43 - .delayedBind( 1000, 'keyup encapsulateSelection change',
 43+ .delayedBind( 250, 'mouseup scrollToPosition focus keyup encapsulateSelection change',
4444 function( event ) {
4545 var context = $(this).data( 'wikiEditor-context' );
4646 $(this).eachAsync( {
@@ -51,19 +51,10 @@
5252 } );
5353 }
5454 )
55 - .bind( 'mouseup scrollToPosition focus keyup encapsulateSelection change',
56 - function( event ) {
57 - var context = $(this).data( 'wikiEditor-context' );
58 - $(this).eachAsync( {
59 - bulk: 0,
60 - loop: function() {
61 - $.wikiEditor.modules.toc.fn.update( context );
62 - }
63 - } );
64 - }
65 - )
6655 .blur( function() {
6756 var context = $(this).data( 'wikiEditor-context' );
 57+ context.$textarea.delayedBindCancel( 250,
 58+ 'mouseup scrollToPosition focus keyup encapsulateSelection change' );
6859 $.wikiEditor.modules.toc.fn.unhighlight( context );
6960 });
7061 },
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -2238,7 +2238,7 @@
22392239 // Add the TOC to the document
22402240 $.wikiEditor.modules.toc.fn.build( context, config );
22412241 context.$textarea
2242 - .delayedBind( 1000, 'keyup encapsulateSelection change',
 2242+ .delayedBind( 250, 'mouseup scrollToPosition focus keyup encapsulateSelection change',
22432243 function( event ) {
22442244 var context = $(this).data( 'wikiEditor-context' );
22452245 $(this).eachAsync( {
@@ -2250,19 +2250,10 @@
22512251 } );
22522252 }
22532253 )
2254 - .bind( 'mouseup scrollToPosition focus keyup encapsulateSelection change',
2255 - function( event ) {
2256 - var context = $(this).data( 'wikiEditor-context' );
2257 - $(this).eachAsync( {
2258 - bulk: 0,
2259 - loop: function() {
2260 - $.wikiEditor.modules.toc.fn.update( context );
2261 - }
2262 - } );
2263 - }
2264 - )
22652254 .blur( function() {
22662255 var context = $(this).data( 'wikiEditor-context' );
 2256+ context.$textarea.delayedBindCancel( 250,
 2257+ 'mouseup scrollToPosition focus keyup encapsulateSelection change' );
22672258 $.wikiEditor.modules.toc.fn.unhighlight( context );
22682259 });
22692260 },
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -141,7 +141,7 @@
142142 $pages.children().hide();$pages.find('*[rel='+selected+']').show();$index.children().removeClass('current');$selectedIndex.addClass('current');},build:function(context,config){var $tabs=$('<div />').addClass('tabs').appendTo(context.modules.$toolbar);var $sections=$('<div />').addClass('sections').appendTo(context.modules.$toolbar);context.modules.$toolbar.append($('<div />').css('clear','both'));var sectionQueue=[];for(section in config){if(section=='main'){context.modules.$toolbar.prepend($.wikiEditor.modules.toolbar.fn.buildSection(context,section,config[section]));}else{sectionQueue.push({'$sections':$sections,'context':context,'id':section,'config':config[section]});$tabs.append($.wikiEditor.modules.toolbar.fn.buildTab(context,section,config[section]));}}
143143 $.eachAsync(sectionQueue,{'bulk':0,'end':function(){$('body').css('position','static');$('body').css('position','relative');},'loop':function(i,s){s.$sections.append($.wikiEditor.modules.toolbar.fn.buildSection(s.context,s.id,s.config));var $section=s.$sections.find('.section:visible');if($section.size()){$sections.animate({'height':$section.outerHeight()},$section.outerHeight()*2);}}});}}};})(jQuery);(function($){$.wikiEditor.modules.toc={api:{},fn:{create:function(context,config){if('$toc'in context.modules){return;}
144144 context.modules.$toc=$('<div />').addClass('wikiEditor-ui-toc').attr('id','wikiEditor-ui-toc');var height=context.$ui.find('.wikiEditor-ui-bottom').height()
145 -context.$ui.find('.wikiEditor-ui-bottom').append(context.modules.$toc);context.modules.$toc.height(context.$ui.find('.wikiEditor-ui-bottom').height());context.modules.$toc.css({'width':'12em','marginTop':-(height)});context.$ui.find('.wikiEditor-ui-text').css(($('body.rtl').size()?'marginLeft':'marginRight'),'12em');$.wikiEditor.modules.toc.fn.build(context,config);context.$textarea.delayedBind(1000,'keyup encapsulateSelection change',function(event){var context=$(this).data('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).bind('mouseup scrollToPosition focus keyup encapsulateSelection change',function(event){var context=$(this).data('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(){var context=$(this).data('wikiEditor-context');$.wikiEditor.modules.toc.fn.unhighlight(context);});},unhighlight:function(context){context.modules.$toc.find('div').removeClass('current');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var position=context.$textarea.getCaretPosition();var section=0;if(context.data.outline.length>0){if(!(position<context.data.outline[0].position-1)){while(section<context.data.outline.length&&context.data.outline[section].position-1<position){section++;}
 145+context.$ui.find('.wikiEditor-ui-bottom').append(context.modules.$toc);context.modules.$toc.height(context.$ui.find('.wikiEditor-ui-bottom').height());context.modules.$toc.css({'width':'12em','marginTop':-(height)});context.$ui.find('.wikiEditor-ui-text').css(($('body.rtl').size()?'marginLeft':'marginRight'),'12em');$.wikiEditor.modules.toc.fn.build(context,config);context.$textarea.delayedBind(250,'mouseup scrollToPosition focus keyup encapsulateSelection change',function(event){var context=$(this).data('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(){var context=$(this).data('wikiEditor-context');context.$textarea.delayedBindCancel(250,'mouseup scrollToPosition focus keyup encapsulateSelection change');$.wikiEditor.modules.toc.fn.unhighlight(context);});},unhighlight:function(context){context.modules.$toc.find('div').removeClass('current');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var position=context.$textarea.getCaretPosition();var section=0;if(context.data.outline.length>0){if(!(position<context.data.outline[0].position-1)){while(section<context.data.outline.length&&context.data.outline[section].position-1<position){section++;}
146146 section=Math.max(0,section);}
147147 var sectionLink=context.modules.$toc.find('div.section-'+section);sectionLink.addClass('current');var relTop=sectionLink.offset().top-context.modules.$toc.offset().top;var scrollTop=context.modules.$toc.scrollTop();var divHeight=context.modules.$toc.height();var sectionHeight=sectionLink.height();if(relTop<0)
148148 context.modules.$toc.scrollTop(scrollTop+relTop);else if(relTop+sectionHeight>divHeight)

Follow-up revisions

RevisionCommit summaryAuthorDate
r59204wmf-deployment: Merging usability changes from trunk...catrope18:53, 18 November 2009

Status & tagging log