template.js.base.tabs.min.js Maven / Gradle / Ivy
'use strict';(function(c){"function"===typeof define&&define.amd?define("jquery ../escape-selector ../keycode ../safe-active-element ../unique-id ../version ../widget".split(" "),c):c(jQuery)})(function(c){c.widget("ui.tabs",{version:"1.12.1",delay:300,options:{active:null,classes:{"ui-tabs":"ui-corner-all","ui-tabs-nav":"ui-corner-all","ui-tabs-panel":"ui-corner-bottom","ui-tabs-tab":"ui-corner-top"},collapsible:!1,event:"click",heightStyle:"content",hide:null,show:null,activate:null,beforeActivate:null,
beforeLoad:null,load:null},_isLocal:function(){var a=/#.*$/;return function(b){var c,e;c=b.href.replace(a,"");e=location.href.replace(a,"");try{c=decodeURIComponent(c)}catch(g){}try{e=decodeURIComponent(e)}catch(f){}return 1e&&(a=0);0>a&&(a=e);return a}for(var e=this.tabs.length-1;-1!==c.inArray(d(),this.options.disabled);)a=b?a+1:a-1;return a},_focusNextTab:function(a,b){a=this._findNextTab(a,b);this.tabs.eq(a).trigger("focus");return a},_setOption:function(a,b){"active"===a?this._activate(b):(this._super(a,b),"collapsible"===a&&(this._toggleClass("ui-tabs-collapsible",null,b),b||!1!==this.options.active||this._activate(0)),"event"===a&&this._setupEvents(b),"heightStyle"===a&&this._setupHeightStyle(b))},
_sanitizeSelector:function(a){return a?a.replace(/[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g,"\\$\x26"):""},refresh:function(){var a=this.options,b=this.tablist.children(":has(a[href])");a.disabled=c.map(b.filter(".ui-state-disabled"),function(a){return b.index(a)});this._processTabs();!1!==a.active&&this.anchors.length?this.active.length&&!c.contains(this.tablist[0],this.active[0])?this.tabs.length===a.disabled.length?(a.active=!1,this.active=c()):this._activate(this._findNextTab(Math.max(0,a.active-1),
!1)):a.active=this.tabs.index(this.active):(a.active=!1,this.active=c());this._refresh()},_refresh:function(){this._setOptionDisabled(this.options.disabled);this._setupEvents(this.options.event);this._setupHeightStyle(this.options.heightStyle);this.tabs.not(this.active).attr({"aria-selected":"false","aria-expanded":"false",tabIndex:-1});this.panels.not(this._getPanelForTab(this.active)).hide().attr({"aria-hidden":"true"});this.active.length?(this.active.attr({"aria-selected":"true","aria-expanded":"true",
tabIndex:0}),this._addClass(this.active,"ui-tabs-active","ui-state-active"),this._getPanelForTab(this.active).show().attr({"aria-hidden":"false"})):this.tabs.eq(0).attr("tabIndex",0)},_processTabs:function(){var a=this,b=this.tabs,d=this.anchors,e=this.panels;this.tablist=this._getList().attr("role","tablist");this._addClass(this.tablist,"ui-tabs-nav","ui-helper-reset ui-helper-clearfix ui-widget-header");this.tablist.on("mousedown"+this.eventNamespace,"\x3e li",function(a){c(this).is(".ui-state-disabled")&&
a.preventDefault()}).on("focus"+this.eventNamespace,".ui-tabs-anchor",function(){c(this).closest("li").is(".ui-state-disabled")&&this.blur()});this.tabs=this.tablist.find("\x3e li:has(a[href])").attr({role:"tab",tabIndex:-1});this._addClass(this.tabs,"ui-tabs-tab","ui-state-default");this.anchors=this.tabs.map(function(){return c("a",this)[0]}).attr({role:"presentation",tabIndex:-1});this._addClass(this.anchors,"ui-tabs-anchor");this.panels=c();this.anchors.each(function(b,d){var e,k,m=c(d).uniqueId().attr("id"),
l=c(d).closest("li"),n=l.attr("aria-controls");a._isLocal(d)?(e=d.hash,k=e.substring(1),e=a.element.find(a._sanitizeSelector(e))):(k=l.attr("aria-controls")||c({}).uniqueId()[0].id,e=a.element.find("#"+k),e.length||(e=a._createPanel(k),e.insertAfter(a.panels[b-1]||a.tablist)),e.attr("aria-live","polite"));e.length&&(a.panels=a.panels.add(e));n&&l.data("ui-tabs-aria-controls",n);l.attr({"aria-controls":k,"aria-labelledby":m});e.attr("aria-labelledby",m)});this.panels.attr("role","tabpanel");this._addClass(this.panels,
"ui-tabs-panel","ui-widget-content");b&&(this._off(b.not(this.tabs)),this._off(d.not(this.anchors)),this._off(e.not(this.panels)))},_getList:function(){return this.tablist||this.element.find("ol, ul").eq(0)},_createPanel:function(a){return c("\x3cdiv\x3e").attr("id",a).data("ui-tabs-destroy",!0)},_setOptionDisabled:function(a){var b,d;c.isArray(a)&&(a.length?a.length===this.anchors.length&&(a=!0):a=!1);for(d=0;b=this.tabs[d];d++)b=c(b),!0===a||-1!==c.inArray(d,a)?(b.attr("aria-disabled","true"),this._addClass(b,
null,"ui-state-disabled")):(b.removeAttr("aria-disabled"),this._removeClass(b,null,"ui-state-disabled"));this.options.disabled=a;this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!0===a)},_setupEvents:function(a){var b={};a&&c.each(a.split(" "),function(a,c){b[c]="_eventHandler"});this._off(this.anchors.add(this.tabs).add(this.panels));this._on(!0,this.anchors,{click:function(a){a.preventDefault()}});this._on(this.anchors,b);this._on(this.tabs,{keydown:"_tabKeydown"});this._on(this.panels,
{keydown:"_panelKeydown"});this._focusable(this.tabs);this._hoverable(this.tabs)},_setupHeightStyle:function(a){var b,d=this.element.parent();"fill"===a?(b=d.height(),b-=this.element.outerHeight()-this.element.height(),this.element.siblings(":visible").each(function(){var a=c(this),d=a.css("position");"absolute"!==d&&"fixed"!==d&&(b-=a.outerHeight(!0))}),this.element.children().not(this.panels).each(function(){b-=c(this).outerHeight(!0)}),this.panels.each(function(){c(this).height(Math.max(0,b-c(this).innerHeight()+
c(this).height()))}).css("overflow","auto")):"auto"===a&&(b=0,this.panels.each(function(){b=Math.max(b,c(this).height("").height())}).height(b))},_eventHandler:function(a){var b=this.options,d=this.active,e=c(a.currentTarget).closest("li"),g=e[0]===d[0],f=g&&b.collapsible,h=f?c():this._getPanelForTab(e),k=d.length?this._getPanelForTab(d):c(),d={oldTab:d,oldPanel:k,newTab:f?c():e,newPanel:h};a.preventDefault();e.hasClass("ui-state-disabled")||e.hasClass("ui-tabs-loading")||this.running||g&&!b.collapsible||
!1===this._trigger("beforeActivate",a,d)||(b.active=f?!1:this.tabs.index(e),this.active=g?c():e,this.xhr&&this.xhr.abort(),k.length||h.length||c.error("jQuery UI Tabs: Mismatching fragment identifier."),h.length&&this.load(this.tabs.index(e),a),this._toggle(a,d))},_toggle:function(a,b){function d(){g.running=!1;g._trigger("activate",a,b)}function e(){g._addClass(b.newTab.closest("li"),"ui-tabs-active","ui-state-active");f.length&&g.options.show?g._show(f,g.options.show,d):(f.show(),d())}var g=this,
f=b.newPanel,h=b.oldPanel;this.running=!0;h.length&&this.options.hide?this._hide(h,this.options.hide,function(){g._removeClass(b.oldTab.closest("li"),"ui-tabs-active","ui-state-active");e()}):(this._removeClass(b.oldTab.closest("li"),"ui-tabs-active","ui-state-active"),h.hide(),e());h.attr("aria-hidden","true");b.oldTab.attr({"aria-selected":"false","aria-expanded":"false"});f.length&&h.length?b.oldTab.attr("tabIndex",-1):f.length&&this.tabs.filter(function(){return 0===c(this).attr("tabIndex")}).attr("tabIndex",
-1);f.attr("aria-hidden","false");b.newTab.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0})},_activate:function(a){a=this._findActive(a);a[0]!==this.active[0]&&(a.length||(a=this.active),a=a.find(".ui-tabs-anchor")[0],this._eventHandler({target:a,currentTarget:a,preventDefault:c.noop}))},_findActive:function(a){return!1===a?c():this.tabs.eq(a)},_getIndex:function(a){"string"===typeof a&&(a=this.anchors.index(this.anchors.filter("[href$\x3d'"+c.ui.escapeSelector(a)+"']")));return a},
_destroy:function(){this.xhr&&this.xhr.abort();this.tablist.removeAttr("role").off(this.eventNamespace);this.anchors.removeAttr("role tabIndex").removeUniqueId();this.tabs.add(this.panels).each(function(){c.data(this,"ui-tabs-destroy")?c(this).remove():c(this).removeAttr("role tabIndex aria-live aria-busy aria-selected aria-labelledby aria-hidden aria-expanded")});this.tabs.each(function(){var a=c(this),b=a.data("ui-tabs-aria-controls");b?a.attr("aria-controls",b).removeData("ui-tabs-aria-controls"):
a.removeAttr("aria-controls")});this.panels.show();"content"!==this.options.heightStyle&&this.panels.css("height","")},enable:function(a){var b=this.options.disabled;!1!==b&&(void 0===a?b=!1:(a=this._getIndex(a),b=c.isArray(b)?c.map(b,function(b){return b!==a?b:null}):c.map(this.tabs,function(b,c){return c!==a?c:null})),this._setOptionDisabled(b))},disable:function(a){var b=this.options.disabled;if(!0!==b){if(void 0===a)b=!0;else{a=this._getIndex(a);if(-1!==c.inArray(a,b))return;b=c.isArray(b)?c.merge([a],
b).sort():[a]}this._setOptionDisabled(b)}},load:function(a,b){a=this._getIndex(a);var d=this,e=this.tabs.eq(a),g=e.find(".ui-tabs-anchor"),f=this._getPanelForTab(e),h={tab:e,panel:f},k=function(a,b){"abort"===b&&d.panels.stop(!1,!0);d._removeClass(e,"ui-tabs-loading");f.removeAttr("aria-busy");a===d.xhr&&delete d.xhr};this._isLocal(g[0])||(this.xhr=c.ajax(this._ajaxSettings(g,b,h)))&&"canceled"!==this.xhr.statusText&&(this._addClass(e,"ui-tabs-loading"),f.attr("aria-busy","true"),this.xhr.done(function(a,
c,e){setTimeout(function(){f.html(a);d._trigger("load",b,h);k(e,c)},1)}).fail(function(a,b){setTimeout(function(){k(a,b)},1)}))},_ajaxSettings:function(a,b,d){var e=this;return{url:a.attr("href").replace(/#.*$/,""),beforeSend:function(a,f){return e._trigger("beforeLoad",b,c.extend({jqXHR:a,ajaxSettings:f},d))}}},_getPanelForTab:function(a){a=c(a).attr("aria-controls");return this.element.find(this._sanitizeSelector("#"+a))}});!1!==c.uiBackCompat&&c.widget("ui.tabs",c.ui.tabs,{_processTabs:function(){this._superApply(arguments);
this._addClass(this.tabs,"ui-tab")}});return c.ui.tabs});
© 2015 - 2024 Weber Informatics LLC | Privacy Policy