-
Notifications
You must be signed in to change notification settings - Fork 33
/
index.js
47 lines (38 loc) · 1.27 KB
/
index.js
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
43
44
45
46
47
/* eslint-env browser */
(function($, Quill) {
$(document).ready(() => {
const quillOptions = {
modules: {
formula: true,
toolbar: [["video", "bold", "italic", "underline", "formula"]]
},
placeholder:
"Type text here, or click on the formula button to enter math.",
theme: "snow"
};
const options = {};
$("input[type='checkbox'].option").each((_, option) => {
const $option = $(option);
const name = $option.attr("data-name");
const isOptionEnabled =
window.location.href.indexOf(`&${name}=true`) !== -1;
if (isOptionEnabled) {
$option.prop("checked", true);
options[name] = JSON.parse($option.attr("data-value"));
}
$option.change(event => {
let url = window.location.href;
const checked = event.target.checked;
if (url.indexOf("?") === -1) {
url += "?";
}
url = url.replace(`&${name}=${!checked}`, "");
url += `&${name}=${checked}`;
window.location.href = url;
});
});
const enableMathQuillFormulaAuthoring = window.mathquill4quill();
const quill = new Quill("#editor", quillOptions);
enableMathQuillFormulaAuthoring(quill, options);
});
})(window.jQuery, window.Quill);