@@ 5558-5622 (lines=65) @@ | ||
5555 | }; |
|
5556 | }) |
|
5557 | ||
5558 | .directive('uibTab', ['$parse', function($parse) { |
|
5559 | return { |
|
5560 | require: '^uibTabset', |
|
5561 | replace: true, |
|
5562 | templateUrl: function(element, attrs) { |
|
5563 | return attrs.templateUrl || 'uib/template/tabs/tab.html'; |
|
5564 | }, |
|
5565 | transclude: true, |
|
5566 | scope: { |
|
5567 | heading: '@', |
|
5568 | index: '=?', |
|
5569 | classes: '@?', |
|
5570 | onSelect: '&select', //This callback is called in contentHeadingTransclude |
|
5571 | //once it inserts the tab's content into the dom |
|
5572 | onDeselect: '&deselect' |
|
5573 | }, |
|
5574 | controller: function() { |
|
5575 | //Empty controller so other directives can require being 'under' a tab |
|
5576 | }, |
|
5577 | controllerAs: 'tab', |
|
5578 | link: function(scope, elm, attrs, tabsetCtrl, transclude) { |
|
5579 | scope.disabled = false; |
|
5580 | if (attrs.disable) { |
|
5581 | scope.$parent.$watch($parse(attrs.disable), function(value) { |
|
5582 | scope.disabled = !! value; |
|
5583 | }); |
|
5584 | } |
|
5585 | ||
5586 | if (angular.isUndefined(attrs.index)) { |
|
5587 | if (tabsetCtrl.tabs && tabsetCtrl.tabs.length) { |
|
5588 | scope.index = Math.max.apply(null, tabsetCtrl.tabs.map(function(t) { return t.index; })) + 1; |
|
5589 | } else { |
|
5590 | scope.index = 0; |
|
5591 | } |
|
5592 | } |
|
5593 | ||
5594 | if (angular.isUndefined(attrs.classes)) { |
|
5595 | scope.classes = ''; |
|
5596 | } |
|
5597 | ||
5598 | scope.select = function(evt) { |
|
5599 | if (!scope.disabled) { |
|
5600 | var index; |
|
5601 | for (var i = 0; i < tabsetCtrl.tabs.length; i++) { |
|
5602 | if (tabsetCtrl.tabs[i].tab === scope) { |
|
5603 | index = i; |
|
5604 | break; |
|
5605 | } |
|
5606 | } |
|
5607 | ||
5608 | tabsetCtrl.select(index, evt); |
|
5609 | } |
|
5610 | }; |
|
5611 | ||
5612 | tabsetCtrl.addTab(scope); |
|
5613 | scope.$on('$destroy', function() { |
|
5614 | tabsetCtrl.removeTab(scope); |
|
5615 | }); |
|
5616 | ||
5617 | //We need to transclude later, once the content container is ready. |
|
5618 | //when this link happens, we're inside a tab heading. |
|
5619 | scope.$transcludeFn = transclude; |
|
5620 | } |
|
5621 | }; |
|
5622 | }]) |
|
5623 | ||
5624 | .directive('uibTabHeadingTransclude', function() { |
|
5625 | return { |
@@ 5557-5621 (lines=65) @@ | ||
5554 | }; |
|
5555 | }) |
|
5556 | ||
5557 | .directive('uibTab', ['$parse', function($parse) { |
|
5558 | return { |
|
5559 | require: '^uibTabset', |
|
5560 | replace: true, |
|
5561 | templateUrl: function(element, attrs) { |
|
5562 | return attrs.templateUrl || 'uib/template/tabs/tab.html'; |
|
5563 | }, |
|
5564 | transclude: true, |
|
5565 | scope: { |
|
5566 | heading: '@', |
|
5567 | index: '=?', |
|
5568 | classes: '@?', |
|
5569 | onSelect: '&select', //This callback is called in contentHeadingTransclude |
|
5570 | //once it inserts the tab's content into the dom |
|
5571 | onDeselect: '&deselect' |
|
5572 | }, |
|
5573 | controller: function() { |
|
5574 | //Empty controller so other directives can require being 'under' a tab |
|
5575 | }, |
|
5576 | controllerAs: 'tab', |
|
5577 | link: function(scope, elm, attrs, tabsetCtrl, transclude) { |
|
5578 | scope.disabled = false; |
|
5579 | if (attrs.disable) { |
|
5580 | scope.$parent.$watch($parse(attrs.disable), function(value) { |
|
5581 | scope.disabled = !! value; |
|
5582 | }); |
|
5583 | } |
|
5584 | ||
5585 | if (angular.isUndefined(attrs.index)) { |
|
5586 | if (tabsetCtrl.tabs && tabsetCtrl.tabs.length) { |
|
5587 | scope.index = Math.max.apply(null, tabsetCtrl.tabs.map(function(t) { return t.index; })) + 1; |
|
5588 | } else { |
|
5589 | scope.index = 0; |
|
5590 | } |
|
5591 | } |
|
5592 | ||
5593 | if (angular.isUndefined(attrs.classes)) { |
|
5594 | scope.classes = ''; |
|
5595 | } |
|
5596 | ||
5597 | scope.select = function(evt) { |
|
5598 | if (!scope.disabled) { |
|
5599 | var index; |
|
5600 | for (var i = 0; i < tabsetCtrl.tabs.length; i++) { |
|
5601 | if (tabsetCtrl.tabs[i].tab === scope) { |
|
5602 | index = i; |
|
5603 | break; |
|
5604 | } |
|
5605 | } |
|
5606 | ||
5607 | tabsetCtrl.select(index, evt); |
|
5608 | } |
|
5609 | }; |
|
5610 | ||
5611 | tabsetCtrl.addTab(scope); |
|
5612 | scope.$on('$destroy', function() { |
|
5613 | tabsetCtrl.removeTab(scope); |
|
5614 | }); |
|
5615 | ||
5616 | //We need to transclude later, once the content container is ready. |
|
5617 | //when this link happens, we're inside a tab heading. |
|
5618 | scope.$transcludeFn = transclude; |
|
5619 | } |
|
5620 | }; |
|
5621 | }]) |
|
5622 | ||
5623 | .directive('uibTabHeadingTransclude', function() { |
|
5624 | return { |