caboose-cms 0.9.196 → 0.9.197

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6c76235f78f0eb25948d31b1cba4c9c3a906627
4
- data.tar.gz: dd7bd594298e84c6cb7a3d4de620446925e83022
3
+ metadata.gz: 314c0ced4535fb77e98f6734f56b75ebc286d765
4
+ data.tar.gz: 2c32df7f98ee703485b10f3aed2aea67759abc1a
5
5
  SHA512:
6
- metadata.gz: da9b374bdf3a3422a9b863bd7e4fb22fd88d0557a30a397d55250be60543d187b676aba43331f7a8c44914949a13f43502e056afc2c39874b4d612c9cfcc9152
7
- data.tar.gz: 73586d3c38f42765bac250e70b601a71cf15f31e3146270cda769260450f0de3c1c2dc54f928577f3eb329c3487adb2936ac0aaeed12097fdb7e3affb4ec26fa
6
+ metadata.gz: 5492cb4605583c1e632afa5de6a16b598615a1e9097539209503a63c9a13018fa1b5b36fcd311dc7890058d0a1a937d0587f1859b69daf0c334d65e4fbc0737d
7
+ data.tar.gz: 69d7658317c0a60327690666903bb9d9572dfd3b883131225882be4f636687ac28d1a8bd303c5f2dfa3903da62de9757422c96f96a0e88fb97390631001031ae
@@ -0,0 +1,184 @@
1
+ //
2
+ // Cart
3
+ //
4
+
5
+ Caboose.Store.Modules.Cart = (function() {
6
+ var self = {
7
+ templates: {
8
+ line_items: JST['caboose/cart/line_items'],
9
+ add_to_cart: JST['caboose/cart/add_to_cart']
10
+ }
11
+ };
12
+
13
+ //
14
+ // Initialize
15
+ //
16
+
17
+ self.initialize = function() {
18
+ self.render_add_to_cart();
19
+ self.render_item_count();
20
+ self.$cart = $('#cart');
21
+ if (!self.$cart.length) return false;
22
+ self.$cart.on('click', '#remove-from-cart', self.remove_handler);
23
+ self.$cart.on('keyup', 'input', self.update_handler);
24
+ self.render();
25
+ };
26
+
27
+ //
28
+ // Set Variant
29
+ //
30
+
31
+ self.set_variant = function(variant) {
32
+ if (self.$add_to_cart) {
33
+ self.$add_to_cart.find('input[name=variant_id]').val(variant ? variant.id : "");
34
+ self.$add_to_cart.trigger('change');
35
+ }
36
+ };
37
+
38
+ //
39
+ // Render
40
+ //
41
+
42
+ self.render = function() {
43
+ $.get('/cart/items', function(response) {
44
+ self.$cart.empty().html(self.templates.line_items({ invoice: response.invoice }));
45
+ self.$cart.removeClass('loading');
46
+ });
47
+ };
48
+
49
+ self.render_add_to_cart = function() {
50
+ self.$add_to_cart = $('#add-to-cart');
51
+ if (!self.$add_to_cart.length) return false;
52
+ self.$add_to_cart.empty().html(self.templates.add_to_cart());
53
+ //$('input[name=quantity]', self.$add_to_cart).on('keyup', self.qty_keyup_handler);
54
+ //$('input[name=quantity,type=hidden,value=1]', self.$add_to_cart);
55
+ $('form', self.$add_to_cart).on('submit', self.add_handler);
56
+ };
57
+
58
+ self.render_item_count = function(item_count) {
59
+ var $link = $('#cart-link, .cart-link');
60
+ //if (!$link.length) return false;
61
+
62
+ function set_count(count) {
63
+ if ($('#cart_item_count').length > 0)
64
+ $('#cart_item_count').html(count);
65
+ else if ($link.length > 0)
66
+ {
67
+ if ($link.children('i') && count < 1) { $link.children('i').remove(); }
68
+ else if ($link.children('i').length) { $link.children('i').empty().text(count); }
69
+ else { $link.append($('<i/>').text(count)); }
70
+ }
71
+ };
72
+
73
+ if (item_count) {
74
+ set_count(item_count);
75
+ } else {
76
+ $.get('/cart/item-count', function(response) {
77
+ set_count(response.item_count);
78
+ });
79
+ }
80
+ };
81
+
82
+ //
83
+ // Event Handlers
84
+ //
85
+
86
+ self.qty_keyup_handler = function(event) {
87
+ var $quantity = $(event.target);
88
+ $quantity.val($quantity.val().match(/\d*\.?\d+/));
89
+ };
90
+
91
+ self.add_handler = function(event) {
92
+ event.preventDefault();
93
+ var $form = $(event.target);
94
+
95
+ if ($form.find('input[name=variant_id]').val().trim() == "") {
96
+ alert('Must select all options');
97
+ } else {
98
+ $.ajax({
99
+ type: $form.attr('method'),
100
+ url: $form.attr('action'),
101
+ data: $form.serialize(),
102
+ success: function(response) {
103
+ if (response.success) {
104
+ self.render_item_count(response.item_count);
105
+ if (self.$add_to_cart.length) self.$add_to_cart.trigger('added');
106
+
107
+ if (!self.$add_to_cart.find('.message').length) {
108
+ self.$add_to_cart
109
+ .append($('<div/>').hide().addClass('message')
110
+ .append($('<p/>').text(response.quantity_message ? response.quantity_message : 'Successfully added to cart'))
111
+ .append($('<p/>')
112
+ .append($('<a/>').attr('href', '/cart').html('View cart')).append(' | ')
113
+ .append($('<a/>').attr('href', '/checkout').html('Continue to checkout'))
114
+ )
115
+ );
116
+ self.$add_to_cart.find('.message').fadeIn();
117
+ Caboose.Store.Modules.Product.$product.trigger('added-to-cart');
118
+
119
+ //setTimeout(function() {
120
+ // self.$add_to_cart.find('.message').fadeOut(function() { $(this).remove() });
121
+ //}, 5000);
122
+ }
123
+ } else {
124
+ if (!self.$add_to_cart.find('.message').length) {
125
+ self.$add_to_cart
126
+ .append($('<div/>').hide().addClass('message')
127
+ .append($('<p/>').addClass('note error').html(response.error ? response.error : (response.errors ? response.errors[0] : "Error adding to cart")))
128
+ // .append($('<p/>').append($('<a/>').attr('href', '/cart').html('View cart')))
129
+ );
130
+ self.$add_to_cart.find('.message').fadeIn();
131
+ }
132
+ //alert(response.errors[0]);
133
+ }
134
+ }
135
+ });
136
+ }
137
+ };
138
+
139
+ self.update_handler = function(event) {
140
+ var $quantity = $(event.target)
141
+ var $line_item = $quantity.parents('li').first();
142
+
143
+ $quantity.val($quantity.val().match(/\d*\.?\d+/));
144
+ if ($quantity.val() == "") return false;
145
+
146
+ delay(function() {
147
+ $.ajax({
148
+ type: 'put',
149
+ url: '/cart/items/' + $line_item.data('id'),
150
+ data: { quantity: $quantity.val() },
151
+ success: function(response) {
152
+ if (response.success) {
153
+ $line_item.find('.price').empty().text('$' + response.line_item.price);
154
+ if (self.$cart.find('.subtotal').length) self.$cart.find('.subtotal').empty().text('$' + response.invoice_subtotal);
155
+ } else {
156
+ alert(response.errors[0]);
157
+ }
158
+ }
159
+ });
160
+ }, 1000);
161
+ };
162
+
163
+ self.remove_handler = function(event) {
164
+ var $line_item = $(event.target).parents('li').first();
165
+
166
+ $.ajax({
167
+ type: 'delete',
168
+ url: '/cart/items/' + $line_item.data('id'),
169
+ success: function(response) {
170
+ if (response.success) {
171
+ self.render();
172
+ self.render_item_count(response.item_count);
173
+ }
174
+ }
175
+ });
176
+ };
177
+
178
+ self.redirect_handler = function(event) {
179
+ event.preventDefault();
180
+ window.location = $(event.target).attr('href');
181
+ };
182
+
183
+ return self;
184
+ }).call(Caboose.Store);
@@ -23,6 +23,7 @@
23
23
  margin-bottom: 20px;
24
24
  text-align: left;
25
25
  line-height: 20px;
26
+ color: #282828;
26
27
  }
27
28
  & > form {
28
29
  text-align: right;
@@ -12,6 +12,7 @@ class Caboose::FormSubmission < ActiveRecord::Base
12
12
  :bcc_to,
13
13
  :category,
14
14
  :date_submitted,
15
+ :ip_address,
15
16
  :is_spam,
16
17
  :is_deleted,
17
18
  :field1_name,
@@ -344,6 +344,7 @@ class Caboose::Schema < Caboose::Utilities::Schema
344
344
  [ :form_name, :string ],
345
345
  [ :sent_to, :string ],
346
346
  [ :date_submitted, :datetime ],
347
+ [ :ip_address, :string ],
347
348
  [ :bcc_to, :string ],
348
349
  [ :category, :string ],
349
350
  [ :is_spam, :boolean , { :default => false }],
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.9.196'
2
+ VERSION = '0.9.197'
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.9.196
4
+ version: 0.9.197
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-10 00:00:00.000000000 Z
11
+ date: 2018-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -537,6 +537,7 @@ files:
537
537
  - app/assets/javascripts/caboose/block_modal_controllers/richtext_modal_controller.js
538
538
  - app/assets/javascripts/caboose/card.js
539
539
  - app/assets/javascripts/caboose/cart.js
540
+ - app/assets/javascripts/caboose/cart_old.js
540
541
  - app/assets/javascripts/caboose/checkout.js
541
542
  - app/assets/javascripts/caboose/checkout/authnet_payment_method_controller.js
542
543
  - app/assets/javascripts/caboose/checkout/billing_address_controller.js