muck-invites 3.3.3 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.3.3
1
+ 3.4.0
@@ -27,16 +27,15 @@ module MuckInvitesHelper
27
27
  user.authentications.find_by_provider('google')
28
28
  end
29
29
 
30
- def yahoo_oauth_for(user)
31
- user.authentications.find_by_provider('yahoo')
32
- end
30
+ def yahoo_oauth_for(user)
31
+ user.authentications.find_by_provider('yahoo')
32
+ end
33
33
 
34
34
  # Generates a javascript array of emails from gmail. Values will be
35
35
  # put into a variable named 'gmail_contacts'
36
- def gmail_contacts_for_auto_complete(user, ignore_cache = false)
37
- return unless google_oauth_for(user)
38
- contacts = gmail_contacts(user, ignore_cache).collect{|contact| "'#{contact[:email]} (#{contact[:name]})'" }
39
- "var gmail_contacts = [#{contacts.join(',')}];"
36
+ def contacts_for_auto_complete(contacts, ignore_cache = false)
37
+ contacts = contacts.collect{|contact| "'#{contact[:email]}'" }
38
+ "var auto_complete_contacts = [#{contacts.join(',')}];"
40
39
  end
41
40
 
42
41
  def service_contacts(user, ignore_cache = false)
@@ -1,5 +1,5 @@
1
1
  <div id="compose-invite">
2
- <h2>Email invites to friends</h2>
2
+ <h2><%=translate('muck.invites.invite_via_email_title') %></h2>
3
3
  <!--
4
4
  <div class="tabs">
5
5
  <ul>
@@ -22,12 +22,12 @@
22
22
  <div id="invite">
23
23
  <%= muck_form_for(:invite_contacts, :url => {:action => 'create'}, :html => {:id => "invite-contacts-form", :name => 'invite-contacts-form'} ) do |f| -%>
24
24
  <div class="form-row">
25
- <label class="invite-email" for="emails">Emails</label>
25
+ <label class="invite-email" for="emails"><%=translate('muck.invites.emails') %></label>
26
26
  <p class="invite-email"><%=translate('muck.invites.email_friends_prompt') %></p>
27
27
  <%= text_area_tag :emails, emails || params[:emails] %>
28
28
  </div>
29
29
  <div class="form-row">
30
- <label class="invite-message" for="message">Message</label>
30
+ <label class="invite-message" for="message"><%=translate('muck.invites.message') %></label>
31
31
  <%= text_area_tag :message, message || params[:message] %>
32
32
  </div>
33
33
  <div class="form-row">
@@ -50,18 +50,6 @@ jQuery(document).ready(function() {
50
50
  });
51
51
  jQuery('.tabs').show();
52
52
 
53
- apply_ajax_forms();
54
-
55
- <% if google_oauth_for(current_user) -%>
56
- <%= gmail_contacts_for_auto_complete(current_user) %>
57
- jQuery("#emails").autocomplete(gmail_contacts, {
58
- minChars: 1,
59
- delay: 200,
60
- autoFill: true,
61
- mustMatch: false,
62
- multiple: true
63
- });
64
- <% end -%>
65
53
  });
66
54
  </script>
67
55
  <% end -%>
@@ -27,12 +27,51 @@ jQuery(document).ready(function() {
27
27
  });
28
28
 
29
29
  jQuery('#emails').change(function(){
30
- var emails = split_list(jQuery('#emails').val());
31
- excluded_checkbox_by_email(emails, false);
32
- included_checkbox_by_email(emails, true);
30
+ set_email_ui();
33
31
  });
32
+
33
+ <%= contacts_for_auto_complete(service_contacts(current_user)) %>
34
+ jQuery("#emails")
35
+ // don't navigate away from the field on tab when selecting an item
36
+ .bind("keydown", function(event){
37
+ if(event.keyCode === $.ui.keyCode.TAB && jQuery(this).data("autocomplete" ).menu.active){
38
+ event.preventDefault();
39
+ }
40
+ set_email_ui();
41
+ })
42
+ .autocomplete({
43
+ minLength: 0,
44
+ source: function( request, response ) {
45
+ // delegate back to autocomplete, but extract the last term
46
+ response( jQuery.ui.autocomplete.filter(
47
+ auto_complete_contacts, extractLast(request.term)));
48
+ },
49
+ focus: function() {
50
+ // prevent value inserted on focus
51
+ return false;
52
+ },
53
+ select: function(event, ui) {
54
+ var terms = split(this.value);
55
+ // remove the current input
56
+ terms.pop();
57
+ // add the selected item
58
+ terms.push(ui.item.value);
59
+ // add placeholder to get the comma-and-space at the end
60
+ terms.push("");
61
+ this.value = terms.join(", ");
62
+ return false;
63
+ }
64
+ });
65
+
34
66
  });
35
67
 
68
+ function split( val ) {
69
+ return val.split( /,\s*/ );
70
+ }
71
+ function extractLast( term ) {
72
+ return split( term ).pop();
73
+ }
74
+
36
75
  function checked_emails(){
37
76
  return get_emails(jQuery('.contacts-list .cb input:checkbox:checked'));
38
77
  }
@@ -42,6 +81,12 @@ function get_emails(cbs){
42
81
  return jQuery(this).val();
43
82
  }).get();
44
83
  }
84
+
85
+ function set_email_ui(){
86
+ var emails = split_list(jQuery('#emails').val());
87
+ excluded_checkbox_by_email(emails, false);
88
+ included_checkbox_by_email(emails, true);
89
+ }
45
90
  // Sets checkboxes that are in 'emails'
46
91
  function included_checkbox_by_email(emails, checked){
47
92
  jQuery('.contacts-list .cb input:checkbox').each(function(index) {
@@ -12,14 +12,17 @@ en:
12
12
  create_success: Invites were sent to %{emails}. You will be notified if they join %{app_name}
13
13
  we_wont_email: We won't email these addresses without your permission.
14
14
  invited_joined: "%{user}} joined %{app_name}"
15
+ invite_via_email_title: Email invites to friends
15
16
  retrieving_contacts: Retrieving contacts
16
17
  we_dont_store: We don't store your login and your password is submitted securely.
18
+ emails: Emails
17
19
  emails_empty: You didn't specify any emails
18
20
  invalid_email_error: does not look like a valid email address.
19
21
  your_email: Your Email
20
22
  your_email_help: The email address of an account with contacts that you want to invite
21
23
  select_emails: "Select emails:"
22
24
  select_all: Select All
25
+ message: Message
23
26
  no_contacts_found: No contacts were found
24
27
  compose_invites: Compose Invite
25
28
  email_friends_prompt: "Enter emails of friends to invite:"
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{muck-invites}
8
- s.version = "3.3.3"
8
+ s.version = "3.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Ball, Joel Duffin"]
12
- s.date = %q{2011-04-28}
12
+ s.date = %q{2011-05-04}
13
13
  s.description = %q{The invite engine for the muck system.}
14
14
  s.email = %q{justin@tatemae.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muck-invites
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
- - 3
9
- - 3
10
- version: 3.3.3
8
+ - 4
9
+ - 0
10
+ version: 3.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Justin Ball, Joel Duffin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-28 00:00:00 -06:00
18
+ date: 2011-05-04 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency