make jslint happy; disable settings onload;
svn path=/plone.app.discussion/trunk/; revision=46088
This commit is contained in:
parent
2a7a65293e
commit
1b36f99a7a
@ -13,21 +13,19 @@
|
||||
* form elements.
|
||||
**************************************************************************/
|
||||
$.disableSettings = function (settings) {
|
||||
$.each(settings,
|
||||
function(intIndex, setting){
|
||||
setting.addClass('unclickable');
|
||||
setting_field = $(setting).find("input,select");
|
||||
setting_field.attr('disabled', 'disabled');
|
||||
});
|
||||
$.each(settings, function (intIndex, setting) {
|
||||
setting.addClass('unclickable');
|
||||
var setting_field = $(setting).find("input,select");
|
||||
setting_field.attr('disabled', 'disabled');
|
||||
});
|
||||
};
|
||||
|
||||
$.enableSettings = function (settings) {
|
||||
$.each(settings,
|
||||
function(intIndex, setting){
|
||||
setting.removeClass('unclickable');
|
||||
setting_field = $(setting).find("input,select");
|
||||
setting_field.removeAttr('disabled');
|
||||
});
|
||||
$.each(settings, function (intIndex, setting) {
|
||||
setting.removeClass('unclickable');
|
||||
var setting_field = $(setting).find("input,select");
|
||||
setting_field.removeAttr('disabled');
|
||||
});
|
||||
};
|
||||
|
||||
//#JSCOVERAGE_IF 0
|
||||
@ -38,10 +36,22 @@
|
||||
**************************************************************************/
|
||||
$(window).load(function () {
|
||||
|
||||
var commenting_enabled_globally = $("#form-widgets-globally_enabled-0").attr("checked");
|
||||
if (commenting_enabled_globally === false) {
|
||||
$.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')
|
||||
]);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* 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']").live("click", function (e) {
|
||||
if ($(this).attr("checked")) {
|
||||
// commenting globally enabled
|
||||
$.enableSettings([
|
||||
@ -51,7 +61,7 @@
|
||||
$('#formfield-form-widgets-show_commenter_image'),
|
||||
$('#formfield-form-widgets-moderator_notification_enabled'),
|
||||
$('#formfield-form-widgets-user_notification_enabled')
|
||||
]);
|
||||
]);
|
||||
} else {
|
||||
// commenting globally disabled
|
||||
$.disableSettings([
|
||||
@ -60,10 +70,26 @@
|
||||
$('#formfield-form-widgets-captcha'),
|
||||
$('#formfield-form-widgets-show_commenter_image'),
|
||||
$('#formfield-form-widgets-moderator_notification_enabled'),
|
||||
$('#formfield-form-widgets-user_notification_enabled'),
|
||||
$('#formfield-form-widgets-user_notification_enabled')
|
||||
]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
* Remove the disabled attribute from all form elements before
|
||||
* submitting the form. Otherwise the z3c.form will raise errors on
|
||||
* the required attributes.
|
||||
*/
|
||||
$("input[name='form.buttons.save']").live("click", function (e) {
|
||||
e.preventDefault();
|
||||
$('#formfield-form-widgets-anonymous_comments').removeAttr('disabled');
|
||||
$('#formfield-form-widgets-text_transform').removeAttr('disabled');
|
||||
$('#formfield-form-widgets-captcha').removeAttr('disabled');
|
||||
$('#formfield-form-widgets-show_commenter_image').removeAttr('disabled');
|
||||
$('#formfield-form-widgets-moderator_notification_enabled').removeAttr('disabled');
|
||||
$('#formfield-form-widgets-user_notification_enabled').removeAttr('disabled');
|
||||
$(this).parents().filter("form").submit();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user