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.
@@ -2,72 +2,206 @@
2
2
  *= require store/spree_core
3
3
  */
4
4
 
5
- .gallery{
6
- width: 900px;
7
- height:276px;
8
- padding:15px 0 0;
9
- overflow: hidden;
10
- z-index:0;
11
- color:#fff;
12
- background:url(/assets/images/bg-gallery.png) no-repeat 20px 0;
13
- margin-bottom:-2px;
14
- }
15
- .gallery .frame{
16
- width:900px;
17
- overflow:hidden;
18
- position:relative;
19
- height:251px;
20
- }
21
- .gallery .frame ul{
22
- position:absolute;
23
- overflow:hidden;
24
- margin:0;
25
- padding:0;
26
- list-style:none;
27
- width:900px;
28
- height:251px;
29
- }
30
- .gallery .frame li{
31
- width:900px;
32
- height:251px;
33
- position:absolute;
34
- top:0;
35
- left:0;
36
- background:#f1f1f1;
37
- }
38
- .gallery .frame li.active{z-index:2;}
39
- .gallery img{
40
- display:block;
41
- }
42
- .gallery .prev,
43
- .gallery .next{
44
- position:absolute;
45
- top:160px;
46
- left:47px;
47
- background:url(/assets/images/sprite01.png) no-repeat;
48
- width:39px;
49
- height:39px;
50
- text-indent:-9999px;
51
- overflow:hidden;
52
- z-index:3;
53
- }
54
- .gallery .next{
55
- right:56px;
56
- left:auto;
57
- background-position: 0 -43px;
58
- }
59
- .gallery .text-holder{
60
- background:url(/assets/images/bg-text02.png) no-repeat;
61
- width: 234px;
62
- height:98px;
63
- padding:45px 0 0 50px;
64
- position:absolute;
65
- right:1px;
66
- bottom:1px;
67
- font:bold 33px/40px 'Candrb', Arial, Helvetica, sans-serif;
68
- text-align:center;
69
- }
70
- .gallery .text-holder strong span{
71
- font-size:52px;
72
- display:block;
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, :only => [:index, :new, :show, :edit]
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,7 +1,5 @@
1
1
  class Admin::SlideshowTypesController < Admin::ResourceController
2
-
3
2
  def location_after_save
4
- edit_admin_slideshow_type_url(@slideshow_type)
5
- end
6
-
3
+ edit_admin_slideshow_type_url(@slideshow_type)
4
+ end
7
5
  end
@@ -1,50 +1,47 @@
1
1
  module SlideshowTypesHelper
2
2
 
3
3
  def insert_slideshow(params={})
4
- @content_for_head_added ||= false
5
- if not @content_for_head_added
6
- content_for(:head) { stylesheet_link_tag 'spree_multi_slideshow.css' }
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
- def slide_images(params)
17
- category = params[:category] || "home"
18
- style = params[:style] || "custom"
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
- slides.map do |slide|
25
- content_tag(:li, raw(link_to(image_tag(slide.attachment.url(style.to_sym)), slide.url, { :title => slide.title })) + raw(content_tag(:div, content_tag(:strong, raw(slide.title)), :class => "text-holder")))
26
- end.join
27
- else
28
- false
29
- end
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
- res = Hash.new()
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
- has_many :slideshow_types
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
- #:default_url => "/missing/:style.jpg",
11
- :styles => {
9
+ :styles => lambda {|a|
10
+ {
12
11
  :thumbnail => "100x33#",
13
12
  :small => "300x100#",
14
13
  :medium => "600x200#",
15
14
  :slide => "900x300#",
16
- :custom => Proc.new {|instance| "#{instance.attachment_width}x#{instance.attachment_height}#"}
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