Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/123890

Change subject: WIP Use new ve.ui.Dialogs and ve.ui.Inspectors
......................................................................

WIP Use new ve.ui.Dialogs and ve.ui.Inspectors

Depends on Idd78bf9e4d5 in core.

Also move various bits of code from initialize to setup.

WIP-ness: Image dialogs broken as we need to rebase on scalable
commit which moves everything to the DM.

Change-Id: I0fae3e5ff2bd0da5b74c244af226b07b1f5883bd
---
M modules/ve-mw/ui/dialogs/ve.ui.MWBetaWelcomeDialog.js
M modules/ve-mw/ui/dialogs/ve.ui.MWCitationDialog.js
M modules/ve-mw/ui/dialogs/ve.ui.MWCommandHelpDialog.js
M modules/ve-mw/ui/dialogs/ve.ui.MWMediaEditDialog.js
M modules/ve-mw/ui/dialogs/ve.ui.MWMediaInsertDialog.js
M modules/ve-mw/ui/dialogs/ve.ui.MWMetaDialog.js
M modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js
M modules/ve-mw/ui/dialogs/ve.ui.MWReferenceListDialog.js
M modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js
M modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js
M modules/ve-mw/ui/inspectors/ve.ui.MWAlienExtensionInspector.js
M modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js
M modules/ve-mw/ui/inspectors/ve.ui.MWGalleryInspector.js
M modules/ve-mw/ui/inspectors/ve.ui.MWHieroInspector.js
M modules/ve-mw/ui/inspectors/ve.ui.MWLanguageInspector.js
M modules/ve-mw/ui/inspectors/ve.ui.MWLinkInspector.js
M modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js
M modules/ve-mw/ui/pages/ve.ui.MWCategoriesPage.js
M modules/ve-mw/ui/pages/ve.ui.MWSettingsPage.js
M modules/ve-mw/ui/ve.ui.MWDialog.js
M modules/ve-mw/ui/widgets/ve.ui.MWReferenceSearchWidget.js
21 files changed, 149 insertions(+), 152 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/90/123890/1

diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWBetaWelcomeDialog.js 
b/modules/ve-mw/ui/dialogs/ve.ui.MWBetaWelcomeDialog.js
index 464c8ac..72bb8ed 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWBetaWelcomeDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWBetaWelcomeDialog.js
@@ -13,15 +13,14 @@
  * @extends ve.ui.MWDialog
  *
  * @constructor
- * @param {ve.ui.Surface} surface Surface dialog is for
  * @param {Object} [config] Configuration options
  */
-ve.ui.MWBetaWelcomeDialog = function VeUiMWBetaWelcomeDialog( surface, config 
) {
+ve.ui.MWBetaWelcomeDialog = function VeUiMWBetaWelcomeDialog( config ) {
        // Configuration initialization
        config = ve.extendObject( { 'size': 'medium', 'footless': false }, 
config );
 
        // Parent constructor
-       ve.ui.MWDialog.call( this, surface, config );
+       ve.ui.MWDialog.call( this, config );
 };
 
 /* Inheritance */
diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWCitationDialog.js 
b/modules/ve-mw/ui/dialogs/ve.ui.MWCitationDialog.js
index 3b37919..1f1d9c1 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWCitationDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWCitationDialog.js
@@ -12,12 +12,11 @@
  * @extends ve.ui.MWTransclusionDialog
  *
  * @constructor
- * @param {ve.ui.Surface} surface Surface dialog is for
  * @param {Object} [config] Configuration options
  */
-ve.ui.MWCitationDialog = function VeUiMWCitationDialog( surface, config ) {
+ve.ui.MWCitationDialog = function VeUiMWCitationDialog( config ) {
        // Parent constructor
-       ve.ui.MWTransclusionDialog.call( this, surface, config );
+       ve.ui.MWTransclusionDialog.call( this, config );
 
        // Properties
        this.referenceModel = null;
@@ -53,8 +52,8 @@
  * @returns {ve.dm.MWReferenceNode|null} Reference node to be edited, null if 
none exists
  */
 ve.ui.MWCitationDialog.prototype.getReferenceNode = function () {
-       var focusedNode = this.surface.getView().getFocusedNode();
-       return focusedNode instanceof ve.ce.MWReferenceNode ? 
focusedNode.getModel() : null;
+       var focusedNode = this.getFragment().getSelectedNode();
+       return focusedNode instanceof ve.dm.MWReferenceNode ? focusedNode : 
null;
 };
 
 /**
@@ -84,7 +83,7 @@
  */
 ve.ui.MWCitationDialog.prototype.saveChanges = function () {
        var item,
-               surfaceModel = this.surface.getModel(),
+               surfaceModel = this.getFragment().getSurface(),
                doc = surfaceModel.getDocument(),
                internalList = doc.getInternalList(),
                obj = this.transclusion.getPlainObject();
diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWCommandHelpDialog.js 
b/modules/ve-mw/ui/dialogs/ve.ui.MWCommandHelpDialog.js
index 108e2a1..76624de 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWCommandHelpDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWCommandHelpDialog.js
@@ -14,12 +14,11 @@
  * @extends ve.ui.CommandHelpDialog
  *
  * @constructor
- * @param {ve.ui.Surface} surface Surface dialog is for
  * @param {Object} [config] Configuration options
  */
-ve.ui.MWCommandHelpDialog = function VeUiMWCommandHelpDialog( surface, config 
) {
+ve.ui.MWCommandHelpDialog = function VeUiMWCommandHelpDialog( config ) {
        // Parent constructor
-       ve.ui.CommandHelpDialog.call( this, surface, config );
+       ve.ui.CommandHelpDialog.call( this, config );
 };
 
 /* Inheritance */
diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWMediaEditDialog.js 
b/modules/ve-mw/ui/dialogs/ve.ui.MWMediaEditDialog.js
index c7a00ef..1d8a168 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWMediaEditDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWMediaEditDialog.js
@@ -13,12 +13,11 @@
  * @extends ve.ui.MWDialog
  *
  * @constructor
- * @param {ve.ui.Surface} surface Surface dialog is for
  * @param {Object} [config] Configuration options
  */
-ve.ui.MWMediaEditDialog = function VeUiMWMediaEditDialog( surface, config ) {
+ve.ui.MWMediaEditDialog = function VeUiMWMediaEditDialog( config ) {
        // Parent constructor
-       ve.ui.MWDialog.call( this, surface, config );
+       ve.ui.MWDialog.call( this, config );
 
        // Properties
        this.mediaNode = null;
@@ -498,7 +497,7 @@
                this.positionInput.intializeSelection();
        } else {
                // If checked, choose default position
-               if ( this.surface.getModel().getDocument().getDir() === 'ltr' ) 
{
+               if ( this.getFragment().getDocument().getDir() === 'ltr' ) {
                        // Assume default is 'right'
                        this.positionInput.selectItem(
                                this.positionInput.getItemFromData( 'right' )
@@ -566,16 +565,15 @@
 ve.ui.MWMediaEditDialog.prototype.setup = function ( data ) {
        var newDoc,
                dialog = this,
-               doc = this.surface.getModel().getDocument(),
-               mediaNodeView = this.surface.getView().getFocusedNode();
+               doc = this.getFragment().getSurface().getDocument();
 
        // Parent method
        ve.ui.MWDialog.prototype.setup.call( this, data );
 
        // Properties
-       this.mediaNode = mediaNodeView.getModel();
+       this.mediaNode = this.getFragment().getSelectedNode();
        this.captionNode = this.mediaNode.getCaptionNode();
-       this.store = this.surface.getModel().getDocument().getStore();
+       this.store = doc.getStore();
 
        if ( this.captionNode && this.captionNode.getLength() > 0 ) {
                newDoc = doc.cloneFromRange( this.captionNode.getRange() );
@@ -670,7 +668,7 @@
                this.positionInput.setDisabled( false );
                if ( this.mediaNode.getAttribute( 'align' ) === 'default' ) {
                        // Assume wiki default according to wiki dir
-                       if ( this.surface.getModel().getDocument().getDir() === 
'ltr' ) {
+                       if ( this.getFragment().getDocument().getDir() === 
'ltr' ) {
                                // Assume default is 'right'
                                this.positionInput.selectItem(
                                        this.positionInput.getItemFromData( 
'right' )
@@ -731,7 +729,7 @@
  */
 ve.ui.MWMediaEditDialog.prototype.teardown = function ( data ) {
        var newDoc, doc, originalAlt, attr, attrs = {},
-               surfaceModel = this.surface.getModel();
+               surfaceModel = this.getFragment().getSurface();
 
        // Data initialization
        data = data || {};
@@ -817,11 +815,11 @@
                                (
                                        this.mediaNode.getAttribute( 'align' ) 
=== 'default' &&
                                        (
-                                               
this.surface.getModel().getDocument().getDir() === 'ltr' &&
+                                               
this.getFragment().getDocument().getDir() === 'ltr' &&
                                                attr !== 'right'
                                        ) ||
                                        (
-                                               
this.surface.getModel().getDocument().getDir() === 'rtl' &&
+                                               
this.getFragment().getDocument().getDir() === 'rtl' &&
                                                attr !== 'left'
                                        )
                                ) ||
diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWMediaInsertDialog.js 
b/modules/ve-mw/ui/dialogs/ve.ui.MWMediaInsertDialog.js
index 33ebe93..1072b93 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWMediaInsertDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWMediaInsertDialog.js
@@ -14,15 +14,14 @@
  * @extends ve.ui.MWDialog
  *
  * @constructor
- * @param {ve.ui.Surface} surface Surface dialog is for
  * @param {Object} [config] Configuration options
  */
-ve.ui.MWMediaInsertDialog = function VeUiMWMediaInsertDialog( surface, config 
) {
+ve.ui.MWMediaInsertDialog = function VeUiMWMediaInsertDialog( config ) {
        // Configuration initialization
        config = ve.extendObject( { 'footless': true }, config );
 
        // Parent constructor
-       ve.ui.MWDialog.call( this, surface, config );
+       ve.ui.MWDialog.call( this, config );
 
        // Properties
        this.item = null;
@@ -174,7 +173,7 @@
                        thumbwidth = this.defaultThumbSize;
                        thumbheight = Math.round( ( info.height / info.width ) 
* thumbwidth );
                }
-               
this.surface.getModel().getFragment().collapseRangeToEnd().insertContent( [
+               this.getFragment().collapseRangeToEnd().insertContent( [
                        {
                                'type': 'mwBlockImage',
                                'attributes': {
diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWMetaDialog.js 
b/modules/ve-mw/ui/dialogs/ve.ui.MWMetaDialog.js
index 8328251..d57fba9 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWMetaDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWMetaDialog.js
@@ -12,12 +12,11 @@
  * @extends ve.ui.MWDialog
  *
  * @constructor
- * @param {ve.ui.Surface} surface Surface dialog is for
  * @param {Object} [config] Configuration options
  */
-ve.ui.MWMetaDialog = function VeUiMWMetaDialog( surface, config ) {
+ve.ui.MWMetaDialog = function VeUiMWMetaDialog( config ) {
        // Parent constructor
-       ve.ui.MWDialog.call( this, surface, config );
+       ve.ui.MWDialog.call( this, config );
 };
 
 /* Inheritance */
@@ -50,17 +49,14 @@
                'flags': ['primary']
        } );
        this.settingsPage = new ve.ui.MWSettingsPage(
-               this.surface,
                'settings',
                { '$': this.$ }
        );
        this.advancedSettingsPage = new ve.ui.MWAdvancedSettingsPage(
-               this.surface,
                'advancedSettings',
                { '$': this.$ }
        );
        this.categoriesPage = new ve.ui.MWCategoriesPage(
-               this.surface,
                'categories',
                {
                        '$': this.$,
@@ -96,7 +92,7 @@
        // Data initialization
        data = data || {};
 
-       var surfaceModel = this.surface.getModel();
+       var surfaceModel = this.getFragment().getSurface();
 
        if ( data.page && this.bookletLayout.getPage( data.page ) ) {
                this.bookletLayout.setPage( data.page );
@@ -107,16 +103,16 @@
        surfaceModel.stopHistoryTracking();
 
        // Let each page set itself up ('languages' page doesn't need this yet)
-       this.settingsPage.setup( data );
-       this.advancedSettingsPage.setup( data );
-       this.categoriesPage.setup( data );
+       this.settingsPage.setup( surfaceModel.metaList, data );
+       this.advancedSettingsPage.setup( surfaceModel.metaList, data );
+       this.categoriesPage.setup( surfaceModel.metaList, data );
 };
 
 /**
  * @inheritdoc
  */
 ve.ui.MWMetaDialog.prototype.teardown = function ( data ) {
-       var surfaceModel = this.surface.getModel(),
+       var surfaceModel = this.getFragment().getSurface(),
                // Place transactions made while dialog was open in a common 
history state
                hasTransactions = surfaceModel.breakpoint();
 
@@ -132,7 +128,7 @@
        this.categoriesPage.teardown( data );
 
        // Return to normal tracking behavior
-       this.surface.getModel().startHistoryTracking();
+       surfaceModel.startHistoryTracking();
 
        // Parent method
        ve.ui.MWDialog.prototype.teardown.call( this, data );
diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js 
b/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js
index db569de..c2b6428 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js
@@ -12,15 +12,14 @@
  * @extends ve.ui.MWDialog
  *
  * @constructor
- * @param {ve.ui.Surface} surface Surface dialog is for
  * @param {Object} [config] Configuration options
  */
-ve.ui.MWReferenceDialog = function VeUiMWReferenceDialog( surface, config ) {
+ve.ui.MWReferenceDialog = function VeUiMWReferenceDialog( config ) {
        // Configuration initialization
        config = ve.extendObject( { 'size': 'medium' }, config );
 
        // Parent constructor
-       ve.ui.MWDialog.call( this, surface, config );
+       ve.ui.MWDialog.call( this, config );
 
        // Properties
        this.referenceModel = null;
@@ -160,8 +159,8 @@
  * @returns {ve.dm.MWReferenceNode|null} Reference node to be edited, null if 
none exists
  */
 ve.ui.MWReferenceDialog.prototype.getReferenceNode = function () {
-       var focusedNode = this.surface.getView().getFocusedNode();
-       return focusedNode instanceof ve.ce.MWReferenceNode ? 
focusedNode.getModel() : null;
+       var focusedNode = this.getFragment().getSelectedNode();
+       return focusedNode instanceof ve.dm.MWReferenceNode ? focusedNode : 
null;
 };
 
 /**
@@ -254,9 +253,7 @@
                'align': 'top',
                'label': ve.msg( 
'visualeditor-dialog-reference-options-group-label' )
        } );
-       this.search = new ve.ui.MWReferenceSearchWidget(
-               this.surface, { '$': this.$ }
-       );
+       this.search = new ve.ui.MWReferenceSearchWidget( { '$': this.$ } );
 
        // Events
        this.applyButton.connect( this, { 'click': [ 'close', { 'action': 
'apply' } ] } );
@@ -318,7 +315,7 @@
                this.insertButton.$element.show();
        }
        this.backButton.$element.hide();
-       this.search.buildIndex();
+       this.search.buildIndex( 
this.getFragment().getDocument().getInternalList() );
        this.selectButton.setDisabled( this.search.isIndexEmpty() );
 };
 
@@ -326,7 +323,7 @@
  * @inheritdoc
  */
 ve.ui.MWReferenceDialog.prototype.teardown = function ( data ) {
-       var surfaceModel = this.surface.getModel();
+       var surfaceModel = this.getFragment().getSurface();
 
        // Data initialization
        data = data || {};
diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceListDialog.js 
b/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceListDialog.js
index d32326c..9b3d104 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceListDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceListDialog.js
@@ -12,15 +12,14 @@
  * @extends ve.ui.MWDialog
  *
  * @constructor
- * @param {ve.ui.Surface} surface Surface dialog is for
  * @param {Object} [config] Configuration options
  */
-ve.ui.MWReferenceListDialog = function VeUiMWReferenceListDialog( surface, 
config ) {
+ve.ui.MWReferenceListDialog = function VeUiMWReferenceListDialog( config ) {
        // Configuration initialization
        config = ve.extendObject( { 'size': 'small' }, config );
 
        // Parent constructor
-       ve.ui.MWDialog.call( this, surface, config );
+       ve.ui.MWDialog.call( this, config );
 
        // Properties
        this.inserting = false;
@@ -92,9 +91,9 @@
 
        // Prepopulate from existing node if we're editing a node
        // instead of inserting a new one
-       node = this.surface.getView().getFocusedNode();
-       if ( node instanceof ve.ce.MWReferenceListNode ) {
-               refGroup = node.getModel().getAttribute( 'refGroup' );
+       node = this.getFragment().getSelectedNode();
+       if ( node instanceof ve.dm.MWReferenceListNode ) {
+               refGroup = node.getAttribute( 'refGroup' );
                this.inserting = false;
        } else {
                refGroup = '';
@@ -112,7 +111,7 @@
         * Focused node.
         *
         * @private
-        * @property {ve.ce.MWReferenceListNode|undefined}
+        * @property {ve.dm.MWReferenceListNode|undefined}
         */
        this.node = node;
 };
@@ -121,10 +120,8 @@
  * @inheritdoc
  */
 ve.ui.MWReferenceListDialog.prototype.teardown = function ( data ) {
-       var refGroup, listGroup, oldListGroup, attrChanges,
-               doc, model,
-               surfaceModel = this.surface.getModel(),
-               node = this.node;
+       var refGroup, listGroup, oldListGroup, attrChanges, doc,
+               surfaceModel = this.getFragment().getSurface();
 
        // Data initialization
        data = data || {};
@@ -134,11 +131,10 @@
                refGroup = this.groupInput.getValue();
                listGroup = 'mwReference/' + refGroup;
 
-               if ( node ) {
+               if ( this.node ) {
                        // Edit existing model
                        doc = surfaceModel.getDocument();
-                       model = node.getModel();
-                       oldListGroup = model.getAttribute( 'listGroup' );
+                       oldListGroup = this.node.getAttribute( 'listGroup' );
 
                        if ( listGroup !== oldListGroup ) {
                                attrChanges = {
@@ -147,7 +143,7 @@
                                };
                                surfaceModel.change(
                                        
ve.dm.Transaction.newFromAttributeChanges(
-                                               doc, 
model.getOuterRange().start, attrChanges
+                                               doc, 
this.node.getOuterRange().start, attrChanges
                                        )
                                );
                        }
diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js 
b/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js
index d24468c..b899875 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js
@@ -17,15 +17,14 @@
  * @extends ve.ui.MWDialog
  *
  * @constructor
- * @param {ve.ui.Surface} surface Surface dialog is for
  * @param {Object} [config] Config options
  */
-ve.ui.MWSaveDialog = function VeUiMWSaveDialog( surface, config ) {
+ve.ui.MWSaveDialog = function VeUiMWSaveDialog( config ) {
        // Configuration initialization
        config = ve.extendObject( { 'size': 'medium' }, config );
 
        // Parent constructor
-       ve.ui.MWDialog.call( this, surface, config );
+       ve.ui.MWDialog.call( this, config );
 
        // Properties
        this.sanityCheckVerified = false;
diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js 
b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js
index 88c68d5..0f5bb07 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js
@@ -12,12 +12,11 @@
  * @extends ve.ui.MWDialog
  *
  * @constructor
- * @param {ve.ui.Surface} surface Surface dialog is for
  * @param {Object} [config] Configuration options
  */
-ve.ui.MWTransclusionDialog = function VeUiMWTransclusionDialog( surface, 
config ) {
+ve.ui.MWTransclusionDialog = function VeUiMWTransclusionDialog( config ) {
        // Parent constructor
-       ve.ui.MWDialog.call( this, surface, config );
+       ve.ui.MWDialog.call( this, config );
 
        // Properties
        this.transclusionNode = null;
@@ -473,15 +472,15 @@
  * @returns {ve.dm.MWTransclusionNode|null} Transclusion node to be edited, 
null if none exists
  */
 ve.ui.MWTransclusionDialog.prototype.getTransclusionNode = function () {
-       var focusedNode = this.surface.getView().getFocusedNode();
-       return focusedNode instanceof ve.ce.MWTransclusionNode ? 
focusedNode.getModel() : null;
+       var focusedNode = this.getFragment().getSelectedNode();
+       return focusedNode instanceof ve.dm.MWTransclusionNode ? focusedNode : 
null;
 };
 
 /**
  * Save changes.
  */
 ve.ui.MWTransclusionDialog.prototype.saveChanges = function () {
-       var surfaceModel = this.surface.getModel(),
+       var surfaceModel = this.getFragment().getSurface(),
                obj = this.transclusion.getPlainObject();
 
        if ( this.transclusionNode instanceof ve.dm.MWTransclusionNode ) {
diff --git a/modules/ve-mw/ui/inspectors/ve.ui.MWAlienExtensionInspector.js 
b/modules/ve-mw/ui/inspectors/ve.ui.MWAlienExtensionInspector.js
index 78bab49..957da32 100644
--- a/modules/ve-mw/ui/inspectors/ve.ui.MWAlienExtensionInspector.js
+++ b/modules/ve-mw/ui/inspectors/ve.ui.MWAlienExtensionInspector.js
@@ -12,12 +12,15 @@
  * @extends ve.ui.MWExtensionInspector
  *
  * @constructor
- * @param {ve.ui.Surface} surface Surface inspector is for
  * @param {Object} [config] Configuration options
  */
-ve.ui.MWAlienExtensionInspector = function VeUiMWAlienExtensionInspector( 
surface, config ) {
+ve.ui.MWAlienExtensionInspector = function VeUiMWAlienExtensionInspector( 
config ) {
        // Parent constructor
-       ve.ui.MWExtensionInspector.call( this, surface, config );
+       ve.ui.MWExtensionInspector.call( this, config );
+
+       // Properties
+       this.attributeInputs = {};
+       this.$attributes = null;
 };
 
 /* Inheritance */
@@ -33,8 +36,6 @@
 ve.ui.MWAlienExtensionInspector.static.title =
        OO.ui.deferMsg( 'visualeditor-mwalienextensioninspector-title' );
 
-ve.ui.MWAlienExtensionInspector.static.nodeView = ve.ce.MWAlienExtensionNode;
-
 ve.ui.MWAlienExtensionInspector.static.nodeModel = ve.dm.MWAlienExtensionNode;
 
 /* Methods */
@@ -43,7 +44,7 @@
  * @inheritdoc
  */
 ve.ui.MWAlienExtensionInspector.prototype.getTitle = function () {
-       return 
this.surface.getView().getFocusedNode().getModel().getExtensionName();
+       return this.getFragment().getSelectedNode().getExtensionName();
 };
 
 /**
@@ -51,12 +52,21 @@
  */
 ve.ui.MWAlienExtensionInspector.prototype.initialize = function () {
        // Parent method
-       ve.ui.MWExtensionInspector.prototype.initialize.call( this );
+       ve.ui.MWExtensionInspector.prototype.initialize.apply( this, arguments 
);
+
+       this.$attributes = this.$( '<div>' ).addClass( 
've-ui-mwAlienExtensionInspector-attributes' );
+       this.$form.append( this.$attributes );
+};
+
+/**
+ * @inheritdoc
+ */
+ve.ui.MWAlienExtensionInspector.prototype.setup = function () {
+       // Parent method
+       ve.ui.MWExtensionInspector.prototype.setup.apply( this, arguments );
 
        var key, attributeInput, field,
-               attributes = 
this.surface.getView().getFocusedNode().model.getAttribute( 'mw' ).attrs;
-
-       this.attributeInputs = {};
+               attributes = this.getFragment().getSelectedNode().getAttribute( 
'mw' ).attrs;
 
        if ( attributes && !ve.isEmptyObject( attributes ) ) {
                for ( key in attributes ) {
@@ -73,11 +83,22 @@
                                        'label': key
                                }
                        );
-                       this.$form.append( field.$element.addClass( 
've-ui-mwAlienExtensionInspector-attributes' ) );
+                       this.$attributes.append( field.$element );
                }
        }
 };
 
+/**
+ * @inheritdoc
+ */
+ve.ui.MWAlienExtensionInspector.prototype.teardown = function () {
+       // Parent method
+       ve.ui.MWExtensionInspector.prototype.teardown.apply( this, arguments );
+
+       this.$attributes.empty();
+       this.attributeInputs = {};
+};
+
 /** */
 ve.ui.MWAlienExtensionInspector.prototype.updateMwData = function ( mwData ) {
        // Parent method
diff --git a/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js 
b/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js
index fb657ce..7b1d9a1 100644
--- a/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js
+++ b/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js
@@ -13,12 +13,11 @@
  * @extends ve.ui.Inspector
  *
  * @constructor
- * @param {ve.ui.Surface} surface Surface inspector is for
  * @param {Object} [config] Configuration options
  */
-ve.ui.MWExtensionInspector = function VeUiMWExtensionInspector( surface, 
config ) {
+ve.ui.MWExtensionInspector = function VeUiMWExtensionInspector( config ) {
        // Parent constructor
-       ve.ui.Inspector.call( this, surface, config );
+       ve.ui.Inspector.call( this, config );
 };
 
 /* Inheritance */
@@ -28,8 +27,6 @@
 /* Static properties */
 
 ve.ui.MWExtensionInspector.static.placeholder = null;
-
-ve.ui.MWExtensionInspector.static.nodeView = null;
 
 ve.ui.MWExtensionInspector.static.nodeModel = null;
 
@@ -57,7 +54,6 @@
 
        this.input = new OO.ui.TextInputWidget( {
                '$': this.$,
-               'overlay': this.surface.$localOverlay,
                'multiline': true
        } );
        this.input.$element.addClass( 've-ui-mwExtensionInspector-input' );
@@ -79,32 +75,20 @@
  * @inheritdoc
  */
 ve.ui.MWExtensionInspector.prototype.setup = function ( data ) {
-       var dir,
-               fragment = this.surface.getModel().getFragment( null, true );
-
        // Parent method
        ve.ui.Inspector.prototype.setup.call( this, data );
 
        // Initialization
-       this.node = this.surface.getView().getFocusedNode();
+       this.node = this.getFragment().getSelectedNode();
        // Make sure we're inspecting the right type of node
-       if ( !( this.node instanceof this.constructor.static.nodeView ) ) {
+       if ( !( this.node instanceof this.constructor.static.nodeModel ) ) {
                this.node = null;
        }
-       this.input.setValue( this.node ? this.node.getModel().getAttribute( 
'mw' ).body.extsrc : '' );
+       this.input.setValue( this.node ? this.node.getAttribute( 'mw' 
).body.extsrc : '' );
 
        this.input.$input.attr( 'placeholder', this.getInputPlaceholder() );
 
-       // By default, the direction of the input element should be the same
-       // as the direction of the content it applies to
-       if ( this.node ) {
-               // The node is being edited
-               dir = this.node.$element.css( 'direction' );
-       } else {
-               // New insertion, base direction on the fragment range
-               dir = 
this.surface.getView().documentView.getDirectionFromRange( fragment.getRange() 
);
-       }
-       this.input.setRTL( dir === 'rtl' );
+       this.input.setRTL( data.dir === 'rtl' );
 };
 
 /**
@@ -123,11 +107,11 @@
  */
 ve.ui.MWExtensionInspector.prototype.teardown = function ( data ) {
        var mwData,
-               surfaceModel = this.surface.getModel();
+               surfaceModel = this.getFragment().getSurface();
 
        if ( this.constructor.static.allowedEmpty || this.input.getValue() !== 
'' ) {
-               if ( this.node instanceof this.constructor.static.nodeView ) {
-                       mwData = ve.copy( this.node.getModel().getAttribute( 
'mw' ) );
+               if ( this.node instanceof this.constructor.static.nodeModel ) {
+                       mwData = ve.copy( this.node.getAttribute( 'mw' ) );
                        this.updateMwData( mwData );
                        surfaceModel.change(
                                ve.dm.Transaction.newFromAttributeChanges(
diff --git a/modules/ve-mw/ui/inspectors/ve.ui.MWGalleryInspector.js 
b/modules/ve-mw/ui/inspectors/ve.ui.MWGalleryInspector.js
index f344f9a..5d246a4 100644
--- a/modules/ve-mw/ui/inspectors/ve.ui.MWGalleryInspector.js
+++ b/modules/ve-mw/ui/inspectors/ve.ui.MWGalleryInspector.js
@@ -14,12 +14,11 @@
  * @extends ve.ui.MWExtensionInspector
  *
  * @constructor
- * @param {ve.ui.Surface} surface Surface inspector is for
  * @param {Object} [config] Configuration options
  */
-ve.ui.MWGalleryInspector = function VeUiMWGalleryInspector( surface, config ) {
+ve.ui.MWGalleryInspector = function VeUiMWGalleryInspector( config ) {
        // Parent constructor
-       ve.ui.MWExtensionInspector.call( this, surface, config );
+       ve.ui.MWExtensionInspector.call( this, config );
 };
 
 /* Inheritance */
@@ -34,8 +33,6 @@
 
 ve.ui.MWGalleryInspector.static.title =
        OO.ui.deferMsg( 'visualeditor-mwgalleryinspector-title' );
-
-ve.ui.MWGalleryInspector.static.nodeView = ve.ce.MWGalleryNode;
 
 ve.ui.MWGalleryInspector.static.nodeModel = ve.dm.MWGalleryNode;
 
diff --git a/modules/ve-mw/ui/inspectors/ve.ui.MWHieroInspector.js 
b/modules/ve-mw/ui/inspectors/ve.ui.MWHieroInspector.js
index ceb237d..c0e3389 100644
--- a/modules/ve-mw/ui/inspectors/ve.ui.MWHieroInspector.js
+++ b/modules/ve-mw/ui/inspectors/ve.ui.MWHieroInspector.js
@@ -12,12 +12,11 @@
  * @extends ve.ui.MWExtensionInspector
  *
  * @constructor
- * @param {ve.ui.Surface} surface Surface inspector is for
  * @param {Object} [config] Configuration options
  */
-ve.ui.MWHieroInspector = function VeUiMWHieroInspector( surface, config ) {
+ve.ui.MWHieroInspector = function VeUiMWHieroInspector( config ) {
        // Parent constructor
-       ve.ui.MWExtensionInspector.call( this, surface, config );
+       ve.ui.MWExtensionInspector.call( this, config );
 };
 
 /* Inheritance */
@@ -32,8 +31,6 @@
 
 ve.ui.MWHieroInspector.static.title =
        OO.ui.deferMsg( 'visualeditor-mwhieroinspector-title' );
-
-ve.ui.MWHieroInspector.static.nodeView = ve.ce.MWHieroNode;
 
 ve.ui.MWHieroInspector.static.nodeModel = ve.dm.MWHieroNode;
 
diff --git a/modules/ve-mw/ui/inspectors/ve.ui.MWLanguageInspector.js 
b/modules/ve-mw/ui/inspectors/ve.ui.MWLanguageInspector.js
index 746e6ec..0216815 100644
--- a/modules/ve-mw/ui/inspectors/ve.ui.MWLanguageInspector.js
+++ b/modules/ve-mw/ui/inspectors/ve.ui.MWLanguageInspector.js
@@ -12,12 +12,11 @@
  * @extends ve.ui.LanguageInspector
  *
  * @constructor
- * @param {ve.ui.Surface} surface
  * @param {Object} [config] Configuration options
  */
-ve.ui.MWLanguageInspector = function VeUiMWLanguageInspector( surface, config 
) {
+ve.ui.MWLanguageInspector = function VeUiMWLanguageInspector( config ) {
        // Parent constructor
-       ve.ui.LanguageInspector.call( this, surface, config );
+       ve.ui.LanguageInspector.call( this, config );
 };
 
 /* Inheritance */
diff --git a/modules/ve-mw/ui/inspectors/ve.ui.MWLinkInspector.js 
b/modules/ve-mw/ui/inspectors/ve.ui.MWLinkInspector.js
index 015c9b7..1cb89f5 100644
--- a/modules/ve-mw/ui/inspectors/ve.ui.MWLinkInspector.js
+++ b/modules/ve-mw/ui/inspectors/ve.ui.MWLinkInspector.js
@@ -14,12 +14,11 @@
  * @extends ve.ui.LinkInspector
  *
  * @constructor
- * @param {ve.ui.Surface} surface Surface inspector is for
  * @param {Object} [config] Configuration options
  */
-ve.ui.MWLinkInspector = function VeUiMWLinkInspector( surface, config ) {
+ve.ui.MWLinkInspector = function VeUiMWLinkInspector( config ) {
        // Parent constructor
-       ve.ui.LinkInspector.call( this, surface, config );
+       ve.ui.LinkInspector.call( this, config );
 };
 
 /* Inheritance */
diff --git a/modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js 
b/modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js
index f742207..150b21e 100644
--- a/modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js
+++ b/modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js
@@ -12,16 +12,15 @@
  * @extends OO.ui.PageLayout
  *
  * @constructor
- * @param {ve.ui.Surface} surface Surface being worked on
  * @param {string} name Unique symbolic name of page
  * @param {Object} [config] Configuration options
  */
-ve.ui.MWAdvancedSettingsPage = function VeUiMWAdvancedSettingsPage( surface, 
name, config ) {
+ve.ui.MWAdvancedSettingsPage = function VeUiMWAdvancedSettingsPage( name, 
config ) {
        // Parent constructor
        OO.ui.PageLayout.call( this, name, config );
 
        // Properties
-       this.metaList = surface.getModel().metaList;
+       this.metaList = null;
        this.indexingOptionTouched = false;
        this.newSectionEditLinkOptionTouched = false;
 
@@ -146,9 +145,12 @@
 /**
  * Setup settings page.
  *
+ * @param {ve.dm.MetaList} metaList Meta list
  * @param {Object} [data] Dialog setup data
  */
-ve.ui.MWAdvancedSettingsPage.prototype.setup = function () {
+ve.ui.MWAdvancedSettingsPage.prototype.setup = function ( metaList ) {
+       this.metaList = metaList;
+
        var // Indexing items
                indexingField = this.indexing.getField(),
                indexingOption = this.getIndexingOptionItem(),
@@ -224,4 +226,6 @@
                        }
                }
        }
+
+       this.metaList = null;
 };
diff --git a/modules/ve-mw/ui/pages/ve.ui.MWCategoriesPage.js 
b/modules/ve-mw/ui/pages/ve.ui.MWCategoriesPage.js
index df6e3b2..e3faf51 100644
--- a/modules/ve-mw/ui/pages/ve.ui.MWCategoriesPage.js
+++ b/modules/ve-mw/ui/pages/ve.ui.MWCategoriesPage.js
@@ -14,12 +14,11 @@
  * @extends OO.ui.PageLayout
  *
  * @constructor
- * @param {ve.ui.Surface} surface Surface being worked on
  * @param {string} name Unique symbolic name of page
  * @param {Object} [config] Configuration options
  * @cfg {jQuery} [$overlay] Overlay to render category settings popups in
  */
-ve.ui.MWCategoriesPage = function VeUiMWCategoriesPage( surface, name, config 
) {
+ve.ui.MWCategoriesPage = function VeUiMWCategoriesPage( name, config ) {
        // Configuration initialization
        config = config || {};
 
@@ -27,7 +26,7 @@
        OO.ui.PageLayout.call( this, name, config );
 
        // Properties
-       this.metaList = surface.getModel().metaList;
+       this.metaList = null;
        this.defaultSortKeyTouched = false;
        this.fallbackDefaultSortKey = mw.config.get( 'wgTitle' );
        this.categoriesFieldset = new OO.ui.FieldsetLayout( {
@@ -59,10 +58,6 @@
        );
 
        // Events
-       this.metaList.connect( this, {
-               'insert': 'onMetaListInsert',
-               'remove': 'onMetaListRemove'
-       } );
        this.categoryWidget.connect( this, {
                'newCategory': 'onNewCategory',
                'updateSortkey': 'onUpdateSortKey'
@@ -72,7 +67,6 @@
        } );
 
        // Initialization
-       this.categoryWidget.addItems( this.getCategoryItems() );
        this.categoriesFieldset.$element.append( this.categoryWidget.$element );
        this.categoryOptionsFieldset.addItems( [ this.defaultSort ] );
        this.$element.append( this.categoriesFieldset.$element, 
this.categoryOptionsFieldset.$element );
@@ -230,10 +224,21 @@
 };
 
 /**
- * Set up the page. This is called when the MWMetaDialog is set up.
+ * Setup categories page.
+ *
+ * @param {ve.dm.MetaList} metaList Meta list
+ * @param {Object} [data] Dialog setup data
  */
-ve.ui.MWCategoriesPage.prototype.setup = function () {
+ve.ui.MWCategoriesPage.prototype.setup = function ( metaList ) {
+       this.metaList = metaList;
+       this.metaList.connect( this, {
+               'insert': 'onMetaListInsert',
+               'remove': 'onMetaListRemove'
+       } );
+
        var defaultSortKeyItem = this.getDefaultSortKeyItem();
+
+       this.categoryWidget.addItems( this.getCategoryItems() );
 
        this.defaultSortInput.setValue(
                defaultSortKeyItem ? defaultSortKeyItem.getAttribute( 'content' 
) : ''
@@ -275,4 +280,11 @@
                        }
                }
        }
+
+       this.categoryWidget.clearItems();
+       this.metaList.disconnect( this, {
+               'insert': 'onMetaListInsert',
+               'remove': 'onMetaListRemove'
+       } );
+       this.metaList = null;
 };
diff --git a/modules/ve-mw/ui/pages/ve.ui.MWSettingsPage.js 
b/modules/ve-mw/ui/pages/ve.ui.MWSettingsPage.js
index c651bd9..470213a 100644
--- a/modules/ve-mw/ui/pages/ve.ui.MWSettingsPage.js
+++ b/modules/ve-mw/ui/pages/ve.ui.MWSettingsPage.js
@@ -12,16 +12,15 @@
  * @extends OO.ui.PageLayout
  *
  * @constructor
- * @param {ve.ui.Surface} surface Surface being worked on
  * @param {string} name Unique symbolic name of page
  * @param {Object} [config] Configuration options
  */
-ve.ui.MWSettingsPage = function VeUiMWSettingsPage( surface, name, config ) {
+ve.ui.MWSettingsPage = function VeUiMWSettingsPage( name, config ) {
        // Parent constructor
        OO.ui.PageLayout.call( this, name, config );
 
        // Properties
-       this.metaList = surface.getModel().metaList;
+       this.metaList = null;
        this.tocOptionTouched = false;
        this.redirectOptionsTouched = false;
        this.tableOfContentsTouched = false;
@@ -215,9 +214,12 @@
 /**
  * Setup settings page.
  *
+ * @param {ve.dm.MetaList} metaList Meta list
  * @param {Object} [data] Dialog setup data
  */
-ve.ui.MWSettingsPage.prototype.setup = function () {
+ve.ui.MWSettingsPage.prototype.setup = function ( metaList ) {
+       this.metaList = metaList;
+
        var // Table of Contents items
                tableOfContentsMetaItem = this.getTableOfContentsMetaItem(),
                tableOfContentsField = this.tableOfContents.getField(),
@@ -330,4 +332,6 @@
        if ( !currentDisableSectionEditLinksItem && newDisableSectionEditState 
) {
                this.metaList.insertMeta( { 'type': 'mwNoEditSection' } );
        }
+
+       this.metaList = null;
 };
diff --git a/modules/ve-mw/ui/ve.ui.MWDialog.js 
b/modules/ve-mw/ui/ve.ui.MWDialog.js
index 2178816..c30ffb1 100644
--- a/modules/ve-mw/ui/ve.ui.MWDialog.js
+++ b/modules/ve-mw/ui/ve.ui.MWDialog.js
@@ -13,12 +13,12 @@
  * @extends ve.ui.Dialog
  *
  * @constructor
- * @param {ve.ui.Surface} surface Surface inspector is for
+ * @param {ve.dm.SurfaceFragment} fragment Surface fragment the dialog is for
  * @param {Object} [config] Configuration options
  */
-ve.ui.MWDialog = function VeUiMWDialog( surface, config ) {
+ve.ui.MWDialog = function VeUiMWDialog( fragment, config ) {
        // Parent constructor
-       ve.ui.Dialog.call( this, surface, config );
+       ve.ui.Dialog.call( this, fragment, config );
 };
 
 /* Inheritance */
diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWReferenceSearchWidget.js 
b/modules/ve-mw/ui/widgets/ve.ui.MWReferenceSearchWidget.js
index 2ce9a5e..f5fe168 100644
--- a/modules/ve-mw/ui/widgets/ve.ui.MWReferenceSearchWidget.js
+++ b/modules/ve-mw/ui/widgets/ve.ui.MWReferenceSearchWidget.js
@@ -12,10 +12,9 @@
  * @extends OO.ui.SearchWidget
  *
  * @constructor
- * @param {ve.ui.Surface} [varname] [description]
  * @param {Object} [config] Configuration options
  */
-ve.ui.MWReferenceSearchWidget = function VeUiMWReferenceSearchWidget( surface, 
config ) {
+ve.ui.MWReferenceSearchWidget = function VeUiMWReferenceSearchWidget( config ) 
{
        // Configuration intialization
        config = ve.extendObject( {
                'placeholder': ve.msg( 
'visualeditor-reference-input-placeholder' )
@@ -25,7 +24,7 @@
        OO.ui.SearchWidget.call( this, config );
 
        // Properties
-       this.surface = surface;
+       this.internalList = null;
        this.index = [];
 
        // Initialization
@@ -86,11 +85,11 @@
  * Build a serchable index of references.
  *
  * @method
+ * @param {ve.dm.InternalList} internalList Internal list
  */
-ve.ui.MWReferenceSearchWidget.prototype.buildIndex = function () {
+ve.ui.MWReferenceSearchWidget.prototype.buildIndex = function ( internalList ) 
{
        var i, iLen, j, jLen, ref, group, groupName, groupNames, view, text, 
firstNodes, indexOrder,
                refGroup, refNode, matches, name, citation,
-               internalList = 
this.surface.getModel().getDocument().getInternalList(),
                groups = internalList.getNodeGroups();
 
        function extractAttrs() {

-- 
To view, visit https://gerrit.wikimedia.org/r/123890
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0fae3e5ff2bd0da5b74c244af226b07b1f5883bd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to