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