This repository has been archived by the owner on Jul 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
dualmultiselect.js
28 lines (27 loc) · 1.77 KB
/
dualmultiselect.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
/*
Created by Alex Klibisz, [email protected]
February 2015
*/
var a;
a = angular.module("dualmultiselect", []), a.directive("dualmultiselect", [function() {
return {
restrict: 'E',
scope: {
options: '='
},
controller:['$scope', function($scope) {
$scope.transfer = function(from, to, index) {
if (index >= 0) {
to.push(from[index]);
from.splice(index, 1);
} else {
for (var i = 0; i < from.length; i++) {
to.push(from[i]);
}
from.length = 0;
}
};
}],
template: '<div class="dualmultiselect"> <div class="row"> <div class="col-lg-12 col-md-12 col-sm-12"> <h4>{{options.title}}<small> {{options.helpMessage}}</small> </h4> <input class="form-control" placeholder="{{options.filterPlaceHolder}}" ng-model="searchTerm"> </div></div><div class="row"> <div class="col-lg-6 col-md-6 col-sm-6"> <label>{{options.labelAll}}</label> <button type="button" class="btn btn-default btn-xs" ng-click="transfer(options.items, options.selectedItems, -1)"> Select All </button> <div class="pool"> <ul> <li ng-repeat="item in options.items | filter: searchTerm | orderBy: options.orderProperty"> <a href="" ng-click="transfer(options.items, options.selectedItems, options.items.indexOf(item))">{{item.name}} ⇒ </a> </li></ul> </div></div><div class="col-lg-6 col-md-6 col-sm-6"> <label>{{options.labelSelected}}</label> <button type="button" class="btn btn-default btn-xs" ng-click="transfer(options.selectedItems, options.items, -1)"> Deselect All </button> <div class="pool"> <ul> <li ng-repeat="item in options.selectedItems | orderBy: options.orderProperty"> <a href="" ng-click="transfer(options.selectedItems, options.items, options.selectedItems.indexOf(item))"> ⇐ {{item.name}}</a> </li></ul> </div></div></div></div>'
};
}]);