Revision 819d58ac
Added by Stephen Beaver over 9 years ago
src/usr/local/www/system_groupmanager_addprivs.php | ||
---|---|---|
207 | 207 |
$a_group['priv'], |
208 | 208 |
build_priv_list(), |
209 | 209 |
true |
210 |
))->addClass('multiselect')->setHelp('Hold down CTRL (PC)/COMMAND (Mac) key to select multiple items.')->setAttribute('style', 'height:400px;'); |
|
210 |
))->addClass('multiselect') |
|
211 |
->setHelp('Hold down CTRL (PC)/COMMAND (Mac) key to select multiple items.'); |
|
212 |
|
|
213 |
$section->addInput(new Form_Select( |
|
214 |
'shadow', |
|
215 |
'Shadow', |
|
216 |
null, |
|
217 |
build_priv_list(), |
|
218 |
true |
|
219 |
))->addClass('shadowselect') |
|
220 |
->setHelp('Hold down CTRL (PC)/COMMAND (Mac) key to select multiple items'); |
|
211 | 221 |
|
212 | 222 |
$section->addInput(new Form_Input( |
213 | 223 |
'filtertxt', |
... | ... | |
268 | 278 |
echo $jdescs; |
269 | 279 |
} |
270 | 280 |
?> |
281 |
$('.shadowselect').hide(); |
|
282 |
|
|
271 | 283 |
// Set the number of options to display |
272 | 284 |
$('.multiselect').attr("size","20"); |
285 |
$('.shadowselect').attr("size","20"); |
|
273 | 286 |
|
274 | 287 |
// When the 'sysprivs" selector is clicked, we display a description |
275 | 288 |
$('.multiselect').click(function() { |
276 | 289 |
$('#pdesc').html('<span class="text-info">' + descs[$(this).children('option:selected').index()] + '</span>'); |
290 |
|
|
291 |
// and update the shadow list from the real list |
|
292 |
$(".multiselect option").each(function() { |
|
293 |
shadowoption = $('.shadowselect option').filter('[value=' + $(this).val() + ']'); |
|
294 |
|
|
295 |
if ($(this).is(':selected')) { |
|
296 |
shadowoption.prop("selected", true); |
|
297 |
} else { |
|
298 |
shadowoption.prop("selected", false); |
|
299 |
} |
|
300 |
}); |
|
277 | 301 |
}); |
278 | 302 |
|
279 | 303 |
$('#btnfilter').prop('type', 'button'); |
280 | 304 |
|
281 | 305 |
$('#btnfilter').click(function() { |
282 | 306 |
searchterm = $('#filtertxt').val().toLowerCase(); |
307 |
copyselect(true); |
|
283 | 308 |
|
309 |
// Then filter |
|
284 | 310 |
$(".multiselect > option").each(function() { |
285 |
if (this.text.toLowerCase().indexOf(searchterm) > -1 ) { |
|
286 |
$(this).show(); |
|
287 |
} else { |
|
288 |
$(this).hide(); |
|
311 |
if (this.text.toLowerCase().indexOf(searchterm) == -1 ) { |
|
312 |
$(this).remove(); |
|
289 | 313 |
} |
290 | 314 |
}); |
291 | 315 |
}); |
... | ... | |
293 | 317 |
$('#btnclear').prop('type', 'button'); |
294 | 318 |
|
295 | 319 |
$('#btnclear').click(function() { |
296 |
$(".multiselect > option").each(function() { |
|
297 |
$(this).show(); |
|
298 |
}); |
|
320 |
// Copy all options from shadow to sysprivs |
|
321 |
copyselect(true) |
|
322 |
|
|
323 |
$('#filtertxt').val(''); |
|
299 | 324 |
}); |
300 | 325 |
|
301 | 326 |
$('#filtertxt').keypress(function(e) { |
... | ... | |
307 | 332 |
|
308 | 333 |
// On submit unhide all options (or else they will not submit) |
309 | 334 |
$('form').submit(function() { |
335 |
|
|
310 | 336 |
$(".multiselect > option").each(function() { |
311 | 337 |
$(this).show(); |
312 | 338 |
}); |
339 |
|
|
340 |
$('.shadowselect').remove(); |
|
341 |
}); |
|
342 |
|
|
343 |
function copyselect(selected) { |
|
344 |
// Copy all optionsfrom shadow to sysprivs |
|
345 |
$('.multiselect').html($('.shadowselect').html()); |
|
346 |
|
|
347 |
if (selected) { |
|
348 |
// Update the shadow list from the real list |
|
349 |
$(".shadowselect option").each(function() { |
|
350 |
multioption = $('.multiselect option').filter('[value=' + $(this).val() + ']'); |
|
351 |
if ($(this).is(':selected')) { |
|
352 |
multioption.prop("selected", true); |
|
353 |
} else { |
|
354 |
multioption.prop("selected", false); |
|
355 |
} |
|
356 |
}); |
|
357 |
} |
|
358 |
} |
|
359 |
|
|
360 |
$('.multiselect').mouseup(function () { |
|
361 |
$('.multiselect').trigger('click'); |
|
313 | 362 |
}); |
314 | 363 |
}); |
315 | 364 |
//]]> |
Also available in: Unified diff
Improvements to priv filtering