2011-03-23 10:51:00 +01:00
|
|
|
/**
|
|
|
|
* File: SecurityAdmin.js
|
|
|
|
*/
|
|
|
|
(function($) {
|
|
|
|
|
|
|
|
var refreshAfterImport = function(e) {
|
|
|
|
// Check for a message <div>, an indication that the form has been submitted.
|
|
|
|
var existingFormMessage = $($(this).contents()).find('.message');
|
|
|
|
if(existingFormMessage && existingFormMessage.html()) {
|
|
|
|
// Refresh member listing
|
|
|
|
var memberTableField = $(window.parent.document).find('#Form_EditForm_Members').get(0);
|
|
|
|
if(memberTableField) memberTableField.refresh();
|
|
|
|
|
|
|
|
// Refresh tree
|
2011-04-17 09:55:23 +02:00
|
|
|
var tree = $(window.parent.document).find('.cms-tree').get(0);
|
2011-03-23 10:51:00 +01:00
|
|
|
if(tree) tree.reload();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Refresh the member listing every time the import iframe is loaded,
|
|
|
|
* which is most likely a form submission.
|
|
|
|
*/
|
2012-07-27 01:17:56 +02:00
|
|
|
$('#MemberImportFormIframe, #GroupImportFormIframe').entwine({
|
|
|
|
onadd: function() {
|
|
|
|
this._super();
|
|
|
|
// TODO entwine can't seem to bind to iframe load events
|
|
|
|
$(this).bind('load', refreshAfterImport);
|
|
|
|
}
|
2011-03-23 10:51:00 +01:00
|
|
|
});
|
2012-07-27 01:17:56 +02:00
|
|
|
|
2011-03-23 10:51:00 +01:00
|
|
|
$.entwine('ss', function($){
|
|
|
|
/**
|
2012-03-05 17:35:10 +01:00
|
|
|
* Class: #Permissions .checkbox[value=ADMIN]
|
|
|
|
*
|
|
|
|
* Automatically check and disable all checkboxes if ADMIN permissions are selected.
|
|
|
|
* As they're disabled, any changes won't be submitted (which is intended behaviour),
|
|
|
|
* checking all boxes is purely presentational.
|
2011-03-23 10:51:00 +01:00
|
|
|
*/
|
2013-05-26 01:11:05 +02:00
|
|
|
$('.permissioncheckboxset .checkbox[value=ADMIN]').entwine({
|
2012-03-05 17:35:10 +01:00
|
|
|
onmatch: function() {
|
|
|
|
this.toggleCheckboxes();
|
|
|
|
|
|
|
|
this._super();
|
|
|
|
},
|
2012-05-14 01:43:36 +02:00
|
|
|
onunmatch: function() {
|
|
|
|
this._super();
|
|
|
|
},
|
2012-03-05 17:35:10 +01:00
|
|
|
/**
|
|
|
|
* Function: onclick
|
|
|
|
*/
|
2011-03-23 10:51:00 +01:00
|
|
|
onclick: function(e) {
|
2012-03-05 17:35:10 +01:00
|
|
|
this.toggleCheckboxes();
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* Function: toggleCheckboxes
|
|
|
|
*/
|
|
|
|
toggleCheckboxes: function() {
|
2013-05-26 01:11:05 +02:00
|
|
|
var self = this,
|
|
|
|
checkboxes = this.parents('.field:eq(0)').find('.checkbox').not(this);
|
2012-03-05 17:35:10 +01:00
|
|
|
|
|
|
|
if(this.is(':checked')) {
|
|
|
|
checkboxes.each(function() {
|
|
|
|
$(this).data('SecurityAdmin.oldChecked', $(this).attr('checked'));
|
|
|
|
$(this).data('SecurityAdmin.oldDisabled', $(this).attr('disabled'));
|
|
|
|
$(this).attr('disabled', 'disabled');
|
|
|
|
$(this).attr('checked', 'checked');
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
checkboxes.each(function() {
|
|
|
|
$(this).attr('checked', $(this).data('SecurityAdmin.oldChecked'));
|
|
|
|
$(this).attr('disabled', $(this).data('SecurityAdmin.oldDisabled'));
|
|
|
|
});
|
|
|
|
}
|
2011-03-23 10:51:00 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2012-05-14 01:43:36 +02:00
|
|
|
}(jQuery));
|