disable form fields when disabling the fields.

svn path=/plone.app.discussion/trunk/; revision=46087
This commit is contained in:
Timo Stollenwerk 2010-12-02 19:09:16 +00:00
parent f97c17e62a
commit 2a7a65293e

View File

@ -14,15 +14,19 @@
**************************************************************************/ **************************************************************************/
$.disableSettings = function (settings) { $.disableSettings = function (settings) {
$.each(settings, $.each(settings,
function(intIndex, objValue){ function(intIndex, setting){
objValue.removeClass('unclickable'); setting.addClass('unclickable');
setting_field = $(setting).find("input,select");
setting_field.attr('disabled', 'disabled');
}); });
}; };
$.enableSettings = function (settings) { $.enableSettings = function (settings) {
$.each(settings, $.each(settings,
function(intIndex, objValue){ function(intIndex, setting){
objValue.addClass('unclickable'); setting.removeClass('unclickable');
setting_field = $(setting).find("input,select");
setting_field.removeAttr('disabled');
}); });
}; };
@ -35,12 +39,12 @@
$(window).load(function () { $(window).load(function () {
/********************************************************************** /**********************************************************************
* If commenting is globally disabled, disable all commenting options. * If commenting is disabled globally, disable all commenting options.
**********************************************************************/ **********************************************************************/
$("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")) {
// commenting globally enable // commenting globally enabled
$.disableSettings([ $.enableSettings([
$('#formfield-form-widgets-anonymous_comments'), $('#formfield-form-widgets-anonymous_comments'),
$('#formfield-form-widgets-text_transform'), $('#formfield-form-widgets-text_transform'),
$('#formfield-form-widgets-captcha'), $('#formfield-form-widgets-captcha'),
@ -50,7 +54,7 @@
]); ]);
} else { } else {
// commenting globally disabled // commenting globally disabled
$.enableSettings([ $.disableSettings([
$('#formfield-form-widgets-anonymous_comments'), $('#formfield-form-widgets-anonymous_comments'),
$('#formfield-form-widgets-text_transform'), $('#formfield-form-widgets-text_transform'),
$('#formfield-form-widgets-captcha'), $('#formfield-form-widgets-captcha'),