r59943 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59942‎ | r59943 | r59944 >
Date:01:00, 11 December 2009
Author:adam
Status:deferred
Tags:
Comment:
WikiEditor Toolbar and TOC - better resize event triggering.
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
@@ -73,18 +73,18 @@
7474 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 21 ),
7575 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 32 ),
7676 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 1 ),
77 - array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 36 ),
 77+ array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 37 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 9 ),
79 - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 49 ),
 79+ array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 50 ),
8080 array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 7 ),
8181 array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 1 ),
8282 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 0 ),
8383 ),
8484 'combined' => array(
85 - array( 'src' => 'js/plugins.combined.js', 'version' => 104 ),
 85+ array( 'src' => 'js/plugins.combined.js', 'version' => 105 ),
8686 ),
8787 'minified' => array(
88 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 104 ),
 88+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 105 ),
8989 ),
9090 ),
9191 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js
@@ -164,13 +164,14 @@
165165 .animate( { 'width' : openWidth }, 'fast', function() {
166166 context.$content.trigger( 'mouseup' );
167167 $( this ).css( { 'marginTop': '0', 'position': 'relative', 'right': 'auto', 'top': 'auto' } );
168 - // Let the UI know things have moved around
169 - context.fn.trigger( 'resize' );
170168 } )
171169 .prev()
172170 .animate( { 'marginRight': ( parseFloat( openWidth ) * -1 ) }, 'fast' )
173171 .children()
174 - .animate( { 'marginRight': openWidth }, 'fast' );
 172+ .animate( { 'marginRight': openWidth }, 'fast', function() {
 173+ // Let the UI know things have moved around
 174+ context.fn.trigger( 'resize' );
 175+ } );
175176 $.cookie( 'wikiEditor-' + context.instance + '-toc-width',
176177 context.modules.toc.$toc.data( 'openWidth' ) );
177178 return false;
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js
@@ -489,12 +489,14 @@
490490 }
491491 $sections.animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2, function() {
492492 $(this).css('overflow', 'visible').css('height', 'auto');
 493+ context.fn.trigger( 'resize' );
493494 } );
494495 $(this).addClass( 'current' );
495496 } else {
496497 $sections.css('height', $section.outerHeight() )
497498 .animate( { 'height': 0 }, $section.outerHeight() * 2, function() {
498499 $(this).css('overflow', 'visible');
 500+ context.fn.trigger( 'resize' );
499501 } );
500502 if ( 'toc' in context.modules ) {
501503 context.modules.toc.$toc.animate({'height': "-="+$section.outerHeight()}, $section.outerHeight() * 2);
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -2221,20 +2221,18 @@
22222222 }
22232223 markedText = "";
22242224 var previousIndex = 0;
2225 - for ( var i = 0; i < this.markers.length; i++ ) {
2226 - markedText += rawText.substring( previousIndex, currentIndex );
2227 -
2228 - for ( var j = 0 ; i < this.markers[i].length; j++ ) {
2229 - markedText += this.markers[i][j];
2230 - }
2231 -
2232 - previousIndex = currentIndex;
2233 - }
2234 - if ( markedText != "" ) {
2235 - markedText.replace( /\n/g, '<br>' );
2236 - context.fn.setContents( { contents:markedText } );
2237 - }
2238 - }
 2225+ for(var currentIndex in this.markers){
 2226+ markedText+= rawText.substring(previousIndex, currentIndex);
 2227+ for(var i = 0 ; i < this.markers[currentIndex].length; i++){
 2228+ markedText += this.markers[currentIndex][i];
 2229+ }
 2230+ previousIndex = currentIndex;
 2231+ }
 2232+ if(markedText != ""){
 2233+ markedText.replace(/\n/g, '<br\>');
 2234+ context.fn.setContents( { contents:markedText } );
 2235+ }
 2236+ }//mark
22392237 }
22402238
22412239 }; })( jQuery );/* Preview module for wikiEditor */
@@ -2507,7 +2505,7 @@
25082506 evt: {
25092507 mark: function() {
25102508 function findOutermostTemplates( tokenStack ) {
2511 - var templateBeginFound = false;
 2509+ templateBeginFound = false;
25122510 for ( ;i< tokenStack.length; i++ ) {
25132511 if ( tokenStack[i].label == "TEMPLATE_BEGIN" ) {
25142512 templateBeginFound = true;
@@ -2544,11 +2542,11 @@
25452543 }
25462544 }; //find outermost templates
25472545
2548 - var markers = $.wikiEditor.modules.highlight.fn.markers;
 2546+ markers = $.wikiEditor.modules.highlight.fn.markers;
25492547 var tokenStack = $.wikiEditor.modules.highlight.fn.tokenArray;
2550 - var i = 0;
 2548+ i = 0;
25512549 var templateBoundaries;
2552 - var templateBeginFound = false;
 2550+ templateBeginFound = false;
25532551
25542552 while ( templateBoundaries = findOutermostTemplates( tokenStack ) ) {
25552553 if ( typeof markers[tokenStack[templateBoundaries[0]].offset] == 'undefined' ) {
@@ -2557,7 +2555,6 @@
25582556 if ( typeof markers[tokenStack[templateBoundaries[1]].offset] == 'undefined' ) {
25592557 markers[tokenStack[templateBoundaries[1]].offset] = [];
25602558 }
2561 -
25622559 markers[tokenStack[templateBoundaries[0]].offset].push( "<div class='wiki-template'>" );
25632560 markers[tokenStack[templateBoundaries[1]].offset].push( "</div>" );
25642561 }
@@ -2628,6 +2625,8 @@
26292626 .replace( /[{}|=]/g , 'X' );
26302627 sanatizedStr = sanatizedStr.substring( 0, startIndex ) +
26312628 sanatizedSegment + sanatizedStr.substring( endIndex );
 2629+ }//while
 2630+ return sanatizedStr;
26322631 };
26332632
26342633 // Whitespace* {{ whitespace* nonwhitespace:
@@ -2766,9 +2765,13 @@
27672766
27682767 //get template name
27692768 this.getName = function() {
2770 - return ranges[templateNameIndex].newVal ||
2771 - wikitext.substring( ranges[templateNameIndex].begin,
2772 - ranges[templateNameIndex].end );
 2769+ if( typeof ranges[templateNameIndex].newVal == 'undefined' ) {
 2770+ return wikitext.substring( ranges[templateNameIndex].begin,
 2771+ ranges[templateNameIndex].end );
 2772+
 2773+ } else {
 2774+ return ranges[templateNameIndex].newVal;
 2775+ }
27732776 };
27742777
27752778 //set template name (if we want to support this)
@@ -2805,14 +2808,18 @@
28062809 this.getText = function() {
28072810 newText = "";
28082811 for ( i = 0 ; i < ranges.length; i++ ) {
2809 - newText += ranges[i].newVal || wikitext.substring(
2810 - ranges[i].begin, ranges[i].end );
 2812+ if( typeof ranges[i].newVal == 'undefined' ) {
 2813+ wikitext.substring( ranges[i].begin, ranges[i].end );
 2814+ } else {
 2815+ newText += ranges[i].newVal;
 2816+ }
28112817 }
28122818 return newText;
28132819 };
28142820 }//template model
2815 -}
28162821
 2822+}//fn
 2823+
28172824 }; } )( jQuery );
28182825
28192826
@@ -2982,13 +2989,14 @@
29832990 .animate( { 'width' : openWidth }, 'fast', function() {
29842991 context.$content.trigger( 'mouseup' );
29852992 $( this ).css( { 'marginTop': '0', 'position': 'relative', 'right': 'auto', 'top': 'auto' } );
2986 - // Let the UI know things have moved around
2987 - context.fn.trigger( 'resize' );
29882993 } )
29892994 .prev()
29902995 .animate( { 'marginRight': ( parseFloat( openWidth ) * -1 ) }, 'fast' )
29912996 .children()
2992 - .animate( { 'marginRight': openWidth }, 'fast' );
 2997+ .animate( { 'marginRight': openWidth }, 'fast', function() {
 2998+ // Let the UI know things have moved around
 2999+ context.fn.trigger( 'resize' );
 3000+ } );
29933001 $.cookie( 'wikiEditor-' + context.instance + '-toc-width',
29943002 context.modules.toc.$toc.data( 'openWidth' ) );
29953003 return false;
@@ -3767,12 +3775,14 @@
37683776 }
37693777 $sections.animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2, function() {
37703778 $(this).css('overflow', 'visible').css('height', 'auto');
 3779+ context.fn.trigger( 'resize' );
37713780 } );
37723781 $(this).addClass( 'current' );
37733782 } else {
37743783 $sections.css('height', $section.outerHeight() )
37753784 .animate( { 'height': 0 }, $section.outerHeight() * 2, function() {
37763785 $(this).css('overflow', 'visible');
 3786+ context.fn.trigger( 'resize' );
37773787 } );
37783788 if ( 'toc' in context.modules ) {
37793789 context.modules.toc.$toc.animate({'height': "-="+$section.outerHeight()}, $section.outerHeight() * 2);
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -129,9 +129,9 @@
130130 match=text.match(regex);var oldOffset=0;while(match!=null){var markOffset=0;if(markAfter){markOffset+=match[0].length;}
131131 this.tokenArray.push(new Token(match.index+oldOffset+markOffset,label));oldOffset+=match.index+match[0].length;newSubstring=text.substring(oldOffset);match=newSubstring.match(regex);}}}}
132132 return this.tokenArray;},markers:[],mark:function(context,division,tokens){var rawText=context.fn.getContents();for(module in $.wikiEditor.modules){if('evt'in $.wikiEditor.modules[module]&&'mark'in $.wikiEditor.modules[module].evt){$.wikiEditor.modules[module].evt.mark();}}
133 -markedText="";var previousIndex=0;for(var i=0;i<this.markers.length;i++){markedText+=rawText.substring(previousIndex,currentIndex);for(var j=0;i<this.markers[i].length;j++){markedText+=this.markers[i][j];}
 133+markedText="";var previousIndex=0;for(var currentIndex in this.markers){markedText+=rawText.substring(previousIndex,currentIndex);for(var i=0;i<this.markers[currentIndex].length;i++){markedText+=this.markers[currentIndex][i];}
134134 previousIndex=currentIndex;}
135 -if(markedText!=""){markedText.replace(/\n/g,'<br>');context.fn.setContents({contents:markedText});}}}};})(jQuery);(function($){$.wikiEditor.modules.preview={api:{},fn:{create:function(context,config){if('initialized'in context.modules.preview){return;}
 135+if(markedText!=""){markedText.replace(/\n/g,'<br\>');context.fn.setContents({contents:markedText});}}}};})(jQuery);(function($){$.wikiEditor.modules.preview={api:{},fn:{create:function(context,config){if('initialized'in context.modules.preview){return;}
136136 context.modules.preview={'initialized':true,'previewText':null,'changesText':null};context.modules.preview.$preview=context.fn.addView({'name':'preview','titleMsg':'wikieditor-preview-tab','init':function(context){var wikitext=context.fn.getContents();if(context.modules.preview.previewText==wikitext){return;}
137137 context.modules.preview.$preview.find('.wikiEditor-preview-contents').empty();context.modules.preview.$preview.find('.wikiEditor-preview-loading').show();$.post(wgScriptPath+'/api.php',{'action':'parse','title':wgPageName,'text':wikitext,'prop':'text','pst':'','format':'json'},function(data){if(typeof data.parse=='undefined'||typeof data.parse.text=='undefined'||typeof data.parse.text['*']=='undefined'){return;}
138138 context.modules.preview.previewText=wikitext;context.modules.preview.$preview.find('.wikiEditor-preview-loading').hide();context.modules.preview.$preview.find('.wikiEditor-preview-contents').html(data.parse.text['*']).find('a:not([href^=#])').click(function(){return false;});},'json');}});context.$changesTab=context.fn.addView({'name':'changes','titleMsg':'wikieditor-preview-changes-tab','init':function(context){var wikitext=context.fn.getContents();if(context.modules.preview.changesText==wikitext){return;}
@@ -161,17 +161,18 @@
162162 $('#wikiEditor-'+context.instance+'-dialog-minor').hide();else if($('#wpMinoredit').is(':checked'))
163163 $('#wikiEditor-'+context.instance+'-dialog-minor').attr('checked','checked');if($('#wpWatchthis').size()==0)
164164 $('#wikiEditor-'+context.instance+'-dialog-watch').hide();else if($('#wpWatchthis').is(':checked'))
165 -$('#wikiEditor-'+context.instance+'-dialog-watch').attr('checked','checked');$(this).find('form').submit(function(e){$(this).closest('.ui-dialog').find('button:first').click();e.preventDefault();});},dialog:{buttons:{'wikieditor-publish-dialog-publish':function(){var minorChecked=$('#wikiEditor-'+context.instance+'-dialog-minor').is(':checked')?'checked':'';var watchChecked=$('#wikiEditor-'+context.instance+'-dialog-watch').is(':checked')?'checked':'';$('#wpMinoredit').attr('checked',minorChecked);$('#wpWatchthis').attr('checked',watchChecked);$('#wpSummary').val($j('#wikiEditor-'+context.instance+'-dialog-summary').val());$('#editform').submit();},'wikieditor-publish-dialog-goback':function(){$(this).dialog('close');}},open:function(){$('#wikiEditor-'+context.instance+'-dialog-summary').focus();},width:500},resizeme:false}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-publish','action':function(){$('#'+dialogID).dialog('open');return false;}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-cancel','action':function(){}});}}};})(jQuery);(function($){$.wikiEditor.modules.templateEditor={api:{},evt:{mark:function(){function findOutermostTemplates(tokenStack){var templateBeginFound=false;for(;i<tokenStack.length;i++){if(tokenStack[i].label=="TEMPLATE_BEGIN"){templateBeginFound=true;break;}}
 165+$('#wikiEditor-'+context.instance+'-dialog-watch').attr('checked','checked');$(this).find('form').submit(function(e){$(this).closest('.ui-dialog').find('button:first').click();e.preventDefault();});},dialog:{buttons:{'wikieditor-publish-dialog-publish':function(){var minorChecked=$('#wikiEditor-'+context.instance+'-dialog-minor').is(':checked')?'checked':'';var watchChecked=$('#wikiEditor-'+context.instance+'-dialog-watch').is(':checked')?'checked':'';$('#wpMinoredit').attr('checked',minorChecked);$('#wpWatchthis').attr('checked',watchChecked);$('#wpSummary').val($j('#wikiEditor-'+context.instance+'-dialog-summary').val());$('#editform').submit();},'wikieditor-publish-dialog-goback':function(){$(this).dialog('close');}},open:function(){$('#wikiEditor-'+context.instance+'-dialog-summary').focus();},width:500},resizeme:false}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-publish','action':function(){$('#'+dialogID).dialog('open');return false;}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-cancel','action':function(){}});}}};})(jQuery);(function($){$.wikiEditor.modules.templateEditor={api:{},evt:{mark:function(){function findOutermostTemplates(tokenStack){templateBeginFound=false;for(;i<tokenStack.length;i++){if(tokenStack[i].label=="TEMPLATE_BEGIN"){templateBeginFound=true;break;}}
166166 var j=i;i++;if(!templateBeginFound){return false;}else{var nestedBegins=1;while(nestedBegins>0&&j<tokenStack.length){j++;if(tokenStack[j].label=="TEMPLATE_END"){nestedBegins--;}
167167 if(tokenStack[j].label=="TEMPLATE_BEGIN"){nestedBegins++;}}
168 -if(nestedBegins==0){var leftMarker=i-1;var rightMarker=j;i=j;return[leftMarker,rightMarker];}else{return false;}}};var markers=$.wikiEditor.modules.highlight.fn.markers;var tokenStack=$.wikiEditor.modules.highlight.fn.tokenArray;var i=0;var templateBoundaries;var templateBeginFound=false;while(templateBoundaries=findOutermostTemplates(tokenStack)){if(typeof markers[tokenStack[templateBoundaries[0]].offset]=='undefined'){markers[tokenStack[templateBoundaries[0]].offset]=[];}
 168+if(nestedBegins==0){var leftMarker=i-1;var rightMarker=j;i=j;return[leftMarker,rightMarker];}else{return false;}}};markers=$.wikiEditor.modules.highlight.fn.markers;var tokenStack=$.wikiEditor.modules.highlight.fn.tokenArray;i=0;var templateBoundaries;templateBeginFound=false;while(templateBoundaries=findOutermostTemplates(tokenStack)){if(typeof markers[tokenStack[templateBoundaries[0]].offset]=='undefined'){markers[tokenStack[templateBoundaries[0]].offset]=[];}
169169 if(typeof markers[tokenStack[templateBoundaries[1]].offset]=='undefined'){markers[tokenStack[templateBoundaries[1]].offset]=[];}
170170 markers[tokenStack[templateBoundaries[0]].offset].push("<div class='wiki-template'>");markers[tokenStack[templateBoundaries[1]].offset].push("</div>");}}},exp:[{regex:/{{/,label:"TEMPLATE_BEGIN"},{regex:/}}/,label:"TEMPLATE_END",markAfter:true}],fn:{create:function(context,config){},model:function(wikitext){function Param(name,value,number,nameIndex,equalsIndex,valueIndex){this.name=name;this.value=value;this.number=number;this.nameIndex=nameIndex;this.equalsIndex=equalsIndex;this.valueIndex=valueIndex;}
171171 function Range(begin,end){this.begin=begin;this.end=end;}
172172 var ranges=[];var sanatizedStr="";var params=[];var paramsByName=[];var templateNameIndex=0;function markOffTemplates(){sanatizedStr=wikitext.replace(/{{/," ");endBraces=sanatizedStr.match(/}}\s*$/);sanatizedStr=sanatizedStr.substring(0,endBraces.index)+" "+
173173 sanatizedStr.substring(endBraces.index+2);while(sanatizedStr.indexOf('{{')!=-1){startIndex=sanatizedStr.indexOf('{{')+1;openBraces=2;endIndex=startIndex;while(openBraces>0){endIndex++;switch(sanatizedStr[endIndex]){case'}':openBraces--;break;case'{':openBraces++;break;}}
174174 sanatizedSegment=sanatizedStr.substring(startIndex,endIndex).replace(/[{}|=]/g,'X');sanatizedStr=sanatizedStr.substring(0,startIndex)+
175 -sanatizedSegment+sanatizedStr.substring(endIndex);};if(wikitext.match(/\s*{{\s*\S*:/)){}
 175+sanatizedSegment+sanatizedStr.substring(endIndex);}
 176+return sanatizedStr;};if(wikitext.match(/\s*{{\s*\S*:/)){}
176177 markOffTemplates();var doneParsing=false;oldDivider=0;divider=sanatizedStr.indexOf('|',oldDivider);if(divider==-1){divider=sanatizedStr.length;doneParsing=true;}
177178 nameMatch=wikitext.substring(oldDivider,divider).match(/[^{\s]+/);if(nameMatch!=undefined){ranges.push(new Range(oldDivider,nameMatch.index));templateNameIndex=ranges.push(new Range(nameMatch.index,nameMatch.index+nameMatch[0].length));templateNameIndex--;ranges[templateNameIndex].old=wikitext.substring(ranges[templateNameIndex].begin,ranges[templateNameIndex].end);}
178179 params.push(ranges[templateNameIndex].old);currentParamNumber=0;var valueEndIndex;while(!doneParsing){currentParamNumber++;oldDivider=divider;divider=sanatizedStr.indexOf('|',oldDivider+1);if(divider==-1){divider=sanatizedStr.length;doneParsing=true;}
@@ -182,14 +183,14 @@
183184 if(typeof params[rangeIndex]=='undefined'){return"";}
184185 valueRange=ranges[params[rangeIndex].valueIndex];if(typeof valueRange.newVal=='undefined'||original){retVal=wikitext.substring(valueRange.begin,valueRange.end);}else{retVal=valueRange.newVal;}
185186 if(value!=null){ranges[params[rangeIndex].valueIndex].newVal=value;}
186 -return retVal;};this.getName=function(){return ranges[templateNameIndex].newVal||wikitext.substring(ranges[templateNameIndex].begin,ranges[templateNameIndex].end);};this.setName=function(name){ranges[templateNameIndex].newVal=name;};this.setValue=function(name,value){return getSetValue(name,value,false);};this.getValue=function(name){return getSetValue(name,null,false);};this.getOriginalValue=function(name){return getSetValue(name,null,true);};this.getAllParams=function(){return paramsByName;};this.getOriginalText=function(){return wikitext;};this.getText=function(){newText="";for(i=0;i<ranges.length;i++){newText+=ranges[i].newVal||wikitext.substring(ranges[i].begin,ranges[i].end);}
 187+return retVal;};this.getName=function(){if(typeof ranges[templateNameIndex].newVal=='undefined'){return wikitext.substring(ranges[templateNameIndex].begin,ranges[templateNameIndex].end);}else{return ranges[templateNameIndex].newVal;}};this.setName=function(name){ranges[templateNameIndex].newVal=name;};this.setValue=function(name,value){return getSetValue(name,value,false);};this.getValue=function(name){return getSetValue(name,null,false);};this.getOriginalValue=function(name){return getSetValue(name,null,true);};this.getAllParams=function(){return paramsByName;};this.getOriginalText=function(){return wikitext;};this.getText=function(){newText="";for(i=0;i<ranges.length;i++){if(typeof ranges[i].newVal=='undefined'){wikitext.substring(ranges[i].begin,ranges[i].end);}else{newText+=ranges[i].newVal;}}
187188 return newText;};}}};})(jQuery);(function($){$.wikiEditor.modules.toc={defaultWidth:'166px',minimumWidth:'70px',api:{},evt:{ready:function(context,event){$.wikiEditor.modules.toc.fn.build(context);context.$content.parent().delayedBind(250,'mouseup scrollToTop keyup change',function(){$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(event){var context=event.data.context;context.$textarea.delayedBindCancel(250,'mouseup scrollToTop keyup change');$.wikiEditor.modules.toc.fn.unhighlight(context);});},resize:function(context,event){context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height()-
188189 context.$ui.find('.tab-toc').outerHeight());}},fn:{create:function(context,config){if('$toc'in context.modules.toc){return;}
189190 var height=context.$ui.find('.wikiEditor-ui-left').height();context.modules.toc.$toc=$('<div />').addClass('wikiEditor-ui-toc').data('context',context);context.$ui.find('.wikiEditor-ui-right').css('width',$.wikiEditor.modules.toc.defaultWidth).append(context.modules.toc.$toc);context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height());context.$ui.find('.wikiEditor-ui-left').css('marginRight',"-"+$.wikiEditor.modules.toc.defaultWidth).children().css('marginRight',$.wikiEditor.modules.toc.defaultWidth);},unhighlight:function(context){context.modules.toc.$toc.find('div').removeClass('current');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var position=context.$textarea.textSelection('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++;}
190191 section=Math.max(0,section);}
191192 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)
192193 context.modules.toc.$toc.scrollTop(scrollTop+relTop);else if(relTop+sectionHeight>divHeight)
193 -context.modules.toc.$toc.scrollTop(scrollTop+relTop+sectionHeight-divHeight);}},collapse:function(event){var $this=$(this),context=$this.data('context'),pT=$this.parent().position().top-1;$this.parent().css({'marginTop':'1px','position':'absolute','left':'auto','right':0,'top':pT}).fadeOut('fast',function(){$(this).hide().css({'marginTop':'0','width':'1px'});context.$ui.find('.wikiEditor-ui-toc-expandControl').fadeIn('fast');}).prev().animate({'marginRight':'-1px'},'fast',function(){$(this).css('marginRight',0);context.fn.trigger('resize');}).children().animate({'marginRight':'1px'},'fast',function(){$(this).css('marginRight',0);});$.cookie('wikiEditor-'+context.instance+'-toc-width',0);return false;},expand:function(event){var $this=$(this),context=$this.data('context'),openWidth=context.modules.toc.$toc.data('openWidth');context.$ui.find('.wikiEditor-ui-toc-expandControl').hide();$this.parent().show().css('marginTop','1px').animate({'width':openWidth},'fast',function(){context.$content.trigger('mouseup');$(this).css({'marginTop':'0','position':'relative','right':'auto','top':'auto'});context.fn.trigger('resize');}).prev().animate({'marginRight':(parseFloat(openWidth)*-1)},'fast').children().animate({'marginRight':openWidth},'fast');$.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;}
 194+context.modules.toc.$toc.scrollTop(scrollTop+relTop+sectionHeight-divHeight);}},collapse:function(event){var $this=$(this),context=$this.data('context'),pT=$this.parent().position().top-1;$this.parent().css({'marginTop':'1px','position':'absolute','left':'auto','right':0,'top':pT}).fadeOut('fast',function(){$(this).hide().css({'marginTop':'0','width':'1px'});context.$ui.find('.wikiEditor-ui-toc-expandControl').fadeIn('fast');}).prev().animate({'marginRight':'-1px'},'fast',function(){$(this).css('marginRight',0);context.fn.trigger('resize');}).children().animate({'marginRight':'1px'},'fast',function(){$(this).css('marginRight',0);});$.cookie('wikiEditor-'+context.instance+'-toc-width',0);return false;},expand:function(event){var $this=$(this),context=$this.data('context'),openWidth=context.modules.toc.$toc.data('openWidth');context.$ui.find('.wikiEditor-ui-toc-expandControl').hide();$this.parent().show().css('marginTop','1px').animate({'width':openWidth},'fast',function(){context.$content.trigger('mouseup');$(this).css({'marginTop':'0','position':'relative','right':'auto','top':'auto'});}).prev().animate({'marginRight':(parseFloat(openWidth)*-1)},'fast').children().animate({'marginRight':openWidth},'fast',function(){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;}
194195 sections[sections.length]=outline[i];}else if(outline[i].nLevel<level){break;}}
195196 return sections;}
196197 function buildList(structure){var list=$('<ul />');for(i in structure){var div=$('<div />').addClass('section-'+structure[i].index).data('wrapper',structure[i].wrapper).click(function(event){context.fn.scrollToTop($(this).data('wrapper'));context.$textarea.textSelection('setSelection',{'start':0,'startContainer':$(this).data('wrapper')});if(typeof $.trackAction!='undefined')
@@ -261,7 +262,7 @@
262263 $.wikiEditor.autoMsg(row[cell],['html','text'])+'</span></td>';}
263264 html+='</tr>';return html;},buildCharacter:function(character,actions){if(typeof character=='string'){character={'label':character,'action':{'type':'encapsulate','options':{'pre':character}}};}else if(0 in character&&1 in character){character={'label':character[0],'action':{'type':'encapsulate','options':{'pre':character[1]}}};}
264265 if('action'in character&&'label'in character){actions[character.label]=character.action;return'<a rel="'+character.label+'" href="#">'+character.label+'</a>';}},buildTab:function(context,id,section){var selected=$.cookie('wikiEditor-'+context.instance+'-toolbar-section');return $('<span />').attr({'class':'tab tab-'+id,'rel':id}).append($('<a />').addClass(selected==id?'current':null).attr('href','#').text($.wikiEditor.autoMsg(section,'label')).data('context',context).bind('mouseup',function(e){$(this).blur();}).bind('click',function(e){var $sections=$(this).data('context').$ui.find('.sections');var $section=$(this).data('context').$ui.find('.section-'+$(this).parent().attr('rel'));var show=$section.css('display')=='none';$previousSections=$section.parent().find('.section:visible');var dH=$previousSections.outerHeight();$previousSections.css('position','absolute');$previousSections.fadeOut('fast',function(){$(this).css('position','relative');});$(this).parent().parent().find('a').removeClass('current');$sections.css('overflow','hidden');if(show){$section.fadeIn('fast');dH=$section.outerHeight()-dH;if('toc'in context.modules){context.modules.toc.$toc.animate({'height':"+="+dH},$section.outerHeight()*2);}
265 -$sections.animate({'height':$section.outerHeight()},$section.outerHeight()*2,function(){$(this).css('overflow','visible').css('height','auto');});$(this).addClass('current');}else{$sections.css('height',$section.outerHeight()).animate({'height':0},$section.outerHeight()*2,function(){$(this).css('overflow','visible');});if('toc'in context.modules){context.modules.toc.$toc.animate({'height':"-="+$section.outerHeight()},$section.outerHeight()*2);}}
 266+$sections.animate({'height':$section.outerHeight()},$section.outerHeight()*2,function(){$(this).css('overflow','visible').css('height','auto');context.fn.trigger('resize');});$(this).addClass('current');}else{$sections.css('height',$section.outerHeight()).animate({'height':0},$section.outerHeight()*2,function(){$(this).css('overflow','visible');context.fn.trigger('resize');});if('toc'in context.modules){context.modules.toc.$toc.animate({'height':"-="+$section.outerHeight()},$section.outerHeight()*2);}}
266267 if($.trackAction!=undefined){$.trackAction($section.attr('rel')+'.'+(show?'show':'hide'));}
267268 $.cookie('wikiEditor-'+$(this).data('context').instance+'-toolbar-section',show?$section.attr('rel'):null);return false;}));},buildSection:function(context,id,section){context.$textarea.trigger('wikiEditor-toolbar-buildSection-'+id,[section]);var selected=$.cookie('wikiEditor-'+context.instance+'-toolbar-section');var $section;switch(section.type){case'toolbar':var $section=$('<div />').attr({'class':'toolbar section section-'+id,'rel':id});if('groups'in section){for(group in section.groups){$section.append($.wikiEditor.modules.toolbar.fn.buildGroup(context,group,section.groups[group]));}}
268269 break;case'booklet':var $pages=$('<div />').addClass('pages');var $index=$('<div />').addClass('index');if('pages'in section){for(page in section.pages){$pages.append($.wikiEditor.modules.toolbar.fn.buildPage(context,page,section.pages[page]));$index.append($.wikiEditor.modules.toolbar.fn.buildBookmark(context,page,section.pages[page]));}}

Status & tagging log