asiaH2/assets/javascripts/plugin/jquery.scrolling-tabs.min.js

8 lines
23 KiB
JavaScript
Raw Permalink Normal View History

2020-04-09 10:46:42 +00:00
/**
* jquery-bootstrap-scrolling-tabs
* @version v2.6.1
* @link https://github.com/mikejacobson/jquery-bootstrap-scrolling-tabs
* @author Mike Jacobson <michaeljjacobson1@gmail.com>
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
!function(e,t){"use strict";function n(e){this.stc=e}function r(e){this.stc=e}function a(e){this.stc=e}function o(t){var o=this;o.$tabsContainer=t,o.instanceId=e.fn.scrollingTabs.nextInstanceId++,o.movableContainerLeftPos=0,o.scrollArrowsVisible=!1,o.scrollToTabEdge=!1,o.disableScrollArrowsOnFullyScrolled=!1,o.reverseScroll=!1,o.widthMultiplier=1,o.scrollMovement=new a(o),o.eventHandlers=new r(o),o.elementsHandler=new n(o)}function i(t,n,r){var a,o=n.tabs,i={paneId:n.propPaneId,title:n.propTitle,active:n.propActive,disabled:n.propDisabled,content:n.propContent},l=n.ignoreTabPanes,c=o.length&&void 0!==o[0][i.content],d=A.getNewElNavTabs(),b=A.getNewElTabContent(),f=l?null:function(){a.after(b)};if(o.length)return o.forEach(function(e,t){var r={forceActiveTab:!0,tabLiContent:n.tabsLiContent&&n.tabsLiContent[t],tabPostProcessor:n.tabsPostProcessors&&n.tabsPostProcessors[t]};A.getNewElTabLi(e,i,r).appendTo(d),!l&&c&&A.getNewElTabPane(e,i,r).appendTo(b)}),a=s(d,n,r,f),a.appendTo(t),t.data({scrtabs:{tabs:o,propNames:i,ignoreTabPanes:l,hasTabContent:c,tabsLiContent:n.tabsLiContent,tabsPostProcessors:n.tabsPostProcessors,scroller:a}}),a.find(".nav-tabs > li").each(function(t){L.storeDataOnLiEl(e(this),o,t)}),t}function s(e,t,n,r){e.find('a[data-toggle="tab"]').removeData(T.DATA_KEY_BOOTSTRAP_TAB);var a=A.getNewElScrollerElementWrappingNavTabsInstance(e.clone(!0),t),i=new o(a),s=e.data("scrtabs");return s?s.scroller=a:e.data("scrtabs",{scroller:a}),e.replaceWith(a.css("visibility","hidden")),t.tabClickHandler&&"function"==typeof t.tabClickHandler&&(a.hasTabClickHandler=!0,i.tabClickHandler=t.tabClickHandler),a.initTabs=function(){i.initTabs(t,a,n,r)},a.scrollToActiveTab=function(){i.scrollToActiveTab(t)},a.initTabs(),C(a,i),a}function l(e){var t=e.updatedTabsArray,n=e.updatedTabsLiContent||[],r=e.updatedTabsPostProcessors||[],a=e.propNames,o=e.ignoreTabPanes,i=e.options,s=e.$currTabLis,l=e.$navTabs,c=o?null:e.$currTabContentPanesContainer,d=o?null:e.$currTabContentPanes,b=!1;return t.forEach(function(e,f){var C,v=s.find('a[href="#'+e[a.paneId]+'"]'),u=f>=s.length;v.length||(b=!0,i.tabLiContent=n[f],i.tabPostProcessor=r[f],v=A.getNewElTabLi(e,a,i),L.storeDataOnLiEl(v,t,f),u?v.appendTo(l):v.insertBefore(s.eq(f)),o||void 0===e[a.content]||(C=A.getNewElTabPane(e,a,i),u?C.appendTo(c):C.insertBefore(d.eq(f))))}),b}function c(e){var t=e.tabLi,n=e.ignoreTabPanes,r=t.$li,a=t.$contentPane,o=t.origTabData,i=t.newTabData,s=e.propNames,l=!1;return o[s.title]!==i[s.title]&&(r.find('a[role="tab"]').html(o[s.title]=i[s.title]),l=!0),o[s.disabled]!==i[s.disabled]&&(i[s.disabled]?(r.addClass("disabled"),r.find('a[role="tab"]').attr("data-toggle","")):(r.removeClass("disabled"),r.find('a[role="tab"]').attr("data-toggle","tab")),o[s.disabled]=i[s.disabled],l=!0),e.options.forceActiveTab&&(r[i[s.active]?"addClass":"removeClass"]("active"),a[i[s.active]?"addClass":"removeClass"]("active"),o[s.active]=i[s.active],l=!0),n||o[s.content]===i[s.content]||(a.html(o[s.content]=i[s.content]),l=!0),l}function d(e){var t,n=e.tabLi,r=e.ignoreTabPanes,a=n.$li;return-1===n.newIdx&&(a.hasClass("active")&&(t=L.getIndexOfClosestEnabledTab(e.$currTabLis,n.currDomIdx))>-1&&(e.$currTabLis.eq(t).addClass("active"),r||e.$currTabContentPanes.eq(t).addClass("active")),a.remove(),r||n.$contentPane.remove(),!0)}function b(t){var n=t.$currTabLis,r=t.updatedTabsArray,a=t.propNames,o=t.ignoreTabPanes,i=[],s=o?null:[];return!!L.didTabOrderChange(n,r,a)&&(r.forEach(function(t){var r=t[a.paneId];i.push(n.find('a[role="tab"][href="#'+r+'"]').parent("li")),o||s.push(e("#"+r))}),t.$navTabs.append(i),o||t.$currTabContentPanesContainer.append(s),!0)}function f(t){var n=t.$currTabLis,r=t.updatedTabsArray,a=t.propNames,o=!1;return n.each(function(n){var i=e(this),s=i.data("tab"),l=L.getTabIndexByPaneId(r,a.paneId,s[a.paneId]),b=l>-1?r[l]:null;if(t.tabLi={$li:i,currDomIdx:n,newIdx:l,$contentPane:A.getElTabPaneForLi(i),origTabData:s,newTabData:b},d(t))return void(o=!0);c(t)&&(o=!0)}),o}function C(t,n){function r(t){e(t.target).append(o.off(T.EVENTS.CLICK))}function a(r){function a(){var n=