share vortex

By vortexius Uploaded Jun 3, 2009
function showShareVortex(doc,myurl,mytitle){
	 _doc = $(doc);

	var my_escaped_title = escape (mytitle);
	var my_escaped_url = escape ( myurl ) ;
	var nShareVortex ='Share in : <ul id="share_vortex_ul">'
	nShareVortex += '<li class="digg"><a title="%title% to Digg" href="http://digg.com/submit?phase=2&url=%url%&title=%escaped_title%" rel="nofollow external" target="_blank">Digg</a></li>';
	nShareVortex += '<li class="twitter"><a title="%title% to Twitter" href="http://twitter.com/home?status=%url%" rel="nofollow external" target="_blank">Twitter</a></li>';
	 nShareVortex += '<li class="stumbleupon"><a title="%title% to Stumbleupon" href="http://www.stumbleupon.com/submit?url=%url%" rel="nofollow external" target="_blank">Stumbleupon</a></li>			';
	 nShareVortex += '<li class="del-icio-us"><a title="%title% to delicious" href="http://del.icio.us/post?url=%url%&title=%escaped_title%" rel="nofollow external" target="_blank">delicious</a></li>			';
	 nShareVortex += '<li class="facebook"><a title="%title% to Facebook" href="http://www.facebook.com/share.php?u=%url%" rel="nofollow external" target="_blank">Facebook</a></li>			';
	 nShareVortex += '<li class="myspace"><a title="%title% to MySpace" href="http://www.myspace.com/Modules/PostTo/Pages/?l=3&u=%url%" rel="nofollow external" target="_blank">MySpace</a></li>			';
	 nShareVortex += '<li class="google"><a title="%title% to Google" href="http://www.google.com/bookmarks/mark?op=edit&bkmk=%url%" rel="nofollow external" target="_blank">Google</a></li>			';
	 nShareVortex += '<li class="technorati"><a title="%title% to Technorati" href="http://technorati.com/cosmos/search.html?url=%url%" rel="nofollow external" target="_blank">Technorati</a></li>			';
	 nShareVortex += '<li class="reddit"><a title="%title% to Reddit" href="http://reddit.com/submit?url=%url%" rel="nofollow external" target="_blank">Reddit</a></li>	';
	 nShareVortex += '</ul>';

	nShareVortex=nShareVortex.replace(/%title%/g , mytitle);
	nShareVortex=nShareVortex.replace(/%escaped_title%/g , my_escaped_title);
	 nShareVortex=nShareVortex.replace(/%url%/g , my_escaped_url);

	 $(jetpack.tabs.focused.contentDocument).find("#share_vortex").css({
		 "background-color": "#D5DCFF",
		 "padding": "10px",
		 "color": "#000000",
		 "font-weight": "500",
		 "margin": "5px",
		 "font-size": '13px',
		 "font-family": 'Arial, Helvetica, sans-serif',
		 "z-index": "100",
		 "position": "relative"
	 }); 

		 //************************
	 _doc.find('body').animate({scrollTop: 0}, 'fast'); //This is a bug, scroll sometimes doesn't work.
			_doc.find('html').animate({scrollTop: 0}, 'fast'); //Hack to make scroll works
			//************************ 
	 _doc.find("#share_vortex").html(nShareVortex).stop(true, true);
	 _doc.find("#share_vortex").html(nShareVortex).fadeIn("slow").fadeTo(15000, 1) //.fadeOut(1500);

	 $(jetpack.tabs.focused.contentDocument).find("#share_vortex_ul").css({
			/*"border-top":"1px solid #EBEBEB",
			"float": "left",
			"padding":"12px 0",*/
			"padding-bottom":"15px",
			"margin":"0",
			"width":"100%"
	 }); 

		 $(jetpack.tabs.focused.contentDocument).find("#share_vortex_ul li").css({
			"display":"inline",
			"float":"left",
			"list-style-image":"none",
			"list-style-position":"outside",
			"list-style-type":"none",
			"margin":"0 9px",
			"padding-top":"1px"
	 }); 

	 return false;
 
}

function shareVortex(doc){
 $(doc).click(function(){
 var body = jetpack.tabs.focused.contentDocument;
		mytitle = $(jetpack.tabs.focused.contentDocument).find("title").text();
		myurl=jetpack.tabs.focused.url;
 if ($(body).find('#share_vortex').length == 0) {
 $(body).find('body').prepend('<div id = "share_vortex" style = display:none> </div>');
 }
 showShareVortex(body,myurl,mytitle);
 });
}

jetpack.statusBar.append({
 html: '<img style = "cursor:pointer" src="http://www.shareaholic.com/media/images/shareaholic_icon_16x16.png"/>',
 onReady: function(doc){
 var sharevortex= new shareVortex(doc);
 },
 width: 16
});