]> git.wh0rd.org Git - tt-rss.git/commitdiff
add experimental clientside headline clamping (refs #479)
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 9 Aug 2012 09:08:07 +0000 (13:08 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 9 Aug 2012 09:08:07 +0000 (13:08 +0400)
classes/feeds.php
js/functions.js
js/viewfeed.js

index 0c9812479a86069b53e1251b56f5a1b86961b69f..23c9e783fd34ee2f66dde43209eb4fa26079bf1b 100644 (file)
@@ -378,8 +378,7 @@ class Feeds extends Protected_Handler {
                                $updated_fmt = make_local_datetime($this->link, $line["updated_noms"], false);\r
 \r
                                if (get_pref($this->link, 'SHOW_CONTENT_PREVIEW')) {\r
-                                       $content_preview = truncate_string(strip_tags($line["content_preview"]),\r
-                                               100);\r
+                                       $content_preview = strip_tags($line["content_preview"]);\r
                                }\r
 \r
                                $score = $line["score"];\r
@@ -458,7 +457,7 @@ class Feeds extends Protected_Handler {
                                        $reply['content'] .= "<a id=\"RTITLE-$id\"\r
                                                href=\"" . htmlspecialchars($line["link"]) . "\"\r
                                                onclick=\"\">" .\r
-                                               truncate_string($line["title"], 200);\r
+                                               $line["title"];\r
 \r
                                        if (get_pref($this->link, 'SHOW_CONTENT_PREVIEW')) {\r
                                                if ($content_preview) {\r
index b2d79dc567a012eed2a01a4a6006936ab90d0f7e..997d55a556f1935ec3a982157ed6aa6618d535d7 100644 (file)
@@ -1718,3 +1718,12 @@ function get_radio_checked(radioObj) {
        }
        return("");
 }
+
+function clamp_element(elem, height) {
+       if (elem && elem.offsetHeight > height) {
+               while (elem.offsetHeight > height)
+                       elem.innerHTML = cp.innerHTML.substring(0, elem.innerHTML.length - 50);
+
+               elem.innerHTML += "&hellip;";
+       }
+}
index 92a610f8d7eafe8e8364bec367ffb2c8a97583bf..2e830164041c7ff21db72b5b1a7236e691e5a320 100644 (file)
@@ -81,6 +81,10 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
                                        reply['headlines']['toolbar']);
 
                                $$("#headlines-frame > div[id*=RROW]").each(function(row) {
+                                       cp = row.getElementsByClassName("contentPreview")[0];
+
+                                       clamp_element(cp, 50);
+
                                        if ($$("#headlines-frame DIV[id="+row.id+"]").length > 1) {
                                                row.parentNode.removeChild(row);
                                        }
@@ -136,8 +140,13 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
 
                                        $$("#headlines-frame > div[id*=RROW]").each(
                                        function(child) {
-                                               if (!Element.visible(child))
+                                               if (!Element.visible(child)) {
                                                        new Effect.Appear(child, { duration : 0.5 });
+
+                                                       cp = child.getElementsByClassName("contentPreview")[0];
+
+                                                       clamp_element(cp, 50);
+                                               }
                                        });
 
                                } else {
@@ -2047,6 +2056,12 @@ function render_local_headlines(feed, is_cat, obj) {
                setActiveFeedId(feed, is_cat);
                initHeadlinesMenu();
 
+
+               $$("#headlines-frame > div[id*=RROW]").each(function(row) {
+                       cp = row.getElementsByClassName("contentPreview")[0];
+                       clamp_element(cp, 50);
+               });
+
                precache_headlines();
 
        } catch (e) {