2012-05-01 00:36:22 +00:00
|
|
|
/**
|
2012-05-22 00:39:03 +00:00
|
|
|
* ContentEditable node for an alien block node.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-05-01 00:36:22 +00:00
|
|
|
* @class
|
|
|
|
* @constructor
|
|
|
|
* @extends {ve.ce.LeafNode}
|
2012-05-22 00:39:03 +00:00
|
|
|
* @param model {ve.dm.AlienBlockNode} Model to observe
|
2012-05-01 00:36:22 +00:00
|
|
|
*/
|
2012-05-22 00:39:03 +00:00
|
|
|
ve.ce.AlienBlockNode = function( model ) {
|
2012-05-01 00:36:22 +00:00
|
|
|
// Inheritance
|
2012-05-22 00:39:03 +00:00
|
|
|
ve.ce.LeafNode.call( this, 'alienBlock', model );
|
2012-05-10 05:36:25 +00:00
|
|
|
|
2012-05-23 19:03:28 +00:00
|
|
|
// DOM Changes
|
|
|
|
this.$.addClass( 've-ce-alienBlockNode' );
|
2012-05-26 06:36:18 +00:00
|
|
|
this.$.attr( 'contenteditable', false );
|
2012-05-23 19:03:28 +00:00
|
|
|
|
2012-05-10 05:36:25 +00:00
|
|
|
// Events
|
|
|
|
this.model.addListenerMethod( this, 'update', 'onUpdate' );
|
|
|
|
|
|
|
|
// Intialization
|
|
|
|
this.onUpdate();
|
2012-05-01 00:36:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Static Members */
|
|
|
|
|
|
|
|
/**
|
2012-05-02 18:29:44 +00:00
|
|
|
* Node rules.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-05-01 00:36:22 +00:00
|
|
|
* @see ve.ce.NodeFactory
|
2012-05-02 18:29:44 +00:00
|
|
|
* @static
|
|
|
|
* @member
|
2012-05-01 00:36:22 +00:00
|
|
|
*/
|
2012-05-22 00:39:03 +00:00
|
|
|
ve.ce.AlienBlockNode.rules = {
|
2012-05-01 00:36:22 +00:00
|
|
|
'canBeSplit': false
|
|
|
|
};
|
|
|
|
|
2012-05-10 05:36:25 +00:00
|
|
|
/* Methods */
|
|
|
|
|
2012-05-22 00:39:03 +00:00
|
|
|
ve.ce.AlienBlockNode.prototype.onUpdate = function() {
|
2012-06-15 06:57:40 +00:00
|
|
|
// TODO preventDefault on click for links inside, user should not leave the page
|
2012-05-10 05:36:25 +00:00
|
|
|
this.$.html( this.model.getAttribute( 'html' ) );
|
|
|
|
};
|
|
|
|
|
2012-05-01 00:36:22 +00:00
|
|
|
/* Registration */
|
|
|
|
|
2012-05-31 22:20:58 +00:00
|
|
|
ve.ce.nodeFactory.register( 'alienBlock', ve.ce.AlienBlockNode );
|
2012-05-01 00:36:22 +00:00
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2012-05-22 00:39:03 +00:00
|
|
|
ve.extendClass( ve.ce.AlienBlockNode, ve.ce.LeafNode );
|