2011-06-14 20:50:35 +02:00
|
|
|
/**
|
|
|
|
* Javascript for Admin / Global categories
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Record original value
|
|
|
|
var cat_original_owner;
|
|
|
|
var permission_prompt;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check to see if admin has taken away access to a category
|
|
|
|
*/
|
|
|
|
function check_owner(element_id) {
|
2011-07-03 11:00:36 +02:00
|
|
|
var checkboxes = $j(':checkbox', document.getElementById(element_id));
|
|
|
|
var all_users = $j(document.getElementById(element_id + '[0]'));
|
2011-06-14 20:50:35 +02:00
|
|
|
|
|
|
|
// If they checked all users, uncheck the others
|
2011-06-21 22:14:56 +02:00
|
|
|
if(all_users.length > 0 && all_users.attr("checked")) {
|
2011-06-14 20:50:35 +02:00
|
|
|
checkboxes.attr("checked",false);
|
|
|
|
all_users.attr("checked", true);
|
2011-07-03 11:00:36 +02:00
|
|
|
checkboxes = $j(':checkbox', document.getElementById(element_id)).filter(':checked');
|
2011-06-14 20:50:35 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find out what changed
|
|
|
|
var seen = [], diff = [], labels = [];
|
|
|
|
for ( var i = 0; i < cat_original_owner.length; i++) {
|
|
|
|
var checkbox = checkboxes.filter('[value="'+cat_original_owner[i]+'"]');
|
2011-06-21 22:14:56 +02:00
|
|
|
if(checkbox.filter(':checked').length == 0 && checkbox.get(0) != undefined) {
|
2011-06-14 20:50:35 +02:00
|
|
|
diff.push(cat_original_owner[i]);
|
2011-07-03 11:00:36 +02:00
|
|
|
labels.push($j(checkbox.get(0).nextSibling).text());
|
2011-06-14 20:50:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-27 23:14:25 +02:00
|
|
|
// Single selection?
|
|
|
|
if(checkboxes.length == 0) {
|
2011-07-03 11:00:36 +02:00
|
|
|
var new_group = $j(document.getElementById(element_id));
|
2011-06-27 23:14:25 +02:00
|
|
|
if(new_group.attr('value') != 0 && cat_original_owner.length > 0) {
|
|
|
|
diff.push(cat_original_owner[0]);
|
|
|
|
var selector = 'option[value="'+cat_original_owner[0]+'"]';
|
2011-07-03 11:00:36 +02:00
|
|
|
labels.push("\n"+$j(selector, new_group).text());
|
2011-06-27 23:14:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-14 20:50:35 +02:00
|
|
|
// Somebody will lose permission, give warning.
|
|
|
|
if(diff.length > 0) {
|
|
|
|
var msg = permission_prompt;
|
|
|
|
for( var i = 0; i < labels.length; i++) {
|
|
|
|
msg += labels[i];
|
|
|
|
}
|
|
|
|
return confirm(msg);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|