switcher.js 1018 Bytes
/*        GNU General Public License version 2 or later; see LICENSE.txt*/var JSwitcher=function(f,c,l){var b,k,i,g,m={onShow:function(){},onHide:function(){},cookieName:"switcher",togglerSelector:"a",elementSelector:"div.tab",elementPrefix:"page-"},a=function(p,o,n){b=jQuery.noConflict();b.extend(m,n);k=b(p).find(m.togglerSelector);i=b(o).find(m.elementSelector);if((k.length===0)||(k.length!==i.length)){return}d();k.each(function(){b(this).on("click",function(){h(b(this).attr("id"))})});var q=document.location.hash.substring(1);if(q){h(q)}else{if(k.length){h(k.first().attr("id"))}}},h=function(o){var p=b("#"+o),n=b("#"+m.elementPrefix+o);if(p.length===0||n.length===0||o===g){return this}if(g){e(b("#"+m.elementPrefix+g));b("#"+g).removeClass("active")}j(n);p.addClass("active");g=o;document.location.hash=g;b(window).scrollTop(0)},e=function(n){m.onShow(n);b(n).hide()},d=function(){i.hide();k.removeClass("active")},j=function(n){m.onHide(n);b(n).show()};a(f,c,l);return{display:h,hide:e,hideAll:d,show:j}};