Remove change state
parent
100235c5e4
commit
3d19d119f2
33
hinter.js
33
hinter.js
|
@ -63,9 +63,6 @@
|
||||||
|
|
||||||
Destroy instance:
|
Destroy instance:
|
||||||
hint.remove(); hint = null;
|
hint.remove(); hint = null;
|
||||||
|
|
||||||
Change multiselect item state:
|
|
||||||
hint.changeMultiItem(index, name, disabled, checked);
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// *** Constructor ***
|
// *** Constructor ***
|
||||||
|
@ -158,6 +155,7 @@ SimpleAutocomplete.prototype.replaceItems = function(items, append)
|
||||||
if (!append)
|
if (!append)
|
||||||
{
|
{
|
||||||
this.hintLayer.scrollTop = 0;
|
this.hintLayer.scrollTop = 0;
|
||||||
|
this.selectedIndex = -1;
|
||||||
this.items = [];
|
this.items = [];
|
||||||
if (!items || items.length == 0)
|
if (!items || items.length == 0)
|
||||||
{
|
{
|
||||||
|
@ -220,39 +218,12 @@ SimpleAutocomplete.prototype.remove = function()
|
||||||
this.items = null;
|
this.items = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Check/uncheck/enable/disable/rename multiselect item
|
|
||||||
SimpleAutocomplete.prototype.changeMultiItem = function(index, name, disabled, checked)
|
|
||||||
{
|
|
||||||
if (this.items && this.items[index] && this.multipleDelimiter)
|
|
||||||
{
|
|
||||||
var d = document.getElementById(this.id+'_item_'+index);
|
|
||||||
d.className = disabled ? 'hintDisabledItem' : 'hintItem';
|
|
||||||
var c = d.children[0];
|
|
||||||
if (name && name != this.items[index][0])
|
|
||||||
{
|
|
||||||
d.removeChild(c);
|
|
||||||
d.innerHTML = name;
|
|
||||||
d.childNodes.length ? d.insertBefore(c, d.childNodes[0]) : d.appendChild(c);
|
|
||||||
this.items[index][0] = name;
|
|
||||||
}
|
|
||||||
c.checked = checked && true;
|
|
||||||
c.disabled = disabled && true;
|
|
||||||
this.items[index][2] = disabled;
|
|
||||||
if ((this.items[index][3] && true) != c.checked && !this.multipleListener)
|
|
||||||
{
|
|
||||||
this.items[index][3] = c.checked;
|
|
||||||
this.toggleValue(index);
|
|
||||||
this.curValue = this.input.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create a drop-down list item, include checkbox if this.multipleDelimiter is true
|
// Create a drop-down list item, include checkbox if this.multipleDelimiter is true
|
||||||
SimpleAutocomplete.prototype.makeItem = function(index, item)
|
SimpleAutocomplete.prototype.makeItem = function(index, item)
|
||||||
{
|
{
|
||||||
var d = document.createElement('div');
|
var d = document.createElement('div');
|
||||||
d.id = this.id+'_item_'+index;
|
d.id = this.id+'_item_'+index;
|
||||||
d.className = item[2] ? 'hintDisabledItem' : 'hintItem';
|
d.className = item[2] ? 'hintDisabledItem' : (this.selectedIndex == index ? 'hintActiveItem' : 'hintItem');
|
||||||
d.title = item[1];
|
d.title = item[1];
|
||||||
d.innerHTML = item[0];
|
d.innerHTML = item[0];
|
||||||
if (this.multipleDelimiter)
|
if (this.multipleDelimiter)
|
||||||
|
|
Loading…
Reference in New Issue