Working on fixing infinite scroll, in particular for aspects with the number 2 in their id.
This commit is contained in:
parent
59334dfaf5
commit
9454c3a1b9
8 changed files with 30 additions and 50 deletions
|
|
@ -25,8 +25,6 @@ class AspectsController < ApplicationController
|
|||
end
|
||||
params[:page] = params[:page] ? params[:page].to_i : 1
|
||||
|
||||
|
||||
|
||||
@selected_contacts = @aspects.map { |aspect| aspect.contacts }.flatten.uniq
|
||||
@aspect_ids = @aspects.map { |a| a.id }
|
||||
@posts = current_user.raw_visible_posts(:by_members_of => @aspect_ids, :type => 'StatusMessage', :order => session[:sort_order] + ' DESC', :page => params[:page]).includes(
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#main_stream.stream{:data => {:guids => aspect_ids.join(',')}}
|
||||
- if posts.length > 0
|
||||
= render 'shared/stream', :posts => fakes
|
||||
=link_to(t('more'), aspects_path(:a_ids => params[:a_ids], :page => params[:page] + 1), :class => 'paginate')
|
||||
#pagination
|
||||
=link_to(t('more'), aspects_path(:page => (params[:page] + 1), :a_ids => params[:a_ids]), :class => 'paginate')
|
||||
- else
|
||||
= render 'aspects/no_posts_message', :post_count => posts.length
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
- content_for :head do
|
||||
= include_javascripts :home
|
||||
|
||||
.span-15.append-2
|
||||
#aspect_stream_container
|
||||
= render 'aspect_stream',
|
||||
|
|
|
|||
|
|
@ -1,21 +1,3 @@
|
|||
$('#aspect_stream_container').html("<%= escape_javascript(render('aspects/aspect_stream', :aspect => @aspect, :aspect_ids => @aspect_ids, :posts => @posts, :fakes => @fakes)) %>");
|
||||
$('#aspect_listings').html("<%= escape_javascript(render('aspects/aspect_listings', :aspects => @aspects)) %>");
|
||||
$('a[rel*=facebox]').facebox();
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#main_stream').infinitescroll({
|
||||
navSelector : "#main_stream + div.pagination",
|
||||
// selector for the paged navigation (it will be hidden)
|
||||
nextSelector : ".pagination a.next_page",
|
||||
// selector for the NEXT link (to page 2)
|
||||
itemSelector : "#main_stream .stream_element",
|
||||
// selector for all items you'll retrieve
|
||||
bufferPx: 300,
|
||||
donetext: "no more.",
|
||||
loadingText: "",
|
||||
loadingImg: '/images/ajax-loader.gif'
|
||||
});
|
||||
|
||||
Diaspora.widgets.timeago.updateTimeAgo();
|
||||
Publisher.initialize();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ javascripts:
|
|||
- public/javascripts/stream.js
|
||||
- public/javascripts/application.js
|
||||
- public/javascripts/search.js
|
||||
- public/javascripts/infinite_scroll.js
|
||||
mobile:
|
||||
- public/javascripts/vendor/jquery152.min.js
|
||||
- public/javascripts/custom-mobile-scripting.js
|
||||
|
|
|
|||
|
|
@ -1,33 +1,6 @@
|
|||
$(document).ready(function() {
|
||||
var scrolled = 0;
|
||||
|
||||
$('#main_stream').infinitescroll({
|
||||
navSelector : ".paginate",
|
||||
// selector for the paged navigation (it will be hidden)
|
||||
nextSelector : ".paginate",
|
||||
// selector for the NEXT link (to page 2)
|
||||
itemSelector : "#main_stream .stream_element",
|
||||
// selector for all items you'll retrieve
|
||||
bufferPx: 300,
|
||||
debug: false,
|
||||
donetext: "no more.",
|
||||
loadingText: "",
|
||||
loadingImg: '/images/ajax-loader.gif'
|
||||
}, function() {
|
||||
scrolled++;
|
||||
|
||||
if(scrolled > 2) {
|
||||
(scrolled === 3) && $(window).unbind('.infscr');
|
||||
|
||||
$("a.paginate")
|
||||
.detach()
|
||||
.appendTo("#main_stream")
|
||||
.css("display", "block");
|
||||
}
|
||||
Diaspora.widgets.timeago.updateTimeAgo();
|
||||
});
|
||||
|
||||
|
||||
InfiniteScroll.initialize();
|
||||
|
||||
$("a.paginate").live("click", function() {
|
||||
$(this).css("display", "none");
|
||||
|
|
|
|||
|
|
@ -176,6 +176,9 @@ $(document).ready(function(){
|
|||
// reinit listeners on stream
|
||||
photozone.html(photos_html);
|
||||
Stream.initialize();
|
||||
InfiniteScroll.initialize();
|
||||
|
||||
Publisher.initialize();
|
||||
|
||||
// fade contents back in
|
||||
if(requests == 0){
|
||||
|
|
|
|||
23
public/javascripts/infinite_scroll.js
Normal file
23
public/javascripts/infinite_scroll.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
var InfiniteScroll = {
|
||||
options: {
|
||||
navSelector : "#pagination",
|
||||
// selector for the paged navigation (it will be hidden)
|
||||
nextSelector : ".paginate",
|
||||
// selector for the NEXT link (to page 2)
|
||||
itemSelector : "#main_stream .stream_element",
|
||||
// selector for all items you'll retrieve
|
||||
pathParse : function( pathStr, nextPage ){
|
||||
return pathStr.replace( "page=2", "page=" + nextPage)
|
||||
},
|
||||
bufferPx: 300,
|
||||
debug: false,
|
||||
donetext: "no more.",
|
||||
loadingText: "",
|
||||
loadingImg: '/images/ajax-loader.gif'
|
||||
},
|
||||
initialize: function(){
|
||||
$('#main_stream').infinitescroll(InfiniteScroll.options, function() {
|
||||
Diaspora.widgets.timeago.updateTimeAgo();
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue