caboose-cms 0.5.56 → 0.5.57

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +8 -8
  2. data/app/assets/javascripts/caboose/cart.js +43 -47
  3. data/app/assets/javascripts/caboose/checkout_step3.js +5 -3
  4. data/app/assets/javascripts/caboose/checkout_step4.js +2 -1
  5. data/app/assets/javascripts/caboose/model/index_table.js +6 -6
  6. data/app/assets/javascripts/caboose/product.js +61 -61
  7. data/app/assets/stylesheets/caboose/product_images.css.scss +31 -0
  8. data/app/assets/stylesheets/caboose/product_options.css.scss +34 -0
  9. data/app/assets/templates/caboose/cart/add_to_cart.jst.ejs +1 -2
  10. data/app/assets/templates/caboose/product/images.jst.ejs +1 -2
  11. data/app/assets/templates/caboose/product/images_old.jst.ejs +7 -0
  12. data/app/assets/templates/caboose/product/options.jst.ejs +0 -10
  13. data/app/controllers/caboose/application_controller.rb +12 -12
  14. data/app/controllers/caboose/checkout_controller.rb +53 -11
  15. data/app/controllers/caboose/products_controller.rb +27 -281
  16. data/app/controllers/caboose/sites_controller.rb +8 -7
  17. data/app/controllers/caboose/variants_controller.rb +123 -41
  18. data/app/models/caboose/order.rb +20 -13
  19. data/app/models/caboose/order_package.rb +3 -0
  20. data/app/models/caboose/schema.rb +30 -22
  21. data/app/models/caboose/shipping_calculator.rb +14 -4
  22. data/app/models/caboose/store_config.rb +1 -0
  23. data/app/views/caboose/checkout/_confirm.html.erb +1 -1
  24. data/app/views/caboose/checkout/step_four.html.erb +8 -41
  25. data/app/views/caboose/checkout/step_one.html.erb +2 -0
  26. data/app/views/caboose/checkout/step_three.html.erb +45 -34
  27. data/app/views/caboose/checkout/step_two.html.erb +2 -1
  28. data/app/views/caboose/products/_admin_header.html.erb +1 -1
  29. data/app/views/caboose/products/admin_edit_images.html.erb +2 -2
  30. data/app/views/caboose/sites/admin_edit_store_config.html.erb +2 -0
  31. data/app/views/caboose/{products/admin_edit_variant_sort_order.html.erb → variants/admin_edit_sort_order.html.erb} +0 -0
  32. data/app/views/caboose/variants/admin_index.html.erb +101 -0
  33. data/config/routes.rb +184 -113
  34. data/lib/caboose/version.rb +1 -1
  35. metadata +7 -7
  36. data/app/views/caboose/products/admin_edit_variant_columns.html.erb +0 -75
  37. data/app/views/caboose/products/admin_edit_variants.html.erb +0 -92
  38. data/app/views/caboose/products/admin_edit_variants_old.html.erb +0 -171
  39. data/app/views/caboose/products/admin_edit_variants_single.html.erb +0 -68
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTkzNGRkMmQ3YWRiMDVmOWE1NjA3MjExMTM5ZDI2NGI5MWUxODc3MA==
4
+ ODFmNjUxMWMxNmI5NWIwN2RlN2I4Yjg3YzY5NjM5ZDIwY2VjZTg5ZQ==
5
5
  data.tar.gz: !binary |-
6
- NGI4NjU2ZGU5ZDUzOTQzMDc4NmVkZDcxMzRlOTUxMzIxMmJkZmYyOQ==
6
+ MTQyZDczZTJmZDY0Y2JiNzBhOTI2YTcwMGE5OGRhMzMzNzg5NzE1Ng==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzM1NzQ4MGE0MTAxMzIyNjQ5YzE3YWY2MDJjY2E2MjdiZThlYjI1NmQ2OWYx
10
- MzA5YzE4MWYwZTUyYTJmNGQ2YzVjYmE2YjgxYzliZjU5ZTU2ZDdlYmE3NmM4
11
- YTMyMGZlYTMxZGQ3ZWVmZGM5MjZiMjllNWY1OGVkM2EzMmFiYmE=
9
+ ZGQ0ZDM1ZGY2NzMyNjNlYTQ2NWZhODkwN2Y4M2FkNjIwMjQzNTIxMjkwOWYx
10
+ MzI1MWM5NzkyYjYxMjE4MTAwMjRkZjIxNjQyNTZkM2JmNTgzZGNhYzJjOGVk
11
+ M2UzMDM2N2UzODc1MDJmOTY5YzU3N2ZhMzAzYzc4NjEyNzM4MGY=
12
12
  data.tar.gz: !binary |-
13
- OWY5NmJiOTdmNmVkZGRiYzExM2QyNTZkMmI3YjM4MWIxNmE2YmFiYTZjYmY0
14
- MDVlOWFhODc5ZThhOGNhMTAzYzBiMjQ3NGUzZDdjMWQ1MzU0NGI1Mjc5NzMz
15
- YWQwNTVkNDhmM2NlMjM5ZThiZWViOWNlMjQzMjgwZTEwY2JiNzI=
13
+ YWFlZTBmODdhZjA2MjA0YjU4ZjA3MTk5ZjJiMmIwOTQ2MmQyMDE2NGIzZGU4
14
+ NWUyMWVkNjUwODAxYzZiN2UxYjAzMWIyYTdiMGNhMjcwYjZkZDNlZTAwZWMw
15
+ ZTIyNjA4MmY4ZTg3OWQ3ZDYyODhmMzczM2Q0ZTFkZDE4YTA0NjA=
@@ -5,8 +5,8 @@
5
5
  Caboose.Store.Modules.Cart = (function() {
6
6
  var self = {
7
7
  templates: {
8
- lineItems: JST['caboose/cart/line_items'],
9
- addToCart: JST['caboose/cart/add_to_cart']
8
+ line_items: JST['caboose/cart/line_items'],
9
+ add_to_cart: JST['caboose/cart/add_to_cart']
10
10
  }
11
11
  };
12
12
 
@@ -15,12 +15,12 @@ Caboose.Store.Modules.Cart = (function() {
15
15
  //
16
16
 
17
17
  self.initialize = function() {
18
- self.renderAddToCart();
19
- self.renderItemCount();
18
+ self.render_add_to_cart();
19
+ self.render_item_count();
20
20
  self.$cart = $('#cart');
21
21
  if (!self.$cart.length) return false;
22
- self.$cart.on('click', '#remove-from-cart', self.removeHandler);
23
- self.$cart.on('keyup', 'input', self.updateHandler);
22
+ self.$cart.on('click', '#remove-from-cart', self.remove_handler);
23
+ self.$cart.on('keyup', 'input', self.update_handler);
24
24
  self.render();
25
25
  };
26
26
 
@@ -28,10 +28,10 @@ Caboose.Store.Modules.Cart = (function() {
28
28
  // Set Variant
29
29
  //
30
30
 
31
- self.setVariant = function(variant) {
32
- if (self.$addToCart) {
33
- self.$addToCart.find('input[name=variant_id]').val(variant ? variant.id : "");
34
- self.$addToCart.trigger('change');
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
35
  }
36
36
  };
37
37
 
@@ -41,38 +41,35 @@ Caboose.Store.Modules.Cart = (function() {
41
41
 
42
42
  self.render = function() {
43
43
  $.get('/cart/items', function(response) {
44
- self.$cart.empty().html(self.templates.lineItems({ order: response.order }));
44
+ self.$cart.empty().html(self.templates.line_items({ order: response.order }));
45
45
  self.$cart.removeClass('loading');
46
46
  });
47
47
  };
48
48
 
49
- self.renderAddToCart = function() {
50
- self.$addToCart = $('#add-to-cart');
51
- if (!self.$addToCart.length) return false;
52
- self.$addToCart.empty().html(self.templates.addToCart());
53
- $('input[name=quantity]', self.$addToCart).on('keyup', self.quantityKeyupHandler);
54
- $('form', self.$addToCart).on('submit', self.addHandler);
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);
55
56
  };
56
57
 
57
- self.renderItemCount = function(itemCount) {
58
+ self.render_item_count = function(item_count) {
58
59
  var $link = $('#cart-link, .cart-link');
59
60
  if (!$link.length) return false;
60
61
 
61
- function setCount(count) {
62
- if ($link.children('i') && count < 1) {
63
- $link.children('i').remove();
64
- } else if ($link.children('i').length) {
65
- $link.children('i').empty().text(count);
66
- } else {
67
- $link.append($('<i/>').text(count));
68
- }
62
+ function set_count(count) {
63
+ if ($link.children('i') && count < 1) { $link.children('i').remove(); }
64
+ else if ($link.children('i').length) { $link.children('i').empty().text(count); }
65
+ else { $link.append($('<i/>').text(count)); }
69
66
  };
70
67
 
71
- if (itemCount) {
72
- setCount(itemCount);
68
+ if (item_count) {
69
+ set_count(item_count);
73
70
  } else {
74
71
  $.get('/cart/item-count', function(response) {
75
- setCount(response.item_count);
72
+ set_count(response.item_count);
76
73
  });
77
74
  }
78
75
  };
@@ -81,12 +78,12 @@ Caboose.Store.Modules.Cart = (function() {
81
78
  // Event Handlers
82
79
  //
83
80
 
84
- self.quantityKeyupHandler = function(event) {
81
+ self.qty_keyup_handler = function(event) {
85
82
  var $quantity = $(event.target);
86
83
  $quantity.val($quantity.val().match(/\d*\.?\d+/));
87
84
  };
88
85
 
89
- self.addHandler = function(event) {
86
+ self.add_handler = function(event) {
90
87
  event.preventDefault();
91
88
  var $form = $(event.target);
92
89
 
@@ -99,11 +96,11 @@ Caboose.Store.Modules.Cart = (function() {
99
96
  data: $form.serialize(),
100
97
  success: function(response) {
101
98
  if (response.success) {
102
- self.renderItemCount(response.item_count);
103
- if (self.$addToCart.length) self.$addToCart.trigger('added');
99
+ self.render_item_count(response.item_count);
100
+ if (self.$add_to_cart.length) self.$add_to_cart.trigger('added');
104
101
 
105
- if (!self.$addToCart.find('.message').length) {
106
- self.$addToCart
102
+ if (!self.$add_to_cart.find('.message').length) {
103
+ self.$add_to_cart
107
104
  .append($('<div/>').hide().addClass('message')
108
105
  .append($('<p/>').text('Successfully added to cart'))
109
106
  .append($('<p/>')
@@ -111,11 +108,11 @@ Caboose.Store.Modules.Cart = (function() {
111
108
  .append($('<a/>').attr('href', '/checkout').html('Continue to checkout'))
112
109
  )
113
110
  );
114
- self.$addToCart.find('.message').fadeIn();
111
+ self.$add_to_cart.find('.message').fadeIn();
115
112
  Caboose.Store.Modules.Product.$product.trigger('added-to-cart');
116
113
 
117
114
  //setTimeout(function() {
118
- // self.$addToCart.find('.message').fadeOut(function() { $(this).remove() });
115
+ // self.$add_to_cart.find('.message').fadeOut(function() { $(this).remove() });
119
116
  //}, 5000);
120
117
  }
121
118
  } else {
@@ -126,9 +123,9 @@ Caboose.Store.Modules.Cart = (function() {
126
123
  }
127
124
  };
128
125
 
129
- self.updateHandler = function(event) {
126
+ self.update_handler = function(event) {
130
127
  var $quantity = $(event.target)
131
- , $lineItem = $quantity.parents('li').first();
128
+ var $line_item = $quantity.parents('li').first();
132
129
 
133
130
  $quantity.val($quantity.val().match(/\d*\.?\d+/));
134
131
  if ($quantity.val() == "") return false;
@@ -136,11 +133,11 @@ Caboose.Store.Modules.Cart = (function() {
136
133
  delay(function() {
137
134
  $.ajax({
138
135
  type: 'put',
139
- url: '/cart/items/' + $lineItem.data('id'),
136
+ url: '/cart/items/' + $line_item.data('id'),
140
137
  data: { quantity: $quantity.val() },
141
138
  success: function(response) {
142
139
  if (response.success) {
143
- $lineItem.find('.price').empty().text('$' + response.line_item.price);
140
+ $line_item.find('.price').empty().text('$' + response.line_item.price);
144
141
  if (self.$cart.find('.subtotal').length) self.$cart.find('.subtotal').empty().text('$' + response.order_subtotal);
145
142
  } else {
146
143
  alert(response.errors[0]);
@@ -150,26 +147,25 @@ Caboose.Store.Modules.Cart = (function() {
150
147
  }, 1000);
151
148
  };
152
149
 
153
- self.removeHandler = function(event) {
154
- var $lineItem = $(event.target).parents('li').first();
150
+ self.remove_handler = function(event) {
151
+ var $line_item = $(event.target).parents('li').first();
155
152
 
156
153
  $.ajax({
157
154
  type: 'delete',
158
- url: '/cart/items/' + $lineItem.data('id'),
155
+ url: '/cart/items/' + $line_item.data('id'),
159
156
  success: function(response) {
160
157
  if (response.success) {
161
158
  self.render();
162
- self.renderItemCount(response.item_count);
159
+ self.render_item_count(response.item_count);
163
160
  }
164
161
  }
165
162
  });
166
163
  };
167
164
 
168
- self.redirectHandler = function(event) {
165
+ self.redirect_handler = function(event) {
169
166
  event.preventDefault();
170
167
  window.location = $(event.target).attr('href');
171
168
  };
172
169
 
173
170
  return self;
174
171
  }).call(Caboose.Store);
175
-
@@ -8,17 +8,19 @@ Caboose.Store.Modules.CheckoutStep3 = (function() {
8
8
  };
9
9
 
10
10
  self.bind_event_handlers = function() {
11
- $('#checkout button').click(self.shipping_click_handler);
11
+ $('a.shipping_rate').click(self.shipping_click_handler);
12
12
  };
13
13
 
14
14
  self.shipping_click_handler = function(event) {
15
+ event.preventDefault();
15
16
  $('#message').html("<p class='loading'>Saving information...</p>");
16
17
  $.ajax({
17
18
  url: '/checkout/shipping',
18
19
  type: 'put',
19
20
  data: {
20
- shipping_method: $(event.target).data('shipping-method'),
21
- shipping_method_code: $(event.target).data('shipping-code')
21
+ carrier: $(event.target).data('carrier'),
22
+ service_code: $(event.target).data('service-code'),
23
+ service_name: $(event.target).data('service-name')
22
24
  },
23
25
  success: function(resp) {
24
26
  if (resp.errors && resp.errors.length > 0)
@@ -7,7 +7,7 @@ Caboose.Store.Modules.CheckoutStep4 = (function() {
7
7
 
8
8
  self.initialize = function() {
9
9
  $('#checkout-confirm').hide();
10
- $('#relay').hide();
10
+ //$('#relay').hide();
11
11
  self.bind_event_handlers();
12
12
  self.expiration_change_handler();
13
13
  };
@@ -30,6 +30,7 @@ Caboose.Store.Modules.CheckoutStep4 = (function() {
30
30
  };
31
31
 
32
32
  self.continue_handler = function(event) {
33
+ alert('Testing');
33
34
  if (!self.is_confirm)
34
35
  {
35
36
  var cc = $('#billing-cc-number').val();
@@ -545,11 +545,11 @@ IndexTable.prototype = {
545
545
  {
546
546
  var div = $('<div/>').addClass('note')
547
547
  .append($('<h2/>').html('Bulk Import'))
548
- .append($('<p/>').html("Enter either the URL where CSV data can be downloaded or the CSV data.</p>"))
549
- .append($('<p/>')
550
- .append('CSV Data URL').append('<br />')
551
- .append($('<input/>').attr('id', that.container + '_bulk_import_data_url').attr('placeholder', 'CSV Data URL').css('width', '100%'))
552
- )
548
+ //.append($('<p/>').html("Enter either the URL where CSV data can be downloaded or the CSV data.</p>"))
549
+ //.append($('<p/>')
550
+ // .append('CSV Data URL').append('<br />')
551
+ // .append($('<input/>').attr('id', that.container + '_bulk_import_data_url').attr('placeholder', 'CSV Data URL').css('width', '100%'))
552
+ //)
553
553
  .append($('<p/>')
554
554
  .append('CSV Data').append('<br />')
555
555
  .append($('<textarea/>').attr('id', that.container + '_bulk_import_data').attr('placeholder', 'CSV Data').css('width', '100%').css('height', '150px'))
@@ -780,7 +780,7 @@ IndexTable.prototype = {
780
780
  data: $('#new_form').serialize(),
781
781
  success: function(resp) {
782
782
  if (resp.error) $('#' + that.container + '_new_message').html("<p class='note error'>" + resp.error + "</p>");
783
- if (resp.redirect || resp.refresh) that.refresh();
783
+ if (resp.redirect || resp.refresh || resp.success) that.refresh();
784
784
  }
785
785
  });
786
786
  },
@@ -5,7 +5,7 @@
5
5
  Caboose.Store.Modules.Product = (function() {
6
6
  var self = {
7
7
  templates: {
8
- images: JST['caboose/product/images'],
8
+ images: JST['caboose/product/images'],
9
9
  options: JST['caboose/product/options']
10
10
  }
11
11
  };
@@ -25,41 +25,40 @@ Caboose.Store.Modules.Product = (function() {
25
25
  self.option2_values = response.option2_values;
26
26
  self.option3_values = response.option3_values;
27
27
  self.render();
28
- self.bindEvents();
29
- self.setVariant(self.getInitialVariant());
30
- self.setOptionsFromVariant(self.variant);
28
+ self.bind_events();
29
+ self.set_variant(self.get_initial_variant());
30
+ self.set_options_from_variant(self.variant);
31
31
  });
32
32
  };
33
33
 
34
34
  //
35
35
  // Render
36
- //
37
-
36
+ //
38
37
  self.render = function() {
39
- var renderFunctions = [];
40
- renderFunctions.push(self.renderImages);
41
- renderFunctions.push(self.renderOptions);
38
+ var render_functions = [];
39
+ render_functions.push(self.render_images);
40
+ render_functions.push(self.render_options);
42
41
 
43
- _.each(renderFunctions, function(renderFunction, index) {
44
- var finished = index == (renderFunctions.length - 1);
42
+ _.each(render_functions, function(render_function, index) {
43
+ var finished = index == (render_functions.length - 1);
45
44
 
46
- renderFunction(function() {
45
+ render_function(function() {
47
46
  if (finished) self.$product.removeClass('loading');
48
47
  });
49
48
  });
50
49
  };
51
50
 
52
- self.renderImages = function(callback) {
53
- self.$images = $('#product-images', self.$product);
51
+ self.render_images = function(callback) {
52
+ self.$images = $('#product-images', self.$product);
54
53
  if (!self.$images.length) return false;
55
54
  self.$images.empty().html(self.templates.images({ images: self.product.images }));
56
55
  if (callback) callback();
57
56
  };
58
57
 
59
- self.renderOptions = function(callback) {
58
+ self.render_options = function(callback) {
60
59
  self.$options = $('#product-options', self.$options);
61
60
  if (!self.$options.length) return false;
62
- self.$options.empty().html(self.templates.options({ options: self.getOptionsWithAllValues() }));
61
+ self.$options.empty().html(self.templates.options({ options: self.get_options_with_all_values() }));
63
62
  if (callback) callback();
64
63
  };
65
64
 
@@ -67,7 +66,7 @@ Caboose.Store.Modules.Product = (function() {
67
66
  // Out of Stock
68
67
  //
69
68
 
70
- self.outOfStock = function() {
69
+ self.out_of_stock = function() {
71
70
  self.$product.find('#add-to-cart').after($('<p/>').addClass('message error').text('Out of Stock')).remove();
72
71
  };
73
72
 
@@ -75,90 +74,91 @@ Caboose.Store.Modules.Product = (function() {
75
74
  // Events
76
75
  //
77
76
 
78
- self.bindEvents = function() {
79
- self.$images.find('ul > li > figure').on('click', self.thumbClickHandler);
80
- self.$images.children('figure').on('click', self.imageClickHandler);
81
- self.$options.find('ul').on('click', 'li', self.optionClickHandler);
77
+ self.bind_events = function() {
78
+ self.$images.find('ul > li > figure').on('click', self.thumb_click_handler);
79
+ self.$images.children('figure').on('click', self.image_click_handler);
80
+ self.$options.find('ul').on('click', 'li', self.option_click_handler);
82
81
  };
83
82
 
84
- self.thumbClickHandler = function(event) {
83
+ self.thumb_click_handler = function(event) {
84
+ //self.$images.children('figure').css('background-image', 'url(' + $(event.target).data('url-large') + ')');
85
85
  self.$images.children('figure').css('background-image', 'url(' + $(event.target).data('url-large') + ')');
86
86
  };
87
87
 
88
- self.imageClickHandler = function(event) {
88
+ self.image_click_handler = function(event) {
89
89
  window.location = $(event.target).css('background-image').match(/^url\("(.*)"\)$/)[1];
90
90
  };
91
91
 
92
- self.optionClickHandler = function(event) {
93
- var $targetOption = $(event.delegateTarget)
94
- , $targetValue = $(event.target);
92
+ self.option_click_handler = function(event) {
93
+ var $target_option = $(event.delegateTarget)
94
+ var $target_value = $(event.target);
95
95
 
96
- if ($targetValue.hasClass('selected')) {
97
- $targetValue.removeClass('selected');
98
- $targetValue = $();
96
+ if ($target_value.hasClass('selected')) {
97
+ $target_value.removeClass('selected');
98
+ $target_value = $();
99
99
  } else {
100
- $targetValue.addClass('selected').siblings().removeClass('selected');
100
+ $target_value.addClass('selected').siblings().removeClass('selected');
101
101
 
102
- self.$options.find('ul').not($targetOption).each(function(index, element) {
102
+ self.$options.find('ul').not($target_option).each(function(index, element) {
103
103
  var $currentOption = $(element)
104
104
  , $currentValue = $currentOption.children('.selected')
105
- , $otherOption = self.$options.find('ul').not($targetOption.add($currentOption))
105
+ , $otherOption = self.$options.find('ul').not($target_option.add($currentOption))
106
106
  , $otherValue = $otherOption.children('.selected')
107
107
  , options = [];
108
108
 
109
109
  if (!$currentValue.length) return true;
110
110
 
111
111
  options.push({ name: $currentOption.data('name'), value: $currentValue.data('value') });
112
- options.push({ name: $targetOption.data('name'), value: $targetValue.data('value') });
112
+ options.push({ name: $target_option.data('name'), value: $target_value.data('value') });
113
113
 
114
- if (!!!self.getVariantFromOptions(options)) {
114
+ if (!!!self.get_variant_from_options(options)) {
115
115
  $currentValue.removeClass('selected');
116
116
  } else if ($otherOption.length && $otherValue.length) {
117
117
  options.push({ name: $otherOption.data('name'), value: $otherValue.data('value') });
118
- if (!!!self.getVariantFromOptions(options)) $otherValue.removeClass('selected');
118
+ if (!!!self.get_variant_from_options(options)) $otherValue.removeClass('selected');
119
119
  }
120
120
  });
121
121
 
122
- $targetOption.children().each(function(index, element) {
123
- var $currentOption = $targetOption
122
+ $target_option.children().each(function(index, element) {
123
+ var $currentOption = $target_option
124
124
  , $currentValue = $(element)
125
- , $otherOption = self.$options.find('ul').not($targetOption).first()
125
+ , $otherOption = self.$options.find('ul').not($target_option).first()
126
126
  , $otherValue = $otherOption.children('.selected')
127
- , $otherOtherOption = self.$options.find('ul').not($targetOption.add($otherOption))
127
+ , $otherOtherOption = self.$options.find('ul').not($target_option.add($otherOption))
128
128
  , $otherOtherValue = $otherOtherOption.children('.selected')
129
129
  , options = [];
130
130
 
131
131
  options.push({ name: $currentOption.data('name'), value: $currentValue.data('value') });
132
132
  if ($otherOption.length && $otherValue.length) options.push({ name: $otherOption.data('name'), value: $otherValue.data('value') });
133
133
  if ($otherOtherOption.length && $otherOtherValue.length) options.push({ name: $otherOtherOption.data('name'), value: $otherOtherValue.data('value') });
134
- self.toggleOptionValue($currentValue, !!self.getVariantFromOptions(options));
134
+ self.toggle_option_value($currentValue, !!self.get_variant_from_options(options));
135
135
  });
136
136
  }
137
137
 
138
- self.$options.find('ul').not($targetOption).each(function(index, element) {
138
+ self.$options.find('ul').not($target_option).each(function(index, element) {
139
139
  var $currentOption = $(element);
140
140
 
141
141
  $currentOption.children().each(function(index, element) {
142
142
  var $currentValue = $(element)
143
- , $otherOption = self.$options.find('ul').not($targetOption.add($currentOption))
143
+ , $otherOption = self.$options.find('ul').not($target_option.add($currentOption))
144
144
  , $otherValue = $otherOption.children('.selected')
145
145
  , options = [];
146
146
 
147
147
  options.push({ name: $currentOption.data('name'), value: $currentValue.data('value') });
148
- if ($targetOption.length && $targetValue.length) options.push({ name: $targetOption.data('name'), value: $targetValue.data('value') });
148
+ if ($target_option.length && $target_value.length) options.push({ name: $target_option.data('name'), value: $target_value.data('value') });
149
149
  if ($otherOption.length && $otherValue.length) options.push({ name: $otherOption.data('name'), value: $otherValue.data('value') });
150
- self.toggleOptionValue($currentValue, !!self.getVariantFromOptions(options));
150
+ self.toggle_option_value($currentValue, !!self.get_variant_from_options(options));
151
151
  });
152
152
  });
153
153
 
154
- self.setVariant(self.getVariantFromOptions(self.getCurrentOptions()));
154
+ self.set_variant(self.get_variant_from_options(self.get_current_options()));
155
155
  };
156
156
 
157
157
  //
158
158
  // Option Methods
159
159
  //
160
160
 
161
- self.getOptionsFromProduct = function() {
161
+ self.get_options_from_product = function() {
162
162
  return _.compact([
163
163
  self.product.option1 ? self.product.option1 : undefined,
164
164
  self.product.option2 ? self.product.option2 : undefined,
@@ -167,7 +167,7 @@ Caboose.Store.Modules.Product = (function() {
167
167
  };
168
168
 
169
169
 
170
- self.getOptionsFromVariant = function(variant) {
170
+ self.get_options_from_variant = function(variant) {
171
171
  return _.compact([
172
172
  self.product.option1 ? { name: self.product.option1, value: variant.option1 } : undefined,
173
173
  self.product.option2 ? { name: self.product.option2, value: variant.option2 } : undefined,
@@ -175,7 +175,7 @@ Caboose.Store.Modules.Product = (function() {
175
175
  ]);
176
176
  };
177
177
 
178
- self.getOptionsWithAllValues = function() {
178
+ self.get_options_with_all_values = function() {
179
179
  var options = [];
180
180
  if (self.product.option1) options.push({ name: self.product.option1, values: self.option1_values });
181
181
  if (self.product.option2) options.push({ name: self.product.option2, values: self.option2_values });
@@ -183,7 +183,7 @@ Caboose.Store.Modules.Product = (function() {
183
183
  return options;
184
184
  };
185
185
 
186
- self.getOptionAttribute = function(option) {
186
+ self.get_option_attribute = function(option) {
187
187
  optionName = _.isObject(option) ? option.name : option;
188
188
 
189
189
  if (self.product.option1 == optionName) {
@@ -195,7 +195,7 @@ Caboose.Store.Modules.Product = (function() {
195
195
  }
196
196
  };
197
197
 
198
- self.getCurrentOptions = function() {
198
+ self.get_current_options = function() {
199
199
  var options = [];
200
200
 
201
201
  self.$options.children('ul').each(function(index, element) {
@@ -210,7 +210,7 @@ Caboose.Store.Modules.Product = (function() {
210
210
  return options;
211
211
  };
212
212
 
213
- self.toggleOptionValue = function($value, on) {
213
+ self.toggle_option_value = function($value, on) {
214
214
  if (on) {
215
215
  $value.addClass('available').removeClass('unavailable');
216
216
  } else {
@@ -222,44 +222,44 @@ Caboose.Store.Modules.Product = (function() {
222
222
  // Variant Methods
223
223
  //
224
224
 
225
- self.getInitialVariant = function () {
225
+ self.get_initial_variant = function () {
226
226
  var variant = _.find(self.product.variants, function(variant) {
227
227
  return variant.quantity_in_stock > 0;
228
228
  });
229
229
 
230
230
  if (!variant) {
231
231
  variant = _.first(self.product.variants);
232
- self.outOfStock();
232
+ self.out_of_stock();
233
233
  }
234
234
 
235
235
  return variant;
236
236
  };
237
237
 
238
- self.getVariantFromOptions = function(options) {
238
+ self.get_variant_from_options = function(options) {
239
239
  if (_.find(options, function(option) { return option.value == undefined })) return false;
240
240
 
241
241
  var attributes = _.object(_.map(options, function(option) {
242
- return [self.getOptionAttribute(option.name), option.value.toString()]
242
+ return [self.get_option_attribute(option.name), option.value.toString()]
243
243
  }));
244
244
 
245
245
  var variants = _.sortBy(_.where(self.product.variants, attributes), function(variant) { return variant.price });
246
246
  return _.find(variants, function(variant) { return variant.quantity_in_stock > 0 });
247
247
  };
248
248
 
249
- self.setOptionsFromVariant = function(variant) {
249
+ self.set_options_from_variant = function(variant) {
250
250
  if (variant.option1) $('#option1 li[data-value="' + variant.option1 + '"]', self.$options).click();
251
251
  if (variant.option1) $('#option2 li[data-value="' + variant.option2 + '"]', self.$options).click();
252
252
  if (variant.option1) $('#option3 li[data-value="' + variant.option3 + '"]', self.$options).click();
253
253
  };
254
254
 
255
- self.setVariant = function(variant) {
255
+ self.set_variant = function(variant) {
256
256
  self.variant = variant;
257
- Caboose.Store.Modules.Cart.setVariant(variant);
258
- if (variant) self.setImageFromVariant(variant);
257
+ Caboose.Store.Modules.Cart.set_variant(variant);
258
+ if (variant) self.set_image_from_variant(variant);
259
259
  if (variant && self.$price.length) self.$price.empty().text('$' + parseFloat((variant.price * 100) / 100).toFixed(2));
260
260
  };
261
261
 
262
- self.getVariant = function(id) {
262
+ self.get_variant = function(id) {
263
263
  return _.find(self.product.variants, function(variant) { return variant.id == (id || self.variant.id) });
264
264
  };
265
265
 
@@ -267,7 +267,7 @@ Caboose.Store.Modules.Product = (function() {
267
267
  // Image Methods
268
268
  //
269
269
 
270
- self.setImageFromVariant = function(variant) {
270
+ self.set_image_from_variant = function(variant) {
271
271
  if (!variant || !variant.images || variant.images.length == 0 || !variant.images[0]) return;
272
272
  self.$product.trigger('variant:updated');
273
273