mediawiki-extensions-Visual.../modules/ve/ui/widgets/ve.ui.SurfaceWidget.js
Trevor Parscal 61ba07d409 Reference dialog commingling
Objectives:

* Merge reference insert and edit dialogs
* Change workflow to put editing/creating a new reference first
* Add secondary page in dialog for selecting an existing reference

Changes:

*.php
* Cleanup unused files/messages

ve.ui.Dialog.css
* In the footer; make primary, constructive and destructive buttons
  appear on the right; all others on the left

ve.ui.MWReferenceSearchWidget.js
* Fix documentation
* Remove create option and reuse section header items

ve.ui.MWReferenceInsertButtonTool.js,
ve.ui.MWReferenceEditButtonTool.js,
ve.ui.MWReferenceButtonTool.js
* Merge reference button tools

ve.ui.MWDialog.css
* Remove body styles, use padded option of layout instead
* Update selectors as per merging of dialogs

ve.ui.MWReferenceInsertDialog.js
ve.ui.MWReferenceEditDialog.js
ve.ui.MWReferenceDialog.js
* Merge reference dialogs
* Add buttons to switch between edit and select mode

ve.init.mw.ViewPageTarget.js
* Update reference button name as per merging of tools

ve.ui.SurfaceWidget.js
* New widget!
* Encapsulates a "sub-surface"

Bug: 51152
Bug: 50458
Change-Id: I8265febf4fd8f64d2ac40470ff033bac68b24d99
2013-07-18 14:14:14 -07:00

106 lines
2.1 KiB
JavaScript

/*!
* VisualEditor UserInterface SurfaceWidget class.
*
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* Creates an ve.ui.SurfaceWidget object.
*
* @class
* @abstract
* @extends ve.ui.Widget
*
* @constructor
* @param {ve.dm.ElementLinearData} data Content data
* @param {Object} [config] Config options
* @cfg {Object[]} [tools] Toolbar configuration
* @cfg {string[]} [commands] List of supported commands
*/
ve.ui.SurfaceWidget = function VeUiSurfaceWidget( data, config ) {
// Config intialization
config = config || {};
// Parent constructor
ve.ui.Widget.call( this, config );
// Properties
this.surface = new ve.ui.Surface( data, { '$$': this.$$ } );
this.toolbar = new ve.ui.Toolbar( this.surface, { '$$': this.$$ } );
// Initialization
this.$
.addClass( 've-ui-surfaceWidget' )
.append( this.toolbar.$, this.surface.$ );
if ( config.tools ) {
this.toolbar.addTools( config.tools );
}
if ( config.commands ) {
this.surface.addCommands( config.commands );
}
};
/* Inheritance */
ve.inheritClass( ve.ui.SurfaceWidget, ve.ui.Widget );
/* Methods */
/**
* Get surface.
*
* @method
* @returns {ve.ui.Surface} Surface
*/
ve.ui.SurfaceWidget.prototype.getSurface = function () {
return this.surface;
};
/**
* Get toolbar.
*
* @method
* @returns {ve.ui.Toolbar} Toolbar
*/
ve.ui.SurfaceWidget.prototype.getToolbar = function () {
return this.toolbar;
};
/**
* Get content data.
*
* @method
* @returns {ve.dm.ElementLinearData} Content data
*/
ve.ui.SurfaceWidget.prototype.getContent = function () {
return this.surface.getModel().getDocument().getData();
};
/**
* Initialize surface and toolbar.
*
* Widget must be attached to DOM before initializing.
*
* @method
*/
ve.ui.SurfaceWidget.prototype.initialize = function () {
this.surface.initialize();
this.surface.view.documentView.documentNode.$.focus();
};
/**
* Destroy surface and toolbar.
*
* @method
*/
ve.ui.SurfaceWidget.prototype.destroy = function () {
if ( this.surface ) {
this.surface.destroy();
}
if ( this.toolbar ) {
this.toolbar.destroy();
}
this.$.remove();
};