manager-view.js
1.72 KB
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
46
47
48
49
/* global $dj, gettext */
$(function () {
"use strict";
$('#add-vocabulary').click(function () {
var new_vocab = $('#new-vocabulary');
var name = new_vocab.value();
new_vocab.val('');
$.ajaxJSON({
method: 'post',
url: $dj.ajax_add_vocabulary,
data: {name: name},
callback: function () {
location.reload(); // porządniejszy by był zwykły formularz...
},
description: gettext("Dodanie słownika")
});
});
$('.user-privileges').find('input[type=checkbox]').change(function () {
var $t = $(this),
user_id = this.id.split('-')[1],
type = this.id.split('-')[0],
index = this.id.split('-')[2],
table_id = $t.closest('table')[0].id,
vocab_name = table_id.substr(table_id.indexOf('_') + 1);
$.ajaxJSON({
method: 'post',
url: $dj.ajax_set_permission,
data: {
name: vocab_name,
user_id: user_id,
perm: type,
on: $t.is(':checked')
}
});
var view_checkbox = $('#view-' + user_id + '-' + index),
change_checkbox = $('#change-' + user_id + '-' + index);
if (type === 'change' && $t.is(':checked') &&
!view_checkbox.is(':checked')) {
view_checkbox.prop('checked', true).change();
}
if (type === 'view' && !$t.is(':checked') &&
change_checkbox.is(':checked')) {
change_checkbox.prop('checked', false).change();
}
});
$('#vocab-accordion').togglepanels();
//{autoHeight: false, collapsible: true, active: false});
});