aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2012-02-03 20:49:38 +0000
committerplegall <plg@piwigo.org>2012-02-03 20:49:38 +0000
commit4264acc26668d0a395e98890ed79e5da1f9cc322 (patch)
tree5a84374d9c1db75c121becf5d1ffc9fa76f390db
parentddb025c51e9aa25e9943854a472813fbbdef69bf (diff)
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
Diffstat (limited to '')
-rw-r--r--admin/themes/default/template/configuration.tpl133
-rw-r--r--admin/themes/default/theme.css4
2 files changed, 35 insertions, 102 deletions
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}
<div class="titrePage">
<h2>{'Piwigo configuration'|@translate} {$TABSHEET_TITLE}</h2>
@@ -74,44 +103,6 @@
{html_options name="week_starts_on" options=$main.week_starts_on_options selected=$main.week_starts_on_options_selected}</label>
</li>
-{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}
-
<li>
<label>{'Default photos order'|@translate}</label>
@@ -254,7 +245,7 @@ jQuery(document).ready(function () {
</label>
</li>
- <li>
+ <li id="notifyAdmin">
<strong>{'Notify administrators when a comment is'|@translate}</strong>
<label id="email_admin_on_comment_validation">
@@ -275,68 +266,6 @@ jQuery(document).ready(function () {
</li>
</ul>
</fieldset>
-{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;
}