2013-06-18 22:58:10 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor user interface MWMediaEditDialog class.
|
|
|
|
*
|
2014-01-05 12:05:05 +00:00
|
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
2013-06-18 22:58:10 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
2014-02-20 05:11:04 +00:00
|
|
|
/*global mw */
|
2013-06-18 22:58:10 +00:00
|
|
|
|
|
|
|
/**
|
Single-click insertion
Objectives:
* Reduce the number of clicks and mouse maneuvers required to insert
media, references or template parameters
* Make use of highlighting with mouse movement or arrow key presses,
similar to menus, to suggest action when clicked
* Improve the way media search results look and feel
Changes:
ve.ui.SelectWidget.js
* Add mouseleave handler to un-highlight when the mouse exits the widget
* Document highlight events (already being emitted)
ve.ui.SearchWidget.js
* Propagate both select and highlight events from results widget
* Make arrow keys change highlight instead of selection
* Get rid of enter event, make enter key select highlighted item instead
* Provide direct access to results widget through getResults method
ve.ui.MenuWidget.js
* Use the selected item as a starting point if nothing is currently
highlighted when adjusting the highlight position
ve.ui.Dialog.js
* Add footless option to hide the foot element and make the body extend
all the way down to the bottom
* Remove applyButton, which only some dialogs need, and should be creating
themselves, along with other buttons as needed
ve.ui.Widget.css
* Change highlight and selected colors of option widgets to match other
selection colors used elsewhere
* Leave selected and highlighted widget looking selected
ve.ui.Frame.css
* Add background color to combat any color that might have been applied to
the frame body in the imported CSS from the parent frame
ve.ui.Dialog.css
* Add rules for footless mode
ve.ui.MWReferenceResultWidget.js,
ve.ui.MWParameterResultWidget.js,
ve.ui.MWMediaResultWidget.js
* Allow highlighting
ve.ui.MWParamterSearchWidget.js
* Switch from selecting the first item when filtering to highlighting
ve-mw/ve.ui.Widget.js
* Adjust media result widget styling to better match other elements
ve.ui.MWTransclusionDialog.js,
ve.ui.MWReferenceListDialog.js,
ve.ui.MWReferenceEditDialog.js,
ve.ui.MWMetaDialog.js
ve.ui.MWMediaEditDialog.js
* Add apply button, as per it being removed from parent class
ve.ui.MWTransclusionDialog.js,
ve.ui.MWReferenceInsertDialog.js,
ve.ui.MWMediaInsertDialog.js
* Insert parameter/reference/media on select, instead of clicking an
insert button
* Use 'insert' instead of 'apply' as argument for close method
Bug: 50774
Bug: 51143
Change-Id: Ia18e79f1f8df2540f465468edb01f5ce989bf843
2013-07-15 21:07:53 +00:00
|
|
|
* Dialog for editing MediaWiki media objects.
|
2013-06-18 22:58:10 +00:00
|
|
|
*
|
|
|
|
* @class
|
2013-07-03 01:30:10 +00:00
|
|
|
* @extends ve.ui.MWDialog
|
2013-06-18 22:58:10 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
2014-03-06 01:07:20 +00:00
|
|
|
* @param {ve.ui.Surface} surface Surface inspector is for
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2013-06-18 22:58:10 +00:00
|
|
|
*/
|
2014-03-06 01:07:20 +00:00
|
|
|
ve.ui.MWMediaEditDialog = function VeUiMWMediaEditDialog( surface, config ) {
|
2013-06-18 22:58:10 +00:00
|
|
|
// Parent constructor
|
2014-03-06 01:07:20 +00:00
|
|
|
ve.ui.MWDialog.call( this, surface, config );
|
2013-06-18 22:58:10 +00:00
|
|
|
|
|
|
|
// Properties
|
Introduce newFromDocumentReplace() transaction builder
Replaces newFromNodeReplacement(). newFromNodeReplacement was very
simplistic and didn't support metadata or internal list items, so
if you had comments or references inside of the data you were editing
(reference contents or an image caption), they'd get mangled.
With this, you can do:
newDoc = doc.getDocumentSlice( node );
// Edit newDoc
tx = ve.dm.Transaction.newFromDocumentReplace( doc, node, newDoc );
surface.change( newDoc );
and that takes care of metadata, internal list items, and things like
references that reference internal list items.
ve.dm.Document.js:
* In getDocumentSlice(), store a reference to the original document
and the number of items in its InternalList at the time of slicing
in the created slice. This is used for reconciliation when the
modified slice is injected back into the parent document with
newFromDocumentReplace().
ve.dm.InternalList.js:
* Add a method for merging in another InternalList. This provides a
mapping from old to new InternalList indexes so the linear model data
being injected by newFromDocumentReplace() can have its InternalList
indexes remapped.
ve.dm.Transaction.js:
* Replace newFromNodeReplacement() with newFromDocumentReplace()
ve.ui.MWMediaEditDialog.js, ve.ui.MWReferenceDialog.js:
* Use getDocumentSlice/newFromDocumentReplace for editing captions/refs
* Change insertion code path to insert an empty internalItem/caption, then
newFromDocumentReplace into that
* Add empty internalList to new mini-documents
ve/test/dm/ve.dm.Transaction.test.js:
* Replace newFromNodeReplacement tests with newFromDocumentReplace tests
ve-mw/test/dm/ve.dm.Transaction.test.js (new):
* Add tests for newFromDocumentReplace with mwReference nodes
ve.dm.mwExample.js:
* Add data for newFromDocumentReplace with mwReference tests
VisualEditor.hooks.php:
* Add new test file
Bug: 52102
Change-Id: I4aa980780114b391924f04df588e81c990c32983
2013-09-05 01:05:07 +00:00
|
|
|
this.mediaNode = null;
|
2013-06-18 22:58:10 +00:00
|
|
|
this.captionNode = null;
|
2014-01-26 14:26:57 +00:00
|
|
|
this.store = null;
|
2013-06-18 22:58:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2013-10-11 21:44:09 +00:00
|
|
|
OO.inheritClass( ve.ui.MWMediaEditDialog, ve.ui.MWDialog );
|
2013-06-18 22:58:10 +00:00
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
|
2013-08-27 23:28:29 +00:00
|
|
|
ve.ui.MWMediaEditDialog.static.name = 'mediaEdit';
|
|
|
|
|
2014-02-12 21:45:37 +00:00
|
|
|
ve.ui.MWMediaEditDialog.static.title =
|
|
|
|
OO.ui.deferMsg( 'visualeditor-dialog-media-title' );
|
2013-06-18 22:58:10 +00:00
|
|
|
|
|
|
|
ve.ui.MWMediaEditDialog.static.icon = 'picture';
|
|
|
|
|
2013-08-09 18:29:09 +00:00
|
|
|
ve.ui.MWMediaEditDialog.static.toolbarGroups = [
|
2013-12-12 19:04:15 +00:00
|
|
|
// History
|
2013-08-27 23:28:29 +00:00
|
|
|
{ 'include': [ 'undo', 'redo' ] },
|
2013-12-12 19:04:15 +00:00
|
|
|
// No formatting
|
|
|
|
/* {
|
|
|
|
'type': 'menu',
|
2014-01-13 22:46:15 +00:00
|
|
|
'indicator': 'down',
|
2014-03-15 00:01:44 +00:00
|
|
|
'title': OO.ui.deferMsg( 'visualeditor-toolbar-format-tooltip' ),
|
2013-12-12 19:04:15 +00:00
|
|
|
'include': [ { 'group': 'format' } ],
|
|
|
|
'promote': [ 'paragraph' ],
|
|
|
|
'demote': [ 'preformatted', 'heading1' ]
|
|
|
|
},*/
|
|
|
|
// Style
|
|
|
|
{
|
|
|
|
'type': 'list',
|
|
|
|
'icon': 'text-style',
|
2014-01-13 22:46:15 +00:00
|
|
|
'indicator': 'down',
|
2014-03-15 00:01:44 +00:00
|
|
|
'title': OO.ui.deferMsg( 'visualeditor-toolbar-style-tooltip' ),
|
2013-12-12 19:04:15 +00:00
|
|
|
'include': [ { 'group': 'textStyle' }, 'clear' ],
|
|
|
|
'promote': [ 'bold', 'italic' ],
|
2014-03-15 00:01:44 +00:00
|
|
|
'demote': [ 'strikethrough', 'code', 'underline', 'clear' ]
|
2013-12-12 19:04:15 +00:00
|
|
|
},
|
|
|
|
// Link
|
|
|
|
{ 'include': [ 'link' ] },
|
|
|
|
// No structure
|
|
|
|
/* {
|
|
|
|
'type': 'bar',
|
|
|
|
'include': [ 'number', 'bullet', 'outdent', 'indent' ]
|
|
|
|
},*/
|
|
|
|
// Insert
|
2013-09-05 00:32:50 +00:00
|
|
|
{
|
2014-02-12 23:04:28 +00:00
|
|
|
'label': OO.ui.deferMsg( 'visualeditor-toolbar-insert' ),
|
2014-01-13 22:46:15 +00:00
|
|
|
'indicator': 'down',
|
2013-09-05 00:32:50 +00:00
|
|
|
'include': '*',
|
2014-02-05 19:45:56 +00:00
|
|
|
'exclude': [
|
2014-03-15 00:01:44 +00:00
|
|
|
{ 'group': 'format' },
|
|
|
|
{ 'group': 'structure' },
|
2014-02-05 19:45:56 +00:00
|
|
|
'referenceList',
|
|
|
|
'gallery'
|
|
|
|
],
|
2014-03-05 22:49:52 +00:00
|
|
|
'promote': [ 'reference', 'mediaInsert' ],
|
|
|
|
'demote': [ 'language', 'specialcharacter' ]
|
2013-09-05 00:32:50 +00:00
|
|
|
}
|
2013-06-18 22:58:10 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
ve.ui.MWMediaEditDialog.static.surfaceCommands = [
|
2013-12-12 19:04:15 +00:00
|
|
|
'undo',
|
|
|
|
'redo',
|
|
|
|
'bold',
|
|
|
|
'italic',
|
|
|
|
'link',
|
|
|
|
'clear',
|
|
|
|
'underline',
|
|
|
|
'subscript',
|
|
|
|
'superscript',
|
|
|
|
'pasteSpecial'
|
2013-06-18 22:58:10 +00:00
|
|
|
];
|
|
|
|
|
2014-02-03 15:08:52 +00:00
|
|
|
ve.ui.MWMediaEditDialog.static.pasteRules = ve.extendObject(
|
2014-02-06 22:30:07 +00:00
|
|
|
ve.copy( ve.init.mw.Target.static.pasteRules ),
|
2014-02-03 15:08:52 +00:00
|
|
|
{
|
|
|
|
'all': {
|
|
|
|
'blacklist': OO.simpleArrayUnion(
|
2014-02-06 22:30:07 +00:00
|
|
|
ve.getProp( ve.init.mw.Target.static.pasteRules, 'all', 'blacklist' ) || [],
|
2014-02-03 15:08:52 +00:00
|
|
|
[
|
|
|
|
// Tables (but not lists) are possible in wikitext with a leading
|
|
|
|
// line break but we prevent creating these with the UI
|
|
|
|
'list', 'listItem', 'definitionList', 'definitionListItem',
|
|
|
|
'table', 'tableCaption', 'tableSection', 'tableRow', 'tableCell'
|
|
|
|
]
|
|
|
|
),
|
|
|
|
// Headings are also possible, but discouraged
|
|
|
|
'conversions': {
|
|
|
|
'mwHeading': 'paragraph'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2013-06-18 22:58:10 +00:00
|
|
|
/* Methods */
|
|
|
|
|
2013-11-05 00:29:50 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2013-06-18 22:58:10 +00:00
|
|
|
ve.ui.MWMediaEditDialog.prototype.initialize = function () {
|
2014-02-27 17:39:19 +00:00
|
|
|
var altTextFieldset, positionFieldset, borderField, positionField;
|
2013-06-21 02:47:10 +00:00
|
|
|
// Parent method
|
2013-07-03 01:30:10 +00:00
|
|
|
ve.ui.MWDialog.prototype.initialize.call( this );
|
2013-06-18 22:58:10 +00:00
|
|
|
|
2013-12-21 22:37:54 +00:00
|
|
|
// Set up the booklet layout
|
|
|
|
this.bookletLayout = new OO.ui.BookletLayout( {
|
|
|
|
'$': this.$,
|
|
|
|
'outlined': true
|
|
|
|
} );
|
|
|
|
|
2014-02-15 01:37:32 +00:00
|
|
|
this.generalSettingsPage = new OO.ui.PageLayout( 'general', { '$': this.$ } );
|
|
|
|
this.advancedSettingsPage = new OO.ui.PageLayout( 'advanced', { '$': this.$ } );
|
2013-12-21 22:37:54 +00:00
|
|
|
this.bookletLayout.addPages( [
|
|
|
|
this.generalSettingsPage, this.advancedSettingsPage
|
|
|
|
] );
|
2014-02-15 01:37:32 +00:00
|
|
|
this.generalSettingsPage.getOutlineItem()
|
|
|
|
.setIcon( 'parameter' )
|
|
|
|
.setLabel( ve.msg( 'visualeditor-dialog-media-page-general' ) );
|
|
|
|
this.advancedSettingsPage.getOutlineItem()
|
|
|
|
.setIcon( 'parameter' )
|
|
|
|
.setLabel( ve.msg( 'visualeditor-dialog-media-page-advanced' ) );
|
2013-12-21 22:37:54 +00:00
|
|
|
|
|
|
|
// Define fieldsets for image settings
|
|
|
|
|
|
|
|
// Caption
|
2014-01-26 14:26:57 +00:00
|
|
|
this.captionFieldset = new OO.ui.FieldsetLayout( {
|
2013-11-01 19:45:59 +00:00
|
|
|
'$': this.$,
|
2013-06-18 22:58:10 +00:00
|
|
|
'label': ve.msg( 'visualeditor-dialog-media-content-section' ),
|
|
|
|
'icon': 'parameter'
|
|
|
|
} );
|
2013-12-21 22:37:54 +00:00
|
|
|
|
2013-12-28 10:29:35 +00:00
|
|
|
// Alt text
|
|
|
|
altTextFieldset = new OO.ui.FieldsetLayout( {
|
|
|
|
'$': this.$,
|
|
|
|
'label': ve.msg( 'visualeditor-dialog-media-alttext-section' ),
|
|
|
|
'icon': 'parameter'
|
|
|
|
} );
|
|
|
|
|
|
|
|
this.altTextInput = new OO.ui.TextInputWidget( {
|
|
|
|
'$': this.$
|
|
|
|
} );
|
|
|
|
|
2014-02-18 19:45:21 +00:00
|
|
|
this.altTextInput.$element.addClass( 've-ui-mwMediaEditDialog-altText' );
|
|
|
|
|
2013-12-28 10:29:35 +00:00
|
|
|
// Build alt text fieldset
|
|
|
|
altTextFieldset.$element
|
|
|
|
.append( this.altTextInput.$element );
|
|
|
|
|
2013-12-29 03:49:06 +00:00
|
|
|
// Position
|
2013-12-29 05:49:56 +00:00
|
|
|
this.positionInput = new OO.ui.ButtonSelectWidget( {
|
2013-12-29 03:49:06 +00:00
|
|
|
'$': this.$
|
|
|
|
} );
|
|
|
|
this.positionInput.addItems( [
|
2014-03-03 11:42:52 +00:00
|
|
|
new OO.ui.ButtonOptionWidget( 'left', {
|
|
|
|
'$': this.$,
|
|
|
|
'icon': 'align-float-left',
|
|
|
|
'label': ve.msg( 'visualeditor-dialog-media-position-left' )
|
|
|
|
} ),
|
|
|
|
new OO.ui.ButtonOptionWidget( 'center', {
|
|
|
|
'$': this.$,
|
|
|
|
'icon': 'align-center',
|
|
|
|
'label': ve.msg( 'visualeditor-dialog-media-position-center' )
|
|
|
|
} ),
|
|
|
|
new OO.ui.ButtonOptionWidget( 'right', {
|
|
|
|
'$': this.$,
|
|
|
|
'icon': 'align-float-right',
|
|
|
|
'label': ve.msg( 'visualeditor-dialog-media-position-right' )
|
|
|
|
} ),
|
2013-12-29 03:49:06 +00:00
|
|
|
], 0 );
|
2014-01-21 18:05:50 +00:00
|
|
|
|
|
|
|
this.positionCheckbox = new OO.ui.CheckboxInputWidget( {
|
|
|
|
'$': this.$
|
|
|
|
} );
|
|
|
|
positionField = new OO.ui.FieldLayout( this.positionCheckbox, {
|
|
|
|
'$': this.$,
|
|
|
|
'align': 'inline',
|
|
|
|
'label': ve.msg( 'visualeditor-dialog-media-position-checkbox' )
|
|
|
|
} );
|
|
|
|
|
|
|
|
positionFieldset = new OO.ui.FieldsetLayout( {
|
|
|
|
'$': this.$,
|
|
|
|
'label': ve.msg( 'visualeditor-dialog-media-position-section' ),
|
|
|
|
'icon': 'parameter'
|
|
|
|
} );
|
|
|
|
|
2013-12-29 03:49:06 +00:00
|
|
|
// Build position fieldset
|
2014-01-21 18:05:50 +00:00
|
|
|
positionFieldset.$element.append( [
|
|
|
|
positionField.$element,
|
|
|
|
this.positionInput.$element
|
|
|
|
] );
|
2013-12-29 03:49:06 +00:00
|
|
|
|
2013-12-29 05:49:56 +00:00
|
|
|
// Type
|
|
|
|
this.typeFieldset = new OO.ui.FieldsetLayout( {
|
|
|
|
'$': this.$,
|
|
|
|
'label': ve.msg( 'visualeditor-dialog-media-type-section' ),
|
|
|
|
'icon': 'parameter'
|
|
|
|
} );
|
|
|
|
|
|
|
|
this.typeInput = new OO.ui.ButtonSelectWidget( {
|
|
|
|
'$': this.$
|
|
|
|
} );
|
|
|
|
this.typeInput.addItems( [
|
|
|
|
// TODO: Inline images require a bit of further work, will be coming soon
|
|
|
|
new OO.ui.ButtonOptionWidget( 'thumb', {
|
|
|
|
'$': this.$,
|
|
|
|
'label': ve.msg( 'visualeditor-dialog-media-type-thumb' )
|
|
|
|
} ),
|
|
|
|
new OO.ui.ButtonOptionWidget( 'frameless', {
|
|
|
|
'$': this.$,
|
|
|
|
'label': ve.msg( 'visualeditor-dialog-media-type-frameless' )
|
|
|
|
} ),
|
|
|
|
new OO.ui.ButtonOptionWidget( 'frame', {
|
|
|
|
'$': this.$,
|
|
|
|
'label': ve.msg( 'visualeditor-dialog-media-type-frame' )
|
|
|
|
} ),
|
2014-02-27 17:39:19 +00:00
|
|
|
new OO.ui.ButtonOptionWidget( 'none', {
|
2013-12-29 05:49:56 +00:00
|
|
|
'$': this.$,
|
2014-02-27 17:39:19 +00:00
|
|
|
'label': ve.msg( 'visualeditor-dialog-media-type-none' )
|
2013-12-29 05:49:56 +00:00
|
|
|
} )
|
|
|
|
] );
|
2014-02-27 17:39:19 +00:00
|
|
|
this.borderCheckbox = new OO.ui.CheckboxInputWidget( {
|
|
|
|
'$': this.$
|
|
|
|
} );
|
|
|
|
borderField = new OO.ui.FieldLayout( this.borderCheckbox, {
|
|
|
|
'$': this.$,
|
|
|
|
'align': 'inline',
|
|
|
|
'label': ve.msg( 'visualeditor-dialog-media-type-border' )
|
|
|
|
} );
|
2013-12-29 05:49:56 +00:00
|
|
|
|
|
|
|
// Build type fieldset
|
2014-02-27 17:39:19 +00:00
|
|
|
this.typeFieldset.$element.append( [
|
|
|
|
this.typeInput.$element,
|
|
|
|
borderField.$element
|
|
|
|
] );
|
2013-12-29 05:49:56 +00:00
|
|
|
|
2013-12-21 22:37:54 +00:00
|
|
|
// Size
|
2014-01-26 14:26:57 +00:00
|
|
|
this.sizeFieldset = new OO.ui.FieldsetLayout( {
|
2013-12-21 22:37:54 +00:00
|
|
|
'$': this.$,
|
|
|
|
'label': ve.msg( 'visualeditor-dialog-media-size-section' ),
|
|
|
|
'icon': 'parameter'
|
|
|
|
} );
|
|
|
|
|
2014-01-22 20:13:59 +00:00
|
|
|
this.sizeErrorLabel = new OO.ui.LabelWidget( {
|
2013-12-21 22:37:54 +00:00
|
|
|
'$': this.$,
|
|
|
|
'label': ve.msg( 'visualeditor-dialog-media-size-originalsize-error' )
|
|
|
|
} );
|
|
|
|
|
2014-01-26 14:26:57 +00:00
|
|
|
this.sizeWidget = new ve.ui.MediaSizeWidget( {
|
2014-02-27 17:39:19 +00:00
|
|
|
'$': this.$,
|
|
|
|
'showOriginalDimensionsButton': false
|
2013-12-21 22:37:54 +00:00
|
|
|
} );
|
|
|
|
|
2014-02-20 05:11:04 +00:00
|
|
|
this.sizeSelectWidget = new OO.ui.ButtonSelectWidget( {
|
|
|
|
'$': this.$
|
|
|
|
} );
|
|
|
|
this.sizeSelectWidget.addItems( [
|
|
|
|
new OO.ui.ButtonOptionWidget( 'default', {
|
|
|
|
'$': this.$,
|
|
|
|
'label': ve.msg( 'visualeditor-dialog-media-size-choosedefault' )
|
|
|
|
} ),
|
|
|
|
new OO.ui.ButtonOptionWidget( 'custom', {
|
|
|
|
'$': this.$,
|
|
|
|
'label': ve.msg( 'visualeditor-dialog-media-size-choosecustom' )
|
2014-02-27 17:39:19 +00:00
|
|
|
} ),
|
|
|
|
new OO.ui.ButtonOptionWidget( 'full', {
|
|
|
|
'$': this.$,
|
|
|
|
'label': ve.msg( 'visualeditor-dialog-media-size-choosefull' )
|
2014-02-20 05:11:04 +00:00
|
|
|
} )
|
|
|
|
] );
|
|
|
|
|
2014-01-26 14:26:57 +00:00
|
|
|
this.sizeFieldset.$element.append( [
|
2014-02-20 05:11:04 +00:00
|
|
|
this.sizeSelectWidget.$element,
|
2014-01-26 14:26:57 +00:00
|
|
|
this.sizeWidget.$element,
|
2014-01-26 15:02:07 +00:00
|
|
|
this.sizeErrorLabel.$element
|
2013-12-21 22:37:54 +00:00
|
|
|
] );
|
|
|
|
this.sizeErrorLabel.$element.hide();
|
|
|
|
|
2014-02-20 05:11:04 +00:00
|
|
|
// Get wiki default thumbnail size
|
|
|
|
this.defaultThumbSize = mw.config.get( 'wgVisualEditorConfig' )
|
|
|
|
.defaultUserOptions.defaultthumbsize;
|
|
|
|
|
2014-01-17 14:24:12 +00:00
|
|
|
this.applyButton = new OO.ui.ButtonWidget( {
|
2013-11-01 19:45:59 +00:00
|
|
|
'$': this.$,
|
2013-07-18 18:36:43 +00:00
|
|
|
'label': ve.msg( 'visualeditor-dialog-action-apply' ),
|
|
|
|
'flags': ['primary']
|
Single-click insertion
Objectives:
* Reduce the number of clicks and mouse maneuvers required to insert
media, references or template parameters
* Make use of highlighting with mouse movement or arrow key presses,
similar to menus, to suggest action when clicked
* Improve the way media search results look and feel
Changes:
ve.ui.SelectWidget.js
* Add mouseleave handler to un-highlight when the mouse exits the widget
* Document highlight events (already being emitted)
ve.ui.SearchWidget.js
* Propagate both select and highlight events from results widget
* Make arrow keys change highlight instead of selection
* Get rid of enter event, make enter key select highlighted item instead
* Provide direct access to results widget through getResults method
ve.ui.MenuWidget.js
* Use the selected item as a starting point if nothing is currently
highlighted when adjusting the highlight position
ve.ui.Dialog.js
* Add footless option to hide the foot element and make the body extend
all the way down to the bottom
* Remove applyButton, which only some dialogs need, and should be creating
themselves, along with other buttons as needed
ve.ui.Widget.css
* Change highlight and selected colors of option widgets to match other
selection colors used elsewhere
* Leave selected and highlighted widget looking selected
ve.ui.Frame.css
* Add background color to combat any color that might have been applied to
the frame body in the imported CSS from the parent frame
ve.ui.Dialog.css
* Add rules for footless mode
ve.ui.MWReferenceResultWidget.js,
ve.ui.MWParameterResultWidget.js,
ve.ui.MWMediaResultWidget.js
* Allow highlighting
ve.ui.MWParamterSearchWidget.js
* Switch from selecting the first item when filtering to highlighting
ve-mw/ve.ui.Widget.js
* Adjust media result widget styling to better match other elements
ve.ui.MWTransclusionDialog.js,
ve.ui.MWReferenceListDialog.js,
ve.ui.MWReferenceEditDialog.js,
ve.ui.MWMetaDialog.js
ve.ui.MWMediaEditDialog.js
* Add apply button, as per it being removed from parent class
ve.ui.MWTransclusionDialog.js,
ve.ui.MWReferenceInsertDialog.js,
ve.ui.MWMediaInsertDialog.js
* Insert parameter/reference/media on select, instead of clicking an
insert button
* Use 'insert' instead of 'apply' as argument for close method
Bug: 50774
Bug: 51143
Change-Id: Ia18e79f1f8df2540f465468edb01f5ce989bf843
2013-07-15 21:07:53 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
// Events
|
2013-11-05 00:29:50 +00:00
|
|
|
this.applyButton.connect( this, { 'click': [ 'close', { 'action': 'apply' } ] } );
|
2014-01-21 18:05:50 +00:00
|
|
|
this.positionCheckbox.connect( this, { 'change': 'onPositionCheckboxChange' } );
|
2014-02-20 05:11:04 +00:00
|
|
|
this.sizeSelectWidget.connect( this, { 'select': 'onSizeSelectWidgetSelect' } );
|
|
|
|
this.sizeWidget.connect( this, { 'change': 'onSizeWidgetChange' } );
|
2014-02-24 21:56:24 +00:00
|
|
|
this.typeInput.connect( this, { 'select': 'onTypeChange' } );
|
2013-06-18 22:58:10 +00:00
|
|
|
|
|
|
|
// Initialization
|
2013-12-28 10:29:35 +00:00
|
|
|
this.generalSettingsPage.$element.append( [
|
|
|
|
this.captionFieldset.$element,
|
|
|
|
altTextFieldset.$element
|
|
|
|
] );
|
2013-12-29 03:49:06 +00:00
|
|
|
|
|
|
|
this.advancedSettingsPage.$element.append( [
|
|
|
|
positionFieldset.$element,
|
2013-12-29 05:49:56 +00:00
|
|
|
this.typeFieldset.$element,
|
2013-12-29 03:49:06 +00:00
|
|
|
this.sizeFieldset.$element
|
|
|
|
] );
|
2013-12-21 22:37:54 +00:00
|
|
|
|
|
|
|
this.$body.append( this.bookletLayout.$element );
|
2013-11-01 19:45:59 +00:00
|
|
|
this.$foot.append( this.applyButton.$element );
|
2013-06-18 22:58:10 +00:00
|
|
|
};
|
|
|
|
|
2014-02-20 05:11:04 +00:00
|
|
|
/**
|
|
|
|
* Handle change event on the sizeWidget. Switch the size select
|
|
|
|
* from default to custom and vise versa based on the values in
|
|
|
|
* the widget.
|
|
|
|
*/
|
|
|
|
ve.ui.MWMediaEditDialog.prototype.onSizeWidgetChange = function () {
|
2014-03-05 19:31:45 +00:00
|
|
|
var selectedType = this.typeInput.getSelectedItem() ? this.typeInput.getSelectedItem().getData() : '',
|
|
|
|
thumbOrFrameless = selectedType === 'thumb' || selectedType === 'frameless';
|
|
|
|
|
2014-02-27 17:39:19 +00:00
|
|
|
// Switch to 'default' or 'custom' size
|
2014-02-20 05:11:04 +00:00
|
|
|
if ( this.sizeWidget.isEmpty() ) {
|
2014-03-05 19:31:45 +00:00
|
|
|
this.sizeSelectWidget.selectItem(
|
|
|
|
this.sizeSelectWidget.getItemFromData(
|
|
|
|
thumbOrFrameless ?
|
|
|
|
'default' :
|
|
|
|
'full'
|
|
|
|
)
|
|
|
|
);
|
2014-02-20 05:11:04 +00:00
|
|
|
} else {
|
2014-03-05 19:31:45 +00:00
|
|
|
this.sizeSelectWidget.selectItem(
|
|
|
|
this.sizeSelectWidget.getItemFromData(
|
|
|
|
thumbOrFrameless &&
|
2014-03-13 03:50:56 +00:00
|
|
|
// Sanity check just in case before the comparison
|
|
|
|
this.sizeWidget.getCurrentDimensions() &&
|
|
|
|
// Make sure there are original dimensions set up
|
|
|
|
this.sizeWidget.getOriginalDimensions() &&
|
2014-03-05 19:31:45 +00:00
|
|
|
OO.compare(
|
|
|
|
this.sizeWidget.getCurrentDimensions(),
|
|
|
|
this.sizeWidget.getOriginalDimensions()
|
|
|
|
) ?
|
|
|
|
// If the value is full size for either thumb or frameless
|
|
|
|
// images, make sure the size select is on 'full' despite the
|
|
|
|
// fact that there are actual "custom" numbers in the
|
|
|
|
// size widget
|
|
|
|
'full' :
|
|
|
|
// Otherwise, when the widget has actual typed values, it
|
|
|
|
// is considerind 'custom' so clicking the 'full' button
|
|
|
|
// will result in removing size attributes altogether from
|
|
|
|
// the wikitext (faux-default)
|
|
|
|
'custom'
|
2014-02-27 17:39:19 +00:00
|
|
|
)
|
2014-03-05 19:31:45 +00:00
|
|
|
);
|
2014-02-20 05:11:04 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-02-24 21:56:24 +00:00
|
|
|
/**
|
|
|
|
* Handle type change, particularly to and from 'thumb' to make
|
|
|
|
* sure size is limited.
|
2014-03-06 18:37:17 +00:00
|
|
|
* @param {OO.ui.ButtonOptionWidget} item Selected item
|
2014-02-24 21:56:24 +00:00
|
|
|
*/
|
2014-03-06 18:37:17 +00:00
|
|
|
ve.ui.MWMediaEditDialog.prototype.onTypeChange = function ( item ) {
|
2014-03-13 03:50:56 +00:00
|
|
|
var originalDimensions = this.sizeWidget.getOriginalDimensions(),
|
|
|
|
selectedType = item ? item.getData() : '',
|
2014-03-05 19:31:45 +00:00
|
|
|
thumbOrFrameless = selectedType === 'thumb' || selectedType === 'frameless';
|
|
|
|
|
|
|
|
// As per wikitext docs, both 'thumb' and 'frameless' have
|
|
|
|
// explicitly limited size, as opposed to the similar case
|
|
|
|
// of having no type specified
|
|
|
|
if ( thumbOrFrameless ) {
|
2014-03-12 03:03:56 +00:00
|
|
|
// Set the placeholders to be wiki default, but only if the image
|
|
|
|
// is not smaller. Limit on width only (according to wikitext default)
|
2014-03-13 03:50:56 +00:00
|
|
|
if ( originalDimensions.width > this.defaultThumbSize ) {
|
2014-02-27 17:39:19 +00:00
|
|
|
this.sizeWidget.setPlaceholderDimensions( {
|
|
|
|
'width': this.defaultThumbSize,
|
|
|
|
} );
|
|
|
|
} else {
|
2014-03-12 03:03:56 +00:00
|
|
|
// The image is smaller than wiki default. Make the default dimensions
|
|
|
|
// the image max size
|
2014-03-13 03:50:56 +00:00
|
|
|
this.sizeWidget.setPlaceholderDimensions( originalDimensions );
|
2014-02-27 17:39:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Enable the size select widget 'default' option
|
|
|
|
this.sizeSelectWidget.getItemFromData( 'default' ).setDisabled( false );
|
2014-02-24 21:56:24 +00:00
|
|
|
// Tell the size widget to limit maxDimensions
|
|
|
|
this.sizeWidget.setEnforcedMax( true );
|
2014-02-27 17:39:19 +00:00
|
|
|
|
2014-02-24 21:56:24 +00:00
|
|
|
} else {
|
2014-02-27 17:39:19 +00:00
|
|
|
// Set placeholders to be image original dimensions
|
|
|
|
// Technically, this is the 'default' of non thumb/frameless
|
|
|
|
// images, as that is the size that they render in when
|
|
|
|
// no size is specified.
|
2014-03-13 03:50:56 +00:00
|
|
|
this.sizeWidget.setPlaceholderDimensions( originalDimensions );
|
2014-02-27 17:39:19 +00:00
|
|
|
|
|
|
|
// Don't allow for 'default' choice
|
|
|
|
this.sizeSelectWidget.getItemFromData( 'default' ).setDisabled( true );
|
2014-02-24 21:56:24 +00:00
|
|
|
// Don't limit the widget for other types (Wikitext doesn't)
|
|
|
|
this.sizeWidget.setEnforcedMax( false );
|
2014-02-27 17:39:19 +00:00
|
|
|
|
2014-03-05 19:31:45 +00:00
|
|
|
// For these types, filled in information is custom
|
2014-02-27 17:39:19 +00:00
|
|
|
if ( !this.sizeWidget.isEmpty() ) {
|
|
|
|
this.sizeSelectWidget.selectItem(
|
|
|
|
this.sizeSelectWidget.getItemFromData( 'custom' )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-05 19:31:45 +00:00
|
|
|
// Default, faux-default (full) buttons on type change
|
2014-02-27 17:39:19 +00:00
|
|
|
if ( this.sizeWidget.isEmpty() ) {
|
2014-03-05 19:31:45 +00:00
|
|
|
|
|
|
|
this.sizeSelectWidget.selectItem(
|
|
|
|
this.sizeSelectWidget.getItemFromData(
|
|
|
|
thumbOrFrameless ?
|
|
|
|
// default for thumb and frameless
|
|
|
|
'default' :
|
|
|
|
// full is the default of basic and frame
|
|
|
|
'full'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
// If the size widget is not empty and the dimensions are
|
|
|
|
// equal to original dimensions, set button to 'full' in
|
|
|
|
// thumbnail or frameless
|
2014-02-27 17:39:19 +00:00
|
|
|
if (
|
2014-03-05 19:31:45 +00:00
|
|
|
thumbOrFrameless &&
|
2014-03-13 03:50:56 +00:00
|
|
|
// Sanity check just in case before the comparison
|
|
|
|
this.sizeWidget.getCurrentDimensions() &&
|
|
|
|
// Make sure there are original dimensions set up
|
|
|
|
this.sizeWidget.getOriginalDimensions() &&
|
2014-03-05 19:31:45 +00:00
|
|
|
OO.compare(
|
|
|
|
this.sizeWidget.getCurrentDimensions(),
|
|
|
|
this.sizeWidget.getOriginalDimensions()
|
|
|
|
)
|
2014-02-27 17:39:19 +00:00
|
|
|
) {
|
|
|
|
this.sizeSelectWidget.selectItem(
|
|
|
|
this.sizeSelectWidget.getItemFromData( 'full' )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-05 19:31:45 +00:00
|
|
|
// Enable or disable border
|
|
|
|
if ( thumbOrFrameless ) {
|
2014-02-27 17:39:19 +00:00
|
|
|
this.borderCheckbox.setDisabled( true );
|
|
|
|
this.borderCheckbox.setValue( false );
|
|
|
|
} else {
|
|
|
|
this.borderCheckbox.setDisabled( false );
|
2014-02-24 21:56:24 +00:00
|
|
|
}
|
2014-03-05 19:31:45 +00:00
|
|
|
|
2014-02-24 21:56:24 +00:00
|
|
|
// Re-validate the existing dimensions
|
|
|
|
this.sizeWidget.validateDimensions();
|
|
|
|
};
|
|
|
|
|
2014-01-21 18:05:50 +00:00
|
|
|
/**
|
|
|
|
* Handle change event on the positionCheckbox element. If an option
|
|
|
|
* is selected, mark the checkbox
|
|
|
|
*/
|
|
|
|
ve.ui.MWMediaEditDialog.prototype.onPositionCheckboxChange = function () {
|
|
|
|
var checked = this.positionCheckbox.getValue();
|
|
|
|
|
|
|
|
if ( !checked ) {
|
|
|
|
// If unchecked, remove selection
|
|
|
|
this.positionInput.intializeSelection();
|
|
|
|
} else {
|
|
|
|
// If checked, choose default position
|
|
|
|
if ( this.surface.getView().getDir() === 'ltr' ) {
|
|
|
|
// Assume default is 'right'
|
|
|
|
this.positionInput.selectItem(
|
|
|
|
this.positionInput.getItemFromData( 'right' )
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
// Assume default is 'left'
|
|
|
|
this.positionInput.selectItem(
|
|
|
|
this.positionInput.getItemFromData( 'left' )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.positionInput.setDisabled( !checked );
|
|
|
|
};
|
|
|
|
|
2014-02-20 05:11:04 +00:00
|
|
|
/**
|
|
|
|
* Respond to sizeSelectWidget change
|
2014-03-06 18:37:17 +00:00
|
|
|
* @param {OO.ui.ButtonOptionWidget} item Selected item
|
2014-02-20 05:11:04 +00:00
|
|
|
*/
|
2014-03-06 18:37:17 +00:00
|
|
|
ve.ui.MWMediaEditDialog.prototype.onSizeSelectWidgetSelect = function ( item ) {
|
|
|
|
var currentItem = item ? item.getData() : '';
|
|
|
|
if ( currentItem === 'default' ) {
|
2014-02-20 05:11:04 +00:00
|
|
|
// Reset so placeholders appear
|
|
|
|
this.sizeWidget.setCurrentDimensions( {
|
|
|
|
'width': 0,
|
|
|
|
'height': 0
|
|
|
|
} );
|
2014-03-06 18:37:17 +00:00
|
|
|
} else if ( currentItem === 'full' ) {
|
2014-02-27 17:39:19 +00:00
|
|
|
if (
|
|
|
|
this.typeInput.getSelectedItem() &&
|
|
|
|
(
|
|
|
|
this.typeInput.getSelectedItem().getData() === 'frame' ||
|
|
|
|
this.typeInput.getSelectedItem().getData() === 'none'
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
// Reset so placeholders appear
|
|
|
|
this.sizeWidget.setCurrentDimensions( {
|
|
|
|
'width': 0,
|
|
|
|
'height': 0
|
|
|
|
} );
|
|
|
|
} else {
|
|
|
|
// Fill in the values of the original dimensions
|
|
|
|
this.sizeWidget.setCurrentDimensions(
|
|
|
|
this.sizeWidget.getOriginalDimensions()
|
|
|
|
);
|
|
|
|
}
|
2014-02-20 05:11:04 +00:00
|
|
|
} else {
|
2014-02-27 17:39:19 +00:00
|
|
|
if ( this.sizeWidget.isEmpty() ) {
|
|
|
|
// Fill the values as actual values into the size widget
|
|
|
|
this.sizeWidget.setCurrentDimensions(
|
|
|
|
this.sizeWidget.getPlaceholderDimensions()
|
|
|
|
);
|
|
|
|
}
|
2014-02-20 05:11:04 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-11-05 00:29:50 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWMediaEditDialog.prototype.setup = function ( data ) {
|
2014-01-26 15:02:07 +00:00
|
|
|
var newDoc,
|
2014-01-26 20:09:40 +00:00
|
|
|
dialog = this,
|
|
|
|
doc = this.surface.getModel().getDocument(),
|
|
|
|
mediaNodeView = this.surface.getView().getFocusedNode();
|
2013-12-21 22:37:54 +00:00
|
|
|
|
2013-06-18 22:58:10 +00:00
|
|
|
// Parent method
|
2013-11-05 00:29:50 +00:00
|
|
|
ve.ui.MWDialog.prototype.setup.call( this, data );
|
|
|
|
|
2013-07-18 18:36:43 +00:00
|
|
|
// Properties
|
2014-01-26 20:09:40 +00:00
|
|
|
this.mediaNode = mediaNodeView.getModel();
|
Introduce newFromDocumentReplace() transaction builder
Replaces newFromNodeReplacement(). newFromNodeReplacement was very
simplistic and didn't support metadata or internal list items, so
if you had comments or references inside of the data you were editing
(reference contents or an image caption), they'd get mangled.
With this, you can do:
newDoc = doc.getDocumentSlice( node );
// Edit newDoc
tx = ve.dm.Transaction.newFromDocumentReplace( doc, node, newDoc );
surface.change( newDoc );
and that takes care of metadata, internal list items, and things like
references that reference internal list items.
ve.dm.Document.js:
* In getDocumentSlice(), store a reference to the original document
and the number of items in its InternalList at the time of slicing
in the created slice. This is used for reconciliation when the
modified slice is injected back into the parent document with
newFromDocumentReplace().
ve.dm.InternalList.js:
* Add a method for merging in another InternalList. This provides a
mapping from old to new InternalList indexes so the linear model data
being injected by newFromDocumentReplace() can have its InternalList
indexes remapped.
ve.dm.Transaction.js:
* Replace newFromNodeReplacement() with newFromDocumentReplace()
ve.ui.MWMediaEditDialog.js, ve.ui.MWReferenceDialog.js:
* Use getDocumentSlice/newFromDocumentReplace for editing captions/refs
* Change insertion code path to insert an empty internalItem/caption, then
newFromDocumentReplace into that
* Add empty internalList to new mini-documents
ve/test/dm/ve.dm.Transaction.test.js:
* Replace newFromNodeReplacement tests with newFromDocumentReplace tests
ve-mw/test/dm/ve.dm.Transaction.test.js (new):
* Add tests for newFromDocumentReplace with mwReference nodes
ve.dm.mwExample.js:
* Add data for newFromDocumentReplace with mwReference tests
VisualEditor.hooks.php:
* Add new test file
Bug: 52102
Change-Id: I4aa980780114b391924f04df588e81c990c32983
2013-09-05 01:05:07 +00:00
|
|
|
this.captionNode = this.mediaNode.getCaptionNode();
|
2014-01-26 14:26:57 +00:00
|
|
|
this.store = this.surface.getModel().getDocument().getStore();
|
|
|
|
|
2013-06-18 22:58:10 +00:00
|
|
|
if ( this.captionNode && this.captionNode.getLength() > 0 ) {
|
2013-10-03 09:52:21 +00:00
|
|
|
newDoc = doc.cloneFromRange( this.captionNode.getRange() );
|
2013-06-18 22:58:10 +00:00
|
|
|
} else {
|
2014-02-06 14:12:04 +00:00
|
|
|
newDoc = new ve.dm.Document( [
|
2013-06-18 22:58:10 +00:00
|
|
|
{ 'type': 'paragraph', 'internal': { 'generated': 'wrapper' } },
|
Introduce newFromDocumentReplace() transaction builder
Replaces newFromNodeReplacement(). newFromNodeReplacement was very
simplistic and didn't support metadata or internal list items, so
if you had comments or references inside of the data you were editing
(reference contents or an image caption), they'd get mangled.
With this, you can do:
newDoc = doc.getDocumentSlice( node );
// Edit newDoc
tx = ve.dm.Transaction.newFromDocumentReplace( doc, node, newDoc );
surface.change( newDoc );
and that takes care of metadata, internal list items, and things like
references that reference internal list items.
ve.dm.Document.js:
* In getDocumentSlice(), store a reference to the original document
and the number of items in its InternalList at the time of slicing
in the created slice. This is used for reconciliation when the
modified slice is injected back into the parent document with
newFromDocumentReplace().
ve.dm.InternalList.js:
* Add a method for merging in another InternalList. This provides a
mapping from old to new InternalList indexes so the linear model data
being injected by newFromDocumentReplace() can have its InternalList
indexes remapped.
ve.dm.Transaction.js:
* Replace newFromNodeReplacement() with newFromDocumentReplace()
ve.ui.MWMediaEditDialog.js, ve.ui.MWReferenceDialog.js:
* Use getDocumentSlice/newFromDocumentReplace for editing captions/refs
* Change insertion code path to insert an empty internalItem/caption, then
newFromDocumentReplace into that
* Add empty internalList to new mini-documents
ve/test/dm/ve.dm.Transaction.test.js:
* Replace newFromNodeReplacement tests with newFromDocumentReplace tests
ve-mw/test/dm/ve.dm.Transaction.test.js (new):
* Add tests for newFromDocumentReplace with mwReference nodes
ve.dm.mwExample.js:
* Add data for newFromDocumentReplace with mwReference tests
VisualEditor.hooks.php:
* Add new test file
Bug: 52102
Change-Id: I4aa980780114b391924f04df588e81c990c32983
2013-09-05 01:05:07 +00:00
|
|
|
{ 'type': '/paragraph' },
|
|
|
|
{ 'type': 'internalList' },
|
|
|
|
{ 'type': '/internalList' }
|
2014-02-06 14:12:04 +00:00
|
|
|
] );
|
2013-06-18 22:58:10 +00:00
|
|
|
}
|
|
|
|
|
2013-07-18 18:36:43 +00:00
|
|
|
this.captionSurface = new ve.ui.SurfaceWidget(
|
Introduce newFromDocumentReplace() transaction builder
Replaces newFromNodeReplacement(). newFromNodeReplacement was very
simplistic and didn't support metadata or internal list items, so
if you had comments or references inside of the data you were editing
(reference contents or an image caption), they'd get mangled.
With this, you can do:
newDoc = doc.getDocumentSlice( node );
// Edit newDoc
tx = ve.dm.Transaction.newFromDocumentReplace( doc, node, newDoc );
surface.change( newDoc );
and that takes care of metadata, internal list items, and things like
references that reference internal list items.
ve.dm.Document.js:
* In getDocumentSlice(), store a reference to the original document
and the number of items in its InternalList at the time of slicing
in the created slice. This is used for reconciliation when the
modified slice is injected back into the parent document with
newFromDocumentReplace().
ve.dm.InternalList.js:
* Add a method for merging in another InternalList. This provides a
mapping from old to new InternalList indexes so the linear model data
being injected by newFromDocumentReplace() can have its InternalList
indexes remapped.
ve.dm.Transaction.js:
* Replace newFromNodeReplacement() with newFromDocumentReplace()
ve.ui.MWMediaEditDialog.js, ve.ui.MWReferenceDialog.js:
* Use getDocumentSlice/newFromDocumentReplace for editing captions/refs
* Change insertion code path to insert an empty internalItem/caption, then
newFromDocumentReplace into that
* Add empty internalList to new mini-documents
ve/test/dm/ve.dm.Transaction.test.js:
* Replace newFromNodeReplacement tests with newFromDocumentReplace tests
ve-mw/test/dm/ve.dm.Transaction.test.js (new):
* Add tests for newFromDocumentReplace with mwReference nodes
ve.dm.mwExample.js:
* Add data for newFromDocumentReplace with mwReference tests
VisualEditor.hooks.php:
* Add new test file
Bug: 52102
Change-Id: I4aa980780114b391924f04df588e81c990c32983
2013-09-05 01:05:07 +00:00
|
|
|
newDoc,
|
2013-07-18 18:36:43 +00:00
|
|
|
{
|
2013-11-01 19:45:59 +00:00
|
|
|
'$': this.$,
|
2013-08-09 18:29:09 +00:00
|
|
|
'tools': this.constructor.static.toolbarGroups,
|
2014-02-03 15:08:52 +00:00
|
|
|
'commands': this.constructor.static.surfaceCommands,
|
|
|
|
'pasteRules': this.constructor.static.pasteRules
|
2013-07-18 18:36:43 +00:00
|
|
|
}
|
2013-06-18 22:58:10 +00:00
|
|
|
);
|
|
|
|
|
2014-02-12 20:38:52 +00:00
|
|
|
this.initialDimensions = ve.copy( mediaNodeView.currentDimensions );
|
2014-01-26 20:09:40 +00:00
|
|
|
this.sizeWidget.setPropertiesFromScalable( mediaNodeView );
|
|
|
|
|
2014-02-12 21:11:34 +00:00
|
|
|
// HACK: Override properties with image-specific current size
|
|
|
|
// Ideally, this should be dealt with in setPropertiesFromScalable
|
|
|
|
// but the currentDimensions object of the mediaNodeView seems
|
|
|
|
// to not be updated properly. Without this hack, the media
|
|
|
|
// dialog presents the dimensions that the image had in the
|
|
|
|
// beginning of the session (in the wikitext) rather than update
|
|
|
|
// these when the image is resized either from the dialog or
|
|
|
|
// by the resize handles.
|
|
|
|
this.sizeWidget.setCurrentDimensions( {
|
|
|
|
'width': this.mediaNode.getAttribute( 'width' ),
|
|
|
|
'height': this.mediaNode.getAttribute( 'height' )
|
|
|
|
} );
|
|
|
|
|
2014-02-27 17:39:19 +00:00
|
|
|
// Start with the original dimensions button disabled
|
|
|
|
this.sizeSelectWidget.getItemFromData( 'full' ).setDisabled( true );
|
|
|
|
|
2014-01-26 20:09:40 +00:00
|
|
|
if ( !mediaNodeView.getOriginalDimensions() ) {
|
|
|
|
mediaNodeView.fetchDimensions()
|
|
|
|
.done( function () {
|
|
|
|
dialog.sizeWidget.setOriginalDimensions( mediaNodeView.getOriginalDimensions() );
|
2014-02-24 21:56:24 +00:00
|
|
|
dialog.sizeWidget.setEnforcedMax( false );
|
2014-02-27 17:39:19 +00:00
|
|
|
// Original dimensions available, enable the button
|
|
|
|
this.sizeSelectWidget.getItemFromData( 'full' ).setDisabled( false );
|
2014-01-26 20:09:40 +00:00
|
|
|
if ( mediaNodeView.getMaxDimensions() ) {
|
|
|
|
dialog.sizeWidget.setMaxDimensions( mediaNodeView.getMaxDimensions() );
|
2014-02-24 21:56:24 +00:00
|
|
|
if ( dialog.mediaNode.getAttribute( 'type' ) === 'thumb' ) {
|
|
|
|
// Tell the size widget to limit maxDimensions to image's original dimensions
|
|
|
|
dialog.sizeWidget.setEnforcedMax( true );
|
|
|
|
}
|
2014-01-26 20:09:40 +00:00
|
|
|
}
|
|
|
|
} )
|
|
|
|
.fail( function () {
|
|
|
|
dialog.sizeErrorLabel.$element.show();
|
|
|
|
} );
|
2014-02-24 21:56:24 +00:00
|
|
|
} else {
|
|
|
|
if (
|
|
|
|
this.mediaNode.getAttribute( 'type' ) === 'thumb' &&
|
|
|
|
this.sizeWidget.getMaxDimensions()
|
|
|
|
) {
|
|
|
|
// Tell the size widget to limit maxDimensions to image's original dimensions
|
|
|
|
this.sizeWidget.setEnforcedMax( true );
|
|
|
|
} else {
|
|
|
|
this.sizeWidget.setEnforcedMax( false );
|
|
|
|
}
|
2014-02-27 17:39:19 +00:00
|
|
|
|
|
|
|
// If there are original dimensions, enable that choice
|
|
|
|
if ( this.sizeWidget.getOriginalDimensions() ) {
|
|
|
|
this.sizeSelectWidget.getItemFromData( 'full' ).setDisabled( false );
|
|
|
|
}
|
2014-01-26 20:09:40 +00:00
|
|
|
}
|
2014-02-24 21:56:24 +00:00
|
|
|
|
2013-12-28 10:29:35 +00:00
|
|
|
// Set initial alt text
|
|
|
|
this.altTextInput.setValue( this.mediaNode.getAttribute( 'alt' ) || '' );
|
2013-12-21 22:37:54 +00:00
|
|
|
|
2013-12-29 03:49:06 +00:00
|
|
|
// Set initial position
|
2014-01-21 18:05:50 +00:00
|
|
|
if (
|
|
|
|
!this.mediaNode.getAttribute( 'align' ) ||
|
|
|
|
this.mediaNode.getAttribute( 'align' ) === 'none'
|
|
|
|
) {
|
|
|
|
this.positionCheckbox.setValue( false );
|
|
|
|
this.positionInput.setDisabled( true );
|
|
|
|
this.positionInput.intializeSelection();
|
|
|
|
} else {
|
|
|
|
this.positionCheckbox.setValue( true );
|
|
|
|
this.positionInput.setDisabled( false );
|
|
|
|
if ( this.mediaNode.getAttribute( 'align' ) === 'default' ) {
|
|
|
|
// Assume wiki default according to wiki dir
|
|
|
|
if ( this.surface.getView().getDir() === 'ltr' ) {
|
|
|
|
// Assume default is 'right'
|
|
|
|
this.positionInput.selectItem(
|
|
|
|
this.positionInput.getItemFromData( 'right' )
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
// Assume default is 'left'
|
|
|
|
this.positionInput.selectItem(
|
|
|
|
this.positionInput.getItemFromData( 'left' )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.positionInput.selectItem(
|
|
|
|
this.positionInput.getItemFromData( this.mediaNode.getAttribute( 'align' ) )
|
|
|
|
);
|
|
|
|
}
|
2013-12-29 03:49:06 +00:00
|
|
|
}
|
|
|
|
|
2014-02-27 17:39:19 +00:00
|
|
|
// Border flag
|
|
|
|
this.borderCheckbox.setValue( !!this.mediaNode.getAttribute( 'borderImage' ) );
|
|
|
|
|
2013-12-29 05:49:56 +00:00
|
|
|
// Set image type
|
2014-01-21 18:05:50 +00:00
|
|
|
this.typeInput.intializeSelection();
|
2013-12-29 05:49:56 +00:00
|
|
|
if ( this.mediaNode.getAttribute( 'type' ) !== undefined ) {
|
|
|
|
this.typeInput.selectItem(
|
|
|
|
this.typeInput.getItemFromData( this.mediaNode.getAttribute( 'type' ) )
|
|
|
|
);
|
2014-02-27 17:39:19 +00:00
|
|
|
} else {
|
|
|
|
// Explicitly show 'none' if no type was specified
|
|
|
|
this.typeInput.selectItem(
|
|
|
|
this.typeInput.getItemFromData( 'none' )
|
|
|
|
);
|
2013-12-29 05:49:56 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 05:11:04 +00:00
|
|
|
// Initialize size
|
|
|
|
if ( this.mediaNode.getAttribute( 'defaultSize' ) ) {
|
2014-02-27 17:39:19 +00:00
|
|
|
this.sizeSelectWidget.selectItem(
|
2014-02-20 05:11:04 +00:00
|
|
|
this.sizeSelectWidget.getItemFromData( 'default' )
|
|
|
|
);
|
|
|
|
// Use placeholders
|
|
|
|
this.sizeWidget.setCurrentDimensions( {
|
|
|
|
'width': 0,
|
|
|
|
'height': 0
|
|
|
|
} );
|
|
|
|
} else {
|
2014-02-26 23:26:30 +00:00
|
|
|
// Set placeholders for the default bounding box
|
2014-02-27 17:39:19 +00:00
|
|
|
this.sizeSelectWidget.selectItem(
|
2014-02-20 05:11:04 +00:00
|
|
|
this.sizeSelectWidget.getItemFromData( 'custom' )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-07-18 18:36:43 +00:00
|
|
|
// Initialization
|
2014-01-26 14:26:57 +00:00
|
|
|
this.captionFieldset.$element.append( this.captionSurface.$element );
|
2013-06-18 22:58:10 +00:00
|
|
|
this.captionSurface.initialize();
|
|
|
|
};
|
|
|
|
|
2013-11-05 00:29:50 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWMediaEditDialog.prototype.teardown = function ( data ) {
|
2013-12-28 10:29:35 +00:00
|
|
|
var newDoc, doc, originalAlt, attr, attrs = {},
|
2013-11-05 00:29:50 +00:00
|
|
|
surfaceModel = this.surface.getModel();
|
2013-06-18 22:58:10 +00:00
|
|
|
|
2013-11-05 00:29:50 +00:00
|
|
|
// Data initialization
|
|
|
|
data = data || {};
|
2013-06-18 22:58:10 +00:00
|
|
|
|
2013-11-05 00:29:50 +00:00
|
|
|
if ( data.action === 'apply' ) {
|
Introduce newFromDocumentReplace() transaction builder
Replaces newFromNodeReplacement(). newFromNodeReplacement was very
simplistic and didn't support metadata or internal list items, so
if you had comments or references inside of the data you were editing
(reference contents or an image caption), they'd get mangled.
With this, you can do:
newDoc = doc.getDocumentSlice( node );
// Edit newDoc
tx = ve.dm.Transaction.newFromDocumentReplace( doc, node, newDoc );
surface.change( newDoc );
and that takes care of metadata, internal list items, and things like
references that reference internal list items.
ve.dm.Document.js:
* In getDocumentSlice(), store a reference to the original document
and the number of items in its InternalList at the time of slicing
in the created slice. This is used for reconciliation when the
modified slice is injected back into the parent document with
newFromDocumentReplace().
ve.dm.InternalList.js:
* Add a method for merging in another InternalList. This provides a
mapping from old to new InternalList indexes so the linear model data
being injected by newFromDocumentReplace() can have its InternalList
indexes remapped.
ve.dm.Transaction.js:
* Replace newFromNodeReplacement() with newFromDocumentReplace()
ve.ui.MWMediaEditDialog.js, ve.ui.MWReferenceDialog.js:
* Use getDocumentSlice/newFromDocumentReplace for editing captions/refs
* Change insertion code path to insert an empty internalItem/caption, then
newFromDocumentReplace into that
* Add empty internalList to new mini-documents
ve/test/dm/ve.dm.Transaction.test.js:
* Replace newFromNodeReplacement tests with newFromDocumentReplace tests
ve-mw/test/dm/ve.dm.Transaction.test.js (new):
* Add tests for newFromDocumentReplace with mwReference nodes
ve.dm.mwExample.js:
* Add data for newFromDocumentReplace with mwReference tests
VisualEditor.hooks.php:
* Add new test file
Bug: 52102
Change-Id: I4aa980780114b391924f04df588e81c990c32983
2013-09-05 01:05:07 +00:00
|
|
|
newDoc = this.captionSurface.getSurface().getModel().getDocument();
|
2013-06-18 22:58:10 +00:00
|
|
|
doc = surfaceModel.getDocument();
|
Introduce newFromDocumentReplace() transaction builder
Replaces newFromNodeReplacement(). newFromNodeReplacement was very
simplistic and didn't support metadata or internal list items, so
if you had comments or references inside of the data you were editing
(reference contents or an image caption), they'd get mangled.
With this, you can do:
newDoc = doc.getDocumentSlice( node );
// Edit newDoc
tx = ve.dm.Transaction.newFromDocumentReplace( doc, node, newDoc );
surface.change( newDoc );
and that takes care of metadata, internal list items, and things like
references that reference internal list items.
ve.dm.Document.js:
* In getDocumentSlice(), store a reference to the original document
and the number of items in its InternalList at the time of slicing
in the created slice. This is used for reconciliation when the
modified slice is injected back into the parent document with
newFromDocumentReplace().
ve.dm.InternalList.js:
* Add a method for merging in another InternalList. This provides a
mapping from old to new InternalList indexes so the linear model data
being injected by newFromDocumentReplace() can have its InternalList
indexes remapped.
ve.dm.Transaction.js:
* Replace newFromNodeReplacement() with newFromDocumentReplace()
ve.ui.MWMediaEditDialog.js, ve.ui.MWReferenceDialog.js:
* Use getDocumentSlice/newFromDocumentReplace for editing captions/refs
* Change insertion code path to insert an empty internalItem/caption, then
newFromDocumentReplace into that
* Add empty internalList to new mini-documents
ve/test/dm/ve.dm.Transaction.test.js:
* Replace newFromNodeReplacement tests with newFromDocumentReplace tests
ve-mw/test/dm/ve.dm.Transaction.test.js (new):
* Add tests for newFromDocumentReplace with mwReference nodes
ve.dm.mwExample.js:
* Add data for newFromDocumentReplace with mwReference tests
VisualEditor.hooks.php:
* Add new test file
Bug: 52102
Change-Id: I4aa980780114b391924f04df588e81c990c32983
2013-09-05 01:05:07 +00:00
|
|
|
if ( !this.captionNode ) {
|
2013-06-18 22:58:10 +00:00
|
|
|
// Insert a new caption at the beginning of the image node
|
|
|
|
surfaceModel.getFragment()
|
|
|
|
.adjustRange( 1 )
|
|
|
|
.collapseRangeToStart()
|
Introduce newFromDocumentReplace() transaction builder
Replaces newFromNodeReplacement(). newFromNodeReplacement was very
simplistic and didn't support metadata or internal list items, so
if you had comments or references inside of the data you were editing
(reference contents or an image caption), they'd get mangled.
With this, you can do:
newDoc = doc.getDocumentSlice( node );
// Edit newDoc
tx = ve.dm.Transaction.newFromDocumentReplace( doc, node, newDoc );
surface.change( newDoc );
and that takes care of metadata, internal list items, and things like
references that reference internal list items.
ve.dm.Document.js:
* In getDocumentSlice(), store a reference to the original document
and the number of items in its InternalList at the time of slicing
in the created slice. This is used for reconciliation when the
modified slice is injected back into the parent document with
newFromDocumentReplace().
ve.dm.InternalList.js:
* Add a method for merging in another InternalList. This provides a
mapping from old to new InternalList indexes so the linear model data
being injected by newFromDocumentReplace() can have its InternalList
indexes remapped.
ve.dm.Transaction.js:
* Replace newFromNodeReplacement() with newFromDocumentReplace()
ve.ui.MWMediaEditDialog.js, ve.ui.MWReferenceDialog.js:
* Use getDocumentSlice/newFromDocumentReplace for editing captions/refs
* Change insertion code path to insert an empty internalItem/caption, then
newFromDocumentReplace into that
* Add empty internalList to new mini-documents
ve/test/dm/ve.dm.Transaction.test.js:
* Replace newFromNodeReplacement tests with newFromDocumentReplace tests
ve-mw/test/dm/ve.dm.Transaction.test.js (new):
* Add tests for newFromDocumentReplace with mwReference nodes
ve.dm.mwExample.js:
* Add data for newFromDocumentReplace with mwReference tests
VisualEditor.hooks.php:
* Add new test file
Bug: 52102
Change-Id: I4aa980780114b391924f04df588e81c990c32983
2013-09-05 01:05:07 +00:00
|
|
|
.insertContent( [ { 'type': 'mwImageCaption' }, { 'type': '/mwImageCaption' } ] );
|
|
|
|
this.captionNode = this.mediaNode.getCaptionNode();
|
2013-06-18 22:58:10 +00:00
|
|
|
}
|
Introduce newFromDocumentReplace() transaction builder
Replaces newFromNodeReplacement(). newFromNodeReplacement was very
simplistic and didn't support metadata or internal list items, so
if you had comments or references inside of the data you were editing
(reference contents or an image caption), they'd get mangled.
With this, you can do:
newDoc = doc.getDocumentSlice( node );
// Edit newDoc
tx = ve.dm.Transaction.newFromDocumentReplace( doc, node, newDoc );
surface.change( newDoc );
and that takes care of metadata, internal list items, and things like
references that reference internal list items.
ve.dm.Document.js:
* In getDocumentSlice(), store a reference to the original document
and the number of items in its InternalList at the time of slicing
in the created slice. This is used for reconciliation when the
modified slice is injected back into the parent document with
newFromDocumentReplace().
ve.dm.InternalList.js:
* Add a method for merging in another InternalList. This provides a
mapping from old to new InternalList indexes so the linear model data
being injected by newFromDocumentReplace() can have its InternalList
indexes remapped.
ve.dm.Transaction.js:
* Replace newFromNodeReplacement() with newFromDocumentReplace()
ve.ui.MWMediaEditDialog.js, ve.ui.MWReferenceDialog.js:
* Use getDocumentSlice/newFromDocumentReplace for editing captions/refs
* Change insertion code path to insert an empty internalItem/caption, then
newFromDocumentReplace into that
* Add empty internalList to new mini-documents
ve/test/dm/ve.dm.Transaction.test.js:
* Replace newFromNodeReplacement tests with newFromDocumentReplace tests
ve-mw/test/dm/ve.dm.Transaction.test.js (new):
* Add tests for newFromDocumentReplace with mwReference nodes
ve.dm.mwExample.js:
* Add data for newFromDocumentReplace with mwReference tests
VisualEditor.hooks.php:
* Add new test file
Bug: 52102
Change-Id: I4aa980780114b391924f04df588e81c990c32983
2013-09-05 01:05:07 +00:00
|
|
|
// Replace the contents of the caption
|
|
|
|
surfaceModel.change(
|
2013-09-30 13:25:28 +00:00
|
|
|
ve.dm.Transaction.newFromRemoval( doc, this.captionNode.getRange(), true )
|
|
|
|
);
|
|
|
|
surfaceModel.change(
|
|
|
|
ve.dm.Transaction.newFromDocumentInsertion( doc, this.captionNode.getRange().start, newDoc )
|
Introduce newFromDocumentReplace() transaction builder
Replaces newFromNodeReplacement(). newFromNodeReplacement was very
simplistic and didn't support metadata or internal list items, so
if you had comments or references inside of the data you were editing
(reference contents or an image caption), they'd get mangled.
With this, you can do:
newDoc = doc.getDocumentSlice( node );
// Edit newDoc
tx = ve.dm.Transaction.newFromDocumentReplace( doc, node, newDoc );
surface.change( newDoc );
and that takes care of metadata, internal list items, and things like
references that reference internal list items.
ve.dm.Document.js:
* In getDocumentSlice(), store a reference to the original document
and the number of items in its InternalList at the time of slicing
in the created slice. This is used for reconciliation when the
modified slice is injected back into the parent document with
newFromDocumentReplace().
ve.dm.InternalList.js:
* Add a method for merging in another InternalList. This provides a
mapping from old to new InternalList indexes so the linear model data
being injected by newFromDocumentReplace() can have its InternalList
indexes remapped.
ve.dm.Transaction.js:
* Replace newFromNodeReplacement() with newFromDocumentReplace()
ve.ui.MWMediaEditDialog.js, ve.ui.MWReferenceDialog.js:
* Use getDocumentSlice/newFromDocumentReplace for editing captions/refs
* Change insertion code path to insert an empty internalItem/caption, then
newFromDocumentReplace into that
* Add empty internalList to new mini-documents
ve/test/dm/ve.dm.Transaction.test.js:
* Replace newFromNodeReplacement tests with newFromDocumentReplace tests
ve-mw/test/dm/ve.dm.Transaction.test.js (new):
* Add tests for newFromDocumentReplace with mwReference nodes
ve.dm.mwExample.js:
* Add data for newFromDocumentReplace with mwReference tests
VisualEditor.hooks.php:
* Add new test file
Bug: 52102
Change-Id: I4aa980780114b391924f04df588e81c990c32983
2013-09-05 01:05:07 +00:00
|
|
|
);
|
2014-02-20 05:11:04 +00:00
|
|
|
|
2014-02-27 17:39:19 +00:00
|
|
|
// Default size excitement
|
|
|
|
if (
|
|
|
|
// If the size widget is empty, the placeholders are showing
|
|
|
|
// which means the image should be default size. In the case of
|
|
|
|
// 'thumb' and 'frameless' that size would be wiki default and
|
|
|
|
// in the case of the other types, that would be image original
|
|
|
|
// size. Either way, the actual default size will come from the
|
|
|
|
// placeholders.
|
|
|
|
this.sizeWidget.isEmpty()
|
|
|
|
) {
|
2014-02-20 05:11:04 +00:00
|
|
|
attrs.defaultSize = true;
|
2014-02-27 17:39:19 +00:00
|
|
|
|
|
|
|
// If there are placeholders, they represent the default size
|
|
|
|
attr = this.sizeWidget.getPlaceholderDimensions();
|
|
|
|
if ( attr ) {
|
|
|
|
attrs.width = attr.width;
|
|
|
|
attrs.height = attr.height;
|
|
|
|
}
|
2014-02-20 05:11:04 +00:00
|
|
|
} else {
|
2014-02-27 17:39:19 +00:00
|
|
|
// If size exists, explicitly set it as custom, but
|
|
|
|
// only if the size is valid
|
2014-02-20 05:11:04 +00:00
|
|
|
if ( this.sizeWidget.isCurrentDimensionsValid() ) {
|
2014-02-27 17:39:19 +00:00
|
|
|
attrs = this.sizeWidget.getCurrentDimensions();
|
2014-02-12 20:38:52 +00:00
|
|
|
attrs.defaultSize = false;
|
|
|
|
}
|
2013-12-21 22:37:54 +00:00
|
|
|
}
|
|
|
|
|
2013-12-28 10:29:35 +00:00
|
|
|
attr = $.trim( this.altTextInput.getValue() );
|
|
|
|
originalAlt = this.mediaNode.getAttribute( 'alt' );
|
|
|
|
// Allow the user to submit an empty alternate text but
|
|
|
|
// not if there was no alternate text originally to avoid
|
|
|
|
// dirty diffing images with empty |alt=
|
|
|
|
if (
|
|
|
|
// If there was no original alternate text but there
|
|
|
|
// is a value now, update
|
|
|
|
( originalAlt === undefined && attr ) ||
|
|
|
|
// If original alternate text was defined, always
|
|
|
|
// update, even if the input is empty to allow the
|
|
|
|
// user to unset it
|
|
|
|
originalAlt !== undefined
|
|
|
|
) {
|
|
|
|
attrs.alt = attr;
|
|
|
|
}
|
|
|
|
|
2014-01-21 18:05:50 +00:00
|
|
|
if ( !this.positionCheckbox.getValue() ) {
|
|
|
|
// Only change to 'none' if alignment was originally
|
|
|
|
// set to anything else
|
|
|
|
if (
|
|
|
|
this.mediaNode.getAttribute( 'align' ) &&
|
|
|
|
this.mediaNode.getAttribute( 'align' ) !== 'none'
|
|
|
|
) {
|
|
|
|
attrs.align = 'none';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
attr = this.positionInput.getSelectedItem().getData();
|
|
|
|
// If alignment was originally default and is still
|
|
|
|
// set to the default position according to the wiki
|
|
|
|
// content direction, do not change it
|
|
|
|
if (
|
|
|
|
(
|
|
|
|
this.mediaNode.getAttribute( 'align' ) === 'default' &&
|
|
|
|
(
|
|
|
|
this.surface.getView().getDir() === 'ltr' &&
|
|
|
|
attr !== 'right'
|
|
|
|
) ||
|
|
|
|
(
|
|
|
|
this.surface.getView().getDir() === 'rtl' &&
|
|
|
|
attr !== 'left'
|
|
|
|
)
|
|
|
|
) ||
|
|
|
|
this.mediaNode.getAttribute( 'align' ) !== 'default'
|
|
|
|
) {
|
|
|
|
attrs.align = attr;
|
|
|
|
}
|
2013-12-29 03:49:06 +00:00
|
|
|
}
|
|
|
|
|
2014-02-27 17:39:19 +00:00
|
|
|
// Border
|
|
|
|
if (
|
|
|
|
!this.borderCheckbox.isDisabled() &&
|
|
|
|
this.borderCheckbox.getValue() === true
|
|
|
|
) {
|
|
|
|
attrs.borderImage = true;
|
|
|
|
} else {
|
|
|
|
attrs.borderImage = false;
|
|
|
|
}
|
|
|
|
|
2013-12-29 05:49:56 +00:00
|
|
|
attr = this.typeInput.getSelectedItem();
|
|
|
|
if ( attr ) {
|
|
|
|
attrs.type = attr.getData();
|
|
|
|
}
|
2013-12-21 22:37:54 +00:00
|
|
|
surfaceModel.change(
|
|
|
|
ve.dm.Transaction.newFromAttributeChanges( doc, this.mediaNode.getOffset(), attrs )
|
|
|
|
);
|
2013-06-18 22:58:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Cleanup
|
|
|
|
this.captionSurface.destroy();
|
2013-07-18 18:36:43 +00:00
|
|
|
this.captionSurface = null;
|
|
|
|
this.captionNode = null;
|
2013-11-05 00:29:50 +00:00
|
|
|
|
|
|
|
// Parent method
|
|
|
|
ve.ui.MWDialog.prototype.teardown.call( this, data );
|
2013-06-18 22:58:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
2013-08-27 23:28:29 +00:00
|
|
|
ve.ui.dialogFactory.register( ve.ui.MWMediaEditDialog );
|