Changeset 13024 for trunk/admin


Ignore:
Timestamp:
Feb 3, 2012, 9:49:38 PM (12 years ago)
Author:
plg
Message:

smarter use of jQuery closure to manage conditional display of options

Location:
trunk/admin/themes/default
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/themes/default/template/configuration.tpl

    r13004 r13024  
    1 
    2 {include file='include/autosize.inc.tpl'}
     1{footer_script}{literal}
     2jQuery(document).ready(function(){
     3  jQuery("#activate_comments").change(function(){
     4    if ($(this).is(':checked')) {
     5      jQuery("#comments_param_warp").show();
     6    } else {
     7      jQuery("#comments_param_warp").hide();
     8    }
     9  });
     10
     11  var targets = {
     12    'input[name="rate"]' : '#rate_anonymous',
     13    'input[name="allow_user_registration"]' : '#email_admin_on_new_user',
     14    'input[name="comments_validation"]' : '#email_admin_on_comment_validation',
     15    'input[name="user_can_edit_comment"]' : '#email_admin_on_comment_edition',
     16    'input[name="user_can_delete_comment"]' : '#email_admin_on_comment_deletion',
     17  };
     18
     19  for (selector in targets) {
     20    var target = targets[selector];
     21
     22    jQuery(target).toggle(jQuery(selector).is(':checked'));
     23
     24    (function(target){
     25      jQuery(selector).bind('change', function() {
     26        jQuery(target).toggle($(this).is(':checked'));
     27      });
     28    })(target);
     29  };
     30});
     31{/literal}{/footer_script}
    332
    433<div class="titrePage">
     
    75104    </li>
    76105   
    77 {footer_script}{literal}
    78 jQuery(document).ready(function(){
    79   /* rate_anonymous visible only if rate is permitted */
    80   if (jQuery('input[name="rate"]').is(':checked')) {
    81     jQuery('#rate_anonymous').show();
    82   }
    83   else {
    84     jQuery('#rate_anonymous').hide();
    85   }
    86 
    87   jQuery('input[name="rate"]').change(function(){
    88     if ($(this).is(':checked')) {
    89       jQuery('#rate_anonymous').show();
    90     }
    91     else {
    92       jQuery('#rate_anonymous').hide();
    93     }
    94   });
    95 
    96   /* email_admin_on_new_user checkbox only if allow_user_registration */
    97   if (jQuery('input[name="allow_user_registration"]').is(':checked')) {
    98     jQuery('#email_admin_on_new_user').show();
    99   }
    100   else {
    101     jQuery('#email_admin_on_new_user').hide();
    102   }
    103 
    104   jQuery('input[name="allow_user_registration"]').change(function(){
    105     if ($(this).is(':checked')) {
    106       jQuery('#email_admin_on_new_user').show();
    107     }
    108     else {
    109       jQuery('#email_admin_on_new_user').hide();
    110     }
    111   });
    112 });
    113 {/literal}{/footer_script}
    114 
    115106    <li>
    116107        <label>{'Default photos order'|@translate}</label>
     
    255246    </li>
    256247
    257     <li>
     248    <li id="notifyAdmin">
    258249      <strong>{'Notify administrators when a comment is'|@translate}</strong>
    259250
     
    276267  </ul>
    277268</fieldset>
    278 {footer_script}{literal}
    279 jQuery(document).ready(function(){
    280   jQuery("#activate_comments").change(function(){
    281     if ($(this).is(':checked')) {
    282       jQuery("#comments_param_warp").show();
    283     } else {
    284       jQuery("#comments_param_warp").hide();
    285     }
    286   });
    287 
    288   /* notify on validation checkbox */
    289   if (jQuery('input[name="comments_validation"]').is(':checked')) {
    290     jQuery('#email_admin_on_comment_validation').show();
    291   }
    292   else {
    293     jQuery('#email_admin_on_comment_validation').hide();
    294   }
    295 
    296   jQuery('input[name="comments_validation"]').change(function(){
    297     if ($(this).is(':checked')) {
    298       jQuery('#email_admin_on_comment_validation').show();
    299     }
    300     else {
    301       jQuery('#email_admin_on_comment_validation').hide();
    302     }
    303   });
    304 
    305   /* notify on edition checkbox */
    306   if (jQuery('input[name="user_can_edit_comment"]').is(':checked')) {
    307     jQuery('#email_admin_on_comment_edition').show();
    308   }
    309   else {
    310     jQuery('#email_admin_on_comment_edition').hide();
    311   }
    312 
    313   jQuery('input[name="user_can_edit_comment"]').change(function(){
    314     if ($(this).is(':checked')) {
    315       jQuery('#email_admin_on_comment_edition').show();
    316     }
    317     else {
    318       jQuery('#email_admin_on_comment_edition').hide();
    319     }
    320   });
    321  
    322   /* notify on deletion checkbox */
    323   if (jQuery('input[name="user_can_delete_comment"]').is(':checked')) {
    324     jQuery('#email_admin_on_comment_deletion').show();
    325   }
    326   else {
    327     jQuery('#email_admin_on_comment_deletion').hide();
    328   }
    329 
    330   jQuery('input[name="user_can_delete_comment"]').change(function(){
    331     if ($(this).is(':checked')) {
    332       jQuery('#email_admin_on_comment_deletion').show();
    333     }
    334     else {
    335       jQuery('#email_admin_on_comment_deletion').hide();
    336     }
    337   });
    338 });
    339 {/literal}{/footer_script}
    340269{/if}
    341270
  • trunk/admin/themes/default/theme.css

    r13020 r13024  
    482482#configContent label {
    483483  font-weight: bold;
     484}
     485
     486#notifyAdmin label {
     487   white-space:nowrap;
    484488}
    485489
Note: See TracChangeset for help on using the changeset viewer.