blob: 0a30808b92dc15ba3bc91f34cb613ec82f557649 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
if (typeof(document.getElementById('new-note-form')) != 'undefined' && document.getElementById('new-note-form') != null) {
document.addEventListener('readystatechange', event => {
if (event.target.readyState === "complete") {
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');
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());
};
var create_notebook_btn = document.getElementById('add_id_notebook');
addHandler(create_notebook_btn);
function addHandler(el){
el.addEventListener('click', function(e){
e.preventDefault();
var modal = modalBox(el, document.getElementById('js-overlay-notebook'));
});
}
var notebookAddForm = document.getElementById('nb-create-form');
ajaxHijack(notebookAddForm, notebookCreate)
}
});
}
|