caboose-cms 0.5.191 → 0.5.192
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/assets/javascripts/caboose/product_new.js +306 -305
- data/lib/caboose/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzFhZWU3NWRkNDk3NzhiMzM5ZDA2ZDdjZWU3YjgyOTFjMTdkODI4MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWIzZmZkM2Q2ODE0Y2Q1MDAyOTc4MTUwNjIwZWFmNDQ0ZTVmMDJjMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTMxZDUzZDU2ZTkwZTc1NjM2ZGY5MGZhYjdmZDY3NTgzMmQ0MWZkOTcyNzc5
|
10
|
+
NWIzYTgyMTZiNTFmOGJkMTczMTNmNjA5OTVmYTBmZmM3ZDkzOTA5YTJjN2Y4
|
11
|
+
NjlmM2Y1MTBmMmRmYWFjN2JkNTRhZmQ2ZDcxMjA0NGJmYmI4MTU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjcyODM0MmExYjBlOGVjZTJjZDE3M2NkYTA1NjQwYmE4MGI0NjQ0MTBkMDYx
|
14
|
+
M2EzYTI3YjU0Yzg5NWExZDdjNTc5ODI1ZTIwMjVjMTkzMjgwZDcxYTFlOGJj
|
15
|
+
MTZkMjIxYTJhYWJhNDMyMjEwN2ZlMDkzY2Y3NTY4NDNkNzAxNGE=
|
@@ -1,305 +1,306 @@
|
|
1
|
-
|
2
|
-
var ProductController = function(params) { this.init(params); };
|
3
|
-
|
4
|
-
ProductController.prototype = {
|
5
|
-
|
6
|
-
product: false,
|
7
|
-
option_values: [[], [], []],
|
8
|
-
|
9
|
-
init: function() {
|
10
|
-
self.$price = self.$product.find('#product-price');
|
11
|
-
$("<span id='percent-off'></span").insertAfter(self.$price);
|
12
|
-
$("<span id='sale-price'></span").insertBefore(self.$price);
|
13
|
-
if (!self.$product.length) return false;
|
14
|
-
},
|
15
|
-
|
16
|
-
refresh: function(after)
|
17
|
-
{
|
18
|
-
var that = this;
|
19
|
-
$.ajax({
|
20
|
-
url: '/products/' + that.product.id + '/info',
|
21
|
-
type: 'get',
|
22
|
-
success: function(resp) {
|
23
|
-
that.product = resp.product;
|
24
|
-
that.option_values = [that.option1_values, that.option2_values, that.option3_values];
|
25
|
-
that.render();
|
26
|
-
that.set_variant(self.get_initial_variant());
|
27
|
-
that.set_options_from_variant(self.variant);
|
28
|
-
}
|
29
|
-
);
|
30
|
-
},
|
31
|
-
|
32
|
-
render: function()
|
33
|
-
{
|
34
|
-
var that = this;
|
35
|
-
that.render_images();
|
36
|
-
that.render_options();
|
37
|
-
$('#message').empty();
|
38
|
-
},
|
39
|
-
|
40
|
-
initalize_zoom: function(image_url)
|
41
|
-
{
|
42
|
-
var big_image = $("#product-images").children("figure").first();
|
43
|
-
big_image.data("zoom-image",image_url);
|
44
|
-
big_image.elevateZoom();
|
45
|
-
},
|
46
|
-
|
47
|
-
render_images: function()
|
48
|
-
{
|
49
|
-
var that = this;
|
50
|
-
var div = $('<div/>').append($('<figure/>').attr('id', 'main_image').click(function(e) {
|
51
|
-
window.location = $(e.target).css('background-image').match(/^url\("(.*)"\)$/)[1];
|
52
|
-
}));
|
53
|
-
|
54
|
-
if (that.product.images.length > 0)
|
55
|
-
{
|
56
|
-
var ul = $('<ul/>');
|
57
|
-
$.each(product.images, function(i, image) {
|
58
|
-
ul.append(
|
59
|
-
$('<li/>').data('id', image.id).append(
|
60
|
-
$('<figure/>')
|
61
|
-
.data('url-large', image.urls.large)
|
62
|
-
.data('url-huge' , image.urls.huge)
|
63
|
-
.css('background-image', "url(" + image.urls.thumb + ")")
|
64
|
-
.click(function(e) {
|
65
|
-
$('#main_image').css('background-image', 'url(' + $(this).data('url-large') + ')');
|
66
|
-
that.initalize_zoom($(this).data('url-huge'));
|
67
|
-
})
|
68
|
-
)
|
69
|
-
);
|
70
|
-
});
|
71
|
-
div.append(ul);
|
72
|
-
}
|
73
|
-
else
|
74
|
-
{
|
75
|
-
div.append($('<p/>').html("This product doesn't have any images yet."));
|
76
|
-
}
|
77
|
-
$('#product-images').empty().append(div);
|
78
|
-
},
|
79
|
-
|
80
|
-
render_options: function()
|
81
|
-
{
|
82
|
-
var that = this;
|
83
|
-
var div = $('<div/>');
|
84
|
-
|
85
|
-
if (that.product.options.length > 0)
|
86
|
-
{
|
87
|
-
$.each(that.product.options, function(i, option) {
|
88
|
-
div.append($('<h3>').html(option));
|
89
|
-
var ul = $('<ul/>').attr('id', 'option' + (i + 1)).data('name', option);
|
90
|
-
$.each(that.option_values[i], function(j, option_value) {
|
91
|
-
ul.append($('<li/>')
|
92
|
-
.attr('id', 'option_' + i + '_' + j)
|
93
|
-
.data('i', i).data('j', j).data('value', option_value)
|
94
|
-
.html(option_value)
|
95
|
-
.click(function(e) {
|
96
|
-
that.select_option($(this).data('i'), $(this).data('value'));
|
97
|
-
})
|
98
|
-
);
|
99
|
-
});
|
100
|
-
div.append(ul);
|
101
|
-
});
|
102
|
-
}
|
103
|
-
else
|
104
|
-
{
|
105
|
-
div.append($('<p/>').html("This product doesn't have any options."));
|
106
|
-
}
|
107
|
-
$('#product-options').empty().append(div);
|
108
|
-
},
|
109
|
-
|
110
|
-
selected_options: false,
|
111
|
-
|
112
|
-
select_option: function(option_index, value)
|
113
|
-
{
|
114
|
-
var that = this;
|
115
|
-
that.selected_options[option_index] = (that.selected_options[option_index] == value ? false : value);
|
116
|
-
$('#product-options li').removeClass('available').removeClass('unavailable').removeClass('selected');
|
117
|
-
|
118
|
-
if (that.product.options.length > 0)
|
119
|
-
{
|
120
|
-
$.each(that.product.options, function(i, option) {
|
121
|
-
$.each(that.option_values[i], function(j, option_value) {
|
122
|
-
var el = $('#option_' + i + '_' + j);
|
123
|
-
if (that.variant_is_available(i, option_value))
|
124
|
-
{
|
125
|
-
el.addClass('available');
|
126
|
-
if (that.selected_options[i] == option_value)
|
127
|
-
el.addClass('selected');
|
128
|
-
}
|
129
|
-
else
|
130
|
-
{
|
131
|
-
el.addClass('unavailable');
|
132
|
-
}
|
133
|
-
});
|
134
|
-
});
|
135
|
-
}
|
136
|
-
//self.set_variant(self.get_variant_from_options(self.get_current_options()));
|
137
|
-
},
|
138
|
-
|
139
|
-
variant_is_available: function(option_index, option_value)
|
140
|
-
{
|
141
|
-
var that = this;
|
142
|
-
var exists = true;
|
143
|
-
|
144
|
-
var options_array = [];
|
145
|
-
$.each(that.product.options, function(i, option) {
|
146
|
-
if (that.selected_option[i] == false) // Any option will work
|
147
|
-
{
|
148
|
-
options_array[i] = that.option_values[i];
|
149
|
-
}
|
150
|
-
else if (i == option_index) // Only the given option_value will work
|
151
|
-
{
|
152
|
-
options_array[i] = [option_value];
|
153
|
-
}
|
154
|
-
else // Only the previously selected option will work
|
155
|
-
{
|
156
|
-
options_array[i] = [that.selected_option[i]];
|
157
|
-
}
|
158
|
-
});
|
159
|
-
|
160
|
-
var found_it = false;
|
161
|
-
$.each(that.product.variants, function(i, v) {
|
162
|
-
var matches = true;
|
163
|
-
$.each(options_array, function(j, option_values) {
|
164
|
-
if (option_values.index_of(v['option'+j]) != -1)
|
165
|
-
{
|
166
|
-
matches = false;
|
167
|
-
return false;
|
168
|
-
}
|
169
|
-
});
|
170
|
-
if (matches)
|
171
|
-
{
|
172
|
-
found_it = true;
|
173
|
-
return false;
|
174
|
-
}
|
175
|
-
});
|
176
|
-
return found_it;
|
177
|
-
},
|
178
|
-
|
179
|
-
variant_for_options: function()
|
180
|
-
{
|
181
|
-
var that = this;
|
182
|
-
var exists = true;
|
183
|
-
|
184
|
-
var options_array = [];
|
185
|
-
$.each(that.product.options, function(i, option) {
|
186
|
-
options_array[i] = that.selected_option[i];
|
187
|
-
});
|
188
|
-
|
189
|
-
var matching_variant = false;
|
190
|
-
$.each(that.product.variants, function(i, v) {
|
191
|
-
var matches = true;
|
192
|
-
$.each(options_array, function(j, option_value) {
|
193
|
-
if (option_value != v['option'+j]) { matches = false; return false; }
|
194
|
-
});
|
195
|
-
if (matches) { matching_variant = v; return false; }
|
196
|
-
});
|
197
|
-
return matching_variant;
|
198
|
-
},
|
199
|
-
|
200
|
-
//
|
201
|
-
// Variant Methods
|
202
|
-
//
|
203
|
-
|
204
|
-
initial_variant: function ()
|
205
|
-
{
|
206
|
-
var that = this;
|
207
|
-
var available_variants = $.grep(that.product.variants, function(v) { return v.quantity_in_stock > 0; });
|
208
|
-
|
209
|
-
if (!available_variants)
|
210
|
-
$('#add-to-cart').after($('<p/>').addClass('message error').text('Out of Stock')).remove();
|
211
|
-
|
212
|
-
variant = available_variants ? available_variants[0] : that.product.variants[0];
|
213
|
-
return variant;
|
214
|
-
},
|
215
|
-
|
216
|
-
self.set_variant = function(variant) {
|
217
|
-
self.variant = variant;
|
218
|
-
Caboose.Store.Modules.Cart.set_variant(variant);
|
219
|
-
if (variant) self.set_image_from_variant(variant);
|
220
|
-
if (variant && self.$price.length) self.$price.empty().text('$' + parseFloat((variant.price * 100) / 100).toFixed(2));
|
221
|
-
if (variant && self.variant_on_sale(variant)) {
|
222
|
-
self.$price.addClass("on-sale");
|
223
|
-
var percent = 100 - ((variant.sale_price / variant.price) * 100).toFixed(0);
|
224
|
-
$("#percent-off").text("SALE! Save " + percent + "%");
|
225
|
-
$("#sale-price").text('$' + parseFloat((variant.sale_price * 100) / 100).toFixed(2));
|
226
|
-
}
|
227
|
-
else {
|
228
|
-
self.$price.removeClass("on-sale");
|
229
|
-
$("#percent-off").text('');
|
230
|
-
$("#sale-price").text('');
|
231
|
-
}
|
232
|
-
},
|
233
|
-
|
234
|
-
variant_on_sale: function(variant)
|
235
|
-
{
|
236
|
-
if (variant.sale_price != "" && variant.sale_price != 0)
|
237
|
-
{
|
238
|
-
var d = new Date();
|
239
|
-
if (variant.date_sale_starts && d < variant.date_sale_starts) return false;
|
240
|
-
if (variant.date_sale_ends && d > variant.date_sale_ends) return false;
|
241
|
-
return true;
|
242
|
-
}
|
243
|
-
return false;
|
244
|
-
},
|
245
|
-
|
246
|
-
get_variant: function(variant_id)
|
247
|
-
{
|
248
|
-
for (var v in this.product.variants)
|
249
|
-
if (v.id == variant_id)
|
250
|
-
return v;
|
251
|
-
return false;
|
252
|
-
},
|
253
|
-
|
254
|
-
//
|
255
|
-
// Option Methods
|
256
|
-
//
|
257
|
-
|
258
|
-
self.get_option_attribute = function(option)
|
259
|
-
{
|
260
|
-
optionName = _.isObject(option) ? option.name : option;
|
261
|
-
if (self.product.option1 == optionName) { return 'option1'; }
|
262
|
-
else if (self.product.option2 == optionName) { return 'option2'; }
|
263
|
-
else if (self.product.option3 == optionName) { return 'option3'; }
|
264
|
-
},
|
265
|
-
|
266
|
-
self.get_current_options = function()
|
267
|
-
{
|
268
|
-
var options = [];
|
269
|
-
|
270
|
-
self.$options.children('ul').each(function(index, element) {
|
271
|
-
var $option = $(element);
|
272
|
-
|
273
|
-
options.push({
|
274
|
-
name: $option.data('name'),
|
275
|
-
value: $option.children('.selected').first().data('value')
|
276
|
-
});
|
277
|
-
});
|
278
|
-
|
279
|
-
return options;
|
280
|
-
},
|
281
|
-
|
282
|
-
//
|
283
|
-
// Image Methods
|
284
|
-
//
|
285
|
-
|
286
|
-
set_image_from_variant: function(variant)
|
287
|
-
{
|
288
|
-
if (!variant || !variant.images || variant.images.length == 0 || !variant.images[0]) return;
|
289
|
-
|
290
|
-
$('#main_image').css('background-image', 'url(' + $(this).data('url-large') + ')');
|
291
|
-
that.initalize_zoom($(this).data('url-huge'));
|
292
|
-
|
293
|
-
var $figure = self.$images.children('figure');
|
294
|
-
if (variant.images && variant.images.length > 0 && variant.images[0]) {
|
295
|
-
$figure.css('background-image', 'url(' + variant.images[0].urls.large + ')');
|
296
|
-
self.initalize_zoom(variant.images[0].urls.huge);
|
297
|
-
} else if ($figure.css('background-image').toLowerCase() == 'none') {
|
298
|
-
$figure.css('background-image', 'url(' + _.first(self.product.images).urls.large + ')');
|
299
|
-
self.initalize_zoom(_.first(self.product.images).urls.huge);
|
300
|
-
}
|
301
|
-
|
302
|
-
};
|
303
|
-
|
304
|
-
return self;
|
305
|
-
}).call(Caboose.Store);
|
1
|
+
//
|
2
|
+
//var ProductController = function(params) { this.init(params); };
|
3
|
+
//
|
4
|
+
//ProductController.prototype = {
|
5
|
+
//
|
6
|
+
// product: false,
|
7
|
+
// option_values: [[], [], []],
|
8
|
+
//
|
9
|
+
// init: function() {
|
10
|
+
// self.$price = self.$product.find('#product-price');
|
11
|
+
// $("<span id='percent-off'></span").insertAfter(self.$price);
|
12
|
+
// $("<span id='sale-price'></span").insertBefore(self.$price);
|
13
|
+
// if (!self.$product.length) return false;
|
14
|
+
// },
|
15
|
+
//
|
16
|
+
// refresh: function(after)
|
17
|
+
// {
|
18
|
+
// var that = this;
|
19
|
+
// $.ajax({
|
20
|
+
// url: '/products/' + that.product.id + '/info',
|
21
|
+
// type: 'get',
|
22
|
+
// success: function(resp) {
|
23
|
+
// that.product = resp.product;
|
24
|
+
// that.option_values = [that.option1_values, that.option2_values, that.option3_values];
|
25
|
+
// that.render();
|
26
|
+
// that.set_variant(self.get_initial_variant());
|
27
|
+
// that.set_options_from_variant(self.variant);
|
28
|
+
// }
|
29
|
+
// );
|
30
|
+
// },
|
31
|
+
//
|
32
|
+
// render: function()
|
33
|
+
// {
|
34
|
+
// var that = this;
|
35
|
+
// that.render_images();
|
36
|
+
// that.render_options();
|
37
|
+
// $('#message').empty();
|
38
|
+
// },
|
39
|
+
//
|
40
|
+
// initalize_zoom: function(image_url)
|
41
|
+
// {
|
42
|
+
// var big_image = $("#product-images").children("figure").first();
|
43
|
+
// big_image.data("zoom-image",image_url);
|
44
|
+
// big_image.elevateZoom();
|
45
|
+
// },
|
46
|
+
//
|
47
|
+
// render_images: function()
|
48
|
+
// {
|
49
|
+
// var that = this;
|
50
|
+
// var div = $('<div/>').append($('<figure/>').attr('id', 'main_image').click(function(e) {
|
51
|
+
// window.location = $(e.target).css('background-image').match(/^url\("(.*)"\)$/)[1];
|
52
|
+
// }));
|
53
|
+
//
|
54
|
+
// if (that.product.images.length > 0)
|
55
|
+
// {
|
56
|
+
// var ul = $('<ul/>');
|
57
|
+
// $.each(product.images, function(i, image) {
|
58
|
+
// ul.append(
|
59
|
+
// $('<li/>').data('id', image.id).append(
|
60
|
+
// $('<figure/>')
|
61
|
+
// .data('url-large', image.urls.large)
|
62
|
+
// .data('url-huge' , image.urls.huge)
|
63
|
+
// .css('background-image', "url(" + image.urls.thumb + ")")
|
64
|
+
// .click(function(e) {
|
65
|
+
// $('#main_image').css('background-image', 'url(' + $(this).data('url-large') + ')');
|
66
|
+
// that.initalize_zoom($(this).data('url-huge'));
|
67
|
+
// })
|
68
|
+
// )
|
69
|
+
// );
|
70
|
+
// });
|
71
|
+
// div.append(ul);
|
72
|
+
// }
|
73
|
+
// else
|
74
|
+
// {
|
75
|
+
// div.append($('<p/>').html("This product doesn't have any images yet."));
|
76
|
+
// }
|
77
|
+
// $('#product-images').empty().append(div);
|
78
|
+
// },
|
79
|
+
//
|
80
|
+
// render_options: function()
|
81
|
+
// {
|
82
|
+
// var that = this;
|
83
|
+
// var div = $('<div/>');
|
84
|
+
//
|
85
|
+
// if (that.product.options.length > 0)
|
86
|
+
// {
|
87
|
+
// $.each(that.product.options, function(i, option) {
|
88
|
+
// div.append($('<h3>').html(option));
|
89
|
+
// var ul = $('<ul/>').attr('id', 'option' + (i + 1)).data('name', option);
|
90
|
+
// $.each(that.option_values[i], function(j, option_value) {
|
91
|
+
// ul.append($('<li/>')
|
92
|
+
// .attr('id', 'option_' + i + '_' + j)
|
93
|
+
// .data('i', i).data('j', j).data('value', option_value)
|
94
|
+
// .html(option_value)
|
95
|
+
// .click(function(e) {
|
96
|
+
// that.select_option($(this).data('i'), $(this).data('value'));
|
97
|
+
// })
|
98
|
+
// );
|
99
|
+
// });
|
100
|
+
// div.append(ul);
|
101
|
+
// });
|
102
|
+
// }
|
103
|
+
// else
|
104
|
+
// {
|
105
|
+
// div.append($('<p/>').html("This product doesn't have any options."));
|
106
|
+
// }
|
107
|
+
// $('#product-options').empty().append(div);
|
108
|
+
// },
|
109
|
+
//
|
110
|
+
// selected_options: false,
|
111
|
+
//
|
112
|
+
// select_option: function(option_index, value)
|
113
|
+
// {
|
114
|
+
// var that = this;
|
115
|
+
// that.selected_options[option_index] = (that.selected_options[option_index] == value ? false : value);
|
116
|
+
// $('#product-options li').removeClass('available').removeClass('unavailable').removeClass('selected');
|
117
|
+
//
|
118
|
+
// if (that.product.options.length > 0)
|
119
|
+
// {
|
120
|
+
// $.each(that.product.options, function(i, option) {
|
121
|
+
// $.each(that.option_values[i], function(j, option_value) {
|
122
|
+
// var el = $('#option_' + i + '_' + j);
|
123
|
+
// if (that.variant_is_available(i, option_value))
|
124
|
+
// {
|
125
|
+
// el.addClass('available');
|
126
|
+
// if (that.selected_options[i] == option_value)
|
127
|
+
// el.addClass('selected');
|
128
|
+
// }
|
129
|
+
// else
|
130
|
+
// {
|
131
|
+
// el.addClass('unavailable');
|
132
|
+
// }
|
133
|
+
// });
|
134
|
+
// });
|
135
|
+
// }
|
136
|
+
// //self.set_variant(self.get_variant_from_options(self.get_current_options()));
|
137
|
+
// },
|
138
|
+
//
|
139
|
+
// variant_is_available: function(option_index, option_value)
|
140
|
+
// {
|
141
|
+
// var that = this;
|
142
|
+
// var exists = true;
|
143
|
+
//
|
144
|
+
// var options_array = [];
|
145
|
+
// $.each(that.product.options, function(i, option) {
|
146
|
+
// if (that.selected_option[i] == false) // Any option will work
|
147
|
+
// {
|
148
|
+
// options_array[i] = that.option_values[i];
|
149
|
+
// }
|
150
|
+
// else if (i == option_index) // Only the given option_value will work
|
151
|
+
// {
|
152
|
+
// options_array[i] = [option_value];
|
153
|
+
// }
|
154
|
+
// else // Only the previously selected option will work
|
155
|
+
// {
|
156
|
+
// options_array[i] = [that.selected_option[i]];
|
157
|
+
// }
|
158
|
+
// });
|
159
|
+
//
|
160
|
+
// var found_it = false;
|
161
|
+
// $.each(that.product.variants, function(i, v) {
|
162
|
+
// var matches = true;
|
163
|
+
// $.each(options_array, function(j, option_values) {
|
164
|
+
// if (option_values.index_of(v['option'+j]) != -1)
|
165
|
+
// {
|
166
|
+
// matches = false;
|
167
|
+
// return false;
|
168
|
+
// }
|
169
|
+
// });
|
170
|
+
// if (matches)
|
171
|
+
// {
|
172
|
+
// found_it = true;
|
173
|
+
// return false;
|
174
|
+
// }
|
175
|
+
// });
|
176
|
+
// return found_it;
|
177
|
+
// },
|
178
|
+
//
|
179
|
+
// variant_for_options: function()
|
180
|
+
// {
|
181
|
+
// var that = this;
|
182
|
+
// var exists = true;
|
183
|
+
//
|
184
|
+
// var options_array = [];
|
185
|
+
// $.each(that.product.options, function(i, option) {
|
186
|
+
// options_array[i] = that.selected_option[i];
|
187
|
+
// });
|
188
|
+
//
|
189
|
+
// var matching_variant = false;
|
190
|
+
// $.each(that.product.variants, function(i, v) {
|
191
|
+
// var matches = true;
|
192
|
+
// $.each(options_array, function(j, option_value) {
|
193
|
+
// if (option_value != v['option'+j]) { matches = false; return false; }
|
194
|
+
// });
|
195
|
+
// if (matches) { matching_variant = v; return false; }
|
196
|
+
// });
|
197
|
+
// return matching_variant;
|
198
|
+
// },
|
199
|
+
//
|
200
|
+
// //
|
201
|
+
// // Variant Methods
|
202
|
+
// //
|
203
|
+
//
|
204
|
+
// initial_variant: function ()
|
205
|
+
// {
|
206
|
+
// var that = this;
|
207
|
+
// var available_variants = $.grep(that.product.variants, function(v) { return v.quantity_in_stock > 0; });
|
208
|
+
//
|
209
|
+
// if (!available_variants)
|
210
|
+
// $('#add-to-cart').after($('<p/>').addClass('message error').text('Out of Stock')).remove();
|
211
|
+
//
|
212
|
+
// variant = available_variants ? available_variants[0] : that.product.variants[0];
|
213
|
+
// return variant;
|
214
|
+
// },
|
215
|
+
//
|
216
|
+
// self.set_variant = function(variant) {
|
217
|
+
// self.variant = variant;
|
218
|
+
// Caboose.Store.Modules.Cart.set_variant(variant);
|
219
|
+
// if (variant) self.set_image_from_variant(variant);
|
220
|
+
// if (variant && self.$price.length) self.$price.empty().text('$' + parseFloat((variant.price * 100) / 100).toFixed(2));
|
221
|
+
// if (variant && self.variant_on_sale(variant)) {
|
222
|
+
// self.$price.addClass("on-sale");
|
223
|
+
// var percent = 100 - ((variant.sale_price / variant.price) * 100).toFixed(0);
|
224
|
+
// $("#percent-off").text("SALE! Save " + percent + "%");
|
225
|
+
// $("#sale-price").text('$' + parseFloat((variant.sale_price * 100) / 100).toFixed(2));
|
226
|
+
// }
|
227
|
+
// else {
|
228
|
+
// self.$price.removeClass("on-sale");
|
229
|
+
// $("#percent-off").text('');
|
230
|
+
// $("#sale-price").text('');
|
231
|
+
// }
|
232
|
+
// },
|
233
|
+
//
|
234
|
+
// variant_on_sale: function(variant)
|
235
|
+
// {
|
236
|
+
// if (variant.sale_price != "" && variant.sale_price != 0)
|
237
|
+
// {
|
238
|
+
// var d = new Date();
|
239
|
+
// if (variant.date_sale_starts && d < variant.date_sale_starts) return false;
|
240
|
+
// if (variant.date_sale_ends && d > variant.date_sale_ends) return false;
|
241
|
+
// return true;
|
242
|
+
// }
|
243
|
+
// return false;
|
244
|
+
// },
|
245
|
+
//
|
246
|
+
// get_variant: function(variant_id)
|
247
|
+
// {
|
248
|
+
// for (var v in this.product.variants)
|
249
|
+
// if (v.id == variant_id)
|
250
|
+
// return v;
|
251
|
+
// return false;
|
252
|
+
// },
|
253
|
+
//
|
254
|
+
// //
|
255
|
+
// // Option Methods
|
256
|
+
// //
|
257
|
+
//
|
258
|
+
// self.get_option_attribute = function(option)
|
259
|
+
// {
|
260
|
+
// optionName = _.isObject(option) ? option.name : option;
|
261
|
+
// if (self.product.option1 == optionName) { return 'option1'; }
|
262
|
+
// else if (self.product.option2 == optionName) { return 'option2'; }
|
263
|
+
// else if (self.product.option3 == optionName) { return 'option3'; }
|
264
|
+
// },
|
265
|
+
//
|
266
|
+
// self.get_current_options = function()
|
267
|
+
// {
|
268
|
+
// var options = [];
|
269
|
+
//
|
270
|
+
// self.$options.children('ul').each(function(index, element) {
|
271
|
+
// var $option = $(element);
|
272
|
+
//
|
273
|
+
// options.push({
|
274
|
+
// name: $option.data('name'),
|
275
|
+
// value: $option.children('.selected').first().data('value')
|
276
|
+
// });
|
277
|
+
// });
|
278
|
+
//
|
279
|
+
// return options;
|
280
|
+
// },
|
281
|
+
//
|
282
|
+
// //
|
283
|
+
// // Image Methods
|
284
|
+
// //
|
285
|
+
//
|
286
|
+
// set_image_from_variant: function(variant)
|
287
|
+
// {
|
288
|
+
// if (!variant || !variant.images || variant.images.length == 0 || !variant.images[0]) return;
|
289
|
+
//
|
290
|
+
// $('#main_image').css('background-image', 'url(' + $(this).data('url-large') + ')');
|
291
|
+
// that.initalize_zoom($(this).data('url-huge'));
|
292
|
+
//
|
293
|
+
// var $figure = self.$images.children('figure');
|
294
|
+
// if (variant.images && variant.images.length > 0 && variant.images[0]) {
|
295
|
+
// $figure.css('background-image', 'url(' + variant.images[0].urls.large + ')');
|
296
|
+
// self.initalize_zoom(variant.images[0].urls.huge);
|
297
|
+
// } else if ($figure.css('background-image').toLowerCase() == 'none') {
|
298
|
+
// $figure.css('background-image', 'url(' + _.first(self.product.images).urls.large + ')');
|
299
|
+
// self.initalize_zoom(_.first(self.product.images).urls.huge);
|
300
|
+
// }
|
301
|
+
//
|
302
|
+
// };
|
303
|
+
//
|
304
|
+
// return self;
|
305
|
+
//}).call(Caboose.Store);
|
306
|
+
//
|
data/lib/caboose/version.rb
CHANGED