| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
ve.dm.ImageNode = function VeDmImageNode() { |
| 18 |
|
| 19 |
ve.dm.FocusableNode.call( this ); |
| 20 |
ve.dm.ResizableNode.call( this ); |
| 21 |
}; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
OO.mixinClass( ve.dm.ImageNode, ve.dm.FocusableNode ); |
| 26 |
|
| 27 |
OO.mixinClass( ve.dm.ImageNode, ve.dm.ResizableNode ); |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
ve.dm.ImageNode.static.isDiffComparable = function ( element, other ) { |
| 36 |
|
| 37 |
return element.type === other.type && element.attributes.src === other.attributes.src; |
| 38 |
}; |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
ve.dm.ImageNode.static.describeChanges = function ( attributeChanges, attributes ) { |
| 45 |
const customKeys = [ 'width', 'height' ], |
| 46 |
descriptions = []; |
| 47 |
|
| 48 |
function describeSize( width, height ) { |
| 49 |
return width + ve.msg( 'visualeditor-dimensionswidget-times' ) + height + ve.msg( 'visualeditor-dimensionswidget-px' ); |
| 50 |
} |
| 51 |
|
| 52 |
if ( 'width' in attributeChanges || 'height' in attributeChanges ) { |
| 53 |
const sizeFrom = describeSize( |
| 54 |
'width' in attributeChanges ? attributeChanges.width.from : attributes.width, |
| 55 |
'height' in attributeChanges ? attributeChanges.height.from : attributes.height |
| 56 |
); |
| 57 |
const sizeTo = describeSize( |
| 58 |
'width' in attributeChanges ? attributeChanges.width.to : attributes.width, |
| 59 |
'height' in attributeChanges ? attributeChanges.height.to : attributes.height |
| 60 |
); |
| 61 |
|
| 62 |
descriptions.push( ve.htmlMsg( 'visualeditor-changedesc-image-size', this.wrapText( 'del', sizeFrom ), this.wrapText( 'ins', sizeTo ) ) ); |
| 63 |
} |
| 64 |
for ( const key in attributeChanges ) { |
| 65 |
if ( customKeys.indexOf( key ) === -1 ) { |
| 66 |
const change = this.describeChange( key, attributeChanges[ key ] ); |
| 67 |
if ( change ) { |
| 68 |
descriptions.push( change ); |
| 69 |
} |
| 70 |
} |
| 71 |
} |
| 72 |
return descriptions; |
| 73 |
}; |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
ve.dm.ImageNode.static.describeChange = function ( key, change ) { |
| 80 |
switch ( key ) { |
| 81 |
case 'align': |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
return ve.htmlMsg( 'visualeditor-changedesc-align', |
| 90 |
this.wrapText( 'del', ve.msg( 'visualeditor-align-desc-' + change.from ) ), |
| 91 |
this.wrapText( 'ins', ve.msg( 'visualeditor-align-desc-' + change.to ) ) |
| 92 |
); |
| 93 |
|
| 94 |
case 'originalClasses': |
| 95 |
case 'unrecognizedClasses': |
| 96 |
return; |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
return ve.dm.Node.static.describeChange.apply( this, arguments ); |
| 101 |
}; |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
ve.dm.ImageNode.prototype.createScalable = function () { |
| 109 |
return new ve.dm.Scalable( { |
| 110 |
currentDimensions: { |
| 111 |
width: this.getAttribute( 'width' ), |
| 112 |
height: this.getAttribute( 'height' ) |
| 113 |
}, |
| 114 |
minDimensions: { |
| 115 |
width: 1, |
| 116 |
height: 1 |
| 117 |
} |
| 118 |
} ); |
| 119 |
}; |