'ajax-remove-category' => 'Remove category',
'ajax-edit-category' => 'Edit category',
'ajax-add-category-submit' => 'Add',
+'ajax-confirm-ok' => 'OK',
'ajax-confirm-title' => 'Confirm action',
'ajax-confirm-prompt' => 'You can provide an edit summary below.
Click "Save" to save your edit.',
'ajax-confirm-save' => 'Save',
'ajax-confirm-save-all' => 'Save all changes',
+'ajax-cancel' => 'Cancel edits',
'ajax-add-category-summary' => 'Add category "$1"',
'ajax-edit-category-summary' => 'Change category "$1" to "$2"',
'ajax-remove-category-summary' => 'Remove category "$1"',
// * Add Hooks for soft redirect
// * Handle normal redirects
+// * Fixme on narrow windows
+// * Enter to submit
( function( $, mw ) {
var categoryNamespaceId = namespaceIds['category'];
var categoryNamespace = mw.config.get( 'wgFormattedNamespaces' )[categoryNamespaceId];
var _saveAllButton;
+ var _cancelAllButton;
+ var _multiEdit = ( wgUserGroups.indexOf("user") != -1 );
/**
* Helper function for $.fn.suggestion
*/
_confirmEdit = function ( fn, actionSummary, doneFn, all ) {
// Check whether to use multiEdit mode
- if ( wgUserGroups.indexOf("user") != -1 && !all ) {
+ if ( _multiEdit && !all ) {
// Stash away
_stash.summaries.push( actionSummary );
_stash.fns.push( fn );
+ //TODO add Cancel button
_saveAllButton.show();
-
+ //_cancelAllButton.show();
+
// This only does visual changes
doneFn( true );
return;
}
return newtext;
};
- var doneFn = function() {
- //Remove saveAllButton
- _saveAllButton.hide();
-
- // Clean stash
- _stash.fns = [];
- _stash.summaries = [];
+ var doneFn = _resetToActual;
- // TODO
- // Any link with $link.css('text-decoration', 'line-through');
- // needs to be removed
- };
_confirmEdit( combinedFn, summary, doneFn, true );
};
+ _resetToActual = function() {
+ //Remove saveAllButton
+ _saveAllButton.hide();
+ _cancelAllButton.hide();
+
+ // Clean stash
+ _stash.fns = [];
+ _stash.summaries = [];
+
+ // TODO
+ $container.find('.mw-removed-category').parent().remove();
+ // Any link with $link.css('text-decoration', 'line-through');
+ // needs to be removed
+
+ };
+
_doEdit = function ( page, fn, summary, doneFn ) {
// Get an edit token for the page.
var getTokenVars = {
var $link = $this.parent().find( 'a:not(.icon)' );
var category = $link.text();
- var $input = _makeSuggestionBox( category, _handleCategoryEdit, mw.msg( 'ajax-confirm-save' ) );
+ var $input = _makeSuggestionBox( category,
+ _handleCategoryEdit,
+ _multiEdit ? mw.msg( 'ajax-confirm-ok' ) : mw.msg( 'ajax-confirm-save' )
+ );
$link.after( $input ).hide();
_catElements[category].editButton.hide();
_catElements[category].deleteButton.unbind('click').click( function() {
summary,
function( unsaved ) {
if ( unsaved ) {
- //TODO flesh out: Make it a class, make revertable
- $link.css('text-decoration', 'line-through');
+ //TODO Make revertable
+ $link.addClass('.mw-removed-category');
} else {
$this.parent().remove();
}
category = $.ucFirst( category );
if ( _containsCat(category) ) {
- _showError( mw.msg( 'ajax-category-already-present' ) );
+ _showError( mw.msg( 'ajax-category-already-present', category ) );
return;
}
var appendText = "\n[[" + categoryNamespace + ":" + category + "]]\n";
};
_handleCategoryEdit = function ( e ) {
+ //FIXME: in MultiEdit Mode handle successive edits to same category
e.preventDefault();
// Grab category text
var $link = $this.parent().parent().find( 'a:not(.icon)' );
var category = $link.text();
- // User didn't change anything. Just close the box
+ // User didn't change anything.
if ( category == categoryNew ) {
- $this.parent().remove();
- $link.show();
+ _catElements[category].deleteButton.click();
return;
}
categoryRegex = _buildRegex( category );
summary,
function() {
// Remove input box & button
- $this.parent().remove();
-
+ _catElements[category].deleteButton.click();
+ _catElements[categoryNew] = _catElements[category];
+ delete _catElements[category];
// Update link text and href
$link.show().text( categoryNew ).attr( 'href', _catLink( categoryNew ) );
}
'',
mw.msg( 'ajax-confirm-save-all' )
);
+ _cancelAllButton = _createButton( 'icon-tick',
+ mw.msg( 'ajax-confirm-save-all' ),
+ '',
+ mw.msg( 'ajax-confirm-save-all' )
+ );
_saveAllButton.click( _handleStashedCategories ).hide();
- $containerNormal.append( _saveAllButton );
+ _cancelAllButton.hide();
+
+ $containerNormal.append( _saveAllButton ).append( _cancelAllButton );
};
_stash = {