You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6 lines
15 KiB

  1. /*!
  2. * Angular Material Design
  3. * https://github.com/angular/material
  4. * @license MIT
  5. * v1.1.0-master-2b98560
  6. */
  7. !function(e,t,n){"use strict";function a(){function e(e,a,s,i){if(i){var d=i.getTabElementIndex(a),c=n(a,"md-tab-body").remove(),o=n(a,"md-tab-label").remove(),r=i.insertTab({scope:e,parent:e.$parent,index:d,element:a,template:c.html(),label:o.html()},d);e.select=e.select||t.noop,e.deselect=e.deselect||t.noop,e.$watch("active",function(e){e&&i.select(r.getIndex(),!0)}),e.$watch("disabled",function(){i.refreshIndex()}),e.$watch(function(){return i.getTabElementIndex(a)},function(e){r.index=e,i.updateTabOrder()}),e.$on("$destroy",function(){i.removeTab(r)})}}function n(e,n){for(var a=e[0].children,s=0,i=a.length;s<i;s++){var d=a[s];if(d.tagName===n.toUpperCase())return t.element(d)}return t.element()}return{require:"^?mdTabs",terminal:!0,compile:function(a,s){var i=n(a,"md-tab-label"),d=n(a,"md-tab-body");if(0==i.length&&(i=t.element("<md-tab-label></md-tab-label>"),s.label?i.text(s.label):i.append(a.contents()),0==d.length)){var c=a.contents().detach();d=t.element("<md-tab-body></md-tab-body>"),d.append(c)}return a.append(i),d.html()&&a.append(d),e},scope:{active:"=?mdActive",disabled:"=?ngDisabled",select:"&?mdOnSelect",deselect:"&?mdOnDeselect"}}}function s(){return{require:"^?mdTabs",link:function(e,t,n,a){a&&a.attachRipple(e,t)}}}function i(){return{terminal:!0}}function d(e){return{restrict:"A",compile:function(t,n){var a=e(n.mdTabScroll,null,!0);return function(e,t){t.on("mousewheel",function(t){e.$apply(function(){a(e,{$event:t})})})}}}}function c(e,a,s,i,d,c,o,r,l,f){function b(){le.selectedIndex=le.selectedIndex||0,m(),p(),u(),f(a),c.nextTick(function(){be=q(),ie(),te(),de(),le.tabs[le.selectedIndex]&&le.tabs[le.selectedIndex].scope.select(),pe=!0,Y()})}function m(){var e=r.$mdTabsTemplate,n=t.element(a[0].querySelector("md-tab-data"));n.html(e),l(n.contents())(le.parent),delete r.$mdTabsTemplate}function u(){t.element(s).on("resize",A),e.$on("$destroy",x)}function p(){e.$watch("$mdTabsCtrl.selectedIndex",y)}function h(e,t){var n=r.$normalize("md-"+e);t&&K(e,t),r.$observe(n,function(t){le[e]=t})}function g(e,t){function n(t){le[e]="false"!==t}var a=r.$normalize("md-"+e);t&&K(e,t),r.hasOwnProperty(a)&&n(r[a]),r.$observe(a,n)}function x(){ue=!0,t.element(s).off("resize",A)}function T(e){var n=q();t.element(n.wrapper).toggleClass("md-stretch-tabs",j()),de()}function v(e){le.shouldCenterTabs=N()}function $(e,n){if(e!==n){var a=q();t.forEach(a.tabs,function(t){t.style.maxWidth=e+"px"}),c.nextTick(le.updateInkBarStyles)}}function C(e,t){e!==t&&(le.maxTabWidth=V(),le.shouldCenterTabs=N(),c.nextTick(function(){le.maxTabWidth=V(),te(le.selectedIndex)}))}function I(e){a[e?"removeClass":"addClass"]("md-no-tab-content")}function w(n){var a=q(),s=le.shouldCenterTabs?"":"-"+n+"px";t.element(a.paging).css(i.CSS.TRANSFORM,"translate3d("+s+", 0, 0)"),e.$broadcast("$mdTabsPaginationChanged")}function k(e,t){e!==t&&q().tabs[e]&&(te(),ee())}function y(t,n){t!==n&&(le.selectedIndex=U(t),le.lastSelectedIndex=n,le.updateInkBarStyles(),ie(),te(t),e.$broadcast("$mdTabsChanged"),le.tabs[n]&&le.tabs[n].scope.deselect(),le.tabs[t]&&le.tabs[t].scope.select())}function S(e){var t=a[0].getElementsByTagName("md-tab");return Array.prototype.indexOf.call(t,e[0])}function L(){L.watcher||(L.watcher=e.$watch(function(){c.nextTick(function(){L.watcher&&a.prop("offsetParent")&&(L.watcher(),L.watcher=null,A())},!1)}))}function P(e){switch(e.keyCode){case i.KEY_CODE.LEFT_ARROW:e.preventDefault(),Z(-1,!0);break;case i.KEY_CODE.RIGHT_ARROW:e.preventDefault(),Z(1,!0);break;case i.KEY_CODE.SPACE:case i.KEY_CODE.ENTER:e.preventDefault(),fe||W(le.focusIndex)}le.lastClick=!1}function W(e,t){fe||(le.focusIndex=le.selectedIndex=e),le.lastClick=!0,t&&le.noSelectClick||c.nextTick(function(){le.tabs[e].element.triggerHandler("click")},!1)}function D(e){le.shouldPaginate&&(e.preventDefault(),le.offsetLeft=oe(le.offsetLeft-e.wheelDelta))}function E(){var e,t,n=q(),a=n.canvas.clientWidth,s=a+le.offsetLeft;for(e=0;e<n.tabs.length&&(t=n.tabs[e],!(t.offsetLeft+t.offsetWidth>s));e++);a>t.offsetWidth?le.offsetLeft=oe(t.offsetLeft):le.offsetLeft=oe(t.offsetLeft+(t.offsetWidth-a+1))}function O(){var e,t,n=q();for(e=0;e<n.tabs.length&&(t=n.tabs[e],!(t.offsetLeft+t.offsetWidth>=le.offsetLeft));e++);n.canvas.clientWidth>t.offsetWidth?le.offsetLeft=oe(t.offsetLeft+t.offsetWidth-n.canvas.clientWidth):le.offsetLeft=oe(t.offsetLeft)}function A(){le.lastSelectedIndex=le.selectedIndex,le.offsetLeft=oe(le.offsetLeft),c.nextTick(function(){le.updateInkBarStyles(),Y()})}function B(e){t.element(q().inkBar).toggleClass("ng-hide",e)}function M(e){a.toggleClass("md-dynamic-height",e)}function R(e){if(!ue){var t=le.selectedIndex,n=le.tabs.splice(e.getIndex(),1)[0];se(),le.selectedIndex===t&&(n.scope.deselect(),le.tabs[le.selectedIndex]&&le.tabs[le.selectedIndex].scope.select()),c.nextTick(function(){Y(),le.offsetLeft=oe(le.offsetLeft)})}}function F(e,n){var a=pe,s={getIndex:function(){return le.tabs.indexOf(i)},isActive:function(){return this.getIndex()===le.selectedIndex},isLeft:function(){return this.getIndex()<le.selectedIndex},isRight:function(){return this.getIndex()>le.selectedIndex},shouldRender:function(){return!le.noDisconnect||this.isActive()},hasFocus:function(){return!le.lastClick&&le.hasFocus&&this.getIndex()===le.focusIndex},id:c.nextUid()},i=t.extend(s,e);return t.isDefined(n)?le.tabs.splice(n,0,i):le.tabs.push(i),ne(),ae(),c.nextTick(function(){Y(),a&&le.autoselect&&c.nextTick(function(){c.nextTick(function(){W(le.tabs.indexOf(i))})})}),i}function q(){var e={},t=a[0];return e.wrapper=t.querySelector("md-tabs-wrapper"),e.canvas=e.wrapper.querySelector("md-tabs-canvas"),e.paging=e.canvas.querySelector("md-pagination-wrapper"),e.inkBar=e.paging.querySelector("md-ink-bar"),e.contents=t.querySelectorAll("md-tabs-content-wrapper > md-tab-content"),e.tabs=e.paging.querySelectorAll("md-tab-item"),e.dummies=e.canvas.querySelectorAll("md-dummy-tab"),e}function H(){return le.offsetLeft>0}function _(){var e=q(),t=e.tabs[e.tabs.length-1];return t&&t.offsetLeft+t.offsetWidth>e.canvas.clientWidth+le.offsetLeft}function j(){switch(le.stretchTabs){case"always":return!0;case"never":return!1;default:return!le.shouldPaginate&&s.matchMedia("(max-width: 600px)").matches}}function N(){return le.centerTabs&&!le.shouldPaginate}function z(){if(le.noPagination||!pe)return!1;var e=a.prop("clientWidth");return t.forEach(q().dummies,function(t){e-=t.offsetWidth}),e<0}function U(e){if(e===-1)return-1;var t,n,a=Math.max(le.tabs.length-e,e);for(t=0;t<=a;t++){if(n=le.tabs[e+t],n&&n.scope.disabled!==!0)return n.getIndex();if(n=le.tabs[e-t],n&&n.scope.disabled!==!0)return n.getIndex()}return e}function K(e,t,n){Object.defineProperty(le,e,{get:function(){return n},set:function(e){var a=n;n=e,t&&t(e,a)}})}function Y(){G(),le.maxTabWidth=V(),le.shouldPaginate=z()}function G(){var e=q();j()?t.element(e.paging).css("width",""):t.element(e.paging).css("width",J()+"px")}function J(){return Q(q().dummies)}function Q(e){var n=0;return t.forEach(e,function(e){n+=Math.max(e.offsetWidth,e.getBoundingClientRect().width)}),Math.ceil(n)}function V(){return a.prop("clientWidth")}function X(){var e=le.tabs[le.selectedIndex],t=le.tabs[le.focusIndex];le.tabs=le.tabs.sort(function(e,t){return e.index-t.index}),le.selectedIndex=le.tabs.indexOf(e),le.focusIndex=le.tabs.indexOf(t)}function Z(e,t){var n,a=t?"focusIndex":"selectedIndex",s=le[a];for(n=s+e;le.tabs[n]&&le.tabs[n].scope.disabled;n+=e);le.tabs[n]&&(le[a]=n)}function ee(){q().dummies[le.focusIndex].focus()}function te(e){var t=q();if(null==e&&(e=le.focusIndex),t.tabs[e]&&!le.shouldCenterTabs){var n=t.tabs[e],a=n.offsetLeft,s=n.offsetWidth+a;le.offsetLeft=Math.max(le.offsetLeft,oe(s-t.canvas.clientWidth+64)),le.offsetLeft=Math.min(le.offsetLeft,oe(a))}}function ne(){me.forEach(function(e){c.nextTick(e)}),me=[]}function ae(){var e=!1;t.forEach(le.tabs,function(t){t.template&&(e=!0)}),le.hasContent=e}function se(){le.selectedIndex=U(le.selectedIndex),le.focusIndex=U(le.focusIndex)}function ie(){if(!le.dynamicHeight)return a.css("height","");if(!le.tabs.length)return me.push(ie);var e=q(),t=e.contents[le.selectedIndex],s=t?t.offsetHeight:0,i=e.wrapper.offsetHeight,d=s+i,r=a.prop("clientHeight");if(r!==d){"bottom"===a.attr("md-align-tabs")&&(r-=i,d-=i,a.attr("md-border-bottom")!==n&&++r),fe=!0;var l={height:r+"px"},f={height:d+"px"};a.css(l),o(a,{from:l,to:f,easing:"cubic-bezier(0.35, 0, 0.25, 1)",duration:.5}).start().done(function(){a.css({transition:"none",height:""}),c.nextTick(function(){a.css("transition","")}),fe=!1})}}function de(){var e=q();if(!e.tabs[le.selectedIndex])return void t.element(e.inkBar).css({left:"auto",right:"auto"});if(!le.tabs.length)return me.push(le.updateInkBarStyles);if(!a.prop("offsetParent"))return L();var n=le.selectedIndex,s=e.paging.offsetWidth,i=e.tabs[n],d=i.offsetLeft,o=s-d-i.offsetWidth;if(le.shouldCenterTabs){var r=Q(e.tabs);s>r&&c.nextTick(de,!1)}ce(),t.element(e.inkBar).css({left:d+"px",right:o+"px"})}function ce(){var e=q(),n=le.selectedIndex,a=le.lastSelectedIndex,s=t.element(e.inkBar);t.isNumber(a)&&s.toggleClass("md-left",n<a).toggleClass("md-right",n>a)}function oe(e){var t=q();if(!t.tabs.length||!le.shouldPaginate)return 0;var n=t.tabs[t.tabs.length-1],a=n.offsetLeft+n.offsetWidth;return e=Math.max(0,e),e=Math.min(a-t.canvas.clientWidth,e)}function re(e,n){var a=q(),s={colorElement:t.element(a.inkBar)};d.attach(e,n,s)}var le=this,fe=!1,be=q(),me=[],ue=!1,pe=!1;h("stretchTabs",T),K("focusIndex",k,le.selectedIndex||0),K("offsetLeft",w,0),K("hasContent",I,!1),K("maxTabWidth",$,V()),K("shouldPaginate",C,!1),g("noInkBar",B),g("dynamicHeight",M),g("noPagination"),g("swipeContent"),g("noDisconnect"),g("autoselect"),g("noSelectClick"),g("centerTabs",v,!1),g("enableDisconnect"),le.scope=e,le.parent=e.$parent,le.tabs=[],le.lastSelectedIndex=null,le.hasFocus=!1,le.lastClick=!0,le.shouldCenterTabs=N(),le.updatePagination=c.debounce(Y,100),le.redirectFocus=ee,le.attachRipple=re,le.insertTab=F,le.removeTab=R,le.select=W,le.scroll=D,le.nextPage=E,le.previousPage=O,le.keydown=P,le.canPageForward=_,le.canPageBack=H,le.refreshIndex=se,le.incrementIndex=Z,le.getTabElementIndex=S,le.updateInkBarStyles=c.debounce(de,100),le.updateTabOrder=c.debounce(X,100),b()}function o(e){return{scope:{selectedIndex:"=?mdSelected"},template:function(t,n){return n.$mdTabsTemplate=t.html(),'<md-tabs-wrapper> <md-tab-data></md-tab-data> <md-prev-button tabindex="-1" role="button" aria-label="Previous Page" aria-disabled="{{!$mdTabsCtrl.canPageBack()}}" ng-class="{ \'md-disabled\': !$mdTabsCtrl.canPageBack() }" ng-if="$mdTabsCtrl.shouldPaginate" ng-click="$mdTabsCtrl.previousPage()"> <md-icon md-svg-src="'+e.mdTabsArrow+'"></md-icon> </md-prev-button> <md-next-button tabindex="-1" role="button" aria-label="Next Page" aria-disabled="{{!$mdTabsCtrl.canPageForward()}}" ng-class="{ \'md-disabled\': !$mdTabsCtrl.canPageForward() }" ng-if="$mdTabsCtrl.shouldPaginate" ng-click="$mdTabsCtrl.nextPage()"> <md-icon md-svg-src="'+e.mdTabsArrow+'"></md-icon> </md-next-button> <md-tabs-canvas tabindex="{{ $mdTabsCtrl.hasFocus ? -1 : 0 }}" aria-activedescendant="tab-item-{{$mdTabsCtrl.tabs[$mdTabsCtrl.focusIndex].id}}" ng-focus="$mdTabsCtrl.redirectFocus()" ng-class="{ \'md-paginated\': $mdTabsCtrl.shouldPaginate, \'md-center-tabs\': $mdTabsCtrl.shouldCenterTabs }" ng-keydown="$mdTabsCtrl.keydown($event)" role="tablist"> <md-pagination-wrapper ng-class="{ \'md-center-tabs\': $mdTabsCtrl.shouldCenterTabs }" md-tab-scroll="$mdTabsCtrl.scroll($event)"> <md-tab-item tabindex="-1" class="md-tab" ng-repeat="tab in $mdTabsCtrl.tabs" role="tab" aria-controls="tab-content-{{::tab.id}}" aria-selected="{{tab.isActive()}}" aria-disabled="{{tab.scope.disabled || \'false\'}}" ng-click="$mdTabsCtrl.select(tab.getIndex())" ng-class="{ \'md-active\': tab.isActive(), \'md-focused\': tab.hasFocus(), \'md-disabled\': tab.scope.disabled }" ng-disabled="tab.scope.disabled" md-swipe-left="$mdTabsCtrl.nextPage()" md-swipe-right="$mdTabsCtrl.previousPage()" md-tabs-template="::tab.label" md-scope="::tab.parent"></md-tab-item> <md-ink-bar></md-ink-bar> </md-pagination-wrapper> <md-tabs-dummy-wrapper class="md-visually-hidden md-dummy-wrapper"> <md-dummy-tab class="md-tab" tabindex="-1" id="tab-item-{{::tab.id}}" role="tab" aria-controls="tab-content-{{::tab.id}}" aria-selected="{{tab.isActive()}}" aria-disabled="{{tab.scope.disabled || \'false\'}}" ng-focus="$mdTabsCtrl.hasFocus = true" ng-blur="$mdTabsCtrl.hasFocus = false" ng-repeat="tab in $mdTabsCtrl.tabs" md-tabs-template="::tab.label" md-scope="::tab.parent"></md-dummy-tab> </md-tabs-dummy-wrapper> </md-tabs-canvas> </md-tabs-wrapper> <md-tabs-content-wrapper ng-show="$mdTabsCtrl.hasContent && $mdTabsCtrl.selectedIndex >= 0" class="_md"> <md-tab-content id="tab-content-{{::tab.id}}" class="_md" role="tabpanel" aria-labelledby="tab-item-{{::tab.id}}" md-swipe-left="$mdTabsCtrl.swipeContent && $mdTabsCtrl.incrementIndex(1)" md-swipe-right="$mdTabsCtrl.swipeContent && $mdTabsCtrl.incrementIndex(-1)" ng-if="$mdTabsCtrl.hasContent" ng-repeat="(index, tab) in $mdTabsCtrl.tabs" ng-class="{ \'md-no-transition\': $mdTabsCtrl.lastSelectedIndex == null, \'md-active\': tab.isActive(), \'md-left\': tab.isLeft(), \'md-right\': tab.isRight(), \'md-no-scroll\': $mdTabsCtrl.dynamicHeight }"> <div md-tabs-template="::tab.template" md-connected-if="tab.isActive()" md-scope="::tab.parent" ng-if="$mdTabsCtrl.enableDisconnect || tab.shouldRender()"></div> </md-tab-content> </md-tabs-content-wrapper>'},controller:"MdTabsController",controllerAs:"$mdTabsCtrl",bindToController:!0}}function r(e,t){return{require:"^?mdTabs",link:function(n,a,s,i){if(i){var d,c,o=function(){i.updatePagination(),i.updateInkBarStyles()};if("MutationObserver"in t){var r={childList:!0,subtree:!0,characterData:!0};d=new MutationObserver(o),d.observe(a[0],r),c=d.disconnect.bind(d)}else{var l=e.debounce(o,15,null,!1);a.on("DOMSubtreeModified",l),c=a.off.bind(a,"DOMSubtreeModified",l)}n.$on("$destroy",function(){c()})}}}}function l(e,t){function n(n,a,s,i){function d(){n.$watch("connected",function(e){e===!1?c():o()}),n.$on("$destroy",o)}function c(){i.enableDisconnect&&t.disconnectScope(r)}function o(){i.enableDisconnect&&t.reconnectScope(r)}if(i){var r=i.enableDisconnect?n.compileScope.$new():n.compileScope;return a.html(n.template),e(a.contents())(r),t.nextTick(d)}}return{restrict:"A",link:n,scope:{template:"=mdTabsTemplate",connected:"=?mdConnectedIf",compileScope:"=mdScope"},require:"^?mdTabs"}}t.module("material.components.tabs",["material.core","material.components.icon"]),t.module("material.components.tabs").directive("mdTab",a),t.module("material.components.tabs").directive("mdTabItem",s),t.module("material.components.tabs").directive("mdTabLabel",i),d.$inject=["$parse"],t.module("material.components.tabs").directive("mdTabScroll",d),c.$inject=["$scope","$element","$window","$mdConstant","$mdTabInkRipple","$mdUtil","$animateCss","$attrs","$compile","$mdTheming"],t.module("material.components.tabs").controller("MdTabsController",c),o.$inject=["$$mdSvgRegistry"],t.module("material.components.tabs").directive("mdTabs",o),r.$inject=["$mdUtil","$window"],t.module("material.components.tabs").directive("mdTabsDummyWrapper",r),l.$inject=["$compile","$mdUtil"],t.module("material.components.tabs").directive("mdTabsTemplate",l)}(window,window.angular);