|
WT_DECLARE_WT_MEMBER(1,JavaScriptConstructor,"WSuggestionPopup",function(t,e,z,F,r,u,A){function q(a){return $(a).hasClass("Wt-suggest-onedit")||$(a).hasClass("Wt-suggest-dropdown")}function c(){return e.style.display!="none"}function g(a){e.style.display="block";d.positionAtWidget(e.id,a.id,d.Vertical)}function h(a){a=d.target(a||window.event);if(!d.hasTag(a,"UL")){for(;a&&!d.hasTag(a,"LI");)a=a.parentNode;a&&n(a)}}function n(a){var b=a.firstChild.firstChild,l=d.getElement(f),m=b.innerHTML;b=b.getAttribute("sug");
|
|
l.focus();z(l,m,b);t.emit(e,"select",a.id,l.id);i();f=null}function i(){e.style.display="none";if(f!=null&&B!=null){d.getElement(f).onkeydown=B;B=null}}function C(a,b){for(a=b?a.nextSibling:a.previousSibling;a;a=b?a.nextSibling:a.previousSibling)if(d.hasTag(a,"LI"))if(a.style.display!="none")return a;return null}function v(a){var b=a.parentNode;if(a.offsetTop+a.offsetHeight>b.scrollTop+b.clientHeight)b.scrollTop=a.offsetTop+a.offsetHeight-b.clientHeight;else if(a.offsetTop<b.scrollTop)b.scrollTop=
|
|
a.offsetTop}$(".Wt-domRoot").add(e);jQuery.data(e,"obj",this);var s=this,d=t.WT,o=null,f=null,J=false,D=null,K=null,L=u,E=null,G=null,w=false;this.defaultValue=A;var B=null;this.showPopup=function(a){e.style.display="block";G=o=null;B=a.onkeydown;a.onkeydown=function(b){s.editKeyDown(this,b||window.event)}};this.editMouseMove=function(a,b){if(q(a))a.style.cursor=d.widgetCoordinates(a,b).x>a.offsetWidth-16?"default":""};this.showAt=function(a){i();f=a.id;w=true;s.refilter()};this.editClick=function(a,
|
|
b){if(q(a))if(d.widgetCoordinates(a,b).x>a.offsetWidth-16)if(f!=a.id||!c())s.showAt(a);else{i();f=null}};this.editKeyDown=function(a,b){if(!q(a))return true;if(f!=a.id)if($(a).hasClass("Wt-suggest-onedit")){f=a.id;w=false}else if($(a).hasClass("Wt-suggest-dropdown")&&b.keyCode==40){f=a.id;w=true}else{f=null;return true}var l=o?d.getElement(o):null;if(c()&&l)if(b.keyCode==13||b.keyCode==9){n(l);d.cancelEvent(b);setTimeout(function(){a.focus()},0);return false}else if(b.keyCode==40||b.keyCode==38||
|
|
b.keyCode==34||b.keyCode==33){if(b.type.toUpperCase()=="KEYDOWN"){J=true;d.cancelEvent(b,d.CancelDefaultAction)}if(b.type.toUpperCase()=="KEYPRESS"&&J==true){d.cancelEvent(b);return false}var m=l,p=b.keyCode==40||b.keyCode==34;b=b.keyCode==34||b.keyCode==33?e.clientHeight/l.offsetHeight:1;var j;for(j=0;m&&j<b;++j){var x=C(m,p);if(!x)break;m=x}if(m&&d.hasTag(m,"LI")){l.className="";m.className="active";o=m.id}return false}return b.keyCode!=13&&b.keyCode!=9};this.filtered=function(a,b){D=a;L=b;s.refilter()};
|
|
this.refilter=function(){var a=o?d.getElement(o):null,b=d.getElement(f),l=F(b),m=e.childNodes,p=l(null);G=b.value;if(r>0||u)if(p.length<r&&!w){i();return}else{var j=L ?p:p.substring(0,Math.max(D!==null?D.length:0,r));if(j!=D)if(j!=K){K=j;t.emit(e,"filter",j)}}var x=j=null;p=w&&p.length==0;var y,M;y=0;for(M=m.length;y<M;++y){var k=m[y];if(d.hasTag(k,"LI")){var H=k.firstChild;if(k.orig==null)k.orig=H.firstChild.innerHTML;var I=l(k.orig),N=p||I.match;if(I.suggestion!=H.firstChild.innerHTML)H.firstChild.innerHTML=
|
|
I.suggestion;if(N){if(k.style.display!="")k.style.display="";if(j==null)j=k;if(y==this.defaultValue)x=k}else if(k.style.display!="none")k.style.display="none";if(k.className!="")k.className=""}}if(j==null)i();else{if(!c()){g(b);s.showPopup(b);a=null}if(!a||a.style.display=="none"){a=x||j;a.parentNode.scrollTop=0;o=a.id}a.className="active";v(a)}};this.editKeyUp=function(a,b){if(f!=null)if(q(a))if(!(!c()&&(b.keyCode==13||b.keyCode==9)))if(b.keyCode==27||b.keyCode==37||b.keyCode==39)i();else if(a.value!=
|
|
G)s.refilter();else(a=o?d.getElement(o):null)&&v(a)};e.onclick=h;e.onscroll=function(){if(E){clearTimeout(E);var a=d.getElement(f);a&&a.focus()}};this.delayHide=function(a){E=setTimeout(function(){E=null;if(e&&(a==null||f==a.id))i()},300)}});
|
|
WT_DECLARE_WT_MEMBER(2,JavaScriptConstructor,"WSuggestionPopupStdMatcher",function(t,e,z,F,r,u,A){function q(c){var g=c.value;c=c.selectionStart?c.selectionStart:g.length;for(var h=z?g.lastIndexOf(z,c-1)+1:0;h<c&&F.indexOf(g.charAt(h))!=-1;)++h;return{start:h,end:c}}this.match=function(c){var g=q(c),h=c.value.substring(g.start,g.end),n;n=u.length==0?r.length!=0?"(^|(?:["+r+"]))":"(^)":"("+u+")";n+="("+h.replace(new RegExp("([\\^\\\\\\][\\-.$*+?()|{}])","g"),"\\$1")+")";n=new RegExp(n,"gi");return function(i){if(!i)return h;
|
|
var C=false;if(h.length){var v=i.replace(n,"$1"+t+"$2"+e);if(v!=i){C=true;i=v}}return{match:C,suggestion:i}}};this.replace=function(c,g,h){g=q(c);var n=c.value.substring(0,g.start)+h+A;if(g.end<c.value.length)n+=c.value.substring(g.end,c.value.length);c.value=n;if(c.selectionStart){c.selectionStart=g.start+h.length+A.length;c.selectionEnd=c.selectionStart}}});
|