editor: removing old unused code
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 16 Jan 2014 15:05:06 +0000 (16:05 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 17 Jan 2014 14:25:05 +0000 (15:25 +0100)
src/editor/modules/metadataEditor/metadataEditor.js
src/editor/modules/metadataEditor/transformations.js [deleted file]

index 5530de9..38b4e56 100644 (file)
@@ -1,10 +1,9 @@
 define([
 'libs/jquery',
 'libs/underscore',
-'./transformations',
 'libs/text!./templates/main.html',
 'libs/text!./templates/item.html'
-], function($, _, transformations, mainTemplate, itemTemplate) {
+], function($, _, mainTemplate, itemTemplate) {
 
 'use strict';
 
@@ -55,22 +54,12 @@ return function(sandbox) {
             };
             this.metaTable.on('keyup', '[contenteditable]', _.throttle(onKeyUp, 500));
         },
-        getMetadata: function() {
-            var toret = [];
-            this.node.find('tr').each(function() {
-                var inputs = $(this).find('td [contenteditable]');
-                var key = $(inputs[0]).text();
-                var value = $(inputs[1]).text();
-                toret.push({key:key, value: value});
-            });
-            return toret;
-        },
         setMetadata: function(node) {
             var view = this,
                 metadata = node.getMetadata();
             this.metaTable.find('tr').remove();
             metadata.forEach(function(row) {
-                view._addMetaRow(row.key, row.value);
+                view._addMetaRow(row.getKey(), row.getValue());
             });
         },
         _addMetaRow: function(key, value) {
@@ -92,40 +81,17 @@ return function(sandbox) {
                     view.setMetadata(currentNode);
                 }
             });
-//            view.setMetadata(transformations.getMetadata(xml));
-            // sandbox.publish('metadataSet'); to wywalki
         },
         setNodeElement: function(node) {
             if(currentNode && currentNode.sameNode(node)) {
-                return;
+                return
             }
             currentNode = node;
             view.setMetadata(node);
         },
-        getMetadata: function() {
-            return transformations.getXML(view.getMetadata());
-        },
         getView: function() {
             return view.node;
-        },
-        attachMetadata: function(document) {
-            var toret = $('<div>');
-            toret.append($(document));
-            var meta = $('<metadata></metadata>\n').append(transformations.getXML(view.getMetadata()));
-            
-            var metadata = toret.find('metadata');
-            if(metadata.length === 0) {
-                var section = toret.find('section');
-                section = section.length ? $(section[0]) : null;
-                if(section) {
-                    section.prepend(meta);
-                }
-            } else {
-                metadata.replaceWith(meta);
-            }
-            return toret.html();
         }
-        
     };
 };
 
diff --git a/src/editor/modules/metadataEditor/transformations.js b/src/editor/modules/metadataEditor/transformations.js
deleted file mode 100644 (file)
index 4bb3fdc..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-define(['libs/jquery', 'libs/underscore'], function($, _) {
-
-    'use strict';
-
-    return {
-        getMetadata: function(xml) {
-            var toret = {};
-            $(xml).find('metadata').children().each(function() {
-                var node = $(this);
-                toret[this.nodeName.split(':')[1].toLowerCase()] = node.text();
-            });
-            return toret;
-        },
-        getXML: function(metadata) {
-            var meta = $('<metadata></metadata>\n');
-            _.each(_.keys(metadata), function(key) {
-                meta.append('\n\t<dc:'+key+'>' + metadata[key] + '</dc:'+key+'>');
-            });
-            meta.append('\n');
-            /* globals vkbeautify */
-            return vkbeautify.xml(meta.html());
-        }
-    };
-
-});
\ No newline at end of file