classe_social.js
5.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*jslint plusplus:false,white:false,undef: false, rhino: true, onevar: true, evil: true */
/*
Title: Social
Arquivo:
i3geo/classesjs/classe_social.js
Licenca:
GPL2
i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet
Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil
Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com
Este programa é software livre; você pode redistribuí-lo
e/ou modificá-lo sob os termos da Licença Pública Geral
GNU conforme publicada pela Free Software Foundation;
Este programa é distribuído na expectativa de que seja útil,
porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita
de COMERCIABILIDADE OU ADEQUACÃO A UMA FINALIDADE ESPECÍFICA.
Consulte a Licença Pública Geral do GNU para mais detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral do
GNU junto com este programa; se não, escreva para a
Free Software Foundation, Inc., no endereço
59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
*/
if(typeof(i3GEO) === 'undefined'){
var i3GEO = {};
}
/*
Classe: i3GEO.social
Opções de compartilhamento e uso de redes sociais.
*/
i3GEO.social = {
curtirFacebook: function(url,tipo){
if(tipo === "comtotal")
{return "<iframe src='http://www.facebook.com/plugins/like.php?href="+url+"&layout=button_count&show_faces=false&width=160&action=like&colorscheme=light&height=21' scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:160px; height:21px;' allowTransparency='true'></iframe>";}
if(tipo === "semtotal")
{return "<iframe src='http://www.facebook.com/plugins/like.php?href="+url+"&layout=button_count&show_faces=false&action=like&colorscheme=light&height=21' scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:100px; height:21px;' allowTransparency='true'></iframe>";}
},
publicarTwitter: function(url,tipo){
var re = new RegExp("=","g");
url = url.replace(re,'%3d');
if(tipo === "comtotal")
{return '<iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?count=horizontal&via=i3geo&url='+url+'" style="width:100px; height:21px;"></iframe>';}
if(tipo === "semtotal")
{return '<iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?count=none&via=i3geo&url='+url+'" style="width:65px; height:21px;"></iframe>';}
},
/*
Function: compartilhar
Cria os botões de publicar no Twitter e curtir/compartilhar no Facebook
Gera o HTML contendo as tags IMG com os links
Parametro:
id {string} - id do elemento HTML que receberá os links
urlcf {string} - url para o Facebook
urlpt {string} - url para o Twitter
tipo {string} - tipo de botão comtotal|semtotal
locaplic {string} - url onde está o i3Geo. Se não for especificada, será obtida de i3GEO.configura.locaplic
Return:
HTML com os botões
*/
compartilhar: function(id,urlcf,urlpt,tipo,locaplic){
if(!locaplic)
{locaplic = i3GEO.configura.locaplic;}
if(!tipo)
{tipo = "comtotal";}
var onde = $i(id),
tabela = "";
if(tipo === "comtotal")
{tabela += "<table style='width:250px' ><tr>";}
if(tipo === "semtotal")
{tabela += "<table style='width:115px' ><tr>";}
if(onde || id === ""){
if(urlpt !== ""){
tabela += "<td>"+i3GEO.social.publicarTwitter(urlpt,tipo)+"</td>";
}
if(urlcf !== ""){
//tabela += "<td><img style='cursor:pointer' src='"+locaplic+"/imagens/facebook.gif' onclick='javascript:window.open(\"http://www.facebook.com/sharer.php?u="+urlcf+"\")' title='Compartilhar'/></td>";
tabela += "<td>"+i3GEO.social.curtirFacebook(urlcf,tipo)+"</td>";
}
tabela += "</tr></table>";
if(id !== "")
{onde.innerHTML = tabela;}
return tabela;
}
else
{return false;}
},
/*
Function: bookmark
Cria os botões de bookmark em redes sociais
Gera o HTML contendo as tags IMG com os links
Parametro:
link {string} - link que será marcado
locaplic {string} - url onde está o i3Geo. Se não for especificada, será obtida de i3GEO.configura.locaplic
Return:
HTML com os botões
*/
bookmark: function(link,locaplic){
if(!locaplic)
{locaplic = i3GEO.configura.locaplic;}
var ins = "<img style='cursor:pointer' src='"+locaplic+"/imagens/delicious.gif' onclick='javascript:window.open(\"http://del.icio.us/post?url="+link+"\")' title='Delicious'/> ";
ins += "<img style='cursor:pointer' src='"+locaplic+"/imagens/digg.gif' onclick='javascript:window.open(\"http://digg.com/submit/post?url="+link+"\")' title='Digg'/> ";
ins += "<img style='cursor:pointer' src='"+locaplic+"/imagens/facebook.gif' onclick='javascript:window.open(\"http://www.facebook.com/sharer.php?u="+link+"\")' title='Facebook'/> ";
ins += "<img style='cursor:pointer' src='"+locaplic+"/imagens/stumbleupon.gif' onclick='javascript:window.open(\"http://www.stumbleupon.com/submit?url="+link+"\")' title='StumbleUpon'/>";
return ins;
}
};