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.
|
||||
Homepage: http://yourcmc.ru/wiki/SHint_JS
|
||||
Homepage: http://yourcmc.ru/wiki/SimpleAutocomplete
|
||||
(c) Vitaliy Filippov 2011
|
||||
Usage:
|
||||
Include hinter.css, hinter.js on your page. Then write:
|
||||
var hint = new SimpleAutocomplete(input, dataLoader, multipleDelimiter, onChangeListener, maxHeight, emptyText);
|
||||
Parameters:
|
||||
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)
|
||||
Callback which should load autocomplete options and then call
|
||||
hint.replaceItems([ [ name, value ], [ name, value ], ... ])
|
||||
|
@ -20,8 +20,9 @@
|
|||
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
|
||||
item or items, typed by the user.
|
||||
onChangeListener
|
||||
onChangeListener(hint, index)
|
||||
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.
|
||||
maxHeight
|
||||
Maximum hint dropdown height in pixels
|
||||
|
@ -444,10 +445,13 @@ var stopEvent = function(ev, cancelBubble, preventDefault)
|
|||
};
|
||||
|
||||
// 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
|
||||
var getOffset = function(elem)
|
||||
|
|
Loading…
Reference in New Issue