if(!anchor.is('[wlxml-tag]'))\r
return;\r
view._markSelected(anchor);\r
- });
+ });\r
+ \r
+ \r
+ this.metaTable = this.node.find('#rng-visualEditor-meta table');\r
+ \r
+ this.metaTable.find('.rng-visualEditor-metaAddBtn').click(function() {\r
+ view._addMetaRow();\r
+ isDirty = true;\r
+ });\r
+ \r
+ this.metaTable.on('click', '.rng-visualEditor-metaRemoveBtn', function(e) {\r
+ $(e.target).closest('tr').remove();\r
+ isDirty = true;\r
+ });\r
+
},\r
getMetaData: function() {\r
var toret = {};\r
- this.node.find('#rng-visualEditor-meta table tr').each(function() {\r
+ this.metaTable.find('tr').not('.rng-visualEditor-addMetaRow').each(function() {\r
var tr = $(this);\r
- var key = $(tr.find('td')[0]).html();\r
- var value = $(tr.find('td input')[0]).val();\r
+ var inputs = $(this).find('td input');\r
+ var key = $(inputs[0]).val()\r
+ var value = $(inputs[1]).val()\r
toret[key] = value;\r
});\r
console.log(toret);\r
return toret;\r
},\r
setMetaData: function(metadata) {\r
- var table = this.node.find('#rng-visualEditor-meta table');\r
- table.empty();\r
+ var view = this;\r
+ this.metaTable.find('tr').not('.rng-visualEditor-addMetaRow').remove();\r
_.each(_.keys(metadata), function(key) { \r
- $(sandbox.getTemplate('metaItem')({key: key, value: metadata[key]})).appendTo(table);\r
+ view._addMetaRow(key, metadata[key]);\r
});\r
},\r
setBody: function(HTMLTree) {\r
_markSelected: function(node) {\r
this.node.find('.rng-current').removeClass('rng-current');\r
node.addClass('rng-current');\r
+ },\r
+ _addMetaRow: function(key, value) {\r
+ var addRow = this.metaTable.find('.rng-visualEditor-addMetaRow');\r
+ $(sandbox.getTemplate('metaItem')({key: key || '', value: value || ''})).insertBefore(addRow);\r
}\r
};\r
view.setup();\r