File: selectize.html

package info (click to toggle)
json-editor.js 1.3.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 1,692 kB
  • sloc: perl: 39; makefile: 5
file content (95 lines) | stat: -rw-r--r-- 3,079 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>JSON Editor Selectize Integration Example</title>
    <script src="../../../javascript/json-editor/jsoneditor.min.js"></script>
    <script src="../../../javascript/jquery/jquery.min.js"></script>
    <script src="../../../javascript/selectize.js/selectize.js"></script>
    <link rel="stylesheet" href="../../../javascript/selectize.js/css/selectize.bootstrap3.css">
  </head>
  <body>
    <h1>JSON Editor Selectize Integration Example</h1>

    <p style='margin-bottom:20px;'>This example demonstrates JSONEditor's integration with Selectize</p>

    <div id='editor_holder'></div>
    <button id='submit'>Submit (console.log)</button>

    <script>
    // Global selectize options
    JSONEditor.plugins.selectize.enable = true;

      // Initialize the editor with a JSON schema
      var editor = new JSONEditor(document.getElementById('editor_holder'),{
        schema: {
          type: "object",
          title: "Text",
          required: ["fontSize","color","font","weight","possibleFonts"],
          properties: {
            fontSize: {
              type: "integer",
              enum: [10,11,12,14,16,18,20,22,24,36,48,60,72,100],
              default: 24,
              options: {
                // Override defaullt options
                selectize_options: {
                  create: true
                }
              }
            },
            color: {
              type: "string",
              enum: ["black","red","green","blue","yellow","orange","purple","brown","white","cyan","magenta"],
              options: {
                // Override defaullt options
                selectize_options: {
                  create: false,
                  sortField: 'text'
                }
              }
            },
            font: {
              type: "string",
              enumSource: "possible_fonts",
              watch: {
                "possible_fonts": "root.possibleFonts"
              },
              options: {
                // Override defaullt options
                selectize_options: {
                  create: false,
                  sortField: 'text'
                }
              }
            },
            weight: {
              type: "string",
              enum: ["normal","bold","bolder","lighter"],
              options: {
                enum_titles: ["Normal (400)","Bold (700)","Bolder (900)","Lighter (200)"]
              }
            },
            possibleFonts: {
              type: "array",
              uniqueItems: true,
              items: {
                type: "string"
              },
              default: ["Arial","Times","Helvetica","Comic Sans"]
            }
          }
        },
        startval: {
          color: "red"
        }
      });

      // Hook up the submit button to log to the console
      document.getElementById('submit').addEventListener('click',function() {
        // Get the value from the editor
        console.log(editor.getValue());
      });
    </script>
  </body>
</html>