Permalink
Browse files

Made twitter share url even COOLER

  • Loading branch information...
1 parent 6daf723 commit 609ef15e9d4344b3833489ed9f6887890dbb7b6c @jacquescrocker committed Aug 14, 2010
Showing with 47 additions and 17 deletions.
  1. +6 −9 dynamic/misc/_navbar.erb
  2. +18 −0 helpers.rb
  3. +23 −1 layouts/default.erb
  4. +0 −7 static/css/slides.css
View
@@ -2,15 +2,12 @@
<a href="#home" class="title home">If I would have known just one thing...</a>
<a href="#" class="prev">Previous Slide</a>
<a href="#" class="next">Next Slide</a>
- <a href="#" class="tweet">Tweet this Slide</a>
- <a href="http://twitter.com/share" class="twitter-share-button"
- data-url="http://ifiwouldhaveknownjustonething.com#<%= slide %>"
- data-text="If I would have known just one thing... (by <%= author_name %>)"
- data-count="horizontal"
- <% if defined?(author_twitter) %>
- data-via="<%= author_twitter %>"
- <% end %>
- data-related="sayhellothere">Tweet</a>
+ <%= twitter_share :label => "Tweet this Slide",
+ :url => "http://ifiwouldhaveknownjustonething.com##{slide}",
+ :text => "If I would have known just one thing... (by #{author_name})",
+ :via => defined?(author_twitter) ? author_twitter : nil,
+ :related => "sayhellothere" %>
+
</nav>
View
@@ -1,9 +1,27 @@
+require 'uri'
+
module FrankHelpers
def partial(*args)
render_partial(*args)
end
+ def twitter_share(options = {})
+ %{
+ <a href="#{twitter_share_url(options)}" class="tweet">#{options[:label] || 'Tweet this'}</a>
+ }
+ end
+
+ def twitter_share_url(options = {})
+ base = "http://twitter.com/share?"
+ params = []
+ params << "url=#{URI.encode(options[:url])}"
+ params << "text=#{URI.encode(options[:text])}"
+ params << "via=#{URI.encode(options[:via])}" if options[:via]
+ params << "related=#{URI.encode(options[:related])}"
+ base+params.join("&")
+ end
+
def slidedeck
result = []
Pathname.new(File.dirname(__FILE__)).join("dynamic", "slidedeck").children.each do |child|
View
@@ -466,6 +466,29 @@
});
})
+ $(".tweet").click(function(e) {
+ e.preventDefault();
+
+ var url = $(this).attr("href");
+
+ var Z = 550,
+ h = 450;
+ var c = screen.height;
+ var b = screen.width;
+ var a = Math.round((b / 2) - (Z / 2));
+ var g = 0;
+ if (c > h) {
+ g = Math.round((c / 2) - (h / 2))
+ }
+
+ var tweetWindow = window.open(url, "twitter_tweet", "left=" + a + ",top=" + g + ",width=" + Z + ",height=" + h + ",personalbar=no,toolbar=no,scrollbars=yes,location=yes,resizable=yes");
+ if (tweetWindow) {
+ tweetWindow.focus()
+ } else {
+ window.location.href = Y
+ }
+ })
+
})();
</script>
@@ -484,6 +507,5 @@
})();
</script>
- <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
</body>
</html>
View
@@ -532,14 +532,7 @@ info {
background-position: 0 -36px;
}
-.slide.know nav .twitter-share-button {
- right: 180px;
- top: 20px;
- position: absolute;
-}
-
.slide.know nav a.tweet {
- display: none;
top: 22px;
right: 185px;
width: 136px;

0 comments on commit 609ef15

Please sign in to comment.