mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
improve field add on frontmatter
This commit is contained in:
parent
26c89f1fce
commit
c81c1d3bf1
2
assets/js/app.min.js
vendored
2
assets/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
@ -119,21 +119,16 @@ $(document).on('page:editor', function() {
|
||||
event.preventDefault();
|
||||
defaultID = "lorem-ipsum-sin-dolor-amet";
|
||||
|
||||
if ($("#" + defaultID).length) {
|
||||
return false;
|
||||
// Remove if there is an incomplete new item
|
||||
newItem = $("#" + defaultID);
|
||||
if (newItem.length) {
|
||||
newItem.remove();
|
||||
}
|
||||
|
||||
block = $(this).parent().parent();
|
||||
blockType = block.data("type");
|
||||
blockID = block.attr("id");
|
||||
|
||||
// Main add button, after all blocks
|
||||
if (block.is('div') && block.hasClass("frontmatter")) {
|
||||
block = $('.blocks');
|
||||
block.append('<div class="block" id="' + defaultID + '"></div>');
|
||||
blockType = "object";
|
||||
}
|
||||
|
||||
// If the Block Type is an array
|
||||
if (blockType == "array") {
|
||||
newID = blockID + "[]";
|
||||
@ -141,15 +136,19 @@ $(document).on('page:editor', function() {
|
||||
input = input.replace(/\[/, '\\[');
|
||||
input = input.replace(/\]/, '\\]');
|
||||
block.append('<div id="' + newID + '-' + $('#' + input + ' > div').length + '" data-type="array-item"><input name="' + newID + ':auto" id="' + newID + '"></input><span class="actions"> <button class="delete">−</button></span></div></div>');
|
||||
console.log('New array item added.');
|
||||
}
|
||||
|
||||
if (blockType == "object" && !block.hasClass("frontmatter")) {
|
||||
block.append('<div class="block" id="' + defaultID + '"></div>');
|
||||
// Main add button, after all blocks
|
||||
if (block.is('div') && block.hasClass("frontmatter")) {
|
||||
block = $('.blocks');
|
||||
blockType = "object";
|
||||
}
|
||||
|
||||
// If the Block is an object
|
||||
if (blockType == "object") {
|
||||
block.append('<div class="block" id="' + defaultID + '"></div>');
|
||||
|
||||
newItem = $("#" + defaultID);
|
||||
newItem.html('<input id="name-' + defaultID + '" placeholder="Write the field name and press enter..."></input>');
|
||||
field = $("#name-" + defaultID);
|
||||
@ -167,7 +166,6 @@ $(document).on('page:editor', function() {
|
||||
}
|
||||
|
||||
$(field).keypress(function(event) {
|
||||
console.log('got it');
|
||||
// When you press enter within the new name field:
|
||||
if (event.which == 13) {
|
||||
event.preventDefault();
|
||||
|
Loading…
Reference in New Issue
Block a user