X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/a398f2a96740ebe6dd60559d90e74c648e7009af..fe38f435c3602a2259e36b11f6faf1f99272e52b:/modules/nodePane/nodePane.js diff --git a/modules/nodePane/nodePane.js b/modules/nodePane/nodePane.js index 57f5c17..b723e68 100644 --- a/modules/nodePane/nodePane.js +++ b/modules/nodePane/nodePane.js @@ -2,19 +2,20 @@ define([ 'libs/text!./template.html', 'libs/jquery-1.9.1.min', 'libs/underscore-min', - -], function(templateSrc, $, _) { +'modules/nodePane/metaWidget/metaWidget', +'utils/wlxml' +], function(templateSrc, $, _, metaWidget, wlxmlUtils) { 'use strict'; return function(sandbox) { - var view = $(_.template(templateSrc)()); + var view = $(_.template(templateSrc)({tagNames: wlxmlUtils.wlxmlTagNames, classNames: wlxmlUtils.wlxmlClassNames})); view.on('change', 'select', function(e) { var target = $(e.target); var attr = target.attr('class').split('-')[3] === 'tagSelect' ? 'tag' : 'class'; - sandbox.publish('nodeChanged', attr, target.val()); + sandbox.publish('nodeElementChange', attr, target.val().replace(/-/g, '.')); }); return { @@ -24,9 +25,17 @@ return function(sandbox) { getView: function() { return view; }, - setNode: function(canvasNode) { - view.find('.rng-module-nodePane-tagSelect').val(canvasNode.getTag()); - view.find('.rng-module-nodePane-classSelect').val(canvasNode.getClass()); + setNodeElement: function(nodeElement) { + view.find('.rng-module-nodePane-tagSelect').val(nodeElement.getWlxmlTag()); + + var escapedClassName = (nodeElement.getWlxmlClass() || '').replace(/\./g, '-') + view.find('.rng-module-nodePane-classSelect').val(escapedClassName); + + var widget = metaWidget.create({attrs:nodeElement.getWlxmlMetaAttrs()}); + widget.on('valueChanged', function(key, value) { + sandbox.publish('nodeElementChange', key, value); + }); + view.find('.metaFields').empty().append(widget.el); } };