Index: trunk/phase3/resources/mediawiki.page/mediawiki.page.ajaxCategories.js |
— | — | @@ -16,17 +16,18 @@ |
17 | 17 | |
18 | 18 | var catLinkWrapper = '<li/>'; |
19 | 19 | var $container = $( '.catlinks' ); |
| 20 | + var $containerNormal = $( '#mw-normal-catlinks' ); |
20 | 21 | |
21 | 22 | var categoryLinkSelector = '#mw-normal-catlinks li a'; |
22 | 23 | var _request; |
23 | 24 | |
24 | 25 | var _catElements = {}; |
25 | 26 | |
26 | | - var namespaceIds = mw.config.get( 'wgNamespaceIds' ) |
| 27 | + var namespaceIds = mw.config.get( 'wgNamespaceIds' ); |
27 | 28 | var categoryNamespaceId = namespaceIds['category']; |
28 | 29 | var categoryNamespace = mw.config.get( 'wgFormattedNamespaces' )[categoryNamespaceId]; |
| 30 | + var _saveAllButton; |
29 | 31 | |
30 | | - |
31 | 32 | /** |
32 | 33 | * Helper function for $.fn.suggestion |
33 | 34 | * |
— | — | @@ -169,23 +170,15 @@ |
170 | 171 | */ |
171 | 172 | _confirmEdit = function ( fn, actionSummary, doneFn, all ) { |
172 | 173 | // Check whether to use multiEdit mode |
173 | | - if ( mw.config.get('AJAXCategoriesMulti') && !all ) { |
| 174 | + if ( wgUserGroups.indexOf("user") != -1 && !all ) { |
174 | 175 | // Stash away |
175 | 176 | _stash.summaries.push( actionSummary ); |
176 | 177 | _stash.fns.push( fn ); |
177 | | - _stash.doneFns.push( doneFn ); |
178 | 178 | |
179 | | - // Make sure we have a save button |
180 | | - if ( !_saveAllButton ) { |
181 | | - //TODO Make more clickable |
182 | | - _saveAllButton = _createButton( 'icon-tick', |
183 | | - mw.msg( 'ajax-confirm-save-all' ), |
184 | | - '', |
185 | | - mw.msg( 'ajax-confirm-save-all' ) |
186 | | - ); |
187 | | - _saveAllButton.click( _handleStashedCategories ); |
188 | | - } |
189 | | - |
| 179 | + _saveAllButton.show(); |
| 180 | + |
| 181 | + // This only does visual changes |
| 182 | + doneFn( true ); |
190 | 183 | return; |
191 | 184 | } |
192 | 185 | // Produce a confirmation dialog |
— | — | @@ -251,22 +244,25 @@ |
252 | 245 | // Save fns |
253 | 246 | fns = _stash.fns; |
254 | 247 | |
255 | | - //TODO do I need a space? |
256 | | - var summary = _stash.summaries.join(' '); |
| 248 | + // RTL? |
| 249 | + var summary = _stash.summaries.join('. '); |
257 | 250 | var combinedFn = function( oldtext ) { |
258 | 251 | // Run the text through all action functions |
259 | 252 | newtext = oldtext; |
260 | 253 | for ( var i = 0; i < fns.length; i++ ) { |
261 | 254 | newtext = fns[i]( newtext ); |
262 | | - }; |
| 255 | + } |
263 | 256 | return newtext; |
264 | 257 | } |
265 | 258 | var doneFn = function() { |
266 | 259 | //Remove saveAllButton |
267 | | - _saveAllButton.remove(); |
268 | | - _saveAllButton = undefined; |
| 260 | + _saveAllButton.hide(); |
| 261 | + |
| 262 | + // TODO |
| 263 | + // Any link with $link.css('text-decoration', 'line-through'); |
| 264 | + // needs to be removed |
269 | 265 | }; |
270 | | - |
| 266 | + _confirmEdit( combinedFn, summary, doneFn, true ); |
271 | 267 | }; |
272 | 268 | |
273 | 269 | _doEdit = function ( page, fn, summary, doneFn ) { |
— | — | @@ -398,7 +394,7 @@ |
399 | 395 | var $link = $this.parent().find( 'a:not(.icon)' ); |
400 | 396 | var category = $link.text(); |
401 | 397 | |
402 | | - categoryRegex = _buildRegex( category ); |
| 398 | + var categoryRegex = _buildRegex( category ); |
403 | 399 | |
404 | 400 | var summary = mw.msg( 'ajax-remove-category-summary', category ); |
405 | 401 | |
— | — | @@ -418,8 +414,13 @@ |
419 | 415 | return newText; |
420 | 416 | }, |
421 | 417 | summary, |
422 | | - function() { |
423 | | - $this.parent().remove(); |
| 418 | + function( unsaved ) { |
| 419 | + if ( unsaved ) { |
| 420 | + //TODO flesh out: Make it a class, make revertable |
| 421 | + $link.css('text-decoration', 'line-through'); |
| 422 | + } else { |
| 423 | + $this.parent().remove(); |
| 424 | + } |
424 | 425 | } |
425 | 426 | ); |
426 | 427 | }; |
— | — | @@ -585,8 +586,6 @@ |
586 | 587 | // Only do it for articles. |
587 | 588 | if ( !mw.config.get( 'wgIsArticle' ) ) return; |
588 | 589 | |
589 | | - var clElement = $( '#mw-normal-catlinks' ); |
590 | | - |
591 | 590 | // Unhide hidden category holders. |
592 | 591 | $('#mw-hidden-catlinks').show(); |
593 | 592 | |
— | — | @@ -597,7 +596,7 @@ |
598 | 597 | mw.msg( 'ajax-add-category' ) |
599 | 598 | ); |
600 | 599 | addLink.click( _handleAddLink ); |
601 | | - clElement.append( addLink ); |
| 600 | + $containerNormal.append( addLink ); |
602 | 601 | |
603 | 602 | // Create add category prompt |
604 | 603 | var promptContainer = _makeSuggestionBox( '', _handleCategoryAdd, mw.msg( 'ajax-add-category-submit' ) ); |
— | — | @@ -608,13 +607,21 @@ |
609 | 608 | _createCatButtons( this ); |
610 | 609 | }); |
611 | 610 | |
612 | | - clElement.append( promptContainer ); |
| 611 | + $containerNormal.append( promptContainer ); |
| 612 | + |
| 613 | + //TODO Make more clickable |
| 614 | + _saveAllButton = _createButton( 'icon-tick', |
| 615 | + mw.msg( 'ajax-confirm-save-all' ), |
| 616 | + '', |
| 617 | + mw.msg( 'ajax-confirm-save-all' ) |
| 618 | + ); |
| 619 | + _saveAllButton.click( _handleStashedCategories ).hide(); |
| 620 | + $containerNormal.append( _saveAllButton ) |
613 | 621 | }; |
614 | 622 | |
615 | 623 | _stash = { |
616 | 624 | summaries : [], |
617 | | - fns : [], |
618 | | - doneFns : [], |
| 625 | + fns : [] |
619 | 626 | }; |
620 | 627 | }; |
621 | 628 | // Now make a new version |