1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 02:29:26 +02:00
OpenSTF/res/app/components/stf/common-ui/nice-tabs/nice-tabs-directive.js
2014-03-27 20:03:22 +09:00

36 lines
920 B
JavaScript

module.exports = function niceTabsDirective() {
return {
restrict: 'EA',
replace: true,
scope: {
tabs: '=',
filter: '='
},
template: require('./nice-tabs.jade'),
link: function (scope, element, attrs) {
// TODO: add support for 'key' for saving in localstorage
// TODO: add support for 'direction=below' for below tabs
scope.$watch('tabs', function (newValue, oldValue) {
if (newValue !== oldValue) {
scope.tabs = newValue
}
})
scope.$watch('filter', function (newValue, oldValue) {
if (newValue !== oldValue) {
scope.filter = newValue
}
})
scope.tabFound = function (tab) {
var found = false
angular.forEach(tab.filters, function (value) {
if (value === scope.filter) {
found = true
}
})
return found
}
}
}
}