Sha256: 2455bac148b0f38320dde75ee670a1991e4d04e945fdb0f18c1c31c30c19f096

Contents?: true

Size: 1.92 KB

Versions: 5

Compression:

Stored size: 1.92 KB

Contents

<script type="text/javascript" language="JavaScript">
jQuery(document).ready(function() {
  jQuery(".get-contacts-button").click(function() {
    jQuery(this).parent('form').hide();
    jQuery(".contacts-loading").show();
    jQuery("#invite-messages-container").hide();
  });
  apply_ajax_forms();
  
  jQuery('.select-all-contacts').live('click', function(){
    var cbs = jQuery(this).parent('.select-all').siblings('.table-wrapper').find('input:checkbox').attr("checked", jQuery(this).is(':checked'));
    var emails = checked_emails();
    jQuery('#emails').val(emails.join(', '));
  });
  
  jQuery('.contacts-list .cb input[type=checkbox]').live('change', function(){
    var emails = jQuery('#emails').val();
    var email = jQuery(this).val();
    var checked = jQuery(this).is(':checked');
    if(checked){
      jQuery('#emails').val(add_to_list(emails, email));
    } else {
      jQuery('#emails').val(remove_from_list(emails, email));
    }
    included_checkbox_by_email([email], checked);
  });
  
  jQuery('#emails').change(function(){
    var emails = split_list(jQuery('#emails').val());
    excluded_checkbox_by_email(emails, false);
    included_checkbox_by_email(emails, true);
  });
});

function checked_emails(){
   return get_emails(jQuery('.contacts-list .cb input:checkbox:checked'));
}

function get_emails(cbs){
  return cbs.map(function() {
    return jQuery(this).val();
  }).get();
}
// Sets checkboxes that are in 'emails'
function included_checkbox_by_email(emails, checked){
  jQuery('.contacts-list .cb input:checkbox').each(function(index) {
    if(emails.indexOf(jQuery(this).val()) > -1){
      jQuery(this).attr("checked",checked);
    }
  });
}
// Sets checkboxes that aren't in 'emails'
function excluded_checkbox_by_email(emails, checked){
  jQuery('.contacts-list .cb input:checkbox').each(function(index) {
    if(emails.indexOf(jQuery(this).val()) <= -1){
      jQuery(this).attr("checked",checked);
    }
  });
}
</script>

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
muck-invites-3.1.0 app/views/invites/_invite_scripts.erb
muck-invites-3.0.0 app/views/invites/_invite_scripts.erb
muck-invites-0.1.12 app/views/invites/_invite_scripts.erb
muck-invites-0.1.11 app/views/invites/_invite_scripts.erb
muck-invites-0.1.10 app/views/invites/_invite_scripts.erb