Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js |
— | — | @@ -135,7 +135,18 @@ |
136 | 136 | collapseTemplate( $visibleDiv ); |
137 | 137 | }); |
138 | 138 | }, |
| 139 | + |
| 140 | + |
139 | 141 | /** |
| 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 | + /** |
140 | 151 | * Builds a template model from given wikitext representation, allowing object-oriented manipulation of the contents |
141 | 152 | * of the template while preserving whitespace and formatting. |
142 | 153 | * |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | * ; Definition |
36 | 36 | * : Definition |
37 | 37 | */ |
38 | | - if ( event.data.scope == 'keydown' ) { |
| 38 | + if ( event.data.scope == 'none' ) { |
39 | 39 | $.wikiEditor.modules.highlight.fn.scan( context, "" ); |
40 | 40 | $.wikiEditor.modules.highlight.fn.mark( context, "", "" ); |
41 | 41 | } |
— | — | @@ -103,9 +103,10 @@ |
104 | 104 | * @param offset |
105 | 105 | * @param label |
106 | 106 | */ |
107 | | - function Token( offset, label ) { |
| 107 | + function Token( offset, label, tokenStart ) { |
108 | 108 | this.offset = offset; |
109 | 109 | this.label = label; |
| 110 | + this.tokenStart = tokenStart; |
110 | 111 | } |
111 | 112 | // Reset tokens |
112 | 113 | var tokenArray = context.modules.highlight.tokenArray = []; |
— | — | @@ -124,11 +125,12 @@ |
125 | 126 | var oldOffset = 0; |
126 | 127 | while ( match != null ) { |
127 | 128 | var markOffset = 0; |
| 129 | + var tokenStart = match.index + oldOffset + markOffset; |
128 | 130 | if ( markAfter ) { |
129 | 131 | markOffset += match[0].length; |
130 | 132 | } |
131 | 133 | tokenArray.push( |
132 | | - new Token( match.index + oldOffset + markOffset, label ) |
| 134 | + new Token( match.index + oldOffset + markOffset, label, tokenStart ) |
133 | 135 | ); |
134 | 136 | oldOffset += match.index + match[0].length; |
135 | 137 | newSubstring = text.substring( oldOffset ); |
— | — | @@ -137,7 +139,14 @@ |
138 | 140 | } |
139 | 141 | } |
140 | 142 | } |
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 | + } ); |
142 | 151 | context.fn.trigger( 'scan' ); |
143 | 152 | }, |
144 | 153 | /** |