return this.dom.attr('wlxml-class');
};
+CanvasNode.prototype.setClass = function(klass) {
+ if(klass != this.getClass()) {
+ this.dom.attr('wlxml-class', klass);
+ var c = this;
+ this.getMetaAttrs().forEach(function(attr) {
+ c.dom.removeAttr('wlxml-meta-' + attr.name);
+ });
+ }
+}
+
CanvasNode.prototype.getId = function() {
return this.dom.attr('id');
};
},
modifyCurrentNode: function(attr, value) {
if(manager.currentNode) {
- if(_.contains(['tag', 'class'], attr)) {
+ if(attr === 'tag') {
manager.getNodeElement(manager.currentNode).attr('wlxml-'+attr, value);
+ }
+ else if(attr === 'class') {
+ manager.currentNode.setClass(value);
} else {
// changing node meta attr
manager.currentNode.setMetaAttr(attr, value);
});
});
+suite('modifing node', function() {
+ test('changing class removes meta attributes', function() {
+ var node = canvasNode.create({tag: 'span', klass: 'uri', meta: {uri: 'http://some.uri.com'}});
+
+ assert.equal(node.getMetaAttr('uri'), 'http://some.uri.com');
+
+ node.setClass('author');
+
+ assert.equal(node.getMetaAttr('uri'), undefined);
+ })
+})
+
});
\ No newline at end of file
},
selectNode: function(canvasNode, origin) {
sandbox.getModule('documentCanvas').selectNode(canvasNode);
+ this.updateNodesModules(canvasNode);
+ },
+ updateNodesModules: function(canvasNode) {
sandbox.getModule('nodePane').setNode(canvasNode);
sandbox.getModule('nodeFamilyTree').setNode(canvasNode);
sandbox.getModule('nodeBreadCrumbs').setNode(canvasNode);
-
},
resetDocument: function(document, reason) {
var modules = [];
dirty.documentCanvas = true;
},
+ currentNodeChanged: function(canvasNode) {
+ commands.updateNodesModules(canvasNode);
+ },
+
nodeHovered: function(canvasNode) {
commands.highlightDocumentNode(canvasNode);
},