spree_multi_slideshow 0.70.7 → 0.70.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -1
- data/app/assets/images/store/bx_loader.gif +0 -0
- data/app/assets/images/store/controls.png +0 -0
- data/app/assets/javascripts/admin/spree_multi_slideshow.js +1 -0
- data/app/assets/javascripts/store/spree_multi_slideshow.js +1159 -213
- data/app/assets/stylesheets/store/spree_multi_slideshow.css +202 -68
- data/app/controllers/admin/slides_controller.rb +5 -7
- data/app/controllers/admin/slideshow_types_controller.rb +2 -4
- data/app/helpers/slideshow_types_helper.rb +37 -40
- data/app/models/slide.rb +16 -7
- data/app/models/slideshow_type.rb +12 -7
- data/app/views/admin/shared/_slideshow_type_tabs.html.erb +5 -7
- data/app/views/admin/slides/_form.html.erb +15 -8
- data/app/views/admin/slides/edit.html.erb +5 -5
- data/app/views/admin/slides/index.html.erb +14 -15
- data/app/views/admin/slides/new.html.erb +2 -2
- data/app/views/admin/slideshow_types/_form.html.erb +40 -8
- data/app/views/admin/slideshow_types/edit.html.erb +6 -7
- data/app/views/admin/slideshow_types/index.html.erb +29 -29
- data/app/views/admin/slideshow_types/new.html.erb +47 -5
- data/app/views/admin/slideshow_types/new.js.erb +2 -0
- data/config/locales/it.yml +21 -22
- data/db/migrate/20120116081431_create_slideshow_types.rb +1 -1
- data/db/migrate/20130116143809_add_option_pagination.rb +13 -0
- data/lib/generators/spree_multi_slideshow/install/install_generator.rb +0 -9
- metadata +7 -19
@@ -2,72 +2,206 @@
|
|
2
2
|
*= require store/spree_core
|
3
3
|
*/
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
.
|
22
|
-
position:
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
}
|
70
|
-
|
71
|
-
|
72
|
-
|
5
|
+
/**
|
6
|
+
* BxSlider v4.0 - Fully loaded, responsive content slider
|
7
|
+
* http://bxslider.com
|
8
|
+
*
|
9
|
+
* Written by: Steven Wanderski, 2012
|
10
|
+
* http://stevenwanderski.com
|
11
|
+
* (while drinking Belgian ales and listening to jazz)
|
12
|
+
*
|
13
|
+
* CEO and founder of bxCreative, LTD
|
14
|
+
* http://bxcreative.com
|
15
|
+
*/
|
16
|
+
|
17
|
+
|
18
|
+
/** RESET AND LAYOUT
|
19
|
+
===================================*/
|
20
|
+
|
21
|
+
.bx-wrapper {
|
22
|
+
position: relative;
|
23
|
+
margin: 0 0 60px;
|
24
|
+
padding: 0;
|
25
|
+
*zoom: 1;
|
26
|
+
}
|
27
|
+
|
28
|
+
.bx-wrapper img {
|
29
|
+
width: 100%;
|
30
|
+
display: block;
|
31
|
+
}
|
32
|
+
|
33
|
+
/** THEME
|
34
|
+
===================================*/
|
35
|
+
|
36
|
+
.slideshow {
|
37
|
+
width: 960px;
|
38
|
+
min-height: 50px;
|
39
|
+
margin: auto;
|
40
|
+
}
|
41
|
+
.bxslider {
|
42
|
+
margin: 0px;
|
43
|
+
}
|
44
|
+
|
45
|
+
.bx-wrapper .bx-viewport {
|
46
|
+
-moz-box-shadow: 0 0 5px #ccc;
|
47
|
+
-webkit-box-shadow: 0 0 5px #ccc;
|
48
|
+
box-shadow: 0 0 5px #ccc;
|
49
|
+
}
|
50
|
+
|
51
|
+
.bx-wrapper .bx-pager,
|
52
|
+
.bx-wrapper .bx-controls-auto {
|
53
|
+
position: absolute;
|
54
|
+
bottom: -30px;
|
55
|
+
width: 100%;
|
56
|
+
}
|
57
|
+
|
58
|
+
/* LOADER */
|
59
|
+
|
60
|
+
.bx-wrapper .bx-loading {
|
61
|
+
min-height: 50px;
|
62
|
+
background: url(bx_loader.gif) center center no-repeat #fff;
|
63
|
+
height: 100%;
|
64
|
+
width: 100%;
|
65
|
+
position: absolute;
|
66
|
+
top: 0;
|
67
|
+
left: 0;
|
68
|
+
z-index: 2000;
|
69
|
+
}
|
70
|
+
|
71
|
+
/* PAGER */
|
72
|
+
|
73
|
+
.bx-wrapper .bx-pager {
|
74
|
+
text-align: center;
|
75
|
+
font-size: .85em;
|
76
|
+
font-family: Arial;
|
77
|
+
font-weight: bold;
|
78
|
+
color: #666;
|
79
|
+
padding-top: 20px;
|
80
|
+
}
|
81
|
+
|
82
|
+
.bx-wrapper .bx-pager .bx-pager-item,
|
83
|
+
.bx-wrapper .bx-controls-auto .bx-controls-auto-item {
|
84
|
+
display: inline-block;
|
85
|
+
*zoom: 1;
|
86
|
+
*display: inline;
|
87
|
+
}
|
88
|
+
|
89
|
+
.bx-wrapper .bx-pager.bx-default-pager a {
|
90
|
+
background: #666;
|
91
|
+
text-indent: -9999px;
|
92
|
+
display: block;
|
93
|
+
width: 10px;
|
94
|
+
height: 10px;
|
95
|
+
margin: 0 5px;
|
96
|
+
outline: 0;
|
97
|
+
-moz-border-radius: 5px;
|
98
|
+
-webkit-border-radius: 5px;
|
99
|
+
border-radius: 5px;
|
100
|
+
}
|
101
|
+
|
102
|
+
.bx-wrapper .bx-pager.bx-default-pager a:hover,
|
103
|
+
.bx-wrapper .bx-pager.bx-default-pager a.active {
|
104
|
+
background: #000;
|
105
|
+
}
|
106
|
+
|
107
|
+
/* DIRECTION CONTROLS (NEXT / PREV) */
|
108
|
+
|
109
|
+
.bx-wrapper .bx-prev {
|
110
|
+
left: 10px;
|
111
|
+
background: url(controls.png) no-repeat 0 -32px;
|
112
|
+
}
|
113
|
+
|
114
|
+
.bx-wrapper .bx-next {
|
115
|
+
right: 10px;
|
116
|
+
background: url(controls.png) no-repeat -43px -32px;
|
117
|
+
}
|
118
|
+
|
119
|
+
.bx-wrapper .bx-prev:hover {
|
120
|
+
background-position: 0 0;
|
121
|
+
}
|
122
|
+
|
123
|
+
.bx-wrapper .bx-next:hover {
|
124
|
+
background-position: -43px 0;
|
125
|
+
}
|
126
|
+
|
127
|
+
.bx-wrapper .bx-controls-direction a {
|
128
|
+
position: absolute;
|
129
|
+
top: 50%;
|
130
|
+
margin-top: -16px;
|
131
|
+
outline: 0;
|
132
|
+
width: 32px;
|
133
|
+
height: 32px;
|
134
|
+
text-indent: -9999px;
|
135
|
+
z-index: 9999;
|
136
|
+
}
|
137
|
+
|
138
|
+
.bx-wrapper .bx-controls-direction a.disabled {
|
139
|
+
display: none;
|
140
|
+
}
|
141
|
+
|
142
|
+
/* AUTO CONTROLS (START / STOP) */
|
143
|
+
|
144
|
+
.bx-wrapper .bx-controls-auto {
|
145
|
+
text-align: center;
|
146
|
+
}
|
147
|
+
|
148
|
+
.bx-wrapper .bx-controls-auto .bx-start {
|
149
|
+
display: block;
|
150
|
+
text-indent: -9999px;
|
151
|
+
width: 10px;
|
152
|
+
height: 11px;
|
153
|
+
outline: 0;
|
154
|
+
background: url(controls.png) -86px -11px no-repeat;
|
155
|
+
margin: 0 3px;
|
156
|
+
}
|
157
|
+
|
158
|
+
.bx-wrapper .bx-controls-auto .bx-start:hover,
|
159
|
+
.bx-wrapper .bx-controls-auto .bx-start.active {
|
160
|
+
background-position: -86px 0;
|
161
|
+
}
|
162
|
+
|
163
|
+
.bx-wrapper .bx-controls-auto .bx-stop {
|
164
|
+
display: block;
|
165
|
+
text-indent: -9999px;
|
166
|
+
width: 9px;
|
167
|
+
height: 11px;
|
168
|
+
outline: 0;
|
169
|
+
background: url(controls.png) -86px -44px no-repeat;
|
170
|
+
margin: 0 3px;
|
171
|
+
}
|
172
|
+
|
173
|
+
.bx-wrapper .bx-controls-auto .bx-stop:hover,
|
174
|
+
.bx-wrapper .bx-controls-auto .bx-stop.active {
|
175
|
+
background-position: -86px -33px;
|
176
|
+
}
|
177
|
+
|
178
|
+
/* PAGER WITH AUTO-CONTROLS HYBRID LAYOUT */
|
179
|
+
|
180
|
+
.bx-wrapper .bx-controls.bx-has-controls-auto.bx-has-pager .bx-pager {
|
181
|
+
text-align: left;
|
182
|
+
width: 80%;
|
183
|
+
}
|
184
|
+
|
185
|
+
.bx-wrapper .bx-controls.bx-has-controls-auto.bx-has-pager .bx-controls-auto {
|
186
|
+
right: 0;
|
187
|
+
width: 35px;
|
188
|
+
}
|
189
|
+
|
190
|
+
/* IMAGE CAPTIONS */
|
191
|
+
|
192
|
+
.bx-wrapper .bx-caption {
|
193
|
+
position: absolute;
|
194
|
+
bottom: 0;
|
195
|
+
left: 0;
|
196
|
+
background: #666\9;
|
197
|
+
background: rgba(80, 80, 80, 0.75);
|
198
|
+
width: 100%;
|
199
|
+
}
|
200
|
+
|
201
|
+
.bx-wrapper .bx-caption span {
|
202
|
+
color: #fff;
|
203
|
+
font-family: Arial;
|
204
|
+
display: block;
|
205
|
+
font-size: .85em;
|
206
|
+
padding: 10px;
|
73
207
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class Admin::SlidesController < Admin::ResourceController
|
2
|
-
before_filter :load_data
|
2
|
+
before_filter :load_data
|
3
3
|
|
4
4
|
def update_positions
|
5
5
|
params[:positions].each do |id, index|
|
@@ -7,18 +7,16 @@ class Admin::SlidesController < Admin::ResourceController
|
|
7
7
|
end
|
8
8
|
|
9
9
|
respond_to do |format|
|
10
|
-
format.html { redirect_to admin_slideshow_type_slides_url(@slideshow_type) }
|
11
10
|
format.js { render :text => 'Ok' }
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
15
14
|
private
|
16
|
-
def load_data
|
17
|
-
@slideshow_type = SlideshowType.find(params[:slideshow_type_id])
|
18
|
-
end
|
19
|
-
|
20
15
|
def location_after_save
|
21
16
|
admin_slideshow_type_slides_url(@slideshow_type)
|
22
17
|
end
|
23
|
-
|
18
|
+
|
19
|
+
def load_data
|
20
|
+
@slideshow_type = SlideshowType.find(params[:slideshow_type_id])
|
21
|
+
end
|
24
22
|
end
|
@@ -1,50 +1,47 @@
|
|
1
1
|
module SlideshowTypesHelper
|
2
2
|
|
3
3
|
def insert_slideshow(params={})
|
4
|
-
|
5
|
-
if
|
6
|
-
|
7
|
-
content_for(:head) { javascript_include_tag 'spree_multi_slideshow.js' }
|
8
|
-
@content_for_head_added = true
|
9
|
-
end
|
10
|
-
if slide_images(params)
|
11
|
-
navigation = enable_navigation(params)
|
12
|
-
content_tag(:div, navigation[:prev] + content_tag(:div, content_tag(:ul, raw(slide_images(params))), :class => "frame") + navigation[:succ], :class => "gallery playing")
|
4
|
+
@@slideshow = SlideshowType.enable.find_by_category(params[:category])
|
5
|
+
if @@slideshow.blank? || (!@@slideshow.blank? && @@slideshow.slides.empty?)
|
6
|
+
return ''
|
13
7
|
end
|
8
|
+
res = []
|
9
|
+
|
10
|
+
res << content_tag(:div, content_tag(:ul, slide_images(params, @@slideshow), :class => "bxslider"), :class => "slideshow")
|
11
|
+
res << "<script type='text/javascript'>
|
12
|
+
$(function() {
|
13
|
+
$('.bxslider').bxSlider({
|
14
|
+
adaptiveHeight: true,
|
15
|
+
speed: #{params[:speed] || 500},
|
16
|
+
mode: '#{params[:mode] || "horizontal"}',
|
17
|
+
controls: #{@@slideshow.enable_navigation},
|
18
|
+
auto: #{params[:auto_start] || "false"},
|
19
|
+
infiniteLoop: #{params[:infinite_loop] || "false"},
|
20
|
+
hideControlOnEnd: #{params[:hide_on_end] || "true"}
|
21
|
+
});
|
22
|
+
});
|
23
|
+
</script>"
|
24
|
+
|
25
|
+
res.join.html_safe
|
14
26
|
end
|
27
|
+
|
28
|
+
def slide_images(params, slideshow)
|
29
|
+
params[:style] ||= "custom"
|
30
|
+
params[:show_content] ||= false
|
31
|
+
max = slideshow.slide_number || slideshow.slides.count
|
32
|
+
slides = slideshow.slides.limit(max).sort_by { |slide| slide.position }
|
15
33
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
slideshow = SlideshowType.enable(category)
|
20
|
-
if !slideshow.blank?
|
21
|
-
max = slideshow.first.slide_number || 4
|
22
|
-
slides = Slide.where("slideshow_type_id = ?", slideshow.first.id).limit(max).sort_by { |slide| slide.position }
|
34
|
+
slides.map do |slide|
|
35
|
+
content_tag(:li, :class => "slide") do
|
36
|
+
divs = []
|
23
37
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
def enable_navigation(params)
|
33
|
-
category = params[:category] || "home"
|
34
|
-
slideshow = SlideshowType.enable(category)
|
35
|
-
if !slideshow.blank?
|
36
|
-
if slideshow.first.enable_navigation
|
37
|
-
prev = link_to("prev", "#", :class => "prev")
|
38
|
-
succ = link_to("next", "#", :class => "next")
|
39
|
-
else
|
40
|
-
prev = ""
|
41
|
-
succ = ""
|
38
|
+
divs << link_to(image_tag(slide.attachment.url(params[:style].to_sym)), (slide.url.blank? ? "javascript: void(0)" : slide.url), { :title => slide.title })
|
39
|
+
if params[:show_content]
|
40
|
+
divs << content_tag(:div, content_tag(:strong, raw(slide.title)) + content_tag(:p, raw(slide.content)), :class => "text-holder")
|
41
|
+
end
|
42
|
+
|
43
|
+
divs.join.html_safe
|
42
44
|
end
|
43
|
-
|
44
|
-
res[:prev] = prev
|
45
|
-
res[:succ] = succ
|
46
|
-
return res
|
47
|
-
end
|
45
|
+
end.join.html_safe
|
48
46
|
end
|
49
|
-
|
50
47
|
end
|
data/app/models/slide.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
class Slide < ActiveRecord::Base
|
2
|
-
|
3
|
-
|
4
|
-
attr_accessor :attachment_width, :attachment_height
|
2
|
+
belongs_to :slideshow_type
|
3
|
+
validate :no_attachement_errors
|
5
4
|
attr_accessible :title, :url, :slideshow_type_id, :attachment, :attachment_width, :attachment_height
|
6
5
|
|
7
6
|
has_attached_file :attachment,
|
8
7
|
:url => "/spree/slides/:id/:style_:basename.:extension",
|
9
8
|
:path => ":rails_root/public/spree/slides/:id/:style_:basename.:extension",
|
10
|
-
|
11
|
-
|
9
|
+
:styles => lambda {|a|
|
10
|
+
{
|
12
11
|
:thumbnail => "100x33#",
|
13
12
|
:small => "300x100#",
|
14
13
|
:medium => "600x200#",
|
15
14
|
:slide => "900x300#",
|
16
|
-
:custom =>
|
15
|
+
:custom => "#{a.instance.attachment_width}x#{a.instance.attachment_height}#"
|
16
|
+
}
|
17
17
|
},
|
18
18
|
:convert_options => {
|
19
19
|
:thumbnail => "-gravity center",
|
@@ -26,11 +26,20 @@ class Slide < ActiveRecord::Base
|
|
26
26
|
validates_presence_of :slideshow_type_id
|
27
27
|
validates_attachment_presence :attachment
|
28
28
|
validates_attachment_content_type :attachment, :content_type => ['image/jpeg', 'image/png', 'image/gif', 'image/jpg', 'image/x-png', 'image/pjpeg'], :message => "deve essere JPG, JPEG, PNG o GIF"
|
29
|
-
|
29
|
+
|
30
30
|
def initialize(*args)
|
31
31
|
super(*args)
|
32
32
|
last_slide = Slide.last
|
33
33
|
self.position = last_slide ? last_slide.position + 1 : 0
|
34
34
|
end
|
35
35
|
|
36
|
+
# if there are errors from the plugin, then add a more meaningful message
|
37
|
+
def no_attachement_errors
|
38
|
+
unless attachment.errors.empty?
|
39
|
+
# uncomment this to get rid of the less-than-useful interrim messages
|
40
|
+
# errors.clear
|
41
|
+
errors.add :attachment, "Paperclip returned errors for file '#{attachment_file_name}' - check ImageMagick installation or image source file."
|
42
|
+
false
|
43
|
+
end
|
44
|
+
end
|
36
45
|
end
|