X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/b2afd91d9ec91ebcf2779b6cbd36f62eba871d69..880c488dbdf310c616a237274d84d93517403372:/src/editor/modules/nodeFamilyTree/nodeFamilyTree.js?ds=sidebyside
diff --git a/src/editor/modules/nodeFamilyTree/nodeFamilyTree.js b/src/editor/modules/nodeFamilyTree/nodeFamilyTree.js
index cb7b57a..e2a4eb8 100644
--- a/src/editor/modules/nodeFamilyTree/nodeFamilyTree.js
+++ b/src/editor/modules/nodeFamilyTree/nodeFamilyTree.js
@@ -23,7 +23,7 @@ return function(sandbox) {
return idx;
}
return -1;
- }
+ };
var startListening = function(document) {
listens = true;
@@ -32,12 +32,11 @@ return function(sandbox) {
view.setElement();
}
}, this);
- }
+ };
var view = {
dom: $('
' + template({contents: null, parent: null}) + '
'),
setup: function() {
- var view = this;
this.dom.on('click', 'a', function(e) {
var target = $(e.target);
sandbox.publish('nodeClicked', target.data('element'));
@@ -54,7 +53,6 @@ return function(sandbox) {
},
setElement: function(element) {
element = element || this.currentNodeElement;
- console.log('familyTree sets node');
var textElement = element.getText ? element : null,
nodeElement = element.getText ? element.parent() : element, // TODO: better type detection
nodeElementParent = nodeElement.parent(),
@@ -67,7 +65,7 @@ return function(sandbox) {
items.push(nodeElementParent);
parent = {
id: items.length - 1,
- repr: wlxmlUtils.wlxmlTagNames[nodeElementParent.getTagName()] + (nodeElementParent.getClass() ? ' / ' + wlxmlUtils.wlxmlClassNames[nodeElementParent.getClass()] : '')
+ repr: wlxmlUtils.getTagLabel(nodeElementParent.getTagName()) + (nodeElementParent.getClass() ? ' / ' + wlxmlUtils.getClassLabel(nodeElementParent.getClass()) : '')
};
}
@@ -77,8 +75,9 @@ return function(sandbox) {
nodeContents.forEach(function(child) {
if(child.getText) {
var text = child.getText();
- if(!text)
+ if(!text) {
text = '';
+ }
else {
if(text.length > 13) {
text = text.substr(0,13) + '...';
@@ -92,7 +91,7 @@ return function(sandbox) {
} else {
contents.push({
id: items.length,
- repr: wlxmlUtils.wlxmlTagNames[child.getTagName()] + (child.getClass() ? ' / ' + wlxmlUtils.wlxmlClassNames[child.getClass()] : '')
+ repr: wlxmlUtils.getTagLabel(child.getTagName()) + (child.getClass() ? ' / ' + wlxmlUtils.getClassLabel(child.getClass()) : '')
});
}
items.push(child);
@@ -101,7 +100,7 @@ return function(sandbox) {
this.dom.append($(template({parent: parent, contents: contents})));
if(parent) {
- this.dom.find('.rng-module-nodeFamilyTree-parent').data('element', nodeElementParent)
+ this.dom.find('.rng-module-nodeFamilyTree-parent').data('element', nodeElementParent);
}
this.dom.find('li a').each(function(idx, a) {
$(a).data('element', nodeContents[idx]);
@@ -127,8 +126,9 @@ return function(sandbox) {
if(!listens) {
startListening(element.document);
}
- if(!(element.sameNode(view.currentNodeElement)))
+ if(!(element.sameNode(view.currentNodeElement))) {
view.setElement(element);
+ }
},
getView: function() {
return view.dom;