mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-01 17:36:35 +00:00
1878c7c5a8
*.php * Added links to new file ve.ce.ImageNode.js * Added relocatable node mixin * Added $image reference to the actual img element, so if it's wrapped in a sub class the functionality in the parent class doesn't break. * Moved drag start event handling to relocatable node * Removed drag end binding, not needed. ve.ce.MWImageNode.js * Moved addClass to initialization section of constructor. * Copied 'view' data prop from image element to keep stuff working after the wrapping. ve.ce.Node.css * Switched to default (arrow) cursor for images. ve.ce.RelocatableNode.js * New mixing for nodes that should be relocatable * Added implementation for drag start, which tells the surface to allow dragging this node. ve.ce.Surface.js * Added relocation support, which is used by relocatable nodes * Split onDocumentDragDrop into onDocumentDragOver and onDocumentDrop which now have implementations that support relocation of nodes ve.ui.Context.js * Added relocation tracking to prevent context being shown while relocating Change-Id: I8703adfb707af2c3224431afc3418356ac2c686c
59 lines
1.3 KiB
JavaScript
59 lines
1.3 KiB
JavaScript
/*!
|
|
* VisualEditor ContentEditable RelocatableNode class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* ContentEditable relocatable node.
|
|
*
|
|
* @class
|
|
* @abstract
|
|
*
|
|
* @constructor
|
|
* @param {jQuery} [$draggable=this.$] Draggable DOM element
|
|
*/
|
|
ve.ce.RelocatableNode = function VeCeRelocatableNode( $draggable ) {
|
|
// Properties
|
|
this.$draggable = $draggable || this.$;
|
|
this.surface = null;
|
|
|
|
// Events
|
|
this.$draggable.on( {
|
|
'dragstart': ve.bind( this.onRelocatableDragStart, this ),
|
|
'dragend': ve.bind( this.onRelocatableDragEnd, this )
|
|
} );
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Handle element drag start.
|
|
*
|
|
* @method
|
|
* @param {jQuery.Event} e Drag start event
|
|
*/
|
|
ve.ce.RelocatableNode.prototype.onRelocatableDragStart = function () {
|
|
// Store a copy of the surface, when dragend occurs the node will be detached
|
|
this.surface = this.getRoot().getSurface();
|
|
|
|
if ( this.surface ) {
|
|
// Allow dragging this node in the surface
|
|
this.surface.startRelocation( this );
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Handle element drag end.
|
|
*
|
|
* @method
|
|
* @param {jQuery.Event} e Drag end event
|
|
*/
|
|
ve.ce.RelocatableNode.prototype.onRelocatableDragEnd = function () {
|
|
if ( this.surface ) {
|
|
this.surface.endRelocation();
|
|
this.surface = null;
|
|
}
|
|
};
|