Update VE core submodule to master (55a5cdc): use new ve.ui.Dialogs and ve.ui.Inspectors

Move various bits of code from initialize to setup as required.

MWDialog is now useless so use ve.ui.Dialog directly.

New changes:
0b2d03f [BREAKING CHANGE] Pass fragments, not surfaces, to windows (reprise)
0101ac4 Update OOjs UI to v0.1.0-pre (ac6848398c)

Change-Id: I0fae3e5ff2bd0da5b74c244af226b07b1f5883bd
This commit is contained in:
Ed Sanders 2014-04-04 10:42:13 -07:00 committed by Roan Kattouw
parent f2422d916c
commit 0e51180709
24 changed files with 183 additions and 216 deletions

View file

@ -618,7 +618,6 @@ $wgResourceModules += array(
'modules/ve-mw/ce/annotations/ve.ce.MWNowikiAnnotation.js',
// ui
'modules/ve-mw/ui/ve.ui.MWDialog.js',
'modules/ve-mw/ui/ve.ui.MWCommandRegistry.js',
'modules/ve-mw/ui/widgets/ve.ui.MWTitleInputWidget.js',

2
lib/ve

@ -1 +1 @@
Subproject commit c150259d39ac59f3bbc6a1c7a3f0663ff12163c3
Subproject commit 55a5cdc0478120d0222051b68c40999083be7d3d

View file

@ -838,8 +838,8 @@ ve.init.mw.Target.prototype.generateCitationFeatures = function () {
new ve.ui.Command( name, 'dialog', 'open', name, data )
);
// Generate dialog
dialog = function GeneratedMWCitationDialog( toolbar, config ) {
ve.ui.MWCitationDialog.call( this, toolbar, config );
dialog = function GeneratedMWCitationDialog( config ) {
ve.ui.MWCitationDialog.call( this, config );
};
OO.inheritClass( dialog, ve.ui.MWCitationDialog );
dialog.static.name = name;

View file

@ -1,4 +1,3 @@
/*global mw */
/*!
* VisualEditor user interface MWBetaWelcomeDialog class.
*
@ -6,27 +5,28 @@
* @license The MIT License (MIT); see LICENSE.txt
*/
/*global mw */
/**
* Dialog for inserting MediaWiki media objects.
*
* @class
* @extends ve.ui.MWDialog
* @extends ve.ui.Dialog
*
* @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.Dialog.call( this, config );
};
/* Inheritance */
OO.inheritClass( ve.ui.MWBetaWelcomeDialog, ve.ui.MWDialog );
OO.inheritClass( ve.ui.MWBetaWelcomeDialog, ve.ui.Dialog );
/* Static Properties */
@ -54,7 +54,7 @@ ve.ui.MWBetaWelcomeDialog.prototype.getTitle = function () {
*/
ve.ui.MWBetaWelcomeDialog.prototype.initialize = function () {
// Parent method
ve.ui.MWDialog.prototype.initialize.call( this );
ve.ui.Dialog.prototype.initialize.call( this );
// Properties
this.contentLayout = new OO.ui.PanelLayout( {

View file

@ -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 @@ ve.ui.MWCitationDialog.prototype.getApplyButtonLabel = function () {
* @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.getTransclusionNode = function () {
*/
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();

View file

@ -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 */

View file

@ -10,15 +10,14 @@
* Dialog for editing MediaWiki media objects.
*
* @class
* @extends ve.ui.MWDialog
* @extends ve.ui.Dialog
*
* @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.Dialog.call( this, config );
// Properties
this.mediaNode = null;
@ -29,7 +28,7 @@ ve.ui.MWMediaEditDialog = function VeUiMWMediaEditDialog( surface, config ) {
/* Inheritance */
OO.inheritClass( ve.ui.MWMediaEditDialog, ve.ui.MWDialog );
OO.inheritClass( ve.ui.MWMediaEditDialog, ve.ui.Dialog );
/* Static Properties */
@ -134,7 +133,7 @@ ve.ui.MWMediaEditDialog.static.pasteRules = ve.extendObject(
ve.ui.MWMediaEditDialog.prototype.initialize = function () {
var altTextFieldset, positionFieldset, borderField, positionField;
// Parent method
ve.ui.MWDialog.prototype.initialize.call( this );
ve.ui.Dialog.prototype.initialize.call( this );
this.$spinner = this.$( '<div>' ).addClass( 've-specialchar-spinner' );
@ -390,7 +389,7 @@ ve.ui.MWMediaEditDialog.prototype.onPositionCheckboxChange = function () {
this.positionInput.selectItem( null );
} 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' )
@ -412,16 +411,15 @@ ve.ui.MWMediaEditDialog.prototype.onPositionCheckboxChange = function () {
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 );
ve.ui.Dialog.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() );
@ -502,7 +500,7 @@ ve.ui.MWMediaEditDialog.prototype.setup = function ( data ) {
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' )
@ -548,7 +546,7 @@ ve.ui.MWMediaEditDialog.prototype.teardown = function ( data ) {
var newDoc, doc, originalAlt, attr, transactionAttributes = {},
imageSizeType, imageType, imageAlignmentCheckbox,
imageAlignmentValue, originalDimensions,
surfaceModel = this.surface.getModel();
surfaceModel = this.getFragment().getSurface();
// Data initialization
data = data || {};
@ -650,11 +648,11 @@ ve.ui.MWMediaEditDialog.prototype.teardown = function ( data ) {
(
this.mediaNode.getAttribute( 'align' ) === 'default' &&
(
this.surface.getModel().getDocument().getDir() === 'ltr' &&
this.getFragment().getDocument().getDir() === 'ltr' &&
imageAlignmentValue !== 'right'
) ||
(
this.surface.getModel().getDocument().getDir() === 'rtl' &&
this.getFragment().getDocument().getDir() === 'rtl' &&
imageAlignmentValue !== 'left'
)
) ||
@ -689,7 +687,7 @@ ve.ui.MWMediaEditDialog.prototype.teardown = function ( data ) {
this.captionNode = null;
// Parent method
ve.ui.MWDialog.prototype.teardown.call( this, data );
ve.ui.Dialog.prototype.teardown.call( this, data );
};
/* Registration */

View file

@ -11,18 +11,17 @@
* Dialog for inserting MediaWiki media objects.
*
* @class
* @extends ve.ui.MWDialog
* @extends ve.ui.Dialog
*
* @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.Dialog.call( this, config );
// Properties
this.item = null;
@ -31,7 +30,7 @@ ve.ui.MWMediaInsertDialog = function VeUiMWMediaInsertDialog( surface, config )
/* Inheritance */
OO.inheritClass( ve.ui.MWMediaInsertDialog, ve.ui.MWDialog );
OO.inheritClass( ve.ui.MWMediaInsertDialog, ve.ui.Dialog );
/* Static Properties */
@ -61,7 +60,7 @@ ve.ui.MWMediaInsertDialog.prototype.onSearchSelect = function ( item ) {
*/
ve.ui.MWMediaInsertDialog.prototype.initialize = function () {
// Parent method
ve.ui.MWDialog.prototype.initialize.call( this );
ve.ui.Dialog.prototype.initialize.call( this );
this.defaultThumbSize = mw.config.get( 'wgVisualEditorConfig' )
.defaultUserOptions.defaultthumbsize;
@ -88,7 +87,7 @@ ve.ui.MWMediaInsertDialog.prototype.initialize = function () {
*/
ve.ui.MWMediaInsertDialog.prototype.setup = function ( data ) {
// Parent method
ve.ui.MWDialog.prototype.setup.call( this, data );
ve.ui.Dialog.prototype.setup.call( this, data );
// Show a spinner while we check for file repos.
// this will only be done once per session.
@ -189,7 +188,7 @@ ve.ui.MWMediaInsertDialog.prototype.teardown = function ( data ) {
};
}
this.surface.getModel().getFragment().collapseRangeToEnd().insertContent( [
this.getFragment().collapseRangeToEnd().insertContent( [
{
'type': 'mwBlockImage',
'attributes': {
@ -213,7 +212,7 @@ ve.ui.MWMediaInsertDialog.prototype.teardown = function ( data ) {
this.search.clear();
// Parent method
ve.ui.MWDialog.prototype.teardown.call( this, data );
ve.ui.Dialog.prototype.teardown.call( this, data );
};
/* Registration */

View file

@ -9,20 +9,19 @@
* Dialog for editing MediaWiki page meta information.
*
* @class
* @extends ve.ui.MWDialog
* @extends ve.ui.Dialog
*
* @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.Dialog.call( this, config );
};
/* Inheritance */
OO.inheritClass( ve.ui.MWMetaDialog, ve.ui.MWDialog );
OO.inheritClass( ve.ui.MWMetaDialog, ve.ui.Dialog );
/* Static Properties */
@ -40,7 +39,7 @@ ve.ui.MWMetaDialog.static.icon = 'window';
*/
ve.ui.MWMetaDialog.prototype.initialize = function () {
// Parent method
ve.ui.MWDialog.prototype.initialize.call( this );
ve.ui.Dialog.prototype.initialize.call( this );
// Properties
this.bookletLayout = new OO.ui.BookletLayout( { '$': this.$, 'outlined': true } );
@ -50,17 +49,14 @@ ve.ui.MWMetaDialog.prototype.initialize = function () {
'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.$,
@ -91,12 +87,12 @@ ve.ui.MWMetaDialog.prototype.initialize = function () {
*/
ve.ui.MWMetaDialog.prototype.setup = function ( data ) {
// Parent method
ve.ui.MWDialog.prototype.setup.call( this, data );
ve.ui.Dialog.prototype.setup.call( this, data );
// 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 @@ ve.ui.MWMetaDialog.prototype.setup = function ( data ) {
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,10 +128,10 @@ ve.ui.MWMetaDialog.prototype.teardown = function ( data ) {
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 );
ve.ui.Dialog.prototype.teardown.call( this, data );
};
/* Registration */

View file

@ -9,18 +9,17 @@
* Dialog for editing MediaWiki references.
*
* @class
* @extends ve.ui.MWDialog
* @extends ve.ui.Dialog
*
* @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.Dialog.call( this, config );
// Properties
this.referenceModel = null;
@ -28,7 +27,7 @@ ve.ui.MWReferenceDialog = function VeUiMWReferenceDialog( surface, config ) {
/* Inheritance */
OO.inheritClass( ve.ui.MWReferenceDialog, ve.ui.MWDialog );
OO.inheritClass( ve.ui.MWReferenceDialog, ve.ui.Dialog );
/* Static Properties */
@ -160,8 +159,8 @@ ve.ui.MWReferenceDialog.prototype.onSearchSelect = function ( ref ) {
* @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;
};
/**
@ -212,7 +211,7 @@ ve.ui.MWReferenceDialog.prototype.useReference = function ( ref ) {
*/
ve.ui.MWReferenceDialog.prototype.initialize = function () {
// Parent method
ve.ui.MWDialog.prototype.initialize.call( this );
ve.ui.Dialog.prototype.initialize.call( this );
// Properties
this.panels = new OO.ui.StackLayout( { '$': this.$ } );
@ -254,9 +253,7 @@ ve.ui.MWReferenceDialog.prototype.initialize = function () {
'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' } ] } );
@ -296,7 +293,7 @@ ve.ui.MWReferenceDialog.prototype.initialize = function () {
*/
ve.ui.MWReferenceDialog.prototype.setup = function ( data ) {
// Parent method
ve.ui.MWDialog.prototype.setup.call( this, data );
ve.ui.Dialog.prototype.setup.call( this, data );
this.referenceNode = this.getReferenceNode();
@ -318,7 +315,7 @@ ve.ui.MWReferenceDialog.prototype.setup = function ( data ) {
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 @@ ve.ui.MWReferenceDialog.prototype.setup = function ( data ) {
* @inheritdoc
*/
ve.ui.MWReferenceDialog.prototype.teardown = function ( data ) {
var surfaceModel = this.surface.getModel();
var surfaceModel = this.getFragment().getSurface();
// Data initialization
data = data || {};
@ -352,7 +349,7 @@ ve.ui.MWReferenceDialog.prototype.teardown = function ( data ) {
this.referenceNode = null;
// Parent method
ve.ui.MWDialog.prototype.teardown.call( this, data );
ve.ui.Dialog.prototype.teardown.call( this, data );
};
/* Registration */

View file

@ -9,18 +9,17 @@
* Dialog for inserting and editing MediaWiki reference lists.
*
* @class
* @extends ve.ui.MWDialog
* @extends ve.ui.Dialog
*
* @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.Dialog.call( this, config );
// Properties
this.inserting = false;
@ -28,7 +27,7 @@ ve.ui.MWReferenceListDialog = function VeUiMWReferenceListDialog( surface, confi
/* Inheritance */
OO.inheritClass( ve.ui.MWReferenceListDialog, ve.ui.MWDialog );
OO.inheritClass( ve.ui.MWReferenceListDialog, ve.ui.Dialog );
/* Static Properties */
@ -46,7 +45,7 @@ ve.ui.MWReferenceListDialog.static.icon = 'references';
*/
ve.ui.MWReferenceListDialog.prototype.initialize = function () {
// Parent method
ve.ui.MWDialog.prototype.initialize.call( this );
ve.ui.Dialog.prototype.initialize.call( this );
// Properties
this.editPanel = new OO.ui.PanelLayout( {
@ -86,15 +85,15 @@ ve.ui.MWReferenceListDialog.prototype.initialize = function () {
*/
ve.ui.MWReferenceListDialog.prototype.setup = function ( data ) {
// Parent method
ve.ui.MWDialog.prototype.setup.call( this, data );
ve.ui.Dialog.prototype.setup.call( this, data );
var node, refGroup;
// 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 @@ ve.ui.MWReferenceListDialog.prototype.setup = function ( data ) {
* Focused node.
*
* @private
* @property {ve.ce.MWReferenceListNode|undefined}
* @property {ve.dm.MWReferenceListNode|undefined}
*/
this.node = node;
};
@ -121,10 +120,8 @@ ve.ui.MWReferenceListDialog.prototype.setup = function ( data ) {
* @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 @@ ve.ui.MWReferenceListDialog.prototype.teardown = function ( data ) {
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 @@ ve.ui.MWReferenceListDialog.prototype.teardown = function ( data ) {
};
surfaceModel.change(
ve.dm.Transaction.newFromAttributeChanges(
doc, model.getOuterRange().start, attrChanges
doc, this.node.getOuterRange().start, attrChanges
)
);
}
@ -167,7 +163,7 @@ ve.ui.MWReferenceListDialog.prototype.teardown = function ( data ) {
}
// Parent method
ve.ui.MWDialog.prototype.teardown.call( this, data );
ve.ui.Dialog.prototype.teardown.call( this, data );
};
/* Registration */

View file

@ -14,18 +14,17 @@
* noted otherwise.
*
* @class
* @extends ve.ui.MWDialog
* @extends ve.ui.Dialog
*
* @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.Dialog.call( this, config );
// Properties
this.sanityCheckVerified = false;
@ -37,7 +36,7 @@ ve.ui.MWSaveDialog = function VeUiMWSaveDialog( surface, config ) {
/* Inheritance */
OO.inheritClass( ve.ui.MWSaveDialog, ve.ui.MWDialog );
OO.inheritClass( ve.ui.MWSaveDialog, ve.ui.Dialog );
/* Static Properties */
@ -297,7 +296,7 @@ ve.ui.MWSaveDialog.prototype.setEditSummary = function ( summary ) {
ve.ui.MWSaveDialog.prototype.initialize = function () {
var saveDialog = this;
// Parent method
ve.ui.MWDialog.prototype.initialize.call( this );
ve.ui.Dialog.prototype.initialize.call( this );
// Properties
this.savePanel = new OO.ui.PanelLayout( { '$': this.$, 'scrollable': true } );

View file

@ -9,15 +9,14 @@
* Dialog for inserting and editing MediaWiki transclusions.
*
* @class
* @extends ve.ui.MWDialog
* @extends ve.ui.Dialog
*
* @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.Dialog.call( this, config );
// Properties
this.transclusionNode = null;
@ -30,7 +29,7 @@ ve.ui.MWTransclusionDialog = function VeUiMWTransclusionDialog( surface, config
/* Inheritance */
OO.inheritClass( ve.ui.MWTransclusionDialog, ve.ui.MWDialog );
OO.inheritClass( ve.ui.MWTransclusionDialog, ve.ui.Dialog );
/* Static Properties */
@ -412,7 +411,7 @@ ve.ui.MWTransclusionDialog.prototype.addPart = function ( part ) {
*/
ve.ui.MWTransclusionDialog.prototype.initialize = function () {
// Parent method
ve.ui.MWDialog.prototype.initialize.call( this );
ve.ui.Dialog.prototype.initialize.call( this );
// Properties
this.applyButton = new OO.ui.ButtonWidget( {
@ -473,15 +472,15 @@ ve.ui.MWTransclusionDialog.prototype.initialize = function () {
* @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 ) {
@ -499,7 +498,7 @@ ve.ui.MWTransclusionDialog.prototype.setup = function ( data ) {
transclusionNode = this.getTransclusionNode( data );
// Parent method
ve.ui.MWDialog.prototype.setup.call( this, data );
ve.ui.Dialog.prototype.setup.call( this, data );
// Data initialization
data = data || {};
@ -562,7 +561,7 @@ ve.ui.MWTransclusionDialog.prototype.teardown = function ( data ) {
this.setMode( 'single' );
// Parent method
ve.ui.MWDialog.prototype.teardown.call( this, data );
ve.ui.Dialog.prototype.teardown.call( this, data );
};
/* Registration */

View file

@ -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.icon = 'alienextension';
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 @@ ve.ui.MWAlienExtensionInspector.static.nodeModel = ve.dm.MWAlienExtensionNode;
* @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.getTitle = function () {
*/
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 @@ ve.ui.MWAlienExtensionInspector.prototype.initialize = function () {
'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

View file

@ -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 */
@ -29,8 +28,6 @@ OO.inheritClass( ve.ui.MWExtensionInspector, ve.ui.Inspector );
ve.ui.MWExtensionInspector.static.placeholder = null;
ve.ui.MWExtensionInspector.static.nodeView = null;
ve.ui.MWExtensionInspector.static.nodeModel = null;
ve.ui.MWExtensionInspector.static.removable = false;
@ -57,7 +54,6 @@ ve.ui.MWExtensionInspector.prototype.initialize = function () {
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 @@ ve.ui.MWExtensionInspector.prototype.getInputPlaceholder = function () {
* @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.ready = function () {
*/
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(

View file

@ -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 */
@ -35,8 +34,6 @@ ve.ui.MWGalleryInspector.static.icon = 'gallery';
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;
/* Methods */

View file

@ -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 */
@ -33,8 +32,6 @@ ve.ui.MWHieroInspector.static.icon = 'hiero';
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;
/* Methods */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 @@ ve.ui.MWAdvancedSettingsPage.prototype.getNewSectionEditLinkItem = function () {
/**
* 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 @@ ve.ui.MWAdvancedSettingsPage.prototype.teardown = function ( data ) {
}
}
}
this.metaList = null;
};

View file

@ -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 @@ ve.ui.MWCategoriesPage = function VeUiMWCategoriesPage( surface, name, config )
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 @@ ve.ui.MWCategoriesPage = function VeUiMWCategoriesPage( surface, name, config )
);
// Events
this.metaList.connect( this, {
'insert': 'onMetaListInsert',
'remove': 'onMetaListRemove'
} );
this.categoryWidget.connect( this, {
'newCategory': 'onNewCategory',
'updateSortkey': 'onUpdateSortKey'
@ -72,7 +67,6 @@ ve.ui.MWCategoriesPage = function VeUiMWCategoriesPage( surface, name, config )
} );
// 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,11 +224,22 @@ ve.ui.MWCategoriesPage.prototype.insertMetaListItem = function ( metaBase ) {
};
/**
* 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,8 @@ ve.ui.MWCategoriesPage.prototype.teardown = function () {
}
}
}
this.categoryWidget.clearItems();
this.metaList.disconnect( this );
this.metaList = null;
};

View file

@ -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 @@ ve.ui.MWSettingsPage.prototype.getDisableSectionEditLinksItem = function () {
/**
* 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 @@ ve.ui.MWSettingsPage.prototype.teardown = function ( data ) {
if ( !currentDisableSectionEditLinksItem && newDisableSectionEditState ) {
this.metaList.insertMeta( { 'type': 'mwNoEditSection' } );
}
this.metaList = null;
};

View file

@ -1,26 +0,0 @@
/*!
* VisualEditor UserInterface MWDialog class.
*
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* UserInterface MediaWiki dialog.
*
* @class
* @abstract
* @extends ve.ui.Dialog
*
* @constructor
* @param {ve.ui.Surface} surface Surface inspector is for
* @param {Object} [config] Configuration options
*/
ve.ui.MWDialog = function VeUiMWDialog( surface, config ) {
// Parent constructor
ve.ui.Dialog.call( this, surface, config );
};
/* Inheritance */
OO.inheritClass( ve.ui.MWDialog, ve.ui.Dialog );

View file

@ -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,6 @@ ve.ui.MWReferenceSearchWidget = function VeUiMWReferenceSearchWidget( surface, c
OO.ui.SearchWidget.call( this, config );
// Properties
this.surface = surface;
this.index = [];
// Initialization
@ -86,11 +84,11 @@ ve.ui.MWReferenceSearchWidget.prototype.onResultsSelect = function ( item ) {
* 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() {