Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.hooks.php |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | * Intercept the display of the toolbar, replacing the content of $toolbar |
17 | 17 | */ |
18 | 18 | public static function intercept( &$toolbar ) { |
19 | | - global $wgUser, $wgOut, $wgJsMimeType; |
| 19 | + global $wgUser, $wgOut, $wgJsMimeType, $wgRequest; |
20 | 20 | global $wgEditToolbarGlobalEnable, $wgEditToolbarUserEnable; |
21 | 21 | |
22 | 22 | // Checks if... |
— | — | @@ -98,9 +98,17 @@ |
99 | 99 | $messagesList = implode( ',', $messages ); |
100 | 100 | // Encapsulates list in javascript code to set them durring load |
101 | 101 | $messagesJs = "loadGM({{$messagesList}});"; |
| 102 | + |
| 103 | + // Ensure persistency of tabs' show/hide status between submits |
| 104 | + $persistentTabs = array( 'format' ); |
| 105 | + $tabsJs = ""; |
| 106 | + foreach( $persistentTabs as $tab ) |
| 107 | + if( $wgRequest->wasPosted() && $wgRequest->getInt( "ET$tab" ) == 1 ) |
| 108 | + $tabsJs .= "editToolbarConfiguration['$tab'].showInitially = '1';"; |
| 109 | + |
102 | 110 | // Appends javascript message setting code |
103 | 111 | $toolbar .= Xml::element( |
104 | | - 'script', array( 'type' => $wgJsMimeType ), $messagesJs |
| 112 | + 'script', array( 'type' => $wgJsMimeType ), $messagesJs . $tabsJs |
105 | 113 | ); |
106 | 114 | // Continue |
107 | 115 | return true; |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js |
— | — | @@ -81,29 +81,40 @@ |
82 | 82 | .attr( { 'class': 'section', 'id': $(this).attr( 'id' ) + '-section-' + section } ) |
83 | 83 | .appendTo( sectionsDiv ); |
84 | 84 | // Appends toolbar to section div |
85 | | - sectionDiv.addToolbarSection( tools[section], textbox ) |
| 85 | + sectionDiv.addToolbarSection( tools[section], textbox ); |
| 86 | + // Add hidden form field used for show/hide persistency |
| 87 | + if( $( '#ET' + section ).length == 0 ) |
| 88 | + textbox.parent( 'form' ).append( |
| 89 | + $( '<input />' ) |
| 90 | + .attr( { 'type': 'hidden', |
| 91 | + 'id': 'ET' + section, |
| 92 | + 'name': 'ET' + section } ) |
| 93 | + .val( tools[section].showInitially ) |
| 94 | + ); |
| 95 | + var showHideLink = $( '<a />' ) |
| 96 | + .text( tools[section].label || gM( tools[section].labelMsg ) ) |
| 97 | + .attr( { 'href': '#', 'rel': section } ) |
| 98 | + .data( 'sectionDiv', sectionDiv ) |
| 99 | + .click( function() { |
| 100 | + $(this).blur(); |
| 101 | + var show = ( $(this).data( 'sectionDiv' ).css( 'display' ) == 'none' ); |
| 102 | + $(this).data( 'sectionDiv' ).parent().children().hide(); |
| 103 | + $(this).parent().parent().find( 'a' ).removeClass( 'current' ); |
| 104 | + if ( show ) { |
| 105 | + $(this).data( 'sectionDiv' ).show(); |
| 106 | + $(this).addClass( 'current' ); |
| 107 | + } |
| 108 | + $( '#ET' + section ).val( ( show ? '1' : '0' ) ); |
| 109 | + return false; |
| 110 | + }); |
86 | 111 | // Appends section tab |
87 | 112 | tabDiv.append( |
88 | 113 | $( '<div />' ) |
89 | 114 | .attr( 'class', 'tab' ) |
90 | | - .append( |
91 | | - $( '<a />' ) |
92 | | - .text( tools[section].label || gM( tools[section].labelMsg ) ) |
93 | | - .attr( { 'href': '#', 'rel': section } ) |
94 | | - .data( 'sectionDiv', sectionDiv ) |
95 | | - .click( function() { |
96 | | - $(this).blur(); |
97 | | - var show = ( $(this).data( 'sectionDiv' ).css( 'display' ) == 'none' ); |
98 | | - $(this).data( 'sectionDiv' ).parent().children().hide(); |
99 | | - $(this).parent().parent().find( 'a' ).removeClass( 'current' ); |
100 | | - if ( show ) { |
101 | | - $(this).data( 'sectionDiv' ).show(); |
102 | | - $(this).addClass( 'current' ); |
103 | | - } |
104 | | - return false; |
105 | | - }) |
106 | | - ) |
| 115 | + .append( showHideLink ) |
107 | 116 | ); |
| 117 | + if( $( '#ET' + section ).val() != '0' ) |
| 118 | + showHideLink.click(); |
108 | 119 | } |
109 | 120 | }); |
110 | 121 | }, |
— | — | @@ -359,6 +370,7 @@ |
360 | 371 | }, |
361 | 372 | // Format section |
362 | 373 | 'format': { |
| 374 | + showInitially: '0', |
363 | 375 | labelMsg: 'edittoolbar-section-format', |
364 | 376 | groups: { |
365 | 377 | 'heading': { |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | ); |
32 | 32 | |
33 | 33 | // Bump the version number every time you change any of the .css/.js files |
34 | | -$wgEditToolbarStyleVersion = 0; |
| 34 | +$wgEditToolbarStyleVersion = 1; |
35 | 35 | |
36 | 36 | // Set this to true to simply override the stock toolbar for everyone |
37 | 37 | $wgEditToolbarGlobalEnable = false; |