remove expandable CDM headlines

This commit is contained in:
Andrew Dolgov 2018-11-30 13:51:54 +03:00
parent c8c9a26f30
commit 9563e3bcd6
8 changed files with 52 additions and 293 deletions

View File

@ -277,7 +277,6 @@ class Feeds extends Handler_Protected {
$lnum = $offset;
$num_unread = 0;
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info);
$expand_cdm = get_pref('CDM_EXPANDED');
if (is_object($result)) {
@ -497,11 +496,9 @@ class Feeds extends Handler_Protected {
}
}
$expanded_class = $expand_cdm ? "expanded" : "expandable";
$content_encoded = htmlspecialchars(json_encode($line["content"]));
$tmp_content = "<div class=\"cdm $hlc_suffix $expanded_class $class\"
$tmp_content = "<div class=\"cdm expanded $hlc_suffix $class\"
id=\"RROW-$id\" data-content=\"$content_encoded\" data-article-id='$id' data-orig-feed-id='$feed_id' $mouseover_attrs>";
$tmp_content .= "<div class=\"cdmHeader\">";
@ -543,13 +540,6 @@ class Feeds extends Handler_Protected {
<img src=\"images/collapse.png\" onclick=\"cdmCollapseArticle(event, $id)\"
title=\"".__("Collapse article")."\"/></span>";
if (!$expand_cdm)
$content_hidden = "style=\"display : none\"";
else
$excerpt_hidden = "style=\"display : none\"";
$tmp_content .= "<span $excerpt_hidden id=\"CEXC-$id\" class=\"cdmExcerpt\">" . $content_preview . "</span>";
$tmp_content .= "</span>";
if (!$vfeed_group_enabled) {
@ -578,9 +568,7 @@ class Feeds extends Handler_Protected {
$tmp_content .= "</div>"; //cdmHeader
$tmp_content .= "<div class=\"cdmContent\" $content_hidden
onclick=\"return cdmClicked(event, $id, true);\"
id=\"CICD-$id\">";
$tmp_content .= "<div class=\"cdmContent\" onclick=\"return cdmClicked(event, $id, true);\" id=\"CICD-$id\">";
$tmp_content .= "<div id=\"POSTNOTE-$id\">";
if ($line['note']) {
@ -590,6 +578,7 @@ class Feeds extends Handler_Protected {
if (!$line['lang']) $line['lang'] = 'en';
// this is filled from RROW data-content
$tmp_content .= "<div class=\"cdmContentInner\" lang=\"".$line['lang']."\">";
if ($line["orig_feed_id"]) {

View File

@ -162,7 +162,7 @@ class Pref_Prefs extends Handler_Protected {
$prefs_blacklist = array("ALLOW_DUPLICATE_POSTS", "STRIP_UNSAFE_TAGS", "REVERSE_HEADLINES",
"SORT_HEADLINES_BY_FEED_DATE", "DEFAULT_ARTICLE_LIMIT",
"FEEDS_SORT_BY_UNREAD");
"FEEDS_SORT_BY_UNREAD", "CDM_EXPANDED");
/* "FEEDS_SORT_BY_UNREAD", "HIDE_READ_FEEDS", "REVERSE_HEADLINES" */

View File

@ -115,66 +115,6 @@
}
.cdm.expandable {
background-color : #f0f0f0;
border: 0px solid #ddd;
border-bottom-width: 1px;
> hr {
display : none;
}
div.cdmHeader span.titleWrap {
white-space : nowrap;
text-overflow : ellipsis;
overflow : hidden;
max-width : 500px;
}
}
.cdm.expandable.Unread {
background : white;
}
.cdm.expandable.Selected:not(.active) {
background : desaturate(@color-accent, 25%);
a,
.cdmHeader a.title,
span {
color : white;
}
}
.cdm.expandable.active {
background : white ! important;
}
div.cdm.expandable.active div.cdmHeader span.titleWrap {
white-space : normal;
}
div.cdm.expandable div.cdmHeader a.title {
font-weight : 600;
color : @default-text;
font-size : 14px;
transition : color 0.2s, background 0.2s;
text-rendering: optimizelegibility;
font-family : @fonts-ui-bold;
}
div.cdm.expandable.Unread div.cdmHeader a.title {
color : black;
}
div.cdm.expandable.active div.cdmHeader a.title {
color: @color-link;
font-size: 16px;
font-weight: 600;
text-rendering: optimizelegibility;
font-family: @fonts-ui-bold;
}
div.cdm.expanded div.cdmHeader {
background : transparent ! important;
}

File diff suppressed because one or more lines are too long

View File

@ -1164,8 +1164,7 @@
"feed_debug_viewfeed" => __("Debug viewfeed()"),
"catchup_all" => __("Mark all feeds as read"),
"cat_toggle_collapse" => __("Un/collapse current category"),
"toggle_combined_mode" => __("Toggle combined mode"),
"toggle_cdm_expanded" => __("Toggle auto expand in combined mode")),
"toggle_combined_mode" => __("Toggle combined mode")),
__("Go to") => array(
"goto_all" => __("All articles"),
"goto_fresh" => __("Fresh"),
@ -1233,7 +1232,6 @@
"f *d" => "feed_debug_update",
"f *g" => "feed_debug_viewfeed",
"f *c" => "toggle_combined_mode",
"f c" => "toggle_cdm_expanded",
"*q" => "catchup_all",
"x" => "cat_toggle_collapse",
// "goto" => array(
@ -1310,7 +1308,6 @@
$data["num_feeds"] = (int) $num_feeds;
$data['last_article_id'] = Article::getLastArticleId();
$data['cdm_expanded'] = get_pref('CDM_EXPANDED');
$data['dep_ts'] = calculate_dep_timestamp();
$data['reload_on_ts_change'] = !defined('_NO_RELOAD_ON_TS_CHANGE');

View File

@ -299,32 +299,6 @@ function init_hotkey_actions() {
hotkey_actions["prev_article_noexpand"] = function() {
moveToPost('prev', true, true);
};
hotkey_actions["collapse_article"] = function() {
const id = getActiveArticleId();
const elem = $("CICD-"+id);
if (elem) {
if (elem.visible()) {
cdmCollapseArticle(null, id);
}
else {
cdmExpandArticle(id);
}
}
};
hotkey_actions["toggle_expand"] = function() {
const id = getActiveArticleId();
const elem = $("CICD-"+id);
if (elem) {
if (elem.visible()) {
cdmCollapseArticle(null, id, false);
}
else {
cdmExpandArticle(id);
}
}
};
hotkey_actions["search_dialog"] = function() {
search();
};
@ -361,13 +335,7 @@ function init_hotkey_actions() {
scrollArticle(-40);
};
hotkey_actions["close_article"] = function() {
if (isCdmMode()) {
if (!getInitParam("cdm_expanded")) {
cdmCollapseArticle(false, getActiveArticleId());
}
} else {
closeArticlePanel();
}
closeArticlePanel();
};
hotkey_actions["email_article"] = function() {
if (typeof emailArticle != "undefined") {
@ -531,16 +499,6 @@ function init_hotkey_actions() {
viewCurrentFeed();
})
};
hotkey_actions["toggle_cdm_expanded"] = function() {
notify_progress("Loading, please wait...");
const value = getInitParam("cdm_expanded") ? "false" : "true";
xhrPost("backend.php", {op: "rpc", method: "setpref", key: "CDM_EXPANDED", value: value}, () => {
setInitParam("cdm_expanded", !getInitParam("cdm_expanded"));
viewCurrentFeed();
});
};
}
function init_second_stage() {

View File

@ -490,7 +490,6 @@ function moveToPost(mode, noscroll, noexpand) {
scrollArticle(ctr.offsetHeight/4);
} else if (next_id) {
cdmExpandArticle(next_id, noexpand);
cdmScrollToArticleId(next_id, true);
}
@ -509,24 +508,14 @@ function moveToPost(mode, noscroll, noexpand) {
const prev_article = $("RROW-" + prev_id);
var ctr = $("headlines-frame");
if (!getInitParam("cdm_expanded")) {
if (!noscroll && article && article.offsetTop < ctr.scrollTop) {
scrollArticle(-ctr.offsetHeight/4);
} else {
cdmExpandArticle(prev_id, noexpand);
cdmScrollToArticleId(prev_id, true);
}
} else if (!noscroll && article && article.offsetTop < ctr.scrollTop) {
scrollArticle(-ctr.offsetHeight/3);
} else if (!noscroll && prev_article &&
prev_article.offsetTop < ctr.scrollTop) {
cdmExpandArticle(prev_id, noexpand);
scrollArticle(-ctr.offsetHeight/4);
} else if (prev_id) {
cdmExpandArticle(prev_id, noexpand);
cdmScrollToArticleId(prev_id, noscroll);
}
if (!noscroll && article && article.offsetTop < ctr.scrollTop) {
scrollArticle(-ctr.offsetHeight/3);
} else if (!noscroll && prev_article &&
prev_article.offsetTop < ctr.scrollTop) {
scrollArticle(-ctr.offsetHeight/4);
} else if (prev_id) {
cdmScrollToArticleId(prev_id, noscroll);
}
} else if (prev_id) {
correctHeadlinesOffset(prev_id);
@ -1016,7 +1005,7 @@ function postMouseOut(id) {
}
function unpackVisibleHeadlines() {
if (!isCdmMode() || !getInitParam("cdm_expanded")) return;
if (!isCdmMode()) return;
$$("#headlines-frame div[id*=RROW][data-content]").each((row) => {
//console.log('checking', row.id);
@ -1058,8 +1047,7 @@ function headlines_scroll_handler(e) {
// set topmost child in the buffer as active
if (isCdmMode() && getInitParam("cdm_auto_catchup") == 1 &&
getSelectedArticleIds2().length <= 1 &&
getInitParam("cdm_expanded")) {
getSelectedArticleIds2().length <= 1) {
const rows = $$("#headlines-frame > div[id*=RROW]");
@ -1241,111 +1229,6 @@ function catchupRelativeToArticle(below, id) {
}
}
function cdmCollapseArticle(event, id, unmark) {
if (unmark == undefined) unmark = true;
const row = $("RROW-" + id);
const elem = $("CICD-" + id);
if (elem && row) {
const collapse = row.select("span[class='collapseBtn']")[0];
Element.hide(elem);
Element.show("CEXC-" + id);
Element.hide(collapse);
if (unmark) {
row.removeClassName("active");
markHeadline(id, false);
if (id == getActiveArticleId()) {
setActiveArticleId(0);
}
updateSelectedPrompt();
}
if (event) Event.stop(event);
PluginHost.run(PluginHost.HOOK_ARTICLE_COLLAPSED, id);
if (row.offsetTop < $("headlines-frame").scrollTop)
scrollToRowId(row.id);
$("floatingTitle").style.visibility = "hidden";
$("floatingTitle").setAttribute("data-article-id", 0);
}
}
function cdmExpandArticle(id, noexpand) {
console.log("cdmExpandArticle " + id);
const row = $("RROW-" + id);
if (!row) return false;
const oldrow = $("RROW-" + getActiveArticleId());
let elem = $("CICD-" + getActiveArticleId());
if (id == getActiveArticleId() && Element.visible(elem))
return true;
selectArticles("none");
const old_offset = row.offsetTop;
if (getActiveArticleId() && elem && !getInitParam("cdm_expanded")) {
let collapse = oldrow.select("span[class='collapseBtn']")[0];
Element.hide(elem);
Element.show("CEXC-" + getActiveArticleId());
Element.hide(collapse);
}
if (oldrow) oldrow.removeClassName("active");
setActiveArticleId(id);
elem = $("CICD-" + id);
let collapse = row.select("span[class='collapseBtn']")[0];
const cencw = $("CENCW-" + id);
if (!Element.visible(elem) && !noexpand) {
if (cencw) {
cencw.innerHTML = htmlspecialchars_decode(cencw.innerHTML);
cencw.setAttribute('id', '');
Element.show(cencw);
}
Element.show(elem);
Element.hide("CEXC-" + id);
Element.show(collapse);
}
const new_offset = row.offsetTop;
if (old_offset > new_offset)
$("headlines-frame").scrollTop -= (old_offset - new_offset);
if (!noexpand) {
if (catchup_id_batch.indexOf(id) == -1)
catchup_id_batch.push(id);
catchupCurrentBatchIfNeeded();
}
toggleSelected(id);
row.addClassName("active");
PluginHost.run(PluginHost.HOOK_ARTICLE_EXPANDED, id);
return false;
}
function getArticleUnderPointer() {
return post_under_pointer;
}
@ -1382,42 +1265,37 @@ function cdmClicked(event, id, in_body) {
if (!event.ctrlKey && !event.metaKey) {
if (!getInitParam("cdm_expanded")) {
return cdmExpandArticle(id);
} else {
let elem = $("RROW-" + getActiveArticleId());
let elem = $("RROW-" + getActiveArticleId());
if (elem) elem.removeClassName("active");
if (elem) elem.removeClassName("active");
selectArticles("none");
toggleSelected(id);
selectArticles("none");
toggleSelected(id);
elem = $("RROW-" + id);
const article_is_unread = elem.hasClassName("Unread");
elem = $("RROW-" + id);
const article_is_unread = elem.hasClassName("Unread");
elem.removeClassName("Unread");
elem.addClassName("active");
elem.removeClassName("Unread");
elem.addClassName("active");
setActiveArticleId(id);
setActiveArticleId(id);
if (article_is_unread) {
decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
updateFloatingTitle(true);
if (article_is_unread) {
decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
updateFloatingTitle(true);
const query = {
op: "rpc", method: "catchupSelected",
cmode: 0, ids: id
};
const query = {
op: "rpc", method: "catchupSelected",
cmode: 0, ids: id
};
xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport);
});
}
return !event.shiftKey;
xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport);
});
}
return !event.shiftKey;
} else if (!in_body) {
toggleSelected(id, true);

View File

@ -26,27 +26,24 @@ require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
ready(function() {
PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) {
if (getInitParam('cdm_expanded')) {
window.setTimeout(function() {
if (row) {
const c_inner = row.select(".cdmContentInner")[0];
const c_inter = row.select(".cdmIntermediate")[0];
window.setTimeout(function() {
if (row) {
const c_inner = row.select(".cdmContentInner")[0];
const c_inter = row.select(".cdmIntermediate")[0];
if (c_inner && c_inter &&
row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) {
if (c_inner && c_inter &&
row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) {
c_inter.parentNode.removeChild(c_inter);
c_inter.parentNode.removeChild(c_inter);
c_inner.innerHTML = "<div class='contentSizeWrapper'>" +
c_inner.innerHTML +
c_inter.innerHTML + "</div>" +
"<button class='expandPrompt' onclick='return expandSizeWrapper(\""+row.id+"\")' href='#'>" +
__("Click to expand article") + "</button>";
}
c_inner.innerHTML = "<div class='contentSizeWrapper'>" +
c_inner.innerHTML +
c_inter.innerHTML + "</div>" +
"<button class='expandPrompt' onclick='return expandSizeWrapper(\""+row.id+"\")' href='#'>" +
__("Click to expand article") + "</button>";
}
}, 150);
}
}
}, 150);
return true;
});