Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -73,18 +73,18 @@ |
74 | 74 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 21 ), |
75 | 75 | array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 32 ), |
76 | 76 | 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 ), |
78 | 78 | 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 ), |
80 | 80 | array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 7 ), |
81 | 81 | array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 1 ), |
82 | 82 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 0 ), |
83 | 83 | ), |
84 | 84 | 'combined' => array( |
85 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 104 ), |
| 85 | + array( 'src' => 'js/plugins.combined.js', 'version' => 105 ), |
86 | 86 | ), |
87 | 87 | 'minified' => array( |
88 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 104 ), |
| 88 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 105 ), |
89 | 89 | ), |
90 | 90 | ), |
91 | 91 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js |
— | — | @@ -164,13 +164,14 @@ |
165 | 165 | .animate( { 'width' : openWidth }, 'fast', function() { |
166 | 166 | context.$content.trigger( 'mouseup' ); |
167 | 167 | $( this ).css( { 'marginTop': '0', 'position': 'relative', 'right': 'auto', 'top': 'auto' } ); |
168 | | - // Let the UI know things have moved around |
169 | | - context.fn.trigger( 'resize' ); |
170 | 168 | } ) |
171 | 169 | .prev() |
172 | 170 | .animate( { 'marginRight': ( parseFloat( openWidth ) * -1 ) }, 'fast' ) |
173 | 171 | .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 | + } ); |
175 | 176 | $.cookie( 'wikiEditor-' + context.instance + '-toc-width', |
176 | 177 | context.modules.toc.$toc.data( 'openWidth' ) ); |
177 | 178 | return false; |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js |
— | — | @@ -489,12 +489,14 @@ |
490 | 490 | } |
491 | 491 | $sections.animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2, function() { |
492 | 492 | $(this).css('overflow', 'visible').css('height', 'auto'); |
| 493 | + context.fn.trigger( 'resize' ); |
493 | 494 | } ); |
494 | 495 | $(this).addClass( 'current' ); |
495 | 496 | } else { |
496 | 497 | $sections.css('height', $section.outerHeight() ) |
497 | 498 | .animate( { 'height': 0 }, $section.outerHeight() * 2, function() { |
498 | 499 | $(this).css('overflow', 'visible'); |
| 500 | + context.fn.trigger( 'resize' ); |
499 | 501 | } ); |
500 | 502 | if ( 'toc' in context.modules ) { |
501 | 503 | context.modules.toc.$toc.animate({'height': "-="+$section.outerHeight()}, $section.outerHeight() * 2); |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -2221,20 +2221,18 @@ |
2222 | 2222 | } |
2223 | 2223 | markedText = ""; |
2224 | 2224 | 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 |
2239 | 2237 | } |
2240 | 2238 | |
2241 | 2239 | }; })( jQuery );/* Preview module for wikiEditor */ |
— | — | @@ -2507,7 +2505,7 @@ |
2508 | 2506 | evt: { |
2509 | 2507 | mark: function() { |
2510 | 2508 | function findOutermostTemplates( tokenStack ) { |
2511 | | - var templateBeginFound = false; |
| 2509 | + templateBeginFound = false; |
2512 | 2510 | for ( ;i< tokenStack.length; i++ ) { |
2513 | 2511 | if ( tokenStack[i].label == "TEMPLATE_BEGIN" ) { |
2514 | 2512 | templateBeginFound = true; |
— | — | @@ -2544,11 +2542,11 @@ |
2545 | 2543 | } |
2546 | 2544 | }; //find outermost templates |
2547 | 2545 | |
2548 | | - var markers = $.wikiEditor.modules.highlight.fn.markers; |
| 2546 | + markers = $.wikiEditor.modules.highlight.fn.markers; |
2549 | 2547 | var tokenStack = $.wikiEditor.modules.highlight.fn.tokenArray; |
2550 | | - var i = 0; |
| 2548 | + i = 0; |
2551 | 2549 | var templateBoundaries; |
2552 | | - var templateBeginFound = false; |
| 2550 | + templateBeginFound = false; |
2553 | 2551 | |
2554 | 2552 | while ( templateBoundaries = findOutermostTemplates( tokenStack ) ) { |
2555 | 2553 | if ( typeof markers[tokenStack[templateBoundaries[0]].offset] == 'undefined' ) { |
— | — | @@ -2557,7 +2555,6 @@ |
2558 | 2556 | if ( typeof markers[tokenStack[templateBoundaries[1]].offset] == 'undefined' ) { |
2559 | 2557 | markers[tokenStack[templateBoundaries[1]].offset] = []; |
2560 | 2558 | } |
2561 | | - |
2562 | 2559 | markers[tokenStack[templateBoundaries[0]].offset].push( "<div class='wiki-template'>" ); |
2563 | 2560 | markers[tokenStack[templateBoundaries[1]].offset].push( "</div>" ); |
2564 | 2561 | } |
— | — | @@ -2628,6 +2625,8 @@ |
2629 | 2626 | .replace( /[{}|=]/g , 'X' ); |
2630 | 2627 | sanatizedStr = sanatizedStr.substring( 0, startIndex ) + |
2631 | 2628 | sanatizedSegment + sanatizedStr.substring( endIndex ); |
| 2629 | + }//while |
| 2630 | + return sanatizedStr; |
2632 | 2631 | }; |
2633 | 2632 | |
2634 | 2633 | // Whitespace* {{ whitespace* nonwhitespace: |
— | — | @@ -2766,9 +2765,13 @@ |
2767 | 2766 | |
2768 | 2767 | //get template name |
2769 | 2768 | 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 | + } |
2773 | 2776 | }; |
2774 | 2777 | |
2775 | 2778 | //set template name (if we want to support this) |
— | — | @@ -2805,14 +2808,18 @@ |
2806 | 2809 | this.getText = function() { |
2807 | 2810 | newText = ""; |
2808 | 2811 | 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 | + } |
2811 | 2817 | } |
2812 | 2818 | return newText; |
2813 | 2819 | }; |
2814 | 2820 | }//template model |
2815 | | -} |
2816 | 2821 | |
| 2822 | +}//fn |
| 2823 | + |
2817 | 2824 | }; } )( jQuery ); |
2818 | 2825 | |
2819 | 2826 | |
— | — | @@ -2982,13 +2989,14 @@ |
2983 | 2990 | .animate( { 'width' : openWidth }, 'fast', function() { |
2984 | 2991 | context.$content.trigger( 'mouseup' ); |
2985 | 2992 | $( this ).css( { 'marginTop': '0', 'position': 'relative', 'right': 'auto', 'top': 'auto' } ); |
2986 | | - // Let the UI know things have moved around |
2987 | | - context.fn.trigger( 'resize' ); |
2988 | 2993 | } ) |
2989 | 2994 | .prev() |
2990 | 2995 | .animate( { 'marginRight': ( parseFloat( openWidth ) * -1 ) }, 'fast' ) |
2991 | 2996 | .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 | + } ); |
2993 | 3001 | $.cookie( 'wikiEditor-' + context.instance + '-toc-width', |
2994 | 3002 | context.modules.toc.$toc.data( 'openWidth' ) ); |
2995 | 3003 | return false; |
— | — | @@ -3767,12 +3775,14 @@ |
3768 | 3776 | } |
3769 | 3777 | $sections.animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2, function() { |
3770 | 3778 | $(this).css('overflow', 'visible').css('height', 'auto'); |
| 3779 | + context.fn.trigger( 'resize' ); |
3771 | 3780 | } ); |
3772 | 3781 | $(this).addClass( 'current' ); |
3773 | 3782 | } else { |
3774 | 3783 | $sections.css('height', $section.outerHeight() ) |
3775 | 3784 | .animate( { 'height': 0 }, $section.outerHeight() * 2, function() { |
3776 | 3785 | $(this).css('overflow', 'visible'); |
| 3786 | + context.fn.trigger( 'resize' ); |
3777 | 3787 | } ); |
3778 | 3788 | if ( 'toc' in context.modules ) { |
3779 | 3789 | context.modules.toc.$toc.animate({'height': "-="+$section.outerHeight()}, $section.outerHeight() * 2); |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -129,9 +129,9 @@ |
130 | 130 | match=text.match(regex);var oldOffset=0;while(match!=null){var markOffset=0;if(markAfter){markOffset+=match[0].length;} |
131 | 131 | this.tokenArray.push(new Token(match.index+oldOffset+markOffset,label));oldOffset+=match.index+match[0].length;newSubstring=text.substring(oldOffset);match=newSubstring.match(regex);}}}} |
132 | 132 | 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];} |
134 | 134 | 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;} |
136 | 136 | 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;} |
137 | 137 | 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;} |
138 | 138 | 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 @@ |
162 | 162 | $('#wikiEditor-'+context.instance+'-dialog-minor').hide();else if($('#wpMinoredit').is(':checked')) |
163 | 163 | $('#wikiEditor-'+context.instance+'-dialog-minor').attr('checked','checked');if($('#wpWatchthis').size()==0) |
164 | 164 | $('#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;}} |
166 | 166 | 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--;} |
167 | 167 | 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]=[];} |
169 | 169 | if(typeof markers[tokenStack[templateBoundaries[1]].offset]=='undefined'){markers[tokenStack[templateBoundaries[1]].offset]=[];} |
170 | 170 | 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;} |
171 | 171 | function Range(begin,end){this.begin=begin;this.end=end;} |
172 | 172 | 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)+" "+ |
173 | 173 | 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;}} |
174 | 174 | 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*:/)){} |
176 | 177 | markOffTemplates();var doneParsing=false;oldDivider=0;divider=sanatizedStr.indexOf('|',oldDivider);if(divider==-1){divider=sanatizedStr.length;doneParsing=true;} |
177 | 178 | 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);} |
178 | 179 | 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 @@ |
183 | 184 | if(typeof params[rangeIndex]=='undefined'){return"";} |
184 | 185 | valueRange=ranges[params[rangeIndex].valueIndex];if(typeof valueRange.newVal=='undefined'||original){retVal=wikitext.substring(valueRange.begin,valueRange.end);}else{retVal=valueRange.newVal;} |
185 | 186 | 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;}} |
187 | 188 | 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()- |
188 | 189 | context.$ui.find('.tab-toc').outerHeight());}},fn:{create:function(context,config){if('$toc'in context.modules.toc){return;} |
189 | 190 | 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++;} |
190 | 191 | section=Math.max(0,section);} |
191 | 192 | 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) |
192 | 193 | 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;} |
194 | 195 | sections[sections.length]=outline[i];}else if(outline[i].nLevel<level){break;}} |
195 | 196 | return sections;} |
196 | 197 | 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 @@ |
262 | 263 | $.wikiEditor.autoMsg(row[cell],['html','text'])+'</span></td>';} |
263 | 264 | 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]}}};} |
264 | 265 | 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);}} |
266 | 267 | if($.trackAction!=undefined){$.trackAction($section.attr('rel')+'.'+(show?'show':'hide'));} |
267 | 268 | $.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]));}} |
268 | 269 | 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]));}} |