caboose-cms 0.7.46 → 0.7.47

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: 886ac376765988b984868dce363f22e9b9b052ab
4
- data.tar.gz: 275663e37010387c36431a065692b4af6c4e63fc
3
+ metadata.gz: 97e5d06a76226c44c19e33d6d818e1dde1728f9e
4
+ data.tar.gz: e4bff286f011bef198631f52b910998c0c478fb0
5
5
  SHA512:
6
- metadata.gz: 971bbf0b06002f79cc7014db7bd37791bb11cab68ae7386adc287b8067fc6f2f831068e5a9d6e03e0e3fa7b4e8e58bcb5a7e5ba9700f653d1ab0d96c414f5283
7
- data.tar.gz: 6096afa69d336978603055de68544e5154a0fd87b9186d1bbff025084fbc50e339925a0283ca56c0f32c412cb0a289cf24b7cad12c7a5a52d636074298c5420e
6
+ metadata.gz: 516be68e61c0604aa4d83a8e6e78f0da7c9674c4d8ccc82dfe8e8b95f8559a02c31991a50814c928977eaf9b648bdba89fe24e766dd84e24c1c83d5ebf4a1809
7
+ data.tar.gz: 9af2ec3cf136043d6e1fe647eaa08143a482d80836786c9f004380318497574ee19b3db0ed83d7f2aac4c102a5fcbc9995dd31c7e5f2335edcecfc4bd8a065d5
@@ -18,7 +18,7 @@ Caboose.Store.Modules.Product = (function() {
18
18
  self.$product = $('#product');
19
19
  self.$price = self.$product.find('#product-price');
20
20
  $("<span id='percent-off'></span").insertAfter(self.$price);
21
- $("<span id='sale-price'></span").insertBefore(self.$price);
21
+ $("<span id='sale-price'></span").insertBefore(self.$price);
22
22
  if (!self.$product.length) return false;
23
23
 
24
24
  $.get('/products/' + self.$product.data('id') + '/info', function(response) {
@@ -72,7 +72,7 @@ Caboose.Store.Modules.Product = (function() {
72
72
  self.render_options = function(callback) {
73
73
  self.$options = $('#product-options', self.$options);
74
74
  if (!self.$options.length) return false;
75
- self.$options.empty().html(self.templates.options({ options: self.get_options_with_all_values() }));
75
+ self.$options.empty().html(self.templates.options({ product: self.product, options: self.get_options_with_all_values() }));
76
76
  if (callback) callback();
77
77
  };
78
78
 
@@ -91,7 +91,7 @@ Caboose.Store.Modules.Product = (function() {
91
91
  self.bind_events = function() {
92
92
  self.$images.find('ul > li > figure').on('click', self.thumb_click_handler);
93
93
  self.$images.children('figure').on('click', self.image_click_handler);
94
- self.$options.find('ul').on('click', 'li', self.option_click_handler);
94
+ self.$options.find('ul').on('click', 'li', self.option_click_handler);
95
95
  };
96
96
 
97
97
  self.thumb_click_handler = function(event) {
@@ -103,10 +103,13 @@ Caboose.Store.Modules.Product = (function() {
103
103
  window.location = $(event.target).css('background-image').match(/^url\("(.*)"\)$/)[1];
104
104
  };
105
105
 
106
- self.option_click_handler = function(event) {
106
+ self.option_click_handler = function(event) {
107
107
  var $target_option = $(event.delegateTarget)
108
108
  var $target_value = $(event.target);
109
-
109
+
110
+ if ($target_value[0].nodeName == 'IMG')
111
+ $target_value = $target_value.parent();
112
+
110
113
  if ($target_value.hasClass('selected')) {
111
114
  $target_value.removeClass('selected');
112
115
  $target_value = $();
@@ -270,8 +273,14 @@ Caboose.Store.Modules.Product = (function() {
270
273
  self.variant = variant;
271
274
  Caboose.Store.Modules.Cart.set_variant(variant);
272
275
  if (variant) self.set_image_from_variant(variant);
273
- if (variant && self.$price.length) self.$price.empty().text('$' + parseFloat((variant.price * 100) / 100).toFixed(2));
274
- if (variant && self.variant_on_sale(variant)) {
276
+ if (variant && self.$price.length) self.$price.empty().text('$' + parseFloat((variant.price * 100) / 100).toFixed(2));
277
+ if (variant && variant.clearance == true) {
278
+ self.$price.addClass("on-clearance");
279
+ var percent = 100 - ((variant.clearance_price / variant.price) * 100).toFixed(0);
280
+ $("#percent-off").text("CLEARANCE! Save " + percent + "%");
281
+ $("#sale-price").text('$' + parseFloat((variant.clearance_price * 100) / 100).toFixed(2));
282
+ }
283
+ else if (variant && self.variant_on_sale(variant)) {
275
284
  self.$price.addClass("on-sale");
276
285
  var percent = 100 - ((variant.sale_price / variant.price) * 100).toFixed(0);
277
286
  $("#percent-off").text("SALE! Save " + percent + "%");
@@ -279,6 +288,7 @@ Caboose.Store.Modules.Product = (function() {
279
288
  }
280
289
  else {
281
290
  self.$price.removeClass("on-sale");
291
+ self.$price.removeClass("on-clearance");
282
292
  $("#percent-off").text('');
283
293
  $("#sale-price").text('');
284
294
  }
@@ -1,9 +1,13 @@
1
- <% _.each(options, function(option, index) { %>
1
+ <% _.each(options, function(option, index) { %>
2
2
  <h3><%= option.name %></h3>
3
3
  <ul id="<%= 'option' + (index + 1) %>" data-name="<%= option.name %>">
4
- <% _.each(_.sortBy(option.values, function(option) { return parseFloat(option) }), function(value) { %>
5
- <li data-value="<%= value %>"><%= value %></li>
6
- <% }); %>
4
+ <%
5
+ for (var k in option.values) {
6
+ var url = option.values[k]
7
+ if (url) { %><li data-value="<%= k %>" class='swatch'><div></div><img src='<%= url %>' /><div></div></li><% }
8
+ else { %><li data-value="<%= k %>"><%= k %></li><% }
9
+ }
10
+ %>
7
11
  </ul>
8
12
  <% }); %>
9
13
 
@@ -47,7 +47,7 @@ module Caboose
47
47
  li.quantity += qty
48
48
  li.subtotal = li.unit_price * li.quantity
49
49
  else
50
- unit_price = v.on_sale? ? v.sale_price : v.price
50
+ unit_price = v.clearance && v.clearance_price ? v.clearance_price : (v.on_sale? ? v.sale_price : v.price)
51
51
  li = LineItem.new(
52
52
  :order_id => @order.id,
53
53
  :variant_id => v.id,
@@ -130,9 +130,9 @@ module Caboose
130
130
  p = Product.find(params[:id])
131
131
  render :json => {
132
132
  :product => p,
133
- :option1_values => p.option1_values,
134
- :option2_values => p.option2_values,
135
- :option3_values => p.option3_values
133
+ :option1_values => p.option1_values_with_media(true),
134
+ :option2_values => p.option2_values_with_media(true),
135
+ :option3_values => p.option3_values_with_media(true)
136
136
  }
137
137
  end
138
138
 
@@ -89,7 +89,7 @@ module Caboose
89
89
 
90
90
  def verify_unit_price
91
91
  if self.unit_price.nil?
92
- self.unit_price = self.variant.on_sale? ? self.variant.sale_price : self.variant.price
92
+ self.unit_price = self.variant.clearance && self.variant.clearance_price ? self.variant.clearance_price : (self.variant.on_sale? ? self.variant.sale_price : self.variant.price)
93
93
  self.save
94
94
  end
95
95
  end
@@ -162,9 +162,9 @@ module Caboose
162
162
  self.variants.where(:status => 'Active').reorder(:option1_sort_order).pluck(:option1).uniq.reject { |x| x.nil? || x.empty? }
163
163
  end
164
164
 
165
- def option1_values_with_media
165
+ def option1_values_with_media(url_only = false)
166
166
  h = {}
167
- self.variants.where("status = ? and option1 is not null", 'Active').reorder(:option1_sort_order).each{ |v| h[v.option1] = v.option1_media }
167
+ self.variants.where("status = ? and option1 is not null", 'Active').reorder(:option1_sort_order).each{ |v| h[v.option1] = url_only ? (v.option1_media && v.option1_media.image ? v.option1_media.image.url(:thumb) : false) : v.option1_media }
168
168
  return h
169
169
  end
170
170
 
@@ -172,9 +172,9 @@ module Caboose
172
172
  self.variants.where(:status => 'Active').reorder(:option2_sort_order).pluck(:option2).uniq.reject { |x| x.nil? || x.empty? }
173
173
  end
174
174
 
175
- def option2_values_with_media
175
+ def option2_values_with_media(url_only = false)
176
176
  h = {}
177
- self.variants.where("status = ? and option2 is not null", 'Active').reorder(:option2_sort_order).each{ |v| h[v.option2] = v.option2_media }
177
+ self.variants.where("status = ? and option2 is not null", 'Active').reorder(:option2_sort_order).each{ |v| h[v.option2] = url_only ? (v.option2_media && v.option2_media.image ? v.option2_media.image.url(:thumb) : false) : v.option2_media }
178
178
  return h
179
179
  end
180
180
 
@@ -182,9 +182,9 @@ module Caboose
182
182
  self.variants.where(:status => 'Active').reorder(:option3_sort_order).pluck(:option3).uniq.reject { |x| x.nil? || x.empty? }
183
183
  end
184
184
 
185
- def option3_values_with_media
185
+ def option3_values_with_media(url_only = false)
186
186
  h = {}
187
- self.variants.where("status = ? and option3 is not null", 'Active').reorder(:option3_sort_order).each{ |v| h[v.option3] = v.option3_media }
187
+ self.variants.where("status = ? and option3 is not null", 'Active').reorder(:option3_sort_order).each{ |v| h[v.option3] = url_only ? (v.option3_media && v.option3_media.image ? v.option3_media.image.url(:thumb) : false) : v.option3_media }
188
188
  return h
189
189
  end
190
190
 
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.7.46'
2
+ VERSION = '0.7.47'
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.7.46
4
+ version: 0.7.47
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-01-08 00:00:00.000000000 Z
11
+ date: 2016-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg