Commit 1ead86ec2e6d27ec7961ff20016aec7e12054390
1 parent
99b49d6e
Exists in
master
and in
29 other branches
[media-panel-improvements] Really shows all items in view all
Uses pagination and loads the pages using ajax.
Showing
6 changed files
with
21 additions
and
9 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
@@ -385,7 +385,7 @@ class CmsController < MyProfileController | @@ -385,7 +385,7 @@ class CmsController < MyProfileController | ||
385 | end | 385 | end |
386 | 386 | ||
387 | def view_all_media | 387 | def view_all_media |
388 | - paginate_options = {:page => 1} | 388 | + paginate_options = {:page => params[:page].blank? ? 1 : params[:page] } |
389 | @key = params[:key].to_sym | 389 | @key = params[:key].to_sym |
390 | load_recent_files(params[:parent_id], params[:q], paginate_options) | 390 | load_recent_files(params[:parent_id], params[:q], paginate_options) |
391 | end | 391 | end |
app/views/cms/_published_media_items.html.erb
@@ -7,9 +7,6 @@ | @@ -7,9 +7,6 @@ | ||
7 | <%= link_to(_('View all'), {:controller => 'cms', :action => 'view_all_media', :profile => profile.identifier, :key => key}, :class => 'view-all colorbox', 'data-key' => key) %> | 7 | <%= link_to(_('View all'), {:controller => 'cms', :action => 'view_all_media', :profile => profile.identifier, :key => key}, :class => 'view-all colorbox', 'data-key' => key) %> |
8 | <% end %> | 8 | <% end %> |
9 | </div> | 9 | </div> |
10 | - <% @recent_files[key].each do |file| %> | ||
11 | - <% @file = file %> | ||
12 | - <%= render :partial => "cms/media_panel/#{key.to_s.singularize}" %> | ||
13 | - <% end %> | 10 | + <%= render :partial => "cms/media_panel/list_published_media_items", :locals => { key: key, show_pagination_links: false } %> |
14 | </div> | 11 | </div> |
15 | <% end %> | 12 | <% end %> |
app/views/cms/media_panel/_list_published_media_items.html.erb
0 → 100644
app/views/cms/view_all_media.html.erb
1 | <h1><%= file_types[@key] %></h1> | 1 | <h1><%= file_types[@key] %></h1> |
2 | 2 | ||
3 | <div class='view-all-media view-all-<%= @key %>'> | 3 | <div class='view-all-media view-all-<%= @key %>'> |
4 | - <% @recent_files[@key].each do |file| %> | ||
5 | - <% @file = file %> | ||
6 | - <%= render :partial => "cms/media_panel/#{@key.to_s.singularize}" %> | ||
7 | - <% end %> | 4 | + <%= render :partial => "cms/media_panel/list_published_media_items", :locals => { key: @key, show_pagination_links: true } %> |
8 | </div> | 5 | </div> |
6 | + | ||
7 | +<%= javascript_include_tag 'media-panel.js' %> |
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +jQuery('.view-all-media').html('<%= escape_javascript(render :partial => "cms/media_panel/list_published_media_items", :locals => { key: @key, show_pagination_links: true }) %>'); |
public/javascripts/media-panel.js
1 | var file_id = 1; | 1 | var file_id = 1; |
2 | 2 | ||
3 | +jQuery('.view-all-media').on('click', '.pagination a', function(event) { | ||
4 | + jQuery.ajax({ | ||
5 | + url: this.href, | ||
6 | + beforeSend: function(){jQuery('.view-all-media').addClass('fetching')}, | ||
7 | + complete: function() {jQuery('.view-all-media').removeClass('fetching')}, | ||
8 | + dataType: 'script' | ||
9 | + }); | ||
10 | + return false; | ||
11 | +}); | ||
12 | + | ||
3 | jQuery('#file').fileupload({ | 13 | jQuery('#file').fileupload({ |
4 | add: function(e, data){ | 14 | add: function(e, data){ |
5 | data.files[0].id = file_id; | 15 | data.files[0].id = file_id; |