Browse Source

twitter button now works

Oz N Tiram 9 years ago
parent
commit
966ca8b3bc
2 changed files with 16 additions and 1 deletions
  1. 15 0
      media/js/scripts.js
  2. 1 1
      templates/entry.html

+ 15 - 0
media/js/scripts.js

@@ -0,0 +1,15 @@
+// Empty JS for your own code to be here
+$(document).ready(function() {
+
+	$('a.tweet').click(function(e){
+	  e.preventDefault();
+	  //We get the URL of the link
+	  var loc = $(this).attr('href');
+	  //We get the title of the link
+	  var title  = encodeURIComponent($(this).attr('title'));
+	  var title  = escape($(this).attr('title'));
+	  //We trigger a new window with the Twitter dialog, in the middle of the page
+	  window.open('http://twitter.com/share?url=' + loc + '&text=' + title + '&', 'twitterwindow', 'height=450, width=550, top='+($(window).height()/2 - 225) +', left='+$(window).width()/2 +', toolbar=0, location=0, menubar=0, directories=0, scrollbars=0');
+	});
+
+});

+ 1 - 1
templates/entry.html

@@ -13,7 +13,7 @@
 	<h4>Share this post:</h4> 
 	<i class="fa fa-linkedin-square fa-2x"></i>
 	<i class="fa fa-facebook-square fa-2x"></i>
-	<i class="fa fa-twitter-square fa-2x"></i>
+	<a class="tweet" href="{{site_url}}/{{entry.permalink}}" title="{{entry.title}}" target="_blank"><i class="fa fa-twitter-square fa-2x"></i></a>
 	<i class="fa fa-google-plus-square fa-2x"></i>
 	<i class="fa fa-envelope-square fa-2x"></i>
 </div>