From 4264acc26668d0a395e98890ed79e5da1f9cc322 Mon Sep 17 00:00:00 2001 From: plegall Date: Fri, 3 Feb 2012 20:49:38 +0000 Subject: smarter use of jQuery closure to manage conditional display of options git-svn-id: http://piwigo.org/svn/trunk@13024 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/themes/default/template/configuration.tpl | 133 ++++++------------------ admin/themes/default/theme.css | 4 + 2 files changed, 35 insertions(+), 102 deletions(-) (limited to 'admin/themes/default') diff --git a/admin/themes/default/template/configuration.tpl b/admin/themes/default/template/configuration.tpl index f880bea05..4c7aa31f2 100644 --- a/admin/themes/default/template/configuration.tpl +++ b/admin/themes/default/template/configuration.tpl @@ -1,5 +1,34 @@ +{footer_script}{literal} +jQuery(document).ready(function(){ + jQuery("#activate_comments").change(function(){ + if ($(this).is(':checked')) { + jQuery("#comments_param_warp").show(); + } else { + jQuery("#comments_param_warp").hide(); + } + }); -{include file='include/autosize.inc.tpl'} + var targets = { + 'input[name="rate"]' : '#rate_anonymous', + 'input[name="allow_user_registration"]' : '#email_admin_on_new_user', + 'input[name="comments_validation"]' : '#email_admin_on_comment_validation', + 'input[name="user_can_edit_comment"]' : '#email_admin_on_comment_edition', + 'input[name="user_can_delete_comment"]' : '#email_admin_on_comment_deletion', + }; + + for (selector in targets) { + var target = targets[selector]; + + jQuery(target).toggle(jQuery(selector).is(':checked')); + + (function(target){ + jQuery(selector).bind('change', function() { + jQuery(target).toggle($(this).is(':checked')); + }); + })(target); + }; +}); +{/literal}{/footer_script}

{'Piwigo configuration'|@translate} {$TABSHEET_TITLE}

@@ -74,44 +103,6 @@ {html_options name="week_starts_on" options=$main.week_starts_on_options selected=$main.week_starts_on_options_selected} -{footer_script}{literal} -jQuery(document).ready(function(){ - /* rate_anonymous visible only if rate is permitted */ - if (jQuery('input[name="rate"]').is(':checked')) { - jQuery('#rate_anonymous').show(); - } - else { - jQuery('#rate_anonymous').hide(); - } - - jQuery('input[name="rate"]').change(function(){ - if ($(this).is(':checked')) { - jQuery('#rate_anonymous').show(); - } - else { - jQuery('#rate_anonymous').hide(); - } - }); - - /* email_admin_on_new_user checkbox only if allow_user_registration */ - if (jQuery('input[name="allow_user_registration"]').is(':checked')) { - jQuery('#email_admin_on_new_user').show(); - } - else { - jQuery('#email_admin_on_new_user').hide(); - } - - jQuery('input[name="allow_user_registration"]').change(function(){ - if ($(this).is(':checked')) { - jQuery('#email_admin_on_new_user').show(); - } - else { - jQuery('#email_admin_on_new_user').hide(); - } - }); -}); -{/literal}{/footer_script} -
  • @@ -254,7 +245,7 @@ jQuery(document).ready(function () {
  • -
  • +
  • {'Notify administrators when a comment is'|@translate}
  • -{footer_script}{literal} -jQuery(document).ready(function(){ - jQuery("#activate_comments").change(function(){ - if ($(this).is(':checked')) { - jQuery("#comments_param_warp").show(); - } else { - jQuery("#comments_param_warp").hide(); - } - }); - - /* notify on validation checkbox */ - if (jQuery('input[name="comments_validation"]').is(':checked')) { - jQuery('#email_admin_on_comment_validation').show(); - } - else { - jQuery('#email_admin_on_comment_validation').hide(); - } - - jQuery('input[name="comments_validation"]').change(function(){ - if ($(this).is(':checked')) { - jQuery('#email_admin_on_comment_validation').show(); - } - else { - jQuery('#email_admin_on_comment_validation').hide(); - } - }); - - /* notify on edition checkbox */ - if (jQuery('input[name="user_can_edit_comment"]').is(':checked')) { - jQuery('#email_admin_on_comment_edition').show(); - } - else { - jQuery('#email_admin_on_comment_edition').hide(); - } - - jQuery('input[name="user_can_edit_comment"]').change(function(){ - if ($(this).is(':checked')) { - jQuery('#email_admin_on_comment_edition').show(); - } - else { - jQuery('#email_admin_on_comment_edition').hide(); - } - }); - - /* notify on deletion checkbox */ - if (jQuery('input[name="user_can_delete_comment"]').is(':checked')) { - jQuery('#email_admin_on_comment_deletion').show(); - } - else { - jQuery('#email_admin_on_comment_deletion').hide(); - } - - jQuery('input[name="user_can_delete_comment"]').change(function(){ - if ($(this).is(':checked')) { - jQuery('#email_admin_on_comment_deletion').show(); - } - else { - jQuery('#email_admin_on_comment_deletion').hide(); - } - }); -}); -{/literal}{/footer_script} {/if} {if isset($sizes)} diff --git a/admin/themes/default/theme.css b/admin/themes/default/theme.css index 87c28c531..14aa30b96 100644 --- a/admin/themes/default/theme.css +++ b/admin/themes/default/theme.css @@ -483,6 +483,10 @@ FORM.properties SPAN.property { font-weight: bold; } +#notifyAdmin label { + white-space:nowrap; +} + #mainConf li { margin-bottom: 1em; } -- cgit v1.2.3