Browse Source

Bring back "shortcuts" feature

Vijayakrishnan 4 years ago
parent
commit
75d234923a
1 changed files with 24 additions and 1 deletions
  1. 24 1
      resources/views/app/patient/note/note-section-list.blade.php

+ 24 - 1
resources/views/app/patient/note/note-section-list.blade.php

@@ -112,6 +112,16 @@ if ($latestSectionTS === 0 || $latestSectionTS < $sectionTS) {
 
 
         function init() {
         function init() {
             $('[note-rte]').each(function() {
             $('[note-rte]').each(function() {
+
+                $(this).wrap(
+                    $('<div class="border-left border-right rte-holder"/>')
+                        .attr('data-shortcuts', '')
+                );
+
+                // give a unique id to this editor instance
+                var editorID = Math.ceil(Math.random() * 99999),
+                    fieldName = this.name;
+
                 var el = this;
                 var el = this;
                 var existingContent = $(el).attr('data-content');
                 var existingContent = $(el).attr('data-content');
                 var quill = new Quill(el, {
                 var quill = new Quill(el, {
@@ -130,6 +140,13 @@ if ($latestSectionTS === 0 || $latestSectionTS < $sectionTS) {
                     }
                     }
                 });
                 });
 
 
+                var toolbar = $(quill.container).prev('.ql-toolbar');
+
+                // add button for new shortcut
+                var newSCButton = $('<button class="btn bg-white btn-sm btn-default text-primary w-auto px-2 border py-0 ' +
+                    'text-sm add-shortcut" data-editor-id="' + editorID + '">+ Shortcut</button>');
+                toolbar.append(newSCButton);
+
                 quill.root.innerHTML = existingContent;
                 quill.root.innerHTML = existingContent;
 
 
                 quill.on('text-change', function(delta, oldDelta, source) {
                 quill.on('text-change', function(delta, oldDelta, source) {
@@ -139,6 +156,12 @@ if ($latestSectionTS === 0 || $latestSectionTS < $sectionTS) {
                     });
                     });
                     var dataField = $(el).closest('.note-section').find('input[name=data]').val(dataValue);
                     var dataField = $(el).closest('.note-section').find('input[name=data]').val(dataValue);
                 });
                 });
+
+                $(quill.container)
+                    .find('.ql-editor[contenteditable]')
+                    .attr('data-field', fieldName)
+                    .attr('data-editor-id', editorID)
+                    .attr('with-shortcuts', 1);
             })
             })
 
 
             $('[btn-save-form]').on('click', function() {
             $('[btn-save-form]').on('click', function() {
@@ -217,4 +240,4 @@ if ($latestSectionTS === 0 || $latestSectionTS < $sectionTS) {
         addMCInitializer('note-sections-list-{{ $patient->uid }}', init);
         addMCInitializer('note-sections-list-{{ $patient->uid }}', init);
 
 
     })();
     })();
-</script>
+</script>