Revert "caseSensitive option added to autocomplete"
This reverts commit 89601c3115
.
This commit is contained in:
parent
89601c3115
commit
168a65cda4
|
@ -25,7 +25,7 @@
|
||||||
*
|
*
|
||||||
* @author Jos de Jong, <wjosdejong@gmail.com>
|
* @author Jos de Jong, <wjosdejong@gmail.com>
|
||||||
* @version 5.11.0
|
* @version 5.11.0
|
||||||
* @date 2017-12-02
|
* @date 2017-11-22
|
||||||
*/
|
*/
|
||||||
(function webpackUniversalModuleDefinition(root, factory) {
|
(function webpackUniversalModuleDefinition(root, factory) {
|
||||||
if(typeof exports === 'object' && typeof module === 'object')
|
if(typeof exports === 'object' && typeof module === 'object')
|
||||||
|
@ -8084,51 +8084,51 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
/* 10 */
|
/* 10 */
|
||||||
/***/ function(module, exports) {
|
/***/ function(module, exports) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license
|
* Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license
|
||||||
* Author: Jim Palmer (based on chunking idea from Dave Koelle)
|
* Author: Jim Palmer (based on chunking idea from Dave Koelle)
|
||||||
*/
|
*/
|
||||||
/*jshint unused:false */
|
/*jshint unused:false */
|
||||||
module.exports = function naturalSort (a, b) {
|
module.exports = function naturalSort (a, b) {
|
||||||
"use strict";
|
"use strict";
|
||||||
var re = /(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,
|
var re = /(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,
|
||||||
sre = /(^[ ]*|[ ]*$)/g,
|
sre = /(^[ ]*|[ ]*$)/g,
|
||||||
dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,
|
dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,
|
||||||
hre = /^0x[0-9a-f]+$/i,
|
hre = /^0x[0-9a-f]+$/i,
|
||||||
ore = /^0/,
|
ore = /^0/,
|
||||||
i = function(s) { return naturalSort.insensitive && ('' + s).toLowerCase() || '' + s; },
|
i = function(s) { return naturalSort.insensitive && ('' + s).toLowerCase() || '' + s; },
|
||||||
// convert all to strings strip whitespace
|
// convert all to strings strip whitespace
|
||||||
x = i(a).replace(sre, '') || '',
|
x = i(a).replace(sre, '') || '',
|
||||||
y = i(b).replace(sre, '') || '',
|
y = i(b).replace(sre, '') || '',
|
||||||
// chunk/tokenize
|
// chunk/tokenize
|
||||||
xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
|
xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
|
||||||
yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
|
yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
|
||||||
// numeric, hex or date detection
|
// numeric, hex or date detection
|
||||||
xD = parseInt(x.match(hre), 16) || (xN.length !== 1 && x.match(dre) && Date.parse(x)),
|
xD = parseInt(x.match(hre), 16) || (xN.length !== 1 && x.match(dre) && Date.parse(x)),
|
||||||
yD = parseInt(y.match(hre), 16) || xD && y.match(dre) && Date.parse(y) || null,
|
yD = parseInt(y.match(hre), 16) || xD && y.match(dre) && Date.parse(y) || null,
|
||||||
oFxNcL, oFyNcL;
|
oFxNcL, oFyNcL;
|
||||||
// first try and sort Hex codes or Dates
|
// first try and sort Hex codes or Dates
|
||||||
if (yD) {
|
if (yD) {
|
||||||
if ( xD < yD ) { return -1; }
|
if ( xD < yD ) { return -1; }
|
||||||
else if ( xD > yD ) { return 1; }
|
else if ( xD > yD ) { return 1; }
|
||||||
}
|
}
|
||||||
// natural sorting through split numeric strings and default strings
|
// natural sorting through split numeric strings and default strings
|
||||||
for(var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc++) {
|
for(var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc++) {
|
||||||
// find floats not starting with '0', string or 0 if not defined (Clint Priest)
|
// find floats not starting with '0', string or 0 if not defined (Clint Priest)
|
||||||
oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
|
oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
|
||||||
oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
|
oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
|
||||||
// handle numeric vs string comparison - number < string - (Kyle Adams)
|
// handle numeric vs string comparison - number < string - (Kyle Adams)
|
||||||
if (isNaN(oFxNcL) !== isNaN(oFyNcL)) { return (isNaN(oFxNcL)) ? 1 : -1; }
|
if (isNaN(oFxNcL) !== isNaN(oFyNcL)) { return (isNaN(oFxNcL)) ? 1 : -1; }
|
||||||
// rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
|
// rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
|
||||||
else if (typeof oFxNcL !== typeof oFyNcL) {
|
else if (typeof oFxNcL !== typeof oFyNcL) {
|
||||||
oFxNcL += '';
|
oFxNcL += '';
|
||||||
oFyNcL += '';
|
oFyNcL += '';
|
||||||
}
|
}
|
||||||
if (oFxNcL < oFyNcL) { return -1; }
|
if (oFxNcL < oFyNcL) { return -1; }
|
||||||
if (oFxNcL > oFyNcL) { return 1; }
|
if (oFxNcL > oFyNcL) { return 1; }
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -25,7 +25,7 @@
|
||||||
*
|
*
|
||||||
* @author Jos de Jong, <wjosdejong@gmail.com>
|
* @author Jos de Jong, <wjosdejong@gmail.com>
|
||||||
* @version 5.11.0
|
* @version 5.11.0
|
||||||
* @date 2017-12-02
|
* @date 2017-11-22
|
||||||
*/
|
*/
|
||||||
(function webpackUniversalModuleDefinition(root, factory) {
|
(function webpackUniversalModuleDefinition(root, factory) {
|
||||||
if(typeof exports === 'object' && typeof module === 'object')
|
if(typeof exports === 'object' && typeof module === 'object')
|
||||||
|
@ -2898,16 +2898,16 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
/* 6 */
|
/* 6 */
|
||||||
/***/ function(module, exports) {
|
/***/ function(module, exports) {
|
||||||
|
|
||||||
module.exports = function(module) {
|
module.exports = function(module) {
|
||||||
if(!module.webpackPolyfill) {
|
if(!module.webpackPolyfill) {
|
||||||
module.deprecate = function() {};
|
module.deprecate = function() {};
|
||||||
module.paths = [];
|
module.paths = [];
|
||||||
// module.parent = undefined by default
|
// module.parent = undefined by default
|
||||||
module.children = [];
|
module.children = [];
|
||||||
module.webpackPolyfill = 1;
|
module.webpackPolyfill = 1;
|
||||||
}
|
}
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
|
@ -15617,51 +15617,51 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
/* 60 */
|
/* 60 */
|
||||||
/***/ function(module, exports) {
|
/***/ function(module, exports) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license
|
* Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license
|
||||||
* Author: Jim Palmer (based on chunking idea from Dave Koelle)
|
* Author: Jim Palmer (based on chunking idea from Dave Koelle)
|
||||||
*/
|
*/
|
||||||
/*jshint unused:false */
|
/*jshint unused:false */
|
||||||
module.exports = function naturalSort (a, b) {
|
module.exports = function naturalSort (a, b) {
|
||||||
"use strict";
|
"use strict";
|
||||||
var re = /(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,
|
var re = /(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,
|
||||||
sre = /(^[ ]*|[ ]*$)/g,
|
sre = /(^[ ]*|[ ]*$)/g,
|
||||||
dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,
|
dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,
|
||||||
hre = /^0x[0-9a-f]+$/i,
|
hre = /^0x[0-9a-f]+$/i,
|
||||||
ore = /^0/,
|
ore = /^0/,
|
||||||
i = function(s) { return naturalSort.insensitive && ('' + s).toLowerCase() || '' + s; },
|
i = function(s) { return naturalSort.insensitive && ('' + s).toLowerCase() || '' + s; },
|
||||||
// convert all to strings strip whitespace
|
// convert all to strings strip whitespace
|
||||||
x = i(a).replace(sre, '') || '',
|
x = i(a).replace(sre, '') || '',
|
||||||
y = i(b).replace(sre, '') || '',
|
y = i(b).replace(sre, '') || '',
|
||||||
// chunk/tokenize
|
// chunk/tokenize
|
||||||
xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
|
xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
|
||||||
yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
|
yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
|
||||||
// numeric, hex or date detection
|
// numeric, hex or date detection
|
||||||
xD = parseInt(x.match(hre), 16) || (xN.length !== 1 && x.match(dre) && Date.parse(x)),
|
xD = parseInt(x.match(hre), 16) || (xN.length !== 1 && x.match(dre) && Date.parse(x)),
|
||||||
yD = parseInt(y.match(hre), 16) || xD && y.match(dre) && Date.parse(y) || null,
|
yD = parseInt(y.match(hre), 16) || xD && y.match(dre) && Date.parse(y) || null,
|
||||||
oFxNcL, oFyNcL;
|
oFxNcL, oFyNcL;
|
||||||
// first try and sort Hex codes or Dates
|
// first try and sort Hex codes or Dates
|
||||||
if (yD) {
|
if (yD) {
|
||||||
if ( xD < yD ) { return -1; }
|
if ( xD < yD ) { return -1; }
|
||||||
else if ( xD > yD ) { return 1; }
|
else if ( xD > yD ) { return 1; }
|
||||||
}
|
}
|
||||||
// natural sorting through split numeric strings and default strings
|
// natural sorting through split numeric strings and default strings
|
||||||
for(var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc++) {
|
for(var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc++) {
|
||||||
// find floats not starting with '0', string or 0 if not defined (Clint Priest)
|
// find floats not starting with '0', string or 0 if not defined (Clint Priest)
|
||||||
oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
|
oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
|
||||||
oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
|
oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
|
||||||
// handle numeric vs string comparison - number < string - (Kyle Adams)
|
// handle numeric vs string comparison - number < string - (Kyle Adams)
|
||||||
if (isNaN(oFxNcL) !== isNaN(oFyNcL)) { return (isNaN(oFxNcL)) ? 1 : -1; }
|
if (isNaN(oFxNcL) !== isNaN(oFyNcL)) { return (isNaN(oFxNcL)) ? 1 : -1; }
|
||||||
// rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
|
// rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
|
||||||
else if (typeof oFxNcL !== typeof oFyNcL) {
|
else if (typeof oFxNcL !== typeof oFyNcL) {
|
||||||
oFxNcL += '';
|
oFxNcL += '';
|
||||||
oFyNcL += '';
|
oFyNcL += '';
|
||||||
}
|
}
|
||||||
if (oFxNcL < oFyNcL) { return -1; }
|
if (oFxNcL < oFyNcL) { return -1; }
|
||||||
if (oFxNcL > oFyNcL) { return 1; }
|
if (oFxNcL > oFyNcL) { return 1; }
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
|
@ -16031,7 +16031,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
function completely(config) {
|
function completely(config) {
|
||||||
config = config || {};
|
config = config || {};
|
||||||
config.confirmKeys = config.confirmKeys || [39, 35, 9] // right, end, tab
|
config.confirmKeys = config.confirmKeys || [39, 35, 9] // right, end, tab
|
||||||
config.caseSensitive = config.caseSensitive || false // autocomplete case sensitive
|
|
||||||
|
|
||||||
var fontSize = '';
|
var fontSize = '';
|
||||||
var fontFamily = '';
|
var fontFamily = '';
|
||||||
|
@ -16076,10 +16075,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
|
|
||||||
rows = [];
|
rows = [];
|
||||||
for (var i = 0; i < array.length; i++) {
|
for (var i = 0; i < array.length; i++) {
|
||||||
|
if (array[i].indexOf(token) !== 0) { continue; }
|
||||||
if ( (config.caseSensitive && array[i].indexOf(token) !== 0)
|
|
||||||
||(!config.caseSensitive && array[i].toLowerCase().indexOf(token.toLowerCase()) !== 0)) { continue; }
|
|
||||||
|
|
||||||
var divRow = document.createElement('div');
|
var divRow = document.createElement('div');
|
||||||
divRow.className = 'item';
|
divRow.className = 'item';
|
||||||
//divRow.style.color = config.color;
|
//divRow.style.color = config.color;
|
||||||
|
@ -16094,8 +16090,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
if (rows.length === 0) {
|
if (rows.length === 0) {
|
||||||
return; // nothing to show.
|
return; // nothing to show.
|
||||||
}
|
}
|
||||||
if (rows.length === 1 && ( (token.toLowerCase() === rows[0].__hint.toLowerCase() && !config.caseSensitive)
|
if (rows.length === 1 && token === rows[0].__hint) {
|
||||||
||(token === rows[0].__hint && config.caseSensitive))){
|
|
||||||
return; // do not show the dropDown if it has only one element which matches what we have just displayed.
|
return; // do not show the dropDown if it has only one element which matches what we have just displayed.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16281,10 +16276,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
|
|
||||||
for (var i = 0; i < optionsLength; i++) {
|
for (var i = 0; i < optionsLength; i++) {
|
||||||
var opt = this.options[i];
|
var opt = this.options[i];
|
||||||
if ( (!config.caseSensitive && opt.toLowerCase().indexOf(token.toLowerCase()) === 0)
|
if (opt.indexOf(token) === 0) { // <-- how about upperCase vs. lowercase
|
||||||
|| (config.caseSensitive && opt.indexOf(token) === 0)) { // <-- how about upperCase vs. lowercase
|
this.elementHint.innerText = leftSide + opt;
|
||||||
this.elementHint.innerText = leftSide + token + opt.substring(token.length);
|
|
||||||
this.elementHint.realInnerText = leftSide + opt;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16318,10 +16311,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var text = this.element.innerText;
|
|
||||||
text = text.replace('\n', '');
|
|
||||||
var startFrom = this.startFrom;
|
|
||||||
|
|
||||||
if (config.confirmKeys.indexOf(keyCode) >= 0) { // (autocomplete triggered)
|
if (config.confirmKeys.indexOf(keyCode) >= 0) { // (autocomplete triggered)
|
||||||
if (keyCode == 9) {
|
if (keyCode == 9) {
|
||||||
if (this.elementHint.innerText.length == 0) {
|
if (this.elementHint.innerText.length == 0) {
|
||||||
|
@ -16329,8 +16318,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.elementHint.innerText.length > 0) { // if there is a hint
|
if (this.elementHint.innerText.length > 0) { // if there is a hint
|
||||||
if (this.element.innerText != this.elementHint.realInnerText) {
|
if (this.element.innerText != this.elementHint.innerText) {
|
||||||
this.element.innerText = this.elementHint.realInnerText;
|
this.element.innerText = this.elementHint.innerText;
|
||||||
rs.hideDropDown();
|
rs.hideDropDown();
|
||||||
setEndOfContenteditable(this.element);
|
setEndOfContenteditable(this.element);
|
||||||
if (keyCode == 9) {
|
if (keyCode == 9) {
|
||||||
|
@ -16357,7 +16346,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.element.innerText = this.elementHint.realInnerText;
|
this.element.innerText = this.elementHint.innerText;
|
||||||
rs.hideDropDown();
|
rs.hideDropDown();
|
||||||
setEndOfContenteditable(this.element);
|
setEndOfContenteditable(this.element);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -16367,22 +16356,18 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyCode == 40) { // down
|
if (keyCode == 40) { // down
|
||||||
var token = text.substring(this.startFrom);
|
|
||||||
var m = dropDownController.move(+1);
|
var m = dropDownController.move(+1);
|
||||||
if (m == '') { rs.onArrowDown(); }
|
if (m == '') { rs.onArrowDown(); }
|
||||||
this.elementHint.innerText = leftSide + token + m.substring(token.length);
|
this.elementHint.innerText = leftSide + m;
|
||||||
this.elementHint.realInnerText = leftSide + m;
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyCode == 38) { // up
|
if (keyCode == 38) { // up
|
||||||
var token = text.substring(this.startFrom);
|
|
||||||
var m = dropDownController.move(-1);
|
var m = dropDownController.move(-1);
|
||||||
if (m == '') { rs.onArrowUp(); }
|
if (m == '') { rs.onArrowUp(); }
|
||||||
this.elementHint.innerText = leftSide + token + m.substring(token.length);
|
this.elementHint.innerText = leftSide + m;
|
||||||
this.elementHint.realInnerText = leftSide + m;
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
return;
|
return;
|
||||||
|
@ -37369,7 +37354,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
/* 67 */
|
/* 67 */
|
||||||
/***/ function(module, exports) {
|
/***/ function(module, exports) {
|
||||||
|
|
||||||
module.exports = function() { throw new Error("define cannot be used indirect"); };
|
module.exports = function() { throw new Error("define cannot be used indirect"); };
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -162,10 +162,6 @@ Constructs a new JSONEditor.
|
||||||
|
|
||||||
Indicate the KeyCodes for trigger confirm completion, by default those keys are: [39, 35, 9] which are the code for [right, end, tab]
|
Indicate the KeyCodes for trigger confirm completion, by default those keys are: [39, 35, 9] which are the code for [right, end, tab]
|
||||||
|
|
||||||
- `{boolean} caseSensitive`
|
|
||||||
|
|
||||||
Indicate if the autocomplete is going to be strict case-sensitive to match the options.
|
|
||||||
|
|
||||||
- `{Function} getOptions (text: string, path: string[], input: string, editor: JSONEditor)`
|
- `{Function} getOptions (text: string, path: string[], input: string, editor: JSONEditor)`
|
||||||
|
|
||||||
This function will return your possible options for create the autocomplete selection, you can control dynamically which options you want to display according to the current active editing node.
|
This function will return your possible options for create the autocomplete selection, you can control dynamically which options you want to display according to the current active editing node.
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
var options = {
|
var options = {
|
||||||
autocomplete: {
|
autocomplete: {
|
||||||
confirmKeys: [39, 35, 9, 190], // Confirm Autocomplete Keys: [right, end, tab, '.'] // By default are only [right, end, tab]
|
confirmKeys: [39, 35, 9, 190], // Confirm Autocomplete Keys: [right, end, tab, '.'] // By default are only [right, end, tab]
|
||||||
caseSensitive: true,
|
|
||||||
|
|
||||||
getOptions: function (text, path, input, editor) {
|
getOptions: function (text, path, input, editor) {
|
||||||
if (!text.startsWith(activationChar) || input !== 'value') return [];
|
if (!text.startsWith(activationChar) || input !== 'value') return [];
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
function completely(config) {
|
function completely(config) {
|
||||||
config = config || {};
|
config = config || {};
|
||||||
config.confirmKeys = config.confirmKeys || [39, 35, 9] // right, end, tab
|
config.confirmKeys = config.confirmKeys || [39, 35, 9] // right, end, tab
|
||||||
config.caseSensitive = config.caseSensitive || false // autocomplete case sensitive
|
|
||||||
|
|
||||||
var fontSize = '';
|
var fontSize = '';
|
||||||
var fontFamily = '';
|
var fontFamily = '';
|
||||||
|
@ -48,10 +47,7 @@ function completely(config) {
|
||||||
|
|
||||||
rows = [];
|
rows = [];
|
||||||
for (var i = 0; i < array.length; i++) {
|
for (var i = 0; i < array.length; i++) {
|
||||||
|
if (array[i].indexOf(token) !== 0) { continue; }
|
||||||
if ( (config.caseSensitive && array[i].indexOf(token) !== 0)
|
|
||||||
||(!config.caseSensitive && array[i].toLowerCase().indexOf(token.toLowerCase()) !== 0)) { continue; }
|
|
||||||
|
|
||||||
var divRow = document.createElement('div');
|
var divRow = document.createElement('div');
|
||||||
divRow.className = 'item';
|
divRow.className = 'item';
|
||||||
//divRow.style.color = config.color;
|
//divRow.style.color = config.color;
|
||||||
|
@ -66,8 +62,7 @@ function completely(config) {
|
||||||
if (rows.length === 0) {
|
if (rows.length === 0) {
|
||||||
return; // nothing to show.
|
return; // nothing to show.
|
||||||
}
|
}
|
||||||
if (rows.length === 1 && ( (token.toLowerCase() === rows[0].__hint.toLowerCase() && !config.caseSensitive)
|
if (rows.length === 1 && token === rows[0].__hint) {
|
||||||
||(token === rows[0].__hint && config.caseSensitive))){
|
|
||||||
return; // do not show the dropDown if it has only one element which matches what we have just displayed.
|
return; // do not show the dropDown if it has only one element which matches what we have just displayed.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,10 +248,8 @@ function completely(config) {
|
||||||
|
|
||||||
for (var i = 0; i < optionsLength; i++) {
|
for (var i = 0; i < optionsLength; i++) {
|
||||||
var opt = this.options[i];
|
var opt = this.options[i];
|
||||||
if ( (!config.caseSensitive && opt.toLowerCase().indexOf(token.toLowerCase()) === 0)
|
if (opt.indexOf(token) === 0) { // <-- how about upperCase vs. lowercase
|
||||||
|| (config.caseSensitive && opt.indexOf(token) === 0)) { // <-- how about upperCase vs. lowercase
|
this.elementHint.innerText = leftSide + opt;
|
||||||
this.elementHint.innerText = leftSide + token + opt.substring(token.length);
|
|
||||||
this.elementHint.realInnerText = leftSide + opt;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,10 +283,6 @@ function completely(config) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var text = this.element.innerText;
|
|
||||||
text = text.replace('\n', '');
|
|
||||||
var startFrom = this.startFrom;
|
|
||||||
|
|
||||||
if (config.confirmKeys.indexOf(keyCode) >= 0) { // (autocomplete triggered)
|
if (config.confirmKeys.indexOf(keyCode) >= 0) { // (autocomplete triggered)
|
||||||
if (keyCode == 9) {
|
if (keyCode == 9) {
|
||||||
if (this.elementHint.innerText.length == 0) {
|
if (this.elementHint.innerText.length == 0) {
|
||||||
|
@ -301,8 +290,8 @@ function completely(config) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.elementHint.innerText.length > 0) { // if there is a hint
|
if (this.elementHint.innerText.length > 0) { // if there is a hint
|
||||||
if (this.element.innerText != this.elementHint.realInnerText) {
|
if (this.element.innerText != this.elementHint.innerText) {
|
||||||
this.element.innerText = this.elementHint.realInnerText;
|
this.element.innerText = this.elementHint.innerText;
|
||||||
rs.hideDropDown();
|
rs.hideDropDown();
|
||||||
setEndOfContenteditable(this.element);
|
setEndOfContenteditable(this.element);
|
||||||
if (keyCode == 9) {
|
if (keyCode == 9) {
|
||||||
|
@ -329,7 +318,7 @@ function completely(config) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.element.innerText = this.elementHint.realInnerText;
|
this.element.innerText = this.elementHint.innerText;
|
||||||
rs.hideDropDown();
|
rs.hideDropDown();
|
||||||
setEndOfContenteditable(this.element);
|
setEndOfContenteditable(this.element);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -339,22 +328,18 @@ function completely(config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyCode == 40) { // down
|
if (keyCode == 40) { // down
|
||||||
var token = text.substring(this.startFrom);
|
|
||||||
var m = dropDownController.move(+1);
|
var m = dropDownController.move(+1);
|
||||||
if (m == '') { rs.onArrowDown(); }
|
if (m == '') { rs.onArrowDown(); }
|
||||||
this.elementHint.innerText = leftSide + token + m.substring(token.length);
|
this.elementHint.innerText = leftSide + m;
|
||||||
this.elementHint.realInnerText = leftSide + m;
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyCode == 38) { // up
|
if (keyCode == 38) { // up
|
||||||
var token = text.substring(this.startFrom);
|
|
||||||
var m = dropDownController.move(-1);
|
var m = dropDownController.move(-1);
|
||||||
if (m == '') { rs.onArrowUp(); }
|
if (m == '') { rs.onArrowUp(); }
|
||||||
this.elementHint.innerText = leftSide + token + m.substring(token.length);
|
this.elementHint.innerText = leftSide + m;
|
||||||
this.elementHint.realInnerText = leftSide + m;
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue