sofa_gallery 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/.travis.yml +1 -0
  2. data/VERSION +1 -1
  3. data/app/assets/images/sofa_gallery/orbit/bullets.jpg +0 -0
  4. data/app/assets/images/sofa_gallery/orbit/left-arrow.png +0 -0
  5. data/app/assets/images/sofa_gallery/orbit/loading.gif +0 -0
  6. data/app/assets/images/sofa_gallery/orbit/mask-black.png +0 -0
  7. data/app/assets/images/sofa_gallery/orbit/pause-black.png +0 -0
  8. data/app/assets/images/sofa_gallery/orbit/right-arrow.png +0 -0
  9. data/app/assets/images/sofa_gallery/orbit/rotator-black.png +0 -0
  10. data/app/assets/images/sofa_gallery/orbit/timer-black.png +0 -0
  11. data/app/assets/javascripts/sofa_gallery/jquery.orbit-1.2.3.min.js +17 -0
  12. data/app/assets/stylesheets/sofa_gallery/admin.css +37 -1
  13. data/app/assets/stylesheets/sofa_gallery/carousel.css.erb +208 -0
  14. data/app/controllers/sofa_gallery/admin/photos_controller.rb +23 -3
  15. data/app/helpers/sofa_gallery_helper.rb +9 -0
  16. data/app/models/sofa_gallery/photo.rb +4 -3
  17. data/app/views/sofa_gallery/_carousel.html.erb +25 -11
  18. data/app/views/sofa_gallery/_list_galleries.html.erb +1 -1
  19. data/app/views/sofa_gallery/_thumbnails.html.erb +1 -1
  20. data/app/views/sofa_gallery/admin/_navigation.html.erb +1 -1
  21. data/app/views/sofa_gallery/admin/photos/_form.html.erb +2 -2
  22. data/app/views/sofa_gallery/admin/photos/new.html.erb +1 -1
  23. data/sofa_gallery.gemspec +12 -9
  24. data/test/functional/admin/photos_controller_test.rb +64 -7
  25. data/test/unit/photo_test.rb +1 -1
  26. metadata +70 -61
  27. data/app/assets/javascripts/sofa_gallery/carousel.js +0 -44
  28. data/app/assets/stylesheets/sofa_gallery/carousel.css +0 -186
  29. data/app/assets/stylesheets/sofa_gallery/tango/credits.txt +0 -1
  30. data/app/assets/stylesheets/sofa_gallery/tango/next-horizontal.png +0 -0
  31. data/app/assets/stylesheets/sofa_gallery/tango/next-vertical.png +0 -0
  32. data/app/assets/stylesheets/sofa_gallery/tango/prev-horizontal.png +0 -0
  33. data/app/assets/stylesheets/sofa_gallery/tango/prev-vertical.png +0 -0
data/.travis.yml CHANGED
@@ -1 +1,2 @@
1
+ rvm: 1.9.2
1
2
  script: "bundle exec rake db:drop db:create db:migrate test"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
@@ -0,0 +1,17 @@
1
+ /*
2
+ * jQuery Orbit Plugin 1.2.3
3
+ * www.ZURB.com/playground
4
+ * Copyright 2010, ZURB
5
+ * Free to use under the MIT license.
6
+ * http://www.opensource.org/licenses/mit-license.php
7
+ */
8
+
9
+ (function(d){d.fn.orbit=function(a){a=d.extend({animation:"horizontal-push",animationSpeed:600,timer:!0,advanceSpeed:4E3,pauseOnHover:!1,startClockOnMouseOut:!1,startClockOnMouseOutAfter:1E3,directionalNav:!0,captions:!0,captionAnimation:"fade",captionAnimationSpeed:600,bullets:!1,bulletThumbs:!1,bulletThumbLocation:"",afterSlideChange:function(){}},a);return this.each(function(){function q(){if(!a.timer||a.timer=="false")return!1;else r.is(":hidden")?s=setInterval(function(){l("next")},a.advanceSpeed):
10
+ (o=!0,x.removeClass("active"),s=setInterval(function(){var a="rotate("+m+"deg)";m+=2;t.css({"-webkit-transform":a,"-moz-transform":a,"-o-transform":a});m>180&&(t.addClass("move"),y.addClass("move"));m>360&&(t.removeClass("move"),y.removeClass("move"),m=0,l("next"))},a.advanceSpeed/180))}function n(){if(!a.timer||a.timer=="false")return!1;else o=!1,clearInterval(s),x.addClass("active")}function z(){if(!a.captions||a.captions=="false")return!1;else{var c=e.eq(b).data("caption");(_captionHTML=d(c).html())?
11
+ (j.attr("id",c).html(_captionHTML),a.captionAnimation=="none"&&j.show(),a.captionAnimation=="fade"&&j.fadeIn(a.captionAnimationSpeed),a.captionAnimation=="slideOpen"&&j.slideDown(a.captionAnimationSpeed)):(a.captionAnimation=="none"&&j.hide(),a.captionAnimation=="fade"&&j.fadeOut(a.captionAnimationSpeed),a.captionAnimation=="slideOpen"&&j.slideUp(a.captionAnimationSpeed))}}function A(){if(a.bullets)C.children("li").removeClass("active").eq(b).addClass("active");else return!1}function l(c){function d(){e.eq(f).css({"z-index":1});
12
+ u=!1;a.afterSlideChange.call(this)}var f=b,g=c;if(f==g)return!1;if(e.length=="1")return!1;u||(u=!0,c=="next"?(b++,b==p&&(b=0)):c=="prev"?(b--,b<0&&(b=p-1)):(b=c,f<b?g="next":f>b&&(g="prev")),A(),e.eq(f).css({"z-index":2}),a.animation=="fade"&&e.eq(b).css({opacity:0,"z-index":3}).animate({opacity:1},a.animationSpeed,d),a.animation=="horizontal-slide"&&(g=="next"&&e.eq(b).css({left:h,"z-index":3}).animate({left:0},a.animationSpeed,d),g=="prev"&&e.eq(b).css({left:-h,"z-index":3}).animate({left:0},a.animationSpeed,
13
+ d)),a.animation=="vertical-slide"&&(g=="prev"&&e.eq(b).css({top:v,"z-index":3}).animate({top:0},a.animationSpeed,d),g=="next"&&e.eq(b).css({top:-v,"z-index":3}).animate({top:0},a.animationSpeed,d)),a.animation=="horizontal-push"&&(g=="next"&&(e.eq(b).css({left:h,"z-index":3}).animate({left:0},a.animationSpeed,d),e.eq(f).animate({left:-h},a.animationSpeed)),g=="prev"&&(e.eq(b).css({left:-h,"z-index":3}).animate({left:0},a.animationSpeed,d),e.eq(f).animate({left:h},a.animationSpeed))),z())}var b=0,
14
+ p=0,h,v,u,f=d(this).addClass("orbit"),c=f.wrap('<div class="orbit-wrapper" />').parent();f.add(h).width("1px").height("1px");var e=f.children("img, a, div");e.each(function(){var a=d(this),b=a.width(),a=a.height();b>f.width()&&(f.add(c).width(b),h=f.width());a>f.height()&&(f.add(c).height(a),v=f.height());p++});if(e.length==1)a.directionalNav=!1,a.timer=!1,a.bullets=!1;e.eq(b).css({"z-index":3}).fadeIn(function(){e.css({display:"block"})});if(a.timer){c.append('<div class="timer"><span class="mask"><span class="rotator"></span></span><span class="pause"></span></div>');
15
+ var r=c.children("div.timer"),o;if(r.length!=0){var t=d("div.timer span.rotator"),y=d("div.timer span.mask"),x=d("div.timer span.pause"),m=0,s;q();r.click(function(){o?n():q()});if(a.startClockOnMouseOut){var B;c.mouseleave(function(){B=setTimeout(function(){o||q()},a.startClockOnMouseOutAfter)});c.mouseenter(function(){clearTimeout(B)})}}}a.pauseOnHover&&c.mouseenter(function(){n()});if(a.captions){c.append('<div class="orbit-caption"></div>');var j=c.children(".orbit-caption");z()}if(a.directionalNav){if(a.directionalNav==
16
+ "false")return!1;c.append('<div class="slider-nav"><span class="right">Right</span><span class="left">Left</span></div>');var k=c.children("div.slider-nav").children("span.left"),w=c.children("div.slider-nav").children("span.right");k.click(function(){n();l("prev")});w.click(function(){n();l("next")})}if(a.bullets){c.append('<ul class="orbit-bullets"></ul>');var C=c.children("ul.orbit-bullets");for(i=0;i<p;i++){k=d("<li>"+(i+1)+"</li>");if(a.bulletThumbs&&(w=e.eq(i).data("thumb")))k=d('<li class="has-thumb">'+
17
+ i+"</li>"),k.css({background:"url("+a.bulletThumbLocation+w+") no-repeat"});c.children("ul.orbit-bullets").append(k);k.data("index",i);k.click(function(){n();l(d(this).data("index"))})}A()}})}})(jQuery);
@@ -12,10 +12,46 @@
12
12
  margin: 0 5px;
13
13
  }
14
14
 
15
+ /* -- Table --------------------------------------------------------------- */
16
+
15
17
  #cms_body table.formatted td.preview {
16
18
  height: 45px;
17
19
  }
18
20
 
19
21
  #cms_body table.formatted td.embed {
20
22
  font-size: 8px;
21
- }
23
+ }
24
+
25
+ #cms_body table.formatted {
26
+ width: 100%;
27
+ }
28
+
29
+ #cms_body table.formatted th, td {
30
+ white-space: nowrap;
31
+ padding: 6px;
32
+ background-color: #f1f1f1;
33
+ border-bottom: 2px solid #e6e6e6;
34
+ }
35
+
36
+
37
+
38
+ #cms_body table.formatted th.main, td.main {
39
+ white-space: normal;
40
+ width: 100%;
41
+ }
42
+ #cms_body table.formatted th {
43
+ background-color: #252525;
44
+ color: #f7f7f7;
45
+ font-size: 12px;
46
+ }
47
+ #cms_body table.formatted th:first-child {
48
+ border-radius: 5px 0px 0px 5px;
49
+ }
50
+ #cms_body table.formatted th:last-child {
51
+ border-radius: 0px 5px 5px 0px
52
+ }
53
+
54
+ #cms_body table.formatted tr:hover td {
55
+ background-color: #fff
56
+ }
57
+
@@ -0,0 +1,208 @@
1
+ /* CSS for jQuery Orbit Plugin 1.2.3
2
+ * www.ZURB.com/playground
3
+ * Copyright 2010, ZURB
4
+ * Free to use under the MIT license.
5
+ * http://www.opensource.org/licenses/mit-license.php
6
+
7
+
8
+
9
+ /* PUT IN YOUR SLIDER ID AND SIZE TO MAKE LOAD BEAUTIFULLY
10
+ ================================================== */
11
+ #featured {
12
+ width: 960px;
13
+ height: 480px;
14
+ background: #000 url(<%= asset_path('sofa_gallery/orbit/loading.gif') %>) no-repeat center center;
15
+ overflow: hidden; }
16
+ #featured>img,
17
+ #featured>div,
18
+ #featured>a { display: none; }
19
+
20
+
21
+ /* CONTAINER
22
+ ================================================== */
23
+
24
+ div.orbit-wrapper {
25
+ width: 1px;
26
+ height: 1px;
27
+ position: relative; }
28
+
29
+ div.orbit {
30
+ width: 1px;
31
+ height: 1px;
32
+ position: relative;
33
+ overflow: hidden }
34
+
35
+ div.orbit>img {
36
+ position: absolute;
37
+ top: 0;
38
+ left: 0;
39
+ display: none; }
40
+
41
+ div.orbit>a {
42
+ border: none;
43
+ position: absolute;
44
+ top: 0;
45
+ left: 0;
46
+ line-height: 0;
47
+ display: none; }
48
+
49
+ .orbit>div {
50
+ position: absolute;
51
+ top: 0;
52
+ left: 0;
53
+ width: 100%;
54
+ height: 100%; }
55
+
56
+ /* Note: If your slider only uses content or anchors, you're going to want to put the width and height declarations on the ".orbit>div" and "div.orbit>a" tags in addition to just the .orbit-wrapper */
57
+
58
+
59
+ /* TIMER
60
+ ================================================== */
61
+
62
+ div.timer {
63
+ width: 40px;
64
+ height: 40px;
65
+ overflow: hidden;
66
+ position: absolute;
67
+ top: 10px;
68
+ right: 10px;
69
+ opacity: .6;
70
+ cursor: pointer;
71
+ z-index: 1001; }
72
+
73
+ span.rotator {
74
+ display: block;
75
+ width: 40px;
76
+ height: 40px;
77
+ position: absolute;
78
+ top: 0;
79
+ left: -20px;
80
+ background: url(<%= asset_path('sofa_gallery/orbit/rotator-black.png') %>) no-repeat;
81
+ z-index: 3; }
82
+
83
+ span.mask {
84
+ display: block;
85
+ width: 20px;
86
+ height: 40px;
87
+ position: absolute;
88
+ top: 0;
89
+ right: 0;
90
+ z-index: 2;
91
+ overflow: hidden; }
92
+
93
+ span.rotator.move {
94
+ left: 0 }
95
+
96
+ span.mask.move {
97
+ width: 40px;
98
+ left: 0;
99
+ background: url(<%= asset_path('sofa_gallery/orbit/timer-black.png') %>) repeat 0 0; }
100
+
101
+ span.pause {
102
+ display: block;
103
+ width: 40px;
104
+ height: 40px;
105
+ position: absolute;
106
+ top: 0;
107
+ left: 0;
108
+ background: url(<%= asset_path('sofa_gallery/orbit/pause-black.png') %>) no-repeat;
109
+ z-index: 4;
110
+ opacity: 0; }
111
+
112
+ span.pause.active {
113
+ background: url(<%= asset_path('sofa_gallery/orbit/pause-black.png') %>) no-repeat 0 -40px }
114
+
115
+ div.timer:hover span.pause,
116
+ span.pause.active {
117
+ opacity: 1 }
118
+
119
+
120
+ /* CAPTIONS
121
+ ================================================== */
122
+
123
+ .orbit-caption {
124
+ display: none; }
125
+
126
+ .orbit-wrapper .orbit-caption {
127
+ background: #000;
128
+ background: rgba(0,0,0,.6);
129
+ z-index: 1000;
130
+ color: #fff;
131
+ text-align: center;
132
+ padding: 7px 0;
133
+ font-size: 13px;
134
+ position: absolute;
135
+ right: 0;
136
+ bottom: 0;
137
+ width: 100%; }
138
+
139
+
140
+ /* DIRECTIONAL NAV
141
+ ================================================== */
142
+
143
+ div.slider-nav {
144
+ display: block;
145
+ overflow: hidden; }
146
+
147
+ div.slider-nav span {
148
+ width: 78px;
149
+ height: 100px;
150
+ text-indent: -9999px;
151
+ position: absolute;
152
+ z-index: 1000;
153
+ top: 50%;
154
+ top: 0;
155
+ /* margin-top: -50px;*/
156
+ cursor: pointer; }
157
+
158
+ div.slider-nav span.right {
159
+ width: 45%;
160
+ height: 100%;
161
+ right: 0; }
162
+
163
+ div.slider-nav span.right:hover {
164
+ background: url(<%= asset_path('sofa_gallery/orbit/right-arrow.png') %>) center right no-repeat; }
165
+
166
+ div.slider-nav span.left {
167
+ width: 45%;
168
+ height: 100%;
169
+ left: 0; }
170
+
171
+ div.slider-nav span.left:hover {
172
+ background: url(<%= asset_path('sofa_gallery/orbit/left-arrow.png') %>) center left no-repeat; }
173
+
174
+ /* BULLET NAV
175
+ ================================================== */
176
+
177
+ .orbit-bullets {
178
+ position: absolute;
179
+ z-index: 1000;
180
+ list-style: none;
181
+ bottom: -40px;
182
+ left: 50%;
183
+ margin-left: -50px;
184
+ padding: 0; }
185
+
186
+ .orbit-bullets li {
187
+ float: left;
188
+ margin-left: 5px;
189
+ cursor: pointer;
190
+ color: #999;
191
+ text-indent: -9999px;
192
+ background: url(<%= asset_path('sofa_gallery/orbit/bullets.jpg') %>) no-repeat 4px 0;
193
+ width: 13px;
194
+ height: 12px;
195
+ overflow: hidden; }
196
+
197
+ .orbit-bullets li.active {
198
+ color: #222;
199
+ background-position: -8px 0; }
200
+
201
+ .orbit-bullets li.has-thumb {
202
+ background: none;
203
+ width: 100px;
204
+ height: 75px; }
205
+
206
+ .orbit-bullets li.active.has-thumb {
207
+ background-position: 0 0;
208
+ border-top: 2px solid #000; }
@@ -13,7 +13,27 @@ class SofaGallery::Admin::PhotosController < SofaGallery::Admin::BaseController
13
13
  end
14
14
 
15
15
  def create
16
- @photo.save!
16
+ file_array = params[:sofa_gallery_photo][:image] || [nil]
17
+
18
+ file_array.each_with_index do |file, i|
19
+ file_params = params[:sofa_gallery_photo].merge(:image => file)
20
+
21
+ title = (file_params[:title].blank? && file_params[:image] ?
22
+ file_params[:image].original_filename :
23
+ file_params[:title]
24
+ )
25
+ title = title + " #{i + 1}" if file_params[:title] == title && file_array.size > 1
26
+
27
+ slug = (file_params[:slug].blank? && file_params[:image] ?
28
+ file_params[:image].original_filename.parameterize :
29
+ file_params[:slug]
30
+ )
31
+ slug = (slug + "-#{i + 1}") if file_params[:slug] == slug && file_array.size > 1
32
+
33
+ @photo = SofaGallery::Photo.new({:gallery => @gallery}.merge(file_params.merge(:title => title, :slug => slug) || {}))
34
+ @photo.save!
35
+ end
36
+
17
37
  flash[:notice] = 'Photo created'
18
38
  redirect_to :action => :index
19
39
  rescue ActiveRecord::RecordInvalid
@@ -26,7 +46,7 @@ class SofaGallery::Admin::PhotosController < SofaGallery::Admin::BaseController
26
46
  end
27
47
 
28
48
  def update
29
- @photo.update_attributes!(params[:photo])
49
+ @photo.update_attributes!(params[:sofa_gallery_photo])
30
50
  flash[:notice] = 'Photo updated'
31
51
  redirect_to :action => :index
32
52
  rescue ActiveRecord::RecordInvalid
@@ -70,7 +90,7 @@ protected
70
90
  end
71
91
 
72
92
  def build_photo
73
- @photo = SofaGallery::Photo.new({:gallery => @gallery}.merge(params[:photo] || {}))
93
+ @photo = SofaGallery::Photo.new({:gallery => @gallery}.merge(params[:sofa_gallery_photo] || {}))
74
94
  end
75
95
 
76
96
  end
@@ -18,4 +18,13 @@ module SofaGalleryHelper
18
18
  end
19
19
  end
20
20
 
21
+ def render_galleries(type = 'list_galleries')
22
+ @galleries = SofaGallery::Gallery.all
23
+ if (@galleries)
24
+ render :partial => "sofa_gallery/#{type}"
25
+ else
26
+ render :text => 'Gallery not found.', :status => 404
27
+ end
28
+ end
29
+
21
30
  end
@@ -30,6 +30,10 @@ class SofaGallery::Photo < ActiveRecord::Base
30
30
  # -- Validations ----------------------------------------------------------
31
31
  validates :gallery_id,
32
32
  :presence => true
33
+ validates :slug,
34
+ :presence => true,
35
+ :uniqueness => true,
36
+ :format => { :with => /^\w[a-z0-9_-]*$/i }
33
37
  validates_attachment_presence :image,
34
38
  :message => 'There was no file uploaded!'
35
39
  validates_attachment_content_type :image,
@@ -37,9 +41,6 @@ class SofaGallery::Photo < ActiveRecord::Base
37
41
  :message => 'Please only upload .jpg, .jpeg, .gif or .png files.'
38
42
  validates_attachment_size :image,
39
43
  :less_than => 5.megabytes
40
-
41
- # -- Scopes ---------------------------------------------------------------
42
- default_scope order(:position)
43
44
 
44
45
  # -- Instance Methods -----------------------------------------------------
45
46
  def image_geometry(style = :original)
@@ -1,17 +1,31 @@
1
1
  <% if @gallery %>
2
+ <!--[if IE]>
3
+ <style type="text/css">
4
+ .timer { display: none !important; }
5
+ div.caption { background:transparent; filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000,endColorstr=#99000000);zoom: 1; }
6
+ </style>
7
+ <![endif]-->
2
8
  <% content_for :head do %>
3
- <%= stylesheet_link_tag "/assets/sofa_gallery/sofa_gallery_carousel.css" %>
4
- <%= javascript_include_tag "/assets/sofa_gallery/sofa_gallery_carousel.js" %>
9
+ <%= javascript_include_tag "sofa_gallery/jquery.orbit-1.2.3.min.js" %>
10
+ <%= stylesheet_link_tag "sofa_gallery/carousel.css" %>
5
11
  <% end %>
6
- <ul id="cms_carousel" class="jcarousel-skin-tango">
7
- <% @gallery.photos.each do |photo| %>
8
- <li id="<%= dom_id(photo) %>">
9
- <div class="photo">
10
- <%= link_to image_tag(photo.image.url(:full), :alt => photo.description), photo.url %>
11
- </div>
12
- </li>
12
+ <% content_for :doc_ready do %>
13
+ $('#featured').orbit();
14
+ <% end %>
15
+ <% if @gallery.photos.count > 0 %>
16
+ <div id="featured">
17
+ <% @gallery.photos.order(:position).each do |photo| %>
18
+ <%= photo.image.url(:full), :alt => photo.description, :id => dom_id(photo), :"data-caption" => "##{dom_id(photo)}htmlCaption" %>
19
+ <% end %>
20
+ </div>
21
+ <% @gallery.photos.reject{|p| p.description.blank?}.each do |photo| %>
22
+ <span class="orbit-caption" id="<%=dom_id(photo)%>htmlCaption">
23
+ <%= photo.description %>
24
+ </span>
13
25
  <% end %>
14
- </ul>
26
+ <% else %>
27
+ <em>No photos in this gallery.</em>
28
+ <% end %>
15
29
  <% else %>
16
- Gallery not found.
30
+ No images were found.
17
31
  <% end %>
@@ -5,7 +5,7 @@
5
5
  <% @galleries.each do |gallery| %>
6
6
  <div class="sofa_gallery">
7
7
  <div class="photo_preview">
8
- <% gallery.photos.limit(6).each do |photo| %>
8
+ <% gallery.photos.order(:position).limit(6).each do |photo| %>
9
9
  <%= image_tag(photo.image.url(:admin_thumb), :alt => photo.description) %>
10
10
  <% end %>
11
11
  </div>
@@ -8,7 +8,7 @@
8
8
  <p><%= @gallery.description %></p>
9
9
  <br />
10
10
  <% if @gallery.photos.count > 0 %>
11
- <% @gallery.photos.each do |photo| %>
11
+ <% @gallery.photos.order(:position).each do |photo| %>
12
12
  <li id="<%= dom_id(photo) %>">
13
13
  <div class="photo" style="width: <%= @gallery.thumb_width %>px; height: <%= @gallery.thumb_height %>px;">
14
14
  <%= link_to photo.image.url(:full), :rel => "prettyPhoto[pp_gal]", :title => photo.description do %>
@@ -2,4 +2,4 @@
2
2
  <%= stylesheet_link_tag "sofa_gallery/sofa_gallery_admin.css" %>
3
3
  <% end %>
4
4
 
5
- <li><%= active_link_to 'Galleries', gallery_admin_galleries_path %></li>
5
+ <li><%= active_link_to 'Galleries', sofa_gallery_admin_galleries_path %></li>
@@ -1,13 +1,13 @@
1
1
  <%= form.text_field :title, :id => (@photo.new_record?? 'slugify' : nil) %>
2
2
  <%= form.text_field :slug, :id => 'slug' %>
3
- <% if @photo.image? %>
3
+ <% if @photo.image? && @photo.id.present? %>
4
4
  <%= form.simple_field 'Current Image' do %>
5
5
  <%= image_tag(@photo.image.url(:thumb)) %>
6
6
  <br/>
7
7
  <%= link_to 'Crop Image', crop_sofa_gallery_admin_gallery_photo_path(@gallery, @photo) if @photo.force_aspect? %>
8
8
  <% end %>
9
9
  <% end %>
10
- <%= form.file_field :image %>
10
+ <%= form.file_field :image, :multiple => true %>
11
11
  <%= form.text_area :description %>
12
12
  <%= form.simple_field nil, nil, :class => 'submit_element' do %>
13
13
  <%= link_to "Cancel", sofa_gallery_admin_gallery_photos_path(@photo.gallery), :id => 'cancel_btn' %>
@@ -1,5 +1,5 @@
1
1
  <h1>New Photo</h1>
2
2
 
3
- <%= sofa_gallery_form_for @photo, :as => :photo, :url => {:action => :create}, :html => {:multipart => true} do |form|%>
3
+ <%= sofa_gallery_form_for @photo, :url => {:action => :create}, :html => {:multipart => true} do |form|%>
4
4
  <%= render :partial => form %>
5
5
  <% end -%>
data/sofa_gallery.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "sofa_gallery"
8
- s.version = "0.0.5"
8
+ s.version = "0.0.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Oleg Khabarov", "Stephen McLeod", "The Working Group Inc."]
12
- s.date = "2011-10-03"
12
+ s.date = "2011-10-11"
13
13
  s.description = ""
14
14
  s.email = "stephen@theworkinggroup.ca"
15
15
  s.extra_rdoc_files = [
@@ -25,6 +25,14 @@ Gem::Specification.new do |s|
25
25
  "Rakefile",
26
26
  "VERSION",
27
27
  "app/assets/images/sofa_gallery/jcrop.gif",
28
+ "app/assets/images/sofa_gallery/orbit/bullets.jpg",
29
+ "app/assets/images/sofa_gallery/orbit/left-arrow.png",
30
+ "app/assets/images/sofa_gallery/orbit/loading.gif",
31
+ "app/assets/images/sofa_gallery/orbit/mask-black.png",
32
+ "app/assets/images/sofa_gallery/orbit/pause-black.png",
33
+ "app/assets/images/sofa_gallery/orbit/right-arrow.png",
34
+ "app/assets/images/sofa_gallery/orbit/rotator-black.png",
35
+ "app/assets/images/sofa_gallery/orbit/timer-black.png",
28
36
  "app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/btnNext.png",
29
37
  "app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/btnPrevious.png",
30
38
  "app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/contentPattern.png",
@@ -65,20 +73,15 @@ Gem::Specification.new do |s|
65
73
  "app/assets/images/sofa_gallery/prettyPhoto/light_square/sprite.png",
66
74
  "app/assets/javascripts/sofa_gallery/admin.js",
67
75
  "app/assets/javascripts/sofa_gallery/application.js",
68
- "app/assets/javascripts/sofa_gallery/carousel.js",
69
76
  "app/assets/javascripts/sofa_gallery/jquery.jcrop.js",
77
+ "app/assets/javascripts/sofa_gallery/jquery.orbit-1.2.3.min.js",
70
78
  "app/assets/javascripts/sofa_gallery/thumbnails.js",
71
79
  "app/assets/stylesheets/sofa_gallery/admin.css",
72
80
  "app/assets/stylesheets/sofa_gallery/application.css",
73
- "app/assets/stylesheets/sofa_gallery/carousel.css",
81
+ "app/assets/stylesheets/sofa_gallery/carousel.css.erb",
74
82
  "app/assets/stylesheets/sofa_gallery/gallery_list.css",
75
83
  "app/assets/stylesheets/sofa_gallery/jquery.jcrop.css",
76
84
  "app/assets/stylesheets/sofa_gallery/reset.css",
77
- "app/assets/stylesheets/sofa_gallery/tango/credits.txt",
78
- "app/assets/stylesheets/sofa_gallery/tango/next-horizontal.png",
79
- "app/assets/stylesheets/sofa_gallery/tango/next-vertical.png",
80
- "app/assets/stylesheets/sofa_gallery/tango/prev-horizontal.png",
81
- "app/assets/stylesheets/sofa_gallery/tango/prev-vertical.png",
82
85
  "app/assets/stylesheets/sofa_gallery/thumbnails.css.erb",
83
86
  "app/controllers/application_controller.rb",
84
87
  "app/controllers/sofa_gallery/admin/base_controller.rb",
@@ -25,28 +25,85 @@ class SofaGallery::Admin::PhotosControllerTest < ActionController::TestCase
25
25
  assert_select "form[action='/admin/galleries/#{gallery.id}/photos']"
26
26
  end
27
27
 
28
- def test_creation
28
+ def test_create
29
29
  assert_difference 'SofaGallery::Photo.count' do
30
- post :create, :gallery_id => sofa_gallery_galleries(:default), :photo => {
30
+ post :create, :gallery_id => sofa_gallery_galleries(:default), :sofa_gallery_photo => {
31
31
  :title => 'Test Photo',
32
32
  :slug => 'test-photo',
33
- :image => fixture_file_upload('/files/default.jpg', 'image/jpeg')
33
+ :image => [fixture_file_upload('/files/default.jpg', 'image/jpeg')]
34
34
  }
35
35
  assert_response :redirect
36
36
  assert_redirected_to :action => :index
37
37
  assert_equal 'Photo created', flash[:notice]
38
+
39
+ photo = SofaGallery::Photo.last
40
+ assert_equal 'Test Photo', photo.title
41
+ assert_equal 'test-photo', photo.slug
42
+ end
43
+ end
44
+
45
+ def test_create_without_title_or_slug
46
+ assert_difference 'SofaGallery::Photo.count', 2 do
47
+ post :create, :gallery_id => sofa_gallery_galleries(:default), :sofa_gallery_photo => {
48
+ :image => [fixture_file_upload('/files/default.jpg', 'image/jpeg')]
49
+ }
50
+ assert_response :redirect
51
+ assert_redirected_to :action => :index
52
+ assert_equal 'Photo created', flash[:notice]
53
+
54
+ photo = SofaGallery::Photo.last
55
+ assert_equal 'default.jpg', photo.title
56
+ assert_equal 'default-jpg', photo.slug
57
+
58
+ post :create, :gallery_id => sofa_gallery_galleries(:default), :sofa_gallery_photo => {
59
+ :slug => 'Testrrr',
60
+ :image => [fixture_file_upload('/files/default.jpg', 'image/jpeg')]
61
+ }
62
+
63
+ photo = SofaGallery::Photo.last
64
+ assert_equal 'default.jpg', photo.title
65
+ assert_equal 'Testrrr', photo.slug
38
66
  end
39
67
  end
40
68
 
41
- def test_creation_fail
69
+ def test_create_failure
42
70
  assert_no_difference 'SofaGallery::Photo.count' do
43
- post :create, :gallery_id => sofa_gallery_galleries(:default), :photo => { }
71
+ post :create, :gallery_id => sofa_gallery_galleries(:default), :sofa_gallery_photo => { }
44
72
  assert_response :success
45
73
  assert_template 'new'
46
74
  assert_equal 'Failed to create Photo', flash[:error]
47
75
  end
48
76
  end
49
77
 
78
+
79
+ def test_create_multiple
80
+ SofaGallery::Photo.delete_all
81
+
82
+ assert_difference 'SofaGallery::Photo.count', 2 do
83
+ post :create, :gallery_id => sofa_gallery_galleries(:default), :sofa_gallery_photo => {
84
+ :title => 'Test Photo',
85
+ :slug => 'test-photo',
86
+ :image => [
87
+ fixture_file_upload('/files/default.jpg', 'image/jpeg'),
88
+ fixture_file_upload('/files/default.jpg', 'image/jpeg')
89
+ ]
90
+ }
91
+ assert_response :redirect
92
+ assert_redirected_to :action => :index
93
+
94
+ photo_a, photo_b = SofaGallery::Photo.all
95
+
96
+ assert_equal 'default.jpg', photo_a.image_file_name
97
+ assert_equal 'default.jpg', photo_b.image_file_name
98
+ assert_equal 'Test Photo 1', photo_a.title
99
+ assert_equal 'Test Photo 2', photo_b.title
100
+ assert_equal 'test-photo-1', photo_a.slug
101
+ assert_equal 'test-photo-2', photo_b.slug
102
+ assert_equal 'Photo created', flash[:notice]
103
+ end
104
+ end
105
+
106
+
50
107
  def test_get_edit
51
108
  photo = sofa_gallery_photos(:default)
52
109
  get :edit, :gallery_id => photo.gallery, :id => photo
@@ -64,7 +121,7 @@ class SofaGallery::Admin::PhotosControllerTest < ActionController::TestCase
64
121
 
65
122
  def test_update
66
123
  photo = sofa_gallery_photos(:default)
67
- put :update, :gallery_id => photo.gallery, :id => photo, :photo => {
124
+ put :update, :gallery_id => photo.gallery, :id => photo, :sofa_gallery_photo => {
68
125
  :title => 'Updated Title'
69
126
  }
70
127
  assert_response :redirect
@@ -77,7 +134,7 @@ class SofaGallery::Admin::PhotosControllerTest < ActionController::TestCase
77
134
 
78
135
  def test_update_failure
79
136
  photo = sofa_gallery_photos(:default)
80
- put :update, :gallery_id => photo.gallery, :id => photo, :photo => {
137
+ put :update, :gallery_id => photo.gallery, :id => photo, :sofa_gallery_photo => {
81
138
  :title => 'Updated Title',
82
139
  :image => fixture_file_upload('/files/default.txt', 'text/plain')
83
140
  }
@@ -11,7 +11,7 @@ class PhotoTest < ActiveSupport::TestCase
11
11
  def test_validations
12
12
  photo = SofaGallery::Photo.new
13
13
  assert photo.invalid?
14
- assert_has_errors_on photo, :image_file_name
14
+ assert_has_errors_on photo, {:gallery_id=>["can't be blank"], :slug=>["can't be blank", "is invalid"], :image_file_name=>["There was no file uploaded!"]}
15
15
  end
16
16
 
17
17
  def test_creation
metadata CHANGED
@@ -1,81 +1,84 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sofa_gallery
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.5
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
5
+ version: 0.0.6
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Oleg Khabarov
9
9
  - Stephen McLeod
10
10
  - The Working Group Inc.
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-10-03 00:00:00.000000000Z
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
14
+
15
+ date: 2011-10-11 00:00:00 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
17
18
  name: rails
18
- requirement: &70146921382500 !ruby/object:Gem::Requirement
19
+ requirement: &id001 !ruby/object:Gem::Requirement
19
20
  none: false
20
- requirements:
21
- - - ! '>='
22
- - !ruby/object:Gem::Version
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
23
24
  version: 3.1.0
24
25
  type: :runtime
25
26
  prerelease: false
26
- version_requirements: *70146921382500
27
- - !ruby/object:Gem::Dependency
27
+ version_requirements: *id001
28
+ - !ruby/object:Gem::Dependency
28
29
  name: paperclip
29
- requirement: &70146921381820 !ruby/object:Gem::Requirement
30
+ requirement: &id002 !ruby/object:Gem::Requirement
30
31
  none: false
31
- requirements:
32
+ requirements:
32
33
  - - ~>
33
- - !ruby/object:Gem::Version
34
+ - !ruby/object:Gem::Version
34
35
  version: 2.3.0
35
36
  type: :runtime
36
37
  prerelease: false
37
- version_requirements: *70146921381820
38
- - !ruby/object:Gem::Dependency
38
+ version_requirements: *id002
39
+ - !ruby/object:Gem::Dependency
39
40
  name: jquery-rails
40
- requirement: &70146921381220 !ruby/object:Gem::Requirement
41
+ requirement: &id003 !ruby/object:Gem::Requirement
41
42
  none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
45
46
  version: 1.0.14
46
47
  type: :runtime
47
48
  prerelease: false
48
- version_requirements: *70146921381220
49
- - !ruby/object:Gem::Dependency
49
+ version_requirements: *id003
50
+ - !ruby/object:Gem::Dependency
50
51
  name: sqlite3
51
- requirement: &70146921380600 !ruby/object:Gem::Requirement
52
+ requirement: &id004 !ruby/object:Gem::Requirement
52
53
  none: false
53
- requirements:
54
- - - ! '>='
55
- - !ruby/object:Gem::Version
56
- version: '0'
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
57
58
  type: :development
58
59
  prerelease: false
59
- version_requirements: *70146921380600
60
- - !ruby/object:Gem::Dependency
60
+ version_requirements: *id004
61
+ - !ruby/object:Gem::Dependency
61
62
  name: jeweler
62
- requirement: &70146921379900 !ruby/object:Gem::Requirement
63
+ requirement: &id005 !ruby/object:Gem::Requirement
63
64
  none: false
64
- requirements:
65
- - - ! '>='
66
- - !ruby/object:Gem::Version
67
- version: '0'
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
68
69
  type: :development
69
70
  prerelease: false
70
- version_requirements: *70146921379900
71
- description: ''
71
+ version_requirements: *id005
72
+ description: ""
72
73
  email: stephen@theworkinggroup.ca
73
74
  executables: []
75
+
74
76
  extensions: []
75
- extra_rdoc_files:
77
+
78
+ extra_rdoc_files:
76
79
  - LICENSE
77
80
  - README.md
78
- files:
81
+ files:
79
82
  - .document
80
83
  - .travis.yml
81
84
  - Gemfile
@@ -84,6 +87,14 @@ files:
84
87
  - Rakefile
85
88
  - VERSION
86
89
  - app/assets/images/sofa_gallery/jcrop.gif
90
+ - app/assets/images/sofa_gallery/orbit/bullets.jpg
91
+ - app/assets/images/sofa_gallery/orbit/left-arrow.png
92
+ - app/assets/images/sofa_gallery/orbit/loading.gif
93
+ - app/assets/images/sofa_gallery/orbit/mask-black.png
94
+ - app/assets/images/sofa_gallery/orbit/pause-black.png
95
+ - app/assets/images/sofa_gallery/orbit/right-arrow.png
96
+ - app/assets/images/sofa_gallery/orbit/rotator-black.png
97
+ - app/assets/images/sofa_gallery/orbit/timer-black.png
87
98
  - app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/btnNext.png
88
99
  - app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/btnPrevious.png
89
100
  - app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/contentPattern.png
@@ -124,20 +135,15 @@ files:
124
135
  - app/assets/images/sofa_gallery/prettyPhoto/light_square/sprite.png
125
136
  - app/assets/javascripts/sofa_gallery/admin.js
126
137
  - app/assets/javascripts/sofa_gallery/application.js
127
- - app/assets/javascripts/sofa_gallery/carousel.js
128
138
  - app/assets/javascripts/sofa_gallery/jquery.jcrop.js
139
+ - app/assets/javascripts/sofa_gallery/jquery.orbit-1.2.3.min.js
129
140
  - app/assets/javascripts/sofa_gallery/thumbnails.js
130
141
  - app/assets/stylesheets/sofa_gallery/admin.css
131
142
  - app/assets/stylesheets/sofa_gallery/application.css
132
- - app/assets/stylesheets/sofa_gallery/carousel.css
143
+ - app/assets/stylesheets/sofa_gallery/carousel.css.erb
133
144
  - app/assets/stylesheets/sofa_gallery/gallery_list.css
134
145
  - app/assets/stylesheets/sofa_gallery/jquery.jcrop.css
135
146
  - app/assets/stylesheets/sofa_gallery/reset.css
136
- - app/assets/stylesheets/sofa_gallery/tango/credits.txt
137
- - app/assets/stylesheets/sofa_gallery/tango/next-horizontal.png
138
- - app/assets/stylesheets/sofa_gallery/tango/next-vertical.png
139
- - app/assets/stylesheets/sofa_gallery/tango/prev-horizontal.png
140
- - app/assets/stylesheets/sofa_gallery/tango/prev-vertical.png
141
147
  - app/assets/stylesheets/sofa_gallery/thumbnails.css.erb
142
148
  - app/controllers/application_controller.rb
143
149
  - app/controllers/sofa_gallery/admin/base_controller.rb
@@ -198,31 +204,34 @@ files:
198
204
  - test/unit/gallery_test.rb
199
205
  - test/unit/photo_test.rb
200
206
  homepage: http://github.com/twg/sofa-gallery
201
- licenses:
207
+ licenses:
202
208
  - MIT
203
209
  post_install_message:
204
210
  rdoc_options: []
205
- require_paths:
211
+
212
+ require_paths:
206
213
  - lib
207
- required_ruby_version: !ruby/object:Gem::Requirement
214
+ required_ruby_version: !ruby/object:Gem::Requirement
208
215
  none: false
209
- requirements:
210
- - - ! '>='
211
- - !ruby/object:Gem::Version
212
- version: '0'
213
- segments:
216
+ requirements:
217
+ - - ">="
218
+ - !ruby/object:Gem::Version
219
+ hash: -3072931636190028721
220
+ segments:
214
221
  - 0
215
- hash: -3729767750666364040
216
- required_rubygems_version: !ruby/object:Gem::Requirement
222
+ version: "0"
223
+ required_rubygems_version: !ruby/object:Gem::Requirement
217
224
  none: false
218
- requirements:
219
- - - ! '>='
220
- - !ruby/object:Gem::Version
221
- version: '0'
225
+ requirements:
226
+ - - ">="
227
+ - !ruby/object:Gem::Version
228
+ version: "0"
222
229
  requirements: []
230
+
223
231
  rubyforge_project:
224
232
  rubygems_version: 1.8.10
225
233
  signing_key:
226
234
  specification_version: 3
227
235
  summary: SofaGallery is an image gallery engine for Rails 3.1 apps (and ComfortableMexicanSofa)
228
236
  test_files: []
237
+
@@ -1,44 +0,0 @@
1
- /*!
2
- * jCarousel - Riding carousels with jQuery
3
- * http://sorgalla.com/jcarousel/
4
- *
5
- * Copyright (c) 2006 Jan Sorgalla (http://sorgalla.com)
6
- * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
7
- * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
8
- *
9
- * Built on top of the jQuery library
10
- * http://jquery.com
11
- *
12
- * Inspired by the "Carousel Component" by Bill Scott
13
- * http://billwscott.com/carousel/
14
- */
15
-
16
- (function(g){var q={vertical:!1,rtl:!1,start:1,offset:1,size:null,scroll:3,visible:null,animation:"normal",easing:"swing",auto:0,wrap:null,initCallback:null,setupCallback:null,reloadCallback:null,itemLoadCallback:null,itemFirstInCallback:null,itemFirstOutCallback:null,itemLastInCallback:null,itemLastOutCallback:null,itemVisibleInCallback:null,itemVisibleOutCallback:null,animationStepCallback:null,buttonNextHTML:"<div></div>",buttonPrevHTML:"<div></div>",buttonNextEvent:"click",buttonPrevEvent:"click", buttonNextCallback:null,buttonPrevCallback:null,itemFallbackDimension:null},m=!1;g(window).bind("load.jcarousel",function(){m=!0});g.jcarousel=function(a,c){this.options=g.extend({},q,c||{});this.autoStopped=this.locked=!1;this.buttonPrevState=this.buttonNextState=this.buttonPrev=this.buttonNext=this.list=this.clip=this.container=null;if(!c||c.rtl===void 0)this.options.rtl=(g(a).attr("dir")||g("html").attr("dir")||"").toLowerCase()=="rtl";this.wh=!this.options.vertical?"width":"height";this.lt=!this.options.vertical? this.options.rtl?"right":"left":"top";for(var b="",d=a.className.split(" "),f=0;f<d.length;f++)if(d[f].indexOf("jcarousel-skin")!=-1){g(a).removeClass(d[f]);b=d[f];break}a.nodeName.toUpperCase()=="UL"||a.nodeName.toUpperCase()=="OL"?(this.list=g(a),this.clip=this.list.parents(".jcarousel-clip"),this.container=this.list.parents(".jcarousel-container")):(this.container=g(a),this.list=this.container.find("ul,ol").eq(0),this.clip=this.container.find(".jcarousel-clip"));if(this.clip.size()===0)this.clip= this.list.wrap("<div></div>").parent();if(this.container.size()===0)this.container=this.clip.wrap("<div></div>").parent();b!==""&&this.container.parent()[0].className.indexOf("jcarousel-skin")==-1&&this.container.wrap('<div class=" '+b+'"></div>');this.buttonPrev=g(".jcarousel-prev",this.container);if(this.buttonPrev.size()===0&&this.options.buttonPrevHTML!==null)this.buttonPrev=g(this.options.buttonPrevHTML).appendTo(this.container);this.buttonPrev.addClass(this.className("jcarousel-prev"));this.buttonNext= g(".jcarousel-next",this.container);if(this.buttonNext.size()===0&&this.options.buttonNextHTML!==null)this.buttonNext=g(this.options.buttonNextHTML).appendTo(this.container);this.buttonNext.addClass(this.className("jcarousel-next"));this.clip.addClass(this.className("jcarousel-clip")).css({position:"relative"});this.list.addClass(this.className("jcarousel-list")).css({overflow:"hidden",position:"relative",top:0,margin:0,padding:0}).css(this.options.rtl?"right":"left",0);this.container.addClass(this.className("jcarousel-container")).css({position:"relative"}); !this.options.vertical&&this.options.rtl&&this.container.addClass("jcarousel-direction-rtl").attr("dir","rtl");var j=this.options.visible!==null?Math.ceil(this.clipping()/this.options.visible):null,b=this.list.children("li"),e=this;if(b.size()>0){var h=0,i=this.options.offset;b.each(function(){e.format(this,i++);h+=e.dimension(this,j)});this.list.css(this.wh,h+100+"px");if(!c||c.size===void 0)this.options.size=b.size()}this.container.css("display","block");this.buttonNext.css("display","block");this.buttonPrev.css("display", "block");this.funcNext=function(){e.next()};this.funcPrev=function(){e.prev()};this.funcResize=function(){e.resizeTimer&&clearTimeout(e.resizeTimer);e.resizeTimer=setTimeout(function(){e.reload()},100)};this.options.initCallback!==null&&this.options.initCallback(this,"init");!m&&g.browser.safari?(this.buttons(!1,!1),g(window).bind("load.jcarousel",function(){e.setup()})):this.setup()};var f=g.jcarousel;f.fn=f.prototype={jcarousel:"0.2.8"};f.fn.extend=f.extend=g.extend;f.fn.extend({setup:function(){this.prevLast= this.prevFirst=this.last=this.first=null;this.animating=!1;this.tail=this.resizeTimer=this.timer=null;this.inTail=!1;if(!this.locked){this.list.css(this.lt,this.pos(this.options.offset)+"px");var a=this.pos(this.options.start,!0);this.prevFirst=this.prevLast=null;this.animate(a,!1);g(window).unbind("resize.jcarousel",this.funcResize).bind("resize.jcarousel",this.funcResize);this.options.setupCallback!==null&&this.options.setupCallback(this)}},reset:function(){this.list.empty();this.list.css(this.lt, "0px");this.list.css(this.wh,"10px");this.options.initCallback!==null&&this.options.initCallback(this,"reset");this.setup()},reload:function(){this.tail!==null&&this.inTail&&this.list.css(this.lt,f.intval(this.list.css(this.lt))+this.tail);this.tail=null;this.inTail=!1;this.options.reloadCallback!==null&&this.options.reloadCallback(this);if(this.options.visible!==null){var a=this,c=Math.ceil(this.clipping()/this.options.visible),b=0,d=0;this.list.children("li").each(function(f){b+=a.dimension(this, c);f+1<a.first&&(d=b)});this.list.css(this.wh,b+"px");this.list.css(this.lt,-d+"px")}this.scroll(this.first,!1)},lock:function(){this.locked=!0;this.buttons()},unlock:function(){this.locked=!1;this.buttons()},size:function(a){if(a!==void 0)this.options.size=a,this.locked||this.buttons();return this.options.size},has:function(a,c){if(c===void 0||!c)c=a;if(this.options.size!==null&&c>this.options.size)c=this.options.size;for(var b=a;b<=c;b++){var d=this.get(b);if(!d.length||d.hasClass("jcarousel-item-placeholder"))return!1}return!0}, get:function(a){return g(">.jcarousel-item-"+a,this.list)},add:function(a,c){var b=this.get(a),d=0,p=g(c);if(b.length===0)for(var j,e=f.intval(a),b=this.create(a);;){if(j=this.get(--e),e<=0||j.length){e<=0?this.list.prepend(b):j.after(b);break}}else d=this.dimension(b);p.get(0).nodeName.toUpperCase()=="LI"?(b.replaceWith(p),b=p):b.empty().append(c);this.format(b.removeClass(this.className("jcarousel-item-placeholder")),a);p=this.options.visible!==null?Math.ceil(this.clipping()/this.options.visible): null;d=this.dimension(b,p)-d;a>0&&a<this.first&&this.list.css(this.lt,f.intval(this.list.css(this.lt))-d+"px");this.list.css(this.wh,f.intval(this.list.css(this.wh))+d+"px");return b},remove:function(a){var c=this.get(a);if(c.length&&!(a>=this.first&&a<=this.last)){var b=this.dimension(c);a<this.first&&this.list.css(this.lt,f.intval(this.list.css(this.lt))+b+"px");c.remove();this.list.css(this.wh,f.intval(this.list.css(this.wh))-b+"px")}},next:function(){this.tail!==null&&!this.inTail?this.scrollTail(!1): this.scroll((this.options.wrap=="both"||this.options.wrap=="last")&&this.options.size!==null&&this.last==this.options.size?1:this.first+this.options.scroll)},prev:function(){this.tail!==null&&this.inTail?this.scrollTail(!0):this.scroll((this.options.wrap=="both"||this.options.wrap=="first")&&this.options.size!==null&&this.first==1?this.options.size:this.first-this.options.scroll)},scrollTail:function(a){if(!this.locked&&!this.animating&&this.tail){this.pauseAuto();var c=f.intval(this.list.css(this.lt)), c=!a?c-this.tail:c+this.tail;this.inTail=!a;this.prevFirst=this.first;this.prevLast=this.last;this.animate(c)}},scroll:function(a,c){!this.locked&&!this.animating&&(this.pauseAuto(),this.animate(this.pos(a),c))},pos:function(a,c){var b=f.intval(this.list.css(this.lt));if(this.locked||this.animating)return b;this.options.wrap!="circular"&&(a=a<1?1:this.options.size&&a>this.options.size?this.options.size:a);for(var d=this.first>a,g=this.options.wrap!="circular"&&this.first<=1?1:this.first,j=d?this.get(g): this.get(this.last),e=d?g:g-1,h=null,i=0,k=!1,l=0;d?--e>=a:++e<a;){h=this.get(e);k=!h.length;if(h.length===0&&(h=this.create(e).addClass(this.className("jcarousel-item-placeholder")),j[d?"before":"after"](h),this.first!==null&&this.options.wrap=="circular"&&this.options.size!==null&&(e<=0||e>this.options.size)))j=this.get(this.index(e)),j.length&&(h=this.add(e,j.clone(!0)));j=h;l=this.dimension(h);k&&(i+=l);if(this.first!==null&&(this.options.wrap=="circular"||e>=1&&(this.options.size===null||e<= this.options.size)))b=d?b+l:b-l}for(var g=this.clipping(),m=[],o=0,n=0,j=this.get(a-1),e=a;++o;){h=this.get(e);k=!h.length;if(h.length===0){h=this.create(e).addClass(this.className("jcarousel-item-placeholder"));if(j.length===0)this.list.prepend(h);else j[d?"before":"after"](h);if(this.first!==null&&this.options.wrap=="circular"&&this.options.size!==null&&(e<=0||e>this.options.size))j=this.get(this.index(e)),j.length&&(h=this.add(e,j.clone(!0)))}j=h;l=this.dimension(h);if(l===0)throw Error("jCarousel: No width/height set for items. This will cause an infinite loop. Aborting..."); this.options.wrap!="circular"&&this.options.size!==null&&e>this.options.size?m.push(h):k&&(i+=l);n+=l;if(n>=g)break;e++}for(h=0;h<m.length;h++)m[h].remove();i>0&&(this.list.css(this.wh,this.dimension(this.list)+i+"px"),d&&(b-=i,this.list.css(this.lt,f.intval(this.list.css(this.lt))-i+"px")));i=a+o-1;if(this.options.wrap!="circular"&&this.options.size&&i>this.options.size)i=this.options.size;if(e>i){o=0;e=i;for(n=0;++o;){h=this.get(e--);if(!h.length)break;n+=this.dimension(h);if(n>=g)break}}e=i-o+ 1;this.options.wrap!="circular"&&e<1&&(e=1);if(this.inTail&&d)b+=this.tail,this.inTail=!1;this.tail=null;if(this.options.wrap!="circular"&&i==this.options.size&&i-o+1>=1&&(d=f.intval(this.get(i).css(!this.options.vertical?"marginRight":"marginBottom")),n-d>g))this.tail=n-g-d;if(c&&a===this.options.size&&this.tail)b-=this.tail,this.inTail=!0;for(;a-- >e;)b+=this.dimension(this.get(a));this.prevFirst=this.first;this.prevLast=this.last;this.first=e;this.last=i;return b},animate:function(a,c){if(!this.locked&& !this.animating){this.animating=!0;var b=this,d=function(){b.animating=!1;a===0&&b.list.css(b.lt,0);!b.autoStopped&&(b.options.wrap=="circular"||b.options.wrap=="both"||b.options.wrap=="last"||b.options.size===null||b.last<b.options.size||b.last==b.options.size&&b.tail!==null&&!b.inTail)&&b.startAuto();b.buttons();b.notify("onAfterAnimation");if(b.options.wrap=="circular"&&b.options.size!==null)for(var c=b.prevFirst;c<=b.prevLast;c++)c!==null&&!(c>=b.first&&c<=b.last)&&(c<1||c>b.options.size)&&b.remove(c)}; this.notify("onBeforeAnimation");if(!this.options.animation||c===!1)this.list.css(this.lt,a+"px"),d();else{var f=!this.options.vertical?this.options.rtl?{right:a}:{left:a}:{top:a},d={duration:this.options.animation,easing:this.options.easing,complete:d};if(g.isFunction(this.options.animationStepCallback))d.step=this.options.animationStepCallback;this.list.animate(f,d)}}},startAuto:function(a){if(a!==void 0)this.options.auto=a;if(this.options.auto===0)return this.stopAuto();if(this.timer===null){this.autoStopped= !1;var c=this;this.timer=window.setTimeout(function(){c.next()},this.options.auto*1E3)}},stopAuto:function(){this.pauseAuto();this.autoStopped=!0},pauseAuto:function(){if(this.timer!==null)window.clearTimeout(this.timer),this.timer=null},buttons:function(a,c){if(a==null&&(a=!this.locked&&this.options.size!==0&&(this.options.wrap&&this.options.wrap!="first"||this.options.size===null||this.last<this.options.size),!this.locked&&(!this.options.wrap||this.options.wrap=="first")&&this.options.size!==null&& this.last>=this.options.size))a=this.tail!==null&&!this.inTail;if(c==null&&(c=!this.locked&&this.options.size!==0&&(this.options.wrap&&this.options.wrap!="last"||this.first>1),!this.locked&&(!this.options.wrap||this.options.wrap=="last")&&this.options.size!==null&&this.first==1))c=this.tail!==null&&this.inTail;var b=this;this.buttonNext.size()>0?(this.buttonNext.unbind(this.options.buttonNextEvent+".jcarousel",this.funcNext),a&&this.buttonNext.bind(this.options.buttonNextEvent+".jcarousel",this.funcNext), this.buttonNext[a?"removeClass":"addClass"](this.className("jcarousel-next-disabled")).attr("disabled",a?!1:!0),this.options.buttonNextCallback!==null&&this.buttonNext.data("jcarouselstate")!=a&&this.buttonNext.each(function(){b.options.buttonNextCallback(b,this,a)}).data("jcarouselstate",a)):this.options.buttonNextCallback!==null&&this.buttonNextState!=a&&this.options.buttonNextCallback(b,null,a);this.buttonPrev.size()>0?(this.buttonPrev.unbind(this.options.buttonPrevEvent+".jcarousel",this.funcPrev), c&&this.buttonPrev.bind(this.options.buttonPrevEvent+".jcarousel",this.funcPrev),this.buttonPrev[c?"removeClass":"addClass"](this.className("jcarousel-prev-disabled")).attr("disabled",c?!1:!0),this.options.buttonPrevCallback!==null&&this.buttonPrev.data("jcarouselstate")!=c&&this.buttonPrev.each(function(){b.options.buttonPrevCallback(b,this,c)}).data("jcarouselstate",c)):this.options.buttonPrevCallback!==null&&this.buttonPrevState!=c&&this.options.buttonPrevCallback(b,null,c);this.buttonNextState= a;this.buttonPrevState=c},notify:function(a){var c=this.prevFirst===null?"init":this.prevFirst<this.first?"next":"prev";this.callback("itemLoadCallback",a,c);this.prevFirst!==this.first&&(this.callback("itemFirstInCallback",a,c,this.first),this.callback("itemFirstOutCallback",a,c,this.prevFirst));this.prevLast!==this.last&&(this.callback("itemLastInCallback",a,c,this.last),this.callback("itemLastOutCallback",a,c,this.prevLast));this.callback("itemVisibleInCallback",a,c,this.first,this.last,this.prevFirst, this.prevLast);this.callback("itemVisibleOutCallback",a,c,this.prevFirst,this.prevLast,this.first,this.last)},callback:function(a,c,b,d,f,j,e){if(!(this.options[a]==null||typeof this.options[a]!="object"&&c!="onAfterAnimation")){var h=typeof this.options[a]=="object"?this.options[a][c]:this.options[a];if(g.isFunction(h)){var i=this;if(d===void 0)h(i,b,c);else if(f===void 0)this.get(d).each(function(){h(i,this,d,b,c)});else for(var a=function(a){i.get(a).each(function(){h(i,this,a,b,c)})},k=d;k<=f;k++)k!== null&&!(k>=j&&k<=e)&&a(k)}}},create:function(a){return this.format("<li></li>",a)},format:function(a,c){for(var a=g(a),b=a.get(0).className.split(" "),d=0;d<b.length;d++)b[d].indexOf("jcarousel-")!=-1&&a.removeClass(b[d]);a.addClass(this.className("jcarousel-item")).addClass(this.className("jcarousel-item-"+c)).css({"float":this.options.rtl?"right":"left","list-style":"none"}).attr("jcarouselindex",c);return a},className:function(a){return a+" "+a+(!this.options.vertical?"-horizontal":"-vertical")}, dimension:function(a,c){var b=g(a);if(c==null)return!this.options.vertical?b.outerWidth(!0)||f.intval(this.options.itemFallbackDimension):b.outerHeight(!0)||f.intval(this.options.itemFallbackDimension);else{var d=!this.options.vertical?c-f.intval(b.css("marginLeft"))-f.intval(b.css("marginRight")):c-f.intval(b.css("marginTop"))-f.intval(b.css("marginBottom"));g(b).css(this.wh,d+"px");return this.dimension(b)}},clipping:function(){return!this.options.vertical?this.clip[0].offsetWidth-f.intval(this.clip.css("borderLeftWidth"))- f.intval(this.clip.css("borderRightWidth")):this.clip[0].offsetHeight-f.intval(this.clip.css("borderTopWidth"))-f.intval(this.clip.css("borderBottomWidth"))},index:function(a,c){if(c==null)c=this.options.size;return Math.round(((a-1)/c-Math.floor((a-1)/c))*c)+1}});f.extend({defaults:function(a){return g.extend(q,a||{})},intval:function(a){a=parseInt(a,10);return isNaN(a)?0:a},windowLoaded:function(){m=!0}});g.fn.jcarousel=function(a){if(typeof a=="string"){var c=g(this).data("jcarousel"),b=Array.prototype.slice.call(arguments, 1);return c[a].apply(c,b)}else return this.each(function(){var b=g(this).data("jcarousel");b?(a&&g.extend(b.options,a),b.reload()):g(this).data("jcarousel",new f(this,a))})}})(jQuery);
17
-
18
-
19
- function mycarousel_initCallback(carousel)
20
- {
21
- // Disable autoscrolling if the user clicks the prev or next button.
22
- carousel.buttonNext.bind('click', function() {
23
- carousel.startAuto(0);
24
- });
25
-
26
- carousel.buttonPrev.bind('click', function() {
27
- carousel.startAuto(0);
28
- });
29
-
30
- // Pause autoscrolling if the user moves with the cursor over the clip.
31
- carousel.clip.hover(function() {
32
- carousel.stopAuto();
33
- }, function() {
34
- carousel.startAuto();
35
- });
36
- };
37
-
38
- jQuery(document).ready(function() {
39
- jQuery('#cms_carousel').jcarousel({
40
- auto: 2,
41
- wrap: 'last',
42
- initCallback: mycarousel_initCallback
43
- });
44
- });
@@ -1,186 +0,0 @@
1
- .jcarousel-skin-tango .jcarousel-container {
2
- -moz-border-radius: 10px;
3
- -webkit-border-radius: 10px;
4
- border-radius: 10px;
5
- background: #F0F6F9;
6
- border: 1px solid #346F97;
7
- }
8
-
9
- .jcarousel-skin-tango .jcarousel-direction-rtl {
10
- direction: rtl;
11
- }
12
-
13
- .jcarousel-skin-tango .jcarousel-container-horizontal {
14
- width: 245px;
15
- padding: 20px 40px;
16
- }
17
-
18
- .jcarousel-skin-tango .jcarousel-container-vertical {
19
- width: 75px;
20
- height: 245px;
21
- padding: 40px 20px;
22
- }
23
-
24
- .jcarousel-skin-tango .jcarousel-clip {
25
- overflow: hidden;
26
- }
27
-
28
- .jcarousel-skin-tango .jcarousel-clip-horizontal {
29
- width: 245px;
30
- height: 75px;
31
- }
32
-
33
- .jcarousel-skin-tango .jcarousel-clip-vertical {
34
- width: 75px;
35
- height: 245px;
36
- }
37
-
38
- .jcarousel-skin-tango .jcarousel-item {
39
- width: 75px;
40
- height: 75px;
41
- }
42
-
43
- .jcarousel-skin-tango .jcarousel-item-horizontal {
44
- margin-left: 0;
45
- margin-right: 10px;
46
- }
47
-
48
- .jcarousel-skin-tango .jcarousel-direction-rtl .jcarousel-item-horizontal {
49
- margin-left: 10px;
50
- margin-right: 0;
51
- }
52
-
53
- .jcarousel-skin-tango .jcarousel-item-vertical {
54
- margin-bottom: 10px;
55
- }
56
-
57
- .jcarousel-skin-tango .jcarousel-item-placeholder {
58
- background: #fff;
59
- color: #000;
60
- }
61
-
62
- /**
63
- * Horizontal Buttons
64
- */
65
- .jcarousel-skin-tango .jcarousel-next-horizontal {
66
- position: absolute;
67
- top: 43px;
68
- right: 5px;
69
- width: 32px;
70
- height: 32px;
71
- cursor: pointer;
72
- background: transparent url((/assets/sofa_gallery/tango/next-horizontal.png) no-repeat 0 0;
73
- }
74
-
75
- .jcarousel-skin-tango .jcarousel-direction-rtl .jcarousel-next-horizontal {
76
- left: 5px;
77
- right: auto;
78
- background-image: url((/assets/sofa_gallery/tango/prev-horizontal.png);
79
- }
80
-
81
- .jcarousel-skin-tango .jcarousel-next-horizontal:hover,
82
- .jcarousel-skin-tango .jcarousel-next-horizontal:focus {
83
- background-position: -32px 0;
84
- }
85
-
86
- .jcarousel-skin-tango .jcarousel-next-horizontal:active {
87
- background-position: -64px 0;
88
- }
89
-
90
- .jcarousel-skin-tango .jcarousel-next-disabled-horizontal,
91
- .jcarousel-skin-tango .jcarousel-next-disabled-horizontal:hover,
92
- .jcarousel-skin-tango .jcarousel-next-disabled-horizontal:focus,
93
- .jcarousel-skin-tango .jcarousel-next-disabled-horizontal:active {
94
- cursor: default;
95
- background-position: -96px 0;
96
- }
97
-
98
- .jcarousel-skin-tango .jcarousel-prev-horizontal {
99
- position: absolute;
100
- top: 43px;
101
- left: 5px;
102
- width: 32px;
103
- height: 32px;
104
- cursor: pointer;
105
- background: transparent url((/assets/sofa_gallery/tango/prev-horizontal.png) no-repeat 0 0;
106
- }
107
-
108
- .jcarousel-skin-tango .jcarousel-direction-rtl .jcarousel-prev-horizontal {
109
- left: auto;
110
- right: 5px;
111
- background-image: url((/assets/sofa_gallery/tango/next-horizontal.png);
112
- }
113
-
114
- .jcarousel-skin-tango .jcarousel-prev-horizontal:hover,
115
- .jcarousel-skin-tango .jcarousel-prev-horizontal:focus {
116
- background-position: -32px 0;
117
- }
118
-
119
- .jcarousel-skin-tango .jcarousel-prev-horizontal:active {
120
- background-position: -64px 0;
121
- }
122
-
123
- .jcarousel-skin-tango .jcarousel-prev-disabled-horizontal,
124
- .jcarousel-skin-tango .jcarousel-prev-disabled-horizontal:hover,
125
- .jcarousel-skin-tango .jcarousel-prev-disabled-horizontal:focus,
126
- .jcarousel-skin-tango .jcarousel-prev-disabled-horizontal:active {
127
- cursor: default;
128
- background-position: -96px 0;
129
- }
130
-
131
- /**
132
- * Vertical Buttons
133
- */
134
- .jcarousel-skin-tango .jcarousel-next-vertical {
135
- position: absolute;
136
- bottom: 5px;
137
- left: 43px;
138
- width: 32px;
139
- height: 32px;
140
- cursor: pointer;
141
- background: transparent url((/assets/sofa_gallery/tango/next-vertical.png) no-repeat 0 0;
142
- }
143
-
144
- .jcarousel-skin-tango .jcarousel-next-vertical:hover,
145
- .jcarousel-skin-tango .jcarousel-next-vertical:focus {
146
- background-position: 0 -32px;
147
- }
148
-
149
- .jcarousel-skin-tango .jcarousel-next-vertical:active {
150
- background-position: 0 -64px;
151
- }
152
-
153
- .jcarousel-skin-tango .jcarousel-next-disabled-vertical,
154
- .jcarousel-skin-tango .jcarousel-next-disabled-vertical:hover,
155
- .jcarousel-skin-tango .jcarousel-next-disabled-vertical:focus,
156
- .jcarousel-skin-tango .jcarousel-next-disabled-vertical:active {
157
- cursor: default;
158
- background-position: 0 -96px;
159
- }
160
-
161
- .jcarousel-skin-tango .jcarousel-prev-vertical {
162
- position: absolute;
163
- top: 5px;
164
- left: 43px;
165
- width: 32px;
166
- height: 32px;
167
- cursor: pointer;
168
- background: transparent url((/assets/sofa_gallery/tango/prev-vertical.png) no-repeat 0 0;
169
- }
170
-
171
- .jcarousel-skin-tango .jcarousel-prev-vertical:hover,
172
- .jcarousel-skin-tango .jcarousel-prev-vertical:focus {
173
- background-position: 0 -32px;
174
- }
175
-
176
- .jcarousel-skin-tango .jcarousel-prev-vertical:active {
177
- background-position: 0 -64px;
178
- }
179
-
180
- .jcarousel-skin-tango .jcarousel-prev-disabled-vertical,
181
- .jcarousel-skin-tango .jcarousel-prev-disabled-vertical:hover,
182
- .jcarousel-skin-tango .jcarousel-prev-disabled-vertical:focus,
183
- .jcarousel-skin-tango .jcarousel-prev-disabled-vertical:active {
184
- cursor: default;
185
- background-position: 0 -96px;
186
- }
@@ -1 +0,0 @@
1
- Button images copyright by Tango Icon Library Team (http://tango.freedesktop.org/Tango_Icon_Library)