fnp
/
fnpeditor.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
ff17619
)
metaWidget wip: reacting to class change
author
Aleksander Łukasz
<aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 1 Jul 2013 14:12:10 +0000
(16:12 +0200)
committer
Aleksander Łukasz
<aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 1 Jul 2013 14:12:10 +0000
(16:12 +0200)
modules/documentCanvas/canvasNode.js
patch
|
blob
|
history
modules/documentCanvas/documentCanvas.js
patch
|
blob
|
history
modules/documentCanvas/tests/canvasNode.test.js
patch
|
blob
|
history
modules/rng/rng.js
patch
|
blob
|
history
diff --git
a/modules/documentCanvas/canvasNode.js
b/modules/documentCanvas/canvasNode.js
index
a57c10a
..
1ef5628
100644
(file)
--- a/
modules/documentCanvas/canvasNode.js
+++ b/
modules/documentCanvas/canvasNode.js
@@
-38,6
+38,16
@@
CanvasNode.prototype.getClass = function() {
return this.dom.attr('wlxml-class');
};
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');
};
CanvasNode.prototype.getId = function() {
return this.dom.attr('id');
};
diff --git
a/modules/documentCanvas/documentCanvas.js
b/modules/documentCanvas/documentCanvas.js
index
50a3777
..
2fa8722
100644
(file)
--- a/
modules/documentCanvas/documentCanvas.js
+++ b/
modules/documentCanvas/documentCanvas.js
@@
-29,8
+29,11
@@
return function(sandbox) {
},
modifyCurrentNode: function(attr, value) {
if(manager.currentNode) {
},
modifyCurrentNode: function(attr, value) {
if(manager.currentNode) {
- if(
_.contains(['tag', 'class'], attr)
) {
+ if(
attr === 'tag'
) {
manager.getNodeElement(manager.currentNode).attr('wlxml-'+attr, value);
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);
} else {
// changing node meta attr
manager.currentNode.setMetaAttr(attr, value);
diff --git
a/modules/documentCanvas/tests/canvasNode.test.js
b/modules/documentCanvas/tests/canvasNode.test.js
index
f944d90
..
0077d46
100644
(file)
--- a/
modules/documentCanvas/tests/canvasNode.test.js
+++ b/
modules/documentCanvas/tests/canvasNode.test.js
@@
-81,4
+81,16
@@
suite('meta attributes', function() {
});
});
});
});
+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
});
\ No newline at end of file
diff --git
a/modules/rng/rng.js
b/modules/rng/rng.js
index
469a6fc
..
2078494
100644
(file)
--- a/
modules/rng/rng.js
+++ b/
modules/rng/rng.js
@@
-64,10
+64,12
@@
return function(sandbox) {
},
selectNode: function(canvasNode, origin) {
sandbox.getModule('documentCanvas').selectNode(canvasNode);
},
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);
sandbox.getModule('nodePane').setNode(canvasNode);
sandbox.getModule('nodeFamilyTree').setNode(canvasNode);
sandbox.getModule('nodeBreadCrumbs').setNode(canvasNode);
-
},
resetDocument: function(document, reason) {
var modules = [];
},
resetDocument: function(document, reason) {
var modules = [];
@@
-199,6
+201,10
@@
return function(sandbox) {
dirty.documentCanvas = true;
},
dirty.documentCanvas = true;
},
+ currentNodeChanged: function(canvasNode) {
+ commands.updateNodesModules(canvasNode);
+ },
+
nodeHovered: function(canvasNode) {
commands.highlightDocumentNode(canvasNode);
},
nodeHovered: function(canvasNode) {
commands.highlightDocumentNode(canvasNode);
},