cleanup dismissArticle functions

This commit is contained in:
Andrew Dolgov 2016-03-22 10:11:11 +03:00
parent 11514d576f
commit 6056d164fa
2 changed files with 43 additions and 110 deletions

View File

@ -451,8 +451,8 @@ function catchupFeedInGroup(id) {
if (rows.length > 0) { if (rows.length > 0) {
rows.each(function (row) { rows.each(function (row) {
new Effect.Fade(row, {duration : 0.5, afterFinish: function() { new Effect.Fade(row, {duration : 0.5, afterFinish: function(obj) {
Element.remove(row); Element.remove(obj.element);
}}); }});
}); });

View File

@ -552,7 +552,7 @@ function moveToPost(mode, noscroll, noexpand) {
try { try {
var rows = getVisibleArticleIds(); var rows = getLoadedArticleIds();
var prev_id = false; var prev_id = false;
var next_id = false; var next_id = false;
@ -693,17 +693,6 @@ function updateSelectedPrompt() {
} }
} }
function toggleUnread_afh(effect) {
try {
var elem = effect.element;
elem.style.backgroundColor = "";
} catch (e) {
exception_error("toggleUnread_afh", e);
}
}
function toggleUnread(id, cmode, effect) { function toggleUnread(id, cmode, effect) {
try { try {
@ -1428,7 +1417,7 @@ function catchupRelativeToArticle(below, id) {
return; return;
} }
var visible_ids = getVisibleArticleIds(); var visible_ids = getLoadedArticleIds();
var ids_to_mark = new Array(); var ids_to_mark = new Array();
@ -1642,26 +1631,36 @@ function show_labels_in_headlines(transport) {
} }
} }
function dismissArticle(id) { function dismissArticles(ids) {
try { try {
var elem = $("RROW-" + id);
if (!elem) return; console.log("dismissArticles: " + ids);
toggleUnread(id, 0, true); for (var i = 0; i < ids.length; i++) {
var elem = $("RROW-" + ids[i]);
new Effect.Fade(elem, {duration : 0.5}); new Effect.Fade(elem, {
duration: 0.5, afterFinish: function (obj) {
// Remove the content, too Element.remove(obj.element);
var elem_content = $("CICD-" + id);
if (elem_content) {
Element.remove(elem_content);
} }
});
if (id == getActiveArticleId()) { if (ids[i] == getActiveArticleId()) {
setActiveArticleId(0); setActiveArticleId(0);
} }
}
selectionToggleUnread(false, false, false, ids);
} catch (e) {
exception_error("dismissArticles", e);
}
}
function dismissArticle(id) {
try {
dismissArticles([id]);
} catch (e) { } catch (e) {
exception_error("dismissArticle", e); exception_error("dismissArticle", e);
} }
@ -1669,33 +1668,7 @@ function dismissArticle(id) {
function dismissSelectedArticles() { function dismissSelectedArticles() {
try { try {
dismissArticles(getSelectedArticleIds2());
var ids = getVisibleArticleIds();
var tmp = [];
var sel = [];
for (var i = 0; i < ids.length; i++) {
var elem = $("RROW-" + ids[i]);
if (elem.className && elem.hasClassName("Selected") &&
ids[i] != getActiveArticleId()) {
new Effect.Fade(elem, {duration : 0.5});
sel.push(ids[i]);
// Remove the content, too
var elem_content = $("CICD-" + ids[i]);
if (elem_content) {
Element.remove(elem_content);
}
} else {
tmp.push(ids[i]);
}
}
if (sel.length > 0)
selectionToggleUnread(false);
} catch (e) { } catch (e) {
exception_error("dismissSelectedArticles", e); exception_error("dismissSelectedArticles", e);
} }
@ -1703,54 +1676,25 @@ function dismissSelectedArticles() {
function dismissReadArticles() { function dismissReadArticles() {
try { try {
var ids = getLoadedArticleIds();
var ids = getVisibleArticleIds();
var tmp = []; var tmp = [];
for (var i = 0; i < ids.length; i++) { ids.each(function(id) {
var elem = $("RROW-" + ids[i]); var elem = $("RROW-" + id);
if (elem.className && !elem.hasClassName("Unread") && if (elem && !elem.hasClassName("Unread")) {
!elem.hasClassName("Selected")) { tmp.push(id);
}
new Effect.Fade(elem, {duration : 0.5}); });
// Remove the content, too dismissArticles(tmp);
var elem_content = $("CICD-" + ids[i]);
if (elem_content) {
Element.remove(elem_content);
}
} else {
tmp.push(ids[i]);
}
}
} catch (e) { } catch (e) {
exception_error("dismissReadArticles", e); exception_error("dismissReadArticles", e);
} }
} }
// we don't really hide rows anymore
function getVisibleArticleIds() {
return getLoadedArticleIds();
/*var ids = [];
try {
getLoadedArticleIds().each(function(id) {
var elem = $("RROW-" + id);
if (elem && Element.visible(elem))
ids.push(id);
});
} catch (e) {
exception_error("getVisibleArticleIds", e);
}
return ids; */
}
function cdmClicked(event, id) { function cdmClicked(event, id) {
try { try {
//var shift_key = event.shiftKey; //var shift_key = event.shiftKey;
@ -1839,17 +1783,6 @@ function hlClicked(event, id) {
} }
} }
function getFirstVisibleHeadlineId() {
var rows = getVisibleArticleIds();
return rows[0];
}
function getLastVisibleHeadlineId() {
var rows = getVisibleArticleIds();
return rows[rows.length-1];
}
function openArticleInNewWindow(id) { function openArticleInNewWindow(id) {
toggleUnread(id, 0, false); toggleUnread(id, 0, false);
window.open("backend.php?op=article&method=redirect&id=" + id); window.open("backend.php?op=article&method=redirect&id=" + id);
@ -1886,7 +1819,7 @@ function getRelativePostIds(id, limit) {
if (!limit) limit = 6; //3 if (!limit) limit = 6; //3
var ids = getVisibleArticleIds(); var ids = getLoadedArticleIds();
for (var i = 0; i < ids.length; i++) { for (var i = 0; i < ids.length; i++) {
if (ids[i] == id) { if (ids[i] == id) {