r61508 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61507‎ | r61508 | r61509 >
Date:01:18, 26 January 2010
Author:nimishg
Status:ok (Comments)
Tags:
Comment:
no longer collapses parser functions or zero-arg templates, added comments and scoping
Modified paths:
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js
@@ -95,6 +95,7 @@
9696 // Build a model for this
9797
9898 var model = new $.wikiEditor.modules.templateEditor.fn.model( $( this ).text() );
 99+ if(!model.isCollapsible()){ return;}
99100 var $template = $( this )
100101 .wrap( '<div class="wikiEditor-template"></div>' )
101102 .addClass( 'wikiEditor-template-text wikiEditor-nodisplay' )
@@ -252,6 +253,10 @@
253254 */
254255 model: function( wikitext ) {
255256
 257+ /* Private members */
 258+
 259+ var collapsible = true;
 260+
256261 /* Private Functions */
257262
258263 /**
@@ -400,12 +405,18 @@
401406 return newText;
402407 };
403408
 409+ this.isCollapsible = function(){
 410+ return collapsible;
 411+ }
 412+
404413 /**
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.
406416 */
 417+
407418 this.updateRanges = function() {
408419 var adjustment = 0;
409 - for ( i = 0 ; i < ranges.length; i++ ) {
 420+ for (var i = 0 ; i < ranges.length; i++ ) {
410421 ranges[i].begin += adjustment;
411422 if( typeof ranges[i].adjust != 'undefined' ) {
412423 adjustment += ranges[i].adjust();
@@ -419,7 +430,7 @@
420431
421432 // Whitespace* {{ whitespace* nonwhitespace:
422433 if ( wikitext.match( /\s*{{\s*\S*:/ ) ) {
423 - // We have a parser function!
 434+ collapsible = false; // is a parser function
424435 }
425436 /*
426437 * Take all template-specific characters that are not particular to the template we're looking at, namely {|=},
@@ -482,6 +493,7 @@
483494 if ( divider == -1 ) {
484495 divider = sanatizedStr.length;
485496 doneParsing = true;
 497+ collapsible = false; //zero params
486498 }
487499 nameMatch = sanatizedStr.substring( 0, divider ).match( /[^\s]/ );
488500 if ( nameMatch != null ) {
@@ -596,7 +608,7 @@
597609 this.params = params;
598610 this.paramsByName = paramsByName;
599611 this.templateNameIndex = templateNameIndex;
600 - } // model
 612+ } // model
601613 }
602614
603615 }; } )( jQuery );

Follow-up revisions

RevisionCommit summaryAuthorDate
r61517UsabilityInitiative: Bump and recombine for r61508, whitespace changes for r6...catrope14:20, 26 January 2010

Comments

#Comment by Catrope (talk | contribs)   10:06, 26 January 2010
-	} // model
+	} // model	

You're adding trailing whitespace here.

Status & tagging log