1 rng.modules.visualEditor = function(sandbox) {
\r
2 var transformations = rng.modules.visualEditor.transformations;
\r
5 node: $(sandbox.getTemplate('main')()),
\r
7 var node = this.node;
\r
8 node.find('#rng-visualEditor-content').on('keyup', function() {
\r
12 node.find('#rng-visualEditor-meta').on('keyup', function() {
\r
16 this.node.on('mouseover', '.rng', function(e) { $(e.target).addClass('rng-hover')});
\r
17 this.node.on('mouseout', '.rng', function(e) { $(e.target).removeClass('rng-hover')});
\r
18 this.node.on('click', '.rng', function(e) {
\r
19 node.find('.rng').removeClass('rng-current');
\r
20 $(e.target).addClass('rng-current');
\r
23 getMetaData: function() {
\r
25 this.node.find('#rng-visualEditor-meta table tr').each(function() {
\r
27 var key = $(tr.find('td')[0]).html();
\r
28 var value = $(tr.find('td input')[0]).val();
\r
34 setMetaData: function(metadata) {
\r
35 var table = this.node.find('#rng-visualEditor-meta table');
\r
37 _.each(_.keys(metadata), function(key) {
\r
38 $(sandbox.getTemplate('metaItem')({key: key, value: metadata[key]})).appendTo(table);
\r
41 setBody: function(HTMLTree) {
\r
42 this.node.find('#rng-visualEditor-content').html(HTMLTree);
\r
44 getBody: function() {
\r
45 return this.node.find('#rng-visualEditor-content').html();
\r
50 var isDirty = false;
\r
55 sandbox.publish('ready');
\r
57 getView: function() {
\r
60 setDocument: function(xml) {
\r
61 var transformed = transformations.fromXML.getDocumentDescription(xml);
\r
62 view.setBody(transformed.HTMLTree);
\r
63 view.setMetaData(transformed.metadata);
\r
66 getDocument: function() {
\r
67 return transformations.toXML.getXML({HTMLTree: view.getBody(), metadata: view.getMetaData()});
\r
69 isDirty: function() {
\r
72 setDirty: function(dirty) {
\r