aboutsummaryrefslogtreecommitdiff
path: root/scripts/src/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/src/util.js')
-rw-r--r--scripts/src/util.js25
1 files changed, 24 insertions, 1 deletions
diff --git a/scripts/src/util.js b/scripts/src/util.js
index 694a393..daad7e1 100644
--- a/scripts/src/util.js
+++ b/scripts/src/util.js
@@ -23,6 +23,15 @@ function getJSON(method, url, callback) {
request.send();
}
+// hijack a form and submit with ajax
+function ajaxHijack(form, func) {
+ form.onsubmit = function(e) {
+ e.preventDefault();
+ func(e.target);
+ return false;
+ }
+}
+
//global init for Color Picker
function initColorPicker(form){
var notebook_form_inputs = form.getElementsByTagName('input');
@@ -130,7 +139,7 @@ function modalBox(el, content){
//handle removing modals
overlay.destroy = function(){
if(overlay.parentNode === document.body) {
- wrapper = document.querySelector('#content-wrapper').firstChild;
+ var wrapper = document.querySelector('#content-wrapper').firstChild;
window.elemsRemoved = wrapper;
wrapper.remove();
overlay.parentNode.removeChild(overlay);
@@ -150,3 +159,17 @@ function modalBox(el, content){
});
return overlay;
};
+
+/**
+ * Check whether editor content is empty or not.
+ * @return {Bool}
+ */
+function isQuillEmpty(quill) {
+ return quill.getContents().ops[0].insert == '\n' && quill.getLength() < 2;
+}
+function isEmpty(quill) {
+ const commentText = quill.getText().trim();
+ console.log(commentText);
+ const re = /^<p>(<br>|<br\/>|<br\s\/>|\s+|\r)<\/p>$/gm;
+ return re.test(commentText);
+};