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';
};
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) {
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();
}
-
};
};
+++ /dev/null
-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