Do not call getOffset on init
parent
62acbb95b8
commit
08bd47dd42
30
hinter.js
30
hinter.js
|
@ -2,7 +2,7 @@
|
|||
|
||||
Homepage: http://yourcmc.ru/wiki/SimpleAutocomplete
|
||||
License: MPL 2.0+ (http://www.mozilla.org/MPL/2.0/)
|
||||
Version: 2014-09-05
|
||||
Version: 2014-09-11
|
||||
(c) Vitaliy Filippov 2011-2014
|
||||
|
||||
Usage:
|
||||
|
@ -122,8 +122,6 @@ SimpleAutocomplete.prototype.init = function()
|
|||
this.id = this.input.id + l.length;
|
||||
l.push(this);
|
||||
|
||||
var p = getOffset(e);
|
||||
|
||||
// Create hint layer
|
||||
var t = this.hintLayer = document.createElement('div');
|
||||
t.className = this.className;
|
||||
|
@ -131,9 +129,7 @@ SimpleAutocomplete.prototype.init = function()
|
|||
{
|
||||
t.style.display = 'none';
|
||||
t.style.position = 'absolute';
|
||||
t.style.top = (p.top+e.offsetHeight) + 'px';
|
||||
t.style.zIndex = 1000;
|
||||
t.style.left = p.left + 'px';
|
||||
document.body.appendChild(t);
|
||||
}
|
||||
else
|
||||
|
@ -567,21 +563,6 @@ SimpleAutocomplete.GlobalMouseDown = function(ev)
|
|||
// *** UTILITY FUNCTIONS ***
|
||||
// Remove this section if you already have these functions defined somewhere else
|
||||
|
||||
// Cross-browser add/remove event listeners
|
||||
var addListener = function()
|
||||
{
|
||||
return window.addEventListener
|
||||
? function(el, type, fn) { el.addEventListener(type, fn, false); }
|
||||
: function(el, type, fn) { el.attachEvent('on'+type, fn); };
|
||||
}();
|
||||
|
||||
var removeListener = function()
|
||||
{
|
||||
return window.removeEventListener
|
||||
? function(el, type, fn) { el.removeEventListener(type, fn, false); }
|
||||
: function(el, type, fn) { el.detachEvent('on'+type, fn); };
|
||||
}();
|
||||
|
||||
// Cancel event bubbling and/or default action
|
||||
var stopEvent = function(ev, cancelBubble, preventDefault)
|
||||
{
|
||||
|
@ -598,15 +579,6 @@ var stopEvent = function(ev, cancelBubble, preventDefault)
|
|||
return !preventDefault;
|
||||
};
|
||||
|
||||
// Remove leading and trailing whitespace
|
||||
if (!String.prototype.trim)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue