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, select: null,
focus: null, focus: null,
}, },
//gnips: adding callback and keydown function //gnips: adding callback, keyfunc and breakvalue
selectFunc: function(){}, selectFunc: function(){},
keydownFunc: function(){} keyFunc: function(){},
breakValue: []
}; };
this._el = element; this._el = element;
this._$el = $(this._el); this._$el = $(this._el);
@@ -352,8 +353,8 @@ var AutoComplete = (function () {
AutoComplete.prototype.bindDefaultEventListeners = function () { AutoComplete.prototype.bindDefaultEventListeners = function () {
var _this = this; var _this = this;
this._$el.on('keydown', function (evt) { this._$el.on('keydown', function (evt) {
//gnips: call keydown function //gnips: check breakValue and call keydown function
('' == _this._$el.val() && _this._settings.keydownFunc(evt.which)); (('' == _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) { switch (evt.which) {
case 9: case 9:
if (_this._dd.isItemFocused) { if (_this._dd.isItemFocused) {
+9 -5
View File
@@ -4,9 +4,9 @@
Desc. : JS - Fonia Custom Class v3 Desc. : JS - Fonia Custom Class v3
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : June 19th, 2009. 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; }, {}) 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 ('object' === typeof func_comp){
if ('function' === typeof func_comp) objComp.selectFunc = func_comp; objComp = $.extend(true, {}, objComp, func_comp);
$(elm).autoComplete(objComp); } 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() { getAppID: function() {
return this.APP_ID; return this.APP_ID;
-11
View File
@@ -223,17 +223,6 @@ final class Form {
return $tout; return $tout;
} }
/*public function textauto($tlabel="", $tfield, $tvalue=null, $benable=true, $breq=false, $holdtxt=null, $nmaxsize=null, $thelp="") {
$tvalue = ($tvalue==null) ? array('value'=>0, 'text'=>"") : $tvalue;
$_enab = ($benable==true) ? "" : ' disabled=true';
$_req = ($breq==true) ? " required=true" : "";
$_max = ($nmaxsize==null) ? "" : ' maxlength="'.$nmaxsize.'"';
$_holdtxt = ($holdtxt==null) ? "" : ' placeholder="'.$holdtxt.'"';
$tout = '<select class="form-control" id="'.$tfield.'" name="'.$tfield.'" default-value="'.$tvalue['value'].'" default-text="'.$tvalue['text'].'"'.$_enab.$_max.$_holdtxt.$_req.' /></select>';
$this->__aform[$tfield] = array('label'=>$tlabel, 'help'=>$thelp, 'form'=>$tout);
return $tout;
}*/
public function datebox($tlabel="", $tfield, $tvalue=null, $benable=true, $breq=false, $thelp="", $tkeyup=null, $tblur=null) { public function datebox($tlabel="", $tfield, $tvalue=null, $benable=true, $breq=false, $thelp="", $tkeyup=null, $tblur=null) {
if ($tvalue<>null) $tvalue = tgl_sql2str($tvalue); if ($tvalue<>null) $tvalue = tgl_sql2str($tvalue);
$tout = '<div class="input-group">'; $tout = '<div class="input-group">';