2 'libs/text!./template.html',
5 'modules/nodePane/metaWidget/metaWidget',
7 ], function(templateSrc, $, _, metaWidget, wlxmlUtils) {
11 return function(sandbox) {
13 var view = $(_.template(templateSrc)({utils: wlxmlUtils})),
17 view.on('change', 'select', function(e) {
18 var target = $(e.target);
19 var attr = target.attr('class').split('-')[3] === 'tagSelect' ? 'Tag' : 'Class',
20 value = target.val().replace(/-/g, '.');
21 currentNode['set' + attr](value);
28 sandbox.publish('ready');
33 setNodeElement: function(wlxmlNodeElement) {
34 if(wlxmlNodeElement) {
37 wlxmlNodeElement.document.on('change', function(event) {
38 if(currentNode && !currentNode.isInDocument()) {
39 module.setNodeElement(null);
41 if(event.type === 'nodeAttrChange' && event.meta.node.sameNode(currentNode)) {
42 module.setNodeElement(currentNode);
48 view.find('.rng-module-nodePane-tagSelect').attr('disabled', false).val(wlxmlNodeElement.getTagName());
50 var escapedClassName = (wlxmlNodeElement.getClass() || '').replace(/\./g, '-');
51 view.find('.rng-module-nodePane-classSelect').attr('disabled', false).val(escapedClassName);
53 var attrs = _.extend(wlxmlNodeElement.getMetaAttributes(), wlxmlNodeElement.getOtherAttributes());
54 var widget = metaWidget.create({attrs:attrs});
55 widget.on('valueChanged', function(key, value) {
56 wlxmlNodeElement.setMetaAttribute(key, value);
57 //wlxmlNodeElement.setMetaAttribute(key, value);
59 view.find('.metaFields').empty().append(widget.el);
61 view.find('.rng-module-nodePane-tagSelect').attr('disabled', true).val('');
62 view.find('.rng-module-nodePane-classSelect').attr('disabled', true).val('');
63 view.find('.metaFields').empty();
65 currentNode = wlxmlNodeElement;