diff --git a/hinter.js b/hinter.js index 9c97afa..40f797e 100644 --- a/hinter.js +++ b/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) { diff --git a/hinter.min.js b/hinter.min.js index 03fee68..a0c15d7 100644 --- a/hinter.min.js +++ b/hinter.min.js @@ -1,4 +1,4 @@ // (c) Vitaliy Filippov 2011-2013 // @license MPL 2.0 http://www.mozilla.org/MPL/2.0/ // http://yourcmc.ru/wiki/SimpleAutocomplete -var SimpleAutocomplete=function(b,a,c){if(typeof(b)=="string"){b=document.getElementById(b)}if(!c){c={}}this.input=b;this.a=a;this.b=c.multipleDelimiter;this.c=c.multipleListener;this.d=c.onChangeListener;this.e=c.emptyText;this.f=c.prompt;this.g=c.delay;this.h=c.moreMarker;this.i=c.persist;this.j=c.className||"hintLayer";if(this.h===undefined){this.h="#MORE"}if(this.g===undefined){this.g=300}this.k=0;this.l=null;this.m=[];this.n=[];this.o=0;this.p=-1;this.q=false;this.r()};SimpleAutocomplete.prototype.r=function(){var f=this.input;var a=SimpleAutocomplete.s;this.t=this.input.id+a.length;a.push(this);var d=getOffset(f);var c=this.u=document.createElement("div");c.className=this.j;if(!this.i){c.style.display="none";c.style.position="absolute";c.style.top=(d.top+f.offsetHeight)+"px";c.style.zIndex=1000;c.style.left=d.left+"px";document.body.appendChild(c)}else{f.nextSibling?f.parentNode.insertBefore(c,f.nextSibling):f.parentNode.appendChild(c)}f.SimpleAutocomplete_input=this;c.SimpleAutocomplete_layer=this;if(typeof f.autocomplete!=="undefined"){f.autocomplete="off";addListener(window,"beforeunload",function(){f.autocomplete="on"})}var b=this;this.v("keydown",function(e){return b.w(e)});this.v("keyup",function(e){return b.x(e)});this.v("change",function(){return b.onChange()});this.v("focus",function(){return b.y()});this.v("blur",function(){return b.z()});addListener(c,"mousedown",function(e){return b.aa(e)});this.onChange(true)};SimpleAutocomplete.prototype.replaceItems=function(c,a){if(!a){this.u.scrollTop=0;this.p=0;this.n=[];if(!c||c.length==0){if(this.e){this.u.innerHTML='