diff options
Diffstat (limited to 'www/wiki/extensions/Translate/resources/js/ext.translate.special.aggregategroups.js')
-rw-r--r-- | www/wiki/extensions/Translate/resources/js/ext.translate.special.aggregategroups.js | 85 |
1 files changed, 40 insertions, 45 deletions
diff --git a/www/wiki/extensions/Translate/resources/js/ext.translate.special.aggregategroups.js b/www/wiki/extensions/Translate/resources/js/ext.translate.special.aggregategroups.js index 77514538..ba9ba5f3 100644 --- a/www/wiki/extensions/Translate/resources/js/ext.translate.special.aggregategroups.js +++ b/www/wiki/extensions/Translate/resources/js/ext.translate.special.aggregategroups.js @@ -1,6 +1,4 @@ -/*global alert:false */ - -( function ( $, mw ) { +( function () { 'use strict'; function getApiParams( $target ) { @@ -20,15 +18,15 @@ } params = $.extend( getApiParams( $target ), { - 'do': 'dissociate', + do: 'dissociate', group: $target.data( 'groupid' ) } ); - // Change to csrf when support for MW 1.25 is dropped - api.postWithToken( 'edit', params ) + api.postWithToken( 'csrf', params ) .done( successFunction ) .fail( function ( code, data ) { - window.alert( data.error && data.error.info ); + // eslint-disable-next-line no-alert + alert( data.error && data.error.info ); } ); } @@ -51,7 +49,7 @@ $a = $( '<a>', aAttr ).text( subgroupName ); spanAttr = { - 'class': 'tp-aggregate-remove-button', + class: 'tp-aggregate-remove-button', 'data-groupid': subgroupId }; @@ -73,17 +71,18 @@ if ( subgroupId ) { params = $.extend( getApiParams( $target ), { - 'do': 'associate', + do: 'associate', group: subgroupId } ); - // Change to csrf when support for MW 1.25 is dropped - api.postWithToken( 'edit', params ) + api.postWithToken( 'csrf', params ) .done( successFunction ) .fail( function ( code, data ) { - window.alert( data.error && data.error.info ); + // eslint-disable-next-line no-alert + alert( data.error && data.error.info ); } ); } else { + // eslint-disable-next-line no-alert alert( mw.msg( 'tpt-invalid-group' ) ); } } @@ -99,16 +98,17 @@ // XXX: 'confirm' is nonstandard. if ( $.isFunction( window.confirm ) && + // eslint-disable-next-line no-alert window.confirm( mw.msg( 'tpt-aggregategroup-remove-confirm' ) ) ) { params = $.extend( getApiParams( $target ), { - 'do': 'remove' + do: 'remove' } ); - // Change to csrf when support for MW 1.25 is dropped - api.postWithToken( 'edit', params ) + api.postWithToken( 'csrf', params ) .done( successFunction ) .fail( function ( code, data ) { - window.alert( data.error && data.error.info ); + // eslint-disable-next-line no-alert + alert( data.error && data.error.info ); } ); } } @@ -116,7 +116,7 @@ function editGroup( event ) { var $target = $( event.target ), $parent = $target.closest( '.mw-tpa-group' ), - aggregateGroupId = $parent.data( 'groupid' ), + aggregateGroupId = $parent.data( 'groupid' ), $displayGroup = $parent.children( '.tp-display-group' ), $editGroup = $parent.children( '.tp-edit-group' ), successFunction, @@ -139,18 +139,17 @@ params = { action: 'aggregategroups', - 'do': 'update', + do: 'update', groupname: aggregateGroupName, groupdescription: aggregateGroupDesc, - aggregategroup: aggregateGroupId, - format: 'json' + aggregategroup: aggregateGroupId }; - // Change to csrf when support for MW 1.25 is dropped - api.postWithToken( 'edit', params ) + api.postWithToken( 'csrf', params ) .done( successFunction ) .fail( function ( code, data ) { - window.alert( data.error.info ); + // eslint-disable-next-line no-alert + alert( data.error.info ); } ); } @@ -161,7 +160,7 @@ $parent.children( '.tp-edit-group' ).addClass( 'hidden' ); } - $( document ).ready( function () { + $( function () { var excludeFunction, autocompleteFunction, resp, api = new mw.Api(), exclude = [], @@ -175,7 +174,6 @@ // Get list of subgroups using API api.get( { action: 'query', - format: 'json', meta: 'messagegroups', mgformat: 'tree', mgroot: 'all', @@ -191,7 +189,7 @@ // Need to trim to remove the trailing whitespace // Can't use innerText not supported by Firefox var groupName = $( data ).text(); - groupName = $.trim( groupName ); + groupName = groupName.trim(); exclude.push( groupName ); } ); @@ -271,27 +269,25 @@ .append( $displayHeader ) .append( $( '<p>' ).addClass( 'tp-desc' ).text( aggregateGroupDesc ) ); - $saveButton = ( $( '<input>' ) + $saveButton = $( '<input>' ) .attr( { type: 'button', - 'class': 'tp-aggregategroup-update' + class: 'tp-aggregategroup-update' } ) - .val( mw.msg( 'tpt-aggregategroup-update' ) ) - ); - $cancelButton = ( $( '<input>' ) + .val( mw.msg( 'tpt-aggregategroup-update' ) ); + $cancelButton = $( '<input>' ) .attr( { type: 'button', - 'class': 'tp-aggregategroup-update-cancel' + class: 'tp-aggregategroup-update-cancel' } ) - .val( mw.msg( 'tpt-aggregategroup-update-cancel' ) ) - ); + .val( mw.msg( 'tpt-aggregategroup-update-cancel' ) ); $divEdit = $( '<div>' ) .addClass( 'tp-edit-group hidden' ) .append( $( '<label>' ) .text( mw.msg( 'tpt-aggregategroup-edit-name' ) ) ) .append( $( '<input>' ) .attr( { - 'class': 'tp-aggregategroup-edit-name', + class: 'tp-aggregategroup-edit-name', id: 'tp-agg-name' } ) .val( aggregateGroupName ) @@ -300,7 +296,7 @@ .text( mw.msg( 'tpt-aggregategroup-edit-description' ) ) ) .append( $( '<input>' ) .attr( { - 'class': 'tp-aggregategroup-edit-description', + class: 'tp-aggregategroup-edit-description', id: 'tp-agg-desc' } ) .val( aggregateGroupDesc ) @@ -316,7 +312,7 @@ $groupSelector = $( '<input>' ).attr( { type: 'text', - 'class': 'tp-group-input' + class: 'tp-group-input' } ); $groupSelector.focus( excludeFunction ); $groupSelector.autocomplete( { @@ -329,7 +325,7 @@ $addButton = $( '<input>' ) .attr( { type: 'button', - 'class': 'tp-aggregate-add-button', + class: 'tp-aggregate-add-button', id: aggregateGroupId } ) .val( mw.msg( 'tpt-aggregategroup-add' ) ); @@ -352,18 +348,17 @@ params = { action: 'aggregategroups', - 'do': 'add', + do: 'add', groupname: aggregateGroupName, - groupdescription: aggregateGroupDesc, - format: 'json' + groupdescription: aggregateGroupDesc }; - // Change to csrf when support for MW 1.25 is dropped - api.postWithToken( 'edit', params ) + api.postWithToken( 'csrf', params ) .done( successFunction ) .fail( function ( code, data ) { - window.alert( data.error && data.error.info ); + // eslint-disable-next-line no-alert + alert( data.error && data.error.info ); } ); } ); } ); -}( jQuery, mediaWiki ) ); +}() ); |