diff --git a/examples/13_autocomplete_simplest.html b/examples/11_autocomplete_basic.html similarity index 92% rename from examples/13_autocomplete_simplest.html rename to examples/11_autocomplete_basic.html index ef82482..923e54c 100644 --- a/examples/13_autocomplete_simplest.html +++ b/examples/11_autocomplete_basic.html @@ -36,8 +36,8 @@ var options = { modes: ['text', 'tree'], autocomplete: { - ApplyTo:['name','value'], // This indicates the autocomplete is going to be applied to json properties names and values. - GetOptions: function () { + applyTo:['name','value'], // This indicates the autocomplete is going to be applied to json properties names and values. + getOptions: function () { return ["apple","cranberry","raspberry","pie"]; } } diff --git a/examples/12_autocomplete_simple.html b/examples/12_autocomplete_dynamic.html similarity index 96% rename from examples/12_autocomplete_simple.html rename to examples/12_autocomplete_dynamic.html index 20f55a6..7656f98 100644 --- a/examples/12_autocomplete_simple.html +++ b/examples/12_autocomplete_dynamic.html @@ -36,8 +36,8 @@ var options = { modes: ['text', 'tree'], autocomplete: { - ApplyTo:['value'], - GetOptions: function (autocomplete, node, text) { + applyTo:['value'], + getOptions: function (autocomplete, node, text) { // Return all strings in json function stringify(o, prefix) { diff --git a/examples/11_autocomplete.html b/examples/13_autocomplete_advanced.html similarity index 91% rename from examples/11_autocomplete.html rename to examples/13_autocomplete_advanced.html index e8f543b..a092ada 100644 --- a/examples/11_autocomplete.html +++ b/examples/13_autocomplete_advanced.html @@ -25,6 +25,7 @@
This example demonstrates how to autocomplete works with an ActivationChar option, press "*" in any value and continue with autocompletion. + The autocomplete returns the posible jsonpaths of the existing json document.
@@ -35,12 +36,12 @@ var options = { modes: ['text', 'tree'], autocomplete: { - Config: { + config: { ConfirmKeys: [39, 35, 9, 190] // Confirm Autocomplete Keys: [right, end, tab, '.'] // By default are only [right, end, tab] }, - ActivationChar: '*', // ActivationChar indicate if the value starts with this Char then autocompletion will be activated. ('' will be ignored). - ApplyTo:['value'], - GetOptions: function (autocomplete, node, text) { + activationChar: '*', // ActivationChar indicate if the value starts with this Char then autocompletion will be activated. ('' will be ignored). + applyTo:['value'], + getOptions: function (autocomplete, node, text) { var YaskON = { // Return first level json paths by the node 'o' @@ -74,7 +75,7 @@ autocomplete.startFrom = 0; var lastPoint = text.lastIndexOf('.'); if ((lastPoint > 0) && (text.length > 1)) { - var fnode = node.editor.node.findNode('.' + text.substring(this.ActivationChar.length, lastPoint)); + var fnode = node.editor.node.findNode('.' + text.substring(this.activationChar.length, lastPoint)); if (fnode && typeof fnode.getValue() == 'object') { data = fnode.getValue(); // Indicate that autocompletion should start after the . (ignoring the first part) @@ -84,7 +85,7 @@ else data = node.editor.get(); - var optionsStr = YaskON.stringify(data, null, this.ActivationChar); + var optionsStr = YaskON.stringify(data, null, this.activationChar); var options = optionsStr.split("\n"); return options; diff --git a/src/js/treemode.js b/src/js/treemode.js index c32db01..fdba70f 100644 --- a/src/js/treemode.js +++ b/src/js/treemode.js @@ -53,7 +53,7 @@ treemode.create = function (container, options) { this._setOptions(options); if (options.autocomplete) - this.autocomplete = new autocomplete(options.autocomplete.Config); + this.autocomplete = new autocomplete(options.autocomplete.config); if (this.options.history && this.options.mode !== 'view') { this.history = new History(this); @@ -1107,13 +1107,13 @@ treemode._onKeyDown = function (event) { if ((this.options.autocomplete) && (!handled)) { if (!ctrlKey && !altKey && !metaKey && (event.key.length == 1 || keynum == 8 || keynum == 46)) { handled = false; - if ((this.options.autocomplete.ApplyTo.indexOf('value') >= 0 && event.target.className.indexOf("jsoneditor-value") >= 0) || - (this.options.autocomplete.ApplyTo.indexOf('name') >= 0 && event.target.className.indexOf("jsoneditor-field") >= 0)) { + if ((this.options.autocomplete.applyTo.indexOf('value') >= 0 && event.target.className.indexOf("jsoneditor-value") >= 0) || + (this.options.autocomplete.applyTo.indexOf('name') >= 0 && event.target.className.indexOf("jsoneditor-field") >= 0)) { var node = Node.getNodeFromTarget(event.target); - if (this.options.autocomplete.ActivationChar == null || event.target.innerText.startsWith(this.options.autocomplete.ActivationChar)) { // Activate autocomplete + if (this.options.autocomplete.activationChar == null || event.target.innerText.startsWith(this.options.autocomplete.activationChar)) { // Activate autocomplete setTimeout(function (hnode, element) { if (element.innerText.length > 0) { - var options = this.options.autocomplete.GetOptions(this.autocomplete, hnode, element.innerText); + var options = this.options.autocomplete.getOptions(this.autocomplete, hnode, element.innerText); if (options.length > 0) this.autocomplete.Show(element, options); }