/** * @ngdoc directive * @name Bastion.components.directive:nutupaneTable * @restrict A * * @require $compile * * @description * * @example */ angular.module('Bastion.components').directive('nutupaneTable', ['$compile', '$window', function ($compile, $window) { return { restrict: 'A', link: function (scope, element) { var originalTable, clonedTable, clonedThs, windowElement = angular.element($window); scope.$on("$stateChangeSuccess", function (event, newState, newParams, oldState) { // Only clone the table if the collapsed value changed or it's the first time. if (newState.collapsed !== oldState.collapsed || !oldState.name) { buildTable(); } else { element.find("table:not(.cloned-nutupane-table)").find('thead').hide(); } }); function buildTable() { element.find('.cloned-nutupane-table').remove(); originalTable = element.find('table'); clonedTable = originalTable.clone(); clonedTable.removeAttr("nutupane-table"); clonedTable.addClass("cloned-nutupane-table"); clonedTable.find('tbody').remove(); clonedTable.find('thead tr').append('