|
@@ -94,9 +94,10 @@ $(document).ready(function () {
|
|
|
if (body.is('.stag_rhs_collapsed')) {
|
|
|
icon.removeClass().addClass('fa fa-arrow-left');
|
|
|
}
|
|
|
- initPrimaryForm();
|
|
|
initCreateNote();
|
|
|
+ initQuillEdit();
|
|
|
initFastLoad();
|
|
|
+ initPrimaryForm();
|
|
|
if(typeof initializeCalendar !== 'undefined') {
|
|
|
initializeCalendar();
|
|
|
}
|
|
@@ -204,9 +205,10 @@ function onFastLoaded(_data, _href, _history) {
|
|
|
content += '<script src="/js/yemi.js?_=4"></script>';
|
|
|
targetParent.html(content);
|
|
|
window.setTimeout(function() {
|
|
|
- initPrimaryForm();
|
|
|
initCreateNote();
|
|
|
+ initQuillEdit();
|
|
|
initFastLoad(targetParent);
|
|
|
+ initPrimaryForm();
|
|
|
}, 50);
|
|
|
if(typeof initializeCalendar !== 'undefined') {
|
|
|
initializeCalendar();
|
|
@@ -244,8 +246,15 @@ function fastLoad(_href, _history = true, _useCache = true) {
|
|
|
}
|
|
|
|
|
|
function initPrimaryForm() {
|
|
|
- if($('.primary-form:visible').length) {
|
|
|
- $('.primary-form:visible').first().find('input, textarea, select').first().focus().select();
|
|
|
+ var primaryForm = $('.primary-form:visible');
|
|
|
+ if (primaryForm.length) {
|
|
|
+ var rte = primaryForm.first().find('[contenteditable="true"]').first();
|
|
|
+ if(rte.length) {
|
|
|
+ rte.focus().select();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ primaryForm.first().find('input, textarea, select').first().focus().select();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -278,3 +287,43 @@ function initCreateNote() {
|
|
|
}, 'json');
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+function initQuillEdit(_selector = '.note-content[auto-edit]') {
|
|
|
+
|
|
|
+ $(document)
|
|
|
+ .off('click.enable-edit', '.note-content:not([auto-edit])')
|
|
|
+ .on('click.enable-edit', '.note-content:not([auto-edit])', function() {
|
|
|
+ $(this).attr('auto-edit', 1);
|
|
|
+ initQuillEdit();
|
|
|
+ initPrimaryForm();
|
|
|
+ });
|
|
|
+
|
|
|
+ if(!$(_selector).length) return;
|
|
|
+ var noteUid = $(_selector).attr('data-note-uid');
|
|
|
+ var qe = new Quill(_selector, {
|
|
|
+ theme: 'snow'
|
|
|
+ });
|
|
|
+ var toolbar = $(qe.container).prev('.ql-toolbar');
|
|
|
+ var saveButton = $('<button class="btn btn-sm btn-primary w-auto px-3 py-0 text-sm text-white save-note-content" disabled>Save</button>');
|
|
|
+ toolbar.append(saveButton);
|
|
|
+ saveButton.on('click', function() {
|
|
|
+ $.post('/api/note/putFreeTextHtml', {
|
|
|
+ uid: noteUid,
|
|
|
+ freeTextHtml: qe.root.innerHTML,
|
|
|
+ }, function(_data) {
|
|
|
+ if (!_data.success) {
|
|
|
+ toastr.error(_data.message);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // toastr.success('Note saved');
|
|
|
+ // saveButton.prop('disabled', true);
|
|
|
+ fastLoad(window.location.pathname, false, false);
|
|
|
+ }
|
|
|
+ }, 'json');
|
|
|
+ });
|
|
|
+ qe.on('text-change', function() {
|
|
|
+ saveButton.prop('disabled', false);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+
|