1 $(document).ready(function(){
2 $('#tweet_body').focus();
4 $('#tweet_body').keypress(function(){
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.
9 function update_share() {
10 var text = encodeURIComponent( $('#tweet_body').val() );
11 var url = encodeURIComponent( $('#copylink').val() );
12 var tw = 'http://twitter.com/intent/tweet?status='+text;
13 var fb = 'http://www.facebook.com/share.php?u='+url ;
14 $('#share_tw').attr('href', tw);
15 $('#share_fb').attr('href', fb);
17 var charcount = parseInt(140 - $('#tweet_body').val().length);
19 .toggleClass("negative", charcount < 0)
23 function share(dest) {
24 var url = $('#share_'+dest).attr('href');
27 //var url = $('#share_fb').attr('href');
28 window.open( url, 'fb','toolbar=no,width=1000,height=550');
31 //var url = $('#share_tw').attr('href');
32 window.open(url, 'tw','toolbar=no,width=800,height=550');
38 function init_clipboard() {
39 var clipboard = new Clipboard('#copylink', {
40 text: function (trigger) {
41 return $(trigger).val();
45 clipboard.on('success', function () {
46 $('#copylink').select();
47 html_pulse('#copybox h2, #copybox h3', 'Copied!');