diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index 410214b..d773e7d 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -385,7 +385,7 @@ class CmsController < MyProfileController end def view_all_media - paginate_options = {:page => 1} + paginate_options = {:page => params[:page].blank? ? 1 : params[:page] } @key = params[:key].to_sym load_recent_files(params[:parent_id], params[:q], paginate_options) end diff --git a/app/views/cms/_published_media_items.html.erb b/app/views/cms/_published_media_items.html.erb index 1d012b4..b9ccdc9 100644 --- a/app/views/cms/_published_media_items.html.erb +++ b/app/views/cms/_published_media_items.html.erb @@ -7,9 +7,6 @@ <%= link_to(_('View all'), {:controller => 'cms', :action => 'view_all_media', :profile => profile.identifier, :key => key}, :class => 'view-all colorbox', 'data-key' => key) %> <% end %> - <% @recent_files[key].each do |file| %> - <% @file = file %> - <%= render :partial => "cms/media_panel/#{key.to_s.singularize}" %> - <% end %> + <%= render :partial => "cms/media_panel/list_published_media_items", :locals => { key: key, show_pagination_links: false } %> <% end %> diff --git a/app/views/cms/media_panel/_list_published_media_items.html.erb b/app/views/cms/media_panel/_list_published_media_items.html.erb new file mode 100644 index 0000000..5ec6b17 --- /dev/null +++ b/app/views/cms/media_panel/_list_published_media_items.html.erb @@ -0,0 +1,5 @@ +<% @recent_files[key].each do |file| %> + <% @file = file %> + <%= render :partial => "cms/media_panel/#{key.to_s.singularize}" %> +<% end %> +<%= pagination_links @recent_files[key] if show_pagination_links %> diff --git a/app/views/cms/view_all_media.html.erb b/app/views/cms/view_all_media.html.erb index 7c0cc50..b5f4258 100644 --- a/app/views/cms/view_all_media.html.erb +++ b/app/views/cms/view_all_media.html.erb @@ -1,8 +1,7 @@

<%= file_types[@key] %>

- <% @recent_files[@key].each do |file| %> - <% @file = file %> - <%= render :partial => "cms/media_panel/#{@key.to_s.singularize}" %> - <% end %> + <%= render :partial => "cms/media_panel/list_published_media_items", :locals => { key: @key, show_pagination_links: true } %>
+ +<%= javascript_include_tag 'media-panel.js' %> diff --git a/app/views/cms/view_all_media.js.erb b/app/views/cms/view_all_media.js.erb new file mode 100644 index 0000000..40dedfa --- /dev/null +++ b/app/views/cms/view_all_media.js.erb @@ -0,0 +1 @@ +jQuery('.view-all-media').html('<%= escape_javascript(render :partial => "cms/media_panel/list_published_media_items", :locals => { key: @key, show_pagination_links: true }) %>'); diff --git a/public/javascripts/media-panel.js b/public/javascripts/media-panel.js index e7a1de2..3777b88 100644 --- a/public/javascripts/media-panel.js +++ b/public/javascripts/media-panel.js @@ -1,5 +1,15 @@ var file_id = 1; +jQuery('.view-all-media').on('click', '.pagination a', function(event) { + jQuery.ajax({ + url: this.href, + beforeSend: function(){jQuery('.view-all-media').addClass('fetching')}, + complete: function() {jQuery('.view-all-media').removeClass('fetching')}, + dataType: 'script' + }); + return false; +}); + jQuery('#file').fileupload({ add: function(e, data){ data.files[0].id = file_id; -- libgit2 0.21.2