spree_minicart 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.bundle/config +2 -0
- data/.gitignore +12 -0
- data/.rspec +1 -0
- data/.sass-cache/7039e9d658d15c788901d448e30f792de6523f14/screen.css.scssc +0 -0
- data/Gemfile +22 -0
- data/LICENSE +26 -0
- data/README.md +87 -0
- data/Rakefile +29 -0
- data/Versionfile +9 -0
- data/app/assets/javascripts/admin/spree_minicart.js +1 -0
- data/app/assets/javascripts/store/spree_minicart.js +55 -0
- data/app/assets/stylesheets/admin/spree_minicart.css +3 -0
- data/app/assets/stylesheets/store/spree_minicart.css +67 -0
- data/app/controllers/orders_controller_decorator.rb +5 -0
- data/app/overrides/layout.rb +5 -0
- data/app/overrides/minicart.rb +11 -0
- data/app/views/spree/orders/populate.js.erb +14 -0
- data/app/views/spree/orders/update.js.erb +7 -0
- data/app/views/spree/shared/_minicart.html.erb +39 -0
- data/app/views/spree/shared/_minicart_line_items.html.erb +32 -0
- data/config/locales/en.yml +6 -0
- data/config/routes.rb +3 -0
- data/lib/assets/javascripts/store/jquery.hoverintent.js +70 -0
- data/lib/generators/spree_minicart/install/install_generator.rb +14 -0
- data/lib/spree_minicart/engine.rb +20 -0
- data/lib/spree_minicart.rb +2 -0
- data/script/rails +5 -0
- data/spec/requests/minicart_spec.rb +43 -0
- data/spec/spec_helper.rb +33 -0
- data/spec/support/shared_connection.rb +12 -0
- data/spec/support/url_helpers.rb +7 -0
- data/spree_minicart.gemspec +27 -0
- metadata +160 -0
data/.bundle/config
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/Gemfile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'mysql2'
|
4
|
+
group :test do
|
5
|
+
gem 'ffaker'
|
6
|
+
gem 'rspec-rails'
|
7
|
+
gem 'capybara'
|
8
|
+
gem 'launchy', '2.0.5'
|
9
|
+
end
|
10
|
+
|
11
|
+
if RUBY_VERSION < "1.9"
|
12
|
+
gem "ruby-debug"
|
13
|
+
else
|
14
|
+
gem "ruby-debug19"
|
15
|
+
end
|
16
|
+
|
17
|
+
group :assets do
|
18
|
+
gem 'sass-rails', '~> 3.1.5'
|
19
|
+
gem 'uglifier', '>= 1.0.3'
|
20
|
+
end
|
21
|
+
|
22
|
+
gemspec
|
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Copyright (c) 2012 [name of plugin creator]
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
* Neither the name Spree nor the names of its contributors may be used to
|
13
|
+
endorse or promote products derived from this software without specific
|
14
|
+
prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
20
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
SpreeMinicart
|
2
|
+
=============
|
3
|
+
|
4
|
+
Minicart feature extracted from [http://www.501kfactory.com](http://www.501kfactory.com).
|
5
|
+
|
6
|
+
Your shopping cart is an incredibly important part of your e-commerce website.
|
7
|
+
|
8
|
+
Minicart allows customer to add/remove an item from their cart without ever leaving the page they're on.
|
9
|
+
Let your customers preview their cart before they start the checkout process.
|
10
|
+
|
11
|
+
Installation
|
12
|
+
------------
|
13
|
+
|
14
|
+
To install Spree Minicart, just add the following to your Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'spree_minicart', '0.0.1'
|
18
|
+
```
|
19
|
+
|
20
|
+
Now, bundle up with:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
bundle
|
24
|
+
```
|
25
|
+
|
26
|
+
And finally run the install generator to automatically insert 'require store/spree_minicart' in your asset file.
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
rails g spree_minicart:install
|
30
|
+
```
|
31
|
+
|
32
|
+
Make sure manifest is inserted correctly, it should look like :
|
33
|
+
- app/assets/stylesheets/store/all.css :
|
34
|
+
|
35
|
+
```css
|
36
|
+
/*
|
37
|
+
*= require store/spree_core
|
38
|
+
*= require store/spree_auth
|
39
|
+
*= require store/spree_api
|
40
|
+
*= require store/spree_promo
|
41
|
+
|
42
|
+
*= require store/spree_minicart
|
43
|
+
*/
|
44
|
+
```
|
45
|
+
|
46
|
+
- app/assets/javascripts/store/all.js :
|
47
|
+
|
48
|
+
```javascript
|
49
|
+
//= require store/spree_core
|
50
|
+
//= require store/spree_auth
|
51
|
+
//= require store/spree_api
|
52
|
+
//= require store/spree_promo
|
53
|
+
//= require store/spree_minicart
|
54
|
+
```
|
55
|
+
|
56
|
+
Example
|
57
|
+
-------
|
58
|
+
|
59
|
+
![Spree Minicart](http://i41.tinypic.com/2n8zszs.png)
|
60
|
+
|
61
|
+
Todo
|
62
|
+
-------
|
63
|
+
|
64
|
+
- Better html markup and HTML test for customization
|
65
|
+
- Better css design
|
66
|
+
- Can update minicart's item quantity
|
67
|
+
|
68
|
+
Testing
|
69
|
+
-------
|
70
|
+
|
71
|
+
Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.
|
72
|
+
|
73
|
+
$ bundle
|
74
|
+
$ bundle exec rake test app
|
75
|
+
$ bundle exec rspec spec
|
76
|
+
|
77
|
+
Compatibility
|
78
|
+
------------
|
79
|
+
|
80
|
+
Tested under Spree 1.0.0
|
81
|
+
|
82
|
+
Contribute
|
83
|
+
----------
|
84
|
+
|
85
|
+
Pull requests for features and bug fix with tests are welcome.
|
86
|
+
|
87
|
+
Copyright (c) 2012 [Stéphane Bounmy], released under the New BSD License
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/packagetask'
|
4
|
+
require 'rubygems/package_task'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
require 'spree/core/testing_support/common_rake'
|
7
|
+
|
8
|
+
RSpec::Core::RakeTask.new
|
9
|
+
|
10
|
+
task :default => [:spec]
|
11
|
+
|
12
|
+
spec = eval(File.read('spree_minicart.gemspec'))
|
13
|
+
|
14
|
+
Gem::PackageTask.new(spec) do |p|
|
15
|
+
p.gem_spec = spec
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Release to gemcutter"
|
19
|
+
task :release => :package do
|
20
|
+
require 'rake/gemcutter'
|
21
|
+
Rake::Gemcutter::Tasks.new(spec).define
|
22
|
+
Rake::Task['gem:push'].invoke
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Generates a dummy app for testing"
|
26
|
+
task :test_app do
|
27
|
+
ENV['LIB_NAME'] = 'spree_minicart'
|
28
|
+
Rake::Task['common:test_app'].invoke
|
29
|
+
end
|
data/Versionfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# This file is used to designate compatibilty with different versions of Spree
|
2
|
+
# Please see http://spreecommerce.com/documentation/extensions.html#versionfile for details
|
3
|
+
|
4
|
+
# Examples
|
5
|
+
#
|
6
|
+
# "0.70.x" => { :branch => "master"}
|
7
|
+
# "0.60.x" => { :branch => "0-60-stable" }
|
8
|
+
# "0.40.x" => { :tag => "v1.0.0", :version => "1.0.0" }
|
9
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require admin/spree_core
|
@@ -0,0 +1,55 @@
|
|
1
|
+
//= require store/spree_core
|
2
|
+
//= require store/jquery.hoverintent
|
3
|
+
|
4
|
+
(function($){
|
5
|
+
$(document).ready(function(){
|
6
|
+
var config = {
|
7
|
+
over: function(){
|
8
|
+
$("#minicart").slideDown();
|
9
|
+
},
|
10
|
+
timeout: 250, // number = milliseconds delay before onMouseOut
|
11
|
+
out: function(){
|
12
|
+
$("#minicart").slideUp();
|
13
|
+
}
|
14
|
+
};
|
15
|
+
|
16
|
+
$("#link-to-cart").hoverIntent( config )
|
17
|
+
|
18
|
+
// hoverintent items created by js http://rndnext.blogspot.com/2009/02/jquery-live-and-plugins.html
|
19
|
+
$("ul#minicart-items li").live('mouseover', function(e)
|
20
|
+
{
|
21
|
+
if (!$(this).data('init'))
|
22
|
+
{
|
23
|
+
$(this).data('init', true);
|
24
|
+
$(this).hoverIntent
|
25
|
+
({
|
26
|
+
over: function(){
|
27
|
+
$(this).find("[data-hook='cart_item_description']").hide()
|
28
|
+
$(this).find("[data-hook='cart_item_actions']").show()
|
29
|
+
},
|
30
|
+
timeout: 100, // number = milliseconds delay before onMouseOut
|
31
|
+
out: function(){
|
32
|
+
$(this).find("[data-hook='cart_item_description']").show()
|
33
|
+
$(this).find("[data-hook='cart_item_actions']").hide()
|
34
|
+
}
|
35
|
+
});
|
36
|
+
$(this).trigger(e);
|
37
|
+
}
|
38
|
+
});
|
39
|
+
|
40
|
+
|
41
|
+
$('form#update-minicart a.delete').live('click', function(e){
|
42
|
+
$(this).parent().siblings('div[data-hook="cart_item_quantity"]').find("input.line_item_quantity").val(0);
|
43
|
+
$(this).parents('form').first().submit();
|
44
|
+
e.preventDefault();
|
45
|
+
});
|
46
|
+
|
47
|
+
$("form[data-remote]").live("ajax:beforeSend", function(){
|
48
|
+
$("#progress").slideDown();
|
49
|
+
})
|
50
|
+
|
51
|
+
$("form[data-remote]").live("ajax:complete", function(){
|
52
|
+
$("#progress").slideUp();
|
53
|
+
})
|
54
|
+
});
|
55
|
+
})(jQuery);
|
@@ -0,0 +1,67 @@
|
|
1
|
+
/*
|
2
|
+
*= require store/spree_core
|
3
|
+
*/
|
4
|
+
|
5
|
+
#progress {
|
6
|
+
display:none;
|
7
|
+
z-index: 99;
|
8
|
+
top: 0px;
|
9
|
+
text-align: center;
|
10
|
+
background: #00ADEE;
|
11
|
+
padding: 4px 10px;
|
12
|
+
color: white;
|
13
|
+
margin: 0 auto;
|
14
|
+
position: fixed;
|
15
|
+
left:50%;
|
16
|
+
}
|
17
|
+
|
18
|
+
nav #main-nav-bar li#link-to-cart #minicart a{
|
19
|
+
font-size: 12px
|
20
|
+
}
|
21
|
+
|
22
|
+
nav #main-nav-bar li#link-to-cart #minicart a.button{
|
23
|
+
font-size: 12px;
|
24
|
+
color: white !important;
|
25
|
+
}
|
26
|
+
|
27
|
+
ul#minicart-items {
|
28
|
+
margin: 0 10px;
|
29
|
+
}
|
30
|
+
|
31
|
+
|
32
|
+
ul#minicart-items li{
|
33
|
+
width: 90px;
|
34
|
+
position: relative;
|
35
|
+
float: left;
|
36
|
+
min-height: 180px;
|
37
|
+
padding: 5px 10px 0;
|
38
|
+
text-align: center;
|
39
|
+
text-transform: none;
|
40
|
+
}
|
41
|
+
|
42
|
+
#minicart {
|
43
|
+
background-color:aliceBlue;
|
44
|
+
z-index: 100;
|
45
|
+
position: absolute;
|
46
|
+
right: 16px;
|
47
|
+
padding: 10px;
|
48
|
+
border: 1px solid #DEDEDE;
|
49
|
+
float:right;
|
50
|
+
display: none;
|
51
|
+
width: 300px;
|
52
|
+
}
|
53
|
+
ul#minicart-items li img{
|
54
|
+
display: block;
|
55
|
+
margin-left: 20px;
|
56
|
+
}
|
57
|
+
|
58
|
+
#minicart div#minicart-details a.button.checkout{
|
59
|
+
float:right;
|
60
|
+
}
|
61
|
+
|
62
|
+
#link-to-cart span.amount {
|
63
|
+
display: none;
|
64
|
+
}
|
65
|
+
#minicart .minicart-actions {
|
66
|
+
display: none;
|
67
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Deface::Override.new(:virtual_path => 'spree/shared/_store_menu',
|
2
|
+
:name => 'add_mini_cart',
|
3
|
+
:insert_bottom => "#link-to-cart",
|
4
|
+
:partial => "spree/shared/minicart")
|
5
|
+
|
6
|
+
Deface::Override.new(:virtual_path => 'spree/products/_cart_form',
|
7
|
+
:name => 'set_remote_to_true_to_add_to_cart',
|
8
|
+
:replace => "code[erb-loud]:contains('form_for :order, :url => populate_orders_url do |f|')",
|
9
|
+
:text => "<%= form_for :order, :url => populate_orders_url, :remote => true do |f| %>",
|
10
|
+
:original => "<%= form_for :order, :url => populate_orders_url do |f| %>")
|
11
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
// Refresh minicart count
|
2
|
+
$("#link-to-cart a").replaceWith('<%= escape_javascript link_to_cart %>')
|
3
|
+
|
4
|
+
// Refresh minicart line items
|
5
|
+
$("#minicart").replaceWith('<%= escape_javascript render("spree/shared/minicart") %>')
|
6
|
+
|
7
|
+
// Sliding down minicart
|
8
|
+
$("#link-to-cart #minicart").slideDown()
|
9
|
+
|
10
|
+
// Sliding up minicart
|
11
|
+
setTimeout(function () {
|
12
|
+
$("#link-to-cart #minicart").slideUp()
|
13
|
+
},
|
14
|
+
5000);
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<% @order ||= current_order(true) %>
|
2
|
+
<div id="minicart">
|
3
|
+
<% @body_id = 'cart' %>
|
4
|
+
|
5
|
+
<% if @order.line_items.empty? %>
|
6
|
+
|
7
|
+
<div data-hook="empty_cart">
|
8
|
+
<p><%= t(:your_cart_is_empty) %></p>
|
9
|
+
<p><%= link_to t(:continue_shopping), products_path, :class => 'button continue' %></p>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<% else %>
|
13
|
+
<div data-hook="outside_cart_form">
|
14
|
+
<div id="minicart-details" data-hook="minicart_details" class="clearfix">
|
15
|
+
<p>
|
16
|
+
<span><%= t(:subtotal) %>: <span class="order-total"><%= order_subtotal(@order) %></span></span>
|
17
|
+
<%= link_to t(:checkout), checkout_path, :class => 'button checkout primary', :id => 'checkout-link' %>
|
18
|
+
</p>
|
19
|
+
</div>
|
20
|
+
<%= form_for @order, :url => update_cart_path, :html => {:id => 'update-minicart'}, :remote => true do |order_form| %>
|
21
|
+
<div data-hook="inside_cart_form">
|
22
|
+
|
23
|
+
<div data-hook="cart_items" class="clearfix">
|
24
|
+
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @order } %>
|
25
|
+
<ul id='minicart-items' class="clearfix">
|
26
|
+
<%= order_form.fields_for :line_items do |item_form| %>
|
27
|
+
<%= render :partial => 'spree/shared/minicart_line_items', :locals => { :variant => item_form.object.variant, :line_item => item_form.object, :item_form => item_form } %>
|
28
|
+
<% end %>
|
29
|
+
</ul>
|
30
|
+
</div>
|
31
|
+
<div id="minicart-footer" data-hook="minicart_footer">
|
32
|
+
<p><%= link_to t("view_shopping_cart"), cart_path, :class => 'button cart' %></p>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
<% end %>
|
36
|
+
</div>
|
37
|
+
<% end %>
|
38
|
+
|
39
|
+
</div>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<li class="<%= cycle('', 'alt') %>">
|
2
|
+
<div data-hook="minicart_item_image">
|
3
|
+
<% if variant.images.length == 0 %>
|
4
|
+
<%= link_to mini_image(variant.product), variant.product %>
|
5
|
+
<% else %>
|
6
|
+
<%= link_to image_tag(variant.images.first.attachment.url(:mini)), variant.product %>
|
7
|
+
<% end %>
|
8
|
+
</div>
|
9
|
+
<div data-hook="cart_item_description">
|
10
|
+
<div data-hook="cart_item_name">
|
11
|
+
<span><%= link_to variant.product.name, product_path(variant.product) %></span>
|
12
|
+
<span><%= "x#{line_item.quantity}" -%></span>
|
13
|
+
<%= variant.options_text %>
|
14
|
+
<% if @order.insufficient_stock_lines.include? line_item %>
|
15
|
+
<span class="out-of-stock">
|
16
|
+
<%= variant.in_stock? ? t(:insufficient_stock, :on_hand => variant.on_hand) : t(:out_of_stock) %><br />
|
17
|
+
</span>
|
18
|
+
<% end %>
|
19
|
+
</div>
|
20
|
+
<div data-hook="cart_item_total">
|
21
|
+
<%= number_to_currency(line_item.price * line_item.quantity) unless line_item.quantity.nil? %>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
<div class='minicart-actions' data-hook="cart_item_actions">
|
25
|
+
<div data-hook="cart_item_quantity">
|
26
|
+
<%= item_form.hidden_field :quantity, :min => 0, :class => "line_item_quantity" %>
|
27
|
+
</div>
|
28
|
+
<div data-hook="cart_item_delete">
|
29
|
+
<%= link_to t("delete"), '#', :class => 'delete', :id => "delete_#{dom_id(line_item)}" %>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
</li>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
/**
|
2
|
+
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
|
3
|
+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
|
4
|
+
*
|
5
|
+
* @param f onMouseOver function || An object with configuration options
|
6
|
+
* @param g onMouseOut function || Nothing (use configuration options object)
|
7
|
+
* @author Brian Cherne brian(at)cherne(dot)net
|
8
|
+
*/
|
9
|
+
(function ($) {
|
10
|
+
$.fn.hoverIntent = function (f, g) {
|
11
|
+
var cfg = {
|
12
|
+
sensitivity: 7,
|
13
|
+
interval: 100,
|
14
|
+
timeout: 0
|
15
|
+
};
|
16
|
+
cfg = $.extend(cfg, g ? {
|
17
|
+
over: f,
|
18
|
+
out: g
|
19
|
+
} : f);
|
20
|
+
var cX, cY, pX, pY;
|
21
|
+
var track = function (ev) {
|
22
|
+
cX = ev.pageX;
|
23
|
+
cY = ev.pageY
|
24
|
+
};
|
25
|
+
var compare = function (ev, ob) {
|
26
|
+
ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
|
27
|
+
if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) {
|
28
|
+
$(ob).unbind("mousemove", track);
|
29
|
+
ob.hoverIntent_s = 1;
|
30
|
+
return cfg.over.apply(ob, [ev])
|
31
|
+
} else {
|
32
|
+
pX = cX;
|
33
|
+
pY = cY;
|
34
|
+
ob.hoverIntent_t = setTimeout(function () {
|
35
|
+
compare(ev, ob)
|
36
|
+
}, cfg.interval)
|
37
|
+
}
|
38
|
+
};
|
39
|
+
var delay = function (ev, ob) {
|
40
|
+
ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
|
41
|
+
ob.hoverIntent_s = 0;
|
42
|
+
return cfg.out.apply(ob, [ev])
|
43
|
+
};
|
44
|
+
var handleHover = function (e) {
|
45
|
+
var ev = jQuery.extend({}, e);
|
46
|
+
var ob = this;
|
47
|
+
if (ob.hoverIntent_t) {
|
48
|
+
ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t)
|
49
|
+
}
|
50
|
+
if (e.type == "mouseenter") {
|
51
|
+
pX = ev.pageX;
|
52
|
+
pY = ev.pageY;
|
53
|
+
$(ob).bind("mousemove", track);
|
54
|
+
if (ob.hoverIntent_s != 1) {
|
55
|
+
ob.hoverIntent_t = setTimeout(function () {
|
56
|
+
compare(ev, ob)
|
57
|
+
}, cfg.interval)
|
58
|
+
}
|
59
|
+
} else {
|
60
|
+
$(ob).unbind("mousemove", track);
|
61
|
+
if (ob.hoverIntent_s == 1) {
|
62
|
+
ob.hoverIntent_t = setTimeout(function () {
|
63
|
+
delay(ev, ob)
|
64
|
+
}, cfg.timeout)
|
65
|
+
}
|
66
|
+
}
|
67
|
+
};
|
68
|
+
return this.bind('mouseenter', handleHover).bind('mouseleave', handleHover)
|
69
|
+
}
|
70
|
+
})(jQuery);
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module SpreeMinicart
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
def add_javascripts
|
6
|
+
append_file "app/assets/javascripts/store/all.js", "//= require store/spree_minicart\n"
|
7
|
+
end
|
8
|
+
|
9
|
+
def add_stylesheets
|
10
|
+
inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_minicart\n", :before => /\*\//, :verbose => true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SpreeMinicart
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
engine_name 'spree_minicart'
|
4
|
+
|
5
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
6
|
+
|
7
|
+
# use rspec for tests
|
8
|
+
config.generators do |g|
|
9
|
+
g.test_framework :rspec
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.activate
|
13
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
|
14
|
+
Rails.configuration.cache_classes ? require(c) : load(c)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
config.to_prepare &method(:activate).to_proc
|
19
|
+
end
|
20
|
+
end
|
data/script/rails
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature "minicart", :js => true do
|
4
|
+
background { @product = Factory(:product, :name => "ror mug", :price => 30) }
|
5
|
+
|
6
|
+
scenario "customer should be able to add and delete a product in the minicart" do
|
7
|
+
visit spree.products_path
|
8
|
+
click_link("ror mug")
|
9
|
+
click_button "Add To Cart"
|
10
|
+
|
11
|
+
within("#link-to-cart a") do
|
12
|
+
page.should have_content("(1)")
|
13
|
+
end
|
14
|
+
|
15
|
+
within("#minicart") do
|
16
|
+
page.should have_content("ror mug")
|
17
|
+
page.should have_content("$30")
|
18
|
+
end
|
19
|
+
|
20
|
+
page.execute_script '$("#minicart-items li").trigger("mouseenter")'
|
21
|
+
within "li div.minicart-actions" do
|
22
|
+
page.should have_content("Delete")
|
23
|
+
# manually sliding down the minicart actions, dont know why its not working
|
24
|
+
page.execute_script '$("#minicart-items li div.minicart-actions").slideDown()'
|
25
|
+
click_link "Delete"
|
26
|
+
end
|
27
|
+
|
28
|
+
URI.parse(current_url).path.should =~ /products/
|
29
|
+
|
30
|
+
within("#minicart") do
|
31
|
+
page.should_not have_content("ror mug")
|
32
|
+
page.should_not have_content("$30")
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
scenario 'minicart should not freak out standard cart', :js => false do
|
38
|
+
visit spree.products_path
|
39
|
+
click_link("ror mug")
|
40
|
+
click_button "Add To Cart"
|
41
|
+
URI.parse(current_url).path.should == "/cart"
|
42
|
+
end
|
43
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
|
6
|
+
require 'rspec/rails'
|
7
|
+
|
8
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
9
|
+
# in spec/support/ and its subdirectories.
|
10
|
+
Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f }
|
11
|
+
|
12
|
+
# Requires factories defined in spree_core
|
13
|
+
require 'spree/core/testing_support/factories'
|
14
|
+
|
15
|
+
RSpec.configure do |config|
|
16
|
+
# == Mock Framework
|
17
|
+
#
|
18
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
19
|
+
#
|
20
|
+
# config.mock_with :mocha
|
21
|
+
# config.mock_with :flexmock
|
22
|
+
# config.mock_with :rr
|
23
|
+
config.mock_with :rspec
|
24
|
+
|
25
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
26
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
27
|
+
|
28
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
29
|
+
# examples within a transaction, remove the following line or assign false
|
30
|
+
# instead of true.
|
31
|
+
config.use_transactional_fixtures = true
|
32
|
+
config.include Spree::UrlHelpers
|
33
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class ActiveRecord::Base
|
2
|
+
mattr_accessor :shared_connection
|
3
|
+
@@shared_connection = nil
|
4
|
+
|
5
|
+
def self.connection
|
6
|
+
@@shared_connection || retrieve_connection
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
# Forces all threads to share the same connection. This works on
|
11
|
+
# Capybara because it starts the web server in a thread.
|
12
|
+
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.platform = Gem::Platform::RUBY
|
4
|
+
s.name = 'spree_minicart'
|
5
|
+
s.version = '0.0.1'
|
6
|
+
s.summary = 'Spree Minicart displays a minicart in your spree store'
|
7
|
+
s.description = "Spree Minicart allows customer to add/remove an item from their cart without ever leaving the page they're on.Let your customers preview their cart before they start the checkout process."
|
8
|
+
s.required_ruby_version = '>= 1.8.7'
|
9
|
+
|
10
|
+
s.author = 'Stéphane Bounmy'
|
11
|
+
s.email = 'stephanebounmy@gmail.com'
|
12
|
+
s.homepage = 'https://github.com/sbounmy/spree_minicart'
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.require_path = 'lib'
|
17
|
+
s.requirements << 'none'
|
18
|
+
|
19
|
+
s.add_dependency 'spree_core', '~> 1.0.0'
|
20
|
+
s.add_dependency 'spree_sample'
|
21
|
+
s.add_development_dependency 'capybara', '1.0.1'
|
22
|
+
s.add_development_dependency 'factory_girl'
|
23
|
+
s.add_development_dependency 'ffaker'
|
24
|
+
s.add_development_dependency 'rspec-rails', '~> 2.7'
|
25
|
+
s.add_development_dependency 'sqlite3'
|
26
|
+
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spree_minicart
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Stéphane Bounmy
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: spree_core
|
16
|
+
requirement: &2156547640 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2156547640
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: spree_sample
|
27
|
+
requirement: &2156547120 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2156547120
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: capybara
|
38
|
+
requirement: &2156546320 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - =
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.0.1
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2156546320
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: factory_girl
|
49
|
+
requirement: &2156544440 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2156544440
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: ffaker
|
60
|
+
requirement: &2156543720 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2156543720
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-rails
|
71
|
+
requirement: &2156542560 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '2.7'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2156542560
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: sqlite3
|
82
|
+
requirement: &2156541820 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *2156541820
|
91
|
+
description: Spree Minicart allows customer to add/remove an item from their cart
|
92
|
+
without ever leaving the page they're on.Let your customers preview their cart before
|
93
|
+
they start the checkout process.
|
94
|
+
email: stephanebounmy@gmail.com
|
95
|
+
executables: []
|
96
|
+
extensions: []
|
97
|
+
extra_rdoc_files: []
|
98
|
+
files:
|
99
|
+
- .bundle/config
|
100
|
+
- .gitignore
|
101
|
+
- .rspec
|
102
|
+
- .sass-cache/7039e9d658d15c788901d448e30f792de6523f14/screen.css.scssc
|
103
|
+
- Gemfile
|
104
|
+
- LICENSE
|
105
|
+
- README.md
|
106
|
+
- Rakefile
|
107
|
+
- Versionfile
|
108
|
+
- app/assets/javascripts/admin/spree_minicart.js
|
109
|
+
- app/assets/javascripts/store/spree_minicart.js
|
110
|
+
- app/assets/stylesheets/admin/spree_minicart.css
|
111
|
+
- app/assets/stylesheets/store/spree_minicart.css
|
112
|
+
- app/controllers/orders_controller_decorator.rb
|
113
|
+
- app/overrides/layout.rb
|
114
|
+
- app/overrides/minicart.rb
|
115
|
+
- app/views/spree/orders/populate.js.erb
|
116
|
+
- app/views/spree/orders/update.js.erb
|
117
|
+
- app/views/spree/shared/_minicart.html.erb
|
118
|
+
- app/views/spree/shared/_minicart_line_items.html.erb
|
119
|
+
- config/locales/en.yml
|
120
|
+
- config/routes.rb
|
121
|
+
- lib/assets/javascripts/store/jquery.hoverintent.js
|
122
|
+
- lib/generators/spree_minicart/install/install_generator.rb
|
123
|
+
- lib/spree_minicart.rb
|
124
|
+
- lib/spree_minicart/engine.rb
|
125
|
+
- script/rails
|
126
|
+
- spec/requests/minicart_spec.rb
|
127
|
+
- spec/spec_helper.rb
|
128
|
+
- spec/support/shared_connection.rb
|
129
|
+
- spec/support/url_helpers.rb
|
130
|
+
- spree_minicart.gemspec
|
131
|
+
homepage: https://github.com/sbounmy/spree_minicart
|
132
|
+
licenses: []
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ! '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: 1.8.7
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
145
|
+
requirements:
|
146
|
+
- - ! '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements:
|
150
|
+
- none
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 1.8.17
|
153
|
+
signing_key:
|
154
|
+
specification_version: 3
|
155
|
+
summary: Spree Minicart displays a minicart in your spree store
|
156
|
+
test_files:
|
157
|
+
- spec/requests/minicart_spec.rb
|
158
|
+
- spec/spec_helper.rb
|
159
|
+
- spec/support/shared_connection.rb
|
160
|
+
- spec/support/url_helpers.rb
|