Created
November 24, 2010 10:38
-
-
Save Takazudo/713459 to your computer and use it in GitHub Desktop.
social tools. see this demo on http://goo.gl/mNZwQ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>socialTools</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> | |
<script src="scripts.js"></script> | |
<script> | |
jQuery(function($) { | |
$('.js-hatebuPoster').hatebuPoster(); | |
$('.js-deliciousPoster').deliciousPoster(); | |
$('.js-buzzPoster').buzzPoster(); | |
$('.js-twitterPoster').twitterPoster(); | |
$('.js-mailToFriend').mailToFriend(); | |
$('.js-facebookPoster').facebookPoster(); | |
$('.js-googleBookmarkPoster').googleBookmarkPoster(); | |
$('.js-mixiDiaryPoster').mixiDiaryPoster(); | |
$('.js-yahooBookmarkPoster').yahooBookmarkPoster(); | |
}); | |
</script> | |
</head> | |
<body> | |
<h1>socialTools</h1> | |
<ul> | |
<li><a class="js-hatebuPoster" href="#">hatebuPoster</a></li> | |
<li><a class="js-deliciousPoster" href="#">deliciousPoster</a></li> | |
<li><a class="js-buzzPoster" href="#">buzzPoster</a></li> | |
<li><a class="js-twitterPoster" href="#">twitterPoster</a></li> | |
<li><a class="js-mailToFriend" href="#">mailToFriend</a></li> | |
<li><a class="js-facebookPoster" href="#">facebookPoster</a></li> | |
<li><a class="js-googleBookmarkPoster" href="#">googleBookmarkPoster</a></li> | |
<li><a class="js-mixiDiaryPoster" href="#" data-mixiposter-body="foobar" data-mixiposter-title="hogehoge">mixiDiaryPoster</a></li> | |
<li><a class="js-yahooBookmarkPoster" href="#">yahooBookmarkPoster</a></li> | |
</ul> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* socialTools | |
* version 0.0.3 (2011/03/13) | |
* author: Takeshi Takatsudo (takazudo[at]gmail.com) | |
* depends: | |
* jQuery 1.5.1 | |
*/ | |
(function($, undefined){ // start $ encapsulation | |
$.fn.hatebuPoster = function(){ | |
$(this).each(function(){ | |
var $el = $(this); | |
var href = encodeURIComponent(location.href); | |
var url = 'http://b.hatena.ne.jp/append?' + href; | |
$el.attr('href', url); | |
$el.attr('target', '_blank'); | |
}); | |
return this; | |
}; | |
$.fn.deliciousPoster = function(){ | |
$(this).each(function(){ | |
var $el = $(this); | |
var href = encodeURIComponent(location.href); | |
var title = encodeURIComponent(document.title); | |
var url = 'http://del.icio.us/post?url=' + href + '&title=' + title + '&v=5&jump=yes'; | |
$el.attr('href', url); | |
$el.attr('target', '_blank'); | |
}); | |
return this; | |
}; | |
$.fn.buzzPoster = function(){ | |
$(this).each(function(){ | |
var $el = $(this); | |
var href = encodeURIComponent(location.href); | |
var title = encodeURIComponent(document.title); | |
var url = 'http://www.google.com/buzz/post?message=' + title + ': ' + href; | |
$el.attr('href', url); | |
$el.attr('target', '_blank'); | |
}); | |
return this; | |
}; | |
$.fn.twitterPoster = function(){ | |
$(this).each(function(){ | |
var $el = $(this); | |
var href = encodeURIComponent(location.href); | |
var title = encodeURIComponent(document.title); | |
var url = 'http://twitter.com/home?status=' + title + ': ' + href; | |
$el.attr('href', url); | |
$el.attr('target', '_blank'); | |
}); | |
return this; | |
}; | |
$.fn.mailToFriend = function(){ | |
$(this).each(function(){ | |
var $el = $(this); | |
var href = encodeURIComponent(location.href); | |
var url = 'mailto:?Body=' + href; | |
$el.attr('href', url); | |
}); | |
return this; | |
}; | |
$.fn.facebookPoster = function(){ | |
$(this).each(function(){ | |
var $el = $(this); | |
var href = encodeURIComponent(location.href); | |
var title = encodeURIComponent(document.title); | |
var url = 'http://www.facebook.com/share.php?u=' + href; | |
$el.attr('href', url); | |
$el.attr('target', '_blank'); | |
}); | |
return this; | |
}; | |
$.fn.googleBookmarkPoster = function(){ | |
$(this).each(function(){ | |
var $el = $(this); | |
var href = encodeURIComponent(location.href); | |
var title = encodeURIComponent(document.title); | |
var url = 'http://www.google.com/bookmarks/mark?op=edit&bkmk=' + href + '&title=' + title; | |
$el.attr('href', url); | |
$el.attr('target', '_blank'); | |
}); | |
return this; | |
}; | |
$.fn.mixiDiaryPoster = function(){ | |
$(this).each(function(){ | |
var $el = $(this); | |
var title = encodeURIComponent($el.data('mixiposter-title')); | |
var body = encodeURIComponent($el.data('mixiposter-body')); | |
var url = 'http://mixi.jp/simplepost/diary?title=' + title + '&body=' + body; | |
$el.attr('href', url); | |
$el.attr('target', '_blank'); | |
}); | |
return this; | |
}; | |
$.fn.yahooBookmarkPoster = function(){ | |
$(this).each(function(){ | |
var $el = $(this); | |
var href = encodeURIComponent(location.href); | |
var title = encodeURIComponent(document.title); | |
var url = 'http://bookmarks.yahoo.co.jp/bookmarklet/showpopup?t=' + title + '&u=' + href + '&opener=bm&ei=UTF-8'; | |
$el.attr('href', url); | |
$el.attr('target', '_blank'); | |
/* | |
release these if you wannna open window using window.open. | |
this can avoid window resizing. | |
$el.click(function(e){ | |
e.preventDefault(); | |
window.open(url,'popup','width=550px,height=480px,status=1,location=0,resizable=1,scrollbars=0,left=100,top=50',0); | |
}); | |
*/ | |
}); | |
return this; | |
}; | |
})(jQuery); // end $ encapsulation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment