2013-04-25 00:47:17 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor ContentEditable MWBlockImageNode class.
|
|
|
|
*
|
|
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ContentEditable MediaWiki image node.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ce.BranchNode
|
2013-10-15 12:18:11 +00:00
|
|
|
* @mixins ve.ce.MWImageNode
|
2013-05-15 17:01:19 +00:00
|
|
|
*
|
2013-04-25 00:47:17 +00:00
|
|
|
* @constructor
|
|
|
|
* @param {ve.dm.MWBlockImageNode} model Model to observe
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2013-04-25 00:47:17 +00:00
|
|
|
*/
|
ve.Element refactor
Objectives:
* Move ve.ui.Element to ve.Element
* Make CE nodes inherit from ve.Element
Changes:
ve.ui.Element.js, ve.Element.js
* Move and rename
* Move ve.ui.get$$ to ve.Element.static.get$$
* Add static getDocument and getWindow methods
* Add instance getElementDocument and getElementWindow methods
* Add getTagName method, which by default reads the static tagName property, but when overridden can return a tag name based on other factors
*.php
* Updated file link
ve.ce.*Annotation.js, ve.ce.*Node.js, ve.ce.View.js, ve.ce.Document
* Added config options pass through
* Replaced passing elements through constructor with defining static tag names
* Added getTagName overrides where needed that derive tag name from model
* Refactore dom wrapper methods, now consistently using getTagName
ve.ce.Surface.js
* Removed static initialization (not needed)
ve.dm.Model.js, ve.ui.Window.js
* Added missing docs
ve.ui.GroupElement.js, ve.ui.Layout.js, ve.ui.Widget.js,
* Updated class name for elements
ve.ui.Frame.js, ve.ui.LookupInputWidget.js
* Updated location of get$$
ve.ui.js
* Move get$$ to ve.Element
ve.js
* Add auto-init of static properties to mixinClass
Change-Id: I39ae14966456903728e4d9e53f806ddce9ca2b70
2013-05-13 20:52:59 +00:00
|
|
|
ve.ce.MWBlockImageNode = function VeCeMWBlockImageNode( model, config ) {
|
2013-05-17 19:40:12 +00:00
|
|
|
|
2013-04-25 00:47:17 +00:00
|
|
|
// Parent constructor
|
ve.Element refactor
Objectives:
* Move ve.ui.Element to ve.Element
* Make CE nodes inherit from ve.Element
Changes:
ve.ui.Element.js, ve.Element.js
* Move and rename
* Move ve.ui.get$$ to ve.Element.static.get$$
* Add static getDocument and getWindow methods
* Add instance getElementDocument and getElementWindow methods
* Add getTagName method, which by default reads the static tagName property, but when overridden can return a tag name based on other factors
*.php
* Updated file link
ve.ce.*Annotation.js, ve.ce.*Node.js, ve.ce.View.js, ve.ce.Document
* Added config options pass through
* Replaced passing elements through constructor with defining static tag names
* Added getTagName overrides where needed that derive tag name from model
* Refactore dom wrapper methods, now consistently using getTagName
ve.ce.Surface.js
* Removed static initialization (not needed)
ve.dm.Model.js, ve.ui.Window.js
* Added missing docs
ve.ui.GroupElement.js, ve.ui.Layout.js, ve.ui.Widget.js,
* Updated class name for elements
ve.ui.Frame.js, ve.ui.LookupInputWidget.js
* Updated location of get$$
ve.ui.js
* Move get$$ to ve.Element
ve.js
* Add auto-init of static properties to mixinClass
Change-Id: I39ae14966456903728e4d9e53f806ddce9ca2b70
2013-05-13 20:52:59 +00:00
|
|
|
ve.ce.BranchNode.call( this, model, config );
|
2013-04-25 00:47:17 +00:00
|
|
|
|
2013-11-01 06:13:09 +00:00
|
|
|
this.$element.addClass( 've-ce-mwBlockImageNode ' );
|
2013-06-19 22:58:13 +00:00
|
|
|
|
2013-11-01 06:13:09 +00:00
|
|
|
// Properties
|
|
|
|
this.type = this.model.getAttribute( 'type' );
|
|
|
|
this.alignment = this.model.getAttribute( 'align' );
|
|
|
|
this.size = {
|
|
|
|
'width': this.model.getAttribute( 'width' ),
|
|
|
|
'height': this.model.getAttribute( 'height' )
|
|
|
|
};
|
ve.Element refactor
Objectives:
* Move ve.ui.Element to ve.Element
* Make CE nodes inherit from ve.Element
Changes:
ve.ui.Element.js, ve.Element.js
* Move and rename
* Move ve.ui.get$$ to ve.Element.static.get$$
* Add static getDocument and getWindow methods
* Add instance getElementDocument and getElementWindow methods
* Add getTagName method, which by default reads the static tagName property, but when overridden can return a tag name based on other factors
*.php
* Updated file link
ve.ce.*Annotation.js, ve.ce.*Node.js, ve.ce.View.js, ve.ce.Document
* Added config options pass through
* Replaced passing elements through constructor with defining static tag names
* Added getTagName overrides where needed that derive tag name from model
* Refactore dom wrapper methods, now consistently using getTagName
ve.ce.Surface.js
* Removed static initialization (not needed)
ve.dm.Model.js, ve.ui.Window.js
* Added missing docs
ve.ui.GroupElement.js, ve.ui.Layout.js, ve.ui.Widget.js,
* Updated class name for elements
ve.ui.Frame.js, ve.ui.LookupInputWidget.js
* Updated location of get$$
ve.ui.js
* Move get$$ to ve.Element
ve.js
* Add auto-init of static properties to mixinClass
Change-Id: I39ae14966456903728e4d9e53f806ddce9ca2b70
2013-05-13 20:52:59 +00:00
|
|
|
|
2013-11-01 06:13:09 +00:00
|
|
|
this.typeToRdfa = this.getTypeToRdfa();
|
2013-05-14 23:39:13 +00:00
|
|
|
|
2013-11-01 06:13:09 +00:00
|
|
|
// DOM Hierarchy for BlockImageNode:
|
|
|
|
// <div> this.$element
|
|
|
|
// - <figure> this.$figure ( ve-ce-mwBlockImageNode-type (thumb) (tright/tleft/etc) )
|
|
|
|
// - <a> this.$a
|
|
|
|
// - <img> this.$image (thumbimage)
|
|
|
|
// - <figcaption> this.$figcaption ( thumbcaption )
|
|
|
|
|
|
|
|
// Build DOM:
|
2013-11-01 19:45:59 +00:00
|
|
|
this.$a = this.$( '<a>' )
|
2013-05-17 18:42:27 +00:00
|
|
|
.addClass( 'image' )
|
2013-10-21 15:12:54 +00:00
|
|
|
.attr( 'href', this.getResolvedAttribute( 'href' ) );
|
2013-05-17 18:42:27 +00:00
|
|
|
|
2013-11-01 19:45:59 +00:00
|
|
|
this.$image = this.$( '<img>' )
|
2013-10-21 15:12:54 +00:00
|
|
|
.attr( 'src', this.getResolvedAttribute( 'src' ) )
|
2013-11-01 06:13:09 +00:00
|
|
|
.attr( 'width', this.size.width )
|
|
|
|
.attr( 'height', this.size.height )
|
2013-05-17 18:42:27 +00:00
|
|
|
.appendTo( this.$a );
|
2013-05-17 19:40:12 +00:00
|
|
|
|
2013-11-01 06:13:09 +00:00
|
|
|
this.$figure = this.$( '<figure>' )
|
|
|
|
.appendTo( this.$element )
|
|
|
|
.append( this.$a )
|
|
|
|
.addClass( 've-ce-mwBlockImageNode-type-' + this.type )
|
|
|
|
// 'typeof' should appear with the proper Parsoid-generated
|
|
|
|
// type. The model deals with converting it
|
|
|
|
.attr( 'typeof', this.typeToRdfa[ this.type ] );
|
2013-08-30 21:04:29 +00:00
|
|
|
|
2013-11-01 06:13:09 +00:00
|
|
|
this.$element
|
|
|
|
.addClass( 've-ce-mwBlockImageNode-align-' + this.alignment );
|
2013-08-30 21:04:29 +00:00
|
|
|
|
2013-11-01 06:13:09 +00:00
|
|
|
// Update size:
|
|
|
|
this.updateSize( this.size.height, this.size.width );
|
2013-06-19 22:58:13 +00:00
|
|
|
|
2013-08-30 21:04:29 +00:00
|
|
|
// Mixin constructors
|
2013-11-01 06:13:09 +00:00
|
|
|
ve.ce.MWImageNode.call( this, this.$figure, this.$image );
|
2013-06-07 00:51:00 +00:00
|
|
|
|
2013-05-17 19:40:12 +00:00
|
|
|
// I smell a caption!
|
2013-11-01 06:13:09 +00:00
|
|
|
this.$figcaption = this.$( '<figcaption> ');
|
|
|
|
|
|
|
|
// attach the figcaption always (to prepare for option of adding one):
|
|
|
|
this.$figcaption.appendTo( this.$figure );
|
|
|
|
|
|
|
|
this.caption = {};
|
|
|
|
if ( this.type !== 'none' && this.type !== 'frameless' && this.model.children.length === 1 ) {
|
|
|
|
this.setCaptionVisible( true );
|
|
|
|
} else {
|
|
|
|
this.setCaptionVisible( false );
|
2013-05-17 19:40:12 +00:00
|
|
|
}
|
2013-10-11 12:33:53 +00:00
|
|
|
|
|
|
|
// Events
|
|
|
|
this.model.connect( this, { 'attributeChange': 'onAttributeChange' } );
|
2013-11-01 06:13:09 +00:00
|
|
|
|
2013-04-25 00:47:17 +00:00
|
|
|
};
|
|
|
|
|
2013-11-01 06:13:09 +00:00
|
|
|
|
2013-04-25 00:47:17 +00:00
|
|
|
/* Inheritance */
|
|
|
|
|
2013-10-11 21:44:09 +00:00
|
|
|
OO.inheritClass( ve.ce.MWBlockImageNode, ve.ce.BranchNode );
|
2013-04-25 00:47:17 +00:00
|
|
|
|
2013-07-16 14:06:47 +00:00
|
|
|
// Need to mixin base class as well
|
2013-10-11 21:44:09 +00:00
|
|
|
OO.mixinClass( ve.ce.MWBlockImageNode, ve.ce.GeneratedContentNode );
|
2013-06-27 18:24:26 +00:00
|
|
|
|
2013-10-11 21:44:09 +00:00
|
|
|
OO.mixinClass( ve.ce.MWBlockImageNode, ve.ce.MWImageNode );
|
2013-07-16 14:06:47 +00:00
|
|
|
|
2013-04-25 00:47:17 +00:00
|
|
|
/* Static Properties */
|
|
|
|
|
2013-05-28 11:31:41 +00:00
|
|
|
ve.ce.MWBlockImageNode.static.name = 'mwBlockImage';
|
2013-04-25 00:47:17 +00:00
|
|
|
|
2013-05-14 23:39:13 +00:00
|
|
|
ve.ce.MWBlockImageNode.static.tagName = 'div';
|
|
|
|
|
|
|
|
ve.ce.MWBlockImageNode.static.renderHtmlAttributes = false;
|
|
|
|
|
2013-06-07 00:51:00 +00:00
|
|
|
ve.ce.MWBlockImageNode.static.transition = false;
|
|
|
|
|
2013-06-19 22:58:13 +00:00
|
|
|
ve.ce.MWBlockImageNode.static.cssClasses = {
|
|
|
|
'default': {
|
2013-11-01 06:13:09 +00:00
|
|
|
'left': 'mw-halign-left',
|
|
|
|
'right': 'mw-halign-right',
|
|
|
|
'center': 'mw-halign-center',
|
|
|
|
'none': 'mw-halign-none'
|
2013-06-19 22:58:13 +00:00
|
|
|
},
|
|
|
|
'none': {
|
2013-11-01 06:13:09 +00:00
|
|
|
'left': 'mw-halign-left',
|
|
|
|
'right': 'mw-halign-right',
|
|
|
|
'center': 'mw-halign-center',
|
|
|
|
'none': 'mw-halign-none'
|
2013-06-19 22:58:13 +00:00
|
|
|
}
|
2013-05-14 23:39:13 +00:00
|
|
|
};
|
ve.Element refactor
Objectives:
* Move ve.ui.Element to ve.Element
* Make CE nodes inherit from ve.Element
Changes:
ve.ui.Element.js, ve.Element.js
* Move and rename
* Move ve.ui.get$$ to ve.Element.static.get$$
* Add static getDocument and getWindow methods
* Add instance getElementDocument and getElementWindow methods
* Add getTagName method, which by default reads the static tagName property, but when overridden can return a tag name based on other factors
*.php
* Updated file link
ve.ce.*Annotation.js, ve.ce.*Node.js, ve.ce.View.js, ve.ce.Document
* Added config options pass through
* Replaced passing elements through constructor with defining static tag names
* Added getTagName overrides where needed that derive tag name from model
* Refactore dom wrapper methods, now consistently using getTagName
ve.ce.Surface.js
* Removed static initialization (not needed)
ve.dm.Model.js, ve.ui.Window.js
* Added missing docs
ve.ui.GroupElement.js, ve.ui.Layout.js, ve.ui.Widget.js,
* Updated class name for elements
ve.ui.Frame.js, ve.ui.LookupInputWidget.js
* Updated location of get$$
ve.ui.js
* Move get$$ to ve.Element
ve.js
* Add auto-init of static properties to mixinClass
Change-Id: I39ae14966456903728e4d9e53f806ddce9ca2b70
2013-05-13 20:52:59 +00:00
|
|
|
|
2013-04-25 00:47:17 +00:00
|
|
|
/* Methods */
|
|
|
|
|
2013-11-01 06:13:09 +00:00
|
|
|
/**
|
|
|
|
* Set up an object that converts from the type to rdfa, based
|
|
|
|
* on the rdfaToType object in the model.
|
|
|
|
* @returns {Object.<string,string>} A type to Rdfa conversion object
|
|
|
|
*/
|
|
|
|
ve.ce.MWBlockImageNode.prototype.getTypeToRdfa = function() {
|
|
|
|
var rdfa, obj = {};
|
|
|
|
|
|
|
|
for ( rdfa in this.model.constructor.static.rdfaToType ) {
|
|
|
|
obj[ this.model.constructor.static.rdfaToType[rdfa] ] = rdfa;
|
|
|
|
}
|
|
|
|
return obj;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Setup a caption node according to the model
|
|
|
|
*/
|
|
|
|
ve.ce.MWBlockImageNode.prototype.setupCaption = function () {
|
|
|
|
// only create a new caption if we need it:
|
|
|
|
if ( !this.caption.view ) {
|
|
|
|
this.caption.model = this.model.children[0];
|
|
|
|
this.caption.view = ve.ce.nodeFactory.create( this.caption.model.getType(), this.caption.model );
|
|
|
|
this.caption.model.connect( this, { 'update': 'onModelUpdate' } );
|
|
|
|
this.children.push( this.caption.view );
|
|
|
|
this.caption.view.attach( this );
|
|
|
|
if ( this.live !== this.caption.view.isLive() ) {
|
|
|
|
this.caption.view.setLive( this.live );
|
|
|
|
}
|
|
|
|
// Make it a 'figcaption'
|
|
|
|
this.caption.view.$element.appendTo( this.$figcaption );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set caption either visible or invisible
|
|
|
|
*
|
|
|
|
* @param {boolean} isVisible declares whether caption will be visible
|
|
|
|
*/
|
|
|
|
ve.ce.MWBlockImageNode.prototype.setCaptionVisible = function ( isVisible ) {
|
|
|
|
if ( isVisible ) {
|
|
|
|
// update the caption:
|
|
|
|
this.setupCaption();
|
|
|
|
this.$figcaption.show();
|
|
|
|
} else {
|
|
|
|
// hide the caption:
|
|
|
|
this.$figcaption.hide();
|
|
|
|
}
|
|
|
|
// update caption visibility state:
|
|
|
|
this.caption.visible = isVisible;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update image alignment, including any style changes that occur
|
|
|
|
*
|
|
|
|
* @param {string} from The old alignment
|
|
|
|
* @param {string} to The new alignment
|
|
|
|
* @param {string} type The type of the image to which to align
|
|
|
|
*/
|
|
|
|
ve.ce.MWBlockImageNode.prototype.updateAlignment = function( from, to, type ) {
|
|
|
|
if ( from !== to ) {
|
|
|
|
// remove previous alignment:
|
|
|
|
this.$figure
|
|
|
|
.removeClass(
|
|
|
|
this.getCssClass( 'none', from )
|
|
|
|
)
|
|
|
|
.removeClass(
|
|
|
|
this.getCssClass( 'default', from )
|
|
|
|
)
|
|
|
|
.removeClass( 've-ce-mwBlockImageNode-align-' + from )
|
|
|
|
// add new alignment:
|
|
|
|
.addClass( 've-ce-mwBlockImageNode-align-' + to );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( type !== 'none' && type !== 'frameless' ) {
|
|
|
|
this.$image
|
|
|
|
.addClass( 've-ce-mwBlockImageNode-thumbimage' );
|
|
|
|
|
|
|
|
this.$figure
|
|
|
|
.addClass(
|
|
|
|
this.getCssClass( 'default', to )
|
|
|
|
)
|
|
|
|
.addClass( 've-ce-mwBlockImageNode-borderwrap' );
|
|
|
|
} else {
|
|
|
|
this.$image
|
|
|
|
.removeClass( 've-ce-mwBlockImageNode-thumbimage' );
|
|
|
|
this.$figure
|
|
|
|
.addClass(
|
|
|
|
this.getCssClass( 'none', to )
|
|
|
|
)
|
|
|
|
.removeClass( 've-ce-mwBlockImageNode-borderwrap' );
|
|
|
|
}
|
|
|
|
this.alignment = to;
|
|
|
|
// update dimensions if alignment involved 'center'
|
|
|
|
if ( to === 'center' || from === 'center' ) {
|
|
|
|
this.updateSize( this.size.height, this.size.width );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resize the image and its wrappers
|
|
|
|
*
|
|
|
|
* @param {Number} height Height of the image
|
|
|
|
* @param {Number} width Width of the image
|
|
|
|
*/
|
|
|
|
ve.ce.MWBlockImageNode.prototype.updateSize = function ( height, width ) {
|
|
|
|
this.$image
|
|
|
|
.attr( 'height', height )
|
|
|
|
.attr( 'width', width );
|
|
|
|
|
|
|
|
this.$figure
|
|
|
|
.css( {
|
|
|
|
'width': width + 5
|
|
|
|
} );
|
|
|
|
|
|
|
|
// update:
|
|
|
|
this.size = {
|
|
|
|
height: height,
|
|
|
|
width: width
|
|
|
|
};
|
|
|
|
};
|
2013-07-24 22:31:46 +00:00
|
|
|
/**
|
|
|
|
* Get the right CSS class to use for alignment
|
2013-11-01 06:13:09 +00:00
|
|
|
*
|
2013-07-24 22:31:46 +00:00
|
|
|
* @param {string} type 'none' or 'default'
|
|
|
|
* @param {string} alignment 'left', 'right', 'center', 'none' or 'default'
|
|
|
|
*/
|
|
|
|
ve.ce.MWBlockImageNode.prototype.getCssClass = function ( type, alignment ) {
|
|
|
|
// TODO use this.model.getAttribute( 'type' ) etc., see bug 52065
|
|
|
|
// Default is different between RTL and LTR wikis:
|
|
|
|
if ( type === 'default' && alignment === 'default' ) {
|
2013-11-01 19:45:59 +00:00
|
|
|
if ( this.$element.css( 'direction' ) === 'rtl' ) {
|
2013-12-12 02:32:35 +00:00
|
|
|
return 'mw-halign-left';
|
2013-07-24 22:31:46 +00:00
|
|
|
} else {
|
2013-12-12 02:32:35 +00:00
|
|
|
return 'mw-halign-right';
|
2013-07-24 22:31:46 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return this.constructor.static.cssClasses[type][alignment];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-07-23 23:13:28 +00:00
|
|
|
/**
|
|
|
|
* Override the default onSetup to add direction-dependent
|
|
|
|
* classes to the image thumbnail.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
2013-10-17 22:09:48 +00:00
|
|
|
ve.ce.MWBlockImageNode.prototype.onSetup = function () {
|
2013-07-24 22:31:46 +00:00
|
|
|
var type = this.model.getAttribute( 'type' );
|
2013-07-23 23:13:28 +00:00
|
|
|
|
2013-07-24 21:02:08 +00:00
|
|
|
ve.ce.BranchNode.prototype.onSetup.call( this );
|
|
|
|
|
2013-11-01 06:13:09 +00:00
|
|
|
this.updateAlignment( this.alignment, this.alignment, type );
|
|
|
|
if ( type !== 'none' && type !=='frameless' ) {
|
|
|
|
this.$element.addClass( this.getCssClass( 'default', this.model.getAttribute( 'align' ) ) );
|
2013-07-23 23:13:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2013-10-11 12:33:53 +00:00
|
|
|
/**
|
2013-11-01 06:13:09 +00:00
|
|
|
* Update the rendering of the 'align', src', 'width' and 'height' attributes
|
|
|
|
* when they change in the model.
|
2013-10-11 12:33:53 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {string} key Attribute key
|
|
|
|
* @param {string} from Old value
|
|
|
|
* @param {string} to New value
|
2013-10-22 17:54:59 +00:00
|
|
|
* @fires setup
|
2013-10-11 12:33:53 +00:00
|
|
|
*/
|
2013-05-14 23:39:13 +00:00
|
|
|
ve.ce.MWBlockImageNode.prototype.onAttributeChange = function ( key, from, to ) {
|
2013-07-01 20:23:51 +00:00
|
|
|
if ( key === 'height' || key === 'width' ) {
|
|
|
|
to = parseInt( to, 10 );
|
|
|
|
}
|
|
|
|
|
2013-06-07 00:51:00 +00:00
|
|
|
if ( from !== to ) {
|
2013-06-19 02:31:01 +00:00
|
|
|
switch ( key ) {
|
|
|
|
case 'align':
|
2013-11-01 06:13:09 +00:00
|
|
|
this.updateAlignment( from, to, this.type );
|
2013-06-19 02:31:01 +00:00
|
|
|
break;
|
|
|
|
case 'src':
|
2013-10-21 15:12:54 +00:00
|
|
|
this.$image.attr( 'src', this.getResolvedAttribute( 'src' ) );
|
2013-06-19 02:31:01 +00:00
|
|
|
break;
|
|
|
|
case 'width':
|
2013-11-01 06:13:09 +00:00
|
|
|
this.size.width = to;
|
|
|
|
this.updateSize( this.size.height, this.size.width );
|
2013-06-30 04:53:50 +00:00
|
|
|
break;
|
|
|
|
case 'height':
|
2013-11-01 06:13:09 +00:00
|
|
|
this.size.height = to;
|
|
|
|
this.updateSize( this.size.height, this.size.width );
|
|
|
|
break;
|
|
|
|
case 'type':
|
|
|
|
this.$element.removeClass( 've-ce-mwBlockImageNode-type-' + from );
|
|
|
|
this.$element.addClass( 've-ce-mwBlockImageNode-type-' + to );
|
|
|
|
|
|
|
|
// Update 'typeof' property
|
|
|
|
this.$figure.attr( 'typeof', this.typeToRdfa[ this.type ] );
|
|
|
|
|
|
|
|
// marking update with same 'to/from' alignment will only update
|
|
|
|
// the alignment based on the new type
|
|
|
|
this.updateAlignment( this.align, this.align, to );
|
|
|
|
// hide/show caption:
|
|
|
|
if ( to !== 'none' && to !== 'frameless' && this.model.children.length === 1 ) {
|
|
|
|
this.setCaptionVisible( true );
|
|
|
|
} else {
|
|
|
|
this.setCaptionVisible( false );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
// Other image attributes if they exist:
|
|
|
|
case 'alt':
|
|
|
|
this.$image.attr( key, to );
|
2013-06-19 02:31:01 +00:00
|
|
|
break;
|
2013-06-07 00:51:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-10-14 11:44:26 +00:00
|
|
|
/** */
|
|
|
|
ve.ce.MWBlockImageNode.prototype.onResizableResizing = function ( dimensions ) {
|
|
|
|
if ( !this.outline ) {
|
|
|
|
ve.ce.ResizableNode.prototype.onResizableResizing.call( this, dimensions );
|
2013-11-01 06:13:09 +00:00
|
|
|
|
|
|
|
this.updateSize( dimensions.height, dimensions.width );
|
2013-10-14 11:44:26 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-07-31 22:53:29 +00:00
|
|
|
/** */
|
2013-04-25 00:47:17 +00:00
|
|
|
ve.ce.MWBlockImageNode.prototype.setupSlugs = function () {
|
2013-05-14 23:39:13 +00:00
|
|
|
// Intentionally empty
|
|
|
|
};
|
|
|
|
|
2013-07-31 22:53:29 +00:00
|
|
|
/** */
|
2013-05-14 23:39:13 +00:00
|
|
|
ve.ce.MWBlockImageNode.prototype.onSplice = function () {
|
|
|
|
// Intentionally empty
|
2013-04-25 00:47:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.ce.nodeFactory.register( ve.ce.MWBlockImageNode );
|