From dad14b513d3e9bab376d3691043c49a99d6db0a4 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 9 Nov 2010 20:57:23 +0300 Subject: refactor combined mode, code cleanup --- cdm.css | 56 +++++++++ functions.php | 399 +++++++++++++++++++++++----------------------------------- tt-rss.css | 172 ------------------------- tt-rss.js | 4 +- tt-rss.php | 1 + viewfeed.js | 90 +++++++------ 6 files changed, 266 insertions(+), 456 deletions(-) create mode 100644 cdm.css diff --git a/cdm.css b/cdm.css new file mode 100644 index 000000000..2795b378c --- /dev/null +++ b/cdm.css @@ -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; +} + diff --git a/functions.php b/functions.php index bc3b28826..af5a5c828 100644 --- a/functions.php +++ b/functions.php @@ -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 .= " " . - $filename . " (" . $ctype . ")" . ""; - - array_push($entries_html, $entry); - - $entry = array(); - - $entry["type"] = $ctype; - $entry["filename"] = $filename; - $entry["url"] = $url; - - array_push($entries, $entry); - } - - print "
"; - - if (!get_pref($link, "STRIP_IMAGES")) { - if ($always_display_enclosures || - !preg_match("/\"".htmlspecialchars($entry["filename"])."\"

"; - } - } - } - } - - if (db_num_rows($result) == 1) { - print __("Attachment:") . " "; - } else { - print __("Attachments:") . " "; - } - - print join(", ", $entries_html); - - print "
"; - } - print ""; - + print ""; } @@ -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 "
"; print "
"; - if (!get_pref($link, "VFEED_GROUP_BY_FEED") || !$line["feed_title"]) { - $cdm_feed_icon = "$feed_icon_img"; - } + print "
"; + print "$updated_fmt"; + print "$marked_pic"; + print "$published_pic"; + print "$score_pic"; - print "
$updated_fmt $score_pic $cdm_feed_icon -
"; + if (!get_pref($link, "VFEED_GROUP_BY_FEED") && $line["feed_title"]) { + print "$feed_icon_img"; + } + print "
"; + + print ""; - print " + ".$line["title"]." - "; - - print $entry_author; - -/* if (!$expand_cdm || $score < -100) { - print "  - (".__('Show article').")"; - } */ + "; print $labels_str; - if (!get_pref($link, 'VFEED_GROUP_BY_FEED')) { - if ($line["feed_title"]) { - print " (".$line["feed_title"].")"; - } - } + if ($expand_cdm) + $content_hidden = "style=\"display : none\""; + else + $excerpt_hidden = "style=\"display : none\""; - print "
"; + print " - $content_preview"; - if ($show_excerpt) { - print "
"; + print "
"; - $content_preview = trim(truncate_string(strip_tags($line["content_preview"]), 100)); + print "
"; - if (strlen($content_preview) != 0) { - print $content_preview; - } else { - print __('Click to expand article'); - } - print "
"; - } - - print "
"; + print "
"; - 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 "
"; - print __("Originally from:"); - - print " "; - - $tmp_line = db_fetch_assoc($tmp_result); - - print "" . - $tmp_line['title'] . ""; - - print " "; - - print ""; - print ""; - - print "
"; + + print "
"; + print __("Originally from:"); + + print " "; + + $tmp_line = db_fetch_assoc($tmp_result); + + print "" . + $tmp_line['title'] . ""; + + print " "; + + print ""; + print ""; + + print "
"; + } } - } -// print "
"; + $article_content = sanitize_rss($link, $line["content_preview"]); print "
"; if ($line['note']) { @@ -5556,136 +5474,69 @@ } print "
"; - 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 .= " " . - $filename . " (" . $ctype . ")" . ""; - - 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 "

\"".htmlspecialchars($entry["filename"])."\"

"; - } - } - } - } - - print "
"; - - if (db_num_rows($e_result) == 1) { - print __("Attachment:") . " "; - } else { - print __("Attachments:") . " "; - } - - print join(", ", $entries_html); - - print "
"; - } - - - print "
"; -// print "
"; + $always_display_enclosures = sql_bool_to_bool(db_fetch_result($tmp_result, + 0, "always_display_enclosures")); -/* if (!$expand_cdm) { - print " - Show article"; - } */ + print_article_enclosures($link, $id, $always_display_enclosures, + $article_content); print "
"; - print "
"; + print "
"; - /* print "
Star it: $marked_pic
"; */ + $tags_str = format_tags_string(get_article_tags($link, $id), $id); + + print "Tags + $tags_str + (+)"; - print __("Select:"). - " "; + print "
"; - print "$marked_pic "; - print "$published_pic "; - print "Zoom "; + title='".__('Show article summary in new window')."'>"; + + if (DIGEST_ENABLE) { + print "Zoom"; + } $note_escaped = htmlspecialchars($line['note'], ENT_QUOTES); - print "PubNote"; - print ""; - - $tags_str = format_tags_string(get_article_tags($link, $id), $id); - - print " - Tags - $tags_str - (+)"; + print "Dismiss"; - print ""; + print "
"; + print "
"; - print " - ".__('toggle unread').""; + print "
"; print "
"; - print "
"; - } + } ++$lnum; - } + } if (!get_pref($link, 'COMBINED_DISPLAY_MODE') && !$offset) { print ""; @@ -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 .= " " . + $filename . " (" . $ctype . ")" . ""; + + array_push($entries_html, $entry); + + $entry = array(); + + $entry["type"] = $ctype; + $entry["filename"] = $filename; + $entry["url"] = $url; + + array_push($entries, $entry); + } + + print "
"; + + if (!get_pref($link, "STRIP_IMAGES")) { + if ($always_display_enclosures || + !preg_match("/\"".htmlspecialchars($entry["filename"])."\"

"; + } + } + } + } + + if (db_num_rows($result) == 1) { + print __("Attachment:") . " "; + } else { + print __("Attachments:") . " "; + } + + print join(", ", $entries_html); + + print "
"; + } + } + ?> diff --git a/tt-rss.css b/tt-rss.css index 7f798a53d..980d7b53e 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -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; } diff --git a/tt-rss.js b/tt-rss.js index 9aaa4c52c..63518c154 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -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; } } diff --git a/tt-rss.php b/tt-rss.php index e580f0c8e..5375309ce 100644 --- a/tt-rss.php +++ b/tt-rss.php @@ -29,6 +29,7 @@ + diff --git a/viewfeed.js b/viewfeed.js index 1a40c9649..d12e95380 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -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); + } +} -- cgit v1.2.3