Factor out enable/disable settings function.
svn path=/plone.app.discussion/trunk/; revision=46086
This commit is contained in:
parent
ffcc29a401
commit
f97c17e62a
@ -7,7 +7,25 @@
|
||||
// This unnamed function allows us to use $ inside of a block of code
|
||||
// without permanently overwriting $.
|
||||
// http://docs.jquery.com/Using_jQuery_with_Other_Libraries
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Disable a control panel setting. Grey out the setting and disable all
|
||||
* form elements.
|
||||
**************************************************************************/
|
||||
$.disableSettings = function (settings) {
|
||||
$.each(settings,
|
||||
function(intIndex, objValue){
|
||||
objValue.removeClass('unclickable');
|
||||
});
|
||||
};
|
||||
|
||||
$.enableSettings = function (settings) {
|
||||
$.each(settings,
|
||||
function(intIndex, objValue){
|
||||
objValue.addClass('unclickable');
|
||||
});
|
||||
};
|
||||
|
||||
//#JSCOVERAGE_IF 0
|
||||
|
||||
/**************************************************************************
|
||||
@ -17,25 +35,29 @@
|
||||
$(window).load(function () {
|
||||
|
||||
/**********************************************************************
|
||||
* If the user hits the "clear" button of an open reply-to-comment form,
|
||||
* remove the form and show the "reply" button again.
|
||||
* If commenting is globally disabled, disable all commenting options.
|
||||
**********************************************************************/
|
||||
$("input[name='form.widgets.globally_enabled:list']").bind("change", function (e) {
|
||||
if ($(this).attr("checked")) {
|
||||
// enable commenting globally
|
||||
$('#formfield-form-widgets-anonymous_comments').removeClass('unclickable');
|
||||
$('#formfield-form-widgets-text_transform').removeClass('unclickable');
|
||||
$('#formfield-form-widgets-captcha').removeClass('unclickable');
|
||||
$('#formfield-form-widgets-show_commenter_image').removeClass('unclickable');
|
||||
$('#formfield-form-widgets-moderator_notification_enabled').removeClass('unclickable');
|
||||
$('#formfield-form-widgets-user_notification_enabled').removeClass('unclickable');
|
||||
// commenting globally enable
|
||||
$.disableSettings([
|
||||
$('#formfield-form-widgets-anonymous_comments'),
|
||||
$('#formfield-form-widgets-text_transform'),
|
||||
$('#formfield-form-widgets-captcha'),
|
||||
$('#formfield-form-widgets-show_commenter_image'),
|
||||
$('#formfield-form-widgets-moderator_notification_enabled'),
|
||||
$('#formfield-form-widgets-user_notification_enabled')
|
||||
]);
|
||||
} else {
|
||||
$('#formfield-form-widgets-anonymous_comments').addClass('unclickable');
|
||||
$('#formfield-form-widgets-text_transform').addClass('unclickable');
|
||||
$('#formfield-form-widgets-captcha').addClass('unclickable');
|
||||
$('#formfield-form-widgets-show_commenter_image').addClass('unclickable');
|
||||
$('#formfield-form-widgets-moderator_notification_enabled').addClass('unclickable');
|
||||
$('#formfield-form-widgets-user_notification_enabled').addClass('unclickable');
|
||||
// commenting globally disabled
|
||||
$.enableSettings([
|
||||
$('#formfield-form-widgets-anonymous_comments'),
|
||||
$('#formfield-form-widgets-text_transform'),
|
||||
$('#formfield-form-widgets-captcha'),
|
||||
$('#formfield-form-widgets-show_commenter_image'),
|
||||
$('#formfield-form-widgets-moderator_notification_enabled'),
|
||||
$('#formfield-form-widgets-user_notification_enabled'),
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user