Fix cancel-bubble
parent
50ccb83a58
commit
ea6f19fac9
23
hinter.js
23
hinter.js
|
@ -95,9 +95,9 @@ SimpleAutocomplete.prototype.init = function()
|
|||
document.body.appendChild(t);
|
||||
|
||||
// Remember instance
|
||||
e.SimpleAutocomplete_input = self;
|
||||
t.SimpleAutocomplete_layer = self;
|
||||
SimpleAutocomplete.SimpleAutocompletes.push(self);
|
||||
e.SimpleAutocomplete_input = this;
|
||||
t.SimpleAutocomplete_layer = this;
|
||||
SimpleAutocomplete.SimpleAutocompletes.push(this);
|
||||
|
||||
// Set event listeners
|
||||
var self = this;
|
||||
|
@ -113,6 +113,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(); });
|
||||
addListener(t, 'mousedown', function(ev) { return self.cancelBubbleOnHint(ev); });
|
||||
this.onChange();
|
||||
};
|
||||
|
||||
|
@ -295,7 +296,7 @@ SimpleAutocomplete.prototype.selectItem = function(index)
|
|||
}
|
||||
this.curValue = this.input.value;
|
||||
if (this.onChangeListener)
|
||||
this.onChangeListener(self, index);
|
||||
this.onChangeListener(this, index);
|
||||
};
|
||||
|
||||
// Hide hinter
|
||||
|
@ -348,6 +349,15 @@ SimpleAutocomplete.prototype.preventCheck = function(ev)
|
|||
return stopEvent(ev, false, true);
|
||||
};
|
||||
|
||||
// Cancel event propagation
|
||||
SimpleAutocomplete.prototype.cancelBubbleOnHint = function(ev)
|
||||
{
|
||||
ev = ev||window.event;
|
||||
if (this.hasFocus)
|
||||
this.skipHideCounter++;
|
||||
return stopEvent(ev, true, false);
|
||||
};
|
||||
|
||||
// Handle item mouse over
|
||||
SimpleAutocomplete.prototype.onItemMouseOver = function(elm)
|
||||
{
|
||||
|
@ -357,7 +367,6 @@ SimpleAutocomplete.prototype.onItemMouseOver = function(elm)
|
|||
// Handle item clicks
|
||||
SimpleAutocomplete.prototype.onItemClick = function(ev, elm)
|
||||
{
|
||||
stopEvent(ev||window.event, true, false);
|
||||
this.selectItem(parseInt(elm.id.substr(this.id.length+6)));
|
||||
return true;
|
||||
};
|
||||
|
@ -479,11 +488,7 @@ SimpleAutocomplete.GlobalMouseDown = function(ev)
|
|||
if (esh)
|
||||
break;
|
||||
else if (target.SimpleAutocomplete_layer)
|
||||
{
|
||||
if (target.SimpleAutocomplete_layer.hasFocus)
|
||||
target.SimpleAutocomplete_layer.skipHideCounter++;
|
||||
return true;
|
||||
}
|
||||
target = target.parentNode;
|
||||
}
|
||||
for (var i in SimpleAutocomplete.SimpleAutocompletes)
|
||||
|
|
Loading…
Reference in New Issue