Factor out enable/disable settings function.
svn path=/plone.app.discussion/trunk/; revision=46086
This commit is contained in:
parent
ffcc29a401
commit
f97c17e62a
@ -8,6 +8,24 @@
|
|||||||
// without permanently overwriting $.
|
// without permanently overwriting $.
|
||||||
// http://docs.jquery.com/Using_jQuery_with_Other_Libraries
|
// 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
|
//#JSCOVERAGE_IF 0
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
@ -17,25 +35,29 @@
|
|||||||
$(window).load(function () {
|
$(window).load(function () {
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* If the user hits the "clear" button of an open reply-to-comment form,
|
* If commenting is globally disabled, disable all commenting options.
|
||||||
* remove the form and show the "reply" button again.
|
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
$("input[name='form.widgets.globally_enabled:list']").bind("change", function (e) {
|
$("input[name='form.widgets.globally_enabled:list']").bind("change", function (e) {
|
||||||
if ($(this).attr("checked")) {
|
if ($(this).attr("checked")) {
|
||||||
// enable commenting globally
|
// commenting globally enable
|
||||||
$('#formfield-form-widgets-anonymous_comments').removeClass('unclickable');
|
$.disableSettings([
|
||||||
$('#formfield-form-widgets-text_transform').removeClass('unclickable');
|
$('#formfield-form-widgets-anonymous_comments'),
|
||||||
$('#formfield-form-widgets-captcha').removeClass('unclickable');
|
$('#formfield-form-widgets-text_transform'),
|
||||||
$('#formfield-form-widgets-show_commenter_image').removeClass('unclickable');
|
$('#formfield-form-widgets-captcha'),
|
||||||
$('#formfield-form-widgets-moderator_notification_enabled').removeClass('unclickable');
|
$('#formfield-form-widgets-show_commenter_image'),
|
||||||
$('#formfield-form-widgets-user_notification_enabled').removeClass('unclickable');
|
$('#formfield-form-widgets-moderator_notification_enabled'),
|
||||||
|
$('#formfield-form-widgets-user_notification_enabled')
|
||||||
|
]);
|
||||||
} else {
|
} else {
|
||||||
$('#formfield-form-widgets-anonymous_comments').addClass('unclickable');
|
// commenting globally disabled
|
||||||
$('#formfield-form-widgets-text_transform').addClass('unclickable');
|
$.enableSettings([
|
||||||
$('#formfield-form-widgets-captcha').addClass('unclickable');
|
$('#formfield-form-widgets-anonymous_comments'),
|
||||||
$('#formfield-form-widgets-show_commenter_image').addClass('unclickable');
|
$('#formfield-form-widgets-text_transform'),
|
||||||
$('#formfield-form-widgets-moderator_notification_enabled').addClass('unclickable');
|
$('#formfield-form-widgets-captcha'),
|
||||||
$('#formfield-form-widgets-user_notification_enabled').addClass('unclickable');
|
$('#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