Dotclear

source: plugins/pages/js/_users_actions.js @ 3880:e6d1f6d9d7df

Revision 3880:e6d1f6d9d7df, 1.0 KB checked in by franck <carnet.franck.paul@…>, 7 years ago (diff)

Use let and const rather than var (ES2015/ES6), use template string where is more efficient

Line 
1/*global $, jQuery */
2'use strict';
3
4jQuery.fn.updatePagesPermissionsForm = function() {
5  return this.each(function() {
6
7    let perms = {};
8    const re = /^perm\[(.+?)\]\[(.+?)\]$/;
9
10    // Building a nice object of form elements
11    for (let i = 0; i < this.elements.length; i++) {
12      const e = this.elements[i];
13
14      if (e.name == undefined) {
15        continue;
16      }
17      const prop = e.name.match(re);
18      if (!prop) {
19        continue;
20      }
21      if (perms[prop[1]] == undefined) {
22        perms[prop[1]] = {};
23      }
24      perms[prop[1]][prop[2]] = e;
25
26      // select related permissions for admin
27      if (prop[2] == 'admin') {
28        if (e.checked) {
29          admin(e, perms, re);
30        }
31        $(e).click(function() {
32          admin(this, perms, re);
33        });
34      }
35    }
36
37    function admin(E, perms, re) {
38      const P = E.name.match(re);
39
40      perms[P[1]].pages.checked = E.checked;
41      perms[P[1]].pages.disabled = E.checked;
42    }
43  });
44};
45
46$(function() {
47  $('#permissions-form').updatePagesPermissionsForm();
48});
Note: See TracBrowser for help on using the repository browser.

Sites map