pull/144/head
Henrique Dias 2016-07-06 11:25:00 +01:00
parent a0d63bcd14
commit 607f2268d0
2 changed files with 37 additions and 10 deletions

File diff suppressed because one or more lines are too long

View File

@ -618,6 +618,30 @@ var addFrontMatterItem = function(event) {
input = input.replace(/\[/, '\\['); input = input.replace(/\[/, '\\[');
input = input.replace(/\]/, '\\]'); input = input.replace(/\]/, '\\]');
let fieldsets = block.getElementsByTagName("fieldset");
if (fieldsets.length > 0) {
let newtype = fieldsets[0].dataset.type;
let bid = id + "[" + fieldsets.length + "]";
let name = fieldsets.length;
let template = `<fieldset id="${bid}" data-type="${newtype}">
<h3>${name}</h3>
<div class="action add">
<i class="material-icons">add</i>
</div>
<div class="action delete" data-delete="${bid}">
<i class="material-icons">close</i>
</div>
<div class="group">
</div>
</fieldset>`;
block.insertAdjacentHTML('beforeend', template);
document.querySelector(`div[data-delete="${bid}"]`).addEventListener('click', deleteFrontMatterItem);
document.getElementById(bid).querySelector('.action.add').addEventListener('click', addFrontMatterItem);
} else {
block.querySelector('.group').insertAdjacentHTML('beforeend', `<div id="${fieldID}-${count}" data-type="array-item"> block.querySelector('.group').insertAdjacentHTML('beforeend', `<div id="${fieldID}-${count}" data-type="array-item">
<input name="${fieldID}" id="${fieldID}" type="text" data-parent-type="array"></input> <input name="${fieldID}" id="${fieldID}" type="text" data-parent-type="array"></input>
<div class="action delete" data-delete="${fieldID}-${count}"> <div class="action delete" data-delete="${fieldID}-${count}">
@ -629,6 +653,9 @@ var addFrontMatterItem = function(event) {
document.querySelector(`div[data-delete="${fieldID}-${count}"]`).addEventListener('click', deleteFrontMatterItem); document.querySelector(`div[data-delete="${fieldID}-${count}"]`).addEventListener('click', deleteFrontMatterItem);
} }
}
if (type == "object" || type == "parent") { if (type == "object" || type == "parent") {
let template = `<div class="group temp" id="${tempID}"> let template = `<div class="group temp" id="${tempID}">
<div class="block" id="${tempID}"> <div class="block" id="${tempID}">