return idx;
}
return -1;
- }
+ };
var startListening = function(document) {
listens = true;
view.setElement();
}
}, this);
- }
+ };
var view = {
dom: $('<div>' + template({contents: null, parent: null}) + '</div>'),
setup: function() {
- var view = this;
this.dom.on('click', 'a', function(e) {
var target = $(e.target);
sandbox.publish('nodeClicked', target.data('element'));
},
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(),
nodeContents.forEach(function(child) {
if(child.getText) {
var text = child.getText();
- if(!text)
+ if(!text) {
text = '<pusty tekst>';
+ }
else {
if(text.length > 13) {
text = text.substr(0,13) + '...';
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]);
if(!listens) {
startListening(element.document);
}
- if(!(element.sameNode(view.currentNodeElement)))
+ if(!(element.sameNode(view.currentNodeElement))) {
view.setElement(element);
+ }
},
getView: function() {
return view.dom;