Merge "Improve logging of exceptions which are not thrown but attached to context"
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / ui / mw.rcfilters.ui.FormWrapperWidget.js
1 ( function ( mw ) {
2 /**
3 * Wrapper for the RC form with hide/show links
4 *
5 * @extends OO.ui.Widget
6 *
7 * @constructor
8 * @param {mw.rcfilters.dm.ChangesListViewModel} model Changes list view model
9 * @param {jQuery} $formRoot Root element of the form to attach to
10 * @param {Object} config Configuration object
11 */
12 mw.rcfilters.ui.FormWrapperWidget = function MwRcfiltersUiFormWrapperWidget( model, $formRoot, config ) {
13 config = config || {};
14
15 // Parent
16 mw.rcfilters.ui.FormWrapperWidget.parent.call( this, $.extend( {}, config, {
17 $element: $formRoot
18 } ) );
19
20 this.model = model;
21 this.$submitButton = this.$element.find( 'input[type=submit]' );
22
23 // Events
24 this.model.connect( this, {
25 invalidate: 'onModelInvalidate',
26 update: 'onModelUpdate'
27 } );
28 };
29
30 /* Initialization */
31
32 OO.inheritClass( mw.rcfilters.ui.FormWrapperWidget, OO.ui.Widget );
33
34 /**
35 * Respond to model invalidate
36 */
37 mw.rcfilters.ui.FormWrapperWidget.prototype.onModelInvalidate = function () {
38 this.$submitButton.prop( 'disabled', true );
39 };
40
41 /**
42 * Respond to model update
43 */
44 mw.rcfilters.ui.FormWrapperWidget.prototype.onModelUpdate = function () {
45 this.$submitButton.prop( 'disabled', false );
46 };
47 }( mediaWiki ) );