facebook-social_plugins 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
@@ -2,20 +2,38 @@ module FacebookSocialPlugins
|
|
2
2
|
module ScriptHelper
|
3
3
|
|
4
4
|
# can be used inside a js.erb file or similar
|
5
|
-
def
|
6
|
-
selector = options[:selector] || '#
|
5
|
+
def fb_login_and_react options = {:ready => false, :selector => '#fb_login', :success => 'reload();', :failure => ''}
|
6
|
+
selector = options[:selector] || '#fb_login'
|
7
|
+
success = options[:success] || '// on success'
|
8
|
+
failure = options[:failure] || '// on failure'
|
7
9
|
script = %Q{$('#{selector}').click(function() {
|
8
|
-
FB.
|
9
|
-
|
10
|
+
FB.login(function(response) {
|
11
|
+
if (response.authResponse) {
|
12
|
+
#{success}
|
13
|
+
} else {
|
14
|
+
#{failure}
|
15
|
+
}
|
16
|
+
});
|
17
|
+
return false;
|
18
|
+
}#{scope_permissions options[:scope]}
|
10
19
|
}
|
11
20
|
options[:ready] ? wrap_ready(script) : script
|
12
21
|
end
|
13
22
|
|
14
|
-
def
|
15
|
-
selector = options[:selector] || '#
|
23
|
+
def fb_logout_and_react options = {:ready => false, :selector => '#fb_logout', :success => 'reload();', :failure => ''}
|
24
|
+
selector = options[:selector] || '#fb_logout'
|
25
|
+
success = options[:success] || '// on success'
|
26
|
+
failure = options[:failure] || '// on failure'
|
16
27
|
script = %Q{$('#{selector}').click(function() {
|
17
|
-
FB.
|
18
|
-
|
28
|
+
FB.login(function(response) {
|
29
|
+
if (response.authResponse) {
|
30
|
+
#{success}
|
31
|
+
} else {
|
32
|
+
#{failure}
|
33
|
+
}
|
34
|
+
});
|
35
|
+
return false;
|
36
|
+
}
|
19
37
|
}
|
20
38
|
options[:ready] ? wrap_ready(script) : script
|
21
39
|
end
|
@@ -62,6 +80,18 @@ module FacebookSocialPlugins
|
|
62
80
|
|
63
81
|
protected
|
64
82
|
|
83
|
+
def scope_permissions scope
|
84
|
+
scopes = case scope
|
85
|
+
when Array
|
86
|
+
scope.join(',')
|
87
|
+
when String
|
88
|
+
scope
|
89
|
+
else
|
90
|
+
nil
|
91
|
+
end
|
92
|
+
scopes ? ", {scope: '#{scopes}'}" : ''
|
93
|
+
end
|
94
|
+
|
65
95
|
def wrap_ready script
|
66
96
|
%Q{$(function() {
|
67
97
|
#{script}
|
@@ -57,17 +57,17 @@ describe FacebookSocialPlugins::ScriptHelper do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
describe '#
|
60
|
+
describe '#fb_login_and_react' do
|
61
61
|
it 'should work' do
|
62
|
-
output =
|
63
|
-
output.should == "$(function() {\n\t\t$('#fb_login').click(function() { \n\t\tFB.
|
62
|
+
output = fb_login_and_react :ready => true, :selector => '#fb_login', :scope => 'email,user_likes'
|
63
|
+
output.should == "$(function() {\n\t\t$('#fb_login').click(function() { \n\t\tFB.login(function(response) { \n\t\t\tif (response.authResponse) {\n\t\t\t\t// on success\n\t\t\t} else {\n\t\t\t\t// on failure\n\t\t\t}\t\t\t\n\t\t}); \n\t\treturn false;\n }, {scope: 'email,user_likes'}\n\n\t}\n"
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
describe '#
|
67
|
+
describe '#fb_logout_and_react' do
|
68
68
|
it 'should work' do
|
69
|
-
output =
|
70
|
-
output.should == "$(function() {\n\t\t$('#
|
69
|
+
output = fb_logout_and_react :ready => true, :failure => "console.log('failed FB logout');"
|
70
|
+
output.should == "$(function() {\n\t\t$('#fb_logout').click(function() { \n\t\tFB.login(function(response) { \n\t\t\tif (response.authResponse) {\n\t\t\t\t// on success\n\t\t\t} else {\n\t\t\t\tconsole.log('failed FB logout');\n\t\t\t}\t\t\t\n\t\t}); \n\t\treturn false;\n \t}\n\n\t}\n"
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facebook-social_plugins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -200,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
200
200
|
version: '0'
|
201
201
|
segments:
|
202
202
|
- 0
|
203
|
-
hash:
|
203
|
+
hash: -524476929099474942
|
204
204
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
205
|
none: false
|
206
206
|
requirements:
|