caboose-cms 0.9.193 → 0.9.194

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/caboose/main.js +35 -34
  3. data/app/assets/stylesheets/caboose/login.scss +95 -0
  4. data/app/controllers/caboose/application_controller.rb +1 -1
  5. data/app/controllers/caboose/block_type_categories_controller.rb +25 -2
  6. data/app/controllers/caboose/block_types_controller.rb +34 -35
  7. data/app/controllers/caboose/login_controller.rb +33 -37
  8. data/app/controllers/caboose/pages_controller.rb +2 -7
  9. data/app/controllers/caboose/register_controller.rb +12 -14
  10. data/app/controllers/caboose/users_controller.rb +40 -46
  11. data/app/mailers/caboose/login_mailer.rb +3 -2
  12. data/app/models/caboose/authenticator.rb +2 -2
  13. data/app/models/caboose/block_type_category.rb +4 -2
  14. data/app/models/caboose/schema.rb +4 -2
  15. data/app/views/caboose/block_type_categories/admin_edit.html.erb +43 -0
  16. data/app/views/caboose/block_type_categories/admin_index.html.erb +23 -0
  17. data/app/{assets/javascripts/caboose/testing.js → views/caboose/block_type_categories/admin_new.html.erb} +0 -0
  18. data/app/views/caboose/block_types/admin_edit.html.erb +8 -8
  19. data/app/views/caboose/extras/error.html.erb +1 -1
  20. data/app/views/caboose/login/forgot_password_form.html.erb +38 -51
  21. data/app/views/caboose/login/index.html.erb +41 -64
  22. data/app/views/caboose/login/reset_password_form.html.erb +35 -35
  23. data/app/views/caboose/register/index.html.erb +51 -44
  24. data/lib/caboose/version.rb +1 -1
  25. metadata +6 -8
  26. data/app/assets/javascripts/caboose/cart_old.js +0 -184
  27. data/app/assets/javascripts/caboose/checkout_old.js +0 -151
  28. data/app/assets/javascripts/caboose/product_new.js +0 -306
  29. data/app/assets/javascripts/caboose/product_old.js +0 -324
  30. data/app/assets/stylesheets/caboose/login.css +0 -134
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.9.193'
2
+ VERSION = '0.9.194'
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.193
4
+ version: 0.9.194
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-09 00:00:00.000000000 Z
11
+ date: 2018-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -537,7 +537,6 @@ 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
541
540
  - app/assets/javascripts/caboose/checkout.js
542
541
  - app/assets/javascripts/caboose/checkout/authnet_payment_method_controller.js
543
542
  - app/assets/javascripts/caboose/checkout/billing_address_controller.js
@@ -552,7 +551,6 @@ files:
552
551
  - app/assets/javascripts/caboose/checkout_gift_cards.js
553
552
  - app/assets/javascripts/caboose/checkout_login_register.js
554
553
  - app/assets/javascripts/caboose/checkout_module.js
555
- - app/assets/javascripts/caboose/checkout_old.js
556
554
  - app/assets/javascripts/caboose/checkout_payment_authnet.js
557
555
  - app/assets/javascripts/caboose/checkout_payment_stripe.js
558
556
  - app/assets/javascripts/caboose/checkout_shipping.js
@@ -608,13 +606,10 @@ files:
608
606
  - app/assets/javascripts/caboose/my_account_edit_invoice.js
609
607
  - app/assets/javascripts/caboose/my_account_payment_method_controller.js
610
608
  - app/assets/javascripts/caboose/product.js
611
- - app/assets/javascripts/caboose/product_new.js
612
- - app/assets/javascripts/caboose/product_old.js
613
609
  - app/assets/javascripts/caboose/s3upload.js
614
610
  - app/assets/javascripts/caboose/shortcut.js
615
611
  - app/assets/javascripts/caboose/spectrum.js
616
612
  - app/assets/javascripts/caboose/station.js
617
- - app/assets/javascripts/caboose/testing.js
618
613
  - app/assets/javascripts/caboose/tinymce_init.js
619
614
  - app/assets/javascripts/caboose/united_states.js
620
615
  - app/assets/javascripts/caboose/variant_children_controller.js
@@ -644,7 +639,7 @@ files:
644
639
  - app/assets/stylesheets/caboose/icons.txt
645
640
  - app/assets/stylesheets/caboose/jquery.datetimepicker.css
646
641
  - app/assets/stylesheets/caboose/jquery.timepicker.css
647
- - app/assets/stylesheets/caboose/login.css
642
+ - app/assets/stylesheets/caboose/login.scss
648
643
  - app/assets/stylesheets/caboose/message_boxes.css.scss
649
644
  - app/assets/stylesheets/caboose/modal.css
650
645
  - app/assets/stylesheets/caboose/modal_inline.css
@@ -900,6 +895,9 @@ files:
900
895
  - app/views/caboose/application/under_construction.html.erb
901
896
  - app/views/caboose/assets/admin_ace.html.erb
902
897
  - app/views/caboose/assets/admin_index.html.erb
898
+ - app/views/caboose/block_type_categories/admin_edit.html.erb
899
+ - app/views/caboose/block_type_categories/admin_index.html.erb
900
+ - app/views/caboose/block_type_categories/admin_new.html.erb
903
901
  - app/views/caboose/block_type_sources/admin_edit.html.erb
904
902
  - app/views/caboose/block_type_sources/admin_index.html.erb
905
903
  - app/views/caboose/block_type_sources/admin_new.html.erb
@@ -1,184 +0,0 @@
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);
@@ -1,151 +0,0 @@
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/addresses',
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
- Caboose.Checkout = new CabooseCheckout();
151
-
@@ -1,306 +0,0 @@
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
- //