r60267 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60266‎ | r60267 | r60268 >
Date:17:55, 21 December 2009
Author:nimishg
Status:ok
Tags:
Comment:
correctly recognizes what to do with multiple tokens in the same spot
Modified paths:
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js
@@ -135,7 +135,18 @@
136136 collapseTemplate( $visibleDiv );
137137 });
138138 },
 139+
 140+
139141 /**
 142+ * Gets templateInfo node from templateInfo extension, if it exists
 143+ */
 144+ getTemplateInfo: function ( templateName ){
 145+ var templateInfo = '';
 146+ //API call here
 147+ return $( templateInfo );
 148+ },
 149+
 150+ /**
140151 * Builds a template model from given wikitext representation, allowing object-oriented manipulation of the contents
141152 * of the template while preserving whitespace and formatting.
142153 *
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js
@@ -34,7 +34,7 @@
3535 * ; Definition
3636 * : Definition
3737 */
38 - if ( event.data.scope == 'keydown' ) {
 38+ if ( event.data.scope == 'none' ) {
3939 $.wikiEditor.modules.highlight.fn.scan( context, "" );
4040 $.wikiEditor.modules.highlight.fn.mark( context, "", "" );
4141 }
@@ -103,9 +103,10 @@
104104 * @param offset
105105 * @param label
106106 */
107 - function Token( offset, label ) {
 107+ function Token( offset, label, tokenStart ) {
108108 this.offset = offset;
109109 this.label = label;
 110+ this.tokenStart = tokenStart;
110111 }
111112 // Reset tokens
112113 var tokenArray = context.modules.highlight.tokenArray = [];
@@ -124,11 +125,12 @@
125126 var oldOffset = 0;
126127 while ( match != null ) {
127128 var markOffset = 0;
 129+ var tokenStart = match.index + oldOffset + markOffset;
128130 if ( markAfter ) {
129131 markOffset += match[0].length;
130132 }
131133 tokenArray.push(
132 - new Token( match.index + oldOffset + markOffset, label )
 134+ new Token( match.index + oldOffset + markOffset, label, tokenStart )
133135 );
134136 oldOffset += match.index + match[0].length;
135137 newSubstring = text.substring( oldOffset );
@@ -137,7 +139,14 @@
138140 }
139141 }
140142 }
141 - tokenArray.sort( function( a, b ) { return a.offset - b.offset; } );
 143+ //sort by offset, or if offset same, sort by start
 144+ tokenArray.sort( function( a, b ) {
 145+ if( a.offset - b.offset == 0 ){
 146+ return a.tokenStart- b.tokenStart;
 147+ } else {
 148+ return a.offset - b.offset;
 149+ }
 150+ } );
142151 context.fn.trigger( 'scan' );
143152 },
144153 /**

Status & tagging log