mw.widgets.ComplexTitleInputWidget: Add infusion helpers
authorBartosz Dziewoński <matma.rex@gmail.com>
Thu, 1 Oct 2015 23:30:52 +0000 (01:30 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Tue, 3 Nov 2015 22:45:11 +0000 (22:45 +0000)
* reusePreInfuseDOM
* gatherPreInfuseState
* restorePreInfuseState

Depends on I3c21b3710d16dbb4dbcbdd3871a70fdfd0e7b536 in OOjs UI.

Bug: T114134
Bug: T117310
Change-Id: I939551579fe1d03603d65b3562c1c977681994a6

resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.js

index 0c6c15e..ddae9b1 100644 (file)
 
        OO.inheritClass( mw.widgets.ComplexTitleInputWidget, OO.ui.Widget );
 
+       /* Static Methods */
+       /*jshint -W024*/
+
+       /**
+        * @inheritdoc
+        */
+       mw.widgets.ComplexTitleInputWidget.static.reusePreInfuseDOM = function ( node, config ) {
+               config = mw.widgets.ComplexTitleInputWidget.parent.static.reusePreInfuseDOM( node, config );
+               config.namespace = mw.widgets.NamespaceInputWidget.static.reusePreInfuseDOM(
+                       $( node ).find( '.mw-widget-namespaceInputWidget' ),
+                       config.namespace
+               );
+               config.title = mw.widgets.TitleInputWidget.static.reusePreInfuseDOM(
+                       $( node ).find( '.mw-widget-titleInputWidget' ),
+                       config.title
+               );
+               return config;
+       };
+
+       /**
+        * @inheritdoc
+        */
+       mw.widgets.ComplexTitleInputWidget.static.gatherPreInfuseState = function ( node, config ) {
+               var state = mw.widgets.ComplexTitleInputWidget.parent.static.gatherPreInfuseState( node, config );
+               state.namespace = mw.widgets.NamespaceInputWidget.static.gatherPreInfuseState(
+                       $( node ).find( '.mw-widget-namespaceInputWidget' ),
+                       config.namespace
+               );
+               state.title = mw.widgets.TitleInputWidget.static.gatherPreInfuseState(
+                       $( node ).find( '.mw-widget-titleInputWidget' ),
+                       config.title
+               );
+               return state;
+       };
+
+       /*jshint +W024*/
+
        /* Methods */
 
        /**
                this.title.setNamespace( Number( this.namespace.getValue() ) );
        };
 
+       /**
+        * @inheritdoc
+        */
+       mw.widgets.ComplexTitleInputWidget.prototype.restorePreInfuseState = function ( state ) {
+               mw.widgets.ComplexTitleInputWidget.parent.prototype.restorePreInfuseState.call( this, state );
+               this.namespace.restorePreInfuseState( state.namespace );
+               this.title.restorePreInfuseState( state.title );
+       };
+
 }( jQuery, mediaWiki ) );