caboose-cms 0.8.43 → 0.8.44

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/caboose/admin_page_edit_content.js +83 -70
  3. data/app/assets/javascripts/caboose/card.js +2432 -0
  4. data/app/assets/javascripts/caboose/clipboard.js +7 -0
  5. data/app/assets/javascripts/caboose/modal_controllers/modal_block_controller.js +174 -252
  6. data/app/assets/javascripts/caboose/modal_controllers/modal_controller.js +160 -12
  7. data/app/assets/javascripts/caboose/modal_controllers/modal_media_controller.js +419 -0
  8. data/app/assets/javascripts/caboose/modal_integration.js +21 -1
  9. data/app/assets/javascripts/caboose/model/bound_checkbox.js +13 -6
  10. data/app/assets/javascripts/caboose/model/bound_select.js +16 -7
  11. data/app/assets/javascripts/caboose/model/bound_text.js +15 -2
  12. data/app/assets/stylesheets/caboose/admin_block_edit_image.css.scss +16 -1
  13. data/app/assets/stylesheets/caboose/admin_new_block.css +9 -0
  14. data/app/assets/stylesheets/caboose/application.css +2 -1
  15. data/app/assets/stylesheets/caboose/modal_inline.css +8 -15
  16. data/app/assets/stylesheets/caboose/my_account.scss +178 -0
  17. data/app/controllers/caboose/block_types_controller.rb +20 -0
  18. data/app/controllers/caboose/blocks_controller.rb +70 -8
  19. data/app/controllers/caboose/media_controller.rb +39 -3
  20. data/app/models/caboose/block.rb +17 -1
  21. data/app/models/caboose/media.rb +9 -8
  22. data/app/models/caboose/schema.rb +1 -0
  23. data/app/views/caboose/block_types/admin_edit.html.erb +5 -2
  24. data/app/views/caboose/block_types/admin_index.html.erb +2 -1
  25. data/app/views/caboose/my_account/index.html.erb +124 -63
  26. data/app/views/caboose/my_account/index_old.html.erb +191 -0
  27. data/app/views/caboose/pages/admin_edit_content.html.erb +16 -1
  28. data/lib/caboose/version.rb +1 -1
  29. metadata +8 -3
  30. data/app/assets/stylesheets/caboose/my_account.css +0 -2
@@ -0,0 +1,191 @@
1
+ <%
2
+ store_config = @invoice.site.store_config if @invoice
3
+ u = @logged_in_user
4
+ %>
5
+ <div id='my_account'>
6
+ <h1>My Account</h1>
7
+ <p><div id='user_<%= @user.id %>_first_name' ></div></p>
8
+ <p><div id='user_<%= @user.id %>_last_name' ></div></p>
9
+ <p><div id='user_<%= @user.id %>_email' ></div></p>
10
+ <p><div id='user_<%= @user.id %>_phone' ></div></p>
11
+ <div id='message2'></div>
12
+
13
+ <% if @site.use_store && store_config %>
14
+ <h2>Billing</h2>
15
+ <p id='card_details'>
16
+ <% if u.card_brand && u.card_last4 %>You have a <%= u.card_brand %> ending in <%= u.card_last4 %> on file.<% else %>You have no card on file.<% end %>
17
+ <a href='#' onclick="toggle_stripe_form();" />edit</a>
18
+ </p>
19
+ <form action='' method='post' id='stripe_form' class='stripe_form'>
20
+ <div class='card_number_container'><input id='card_number' type='tel' autocomplete='off' autocorrect='off' spellcheck='off' autocapitalize='off' placeholder='Card number' /><div class='svg icon' style='width:30px;height:30px'><svg version="1.1" viewBox="0 0 30 30" width="30" height="30" focusable="false"><g fill-rule="evenodd"><path d="M2.00585866,0 C0.898053512,0 0,0.900176167 0,1.99201702 L0,9.00798298 C0,10.1081436 0.897060126,11 2.00585866,11 L11.9941413,11 C13.1019465,11 14,10.0998238 14,9.00798298 L14,1.99201702 C14,0.891856397 13.1029399,0 11.9941413,0 L2.00585866,0 Z M2.00247329,1 C1.44882258,1 1,1.4463114 1,1.99754465 L1,9.00245535 C1,9.55338405 1.45576096,10 2.00247329,10 L11.9975267,10 C12.5511774,10 13,9.5536886 13,9.00245535 L13,1.99754465 C13,1.44661595 12.544239,1 11.9975267,1 L2.00247329,1 Z M1,3 L1,5 L13,5 L13,3 L1,3 Z M11,8 L11,9 L12,9 L12,8 L11,8 Z M9,8 L9,9 L10,9 L10,8 L9,8 Z M9,8" style="fill:#3b6faa" transform="translate(8,10)"></g></svg></div></div>
21
+ <div class='card_exp_container' ><input id='card_exp' type='tel' autocomplete='off' autocorrect='off' spellcheck='off' autocapitalize='off' placeholder='MM / YY' x-autocompletetype='off' autocompletetype'=off' /><div class='svg icon' style='width:30px;height:30px'><svg version="1.1" viewBox="0 0 30 30" width="30" height="30" focusable="false"><g fill-rule="evenodd"><path d="M2.0085302,1 C0.899249601,1 0,1.90017617 0,2.99201702 L0,10.007983 C0,11.1081436 0.901950359,12 2.0085302,12 L9.9914698,12 C11.1007504,12 12,11.0998238 12,10.007983 L12,2.99201702 C12,1.8918564 11.0980496,1 9.9914698,1 L2.0085302,1 Z M1.99539757,4 C1.44565467,4 1,4.43788135 1,5.00292933 L1,9.99707067 C1,10.5509732 1.4556644,11 1.99539757,11 L10.0046024,11 C10.5543453,11 11,10.5621186 11,9.99707067 L11,5.00292933 C11,4.44902676 10.5443356,4 10.0046024,4 L1.99539757,4 Z M3,1 L3,2 L4,2 L4,1 L3,1 Z M8,1 L8,2 L9,2 L9,1 L8,1 Z M3,0 L3,1 L4,1 L4,0 L3,0 Z M8,0 L8,1 L9,1 L9,0 L8,0 Z M8,0" style="fill:#3b6faa" transform="translate(8,9)"></g></svg></div></div>
22
+ <div class='card_cvc_container' ><input id='card_cvc' type='tel' autocomplete='off' autocorrect='off' spellcheck='off' autocapitalize='off' placeholder='CVC' maxlength='4' /><div class='svg icon' style='width:30px;height:30px'><svg version="1.1" viewBox="0 0 30 30" width="30" height="30" focusable="false"><g fill-rule="evenodd"><path d="M8.8,4 C8.8,1.79086089 7.76640339,4.18628304e-07 5.5,0 C3.23359661,-4.1480896e-07 2.2,1.79086089 2.2,4 L3.2,4 C3.2,2.34314567 3.81102123,0.999999681 5.5,1 C7.18897877,1.00000032 7.80000001,2.34314567 7.80000001,4 L8.8,4 Z M1.99201702,4 C0.891856397,4 0,4.88670635 0,5.99810135 L0,10.0018986 C0,11.1054196 0.900176167,12 1.99201702,12 L9.00798298,12 C10.1081436,12 11,11.1132936 11,10.0018986 L11,5.99810135 C11,4.89458045 10.0998238,4 9.00798298,4 L1.99201702,4 Z M1.99754465,5 C1.44661595,5 1,5.45097518 1,5.99077797 L1,10.009222 C1,10.5564136 1.4463114,11 1.99754465,11 L9.00245535,11 C9.55338405,11 10,10.5490248 10,10.009222 L10,5.99077797 C10,5.44358641 9.5536886,5 9.00245535,5 L1.99754465,5 Z M1.99754465,5" style="fill:#3b6faa" transform="translate(9,9)"></g></svg></div></div>
23
+ <div class='card_name_container' ><input id='card_name' type='text' autocomplete='off' autocorrect='off' spellcheck='off' autocapitalize='on' placeholder='Name on card' /></div>
24
+ <div class='card_zip_container' ><input id='card_zip' type='tel' autocomplete='off' autocorrect='off' spellcheck='off' autocapitalize='on' placeholder='Zip code' /></div>
25
+ <div id='message'></div>
26
+ <p class='payment_controls'><input type='submit' class='btn' id='save_payment_btn' value='Save' /></p>
27
+ </form>
28
+ <% end %>
29
+
30
+ <p>
31
+ <input type='button' value='Reset Password' class='btn' onclick="reset_user_password();" />
32
+ <% if @site.use_store && store_config %>
33
+ <input type='button' value='Invoice History' class='btn' onclick="window.location='/my-account/invoices';" />
34
+ <% end %>
35
+ </p>
36
+ </div>
37
+
38
+ <% content_for :caboose_js do %>
39
+ <%= javascript_include_tag 'https://js.stripe.com/v2/' %>
40
+ <%= javascript_include_tag 'caboose/model/all' %>
41
+ <%= javascript_include_tag 'caboose/united_states' %>
42
+ <%= javascript_include_tag 'caboose/jquery.payment' %>
43
+ <script type='text/javascript'>
44
+
45
+ $(document).ready(function() {
46
+ new ModelBinder({
47
+ name: 'User',
48
+ id: <%= @user.id %>,
49
+ update_url: '/my-account',
50
+ authenticity_token: '<%= form_authenticity_token %>',
51
+ attributes: [
52
+ { name: 'first_name' , nice_name: 'First name' , type: 'text', value: <%= raw Caboose.json(@user.first_name) %>, width: 400 },
53
+ { name: 'last_name' , nice_name: 'Last name' , type: 'text', value: <%= raw Caboose.json(@user.last_name) %>, width: 400 },
54
+ { name: 'email' , nice_name: 'Email' , type: 'text', value: <%= raw Caboose.json(@user.email) %>, width: 400 },
55
+ { name: 'phone' , nice_name: 'Phone Number' , type: 'text', value: <%= raw Caboose.json(@user.phone) %>, width: 400 }
56
+ ],
57
+ on_load: function() {
58
+ $('#user_<%= @user.id %>_first_name').css('width', '400px');
59
+ $('#user_<%= @user.id %>_last_name' ).css('width', '400px');
60
+ $('#user_<%= @user.id %>_email' ).css('width', '400px');
61
+ $('#user_<%= @user.id %>_phone' ).css('width', '400px');
62
+ }
63
+ });
64
+
65
+ <% if @site.use_store && store_config %>
66
+ $('#stripe_form').submit(function(e) {
67
+ e.preventDefault();
68
+ update_card();
69
+ return false;
70
+ });
71
+
72
+ $('#stripe_form .card_number_container input').payment('formatCardNumber');
73
+ $('#stripe_form .card_exp_container input').payment('formatCardExpiry');
74
+ $('#stripe_form .card_cvc_container input').payment('formatCardCVC');
75
+ $('#stripe_form').hide();
76
+ <% end %>
77
+ });
78
+
79
+ <% if @site.use_store && store_config %>
80
+ function toggle_stripe_form()
81
+ {
82
+ if ($('#stripe_form').is(':visible'))
83
+ $('#stripe_form').hide();
84
+ else
85
+ $('#stripe_form').show();
86
+ }
87
+
88
+ function update_card()
89
+ {
90
+ var info = {
91
+ number: $('#card_number').val(),
92
+ exp: $('#card_exp').val(),
93
+ cvc: $('#card_cvc').val(),
94
+ name: $('card_name').val(),
95
+ address_zip: $('card_zip').val()
96
+ };
97
+ var exp = info.exp.split('/');
98
+ var m = exp.length > 0 ? exp[0] : '';
99
+ var y = exp.length > 1 ? exp[1] : '';
100
+ var error = false;
101
+ if (!$.payment.validateCardNumber(info.number)) error = "Invalid card number.";
102
+ if (!$.payment.validateCardExpiry(m, y)) error = "Invalid expiration date.";
103
+ if (!$.payment.validateCardCVC(info.cvc)) error = "Invalid CVC.";
104
+ if (error) { $('#message').html("<p class='note error'>" + error + "</p>"); return; }
105
+
106
+ $('#save_payment_btn').attr('disabled', 'true').val('Saving card...');
107
+ Stripe.setPublishableKey(<%= raw Caboose.json(store_config.stripe_publishable_key) %>);
108
+ Stripe.card.createToken(info, function(status, resp) {
109
+ if (resp.error)
110
+ {
111
+ $('#save_payment_btn').attr('disabled', 'false').val('Save Payment Method');
112
+ $('#message').html("<p class='note error'>" + resp.error.message + "</p>");
113
+ }
114
+ else
115
+ {
116
+ $.ajax({
117
+ url: '/checkout/stripe-details',
118
+ type: 'put',
119
+ data: { token: resp.id, card: resp.card },
120
+ success: function(resp2) {
121
+ if (resp2.error) $('#payment_message').html("<p class='note error'>" + resp2.error + "</p>");
122
+ if (resp2.success) window.location.reload(true);
123
+ }
124
+ });
125
+ }
126
+ });
127
+ }
128
+ <% end %>
129
+
130
+ function reset_user_password(pass1, pass2)
131
+ {
132
+ if (!pass1)
133
+ {
134
+ var p = $('<p/>').addClass('note warning')
135
+ .append("Please enter your password:<br /><br />")
136
+ .append($('<input/>').attr('type', 'password').attr('id', 'pass1').css('width', '200px')).append(' ')
137
+ .append($('<input/>').attr('type', 'button').val('Continue').click(function(e) { reset_user_password($('#pass1').val()); }))
138
+ .append("<br /><br />Passwords must be 8 characters long.");
139
+ $('#message2').empty().append(p);
140
+ return;
141
+ }
142
+ if (!pass2)
143
+ {
144
+ var p = $('<p/>').addClass('note warning')
145
+ .append("Please enter it again to confirm:<br /><br />")
146
+ .append($('<input/>').attr('type', 'password').attr('id', 'pass2').css('width', '200px')).append(' ')
147
+ .append($('<input/>').attr('type', 'button').val('Continue').click(function(e) { reset_user_password(pass1, $('#pass2').val()); }))
148
+ .append("<br /><br />Passwords must be 8 characters long.");
149
+ $('#message2').empty().append(p);
150
+ return;
151
+ }
152
+ $('#message2').html("<p class='loading'>Setting password...</p>");
153
+ $.ajax({
154
+ url: '/my-account',
155
+ type: 'put',
156
+ data: {
157
+ password: pass1,
158
+ confirm: pass2
159
+ },
160
+ success: function(resp) {
161
+ if (resp.error) $('#message2').html("<p class='note error'>" + resp.error + "</p>");
162
+ if (resp.success) {
163
+ $('#message2').html("<p class='note success'>The password has been successfully updated.</p>");
164
+ setTimeout(function() { $('#message2').empty(); }, 3000);
165
+ }
166
+ }
167
+ });
168
+ }
169
+
170
+ </script>
171
+ <% end %>
172
+ <%= content_for :caboose_css do %>
173
+ <%= stylesheet_link_tag "caboose/my_account", :media => "all" %>
174
+ <style type='text/css'>
175
+
176
+ .stripe_form { width: 100%; }
177
+ .stripe_form .card_number_container { position: relative; width: 100%; } .stripe_form .card_number_container input { padding-left: 30px; height: 37px; font-size: 15px; width: 100%; border-color: #b9b9b9; border-style: solid; border-width: 1px 1px 0px 1px; }
178
+ .stripe_form .card_exp_container { position: relative; width: 50% !important; float: left; } .stripe_form .card_exp_container input { padding-left: 30px; height: 37px; font-size: 15px; width: 100%; border-color: #b9b9b9; border-style: solid; border-width: 1px 1px 0px 1px; }
179
+ .stripe_form .card_cvc_container { position: relative; width: 50%; float: left; } .stripe_form .card_cvc_container input { padding-left: 30px; height: 37px; font-size: 15px; width: 100%; border-color: #b9b9b9; border-style: solid; border-width: 1px 1px 0px 0px; }
180
+ .stripe_form .card_name_container { position: relative; width: 50%; float: left; } .stripe_form .card_name_container input { padding-left: 10px; height: 37px !important; font-size: 15px; width: 100%; border-color: #b9b9b9; border-style: solid; border-width: 1px 0px 1px 1px; }
181
+ .stripe_form .card_zip_container { position: relative; width: 50%; float: left; margin-bottom: 4px; } .stripe_form .card_zip_container input { padding-left: 10px; height: 37px; font-size: 15px; width: 100%; border-color: #b9b9b9; border-style: solid; border-width: 1px 1px 1px 0px; }
182
+
183
+ .stripe_form .card_number_container .icon { position: absolute; top: 3px; left: 1px; transform-origin: 50% 50% 0; pointer-events: none; }
184
+ .stripe_form .card_exp_container .icon { position: absolute; top: 3px; left: 1px; transform-origin: 50% 50% 0; pointer-events: none; }
185
+ .stripe_form .card_cvc_container .icon { position: absolute; top: 3px; left: 1px; transform-origin: 50% 50% 0; pointer-events: none; }
186
+
187
+ .stripe_form .note { width: 100%; margin-bottom: 10px !important; text-align: center; }
188
+ .stripe_form .payment_controls { clear: left; margin-top: 4px !important; }
189
+
190
+ </style>
191
+ <% end %>
@@ -1,6 +1,8 @@
1
1
 
2
2
  <% content_for :caboose_css do %>
3
3
  <%= stylesheet_link_tag 'jquery-ui' %>
4
+ <%= stylesheet_link_tag 'caboose/admin_block_edit_image' %>
5
+ <%= stylesheet_link_tag "caboose/modal_inline" %>
4
6
  <style type='text/css'>
5
7
  #tiny_header {
6
8
  display: block;
@@ -53,12 +55,25 @@
53
55
 
54
56
  <% content_for :caboose_js do %>
55
57
  <%= javascript_include_tag 'jquery-ui' %>
58
+ <%= javascript_include_tag 'caboose/model/all' %>
59
+ <%= javascript_include_tag 'caboose/jquery-ui.drag-multiple.min.js' %>
60
+ <%= javascript_include_tag "caboose/clipboard" %>
56
61
  <%= javascript_include_tag 'caboose/admin_page_edit_content' %>
62
+ <%= javascript_include_tag "caboose/class" %>
63
+ <%= javascript_include_tag "caboose/modal_controllers/modal_controller" %>
64
+ <%= javascript_include_tag "caboose/modal_controllers/modal_block_controller" %>
65
+ <%= javascript_include_tag "caboose/modal_controllers/modal_media_controller" %>
66
+ <% @page.block.modal_js_block_names.each do |s| %>
67
+ <%= javascript_include_tag "caboose/modal_controllers/modal_#{s}_controller" %>
68
+ <% end %>
57
69
  <script type='text/javascript'>
58
70
 
59
71
  var controller = false;
60
72
  $(document).ready(function() {
61
- controller = new PageContentController(<%= @page.id %>);
73
+ controller = new PageContentController({
74
+ page_id: <%= @page.id %>,
75
+ assets_path: <%= raw Caboose.json(asset_path('loading.gif').gsub('loading.gif', '')) %>
76
+ });
62
77
 
63
78
  $('body').append($('<div/>')
64
79
  .attr('id', 'tiny_header')
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.8.43'
2
+ VERSION = '0.8.44'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.43
4
+ version: 0.8.44
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-18 00:00:00.000000000 Z
11
+ date: 2016-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -524,6 +524,7 @@ files:
524
524
  - app/assets/javascripts/caboose/application.js
525
525
  - app/assets/javascripts/caboose/authorize.net.js
526
526
  - app/assets/javascripts/caboose/block_media_controller.js
527
+ - app/assets/javascripts/caboose/card.js
527
528
  - app/assets/javascripts/caboose/cart.js
528
529
  - app/assets/javascripts/caboose/cart_old.js
529
530
  - app/assets/javascripts/caboose/checkout.js
@@ -545,6 +546,7 @@ files:
545
546
  - app/assets/javascripts/caboose/checkout_payment_stripe.js
546
547
  - app/assets/javascripts/caboose/checkout_shipping.js
547
548
  - app/assets/javascripts/caboose/class.js
549
+ - app/assets/javascripts/caboose/clipboard.js
548
550
  - app/assets/javascripts/caboose/date_format.js
549
551
  - app/assets/javascripts/caboose/google_spreadsheets.js
550
552
  - app/assets/javascripts/caboose/imageZoom.js
@@ -564,6 +566,7 @@ files:
564
566
  - app/assets/javascripts/caboose/modal_controllers/modal_block_controller.js
565
567
  - app/assets/javascripts/caboose/modal_controllers/modal_button_controller.js
566
568
  - app/assets/javascripts/caboose/modal_controllers/modal_controller.js
569
+ - app/assets/javascripts/caboose/modal_controllers/modal_media_controller.js
567
570
  - app/assets/javascripts/caboose/modal_integration.js
568
571
  - app/assets/javascripts/caboose/model.form.page.js
569
572
  - app/assets/javascripts/caboose/model.form.user.js
@@ -684,6 +687,7 @@ files:
684
687
  - app/assets/stylesheets/caboose/admin_crumbtrail.css.scss
685
688
  - app/assets/stylesheets/caboose/admin_main.css
686
689
  - app/assets/stylesheets/caboose/admin_media_index.css.scss
690
+ - app/assets/stylesheets/caboose/admin_new_block.css
687
691
  - app/assets/stylesheets/caboose/admin_page_edit_content.css
688
692
  - app/assets/stylesheets/caboose/admin_post_edit_content.css
689
693
  - app/assets/stylesheets/caboose/admin_products.css
@@ -707,7 +711,7 @@ files:
707
711
  - app/assets/stylesheets/caboose/modal_inline.css
708
712
  - app/assets/stylesheets/caboose/modal_main.css
709
713
  - app/assets/stylesheets/caboose/model_binder.css
710
- - app/assets/stylesheets/caboose/my_account.css
714
+ - app/assets/stylesheets/caboose/my_account.scss
711
715
  - app/assets/stylesheets/caboose/my_account_edit_invoice.css.scss
712
716
  - app/assets/stylesheets/caboose/nestable.css
713
717
  - app/assets/stylesheets/caboose/page_bar_generator.css
@@ -1080,6 +1084,7 @@ files:
1080
1084
  - app/views/caboose/modal/index.html.erb
1081
1085
  - app/views/caboose/modification_value_input_fields/admin_edit.html.erb
1082
1086
  - app/views/caboose/my_account/index.html.erb
1087
+ - app/views/caboose/my_account/index_old.html.erb
1083
1088
  - app/views/caboose/my_account_invoices/authnet_relay.html.erb
1084
1089
  - app/views/caboose/my_account_invoices/authnet_response.html.erb
1085
1090
  - app/views/caboose/my_account_invoices/edit.html.erb
@@ -1,2 +0,0 @@
1
-
2
- #my_account p { margin-bottom: 10px; }