piggybak_variants 0.0.15 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -21,10 +21,6 @@ Finally, add `<%= variant_cart_form(@instance) %>` to your sellable item's show
|
|
21
21
|
|
22
22
|
OPTION: `<%= variant_cart_form(@instance, :controls => 'dropdowns') %>` to render dropdowns instead of radio buttons.
|
23
23
|
|
24
|
-
In your `config/environments/production.rb`, add the following line to allow pre-compilation of piggybak_variants.js:
|
25
|
-
|
26
|
-
config.assets.precompile += %w(piggybak_variants/piggybak_variants.js)
|
27
|
-
|
28
24
|
So either add that line, or if you already have it enabled just add `piggybak_variants/piggybak_variants.js` to the array of values.
|
29
25
|
|
30
26
|
TODO
|
@@ -1,66 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
$('#variant_price span').html(variant_map[selected_key].price);
|
9
|
-
} else { // if variant not available
|
10
|
-
$('.variant_options form').hide();
|
11
|
-
$('.unavailable').show();
|
12
|
-
}
|
13
|
-
} else { // if not all selected
|
14
|
-
$('.all_selected').show();
|
15
|
-
$('.variant_options form').hide();
|
16
|
-
}
|
17
|
-
},
|
18
|
-
extractRadioButtonValues: function() {
|
19
|
-
var all_selected = true;
|
20
|
-
var selected = new Array();
|
21
|
-
$.each($('.option'), function(i, j) {
|
22
|
-
var option_id = $(j).attr('id');
|
23
|
-
if($('input[name=' + option_id + ']:checked').length) {
|
24
|
-
selected.push($('input[name=' + option_id + ']:checked').val());
|
25
|
-
} else {
|
26
|
-
all_selected = false;
|
27
|
-
}
|
28
|
-
});
|
29
|
-
return { all_selected: all_selected, selected: selected };
|
30
|
-
},
|
31
|
-
extractDropdownValues: function() {
|
32
|
-
var all_selected = true;
|
33
|
-
// TODO: Nice to see if easier way to select by value, but select[value=""] doesn't work
|
34
|
-
$('.variant_options select').each(function() {
|
35
|
-
if ($(this).val() == '') {
|
36
|
-
all_selected = false;
|
37
|
-
}
|
38
|
-
});
|
39
|
-
if(!all_selected) {
|
40
|
-
return { all_selected: false, selected: '' };
|
41
|
-
}
|
42
|
-
|
43
|
-
var selected = new Array();
|
44
|
-
$.each($('.variant_options .option select'), function(i, j) {
|
45
|
-
selected.push($(this).val());
|
46
|
-
});
|
47
|
-
return { all_selected: true, selected: selected};
|
48
|
-
},
|
49
|
-
toggleVariantForm : function() {
|
50
|
-
$('.unavailable, .all_selected').hide();
|
51
|
-
var data;
|
52
|
-
if ($('.variant_options input[type=radio]').length > 0){
|
53
|
-
data = piggybak_variants.extractRadioButtonValues();
|
54
|
-
} else {
|
55
|
-
data = piggybak_variants.extractDropdownValues();
|
56
|
-
};
|
57
|
-
piggybak_variants.refreshControls(data);
|
58
|
-
}
|
59
|
-
}
|
60
|
-
|
61
|
-
$(function() {
|
62
|
-
$('.variant_options input[type=radio]').click(function() { piggybak_variants.toggleVariantForm(); });
|
63
|
-
$('.variant_options select').change(function() { piggybak_variants.toggleVariantForm(); });
|
64
|
-
piggybak_variants.toggleVariantForm();
|
65
|
-
});
|
66
|
-
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
// the compiled file.
|
6
|
+
//
|
7
|
+
//= require_tree .
|
@@ -0,0 +1,66 @@
|
|
1
|
+
var piggybak_variants = {
|
2
|
+
refreshControls : function(data) {
|
3
|
+
if(data.all_selected) { // if all selected
|
4
|
+
var selected_key = data.selected.sort().join('_');
|
5
|
+
if(variant_map[selected_key]) {
|
6
|
+
$('.variant_options form').show();
|
7
|
+
$('#sellable_id').val(variant_map[selected_key].id);
|
8
|
+
$('#variant_price span').html(variant_map[selected_key].price);
|
9
|
+
} else { // if variant not available
|
10
|
+
$('.variant_options form').hide();
|
11
|
+
$('.unavailable').show();
|
12
|
+
}
|
13
|
+
} else { // if not all selected
|
14
|
+
$('.all_selected').show();
|
15
|
+
$('.variant_options form').hide();
|
16
|
+
}
|
17
|
+
},
|
18
|
+
extractRadioButtonValues: function() {
|
19
|
+
var all_selected = true;
|
20
|
+
var selected = new Array();
|
21
|
+
$.each($('.option'), function(i, j) {
|
22
|
+
var option_id = $(j).attr('id');
|
23
|
+
if($('input[name=' + option_id + ']:checked').length) {
|
24
|
+
selected.push($('input[name=' + option_id + ']:checked').val());
|
25
|
+
} else {
|
26
|
+
all_selected = false;
|
27
|
+
}
|
28
|
+
});
|
29
|
+
return { all_selected: all_selected, selected: selected };
|
30
|
+
},
|
31
|
+
extractDropdownValues: function() {
|
32
|
+
var all_selected = true;
|
33
|
+
// TODO: Nice to see if easier way to select by value, but select[value=""] doesn't work
|
34
|
+
$('.variant_options select').each(function() {
|
35
|
+
if ($(this).val() == '') {
|
36
|
+
all_selected = false;
|
37
|
+
}
|
38
|
+
});
|
39
|
+
if(!all_selected) {
|
40
|
+
return { all_selected: false, selected: '' };
|
41
|
+
}
|
42
|
+
|
43
|
+
var selected = new Array();
|
44
|
+
$.each($('.variant_options .option select'), function(i, j) {
|
45
|
+
selected.push($(this).val());
|
46
|
+
});
|
47
|
+
return { all_selected: true, selected: selected};
|
48
|
+
},
|
49
|
+
toggleVariantForm : function() {
|
50
|
+
$('.unavailable, .all_selected').hide();
|
51
|
+
var data;
|
52
|
+
if ($('.variant_options input[type=radio]').length > 0){
|
53
|
+
data = piggybak_variants.extractRadioButtonValues();
|
54
|
+
} else {
|
55
|
+
data = piggybak_variants.extractDropdownValues();
|
56
|
+
};
|
57
|
+
piggybak_variants.refreshControls(data);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
$(function() {
|
62
|
+
$('.variant_options input[type=radio]').click(function() { piggybak_variants.toggleVariantForm(); });
|
63
|
+
$('.variant_options select').change(function() { piggybak_variants.toggleVariantForm(); });
|
64
|
+
piggybak_variants.toggleVariantForm();
|
65
|
+
});
|
66
|
+
|
@@ -19,7 +19,7 @@ module PiggybakVariants
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
initializer "piggybak_variants.precompile_hook" do |app|
|
22
|
+
initializer "piggybak_variants.precompile_hook", :group => :all do |app|
|
23
23
|
app.config.assets.precompile += ['piggybak_variants/piggybak_variants.js']
|
24
24
|
end
|
25
25
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: piggybak_variants
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -27,69 +27,72 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 3.2.3
|
30
|
-
description:
|
30
|
+
description: ! 'Adds variant support to Piggybak. Variants are options for a product
|
31
|
+
(i.e. small, medium, large, red, blue, green) variants can be configured to display
|
32
|
+
as either radio btns or selects '
|
31
33
|
email:
|
32
34
|
- piggybak@endpoint.com
|
33
35
|
executables: []
|
34
36
|
extensions: []
|
35
37
|
extra_rdoc_files: []
|
36
38
|
files:
|
37
|
-
- app/controllers/piggybak_variants/application_controller.rb
|
38
|
-
- app/assets/stylesheets/piggybak_variants/application.css
|
39
39
|
- app/assets/javascripts/piggybak_variants/piggybak_variants.js
|
40
|
-
- app/
|
41
|
-
- app/
|
40
|
+
- app/assets/javascripts/piggybak_variants/product_show.js
|
41
|
+
- app/assets/stylesheets/piggybak_variants/application.css
|
42
|
+
- app/controllers/piggybak_variants/application_controller.rb
|
43
|
+
- app/helpers/piggybak_variants_helper.rb
|
42
44
|
- app/models/piggybak_variants/option.rb
|
45
|
+
- app/models/piggybak_variants/option_configuration.rb
|
43
46
|
- app/models/piggybak_variants/option_value.rb
|
44
|
-
- app/
|
45
|
-
- app/views/rails_admin/main/_option_values.html.haml
|
47
|
+
- app/models/piggybak_variants/variant.rb
|
46
48
|
- app/views/piggybak_variants/cart/_dropdowns_form.html.erb
|
47
49
|
- app/views/piggybak_variants/cart/_radio_buttons_form.html.erb
|
50
|
+
- app/views/rails_admin/main/_option_values.html.haml
|
48
51
|
- config/routes.rb
|
52
|
+
- db/migrate/20121015144538_create_new_variants.rb
|
49
53
|
- db/migrate/20121016150359_create_options.rb
|
50
|
-
- db/migrate/20121022205428_create_option_configurations.rb
|
51
54
|
- db/migrate/20121016153016_create_option_values.rb
|
52
55
|
- db/migrate/20121016161156_create_option_values_variants.rb
|
53
|
-
- db/migrate/
|
54
|
-
- lib/piggybak_variants.rb
|
55
|
-
- lib/piggybak_variants/engine.rb
|
56
|
-
- lib/piggybak_variants/version.rb
|
56
|
+
- db/migrate/20121022205428_create_option_configurations.rb
|
57
57
|
- lib/acts_as_sellable_with_variants.rb
|
58
58
|
- lib/associated_bubbling_validator.rb
|
59
|
+
- lib/piggybak_variants/engine.rb
|
60
|
+
- lib/piggybak_variants/version.rb
|
61
|
+
- lib/piggybak_variants.rb
|
59
62
|
- MIT-LICENSE
|
60
63
|
- Rakefile
|
61
64
|
- README.md
|
62
|
-
- test/integration/navigation_test.rb
|
63
|
-
- test/piggybak_variants_test.rb
|
64
|
-
- test/test_helper.rb
|
65
|
-
- test/dummy/script/rails
|
66
|
-
- test/dummy/Rakefile
|
67
|
-
- test/dummy/README.rdoc
|
68
|
-
- test/dummy/app/controllers/application_controller.rb
|
69
|
-
- test/dummy/app/assets/stylesheets/application.css
|
70
65
|
- test/dummy/app/assets/javascripts/application.js
|
66
|
+
- test/dummy/app/assets/stylesheets/application.css
|
67
|
+
- test/dummy/app/controllers/application_controller.rb
|
71
68
|
- test/dummy/app/helpers/application_helper.rb
|
72
69
|
- test/dummy/app/views/layouts/application.html.erb
|
73
|
-
- test/dummy/config/
|
70
|
+
- test/dummy/config/application.rb
|
71
|
+
- test/dummy/config/boot.rb
|
72
|
+
- test/dummy/config/database.yml
|
74
73
|
- test/dummy/config/environment.rb
|
75
|
-
- test/dummy/config/
|
74
|
+
- test/dummy/config/environments/development.rb
|
76
75
|
- test/dummy/config/environments/production.rb
|
77
76
|
- test/dummy/config/environments/test.rb
|
78
|
-
- test/dummy/config/environments/development.rb
|
79
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
80
|
-
- test/dummy/config/initializers/secret_token.rb
|
81
|
-
- test/dummy/config/initializers/mime_types.rb
|
82
|
-
- test/dummy/config/initializers/session_store.rb
|
83
77
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
84
78
|
- test/dummy/config/initializers/inflections.rb
|
85
|
-
- test/dummy/config/
|
86
|
-
- test/dummy/config/
|
87
|
-
- test/dummy/config/
|
88
|
-
- test/dummy/
|
79
|
+
- test/dummy/config/initializers/mime_types.rb
|
80
|
+
- test/dummy/config/initializers/secret_token.rb
|
81
|
+
- test/dummy/config/initializers/session_store.rb
|
82
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
83
|
+
- test/dummy/config/locales/en.yml
|
84
|
+
- test/dummy/config/routes.rb
|
85
|
+
- test/dummy/config.ru
|
86
|
+
- test/dummy/public/404.html
|
89
87
|
- test/dummy/public/422.html
|
88
|
+
- test/dummy/public/500.html
|
90
89
|
- test/dummy/public/favicon.ico
|
91
|
-
- test/dummy/
|
92
|
-
- test/dummy/
|
90
|
+
- test/dummy/Rakefile
|
91
|
+
- test/dummy/README.rdoc
|
92
|
+
- test/dummy/script/rails
|
93
|
+
- test/integration/navigation_test.rb
|
94
|
+
- test/piggybak_variants_test.rb
|
95
|
+
- test/test_helper.rb
|
93
96
|
homepage: http://www.piggybak.org
|
94
97
|
licenses: []
|
95
98
|
post_install_message:
|
@@ -102,53 +105,47 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
105
|
- - ! '>='
|
103
106
|
- !ruby/object:Gem::Version
|
104
107
|
version: '0'
|
105
|
-
segments:
|
106
|
-
- 0
|
107
|
-
hash: 4072402557057022978
|
108
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
109
|
none: false
|
110
110
|
requirements:
|
111
111
|
- - ! '>='
|
112
112
|
- !ruby/object:Gem::Version
|
113
113
|
version: '0'
|
114
|
-
segments:
|
115
|
-
- 0
|
116
|
-
hash: 4072402557057022978
|
117
114
|
requirements: []
|
118
115
|
rubyforge_project:
|
119
|
-
rubygems_version: 1.8.
|
116
|
+
rubygems_version: 1.8.24
|
120
117
|
signing_key:
|
121
118
|
specification_version: 3
|
122
119
|
summary: Advanced variant support for Piggybak.
|
123
120
|
test_files:
|
124
|
-
- test/integration/navigation_test.rb
|
125
|
-
- test/piggybak_variants_test.rb
|
126
|
-
- test/test_helper.rb
|
127
|
-
- test/dummy/script/rails
|
128
|
-
- test/dummy/Rakefile
|
129
|
-
- test/dummy/README.rdoc
|
130
|
-
- test/dummy/app/controllers/application_controller.rb
|
131
|
-
- test/dummy/app/assets/stylesheets/application.css
|
132
121
|
- test/dummy/app/assets/javascripts/application.js
|
122
|
+
- test/dummy/app/assets/stylesheets/application.css
|
123
|
+
- test/dummy/app/controllers/application_controller.rb
|
133
124
|
- test/dummy/app/helpers/application_helper.rb
|
134
125
|
- test/dummy/app/views/layouts/application.html.erb
|
135
|
-
- test/dummy/config/
|
126
|
+
- test/dummy/config/application.rb
|
127
|
+
- test/dummy/config/boot.rb
|
128
|
+
- test/dummy/config/database.yml
|
136
129
|
- test/dummy/config/environment.rb
|
137
|
-
- test/dummy/config/
|
130
|
+
- test/dummy/config/environments/development.rb
|
138
131
|
- test/dummy/config/environments/production.rb
|
139
132
|
- test/dummy/config/environments/test.rb
|
140
|
-
- test/dummy/config/environments/development.rb
|
141
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
142
|
-
- test/dummy/config/initializers/secret_token.rb
|
143
|
-
- test/dummy/config/initializers/mime_types.rb
|
144
|
-
- test/dummy/config/initializers/session_store.rb
|
145
133
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
146
134
|
- test/dummy/config/initializers/inflections.rb
|
147
|
-
- test/dummy/config/
|
148
|
-
- test/dummy/config/
|
149
|
-
- test/dummy/config/
|
150
|
-
- test/dummy/
|
135
|
+
- test/dummy/config/initializers/mime_types.rb
|
136
|
+
- test/dummy/config/initializers/secret_token.rb
|
137
|
+
- test/dummy/config/initializers/session_store.rb
|
138
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
139
|
+
- test/dummy/config/locales/en.yml
|
140
|
+
- test/dummy/config/routes.rb
|
141
|
+
- test/dummy/config.ru
|
142
|
+
- test/dummy/public/404.html
|
151
143
|
- test/dummy/public/422.html
|
144
|
+
- test/dummy/public/500.html
|
152
145
|
- test/dummy/public/favicon.ico
|
153
|
-
- test/dummy/
|
154
|
-
- test/dummy/
|
146
|
+
- test/dummy/Rakefile
|
147
|
+
- test/dummy/README.rdoc
|
148
|
+
- test/dummy/script/rails
|
149
|
+
- test/integration/navigation_test.rb
|
150
|
+
- test/piggybak_variants_test.rb
|
151
|
+
- test/test_helper.rb
|