Fix scroll style, make <label> elements in multi-select mode

master
Vitaliy Filippov 2013-04-10 20:19:21 +00:00
parent 7b47d7a939
commit a0366d6169
3 changed files with 16 additions and 20 deletions

View File

@ -4,8 +4,8 @@
background-color: white;
font-size: 80%;
max-height: 300pt;
overflow-y: scroll;
overflow: -moz-scrollbars-vertical;
overflow-y: auto;
-ms-overflow-y: auto;
z-index: 1000;
}
.hintEmptyText {

View File

@ -77,7 +77,7 @@ var SimpleAutocomplete = function(input, dataLoader, params)
// Parameters
this.input = input;
this.dataLoader = dataLoader;
this.multipleDelimiter = params.multipleDelimiter || params.multipleListener;
this.multipleDelimiter = params.multipleDelimiter;
this.multipleListener = params.multipleListener;
this.onChangeListener = params.onChangeListener;
this.emptyText = params.emptyText;
@ -138,8 +138,7 @@ SimpleAutocomplete.prototype.init = function()
this.addRmListener('change', function() { return self.onChange(); });
this.addRmListener('focus', function() { return self.onInputFocus(); });
this.addRmListener('blur', function() { return self.onInputBlur(); });
// Set autocomplete=on to prevent FF and Chrome from clearing inputs on Back click
addListener(window, 'beforeunload', this.closure['beforeunload'] = function() { e.autocomplete = 'on'; });
addListener(window, 'beforeunload', function() { e.autocomplete = 'on'; });
addListener(t, 'mousedown', function(ev) { return self.cancelBubbleOnHint(ev); });
this.onChange();
};
@ -166,7 +165,7 @@ SimpleAutocomplete.prototype.replaceItems = function(items, append)
if (!this.multipleListener)
for (var i in items)
items[i][2] = 0;
if (this.multipleDelimiter && !this.multipleListener)
if (this.multipleDelimiter)
{
var h = {};
var old = this.input.value.split(this.multipleDelimiter);
@ -195,8 +194,6 @@ SimpleAutocomplete.prototype.remove = function()
if (!this.hintLayer)
return;
this.hintLayer.parentNode.removeChild(this.hintLayer);
removeListener(window, 'beforeunload', this.closure['beforeunload']);
delete this.closure['beforeunload'];
for (var i in this.closure)
{
removeListener(this.input, i, this.closure[i]);
@ -222,8 +219,7 @@ SimpleAutocomplete.prototype.makeItem = function(index, item)
d.id = this.id+'_item_'+index;
d.className = item[2] ? 'hintDisabledItem' : (this.selectedIndex == index ? 'hintActiveItem' : 'hintItem');
d.title = item[1];
d.innerHTML = item[0];
if (this.multipleDelimiter)
if (this.multipleDelimiter || this.multipleListener)
{
var c = document.createElement('input');
c.type = 'checkbox';
@ -231,12 +227,15 @@ SimpleAutocomplete.prototype.makeItem = function(index, item)
c.checked = item[3] && true;
c.disabled = item[2] && true;
c.value = item[1];
if (d.childNodes.length)
d.insertBefore(c, d.firstChild);
else
d.appendChild(c);
var l = document.createElement('label');
l.htmlFor = c.id;
l.innerHTML = item[0];
d.appendChild(l);
addListener(c, 'click', this.preventCheck);
}
else
d.innerHTML = item[0];
var self = this;
addListener(d, 'mouseover', function() { return self.onItemMouseOver(this); });
addListener(d, 'mousedown', function(ev) { return self.onItemClick(ev, this); });
@ -285,7 +284,7 @@ SimpleAutocomplete.prototype.getItem = function(index)
// Select index'th item - change the input value and hide the hint if not a multi-select
SimpleAutocomplete.prototype.selectItem = function(index)
{
if (!this.multipleDelimiter)
if (!this.multipleDelimiter && !this.multipleListener)
{
this.input.value = this.items[index][1];
this.hide();
@ -293,11 +292,8 @@ SimpleAutocomplete.prototype.selectItem = function(index)
else
{
document.getElementById(this.id+'_check_'+index).checked = this.items[index][3] = !this.items[index][3];
if (this.multipleListener)
{
this.multipleListener(this, index, this.items[index]);
if (this.multipleListener && !this.multipleListener(this, index, this.items[index]))
return;
}
this.toggleValue(index);
}
this.curValue = this.input.value;

2
hinter.min.js vendored

File diff suppressed because one or more lines are too long