cirandas.net

ref: master

public/javascripts/invite.js


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(function($){
  'use strict';

  function toggle_invitation_method() {
    if (+(this.value) === 1) {
      $('.invite_by_email').hide();
      $('.invite_by_name').show();
    } else {
      $('.invite_by_name').hide();
      $('.invite_by_email').show();
    }
  }

  function manage_members_moderation() {
    var checked = $('#profile_data_allow_members_to_invite').is(':checked');

    if (checked) {
      $('.invite_friends_only').show();
    } else {
      $('.invite_friends_only').hide();
    }
  }

  function hide_invite_friend_login_password() {
    $('#invite-friends-login-password').hide();
  }

  function show_invite_friend_login_password() {
    if (this.value === 'hotmail') {
      $('#hotmail_username_tip').show();
    } else {
      $('#hotmail_username_tip').hide();
    }

    $('#invite-friends-login-password').show();
    $('#login').focus();
  }

  $(document).ready(function() {
    $('.invite_by_email').hide();
    manage_members_moderation();

    // Event triggers
    $('.invite_friend_by').click(toggle_invitation_method);

    $("#import_from_manual").click(hide_invite_friend_login_password);

    $('.invite_by_this_email').click(show_invite_friend_login_password);

    $('#profile_data_allow_members_to_invite').click(manage_members_moderation);
  });
})(jQuery);