|
|
|
@ -569,6 +569,21 @@ 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) |
|
|
|
|
{ |
|
|
|
@ -585,6 +600,15 @@ 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) |
|
|
|
|
{ |
|
|
|
|