removed dupe code
parent
17dfb4df94
commit
0d7e72be51
@ -1,45 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/* globals define, app, socket, utils */
|
/* globals define, app, socket, utils */
|
||||||
define('forum/account/watched', ['forum/account/header', 'forum/infinitescroll'], function(header, infinitescroll) {
|
define('forum/account/watched', ['forum/account/header', 'forum/account/topics'], function(header, topics) {
|
||||||
var AccountWatched = {};
|
var AccountWatched = {};
|
||||||
|
|
||||||
AccountWatched.init = function() {
|
AccountWatched.init = function() {
|
||||||
header.init();
|
header.init();
|
||||||
|
|
||||||
if (!config.usePagination) {
|
topics.handleInfiniteScroll('account/watched', 'uid:' + ajaxify.variables.get('theirid') + ':followed_tids');
|
||||||
infinitescroll.init(loadMore);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function loadMore(direction) {
|
|
||||||
if (direction < 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
infinitescroll.loadMore('topics.loadMoreFromSet', {
|
|
||||||
set: 'uid:' + $('.account-username-box').attr('data-uid') + ':followed_tids',
|
|
||||||
after: $('[component="category"]').attr('data-nextstart')
|
|
||||||
}, function(data, done) {
|
|
||||||
if (data.topics && data.topics.length) {
|
|
||||||
onTopicsLoaded(data.topics, done);
|
|
||||||
} else {
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function onTopicsLoaded(topics, callback) {
|
|
||||||
infinitescroll.parseAndTranslate('account/watched', 'topics', {topics: topics}, function(html) {
|
|
||||||
$('[component="category"]').append(html);
|
|
||||||
html.find('.timeago').timeago();
|
|
||||||
app.createUserTooltips();
|
|
||||||
utils.makeNumbersHumanReadable(html.find('.human-readable-number'));
|
|
||||||
$(window).trigger('action:topics.loaded');
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return AccountWatched;
|
return AccountWatched;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue