Fix mobile infinite scroll

This commit is contained in:
Raphael Sofaer 2011-04-07 15:00:45 -07:00
parent 883ff63ec9
commit d12ec38736
5 changed files with 15 additions and 11 deletions

View file

@ -12,7 +12,8 @@
= link_to t('.post_a_message'), '#publisher_page', :id => 'publisher_button' = link_to t('.post_a_message'), '#publisher_page', :id => 'publisher_button'
#main_stream.stream #main_stream.stream
= render 'shared/stream', :posts => @posts = render 'shared/stream', :posts => @posts
%a.more-link.paginate{:href => aspects_path(:a_ids => params[:a_ids], :page => params[:page] + 1)} #pagination
%h2= t("more") %a.more-link.paginate{:href => aspects_path(:a_ids => params[:a_ids], :page => params[:page] + 1)}
%h2= t("more")
- content_for :subpages do - content_for :subpages do
= render 'shared/publisher', :aspect_ids => @aspect_ids = render 'shared/publisher', :aspect_ids => @aspect_ids

View file

@ -14,4 +14,4 @@
.info .info
%span.time %span.time
= t('ago', :time => time_ago_in_words(post.created_at)) = t('ago', :time => time_ago_in_words(post.created_at))
= link_to "#{t('comments', :count => post.comments.length)} →", status_message_path(post), :class => 'comment_link right' = link_to "#{t('comments', :count => post.comments.length)} →", status_message_path(post), :class => 'comment_link right ui-link'

View file

@ -10,15 +10,14 @@ var InfiniteScroll = {
var newPath = pathStr.replace("?", "?only_posts=true&"); var newPath = pathStr.replace("?", "?only_posts=true&");
return newPath.replace( "page=2", "page=" + nextPage); return newPath.replace( "page=2", "page=" + nextPage);
}, },
bufferPx: 300, bufferPx: 500,
debug: false, debug: false,
donetext: "no more.", donetext: "no more.",
loadingText: "", loadingText: "",
loadingImg: '/images/ajax-loader.gif' loadingImg: '/images/ajax-loader.gif'
}, },
postScrollCallback: function(){},
initialize: function(){ initialize: function(){
$('#main_stream').infinitescroll(InfiniteScroll.options, function() { $('#main_stream').infinitescroll(InfiniteScroll.options, InfiniteScroll.postScrollCallback);
Diaspora.widgets.timeago.updateTimeAgo();
});
} }
} }

View file

@ -12,7 +12,7 @@ Diaspora.widgets.add("timeago", function() {
if(Diaspora.widgets.i18n.language === "en") { if(Diaspora.widgets.i18n.language === "en") {
return; return;
} }
jQuery.timeago.settings.strings = { jQuery.timeago.settings.strings = {
prefixAgo: Diaspora.widgets.i18n.t("timeago.prefixAgo"), prefixAgo: Diaspora.widgets.i18n.t("timeago.prefixAgo"),
prefixFromNow: Diaspora.widgets.i18n.t("timeago.prefixFromNow"), prefixFromNow: Diaspora.widgets.i18n.t("timeago.prefixFromNow"),
@ -30,11 +30,15 @@ Diaspora.widgets.add("timeago", function() {
year: Diaspora.widgets.i18n.t("timeago.year"), year: Diaspora.widgets.i18n.t("timeago.year"),
years: Diaspora.widgets.i18n.t("timeago.years") years: Diaspora.widgets.i18n.t("timeago.years")
}; };
Diaspora.widgets.timeago.updateTimeAgo("abbr"); Diaspora.widgets.timeago.updateTimeAgo("abbr");
}; };
this.updateTimeAgo = function(selector) { this.updateTimeAgo = function(selector) {
$(selector || this.selector).timeago(); $(selector || this.selector).timeago();
}; };
}); });
InfiniteScroll.postScrollCallback = function(){
Diaspora.widgets.timeago.updateTimeAgo();
}

View file

@ -67,7 +67,7 @@ module ActionController
# the user has opted to use either the 'Standard' view or 'Mobile' view. # the user has opted to use either the 'Standard' view or 'Mobile' view.
def set_mobile_format def set_mobile_format
if is_mobile_device? && !request.xhr? if is_mobile_device? && ['/','text/html'].include?(request.format)
request.format = session[:mobile_view] == false ? :html : :mobile request.format = session[:mobile_view] == false ? :html : :mobile
session[:mobile_view] = true if session[:mobile_view].nil? session[:mobile_view] = true if session[:mobile_view].nil?
end end