| 1 | /*! |
| 2 | * VisualEditor ContentEditable MWResizableNode class. |
| 3 | * |
| 4 | * @copyright See AUTHORS.txt |
| 5 | * @license The MIT License (MIT); see LICENSE.txt |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * ContentEditable MediaWiki resizable node. |
| 10 | * |
| 11 | * @class |
| 12 | * @abstract |
| 13 | * @extends ve.ce.ResizableNode |
| 14 | * |
| 15 | * @constructor |
| 16 | * @param {jQuery} [$resizable=this.$element] Resizable DOM element |
| 17 | * @param {Object} [config] Configuration options |
| 18 | */ |
| 19 | ve.ce.MWResizableNode = function VeCeMWResizableNode( $resizable, config ) { |
| 20 | ve.ce.ResizableNode.call( this, $resizable, config ); |
| 21 | }; |
| 22 | |
| 23 | /* Inheritance */ |
| 24 | |
| 25 | OO.inheritClass( ve.ce.MWResizableNode, ve.ce.ResizableNode ); |
| 26 | |
| 27 | /** |
| 28 | * Generate an object of attributes changes from the new width and height. |
| 29 | * |
| 30 | * If either property changes, clear the defaultSize flag. |
| 31 | * |
| 32 | * @param {number} width New image width |
| 33 | * @param {number} height New image height |
| 34 | * @return {Object} Attribute changes |
| 35 | */ |
| 36 | ve.ce.MWResizableNode.prototype.getAttributeChanges = function ( width, height ) { |
| 37 | const attrChanges = ve.ce.ResizableNode.prototype.getAttributeChanges.call( this, width, height ); |
| 38 | if ( !ve.isEmptyObject( attrChanges ) ) { |
| 39 | attrChanges.defaultSize = false; |
| 40 | } |
| 41 | // type=frame is not resizeable, so change it to type=thumb |
| 42 | if ( this.getModel().getAttribute( 'type' ) === 'frame' ) { |
| 43 | attrChanges.type = 'thumb'; |
| 44 | } |
| 45 | return attrChanges; |
| 46 | }; |