-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathselection-button.js
46 lines (37 loc) · 1.2 KB
/
selection-button.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
angular
.module('nzbhydraApp')
.directive('selectionButton', selectionButton);
function selectionButton() {
return {
templateUrl: 'static/html/directives/selection-button.html',
scope: {
selected: "=",
selectable: "=",
invertSelection: "<",
selectAll: "<",
deselectAll: "<",
btn: "@"
},
controller: controller
};
function controller($scope) {
if (angular.isUndefined($scope.btn)) {
$scope.btn = "default"; //Will form class "btn-default"
}
if (angular.isUndefined($scope.invertSelection)) {
$scope.invertSelection = function () {
$scope.selected = _.difference($scope.selectable, $scope.selected);
};
}
if (angular.isUndefined($scope.selectAll)) {
$scope.selectAll = function () {
$scope.selected.push.apply($scope.selected, $scope.selectable);
};
}
if (angular.isUndefined($scope.deselectAll)) {
$scope.deselectAll = function () {
$scope.selected.splice(0, $scope.selected.length);
};
}
}
}