Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | 1x 1025x 1025x 1025x 1025x 1x 1x 1008x 1008x 1008x 1008x 1x 846x 846x 846x 1x 1x 2033x 1x 1631x 1x | /*!
* VisualEditor ContentEditable ContentEditableNode class.
*
* @copyright See AUTHORS.txt
*/
/**
* A ContentEditableNode maintains its own contentEditable property
*
* @class
* @abstract
*
* @constructor
*/
ve.ce.ContentEditableNode = function VeCeContentEditableNode() {
this.ceSurface = null;
this.setContentEditable( true );
this.setReadOnly( false );
this.connect( this, {
setup: 'onContentEditableSetup',
teardown: 'onContentEditableTeardown'
} );
};
/* Inheritance */
OO.initClass( ve.ce.ContentEditableNode );
// Assumes ve.ce.Node as a base class
/* Methods */
/**
* Handle setup events on the node
*/
ve.ce.ContentEditableNode.prototype.onContentEditableSetup = function () {
// Exit if already setup or not attached
Iif ( this.ceSurface || !this.root ) {
return;
}
this.ceSurface = this.root.getSurface().getSurface();
this.ceSurface.connect( this, { readOnly: 'onSurfaceReadOnly' } );
// Set initial state
this.setReadOnly( this.ceSurface.isReadOnly() );
};
/**
* Handle teardown events on the node
*/
ve.ce.ContentEditableNode.prototype.onContentEditableTeardown = function () {
// Exit if not setup
Iif ( !this.ceSurface ) {
return;
}
this.ceSurface.disconnect( this, { readOnly: 'onSurfaceReadOnly' } );
this.ceSurface = null;
};
/**
* Handle readOnly events from the surface
*
* @param {boolean} readOnly Surface is read-only
*/
ve.ce.ContentEditableNode.prototype.onSurfaceReadOnly = function ( readOnly ) {
this.setReadOnly( readOnly );
};
/**
* Called when the surface read-only state changes
*
* @param {boolean} readOnly Surface is read-only
*/
ve.ce.ContentEditableNode.prototype.setReadOnly = function ( readOnly ) {
this.$element.prop( 'spellcheck', !readOnly );
};
/**
* Enable or disable editing on this node
*
* @param {boolean} enabled Whether to enable editing
*/
ve.ce.ContentEditableNode.prototype.setContentEditable = function ( enabled ) {
this.$element.prop( 'contentEditable', ( !!enabled ).toString() );
};
/**
* Check if the node is currently editable
*
* @return {boolean} Node is currently editable
*/
ve.ce.ContentEditableNode.prototype.isContentEditable = function () {
return this.$element.prop( 'contentEditable' ) === 'true';
};
|