Page MenuHomePhabricator
Paste P2475

(An Untitled Masterwork)
ActivePublic

Authored by lfaraone on Jan 14 2016, 7:51 PM.
/*!
* Toggler for a list of checkboxes.
*
* @licence GNU GPL v2 or later
* @author Luke Faraone <luke at faraone dot cc>
* Based on `ext.nuke.js from https://www.mediawiki.org/wiki/Extension:Nuke by Jeroen De Dauw <jeroendedauw at gmail dot com>
*/
( function ( mw, $ ) {
'use strict';
var $checkboxes = $( 'li input[type=checkbox]' );
var $toggleOptions = mw.message('log-checkbox-select', [
$( '<a>' )
.text( mw.msg( 'log-checkbox-all' ) )
.click( function (e) {
selectAll( true );
e.preventDefault();
} ),
mw.msg( "comma-separator" ),
$( '<a>' )
.text( mw.msg( 'log-checkbox-none' ) )
.click( function (e) {
selectAll( false );
e.preventDefault();
} ),
mw.msg( "comma-separator" ),
$( '<a>' )
.text( mw.msg( 'log-checkbox-invert' ) )
.click( function (e) {
$checkboxes.each( function () {
$( this ).prop( 'checked', !$( this ).is( ':checked' ) );
} );
e.preventDefault();
} )
]).parseDom()
$ ( '.toggle-option-placeholder' ).append(
$( '<p>' ).append($toggleOptions)
);
function selectAll( check ) {
$checkboxes.prop( 'checked', check );
}
}( mediaWiki, jQuery ) );

Event Timeline

lfaraone updated the paste's language from autodetect to js.Jan 14 2016, 7:51 PM
lfaraone edited the content of this paste. (Show Details)