1 rng.modules.visualEditor = function(sandbox) {
\r
2 var transformations = rng.modules.visualEditor.transformations;
\r
4 var view = $(sandbox.getTemplate('main')());
\r
7 var getMetaData = function() {
\r
9 view.find('#rng-visualEditor-meta table tr').each(function() {
\r
11 var key = $(tr.find('td')[0]).html();
\r
12 var value = $(tr.find('td input')[0]).val();
\r
19 var setMetaData = function(metadata) {
\r
20 var table = view.find('#rng-visualEditor-meta table');
\r
22 _.each(_.keys(metadata), function(key) {
\r
23 $(sandbox.getTemplate('metaItem')({key: key, value: metadata[key]})).appendTo(table);
\r
27 $('#rng-visualEditor-content', view).on('keyup', function() {
\r
31 $('#rng-visualEditor-meta', view).on('keyup', function() {
\r
37 sandbox.publish('ready');
\r
39 getView: function() {
\r
42 setDocument: function(xml) {
\r
43 var transformed = transformations.fromXML.getDocumentDescription(xml);
\r
44 $('#rng-visualEditor-content', view).html(transformed.HTMLTree);
\r
45 setMetaData(transformed.metadata);
\r
48 getDocument: function() {
\r
49 return transformations.toXML.getXML({HTMLTree: $('#rng-visualEditor-content').html(), metadata: getMetaData()});
\r
51 isDirty: function() {
\r
54 setDirty: function(dirty) {
\r