assorted fixes, support for n/p shortcuts in CDM (refs #191)
This commit is contained in:
parent
1681df970b
commit
b8e6acea95
|
@ -36,6 +36,10 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
|
|||
|
||||
// if (!offset) page_offset = 0;
|
||||
|
||||
if (feed == getActiveFeedId()) {
|
||||
cache_invalidate("F:" + feed);
|
||||
}
|
||||
|
||||
var force_nocache = false;
|
||||
|
||||
var page_offset = 0;
|
||||
|
|
|
@ -944,6 +944,10 @@ div.cdmArticleSelected div.cdmFooter {
|
|||
background-color : transparent;
|
||||
}
|
||||
|
||||
div.cdmArticleUnreadSelected div.cdmFooter {
|
||||
background-color : transparent;
|
||||
}
|
||||
|
||||
div.cdmFooter span.s0 {
|
||||
border-width : 0px 1px 0px 0px;
|
||||
border-color : #c0c0c0;
|
||||
|
|
188
viewfeed.js
188
viewfeed.js
|
@ -667,9 +667,10 @@ function correctHeadlinesOffset(id) {
|
|||
|
||||
function moveToPost(mode) {
|
||||
|
||||
try {
|
||||
|
||||
// check for combined mode
|
||||
if (!document.getElementById("headlinesList"))
|
||||
return;
|
||||
if (document.getElementById("headlinesList")) {
|
||||
|
||||
var rows = getVisibleHeadlineIds();
|
||||
|
||||
|
@ -705,9 +706,82 @@ function moveToPost(mode) {
|
|||
view(prev_id, getActiveFeedId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var rows = cdmGetUnreadArticles();
|
||||
|
||||
if (mode == "next") {
|
||||
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
|
||||
if (cdmArticleIsActuallyVisible(rows[i]) ||
|
||||
cdmArticleIsBelowViewport(rows[i])) {
|
||||
|
||||
cdmScrollToArticleId(rows[i]);
|
||||
setTimeout("toggleUnread(" + rows[i] + ", undefined, true)", 500);
|
||||
//toggleUnread(rows[i], undefined, true);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function toggleUnread(id, cmode) {
|
||||
} else if (mode == "prev") {
|
||||
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
|
||||
if (cdmArticleIsActuallyVisible(rows[i]) ||
|
||||
(cdmArticleIsAboveViewport(rows[i]) &&
|
||||
!cdmArticleIsAboveViewport(rows[i+1]))) {
|
||||
|
||||
cdmScrollToArticleId(rows[i]);
|
||||
setTimeout("toggleUnread(" + rows[i] + ", undefined, true)", 500);
|
||||
//toggleUnread(rows[i], undefined, true);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
exception_error(e, "moveToPost");
|
||||
}
|
||||
}
|
||||
|
||||
function toggleSelected(id) {
|
||||
try {
|
||||
|
||||
var row = document.getElementById("RROW-" + id);
|
||||
if (row) {
|
||||
var nc = row.className;
|
||||
|
||||
if (!nc.match("Selected")) {
|
||||
nc = nc + "Selected";
|
||||
} else {
|
||||
nc = nc.replace("Selected", "");
|
||||
}
|
||||
|
||||
row.className = nc;
|
||||
}
|
||||
} catch (e) {
|
||||
exception_error(e, "toggleSelected");
|
||||
}
|
||||
}
|
||||
|
||||
/*function toggleUnread_afh(effect) {
|
||||
try {
|
||||
|
||||
var elem = effect.element;
|
||||
//elem.style.backgroundColor = "transparent";
|
||||
|
||||
alert(elem.className);
|
||||
} catch (e) {
|
||||
exception_error(e, "toggleUnread_afh");
|
||||
}
|
||||
} */
|
||||
|
||||
function toggleUnread(id, cmode, effect) {
|
||||
try {
|
||||
|
||||
var row = document.getElementById("RROW-" + id);
|
||||
|
@ -716,14 +790,36 @@ function toggleUnread(id, cmode) {
|
|||
nc = nc.replace("Unread", "");
|
||||
nc = nc.replace("Selected", "");
|
||||
|
||||
// since we are removing selection from the object, uncheck
|
||||
// corresponding checkbox
|
||||
|
||||
var cb = document.getElementById("RCHK-" + id);
|
||||
if (cb) {
|
||||
cb.checked = false;
|
||||
}
|
||||
|
||||
// NOTE: I'm not sure that resetting selection here is a feature -fox
|
||||
|
||||
if (cmode == undefined || cmode == 2) {
|
||||
if (row.className.match("Unread")) {
|
||||
row.className = nc;
|
||||
|
||||
/* if (effect) {
|
||||
new Effect.Highlight(row, {duration: 1, startcolor: "#fff7d5",
|
||||
afterFinish: toggleUnread_afh,
|
||||
queue: { position:'end', scope: 'TMRQ-' + id, limit: 1 } } );
|
||||
} */
|
||||
|
||||
} else {
|
||||
row.className = nc + "Unread";
|
||||
}
|
||||
} else if (cmode == 0) {
|
||||
row.className = nc;
|
||||
|
||||
/* if (effect) {
|
||||
new Effect.Highlight(row, {duration: 1, startcolor: "#fff7d5",
|
||||
queue: { position:'end', scope: 'TMRQ-' + id, limit: 1 } } );
|
||||
} */
|
||||
} else if (cmode == 1) {
|
||||
row.className = nc + "Unread";
|
||||
}
|
||||
|
@ -1164,6 +1260,90 @@ function editTagsInsert() {
|
|||
}
|
||||
}
|
||||
|
||||
function cdmArticleIsBelowViewport(id) {
|
||||
try {
|
||||
var ctr = document.getElementById("headlinesInnerContainer");
|
||||
var e = document.getElementById("RROW-" + id);
|
||||
|
||||
if (!e || !ctr) return;
|
||||
|
||||
// article starts below viewport
|
||||
|
||||
if (ctr.scrollTop < e.offsetTop) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
exception_error(e, "cdmArticleIsVisible");
|
||||
}
|
||||
}
|
||||
|
||||
function cdmArticleIsAboveViewport(id) {
|
||||
try {
|
||||
var ctr = document.getElementById("headlinesInnerContainer");
|
||||
var e = document.getElementById("RROW-" + id);
|
||||
|
||||
if (!e || !ctr) return;
|
||||
|
||||
// article starts above viewport
|
||||
|
||||
if (ctr.scrollTop > e.offsetTop + e.offsetHeight) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
exception_error(e, "cdmArticleIsVisible");
|
||||
}
|
||||
}
|
||||
|
||||
function cdmScrollToArticleId(id) {
|
||||
try {
|
||||
var ctr = document.getElementById("headlinesInnerContainer");
|
||||
var e = document.getElementById("RROW-" + id);
|
||||
|
||||
if (!e || !ctr) return;
|
||||
|
||||
ctr.scrollTop = e.offsetTop;
|
||||
|
||||
} catch (e) {
|
||||
exception_error(e, "cdmScrollToArticleId");
|
||||
}
|
||||
}
|
||||
|
||||
function cdmArticleIsActuallyVisible(id) {
|
||||
try {
|
||||
var ctr = document.getElementById("headlinesInnerContainer");
|
||||
var e = document.getElementById("RROW-" + id);
|
||||
|
||||
if (!e || !ctr) return;
|
||||
|
||||
// article fits in viewport OR article is longer than viewport and
|
||||
// its bottom is visible
|
||||
|
||||
if (ctr.scrollTop <= e.offsetTop && e.offsetTop + e.offsetHeight <=
|
||||
ctr.scrollTop + ctr.offsetHeight) {
|
||||
|
||||
return true;
|
||||
|
||||
} else if (e.offsetHeight > ctr.offsetHeight &&
|
||||
e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
|
||||
e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
} catch (e) {
|
||||
exception_error(e, "cdmArticleIsVisible");
|
||||
}
|
||||
}
|
||||
|
||||
function cdmWatchdog() {
|
||||
|
||||
try {
|
||||
|
@ -1350,6 +1530,8 @@ function cdmMouseOut(elem) {
|
|||
function headlines_scroll_handler() {
|
||||
try {
|
||||
|
||||
debug("headlines_scroll_handler");
|
||||
|
||||
var e = document.getElementById("headlinesInnerContainer");
|
||||
|
||||
// don't do infinite scrolling when Limit == All
|
||||
|
|
Loading…
Reference in New Issue