Infinite scroll is now a widget, remove InfiniteScroll#postScroll, use DiasporaJS pub/sub instead, remove timeago.js hacks
This commit is contained in:
parent
d28e7e70b8
commit
3d11b402e0
8 changed files with 49 additions and 64 deletions
|
|
@ -29,11 +29,11 @@ javascripts:
|
||||||
- public/javascripts/widgets/alert.js
|
- public/javascripts/widgets/alert.js
|
||||||
- public/javascripts/widgets/embedder.js
|
- public/javascripts/widgets/embedder.js
|
||||||
- public/javascripts/widgets/timeago.js
|
- public/javascripts/widgets/timeago.js
|
||||||
|
- public/javascripts/widgets/infinite-scroll.js
|
||||||
- public/javascripts/widgets/directionDetector.js
|
- public/javascripts/widgets/directionDetector.js
|
||||||
- public/javascripts/view.js
|
- public/javascripts/view.js
|
||||||
- public/javascripts/stream.js
|
- public/javascripts/stream.js
|
||||||
- public/javascripts/search.js
|
- public/javascripts/search.js
|
||||||
- public/javascripts/infinite-scroll.js
|
|
||||||
mobile:
|
mobile:
|
||||||
- public/javascripts/vendor/jquery152.min.js
|
- public/javascripts/vendor/jquery152.min.js
|
||||||
- public/javascripts/custom-mobile-scripting.js
|
- public/javascripts/custom-mobile-scripting.js
|
||||||
|
|
@ -41,7 +41,7 @@ javascripts:
|
||||||
- public/javascripts/vendor/jquery.infinitescroll.min.js
|
- public/javascripts/vendor/jquery.infinitescroll.min.js
|
||||||
- public/javascripts/diaspora.js
|
- public/javascripts/diaspora.js
|
||||||
- public/javascripts/widgets/i18n.js
|
- public/javascripts/widgets/i18n.js
|
||||||
- public/javascripts/infinite-scroll.js
|
- public/javascripts/widgets/infinite-scroll.js
|
||||||
- public/javascripts/rails.js
|
- public/javascripts/rails.js
|
||||||
mailchimp:
|
mailchimp:
|
||||||
- public/javascripts/vendor/mailchimp/jquery.form.js
|
- public/javascripts/vendor/mailchimp/jquery.form.js
|
||||||
|
|
|
||||||
|
|
@ -31,4 +31,5 @@ en:
|
||||||
cannot_remove: "Cannot remove person from last aspect. (If you want to disconnect from this person you must remove contact.)"
|
cannot_remove: "Cannot remove person from last aspect. (If you want to disconnect from this person you must remove contact.)"
|
||||||
publisher:
|
publisher:
|
||||||
at_least_one_aspect: "You must publish to at least one aspect"
|
at_least_one_aspect: "You must publish to at least one aspect"
|
||||||
|
infinite_scroll:
|
||||||
|
no_more: "No more posts."
|
||||||
|
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
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 : ".stream_element",
|
|
||||||
// selector for all items you'll retrieve
|
|
||||||
pathParse : function( pathStr, nextPage ){
|
|
||||||
var newPath = pathStr.replace("?", "?only_posts=true&");
|
|
||||||
var last_time = $('#main_stream .stream_element').last().find('.time').attr('integer');
|
|
||||||
return newPath.replace( /max_time=\d+/, 'max_time=' + last_time);
|
|
||||||
},
|
|
||||||
bufferPx: 500,
|
|
||||||
debug: false,
|
|
||||||
donetext: "no more.",
|
|
||||||
loadingText: "",
|
|
||||||
loadingImg: '/images/ajax-loader.gif'
|
|
||||||
},
|
|
||||||
postScrollCallback: function(){
|
|
||||||
for (var callback in InfiniteScroll.postScrollCallbacks){
|
|
||||||
InfiniteScroll.postScrollCallbacks[callback]();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
postScrollCallbacks: [],
|
|
||||||
initialize: function(){
|
|
||||||
Diaspora.widgets.subscribe("stream/reloaded", InfiniteScroll.initialize);
|
|
||||||
$('#main_stream').infinitescroll(InfiniteScroll.options, InfiniteScroll.postScrollCallback);
|
|
||||||
},
|
|
||||||
postScroll: function( callback ){
|
|
||||||
InfiniteScroll.postScrollCallbacks.push(callback);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
InfiniteScroll.initialize();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
@ -18,7 +18,8 @@ var View = {
|
||||||
$(document).bind('afterReveal.facebox', function() {
|
$(document).bind('afterReveal.facebox', function() {
|
||||||
jQuery("#facebox label").inFieldLabels();
|
jQuery("#facebox label").inFieldLabels();
|
||||||
});
|
});
|
||||||
InfiniteScroll.postScroll(function(){
|
|
||||||
|
Diaspora.widgets.subscribe("stream/scrolled", function() {
|
||||||
$('#main_stream .comments label').inFieldLabels();
|
$('#main_stream .comments label').inFieldLabels();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ Diaspora.widgets.add("directionDetector", function() {
|
||||||
|
|
||||||
this.start = function() {
|
this.start = function() {
|
||||||
Diaspora.widgets.directionDetector.updateBinds();
|
Diaspora.widgets.directionDetector.updateBinds();
|
||||||
InfiniteScroll.postScroll(function() {
|
|
||||||
|
Diaspora.widgets.subscribe("stream/scrolled", function() {
|
||||||
Diaspora.widgets.directionDetector.updateBinds();
|
Diaspora.widgets.directionDetector.updateBinds();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
35
public/javascripts/widgets/infinite-scroll.js
Normal file
35
public/javascripts/widgets/infinite-scroll.js
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
/* Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
* licensed under the Affero General Public License version 3 or later. See
|
||||||
|
* the COPYRIGHT file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
var InfiniteScroll = function() {
|
||||||
|
this.options = {
|
||||||
|
navSelector : "#pagination",
|
||||||
|
nextSelector : ".paginate",
|
||||||
|
itemSelector : ".stream_element",
|
||||||
|
pathParse : function( pathStr, nextPage ){
|
||||||
|
var newPath = pathStr.replace("?", "?only_posts=true&");
|
||||||
|
var last_time = $('#main_stream .stream_element').last().find('.time').attr('integer');
|
||||||
|
return newPath.replace( /max_time=\d+/, 'max_time=' + last_time);
|
||||||
|
},
|
||||||
|
bufferPx: 500,
|
||||||
|
debug: false,
|
||||||
|
donetext: Diaspora.widgets.i18n.t("infinite_scroll.no_more"),
|
||||||
|
loadingText: "",
|
||||||
|
loadingImg: '/images/ajax-loader.gif'
|
||||||
|
};
|
||||||
|
|
||||||
|
this.start = function() {
|
||||||
|
Diaspora.widgets.subscribe("stream/reloaded", InfiniteScroll.initialize);
|
||||||
|
|
||||||
|
$('#main_stream').infinitescroll(this.options, function() {
|
||||||
|
Diaspora.widgets.publish("stream/scrolled");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
Diaspora.widgets.add("infinitescroll", InfiniteScroll)
|
||||||
|
})();
|
||||||
|
|
||||||
|
|
@ -5,32 +5,17 @@
|
||||||
|
|
||||||
Diaspora.widgets.add("timeago", function() {
|
Diaspora.widgets.add("timeago", function() {
|
||||||
this.selector = "abbr.timeago";
|
this.selector = "abbr.timeago";
|
||||||
this.not_done = true;
|
|
||||||
this.start = function() {
|
this.start = function() {
|
||||||
|
Diaspora.widgets.subscribe("stream/scrolled", this.updateTimeAgo);
|
||||||
this.not_done = false;
|
|
||||||
InfiniteScroll.postScroll(function(){
|
|
||||||
Diaspora.widgets.timeago.updateTimeAgo();
|
|
||||||
});
|
|
||||||
|
|
||||||
if(Diaspora.widgets.i18n.language === "en") {
|
if(Diaspora.widgets.i18n.language !== "en") {
|
||||||
return;
|
$.each($.timeago.settings.strings, function(index, element) {
|
||||||
|
$.timeago.settings.strings[index] = Diaspora.widgets.i18n.t("timeago." + index);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$.each($.timeago.settings.strings, function(index, element) {
|
|
||||||
$.timeago.settings.strings[index] = Diaspora.widgets.i18n.t("timeago." + index);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
Diaspora.widgets.timeago.updateTimeAgo("abbr");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.updateTimeAgo = function(selector) {
|
this.updateTimeAgo = function(selector) {
|
||||||
|
$((typeof selector === "string") ? selector : Diaspora.widgets.timeago.selector).timeago();
|
||||||
if(this.not_done === true){
|
|
||||||
this.not_done = false;
|
|
||||||
Diaspora.widgets.timeago.start();
|
|
||||||
}
|
|
||||||
$(selector || this.selector).timeago();
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue