refactor combined mode, code cleanup

master
Andrew Dolgov 14 years ago
parent 24e2bb3a92
commit dad14b513d

@ -0,0 +1,56 @@
div.cdmHeader img, div.cdmHeader input, div.cdmFooter img {
vertical-align : middle;
}
div.cdmHeader {
padding : 5px;
}
div.cdmHeader span.updated {
color : gray;
font-weight : normal;
}
div.cdmHeader input {
margin-right : 5px;
}
div.cdmHeader img, div.cdmFooter img {
margin-left : 5px;
width : 16px;
height : 16px;
}
div.cdmContent {
font-weight : normal;
}
div.cdmContentInner {
margin : 0px 10px 10px 10px;
}
div.cdmFooter {
background : #f9f9f9;
padding : 5px;
font-weight : normal;
color : gray;
clear : both;
}
.evenUnreadSelected div.cdmFooter, .oddUnreadSelected div.cdmFooter,
.evenSelected div.cdmFooter, .oddSelected div.cdmFooter {
background-color : #FFF2BF;
}
span.cdmExcerpt {
font-size : 11px;
color : gray;
font-weight : normal;
cursor : pointer;
}
div.cdmContent div.postEnclosures {
margin-top : 1em;
color : gray;
}

@ -4979,76 +4979,11 @@
print $article_content;
// $result = db_query($link, "SELECT * FROM ttrss_enclosures WHERE
// post_id = '$id' AND content_url != ''");
print_article_enclosures($link, $id, $always_display_enclosures,
$article_content);
$result = get_article_enclosures($link, $id);
// if (db_num_rows($result) > 0) {
if (count($result) > 0) {
$entries_html = array();
$entries = array();
//while ($line = db_fetch_assoc($result)) {
foreach ($result as $line) {
$url = $line["content_url"];
$ctype = $line["content_type"];
if (!$ctype) $ctype = __("unknown type");
$filename = substr($url, strrpos($url, "/")+1);
$entry = format_inline_player($link, $url, $ctype);
$entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\">" .
$filename . " (" . $ctype . ")" . "</a>";
array_push($entries_html, $entry);
$entry = array();
$entry["type"] = $ctype;
$entry["filename"] = $filename;
$entry["url"] = $url;
array_push($entries, $entry);
}
print "<div class=\"postEnclosures\">";
if (!get_pref($link, "STRIP_IMAGES")) {
if ($always_display_enclosures ||
!preg_match("/<img/i", $article_content)) {
foreach ($entries as $entry) {
if (preg_match("/image/", $entry["type"]) ||
preg_match("/\.(jpg|png|gif|bmp)/i", $entry["filename"])) {
print "<p><img
alt=\"".htmlspecialchars($entry["filename"])."\"
src=\"" .htmlspecialchars($entry["url"]) . "\"/></p>";
}
}
}
}
if (db_num_rows($result) == 1) {
print __("Attachment:") . " ";
} else {
print __("Attachments:") . " ";
}
print join(", ", $entries_html);
print "</div>";
}
print "</div>";
print "</div>";
}
@ -5453,102 +5388,85 @@
}
$expand_cdm = get_pref($link, 'CDM_EXPANDED');
$show_excerpt = false;
if ($expand_cdm && $score >= -100) {
$cdm_cstyle = "";
$show_excerpt = false;
} else {
$cdm_cstyle = "style=\"display : none\"";
$show_excerpt = true;
}
$mouseover_attrs = "onmouseover='postMouseIn($id)'
onmouseout='postMouseOut($id)'";
print "<div class=\"cdmArticle$add_class\"
print "<div class=\"$class\"
id=\"RROW-$id\"
$mouseover_attrs'>";
print "<div class=\"cdmHeader\">";
if (!get_pref($link, "VFEED_GROUP_BY_FEED") || !$line["feed_title"]) {
$cdm_feed_icon = "<span style=\"cursor : pointer\" onclick=\"viewfeed($feed_id)\">$feed_icon_img</span>";
}
print "<div style='float : right'>";
print "<span class='updated'>$updated_fmt</span>";
print "$marked_pic";
print "$published_pic";
print "$score_pic";
print "<div class=\"articleUpdated\">$updated_fmt $score_pic $cdm_feed_icon
</div>";
if (!get_pref($link, "VFEED_GROUP_BY_FEED") && $line["feed_title"]) {
print "<span style=\"cursor : pointer\"
title=\"".htmlspecialchars($line["feed_title"])."\"
onclick=\"viewfeed($feed_id)\">$feed_icon_img</span>";
}
print "</div>";
print "<input type=\"checkbox\" onclick=\"toggleSelectRowById(this,
'RROW-$id')\" class=\"feedCheckBox\" id=\"RCHK-$id\"/>";
print "<span id=\"RTITLE-$id\" class=\"titleWrap$hlc_suffix\"><a class=\"title\"
onclick=\"javascript:toggleUnread($id, 0)\"
print "<span id=\"RTITLE-$id\"
onclick=\"return cdmExpandArticle($id)\"
class=\"titleWrap$hlc_suffix\">
<a class=\"title\"
target=\"_blank\" href=\"".$line["link"]."\">".$line["title"]."</a>
";
print $entry_author;
/* if (!$expand_cdm || $score < -100) {
print "&nbsp;<a id=\"CICH-$id\"
href=\"javascript:cdmExpandArticle($id)\">
(".__('Show article').")</a>";
} */
</span>";
print $labels_str;
if (!get_pref($link, 'VFEED_GROUP_BY_FEED')) {
if ($line["feed_title"]) {
print "&nbsp;(<a href='javascript:viewfeed($feed_id)'>".$line["feed_title"]."</a>)";
}
}
if ($expand_cdm)
$content_hidden = "style=\"display : none\"";
else
$excerpt_hidden = "style=\"display : none\"";
print "</span></div>";
print "<span $excerpt_hidden
onclick=\"return cdmExpandArticle($id)\"
id=\"CEXC-$id\" class=\"cdmExcerpt\"> - $content_preview</span>";
if ($show_excerpt) {
print "<div class=\"cdmExcerpt\" id=\"CEXC-$id\"
onclick=\"cdmExpandArticle($id)\"
title=\"".__('Click to expand article')."\">";
print "</div>";
$content_preview = trim(truncate_string(strip_tags($line["content_preview"]), 100));
print "<div class=\"cdmContent\" $content_hidden
id=\"CICD-$id\">";
if (strlen($content_preview) != 0) {
print $content_preview;
} else {
print __('Click to expand article');
}
print "</div>";
}
print "<div class=\"cdmContent\"
onclick=\"cdmClicked($id)\"
id=\"CICD-$id\" $cdm_cstyle>";
print "<div class=\"cdmContentInner\">";
if ($line["orig_feed_id"]) {
if ($line["orig_feed_id"]) {
$tmp_result = db_query($link, "SELECT * FROM ttrss_archived_feeds
WHERE id = ".$line["orig_feed_id"]);
$tmp_result = db_query($link, "SELECT * FROM ttrss_archived_feeds
WHERE id = ".$line["orig_feed_id"]);
if (db_num_rows($tmp_result) != 0) {
print "<div clear='both'>";
print __("Originally from:");
print "&nbsp;";
$tmp_line = db_fetch_assoc($tmp_result);
print "<a target='_blank'
href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" .
$tmp_line['title'] . "</a>";
print "&nbsp;";
print "<a target='_blank' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
print "<img title='".__('Feed URL')."'class='tinyFeedIcon' src='images/pub_set.gif'></a>";
print "</div>";
print "<div clear='both'>";
print __("Originally from:");
print "&nbsp;";
$tmp_line = db_fetch_assoc($tmp_result);
print "<a target='_blank'
href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" .
$tmp_line['title'] . "</a>";
print "&nbsp;";
print "<a target='_blank' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
print "<img title='".__('Feed URL')."'class='tinyFeedIcon' src='images/pub_set.gif'></a>";
print "</div>";
}
}
}
// print "<div class=\"cdmInnerContent\" id=\"CICD-$id\" $cdm_cstyle>";
$article_content = sanitize_rss($link, $line["content_preview"]);
print "<div id=\"POSTNOTE-$id\">";
if ($line['note']) {
@ -5556,136 +5474,69 @@
}
print "</div>";
print sanitize_rss($link, $line["content_preview"]);
$article_content = $line["content_preview"];
$e_result = db_query($link, "SELECT * FROM ttrss_enclosures WHERE
post_id = '$id' AND content_url != ''");
if (db_num_rows($e_result) > 0) {
$entries_html = array();
$entries = array();
while ($e_line = db_fetch_assoc($e_result)) {
$url = $e_line["content_url"];
$ctype = $e_line["content_type"];
if (!$ctype) $ctype = __("unknown type");
$filename = substr($url, strrpos($url, "/")+1);
$entry = format_inline_player($link, $url, $ctype);
$entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\">" .
$filename . " (" . $ctype . ")" . "</a>";
array_push($entries_html, $entry);
print $article_content;
$entry = array();
$entry["type"] = $ctype;
$entry["filename"] = $filename;
$entry["url"] = $url;
array_push($entries, $entry);
}
$tmp_result = db_query($link, "SELECT always_display_enclosures FROM
ttrss_feeds WHERE id = ".
$tmp_result = db_query($link, "SELECT always_display_enclosures FROM
ttrss_feeds WHERE id = ".
(($line['feed_id'] == null) ? $line['orig_feed_id'] :
$line['feed_id'])." AND owner_uid = ".$_SESSION["uid"]);
$always_display_enclosures = db_fetch_result($tmp_result, 0, "always_display_enclosures");
if (!get_pref($link, "STRIP_IMAGES")) {
if ($always_display_enclosures ||
!preg_match("/img/i", $article_content)) {
foreach ($entries as $entry) {
if (preg_match("/image/", $entry["type"]) ||
preg_match("/\.(jpg|png|gif|bmp)/i", $entry["filename"])) {
print "<p><img
alt=\"".htmlspecialchars($entry["filename"])."\"
src=\"" .htmlspecialchars($entry["url"]) . "\"></p>";
}
}
}
}
print "<div class=\"cdmEnclosures\">";
if (db_num_rows($e_result) == 1) {
print __("Attachment:") . " ";
} else {
print __("Attachments:") . " ";
}
print join(", ", $entries_html);
print "</div>";
}
print "<br clear='both'>";
// print "</div>";
$always_display_enclosures = sql_bool_to_bool(db_fetch_result($tmp_result,
0, "always_display_enclosures"));
/* if (!$expand_cdm) {
print "<a id=\"CICH-$id\"
href=\"javascript:cdmExpandArticle($id)\">
Show article</a>";
} */
print_article_enclosures($link, $id, $always_display_enclosures,
$article_content);
print "</div>";
print "<div class=\"cdmFooter\"><span class='s0'>";
print "<div class=\"cdmFooter\">";
/* print "<div class=\"markedPic\">Star it: $marked_pic</div>"; */
$tags_str = format_tags_string(get_article_tags($link, $id), $id);
print "<img src='".theme_image($link,
'images/tag.png')."' alt='Tags' title='Tags'>
<span id=\"ATSTR-$id\">$tags_str</span>
<a title=\"".__('Edit tags for this article')."\"
href=\"javascript:editArticleTags($id, $feed_id, true)\">(+)</a>";
print __("Select:").
" <input type=\"checkbox\" onclick=\"toggleSelectRowById(this,
'RROW-$id')\" class=\"feedCheckBox\" id=\"RCHK-$id\">";
print "<div style=\"float : right\">";
print "</span><span class='s1'>$marked_pic&nbsp;";
print "$published_pic&nbsp;";
print "<img src=\"images/art-zoom.png\" class='tagsPic'
print "<img src=\"images/art-zoom.png\"
onclick=\"zoomToArticle($id)\"
style=\"cursor : pointer\"
alt='Zoom'
title='".__('Show article summary in new window')."'>&nbsp;";
title='".__('Show article summary in new window')."'>";
if (DIGEST_ENABLE) {
print "<img src=\"".theme_image($link, 'images/art-email.png')."\"
style=\"cursor : pointer\"
onclick=\"emailArticle($id)\"
alt='Zoom' title='".__('Forward by email')."'>";
}
$note_escaped = htmlspecialchars($line['note'], ENT_QUOTES);
print "<img src=\"images/art-pub-note.png\" class='tagsPic'
print "<img src=\"images/art-pub-note.png\"
style=\"cursor : pointer\" style=\"cursor : pointer\"
onclick=\"publishWithNote($id, '$note_escaped')\"
alt='PubNote' title='".__('Publish article with a note')."'>";
print "</span>";
$tags_str = format_tags_string(get_article_tags($link, $id), $id);
print "<span class='s1'>
<img class='tagsPic' src='".theme_image($link,
'images/tag.png')."' alt='Tags' title='Tags'>
<span id=\"ATSTR-$id\">$tags_str</span>
<a title=\"".__('Edit tags for this article')."\"
href=\"javascript:editArticleTags($id, $feed_id, true)\">(+)</a>";
print "<img src=\"images/digest_checkbox.png\"
style=\"cursor : pointer\" style=\"cursor : pointer\"
onclick=\"cdmDismissArticle($id)\"
alt='Dismiss' title='".__('Dismiss article')."'>";
print "</span>";
print "</div>";
print "</div>";
print "<span class='s2'><a class=\"cdmToggleLink\"
href=\"javascript:toggleUnread($id)\">
".__('toggle unread')."</a></span>";
print "</div>";
print "</div>";
print "</div>";
}
}
++$lnum;
}
}
if (!get_pref($link, 'COMBINED_DISPLAY_MODE') && !$offset) {
print "</table>";
@ -7110,4 +6961,70 @@
}
function print_article_enclosures($link, $id, $always_display_enclosures,
$article_content) {
$result = get_article_enclosures($link, $id);
if (count($result) > 0) {
$entries_html = array();
$entries = array();
foreach ($result as $line) {
$url = $line["content_url"];
$ctype = $line["content_type"];
if (!$ctype) $ctype = __("unknown type");
$filename = substr($url, strrpos($url, "/")+1);
$entry = format_inline_player($link, $url, $ctype);
$entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\">" .
$filename . " (" . $ctype . ")" . "</a>";
array_push($entries_html, $entry);
$entry = array();
$entry["type"] = $ctype;
$entry["filename"] = $filename;
$entry["url"] = $url;
array_push($entries, $entry);
}
print "<div class=\"postEnclosures\">";
if (!get_pref($link, "STRIP_IMAGES")) {
if ($always_display_enclosures ||
!preg_match("/<img/i", $article_content)) {
foreach ($entries as $entry) {
if (preg_match("/image/", $entry["type"]) ||
preg_match("/\.(jpg|png|gif|bmp)/i", $entry["filename"])) {
print "<p><img
alt=\"".htmlspecialchars($entry["filename"])."\"
src=\"" .htmlspecialchars($entry["url"]) . "\"/></p>";
}
}
}
}
if (db_num_rows($result) == 1) {
print __("Attachment:") . " ";
} else {
print __("Attachments:") . " ";
}
print join(", ", $entries_html);
print "</div>";
}
}
?>

@ -809,161 +809,6 @@ span.hlFeed a:hover {
color : #4684ff;
}
div.cdmAllTags {
float : left;
background-color : white;
border : 1px solid #c0c0c0;
display : none;
z-index : 3;
top : auto;
left : auto;
right : auto;
position : absolute;
padding : 10px;
}
span.cdmAllTagsCtr:hover div {
display : block;
}
div.cdmArticle {
border-color : #c0c0c0;
border-width : 1px;
border-style : solid;
background : white;
margin : 5px 5px 0px 5px;
color : black;
}
div.cdmArticleUnread {
border-color : #88b0f0;
border-width : 1px;
border-style : solid;
background-color : white;
margin : 5px 5px 0px 5px;
color : black;
}
div.cdmArticleSelected, div.cdmArticleUnreadSelected {
background-color : #fff7d5;
border-color : #e7d796;
border-width : 1px;
border-style : solid;
margin : 5px 5px 0px 5px;
}
div.cdmArticleUnread div.cdmHeader a.title,
div.cdmArticleUnreadSelected div.cdmHeader a.title {
font-weight : bold;
}
div.cdmHeader {
padding : 5px 5px 10px 5px;
color : gray;
}
div.cdmArticleUnread div.cdmHeader {
background : url("images/footer.png") top left;
background-repeat : repeat-x;
}
div.cdmArticleUnread div.cdmHeader span.titleWrap a {
color : black;
}
div.cdmArticleSelected div.cdmFooter, div.cdmArticleUnreadSelected div.cdmFooter {
background : #e7d796;
}
div.cdmFooter input {
vertical-align : middle;
}
div.cdmFooter {
font-size : 12px;
color : black;
padding : 5px;
color : gray;
background : #f9f9f9;
/* border-width : 1px 0px 0px 0px;
border-style : solid;
border-color : #88b0f0; */
}
div.cdmFooter span.s0 {
border-width : 0px 1px 0px 0px;
border-color : #c0c0c0;
border-style : dotted;
padding : 0px 5px 0px 0px;
}
div.cdmFooter span.s1 {
border-width : 0px 1px 0px 0px;
border-color : #c0c0c0;
border-style : dotted;
padding : 0px 5px 0px 5px;
}
div.cdmFooter span.s2 {
padding : 0px 5px 0px 5px;
}
div.cdmFooter img.markedPic, div.cdmFooter img.tagsPic {
width : 16px;
height : 16px;
vertical-align : middle;
}
div.cdmHeader div.articleUpdated {
float : right;
font-weight : bold;
color : gray;
}
div.cdmHeader div.articleUpdated img {
vertical-align : middle;
}
div.cdmFooter input, div.cdmHeader input, div.cdmFooter img {
margin : 0px;
}
div.cdmHeader, div.cdmHeader a {
color : #505050;
font-size : 12px;
}
div.cdmHeader a:hover {
color : #4684ff;
}
div.cdmContent {
margin : 0px 15px 5px 15px;
}
div.cdmContent img {
border-width : 0px;
max-width : 98%;
}
div.cdmContent:hover {
cursor : pointer;
}
div.cdmExcerpt {
margin : 0px 15px 5px 15px;
}
div.cdmExcerpt:hover {
cursor : pointer;
color : #88b0f0;
}
div.cdmEnclosures {
margin-top : 1em;
color : gray;
}
img.markedPic {
cursor : pointer;
}
@ -1074,23 +919,6 @@ div.browserFeedInfo div.detailsPart {
margin : 5px 0px 5px 5px;
}
div.cdmContent a {
color : #4684ff;
}
div.cdmContent a:hover {
color : black;
}
a.cdmToggleLink {
color : #808080;
font-size : 12px;
}
a.cdmToggleLink:hover {
color : #4684ff;
}
.noborder {
border-width : 0px;
}

@ -1009,14 +1009,14 @@ function hotkey_handler(e) {
if (keycode == 78 || keycode == 40) { // n, down
if (typeof moveToPost != 'undefined') {
moveToPost('next');
return;
return false;
}
}
if (keycode == 80 || keycode == 38) { // p, up
if (typeof moveToPost != 'undefined') {
moveToPost('prev');
return;
return false;
}
}

@ -29,6 +29,7 @@
<link rel="stylesheet" type="text/css" href="tt-rss.css?<?php echo $dt_add ?>"/>
<link rel="stylesheet" type="text/css" href="infobox.css?<?php echo $dt_add ?>"/>
<link rel="stylesheet" type="text/css" href="cdm.css?<?php echo $dt_add ?>"/>
<?php $user_theme = get_user_theme_path($link);
if ($user_theme) { ?>

@ -765,12 +765,8 @@ function moveToPost(mode) {
if (next_id) {
if (isCdmMode()) {
if (!cdmArticleIsActuallyVisible(next_id)) {
cdmScrollToArticleId(next_id);
}
cdmSelectArticles("none");
toggleUnread(next_id, 0, true);
toggleSelected(next_id);
cdmExpandArticle(next_id);
cdmScrollToArticleId(next_id);
} else {
correctHeadlinesOffset(next_id);
@ -782,10 +778,8 @@ function moveToPost(mode) {
if (mode == "prev") {
if (prev_id) {
if (isCdmMode()) {
cdmExpandArticle(prev_id);
cdmScrollToArticleId(prev_id);
cdmSelectArticles("none");
toggleUnread(prev_id, 0, true);
toggleSelected(prev_id);
} else {
correctHeadlinesOffset(prev_id);
view(prev_id, getActiveFeedId());
@ -1886,24 +1880,6 @@ function getActiveArticleId() {
return active_post_id;
}
function cdmClicked(id) {
try {
var elem = $("RROW-" + id);
if (elem) {
var id = elem.id.replace("RROW-", "");
active_post_id = id;
// cdmSelectArticles("none");
toggleUnread(id, 0, true);
// toggleSelected(id);
}
} catch (e) {
exception_error("cdmClicked", e);
}
}
function preloadArticleUnderPointer(id) {
try {
if (getInitParam("bw_limit") == "1") return;
@ -1978,8 +1954,8 @@ function headlines_scroll_handler() {
var toolbar_form = document.forms["main_toolbar_form"];
console.log((e.scrollTop + e.offsetHeight) + " vs " + e.scrollHeight + " dis? " +
_infscroll_disable);
// console.log((e.scrollTop + e.offsetHeight) + " vs " + e.scrollHeight + " dis? " +
// _infscroll_disable);
if (e.scrollTop + e.offsetHeight > e.scrollHeight - 100) {
if (!_infscroll_disable) {
@ -2068,28 +2044,47 @@ function catchupRelativeToArticle(below) {
}
}
function cdmExpandArticle(a_id) {
function cdmExpandArticle(id) {
try {
var id = 'CICD-' + a_id;
try {
Element.hide("CEXC-" + a_id);
} catch (e) { }
var elem = $("CICD-" + active_post_id);
Effect.Appear(id, {duration : 0.5,
beforeStart: function(effect) {
var h_id = 'CICH-' + a_id;
var h_elem = $(h_id);
if (h_elem) { h_elem.style.display = "none"; }
if (id == active_post_id && Element.visible(elem))
return true;
cdmSelectArticles("none");
var old_offset = $("RROW-" + id).offsetTop;
if (active_post_id && elem) {
Element.hide(elem);
Element.show("CEXC-" + active_post_id);
}
toggleUnread(a_id, 0);
}});
active_post_id = id;
elem = $("CICD-" + id);
if (!Element.visible(elem)) {
Element.show(elem);
Element.hide("CEXC-" + id);
}
var new_offset = $("RROW-" + id).offsetTop;
$("headlinesInnerContainer").scrollTop += (new_offset-old_offset);
if ($("RROW-" + id).offsetTop != old_offset)
$("headlinesInnerContainer").scrollTop = new_offset;
toggleUnread(id, 0, true);
toggleSelected(id);
} catch (e) {
exception_error("cdmExpandArticle", e);
}
return false;
}
function fixHeadlinesOrder(ids) {
@ -2358,3 +2353,16 @@ function emailArticleDo() {
exception_error("emailArticleDo", e);
}
}
function cdmDismissArticle(id) {
try {
var elem = $("RROW-" + id);
toggleUnread(id, 0, true);
new Effect.Fade(elem, {duration : 0.5});
} catch (e) {
exception_error("cdmDismissArticle", e);
}
}

Loading…
Cancel
Save