json-editor.blade.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <!--- json-editor --->
  2. <div class="modal fade" id="modal-json-editor" 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-slate-300">
  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 p-2" style="background-color: #f5f5f5;">
  10. <div class="mt-4 card">
  11. <div id="editor" class="json-editor"></div>
  12. <pre class="table-footer" id="json"></pre>
  13. </div>
  14. <div class="position-absolute" style="top: 3px; right: 10px;">
  15. <button type="button" class="font-weight-bold btn btn-danger btn-sm icon-copy3 complete-memo-btn"
  16. onclick="complete_json()">
  17. </button>
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. @once
  24. <link href="/css/jsoneditor.css?{{ date('YmdHis') }}" rel="stylesheet" type="text/css">
  25. <script src="/js/components/jquery.jsoneditor.js?{{date('YmdHis')}}"></script>
  26. <script>
  27. $(document).on('shown.bs.modal','#modal-json-editor', function (e) {
  28. let json = {}
  29. if (! isEmpty($('#modal-json-editor').find('#json').html())) {
  30. json = JSON.parse($('#modal-json-editor').find('#json').html());
  31. }
  32. $('#modal-json-editor').find('#editor').jsonEditor(json, { change: function(data) {
  33. $('#modal-json-editor').find('#json').html(JSON.stringify(data));
  34. } });
  35. })
  36. // $(document).on('dblclick', '#modal-json-editor #editor', function() {
  37. // complete_json()
  38. // });
  39. function complete_json() {
  40. $('#modal-json-editor').modal('hide');
  41. let dom = $('#modal-json-editor').data('parameter')
  42. $(dom).val($('#modal-json-editor').find('#json').html())
  43. }
  44. </script>
  45. @endonce