From: Aleksander Ɓukasz Date: Thu, 16 Jan 2014 15:05:06 +0000 (+0100) Subject: editor: removing old unused code X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/10d593c6eecc49a8fe222ed2048c3f10e390b687 editor: removing old unused code --- diff --git a/src/editor/modules/metadataEditor/metadataEditor.js b/src/editor/modules/metadataEditor/metadataEditor.js index 5530de9..38b4e56 100644 --- a/src/editor/modules/metadataEditor/metadataEditor.js +++ b/src/editor/modules/metadataEditor/metadataEditor.js @@ -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 = $('
'); - toret.append($(document)); - var meta = $('\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 index 4bb3fdc..0000000 --- a/src/editor/modules/metadataEditor/transformations.js +++ /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 = $('\n'); - _.each(_.keys(metadata), function(key) { - meta.append('\n\t' + metadata[key] + ''); - }); - meta.append('\n'); - /* globals vkbeautify */ - return vkbeautify.xml(meta.html()); - } - }; - -}); \ No newline at end of file