http://www.mediawiki.org/wiki/Special:Code/MediaWiki/60991
Revision: 60991 Author: adam Date: 2010-01-12 22:35:52 +0000 (Tue, 12 Jan 2010) Log Message: ----------- NTOC - Repaired updating highlighted section on cursor move Modified Paths: -------------- trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js trunk/extensions/UsabilityInitiative/js/plugins.combined.js trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js Modified: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php =================================================================== --- trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php 2010-01-12 22:14:36 UTC (rev 60990) +++ trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php 2010-01-12 22:35:52 UTC (rev 60991) @@ -88,16 +88,16 @@ array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 12 ), array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 40 ), array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 10 ), - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 58 ), + array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 59 ), array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 9 ), array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 14 ), array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 1 ), ), 'combined' => array( - array( 'src' => 'js/plugins.combined.js', 'version' => 137 ), + array( 'src' => 'js/plugins.combined.js', 'version' => 138 ), ), 'minified' => array( - array( 'src' => 'js/plugins.combined.min.js', 'version' => 137 ), + array( 'src' => 'js/plugins.combined.min.js', 'version' => 138 ), ), ), ); Modified: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js =================================================================== --- trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js 2010-01-12 22:14:36 UTC (rev 60990) +++ trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js 2010-01-12 22:35:52 UTC (rev 60991) @@ -22,6 +22,9 @@ * Event handlers */ evt: { + change: function( context, event ) { + $.wikiEditor.modules.toc.fn.update( context ); + }, ready: function( context, event ) { // Add the TOC to the document $.wikiEditor.modules.toc.fn.build( context ); @@ -145,7 +148,8 @@ * @param {Object} event Event object with context as data */ collapse: function( event ) { - var $this = $( this ), context = $this.data( 'context' ), + var $this = $( this ), + context = $this.data( 'context' ), pT = $this.parent().position().top - 1; $this.parent() .css( { @@ -247,7 +251,7 @@ .addClass( 'section-' + structure[i].index ) .data( 'wrapper', wrapper ) .click( function( event ) { - context.fn.scrollToTop( $(this).data( 'wrapper' ) ); + context.fn.scrollToTop( $( this ).data( 'wrapper' ) ); context.$textarea.textSelection( 'setSelection', { 'start': 0, 'startContainer': $(this).data( 'wrapper' ) @@ -255,7 +259,7 @@ // Highlight the clicked link $.wikiEditor.modules.toc.fn.unhighlight( context ); - $(this).addClass( 'current' ); + $( this ).addClass( 'current' ); if ( typeof $.trackAction != 'undefined' ) $.trackAction( 'ntoc.heading' ); Modified: trunk/extensions/UsabilityInitiative/js/plugins.combined.js =================================================================== --- trunk/extensions/UsabilityInitiative/js/plugins.combined.js 2010-01-12 22:14:36 UTC (rev 60990) +++ trunk/extensions/UsabilityInitiative/js/plugins.combined.js 2010-01-12 22:35:52 UTC (rev 60991) @@ -8352,6 +8352,9 @@ * Event handlers */ evt: { + change: function( context, event ) { + $.wikiEditor.modules.toc.fn.update( context ); + }, ready: function( context, event ) { // Add the TOC to the document $.wikiEditor.modules.toc.fn.build( context ); @@ -8475,7 +8478,8 @@ * @param {Object} event Event object with context as data */ collapse: function( event ) { - var $this = $( this ), context = $this.data( 'context' ), + var $this = $( this ), + context = $this.data( 'context' ), pT = $this.parent().position().top - 1; $this.parent() .css( { @@ -8577,7 +8581,7 @@ .addClass( 'section-' + structure[i].index ) .data( 'wrapper', wrapper ) .click( function( event ) { - context.fn.scrollToTop( $(this).data( 'wrapper' ) ); + context.fn.scrollToTop( $( this ).data( 'wrapper' ) ); context.$textarea.textSelection( 'setSelection', { 'start': 0, 'startContainer': $(this).data( 'wrapper' ) @@ -8585,7 +8589,7 @@ // Highlight the clicked link $.wikiEditor.modules.toc.fn.unhighlight( context ); - $(this).addClass( 'current' ); + $( this ).addClass( 'current' ); if ( typeof $.trackAction != 'undefined' ) $.trackAction( 'ntoc.heading' ); Modified: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js =================================================================== --- trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js 2010-01-12 22:14:36 UTC (rev 60990) +++ trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js 2010-01-12 22:35:52 UTC (rev 60991) @@ -553,7 +553,7 @@ nameEndIndex=nameEnd.index+oldDivider+2;ranges.push(new Range(ranges[ranges.length-1].end,nameBeginIndex));nameIndex=ranges.push(new Range(nameBeginIndex,nameEndIndex))-1;currentValue=currentField.substring(currentField.indexOf('=')+1);oldDivider+=currentField.indexOf('=')+1;valueBegin=currentValue.match(/\S+/);if(valueBegin==null){continue;} valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentValue.match(/[^\s]\s*$/);if(valueEnd==null){continue;} valueEndIndex=valueEnd.index+oldDivider+2;equalsIndex=ranges.push(new Range(ranges[ranges.length-1].end,valueBeginIndex))-1;valueIndex=ranges.push(new Range(valueBeginIndex,valueEndIndex))-1;params.push(new Param(wikitext.substring(nameBeginIndex,nameEndIndex),wikitext.substring(valueBeginIndex,valueEndIndex),currentParamNumber,nameIndex,equalsIndex,valueIndex));paramsByName[wikitext.substring(nameBeginIndex,nameEndIndex)]=currentParamNumber;}} -ranges.push(new Range(valueEndIndex,wikitext.length));this.ranges=ranges;this.wikitext=wikitext;this.params=params;this.paramsByName=paramsByName;this.templateNameIndex=templateNameIndex;}}};})(jQuery);(function($){$.wikiEditor.modules.toc={cfg:{defaultWidth:'166px',minimumWidth:'70px',rtl:false},api:{},evt:{ready:function(context,event){$.wikiEditor.modules.toc.fn.build(context);context.$content.parent().blur(function(event){var context=event.data.context;$.wikiEditor.modules.toc.fn.unhighlight(context);});},resize:function(context,event){context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height()- +ranges.push(new Range(valueEndIndex,wikitext.length));this.ranges=ranges;this.wikitext=wikitext;this.params=params;this.paramsByName=paramsByName;this.templateNameIndex=templateNameIndex;}}};})(jQuery);(function($){$.wikiEditor.modules.toc={cfg:{defaultWidth:'166px',minimumWidth:'70px',rtl:false},api:{},evt:{change:function(context,event){$.wikiEditor.modules.toc.fn.update(context);},ready:function(context,event){$.wikiEditor.modules.toc.fn.build(context);context.$content.parent().blur(function(event){var context=event.data.context;$.wikiEditor.modules.toc.fn.unhighlight(context);});},resize:function(context,event){context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height()- context.$ui.find('.tab-toc').outerHeight());},mark:function(context,event){var markers=context.modules.highlight.markers;var tokenArray=context.modules.highlight.tokenArray;var outline=context.data.outline=[];var h=0;for(var i=0;i<tokenArray.length;i++){if(tokenArray[i].label!='TOC_HEADER'){continue;} h++;markers.push({index:h,start:tokenArray[i].tokenStart,end:tokenArray[i].offset,afterWrap:function(node){var marker=$(node).data('marker');$(node).addClass('wikiEditor-toc-header').addClass('wikiEditor-toc-section-'+marker.index).data('section',marker.index);},getWrapper:function(ca1,ca2){return $(ca1.parentNode).is('div.wikiEditor-toc-header')&&ca1.previousSibling==null&&ca1.nextSibling==null?ca1.parentNode:null;}});outline.push({'text':tokenArray[i].match[2],'level':tokenArray[i].match[1].length,'index':h});} $.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}},exp:[{'regex':/^(={1,6})(.+?)\1\s*$/m,'label':'TOC_HEADER','markAfter':true}],fn:{create:function(context,config){if('$toc'in context.modules.toc){return;} _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs