X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/eebb24ef74a635e06c6bc8f074302996ca5936ec..b5a1f98a2118706355925314bfe3027ba45464e8:/modules/nodeBreadCrumbs/nodeBreadCrumbs.js diff --git a/modules/nodeBreadCrumbs/nodeBreadCrumbs.js b/modules/nodeBreadCrumbs/nodeBreadCrumbs.js new file mode 100644 index 0000000..99143bc --- /dev/null +++ b/modules/nodeBreadCrumbs/nodeBreadCrumbs.js @@ -0,0 +1,51 @@ +define([ +'libs/jquery-1.9.1.min', +'libs/underscore-min', +'libs/text!./template.html'], function($, _, templateSrc) { + +'use strict'; + +return function(sandbox) { + + var template = _.template(templateSrc); + + var view = { + dom: $('
' + template({node:null, parents: null}) + '
'), + setup: function() { + this.dom.on('mouseenter', 'a', function(e) { + var target = $(e.target); + sandbox.publish('nodeHighlighted', target.attr('data-id')); + }); + this.dom.on('mouseleave', 'a', function(e) { + var target = $(e.target); + sandbox.publish('nodeDimmed', target.attr('data-id')); + }); + this.dom.on('click', 'a', function(e) { + e.preventDefault(); + sandbox.publish('nodeSelected', target.attr('data-id')); + }); + }, + + setNode: function(node) { + this.dom.empty(); + this.dom.html(template({node: node, parents: node.parents('[wlxml-tag]')})); + }, + + highlightNode: function(id) { + this.dom.find('a[data-id="'+id+'"]').addClass('rng-common-hoveredNode'); + }, + dimNode: function(id) { + this.dom.find('a[data-id="' +id+'"]').removeClass('rng-common-hoveredNode'); + } + } + + view.setup(); + + return { + start: function() { sandbox.publish('ready'); }, + getView: function() { return view.dom; }, + setNode: function(node) { view.setNode(node); } + } +} + +}); \ No newline at end of file