X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/f129f1dd6ba62fa571960330c62191e08e53deb2..6de8b7d1e30971aa6582804ae3b4e9364e31a158:/modules/visualEditor.js?ds=sidebyside diff --git a/modules/visualEditor.js b/modules/visualEditor.js index dc0b801..9721d29 100644 --- a/modules/visualEditor.js +++ b/modules/visualEditor.js @@ -33,7 +33,7 @@ rng.modules.visualEditor = function(sandbox) { var metaTable = this.metaTable = this.node.find('#rng-visualEditor-meta table'); - this.metaTable.find('.rng-visualEditor-metaAddBtn').click(function() { + this.node.find('.rng-visualEditor-metaAddBtn').click(function() { var newRow = view._addMetaRow('', ''); $(newRow.find('td div')[0]).focus(); isDirty = true; @@ -47,12 +47,12 @@ rng.modules.visualEditor = function(sandbox) { this.metaTable.on('keydown', '[contenteditable]', function(e) { console.log(e.which); if(e.which === 13) { - if($('*:focus').hasClass('rng-visualEditor-metaItemKey')) { + if($(document.activeElement).hasClass('rng-visualEditor-metaItemKey')) { metaTable.find('.rng-visualEditor-metaItemValue').focus(); } else { var input = $(''); input.appendTo('body').focus() - metaTable.find('.rng-visualEditor-metaAddBtn').focus(); + view.node.find('.rng-visualEditor-metaAddBtn').focus(); input.remove(); } e.preventDefault(); @@ -63,7 +63,7 @@ rng.modules.visualEditor = function(sandbox) { }, getMetaData: function() { var toret = {}; - this.metaTable.find('tr').not('.rng-visualEditor-addMetaRow').each(function() { + this.metaTable.find('tr').each(function() { var tr = $(this); var inputs = $(this).find('td [contenteditable]'); var key = $(inputs[0]).text(); @@ -75,7 +75,7 @@ rng.modules.visualEditor = function(sandbox) { }, setMetaData: function(metadata) { var view = this; - this.metaTable.find('tr').not('.rng-visualEditor-addMetaRow').remove(); + this.metaTable.find('tr').remove(); _.each(_.keys(metadata), function(key) { view._addMetaRow(key, metadata[key]); }); @@ -91,9 +91,8 @@ rng.modules.visualEditor = function(sandbox) { node.addClass('rng-current'); }, _addMetaRow: function(key, value) { - var addRow = this.metaTable.find('.rng-visualEditor-addMetaRow'); var newRow = $(sandbox.getTemplate('metaItem')({key: key || '', value: value || ''})); - newRow.insertBefore(addRow); + newRow.appendTo(this.metaTable); return newRow; } };