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.
- data/README.md +5 -1
- data/app/assets/javascripts/admin/spree_multi_slideshow.js +1 -1
- data/app/assets/javascripts/store/spree_multi_slideshow.js +213 -1159
- data/app/assets/stylesheets/admin/spree_multi_slideshow.css +1 -1
- data/app/assets/stylesheets/store/spree_multi_slideshow.css +56 -202
- data/app/controllers/spree/admin/slides_controller.rb +29 -0
- data/app/controllers/spree/admin/slideshow_types_controller.rb +11 -0
- data/app/helpers/spree/slides_helper.rb +4 -0
- data/app/helpers/spree/slideshow_types_helper.rb +61 -0
- data/app/models/spree/slide.rb +35 -0
- data/app/models/spree/slideshow_type.rb +17 -0
- data/app/overrides/slideshow_type_admin_tab.rb +1 -1
- data/app/views/spree/admin/shared/_slideshow_type_tabs.html.erb +16 -0
- data/app/views/spree/admin/slides/_form.html.erb +7 -0
- data/app/views/spree/admin/slides/edit.html.erb +17 -0
- data/app/views/spree/admin/slides/index.html.erb +35 -0
- data/app/views/{admin → spree/admin}/slides/new.html.erb +2 -2
- data/app/views/spree/admin/slideshow_types/_form.html.erb +8 -0
- data/app/views/spree/admin/slideshow_types/edit.html.erb +8 -0
- data/app/views/spree/admin/slideshow_types/index.html.erb +32 -0
- data/app/views/spree/admin/slideshow_types/new.html.erb +7 -0
- data/config/locales/en.yml +52 -2
- data/config/locales/it.yml +78 -25
- data/config/routes.rb +1 -1
- data/db/migrate/20120116081431_create_slideshow_types.rb +2 -1
- data/db/migrate/20120116083546_create_slides.rb +2 -1
- data/db/migrate/20120323164044_multi_slideshow_namespace.rb +6 -0
- data/lib/generators/spree_multi_slideshow/install/install_generator.rb +13 -3
- data/lib/spree_multi_slideshow.rb +0 -2
- metadata +132 -74
- data/app/assets/images/store/bx_loader.gif +0 -0
- data/app/assets/images/store/controls.png +0 -0
- data/app/controllers/admin/slides_controller.rb +0 -22
- data/app/controllers/admin/slideshow_types_controller.rb +0 -5
- data/app/helpers/slides_helper.rb +0 -2
- data/app/helpers/slideshow_types_helper.rb +0 -45
- data/app/models/slide.rb +0 -45
- data/app/models/slideshow_type.rb +0 -21
- data/app/views/admin/shared/_slideshow_type_tabs.html.erb +0 -14
- data/app/views/admin/slides/_form.html.erb +0 -15
- data/app/views/admin/slides/edit.html.erb +0 -17
- data/app/views/admin/slides/index.html.erb +0 -32
- data/app/views/admin/slideshow_types/_form.html.erb +0 -40
- data/app/views/admin/slideshow_types/edit.html.erb +0 -7
- data/app/views/admin/slideshow_types/index.html.erb +0 -32
- data/app/views/admin/slideshow_types/new.html.erb +0 -49
- data/app/views/admin/slideshow_types/new.js.erb +0 -2
- data/db/migrate/20120719112245_rename_image_to_attachment.rb +0 -15
- data/db/migrate/20130116143809_add_option_pagination.rb +0 -13
Binary file
|
Binary file
|
@@ -1,22 +0,0 @@
|
|
1
|
-
class Admin::SlidesController < Admin::ResourceController
|
2
|
-
before_filter :load_data
|
3
|
-
|
4
|
-
def update_positions
|
5
|
-
params[:positions].each do |id, index|
|
6
|
-
Slide.update_all(['position=?', index], ['id=?', id])
|
7
|
-
end
|
8
|
-
|
9
|
-
respond_to do |format|
|
10
|
-
format.js { render :text => 'Ok' }
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
def location_after_save
|
16
|
-
admin_slideshow_type_slides_url(@slideshow_type)
|
17
|
-
end
|
18
|
-
|
19
|
-
def load_data
|
20
|
-
@slideshow_type = SlideshowType.find(params[:slideshow_type_id])
|
21
|
-
end
|
22
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module SlideshowTypesHelper
|
2
|
-
|
3
|
-
def insert_slideshow(params={})
|
4
|
-
@@slideshow = SlideshowType.enable.find_by_category(params[:category])
|
5
|
-
if @@slideshow.blank? || (!@@slideshow.blank? && @@slideshow.slides.empty?)
|
6
|
-
return ''
|
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
|
-
controls: #{@@slideshow.enable_navigation},
|
16
|
-
autoStart: false,
|
17
|
-
infiniteLoop: false,
|
18
|
-
hideControlOnEnd: true
|
19
|
-
});
|
20
|
-
});
|
21
|
-
</script>"
|
22
|
-
|
23
|
-
res.join.html_safe
|
24
|
-
end
|
25
|
-
|
26
|
-
def slide_images(params, slideshow)
|
27
|
-
params[:style] ||= "custom"
|
28
|
-
params[:show_content] ||= false
|
29
|
-
max = slideshow.slide_number || slideshow.slides.count
|
30
|
-
slides = slideshow.slides.limit(max).sort_by { |slide| slide.position }
|
31
|
-
|
32
|
-
slides.map do |slide|
|
33
|
-
content_tag(:li, :class => "slide") do
|
34
|
-
divs = []
|
35
|
-
|
36
|
-
divs << link_to(image_tag(slide.attachment.url(params[:style].to_sym)), (slide.url.blank? ? "javascript: void(0)" : slide.url), { :title => slide.title })
|
37
|
-
if params[:show_content]
|
38
|
-
divs << content_tag(:div, content_tag(:strong, raw(slide.title)) + content_tag(:p, raw(slide.content)), :class => "text-holder")
|
39
|
-
end
|
40
|
-
|
41
|
-
divs.join.html_safe
|
42
|
-
end
|
43
|
-
end.join.html_safe
|
44
|
-
end
|
45
|
-
end
|
data/app/models/slide.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
class Slide < ActiveRecord::Base
|
2
|
-
belongs_to :slideshow_type
|
3
|
-
validate :no_attachement_errors
|
4
|
-
attr_accessible :title, :url, :slideshow_type_id, :attachment, :attachment_width, :attachment_height
|
5
|
-
|
6
|
-
has_attached_file :attachment,
|
7
|
-
:url => "/spree/slides/:id/:style_:basename.:extension",
|
8
|
-
:path => ":rails_root/public/spree/slides/:id/:style_:basename.:extension",
|
9
|
-
:styles => lambda {|a|
|
10
|
-
{
|
11
|
-
:thumbnail => "100x33#",
|
12
|
-
:small => "300x100#",
|
13
|
-
:medium => "600x200#",
|
14
|
-
:slide => "900x300#",
|
15
|
-
:custom => "#{a.instance.attachment_width}x#{a.instance.attachment_height}#"
|
16
|
-
}
|
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
|
-
validates_presence_of :slideshow_type_id
|
27
|
-
validates_attachment_presence :attachment
|
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
|
-
|
30
|
-
def initialize(*args)
|
31
|
-
super(*args)
|
32
|
-
last_slide = Slide.last
|
33
|
-
self.position = last_slide ? last_slide.position + 1 : 0
|
34
|
-
end
|
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
|
45
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
class SlideshowType < ActiveRecord::Base
|
2
|
-
has_many :slides
|
3
|
-
after_update :reprocess_slides
|
4
|
-
|
5
|
-
attr_accessible :category, :slide_width, :slide_height, :slide_number, :enable_navigation, :enabled, :enable_pagination
|
6
|
-
|
7
|
-
validates :slide_number, :slide_width, :slide_height, :presence => true
|
8
|
-
validates_uniqueness_of :category
|
9
|
-
validates_numericality_of :slide_number, :only_integer => true
|
10
|
-
|
11
|
-
scope :enable, where("enabled IS NOT NULL AND enabled = 1")
|
12
|
-
|
13
|
-
def reprocess_slides
|
14
|
-
self.slides.each do |slide|
|
15
|
-
slide.attachment_width = self.slide_width
|
16
|
-
slide.attachment_height = self.slide_height
|
17
|
-
slide.save!
|
18
|
-
slide.attachment.reprocess!(:custom)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<% content_for :sidebar do %>
|
2
|
-
<h3><%= t(:sidebar) %></h3>
|
3
|
-
<br class="clear" />
|
4
|
-
<ul class="sidebar slide-menu" data-hook="admin_slide_tabs">
|
5
|
-
<li<%== ' class="active"' if current == 'Slideshow Details' %>>
|
6
|
-
<%= link_to t(:detail), edit_admin_slideshow_type_url(@slideshow_type) %>
|
7
|
-
</li>
|
8
|
-
<li<%== ' class="active"' if current == 'Slides' %>>
|
9
|
-
<%= link_to t(:slide), admin_slideshow_type_slides_path(@slideshow_type) %>
|
10
|
-
</li>
|
11
|
-
</ul>
|
12
|
-
<br class="clear" />
|
13
|
-
|
14
|
-
<% end %>
|
@@ -1,15 +0,0 @@
|
|
1
|
-
<%= f.hidden_field(:slideshow_type_id, :value => @slideshow_type.id) %>
|
2
|
-
<%= f.hidden_field(:attachment_width, :value => @slideshow_type.slide_width) %>
|
3
|
-
<%= f.hidden_field(:attachment_height, :value => @slideshow_type.slide_height) %>
|
4
|
-
<tr data-hook="file">
|
5
|
-
<td><%= t(:filename) %>:</td>
|
6
|
-
<td><%= f.file_field :attachment %></td>
|
7
|
-
</tr>
|
8
|
-
<tr data-hook="title">
|
9
|
-
<td><%= t(:title) %>:</td>
|
10
|
-
<td><%= f.text_field :title %></td>
|
11
|
-
</tr>
|
12
|
-
<tr data-hook="url">
|
13
|
-
<td><%= t(:url) %>:</td>
|
14
|
-
<td><%= f.text_field :url %></td>
|
15
|
-
</tr>
|
@@ -1,17 +0,0 @@
|
|
1
|
-
<%= render :partial => 'admin/shared/slideshow_type_tabs', :locals => {:current => 'Slides'} %>
|
2
|
-
|
3
|
-
<%= render 'shared/error_messages', :target => @slide %>
|
4
|
-
|
5
|
-
<%= form_for [:admin, @slideshow_type, @slide], :html => { :multipart => true } do |f| %>
|
6
|
-
<table class="basic-table" data-hook="edit_slide">
|
7
|
-
<tr data-hook="thumbnail">
|
8
|
-
<td><%= t(:thumbnail) %>:</td>
|
9
|
-
<td><%= link_to image_tag(@slide.attachment.url(:small)), @slide.attachment.url(:medium) %></td>
|
10
|
-
</tr>
|
11
|
-
<%= render :partial => 'form', :locals => { :f => f } %>
|
12
|
-
</table>
|
13
|
-
<p class="form-buttons" data-hook="buttons">
|
14
|
-
<%= button t(:update) %>
|
15
|
-
<%= t(:or) %> <%= link_to t(:cancel), admin_slideshow_type_slides_path(@slideshow_type), :id => 'cancel_link' %>
|
16
|
-
</p>
|
17
|
-
<% end %>
|
@@ -1,32 +0,0 @@
|
|
1
|
-
<%= render :partial => 'admin/shared/slideshow_type_tabs', :locals => {:current => 'Slides'} %>
|
2
|
-
|
3
|
-
<table class="index sortable" data-hook="images_table">
|
4
|
-
<tr data-hook="images_header">
|
5
|
-
<th><%= t(:thumbnail) %></th>
|
6
|
-
<th><%= t(:title) %></th>
|
7
|
-
<th><%= t(:url) %></th>
|
8
|
-
<th><%= t(:action) %></th>
|
9
|
-
</tr>
|
10
|
-
|
11
|
-
<% @slideshow_type.slides.each do |slide| %>
|
12
|
-
<tr id="<%= dom_id(slide) %>" data-hook="slides_row">
|
13
|
-
<td>
|
14
|
-
<span class="handle"></span>
|
15
|
-
<%= link_to image_tag(slide.attachment.url(:thumbnail)), slide.attachment.url(:medium) %>
|
16
|
-
</td>
|
17
|
-
<td><%= slide.title %></td>
|
18
|
-
<td><%= slide.url %></td>
|
19
|
-
<td class="actions">
|
20
|
-
<%= link_to_with_icon 'edit', t(:edit), edit_admin_slideshow_type_slide_url(@slideshow_type, slide), :class => 'edit' %>
|
21
|
-
|
22
|
-
<%= link_to_delete slide, {:url => admin_slideshow_type_slide_url(@slideshow_type, slide) }%>
|
23
|
-
</td>
|
24
|
-
</tr>
|
25
|
-
<% end %>
|
26
|
-
</table>
|
27
|
-
|
28
|
-
<div id="slides" data-hook></div>
|
29
|
-
<br />
|
30
|
-
<p data-hook="links">
|
31
|
-
<%= link_to icon('add') + ' ' + t(:new_slide), new_admin_slideshow_type_slide_url(@slideshow_type), :id => 'new_slide_link' %>
|
32
|
-
</p>
|
@@ -1,40 +0,0 @@
|
|
1
|
-
<div class="clearfix">
|
2
|
-
<div class="left" data-hook="admin_slideshow_form_left">
|
3
|
-
<%= f.field_container :category do %>
|
4
|
-
<%= f.label :category, t(:category) %> <span class="required">*</span><br />
|
5
|
-
<%= f.text_field :category, :class => 'fullwidth title' %>
|
6
|
-
<%= f.error_message_on :category %>
|
7
|
-
<% end %>
|
8
|
-
|
9
|
-
<%= f.field_container :slide_width do %>
|
10
|
-
<%= f.label :slide_width, t(:slide_width) %> <span class="required">*</span><br />
|
11
|
-
<%= f.text_field :slide_width, :class => 'fullwidth title' %>
|
12
|
-
<%= f.error_message_on :slide_width %>
|
13
|
-
<% end %>
|
14
|
-
|
15
|
-
<%= f.field_container :slide_height do %>
|
16
|
-
<%= f.label :slide_height, t(:slide_height)%> <span class="required">*</span><br />
|
17
|
-
<%= f.text_field :slide_height, :class => 'fullwidth title' %>
|
18
|
-
<%= f.error_message_on :slide_height %>
|
19
|
-
<% end %>
|
20
|
-
</div>
|
21
|
-
<div class="right" data-hook="admin_slideshow_form_right">
|
22
|
-
<%= f.field_container :slide_number do %>
|
23
|
-
<%= f.label :slide_number, t(:slide_number) %><br />
|
24
|
-
<%= f.text_field :slide_number, :class => 'title' %>
|
25
|
-
<%= f.error_message_on :slide_number %>
|
26
|
-
<% end %>
|
27
|
-
|
28
|
-
<%= f.field_container :enable_navigation do %>
|
29
|
-
<%= f.label :enable_navigation, t(:enable_navigation) %><br />
|
30
|
-
<%= f.check_box :enable_navigation, :class => 'title' %>
|
31
|
-
<%= f.error_message_on :enable_navigation %>
|
32
|
-
<% end %>
|
33
|
-
|
34
|
-
<%= f.field_container :enabled do %>
|
35
|
-
<%= f.label :enabled, t(:enabled) %> <span class="required">*</span><br />
|
36
|
-
<%= f.check_box :enabled, :class => 'title' %>
|
37
|
-
<%= f.error_message_on :enabled %>
|
38
|
-
<% end %>
|
39
|
-
</div>
|
40
|
-
</div>
|
@@ -1,7 +0,0 @@
|
|
1
|
-
<%= render :partial => 'admin/shared/slideshow_type_tabs', :locals => {:current => 'Slideshow Details'} %>
|
2
|
-
<%= render 'shared/error_messages', :target => @slideshow_type %>
|
3
|
-
|
4
|
-
<%= form_for [:admin, @slideshow_type], :html => { :method => :put, :multipart => true } do |f| %>
|
5
|
-
<%= render :partial => 'form', :locals => {:f => f} %>
|
6
|
-
<%= render :partial => 'admin/shared/edit_resource_links' %>
|
7
|
-
<% end %>
|
@@ -1,32 +0,0 @@
|
|
1
|
-
<div class="toolbar" data-hook="toolbar">
|
2
|
-
<ul class="actions">
|
3
|
-
<li id="new_slideshow_type_link">
|
4
|
-
<%= button_link_to t(:new_slideshow_type), new_object_url, {:remote => true, :icon => 'add', :id => 'admin_new_slideshow_type'} %>
|
5
|
-
</li>
|
6
|
-
</ul>
|
7
|
-
<br class="clear" />
|
8
|
-
</div>
|
9
|
-
|
10
|
-
<h1><%= "#{t('actions.listing')} #{t(:slideshow_type)}" %></h1>
|
11
|
-
|
12
|
-
<div id="new_slideshow" data-hook></div>
|
13
|
-
|
14
|
-
<table class="index" id="listing_slideshow_types">
|
15
|
-
<tr data-hook="admin_slideshow_types_index_headers">
|
16
|
-
<th><%= t(:category) %></th>
|
17
|
-
<th><%= t(:enable) %></th>
|
18
|
-
<th><%= t(:slide_number) %></th>
|
19
|
-
<th data-hook="admin_slideshow_types_index_header_actions"></th>
|
20
|
-
</tr>
|
21
|
-
<% @slideshow_types.each do |slideshow_type| %>
|
22
|
-
<tr id="<%= dom_id slideshow_type %>" data-hook="admin_slideshow_types_index_rows">
|
23
|
-
<td><%= slideshow_type.category %></td>
|
24
|
-
<td><%= icon('tick') if slideshow_type.enabled %></td>
|
25
|
-
<td><%= slideshow_type.slide_number %></td>
|
26
|
-
<td class="actions" data-hook="admin_products_index_row_actions">
|
27
|
-
<%= link_to_edit slideshow_type, :class => 'edit' %>
|
28
|
-
<%= link_to_delete slideshow_type %>
|
29
|
-
</td>
|
30
|
-
</tr>
|
31
|
-
<% end %>
|
32
|
-
</table>
|
@@ -1,49 +0,0 @@
|
|
1
|
-
<%= render 'shared/error_messages', :target => @slideshow_type %>
|
2
|
-
|
3
|
-
<%= form_for [:admin, @slideshow_type], :html => { :multipart => true } do |f| %>
|
4
|
-
<fieldset data-hook="new_slideshow_type">
|
5
|
-
<div class="clearfix" data-hook="new_product_attrs">
|
6
|
-
<div class="left">
|
7
|
-
<%= f.field_container :category do %>
|
8
|
-
<%= f.label :category, t(:category) %> <span class="required">*</span><br />
|
9
|
-
<%= f.text_field :category, :class => 'fullwidth title' %>
|
10
|
-
<%= f.error_message_on :category %>
|
11
|
-
<% end %>
|
12
|
-
|
13
|
-
<%= f.field_container :slide_width do %>
|
14
|
-
<%= f.label :slide_width, t(:slide_width) %> <span class="required">*</span><br />
|
15
|
-
<%= f.text_field :slide_width, :class => 'fullwidth title' %>
|
16
|
-
<%= f.error_message_on :slide_width %>
|
17
|
-
<% end %>
|
18
|
-
|
19
|
-
<%= f.field_container :slide_height do %>
|
20
|
-
<%= f.label :slide_height, t(:slide_height) %> <span class="required">*</span><br />
|
21
|
-
<%= f.text_field :slide_height, :class => 'fullwidth title' %>
|
22
|
-
<%= f.error_message_on :slide_height %>
|
23
|
-
<% end %>
|
24
|
-
</div>
|
25
|
-
<div class="right">
|
26
|
-
<%= f.field_container :slide_number do %>
|
27
|
-
<%= f.label :slide_number, t(:slide_number) %><br />
|
28
|
-
<%= f.text_field :slide_number, :class => 'fullwidth title' %>
|
29
|
-
<%= f.error_message_on :slide_number %>
|
30
|
-
<% end %>
|
31
|
-
|
32
|
-
<%= f.field_container :enable_navigation do %>
|
33
|
-
<%= f.label :enable_navigation, t(:enable_navigation) %><br />
|
34
|
-
<%= f.check_box :enable_navigation, :class => 'fullwidth title' %>
|
35
|
-
<%= f.error_message_on :enable_navigation %>
|
36
|
-
<% end %>
|
37
|
-
|
38
|
-
<%= f.field_container :enabled do %>
|
39
|
-
<%= f.label :enabled, t(:enabled) %> <span class="required">*</span><br />
|
40
|
-
<%= f.check_box :enabled, :class => 'fullwidth title' %>
|
41
|
-
<%= f.error_message_on :enabled %>
|
42
|
-
<% end %>
|
43
|
-
</div>
|
44
|
-
</div>
|
45
|
-
|
46
|
-
<%= render :partial => 'admin/shared/new_resource_links' %>
|
47
|
-
|
48
|
-
</fieldset>
|
49
|
-
<% end %>
|
@@ -1,15 +0,0 @@
|
|
1
|
-
class RenameImageToAttachment < ActiveRecord::Migration
|
2
|
-
def up
|
3
|
-
rename_column :slides, :image_content_type, :attachment_content_type
|
4
|
-
rename_column :slides, :image_file_name, :attachment_file_name
|
5
|
-
rename_column :slides, :image_updated_at, :attachment_updated_at
|
6
|
-
rename_column :slides, :image_size, :attachment_size
|
7
|
-
end
|
8
|
-
|
9
|
-
def down
|
10
|
-
rename_column :slides, :attachment_content_type, :image_content_type
|
11
|
-
rename_column :slides, :attachment_file_name, :image_file_name
|
12
|
-
rename_column :slides, :attachment_updated_at, :image_updated_at
|
13
|
-
rename_column :slides, :attachment_size, :image_size
|
14
|
-
end
|
15
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
class AddOptionPagination < ActiveRecord::Migration
|
2
|
-
def up
|
3
|
-
add_column :slideshow_types, :enable_pagination, :boolean, :default => false, :after => :enable_navigation
|
4
|
-
add_column :slides, :attachment_width, :string, :after => :attachment_size
|
5
|
-
add_column :slides, :attachment_height, :string, :after => :attachment_width
|
6
|
-
end
|
7
|
-
|
8
|
-
def down
|
9
|
-
remove_column :slideshow_types, :enable_pagination
|
10
|
-
remove_column :slides, :attachment_width
|
11
|
-
remove_column :slides, :attachment_height
|
12
|
-
end
|
13
|
-
end
|