angular.module('hexmeh', []) .directive('fadey', function() { return { restrict: 'A', link: function(scope, elm, attrs) { var duration = parseInt(attrs.fadey); if (isNaN(duration)) { duration = 500; } elm = jQuery(elm); elm.hide(); elm.fadeIn(duration) scope.destroy = function(complete) { elm.fadeOut(duration, function() { if (complete) { complete.apply(scope); } }); }; } }; }) .directive('tabs', function () { return { restrict: 'E', transclude: true, scope: {}, controller: function($scope, $element) { var panes = $scope.panes = []; $scope.select = function(pane) { angular.forEach(panes, function(pane) { pane.selected = false; }); pane.selected = true; } this.addPane = function(pane) { if (panes.length == 0) $scope.select(pane); panes.push(pane); } }, template: '
' + '' + '
' + '
', replace: true }; }) .directive('pane', function() { return { require: '^tabs', restrict: 'E', transclude: true, scope: { title: '@' }, link: function(scope, element, attrs, tabsCtrl) { tabsCtrl.addPane(scope); }, template: '
' + '
', replace: true }; });