comments
parent
62f3b28e15
commit
db582b94f0
16
hinter.js
16
hinter.js
|
@ -1,12 +1,12 @@
|
||||||
/* Simple autocomplete for text inputs, with the support for multiple selection.
|
/* Simple autocomplete for text inputs, with the support for multiple selection.
|
||||||
Homepage: http://yourcmc.ru/wiki/SHint_JS
|
Homepage: http://yourcmc.ru/wiki/SimpleAutocomplete
|
||||||
(c) Vitaliy Filippov 2011
|
(c) Vitaliy Filippov 2011
|
||||||
Usage:
|
Usage:
|
||||||
Include hinter.css, hinter.js on your page. Then write:
|
Include hinter.css, hinter.js on your page. Then write:
|
||||||
var hint = new SimpleAutocomplete(input, dataLoader, multipleDelimiter, onChangeListener, maxHeight, emptyText);
|
var hint = new SimpleAutocomplete(input, dataLoader, multipleDelimiter, onChangeListener, maxHeight, emptyText);
|
||||||
Parameters:
|
Parameters:
|
||||||
input
|
input
|
||||||
The input, either id or DOM element reference.
|
The input, either id or DOM element reference (the input must have an id anyway).
|
||||||
dataLoader(hint, value)
|
dataLoader(hint, value)
|
||||||
Callback which should load autocomplete options and then call
|
Callback which should load autocomplete options and then call
|
||||||
hint.replaceItems([ [ name, value ], [ name, value ], ... ])
|
hint.replaceItems([ [ name, value ], [ name, value ], ... ])
|
||||||
|
@ -20,8 +20,9 @@
|
||||||
dataLoader should handle it's 'value' parameter accordingly in this case,
|
dataLoader should handle it's 'value' parameter accordingly in this case,
|
||||||
because it will be just the raw value of the input, probably with incomplete
|
because it will be just the raw value of the input, probably with incomplete
|
||||||
item or items, typed by the user.
|
item or items, typed by the user.
|
||||||
onChangeListener
|
onChangeListener(hint, index)
|
||||||
Callback which is called when input value is changed using this dropdown.
|
Callback which is called when input value is changed using this dropdown.
|
||||||
|
index is the number of element which selection is changed, starting with 0.
|
||||||
It must be used instead of normal 'onchange' event.
|
It must be used instead of normal 'onchange' event.
|
||||||
maxHeight
|
maxHeight
|
||||||
Maximum hint dropdown height in pixels
|
Maximum hint dropdown height in pixels
|
||||||
|
@ -444,10 +445,13 @@ var stopEvent = function(ev, cancelBubble, preventDefault)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Remove leading and trailing whitespace
|
// Remove leading and trailing whitespace
|
||||||
String.prototype.trim = function()
|
if (!String.prototype.trim)
|
||||||
{
|
{
|
||||||
return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
String.prototype.trim = function()
|
||||||
};
|
{
|
||||||
|
return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Get element position, relative to the top-left corner of page
|
// Get element position, relative to the top-left corner of page
|
||||||
var getOffset = function(elem)
|
var getOffset = function(elem)
|
||||||
|
|
Loading…
Reference in New Issue