Index: trunk/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.js |
— | — | @@ -1,5 +1,26 @@ |
2 | 2 | /* JavaScript for NavigableTOC extension */ |
3 | 3 | |
| 4 | +/* |
| 5 | + * This function should be called on the text area to map out the section |
| 6 | + * character positions by scanning for headings, and the resulting data will |
| 7 | + * be stored as $(this).data( 'sections', { ... } ) |
| 8 | + */ |
| 9 | +jQuery.fn.mapSections = function() { |
| 10 | + return this.each( function() { |
| 11 | + // WRITE CODE HERE :) |
| 12 | + } ); |
| 13 | +}; |
| 14 | +/* |
| 15 | + * This function should be called on the text area with a selected UL element |
| 16 | + * to perform the list update on, where it will match the current cursor |
| 17 | + * position to an item on the outline and classify that li as 'current' |
| 18 | + */ |
| 19 | +jQuery.fn.updateSectionsList = function( list ) { |
| 20 | + return this.each( function( list ) { |
| 21 | + // WRITE CODE HERE :) |
| 22 | + } ); |
| 23 | +}; |
| 24 | + |
4 | 25 | $( document ).ready( function() { |
5 | 26 | if ( $.section == '' ) { |
6 | 27 | // Full page edit |
— | — | @@ -18,17 +39,16 @@ |
19 | 40 | } |
20 | 41 | // Unlink all section links that didn't get an offset |
21 | 42 | $( '.toc:last * li' ).each( function() { |
22 | | - link = $(this).children( 'a' ); |
23 | | - if ( typeof link.data( 'offset') == 'undefined' && |
24 | | - link.is( ':visible' ) ) { |
| 43 | + link = $(this).children( 'a:visible' ); |
| 44 | + if ( typeof link.data( 'offset') == 'undefined' ) { |
25 | 45 | link.hide(); |
26 | 46 | $(this).prepend( link.html() ); |
27 | 47 | } |
28 | 48 | }); |
29 | 49 | |
30 | 50 | $( '.toc:last * li a' ).click( function(e) { |
31 | | - if( typeof jQuery(this).data( 'offset' ) != 'undefined' ) |
32 | | - jQuery( '#wpTextbox1' ).scrollToPosition( jQuery(this).data( 'offset' ) ); |
| 51 | + if( typeof $(this).data( 'offset' ) != 'undefined' ) |
| 52 | + $( '#wpTextbox1' ).scrollToPosition( $(this).data( 'offset' ) ); |
33 | 53 | e.preventDefault(); |
34 | 54 | }); |
35 | 55 | |
— | — | @@ -54,5 +74,4 @@ |
55 | 75 | // This is ugly as hell |
56 | 76 | setTimeout(styleCurrentSection, 0); |
57 | 77 | }); |
58 | | - |
59 | 78 | }); |