memo2.blade.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <!--- memo --->
  2. <div class="modal fade" id="modal-memo2" aria-hidden="true" data-backdrop="static" style="z-index: 1050; overflow: auto;">
  3. <div class="modal-dialog m-auto pt-4">
  4. <div class="modal-content">
  5. <div class="modal-header bg-danger-10">
  6. <h4 class="modal-title text-white" id="myModalLabel">메모필드 입력 -메모필드(여러줄로 입력될 수 있는 필드)</h4>
  7. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fas fa-times"></i></button>
  8. </div>
  9. <div class="modal-body pt-0 pb-2 px-2" style="background-color: #f5f5f5;">
  10. <div class="text-right">
  11. <div class="btn-group my-1">
  12. <button type="button" class="btn btn-primary btn-sm memo2-act save-button" data-value="save">
  13. 저장
  14. </button>
  15. @include('front.dabory.erp.partial.select-btn-options', [
  16. 'selectBtns' => [
  17. [ 'Value' => 'close', 'Caption' => '취소' ],
  18. ],
  19. 'eventClassName' => 'memo2-act',
  20. ])
  21. </div>
  22. </div>
  23. <div class="p-0">
  24. <textarea class="fr-view" id="memo-textarea" style="height: 690px;"></textarea>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. @once
  31. <script>
  32. $(document).ready(async function() {
  33. $('#modal-memo2 .modal-body button').addClass('bg-danger-10 border-danger-10 bg-danger-10-hover')
  34. });
  35. $('.memo2-act').on('click', function () {
  36. // console.log($(this).data('value'))
  37. switch( $(this).data('value') ) {
  38. case 'save': complete_memo2(this); break;
  39. case 'close': $('#modal-memo2').modal('hide'); break;
  40. }
  41. });
  42. $(document).on('dblclick', '#modal-memo2 .fr-view', function () {
  43. complete_memo2(this);
  44. });
  45. $(document).delegate('#modal-memo2 #memo-textarea', 'keydown', function(e) {
  46. const key_code = e.keyCode || e.which
  47. if (key_code === 9) {
  48. e.preventDefault();
  49. const start = this.selectionStart
  50. const end = this.selectionEnd
  51. // set textarea value to: text before caret + tab + text after caret
  52. $(this).val($(this).val().substring(0, start)
  53. + "\t"
  54. + $(this).val().substring(end))
  55. // put caret at right position again
  56. this.selectionStart = this.selectionEnd = start + 1
  57. }
  58. });
  59. function complete_memo2($this) {
  60. const modal_body = $($this).closest('.modal-body')
  61. const editor = $(modal_body).find('#memo-textarea')
  62. $($('#modal-memo2').data('txtarea_id')).val( editor.val() )
  63. $('#modal-memo2').modal('hide')
  64. $('#modal-memo2').trigger('complete.memo2', [$('#modal-memo2').data('txtarea_id'), $('#modal-memo2').data('id')])
  65. }
  66. </script>
  67. @endonce