view NCBI Blast reference example_files/jquery_007.js @ 120:2729c2326235

Fix for Rikilt issue 13 Hit e-value and identity% should be taken from the hsp with the highest bit score. Previously each of these values was calculated independently. Also use arrays for cover calculation instead of python lists and refactor the hit_info() code a bit.
author Jan Kanis <jan.code@jankanis.nl>
date Thu, 31 Jul 2014 16:14:36 +0200
parents 344cd76f6fd2
children
line wrap: on
line source

jQuery.widget("ui.ncbibasicmenu",{options:{defaultSelection:-1,allowMultipleSelections:false,orientation:"vertical",preventDefaultCheck:true,stopPropagationCheck:true,normalizeSubsToOneLevel:false,disableSelect:false},styles:{itemNoHilite:"ui-ncbimenu-item-no-hlt",itemSkip:"ui-ncbimenu-item-skip"},_init:function(){this._loadedOnce&&this.rescan();this._loadedOnce=true},_create:function(){this._setSelectorString();this._addClasses();this._formatList();this._addEvents();this._setUpDefaults();this._setTabIndex();
this._addAria()},rescan:function(){this._addClasses();this._setTabIndex();this._addAria();this._destroyFocusEvents();this._setUpFocusEvents()},destroy:function(){this._destroyTabIndex();this._destroyClasses();this._destroyEvents();this._destroyAria();this._destroyFormatList()},_setSelectorString:function(){var a=">";if(this.options.normalizeSubsToOneLevel){a="";this.element.addClass("oneLevel")}this._liSelector=a+"li:not(.ui-ncbimenu-item-skip)"},_addClasses:function(){this.isVert=this.options.orientation===
"vertical";var a="ui-ncbibasicmenu";this.isVert||(a+=" orientation_hort");this.element.addClass(a)},_destroyClasses:function(){this.element.removeClass("ui-ncbibasicmenu")},_setUpDefaults:function(){this.selectedOption=this.options.defaultSelection;if(this.selectedOption!==-1){var a=this.element.find(this._liSelector+">a");if(this.options.allowMultipleSelections)for(var b=0;b<this.selectedOption.length;b++)this._makeSelection(a.eq(this.selectedOption[b]),"load");else this._makeSelection(a.eq(this.selectedOption),
"load")}},_formatList:function(){},_destroyFormatList:function(){},_setTabIndex:function(){var a=this.element.find(this._liSelector+">a").attr("tabindex","-1"),b=this.element.find(this._liSelector+".selected>a");if(b.length>0)b=b.eq(0);else{var c=0;for(b=a.eq(0);b.is("."+this.styles.itemSkip+" a")&&c<a.length-1;){c+=1;b=a.eq(c)}}this.options.nested||b.removeAttr("tabindex")},_destroyTabIndex:function(){this.element.find(this._liSelector+">a").removeAttr("tabindex")},_addEvents:function(){this._setUpKeyListener();
this._setUpClickEvents();this._setUpFocusEvents();this._setUpHoverEvents()},_destroyEvents:function(){this._destroyKeyListener();this._destroyClickEvents();this._destroyFocusEvents();this._destroyHoverEvents()},_setUpKeyListener:function(){if(!this._menuKeyListener){var a=this;this._menuKeyListener=function(b){if(a.element.is(":visible"))if(a._keyPressDetected(b.keyCode)){b.preventDefault();a.options.stopPropagationCheck&&b.stopPropagation()}};jQuery(document).keydown(this._menuKeyListener)}},_destroyKeyListener:function(){if(this._menuKeyListener){jQuery(window).unbind("keydown",
this._menuKeyListener);this._menuKeyListener=null}},_setUpClickEvents:function(){var a=this;this._ulClickEvent=function(b){var c=b.srcElement||b.target;if(c){a.options.disableSelect||a._makeSelection(jQuery(c),"click");a.options.stopPropagationCheck&&b.stopPropagation();a.options.preventDefaultCheck&&jQuery(c).siblings("ul").length===1&&b.preventDefault()}};this.element.on("click.ncbibasicmenu",this._ulClickEvent)},_destroyClickEvents:function(){this.element.off("click",this._ulClickEvent)},_setUpFocusEvents:function(){var a=
this;this._focusFnc=function(){a._menuFocused(this)};this._blurFnc=function(){a._menuBlured(this)};this.element.find(this._liSelector+">a").on("blur",this._blurFnc).on("focus",this._focusFnc)},_destroyFocusEvents:function(){this.element.find(this._liSelector+">a").off("blur",this._blurFnc).off("focus",this._focusFnc)},focus:function(){this._menuFocused(null)},_menuFocused:function(a){this._lastAnchor=a;this._isFocused=true},_menuBlured:function(a){if(this._lastAnchor==a)this._isFocused=false},removeFocus:function(){this._menuBlured()},
_setUpHoverEvents:function(){var a=this;this._mouseEnterFnc=function(b){b=jQuery(b.target).closest("li");!b.hasClass(a.styles.itemNoHilite)&&!b.hasClass(a.styles.itemSkip)&&b.addClass("hover")};this.mouseLeaveFnc=function(){jQuery(this).removeClass("hover")};this.element.on("mouseenter","li",this._mouseEnterFnc).on("mouseleave","li",this.mouseLeaveFnc)},_destroyHoverEvents:function(){this.element.off("mouseenter",this._mouseEnterFnc).off("mouseleave",this.mouseLeaveFnc);this.mouseLeaveFnc=this._mouseEnterFnc=
null},_makeSelection:function(a,b){var c=a.parent("li");if(c.length===1){var d=c.hasClass("selected");this.options.allowMultipleSelections||this._removeAllSelections();if(!c.hasClass(this.styles.itemSkip)){c.hasClass(this.styles.itemNoHilite)||c[d?"removeClass":"addClass"]("selected");var e=d?"unselected":"selected";b!=="menunav"&&this._trigger(e,"x",[a,c,b]);if(b==="click"||b==="load")this.selectedOption=this.element.find(this._liSelector+".selected").index();else d||c.find(">a").focus()}}this._setTabIndex()},
_keys:{up:38,down:40,left:37,right:39,enter:13,escape:27,tab:9},_keyPressDetected:function(a){var b=this._keys,c=false;if(this._isFocused&&this.element.has(this._liSelector+">a:focus"))switch(a){case b.up:this._upDownPressed(-1);c=true;break;case b.down:this._upDownPressed(1);c=true;break;case b.left:this._leftRightPressed(-1);c=true;break;case b.right:this._leftRightPressed(1);c=true;break;case b.enter:this._enterSelected();c=false;break;case b.escape:this._escapeTyped();c=false;break;case b.tab:this._trigger("tab");
default:c=false}return c},_upDownPressed:function(a){this.isVert?this._moveSelection(a):this._trigger(a===1?"actiondown":"actionup","x",this.focusedElement())},_leftRightPressed:function(a){this.isVert?this._trigger(a===1?"actionright":"actionleft","x",this.focusedElement()):this._moveSelection(a)},focusedElement:function(){return this.selectedOption!==-1?this.element.find(this._liSelector).eq(this.selectedOption):this.element.find(this._liSelector+":has(>a:focus)")},moveSelection:function(a){this._moveSelection(a)},
_getNextIndex:function(a,b,c){a=a+b;if(a<0)a=c-1;else if(a>c-1)a=0;return a},_moveSelection:function(a){for(var b=this.element.find(this._liSelector+">a"),c=this._getNextIndex(this.selectedOption,a,b.length);b.eq(c).closest("li").hasClass(this.styles.itemSkip);)c=this._getNextIndex(c,a,b.length);this.selectedOption=c;this._makeSelection(b.eq(c),"keyboard")},removeAllSelections:function(){this.selectedOption=-1;this._removeAllSelections();this._setTabIndex()},_removeAllSelections:function(){this.element.find(this._liSelector).removeClass("selected")},
_enterSelected:function(){this._trigger("enter")},_escapeTyped:function(){this._trigger("escape","x",this.focusedElement())},_addAria:function(){var a=this.element.parents('[role="menubar"]'),b=this.element.find(this._liSelector),c=b.find(">a");this.element.attr("role",a.length===0?"menubar":"menu");b.attr("role","presentation");c.attr("role","menuitem")},_destroyAria:function(){var a=this.element.find(this._liSelector),b=a.find(">a");this.element.removeAttr("role");a.removeAttr("role");b.removeAttr("role")},
selectFirstItem:function(){this.selectedOption=0;this._moveSelection(0)}});