Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -67,16 +67,16 @@ |
68 | 68 | array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 9 ), |
69 | 69 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 11 ), |
70 | 70 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 4 ), |
71 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 16 ), |
| 71 | + array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 17 ), |
72 | 72 | // FIXME: jQuery UI doesn't belong here, should move to no_js2 |
73 | 73 | // once we figure out how to do jQuery UI properly in JS2 |
74 | 74 | array( 'src' => 'js/js2/jquery-ui-1.7.2.js', 'version' => '1.7.2y' ), |
75 | 75 | ), |
76 | 76 | 'combined' => array( |
77 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 37 ), |
| 77 | + array( 'src' => 'js/plugins.combined.js', 'version' => 38 ), |
78 | 78 | ), |
79 | 79 | 'minified' => array( |
80 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 37 ), |
| 80 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 38 ), |
81 | 81 | ), |
82 | 82 | ), |
83 | 83 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js |
— | — | @@ -172,23 +172,22 @@ |
173 | 173 | } |
174 | 174 | // Build outline from wikitext |
175 | 175 | var outline = []; |
176 | | - var wikitext = '\n' + $.wikiEditor.fixOperaBrokenness( context.$textarea.val() ) + '\n'; |
| 176 | + var wikitext = $.wikiEditor.fixOperaBrokenness( context.$textarea.val() ); |
177 | 177 | var headings = wikitext.match( /^={1,6}.+={1,6}\s*$/gm ); |
178 | 178 | var offset = 0; |
179 | 179 | headings = $.makeArray( headings ); |
180 | 180 | for ( var h = 0; h < headings.length; h++ ) { |
181 | | - text = headings[h]; |
| 181 | + text = $.trim( headings[h] ); |
182 | 182 | // Get position of first occurence |
183 | 183 | var position = wikitext.indexOf( text, offset ); |
184 | 184 | // Update offset to avoid stumbling on duplicate headings |
185 | | - if ( position > offset ) { |
| 185 | + if ( position >= offset ) { |
186 | 186 | offset = position + 1; |
187 | 187 | } else if ( position == -1 ) { |
188 | 188 | // Not sure this is possible, or what should happen |
189 | 189 | continue; |
190 | 190 | } |
191 | | - // Trim off whitespace |
192 | | - text = $.trim( text ); |
| 191 | + |
193 | 192 | // Detect the starting and ending heading levels |
194 | 193 | var startLevel = 0; |
195 | 194 | for ( var c = 0; c < text.length; c++ ) { |
— | — | @@ -237,7 +236,13 @@ |
238 | 237 | if ( $( 'input[name=wpSection]' ).val() == '' ) |
239 | 238 | structure.unshift( { 'text': wgPageName.replace(/_/g, ' '), 'level': 1, 'index': 0, 'position': 0 } ); |
240 | 239 | context.modules.$toc.html( buildList( structure ) ); |
241 | | - context.modules.$toc.find( 'ul a' ).autoEllipse( { 'position': 'right', 'tooltip': true } ); |
| 240 | + |
| 241 | + var links = context.modules.$toc.find( 'ul a' ); |
| 242 | + // Highlighted links are wider; autoEllipse links in |
| 243 | + // highlighted state |
| 244 | + links.addClass( 'currentSelection' ); |
| 245 | + links.autoEllipse( { 'position': 'right', 'tooltip': true } ); |
| 246 | + links.removeClass( 'currentSelection' ); |
242 | 247 | // Cache the outline for later use |
243 | 248 | context.data.outline = outline; |
244 | 249 | } |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -2193,23 +2193,22 @@ |
2194 | 2194 | } |
2195 | 2195 | // Build outline from wikitext |
2196 | 2196 | var outline = []; |
2197 | | - var wikitext = '\n' + $.wikiEditor.fixOperaBrokenness( context.$textarea.val() ) + '\n'; |
| 2197 | + var wikitext = $.wikiEditor.fixOperaBrokenness( context.$textarea.val() ); |
2198 | 2198 | var headings = wikitext.match( /^={1,6}.+={1,6}\s*$/gm ); |
2199 | 2199 | var offset = 0; |
2200 | 2200 | headings = $.makeArray( headings ); |
2201 | 2201 | for ( var h = 0; h < headings.length; h++ ) { |
2202 | | - text = headings[h]; |
| 2202 | + text = $.trim( headings[h] ); |
2203 | 2203 | // Get position of first occurence |
2204 | 2204 | var position = wikitext.indexOf( text, offset ); |
2205 | 2205 | // Update offset to avoid stumbling on duplicate headings |
2206 | | - if ( position > offset ) { |
| 2206 | + if ( position >= offset ) { |
2207 | 2207 | offset = position + 1; |
2208 | 2208 | } else if ( position == -1 ) { |
2209 | 2209 | // Not sure this is possible, or what should happen |
2210 | 2210 | continue; |
2211 | 2211 | } |
2212 | | - // Trim off whitespace |
2213 | | - text = $.trim( text ); |
| 2212 | + |
2214 | 2213 | // Detect the starting and ending heading levels |
2215 | 2214 | var startLevel = 0; |
2216 | 2215 | for ( var c = 0; c < text.length; c++ ) { |
— | — | @@ -2258,7 +2257,13 @@ |
2259 | 2258 | if ( $( 'input[name=wpSection]' ).val() == '' ) |
2260 | 2259 | structure.unshift( { 'text': wgPageName.replace(/_/g, ' '), 'level': 1, 'index': 0, 'position': 0 } ); |
2261 | 2260 | context.modules.$toc.html( buildList( structure ) ); |
2262 | | - context.modules.$toc.find( 'ul a' ).autoEllipse( { 'position': 'right', 'tooltip': true } ); |
| 2261 | + |
| 2262 | + var links = context.modules.$toc.find( 'ul a' ); |
| 2263 | + // Highlighted links are wider; autoEllipse links in |
| 2264 | + // highlighted state |
| 2265 | + links.addClass( 'currentSelection' ); |
| 2266 | + links.autoEllipse( { 'position': 'right', 'tooltip': true } ); |
| 2267 | + links.removeClass( 'currentSelection' ); |
2263 | 2268 | // Cache the outline for later use |
2264 | 2269 | context.data.outline = outline; |
2265 | 2270 | } |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -148,8 +148,8 @@ |
149 | 149 | function buildList(structure){var list=$('<ul />');for(i in structure){var item=$('<li />').append($('<a />').attr('href','#').addClass('section-'+structure[i].index).data('textbox',context.$textarea).data('position',structure[i].position).click(function(event){$(this).data('textbox').setSelection($(this).data('position')).scrollToCaretPosition(true);event.preventDefault();}).text(structure[i].text));if(structure[i].sections!==undefined){item.append(buildList(structure[i].sections));} |
150 | 150 | list.append(item);} |
151 | 151 | return list;} |
152 | | -var outline=[];var wikitext='\n'+$.wikiEditor.fixOperaBrokenness(context.$textarea.val())+'\n';var headings=wikitext.match(/^={1,6}.+={1,6}\s*$/gm);var offset=0;headings=$.makeArray(headings);for(var h=0;h<headings.length;h++){text=headings[h];var position=wikitext.indexOf(text,offset);if(position>offset){offset=position+1;}else if(position==-1){continue;} |
153 | | -text=$.trim(text);var startLevel=0;for(var c=0;c<text.length;c++){if(text.charAt(c)=='='){startLevel++;}else{break;}} |
| 152 | +var outline=[];var wikitext=$.wikiEditor.fixOperaBrokenness(context.$textarea.val());var headings=wikitext.match(/^={1,6}.+={1,6}\s*$/gm);var offset=0;headings=$.makeArray(headings);for(var h=0;h<headings.length;h++){text=$.trim(headings[h]);var position=wikitext.indexOf(text,offset);if(position>=offset){offset=position+1;}else if(position==-1){continue;} |
| 153 | +var startLevel=0;for(var c=0;c<text.length;c++){if(text.charAt(c)=='='){startLevel++;}else{break;}} |
154 | 154 | var endLevel=0;for(var c=text.length-1;c>=0;c--){if(text.charAt(c)=='='){endLevel++;}else{break;}} |
155 | 155 | var level=Math.min(startLevel,endLevel);text=$.trim(text.substr(level,text.length-(level*2)));outline[h]={'text':text,'position':position,'level':level,'index':h+1};} |
156 | 156 | var lastLevel=0;var nLevel=0;for(var i=0;i<outline.length;i++){if(outline[i].level>lastLevel){nLevel++;} |
— | — | @@ -157,4 +157,4 @@ |
158 | 158 | if(nLevel<=0){nLevel=1;} |
159 | 159 | outline[i].nLevel=nLevel;lastLevel=outline[i].level;} |
160 | 160 | var structure=buildStructure(outline);if($('input[name=wpSection]').val()=='') |
161 | | -structure.unshift({'text':wgPageName.replace(/_/g,' '),'level':1,'index':0,'position':0});context.modules.$toc.html(buildList(structure));context.modules.$toc.find('ul a').autoEllipse({'position':'right','tooltip':true});context.data.outline=outline;}}};})(jQuery); |
\ No newline at end of file |
| 161 | +structure.unshift({'text':wgPageName.replace(/_/g,' '),'level':1,'index':0,'position':0});context.modules.$toc.html(buildList(structure));var links=context.modules.$toc.find('ul a');links.addClass('currentSelection');links.autoEllipse({'position':'right','tooltip':true});links.removeClass('currentSelection');context.data.outline=outline;}}};})(jQuery); |
\ No newline at end of file |