From 411fe209d642f64ee1f856908e6c1b4507893fcf Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 25 Nov 2010 12:05:48 +0300 Subject: [PATCH] tweak display of tweet button --- functions.php | 60 ++++++++++++++++++++++++++++--------------- images/art-tweet.png | Bin 0 -> 1256 bytes viewfeed.js | 38 ++++++++++++++------------- 3 files changed, 59 insertions(+), 39 deletions(-) create mode 100644 images/art-tweet.png diff --git a/functions.php b/functions.php index 6b76cea3..888af566 100644 --- a/functions.php +++ b/functions.php @@ -2002,9 +2002,9 @@ } } - function truncate_string($str, $max_len) { + function truncate_string($str, $max_len, $suffix = '…') { if (mb_strlen($str, "utf-8") > $max_len - 3) { - return mb_substr($str, 0, $max_len, "utf-8") . "…"; + return mb_substr($str, 0, $max_len, "utf-8") . $suffix; } else { return $str; } @@ -4577,6 +4577,15 @@ print "
" . truncate_string(strip_tags($line['title']), 15) . "
"; + $tweet_title = htmlspecialchars( + truncate_string(strip_tags($line['title']), 100, '...')); + + $tweet_link = htmlspecialchars($line['link']); + + print ""; + print json_encode(array("title" => $tweet_title, "link" => $tweet_link)); + print ""; + print "
"; /* print "
"; } + if (ENABLE_TWEET_BUTTON) { + print "Zoom"; + } + print "Tweet"; - print "
"; print "
"; @@ -5227,11 +5235,14 @@ $short_title = truncate_string( strip_tags($line['title']), 90); - print "
Tweet"; + $tweet_title = htmlspecialchars( + truncate_string(strip_tags($line['title']), 100, '...')); + + $tweet_link = htmlspecialchars($line['link']); + + print ""; + print json_encode(array("title" => $tweet_title, "link" => $tweet_link)); + print ""; print ""; @@ -5253,6 +5264,13 @@ alt='Zoom' title='".__('Open article in new tab')."'>"; + $note_escaped = htmlspecialchars($line['note'], ENT_QUOTES); + + print "PubNote"; + if (DIGEST_ENABLE) { print "Zoom"; } - $note_escaped = htmlspecialchars($line['note'], ENT_QUOTES); - - print "PubNote"; + if (ENABLE_TWEET_BUTTON) { + print "Zoom"; + } print "V?XNM@;|# literal 0 HcmV?d00001 diff --git a/viewfeed.js b/viewfeed.js index b276a3ef..602dc772 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -104,10 +104,6 @@ function headlines_callback2(transport, feed_cur_page) { dijit.byId("headlines-toolbar").attr('content', headlines_toolbar.firstChild.nodeValue); - $$("#headlines-frame a.twitter-share-button").each( - function(btn) { var tbtn = new twttr.TweetButton(btn); - tbtn.render(); }); - initHeadlinesMenu(); var cache_prefix = ""; @@ -143,10 +139,6 @@ function headlines_callback2(transport, feed_cur_page) { c.attr('content', c.attr('content') + headlines_content.firstChild.nodeValue); - $$("#headlines-frame a.twitter-share-button").each( - function(btn) { var tbtn = new twttr.TweetButton(btn); - tbtn.render(); }); - console.log("restore selected ids: " + ids); for (var i = 0; i < ids.length; i++) { @@ -228,9 +220,6 @@ function render_article(article) { correctHeadlinesOffset(getActiveArticleId()); - $$("#content-insert a.twitter-share-button").each( - function(btn) { var tbtn = new twttr.TweetButton(btn); tbtn.render(); }); - } catch (e) { exception_error("render_article", e); } @@ -1724,9 +1713,6 @@ function zoomToArticle(event, id) { dijit.byId("content-tabs").addChild(article_pane); - $$("#ATAB-"+id+" a.twitter-share-button").each( - function(btn) { var tbtn = new twttr.TweetButton(btn); tbtn.render(); }); - if (!event || !event.shiftKey) dijit.byId("content-tabs").selectChild(article_pane); @@ -1758,10 +1744,6 @@ function zoomToArticle(event, id) { dijit.byId("content-tabs").addChild(article_pane); - $$("#ATAB-"+id+" a.twitter-share-button").each( - function(btn) { var tbtn = new twttr.TweetButton(btn); - tbtn.render(); }); - if (!event || !event.shiftKey) dijit.byId("content-tabs").selectChild(article_pane); @@ -2320,3 +2302,23 @@ function initHeadlinesMenu() { exception_error("initHeadlinesMenu", e); } } + +function tweetArticle(id) { + try { + var d = new Date(); + var ts = d.getTime(); + + var ti = JSON.parse($("TWEETINFO-" + id).innerHTML); + + var share_url = "http://twitter.com/share?_=" + ts + + "&text=" + param_escape(ti.title) + + "&url=" + param_escape(ti.link); + + window.open(share_url, 'ttrss_tweet', + "status=0,toolbar=0,location=0,width=500,height=400,scrollbars=1,menubar=0"); + + + } catch (e) { + exception_error("tweetArticle", e); + } +} -- 2.39.5