// DocumentElement represents a text or an element node from WLXML document rendered inside Canvas
var DocumentElement = function(wlxmlNode, canvas) {
- if(arguments.length === 0) {
- return;
- }
this.wlxmlNode = wlxmlNode;
this.canvas = canvas;
return other && (typeof other === typeof this) && other.dom()[0] === this.dom()[0];
},
- markAsCurrent: function() {
- this.canvas.markAsCurrent(this);
- },
-
getVerticallyFirstTextElement: function() {
var toret;
this.children().some(function(child) {
- if(!child.isVisible()) {
- return false; // continue
- }
if(child instanceof DocumentTextElement) {
toret = child;
return true; // break
return this.canvas.getDocumentElement(utils.nearestInDocumentOrder(selector, direction, this.dom()[0]));
},
- isVisible: function() {
- return this instanceof DocumentTextElement || this.getWlxmlTag() !== 'metadata';
- },
-
- isInsideList: function() {
- return this.parents().some(function(parent) {
- return parent.is('list');
- });
- },
-
exec: function(method) {
if(this.manager && this.manager[method]) {
return this.manager[method].apply(this.manager, Array.prototype.slice.call(arguments, 1));
return element;
};
-DocumentNodeElement.prototype = new DocumentElement();
+DocumentNodeElement.prototype = Object.create(DocumentElement.prototype);
$.extend(DocumentNodeElement.prototype, {
this.manager = wlxmlManagers.getFor(this);
this.manager.setup();
},
- is: function(what) {
- if(what === 'list' && _.contains(['list.items', 'list.items.enum'], this.getWlxmlClass())) {
- return true;
- }
- return false;
- },
toggleLabel: function(toggle) {
var displayCss = toggle ? 'inline-block' : 'none';
var label = this.dom().children('.canvas-widgets').find('.canvas-widget-label');
}
});
-DocumentTextElement.prototype = new DocumentElement();
+DocumentTextElement.prototype = Object.create(DocumentElement.prototype);
$.extend(DocumentTextElement.prototype, {
createDOM: function() {