From ac4c1383ae3b1af7be056b1f75c8125b272b0e5f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 13 Jul 2015 01:19:52 +0300 Subject: [PATCH] bring cdmFeedTitle style in line with the rest of the UI send headline rows as separate JSON objects --- classes/feeds.php | 161 +++++++++++++++++++++++++--------------------- css/cdm.css | 5 +- js/viewfeed.js | 51 +++++++++++---- 3 files changed, 127 insertions(+), 90 deletions(-) diff --git a/classes/feeds.php b/classes/feeds.php index 9608290c..089c3e71 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -307,7 +307,11 @@ class Feeds extends Handler_Protected { $expand_cdm = get_pref('CDM_EXPANDED'); + $reply['content'] = array(); + while ($line = $this->dbh->fetch_assoc($result)) { + $headline_row = ''; + $line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { @@ -448,76 +452,79 @@ class Feeds extends Handler_Protected { $vf_catchup_link = "".__('mark feed as read').""; - $reply['content'] .= "
". + $feed_title_row = "
". "
$feed_icon_img
". - "". $line["feed_title"]." + "". + $line["feed_title"]." $vf_catchup_link
"; + array_push($reply['content'], array('id' => 0, 'kind' => 'feed_title', 'html' => $feed_title_row)); + } } $mouseover_attrs = "onmouseover='postMouseIn(event, $id)' onmouseout='postMouseOut($id)'"; - $reply['content'] .= "
"; + $headline_row .= "
"; - $reply['content'] .= "
"; + $headline_row .= "
"; - $reply['content'] .= ""; - $reply['content'] .= "$marked_pic"; - $reply['content'] .= "$published_pic"; + $headline_row .= "$marked_pic"; + $headline_row .= "$published_pic"; - $reply['content'] .= "
"; + $headline_row .= "
"; - $reply['content'] .= "
"; - $reply['content'] .= "" . truncate_string($line["title"], 200); if (get_pref('SHOW_CONTENT_PREVIEW')) { - $reply['content'] .= "" . $line["content_preview"] . ""; + $headline_row .= "" . $line["content_preview"] . ""; } - $reply['content'] .= ""; + $headline_row .= ""; - $reply['content'] .= $labels_str; + $headline_row .= $labels_str; - $reply['content'] .= "
"; + $headline_row .= "
"; if (!$vfeed_group_enabled) { if (@$line["feed_title"]) { $rgba = @$rgba_cache[$feed_id]; - $reply['content'] .= "". + $headline_row .= "". truncate_string($line["feed_title"],30).""; } } - $reply['content'] .= ""; + $headline_row .= ""; - $reply['content'] .= "
$updated_fmt
+ $headline_row .= "
$updated_fmt
"; - $reply['content'] .= "
"; + $headline_row .= "
"; - $reply['content'] .= $score_pic; + $headline_row .= $score_pic; if ($line["feed_title"] && !$vfeed_group_enabled) { - $reply['content'] .= " $feed_icon_img"; } - $reply['content'] .= "
"; - $reply['content'] .= "
"; + $headline_row .= "
"; + $headline_row .= "
"; } else { @@ -551,10 +558,12 @@ class Feeds extends Handler_Protected { //$feed_icon_img = "\"\""; } - $reply['content'] .= "
". + $feed_title_row = "
". "
$feed_icon_img
". "". $line["feed_title"]." $vf_catchup_link
"; + + array_push($reply['content'], array('id' => 0, 'kind' => 'feed_title', 'html' => $feed_title_row)); } } @@ -563,20 +572,20 @@ class Feeds extends Handler_Protected { $expanded_class = $expand_cdm ? "expanded" : "expandable"; - $reply['content'] .= "
"; - $reply['content'] .= "
"; - $reply['content'] .= "
"; + $headline_row .= "
"; + $headline_row .= "
"; - $reply['content'] .= ""; - $reply['content'] .= "$marked_pic"; - $reply['content'] .= "$published_pic"; + $headline_row .= "$marked_pic"; + $headline_row .= "$published_pic"; - $reply['content'] .= "
"; + $headline_row .= "
"; if ($highlight_words && count($highlight_words > 0)) { foreach ($highlight_words as $word) { @@ -585,7 +594,7 @@ class Feeds extends Handler_Protected { } } - $reply['content'] .= " $entry_author"; - $reply['content'] .= $labels_str; + $headline_row .= $labels_str; - $reply['content'] .= ""; + $headline_row .= ""; if (!$vfeed_group_enabled) { if (@$line["feed_title"]) { $rgba = @$rgba_cache[$feed_id]; - $reply['content'] .= "
+ $headline_row .= "
". truncate_string($line["feed_title"],30)." @@ -622,34 +631,34 @@ class Feeds extends Handler_Protected { } } - $reply['content'] .= " + $headline_row .= " $updated_fmt"; - $reply['content'] .= "
"; - $reply['content'] .= "$score_pic"; + $headline_row .= "
"; + $headline_row .= "$score_pic"; if (!get_pref("VFEED_GROUP_BY_FEED") && $line["feed_title"]) { - $reply['content'] .= "$feed_icon_img"; } - $reply['content'] .= "
"; + $headline_row .= "
"; - $reply['content'] .= "
"; + $headline_row .= "
"; - $reply['content'] .= "
"; - $reply['content'] .= "
"; + $headline_row .= "
"; if ($line['note']) { - $reply['content'] .= format_article_note($id, $line['note']); + $headline_row .= format_article_note($id, $line['note']); } - $reply['content'] .= "
"; + $headline_row .= "
"; if (!$line['lang']) $line['lang'] = 'en'; - $reply['content'] .= "
"; + $headline_row .= "
"; if ($line["orig_feed_id"]) { @@ -658,54 +667,54 @@ class Feeds extends Handler_Protected { if ($this->dbh->num_rows($tmp_result) != 0) { - $reply['content'] .= "
"; - $reply['content'] .= __("Originally from:"); + $headline_row .= "
"; + $headline_row .= __("Originally from:"); - $reply['content'] .= " "; + $headline_row .= " "; $tmp_line = $this->dbh->fetch_assoc($tmp_result); - $reply['content'] .= "" . $tmp_line['title'] . ""; - $reply['content'] .= " "; + $headline_row .= " "; - $reply['content'] .= ""; - $reply['content'] .= ""; + $headline_row .= ""; + $headline_row .= ""; - $reply['content'] .= "
"; + $headline_row .= "
"; } } - $reply['content'] .= ""; + $headline_row .= ""; // if (!$expand_cdm) { - $reply['content'] .= ""; - $reply['content'] .= htmlspecialchars($line["content"]); - $reply['content'] .= ""; + $headline_row .= htmlspecialchars($line["content"]); + $headline_row .= ""; + $headline_row .= "
"; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { - $reply['content'] .= $p->hook_article_left_button($line); + $headline_row .= $p->hook_article_left_button($line); } $tags_str = format_tags_string($tags, $id); - $reply['content'] .= "Tags + $headline_row .= "Tags $tags_str (+)"; @@ -729,26 +738,28 @@ class Feeds extends Handler_Protected { } } - if ($entry_comments) $reply['content'] .= " ($entry_comments)"; + if ($entry_comments) $headline_row .= " ($entry_comments)"; - $reply['content'] .= "
"; + $headline_row .= "
"; -// $reply['content'] .= "$marked_pic"; -// $reply['content'] .= "$published_pic"; +// $headline_row .= "$marked_pic"; +// $headline_row .= "$published_pic"; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) { - $reply['content'] .= $p->hook_article_button($line); + $headline_row .= $p->hook_article_button($line); } - $reply['content'] .= "
"; - $reply['content'] .= "
"; + $headline_row .= "
"; + $headline_row .= "
"; - $reply['content'] .= "
"; + $headline_row .= "
"; - $reply['content'] .= "
"; + $headline_row .= "
"; } + array_push($reply['content'], array("id" => (int)$line['id'], 'html' => $headline_row)); + ++$lnum; } diff --git a/css/cdm.css b/css/cdm.css index 0af07076..ed9bedea 100644 --- a/css/cdm.css +++ b/css/cdm.css @@ -213,17 +213,14 @@ div.cdmContent div.postEnclosures { } div.cdmFeedTitle { - border-color : #a0a0a0; + border-color : #4684ff; border-width : 0px 0px 1px 0px; border-style : solid; padding : 5px 3px 5px 5px; - background : url("../images/toolbar.png") bottom left; - background-repeat : repeat-x; } div.cdmFeedTitle a.title { color : #555; - font-style : italic; font-weight : bold; } diff --git a/js/viewfeed.js b/js/viewfeed.js index 1a45e8bb..be30183b 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -86,8 +86,8 @@ function headlines_callback2(transport, offset, background, infscroll_req) { if (infscroll_req == false) { loaded_article_ids = []; - dijit.byId("headlines-frame").attr('content', - reply['headlines']['content']); + /*dijit.byId("headlines-frame").attr('content', + reply['headlines']['content']);*/ //dijit.byId("headlines-toolbar").attr('content', // reply['headlines']['toolbar']); @@ -96,12 +96,28 @@ function headlines_callback2(transport, offset, background, infscroll_req) { reply['headlines']['toolbar'], {parseContent: true}); - $$("#headlines-frame > div[id*=RROW]").each(function(row) { + /*$$("#headlines-frame > div[id*=RROW]").each(function(row) { if (loaded_article_ids.indexOf(row.id) != -1) { row.parentNode.removeChild(row); } else { loaded_article_ids.push(row.id); } + });*/ + + + dijit.byId("headlines-frame").attr("content", ""); + + reply['headlines']['content'].each(function(row) { + if (loaded_article_ids.indexOf(row.id) == -1) { + loaded_article_ids.push(row.id); + } + + var tmp = new Element("div"); + tmp.innerHTML = row.html; + + dojo.parser.parse(tmp.firstChild); + dijit.byId("headlines-frame").domNode.appendChild(tmp.firstChild); + }); var hsp = $("headlines-spacer"); @@ -127,16 +143,16 @@ function headlines_callback2(transport, offset, background, infscroll_req) { var c = dijit.byId("headlines-frame"); var ids = getSelectedArticleIds2(); - var new_elems = []; + //var new_elems = []; - $("headlines-tmp").innerHTML = reply['headlines']['content']; + //$("headlines-tmp").innerHTML = reply['headlines']['content']; var hsp = $("headlines-spacer"); if (hsp) c.domNode.removeChild(hsp); - $$("#headlines-tmp > div").each(function(row) { + /*$$("#headlines-tmp > div").each(function(row) { if (row.className == 'cdmFeedTitle') { row.style.display = 'none'; c.domNode.appendChild(row); @@ -149,18 +165,31 @@ function headlines_callback2(transport, offset, background, infscroll_req) { } else { row.parentNode.removeChild(row); } + });*/ + + reply['headlines']['content'].each(function(row) { + if (loaded_article_ids.indexOf(row.id) == -1 || row.kind == 'feed_title') { + loaded_article_ids.push(row.id); + + var tmp = new Element("div"); + tmp.innerHTML = row.html; + + dojo.parser.parse(tmp.firstChild); + dijit.byId("headlines-frame").domNode.appendChild(tmp.firstChild); + + } }); + if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"}); // if (getInitParam("cdm_auto_catchup") == 1) { c.domNode.appendChild(hsp); // } - console.log("added " + new_elems.size() + " headlines"); + console.log("added " + reply['headlines']['content'].size() + " headlines"); - if (new_elems.size() == 0) - _infscroll_disable = true; + if (reply['headlines']['content'].size() == 0) _infscroll_disable = true; console.log("restore selected ids: " + ids); @@ -170,12 +199,12 @@ function headlines_callback2(transport, offset, background, infscroll_req) { initHeadlinesMenu(); - new_elems.each(function(child) { + /*new_elems.each(function(child) { dojo.parser.parse(child); if (!Element.visible(child)) new Effect.Appear(child, { duration : 0.5 }); - }); + });*/ if (_infscroll_disable) { hsp.innerHTML = "" + -- 2.39.2