Fix order of @var parameter in PHP
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / ui / CheckboxInputWidget.js
1 ( function () {
2 /**
3 * A widget representing a single toggle filter
4 *
5 * @class mw.rcfilters.ui.CheckboxInputWidget
6 * @extends OO.ui.CheckboxInputWidget
7 *
8 * @constructor
9 * @param {Object} config Configuration object
10 */
11 var CheckboxInputWidget = function MwRcfiltersUiCheckboxInputWidget( config ) {
12 config = config || {};
13
14 // Parent
15 CheckboxInputWidget.parent.call( this, config );
16
17 // Event
18 this.$input
19 // HACK: This widget just pretends to be a checkbox for visual purposes.
20 // In reality, all actions - setting to true or false, etc - are
21 // decided by the model, and executed by the controller. This means
22 // that we want to let the controller and model make the decision
23 // of whether to check/uncheck this checkboxInputWidget, and for that,
24 // we have to bypass the browser action that checks/unchecks it during
25 // click.
26 .on( 'click', false )
27 .on( 'change', this.onUserChange.bind( this ) );
28 };
29
30 /* Initialization */
31
32 OO.inheritClass( CheckboxInputWidget, OO.ui.CheckboxInputWidget );
33
34 /* Events */
35
36 /**
37 * @event userChange
38 * @param {boolean} Current state of the checkbox
39 *
40 * The user has checked or unchecked this checkbox
41 */
42
43 /* Methods */
44
45 /**
46 * @inheritdoc
47 */
48 CheckboxInputWidget.prototype.onEdit = function () {
49 // Similarly to preventing defaults in 'click' event, we want
50 // to prevent this widget from deciding anything about its own
51 // state; it emits a change event and the model and controller
52 // make a decision about what its select state is.
53 // onEdit has a widget.$input.prop( 'checked' ) inside a setTimeout()
54 // so we really want to prevent that from messing with what
55 // the model decides the state of the widget is.
56 };
57
58 /**
59 * Respond to checkbox change by a user and emit 'userChange'.
60 */
61 CheckboxInputWidget.prototype.onUserChange = function () {
62 this.emit( 'userChange', this.$input.prop( 'checked' ) );
63 };
64
65 module.exports = CheckboxInputWidget;
66 }() );