autocomplete adding breakValue options

This commit is contained in:
2025-01-02 16:56:15 +07:00
parent 99415e5dc9
commit 1fa2b49c12
3 changed files with 14 additions and 20 deletions
+5 -4
View File
@@ -312,9 +312,10 @@ var AutoComplete = (function () {
select: null,
focus: null,
},
//gnips: adding callback and keydown function
//gnips: adding callback, keyfunc and breakvalue
selectFunc: function(){},
keydownFunc: function(){}
keyFunc: function(){},
breakValue: []
};
this._el = element;
this._$el = $(this._el);
@@ -352,8 +353,8 @@ var AutoComplete = (function () {
AutoComplete.prototype.bindDefaultEventListeners = function () {
var _this = this;
this._$el.on('keydown', function (evt) {
//gnips: call keydown function
('' == _this._$el.val() && _this._settings.keydownFunc(evt.which));
//gnips: check breakValue and call keydown function
(('' == _this._$el.val() || ((_this._settings.breakValue.length > 0) && (_this._settings.breakValue.indexOf(_this._$el.val()) != -1))) && _this._settings.keyFunc(evt.which, _this._$el.val()));
switch (evt.which) {
case 9:
if (_this._dd.isItemFocused) {
+9 -5
View File
@@ -4,9 +4,9 @@
Desc. : JS - Fonia Custom Class v3
Created By : Siau Pheng ([email protected]).
Created Date : June 19th, 2009.
Last Modified : January 18th, 2024.
Last Modified : January 2nd, 2025.
(c) 2009 - 2024, 3FONIA Software; WWW.3FONIA.COM.
(c) 2009 - 2025, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
@@ -579,9 +579,13 @@ var FoniaJS = {
extraData: arrData.reduce(function(o, val) { var t = val.split('='); o[t[0]] = t[1]; return o; }, {})
}
};
if ('function' === typeof func_key) objComp.keydownFunc = func_key;
if ('function' === typeof func_comp) objComp.selectFunc = func_comp;
$(elm).autoComplete(objComp);
if ('object' === typeof func_comp){
objComp = $.extend(true, {}, objComp, func_comp);
} else {//compatible
if ('function' === typeof func_key) objComp.keyFunc = func_key;
if ('function' === typeof func_comp) objComp.selectFunc = func_comp;
}
new AutoComplete(elm, objComp);
},
getAppID: function() {
return this.APP_ID;