Revision 3709:c88e69474c34,
1.0 KB
checked in by franck <carnet.franck.paul@…>, 7 years ago
(diff) |
use strict and no more linter warnings/errors as far as possible, switch from inline js to separate loaded file
|
Line | |
---|
1 | /*global $, jQuery */ |
---|
2 | 'use strict'; |
---|
3 | |
---|
4 | jQuery.fn.updatePagesPermissionsForm = function() { |
---|
5 | return this.each(function() { |
---|
6 | |
---|
7 | var perms = {}; |
---|
8 | var re = /^perm\[(.+?)\]\[(.+?)\]$/; |
---|
9 | var e, prop; |
---|
10 | |
---|
11 | // Building a nice object of form elements |
---|
12 | for (var i = 0; i < this.elements.length; i++) { |
---|
13 | e = this.elements[i]; |
---|
14 | |
---|
15 | if (e.name == undefined) { |
---|
16 | continue; |
---|
17 | } |
---|
18 | prop = e.name.match(re); |
---|
19 | if (!prop) { |
---|
20 | continue; |
---|
21 | } |
---|
22 | if (perms[prop[1]] == undefined) { |
---|
23 | perms[prop[1]] = {}; |
---|
24 | } |
---|
25 | perms[prop[1]][prop[2]] = e; |
---|
26 | |
---|
27 | // select related permissions for admin |
---|
28 | if (prop[2] == 'admin') { |
---|
29 | if (e.checked) { |
---|
30 | admin(e, perms, re); |
---|
31 | } |
---|
32 | $(e).click(function() { |
---|
33 | admin(this, perms, re); |
---|
34 | }); |
---|
35 | } |
---|
36 | } |
---|
37 | |
---|
38 | function admin(E, perms, re) { |
---|
39 | var P = E.name.match(re); |
---|
40 | |
---|
41 | perms[P[1]].pages.checked = E.checked; |
---|
42 | perms[P[1]].pages.disabled = E.checked; |
---|
43 | } |
---|
44 | }); |
---|
45 | }; |
---|
46 | |
---|
47 | $(function() { |
---|
48 | $('#permissions-form').updatePagesPermissionsForm(); |
---|
49 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.