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 Tag: gettext('Tag editing'),
18 Class: gettext('Class editing')
21 view.on('change', 'select', function(e) {
22 var target = $(e.target);
23 var attr = target.attr('class').split('-')[3] === 'tagSelect' ? 'Tag' : 'Class',
24 value = target.val().replace(/-/g, '.'),
25 oldValue = attr === 'Tag' ? currentNode.getTagName() : currentNode.getClass();
26 currentNode.document.transaction(function() {
27 currentNode['set' + attr](value);
28 }, this, msgs[attr] + ': ' + oldValue + ' -> ' + value);
35 sandbox.publish('ready');
40 setNodeElement: function(wlxmlNodeElement) {
41 if(wlxmlNodeElement) {
44 wlxmlNodeElement.document.on('change', function(event) {
45 if(currentNode && !currentNode.isInDocument()) {
46 module.setNodeElement(null);
48 if(event.type === 'nodeAttrChange' && event.meta.node.sameNode(currentNode)) {
49 module.setNodeElement(currentNode);
55 view.find('.rng-module-nodePane-tagSelect').attr('disabled', false).val(wlxmlNodeElement.getTagName());
57 var escapedClassName = (wlxmlNodeElement.getClass() || '').replace(/\./g, '-');
58 view.find('.rng-module-nodePane-classSelect').attr('disabled', false).val(escapedClassName);
60 var attrs = _.extend(wlxmlNodeElement.getMetaAttributes(), wlxmlNodeElement.getOtherAttributes());
61 var widget = metaWidget.create({attrs:attrs});
62 widget.on('valueChanged', function(key, value) {
63 wlxmlNodeElement.setMetaAttribute(key, value);
64 //wlxmlNodeElement.setMetaAttribute(key, value);
66 view.find('.metaFields').empty().append(widget.el);
68 view.find('.rng-module-nodePane-tagSelect').attr('disabled', true).val('');
69 view.find('.rng-module-nodePane-classSelect').attr('disabled', true).val('');
70 view.find('.metaFields').empty();
72 currentNode = wlxmlNodeElement;