aboutsummaryrefslogtreecommitdiff
path: root/scripts/src/note-create.js
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2018-12-31 20:06:26 -0600
committerluxagraf <sng@luxagraf.net>2018-12-31 20:06:26 -0600
commit23b4b185e3f3f8b9f17eebc49110cb4696acdb39 (patch)
tree3ac73213b091054e93819f6293c3297439dd0c34 /scripts/src/note-create.js
parent219ac9b26feec3e2c5cd68cf530485d0dbaa943c (diff)
refactored JS
Diffstat (limited to 'scripts/src/note-create.js')
-rw-r--r--scripts/src/note-create.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/scripts/src/note-create.js b/scripts/src/note-create.js
index b8ecb46..0a30808 100644
--- a/scripts/src/note-create.js
+++ b/scripts/src/note-create.js
@@ -4,13 +4,26 @@ if (typeof(document.getElementById('new-note-form')) != 'undefined' && document.
var form = document.getElementById('new-note-form');
form.quill = initQuill("#note-body");
form.note_text = document.getElementById('id_body_text');
+ form.note_text.required = false;
+ form.note_qjson = document.getElementById('id_body_qjson');
form.fs_body_text = document.getElementById("fs-body_text");
form.fs_body_text.classList.add('hide')
form.note_html = document.getElementById('id_body_html');
form.note_html.innerHTML = form.quill.root.innerHTML;
+ form.quill.on('text-change', function(delta, oldDelta, source) {
+ if (source == 'api') {
+ console.log("An API call triggered this change.");
+ } else if (source == 'user') {
+ console.log("A user action triggered this change.");
+ form.note_text.innerHTML = form.quill.getText();
+ }
+ });
form.onsubmit = function(e) {
var form_texts = e.target.getElementsByTagName('textarea');
- form_texts['body_text'].innerHTML = e.target.quill.getText();
+ if (isQuillEmpty(e.target.quill)) {
+ e.preventDefault();
+ document.getElementById('q-container').classList.add('form-alert');
+ }
form_texts['body_html'].innerHTML = e.target.quill.root.innerHTML;
form_texts['body_qjson'].innerHTML = JSON.stringify(e.target.quill.getContents());
};
@@ -22,6 +35,8 @@ if (typeof(document.getElementById('new-note-form')) != 'undefined' && document.
var modal = modalBox(el, document.getElementById('js-overlay-notebook'));
});
}
+ var notebookAddForm = document.getElementById('nb-create-form');
+ ajaxHijack(notebookAddForm, notebookCreate)
}
});
}