spree_multi_slideshow 0.70.73 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/README.md +5 -1
  2. data/app/assets/javascripts/admin/spree_multi_slideshow.js +1 -1
  3. data/app/assets/javascripts/store/spree_multi_slideshow.js +213 -1159
  4. data/app/assets/stylesheets/admin/spree_multi_slideshow.css +1 -1
  5. data/app/assets/stylesheets/store/spree_multi_slideshow.css +56 -202
  6. data/app/controllers/spree/admin/slides_controller.rb +29 -0
  7. data/app/controllers/spree/admin/slideshow_types_controller.rb +11 -0
  8. data/app/helpers/spree/slides_helper.rb +4 -0
  9. data/app/helpers/spree/slideshow_types_helper.rb +61 -0
  10. data/app/models/spree/slide.rb +35 -0
  11. data/app/models/spree/slideshow_type.rb +17 -0
  12. data/app/overrides/slideshow_type_admin_tab.rb +1 -1
  13. data/app/views/spree/admin/shared/_slideshow_type_tabs.html.erb +16 -0
  14. data/app/views/spree/admin/slides/_form.html.erb +7 -0
  15. data/app/views/spree/admin/slides/edit.html.erb +17 -0
  16. data/app/views/spree/admin/slides/index.html.erb +35 -0
  17. data/app/views/{admin → spree/admin}/slides/new.html.erb +2 -2
  18. data/app/views/spree/admin/slideshow_types/_form.html.erb +8 -0
  19. data/app/views/spree/admin/slideshow_types/edit.html.erb +8 -0
  20. data/app/views/spree/admin/slideshow_types/index.html.erb +32 -0
  21. data/app/views/spree/admin/slideshow_types/new.html.erb +7 -0
  22. data/config/locales/en.yml +52 -2
  23. data/config/locales/it.yml +78 -25
  24. data/config/routes.rb +1 -1
  25. data/db/migrate/20120116081431_create_slideshow_types.rb +2 -1
  26. data/db/migrate/20120116083546_create_slides.rb +2 -1
  27. data/db/migrate/20120323164044_multi_slideshow_namespace.rb +6 -0
  28. data/lib/generators/spree_multi_slideshow/install/install_generator.rb +13 -3
  29. data/lib/spree_multi_slideshow.rb +0 -2
  30. metadata +132 -74
  31. data/app/assets/images/store/bx_loader.gif +0 -0
  32. data/app/assets/images/store/controls.png +0 -0
  33. data/app/controllers/admin/slides_controller.rb +0 -22
  34. data/app/controllers/admin/slideshow_types_controller.rb +0 -5
  35. data/app/helpers/slides_helper.rb +0 -2
  36. data/app/helpers/slideshow_types_helper.rb +0 -45
  37. data/app/models/slide.rb +0 -45
  38. data/app/models/slideshow_type.rb +0 -21
  39. data/app/views/admin/shared/_slideshow_type_tabs.html.erb +0 -14
  40. data/app/views/admin/slides/_form.html.erb +0 -15
  41. data/app/views/admin/slides/edit.html.erb +0 -17
  42. data/app/views/admin/slides/index.html.erb +0 -32
  43. data/app/views/admin/slideshow_types/_form.html.erb +0 -40
  44. data/app/views/admin/slideshow_types/edit.html.erb +0 -7
  45. data/app/views/admin/slideshow_types/index.html.erb +0 -32
  46. data/app/views/admin/slideshow_types/new.html.erb +0 -49
  47. data/app/views/admin/slideshow_types/new.js.erb +0 -2
  48. data/db/migrate/20120719112245_rename_image_to_attachment.rb +0 -15
  49. data/db/migrate/20130116143809_add_option_pagination.rb +0 -13
@@ -14,4 +14,4 @@
14
14
  }
15
15
  .formtastic button:hover {
16
16
  text-shadow: #FFFFFF -1px -1px 0px;
17
- }
17
+ }
@@ -2,206 +2,60 @@
2
2
  *= require store/spree_core
3
3
  */
4
4
 
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;
5
+ .gallery {
6
+ overflow: hidden;
7
+ z-index:0;
8
+ color:#fff;
9
+ background:url(/assets/images/bg-gallery.png) no-repeat 20px 0;
10
+ }
11
+ .gallery .frame {
12
+ position:relative;
13
+ }
14
+ .gallery .frame ul {
15
+ position:absolute;
16
+ margin:0;
17
+ padding:0;
18
+ list-style:none;
19
+ }
20
+ .gallery .frame li {
21
+ position:absolute;
22
+ top:0;
23
+ left:0;
24
+ background:#f1f1f1;
25
+ }
26
+ .gallery .frame li.active {z-index:2;}
27
+ .gallery img {
28
+ display:block;
29
+ }
30
+ .gallery .prev,
31
+ .gallery .next {
32
+ /*position:absolute;
33
+ top:160px;
34
+ left:47px;
35
+ background:url(/assets/images/sprite01.png) no-repeat;
36
+ width:39px;
37
+ height:39px;*/
38
+ text-indent:-9999px;
39
+ overflow:hidden;
40
+ z-index:3;
41
+ }
42
+ .gallery .next {
43
+ right:56px;
44
+ left:auto;
45
+ background-position: 0 -43px;
46
+ }
47
+ .gallery .text-holder {
48
+ background:url(/assets/images/bg-text02.png) no-repeat;
49
+ width: 234px;
50
+ height:98px;
51
+ padding:45px 0 0 50px;
52
+ position:absolute;
53
+ right:1px;
54
+ bottom:1px;
55
+ font:bold 33px/40px 'Candrb', Arial, Helvetica, sans-serif;
56
+ text-align:center;
57
+ }
58
+ .gallery .text-holder strong span {
59
+ font-size:52px;
60
+ display:block;
207
61
  }
@@ -0,0 +1,29 @@
1
+ module Spree
2
+ module Admin
3
+ class SlidesController < ResourceController
4
+ before_filter :load_data
5
+
6
+ def load_data
7
+ @slideshow_type = Spree::SlideshowType.find(params[:slideshow_type_id])
8
+ end
9
+
10
+ def update_positions
11
+ params[:positions].each do |id, index|
12
+ Spree::Slide.update_all(['position=?', index], ['id=?', id])
13
+ end
14
+
15
+ respond_to do |format|
16
+ format.html { redirect_to admin_slideshow_type_slides_url(params[:slideshow_type_id]) }
17
+ format.js { render :text => 'Ok' }
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def location_after_save
24
+ admin_slideshow_type_slides_url(@slideshow_type)
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,11 @@
1
+ module Spree
2
+ module Admin
3
+ class SlideshowTypesController < ResourceController
4
+
5
+ def location_after_save
6
+ edit_admin_slideshow_type_url(@slideshow_type)
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ module Spree
2
+ module SlidesHelper
3
+ end
4
+ end
@@ -0,0 +1,61 @@
1
+ module Spree
2
+ module SlideshowTypesHelper
3
+
4
+ def insert_slideshow(params={})
5
+ @content_for_head_added ||= false
6
+ if not @content_for_head_added
7
+ content_for(:head) { stylesheet_link_tag 'spree_multi_slideshow.css' }
8
+ content_for(:head) { javascript_include_tag 'spree_multi_slideshow.js' }
9
+ @content_for_head_added = true
10
+ end
11
+ if slide_images(params)
12
+ navigation = enable_navigation(params)
13
+ content_tag(:div, navigation[:prev] + content_tag(:div, content_tag(:ul, raw(slide_images(params))), :class => "frame") + navigation[:succ], :class => "gallery #{params[:class]}", :style => "width: #{Spree::SlideshowType.enable(params[:category] || "home").first.slide_width}px; height: #{Spree::SlideshowType.enable(params[:category] || "home").first.slide_height}px;")
14
+ end
15
+ end
16
+
17
+ def slide_images(params)
18
+ category = params[:category] || "home"
19
+ style = params[:style] || "custom"
20
+ slideshow = Spree::SlideshowType.enable(category)
21
+ if !slideshow.blank?
22
+ max = slideshow.first.slide_number || 4
23
+ slides = Spree::Slide.where("slideshow_type_id = ?", slideshow.first.id).limit(max).sort_by { |slide| slide.position }
24
+
25
+ slides.map do |slide|
26
+ content_tag(:li, raw(link_to(image_tag(slide.image.url(style.to_sym)), slide.url, { :title => slide.title })) + raw(content_tag(:div, content_tag(:strong, raw(slide.title)) + content_tag(:p, raw(slide.content)), :class => "text-holder")))
27
+ end.join
28
+ else
29
+ false
30
+ end
31
+ end
32
+
33
+ def enable_navigation(params)
34
+ container_nav = params[:container_navigation] || nil
35
+ cl_nav_container = params[:class_navigation_container].split(",") || nil
36
+ cl_nav_link = params[:class_navigation_link].split(",") || nil
37
+ category = params[:category] || "home"
38
+ slideshow = Spree::SlideshowType.enable(category)
39
+ if !slideshow.blank?
40
+ if slideshow.first.enable_navigation
41
+ prev = link_to("prev", "#", :class => "prev #{cl_nav_link[0]}")
42
+ succ = link_to("next", "#", :class => "next #{cl_nav_link[1]}")
43
+ else
44
+ prev = ""
45
+ succ = ""
46
+ end
47
+
48
+ unless container_nav.blank?
49
+ prev = content_tag(container_nav.to_sym, prev, :class => cl_nav_container[0])
50
+ succ = content_tag(container_nav.to_sym, succ, :class => cl_nav_container[1])
51
+ end
52
+
53
+ res = Hash.new()
54
+ res[:prev] = prev
55
+ res[:succ] = succ
56
+ return res
57
+ end
58
+ end
59
+
60
+ end
61
+ end
@@ -0,0 +1,35 @@
1
+ module Spree
2
+ class Slide < ActiveRecord::Base
3
+
4
+ has_many :slideshow_types
5
+ validates_presence_of :slideshow_type_id
6
+
7
+ has_attached_file :image,
8
+ :url => "/spree/slides/:id/:style_:basename.:extension",
9
+ :path => ":rails_root/public/spree/slides/:id/:style_:basename.:extension",
10
+ #:default_url => "/missing/:style.jpg",
11
+ :styles => {
12
+ :thumbnail => "100x33#",
13
+ :small => "300x100#",
14
+ :medium => "600x200#",
15
+ :slide => "900x300#",
16
+ :custom => Proc.new { |instance| "#{SlideshowType.find(instance.slideshow_type_id).slide_width}x#{SlideshowType.find(instance.slideshow_type_id).slide_height}#" }
17
+ },
18
+ :convert_options => {
19
+ :thumbnail => "-gravity center",
20
+ :small => "-gravity center",
21
+ :medium => "-gravity center",
22
+ :slide => "-gravity center",
23
+ :custom => "-gravity center"
24
+ }
25
+
26
+ #process_in_background :image UTILE MA OCCORRE ATTIVARE ANCHE LA GEMMA DELAYED-PAPERCLIP
27
+
28
+ def initialize(*args)
29
+ super(*args)
30
+ last_slide = Slide.last
31
+ self.position = last_slide ? last_slide.position + 1 : 0
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,17 @@
1
+ module Spree
2
+ class SlideshowType < ActiveRecord::Base
3
+
4
+ belongs_to :slide
5
+
6
+ validates :slide_number, :slide_width, :slide_height, :presence => true
7
+ validates_uniqueness_of :category
8
+ validates_numericality_of :slide_number, :only_integer => true
9
+
10
+ scope :enable, lambda { |category| {:conditions => {:enabled => true, :category => category}} }
11
+
12
+ def initialize(*args)
13
+ super(*args)
14
+ end
15
+
16
+ end
17
+ end
@@ -1,4 +1,4 @@
1
- Deface::Override.new(:virtual_path => "layouts/admin",
1
+ Deface::Override.new(:virtual_path => "spree/layouts/admin",
2
2
  :name => "slideshow_type_admin_tab",
3
3
  :insert_bottom => "[data-hook='admin_tabs']",
4
4
  :text => "<%= tab(:slideshow_types) %>")
@@ -0,0 +1,16 @@
1
+ <% content_for :sidebar do %>
2
+
3
+ <h3><%= t("slideshow_type.sidebar") %></h3>
4
+ <br class="clear" />
5
+
6
+ <ul class="sidebar slide-menu" data-hook="admin_slide_tabs">
7
+ <li<%== ' class="active"' if current == 'Slideshow_type Details' %>>
8
+ <%= link_to t("slideshow_type.detail"), edit_admin_slideshow_type_url(@slideshow_type) %>
9
+ </li>
10
+ <li<%== ' class="active"' if current == 'Slide Image' %>>
11
+ <%= link_to t("slideshow_type.slide.many"), admin_slideshow_type_slides_path(@slideshow_type) %>
12
+ </li>
13
+ </ul>
14
+ <br class="clear" />
15
+
16
+ <% end %>