summaryrefslogtreecommitdiffstats
path: root/modules-available/permissionmanager/clientscript.js
blob: 90d666886301fd8d533809dadb88ab954f56f1c1 (plain) (blame)
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
document.addEventListener("DOMContentLoaded", function() {
	var selectize = $("#select-role");
	if (selectize.length) {
		selectize = selectize.selectize({
			allowEmptyOption: false,
			maxItems: null,
			highlight: false,
			hideSelected: true,
			create: false,
			plugins: ["remove_button"]
		})[0].selectize;

		var $body = $(".dataTable tbody");
		var filterFunc = function(value) {
			var selected = selectize.getValue();
			if (!selected || !selected.length) {
				$body.find("tr").show();
			} else {
				$body.find("tr").hide();
				var str = 'tr.roleid-' + selected.join('.roleid-');
				$body.find(str).show();
			}
		};

		selectize.on("item_add", filterFunc);

		selectize.on("item_remove",filterFunc);
	}

	$("tr").on("click", function(e) {
		if (e.target.type !== "checkbox" && e.target.tagName !== "A") {
			$(this).find("input[type=checkbox]").trigger("click");
		}
	});
});