| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
( function () { |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
mw.widgets.ComplexTitleInputWidget = function MwWidgetsComplexTitleInputWidget( config ) { |
| 23 |
|
| 24 |
mw.widgets.ComplexTitleInputWidget.super.call( this, config ); |
| 25 |
|
| 26 |
|
| 27 |
this.namespace = new mw.widgets.NamespaceInputWidget( config.namespace ); |
| 28 |
this.title = new mw.widgets.TitleInputWidget( Object.assign( |
| 29 |
{}, |
| 30 |
config.title, |
| 31 |
{ |
| 32 |
relative: true, |
| 33 |
namespace: config.namespace.value || null |
| 34 |
} |
| 35 |
) ); |
| 36 |
|
| 37 |
|
| 38 |
this.namespace.connect( this, { change: 'updateTitleNamespace' } ); |
| 39 |
|
| 40 |
|
| 41 |
this.$element |
| 42 |
.addClass( 'mw-widget-complexTitleInputWidget' ) |
| 43 |
.append( |
| 44 |
this.namespace.$element, |
| 45 |
this.title.$element |
| 46 |
); |
| 47 |
this.updateTitleNamespace(); |
| 48 |
}; |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
OO.inheritClass( mw.widgets.ComplexTitleInputWidget, OO.ui.Widget ); |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
mw.widgets.ComplexTitleInputWidget.static.reusePreInfuseDOM = function ( node, config ) { |
| 60 |
config = mw.widgets.ComplexTitleInputWidget.super.static.reusePreInfuseDOM( node, config ); |
| 61 |
config.namespace = mw.widgets.NamespaceInputWidget.static.reusePreInfuseDOM( |
| 62 |
$( node ).find( '.mw-widget-namespaceInputWidget' ), |
| 63 |
config.namespace |
| 64 |
); |
| 65 |
config.title = mw.widgets.TitleInputWidget.static.reusePreInfuseDOM( |
| 66 |
$( node ).find( '.mw-widget-titleInputWidget' ), |
| 67 |
config.title |
| 68 |
); |
| 69 |
return config; |
| 70 |
}; |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
mw.widgets.ComplexTitleInputWidget.static.gatherPreInfuseState = function ( node, config ) { |
| 76 |
const state = mw.widgets.ComplexTitleInputWidget.super.static.gatherPreInfuseState( node, config ); |
| 77 |
state.namespace = mw.widgets.NamespaceInputWidget.static.gatherPreInfuseState( |
| 78 |
$( node ).find( '.mw-widget-namespaceInputWidget' ), |
| 79 |
config.namespace |
| 80 |
); |
| 81 |
state.title = mw.widgets.TitleInputWidget.static.gatherPreInfuseState( |
| 82 |
$( node ).find( '.mw-widget-titleInputWidget' ), |
| 83 |
config.title |
| 84 |
); |
| 85 |
return state; |
| 86 |
}; |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
mw.widgets.ComplexTitleInputWidget.prototype.updateTitleNamespace = function () { |
| 95 |
this.title.setNamespace( Number( this.namespace.getValue() ) ); |
| 96 |
}; |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
mw.widgets.ComplexTitleInputWidget.prototype.restorePreInfuseState = function ( state ) { |
| 102 |
mw.widgets.ComplexTitleInputWidget.super.prototype.restorePreInfuseState.call( this, state ); |
| 103 |
this.namespace.restorePreInfuseState( state.namespace ); |
| 104 |
this.title.restorePreInfuseState( state.title ); |
| 105 |
}; |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
mw.widgets.ComplexTitleInputWidget.prototype.setDisabled = function ( disabled ) { |
| 111 |
mw.widgets.ComplexTitleInputWidget.super.prototype.setDisabled.call( this, disabled ); |
| 112 |
if ( this.namespace ) { |
| 113 |
this.namespace.setDisabled( disabled ); |
| 114 |
} |
| 115 |
|
| 116 |
if ( this.title ) { |
| 117 |
this.title.setDisabled( disabled ); |
| 118 |
} |
| 119 |
return this; |
| 120 |
}; |
| 121 |
|
| 122 |
}() ); |