1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/yourls_ynh.git synced 2024-09-03 20:35:59 +02:00
yourls_ynh/sources/js/share.js

58 lines
1.7 KiB
JavaScript
Raw Normal View History

2014-06-11 18:19:02 +02:00
$(document).ready(function(){
$('#tweet_body').focus();
$('#tweet_body').keypress(function(){
setTimeout( function(){update_share()}, 50 ); // we're delaying, otherwise keypress() always triggers too fast before current key press actually inserts a letter?!! Go figure.
});
})
function update_share() {
var text = encodeURIComponent( $('#tweet_body').val() );
var url = encodeURIComponent( $('#copylink').val() );
var tw = 'http://twitter.com/intent/tweet?status='+text;
var ff = 'http://friendfeed.com/share/bookmarklet/frame#title='+text ;
var fb = 'http://www.facebook.com/share.php?u='+url ;
$('#share_tw').attr('href', tw);
$('#share_ff').attr('href', ff);
$('#share_fb').attr('href', fb);
var charcount = parseInt(140 - $('#tweet_body').val().length);
$('#charcount')
.toggleClass("negative", charcount < 0)
.text( charcount );
}
function share(dest) {
var url = $('#share_'+dest).attr('href');
switch (dest) {
case 'ff':
//$('body').append('<script type="text/javascript" src="http://friendfeed.com/share/bookmarklet/javascript"></script>');
window.open(url, 'ff','toolbar=no,width=500,height=350');
break;
case 'fb':
//var url = $('#share_fb').attr('href');
window.open( url, 'fb','toolbar=no,width=1000,height=550');
break;
case 'tw':
//var url = $('#share_tw').attr('href');
window.open(url, 'tw','toolbar=no,width=800,height=550');
break;
}
return false;
}
function init_clipboard() {
$('#copylink').click(function(){
$(this).select();
})
$('#copylink').zclip({
path: zclipurl,
copy: $('#copylink').val(),
afterCopy:function(){
html_pulse( '#copybox h2, #copybox h3', 'Copied!' );
}
});
};