Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

try to fix for spree 1-3-stable

  • Loading branch information...
commit 33e082dbf6a1579c2598a5f382a258cd889110e3 1 parent 4873913
@damianogiacomello authored
Showing with 429 additions and 184 deletions.
  1. +14 −11 README.md
  2. +41 −0 app/assets/javascripts/admin/slide_settings.js.erb
  3. +21 −21 app/assets/javascripts/store/spree_multi_slideshow.js
  4. +45 −0 app/controllers/spree/admin/slide_settings_controller.rb
  5. +2 −13 app/controllers/spree/admin/slides_controller.rb
  6. +5 −1 app/controllers/spree/admin/slideshows_controller.rb
  7. +10 −6 app/helpers/spree/slideshows_helper.rb
  8. +25 −0 app/models/spree/app_configuration_decorator.rb
  9. +3 −0  app/models/spree/product_decorator.rb
  10. +15 −20 app/models/spree/slide.rb
  11. +6 −1 app/models/spree/slideshow.rb
  12. +3 −0  app/models/spree/taxon_decorator.rb
  13. +7 −1 app/overrides/slideshow_admin_tab.rb
  14. +19 −15 app/views/spree/admin/shared/_slideshow_tabs.html.erb
  15. +72 −0 app/views/spree/admin/slide_settings/edit.html.erb
  16. +30 −19 app/views/spree/admin/slides/_form.html.erb
  17. +30 −25 app/views/spree/admin/slideshows/_form.html.erb
  18. +14 −5 app/views/spree/admin/slideshows/edit.html.erb
  19. +12 −9 app/views/spree/admin/slideshows/index.html.erb
  20. +41 −30 app/views/spree/admin/slideshows/new.html.erb
  21. +1 −1  app/views/spree/admin/slideshows/new.js.erb
  22. +2 −0  config/routes.rb
  23. +4 −0 db/migrate/20120116081431_create_slideshows.rb
  24. +4 −2 db/migrate/20120116083546_create_slides.rb
  25. +3 −4 spree_multi_slideshow.gemspec
View
25 README.md
@@ -22,21 +22,24 @@ Example
1. add slideshow helper method in your view:
<pre>
- <%= insert_slideshow %>
+ <%= insert_slideshow() %>
</pre>
add slides for the slideshow in the admin section
2. Additional options:
<pre>
- <%= insert_slideshow(:category => "my_category") %>
+ {
+ :id => "slideshow"
+ :class => "first_slideshow"
+ :category => "my_category"
+ :style => "custom"
+ :auto => true|false
+ :next_text => ">>"
+ :prev_text => "<<"
+ :next_selector => "bx-next"
+ :prev_selector => "bx-prev"
+ :pagination_class => "pagination"
+ :show_content => true|false
+ }
</pre>
-displays slides for which the category column, dafault is "home"
-<pre>
- <%= insert_slideshow(:style => "small") %>
-</pre>
-style layout for slideshow: [small, medium, slide, default => custom]
-<pre>
- <%= insert_slideshow(:enable_content => true/false, :style => "custom", :category => "custom") %>
-</pre>
-added a content_tag for display title and description of slide
Copyright (c) 2012 [Damiano Giacomello], released under the New BSD License
View
41 app/assets/javascripts/admin/slide_settings.js.erb
@@ -0,0 +1,41 @@
+$(document).ready(function() {
+
+ $('.destroy_style').live("click", function(e) {
+ e.preventDefault();
+ $(this).parent().remove();
+ });
+
+ $('.destroy_new_slide_styles').live("click", function(e) {
+ e.preventDefault();
+ $(this).closest('.new_slide_styles').remove();
+ });
+
+ // Handle adding new styles
+ var styles_hash_index = 1;
+ $('.add_new_style').live("click", function(e) {
+ e.preventDefault();
+ $('#new-styles').append(generate_html_for_hash("new_slide_styles", styles_hash_index));
+ });
+
+ // Generates html for new paperclip styles form fields
+ generate_html_for_hash = function(hash_name, index) {
+ var html = '<div class="' + hash_name + ' row"><div class="field">';
+ html += '<div class="five columns">';
+ html += '<label for="' + hash_name + '_' + index + '_name">';
+ html += Spree.translations.name + '</label>';
+ html += '<input id="' + hash_name + '_' + index + '_name" name="' + hash_name + '[' + index + '][name]" type="text" class="fullwidth"><br>';
+ html += '</div><div class="five columns">'
+ html += '<label for="' + hash_name + '_' + index + '_value">';
+ html += Spree.translations.value + '</label>';
+ html += '<input id="' + hash_name + '_' + index + '_value" name="' + hash_name + '[' + index + '][value]" type="text" class="fullwidth">';
+ html += '</div><div class="two columns">'
+ html += '<a href="#" title="' + Spree.translations.destroy + '" class="destroy_' + hash_name + ' with-tip button" style="margin-top: 19px;"><i class="icon-trash"></i> &nbsp; ' + Spree.translations.destroy + '</a>';
+ html += '</div></div></div>';
+
+ index += 1;
+ return html;
+ };
+
+
+
+});
View
42 app/assets/javascripts/store/spree_multi_slideshow.js
@@ -438,10 +438,10 @@
if(type == 'slide'){
// set the property value
el.css(slider.animProp, propValue);
- // bind a callback method - executes when CSS transition completes
- el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){
- // unbind the callback
- el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
+ // on a callback method - executes when CSS transition completes
+ el.on('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){
+ // off the callback
+ el.off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
updateAfterSlideTransition();
});
}else if(type == 'reset'){
@@ -450,10 +450,10 @@
// make the transition use 'linear'
el.css('-' + slider.cssPrefix + '-transition-timing-function', 'linear');
el.css(slider.animProp, propValue);
- // bind a callback method - executes when CSS transition completes
- el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){
- // unbind the callback
- el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
+ // on a callback method - executes when CSS transition completes
+ el.on('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){
+ // off the callback
+ el.off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
// reset the position
setPositionProperty(params['resetValue'], 'reset', 0);
// start the loop again
@@ -534,9 +534,9 @@
var appendControls = function(){
slider.controls.next = $('<a class="bx-next" href="">' + slider.settings.nextText + '</a>');
slider.controls.prev = $('<a class="bx-prev" href="">' + slider.settings.prevText + '</a>');
- // bind click actions to the controls
- slider.controls.next.bind('click', clickNextBind);
- slider.controls.prev.bind('click', clickPrevBind);
+ // on click actions to the controls
+ slider.controls.next.on('click', clickNextBind);
+ slider.controls.prev.on('click', clickPrevBind);
// if nextSlector was supplied, populate it
if(slider.settings.nextSelector){
$(slider.settings.nextSelector).append(slider.controls.next);
@@ -564,7 +564,7 @@
slider.controls.stop = $('<div class="bx-controls-auto-item"><a class="bx-stop" href="">' + slider.settings.stopText + '</a></div>');
// add the controls to the DOM
slider.controls.autoEl = $('<div class="bx-controls-auto" />');
- // bind click actions to the controls
+ // on click actions to the controls
slider.controls.autoEl.delegate('.bx-start', 'click', clickStartBind);
slider.controls.autoEl.delegate('.bx-stop', 'click', clickStopBind);
// if autoControlsCombine, insert only the "start" control
@@ -852,7 +852,7 @@
start: {x: 0, y: 0},
end: {x: 0, y: 0}
}
- slider.viewport.bind('touchstart', onTouchStart);
+ slider.viewport.on('touchstart', onTouchStart);
}
/**
@@ -871,10 +871,10 @@
// record the starting touch x, y coordinates
slider.touch.start.x = orig.changedTouches[0].pageX;
slider.touch.start.y = orig.changedTouches[0].pageY;
- // bind a "touchmove" event to the viewport
- slider.viewport.bind('touchmove', onTouchMove);
- // bind a "touchend" event to the viewport
- slider.viewport.bind('touchend', onTouchEnd);
+ // on a "touchmove" event to the viewport
+ slider.viewport.on('touchmove', onTouchMove);
+ // on a "touchend" event to the viewport
+ slider.viewport.on('touchend', onTouchEnd);
}
}
@@ -909,7 +909,7 @@
* - DOM event object
*/
var onTouchEnd = function(e){
- slider.viewport.unbind('touchmove', onTouchMove);
+ slider.viewport.off('touchmove', onTouchMove);
var orig = e.originalEvent;
var value = 0;
// record end x, y positions
@@ -947,7 +947,7 @@
}
}
}
- slider.viewport.unbind('touchend', onTouchEnd);
+ slider.viewport.off('touchend', onTouchEnd);
}
/**
@@ -1172,6 +1172,6 @@
/*jshint curly: true, eqeqeq: true, noempty: true, strict: true, undef: true, browser: true */
/*global jQuery: false */
-(function(c,n){var l="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";c.fn.imagesLoaded=function(f){function m(){var b=c(i),a=c(h);d&&(h.length?d.reject(e,b,a):d.resolve(e));c.isFunction(f)&&f.call(g,e,b,a)}function j(b,a){b.src===l||-1!==c.inArray(b,k)||(k.push(b),a?h.push(b):i.push(b),c.data(b,"imagesLoaded",{isBroken:a,src:b.src}),o&&d.notifyWith(c(b),[a,e,c(i),c(h)]),e.length===k.length&&(setTimeout(m),e.unbind(".imagesLoaded")))}var g=this,d=c.isFunction(c.Deferred)?c.Deferred():
-0,o=c.isFunction(d.notify),e=g.find("img").add(g.filter("img")),k=[],i=[],h=[];c.isPlainObject(f)&&c.each(f,function(b,a){if("callback"===b)f=a;else if(d)d[b](a)});e.length?e.bind("load.imagesLoaded error.imagesLoaded",function(b){j(b.target,"error"===b.type)}).each(function(b,a){var d=a.src,e=c.data(a,"imagesLoaded");if(e&&e.src===d)j(a,e.isBroken);else if(a.complete&&a.naturalWidth!==n)j(a,0===a.naturalWidth||0===a.naturalHeight);else if(a.readyState||a.complete)a.src=l,a.src=d}):m();return d?d.promise(g):
+(function(c,n){var l="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";c.fn.imagesLoaded=function(f){function m(){var b=c(i),a=c(h);d&&(h.length?d.reject(e,b,a):d.resolve(e));c.isFunction(f)&&f.call(g,e,b,a)}function j(b,a){b.src===l||-1!==c.inArray(b,k)||(k.push(b),a?h.push(b):i.push(b),c.data(b,"imagesLoaded",{isBroken:a,src:b.src}),o&&d.notifyWith(c(b),[a,e,c(i),c(h)]),e.length===k.length&&(setTimeout(m),e.off(".imagesLoaded")))}var g=this,d=c.isFunction(c.Deferred)?c.Deferred():
+0,o=c.isFunction(d.notify),e=g.find("img").add(g.filter("img")),k=[],i=[],h=[];c.isPlainObject(f)&&c.each(f,function(b,a){if("callback"===b)f=a;else if(d)d[b](a)});e.length?e.on("load.imagesLoaded error.imagesLoaded",function(b){j(b.target,"error"===b.type)}).each(function(b,a){var d=a.src,e=c.data(a,"imagesLoaded");if(e&&e.src===d)j(a,e.isBroken);else if(a.complete&&a.naturalWidth!==n)j(a,0===a.naturalWidth||0===a.naturalHeight);else if(a.readyState||a.complete)a.src=l,a.src=d}):m();return d?d.promise(g):
g}})(jQuery);
View
45 app/controllers/spree/admin/slide_settings_controller.rb
@@ -0,0 +1,45 @@
+module Spree
+ module Admin
+ class SlideSettingsController < Spree::Admin::BaseController
+ def edit
+ @styles = ActiveSupport::JSON.decode(Spree::Config[:attachment_styles])
+ end
+
+ def update
+ update_styles(params)
+
+ Spree::Config.set(params[:preferences])
+ update_paperclip_settings
+
+ respond_to do |format|
+ format.html {
+ flash[:success] = t(:slide_settings_updated)
+ redirect_to edit_admin_image_settings_path
+ }
+ end
+ end
+
+
+ private
+
+ def update_styles(params)
+ params[:new_slide_styles].each do |index, style|
+ params[:slide_styles][style[:name]] = style[:value] unless style[:value].empty?
+ end if params[:new_slide_styles].present?
+
+ styles = params[:slide_styles]
+
+ Spree::Config[:slide_styles] = ActiveSupport::JSON.encode(styles) unless styles.nil?
+ end
+
+ def update_paperclip_settings
+
+ Spree::Slide.attachment_definitions[:attachment][:styles] = ActiveSupport::JSON.decode(Spree::Config[:slide_styles])
+ Spree::Slide.attachment_definitions[:attachment][:path] = Spree::Config[:slide_path]
+ Spree::Slide.attachment_definitions[:attachment][:default_url] = Spree::Config[:slide_default_url]
+ Spree::Slide.attachment_definitions[:attachment][:default_style] = Spree::Config[:slide_default_style]
+ end
+ end
+ end
+end
+
View
15 app/controllers/spree/admin/slides_controller.rb
@@ -6,25 +6,14 @@ class SlidesController < ResourceController
create.before :set_slideshow
update.before :set_slideshow
destroy.before :destroy_before
-
- def update_positions
- params[:positions].each do |id, index|
- Spree::Slide.update_all(['position=?', index], ['id=?', id])
- end
-
- respond_to do |format|
- format.html { redirect_to admin_slideshow_slides_url(@slideshow) }
- format.js { render :text => 'Ok' }
- end
- end
private
def location_after_save
- admin_slideshow_images_url(@slideshow)
+ admin_slideshow_slides_url(@slideshow)
end
def load_data
- @slideshow = Spree::Slideshow.find(params[:slideshow_id].to_i)
+ @slideshow = Spree::Slideshow.find(params[:slideshow_id])
end
def set_slideshow
View
6 app/controllers/spree/admin/slideshows_controller.rb
@@ -1,7 +1,11 @@
module Spree
module Admin
class SlideshowsController < ResourceController
-
+
+ def show
+ redirect_to( :action => :edit )
+ end
+
def location_after_save
edit_admin_slideshow_url(@slideshow)
end
View
16 app/helpers/spree/slideshows_helper.rb
@@ -6,7 +6,7 @@ def insert_slideshow(params={})
params[:id] ||= "slideshow"
params[:class] ||= "first_slideshow"
params[:category] ||= "home"
- params[:auto_play] ||= false
+ params[:auto] ||= false
params[:next_text] ||= '>>'
params[:prev_text] ||= '<<'
params[:next_selector] ||= 'bx-next'
@@ -22,7 +22,9 @@ def insert_slideshow(params={})
res << "<script type='text/javascript'>
$(function() {
$('##{params[:id]}').bxSlider({
- auto: #{params[:auto_play]},
+ auto: #{params[:auto]},
+ autoStart: #{@@slideshow.auto_start},
+ mode: #{@@slideshow.mode},
controls: #{@@slideshow.enable_navigation},
nextText: '#{params[:next_text]}',
nextSelector: '#{params[:next_selector]}',
@@ -30,6 +32,8 @@ def insert_slideshow(params={})
prevSelector: '#{params[:prev_selector]}',
speed: 2000,
pager: #{@@slideshow.enable_pagination},
+ infiniteLoop: #{@@slideshow.infinite_loop},
+ hideControlOnEnd: #{@@slideshow.hide_control_on_end},
autoHover: true,
pagerSelector: '#{params[:pagination_class]}'
});
@@ -40,10 +44,10 @@ def insert_slideshow(params={})
end
def slide_images(params, slideshow)
- params[:style] ||= "custom"
+ params[:style] ||= "medium"
params[:show_content] ||= false
- max = slideshow.slides.count
- slides = slideshow.slides.limit(max).sort_by { |slide| slide.position }
+ max = slideshow.slides.enable.count
+ slides = slideshow.slides.enable.limit(max).sort_by { |slide| slide.position }
slides.map do |slide|
content_tag(:div, :class => "slide_list") do
@@ -51,7 +55,7 @@ def slide_images(params, slideshow)
divs << link_to(image_tag(slide.attachment.url(params[:style].to_sym)), (slide.url.blank? ? "javascript: void(0)" : slide.url), { :title => slide.title })
if params[:show_content]
- divs << content_tag(:div, content_tag(:strong, raw(slide.title)) + content_tag(:p, raw(slide.content)), :class => "caption")
+ divs << content_tag(:div, content_tag(:strong, raw(slide.title)) + content_tag(:p, raw(slide.presentation)), :class => "caption")
end
divs.join.html_safe
View
25 app/models/spree/app_configuration_decorator.rb
@@ -0,0 +1,25 @@
+# This is the primary location for defining spree preferences
+#
+# The expectation is that this is created once and stored in
+# the spree environment
+#
+# setters:
+# a.color = :blue
+# a[:color] = :blue
+# a.set :color = :blue
+# a.preferred_color = :blue
+#
+# getters:
+# a.color
+# a[:color]
+# a.get :color
+# a.preferred_color
+#
+Spree::AppConfiguration.class_eval do
+ # Preferences related to slide settings
+ preference :slide_default_url, :string, :default => '/spree/slides/:id/:style/:basename.:extension'
+ preference :slide_path, :string, :default => ':rails_root/public/spree/slides/:id/:style/:basename.:extension'
+ preference :slide_url, :string, :default => '/spree/slides/:id/:style/:basename.:extension'
+ preference :slide_styles, :string, :default => "{\"mini\":\"60x60#\",\"small\":\"300x100#\",\"medium\":\"600x200#\",\"large\":\"900x300#\"}"
+ preference :slide_default_style, :string, :default => 'medium'
+end
View
3  app/models/spree/product_decorator.rb
@@ -0,0 +1,3 @@
+Spree::Product.class_eval do
+ has_many :slides, :as => :slideable
+end
View
35 app/models/spree/slide.rb
@@ -2,45 +2,40 @@ module Spree
class Slide < ActiveRecord::Base
belongs_to :slideshow
+ belongs_to :slideable, :polymorphic => true
+
validate :no_attachment_errors
validates_presence_of :slideshow_id
validates_attachment_presence :attachment
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"
attr_accessor :attachment_width, :attachment_height
- attr_accessible :title, :url, :attachment_width, :attachment_height, :content, :slideshow_id, :attachment
+ attr_accessible :title, :url, :attachment_width, :attachment_height, :presentation, :slideshow_id, :attachment
has_attached_file :attachment,
:url => "/spree/slides/:id/:style_:basename.:extension",
:path => ":rails_root/public/spree/slides/:id/:style_:basename.:extension",
- :styles => lambda {|a|
- {
- :thumbnail => "100x33#",
+ :styles => ->(a) {{
+ :mini => "60x60#",
:small => "300x100#",
:medium => "600x200#",
- :slide => "900x300#",
+ :large => "900x300#",
:custom => "#{a.instance.attachment_width}x#{a.instance.attachment_height}#"
- }
- },
- :convert_options => {
- :thumbnail => "-gravity center",
- :small => "-gravity center",
- :medium => "-gravity center",
- :slide => "-gravity center",
- :custom => "-gravity center"
- }
+ }},
+ :convert_options => { :all => '-strip -auto-orient' }
# save the w,h of the original image (from which others can be calculated)
# we need to look at the write-queue for images which have not been saved yet
after_post_process :find_dimensions
+ scope :enable, {:conditions => {:enabled => true}}
include Spree::Core::S3Support
supports_s3 :attachment
- Spree::Slide.attachment_definitions[:attachment][:styles] = ActiveSupport::JSON.decode(Spree::Config[:attachment_styles])
- Spree::Slide.attachment_definitions[:attachment][:path] = Spree::Config[:attachment_path]
- Spree::Slide.attachment_definitions[:attachment][:url] = Spree::Config[:attachment_url]
- Spree::Slide.attachment_definitions[:attachment][:default_url] = Spree::Config[:attachment_default_url]
- Spree::Slide.attachment_definitions[:attachment][:default_style] = Spree::Config[:attachment_default_style]
+ Spree::Slide.attachment_definitions[:attachment][:styles] = ActiveSupport::JSON.decode(Spree::Config[:slide_styles])
+ Spree::Slide.attachment_definitions[:attachment][:path] = Spree::Config[:slide_path]
+ Spree::Slide.attachment_definitions[:attachment][:url] = Spree::Config[:slide_url]
+ Spree::Slide.attachment_definitions[:attachment][:default_url] = Spree::Config[:slide_default_url]
+ Spree::Slide.attachment_definitions[:attachment][:default_style] = Spree::Config[:slide_default_style]
def initialize(*args)
super(*args)
@@ -53,7 +48,7 @@ def find_dimensions
filename = temporary.path unless temporary.nil?
filename = attachment.path if filename.blank?
geometry = Paperclip::Geometry.from_file(filename)
- self.attachment_width = geometry.width
+ self.attachment_width = geometry.width
self.attachment_height = geometry.height
end
View
7 app/models/spree/slideshow.rb
@@ -2,11 +2,16 @@ module Spree
class Slideshow < ActiveRecord::Base
has_many :slides
- attr_accessible :category, :enable_navigation, :enabled
+ attr_accessible :category, :enable_navigation, :enabled, :mode,
+ :auto_start, :infinite_loop, :hide_control_on_end
validates :category, :presence => true
validates_uniqueness_of :category
scope :enable, lambda { |category| {:conditions => {:enabled => true, :category => category}} }
+
+ def mode_enum
+ [["Orizzontale", "horizontal"], ["Dissolvenza", "fade"], ["Verticale", "vertical"]]
+ end
end
end
View
3  app/models/spree/taxon_decorator.rb
@@ -0,0 +1,3 @@
+Spree::Taxon.class_eval do
+ has_many :slides, :as => :slideable
+end
View
8 app/overrides/slideshow_admin_tab.rb
@@ -1,4 +1,10 @@
Deface::Override.new(:virtual_path => "spree/layouts/admin",
:name => "slideshow_admin_tab",
:insert_bottom => "[data-hook='admin_tabs']",
- :text => "<%= tab(:slideshows) %>")
+ :text => "<%= tab(:slideshows) %>")
+
+Deface::Override.new(:virtual_path => "spree/admin/shared/_configuration_menu",
+ :name => "add_slide_settings_link_configuration_menu",
+ :insert_bottom => "[data-hook='admin_configurations_sidebar_menu']",
+ :text => "<%= configurations_sidebar_menu_item t(:slide_settings), edit_admin_slide_settings_path %>")
+
View
34 app/views/spree/admin/shared/_slideshow_tabs.html.erb
@@ -1,17 +1,21 @@
-<h1><%= t(:editing_slideshow) %> &ldquo;<%= @slideshow.category %>&rdquo;</h1>
+<% content_for :page_title do %>
+ <%= t(:editing_slideshow) %> &ldquo;<%= @slideshow.category %>&rdquo;
+<% end %>
+
+<% content_for :sidebar_title do %>
+ <span class="category"><%= @slideshow.category %></span>
+<% end %>
<% content_for :sidebar do %>
-
- <h3><%= @slideshow.category %></h3>
- <br class="clear" />
-
- <ul class="sidebar slideshow-menu" data-hook="admin_slideshow_tabs">
- <li<%== ' class="active"' if current == 'Slideshow Details' %>>
- <%= link_to t(:slideshow_details), edit_admin_slideshow_url(@slideshow) %>
- </li>
- <li<%== ' class="active"' if current == 'Slides' %>>
- <%= link_to t(:slides), admin_slideshow_slides_path(@slideshow) %>
- </li>
- </ul>
- <br class="clear" />
-<% end %>
+ <nav class="menu">
+ <ul data-hook="admin_slideshow_tabs">
+ <li<%== ' class="active"' if current == 'Slideshow Details' %>>
+ <%= link_to_with_icon 'icon-edit', t(:slideshow_details), edit_admin_slideshow_url(@slideshow) %>
+ </li>
+ <li<%== ' class="active"' if current == 'Slides' %>>
+ <%= link_to_with_icon 'icon-picture', t(:slides), admin_product_slides_url(@slideshow) %>
+ </li>
+ </ul>
+ </nav>
+
+<% end %>
View
72 app/views/spree/admin/slide_settings/edit.html.erb
@@ -0,0 +1,72 @@
+<%= render :partial => 'spree/admin/shared/configuration_menu' %>
+
+<% content_for :page_title do %>
+ <%= t(:slide_settings) %>
+<% end %>
+
+<%= form_tag admin_slide_settings_path, :method => :put do %>
+
+ <fieldset class="no-border-top">
+ <fieldset class="no-border-bottom">
+ <legend align="center"><%= t(:general_settings)%></legend>
+
+ <div class="field">
+ <div class="warning note"><%= t(:slide_settings_warning) %></div>
+ </div>
+
+ <div data-hook="slide_path" class="field">
+ <%= label_tag 'preferences[slide_path]', t(:slide_path) %>
+ <%= preference_field_tag 'preferences[slide_path]', Spree::Config[:slide_path], :type => :string %>
+ </div>
+
+ <div class="alpha eight columns">
+ <div data-hook="slide_default_url" class="field">
+ <%= label_tag 'preferences[slide_default_url]', t(:slide_default_url) %>
+ <%= preference_field_tag 'preferences[slide_default_url]', Spree::Config[:slide_default_url], :type => :string %>
+ </div>
+ </div>
+
+ <div class="alpha eight columns">
+ <div data-hook="slide_url" class="field">
+ <%= label_tag 'preferences[slide_url]', t(:slide_url) %>
+ <%= preference_field_tag 'preferences[slide_url]', Spree::Config[:slide_url], :type => :string %>
+ </div>
+ </div>
+
+ <div class="omega four columns">
+ <div data-hook="slide_default_style" class="field">
+ <%= label_tag 'preferences[slide_default_style]', t(:slide_default_style) %>
+ <%= collection_select 'preferences', 'slide_default_style', @styles, :first, :first, {:selected => Spree::Config[:slide_default_style] }, :class => 'select2 fullwidth' %>
+ </div>
+ </div>
+
+ <div class="clear"></div>
+
+ </fieldset>
+
+ <fieldset class="no-border-bottom" id="slide_styles" data-hook="attachment_styles">
+ <legend align="center"><%= t(:slide_styles) %></legend>
+
+ <div id="styles_list" class="row frameless">
+ <% @styles.each_with_index do |(style_name, style_value), index| %>
+ <div class="field three columns">
+ <%= label_tag "slide_styles[#{style_name}]", style_name %>
+ <a href='#' alt="<%= t(:destroy)%>" title="<%= t(:destroy)%>" class='destroy_style with-tip'><i class='icon-trash'></i></a>
+ <%= text_field_tag "slide_styles[#{style_name}]", style_value, :class => 'fullwidth' %>
+ </div>
+ <% end %>
+ </div>
+
+ <div id="new-styles" class="row frameless"></div>
+
+ <div class="field">
+ <%= link_to_with_icon 'icon-plus', t(:add_new_style), '#', :class => 'add_new_style button' %>
+ </div>
+ </fieldset>
+
+ <div class="form-buttons filter-actions actions" data-hook="buttons">
+ <%= button t(:update), 'icon-refresh' %>
+ </div>
+ </fieldset>
+
+<% end %>
View
49 app/views/spree/admin/slides/_form.html.erb
@@ -1,19 +1,30 @@
-<%= f.hidden_field :slideshow_id, :value => params[:slideshow_id] %>
-<div data-hook="admin_image_form_fields">
- <tr data-hook="file">
- <td><%= t(:filename) %>:</td>
- <td><%= f.file_field :attachment %></td>
- </tr>
- <tr data-hook="title">
- <td><%= t(:title) %>:</td>
- <td><%= f.text_field :title %></td>
- </tr>
- <tr data-hook="url">
- <td><%= t(:url) %>:</td>
- <td><%= f.text_field :url %></td>
- </tr>
- <tr data-hook="content">
- <td><%= t(:content) %>:</td>
- <td><%= f.text_area :content %></td>
- </tr>
-</div>
+<div data-hook="admin_slide_form_fields">
+ <div class="four columns alpha">
+ <div data-hook="file" class="field">
+ <%= f.label t(:filename) %><br>
+ <%= f.file_field :attachment %>
+ </div>
+ <div data-hook="enabled" class="field">
+ <%= f.field_container :enabled, :class => ['checkbox'] do %>
+ <label>
+ <%= f.check_box :enabled %>
+ <%= t(:enabled) %>
+ </label>
+ <% end %>
+ </div>
+ <div data-hook="url" class="field">
+ <%= f.label t(:url) %><br>
+ <%= f.text_field :url, :class => 'fullwidth' %>
+ </div>
+ <div data-hook="title" class="field">
+ <%= f.label t(:title) %><br>
+ <%= f.text_field :title, :class => 'fullwidth' %>
+ </div>
+ </div>
+ <div data-hook="presentation" class="field omega five columns">
+ <%= f.label t(:presentation) %><br>
+ <%= f.text_area :presentation, :rows => 4, :class => 'fullwidth' %>
+ </div>
+</div>
+
+<div class="clear"></div>
View
55 app/views/spree/admin/slideshows/_form.html.erb
@@ -1,30 +1,35 @@
<div data-hook="admin_slideshow_form_fields">
- <div class="clearfix">
- <div class="left" data-hook="admin_slidewhos_form_left">
- <%= f.field_container :category do %>
- <%= f.label :category, t(:category) %> <span class="required">*</span><br />
- <%= f.text_field :category, :class => 'fullwidth title' %>
- <%= f.error_message_on :category %>
- <% end %>
+ <div class="left eight columns alpha" data-hook="admin_slideshow_form_left">
+ <%= f.field_container :category do %>
+ <%= f.label :category, t(:category) %> <span class="required">*</span><br />
+ <%= f.text_field :category, :class => 'fullwidth title' %>
+ <%= f.error_message_on :category %>
+ <% end %>
- <%= f.field_container :enable_navigation do %>
- <%= f.label :enable_navigation, t(:enable_navigation) %><br />
- <%= f.check_box :enable_navigation %>
- <%= f.error_message_on :enable_navigation %>
- <% end %>
- </div>
- <div class="right" data-hook="admin_product_form_right">
- <%= f.field_container :enable_pagination do %>
- <%= f.label :enable_pagination, t(:enable_pagination) %><br />
- <%= f.check_box :enable_pagination %>
- <%= f.error_message_on :enable_pagination %>
- <% end %>
+ <%= f.field_container :enable_navigation do %>
+ <%= f.label :enable_navigation, t(:enable_navigation) %><br />
+ <%= f.check_box :enable_navigation %>
+ <%= f.error_message_on :enable_navigation %>
+ <% end %>
+ </div>
+ <div class="right four columns omega" data-hook="admin_slideshow_form_right">
+ <%= f.field_container :enable_pagination do %>
+ <%= f.label :enable_pagination, t(:enable_pagination) %><br />
+ <%= f.check_box :enable_pagination %>
+ <%= f.error_message_on :enable_pagination %>
+ <% end %>
- <%= f.field_container :enabled do %>
- <%= f.label :enabled, t(:enabled) %><br />
- <%= f.check_box :enabled %>
- <%= f.error_message_on :enabled %>
- <% end %>
- </div>
+ <%= f.field_container :enabled do %>
+ <%= f.label :enabled, t(:enabled) %><br />
+ <%= f.check_box :enabled %>
+ <%= f.error_message_on :enabled %>
+ <% end %>
</div>
+
+ <div class="clear"></div>
+
+ <div data-hook="admin_slideshow_form_additional_fields"></div>
+
+ <div class="clear"></div>
+
</div>
View
19 app/views/spree/admin/slideshows/edit.html.erb
@@ -1,7 +1,16 @@
-<%= render :partial => 'spree/admin/shared/slideshow_tabs', :locals => {:current => 'Slideshow Details'} %>
-<%= render "spree/shared/error_messages", :target => @slideshow %>
+<% content_for :page_actions do %>
+ <li><%= button_link_to t(:back_to_slideshows_list), session[:return_to] || admin_slideshows_url, :icon => 'icon-arrow-left' %></li>
+ <li id="new_slideshow_link">
+ <%= button_link_to t(:new_slideshow), new_object_url, { :remote => true, :icon => 'icon-plus', :id => 'admin_new_slideshow' } %>
+ </li>
+<% end %>
+
+<%= render :partial => 'spree/admin/shared/slideshow_tabs', :locals => { :current => 'Slideshow Details' } %>
+<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @slideshow } %>
<%= form_for [:admin, @slideshow], :method => :put, :html => { :multipart => true } do |f| %>
- <%= render :partial => "form", :locals => { :f => f } %>
- <%= render :partial => 'spree/admin/shared/edit_resource_links' %>
-<% end %>
+ <fieldset class="no-border-top">
+ <%= render :partial => 'form', :locals => { :f => f } %>
+ <%= render :partial => 'spree/admin/shared/edit_resource_links' %>
+ </fieldset>
+<% end %>
View
21 app/views/spree/admin/slideshows/index.html.erb
@@ -1,13 +1,16 @@
-<div class="toolbar" data-hook="toolbar">
- <ul class="actions">
- <li id="new_slideshow_link">
- <%= button_link_to t(:new_slideshow), new_object_url, { :remote => true, :icon => 'add', :id => 'admin_new_slideshow' } %>
- </li>
- </ul>
- <br class="clear" />
-</div>
+<% content_for :page_title do %>
+ <%= t(:listing_slideshows) %>
+<% end %>
-<h1><%= t(:listing_slideshows) %></h1>
+<% content_for :page_actions do %>
+ <div class="toolbar" data-hook="toolbar">
+ <ul class="actions header-action-links inline-menu">
+ <li id="new_slideshow_link">
+ <%= button_link_to t(:new_slideshow), new_object_url, { :remote => true, :icon => 'icon-plus', :id => 'admin_new_slideshow' } %>
+ </li>
+ </ul>
+ </div>
+<% end %>
<div id="new_slideshow" data-hook></div>
View
71 app/views/spree/admin/slideshows/new.html.erb
@@ -1,35 +1,46 @@
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @slideshow } %>
<%= form_for [:admin, @slideshow], :html => { :multipart => true } do |f| %>
+
<fieldset data-hook="new_slideshow">
- <div class="clearfix" data-hook="new_slideshow_attrs">
- <div class="left">
- <%= f.field_container :category do %>
- <%= f.label :category, t(:category) %> <span class="required">*</span><br />
- <%= f.text_field :category, :class => 'fullwidth title' %>
- <%= f.error_message_on :category %>
- <% end %>
-
- <%= f.field_container :enable_navigation do %>
- <%= f.label :enable_navigation, t(:enable_navigation) %><br />
- <%= f.check_box :enable_navigation %>
- <%= f.error_message_on :enable_navigation %>
- <% end %>
- </div>
- <div class="right">
- <%= f.field_container :enable_pagination do %>
- <%= f.label :enable_pagination, t(:enable_pagination) %><br />
- <%= f.check_box :enable_pagination %>
- <%= f.error_message_on :enable_pagination %>
- <% end %>
-
- <%= f.field_container :enabled do %>
- <%= f.label :enabled, t(:enabled) %><br />
- <%= f.check_box :enabled %>
- <%= f.error_message_on :enabled %>
- <% end %>
- </div>
- </div>
- <%= render :partial => 'spree/admin/shared/new_resource_links' %>
+
+ <legend align="center"><%= t(:new_slideshow) %></legend>
+
+ <%= f.field_container :category do %>
+ <%= f.label :category, t(:category) %> <span class="required">*</span><br />
+ <%= f.text_field :category, :class => 'fullwidth title' %>
+ <%= f.error_message_on :category %>
+ <% end %>
+
+ <div data-hook="new_slideshow_attrs" class="row">
+
+ <div class="four columns">
+ <%= f.field_container :enable_navigation do %>
+ <%= f.label :enable_navigation, t(:enable_navigation) %><br />
+ <%= f.check_box :enable_navigation %>
+ <%= f.error_message_on :enable_navigation %>
+ <% end %>
+ </div>
+
+ <div class="four columns">
+ <%= f.field_container :enable_pagination do %>
+ <%= f.label :enable_pagination, t(:enable_pagination) %><br />
+ <%= f.check_box :enable_pagination %>
+ <%= f.error_message_on :enable_pagination %>
+ <% end %>
+ </div>
+
+ <div class="omega four columns">
+ <%= f.field_container :enabled do %>
+ <%= f.label :enabled, t(:enabled) %><br />
+ <%= f.check_box :enabled %>
+ <%= f.error_message_on :enabled %>
+ <% end %>
+ </div>
+
+ </div>
+
+ <%= render :partial => 'spree/admin/shared/new_resource_links' %>
+
</fieldset>
-<% end %>
+<% end %>
View
2  app/views/spree/admin/slideshows/new.js.erb
@@ -1,2 +1,2 @@
$("#new_slideshow").html('<%= escape_javascript(render :template => "spree/admin/slideshows/new", :formats => [:html], :handlers => [:erb]) %>');
-$("#admin_new_slideshow").parent().hide();
+$("#admin_new_slideshow").parent().hide();
View
2  config/routes.rb
@@ -8,6 +8,8 @@
end
end
end
+
+ resource :slide_settings
end
end
View
4 db/migrate/20120116081431_create_slideshows.rb
@@ -3,6 +3,10 @@ def change
create_table :slideshows do |t|
t.string :category
t.boolean :enabled, :default => false
+ t.string :mode, :default => 'horizontal'
+ t.boolean :auto_start, :default => false
+ t.boolean :infinite_loop, :default => false
+ t.boolean :hide_control_on_end, :default => true
t.boolean :enable_navigation, :default => true
t.boolean :enable_pagination, :default => false
View
6 db/migrate/20120116083546_create_slides.rb
@@ -2,12 +2,14 @@ class CreateSlides < ActiveRecord::Migration
def change
create_table :slides do |t|
t.string :title, :url
- t.text :content
+ t.text :presentation
+ t.boolean :enabled, :default => true
t.string :attachment_content_type, :attachment_file_name
t.datetime :attachment_updated_at
t.integer :attachment_size, :position
-
+
+ t.references :slideable, :polymorphic => true
t.references :slideshow
t.timestamps
View
7 spree_multi_slideshow.gemspec
@@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'spree_multi_slideshow'
- s.version = '1.2.2'
+ s.version = '1.3.0'
s.summary = 'Extension to manage multi slideshow for Spree Shop'
s.required_ruby_version = '>= 1.8.7'
@@ -15,10 +15,9 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'
- s.add_dependency 'spree_core'
+ s.add_dependency 'spree_core', '>= 1.3.0'
s.add_dependency 'aws-sdk'
- s.add_dependency 'paperclip'
- s.add_development_dependency 'rspec-rails'
+ s.add_dependency 'paperclip'
end
Please sign in to comment.
Something went wrong with that request. Please try again.