annotate NCBI Blast reference example_files/jquery_004.js @ 104:a22c909c9b57

stream output
author Jan Kanis <jan.code@jankanis.nl>
date Mon, 07 Jul 2014 11:29:10 +0200
parents 344cd76f6fd2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
1 jQuery.widget("ui.ncbiautocomplete",{options:{webserviceUrl:"/portal/utils/autocomp.fcgi",isUrlRelative:false,dictionary:"",responseFormat:"old",disableUrl:null,prefUrl:null,zIndex:1001,isEnabled:true,hasRelatedMatches:false,minLength:2,expandPauseTime:400,maxListLimit:null,isCrossDomain:false,disableCache:false,requireValidation:false,queryParameter:"q"},_create:function(){if(this.options.localData&&!this.options.dictionary)this.options.dictionary="local";this._storeTitleAttribute();this._createOptionsBox();
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
2 this._addAttributes();this._setHandlers();this._setWebServicePath();this._lastEnteredTerm="";this._setSGData()},_storeTitleAttribute:function(){this.element.data("ncbiautocompleteOriginalTitle",this.element.attr("title"))},destroy:function(){jQuery.Widget.prototype.destroy.apply(this,arguments);this.element.removeAttr("title");this._destroyAria();this._destroyHandlers();var a=this.element.data("ncbiautocompleteOriginalTitle");a&&this.element.attr("title",a)},_destroyOptionsBox:function(){jQuery.ui.ncbiautocomplete._globalOptionsList.optionsBox!=
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
3 null&&jQuery.ui.ncbiautocomplete._globalOptionsList.optionsBox.remove()},_destroyHandlers:function(){this.element.off("keypress keydown keyup cut paste")},_destroyAria:function(){this.element.removeAttr("aria-haspopup").removeAttr("aria-autocomplete").removeAttr("role").removeAttr("autocomplete")},_activeRequest:null,_keys:{up:38,down:40,enter:13,escape:27,tab:9,shift:16},_setSGData:function(){this.sgData={jsevent:"autocomplete",userTyped:"",hasScrolled:false,usedArrows:false,selectionAction:"",optionSelected:"",
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
4 optionIndex:-1,optionsCount:-1}},_addAttributes:function(){this.element.attr({title:"Use up and down arrows to choose an item from the autocomplete.","aria-haspopup":true,"aria-autocomplete":"list",role:"textbox"})},_setHandlers:function(){var a=this;jQuery(this.element).focus(function(){a._focused()}).keypress(function(c){a._keyPress(c,"press")}).keydown(function(c){a._keyPress(c,"down")}).keyup(function(c){a._keyUp(c)}).bind("cut paste",function(){a._changeFired()}).attr("AUTOCOMPLETE","OFF");var b=
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
5 jQuery(this.element)[0];b.autocomplete="off";b.AUTOCOMPLETE="OFF";jQuery(window).resize(function(){a._isActive&&a._positionOptionsBox()});jQuery(document).click(function(c){a._checkClickEvent(c)});jQuery(this._gol.optionsBox).hover(function(){if(a._isActive)a._isOptionsBoxFocused=true},function(){if(a._isActive)a._isOptionsBoxFocused=false})},_isOptionsBoxFocused:false,_createOptionsBox:function(){if(jQuery.ui.ncbiautocomplete._globalOptionsList===null){jQuery.ui.ncbiautocomplete._globalOptionsList=
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
6 {};var a=jQuery("div.grid");a=a.length===1?a:jQuery(document.body);jQuery.ui.ncbiautocomplete._globalOptionsList.optionsBox=jQuery("<div class='ui-ncbiautocomplete-holder shadow' aria-live='assertive'></div>").appendTo(a);jQuery.ui.ncbiautocomplete._globalOptionsList.optionsList=jQuery("<ul class='ui-ncbiautocomplete-options' role='listbox' aria-activedescendant=''></ul>").appendTo(jQuery(jQuery.ui.ncbiautocomplete._globalOptionsList.optionsBox));jQuery.ui.ncbiautocomplete._globalOptionsList.optionsActions=
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
7 jQuery("<div class='ui-ncbiautocomplete-actions shadow'></div>").appendTo(jQuery(jQuery.ui.ncbiautocomplete._globalOptionsList.optionsBox));jQuery.ui.ncbiautocomplete._globalOptionsList.prefLink=jQuery("<a href='#' class='ui-ncbiautocomplete-link-pref'>Preferences</a>").appendTo(jQuery(jQuery.ui.ncbiautocomplete._globalOptionsList.optionsActions));jQuery.ui.ncbiautocomplete._globalOptionsList.turnOffLink=jQuery("<a href='#' class='ui-ncbiautocomplete-link-off'>Turn off</a>").appendTo(jQuery(jQuery.ui.ncbiautocomplete._globalOptionsList.optionsActions));
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
8 jQuery.ui.ncbiautocomplete._globalOptionsList.isIE6=jQuery.browser.msie&&parseInt(jQuery.browser.version,10)<7;if(jQuery.ui.ncbiautocomplete._globalOptionsList.isIE6)jQuery.ui.ncbiautocomplete._globalOptionsList.optionsBox.iframe=jQuery("<iframe src='javascript:\"\";' class='ui-ncbiautocomplete-iframe' marginwidth='0' marginheight='0' align='bottom' scrolling='no' frameborder='0'></iframe>").appendTo(document.body)}this._gol=jQuery.ui.ncbiautocomplete._globalOptionsList},_positionOptionsBox:function(){if(this._gol.activeElement){var a=
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
9 jQuery(this.element),b=jQuery(this._gol.activeElement);a=a.attr("id")||a[0];b=b.attr("id")||b[0];a!==b&&this._hideOptions()}var c=this;if(this._gol.activeElement!==this.element){b=this.options.prefUrl!==null?"block":"none";a=this.options.disableUrl!==null?"block":"none";var e=b==="block"||a==="block"?"block":"none";jQuery(this._gol.prefLink).css("display",b).attr("href",this.options.prefUrl).unbind("click").click(function(){c._prefLinkClick()});jQuery(this._gol.turnOffLink).css("display",a).unbind("click").click(function(m){c.turnOff();
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
10 m.preventDefault()});jQuery(this._gol.optionsActions).css("display",e);jQuery(this._gol.optionsActions).children(":nth-child(2)").addClass("ui-ncbiautocomplete-link-pref-right")}else this._gol.activeElement=this.element;e=this.element;var d=jQuery(this._gol.optionsBox),f=false;if(e.parent().hasClass("jig-ncbiclearbutton-wrap")){e=e.parent();f=true;d.addClass("ui-ncbiautocomplete-holder-clearfix")}else d.removeClass("ui-ncbiautocomplete-holder-clearfix");b=e.outerWidth();a=e.outerHeight();e=e.offset();
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
11 var i,k,h;if(jQuery.browser.msie)h=k=i=0;else{i=parseInt(d.css("borderLeftWidth"),10);k=parseInt(d.css("borderRightWidth"),10);h=f?0:-1}d.css("top",e.top+a+(f?-1:-2)+"px").css("left",e.left+"px").width(b-i-k+h+"px");f=parseInt(this.options.zIndex,10);d.css("zIndex",f);d=jQuery(this._gol.optionsList);d[0].onscroll=function(){};d.scrollTop(0);d[0].onscroll=function(){c.sgData.hasScrolled=true};if(this._gol.isIE6){d=jQuery(this._gol.optionsBox.iframe);d.css("top",e.top+a+"px").css("left",e.left+"px").width(b-
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
12 i-k+h+"px");d.css("zIndex",f-1)}},_isActive:false,_focused:function(){this._gol.activeElement!==this.element&&this._hideOptions();this._setActivedescendant();this._positionOptionsBox();if(this.options.isEnabled){this._isActive=true;this._hasBeenEscaped=false}this.options.minLength===0&&this.options.localData&&this._keyUp({})},_lastEnteredTerm:null,_isCached:false,_hasBeenEscaped:false,_lastKeyPressDwnUpScroll:new Date,_lastFoundMatch:null,_findMatchInCache:function(a){this._lastFoundMatch=null;if(typeof this._localCache[this.options.dictionary]===
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
13 "undefined")return false;var b="l"+(this.options.maxListLimit||"n");if(typeof this._localCache[this.options.dictionary][b]==="undefined")return false;for(var c=0;a.length>1||c<10;){a=a.substr(0,a.length-1);var e=this._localCache[this.options.dictionary][b][a];if(e)if(e.isCompleteList){this._lastFoundMatch=a;return true}else break;c++}return false},_cloneMatchObject:function(a){var b={};b.matchedText=a.matchedText.toString();b.matches=a.matches?a.matches.slice():[];b.isCompleteList=a.isCompleteList===
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
14 true;return b},_timerTriggerEnterEvent:null,_clearTriggerEnterEvent:function(){this._timerTriggerEnterEvent=null},_triggerEnterEvent:function(){var a=this;if(!this._timerTriggerEnterEvent){this._timerTriggerEnterEvent=window.setTimeout(function(){a._clearTriggerEnterEvent()},50);this.element.trigger("ncbiautocompleteenter",this.sgData);this.element.trigger("ncbiautocompletechange",this.sgData);this._sgSend()}},_triggerTabEvent:function(){this.element.trigger("ncbiautocompletetab",this.sgData);this.element.trigger("ncbiautocompletechange",
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
15 this.sgData);this._sgSend()},_keyPress:function(a,b){var c=false,e=this;if(a.keyCode===this._keys.enter||a.keyCode===this._keys.tab){var d=a.keyCode===this._keys.enter,f=false;if(this._isActive&&this.isOptionsBoxOpen())if(this._currIndex===this.options.maxListLimit&&jQuery("li:eq("+this._currIndex+")",this._gol.optionsList).hasClass("ui-ncbiautocomplete-show-more")){this._hideOptions(true);this._gotoShowAll()}else if(this.sgData.optionSelected===jQuery(this.element).val()){f=d;if(!this._timerTriggerEnterEvent){this.sgData.selectionAction=
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
16 d?"enter":"tab";this.element.attr("valueId",this.element.attr("_optValue")||null);if(d)this._triggerEnterEvent();else{this._sentTab||this._triggerTabEvent();this._sentTab=true;window.setTimeout(function(){e._sentTab=false},10)}}this._hideOptions(true);if(d){a.stopPropagation();a.preventDefault();return false}}else a.keyCode===this._keys.tab&&this._hideOptions(true);else if(a.keyCode===this._keys.tab)if(!this._tabCalled){this._hideOptions(true);this._tabCalled=true;window.setTimeout(function(){e._tabCalled=
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
17 false},10)}if(d&&!f){this._hideOptions(true);this._triggerEnterEvent()}}else if(jQuery(this.element).val().length===0&&!this.options.localData)this._hideOptions(true);else if(a.keyCode===this._keys.up){c=true;this._scrollUpDownRateLimiter(-1)}else if(a.keyCode===this._keys.down&&!a.shiftKey){if(jQuery(this.element).val().length>=this.options.minLength&&!this.isOptionsBoxOpen()){this._reopenOptions=true;c=false;return}this._reopenOptions=false;c=true;this._scrollUpDownRateLimiter(1)}if(!this._lastKeyAction||
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
18 b===this._lastKeyAction){this._lastKeyAction=b;this._prevWasArrow=this._usedArrow;this._usedArrow=c}},_scrollUpDownRateLimiter:function(a){if(!(new Date-this._lastKeyPressDwnUpScroll<90)){this._moveSelection(a);this._lastKeyPressDwnUpScroll=new Date}},_checkArrowSelection:function(a){if(this._prevWasArrow&&a.keyCode!==this._keys.down&&a.keyCode!==this._keys.up&&a.keyCode!==this._keys.tab&&a.keyCode!==this._keys.enter&&this._isActive&&this.isOptionsBoxOpen()){this.sgData.selectionAction="arrows";typeof ncbi!==
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
19 "undefined"&&ncbi.sg&&ncbi.sg.ping&&ncbi.sg.ping(this.sgData,false);this._usedArrow=this._prevWasArrow=false}},_keyUp:function(a){if(!(!this.options.isEnabled||this._hasBeenEscaped)){this._checkArrowSelection(a);var b=jQuery(this.element).val().toLowerCase().replace(/^\s+/,"").replace(/\s+$/," "),c="l"+(this.options.maxListLimit||"n");if(!((a.keyCode===this._keys.up||a.keyCode===this._keys.down||a.keyCode===this._keys.enter)&&!this._reopenOptions))if(a.keyCode===this._keys.tab&&this._isOptionsBoxFocused){this._isActive=
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
20 this._isOptionsBoxFocused=false;a.type!=="keyup"&&this._hideOptions(true)}else if(a.keyCode===this._keys.escape){this._isActive=this._isOptionsBoxFocused=false;this._hasBeenEscaped=true;this._hideOptions(true)}else if(!(this._lastEnteredTerm===b||a.keyCode===this._keys.shift))if(this._localCache[this.options.dictionary]&&this._localCache[this.options.dictionary][c]&&this._localCache[this.options.dictionary][c][b]){this._isActive=true;this._resetValueId(b);this._lastEnteredTerm=b;this._displayOptions(this._localCache[this.options.dictionary][c][b])}else if(this._isCached&&
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
21 this._findMatchInCache(b)){this._isActive=true;this._localCache[this.options.dictionary][c][b]=this._cloneMatchObject(this._localCache[this.options.dictionary][c][this._lastFoundMatch]);this._resetValueId(b);this._lastEnteredTerm=b;this._filteredCache(b)}else if(b.length>=this.options.minLength&&this.options.localData){if(!this._localCache||!this._localCache[this.options.dictionary]||!this._localCache[this.options.dictionary][c]||!this._localCache[this.options.dictionary][c]["*_*_local_*_*"])this._putInCache({matchedText:"*_*_local_*_*",
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
22 matches:this.options.localData.slice(),isCompleteList:true},"*_*_local_*_*");this._isActive=true;this._localCache[this.options.dictionary][c][b]=this._cloneMatchObject(this._localCache[this.options.dictionary][c]["*_*_local_*_*"]);this._resetValueId(b);this._lastEnteredTerm=b;this._filteredCache(b)}else if(b.length>=this.options.minLength&&this.options.webserviceUrl){if(!this._isActive){this._isActive=true;this._focused()}if(this._lastEnteredTerm!==b){this._resetValueId(b);this._lastEnteredTerm=b;
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
23 this._fecthOptions(b)}}else{this._resetValueId(b);this._hideOptions()}}},_resetValueId:function(a){this._lastEnteredTerm&&this._lastEnteredTerm.toLowerCase()===a||this._lastTextInTextbox&&this._lastTextInTextbox.toLowerCase()===a||this.element.attr("valueId",null)},_changeFired:function(){this._lastEnteredTerm!==this.element.val()&&this._resetValueId()},_webSerivcePath:null,_setWebServicePath:function(){var a=this.options.webserviceUrl;if(a){var b="";if(this.options.isCrossDomain)this._webSerivcePath=
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
24 "http://www.ncbi.nlm.nih.gov/portal/utils/autocomp.fcgi";else{if(!this.options.isUrlRelative){b=window.location.protocol+"//"+window.location.host;if(a.charAt(0)!=="/")a="/"+a}this._webSerivcePath=b+a}}},_fecthOptions:function(a){this._activeRequest!==null&&this._activeRequest.abort();var b=this,c=this.options.responseFormat==="old"?"text":"json",e={dict:this.options.dictionary};e[this.options.queryParameter]=a;if(this.options.isCrossDomain){this._addGlobalListener("NSuggest_CreateData");jQuery.ajax({url:this._webSerivcePath,
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
25 dataType:"script",data:e,cache:true})}else this._activeRequest=jQuery.get(this._webSerivcePath,e,function(d,f){b._handleResponse(d,f)},c)},_validSeverCall:function(a){var b=false,c;if(this.options.isCrossDomain){typeof console!=="undefined"&&console.warn&&console.warn("Can not do this test with cross domain calls");return false}else if(this.options.dictionary.length>0){var e=this.options.responseFormat==="old"?"text":"json";c={dict:this.options.dictionary};c[this.options.queryParameter]=a;c=jQuery.ajax({url:this._webSerivcePath,
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
26 data:c,async:false,dataTypeString:e});if(c.status===200){c=c.responseText;b="NSuggest_CreateData_test"+(new Date).getTime();this._addGlobalListener(b,true);c=eval(c.replace("NSuggest_CreateData",b));window[b]=null;b=this._isValidCheck(a,c.matches)}}return b},_handleResponse:function(a,b){this._activeRequest=null;if(b==="success")if(this.options.responseProcessor)this._customFormat(a);else this.options.responseFormat==="old"?this._oldFormat(a):this._displayOptions(a);else this.turnOff()},_addGlobalListener:function(a,
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
27 b){var c=this;window[a]=function(e,d,f){e={matchedText:e,matches:d,isCompleteList:f===1};if(b)return e;else c._displayOptions(e)}},_oldFormat:function(a){if(a.indexOf("_dictionary_error")!==-1)this.turnOff(true);else if(jQuery.trim(a).indexOf("NSuggest_CreateData")!==-1){this._addGlobalListener("NSuggest_CreateData_new");eval(a.replace("NSuggest_CreateData","NSuggest_CreateData_new"))}else this._hideOptions()},_localCache:{},_putInCache:function(a,b){if(!this.options.disableCache){var c="l"+(this.options.maxListLimit||
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
28 "n");this._localCache[this.options.dictionary]||(this._localCache[this.options.dictionary]={});this._localCache[this.options.dictionary][c]||(this._localCache[this.options.dictionary][c]={});this._localCache[this.options.dictionary][c][b||this._lastEnteredTerm]||(this._localCache[this.options.dictionary][c][b||this._lastEnteredTerm]=a)}},_setActivedescendant:function(){var a=this.element.attr("id");if(!a){a=jQuery.ui.jig._generateId("ncbiautocomplete");this.element.attr("id",a)}jQuery(this._gol.optionsBox).find("ul:eq(0)").attr("aria-activedescendant",
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
29 a)},_displayOptions:function(a){this._setActivedescendant();this._putInCache(a);var b=a.matchedText,c=a.matches||[];if(b!==this._lastEnteredTerm){a.isCompleteList=true;this._filteredCache(this._lastEnteredTerm,a)}else{this.sgData.userTyped=this._lastEnteredTerm;this.sgData.optionsCount=c;this._positionOptionsBox();var e=this;if(b==="_dictionary_error")this.turnOff(true);else{this._isCached=a.isCompleteList;b=a.previousFormat;if(!b){var d=this.options.maxListLimit;b=0;var f;if(d===null||c.length<=
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
30 d)f=c.length;else{f=d;b=c.length-f}d=(this._lastEnteredTerm||"").replace(/([\^\$\\\?\(\)\[\]\*\+\{\}\|\/\.\,])/g,"\\$1");var i=new RegExp("("+d+")","i");d=new Array(c.length);var k=this.options.hasRelatedMatches;for(f=f-1;f>=0;f--){var h=c[f],m="",q=h.indexOf("@");if(q!==-1){m='valueId="'+h.substr(q+1)+'"';h=h.substr(0,q);k=true}d[f]="<li role='menuitem' "+m+">"+h.replace(i,"<span>$1</span>").replace(/\\"/g,'"')+"</li>"}b>0&&d.push("<li class='ui-ncbiautocomplete-show-more' role='menuitem' moreOption='true'>See all results</li>");
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
31 b=d.join("");if(d.length===0||!k&&b.indexOf("<span>")===-1){this._hideOptions();return}a.previousFormat=b}c=jQuery(this._gol.optionsBox);a=jQuery(this._gol.optionsList);a.scrollTop(0);a.html(b);if(c.css("display")!=="block"&&this._isActive){c.css("display","block");if(this._gol.isIE6){b=jQuery(this._gol.optionsBox.iframe).css("display","block");b.height(b.height()+jQuery(this._gol.optionsActions).height())}}else this._isActive||this._hideOptions();b=jQuery(".ui-ncbiautocomplete-options li");d=(b.eq(0).outerHeight()||
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
32 20)*b.length;b.closest(".ui-ncbiautocomplete-holder").height(d).css("min-height",d+"px");b.closest(".ui-ncbiautocomplete-options").height(d).css("overflow-y","hidden");b=c.width();jQuery("li",a).hover(function(){e._addHightlightMouse(this)},function(){e._removeHighlight("mouse")}).click(function(){e._optionClicked(this);return false});jQuery(a).mouseleave(function(){e._removeHighlight("mouse");e._resetCurrentIndex()});this._resetCurrentIndex();c=jQuery("li",c);b=jQuery(this._gol.optionsBox).width();
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
33 var l=jQuery.browser.msie&&!this._gol.isIE6||jQuery.browser.safari||jQuery.browser.opera;d=c.eq(0);parseFloat(d.css("padding-left"));k=d.html();d.html("<span>MMMMMMMMM.</span>");i=d.children("span:first").width()/10;d.html("<span>&hellip;<span>");d.children("span:first").width();d.html(k);var r=a.width(),y=Math.floor(b/i);c.each(function(){var j=jQuery(this);j.css("white-space","nowrap");var n=j.html();j.attr("fullText",n).attr("acValue",n.replace(/<\/?span>/gi,""));if(j.width()/j.attr("acValue").length<
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
34 9)if(l)j.attr("partialText",j.html()).attr("isIEExpand",true).css("width",r-28+"px");else{var t=n.toLowerCase().indexOf("<span>"),u=n.toLowerCase().indexOf("</span>"),z=function(g){var o=false;if(g>=t&&g<t+6){g=g-t;g=t+g;o=true}if(g>=u&&g<u+7){g=g-u;g=u+g}return{cutLoc:g,addSpan:o}},x=function(g,o,v,A,s){n.indexOf("Journal of magnetic");g=z(g);var p=n.substr(0,g.cutLoc)+(g.addCloseSpan?"</span>":"")+"&hellip;";j.html(p);if(p===A){if(j.height()!==w&&typeof s!=="undefined")p=s;j.attr("partialText",
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
35 p).css("white-space","nowrap")}else if(j.height()===w){o=p.toString()+"";s=Math.floor((g.cutLoc+v)/2);x(s,g.cutLoc,v,p,o)}else{v=Math.floor((parseInt(g.cutLoc,10)+parseInt(o,10))/2);x(v,o,g.cutLoc,p,s)}};j.css("white-space","normal").css("width",r-22+"px");var B=j.height();j.html(".");var w=j.height();j.html(n);B>w&&x(y,0,n.length)}});a.scrollTop(0);this._removeHighlight("mouse");this._hideOptionsIfOffPage()}}},_filteredCache:function(a,b){var c=true,e="l"+(this.options.maxListLimit||"n");if(a===
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
36 null)c=false;else{if(b){b=b;if(typeof this._localCache[this.options.dictionary]==="undefined")this._localCache[this.options.dictionary]={};else if(typeof this._localCache[this.options.dictionary][e]==="undefined")this._localCache[this.options.dictionary][e]={}}else b=this._localCache[this.options.dictionary][e][a];b.matchedText=a;var d=this.options.minLength===0&&a.length===0;if(!this.options.hasRelatedMatches){c=a.replace(/([\^\$\\\?\(\)\[\]\*\+\{\}\|\/\.\,])/g,"\\$1");c=new RegExp(c,"ig");for(var f=
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
37 b.matches.join("!!!~~~!!!").split("!!!~~~!!!"),i=f.length-1;i>=0;i--)!d&&f[i].match(c)===null&&f.splice(i,1);b.matches=f;this._localCache[this.options.dictionary][e][a]=b;c=f.length>0}}c?this._displayOptions(this._localCache[this.options.dictionary][e][a]):this._hideOptions()},_removeHighlight:function(a){if(!(a==="mouse"&&new Date-this._lastKeyPressDwnUpScroll<100)){var b=this;jQuery("li",this._gol.optionsList).removeClass("ui-ncbiautocomplete-options-high").each(function(){b._collapseOption(this)})}},
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
38 _addHightlightMouse:function(a){if(new Date-this._lastKeyPressDwnUpScroll>100){this._resetCurrentIndex();this._currIndex=jQuery(a).prevAll("li").length;this._addHightlight(a)}},_addHightlight:function(a){this._removeHighlight();jQuery(a).addClass("ui-ncbiautocomplete-options-high");var b=this;this._expandTimer&&window.clearTimeout(this._expandTimer);this._expandTimer=window.setTimeout(function(){b._expandOption(a)},this.options.expandPauseTime)},_expandOption:function(a){if(jQuery(a).hasClass("ui-ncbiautocomplete-options-high")){a=
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
39 jQuery(a).attr("isExpanded",true);var b=a.attr("fullText");if(a.html()!==b||a.attr("isIEExpand")){a.html(b).css("text-overflow","").css("white-space","normal").css("-o-text-overflow","");this._scrollIntoView()}}},_collapseOption:function(a){a=jQuery(a);a.attr("isIEExpand")?a.css("text-overflow","ellipsis").css("white-space","nowrap").css("-o-text-overflow","ellipsis"):a.css("white-space","nowrap").html(a.attr("partialText"))},_optionClicked:function(a){a=jQuery(a);if(a.hasClass("ui-ncbiautocomplete-show-more"))this._gotoShowAll();
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
40 else{var b=this._cleanUpSelectionText(a);a=a.attr("valueId")||null;this.sgData.optionSelected=b;this.sgData.optionIndex=this._currIndex;this.sgData.valueId=a;this.sgData.selectionAction="click";this._sgSend();b=jQuery(this.element).val(b);b.attr("valueid",a);b.trigger("ncbiautocompleteoptionclick",this.sgData);b.trigger("ncbiautocompletechange",this.sgData)}this._isOptionsBoxFocused=false;this._hideOptions()},isOptionsBoxOpen:function(){return jQuery(this._gol.optionsBox).css("display")==="block"},
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
41 _hideOptions:function(a){this._gol.activeElement=null;if(!(this._isOptionsBoxFocused&&!a)){var b=jQuery(this._gol.optionsBox);a&&jQuery(this._gol.optionsBox).css("display","none");b.attr("aria-activedescendant")===this.element.attr("id")&&b.attr("aria-activedescendant","");this._gol.isIE6&&jQuery(this._gol.optionsBox.iframe).css("display","none");this._resetCurrentIndex();this._isActive=false;this._lastEnteredTerm=null;b=jQuery(this._gol.optionsBox);var c=jQuery(this._gol.optionsList);b.css("display",
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
42 "none");c.html("");this._lastTextInTextbox=b=this.element.val();if(this.options.requireValidation&&b.length>0&&this.options.isEnabled&&(!this.element.is(":focus")||a))this._trigger((b.length<this.options.minLength?false:this.isInDictionary(b))?"validselection":"invalidselection")}},_setTextCursorToEnd:function(a){var b=this.element;jQuery(b).val(a);if(b.createTextRange){a=b.createTextRange();a.moveStart("character",b.value.length);a.collapse();a.select()}},_resetCurrentIndex:function(){this._currIndex=
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
43 -1},_cleanUpSelectionText:function(a){return jQuery.trim(a.attr("acValue")).replace(/&amp;/gi,"&").replace(/\\"/g,'"')},_currIndex:-1,_moveSelection:function(a){if(this._isActive){this.sgData.usedArrows=true;var b=jQuery("li",this._gol.optionsList).length;this._currIndex+=a;this._removeHighlight();a=this._lastEnteredTerm;var c="";if(!(a===null||a.length<this.options.minLength)){if(this._currIndex<0||this._currIndex>=b)this._currIndex=this._currIndex===-2?b-1:-1;if(this._currIndex!==-1){b=jQuery("li:eq("+
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
44 this._currIndex+")",this._gol.optionsList);this._addHightlight(b);if(this._currIndex===this.options.maxListLimit){this.sgData.optionSelected="";this.sgData.valueId=""}else{a=this._cleanUpSelectionText(b);c=b.attr("valueId")||null;this.sgData.optionSelected=a;this.sgData.valueId=c}}else{this.sgData.optionSelected="";this.sgData.valueId=""}this.element.attr("_optValue",c);this.element.attr("valueId",c);this._setTextCursorToEnd(a);this._scrollIntoView();this.sgData.optionIndex=this._currIndex}}},_scrollIntoView:function(){var a=
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
45 jQuery("li:eq("+this._currIndex+")",this._gol.optionsList);if(a.length!==0){var b=jQuery(this._gol.optionsList),c=b.height(),e=b.scrollTop(),d=a[0].offsetTop;a=a.height();if(d-c+a>e){e=jQuery("li:eq("+(this._currIndex+1)+")",this._gol.optionsList);b.scrollTop((e.length===1?e[0].offsetTop:d+a+10)-c)}else d<e&&b.scrollTop(d)}},enableAutocomnplete:function(){this.options.isEnabled=true},disableAutocomnplete:function(){this.disableAutocomplete()},disableAutocomplete:function(){this._isOptionsBoxFocused=
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
46 this.options.isEnabled=false;this._hideOptions()},turnOff:function(a){this.disableAutocomplete();var b=this.element.data("ncbiautocompleteOriginalTitle");b&&this.element.attr("title",b);if(!a){typeof ncbi!=="undefined"&&ncbi.sg&&ncbi.sg.ping&&ncbi.sg.ping(this.element[0],"autocompleteoffclick","dictionary="+this.options.dictionary);this.element.trigger("ncbiautocompletedisableclicked");a=this.options.disableUrl;if(a!==null&&a.length>0){b=jQuery.ui.jig._getFncFromStr(a);typeof b==="function"?b():jQuery.get(a)}}},
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
47 _prefLinkClick:function(){typeof ncbi!=="undefined"&&ncbi.sg&&ncbi.sg.ping&&ncbi.sg.ping(this.element[0],"autocompleteprefclick","dictionary="+this.options.dictionary)},_checkClickEvent:function(a){if(this._isActive)if(jQuery(this.element)[0]!=a.target){this._isActive=this._isOptionsBoxFocused=false;this._hideOptions()}},_sgSend:function(){typeof ncbi!=="undefined"&&typeof ncbi.sg!=="undefined"&&typeof ncbi.sg.ping!=="undefined"&&ncbi.sg.ping(this.sgData,false)},getSgData:function(){return this.sgData},
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
48 _gotoShowAll:function(){var a=jQuery(this.element),b=a.val();a.trigger("ncbiautocompleteshowall",{value:b,dictionary:this.options.dictionary})},_hideOptionsIfOffPage:function(){if(this.options.maxListLimit){var a=this,b=jQuery(".ui-ncbiautocomplete-options li"),c=b.eq(0).outerHeight()||20,e=jQuery(this._gol.optionsBox),d=jQuery(window).height(),f=e.position().top,i=f+e.outerHeight()-(document.body.scrollTop||document.documentElement.scrollTop||window.pageYOffset||0);if(b.last().hasClass("ui-ncbiautocomplete-show-more")){var k=
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
49 f+"-"+d+"-"+i;if(!this.choppedDetails)this.choppedDetails={};var h=this.choppedDetails[k],m=0,q=function(){i=f+e.outerHeight()-(document.body.scrollTop||document.documentElement.scrollTop||window.pageYOffset||0);if(i>d){b=jQuery(".ui-ncbiautocomplete-options li");var r=b.length-2;if(r>=0){b.eq(r).remove();sz=c*(b.length-1);b.closest(".ui-ncbiautocomplete-holder").height(sz).css("min-height",sz+"px");b.closest(".ui-ncbiautocomplete-options").height(sz).css("overflow-y","hidden");m++;q()}}else a.choppedDetails[k].count=
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
50 m};if(h){var l=h.count;if(l>0){h=2*h.length-l-b.length-2;b.filter(":lt("+(b.length-1)+")").filter(":gt("+h+")").remove();b=jQuery(".ui-ncbiautocomplete-options li");sz=c*b.length;b.closest(".ui-ncbiautocomplete-holder").height(sz).css("min-height",sz+"px");b.closest(".ui-ncbiautocomplete-options").height(sz).css("overflow-y","hidden")}m=l}else this.choppedDetails[k]={count:0,length:b.length};q()}else{l=Math.floor((d-f)/c)*c;h=b.length*c;if(l>h)l=h;b.closest(".ui-ncbiautocomplete-holder").height(l).css("min-height",
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
51 l+"px");b.closest(".ui-ncbiautocomplete-options").height(l).css("overflow-y","auto")}}},isValid:function(){return this.isInDictionary(this.element.val())},isInDictionary:function(a){var b=false;if(a&&a.length>=this.options.minLength&&this.options.dictionary&&this.options.dictionary.length>0&&this.options.isEnabled){var c=false,e="l"+(this.options.maxListLimit||"n"),d=a.toLowerCase();if(this._localCache[this.options.dictionary]&&this._localCache[this.options.dictionary][e]){e=this._localCache[this.options.dictionary][e];
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
52 c=true;if(e[d])b=this._isValidCheck(d,e[d].matches);else for(var f in e)if(b=this._isValidCheck(d,e[f].matches))break}if(!b&&!c)b=this._validSeverCall(a)}return b},_isValidCheck:function(a,b){var c=false;if(b){c=jQuery.inArray(a.toLowerCase(),b)>-1;if(!c){var e=new RegExp("(^|@)("+a.toLowerCase()+")(@|$)","i");jQuery.each(b,function(d,f){if(f.match(e)){c=true;return false}})}}return c},_customFormat:function(a){if(typeof this.options.responseProcessor==="string")this.options.responseProcessor=jQuery.ui.jig._getFncFromStr(this.options.responseProcessor);
bad241dc701f add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
53 this._displayOptions({matchedText:this._lastEnteredTerm,matches:this.options.responseProcessor.call(this,a),isCompleteList:0})}});jQuery.ui.ncbiautocomplete._globalOptionsList=null;