|
|
|
'use strict';
|
|
|
|
|
|
|
|
/* globals define, app, socket */
|
|
|
|
|
|
|
|
define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll'], function(recent, topicSelect, infinitescroll) {
|
|
|
|
var Unread = {};
|
|
|
|
|
|
|
|
$(window).on('action:ajaxify.start', function(ev, data) {
|
|
|
|
if (ajaxify.currentPage !== data.url) {
|
|
|
|
recent.removeListeners();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Unread.init = function() {
|
|
|
|
app.enterRoom('recent_posts');
|
|
|
|
|
|
|
|
$('#new-topics-alert').on('click', function() {
|
|
|
|
$(this).addClass('hide');
|
|
|
|
});
|
|
|
|
|
|
|
|
recent.watchForNewPosts();
|
|
|
|
|
|
|
|
$('#markSelectedRead').on('click', function() {
|
|
|
|
var tids = topicSelect.getSelectedTids();
|
|
|
|
if(!tids.length) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
socket.emit('topics.markAsRead', tids, function(err) {
|
|
|
|
if(err) {
|
|
|
|
return app.alertError(err.message);
|
|
|
|
}
|
|
|
|
|
|
|
|
doneRemovingTids(tids);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#markAllRead').on('click', function() {
|
|
|
|
socket.emit('topics.markAllRead', function(err) {
|
|
|
|
if(err) {
|
|
|
|
return app.alertError(err.message);
|
|
|
|
}
|
|
|
|
|
|
|
|
app.alertSuccess('[[unread:topics_marked_as_read.success]]');
|
|
|
|
|
closes #2792, closes #2791, closes #2788, closes #2787, closes #2786, closes #2785, closes #2784, closes #2783
Squashed commit of the following:
commit ca5064a4effa3904ce936b521b169bba8d24f1a1
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:19:32 2015 -0500
Revert "added ajaxify popstate cache, so back/forward will just put back the already loaded page"
This reverts commit 77d154bb8b9549523e35c323dcb62f811c27dfb6.
commit ae07fc56c156074de8048bb627f5d9be849c8ad1
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:19:24 2015 -0500
Revert "on click, topics are marked read from the unread page. Also fixed an issue where isPopState kept getting set to true, causing issues"
This reverts commit d8c9ec0d406147b4ac9631fcc7687073ee71ea8e.
Conflicts:
public/src/client/unread.js
commit 96ee3631d7e4e1fc2c1b7632d86684fecd1e430f
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:18:25 2015 -0500
Revert "actually fixed isPopState error"
This reverts commit e6701c5a1f5a87a526c860f8e25e68ca1a65492d.
10 years ago
|
|
|
$('#topics-container').empty();
|
|
|
|
$('#category-no-topics').removeClass('hidden');
|
|
|
|
$('.markread').addClass('hidden');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.markread').on('click', '.category', function() {
|
|
|
|
function getCategoryTids(cid) {
|
|
|
|
var tids = [];
|
|
|
|
$('#topics-container .category-item[data-cid="' + cid + '"]').each(function() {
|
|
|
|
tids.push($(this).attr('data-tid'));
|
|
|
|
});
|
|
|
|
return tids;
|
|
|
|
}
|
|
|
|
var cid = $(this).attr('data-cid');
|
|
|
|
var tids = getCategoryTids(cid);
|
|
|
|
|
|
|
|
socket.emit('topics.markCategoryTopicsRead', cid, function(err) {
|
|
|
|
if(err) {
|
|
|
|
return app.alertError(err.message);
|
|
|
|
}
|
|
|
|
|
|
|
|
doneRemovingTids(tids);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
socket.emit('categories.get', onCategoriesLoaded);
|
|
|
|
|
|
|
|
topicSelect.init();
|
|
|
|
|
closes #2792, closes #2791, closes #2788, closes #2787, closes #2786, closes #2785, closes #2784, closes #2783
Squashed commit of the following:
commit ca5064a4effa3904ce936b521b169bba8d24f1a1
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:19:32 2015 -0500
Revert "added ajaxify popstate cache, so back/forward will just put back the already loaded page"
This reverts commit 77d154bb8b9549523e35c323dcb62f811c27dfb6.
commit ae07fc56c156074de8048bb627f5d9be849c8ad1
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:19:24 2015 -0500
Revert "on click, topics are marked read from the unread page. Also fixed an issue where isPopState kept getting set to true, causing issues"
This reverts commit d8c9ec0d406147b4ac9631fcc7687073ee71ea8e.
Conflicts:
public/src/client/unread.js
commit 96ee3631d7e4e1fc2c1b7632d86684fecd1e430f
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:18:25 2015 -0500
Revert "actually fixed isPopState error"
This reverts commit e6701c5a1f5a87a526c860f8e25e68ca1a65492d.
10 years ago
|
|
|
if ($("body").height() <= $(window).height() && $('#topics-container').children().length >= 20) {
|
|
|
|
$('#load-more-btn').show();
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#load-more-btn').on('click', function() {
|
|
|
|
loadMoreTopics();
|
|
|
|
});
|
|
|
|
|
|
|
|
infinitescroll.init(loadMoreTopics);
|
|
|
|
|
|
|
|
function loadMoreTopics(direction) {
|
closes #2792, closes #2791, closes #2788, closes #2787, closes #2786, closes #2785, closes #2784, closes #2783
Squashed commit of the following:
commit ca5064a4effa3904ce936b521b169bba8d24f1a1
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:19:32 2015 -0500
Revert "added ajaxify popstate cache, so back/forward will just put back the already loaded page"
This reverts commit 77d154bb8b9549523e35c323dcb62f811c27dfb6.
commit ae07fc56c156074de8048bb627f5d9be849c8ad1
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:19:24 2015 -0500
Revert "on click, topics are marked read from the unread page. Also fixed an issue where isPopState kept getting set to true, causing issues"
This reverts commit d8c9ec0d406147b4ac9631fcc7687073ee71ea8e.
Conflicts:
public/src/client/unread.js
commit 96ee3631d7e4e1fc2c1b7632d86684fecd1e430f
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:18:25 2015 -0500
Revert "actually fixed isPopState error"
This reverts commit e6701c5a1f5a87a526c860f8e25e68ca1a65492d.
10 years ago
|
|
|
if(direction < 0 || !$('#topics-container').length) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
infinitescroll.loadMore('topics.loadMoreUnreadTopics', {
|
closes #2792, closes #2791, closes #2788, closes #2787, closes #2786, closes #2785, closes #2784, closes #2783
Squashed commit of the following:
commit ca5064a4effa3904ce936b521b169bba8d24f1a1
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:19:32 2015 -0500
Revert "added ajaxify popstate cache, so back/forward will just put back the already loaded page"
This reverts commit 77d154bb8b9549523e35c323dcb62f811c27dfb6.
commit ae07fc56c156074de8048bb627f5d9be849c8ad1
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:19:24 2015 -0500
Revert "on click, topics are marked read from the unread page. Also fixed an issue where isPopState kept getting set to true, causing issues"
This reverts commit d8c9ec0d406147b4ac9631fcc7687073ee71ea8e.
Conflicts:
public/src/client/unread.js
commit 96ee3631d7e4e1fc2c1b7632d86684fecd1e430f
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:18:25 2015 -0500
Revert "actually fixed isPopState error"
This reverts commit e6701c5a1f5a87a526c860f8e25e68ca1a65492d.
10 years ago
|
|
|
after: $('#topics-container').attr('data-nextstart')
|
|
|
|
}, function(data, done) {
|
|
|
|
if (data.topics && data.topics.length) {
|
|
|
|
recent.onTopicsLoaded('unread', data.topics, true, done);
|
closes #2792, closes #2791, closes #2788, closes #2787, closes #2786, closes #2785, closes #2784, closes #2783
Squashed commit of the following:
commit ca5064a4effa3904ce936b521b169bba8d24f1a1
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:19:32 2015 -0500
Revert "added ajaxify popstate cache, so back/forward will just put back the already loaded page"
This reverts commit 77d154bb8b9549523e35c323dcb62f811c27dfb6.
commit ae07fc56c156074de8048bb627f5d9be849c8ad1
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:19:24 2015 -0500
Revert "on click, topics are marked read from the unread page. Also fixed an issue where isPopState kept getting set to true, causing issues"
This reverts commit d8c9ec0d406147b4ac9631fcc7687073ee71ea8e.
Conflicts:
public/src/client/unread.js
commit 96ee3631d7e4e1fc2c1b7632d86684fecd1e430f
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:18:25 2015 -0500
Revert "actually fixed isPopState error"
This reverts commit e6701c5a1f5a87a526c860f8e25e68ca1a65492d.
10 years ago
|
|
|
$('#topics-container').attr('data-nextstart', data.nextStart);
|
|
|
|
} else {
|
|
|
|
done();
|
|
|
|
$('#load-more-btn').hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
closes #2792, closes #2791, closes #2788, closes #2787, closes #2786, closes #2785, closes #2784, closes #2783
Squashed commit of the following:
commit ca5064a4effa3904ce936b521b169bba8d24f1a1
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:19:32 2015 -0500
Revert "added ajaxify popstate cache, so back/forward will just put back the already loaded page"
This reverts commit 77d154bb8b9549523e35c323dcb62f811c27dfb6.
commit ae07fc56c156074de8048bb627f5d9be849c8ad1
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:19:24 2015 -0500
Revert "on click, topics are marked read from the unread page. Also fixed an issue where isPopState kept getting set to true, causing issues"
This reverts commit d8c9ec0d406147b4ac9631fcc7687073ee71ea8e.
Conflicts:
public/src/client/unread.js
commit 96ee3631d7e4e1fc2c1b7632d86684fecd1e430f
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:18:25 2015 -0500
Revert "actually fixed isPopState error"
This reverts commit e6701c5a1f5a87a526c860f8e25e68ca1a65492d.
10 years ago
|
|
|
function doneRemovingTids(tids) {
|
|
|
|
removeTids(tids);
|
|
|
|
|
closes #2792, closes #2791, closes #2788, closes #2787, closes #2786, closes #2785, closes #2784, closes #2783
Squashed commit of the following:
commit ca5064a4effa3904ce936b521b169bba8d24f1a1
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:19:32 2015 -0500
Revert "added ajaxify popstate cache, so back/forward will just put back the already loaded page"
This reverts commit 77d154bb8b9549523e35c323dcb62f811c27dfb6.
commit ae07fc56c156074de8048bb627f5d9be849c8ad1
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:19:24 2015 -0500
Revert "on click, topics are marked read from the unread page. Also fixed an issue where isPopState kept getting set to true, causing issues"
This reverts commit d8c9ec0d406147b4ac9631fcc7687073ee71ea8e.
Conflicts:
public/src/client/unread.js
commit 96ee3631d7e4e1fc2c1b7632d86684fecd1e430f
Author: Julian Lam <[email protected]>
Date: Thu Feb 26 08:18:25 2015 -0500
Revert "actually fixed isPopState error"
This reverts commit e6701c5a1f5a87a526c860f8e25e68ca1a65492d.
10 years ago
|
|
|
app.alertSuccess('[[unread:topics_marked_as_read.success]]');
|
|
|
|
|
|
|
|
if (!$('#topics-container').children().length) {
|
|
|
|
$('#category-no-topics').removeClass('hidden');
|
|
|
|
$('.markread').addClass('hidden');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeTids(tids) {
|
|
|
|
for(var i=0; i<tids.length; ++i) {
|
|
|
|
$('#topics-container .category-item[data-tid="' + tids[i] + '"]').remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onCategoriesLoaded(err, categories) {
|
|
|
|
createCategoryLinks(categories);
|
|
|
|
}
|
|
|
|
|
|
|
|
function createCategoryLinks(categories) {
|
|
|
|
for (var i=0; i<categories.length; ++i) {
|
|
|
|
createCategoryLink(categories[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function createCategoryLink(category) {
|
|
|
|
var link = $('<a role="menuitem" href="#"></a>');
|
|
|
|
|
|
|
|
if (category.icon) {
|
|
|
|
link.append('<i class="fa fa-fw ' + category.icon + '"></i> ' + category.name);
|
|
|
|
} else {
|
|
|
|
link.append(category.name);
|
|
|
|
}
|
|
|
|
|
|
|
|
$('<li role="presentation" class="category" data-cid="' + category.cid + '"></li>')
|
|
|
|
.append(link)
|
|
|
|
.appendTo($('.markread .dropdown-menu'));
|
|
|
|
}
|
|
|
|
|
|
|
|
return Unread;
|
|
|
|
});
|