Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -2662,28 +2662,28 @@ |
2663 | 2663 | var level = 0; |
2664 | 2664 | |
2665 | 2665 | var tokenIndex = 0; |
2666 | | - while( tokenIndex < tokenArray.length ){ |
2667 | | - while( tokenIndex < tokenArray.length && tokenArray[tokenIndex].label != 'TEMPLATE_BEGIN'){ |
| 2666 | + while ( tokenIndex < tokenArray.length ){ |
| 2667 | + while ( tokenIndex < tokenArray.length && tokenArray[tokenIndex].label != 'TEMPLATE_BEGIN' ) { |
2668 | 2668 | tokenIndex++; |
2669 | 2669 | } |
2670 | 2670 | //open template |
2671 | | - if(tokenIndex < tokenArray.length){ |
| 2671 | + if ( tokenIndex < tokenArray.length ) { |
2672 | 2672 | var beginIndex = tokenIndex; |
2673 | 2673 | var endIndex = -1; //no match found |
2674 | 2674 | var openTemplates = 1; |
2675 | 2675 | var templatesMatched = false; |
2676 | | - while(tokenIndex < tokenArray.length && (endIndex == -1) ){ |
| 2676 | + while ( tokenIndex < tokenArray.length && endIndex == -1 ) { |
2677 | 2677 | tokenIndex++; |
2678 | | - if(tokenArray[tokenIndex].label == 'TEMPLATE_BEGIN'){ |
| 2678 | + if ( tokenArray[tokenIndex].label == 'TEMPLATE_BEGIN' ) { |
2679 | 2679 | openTemplates++; |
2680 | | - } else if(tokenArray[tokenIndex].label == 'TEMPLATE_END') { |
| 2680 | + } else if ( tokenArray[tokenIndex].label == 'TEMPLATE_END' ) { |
2681 | 2681 | openTemplates--; |
2682 | | - if(openTemplates == 0){ |
| 2682 | + if ( openTemplates == 0 ) { |
2683 | 2683 | endIndex = tokenIndex; |
2684 | 2684 | } //we can stop looping |
2685 | 2685 | } |
2686 | 2686 | }//while finding template ending |
2687 | | - if(endIndex != -1){ |
| 2687 | + if ( endIndex != -1 ) { |
2688 | 2688 | markers.push( { |
2689 | 2689 | start: tokenArray[beginIndex].offset, |
2690 | 2690 | end: tokenArray[endIndex].offset, |
— | — | @@ -2721,18 +2721,18 @@ |
2722 | 2722 | }, |
2723 | 2723 | stylize: function( context ) { |
2724 | 2724 | var $templates = context.$content.find( '.wiki-template' ); |
2725 | | - $templates.each( function(){ |
2726 | | - if ( typeof $( this ).data( 'model' ) != 'undefined' ) { |
| 2725 | + $templates.each( function() { |
| 2726 | + if ( typeof $(this).data( 'model' ) != 'undefined' ) { |
2727 | 2727 | // We have a model, so all this init stuff has already happened |
2728 | 2728 | return; |
2729 | 2729 | } |
2730 | 2730 | // Hide this |
2731 | | - $(this).addClass('wikieditor-nodisplay'); |
| 2731 | + $(this).addClass( 'wikieditor-nodisplay' ); |
2732 | 2732 | // Build a model for this |
2733 | | - $( this ).data( 'model' , new model( $( this ).text() ) ); |
2734 | | - var model = $( this ).data( 'model' ); |
| 2733 | + $(this).data( 'model' , new model( $( this ).text() ) ); |
| 2734 | + var model = $(this).data( 'model' ); |
2735 | 2735 | // Expand |
2736 | | - function expandTemplate($displayDiv){ |
| 2736 | + function expandTemplate( $displayDiv ) { |
2737 | 2737 | // Housekeeping |
2738 | 2738 | $displayDiv.removeClass( 'wiki-collapsed-template' ); |
2739 | 2739 | $displayDiv.addClass( 'wiki-expanded-template' ); |
— | — | @@ -2740,7 +2740,7 @@ |
2741 | 2741 | $displayDiv.text( model.getText() ); |
2742 | 2742 | }; |
2743 | 2743 | // Collapse |
2744 | | - function collapseTemplate($displayDiv){ |
| 2744 | + function collapseTemplate( $displayDiv ) { |
2745 | 2745 | // Housekeeping |
2746 | 2746 | $displayDiv.addClass( 'wiki-collapsed-template' ); |
2747 | 2747 | $displayDiv.removeClass( 'wiki-expanded-template' ); |
— | — | @@ -2752,11 +2752,11 @@ |
2753 | 2753 | // Let these two know about eachother |
2754 | 2754 | $(this).data( 'display' , $visibleDiv ); |
2755 | 2755 | $visibleDiv.data( 'wikitext-node', $(this) ); |
2756 | | - $(this).after( $visibleDiv ); |
| 2756 | + $(this).after( $visibleDiv ); |
2757 | 2757 | // Add click handler |
2758 | | - $visibleDiv.click( function(){ |
| 2758 | + $visibleDiv.click( function() { |
2759 | 2759 | // Is collapsed, switch to expand |
2760 | | - if ( $(this).data('mode') == 'collapsed' ) { |
| 2760 | + if ( $(this).data( 'mode' ) == 'collapsed' ) { |
2761 | 2761 | expandTemplate( $(this) ); |
2762 | 2762 | } else { |
2763 | 2763 | collapseTemplate( $(this) ); |
— | — | @@ -2933,11 +2933,11 @@ |
2934 | 2934 | var sanatizedStr = wikitext.replace( /{{/, " " ); |
2935 | 2935 | // Replace end |
2936 | 2936 | endBraces = sanatizedStr.match( /}}\s*$/ ); |
2937 | | - sanatizedStr = |
2938 | | - sanatizedStr.substring( 0, endBraces.index ) + " " + sanatizedStr.substring( endBraces.index + 2 ); |
| 2937 | + sanatizedStr = sanatizedStr.substring( 0, endBraces.index ) + " " + |
| 2938 | + sanatizedStr.substring( endBraces.index + 2 ); |
2939 | 2939 | // Match the open braces we just found with equivalent closing braces note, works for any level of braces |
2940 | 2940 | while ( sanatizedStr.indexOf( '{{' ) != -1 ) { |
2941 | | - startIndex = sanatizedStr.indexOf('{{') + 1; |
| 2941 | + startIndex = sanatizedStr.indexOf( '{{' ) + 1; |
2942 | 2942 | openBraces = 2; |
2943 | 2943 | endIndex = startIndex; |
2944 | 2944 | while ( openBraces > 0 ) { |
— | — | @@ -2962,7 +2962,7 @@ |
2963 | 2963 | doneParsing = true; |
2964 | 2964 | } |
2965 | 2965 | nameMatch = wikitext.substring( oldDivider, divider ).match( /[^{\s]+/ ); |
2966 | | - if(nameMatch != undefined){ |
| 2966 | + if ( nameMatch != undefined ) { |
2967 | 2967 | ranges.push( new Range( oldDivider,nameMatch.index ) ); //whitespace and squiggles upto the name |
2968 | 2968 | templateNameIndex = ranges.push( new Range( nameMatch.index, |
2969 | 2969 | nameMatch.index + nameMatch[0].length ) ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -170,7 +170,7 @@ |
171 | 171 | $('#wikiEditor-'+context.instance+'-dialog-minor').attr('checked','checked');if($('#wpWatchthis').size()==0) |
172 | 172 | $('#wikiEditor-'+context.instance+'-dialog-watch').hide();else if($('#wpWatchthis').is(':checked')) |
173 | 173 | $('#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={evt:{mark:function(context,event){var markers=context.modules.highlight.markers;var tokenArray=context.modules.highlight.tokenArray;var level=0;var tokenIndex=0;while(tokenIndex<tokenArray.length){while(tokenIndex<tokenArray.length&&tokenArray[tokenIndex].label!='TEMPLATE_BEGIN'){tokenIndex++;} |
174 | | -if(tokenIndex<tokenArray.length){var beginIndex=tokenIndex;var endIndex=-1;var openTemplates=1;var templatesMatched=false;while(tokenIndex<tokenArray.length&&(endIndex==-1)){tokenIndex++;if(tokenArray[tokenIndex].label=='TEMPLATE_BEGIN'){openTemplates++;}else if(tokenArray[tokenIndex].label=='TEMPLATE_END'){openTemplates--;if(openTemplates==0){endIndex=tokenIndex;}}} |
| 174 | +if(tokenIndex<tokenArray.length){var beginIndex=tokenIndex;var endIndex=-1;var openTemplates=1;var templatesMatched=false;while(tokenIndex<tokenArray.length&&endIndex==-1){tokenIndex++;if(tokenArray[tokenIndex].label=='TEMPLATE_BEGIN'){openTemplates++;}else if(tokenArray[tokenIndex].label=='TEMPLATE_END'){openTemplates--;if(openTemplates==0){endIndex=tokenIndex;}}} |
175 | 175 | if(endIndex!=-1){markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,wrapElement:function(){return $('<div />').addClass('wikiEditor-highlight-template');}});}else{tokenArray[beginIndex].label='TEMPLATE_FALSE_BEGIN';tokenIndex=beginIndex;}}}}},exp:[{'regex':/{{/,'label':"TEMPLATE_BEGIN"},{'regex':/}}/,'label':"TEMPLATE_END",'markAfter':true}],fn:{create:function(context,config){context.modules.templateEditor={};},stylize:function(context){var $templates=context.$content.find('.wiki-template');$templates.each(function(){if(typeof $(this).data('model')!='undefined'){return;} |
176 | 176 | $(this).addClass('wikieditor-nodisplay');$(this).data('model',new model($(this).text()));var model=$(this).data('model');function expandTemplate($displayDiv){$displayDiv.removeClass('wiki-collapsed-template');$displayDiv.addClass('wiki-expanded-template');$displayDiv.data('mode')="expanded";$displayDiv.text(model.getText());};function collapseTemplate($displayDiv){$displayDiv.addClass('wiki-collapsed-template');$displayDiv.removeClass('wiki-expanded-template');$displayDiv.data('mode')="collapsed";$displayDiv.text(model.getName());};var $visibleDiv=$("<div></div>").addClass('wikieditor-noinclude');$(this).data('display',$visibleDiv);$visibleDiv.data('wikitext-node',$(this));$(this).after($visibleDiv);$visibleDiv.click(function(){if($(this).data('mode')=='collapsed'){expandTemplate($(this));}else{collapseTemplate($(this));}});collapseTemplate($visibleDiv);});},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;} |
177 | 177 | function Range(begin,end){this.begin=begin;this.end=end;} |
— | — | @@ -182,7 +182,8 @@ |
183 | 183 | 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.getAllParamNames=function(){return paramsByName;};this.getAllInitialParams=function(){return params;} |
184 | 184 | 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;}} |
185 | 185 | return newText;};if(wikitext.match(/\s*{{\s*\S*:/)){} |
186 | | -var sanatizedStr=wikitext.replace(/{{/," ");endBraces=sanatizedStr.match(/}}\s*$/);sanatizedStr=sanatizedStr.substring(0,endBraces.index)+" "+sanatizedStr.substring(endBraces.index+2);while(sanatizedStr.indexOf('{{')!=-1){startIndex=sanatizedStr.indexOf('{{')+1;openBraces=2;endIndex=startIndex;while(openBraces>0){var brace=sanatizedStr[++endIndex];openBraces+=brace=='}'?-1:brace=='{'?1:0;} |
| 186 | +var sanatizedStr=wikitext.replace(/{{/," ");endBraces=sanatizedStr.match(/}}\s*$/);sanatizedStr=sanatizedStr.substring(0,endBraces.index)+" "+ |
| 187 | +sanatizedStr.substring(endBraces.index+2);while(sanatizedStr.indexOf('{{')!=-1){startIndex=sanatizedStr.indexOf('{{')+1;openBraces=2;endIndex=startIndex;while(openBraces>0){var brace=sanatizedStr[++endIndex];openBraces+=brace=='}'?-1:brace=='{'?1:0;} |
187 | 188 | sanatizedSegment=sanatizedStr.substring(startIndex,endIndex).replace(/[{}|=]/g,'X');sanatizedStr=sanatizedStr.substring(0,startIndex)+sanatizedSegment+sanatizedStr.substring(endIndex);} |
188 | 189 | var ranges=[];var params=[];var templateNameIndex=0;var doneParsing=false;oldDivider=0;divider=sanatizedStr.indexOf('|',oldDivider);if(divider==-1){divider=sanatizedStr.length;doneParsing=true;} |
189 | 190 | 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);} |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js |
— | — | @@ -13,28 +13,28 @@ |
14 | 14 | var level = 0; |
15 | 15 | |
16 | 16 | var tokenIndex = 0; |
17 | | - while( tokenIndex < tokenArray.length ){ |
18 | | - while( tokenIndex < tokenArray.length && tokenArray[tokenIndex].label != 'TEMPLATE_BEGIN'){ |
| 17 | + while ( tokenIndex < tokenArray.length ){ |
| 18 | + while ( tokenIndex < tokenArray.length && tokenArray[tokenIndex].label != 'TEMPLATE_BEGIN' ) { |
19 | 19 | tokenIndex++; |
20 | 20 | } |
21 | 21 | //open template |
22 | | - if(tokenIndex < tokenArray.length){ |
| 22 | + if ( tokenIndex < tokenArray.length ) { |
23 | 23 | var beginIndex = tokenIndex; |
24 | 24 | var endIndex = -1; //no match found |
25 | 25 | var openTemplates = 1; |
26 | 26 | var templatesMatched = false; |
27 | | - while(tokenIndex < tokenArray.length && (endIndex == -1) ){ |
| 27 | + while ( tokenIndex < tokenArray.length && endIndex == -1 ) { |
28 | 28 | tokenIndex++; |
29 | | - if(tokenArray[tokenIndex].label == 'TEMPLATE_BEGIN'){ |
| 29 | + if ( tokenArray[tokenIndex].label == 'TEMPLATE_BEGIN' ) { |
30 | 30 | openTemplates++; |
31 | | - } else if(tokenArray[tokenIndex].label == 'TEMPLATE_END') { |
| 31 | + } else if ( tokenArray[tokenIndex].label == 'TEMPLATE_END' ) { |
32 | 32 | openTemplates--; |
33 | | - if(openTemplates == 0){ |
| 33 | + if ( openTemplates == 0 ) { |
34 | 34 | endIndex = tokenIndex; |
35 | 35 | } //we can stop looping |
36 | 36 | } |
37 | 37 | }//while finding template ending |
38 | | - if(endIndex != -1){ |
| 38 | + if ( endIndex != -1 ) { |
39 | 39 | markers.push( { |
40 | 40 | start: tokenArray[beginIndex].offset, |
41 | 41 | end: tokenArray[endIndex].offset, |
— | — | @@ -72,18 +72,18 @@ |
73 | 73 | }, |
74 | 74 | stylize: function( context ) { |
75 | 75 | var $templates = context.$content.find( '.wiki-template' ); |
76 | | - $templates.each( function(){ |
77 | | - if ( typeof $( this ).data( 'model' ) != 'undefined' ) { |
| 76 | + $templates.each( function() { |
| 77 | + if ( typeof $(this).data( 'model' ) != 'undefined' ) { |
78 | 78 | // We have a model, so all this init stuff has already happened |
79 | 79 | return; |
80 | 80 | } |
81 | 81 | // Hide this |
82 | | - $(this).addClass('wikieditor-nodisplay'); |
| 82 | + $(this).addClass( 'wikieditor-nodisplay' ); |
83 | 83 | // Build a model for this |
84 | | - $( this ).data( 'model' , new model( $( this ).text() ) ); |
85 | | - var model = $( this ).data( 'model' ); |
| 84 | + $(this).data( 'model' , new model( $( this ).text() ) ); |
| 85 | + var model = $(this).data( 'model' ); |
86 | 86 | // Expand |
87 | | - function expandTemplate($displayDiv){ |
| 87 | + function expandTemplate( $displayDiv ) { |
88 | 88 | // Housekeeping |
89 | 89 | $displayDiv.removeClass( 'wiki-collapsed-template' ); |
90 | 90 | $displayDiv.addClass( 'wiki-expanded-template' ); |
— | — | @@ -91,7 +91,7 @@ |
92 | 92 | $displayDiv.text( model.getText() ); |
93 | 93 | }; |
94 | 94 | // Collapse |
95 | | - function collapseTemplate($displayDiv){ |
| 95 | + function collapseTemplate( $displayDiv ) { |
96 | 96 | // Housekeeping |
97 | 97 | $displayDiv.addClass( 'wiki-collapsed-template' ); |
98 | 98 | $displayDiv.removeClass( 'wiki-expanded-template' ); |
— | — | @@ -103,11 +103,11 @@ |
104 | 104 | // Let these two know about eachother |
105 | 105 | $(this).data( 'display' , $visibleDiv ); |
106 | 106 | $visibleDiv.data( 'wikitext-node', $(this) ); |
107 | | - $(this).after( $visibleDiv ); |
| 107 | + $(this).after( $visibleDiv ); |
108 | 108 | // Add click handler |
109 | | - $visibleDiv.click( function(){ |
| 109 | + $visibleDiv.click( function() { |
110 | 110 | // Is collapsed, switch to expand |
111 | | - if ( $(this).data('mode') == 'collapsed' ) { |
| 111 | + if ( $(this).data( 'mode' ) == 'collapsed' ) { |
112 | 112 | expandTemplate( $(this) ); |
113 | 113 | } else { |
114 | 114 | collapseTemplate( $(this) ); |
— | — | @@ -284,11 +284,11 @@ |
285 | 285 | var sanatizedStr = wikitext.replace( /{{/, " " ); |
286 | 286 | // Replace end |
287 | 287 | endBraces = sanatizedStr.match( /}}\s*$/ ); |
288 | | - sanatizedStr = |
289 | | - sanatizedStr.substring( 0, endBraces.index ) + " " + sanatizedStr.substring( endBraces.index + 2 ); |
| 288 | + sanatizedStr = sanatizedStr.substring( 0, endBraces.index ) + " " + |
| 289 | + sanatizedStr.substring( endBraces.index + 2 ); |
290 | 290 | // Match the open braces we just found with equivalent closing braces note, works for any level of braces |
291 | 291 | while ( sanatizedStr.indexOf( '{{' ) != -1 ) { |
292 | | - startIndex = sanatizedStr.indexOf('{{') + 1; |
| 292 | + startIndex = sanatizedStr.indexOf( '{{' ) + 1; |
293 | 293 | openBraces = 2; |
294 | 294 | endIndex = startIndex; |
295 | 295 | while ( openBraces > 0 ) { |
— | — | @@ -313,7 +313,7 @@ |
314 | 314 | doneParsing = true; |
315 | 315 | } |
316 | 316 | nameMatch = wikitext.substring( oldDivider, divider ).match( /[^{\s]+/ ); |
317 | | - if(nameMatch != undefined){ |
| 317 | + if ( nameMatch != undefined ) { |
318 | 318 | ranges.push( new Range( oldDivider,nameMatch.index ) ); //whitespace and squiggles upto the name |
319 | 319 | templateNameIndex = ranges.push( new Range( nameMatch.index, |
320 | 320 | nameMatch.index + nameMatch[0].length ) ); |