-
-
Save anderson-mota/6415894 to your computer and use it in GitHub Desktop.
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
/** | |
* Referências caso necessário | |
* http://copacocacola.terra.com.br/infografico/dribles/info-dribles/js/info.js | |
*/ | |
var facebook = (function() { | |
var share =function(data, type) { | |
type = type ? type : 'feed'; | |
FB.ui({ | |
method: type, | |
message: data.message, | |
name: data.title, | |
picture: data.image, | |
description: data.content, | |
link: data.url, | |
actions: [{ | |
name: data.title, | |
link: data.url | |
}], | |
user_message_prompt: data.title | |
}, | |
function(response) { | |
// cat your reponse | |
}); | |
}, | |
getFriends = function() { | |
// get all friends | |
FB.api('me/friends', {fields: 'username, name, id, first_name'}, function(friends) { | |
var friends_list = friends.data; | |
var total = friends_list.length; | |
var html = ""; | |
var fb_f = getPhoto; | |
// substituir por template handlebars | |
for(var i = 0; i < total; i++) { | |
html += "<a href='#' class='select-friend' data-id='"+ | |
friends_list[i].id +"' data-pos='" + i + "'" + | |
"data-name='" + friends_list[i].first_name + | |
"' ><img src='" + | |
fb_f(friends_list[i].id) + | |
"' title='" + friends_list[i].name + | |
"'/> <br> " + friends_list[i].first_name +" <span class='select-friend-mask'> </span> </a>"; | |
} | |
// codigo do scrollbar | |
$('.box-select-friends').html(html).mCustomScrollbar(); | |
setTimeout(function() { | |
$('.box-select-friends').mCustomScrollbar("update"); | |
}, 2000); | |
}); | |
}, | |
getPhoto = function(id, w, h) { | |
if (w && h) { | |
return 'https://graph.facebook.com/' + id + '/picture?width=' + w + '&height=' + h; | |
} | |
return 'https://graph.facebook.com/' + id + '/picture'; | |
}; | |
return { | |
share: share, | |
getFriends: getFriends, | |
getPhoto: getPhoto | |
}; | |
})(); |
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
<script> | |
$(function() { | |
$('.share-button').on('click', function(e) { | |
e.preventDefault(); | |
var $self = $(this), | |
data = { | |
title : $self.data('title'), | |
url : 'http://garoto.com.br/pascoagaroto', | |
content : $self.data('content') | |
image : 'image url' | |
}; | |
facebook.share(data); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment