Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js |
— | — | @@ -95,6 +95,7 @@ |
96 | 96 | // Build a model for this |
97 | 97 | |
98 | 98 | var model = new $.wikiEditor.modules.templateEditor.fn.model( $( this ).text() ); |
| 99 | + if(!model.isCollapsible()){ return;} |
99 | 100 | var $template = $( this ) |
100 | 101 | .wrap( '<div class="wikiEditor-template"></div>' ) |
101 | 102 | .addClass( 'wikiEditor-template-text wikiEditor-nodisplay' ) |
— | — | @@ -252,6 +253,10 @@ |
253 | 254 | */ |
254 | 255 | model: function( wikitext ) { |
255 | 256 | |
| 257 | + /* Private members */ |
| 258 | + |
| 259 | + var collapsible = true; |
| 260 | + |
256 | 261 | /* Private Functions */ |
257 | 262 | |
258 | 263 | /** |
— | — | @@ -400,12 +405,18 @@ |
401 | 406 | return newText; |
402 | 407 | }; |
403 | 408 | |
| 409 | + this.isCollapsible = function(){ |
| 410 | + return collapsible; |
| 411 | + } |
| 412 | + |
404 | 413 | /** |
405 | | - * Update ranges if there's been a change |
| 414 | + * Update ranges if there's been a change in one or more 'segments' of the template. |
| 415 | + * Removes adjustment function so adjustment is only made once ever. |
406 | 416 | */ |
| 417 | + |
407 | 418 | this.updateRanges = function() { |
408 | 419 | var adjustment = 0; |
409 | | - for ( i = 0 ; i < ranges.length; i++ ) { |
| 420 | + for (var i = 0 ; i < ranges.length; i++ ) { |
410 | 421 | ranges[i].begin += adjustment; |
411 | 422 | if( typeof ranges[i].adjust != 'undefined' ) { |
412 | 423 | adjustment += ranges[i].adjust(); |
— | — | @@ -419,7 +430,7 @@ |
420 | 431 | |
421 | 432 | // Whitespace* {{ whitespace* nonwhitespace: |
422 | 433 | if ( wikitext.match( /\s*{{\s*\S*:/ ) ) { |
423 | | - // We have a parser function! |
| 434 | + collapsible = false; // is a parser function |
424 | 435 | } |
425 | 436 | /* |
426 | 437 | * Take all template-specific characters that are not particular to the template we're looking at, namely {|=}, |
— | — | @@ -482,6 +493,7 @@ |
483 | 494 | if ( divider == -1 ) { |
484 | 495 | divider = sanatizedStr.length; |
485 | 496 | doneParsing = true; |
| 497 | + collapsible = false; //zero params |
486 | 498 | } |
487 | 499 | nameMatch = sanatizedStr.substring( 0, divider ).match( /[^\s]/ ); |
488 | 500 | if ( nameMatch != null ) { |
— | — | @@ -596,7 +608,7 @@ |
597 | 609 | this.params = params; |
598 | 610 | this.paramsByName = paramsByName; |
599 | 611 | this.templateNameIndex = templateNameIndex; |
600 | | - } // model |
| 612 | + } // model |
601 | 613 | } |
602 | 614 | |
603 | 615 | }; } )( jQuery ); |