caboose-store 0.0.10 → 0.0.11

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 (143) hide show
  1. checksums.yaml +8 -8
  2. data/app/assets/javascripts/caboose/main.js +8 -0
  3. data/app/assets/javascripts/caboose_store/admin.js +0 -19
  4. data/app/assets/javascripts/caboose_store/admin_products.js +3 -4
  5. data/app/assets/javascripts/caboose_store/application.js +6 -5
  6. data/app/assets/javascripts/caboose_store/cart.js.bak +258 -0
  7. data/app/assets/javascripts/caboose_store/checkout.js +151 -0
  8. data/app/assets/javascripts/caboose_store/config.js +83 -0
  9. data/app/assets/javascripts/caboose_store/jquery-ui-multisortable.js +254 -0
  10. data/app/assets/javascripts/caboose_store/jquery-ui.js +3572 -0
  11. data/app/assets/javascripts/caboose_store/main.js +20 -0
  12. data/app/assets/javascripts/caboose_store/modules/cart.js +167 -0
  13. data/app/assets/javascripts/caboose_store/modules/checkout.js +313 -0
  14. data/app/assets/javascripts/caboose_store/modules/product.js +282 -0
  15. data/app/assets/stylesheets/caboose_store/admin.css +3 -3
  16. data/app/assets/stylesheets/caboose_store/application.css +2 -2
  17. data/app/assets/stylesheets/caboose_store/modal.css +1 -0
  18. data/app/assets/templates/caboose_store/cart/add_to_cart.jst.ejs +7 -0
  19. data/app/assets/templates/caboose_store/cart/line_items.jst.ejs +41 -0
  20. data/app/assets/templates/caboose_store/checkout/address.jst.ejs +53 -0
  21. data/app/assets/templates/caboose_store/checkout/forms/guest.jst.ejs +8 -0
  22. data/app/assets/templates/caboose_store/checkout/forms/register.jst.ejs +11 -0
  23. data/app/assets/templates/caboose_store/checkout/forms/signin.jst.ejs +7 -0
  24. data/app/assets/templates/caboose_store/checkout/line_items.jst.ejs +32 -0
  25. data/app/assets/templates/caboose_store/checkout/login.jst.ejs +21 -0
  26. data/app/assets/templates/caboose_store/checkout/payment.jst.ejs +5 -0
  27. data/app/assets/templates/caboose_store/checkout/shipping.jst.ejs +18 -0
  28. data/app/assets/templates/caboose_store/product/images.jst.ejs +8 -0
  29. data/app/assets/templates/caboose_store/product/options.jst.ejs +19 -0
  30. data/app/controllers/caboose_store/application_controller.rb +1 -11
  31. data/app/controllers/caboose_store/cart_controller.rb +36 -44
  32. data/app/controllers/caboose_store/cart_controller.rb.bak +169 -0
  33. data/app/controllers/caboose_store/categories_controller.rb +72 -92
  34. data/app/controllers/caboose_store/checkout_controller.rb +231 -151
  35. data/app/controllers/caboose_store/orders_controller.rb +235 -95
  36. data/app/controllers/caboose_store/product_images_controller.rb +1 -1
  37. data/app/controllers/caboose_store/products_controller.rb +275 -84
  38. data/app/controllers/caboose_store/reviews_controller.rb +1 -1
  39. data/app/controllers/caboose_store/variants_controller.rb +86 -20
  40. data/app/controllers/caboose_store/vendors_controller.rb +73 -0
  41. data/app/helpers/caboose_store/application_helper.rb +3 -41
  42. data/app/helpers/caboose_store/cart_helper.rb +0 -24
  43. data/app/helpers/caboose_store/categories_helper.rb +69 -25
  44. data/app/helpers/caboose_store/checkout_helper.rb +31 -0
  45. data/app/helpers/caboose_store/products_helper.rb +4 -80
  46. data/app/mailers/caboose_store/orders_mailer.rb +6 -13
  47. data/app/models/caboose_store/address.rb +5 -9
  48. data/app/models/caboose_store/caboose_store_plugin.rb +18 -7
  49. data/app/models/caboose_store/category.rb +66 -41
  50. data/app/models/caboose_store/category_membership.rb +1 -2
  51. data/app/models/caboose_store/customization_membership.rb +10 -0
  52. data/app/models/caboose_store/discount.rb +4 -2
  53. data/app/models/caboose_store/line_item.rb +77 -0
  54. data/app/models/caboose_store/message.rb +3 -5
  55. data/app/models/caboose_store/order.rb +153 -63
  56. data/app/models/caboose_store/order_discount.rb +1 -2
  57. data/app/models/caboose_store/order_pdf.rb +2 -4
  58. data/app/models/caboose_store/payment_processors/authorizenet.rb +20 -2
  59. data/app/models/caboose_store/payment_processors/base.rb +0 -2
  60. data/app/models/caboose_store/payment_processors/payscape.rb +91 -1
  61. data/app/models/caboose_store/product.rb +86 -30
  62. data/app/models/caboose_store/product_image.rb +50 -15
  63. data/app/models/caboose_store/product_image_variant.rb +3 -3
  64. data/app/models/caboose_store/review.rb +8 -8
  65. data/app/models/caboose_store/schema.rb +174 -119
  66. data/app/models/caboose_store/search_filter.rb +110 -115
  67. data/app/models/caboose_store/shipping_calculator.rb +51 -49
  68. data/app/models/caboose_store/tax_calculator.rb +2 -6
  69. data/app/models/caboose_store/tax_line.rb +1 -4
  70. data/app/models/caboose_store/variant.rb +77 -21
  71. data/app/models/caboose_store/vendor.rb +17 -2
  72. data/app/views/caboose_store/cart/index.html.erb +3 -18
  73. data/app/views/caboose_store/categories/admin_edit.html.erb +64 -67
  74. data/app/views/caboose_store/categories/admin_index.html.erb +7 -9
  75. data/app/views/caboose_store/categories/admin_new.html.erb +56 -39
  76. data/app/views/caboose_store/checkout/_address_form.html.erb +111 -0
  77. data/app/views/caboose_store/checkout/_billing_form.html.erb +47 -0
  78. data/app/views/caboose_store/checkout/_cart.html.erb +52 -0
  79. data/app/views/caboose_store/checkout/_order_discount.html.erb +40 -0
  80. data/app/views/caboose_store/checkout/_shipping_address.html.erb +10 -0
  81. data/app/views/caboose_store/checkout/_shipping_method.html.erb +2 -0
  82. data/app/views/caboose_store/checkout/_shipping_method_form.html.erb +21 -0
  83. data/app/views/caboose_store/checkout/billing.html.erb +4 -161
  84. data/app/views/caboose_store/checkout/discount.html.erb +5 -160
  85. data/app/views/caboose_store/checkout/empty.html.erb +2 -0
  86. data/app/views/caboose_store/checkout/error.html.erb +2 -0
  87. data/app/views/caboose_store/checkout/index.html.erb +30 -100
  88. data/app/views/caboose_store/checkout/login.html.erb +2 -0
  89. data/app/views/caboose_store/checkout/payment.html.erb +79 -0
  90. data/app/views/caboose_store/checkout/relay.html.erb +12 -0
  91. data/app/views/caboose_store/checkout/relay_postMessage.html.erb +19 -0
  92. data/app/views/caboose_store/checkout/shipping.html.erb +8 -83
  93. data/app/views/caboose_store/checkout/step_one.html.erb +15 -0
  94. data/app/views/caboose_store/checkout/step_two.html.erb +15 -0
  95. data/app/views/caboose_store/checkout/thanks.html.erb +5 -0
  96. data/app/views/caboose_store/layouts/_footer.html.erb +1 -1
  97. data/app/views/caboose_store/orders/admin_edit.html.erb +101 -7
  98. data/app/views/caboose_store/orders/admin_index.html.erb +8 -8
  99. data/app/views/caboose_store/orders_mailer/customer_new_order.html.erb +0 -46
  100. data/app/views/caboose_store/orders_mailer/customer_status_updated.html.erb +0 -48
  101. data/app/views/caboose_store/orders_mailer/fulfillment_new_order.html.erb +0 -42
  102. data/app/views/caboose_store/orders_mailer/shipping_order_ready.html.erb +0 -45
  103. data/app/views/caboose_store/products/_admin_header.html.erb +7 -6
  104. data/app/views/caboose_store/products/_sort_options.html.erb +19 -0
  105. data/app/views/caboose_store/products/admin_add_upcs.html.erb +58 -0
  106. data/app/views/caboose_store/products/admin_edit_categories.html.erb +1 -1
  107. data/app/views/caboose_store/products/admin_edit_description.html.erb +2 -5
  108. data/app/views/caboose_store/products/admin_edit_general.html.erb +58 -1
  109. data/app/views/caboose_store/products/admin_edit_images.html.erb +3 -1
  110. data/app/views/caboose_store/products/admin_edit_variants.html.erb +13 -2
  111. data/app/views/caboose_store/products/admin_edit_variants_single.html.erb +14 -14
  112. data/app/views/caboose_store/products/admin_group_variants.html.erb +433 -0
  113. data/app/views/caboose_store/products/admin_index.html.erb +87 -39
  114. data/app/views/caboose_store/products/admin_sort.html copy.erb +155 -0
  115. data/app/views/caboose_store/products/admin_sort.html.erb +254 -0
  116. data/app/views/caboose_store/products/details.html.erb +1 -2
  117. data/app/views/caboose_store/variants/admin_edit.html.erb +18 -16
  118. data/app/views/caboose_store/variants/admin_group.html.erb +184 -0
  119. data/app/views/caboose_store/vendors/admin_edit.html.erb +24 -0
  120. data/app/views/caboose_store/vendors/admin_index.html.erb +30 -0
  121. data/app/views/caboose_store/vendors/admin_new.html.erb +34 -0
  122. data/config/routes.rb +65 -27
  123. data/lib/caboose-store/caboose_store_helper.rb +29 -30
  124. data/lib/caboose-store/engine.rb +73 -28
  125. data/lib/caboose-store/version.rb +1 -1
  126. data/lib/caboose-store.rb +16 -7
  127. data/lib/tasks/caboose-store.rake +0 -2
  128. metadata +54 -17
  129. data/app/assets/javascripts/caboose_store/modal.js +0 -52
  130. data/app/assets/javascripts/caboose_store/modal_integration.js +0 -25
  131. data/app/assets/javascripts/caboose_store/model.form.page.js +0 -30
  132. data/app/assets/javascripts/caboose_store/model.form.user.js +0 -36
  133. data/app/assets/javascripts/caboose_store/payment_processors/authorizenet.js +0 -21
  134. data/app/assets/javascripts/caboose_store/payment_processors/base.js +0 -21
  135. data/app/assets/javascripts/caboose_store/payment_processors/payscape.js +0 -21
  136. data/app/assets/javascripts/caboose_store/shortcut.js +0 -11
  137. data/app/assets/javascripts/caboose_store/station.js +0 -60
  138. data/app/models/caboose_store/order_line_item.rb +0 -13
  139. data/app/models/caboose_store/states.rb +0 -60
  140. data/app/views/caboose_store/application/_category_thumb.html.erb +0 -6
  141. data/app/views/caboose_store/application/_product_thumb.html.erb +0 -13
  142. data/app/views/caboose_store/checkout/quantity_box.html.erb +0 -39
  143. data/app/views/caboose_store/checkout/thank_you.html.erb +0 -36
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzE4NGU4ODA3MTA0N2ZhMDc1NTc0MmQzOGQ5ZDg5MjQ2MTliYTAzMw==
4
+ NWM5NzBlOTk5ZTczMWM5MDhhYzhkYWYzZTNhYThkYWQ0ZjE3NDc3NA==
5
5
  data.tar.gz: !binary |-
6
- NDc5ZDM3NmQzNTQxZDQzNGMwODY2NDBlNzczNDgyMTVmZWU5NTY3Mw==
6
+ MmJkZDQyYWYwNmIzZjZmZjdlZTBjZWYyY2VmNDU0OGY0MTA0ZDU0Ng==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- Mzc5NjgyMTkwOWEwYTA0NGE2ZDdiNjBjNWYwMjcwZmNlYjJlNDNjN2U3MDkx
10
- MmU4NjFiZGI2MGYxM2YxMDZiMjk4MmJiZTZiOTUxYTIxNzJlMmU3ZDFiYjQz
11
- ODAwY2JhZDYzZTJmMGY0M2FkOGQ2YjFmMGIwMmUwMjhkZjdkYjk=
9
+ M2IzNzQyZWNlNDZlYWNmODgwNjk5ODllZjY2MTNlNjhhYTIwNmE1NDViNGZi
10
+ MmNlODI5MDNmYTgwOWI5MzQ5NjE2YTE0NWMwNzYxNTE2NDU2NTdhOWE1ZGUx
11
+ ZTM0YTliMGI1ZDI0NGQxNjIyZDQ1NjU5NDg4MjIxY2RkMDg2Njg=
12
12
  data.tar.gz: !binary |-
13
- MTljYWMyNGUyZGMzYWQxYWE4MjRhMWUyY2EwZWU5ZDcxYjczMDQ0YzlhM2Fk
14
- OWNhOTc2NWEwNDkxYjRkODk4Y2Y5OTY1NmNkZjkyNzg0MTJjOWIxN2RiODNm
15
- MjI0ZWEwN2E4NTEwZTMyMmMyODU4MzUxZjg1ZTVhYjMxMGJkYjM=
13
+ NTRkZGEzYTU5ZTg1NjJjZTNkNTNlMjc2MGNmMmNkZjBhZmZjNzg0Y2E0Zjdj
14
+ NGE0N2M5ZDI5MmNhOTg1NWQ0YzdiZjNjYzQxNzJmZGY4YTE5YTQ4MjZmMTZl
15
+ NTMwZTdkMmQ0NmQxMDExZjdiOGViZGM1M2EyZGMzODEyMTgzNDQ=
@@ -0,0 +1,8 @@
1
+ //
2
+ // Main
3
+ //
4
+
5
+ var Caboose = (function() {
6
+ return {};
7
+ })();
8
+
@@ -1,19 +0,0 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // the compiled file.
9
- //
10
- // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
- // GO AFTER THE REQUIRES BELOW.
12
- //
13
- //= require jquery
14
- //= require jquery_ujs
15
- //= require colorbox-rails
16
- //= require caboose/modal_integration
17
- /* require jquery.ui.all */
18
- /* require tinymce-jquery */
19
-
@@ -35,14 +35,13 @@ function cancel_delete_product(product_id)
35
35
  function add_variant(product_id)
36
36
  {
37
37
  modal.autosize("<p class='loading'>Adding variant...</p>");
38
+
38
39
  $.ajax({
39
40
  url: '/admin/products/' + product_id + '/variants',
40
41
  type: 'post',
41
42
  success: function(resp) {
42
- if (resp.error)
43
- modal.autosize("<p class='note error'>" + resp.error + "</p>");
44
- if (resp.refresh)
45
- window.location.reload(true);
43
+ if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
44
+ if (resp.refresh) window.location.reload(true);
46
45
  }
47
46
  })
48
47
  }
@@ -10,8 +10,9 @@
10
10
  // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
11
  // GO AFTER THE REQUIRES BELOW.
12
12
  //
13
- //= require jquery
14
- //= require jquery_ujs
15
- //= require colorbox-rails
16
- //= require caboose/modal_integration
17
- //= require application
13
+ //= require_tree ../../templates
14
+ //= require underscore
15
+ //= require caboose_store/config
16
+ //= require caboose_store/main
17
+ //= require_tree ./modules
18
+
@@ -0,0 +1,258 @@
1
+ //
2
+ // Cart
3
+ //
4
+ // :: Initialize
5
+ // :: Open
6
+ // :: Bind Events
7
+ // :: Close
8
+ // :: Add
9
+ // :: Update
10
+ // :: Remove
11
+
12
+ var CabooseCart = function() {
13
+ var self = this;
14
+
15
+ //
16
+ // Initialize
17
+ //
18
+
19
+ self.initialize = function() {
20
+ $.ajax({
21
+ url: '/cart/items',
22
+ type: 'get',
23
+ success: function(response) {
24
+ self.items = response;
25
+
26
+ // If this is the mobile cart page
27
+ if (window.location.pathname == '/cart/mobile') self.bindEvents();
28
+
29
+ // Emit ready event
30
+ Caboose.events.trigger('cart.ready');
31
+
32
+ // Open cart
33
+ $('[caboose-cart=open]').on('click', function(event) {
34
+ event.preventDefault();
35
+
36
+ if ($.browser.mobile) {
37
+ Caboose.redirect('/cart/mobile')
38
+ } else {
39
+ self.open();
40
+ }
41
+ });
42
+
43
+ // Add to cart from button
44
+ $('[caboose-cart=add]').not('form').on('click', function(event) {
45
+ event.preventDefault();
46
+ self.add( $(event.target).data('id') );
47
+ if (!$.browser.mobile) self.open();
48
+ });
49
+
50
+ // Add to cart from form
51
+ $('form[caboose-cart=add]').on('submit', function(event) {
52
+ event.preventDefault();
53
+
54
+ // Initially set the indecator variable to false
55
+ var stop_submission = false;
56
+
57
+ $('.custom-input').each(function(index, el) {
58
+ $el = $(el)
59
+
60
+ // If the value is empty or equal to the placeholder; val() will return the placeholder value if it's empty
61
+ if ( $el.val() == "" || $el.val() == $el.attr('placeholder') ) {
62
+
63
+ // Notify the user that an input is required; assuming all custom inputs are required
64
+ alert('You must enter a value for ' + $el.attr('placeholder'));
65
+
66
+ // Indicate that errors were found
67
+ stop_submission = true;
68
+
69
+ // Exit the each loop
70
+ return false;
71
+ }
72
+ });
73
+
74
+ // Exit function if errors were found
75
+ if (stop_submission) return false;
76
+
77
+ // Collect the form data
78
+ var data = $(event.delegateTarget).serializeArray()
79
+ , json = _.object( _.pluck(data, 'name'), _.pluck(data, 'value') );
80
+
81
+ // Add to cart and open up if this is a desktop browser
82
+ self.add(json);
83
+ if (!$.browser.mobile) self.open();
84
+ });
85
+ }
86
+ });
87
+ };
88
+
89
+ //
90
+ // Open
91
+ //
92
+
93
+ self.open = function(mobile) {
94
+ $.colorbox({
95
+ href: '/modal',
96
+ iframe: true,
97
+ innerWidth: 600,
98
+ innerHeight: 400,
99
+
100
+ onComplete: function() {
101
+ $('#cboxLoadedContent iframe').load(self.bindEvents);
102
+ }
103
+ });
104
+ };
105
+
106
+ //
107
+ // Bind Events
108
+ //
109
+
110
+ self.bindEvents = function() {
111
+ var $container = $('#cboxLoadedContent iframe').contents().find('#modal_content')
112
+ , content = JST['caboose_store/cart/index']({items: self.items});
113
+
114
+ // If container exists inject content into modal
115
+ // otherwise define it as the body for event binding
116
+ if ($container.length) {
117
+ $container.html(content);
118
+ } else {
119
+ $container = $('body')
120
+ }
121
+
122
+ // Close cart
123
+ $container.find('[caboose-cart=close]').on('click', function(event) {
124
+ event.preventDefault();
125
+ self.close();
126
+ });
127
+
128
+ // Redirect user
129
+ $container.find('[caboose-cart=redirect]').on('click', function(event) {
130
+ event.preventDefault();
131
+ window.location.href = event.target.href;
132
+ });
133
+
134
+ // Update item from single input
135
+ $container.find('[caboose-cart=update]').not('form').on('change', function(event) {
136
+ var $target = $(event.target)
137
+ , id = $target.data('id')
138
+ , attribute = $target.attr('name')
139
+ , value = $target.val()
140
+ , attributes = {};
141
+
142
+ attributes[attribute] = value;
143
+ self.update(id, attributes);
144
+ });
145
+
146
+ // Update item from form
147
+ $container.find('form[caboose-cart=update]').on('submit', function(event) {
148
+ event.preventDefault();
149
+
150
+ var $target = $(event.delegateTarget)
151
+ , id = $target.data('id')
152
+ , form = $target.serializeArray()
153
+ , attributes = _.object( _.pluck(form, 'name'), _.pluck(form, 'value') );
154
+
155
+ self.update(id, attributes);
156
+ });
157
+
158
+ // Remove from cart
159
+ $container.find('[caboose-cart=remove]').on('click', function(event) {
160
+ event.preventDefault();
161
+ var id = $(event.target).data('id');
162
+
163
+ self.remove(id, function() {
164
+ if (self.items.length == 0) {
165
+ self.close();
166
+ } else {
167
+ $container.find('[caboose-cart=remove][data-id=' + id + ']').parents('tr').remove();
168
+ }
169
+ });
170
+ });
171
+ };
172
+
173
+ //
174
+ // Close
175
+ //
176
+
177
+ self.close = function() {
178
+ $.colorbox.close();
179
+ };
180
+
181
+ //
182
+ // Add
183
+ //
184
+
185
+ self.add = function(something, callback) {
186
+ var id = _.isNumber(something) ? something : ''
187
+ , data = _.isObject(something) ? something : {};
188
+
189
+ $.ajax({
190
+ url: '/cart/item/' + id,
191
+ type: 'post',
192
+ data: data,
193
+ success: function(response) {
194
+ if (response.error) {
195
+ alert(response.error);
196
+ } else {
197
+
198
+ // If this is mobile then redirect to mobile cart page
199
+ if ($.browser.mobile) Caboose.redirect('/cart/mobile');
200
+
201
+ // If item exists increment quantity, otherwise add to cart
202
+ if ( _.contains(_.pluck(self.items, 'id'), response.id) ) {
203
+ _.find(self.items, function(item) { return item.id == response.id }).quantity = response.quantity;
204
+ } else {
205
+ self.items.push(response);
206
+ }
207
+ }
208
+
209
+ if (callback) callback(response);
210
+ }
211
+ });
212
+ };
213
+
214
+ //
215
+ // Update
216
+ //
217
+
218
+ self.update = function(id, attributes, callback) {
219
+ $.ajax({
220
+ url: '/cart/item/' + id,
221
+ type: 'put',
222
+ data: {attributes: attributes},
223
+ success: function(response) {
224
+
225
+ // If successful update line item quantity; otherwise, notify the user with the received message
226
+ if (response.success) {
227
+ _.find(self.items, function(item) { return item.id == response.item.id }).quantity = response.item.quantity;
228
+ } else if (response.error) {
229
+ alert(response.message);
230
+ }
231
+
232
+ if (callback) callback(response);
233
+ }
234
+ });
235
+ };
236
+
237
+ //
238
+ // Remove
239
+ //
240
+
241
+ self.remove = function(id, callback) {
242
+ $.ajax({
243
+ url: '/cart/item/' + id,
244
+ type: 'delete',
245
+ success: function(response) {
246
+ self.items = _.reject(self.items, function(item) { return item.id == response.id });
247
+ if ($.browser.mobile) Caboose.reload();
248
+ if (callback) callback(response);
249
+ }
250
+ });
251
+ };
252
+
253
+ // Init and return
254
+ $(document).ready(self.initialize);
255
+ return self;
256
+ };
257
+
258
+ Caboose.Store.Cart = new CabooseCart();
@@ -0,0 +1,151 @@
1
+ //
2
+ // Checkout
3
+ //
4
+ // :: Initialize
5
+ // :: Index
6
+ // :: Shipping
7
+ // :: Payment
8
+
9
+ //var CabooseCheckout = function() {
10
+ // var self = this;
11
+ //
12
+ // //
13
+ // // Initialize
14
+ // //
15
+ //
16
+ // self.initialize = function() {
17
+ //
18
+ // // Ensure that a user is logged in
19
+ // //if (!Caboose.loggedIn && window.location.pathname.substring(0, 9) == '/checkout') Caboose.login();
20
+ // console.log('foo');
21
+ //
22
+ // // Route to correct method
23
+ // switch (window.location.pathname) {
24
+ // case '/checkout': self.index(); break;
25
+ // case '/checkout/shipping': self.shipping(); break;
26
+ // case '/checkout/billing': self.billing(); break;
27
+ // }
28
+ // };
29
+ //
30
+ // //
31
+ // // Index
32
+ // //
33
+ //
34
+ // self.index = function() {
35
+ //
36
+ // // Ensure use as billing is automatically checked
37
+ // $('#use-as-billing').prop('checked', true);
38
+ //
39
+ // // Show/hide the billing form
40
+ // $('#use-as-billing').on('change', function(event) {
41
+ // if ($('#use-as-billing')[0].checked) {
42
+ // $('#billing').hide()
43
+ // } else {
44
+ // $('#billing').show()
45
+ // }
46
+ // });
47
+ //
48
+ // // Update address info
49
+ // $('form#address').on('submit', function(event) {
50
+ // event.preventDefault();
51
+ //
52
+ // $.ajax({
53
+ // url: '/checkout/address',
54
+ // type: 'put',
55
+ // data: $(event.delegateTarget).serialize(),
56
+ // success: function(response) {
57
+ // if (response.error) $('#message').html("<p class='note error'>" + response.error + "</p>");
58
+ // if (response.redirect) window.location = response.redirect;
59
+ // }
60
+ // });
61
+ // });
62
+ // };
63
+ //
64
+ // //
65
+ // // Shipping
66
+ // //
67
+ //
68
+ // self.shipping = function() {
69
+ // $('form#shipping-rates').one('submit', function(event) {
70
+ // event.preventDefault();
71
+ //
72
+ // var $form = $(event.delegateTarget)
73
+ // , code = $('input[name=shipping_method_code]:checked', $form).val()
74
+ // , name = $('input#shipping-method-' + code + '-name', $form).val()
75
+ // , price = $('input#shipping-method-' + code + '-price', $form).val();
76
+ //
77
+ // $.ajax({
78
+ // url: '/checkout/shipping-method',
79
+ // type: 'put',
80
+ // data: {
81
+ // shipping_method: {
82
+ // code: code,
83
+ // name: name,
84
+ // price: price
85
+ // }
86
+ // },
87
+ // success: function(response) {
88
+ // if (response.error) $('#message').html("<p class='note error'>" + response.error + "</p>");
89
+ // if (response.redirect) window.location = response.redirect;
90
+ // }
91
+ // });
92
+ // });
93
+ // };
94
+ //
95
+ // //
96
+ // // Billing
97
+ // //
98
+ //
99
+ // self.billing = function() {
100
+ // window.relay = function(authorized) {
101
+ // if (authorized) {
102
+ // window.location.replace('/checkout/thanks');
103
+ // } else {
104
+ // window.location.replace('/checkout/error');
105
+ // }
106
+ // };
107
+ //
108
+ // $('#billing-expiration-month, #billing-expiration-year').on('change', function(event) {
109
+ // $('input[name=billing-cc-exp]').val($('#billing-expiration-month').val() + $('#billing-expiration-year').val());
110
+ // });
111
+ //
112
+ // $('#billing-form').one('submit', function(e) {
113
+ // e.preventDefault();
114
+ //
115
+ // // TODO this is a temporary fix.. for some reason the one submit event is getting registered multiple times
116
+ // if ($('#billing-confirmation').length) return false;
117
+ //
118
+ // $('input[name=billing-cc-exp]').val($('#billing-expiration-month').val() + $('#billing-expiration-year').val());
119
+ //
120
+ // var $form = $(e.delegateTarget)
121
+ // , cc_num = $form.find('input[name=billing-cc-number]').val()
122
+ // , cc_exp = $form.find('input[name=billing-cc-exp]').val()
123
+ // , total = $('input#billing-amount').val()
124
+ // , $confirm = $(document.createElement('div'));
125
+ //
126
+ // $confirm.attr('id', 'billing-confirmation');
127
+ // $confirm.append( $('</p>').attr('style', 'margin-bottom: 0').html('<strong>Credit Card Number</strong>: xxxx-xxxx-xxxx-' + cc_num.replace(/\-\ /g, '').substr(-4)) );
128
+ // $confirm.append( $('</p>').attr('style', 'margin-bottom: 0').html('<strong>Expiration Date</strong>: ' + cc_exp.substr(0, 2) + '/' + cc_exp.substr(2, 2)) );
129
+ // $confirm.append( $('</p>').html('<strong>Total</strong>: $' + total) );
130
+ // $confirm.append( $('</p>').attr('style', 'margin: 24px 0').html('<a href="/checkout/billing">Edit billing info</a>') );
131
+ // $confirm.append( $('</p>').html('<input id="submit-billing" type="button" value="Continue >" />') );
132
+ //
133
+ // $form.after($confirm);
134
+ // $form.hide();
135
+ //
136
+ // $confirm.find('#submit-billing').on('click', function(e) {
137
+ // e.preventDefault();
138
+ // $form.submit();
139
+ // $confirm.after( $('</p>').addClass('loading').text('Authorizing transaction..') );
140
+ // $confirm.hide();
141
+ // });
142
+ // });
143
+ // };
144
+ //
145
+ // // Init and return
146
+ // $(document).ready(self.initialize);
147
+ // return self;
148
+ //};
149
+ //
150
+ //CabooseStore.Checkout = new CabooseCheckout();
151
+ //
@@ -0,0 +1,83 @@
1
+ //
2
+ // Config
3
+ //
4
+
5
+ //
6
+ // Delay
7
+ //
8
+
9
+ var delay = (function() {
10
+ var timer = 0;
11
+
12
+ return function(callback, ms) {
13
+ clearTimeout(timer);
14
+ timer = setTimeout(callback, ms);
15
+ };
16
+ })();
17
+
18
+ //
19
+ // States
20
+ //
21
+
22
+ window.States = {
23
+ "AL": "Alabama",
24
+ "AK": "Alaska",
25
+ "AS": "American Samoa",
26
+ "AZ": "Arizona",
27
+ "AR": "Arkansas",
28
+ "CA": "California",
29
+ "CO": "Colorado",
30
+ "CT": "Connecticut",
31
+ "DE": "Delaware",
32
+ "DC": "District Of Columbia",
33
+ "FM": "Federated States Of Micronesia",
34
+ "FL": "Florida",
35
+ "GA": "Georgia",
36
+ "GU": "Guam",
37
+ "HI": "Hawaii",
38
+ "ID": "Idaho",
39
+ "IL": "Illinois",
40
+ "IN": "Indiana",
41
+ "IA": "Iowa",
42
+ "KS": "Kansas",
43
+ "KY": "Kentucky",
44
+ "LA": "Louisiana",
45
+ "ME": "Maine",
46
+ "MH": "Marshall Islands",
47
+ "MD": "Maryland",
48
+ "MA": "Massachusetts",
49
+ "MI": "Michigan",
50
+ "MN": "Minnesota",
51
+ "MS": "Mississippi",
52
+ "MO": "Missouri",
53
+ "MT": "Montana",
54
+ "NE": "Nebraska",
55
+ "NV": "Nevada",
56
+ "NH": "New Hampshire",
57
+ "NJ": "New Jersey",
58
+ "NM": "New Mexico",
59
+ "NY": "New York",
60
+ "NC": "North Carolina",
61
+ "ND": "North Dakota",
62
+ "MP": "Northern Mariana Islands",
63
+ "OH": "Ohio",
64
+ "OK": "Oklahoma",
65
+ "OR": "Oregon",
66
+ "PW": "Palau",
67
+ "PA": "Pennsylvania",
68
+ "PR": "Puerto Rico",
69
+ "RI": "Rhode Island",
70
+ "SC": "South Carolina",
71
+ "SD": "South Dakota",
72
+ "TN": "Tennessee",
73
+ "TX": "Texas",
74
+ "UT": "Utah",
75
+ "VT": "Vermont",
76
+ "VI": "Virgin Islands",
77
+ "VA": "Virginia",
78
+ "WA": "Washington",
79
+ "WV": "West Virginia",
80
+ "WI": "Wisconsin",
81
+ "WY": "Wyoming"
82
+ };
83
+