From d12ec38736218e11792ce6c138bbf4c686620449 Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Thu, 7 Apr 2011 15:00:45 -0700 Subject: [PATCH] Fix mobile infinite scroll --- app/views/aspects/index.mobile.haml | 5 +++-- app/views/shared/_stream_element.mobile.haml | 2 +- public/javascripts/infinite_scroll.js | 7 +++---- public/javascripts/widgets/timeago.js | 10 +++++++--- vendor/plugins/mobile-fu/lib/mobile_fu.rb | 2 +- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/views/aspects/index.mobile.haml b/app/views/aspects/index.mobile.haml index 92c31211c..a6e78e163 100644 --- a/app/views/aspects/index.mobile.haml +++ b/app/views/aspects/index.mobile.haml @@ -12,7 +12,8 @@ = link_to t('.post_a_message'), '#publisher_page', :id => 'publisher_button' #main_stream.stream = render 'shared/stream', :posts => @posts - %a.more-link.paginate{:href => aspects_path(:a_ids => params[:a_ids], :page => params[:page] + 1)} - %h2= t("more") + #pagination + %a.more-link.paginate{:href => aspects_path(:a_ids => params[:a_ids], :page => params[:page] + 1)} + %h2= t("more") - content_for :subpages do = render 'shared/publisher', :aspect_ids => @aspect_ids diff --git a/app/views/shared/_stream_element.mobile.haml b/app/views/shared/_stream_element.mobile.haml index 1b00a09a7..1065719d8 100644 --- a/app/views/shared/_stream_element.mobile.haml +++ b/app/views/shared/_stream_element.mobile.haml @@ -14,4 +14,4 @@ .info %span.time = 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' diff --git a/public/javascripts/infinite_scroll.js b/public/javascripts/infinite_scroll.js index 0bc18808c..cfdd50bc3 100644 --- a/public/javascripts/infinite_scroll.js +++ b/public/javascripts/infinite_scroll.js @@ -10,15 +10,14 @@ var InfiniteScroll = { var newPath = pathStr.replace("?", "?only_posts=true&"); return newPath.replace( "page=2", "page=" + nextPage); }, - bufferPx: 300, + bufferPx: 500, debug: false, donetext: "no more.", loadingText: "", loadingImg: '/images/ajax-loader.gif' }, + postScrollCallback: function(){}, initialize: function(){ - $('#main_stream').infinitescroll(InfiniteScroll.options, function() { - Diaspora.widgets.timeago.updateTimeAgo(); - }); + $('#main_stream').infinitescroll(InfiniteScroll.options, InfiniteScroll.postScrollCallback); } } diff --git a/public/javascripts/widgets/timeago.js b/public/javascripts/widgets/timeago.js index eb36a520c..2b366c7b0 100644 --- a/public/javascripts/widgets/timeago.js +++ b/public/javascripts/widgets/timeago.js @@ -12,7 +12,7 @@ Diaspora.widgets.add("timeago", function() { if(Diaspora.widgets.i18n.language === "en") { return; } - + jQuery.timeago.settings.strings = { prefixAgo: Diaspora.widgets.i18n.t("timeago.prefixAgo"), prefixFromNow: Diaspora.widgets.i18n.t("timeago.prefixFromNow"), @@ -30,11 +30,15 @@ Diaspora.widgets.add("timeago", function() { year: Diaspora.widgets.i18n.t("timeago.year"), years: Diaspora.widgets.i18n.t("timeago.years") }; - + Diaspora.widgets.timeago.updateTimeAgo("abbr"); }; this.updateTimeAgo = function(selector) { $(selector || this.selector).timeago(); }; -}); \ No newline at end of file +}); + +InfiniteScroll.postScrollCallback = function(){ + Diaspora.widgets.timeago.updateTimeAgo(); +} diff --git a/vendor/plugins/mobile-fu/lib/mobile_fu.rb b/vendor/plugins/mobile-fu/lib/mobile_fu.rb index 0c69a24a5..c83af4a02 100644 --- a/vendor/plugins/mobile-fu/lib/mobile_fu.rb +++ b/vendor/plugins/mobile-fu/lib/mobile_fu.rb @@ -67,7 +67,7 @@ module ActionController # the user has opted to use either the 'Standard' view or 'Mobile' view. 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 session[:mobile_view] = true if session[:mobile_view].nil? end