|
!function(e,t,n){"use strict";function a(){function e(e,a,s,i){if(i){var d=i.getTabElementIndex(a),o=n(a,"md-tab-body").remove(),r=n(a,"md-tab-label").remove(),c=i.insertTab({scope:e,parent:e.$parent,index:d,element:a,template:o.html(),label:r.html()},d);e.select=e.select||t.noop,e.deselect=e.deselect||t.noop,e.$watch("active",function(e){e&&i.select(c.getIndex(),!0)}),e.$watch("disabled",function(){i.refreshIndex()}),e.$watch(function(){return i.getTabElementIndex(a)},function(e){c.index=e,i.updateTabOrder()}),e.$on("$destroy",function(){i.removeTab(c)})}}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 o=a.contents().detach();d=t.element("<md-tab-body></md-tab-body>"),d.append(o)}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 o(e,a,s,i,d,o,r,c,l,f,b){function m(){x("stretchTabs",$),J("focusIndex",S,be.selectedIndex||0),J("offsetLeft",k,0),J("hasContent",y,!1),J("maxTabWidth",I,X()),J("shouldPaginate",w,!1),T("noInkBar",M),T("dynamicHeight",R),T("noPagination"),T("swipeContent"),T("noDisconnect"),T("autoselect"),T("noSelectClick"),T("centerTabs",C,!1),T("enableDisconnect"),be.scope=e,be.parent=e.$parent,be.tabs=[],be.lastSelectedIndex=null,be.hasFocus=!1,be.styleTabItemFocus=!1,be.shouldCenterTabs=K(),be.tabContentPrefix="tab-content-",u()}function u(){be.selectedIndex=be.selectedIndex||0,p(),g(),h(),f(a),o.nextTick(function(){ue=_(),de(),ne(),oe(),be.tabs[be.selectedIndex]&&be.tabs[be.selectedIndex].scope.select(),ge=!0,Q()})}function p(){var e=c.$mdTabsTemplate,n=t.element(a[0].querySelector("md-tab-data"));n.html(e),l(n.contents())(be.parent),delete c.$mdTabsTemplate}function h(){t.element(s).on("resize",B),e.$on("$destroy",v)}function g(){e.$watch("$mdTabsCtrl.selectedIndex",P)}function x(e,t){var n=c.$normalize("md-"+e);t&&J(e,t),c.$observe(n,function(t){be[e]=t})}function T(e,t){function n(t){be[e]="false"!==t}var a=c.$normalize("md-"+e);t&&J(e,t),c.hasOwnProperty(a)&&n(c[a]),c.$observe(a,n)}function v(){he=!0,t.element(s).off("resize",B)}function $(e){var n=_();t.element(n.wrapper).toggleClass("md-stretch-tabs",U()),oe()}function C(e){be.shouldCenterTabs=K()}function I(e,n){if(e!==n){var a=_();t.forEach(a.tabs,function(t){t.style.maxWidth=e+"px"}),o.nextTick(be.updateInkBarStyles)}}function w(e,t){e!==t&&(be.maxTabWidth=X(),be.shouldCenterTabs=K(),o.nextTick(function(){be.maxTabWidth=X(),ne(be.selectedIndex)}))}function y(e){a[e?"removeClass":"addClass"]("md-no-tab-content")}function k(n){var a=_(),s=be.shouldCenterTabs?"":"-"+n+"px";t.element(a.paging).css(i.CSS.TRANSFORM,"translate3d("+s+", 0, 0)"),e.$broadcast("$mdTabsPaginationChanged")}function S(e,t){e!==t&&_().tabs[e]&&(ne(),te())}function P(t,n){t!==n&&(be.selectedIndex=G(t),be.lastSelectedIndex=n,be.updateInkBarStyles(),de(),ne(t),e.$broadcast("$mdTabsChanged"),be.tabs[n]&&be.tabs[n].scope.deselect(),be.tabs[t]&&be.tabs[t].scope.select())}function L(e){var t=a[0].getElementsByTagName("md-tab");return Array.prototype.indexOf.call(t,e[0])}function W(){W.watcher||(W.watcher=e.$watch(function(){o.nextTick(function(){W.watcher&&a.prop("offsetParent")&&(W.watcher(),W.watcher=null,B())},!1)}))}function D(e){switch(e.keyCode){case i.KEY_CODE.LEFT_ARROW:e.preventDefault(),ee(-1,!0);break;case i.KEY_CODE.RIGHT_ARROW:e.preventDefault(),ee(1,!0);break;case i.KEY_CODE.SPACE:case i.KEY_CODE.ENTER:e.preventDefault(),me||A(be.focusIndex)}}function A(e,t){me||(be.focusIndex=be.selectedIndex=e),t&&be.noSelectClick||o.nextTick(function(){be.tabs[e].element.triggerHandler("click")},!1)}function O(e){be.shouldPaginate&&(e.preventDefault(),be.offsetLeft=ce(be.offsetLeft-e.wheelDelta))}function E(){var e,t,n=_(),a=n.canvas.clientWidth,s=a+be.offsetLeft;for(e=0;e<n.tabs.length&&(t=n.tabs[e],!(t.offsetLeft+t.offsetWidth>s));e++);a>t.offsetWidth?be.offsetLeft=ce(t.offsetLeft):be.offsetLeft=ce(t.offsetLeft+(t.offsetWidth-a+1))}function F(){var e,t,n=_();for(e=0;e<n.tabs.length&&(t=n.tabs[e],!(t.offsetLeft+t.offsetWidth>=be.offsetLeft));e++);n.canvas.clientWidth>t.offsetWidth?be.offsetLeft=ce(t.offsetLeft+t.offsetWidth-n.canvas.clientWidth):be.offsetLeft=ce(t.offsetLeft)}function B(){be.lastSelectedIndex=be.selectedIndex,be.offsetLeft=ce(be.offsetLeft),o.nextTick(function(){be.updateInkBarStyles(),Q()})}function M(e){t.element(_().inkBar).toggleClass("ng-hide",e)}function R(e){a.toggleClass("md-dynamic-height",e)}function q(e){if(!he){var t=be.selectedIndex,n=be.tabs.splice(e.getIndex(),1)[0];ie(),be.selectedIndex===t&&(n.scope.deselect(),be.tabs[be.selectedIndex]&&be.tabs[be.selectedIndex].scope.select()),o.nextTick(function(){Q(),be.offsetLeft=ce(be.offsetLeft)})}}function H(e,n){var a=ge,s={getIndex:function(){return be.tabs.indexOf(i)},isActive:function(){return this.getIndex()===be.selectedIndex},isLeft:function(){return this.getIndex()<be.selectedIndex},isRight:function(){return this.getIndex()>be.selectedIndex},shouldRender:function(){return!be.noDisconnect||this.isActive()},hasFocus:function(){return be.styleTabItemFocus&&be.hasFocus&&this.getIndex()===be.focusIndex},id:o.nextUid(),hasContent:!(!e.template||!e.template.trim())},i=t.extend(s,e);return t.isDefined(n)?be.tabs.splice(n,0,i):be.tabs.push(i),ae(),se(),o.nextTick(function(){Q(),fe(i),a&&be.autoselect&&o.nextTick(function(){o.nextTick(function(){A(be.tabs.indexOf(i))})})}),i}function _(){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 j(){return be.offsetLeft>0}function N(){var e=_(),t=e.tabs[e.tabs.length-1];return t&&t.offsetLeft+t.offsetWidth>e.canvas.clientWidth+be.offsetLeft}function z(){var e=be.tabs[be.focusIndex];return e&&e.id?"tab-item-"+e.id:null}function U(){switch(be.stretchTabs){case"always":return!0;case"never":return!1;default:return!be.shouldPaginate&&s.matchMedia("(max-width: 600px)").matches}}function K(){return be.centerTabs&&!be.shouldPaginate}function Y(){if(be.noPagination||!ge)return!1;var e=a.prop("clientWidth");return t.forEach(_().dummies,function(t){e-=t.offsetWidth}),e<0}function G(e){if(e===-1)return-1;var t,n,a=Math.max(be.tabs.length-e,e);for(t=0;t<=a;t++){if(n=be.tabs[e+t],n&&n.scope.disabled!==!0)return n.getIndex();if(n=be.tabs[e-t],n&&n.scope.disabled!==!0)return n.getIndex()}return e}function J(e,t,n){Object.defineProperty(be,e,{get:function(){return n},set:function(e){var a=n;n=e,t&&t(e,a)}})}function Q(){be.maxTabWidth=X(),be.shouldPaginate=Y()}function V(e){var n=0;return t.forEach(e,function(e){n+=Math.max(e.offsetWidth,e.getBoundingClientRect().width)}),Math.ceil(n)}function X(){return a.prop("clientWidth")}function Z(){var e=be.tabs[be.selectedIndex],t=be.tabs[be.focusIndex];be.tabs=be.tabs.sort(function(e,t){return e.index-t.index}),be.selectedIndex=be.tabs.indexOf(e),be.focusIndex=be.tabs.indexOf(t)}function ee(e,t){var n,a=t?"focusIndex":"selectedIndex",s=be[a];for(n=s+e;be.tabs[n]&&be.tabs[n].scope.disabled;n+=e);be.tabs[n]&&(be[a]=n)}function te(){be.styleTabItemFocus="keyboard"===b.getLastInteractionType(),_().dummies[be.focusIndex].focus()}function ne(e){var n=_();if(t.isNumber(e)||(e=be.focusIndex),n.tabs[e]&&!be.shouldCenterTabs){var a=n.tabs[e],s=a.offsetLeft,i=a.offsetWidth+s;be.offsetLeft=Math.max(be.offsetLeft,ce(i-n.canvas.clientWidth+64)),be.offsetLeft=Math.min(be.offsetLeft,ce(s))}}function ae(){pe.forEach(function(e){o.nextTick(e)}),pe=[]}function se(){for(var e=!1,t=0;t<be.tabs.length;t++)if(be.tabs[t].hasContent){e=!0;break}be.hasContent=e}function ie(){be.selectedIndex=G(be.selectedIndex),be.focusIndex=G(be.focusIndex)}function de(){if(!be.dynamicHeight)return a.css("height","");if(!be.tabs.length)return pe.push(de);var e=_(),t=e.contents[be.selectedIndex],s=t?t.offsetHeight:0,i=e.wrapper.offsetHeight,d=s+i,c=a.prop("clientHeight");if(c!==d){"bottom"===a.attr("md-align-tabs")&&(c-=i,d-=i,a.attr("md-border-bottom")!==n&&++c),me=!0;var l={height:c+"px"},f={height:d+"px"};a.css(l),r(a,{from:l,to:f,easing:"cubic-bezier(0.35, 0, 0.25, 1)",duration:.5}).start().done(function(){a.css({transition:"none",height:""}),o.nextTick(function(){a.css("transition","")}),me=!1})}}function oe(){var e=_();if(!e.tabs[be.selectedIndex])return void t.element(e.inkBar).css({left:"auto",right:"auto"});if(!be.tabs.length)return pe.push(be.updateInkBarStyles);if(!a.prop("offsetParent"))return W();var n=be.selectedIndex,s=e.paging.offsetWidth,i=e.tabs[n],d=i.offsetLeft,r=s-d-i.offsetWidth;if(be.shouldCenterTabs){var c=V(e.tabs);s>c&&o.nextTick(oe,!1)}re(),t.element(e.inkBar).css({left:d+"px",right:r+"px"})}function re(){var e=_(),n=be.selectedIndex,a=be.lastSelectedIndex,s=t.element(e.inkBar);t.isNumber(a)&&s.toggleClass("md-left",n<a).toggleClass("md-right",n>a)}function ce(e){var t=_();if(!t.tabs.length||!be.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 le(e,n){var a=_(),s={colorElement:t.element(a.inkBar)};d.attach(e,n,s)}function fe(e){if(e.hasContent){var n=a[0].querySelectorAll('[md-tab-id="'+e.id+'"]');t.element(n).attr("aria-controls",be.tabContentPrefix+e.id)}}var be=this,me=!1,ue=_(),pe=[],he=!1,ge=!1;be.$onInit=m,be.updatePagination=o.debounce(Q,100),be.redirectFocus=te,be.attachRipple=le,be.insertTab=H,be.removeTab=q,be.select=A,be.scroll=O,be.nextPage=E,be.previousPage=F,be.keydown=D,be.canPageForward=N,be.canPageBack=j,be.refreshIndex=ie,be.incrementIndex=ee,be.getTabElementIndex=L,be.updateInkBarStyles=o.debounce(oe,100),be.updateTabOrder=o.debounce(Z,100),be.getFocusedTabId=z,1===t.version.major&&t.version.minor<=4&&this.$onInit()}function r(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="{{$mdTabsCtrl.getFocusedTabId()}}" 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" md-tab-id="{{::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}}" md-tab-id="{{::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="{{:: $mdTabsCtrl.tabContentPrefix + 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="tab.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 c(e,t){return{require:"^?mdTabs",link:function(n,a,s,i){if(i){var d,o,r=function(){i.updatePagination(),i.updateInkBarStyles()};if("MutationObserver"in t){var c={childList:!0,subtree:!0,characterData:!0};d=new MutationObserver(r),d.observe(a[0],c),o=d.disconnect.bind(d)}else{var l=e.debounce(r,15,null,!1);a.on("DOMSubtreeModified",l),o=a.off.bind(a,"DOMSubtreeModified",l)}n.$on("$destroy",function(){o()})}}}}function l(e,t){function n(n,a,s,i){function d(){n.$watch("connected",function(e){e===!1?o():r()}),n.$on("$destroy",r)}function o(){i.enableDisconnect&&t.disconnectScope(c)}function r(){i.enableDisconnect&&t.reconnectScope(c)}if(i){var c=i.enableDisconnect?n.compileScope.$new():n.compileScope;return a.html(n.template),e(a.contents())(c),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),o.$inject=["$scope","$element","$window","$mdConstant","$mdTabInkRipple","$mdUtil","$animateCss","$attrs","$compile","$mdTheming","$mdInteraction"],t.module("material.components.tabs").controller("MdTabsController",o),r.$inject=["$$mdSvgRegistry"],t.module("material.components.tabs").directive("mdTabs",r),c.$inject=["$mdUtil","$window"],t.module("material.components.tabs").directive("mdTabsDummyWrapper",c),l.$inject=["$compile","$mdUtil"],t.module("material.components.tabs").directive("mdTabsTemplate",l)}(window,window.angular);
|