r61273 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61272‎ | r61273 | r61274 >
Date:22:33, 19 January 2010
Author:adam
Status:deferred
Tags:
Comment:
Adding events for TOC collapsing and expanding and ensuring the toolbar resizes itself before the TOC
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)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -163,7 +163,7 @@
164164 array(
165165 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js',
166166 'class' => 'j.wikiEditor.modules.toolbar',
167 - 'version' => 41
 167+ 'version' => 42
168168 ),
169169 array(
170170 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js',
@@ -173,7 +173,7 @@
174174 array(
175175 'src' => 'js/plugins/jquery.wikiEditor.toc.js',
176176 'class' => 'j.wikiEditor.modules.toc',
177 - 'version' => 63
 177+ 'version' => 64
178178 ),
179179 array(
180180 'src' => 'js/plugins/jquery.wikiEditor.preview.js',
@@ -191,10 +191,10 @@
192192 'version' => 1 ),
193193 ),
194194 'combined' => array(
195 - array( 'src' => 'js/plugins.combined.js', 'version' => 156 ),
 195+ array( 'src' => 'js/plugins.combined.js', 'version' => 157 ),
196196 ),
197197 'minified' => array(
198 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 156 ),
 198+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 157 ),
199199 ),
200200 ),
201201 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js
@@ -294,6 +294,7 @@
295295 .css( { 'marginTop': '0', 'width': '1px' } );
296296 context.$ui.find( '.wikiEditor-ui-toc-expandControl' ).fadeIn( 'fast' );
297297 // Let the UI know things have moved around
 298+ context.fn.trigger( 'tocCollapse' );
298299 context.fn.trigger( 'resize' );
299300 } );
300301
@@ -331,6 +332,7 @@
332333 'right' : 'auto',
333334 'left' : 'auto',
334335 'top': 'auto' } );
 336+ context.fn.trigger( 'tocExpand' );
335337 context.fn.trigger( 'resize' );
336338 } );
337339 $.cookie( 'wikiEditor-' + context.instance + '-toc-width',
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js
@@ -167,6 +167,12 @@
168168 evt: {
169169 resize: function( context, event ) {
170170 context.$ui.find( '.sections' ).height( context.$ui.find( '.sections .section:visible' ).outerHeight() );
 171+ },
 172+ tocCollapse: function( context, event ) {
 173+ $.wikiEditor.modules.toolbar( context, event );
 174+ },
 175+ tocExpand: function( context, event ) {
 176+ $.wikiEditor.modules.toolbar( context, event );
171177 }
172178 },
173179 /**
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -8862,6 +8862,7 @@
88638863 .css( { 'marginTop': '0', 'width': '1px' } );
88648864 context.$ui.find( '.wikiEditor-ui-toc-expandControl' ).fadeIn( 'fast' );
88658865 // Let the UI know things have moved around
 8866+ context.fn.trigger( 'tocCollapse' );
88668867 context.fn.trigger( 'resize' );
88678868 } );
88688869
@@ -8899,6 +8900,7 @@
89008901 'right' : 'auto',
89018902 'left' : 'auto',
89028903 'top': 'auto' } );
 8904+ context.fn.trigger( 'tocExpand' );
89038905 context.fn.trigger( 'resize' );
89048906 } );
89058907 $.cookie( 'wikiEditor-' + context.instance + '-toc-width',
@@ -9297,6 +9299,12 @@
92989300 evt: {
92999301 resize: function( context, event ) {
93009302 context.$ui.find( '.sections' ).height( context.$ui.find( '.sections .section:visible' ).outerHeight() );
 9303+ },
 9304+ tocCollapse: function( context, event ) {
 9305+ $.wikiEditor.modules.toolbar( context, event );
 9306+ },
 9307+ tocExpand: function( context, event ) {
 9308+ $.wikiEditor.modules.toolbar( context, event );
93019309 }
93029310 },
93039311 /**
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -585,7 +585,7 @@
586586 context.modules.toc.$toc.data('positionMode','disabled');},enable:function(context){context.modules.toc.$toc.data('positionMode','regular');if(context.modules.toc.$toc.data('collapsed')){context.$ui.find('.wikiEditor-ui-toc-expandControl').show();}else{context.$ui.find('.wikiEditor-ui-right').show();$.wikiEditor.modules.toc.fn.redraw(context,$.wikiEditor.modules.toc.cfg.minimumWidth);context.modules.toc.$toc.find('div').autoEllipsis({'position':'right','tooltip':true,'restoreText':true});}},unhighlight:function(context){context.modules.toc.$toc.find('div').removeClass('current');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var div=context.fn.beforeSelection('div.wikiEditor-toc-header');var section=div.data('section')||0;if(context.data.outline.length>0){var sectionLink=context.modules.toc.$toc.find('div.section-'+section);sectionLink.addClass('current');var relTop=sectionLink.offset().top-context.modules.toc.$toc.offset().top;var scrollTop=context.modules.toc.$toc.scrollTop();var divHeight=context.modules.toc.$toc.height();var sectionHeight=sectionLink.height();if(relTop<0)
587587 context.modules.toc.$toc.scrollTop(scrollTop+relTop);else if(relTop+sectionHeight>divHeight)
588588 context.modules.toc.$toc.scrollTop(scrollTop+relTop+sectionHeight-divHeight);}},collapse:function(event){var $this=$(this),context=$this.data('context');if(context.modules.toc.$toc.data('positionMode')=='goofy'){$.wikiEditor.modules.toc.fn.switchLayout(context);}
589 -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('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('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;}
 589+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;}
590590 sections[sections.length]=outline[i];}else if(outline[i].nLevel<level){break;}}
591591 return sections;}
592592 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)
@@ -618,7 +618,7 @@
619619 break;case'characters':if(!('section'in data&&'page'in data)){continue;}
620620 $characters=context.modules.toolbar.$toolbar.find('div[rel='+data.section+'].section '+'div[rel='+data.page+'].page div');var actions=$characters.data('actions');for(character in data[type]){$characters.append($($.wikiEditor.modules.toolbar.fn.buildCharacter(data[type][character],actions)).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).parent().data('context'),$(this).parent().data('actions')[$(this).attr('rel')]);return false;}));}
621621 break;default:break;}}},removeFromToolbar:function(context,data){js_log("f:removeFromToolbar");if(typeof data.section=='string'){var tab='div.tabs span[rel='+data.section+'].tab';var target='div[rel='+data.section+'].section';if(typeof data.group=='string'){target+=' div[rel='+data.group+'].group';if(typeof data.tool=='string'){target+=' div[rel='+data.tool+'].tool';}}else if(typeof data.page=='string'){var index=target+' div.index div[rel='+data.page+']';target+=' div.pages div[rel='+data.page+'].page';if(typeof data.character=='string'){target+=' a[rel='+data.character+']';}else if(typeof data.row=='number'){target+=' table tr:not(:has(th)):eq('+data.row+')';}else{context.modules.toolbar.$toolbar.find(index).remove();$.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,null,context.modules.toolbar.$toolbar.find(target),context.modules.toolbar.$toolbar.find(index));}}else{context.modules.toolbar.$toolbar.find(tab).remove();}
622 -js_log('target is: '+target);context.modules.toolbar.$toolbar.find(target).remove();}}},evt:{resize:function(context,event){context.$ui.find('.sections').height(context.$ui.find('.sections .section:visible').outerHeight());}},fn:{create:function(context,config){if('$toolbar'in context.modules.toolbar){return;}
 622+js_log('target is: '+target);context.modules.toolbar.$toolbar.find(target).remove();}}},evt:{resize:function(context,event){context.$ui.find('.sections').height(context.$ui.find('.sections .section:visible').outerHeight());},tocCollapse:function(context,event){$.wikiEditor.modules.toolbar(context,event);},tocExpand:function(context,event){$.wikiEditor.modules.toolbar(context,event);}},fn:{create:function(context,config){if('$toolbar'in context.modules.toolbar){return;}
623623 context.modules.toolbar.$toolbar=$('<div />').addClass('wikiEditor-ui-toolbar').attr('id','wikiEditor-ui-toolbar');$.wikiEditor.modules.toolbar.fn.build(context,config);context.$ui.find('.wikiEditor-ui-top').append(context.modules.toolbar.$toolbar);},doAction:function(context,action,source){if($.trackAction!=undefined&&source.closest('.wikiEditor-ui-toolbar').size()){var rels=[];var step=source;var i=0;while(!step.hasClass('wikiEditor-ui-toolbar')){if(i>25){break;}
624624 i++;var rel=step.attr('rel');if(rel){rels.push(step.attr('rel'));}
625625 step=step.parent();}

Follow-up revisions

RevisionCommit summaryAuthorDate
r61275follow up changes to r61272 and r61273adam23:01, 19 January 2010

Status & tagging log