]> git.wh0rd.org Git - tt-rss.git/commitdiff
add a simple appearing preview for unexpanded cdm and normal mode
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 25 Mar 2013 12:08:20 +0000 (16:08 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 25 Mar 2013 12:09:05 +0000 (16:09 +0400)
cdm.css
classes/feeds.php
classes/rpc.php
index.php
js/viewfeed.js
tt-rss.css

diff --git a/cdm.css b/cdm.css
index 6bed55de127239fd57288e310ec555366f5da495..60d4601980084cdae58ccc4fdddbc6b408f39436 100644 (file)
--- a/cdm.css
+++ b/cdm.css
@@ -174,3 +174,23 @@ div.cdm.expanded div.cdmHeader a.title, div.cdm.active div.cdmHeader a.title {
        font-size : 13px;
 }
 
+div#small_article_preview {
+       width : 300px;
+       max-height : 350px;
+       overflow : hidden;
+       border : 1px solid #c0c0c0;
+       background : white;
+       position : absolute;
+       box-shadow : 2px 2px 4px #c0c0c0;
+       z-index : 2;
+}
+
+div#small_article_preview div.content {
+       padding : 5px;
+       font-size : 12px;
+       color : gray;
+}
+
+div#small_article_preview div.content img {
+       max-width : 290px;
+}
index 3657a0564caa247cc91e9d0c0fb186c44506b45e..89ebd4a0a077d3983e20bcffd5357a2b96062733 100644 (file)
@@ -413,7 +413,7 @@ class Feeds extends Handler_Protected {
                                                }
                                        }
 
-                                       $mouseover_attrs = "onmouseover='postMouseIn($id)'
+                                       $mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
                                                onmouseout='postMouseOut($id)'";
 
                                        $reply['content'] .= "<div class='$class' id='RROW-$id' $label_row_style $mouseover_attrs>";
@@ -512,7 +512,7 @@ class Feeds extends Handler_Protected {
                                                }
                                        }
 
-                                       $mouseover_attrs = "onmouseover='postMouseIn($id)'
+                                       $mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
                                                onmouseout='postMouseOut($id)'";
 
                                        $expanded_class = $expand_cdm ? "expanded" : "";
@@ -537,7 +537,6 @@ class Feeds extends Handler_Protected {
                                                onclick=\"return cdmClicked(event, $id);\"
                                                class=\"titleWrap$hlc_suffix\">
                                                <a class=\"title\"
-                                               title=\"".htmlspecialchars($line['title'])."\"
                                                target=\"_blank\" href=\"".
                                                htmlspecialchars($line["link"])."\">".
                                                $line["title"] .
index ea139935ee24faa331481e6d9bf0f9ac1ed51f6f..eb241591b966137924b7fe5d44f542708631c7a7 100644 (file)
@@ -843,5 +843,32 @@ class RPC extends Handler_Protected {
                }
        }
 
+       function cdmArticlePreview() {
+               $id = db_escape_string($this->link, $_REQUEST['id']);
+
+               $result = db_query($this->link, "SELECT link,
+                       ttrss_entries.title, content, feed_url
+                       FROM
+                       ttrss_entries, ttrss_user_entries
+                               LEFT JOIN ttrss_feeds ON (ttrss_user_entries.feed_id = ttrss_feeds.id)
+                       WHERE ref_id = '$id' AND ref_id = ttrss_entries.id AND
+                               ttrss_user_entries.owner_uid = ". $_SESSION["uid"]);
+
+               if (db_num_rows($result) != 0) {
+                       $link = db_fetch_result($result, 0, "link");
+                       $title = db_fetch_result($result, 0, "title");
+                       $feed_url = db_fetch_result($result, 0, "feed_url");
+
+                       $content = sanitize($this->link,
+                               db_fetch_result($result, 0, "content"), false, false, $feed_url);
+
+                       print "<div class='content'>".$content."</content>";
+
+               } else {
+                       print "Article not found.";
+               }
+
+       }
+
 }
 ?>
index f2b035d47db9253bb7da635440fe5b102fd059da..5c5f706d1d57fa2a05cddb917d2a91228247752c 100644 (file)
--- a/index.php
+++ b/index.php
        </div>
 </div>
 
+<div style="display : none" onclick="Element.hide(this)" id="small_article_preview"></div>
+
 <div id="header">
        <img id="net-alert" style="display : none"
                title="<?php echo __("Communication problem with server.") ?>"
index a5d0947bdc47ef78e10e4e0590f553fde2cbe2a7..0e2e9e3fa11c686e2dd266ed34ffd81581b5617d 100644 (file)
@@ -13,6 +13,8 @@ var catchup_timeout_id = false;
 var cids_requested = [];
 var loaded_article_ids = [];
 
+var _post_preview_timeout = false;
+
 var has_storage = 'sessionStorage' in window && window['sessionStorage'] !== null;
 
 function headlines_callback2(transport, offset, background, infscroll_req) {
@@ -1166,12 +1168,54 @@ function getActiveArticleId() {
        return _active_article_id;
 }
 
-function postMouseIn(id) {
+function postMouseIn(e, id) {
        post_under_pointer = id;
+
+       if (_post_preview_timeout) window.clearTimeout(_post_preview_timeout);
+
+       if (!getInitParam("cdm_expanded")) {
+               _post_preview_timeout = window.setTimeout(function() {
+                       displaySmallArticlePreview(e, id);
+               }, 1000);
+       }
+}
+
+function displaySmallArticlePreview(e, id) {
+       try {
+               var query = "?op=rpc&method=cdmarticlepreview&id=" + id;
+
+               new Ajax.Request("backend.php", {
+                       parameters: query,
+                       onComplete: function(transport) {
+                               cexc = $("CEXC-" + id);
+                               preview = $("small_article_preview");
+                               row = $("RROW-" + id);
+
+                               if (id != getActiveArticleId() && (!isCdmMode() || (cexc && Element.visible(cexc))) && row && preview) {
+                                       preview.innerHTML = transport.responseText;
+                                       new Effect.Appear(preview, {duration:0.2});
+
+                                       preview.setStyle({
+                                               left: (e.clientX + 20) + 'px',
+                                               top: (Element.cumulativeOffset(row)[1] + row.offsetHeight + 10) + 'px' });
+
+                               }
+
+                       } });
+
+
+       } catch (e) {
+               exception_error("displaySmallArticlePreview", e);
+       }
 }
 
 function postMouseOut(id) {
        post_under_pointer = false;
+
+       if (_post_preview_timeout) window.clearTimeout(_post_preview_timeout);
+
+       if (Element.visible("small_article_preview"))
+               Element.hide("small_article_preview");
 }
 
 function unpackVisibleHeadlines() {
index 715de1f6e5d9a42c60554c4a3bd1520ed34d9051..cd79aa5a8a0ddf54de453f8b783b10a4c30e5254 100644 (file)
@@ -1220,3 +1220,5 @@ body#ttrssZoom div.footer {
        margin-top : 1em;
        text-align : center;
 }
+
+