json-editor.js.erb 679 B

12345678910111213141516171819202122
  1. window.setupJsonEditor = function ($editors) {
  2. if ($editors == null) {
  3. $editors = $(".live-json-editor");
  4. }
  5. JSONEditor.prototype.ADD_IMG = "<%= image_path 'json-editor/add.png' %>";
  6. JSONEditor.prototype.DELETE_IMG = "<%= image_path 'json-editor/delete.png' %>";
  7. const editors = [];
  8. $editors.each(function () {
  9. const $editor = $(this);
  10. const jsonEditor = new JSONEditor(
  11. $editor,
  12. $editor.data("width") || 400,
  13. $editor.data("height") || 500
  14. );
  15. jsonEditor.doTruncation(true);
  16. jsonEditor.showFunctionButtons();
  17. return editors.push(jsonEditor);
  18. });
  19. return editors;
  20. };
  21. $(() => (window.jsonEditor = setupJsonEditor()[0]));