]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - js/share.js
Oops, missing translatable strings in the calendar.
[Github/YOURLS.git] / js / share.js
1 $(document).ready(function(){\r
2         $('#tweet_body').focus();\r
3 \r
4         $('#tweet_body').keypress(function(){\r
5                 setTimeout( function(){update_share()}, 50 ); // we're delaying, otherwise keypress() always triggers too fast before current key press actually inserts a letter?!! Go figure.\r
6         });\r
7 })\r
8 \r
9 function update_share() {\r
10         var text = encodeURIComponent( $('#tweet_body').val() );\r
11         var url = encodeURIComponent( $('#copylink').val() );\r
12         var tw = 'http://twitter.com/intent/tweet?status='+text;\r
13         var ff = 'http://friendfeed.com/share/bookmarklet/frame#title='+text ;\r
14         var fb = 'http://www.facebook.com/share.php?u='+url ;\r
15         $('#share_tw').attr('href', tw);\r
16         $('#share_ff').attr('href', ff);\r
17         $('#share_fb').attr('href', fb);\r
18         \r
19         var charcount = parseInt(140 - $('#tweet_body').val().length);\r
20         $('#charcount')\r
21                 .toggleClass("negative", charcount < 0)\r
22                 .text( charcount );\r
23 }\r
24 \r
25 function share(dest) {\r
26         var url = $('#share_'+dest).attr('href');\r
27         switch (dest) {\r
28         case 'ff':\r
29                 //$('body').append('<script type="text/javascript" src="http://friendfeed.com/share/bookmarklet/javascript"></script>');\r
30                 window.open(url, 'ff','toolbar=no,width=500,height=350');\r
31                 break;\r
32         case 'fb':\r
33                 //var url = $('#share_fb').attr('href');\r
34                 window.open( url, 'fb','toolbar=no,width=1000,height=550');\r
35                 break;\r
36         case 'tw':\r
37                 //var url = $('#share_tw').attr('href');\r
38                 window.open(url, 'tw','toolbar=no,width=800,height=550');\r
39                 break;\r
40         }\r
41         return false;\r
42 }\r
43 \r
44 function init_clipboard() {\r
45         $('#copylink').click(function(){\r
46                 $(this).select();\r
47         })\r
48         \r
49         $('#copylink').zclip({\r
50                 path: zclipurl,\r
51                 copy: $('#copylink').val(),\r
52                 afterCopy:function(){\r
53                         html_pulse( '#copybox h2, #copybox h3', 'Copied!' );\r
54                 }\r
55         });\r
56 };                     \r
57 \r