Return add/remove listener functions back
parent
8093f628e8
commit
62acbb95b8
24
hinter.js
24
hinter.js
|
@ -567,6 +567,21 @@ SimpleAutocomplete.GlobalMouseDown = function(ev)
|
||||||
// *** UTILITY FUNCTIONS ***
|
// *** UTILITY FUNCTIONS ***
|
||||||
// Remove this section if you already have these functions defined somewhere else
|
// 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
|
// Cancel event bubbling and/or default action
|
||||||
var stopEvent = function(ev, cancelBubble, preventDefault)
|
var stopEvent = function(ev, cancelBubble, preventDefault)
|
||||||
{
|
{
|
||||||
|
@ -583,6 +598,15 @@ var stopEvent = function(ev, cancelBubble, preventDefault)
|
||||||
return !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
|
// Get element position, relative to the top-left corner of page
|
||||||
var getOffset = function(elem)
|
var getOffset = function(elem)
|
||||||
{
|
{
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue