r92164 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92163‎ | r92164 | r92165 >
Date:16:00, 14 July 2011
Author:diebuche
Status:deferred (Comments)
Tags:
Comment:
AjaxCategories: Yay! MultiEdit mode working. May need more polish. Ping r92112
Modified paths:
  • /trunk/phase3/resources/mediawiki.page/mediawiki.page.ajaxCategories.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki.page/mediawiki.page.ajaxCategories.js
@@ -16,17 +16,18 @@
1717
1818 var catLinkWrapper = '<li/>';
1919 var $container = $( '.catlinks' );
 20+ var $containerNormal = $( '#mw-normal-catlinks' );
2021
2122 var categoryLinkSelector = '#mw-normal-catlinks li a';
2223 var _request;
2324
2425 var _catElements = {};
2526
26 - var namespaceIds = mw.config.get( 'wgNamespaceIds' )
 27+ var namespaceIds = mw.config.get( 'wgNamespaceIds' );
2728 var categoryNamespaceId = namespaceIds['category'];
2829 var categoryNamespace = mw.config.get( 'wgFormattedNamespaces' )[categoryNamespaceId];
 30+ var _saveAllButton;
2931
30 -
3132 /**
3233 * Helper function for $.fn.suggestion
3334 *
@@ -169,23 +170,15 @@
170171 */
171172 _confirmEdit = function ( fn, actionSummary, doneFn, all ) {
172173 // Check whether to use multiEdit mode
173 - if ( mw.config.get('AJAXCategoriesMulti') && !all ) {
 174+ if ( wgUserGroups.indexOf("user") != -1 && !all ) {
174175 // Stash away
175176 _stash.summaries.push( actionSummary );
176177 _stash.fns.push( fn );
177 - _stash.doneFns.push( doneFn );
178178
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 );
190183 return;
191184 }
192185 // Produce a confirmation dialog
@@ -251,22 +244,25 @@
252245 // Save fns
253246 fns = _stash.fns;
254247
255 - //TODO do I need a space?
256 - var summary = _stash.summaries.join(' ');
 248+ // RTL?
 249+ var summary = _stash.summaries.join('. ');
257250 var combinedFn = function( oldtext ) {
258251 // Run the text through all action functions
259252 newtext = oldtext;
260253 for ( var i = 0; i < fns.length; i++ ) {
261254 newtext = fns[i]( newtext );
262 - };
 255+ }
263256 return newtext;
264257 }
265258 var doneFn = function() {
266259 //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
269265 };
270 -
 266+ _confirmEdit( combinedFn, summary, doneFn, true );
271267 };
272268
273269 _doEdit = function ( page, fn, summary, doneFn ) {
@@ -398,7 +394,7 @@
399395 var $link = $this.parent().find( 'a:not(.icon)' );
400396 var category = $link.text();
401397
402 - categoryRegex = _buildRegex( category );
 398+ var categoryRegex = _buildRegex( category );
403399
404400 var summary = mw.msg( 'ajax-remove-category-summary', category );
405401
@@ -418,8 +414,13 @@
419415 return newText;
420416 },
421417 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+ }
424425 }
425426 );
426427 };
@@ -585,8 +586,6 @@
586587 // Only do it for articles.
587588 if ( !mw.config.get( 'wgIsArticle' ) ) return;
588589
589 - var clElement = $( '#mw-normal-catlinks' );
590 -
591590 // Unhide hidden category holders.
592591 $('#mw-hidden-catlinks').show();
593592
@@ -597,7 +596,7 @@
598597 mw.msg( 'ajax-add-category' )
599598 );
600599 addLink.click( _handleAddLink );
601 - clElement.append( addLink );
 600+ $containerNormal.append( addLink );
602601
603602 // Create add category prompt
604603 var promptContainer = _makeSuggestionBox( '', _handleCategoryAdd, mw.msg( 'ajax-add-category-submit' ) );
@@ -608,13 +607,21 @@
609608 _createCatButtons( this );
610609 });
611610
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 )
613621 };
614622
615623 _stash = {
616624 summaries : [],
617 - fns : [],
618 - doneFns : [],
 625+ fns : []
619626 };
620627 };
621628 // Now make a new version

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r92112Rewrite ajaxCategories for ResourceLoader. Add some missing functionality (ed...diebuche22:36, 13 July 2011

Comments

#Comment by Krinkle (talk | contribs)   20:55, 3 October 2011

AjaxCategories moved out of core. Marking deferred for now.

Status & tagging log