Script Compartilhar no Twitter

Views:
LINK DO TUTORIAL:

<style>
.post-body {position: relative !important;}
#pajarito {display: none;position: absolute;width: 25px;height: 25px;margin: -2em 2em 0 0;background: url(http://1.bp.blogspot.com/-DXICtW2x5No/VaKmEex2NNI/AAAAAAAAUNU/Jl1QOtvSJgU/s1600/twitter.png) white;border: solid .2em #0CB7F2;border-radius: 100%;cursor: pointer;}
#pajarito:hover {background-color: #eee;}
</style>
<script type="text/javascript">
var seleccionado = '';
var horiz, vert, referencia;
function carga() {
referencia = document.getElementsByClassName('post-body')[0];
var pajarito = document.createElement('span');
pajarito.setAttribute('id', 'pajarito');
pajarito.setAttribute('onmousedown', 'abre()');
referencia.appendChild(pajarito);
referencia.onmouseup = captura;
}
function captura(e) {
seleccionado = (window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text);
if (seleccionado != '') {
if(e.offsetX == undefined){
horiz = e.pageX - $(this).offset().left;
vert = e.pageY - $(this).offset().top;
}
else{
horiz = e.offsetX;
vert = e.offsetY;
}
document.getElementById('pajarito').style.display = 'inline-block';
document.getElementById('pajarito').style.left = horiz + 'px';
document.getElementById('pajarito').style.top = vert + 'px';
} else {
document.getElementById('pajarito').style.display = 'none';
}
}
function abre() {
var origen = window.location.href;
var mensaje = seleccionado.toString().substring(0, 100);
var direccion = 'http://twitter.com/home?status=' + mensaje + ' ' + origen;
window.open(direccion,'','width=500,height=500');
}
onload = carga;
</script>


Home Sobre mim Tutoriais Loja de templates Portfólio Fanpage