From: Aleksander Ɓukasz Date: Mon, 15 Apr 2013 13:42:04 +0000 (+0200) Subject: Separate metadata ui in visual editor X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/9385033bf213d7d00f0646c1ee3b3aa8a463cf02 Separate metadata ui in visual editor --- diff --git a/editor.css b/editor.css index ba6ec7b..9b7995d 100644 --- a/editor.css +++ b/editor.css @@ -17,4 +17,12 @@ body { #rng-skelton-menu ul { list-style-type: none; +} + +#rng-visualEditor-content { + float:left; +} + +#rng-visualEditor-meta { + float:right; } \ No newline at end of file diff --git a/modules/visualEditor.js b/modules/visualEditor.js index 2fecfde..2c3b6d3 100644 --- a/modules/visualEditor.js +++ b/modules/visualEditor.js @@ -4,11 +4,34 @@ rng.modules.visualEditor = function(sandbox) { var view = $(sandbox.getTemplate('main')()); var isDirty = false; + var getMetaData = function() { + var toret = {}; + view.find('#rng-visualEditor-meta table tr').each(function() { + var tr = $(this); + var key = $(tr.find('td')[0]).html(); + var value = $(tr.find('td input')[0]).val(); + toret[key] = value; + }); + console.log(toret); + return toret; + }; + + var setMetaData = function(metadata) { + var table = view.find('#rng-visualEditor-meta table'); + table.empty(); + _.each(_.keys(metadata), function(key) { + $(sandbox.getTemplate('metaItem')({key: key, value: metadata[key]})).appendTo(table); + }); + }; $('#rng-visualEditor-content', view).on('keyup', function() { isDirty = true; }); + $('#rng-visualEditor-meta', view).on('keyup', function() { + isDirty = true; + }); + return { start: function() { sandbox.publish('ready'); @@ -19,10 +42,11 @@ rng.modules.visualEditor = function(sandbox) { setDocument: function(xml) { var transformed = transformations.fromXML.getDocumentDescription(xml); $('#rng-visualEditor-content', view).html(transformed.HTMLTree); + setMetaData(transformed.metadata); isDirty = false; }, getDocument: function() { - return transformations.toXML.getXML({HTMLTree: $('#rng-visualEditor-content').text(), metadata: {}}); + return transformations.toXML.getXML({HTMLTree: $('#rng-visualEditor-content').html(), metadata: getMetaData()}); }, isDirty: function() { return isDirty;