Mercurial > repos > jankanis > blast2html
view Blast output page example trimmed_files/jquery_002.js @ 9:bbdc8fb0de2b
fix descriptiontable width
author | Jan Kanis <jan.code@jankanis.nl> |
---|---|
date | Thu, 08 May 2014 18:59:32 +0200 |
parents | ffe82516a83c |
children |
line wrap: on
line source
(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", 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= 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>')}); 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 "+ 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); 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()}, _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(); 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); 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">'); 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= 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}, 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= 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]}, _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, 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= 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", 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"); 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", 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"); 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"); 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"), function(){b.element!=this&&e(this).ncbitoggler("updateState",a)})}})})(jQuery);