"use strict";var bottomBarHeight=-1;!function(t){var e={select:1,animate:!1,autoMaxExpand:!1,remember:!1,minHeight:0};function a(a,n){var i=this;i.elem=t(a),i.opts=t.extend({},e,i.elem.data(),n),i.init()}a.prototype.init=function(){var e,a,n=this;n.id=n.getId(),n.elem.prepend('<span class="foswikiClear"></span>'),e=t('<ul class="jqTabGroup clearfix"></ul>').prependTo(n.elem),a=1,n.elem.find("> .jqTab").each((function(){var n=t(this),i=n.find(".jqTabLabel:first").remove().html();e.append('<li><a href="#" data-index="'+a+'">'+i+"</a></li>"),n.data("index",a),a++})),void 0===n.currentIndex&&n.switchTab(1),n.opts.autoMaxExpand&&n.autoMaxExpand(),n.elem.find(".jqTabGroup > li > a").on("click",(function(){var e=t(this),a=e.data("index");return e.trigger("blur"),a!==n.currentIndex&&(n.switchTab(a),n.opts.remember&&n.setHash(a)),!1})),n.opts.remember?(t(window).on("hashchange",(function(){var t=n.getHash();void 0!==t&&n.switchTab(t)})),n.switchTab(n.getHash()||n.opts.select||1)):n.switchTab(n.opts.select||1)},a.prototype.parseHash=function(){var t,e,a=window.location.hash.replace(/^.*#!/,"").split(";"),n={},i=a.length;for(e=0;e<i;e++)2==(t=a[e].split("=")).length&&(n[t[0]]=parseInt(t[1],10));return n},a.prototype.getId=function(){var e=this,a=e.elem.attr("id");return t("#"+a+".jqTabPane").length>1?(a=parseInt(a.replace(/^tabpane/,""),10),e.elem.prop("id","tabpane"+(a+1)),e.getId()):a},a.prototype.getHash=function(){return this.parseHash()[this.id]},a.prototype.setHash=function(e){var a=this,n=a.parseHash(),i=[];e!==n[a.id]&&(void 0!==e?n[a.id]=e:delete n[a.id],t.each(n,(function(t,e){Array.isArray(e)&&(e=join("|",e)),i.push(t+="="+e)})),i="!"+i.join(";"),window.location.hash=i)},a.prototype.getTab=function(t){var e,a=this;return void 0!==(e="object"==typeof(t=t||a.currentIndex||a.opts.select)?t:"number"==typeof t?a.elem.find("> .jqTab").eq(t-1):a.elem.find(t))&&0==e.length&&(e=void 0),e},a.prototype.getNextTab=function(t){var e=this.getTab(t);if(e)return this.getTab(e.data("index")+1)},a.prototype.hideTab=function(t){var e,a=this,n=a.getTab(t);n&&(e=n.data("index"),a.getNaviOfTab(e).hide(),a.currentIndex===e&&n.hide())},a.prototype.showTab=function(t){var e,a=this,n=a.getTab(t);n&&(e=n.data("index"),a.getNaviOfTab(e).show(),a.currentIndex===e&&n.show())},a.prototype.getNaviOfTab=function(e){var a,n=this.getTab(e);return n?(a=n.data("index"),this.elem.find("> .jqTabGroup li a").eq(a-1)):t()},a.prototype.switchTab=function(e){var a,n,i,o,r,s,d,h,p=this,c=p.currentIndex,u=p.getTab(e);function l(){var e,a="none";i>0&&(a="easeInOutQuad"),p.opts.autoMaxExpand?p.opts.animate&&"none"!==a&&d.css({opacity:0}).animate({opacity:1},300):p.opts.animate&&"none"!==a&&(r.height("auto"),e=r.height(),h?(r.height(i).animate({height:e},300,a,(function(){r.height("auto")})),d.css({opacity:0}).animate({opacity:1},300,a)):r.height(i).css({opacity:0}).animate({opacity:1,height:e},300,a,(function(){r.height("auto")}))),t(window).trigger("resize"),void 0!==s.afterHandler&&window[s.afterHandler].call(p,c,o),p.currentIndex=o}u&&(void 0!==c&&(n=(a=p.getTab(c)).find(".jqTabContents:first"),c=a.data("index"),i=n.height()),o=u.data("index"),c!==o&&(a&&(a.removeClass("current").hide(),p.getNaviOfTab(c).parent().removeClass("current")),u.addClass("current").show(),p.getNaviOfTab(o).parent().addClass("current"),void 0!==(s=u.data()).beforeHandler&&window[s.beforeHandler].call(p,c,o),r=u.find(".jqTabContents:first"),(p.opts.animate||p.opts.autoMaxExpand)&&i>0&&!r.is(".jqTabDisableMaxExpand")&&r.height(i),d=r,h=!1,void 0!==s.container&&((d=r.find(s.container)).length?h=!0:d=r),void 0!==s.url?(d.load(s.url,void 0,(function(){void 0!==s.afterLoadHandler&&window[s.afterLoadHandler].call(p,c,o),l()})),u.removeData("url")):l()))},a.prototype.autoMaxExpand=function(){var e=this;window.setTimeout((function(){e.fixHeight(),t(window).one("resize.tabpane",(function(){e.autoMaxExpand()}))}),100)},a.prototype.fixHeight=function(){var e,a=this,n=a.elem.find("> .jqTab.current .jqTabContents:first"),i=t(window).height()||window.innerHeight;n.length&&!n.is(".jqTabDisableMaxExpand")&&(bottomBarHeight<=0&&(bottomBarHeight=t(".natEditBottomBar").outerHeight(!0)+n.outerHeight(!0)-n.height()),e=i-n.offset().top-bottomBarHeight-2,a.opts&&a.opts.minHeight&&e<a.opts.minHeight&&(e=a.opts.minHeight),e<0||n.height(e))},t.fn.tabpane=function(e){return this.each((function(){t.data(this,"tabPane")||t.data(this,"tabPane",new a(this,e))}))},t((function(){t(".jqTabPane:not(.jqInitedTabpane)").livequery((function(){t(this).tabpane().addClass("jqInitedTabpane")}))}))}(jQuery);
