make jslint happy; disable settings onload;
svn path=/plone.app.discussion/trunk/; revision=46088
This commit is contained in:
parent
2a7a65293e
commit
1b36f99a7a
@ -13,19 +13,17 @@
|
|||||||
* form elements.
|
* form elements.
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
$.disableSettings = function (settings) {
|
$.disableSettings = function (settings) {
|
||||||
$.each(settings,
|
$.each(settings, function (intIndex, setting) {
|
||||||
function(intIndex, setting){
|
|
||||||
setting.addClass('unclickable');
|
setting.addClass('unclickable');
|
||||||
setting_field = $(setting).find("input,select");
|
var setting_field = $(setting).find("input,select");
|
||||||
setting_field.attr('disabled', 'disabled');
|
setting_field.attr('disabled', 'disabled');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$.enableSettings = function (settings) {
|
$.enableSettings = function (settings) {
|
||||||
$.each(settings,
|
$.each(settings, function (intIndex, setting) {
|
||||||
function(intIndex, setting){
|
|
||||||
setting.removeClass('unclickable');
|
setting.removeClass('unclickable');
|
||||||
setting_field = $(setting).find("input,select");
|
var setting_field = $(setting).find("input,select");
|
||||||
setting_field.removeAttr('disabled');
|
setting_field.removeAttr('disabled');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -38,10 +36,22 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
$(window).load(function () {
|
$(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.
|
* 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")) {
|
if ($(this).attr("checked")) {
|
||||||
// commenting globally enabled
|
// commenting globally enabled
|
||||||
$.enableSettings([
|
$.enableSettings([
|
||||||
@ -60,11 +70,27 @@
|
|||||||
$('#formfield-form-widgets-captcha'),
|
$('#formfield-form-widgets-captcha'),
|
||||||
$('#formfield-form-widgets-show_commenter_image'),
|
$('#formfield-form-widgets-show_commenter_image'),
|
||||||
$('#formfield-form-widgets-moderator_notification_enabled'),
|
$('#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();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//#JSCOVERAGE_ENDIF
|
//#JSCOVERAGE_ENDIF
|
||||||
|
Loading…
Reference in New Issue
Block a user