X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.rcfilters%2Fui%2Fmw.rcfilters.ui.CheckboxInputWidget.js;h=9fd459394470e7ccdc1f8163b67ac45f299e2f42;hb=3cb14f56bdf3271769a5866f9dcaad56bf873aea;hp=86b3b11f24dbd0327915834744beeb73468b4c7b;hpb=49748181dd56ec97e7ba7c13e684a16abceb3cc0;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.CheckboxInputWidget.js b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.CheckboxInputWidget.js index 86b3b11f24..9fd4593944 100644 --- a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.CheckboxInputWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.CheckboxInputWidget.js @@ -14,7 +14,16 @@ mw.rcfilters.ui.CheckboxInputWidget.parent.call( this, config ); // Event - this.$input.on( 'change', this.onUserChange.bind( this ) ); + this.$input + // HACK: This widget just pretends to be a checkbox for visual purposes. + // In reality, all actions - setting to true or false, etc - are + // decided by the model, and executed by the controller. This means + // that we want to let the controller and model make the decision + // of whether to check/uncheck this checkboxInputWidget, and for that, + // we have to bypass the browser action that checks/unchecks it during + // click. + .on( 'click', false ) + .on( 'change', this.onUserChange.bind( this ) ); }; /* Initialization */ @@ -32,6 +41,19 @@ /* Methods */ + /** + * @inheritdoc + */ + mw.rcfilters.ui.CheckboxInputWidget.prototype.onEdit = function () { + // Similarly to preventing defaults in 'click' event, we want + // to prevent this widget from deciding anything about its own + // state; it emits a change event and the model and controller + // make a decision about what its select state is. + // onEdit has a widget.$input.prop( 'checked' ) inside a setTimeout() + // so we really want to prevent that from messing with what + // the model decides the state of the widget is. + }; + /** * Respond to checkbox change by a user and emit 'userChange'. */