Mercurial > repos > jankanis > blast2html
annotate NCBI Blast reference example_files/jquery_007.js @ 42:1d49bce1e4bb
update version
author | Jan Kanis <jan.code@jankanis.nl> |
---|---|
date | Mon, 19 May 2014 18:34:25 +0200 |
parents | 344cd76f6fd2 |
children |
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.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(); |
bad241dc701f
add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff
changeset
|
2 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=== |
bad241dc701f
add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff
changeset
|
3 "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), |
bad241dc701f
add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff
changeset
|
4 "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(); |
bad241dc701f
add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff
changeset
|
5 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", |
bad241dc701f
add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff
changeset
|
6 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= |
bad241dc701f
add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff
changeset
|
7 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()}, |
bad241dc701f
add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff
changeset
|
8 _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= |
bad241dc701f
add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff
changeset
|
9 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()}, |
bad241dc701f
add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff
changeset
|
10 _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"); |
bad241dc701f
add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff
changeset
|
11 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)}, |
bad241dc701f
add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff
changeset
|
12 _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")}, |
bad241dc701f
add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff
changeset
|
13 _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")}, |
bad241dc701f
add example input blast xml and output html page
Jan Kanis <jan.code@jankanis.nl>
parents:
diff
changeset
|
14 selectFirstItem:function(){this.selectedOption=0;this._moveSelection(0)}}); |