Former-commit-id: fbbf79d7572d73f824774f29bbd17af28155c3bc
This commit is contained in:
Henrique Dias
2017-01-15 11:47:52 +00:00
parent 8e0b3b17df
commit ee279c4233
5 changed files with 94 additions and 55 deletions

View File

@@ -22,6 +22,17 @@ editor.textareaAutoGrow = function () {
window.addEventListener('resize', addAutoGrow)
}
editor.toggleSourceEditor = function (event) {
event.preventDefault();
if(document.querySelector('[data-kind="content-only"]')) {
window.location = window.location.pathname + "?visual=true"
return;
}
window.location = window.location.pathname + "?visual=false"
}
function deleteFrontMatterItem(event) {
event.preventDefault();
document.getElementById(this.dataset.delete).remove();
@@ -163,11 +174,18 @@ document.addEventListener("DOMContentLoaded", (event) => {
if(!document.getElementById('editor')) return;
editor.textareaAutoGrow();
templates.arrayItem = document.getElementById("array-item-template");
templates.base = document.getElementById('base-template');
templates.objectItem = document.getElementById("object-item-template");
templates.temporary = document.getElementById('temporary-template');
buttons.save = document.querySelector('#save');
buttons.editSource = document.querySelector('#edit-source');
if(buttons.editSource) {
buttons.editSource.addEventListener('click', editor.toggleSourceEditor)
}
let container = document.getElementById('editor'),
kind = container.dataset.kind;
@@ -255,4 +273,4 @@ document.addEventListener("DOMContentLoaded", (event) => {
});
return false;
});
});