annotate Blast output page example trimmed_files/jquery_002.js @ 20:53cd304c5f26

Add index for multiple results; fix layout of query ruler for edge case The query ruler did not layout nicely if the last segment was too short to contain the text. For very short last segments the text is now displayed after the ruler.
author Jan Kanis <jan.code@jankanis.nl>
date Wed, 14 May 2014 16:20:29 +0200
parents ffe82516a83c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
1 (function(e){e.widget("ui.ncbitoggler",{styles:{ariaWrapper:"ui-ncbitoggler-live",groupMasterReplaceNode:"span.ui-ncbitoggler-group-replace-txt",groupMasterStateClose:"ui-ncbitoggler-group-master-to-close",groupMasterStateOpen:"ui-ncbitoggler-group-master-to-open",master:"ui-ncbitoggler",masterOpen:"ui-ncbitoggler-open",target:"ui-ncbitoggler-slave",targetOpen:"ui-ncbitoggler-slave-open",icon:"ui-icon-triangle-1-e",iconOpen:"ui-icon-triangle-1-s",iconPlusMinusBig:"ui-icon-plus-minus-big",iconPlusMinusBigOpen:"ui-icon-plus-minus-big-open",
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
2 iconArrowStop:"ui-icon-arrowthickstop-1-s",iconArrowStopOpen:"ui-icon-arrowthickstop-1-n"},options:{animation:"slide",closedAppendText:"",cookieNamePrefix:"jig-tog-rem-",indicator:"small-arrow",initOpen:false,isIcon:true,liveRegions:true,openedAppendText:"",remember:false,speed:50,targets:""},_cachedTargetData:{},_create:function(){this._setOption("disabled",false);this.appendTextNode=this.initTargetsClass=this.iconSpan=this.startOpen=this.rememberCookie=this.remember=this.cookieName=this.addedHref=
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
3 null;var a=this.element,b=a[0],c=this.styles,d=this,f=this.options.isIcon;a.data("isOpen",false);a.addClass("ui-widget ui-ncbitoggler");f||a.addClass("ui-ncbitoggler-no-icon");var g=a.attr("href");!g?(this.addedHref=true):(this.addedHref=false);this._validate(g);a.children("span.ui-ncbitoggler-master-text").length===0&&a.contents().filter(function(){return this.nodeType===3}).each(function(){var h=e(this);jQuery.trim(this.nodeValue).length>0&&h.wrap('<span class="ui-ncbitoggler-master-text"></span>')});
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
4 if(this.options.openedAppendText!==""||this.options.closedAppendText!==""){this.appendTextNode=a.children("span.ui-ncbitoggler-appended-text");if(this.appendTextNode.length===0)if(!this.initOpen){this.appendTextNode=e('<span class="ui-ncbitoggler-appended-text">'+this.options.closedAppendText+"</span>");a.find(".ui-ncbitoggler-master-text").after(this.appendTextNode)}}if(this.remember=this.options.remember||false){g=this.element.attr("id");if(!g){window.console&&console.error&&console.error("ncbitoggler: master node "+
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
5 b+" must have a unique id attribute when remembering state");return}this.cookieName=this.options.cookieNamePrefix+g;this.rememberCookie=e.cookie(this.cookieName)}if(this.startOpen=this.rememberCookie?this.rememberCookie==="open"?true:false:a.hasClass("jig-ncbitoggler-open")||a.hasClass(c.masterOpen)||this.options.initOpen?true:false){this.element.data("isOpen",true);a.removeClass(this.styles.master);a.addClass(c.masterOpen);this._targetsOpen=true}else{this.element.data("isOpen",false);a.removeClass(this.styles.masterOpen);
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
6 a.addClass(c.master)}f&&this._initMasterIcon();this.targets=this._getTargets();this.targets.addClass("ui-ncbitoggler").removeClass("ui-ncbitoggler-disabled ui-state-disabled");if(this.startOpen){this.targets.removeClass(c.target);this.targets.addClass(c.targetOpen);this.initTargetsClass=c.targetOpen}else{this.targets.removeClass(c.targetOpen);this.targets.addClass(c.target);this.initTargetsClass=c.target}this._initAria();this._doGrouping();a.click(function(h){d.toggle(h,d)});this._saveReferences()},
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
7 _getGroupMaster:function(){for(var a=this.styles,b=this.element[0].className.split(/\s+/),c=0;c<b.length;c++){var d=b[c].match(/ui-ncbitoggler-group-(.+)$/);if(d){d=d[1];var f=e("a.ui-ncbitoggler-group-open-"+d+", a.ui-ncbitoggler-group-close-"+d,this.options.contextNode);if(f.length===1){f.hasClass("ui-ncbitoggler-group-open-"+d)&&f.addClass(a.groupMasterStateOpen);f.hasClass("ui-ncbitoggler-group-close-"+d)&&f.addClass(a.groupMasterStateClose);return f}}}},_doGrouping:function(){var a=this._getGroupMaster();
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
8 if(a){var b=this,c=this.styles,d=a.data("togglers");this.element.id||e.ui.jig._generateId(this.widgetName);if(!this.element[0].id)this.element[0].id=e.ui.jig._generateId(this.widgetName);if(typeof d==="undefined"){a.data("togglers",[]);a.data("togglers").push(this.element)}else d.push(this.element);var f=a.find(c.groupMasterReplaceNode);a.click(function(g){g.preventDefault();g=a.data("togglers");g=g[g.length-1][0];if(a.hasClass(c.groupMasterStateOpen)){b.open();f.length>0&&f.text(b.options.groupMasterCloseReplaceText);
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
9 b.element[0]===g&&a.removeClass(c.groupMasterStateOpen).addClass(c.groupMasterStateClose)}else{b.close();f.length>0&&f.text(b.options.groupMasterOpenReplaceText);b.element[0]===g&&a.removeClass(c.groupMasterStateClose).addClass(c.groupMasterStateOpen)}})}},_initAria:function(){var a=this.startOpen;this.element.attr({role:"button","aria-expanded":a});this.options.liveRegions&&this.targets.each(function(){var b=e(this);b.find("table").length===0&&!b.parent("div").hasClass("ui-helper-reset")&&b.wrap('<div class="ui-helper-reset" aria-live="assertive">');
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
10 b.attr("aria-hidden",a?"false":"true")})},_validate:function(a){var b=this.element,c=["a"],d=b[0].tagName.toLowerCase();if(e.inArray(d,c)===-1)throw new Error("ncbitoggler: master node must be one of the following elements: "+c.toString());a||b.attr("href","#")},_initMasterIcon:function(){var a=this.element,b=this.styles;if(this.options.indicator=="plus-minus-big"){this.iconOpenClass=b.iconPlusMinusBigOpen;this.iconCloseClass=b.iconPlusMinusBig}else if(this.options.indicator=="arrow-stop"){this.iconOpenClass=
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
11 b.iconArrowStopOpen;this.iconCloseClass=b.iconArrowStop}else{this.iconOpenClass=b.iconOpen;this.iconCloseClass=b.icon}this.iconSpan=a.find("span.ui-icon");if(this.iconSpan.length===0){this.iconSpan=e('<span class="ui-icon"></span>');this.startOpen?this.iconSpan.addClass(this.iconOpenClass):this.iconSpan.addClass(this.iconCloseClass);a.append(this.iconSpan)}else if(this.startOpen){this.iconSpan.removeClass(this.iconCloseClass);this.iconSpan.addClass(this.iconOpenClass)}},getSlaves:function(){return this._targets},
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
12 getTargets:function(){return this.getSlaves()},_getTargets:function(){var a=this.element,b=a.attr("toggles")||a.attr("data-ncbitoggler-toggles");if(b)jQuery.ui.jig._isConsole("warn")&&console.warn('The attributes "toggles" and "data-ncbitoggler-toggles" are deprecated. Please use the "targets" attribute instead (see documentation).');else b=this.options.targets;if(b&&typeof b=="object"){b=b;a="";for(var c in b)a+=c+", ";a=a.replace(/,\s$/,"");c=e(a)}else if(b){c=e(b);if(c.length===0){this.isSibling=
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
13 false;c=b.split(/ +/);b="";for(a=0;a<c.length;a++)b+=a!==c.length-1?"#"+c[a]+",":"#"+c[a];c=e(b)}}else if(a.parent(":header").length>0){a.parent(":header").parent().css("zoom","1");this.isSibling=true;c=a.parent(":header").css("zoom","1").next()}else{this.isSibling=true;c=a.next()}return this._targets=this._normalizeTargets(c)},_normalizeTargets:function(a){var b=[];a.each(function(){var c=this,d=e(this);if(d.hasClass("ui-helper-reset"))c=d.children().get(0);b.push(c)});return ret=e(b)},_getCachedTargetData:function(a){return this._cachedTargetData[a]},
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
14 _cacheTargetData:function(a,b){this._cachedTargetData[a]=b},_openAjaxTarget:function(a,b){var c=this,d=this._getCachedTargetData(a);d?e(a).html(d):e.get(b,function(f){c._cacheTargetData(a,f);e(a).html(f)})},_openTargets:function(){if(!(this._targetsOpening||this._targetsClosing||this._targetOpen)){this._targetsOpening=true;var a=this.targets,b=this.styles;a.removeClass(b.target).addClass(b.targetOpen).attr("aria-hidden","false");var c=this.options.targets;if(typeof c=="object"){var d=this;for(targetSel in c)(function(f){d._openAjaxTarget(f,
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
15 c[f])})(targetSel)}b=this.options.openedAppendText;b!==""&&this.appendTextNode.html(b);a.css("display","");this._targetsOpening=false;this._targetsOpen=true}},_closeTargets:function(){if(!(this._targetsOpening||this._targetsClosing||!this._targetsOpen)){this._targetsClosing=true;var a=this.targets,b=this.styles;a.removeClass(b.targetOpen).addClass(b.target).attr("aria-hidden","true");b=this.options.closedAppendText;b!==""&&this.appendTextNode.html(b);a.css("display","");this._targetsOpen=this._targetsClosing=
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
16 false}},_fixHasLayout:function(a){window.setTimeout(function(){a.targets.addClass("foo").removeClass("foo")},1)},open:function(a){var b=this.element,c=this;if(!b.hasClass(this.styles.master))return b;this.updateState("open");if(this.options.animation==="slide")this.targets.slideToggle(this.options.speed,function(){c._openTargets();e.browser.msie&&c._fixHasLayout(c);b.data("isOpen",true);b.trigger("ncbitoggleropen");a&&a()});else{this._openTargets();e.browser.msie&&c._fixHasLayout(c);b.data("isOpen",
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
17 true);b.trigger("ncbitoggleropen");a&&a()}this._updateReferences("open");return b},close:function(a){var b=this.element,c=this;if(!b.hasClass(this.styles.masterOpen))return b;this.updateState("closed");if(this.options.animation==="slide")this.targets.slideToggle(this.options.speed,function(){c._closeTargets();b.trigger("ncbitogglerclosed").trigger("ncbitogglerclose");b.data("isOpen",false);a&&a()});else{this._closeTargets();b.data("isOpen",false);b.trigger("ncbitogglerclosed");a&&a()}this._updateReferences("closed");
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
18 return b},toggle:function(a,b,c){var d=arguments.length;if(d===0||d===1){b=this;if(d===1)c=arguments[0]}else a.preventDefault();this.element.hasClass(this.styles.master)?b.open(c):b.close(c)},updateState:function(a){var b=this.element;a||(a=b.hasClass(styles.master)?"open":"closed");var c=this.styles.master,d=this.styles.masterOpen,f=this.iconCloseClass,g=this.iconOpenClass;if(a=="closed"){c=this.styles.masterOpen;d=this.styles.master;f=this.iconOpenClass;g=this.iconCloseClass}b.removeClass(c).addClass(d).attr("aria-expanded",
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
19 a=="closed"?"false":"true");this.options.isIcon&&this.iconSpan.removeClass(f).addClass(g);this.remember&&e.cookie(this.cookieName,a)},_removeHandlers:function(){this.element.unbind("click")},destroy:function(){e.Widget.prototype.destroy.apply(this,arguments);var a=this.element,b=this.styles;a.removeClass(b.master+" "+b.masterOpen+" ui-state-disabled ui-widget ui-ncbitoggler-disabled").removeAttr("role").removeAttr("aria-expanded");this.targets.removeClass("ui-ncbitoggler ui-ncbitoggler-slave ui-ncbitoggler-slave-open ui-state-disabled ui-ncbitoggler-disabled");
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
20 this.targets.removeAttr("aria-hidden");if(this.options.isIcon){b=a.find("span.ui-icon")[0];a[0].removeChild(b)}this.targets.each(function(){var d=jQuery(this),f=d.parent("div.ui-helper-reset");if(f.length>0){d.insertBefore(f);f.remove()}});b=a.find("span.ui-ncbitoggler-master-text");var c=b.html();b.remove();a.html(c);this._removeHandlers();return this},disable:function(){e.Widget.prototype.disable.apply(this,arguments);this._removeHandlers();this.targets.addClass("ui-ncbitoggler-disabled ui-state-disabled");
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
21 return this},enable:function(){e.Widget.prototype.enable.apply(this,arguments);this.targets.removeClass("ui-ncbitoggler-disabled ui-state-disabled");var a=this;this.element.click(function(b){a.toggle(b,a)});return this},_saveReferences:function(){var a=this;this._targets.each(function(){typeof e(this).data("ncbitoggler-masters")==="undefined"&&e(this).data("ncbitoggler-masters",[]);e(this).data("ncbitoggler-masters").push(a.element)})},_updateReferences:function(a){var b=this;e.each(this._targets.data("ncbitoggler-masters"),
ffe82516a83c add trimmed down html example
Jan Kanis <jan.code@jankanis.nl>
parents:
diff changeset
22 function(){b.element!=this&&e(this).ncbitoggler("updateState",a)})}})})(jQuery);