spree_multi_slideshow 0.70.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +26 -0
- data/README.md +38 -0
- data/app/assets/images/store/slides/bg-gallery.png +0 -0
- data/app/assets/images/store/slides/bg-text02.png +0 -0
- data/app/assets/images/store/slides/sprite01.png +0 -0
- data/app/assets/javascripts/admin/slides/index.js +10 -0
- data/app/assets/javascripts/admin/slides/new.js +5 -0
- data/app/assets/javascripts/admin/spree_multi_slideshow.js +1 -0
- data/app/assets/javascripts/store/spree_multi_slideshow.js +231 -0
- data/app/assets/stylesheets/admin/spree_multi_slideshow.css +3 -0
- data/app/assets/stylesheets/store/spree_multi_slideshow.css +73 -0
- data/app/controllers/admin/slides_controller.rb +24 -0
- data/app/controllers/admin/slideshow_types_controller.rb +7 -0
- data/app/controllers/spree/slides_controller.rb +5 -0
- data/app/controllers/spree/slideshow_types_controller.rb +5 -0
- data/app/helpers/slides_helper.rb +2 -0
- data/app/helpers/slideshow_types_helper.rb +50 -0
- data/app/models/slide.rb +33 -0
- data/app/models/slideshow_type.rb +15 -0
- data/app/overrides/slideshow_type_admin_tab.rb +4 -0
- data/app/views/admin/shared/_slideshow_type_tabs.html.erb +16 -0
- data/app/views/admin/slides/_form.html.erb +6 -0
- data/app/views/admin/slides/edit.html.erb +17 -0
- data/app/views/admin/slides/index.html.erb +33 -0
- data/app/views/admin/slides/new.html.erb +12 -0
- data/app/views/admin/slideshow_types/_form.html.erb +8 -0
- data/app/views/admin/slideshow_types/edit.html.erb +8 -0
- data/app/views/admin/slideshow_types/index.html.erb +32 -0
- data/app/views/admin/slideshow_types/new.html.erb +7 -0
- data/lib/generators/spree_multi_slideshow/install/install_generator.rb +29 -0
- data/lib/spree_multi_slideshow.rb +2 -0
- data/lib/spree_multi_slideshow/engine.rb +24 -0
- metadata +169 -0
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Copyright (c) 2012 [name of plugin creator]
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
* Neither the name Spree nor the names of its contributors may be used to
|
13
|
+
endorse or promote products derived from this software without specific
|
14
|
+
prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
20
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
SpreeMultiSlideshow
|
2
|
+
===================
|
3
|
+
|
4
|
+
Add multiple slideshow for Spree Commerce Shop
|
5
|
+
|
6
|
+
|
7
|
+
Basic Installation
|
8
|
+
------------------
|
9
|
+
|
10
|
+
1. Add the following to your Gemfile
|
11
|
+
<pre>
|
12
|
+
gem 'spree_multi_slideshow', :git => 'git://github.com/damianogiacomello/spree_multi_slideshow'
|
13
|
+
</pre>
|
14
|
+
2. Run `bundle install`
|
15
|
+
3. To copy and apply migrations run:
|
16
|
+
<pre>
|
17
|
+
rails g spree_multi_slideshow:install
|
18
|
+
</pre>
|
19
|
+
|
20
|
+
Example
|
21
|
+
=======
|
22
|
+
|
23
|
+
1. add slideshow helper method in your view:
|
24
|
+
<pre>
|
25
|
+
<%= insert_slideshow %>
|
26
|
+
</pre>
|
27
|
+
add slides for the slideshow in the admin section
|
28
|
+
2. Additional options:
|
29
|
+
<pre>
|
30
|
+
<%= insert_slideshow(:category => "my_category") %>
|
31
|
+
</pre>
|
32
|
+
displays slides for which the category column, dafault is "home"
|
33
|
+
<pre>
|
34
|
+
<%= insert_slideshow(:style => "small") %>
|
35
|
+
</pre>
|
36
|
+
style layout for slideshow: [small, medium, slide, default => custom]
|
37
|
+
|
38
|
+
Copyright (c) 2012 [Damiano Giacomello], released under the New BSD License
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,10 @@
|
|
1
|
+
$(document).ready(function(){
|
2
|
+
|
3
|
+
$('#new_slide_link').click(function (event) {
|
4
|
+
event.preventDefault();
|
5
|
+
$(this).hide();
|
6
|
+
$.ajax({type: 'GET', url: this.href, data: ({authenticity_token: AUTH_TOKEN}),
|
7
|
+
success: function(r){ $('#slides').html(r);} });
|
8
|
+
});
|
9
|
+
|
10
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require admin/spree_core
|
@@ -0,0 +1,231 @@
|
|
1
|
+
//= require store/spree_core
|
2
|
+
|
3
|
+
// page init
|
4
|
+
jQuery(function($) {
|
5
|
+
initGalleries();
|
6
|
+
});
|
7
|
+
|
8
|
+
// galleries init
|
9
|
+
function initGalleries(){
|
10
|
+
// main banner slideshow
|
11
|
+
jQuery('div.gallery').fadeGallery({
|
12
|
+
autoRotation: true,
|
13
|
+
switchTime: 5000, //ms
|
14
|
+
duration: 800 //ms
|
15
|
+
});
|
16
|
+
};
|
17
|
+
|
18
|
+
// slideshow plugin
|
19
|
+
jQuery.fn.fadeGallery = function(_options){
|
20
|
+
var _options = jQuery.extend({
|
21
|
+
slideElements:'div.frame > ul > li',
|
22
|
+
pagerGener: false,
|
23
|
+
pagerHold: false,
|
24
|
+
pagerLinks:'ul.nav-list li',
|
25
|
+
btnNext:'a.next',
|
26
|
+
btnPrev:'a.prev',
|
27
|
+
btnPlayPause:'a.play-pause',
|
28
|
+
btnPlay:'a.play',
|
29
|
+
btnPause:'a.pause',
|
30
|
+
pausedClass:'paused',
|
31
|
+
disabledClass: 'disabled',
|
32
|
+
playClass:'playing',
|
33
|
+
activeClass:'active',
|
34
|
+
currentNum:false,
|
35
|
+
allNum:false,
|
36
|
+
startSlide:null,
|
37
|
+
noCircle:false,
|
38
|
+
caption:'ul.caption > li',
|
39
|
+
pauseOnHover:false,
|
40
|
+
autoRotation:false,
|
41
|
+
autoHeight:false,
|
42
|
+
onChange:false,
|
43
|
+
switchTime:3000,
|
44
|
+
duration:650,
|
45
|
+
event:'click'
|
46
|
+
},_options);
|
47
|
+
|
48
|
+
return this.each(function(){
|
49
|
+
// gallery options
|
50
|
+
var _this = jQuery(this);
|
51
|
+
var _slides = jQuery(_options.slideElements, _this);
|
52
|
+
var _btnPrev = jQuery(_options.btnPrev, _this);
|
53
|
+
var _btnNext = jQuery(_options.btnNext, _this);
|
54
|
+
var _btnPlayPause = jQuery(_options.btnPlayPause, _this);
|
55
|
+
var _btnPause = jQuery(_options.btnPause, _this);
|
56
|
+
var _btnPlay = jQuery(_options.btnPlay, _this);
|
57
|
+
var _pauseOnHover = _options.pauseOnHover;
|
58
|
+
var _autoRotation = _options.autoRotation;
|
59
|
+
var _activeClass = _options.activeClass;
|
60
|
+
var _disabledClass = _options.disabledClass;
|
61
|
+
var _pausedClass = _options.pausedClass;
|
62
|
+
var _playClass = _options.playClass;
|
63
|
+
var _autoHeight = _options.autoHeight;
|
64
|
+
var _duration = _options.duration;
|
65
|
+
var _switchTime = _options.switchTime;
|
66
|
+
var _controlEvent = _options.event;
|
67
|
+
var _currentNum = (_options.currentNum ? jQuery(_options.currentNum, _this) : false);
|
68
|
+
var _allNum = (_options.allNum ? jQuery(_options.allNum, _this) : false);
|
69
|
+
var _startSlide = _options.startSlide;
|
70
|
+
var _noCycle = _options.noCircle;
|
71
|
+
var _onChange = _options.onChange;
|
72
|
+
var _pagerGener = _options.pagerGener;
|
73
|
+
var _pagerHold = jQuery(_options.pagerHold,_this);
|
74
|
+
var _caption = jQuery(_options.caption,_this);
|
75
|
+
var _paging = '';
|
76
|
+
if(_pagerGener){
|
77
|
+
for(var i=0; i< _slides.length; i++){
|
78
|
+
_paging += '<li><a href="#">'+(i+1)+'</a></li>';
|
79
|
+
}
|
80
|
+
_pagerHold.html('<ul>'+_paging+'</ul>');
|
81
|
+
}
|
82
|
+
var _pagerLinks = jQuery(_options.pagerLinks, _this);
|
83
|
+
// gallery init
|
84
|
+
var _hover = false;
|
85
|
+
var _prevIndex = 0;
|
86
|
+
var _currentIndex = 0;
|
87
|
+
var _slideCount = _slides.length;
|
88
|
+
var _timer;
|
89
|
+
if(_slideCount < 2) return;
|
90
|
+
|
91
|
+
_prevIndex = _slides.index(_slides.filter('.'+_activeClass));
|
92
|
+
if(_prevIndex < 0) _prevIndex = _currentIndex = 0;
|
93
|
+
else _currentIndex = _prevIndex;
|
94
|
+
if(_startSlide != null) {
|
95
|
+
if(_startSlide == 'random') _prevIndex = _currentIndex = Math.floor(Math.random()*_slideCount);
|
96
|
+
else _prevIndex = _currentIndex = parseInt(_startSlide);
|
97
|
+
}
|
98
|
+
_slides.hide().eq(_currentIndex).show();
|
99
|
+
_caption.hide().eq(_currentIndex).show();
|
100
|
+
if(_autoRotation) _this.removeClass(_pausedClass).addClass(_playClass);
|
101
|
+
else _this.removeClass(_playClass).addClass(_pausedClass);
|
102
|
+
|
103
|
+
// gallery control
|
104
|
+
if(_btnPrev.length) {
|
105
|
+
_btnPrev.bind(_controlEvent,function(){
|
106
|
+
prevSlide();
|
107
|
+
return false;
|
108
|
+
});
|
109
|
+
}
|
110
|
+
if(_btnNext.length) {
|
111
|
+
_btnNext.bind(_controlEvent,function(){
|
112
|
+
nextSlide();
|
113
|
+
return false;
|
114
|
+
});
|
115
|
+
}
|
116
|
+
if(_pagerLinks.length) {
|
117
|
+
_pagerLinks.each(function(_ind){
|
118
|
+
jQuery(this).bind(_controlEvent,function(){
|
119
|
+
if(_currentIndex != _ind) {
|
120
|
+
_prevIndex = _currentIndex;
|
121
|
+
_currentIndex = _ind;
|
122
|
+
switchSlide();
|
123
|
+
}
|
124
|
+
return false;
|
125
|
+
});
|
126
|
+
});
|
127
|
+
}
|
128
|
+
|
129
|
+
// play pause section
|
130
|
+
if(_btnPlayPause.length) {
|
131
|
+
_btnPlayPause.bind(_controlEvent,function(){
|
132
|
+
if(_this.hasClass(_pausedClass)) {
|
133
|
+
_this.removeClass(_pausedClass).addClass(_playClass);
|
134
|
+
_autoRotation = true;
|
135
|
+
autoSlide();
|
136
|
+
} else {
|
137
|
+
_autoRotation = false;
|
138
|
+
if(_timer) clearTimeout(_timer);
|
139
|
+
_this.removeClass(_playClass).addClass(_pausedClass);
|
140
|
+
}
|
141
|
+
return false;
|
142
|
+
});
|
143
|
+
}
|
144
|
+
if(_btnPlay.length) {
|
145
|
+
_btnPlay.bind(_controlEvent,function(){
|
146
|
+
_this.removeClass(_pausedClass).addClass(_playClass);
|
147
|
+
_autoRotation = true;
|
148
|
+
autoSlide();
|
149
|
+
return false;
|
150
|
+
});
|
151
|
+
}
|
152
|
+
if(_btnPause.length) {
|
153
|
+
_btnPause.bind(_controlEvent,function(){
|
154
|
+
_autoRotation = false;
|
155
|
+
if(_timer) clearTimeout(_timer);
|
156
|
+
_this.removeClass(_playClass).addClass(_pausedClass);
|
157
|
+
return false;
|
158
|
+
});
|
159
|
+
}
|
160
|
+
// gallery animation
|
161
|
+
function prevSlide() {
|
162
|
+
_prevIndex = _currentIndex;
|
163
|
+
if(_currentIndex > 0) _currentIndex--;
|
164
|
+
else {
|
165
|
+
if(_noCycle) return;
|
166
|
+
else _currentIndex = _slideCount-1;
|
167
|
+
}
|
168
|
+
switchSlide();
|
169
|
+
}
|
170
|
+
function nextSlide() {
|
171
|
+
_prevIndex = _currentIndex;
|
172
|
+
if(_currentIndex < _slideCount-1) _currentIndex++;
|
173
|
+
else {
|
174
|
+
if(_noCycle) return;
|
175
|
+
else _currentIndex = 0;
|
176
|
+
}
|
177
|
+
switchSlide();
|
178
|
+
}
|
179
|
+
function refreshStatus() {
|
180
|
+
if(_pagerLinks.length) _pagerLinks.removeClass(_activeClass).eq(_currentIndex).addClass(_activeClass);
|
181
|
+
if(_currentNum) _currentNum.text(_currentIndex+1);
|
182
|
+
if(_allNum) _allNum.text(_slideCount);
|
183
|
+
_slides.eq(_prevIndex).removeClass(_activeClass);
|
184
|
+
_slides.eq(_currentIndex).addClass(_activeClass);
|
185
|
+
if(_noCycle) {
|
186
|
+
if(_btnPrev.length) {
|
187
|
+
if(_currentIndex == 0) _btnPrev.addClass(_disabledClass);
|
188
|
+
else _btnPrev.removeClass(_disabledClass);
|
189
|
+
}
|
190
|
+
if(_btnNext.length) {
|
191
|
+
if(_currentIndex == _slideCount-1) _btnNext.addClass(_disabledClass);
|
192
|
+
else _btnNext.removeClass(_disabledClass);
|
193
|
+
}
|
194
|
+
}
|
195
|
+
if(typeof _onChange === 'function') {
|
196
|
+
_onChange(_this, _currentIndex);
|
197
|
+
}
|
198
|
+
}
|
199
|
+
function switchSlide() {
|
200
|
+
_slides.eq(_prevIndex).stop().animate({opacity:0},{duration: _duration, queue: false,complete:function(){
|
201
|
+
jQuery(this).css({display:'none'});
|
202
|
+
}})
|
203
|
+
_slides.eq(_currentIndex).stop().css({display:'block',opacity:0}).animate({opacity:1},{duration: _duration, queue: false,complete:function(){
|
204
|
+
jQuery(this).css({opacity:''});
|
205
|
+
}})
|
206
|
+
_caption.eq(_prevIndex).fadeOut();
|
207
|
+
_caption.eq(_currentIndex).fadeIn();
|
208
|
+
if(_autoHeight) _slides.eq(_currentIndex).parent().animate({height:_slides.eq(_currentIndex).outerHeight(true)},{duration:_duration,queue:false});
|
209
|
+
refreshStatus();
|
210
|
+
autoSlide();
|
211
|
+
}
|
212
|
+
|
213
|
+
// autoslide function
|
214
|
+
function autoSlide() {
|
215
|
+
if(!_autoRotation || _hover) return;
|
216
|
+
if(_timer) clearTimeout(_timer);
|
217
|
+
_timer = setTimeout(nextSlide,_switchTime+_duration);
|
218
|
+
}
|
219
|
+
if(_pauseOnHover) {
|
220
|
+
_this.hover(function(){
|
221
|
+
_hover = true;
|
222
|
+
if(_timer) clearTimeout(_timer);
|
223
|
+
},function(){
|
224
|
+
_hover = false;
|
225
|
+
autoSlide();
|
226
|
+
});
|
227
|
+
}
|
228
|
+
refreshStatus();
|
229
|
+
autoSlide();
|
230
|
+
});
|
231
|
+
};
|
@@ -0,0 +1,73 @@
|
|
1
|
+
/*
|
2
|
+
*= require store/spree_core
|
3
|
+
*/
|
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;
|
73
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Admin::SlidesController < Admin::ResourceController
|
2
|
+
before_filter :load_data
|
3
|
+
|
4
|
+
def load_data
|
5
|
+
@slideshow_type = SlideshowType.find(params[:slideshow_type_id])
|
6
|
+
end
|
7
|
+
|
8
|
+
def update_positions
|
9
|
+
params[:positions].each do |id, index|
|
10
|
+
Image.update_all(['position=?', index], ['id=?', id])
|
11
|
+
end
|
12
|
+
|
13
|
+
respond_to do |format|
|
14
|
+
format.js { render :text => 'Ok' }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def location_after_save
|
21
|
+
admin_slideshow_type_slides_url(@slideshow_type)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module SlideshowTypesHelper
|
2
|
+
|
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")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
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 }
|
23
|
+
|
24
|
+
slides.map do |slide|
|
25
|
+
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)), :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 = ""
|
42
|
+
end
|
43
|
+
res = Hash.new()
|
44
|
+
res[:prev] = prev
|
45
|
+
res[:succ] = succ
|
46
|
+
return res
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
data/app/models/slide.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
class Slide < ActiveRecord::Base
|
2
|
+
|
3
|
+
has_many :slideshow_types
|
4
|
+
validates_presence_of :slideshow_type_id
|
5
|
+
|
6
|
+
has_attached_file :image,
|
7
|
+
:url => "/spree/slides/:id/:style_:basename.:extension",
|
8
|
+
:path => ":rails_root/public/spree/slides/:id/:style_:basename.:extension",
|
9
|
+
#:default_url => "/missing/:style.jpg",
|
10
|
+
:styles => {
|
11
|
+
:thumbnail => "100x33#",
|
12
|
+
:small => "300x100#",
|
13
|
+
:medium => "600x200#",
|
14
|
+
:slide => "900x300#",
|
15
|
+
:custom => Proc.new { |instance| "#{SlideshowType.find(instance.slideshow_type_id).slide_width}x#{SlideshowType.find(instance.slideshow_type_id).slide_height}#" }
|
16
|
+
},
|
17
|
+
:convert_options => {
|
18
|
+
:thumbnail => "-gravity center",
|
19
|
+
:small => "-gravity center",
|
20
|
+
:medium => "-gravity center",
|
21
|
+
:slide => "-gravity center",
|
22
|
+
:custom => "-gravity center"
|
23
|
+
}
|
24
|
+
|
25
|
+
#process_in_background :image UTILE MA OCCORRE ATTIVARE ANCHE LA GEMMA DELAYED-PAPERCLIP
|
26
|
+
|
27
|
+
def initialize(*args)
|
28
|
+
super(*args)
|
29
|
+
last_slide = Slide.last
|
30
|
+
self.position = last_slide ? last_slide.position + 1 : 0
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class SlideshowType < ActiveRecord::Base
|
2
|
+
|
3
|
+
belongs_to :slide
|
4
|
+
|
5
|
+
validates :slide_number, :slide_width, :slide_height, :presence => true
|
6
|
+
validates_uniqueness_of :category
|
7
|
+
validates_numericality_of :slide_number, :only_integer => true
|
8
|
+
|
9
|
+
scope :enable, lambda { |category| {:conditions => {:enabled => true, :category => category}} }
|
10
|
+
|
11
|
+
def initialize(*args)
|
12
|
+
super(*args)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -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 %>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<%= f.inputs do %>
|
2
|
+
<%= f.input :title %>
|
3
|
+
<%= f.input :url %>
|
4
|
+
<%= f.input :image, :as => :file, :label => I18n.t("slideshow_type.slide.image.one").capitalize, :hint => f.object.image.blank? ? f.template.content_tag(:span, "No Image Yet") : f.template.image_tag(f.object.image.url(:thumbnail)) %>
|
5
|
+
<%= f.input :slideshow_type_id, :as => :hidden, :value => params[:slideshow_type_id] %>
|
6
|
+
<% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%= render :partial => 'admin/shared/slideshow_type_tabs', :locals => {:current => 'Slide Image'} %>
|
2
|
+
<h1><%= t("slideshow_type.slide.editing_page") %></h1>
|
3
|
+
<%= render 'shared/error_messages', :target => @slide %>
|
4
|
+
|
5
|
+
<%= semantic_form_for [:admin, @slideshow_type, @slide], :html => { :multipart => true } do |f| %>
|
6
|
+
<table class="basic-table" data-hook="edit_image">
|
7
|
+
<tr data-hook="thumbnail">
|
8
|
+
<td><%= t(:thumbnail) %>:</td>
|
9
|
+
<td><%= link_to image_tag(@slide.image.url(:small)), @slide.image.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_slide_url(@slideshow_type), :id => 'cancel_link' %>
|
16
|
+
</p>
|
17
|
+
<% end %>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<%= render :partial => 'admin/shared/slideshow_type_tabs', :locals => {:current => 'Slide Image'} %>
|
2
|
+
|
3
|
+
<%= javascript_include_tag 'admin/slides/index.js' %>
|
4
|
+
<div id="slides" data-hook></div>
|
5
|
+
<p data-hook="links">
|
6
|
+
<%= link_to icon('add') + ' ' + t("slideshow_type.slide.new_page"), new_admin_slideshow_type_slide_url(@slideshow_type), :id => 'new_slide_link' %>
|
7
|
+
</p>
|
8
|
+
|
9
|
+
<table class="index sortable" data-hook="slide_table">
|
10
|
+
<tr data-hook="images_header">
|
11
|
+
<th><%= t("slideshow_type.slide.thumbnail") %></th>
|
12
|
+
<th><%= t("slideshow_type.slide.title") %></th>
|
13
|
+
<th><%= t("slideshow_type.slide.url") %></th>
|
14
|
+
<th><%= t(:action) %></th>
|
15
|
+
</tr>
|
16
|
+
|
17
|
+
<% Slide.find_all_by_slideshow_type_id(@slideshow_type.id).each do |slide| %>
|
18
|
+
<tr id="<%= dom_id(slide) %>" data-hook="images_row">
|
19
|
+
<td>
|
20
|
+
<span class="handle"></span>
|
21
|
+
<%= link_to image_tag(slide.image.url(:thumbnail)), slide.image.url(:medium) %>
|
22
|
+
</td>
|
23
|
+
<td><%= slide.title %></td>
|
24
|
+
<td><%= slide.url %></td>
|
25
|
+
<td class="actions">
|
26
|
+
<%= link_to_with_icon 'edit', t(:edit), edit_admin_slideshow_type_slide_url(@slideshow_type, slide), :class => 'edit' %>
|
27
|
+
|
28
|
+
<%= link_to_delete slide, {:url => admin_slideshow_type_slide_url(@slideshow_type, slide) }%>
|
29
|
+
</td>
|
30
|
+
</tr>
|
31
|
+
<% end %>
|
32
|
+
|
33
|
+
</table>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<h4><%= t("slideshow_type.slide.new_page") %></h4>
|
2
|
+
<%= semantic_form_for [:admin, @slideshow_type, @slide], :html => { :multipart => true } do |f| %>
|
3
|
+
<table class="basic-table" data-hook="new_slide">
|
4
|
+
<%= render :partial => 'form', :locals => { :f => f } %>
|
5
|
+
</table>
|
6
|
+
<p class="form-buttons" data-hook="buttons">
|
7
|
+
<%= button t(:update) %>
|
8
|
+
<%= t(:or) %> <%= link_to t(:cancel), admin_slideshow_type_slides_url(@slideshow_type), :id => 'cancel_link' %>
|
9
|
+
</p>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<%= javascript_include_tag 'admin/slides/new.js' %>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<h1><%= t("slideshow_type.editing_page") %></h1>
|
2
|
+
<%= render :partial => 'admin/shared/slideshow_type_tabs', :locals => {:current => 'Slideshow_type Details'} %>
|
3
|
+
<%= render "shared/error_messages", :target => @slideshow_type %>
|
4
|
+
|
5
|
+
<%= semantic_form_for([:admin, @slideshow_type]) do |f| %>
|
6
|
+
<%= render :partial => "form", :locals => { :f => f } %>
|
7
|
+
<%= render :partial => 'admin/shared/edit_resource_links' %>
|
8
|
+
<% end %>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<div class='toolbar'>
|
2
|
+
<ul class='actions'>
|
3
|
+
<li id="new_product_link">
|
4
|
+
<%= button_link_to t("slideshow_type.new_page"), new_admin_slideshow_type_url, {:icon => 'add'} %>
|
5
|
+
</li>
|
6
|
+
</ul>
|
7
|
+
<br class='clear' />
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<h1><%= t("slideshow_type.many") %></h1>
|
11
|
+
|
12
|
+
<table class="index">
|
13
|
+
<tr>
|
14
|
+
<th><%= t("slideshow_type.category") %></th>
|
15
|
+
<th><%= t("slideshow_type.enable") %></th>
|
16
|
+
<th><%= t("slideshow_type.slide_number") %></th>
|
17
|
+
<th><%= t("action") %></th>
|
18
|
+
</tr>
|
19
|
+
<tbody>
|
20
|
+
<% @slideshow_types.each do |slideshow_type| %>
|
21
|
+
<tr class="<%= cycle('even', 'odd') %>" id="<%= dom_id slideshow_type %>">
|
22
|
+
<td><%= slideshow_type.category %></td>
|
23
|
+
<td><%= icon('tick') if slideshow_type.enabled %></td>
|
24
|
+
<td><%= slideshow_type.slide_number %></td>
|
25
|
+
<td>
|
26
|
+
<%= link_to_edit slideshow_type %>
|
27
|
+
<%= link_to_delete slideshow_type %>
|
28
|
+
</td>
|
29
|
+
</tr>
|
30
|
+
<% end %>
|
31
|
+
</tbody>
|
32
|
+
</table>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<h1><%= t("slideshow_type.new_page") %></h1>
|
2
|
+
<%= render "shared/error_messages", :target => @slideshow_type %>
|
3
|
+
|
4
|
+
<%= semantic_form_for([:admin, @slideshow_type], :html => { :enctype => "multipart/form-data" }) do |f| %>
|
5
|
+
<%= render :partial => "form", :locals => { :f => f } %>
|
6
|
+
<%= render :partial => 'admin/shared/new_resource_links' %>
|
7
|
+
<% end %>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module SpreeMultiSlideshow
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
def add_javascripts
|
6
|
+
append_file "app/assets/javascripts/store/all.js", "//= require store/spree_multi_slideshow\n"
|
7
|
+
#append_file "app/assets/javascripts/admin/all.js", "//= require admin/spree_multi_slideshow\n"
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_stylesheets
|
11
|
+
inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_multi_slideshow\n", :before => /\*\//, :verbose => true
|
12
|
+
#inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/spree_multi_slideshow\n", :before => /\*\//, :verbose => true
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_migrations
|
16
|
+
run 'bundle exec rake railties:install:migrations FROM=spree_multi_slideshow'
|
17
|
+
end
|
18
|
+
|
19
|
+
def run_migrations
|
20
|
+
res = ask "Would you like to run the migrations now? [Y/n]"
|
21
|
+
if res == "" || res.downcase == "y"
|
22
|
+
run 'bundle exec rake db:migrate'
|
23
|
+
else
|
24
|
+
puts "Skiping rake db:migrate, don't forget to run it!"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module SpreeMultiSlideshow
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
engine_name 'spree_multi_slideshow'
|
4
|
+
|
5
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
6
|
+
|
7
|
+
# use rspec for tests
|
8
|
+
config.generators do |g|
|
9
|
+
g.test_framework :rspec
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.activate
|
13
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
|
14
|
+
Rails.application.config.cache_classes ? require(c) : load(c)
|
15
|
+
end
|
16
|
+
|
17
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c|
|
18
|
+
Rails.application.config.cache_classes ? require(c) : load(c)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
config.to_prepare &method(:activate).to_proc
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spree_multi_slideshow
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 257
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 70
|
9
|
+
- 3
|
10
|
+
version: 0.70.3
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Damiano Giacomello
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-03-15 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: spree_core
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: spree_auth
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: formtastic
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: paperclip
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 27
|
71
|
+
segments:
|
72
|
+
- 2
|
73
|
+
- 5
|
74
|
+
- 0
|
75
|
+
version: 2.5.0
|
76
|
+
type: :runtime
|
77
|
+
version_requirements: *id004
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec-rails
|
80
|
+
prerelease: false
|
81
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
version: "0"
|
90
|
+
type: :development
|
91
|
+
version_requirements: *id005
|
92
|
+
description:
|
93
|
+
email: damiano.giacomello@diginess.it
|
94
|
+
executables: []
|
95
|
+
|
96
|
+
extensions: []
|
97
|
+
|
98
|
+
extra_rdoc_files: []
|
99
|
+
|
100
|
+
files:
|
101
|
+
- README.md
|
102
|
+
- LICENSE
|
103
|
+
- lib/generators/spree_multi_slideshow/install/install_generator.rb
|
104
|
+
- lib/spree_multi_slideshow/engine.rb
|
105
|
+
- lib/spree_multi_slideshow.rb
|
106
|
+
- app/assets/images/store/slides/bg-gallery.png
|
107
|
+
- app/assets/images/store/slides/bg-text02.png
|
108
|
+
- app/assets/images/store/slides/sprite01.png
|
109
|
+
- app/assets/javascripts/admin/slides/index.js
|
110
|
+
- app/assets/javascripts/admin/slides/new.js
|
111
|
+
- app/assets/javascripts/admin/spree_multi_slideshow.js
|
112
|
+
- app/assets/javascripts/store/spree_multi_slideshow.js
|
113
|
+
- app/assets/stylesheets/admin/spree_multi_slideshow.css
|
114
|
+
- app/assets/stylesheets/store/spree_multi_slideshow.css
|
115
|
+
- app/controllers/admin/slides_controller.rb
|
116
|
+
- app/controllers/admin/slideshow_types_controller.rb
|
117
|
+
- app/controllers/spree/slides_controller.rb
|
118
|
+
- app/controllers/spree/slideshow_types_controller.rb
|
119
|
+
- app/helpers/slides_helper.rb
|
120
|
+
- app/helpers/slideshow_types_helper.rb
|
121
|
+
- app/models/slide.rb
|
122
|
+
- app/models/slideshow_type.rb
|
123
|
+
- app/overrides/slideshow_type_admin_tab.rb
|
124
|
+
- app/views/admin/shared/_slideshow_type_tabs.html.erb
|
125
|
+
- app/views/admin/slides/_form.html.erb
|
126
|
+
- app/views/admin/slides/edit.html.erb
|
127
|
+
- app/views/admin/slides/index.html.erb
|
128
|
+
- app/views/admin/slides/new.html.erb
|
129
|
+
- app/views/admin/slideshow_types/_form.html.erb
|
130
|
+
- app/views/admin/slideshow_types/edit.html.erb
|
131
|
+
- app/views/admin/slideshow_types/index.html.erb
|
132
|
+
- app/views/admin/slideshow_types/new.html.erb
|
133
|
+
homepage:
|
134
|
+
licenses: []
|
135
|
+
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
hash: 57
|
147
|
+
segments:
|
148
|
+
- 1
|
149
|
+
- 8
|
150
|
+
- 7
|
151
|
+
version: 1.8.7
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
hash: 3
|
158
|
+
segments:
|
159
|
+
- 0
|
160
|
+
version: "0"
|
161
|
+
requirements:
|
162
|
+
- none
|
163
|
+
rubyforge_project:
|
164
|
+
rubygems_version: 1.8.10
|
165
|
+
signing_key:
|
166
|
+
specification_version: 3
|
167
|
+
summary: Extension to manage multi slideshow for Spree Shop
|
168
|
+
test_files: []
|
169
|
+
|