mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Merge "Add more resize events"
This commit is contained in:
commit
b74cb1d634
|
@ -16,7 +16,7 @@
|
|||
* node's DOM rendering.
|
||||
*
|
||||
* If your focusable node changes size and the highlight must be redrawn, call redrawHighlight().
|
||||
* 'resize' and 'rerender' are already bound to call this.
|
||||
* 'resizeEnd' and 'rerender' are already bound to call this.
|
||||
*
|
||||
* @class
|
||||
* @abstract
|
||||
|
@ -34,7 +34,7 @@ ve.ce.FocusableNode = function VeCeFocusableNode( $focusable ) {
|
|||
// Events
|
||||
this.connect( this, {
|
||||
'setup': 'onFocusableSetup',
|
||||
'resize': 'onFocusableResize',
|
||||
'resizeEnd': 'onFocusableResize',
|
||||
'rerender': 'onFocusableRerender',
|
||||
'live': 'onFocusableLive'
|
||||
} );
|
||||
|
|
|
@ -26,7 +26,7 @@ ve.ce.RelocatableNode = function VeCeRelocatableNode( $relocatable ) {
|
|||
this.connect( this, {
|
||||
'focus': 'onRelocatableFocus',
|
||||
'blur': 'onRelocatableBlur',
|
||||
'resize': 'onRelocatableResize',
|
||||
'resizeEnd': 'onRelocatableResize',
|
||||
'live': 'onRelocatableLive'
|
||||
} );
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ ve.ce.ResizableNode = function VeCeResizableNode( $resizable, config ) {
|
|||
'focus': 'onResizableFocus',
|
||||
'blur': 'onResizableBlur',
|
||||
'live': 'onResizableLive',
|
||||
'resize': 'onResizableFocus'
|
||||
'resizeEnd': 'onResizableFocus'
|
||||
} );
|
||||
|
||||
// Initialization
|
||||
|
@ -41,6 +41,22 @@ ve.ce.ResizableNode = function VeCeResizableNode( $resizable, config ) {
|
|||
.append( this.$$( '<div>' ).addClass( 've-ce-resizableNode-swHandle' ) );
|
||||
};
|
||||
|
||||
/* Events */
|
||||
|
||||
/**
|
||||
* @event resizeStart
|
||||
*/
|
||||
|
||||
/**
|
||||
* @event resizing
|
||||
* @param {Object} dimensions Dimension object containing width & height
|
||||
*/
|
||||
|
||||
/**
|
||||
* @event resizeEnd
|
||||
*/
|
||||
|
||||
|
||||
/* Static Properties */
|
||||
|
||||
ve.ce.ResizableNode.static = {};
|
||||
|
@ -108,6 +124,7 @@ ve.ce.ResizableNode.prototype.onResizableLive = function () {
|
|||
*
|
||||
* @method
|
||||
* @param {jQuery.Event} e Click event
|
||||
* @emits resizeStart
|
||||
*/
|
||||
ve.ce.ResizableNode.prototype.onResizeHandlesCornerMouseDown = function ( e ) {
|
||||
// Hide context menu
|
||||
|
@ -142,6 +159,7 @@ ve.ce.ResizableNode.prototype.onResizeHandlesCornerMouseDown = function ( e ) {
|
|||
'mousemove.ve-ce-resizableNode': ve.bind( this.onDocumentMouseMove, this ),
|
||||
'mouseup.ve-ce-resizableNode': ve.bind( this.onDocumentMouseUp, this )
|
||||
} );
|
||||
this.emit( 'resizeStart' );
|
||||
|
||||
return false;
|
||||
};
|
||||
|
@ -181,6 +199,7 @@ ve.ce.ResizableNode.prototype.setResizableHandlesSizeAndPosition = function () {
|
|||
*
|
||||
* @method
|
||||
* @param {jQuery.Event} e Click event
|
||||
* @emits resizing
|
||||
*/
|
||||
ve.ce.ResizableNode.prototype.onDocumentMouseMove = function ( e ) {
|
||||
var newWidth, newHeight, newRatio, snapMin, snapMax, snap,
|
||||
|
@ -260,6 +279,7 @@ ve.ce.ResizableNode.prototype.onDocumentMouseMove = function ( e ) {
|
|||
|
||||
// Update bounding box
|
||||
this.$resizeHandles.css( dimensions );
|
||||
this.emit( 'resizing', dimensions );
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -267,6 +287,7 @@ ve.ce.ResizableNode.prototype.onDocumentMouseMove = function ( e ) {
|
|||
* Handle body mouseup.
|
||||
*
|
||||
* @method
|
||||
* @emits resizeEnd
|
||||
*/
|
||||
ve.ce.ResizableNode.prototype.onDocumentMouseUp = function () {
|
||||
var attrChanges,
|
||||
|
@ -294,7 +315,7 @@ ve.ce.ResizableNode.prototype.onDocumentMouseUp = function () {
|
|||
// user doesn't perform a drag
|
||||
this.root.getSurface().getSurface().getContext().update();
|
||||
|
||||
this.emit( 'resize' );
|
||||
this.emit( 'resizeEnd' );
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue