2
* Hide and show all checkboxes
3
* status = true (show boxes), false (hide boxes)
5
function display_checkboxes(status)
7
var form = document.getElementById('set-permissions');
8
var cb = document.getElementsByTagName('input');
22
for (var i = 0; i < cb.length; i++ )
24
if (cb[i].className == 'permissions-checkbox')
26
cb[i].style.display = display;
35
* Change opacity of element
37
* value = 0 (hidden) till 10 (fully visible)
39
function set_opacity(e, value) {
40
e.style.opacity = value/10;
42
//IE opacity currently turned off, because of its astronomical stupidity
43
//e.style.filter = 'alpha(opacity=' + value*10 + ')';
47
* Reset the opacity and checkboxes
48
* block_id = id of the element that needs to be toggled
50
function toggle_opacity(block_id) {
51
var cb = document.getElementById('checkbox' + block_id);
52
var fs = document.getElementById('perm' + block_id);
65
* Reset the opacity and checkboxes
66
* value = 0 (checked) and 1 (unchecked)
67
* except_id = id of the element not to hide
69
function reset_opacity(status, except_id) {
70
var perm = document.getElementById('set-permissions');
71
var fs = perm.getElementsByTagName('fieldset');
79
for (var i = 0; i < fs.length; i++ )
81
if (fs[i].className != 'quick')
83
set_opacity(fs[i], opacity);
87
if (typeof(except_id) != 'undefined')
89
set_opacity(document.getElementById('perm' + except_id), 10);
92
//reset checkboxes too
93
marklist('set-permissions', 'inherit', !status);
98
* Check whether we have a full radiobutton row of true
99
* index = offset for the row of inputs (0 == first row, 1 == second, 2 == third),
100
* rb = array of radiobuttons
102
function get_radio_status(index, rb)
104
for (var i = index; i < rb.length; i = i + 3 )
106
if (rb[i].checked != true)
110
//at least one is true, but not all (custom)
113
//first one is not true
118
// all radiobuttons true
124
* id = panel the tab needs to be set for,
125
* init = initialising on open,
126
* quick = If no calculation needed, this contains the colour
128
function set_colours(id, init, quick)
130
var table = document.getElementById('table' + id);
131
var tab = document.getElementById('tab' + id);
133
if (typeof(quick) != 'undefined')
135
tab.className = 'permissions-preset-' + quick + ' activetab';
139
var rb = table.getElementsByTagName('input');
140
var colour = 'custom';
142
var status = get_radio_status(0, rb);
148
else if (status == 0)
151
status = get_radio_status(1, rb);
157
else if (status == 0)
159
// We move on to Never
160
status = get_radio_status(2, rb);
171
tab.className = 'permissions-preset-' + colour;
175
tab.className = 'permissions-preset-' + colour + ' activetab';
180
* Initialise advanced tab colours on first load
181
* block_id = block that is opened
183
function init_colours(block_id)
185
var block = document.getElementById('advanced' + block_id);
186
var panels = block.getElementsByTagName('div');
187
var tab = document.getElementById('tab' + id);
189
for (var i = 0; i < panels.length; i++)
191
if(panels[i].className == 'permissions-panel')
193
set_colours(panels[i].id.replace(/options/, ''), true);
197
tab.className = tab.className + ' activetab';
201
* Show/hide option panels
202
* value = suffix for ID to show
203
* adv = we are opening advanced permissions
204
* view = called from view permissions
206
function swap_options(pmask, fmask, cat, adv, view)
208
id = pmask + fmask + cat;
209
active_option = active_pmask + active_fmask + active_cat;
211
var old_tab = document.getElementById('tab' + active_option);
212
var new_tab = document.getElementById('tab' + id);
213
var adv_block = document.getElementById('advanced' + pmask + fmask);
215
if (adv_block.style.display == 'block' && adv == true)
217
dE('advanced' + pmask + fmask, -1);
219
display_checkboxes(false);
223
// no need to set anything if we are clicking on the same tab again
224
if (new_tab == old_tab && !adv)
230
if (adv && (pmask + fmask) != (active_pmask + active_fmask))
232
init_colours(pmask + fmask);
233
display_checkboxes(true);
238
//Checkbox might have been clicked, but we need full visibility
239
display_checkboxes(true);
244
old_tab.className = old_tab.className.replace(/\ activetab/g, '');
245
new_tab.className = new_tab.className + ' activetab';
247
if (id == active_option && adv != true)
252
dE('options' + active_option, -1);
254
//hiding and showing the checkbox
255
if (document.getElementById('checkbox' + active_pmask + active_fmask))
257
dE('checkbox' + pmask + fmask, -1);
259
if ((pmask + fmask) != (active_pmask + active_fmask))
261
document.getElementById('checkbox' + active_pmask + active_fmask).style.display = 'inline';
267
dE('advanced' + active_pmask + active_fmask, -1);
272
dE('advanced' + pmask + fmask, 1);
274
dE('options' + id, 1);
276
active_pmask = pmask;
277
active_fmask = fmask;
282
* Mark all radio buttons in one panel
283
* id = table ID container, s = status ['y'/'u'/'n']
285
function mark_options(id, s)
287
var t = document.getElementById(id);
294
var rb = t.getElementsByTagName('input');
296
for (var r = 0; r < rb.length; r++)
298
if (rb[r].id.substr(rb[r].id.length-1) == s)
300
rb[r].checked = true;
305
function mark_one_option(id, field_name, s)
307
var t = document.getElementById(id);
314
var rb = t.getElementsByTagName('input');
316
for (var r = 0; r < rb.length; r++)
318
if (rb[r].id.substr(rb[r].id.length-field_name.length-3, field_name.length) == field_name && rb[r].id.substr(rb[r].id.length-1) == s)
320
rb[r].checked = true;
326
* Reset role dropdown field to Select role... if an option gets changed
328
function reset_role(id)
330
var t = document.getElementById(id);
337
t.options[0].selected = true;
341
* Load role and set options accordingly
343
function set_role_settings(role_id, target_id)
345
settings = role_options[role_id];
352
// Mark all options to no (unset) first...
353
mark_options(target_id, 'u');
355
for (var r in settings)
357
mark_one_option(target_id, r, (settings[r] == 1) ? 'y' : 'n');