From 8093f628e8deadc5005ca824a4a79d02fcc73ce4 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Fri, 5 Sep 2014 10:35:28 +0000 Subject: [PATCH] Update SA --- hinter.js | 2 +- hinter.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hinter.js b/hinter.js index 6075bc2..9266c9a 100644 --- a/hinter.js +++ b/hinter.js @@ -389,7 +389,7 @@ SimpleAutocomplete.prototype.hide = function() // Show hinter SimpleAutocomplete.prototype.show = function() { - if (!this.disabled && !this.persist) + if (!this.disabled && !this.persist && this.hintLayer.style.display == 'none') { var p = getOffset(this.input); this.hintLayer.style.top = (p.top+this.input.offsetHeight) + 'px'; diff --git a/hinter.min.js b/hinter.min.js index a5616a2..792aeb2 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='
'+this.e+"
"}else{this.ab()}return}while(this.p'+this.f+"":"";this.ac()}if(this.b){var e={};var b=this.input.value.split(this.b);for(var d=0;d=0){var d=this.aj();if(d){d.className=this.n[this.p][2]?"hintDisabledItem":"hintItem"}}this.p=a;b.className="hintActiveItem";return false};SimpleAutocomplete.prototype.aj=function(a){if(a==null){a=this.p}if(a<0){return null}return document.getElementById(this.t+"_item_"+this.p)};SimpleAutocomplete.prototype.selectItem=function(a){if(this.n[a][2]){return false}if(this.h&&this.n[a][1]==this.h){this.n.splice(a,1);elm.parentNode.removeChild(elm);this.k++;this.onChange(true);return}if(!this.b&&!this.c){this.input.value=this.n[a][1];this.hide()}else{document.getElementById(this.t+"_check_"+a).checked=this.n[a][3]=!this.n[a][3];if(this.c&&!this.c(this,a,this.n[a])){return}this.ak(a)}this.al=this.input.value;if(this.d){this.d(this,a,this.n[a])}};SimpleAutocomplete.prototype.ak=function(c){var b=this.input.value.split(this.b);for(var d=0;d=0;d--){if(b[d]==this.n[c][1]){b.splice(d,1)}}this.input.value=b.join(this.b+" ")}else{var e={};for(var d=0;d=0){this.selectItem(this.p)}return stopEvent(e,true,true)}else{if(e.keyCode==27){this.hide();return stopEvent(e,true,true)}else{return true}}}}if(this.p>=0){var f=this.aj();var b=this.u;var a=getOffset(f).top+b.scrollTop-b.style.top.substr(0,b.style.top.length-2);var d=f.scrollHeight;if(a+d-b.offsetHeight>b.scrollTop){b.scrollTop=a+d-b.offsetHeight}else{if(a'+this.e+""}else{this.ab()}return}while(this.p'+this.f+"":"";this.ac()}if(this.b){var e={};var b=this.input.value.split(this.b);for(var d=0;d=0){var d=this.aj();if(d){d.className=this.n[this.p][2]?"hintDisabledItem":"hintItem"}}this.p=a;b.className="hintActiveItem";return false};SimpleAutocomplete.prototype.aj=function(a){if(a==null){a=this.p}if(a<0){return null}return document.getElementById(this.t+"_item_"+this.p)};SimpleAutocomplete.prototype.selectItem=function(a){if(this.n[a][2]){return false}if(this.h&&this.n[a][1]==this.h){this.n.splice(a,1);elm.parentNode.removeChild(elm);this.k++;this.onChange(true);return}if(!this.b&&!this.c){this.input.value=this.n[a][1];this.hide()}else{document.getElementById(this.t+"_check_"+a).checked=this.n[a][3]=!this.n[a][3];if(this.c&&!this.c(this,a,this.n[a])){return}this.ak(a)}this.al=this.input.value;if(this.d){this.d(this,a,this.n[a])}};SimpleAutocomplete.prototype.ak=function(c){var b=this.input.value.split(this.b);for(var d=0;d=0;d--){if(b[d]==this.n[c][1]){b.splice(d,1)}}this.input.value=b.join(this.b+" ")}else{var e={};for(var d=0;d=0){this.selectItem(this.p)}return stopEvent(e,true,true)}else{if(e.keyCode==27){this.hide();return stopEvent(e,true,true)}else{return true}}}}if(this.p>=0){var f=this.aj();var b=this.u;var a=getOffset(f).top+b.scrollTop-b.style.top.substr(0,b.style.top.length-2);var d=f.scrollHeight;if(a+d-b.offsetHeight>b.scrollTop){b.scrollTop=a+d-b.offsetHeight}else{if(a