]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - js/share.js
Save title in database
[Github/YOURLS.git] / js / share.js
1 $(document).ready(function(){\r
2         $('#tweet_body').focus();\r
3 \r
4         $('#tweet_body').keypress(function(event){\r
5                 var text = encodeURI( $('#tweet_body').val() );\r
6                 var tw = 'http://twitter.com/home?status='+text;\r
7                 var ff = 'http://friendfeed.com/share/bookmarklet/frame#title='+encodeURI( $('#tweet_body').val() ) ;\r
8                 $('#share_tw').attr('href', tw);\r
9                 $('#share_ff').attr('href', ff);\r
10                 \r
11                 var charcount = parseInt(140 - $('#tweet_body').val().length);\r
12                 $('#charcount')\r
13                         .toggleClass("negative", charcount < 0)\r
14                         .text( charcount );\r
15         });\r
16 \r
17         $('#copylink').click(function(){\r
18                 $(this).select();\r
19         });     \r
20         \r
21         init_clipboard();\r
22 })\r
23 \r
24 function share(dest) {\r
25         var url = $('#share_'+dest).attr('href');\r
26         switch (dest) {\r
27         case 'ff':\r
28                 //$('body').append('<script type="text/javascript" src="http://friendfeed.com/share/bookmarklet/javascript"></script>');\r
29                 window.open(url, 'ff','toolbar=no,width=500,height=350');\r
30                 break;\r
31         case 'fb':\r
32                 //var url = $('#share_fb').attr('href');\r
33                 window.open( url, 'fb','toolbar=no,width=1000,height=550');\r
34                 break;\r
35         case 'tw':\r
36                 //var url = $('#share_tw').attr('href');\r
37                 window.open(url, 'tw','toolbar=no,width=800,height=550');\r
38                 break;\r
39         }\r
40         return false;\r
41 }\r
42 \r
43 function init_clipboard() {\r
44         //Create a new clipboard client\r
45         clip = new ZeroClipboard.Client();\r
46         \r
47         //Glue the clipboard client to the last td in each row\r
48         clip.glue( 'copylink' );\r
49 \r
50         //Grab the text from the parent row of the icon\r
51         var txt = $('#copylink').val();\r
52         clip.setText(txt);\r
53 \r
54         //Add a complete event to let the user know the text was copied\r
55         clip.addEventListener('complete', function(client, text) {\r
56                 html_pulse( '#copybox h2', 'Copied!' );\r
57         });\r
58         \r
59         // Custom animation on hover\r
60         $('#copylink').css({'backgroundPosition':'130% 50%'});\r
61         $('#'+clip.movieId)\r
62                 .mouseover(function(){\r
63                         $('#copylink').select().animate({'backgroundPosition':'100% 50%'}, 300);\r
64 \r
65                 })\r
66                 .mouseout(function(){\r
67                         $('#copylink').blur().animate({'backgroundPosition':'130% 50%'}, 300);\r
68                 });\r
69                 \r
70         // Force flash clip size (IE fix)\r
71         $('#'+clip.movieId).css('height', '16px');\r
72 };                     \r
73 \r