2012-05-01 00:36:22 +00:00
|
|
|
/**
|
|
|
|
* ContentEditable node for a document.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-05-01 00:36:22 +00:00
|
|
|
* @class
|
|
|
|
* @constructor
|
|
|
|
* @extends {ve.ce.LeafNode}
|
|
|
|
* @param model {ve.dm.AlienNode} Model to observe
|
|
|
|
*/
|
|
|
|
ve.ce.AlienNode = function( model ) {
|
|
|
|
// Inheritance
|
2012-05-05 00:50:54 +00:00
|
|
|
ve.ce.LeafNode.call( this, 'alien', model );
|
2012-05-10 05:36:25 +00:00
|
|
|
|
|
|
|
// Events
|
|
|
|
this.model.addListenerMethod( this, 'update', 'onUpdate' );
|
|
|
|
|
|
|
|
// Intialization
|
|
|
|
var _this = this;
|
|
|
|
|
|
|
|
/* We might need some of those at some point */
|
|
|
|
/*
|
|
|
|
this.$.on( {
|
|
|
|
'mousedown': function() {
|
|
|
|
_this.$.css( '-webkit-user-select', 'none' );
|
|
|
|
},
|
|
|
|
'mouseup': function() {
|
|
|
|
_this.$.css( '-webkit-user-select', '' );
|
|
|
|
},
|
|
|
|
} );
|
|
|
|
|
|
|
|
this.$.attr( 'contenteditable', false );
|
|
|
|
*/
|
|
|
|
|
|
|
|
// TODO: move to .css file
|
|
|
|
this.$.css( {
|
|
|
|
'display': 'inline',
|
|
|
|
'border': 'rgba(0,0,0,0.3) dashed 1px',
|
|
|
|
'background-color': 'rgba(255,255,186,0.3)'
|
|
|
|
} );
|
|
|
|
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
|
|
|
*/
|
|
|
|
ve.ce.AlienNode.rules = {
|
|
|
|
'canBeSplit': false
|
|
|
|
};
|
|
|
|
|
2012-05-10 05:36:25 +00:00
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
ve.ce.AlienNode.prototype.onUpdate = function() {
|
|
|
|
this.$.html( this.model.getAttribute( 'html' ) );
|
|
|
|
};
|
|
|
|
|
2012-05-01 00:36:22 +00:00
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.ce.factory.register( 'alien', ve.ce.AlienNode );
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
ve.extendClass( ve.ce.AlienNode, ve.ce.LeafNode );
|