spree_multi_share 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +20 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +7 -0
  5. data/LICENSE +26 -0
  6. data/README.md +4 -0
  7. data/Rakefile +15 -0
  8. data/Versionfile +11 -0
  9. data/app/assets/images/spree/aol_logo.jpg +0 -0
  10. data/app/assets/images/spree/cs_logo.gif +0 -0
  11. data/app/assets/images/spree/cs_signup.png +0 -0
  12. data/app/assets/images/spree/gmail_logo.jpg +0 -0
  13. data/app/assets/images/spree/msn_logo.jpg +0 -0
  14. data/app/assets/images/spree/osx_logo.jpg +0 -0
  15. data/app/assets/images/spree/outlook_logo.png +0 -0
  16. data/app/assets/images/spree/windows_logo.png +0 -0
  17. data/app/assets/javascripts/admin/spree_multi_share.js +1 -0
  18. data/app/assets/javascripts/spree/cloud_sender.js +2 -0
  19. data/app/assets/javascripts/store/spree_multi_share.js +1 -0
  20. data/app/assets/stylesheets/admin/spree_multi_share.css +3 -0
  21. data/app/assets/stylesheets/spree/cloud_sender.css +4 -0
  22. data/app/assets/stylesheets/store/spree_multi_share.css +3 -0
  23. data/app/controllers/spree/admin/cloudsponge_settings_controller.rb +15 -0
  24. data/app/controllers/spree/cloud_sender_controller.rb +175 -0
  25. data/app/helpers/spree/cloud_sender_helper.rb +2 -0
  26. data/app/mailers/spree/cloud_mailer.rb +21 -0
  27. data/app/models/spree/cloudsponge_configuration.rb +5 -0
  28. data/app/models/spree/mail_to_cloud.rb +42 -0
  29. data/app/overrides/add_cloudsponge_settings_to_admin_configurations_menu.rb +5 -0
  30. data/app/overrides/add_email_to_cloud_link_to_products.rb +7 -0
  31. data/app/views/spree/admin/cloudsponge_settings/edit.html.erb +39 -0
  32. data/app/views/spree/cloud_mailer/mail_to_cloud.text.erb +3 -0
  33. data/app/views/spree/cloud_sender/importAOL.html.erb +56 -0
  34. data/app/views/spree/cloud_sender/importCheck.html.erb +1 -0
  35. data/app/views/spree/cloud_sender/importContacts.html.erb +104 -0
  36. data/app/views/spree/cloud_sender/importGmail.html.erb +62 -0
  37. data/app/views/spree/cloud_sender/importOSX.html.erb +95 -0
  38. data/app/views/spree/cloud_sender/importOutlook.html.erb +95 -0
  39. data/app/views/spree/cloud_sender/send_mail.html.erb +150 -0
  40. data/app/views/spree/products/_mail_to_cloud.text.erb +14 -0
  41. data/config/locales/en.yml +18 -0
  42. data/config/routes.rb +18 -0
  43. data/db/migrate/20130125181027_create_spree_mail_to_clouds.rb +8 -0
  44. data/lib/generators/spree_multi_share/install/install_generator.rb +29 -0
  45. data/lib/spree_multi_share/engine.rb +29 -0
  46. data/lib/spree_multi_share.rb +2 -0
  47. data/script/rails +7 -0
  48. data/spec/controllers/spree/cloud_sender_controller_spec.rb +5 -0
  49. data/spec/helpers/spree/cloud_sender_helper_spec.rb +15 -0
  50. data/spec/mailers/spree/cloud_mailer_spec.rb +5 -0
  51. data/spec/models/spree/mail_to_cloud_spec.rb +5 -0
  52. data/spec/spec_helper.rb +46 -0
  53. data/spree_multi_share.gemspec +30 -0
  54. metadata +61 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27e941c8d872d668169a575305dfc61e73bc2ba3
4
- data.tar.gz: 26b7325a5ed588e865b3611ed16b94634692c635
3
+ metadata.gz: 212c006497ba0fc8a3e87a33c004649d856eca2e
4
+ data.tar.gz: a4d6401a397228036ac898a3b63db6deb82fb947
5
5
  SHA512:
6
- metadata.gz: aa681de79dcbf2855d33f1271870f4a5346d2658d3fbb32ad8f526f3c4848a3c75c1873a5a73da7ac2a80ba8355f490959d3fa935e25f028bff5235a727eac46
7
- data.tar.gz: f9c32dceb1ea4847c1bbd1a83270aaf5fbbbf17227bb968300771f440f8b2dbf14810d253e10eaa99dbdc1bbe47afab40b1ca1f7aef2e70470a5d10b79a12bc5
6
+ metadata.gz: 997b1ea58cf48310d7a5661ca585d69757bb664e4a2d7863bd642b88a3f1d45567905d9b4eaa05664ebeaaebea4ebbb3d9d82d3afb67166e49cfc0954139bb52
7
+ data.tar.gz: aa9205fea095fa7f9c02dcc4096a6f36369855319cc20186660532f05ab704574c22010fbddd54056b9becb2cccb521c421a776be1c9e47ffd4a1387c98495b8
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ Gemfile.lock
2
+ *.DS_Store
3
+ *.gem
4
+ *.rbc
5
+ .bundle
6
+ .config
7
+ coverage
8
+ InstalledFiles
9
+ lib/bundler/man
10
+ pkg
11
+ rdoc
12
+ spec/reports
13
+ test/tmp
14
+ test/version_tmp
15
+ tmp
16
+
17
+ # YARD artifacts
18
+ .yardoc
19
+ _yardoc
20
+ doc/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Provides basic authentication functionality for testing parts of your engine
4
+ gem 'spree_auth_devise', :git => "git://github.com/spree/spree_auth_devise"
5
+
6
+ gemspec
7
+
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2013 [name of plugin creator]
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ spree_multi_share
2
+ =================
3
+
4
+ Extension for Spree that allows customers to share products with their cloud friends for store credit. Powered by CloudSponge.
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ require 'spree/core/testing_support/common_rake'
6
+
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task :default => [:spec]
10
+
11
+ desc 'Generates a dummy app for testing'
12
+ task :test_app do
13
+ ENV['LIB_NAME'] = 'spree_multi_share'
14
+ Rake::Task['common:test_app'].invoke
15
+ end
data/Versionfile ADDED
@@ -0,0 +1,11 @@
1
+ # This file is used to designate compatibilty with different versions of Spree
2
+ # Please see http://spreecommerce.com/documentation/extensions.html#versionfile for details
3
+
4
+ # Examples
5
+ #
6
+ # '1.2.x' => { :branch => 'master' }
7
+ # '1.1.x' => { :branch => '1-1-stable' }
8
+ # '1.0.x' => { :branch => '1-0-stable' }
9
+ # '0.70.x' => { :branch => '0-70-stable' }
10
+ # '0.40.x' => { :tag => 'v1.0.0', :version => '1.0.0' }
11
+
Binary file
@@ -0,0 +1 @@
1
+ //= require admin/spree_core
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1 @@
1
+ //= require store/spree_core
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require admin/spree_core
3
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require store/spree_core
3
+ */
@@ -0,0 +1,15 @@
1
+ module Spree
2
+ module Admin
3
+ class CloudspongeSettingsController < BaseController
4
+ def update
5
+ Spree::Cloudsponge::Config.set(params[:preferences])
6
+
7
+ respond_to do |format|
8
+ format.html {
9
+ redirect_to edit_admin_cloudsponge_settings_path
10
+ }
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,175 @@
1
+ class Spree::CloudSenderController < Spree::BaseController
2
+ require 'rubygems'
3
+
4
+ include Spree::Core::ControllerHelpers::Order
5
+
6
+ before_filter :find_object, :only => [:send_mail, :mail_to_cloud, :send_message]
7
+
8
+ def send_mail
9
+ if request.get?
10
+ @mail_to_cloud = Spree::MailToCloud.new(:sender_email => current_user.try(:email))
11
+ else
12
+ mail_to_cloud
13
+ end
14
+ end
15
+
16
+ def importGmail
17
+ client = HTTPClient.new
18
+ body = { 'service' => params[:service], 'domain_key' => Spree::Cloudsponge::Config[:domain_key], 'domain_password' => Spree::Cloudsponge::Config[:domain_password], 'referrer' => 'sweet_spree' }
19
+ response = client.post('https://api.cloudsponge.com/begin_import/user_consent.json', body)
20
+ data = ActiveSupport::JSON.decode(response.body)
21
+ @authURL = data["url"]
22
+ @importID = data["import_id"]
23
+
24
+ respond_to do | format |
25
+ format.html {render :layout => false}
26
+ end
27
+ end
28
+
29
+ def importAOL
30
+ client = HTTPClient.new
31
+ body = { 'service' => params[:service], 'username' => params[:username], 'password' => params[:password], 'domain_key' => Spree::Cloudsponge::Config[:domain_key], 'domain_password' => Spree::Cloudsponge::Config[:domain_password], 'referrer' => 'sweet_spree' }
32
+ response = client.post('https://api.cloudsponge.com/begin_import/import.json', body)
33
+ data = ActiveSupport::JSON.decode(response.body)
34
+ @importID = data["import_id"]
35
+
36
+ respond_to do | format |
37
+ format.html {render :layout => false}
38
+ end
39
+ end
40
+
41
+ def importOutlook
42
+ client = HTTPClient.new
43
+ body = { 'service' => 'OUTLOOK', 'domain_key' => Spree::Cloudsponge::Config[:domain_key], 'domain_password' => Spree::Cloudsponge::Config[:domain_password], 'referrer' => 'sweet_spree' }
44
+ response = client.post('https://api.cloudsponge.com/begin_import/desktop_applet.json', body)
45
+ data = ActiveSupport::JSON.decode(response.body)
46
+ @authURL = data["url"]
47
+ @importID = data["import_id"]
48
+
49
+ respond_to do | format |
50
+ format.html {render :layout => false}
51
+ end
52
+ end
53
+
54
+ def importOSX
55
+ client = HTTPClient.new
56
+ body = { 'service' => 'ADDRESSBOOK', 'domain_key' => Spree::Cloudsponge::Config[:domain_key], 'domain_password' => Spree::Cloudsponge::Config[:domain_password], 'referrer' => 'sweet_spree' }
57
+ response = client.post('https://api.cloudsponge.com/begin_import/desktop_applet.json', body)
58
+ data = ActiveSupport::JSON.decode(response.body)
59
+ @authURL = data["url"]
60
+ @importID = data["import_id"]
61
+
62
+ respond_to do | format |
63
+ format.html {render :layout => false}
64
+ end
65
+ end
66
+
67
+ def importCheck
68
+ @success = false;
69
+
70
+ client = HTTPClient.new
71
+ body = { 'import_id' => params[:id], 'domain_key' => Spree::Cloudsponge::Config[:domain_key], 'domain_password' => Spree::Cloudsponge::Config[:domain_password] }
72
+ response = client.get('https://api.cloudsponge.com/events/' + params[:id], body)
73
+ @data = ActiveSupport::JSON.decode(response.body)
74
+ if (@data["events"].count > 0)
75
+ if ((@data["events"][0]["event_type"] == "COMPLETE") && (@data["events"][0]["status"] == "COMPLETED"))
76
+ @success = "true"
77
+ elsif ((@data["events"][0]["event_type"] == "COMPLETE") && (@data["events"][0]["status"] == "ERROR"))
78
+ @success = "error"
79
+ else
80
+ @success = "false"
81
+ end
82
+ end
83
+
84
+ respond_to do | format |
85
+ format.html {render :layout => false}
86
+ end
87
+ end
88
+
89
+ def importContacts
90
+ client = HTTPClient.new
91
+ body = { 'import_id' => params[:id], 'domain_key' => Spree::Cloudsponge::Config[:domain_key], 'domain_password' => Spree::Cloudsponge::Config[:domain_password] }
92
+ response = client.get('https://api.cloudsponge.com/contacts/' + params[:id], body)
93
+ @data = ActiveSupport::JSON.decode(response.body)
94
+ @contacts_with_dups = @data["contacts"].sort {|x,y| x["first_name"].capitalize <=> y["first_name"].capitalize}
95
+ @contacts = Array.new
96
+ emailList = Array.new
97
+ @contacts_with_dups.each do |contact|
98
+ if !(contact["email"].nil?) && !(contact["email"][0].nil?) && !(contact["email"][0]["address"].nil?) && (contact["email"][0]["address"] != "")
99
+ if !(emailList.include?(contact["email"][0]["address"]))
100
+ emailList << contact["email"][0]["address"]
101
+ @contacts << contact
102
+ end
103
+ end
104
+ end
105
+
106
+ respond_to do | format |
107
+ format.html {render :layout => false}
108
+ end
109
+ end
110
+
111
+ def cloudsponge_proxy
112
+ importer = Cloudsponge::ContactImporter.new(Spree::Cloudsponge::Config[:domain_key], Spree::Cloudsponge::Config[:domain_password])
113
+ url = Cloudsponge::URL_BASE + 'auth?' + request.query_string
114
+
115
+ response = if request.post?
116
+ Cloudsponge::Utility::post_url(url, request.parameters)
117
+ elsif request.get?
118
+ Cloudsponge::Utility::get_url(url)
119
+ else
120
+ nil
121
+ end
122
+
123
+ if response.is_a?(Net::HTTPRedirection)
124
+ redirect_to response["location"]
125
+ else
126
+ render :text => response.try(:body)
127
+ end
128
+ end
129
+
130
+ private
131
+
132
+ def mail_to_cloud
133
+ @mail_to_cloud = Spree::MailToCloud.new(params[:mail_to_cloud])
134
+ @mail_to_cloud.host = request.env['HTTP_HOST']
135
+ respond_to do |format|
136
+ format.html do
137
+ if @mail_to_cloud.valid?
138
+ flash[:notice] = I18n.t('cloudsponge.mail_sent_to', :email => @mail_to_cloud.recipient_email).html_safe
139
+ flash[:notice] << ActionController::Base.helpers.link_to(I18n.t('cloudsponge.send_to_other'), email_to_cloud_path(@object.class.name.split("::").last.downcase, @object)).html_safe
140
+
141
+ send_message(@object, @mail_to_cloud)
142
+
143
+ #method_name = "after_delivering_#{@object.class.name.downcase}_mail"
144
+ #send(method_name) if respond_to?(method_name, true)
145
+
146
+ redirect_to @object
147
+ else
148
+ render :action => :send_mail
149
+ end
150
+ end
151
+ end
152
+ end
153
+
154
+ def send_message(object, mail_to_cloud)
155
+ @mail_to_cloud.recipients.each do |email_address|
156
+ @temp_mail_to_cloud = mail_to_cloud
157
+ @temp_mail_to_cloud.recipient_email = email_address
158
+ Spree::CloudMailer.mail_to_cloud(object,@temp_mail_to_cloud).deliver
159
+ end
160
+ end
161
+
162
+ def find_object
163
+ class_name = "Spree::#{(params[:type].titleize)}".constantize
164
+ return false if params[:id].blank?
165
+ @object = class_name.find_by_id(params[:id])
166
+ if class_name.respond_to?('find_by_permalink')
167
+ @object ||= class_name.find_by_permalink(params[:id])
168
+ end
169
+ if class_name.respond_to?('get_by_param')
170
+ @object ||= class_name.get_by_param(params[:id])
171
+ end
172
+ # Display 404 page if object is not found.
173
+ raise ActiveRecord::RecordNotFound if @object.nil?
174
+ end
175
+ end
@@ -0,0 +1,2 @@
1
+ module Spree::CloudSenderHelper
2
+ end
@@ -0,0 +1,21 @@
1
+ class Spree::CloudMailer < ActionMailer::Base
2
+ default :from => Spree::MailMethod.current.try(:preferred_mails_from) || ''
3
+
4
+ def mail_to_cloud(object, mail)
5
+ @object = object
6
+ @mail = mail
7
+ opts = {}
8
+
9
+ if mail.hide_recipients && Spree::Config[:hidden_recipients_to_address]
10
+ opts[:to] = Spree::Config[:hidden_recipients_to_address]
11
+ opts[:bcc] = mail.recipient_email
12
+ else
13
+ opts[:to] = mail.recipient_email
14
+ end
15
+ default_url_options[:host] = mail.host
16
+ opts[:subject] = mail.subject
17
+ opts[:reply_to] = mail.sender_email
18
+
19
+ mail(opts)
20
+ end
21
+ end
@@ -0,0 +1,5 @@
1
+ class Spree::CloudspongeConfiguration < Spree::Preferences::Configuration
2
+ # this keys works for localhost
3
+ preference :domain_key, :string, :default => '{Enter Domain Key}'
4
+ preference :domain_password, :string, :default => '{Enter Domain Password}'
5
+ end
@@ -0,0 +1,42 @@
1
+ class Spree::MailToCloud
2
+ include ActiveModel::Validations
3
+ include ActiveModel::Conversion
4
+ attr_accessor :host, :subject, :sender_name, :sender_email, :recipient_name, :recipient_email, :message, :recipients, :invalid_recipients, :hide_recipients
5
+
6
+ EMAILREGEX = /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,8}$/i
7
+
8
+ validates :subject, :presence => true
9
+ validates :sender_name, :presence => true
10
+ validates :sender_email, :format => { :with => EMAILREGEX }
11
+ validates :recipients, :length => {:minimum => 1, :message => "must contain at least one valid email address"}
12
+ validates :invalid_recipients, :length => {:maximum => 0, :message => "must be removed"}
13
+
14
+ def initialize(opts = {})
15
+ @sender_email = opts[:sender_email] || ' '
16
+ @sender_name = opts[:sender_name] || @sender_email.split('@', 2)[0].titleize
17
+ @subject = opts[:subject] || I18n.t('email_to_friend.you_would_like_this', :sender_name => @sender_name, :site => Spree::Config[:site_url])
18
+
19
+ @recipients = []
20
+ @invalid_recipients = []
21
+
22
+ @recipient_email = (opts[:recipient_email] || '').gsub(';', ',').gsub(/\s/ , '')
23
+ @recipient_email.split(',').each do |address|
24
+ if address =~ EMAILREGEX
25
+ @recipients << address
26
+ else
27
+ @invalid_recipients << address
28
+ end
29
+ end
30
+
31
+ @hide_recipients = opts[:hide_recipients] || false
32
+ @message = opts[:message]
33
+ end
34
+
35
+ def persisted?
36
+ false
37
+ end
38
+
39
+ def is_multi
40
+ (@recipients.size + @invalid_recipients.size) > 1
41
+ end
42
+ end
@@ -0,0 +1,5 @@
1
+ Deface::Override.new(:virtual_path => "spree/admin/shared/_configuration_menu",
2
+ :name => "add_cloudsponge_admin_option",
3
+ :insert_bottom => "[data-hook='admin_configurations_sidebar_menu']",
4
+ :text => "<%= configurations_sidebar_menu_item t('cloudsponge.cloudsponge_settings'), edit_admin_cloudsponge_settings_path %>",
5
+ :disabled => false)
@@ -0,0 +1,7 @@
1
+ Deface::Override.new(:virtual_path => "spree/products/show",
2
+ :name => "converted_product_description_678329210",
3
+ :insert_bottom => "[data-hook='product_description'], #product_description[data-hook]",
4
+ :text => "<p class=\"email_to_cloud\">
5
+ <%= link_to t('cloudsponge.send_to_cloud'), email_to_cloud_url('product', @product) %> &nbsp; &nbsp; &nbsp; &nbsp; <small>(<i>powered by</i> <a target='new' href='http://www.cloudsponge.com'>Cloudsponge</a>)</small>
6
+ </p>",
7
+ :disabled => false)
@@ -0,0 +1,39 @@
1
+ <%= render :partial => 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <% content_for :page_title do %>
4
+ <%= t('cloudsponge.cloudsponge_settings') %>
5
+ <% end %>
6
+ <br/>
7
+ <a href='http://www.cloudsponge.com/?utm_source=sweet_spree&utm_medium=partner&utm_campaign=integrator' target='_blank'>CloudSponge</a> is the driving engine behind the spree_multi_share gem.
8
+ <br/><br/>
9
+ <h1>What is CloudSponge?</h1>
10
+ <br/>
11
+ CloudSponge provides software that enables your users to send links for products on your website to their contacts from a variety of the most popular webmail services including Yahoo, Hotmail and Gmail and desktop address books such as Outlook and Mac Address Book.<br/>
12
+ <br/>
13
+ <a href='https://www.cloudsponge.com/sign-up?utm_source=sweet_spree&utm_medium=partner&utm_campaign=integrator' target='_blank'><img src='/assets/spree/cs_signup.png'></a><br/>
14
+ <br/>
15
+ Once you've signed up just enter in your domain key and domain password below and "Tell Your Friends!" links should appear next to all your products!<br/>
16
+
17
+ <%= form_tag(admin_cloudsponge_settings_path, :method => :put) do |f| -%>
18
+
19
+ <fieldset class="no-border-top">
20
+ <div data-hook="admin_cloudsponge_settings" class="row">
21
+
22
+ <div data-hook="domain_key" class="field">
23
+ <label><%= t('cloudsponge.domain_key') %></label><br>
24
+ <%= text_field_tag('preferences[domain_key]', Spree::Cloudsponge::Config[:domain_key], :size => 40) %>
25
+ </div>
26
+
27
+ <div data-hook="domain_password" class="field">
28
+ <label><%= t('cloudsponge.domain_password') %></label><br>
29
+ <%= text_field_tag('preferences[domain_password]', Spree::Cloudsponge::Config[:domain_password], :size => 40) %>
30
+ </div>
31
+ </div>
32
+
33
+ <div class="form-buttons filter-actions actions" data-hook="buttons">
34
+ <%= button t(:update), 'icon-refresh' %>
35
+ </div>
36
+
37
+ </fieldset>
38
+
39
+ <% end -%>
@@ -0,0 +1,3 @@
1
+ <% object_sym = @object.class.name.downcase %>
2
+ <%= render :partial => "spree/products/mail_to_cloud",
3
+ :locals => {:product => @object, :mail => @mail} %>
@@ -0,0 +1,56 @@
1
+ <div id="waitingDiv"><b>Loading Your Address Book...</b><br/><i>(Larger contact lists may take longer to load)</i></div>
2
+ <div id="contentDiv">
3
+ <input type="button" value="Cancel" onclick="closeWindow()">
4
+ </div>
5
+
6
+ <script>
7
+ var i = 0;
8
+ var authReceived = false;
9
+ var loginError = false;
10
+ var intervalID = setInterval(checkAuth, 1000);
11
+
12
+ function checkAuth(){
13
+ i = i + 1;
14
+ tempString = "Loading Your Address Book"
15
+ for (j=0; j<(i%6); j++)
16
+ tempString = tempString + ".";
17
+ jQuery("#waitingDiv").html("<b>" + tempString + "</b><br/><i>(Larger contact lists may take longer to load)</i>");
18
+
19
+ jQuery.ajax("/importCheck/<%= @importID %>", {
20
+ complete:function(jqXHR, textStatus) {
21
+ if (jqXHR.responseText == "true")
22
+ authReceived = true;
23
+ else if (jqXHR.responseText == "error")
24
+ loginError = true;
25
+ }
26
+ });
27
+
28
+ if (loginError){
29
+ clearInterval(intervalID);
30
+ alert("There was a problem with your username or password. Please try again!");
31
+ showAOLLogin();
32
+ }
33
+
34
+ if (authReceived){
35
+ clearInterval(intervalID);
36
+ jQuery("#waitingDiv").html("<b>Authorization Received!</b>");
37
+ jQuery("#importText").html("<b>Loading Contacts. Please wait...</b>");
38
+ jQuery.ajax("/importContacts/<%= @importID %>?service=<%= params[:service] %><% if !(params[:new_client_waiting_list_id].nil?) %>&new_client_waiting_list_id=<%= params[:new_client_waiting_list_id] %><% end %>", {
39
+ complete:function(jqXHR, textStatus) {
40
+ document.getElementById("waitingDiv").style.display = 'none';
41
+ jQuery("#contentDiv").html(jqXHR.responseText);
42
+ }
43
+ });
44
+ }
45
+ }
46
+ </script>
47
+
48
+ <script>
49
+ function closeWindow(){
50
+ document.getElementById("importAOLLogo").style.display = 'none';
51
+ document.getElementById("importText").style.display = 'none';
52
+ document.getElementById("importDiv").style.display = 'none';
53
+ document.getElementById("addressSelectionDiv").style.display = 'block';
54
+ clearInterval(intervalID);
55
+ }
56
+ </script>
@@ -0,0 +1 @@
1
+ <%= @success %>
@@ -0,0 +1,104 @@
1
+ <script>
2
+ contactCount = 0;
3
+ inviteeCount = 0;
4
+ emailList = new Array();
5
+
6
+ function addContact(div, full_name, email){
7
+ div.style.display='none';
8
+ inviteeDiv = document.getElementById("inviteeDiv");
9
+ contactCount = contactCount - 1;
10
+ document.getElementById("contactCountSpan").innerHTML = contactCount;
11
+ inviteeCount = inviteeCount + 1;
12
+ document.getElementById("inviteeCountSpan").innerHTML = inviteeCount;
13
+ inviteeDiv.innerHTML = inviteeDiv.innerHTML + "<div style='cursor:pointer;overflow:auto' onmouseover='this.style.background=\"lightgray\"' onmouseout='this.style.background=\"white\"' onclick='removeContact(this,\"" + email + "\")'><span style='float:left'>&nbsp; <b>-</b> &nbsp; " + full_name + "</span> <span style='float:right'>(" + email + ")</span>";
14
+ emailList.push(email);
15
+ }
16
+
17
+ function removeContact(div, email){
18
+ div.style.display='none';
19
+ contactDiv = document.getElementById("contactDiv");
20
+ contactCount = contactCount + 1;
21
+ document.getElementById("contactCountSpan").innerHTML = contactCount;
22
+ inviteeCount = inviteeCount - 1;
23
+ document.getElementById("inviteeCountSpan").innerHTML = inviteeCount;
24
+ document.getElementById(email).style.display = 'block';
25
+ emailList.splice(emailList.indexOf(email), 1);
26
+ }
27
+
28
+ function addAllContacts(){
29
+ contactDiv = document.getElementById("contactDiv");
30
+ subDivs = contactDiv.getElementsByTagName("div");
31
+ for (i=0; i < subDivs.length; i++){
32
+ displayValue = window.getComputedStyle(subDivs[i], null).getPropertyValue("display");
33
+ if (displayValue != 'none')
34
+ subDivs[i].onclick();
35
+ }
36
+ }
37
+
38
+ function removeAllInvitees(){
39
+ inviteeDiv = document.getElementById("inviteeDiv");
40
+ subDivs = inviteeDiv.getElementsByTagName("div");
41
+ for (i=0; i < subDivs.length; i++){
42
+ displayValue = window.getComputedStyle(subDivs[i], null).getPropertyValue("display");
43
+ if (displayValue != 'none')
44
+ subDivs[i].onclick();
45
+ }
46
+ }
47
+
48
+ jQuery("#importText").html("<b>Please select the contacts you'd like to tell about this product below:</b><br><small><i>powered by</i> <a target='new' href='http://www.cloudsponge.com'>Cloudsponge</a></small>");
49
+ </script>
50
+
51
+ <div style="border:1px solid black; width:300px; height:206px; float:left;">
52
+ <div style="background-color:lightgray;font-size:15px"><b>Contacts (<span id="contactCountSpan">0</span>)</b></div>
53
+ <div style="background-color:lightgray;font-size:12px;cursor: pointer" onclick="addAllContacts();">+ Add All</div>
54
+ <div id="contactDiv" style="overflow:auto;height:173px;font-size:11px;">
55
+ <% contactCount = 0 %>
56
+ <% @contacts.each do |contact| %>
57
+ <% if !(contact["email"][0].nil?) && !(contact["first_name"].nil?) %>
58
+ <% contactCount = contactCount + 1 %>
59
+ <% full_name = contact["first_name"] + " " + contact["last_name"] %>
60
+ <% email = contact["email"][0]["address"] %>
61
+ <div id="<%= email %>" style="cursor:pointer;overflow:auto" onmouseover="this.style.background='lightgray'" onmouseout="this.style.background='white'" onclick="addContact(this, '<%= full_name %>','<%= contact["email"][0]["address"] %>');">
62
+ <span style="float:left;">&nbsp; <b>+</b> &nbsp; <%= full_name %></span> <span style="float:right;">(<%= email %>)</span>
63
+ </div>
64
+ <% end %>
65
+ <% end %>
66
+ </div>
67
+ </div>
68
+ <div style="width:50px; float:left">&nbsp;</div>
69
+ <div style="border:1px solid black; width:300px; height:206px; float:left; overflow:auto">
70
+ <div style="background-color:lightgray;font-size:15px"><b>Invitees (<span id="inviteeCountSpan">0</span>)</b></div>
71
+ <div style="background-color:lightgray;font-size:12px;cursor: pointer" onclick="removeAllInvitees();">+ Remove All</div>
72
+ <div id="inviteeDiv" style="overflow:auto;height:173px;font-size:11px;"></div>
73
+ </div>
74
+ <div style="clear:both">&nbsp;</div>
75
+ <br/>
76
+ <form action="/invite/" method="post">
77
+ <input type="hidden" id="client_email_list" name="client_email_list" value="">
78
+ <% if !(params[:new_client_waiting_list_id].nil?) %>
79
+ <input type="hidden" name="new_client_waiting_list_id" id="new_client_waiting_list_id" value="<%= params[:new_client_waiting_list_id] %>">
80
+ <% end %>
81
+ <input type="button" value="Tell Your Friends!" onclick="inviteContacts(this.form)"> &nbsp; &nbsp;
82
+ <input type="button" value="Cancel" onclick="closeWindow()">
83
+ </form>
84
+
85
+ <script>
86
+ contactCount = <%= contactCount %>;
87
+ document.getElementById("contactCountSpan").innerHTML = contactCount;
88
+ </script>
89
+
90
+ <script>
91
+ function inviteContacts(frm){
92
+ //client_email_list = document.getElementById("client_email_list");
93
+ //client_email_list.value = emailList.join();
94
+ recipient_email_list = emailList.join()
95
+
96
+ if (recipient_email_list == "")
97
+ alert("You must select at least one contact!");
98
+ else{
99
+ document.getElementById("mail_to_cloud_recipient_email").value = recipient_email_list;
100
+ document.getElementById("new_mail_to_cloud").submit();
101
+ }
102
+ //frm.submit();
103
+ }
104
+ </script>