aboutsummaryrefslogtreecommitdiff
path: root/scripts/src/util.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/util.js
parent219ac9b26feec3e2c5cd68cf530485d0dbaa943c (diff)
refactored JS
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);
+};