Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | // Checks if main section is in the structure |
20 | 20 | if ( 'main' in tools ) { |
21 | 21 | // Adds main section to toolbar |
22 | | - $(this).addToolbarSection( tools.main, textbox ); |
| 22 | + $(this).addToolbarSection( tools.main, textbox, 'main' ); |
23 | 23 | } |
24 | 24 | // Appends additional section tabs |
25 | 25 | var tabDiv = $( '<div />' ) |
— | — | @@ -97,7 +97,7 @@ |
98 | 98 | $.eachAsync( sectionQueue, { |
99 | 99 | bulk: 0, |
100 | 100 | loop: function( index, value ) { |
101 | | - value.sectionDiv.addToolbarSection( value.tools, value.textbox ); |
| 101 | + value.sectionDiv.addToolbarSection( value.tools, value.textbox, index ); |
102 | 102 | value.sectionDiv.removeClass( 'loading' ) |
103 | 103 | } |
104 | 104 | } ) |
— | — | @@ -107,8 +107,9 @@ |
108 | 108 | * Adds a toolbar section to a containing div |
109 | 109 | * @param {Object} section Section data to build toolbar from |
110 | 110 | * @param {Object} textbox |
| 111 | + * @param {String} section ID (used for cookies) |
111 | 112 | */ |
112 | | - addToolbarSection: function( section, textbox ) { |
| 113 | + addToolbarSection: function( section, textbox, id ) { |
113 | 114 | // Path to images (THIS WILL HAVE TO CHANGE IF YOU MOVE THIS INTO CORE) |
114 | 115 | var imagePath = wgScriptPath + |
115 | 116 | '/extensions/UsabilityInitiative/EditToolbar/images/'; |
— | — | @@ -212,25 +213,29 @@ |
213 | 214 | var indexDiv = $( '<div />' ) |
214 | 215 | .attr( 'class', 'index' ) |
215 | 216 | .appendTo( $(this) ); |
216 | | - // THIS SHOULD BE REPLACED WITH SOMETHING THAT USES A COOKIE |
217 | | - // TO DETECT THE STATE OF THE LAST VIEW |
218 | | - var first = true; |
| 217 | + |
| 218 | + var bookletCookie = 'edittoolbar-' + $(this).attr( 'id' ) + '-booklet-' + id; |
| 219 | + var selectedID = $.cookie( bookletCookie ); |
| 220 | + |
219 | 221 | // Loops over each page |
220 | 222 | for ( page in section.pages ) { |
221 | 223 | // Appends index entry |
222 | 224 | indexDiv.append( |
223 | 225 | $( '<div />' ) |
224 | | - .attr( 'class', first ? 'current' : null ) |
| 226 | + .attr( 'class', page == selectedID ? 'current' : null ) |
225 | 227 | .text( msg( section.pages[page], 'label' ) ) |
226 | 228 | .data( 'page', page ) |
| 229 | + .data( 'cookie', bookletCookie ) |
227 | 230 | .click( function() { |
228 | 231 | $(this).parent().parent().find( 'div.pages > div.page' ).hide(); |
229 | 232 | $(this).parent().find( 'div' ).removeClass( 'current' ); |
230 | 233 | $(this).parent().parent().find( 'div.pages > div.page-' + $(this).data( 'page' ) ).show(); |
231 | 234 | $(this).addClass( 'current' ); |
| 235 | + |
| 236 | + // Update cookie |
| 237 | + $.cookie( $(this).data( 'cookie'), $(this).data( 'page' ) ); |
232 | 238 | } ) |
233 | 239 | ); |
234 | | - first = false; |
235 | 240 | } |
236 | 241 | var pagesDiv = $( '<div />' ) |
237 | 242 | .attr( 'class', 'pages' ) |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | /* Configuration */ |
20 | 20 | |
21 | 21 | // Bump the version number every time you change any of the .css/.js files |
22 | | -$wgEditToolbarStyleVersion = 6; |
| 22 | +$wgEditToolbarStyleVersion = 7; |
23 | 23 | |
24 | 24 | // Set this to true to simply override the stock toolbar for everyone |
25 | 25 | $wgEditToolbarGlobalEnable = false; |
Index: trunk/extensions/UsabilityInitiative/OptIn/SpecialOptIn.php |
— | — | @@ -25,7 +25,6 @@ |
26 | 26 | } |
27 | 27 | |
28 | 28 | if ( $wgRequest->wasPosted() ) { |
29 | | - // Is the weak comparison intentional? |
30 | 29 | if ( $wgRequest->getVal( 'opt' ) == 'in' ) { |
31 | 30 | $this->optIn( $wgUser ); |
32 | 31 | $wgOut->addWikiMsg( 'optin-success-in' ); |