sharing_tags 0.0.15 → 0.0.16
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.
- checksums.yaml +4 -4
- data/README.md +18 -9
- data/Todo.md +2 -1
- data/app/assets/images/sharing_tags/icons/google.svg +1 -1
- data/app/assets/javascripts/sharing_tags/share/callback.js.coffee +22 -6
- data/app/assets/javascripts/sharing_tags/share/facebook.js.coffee +33 -44
- data/app/assets/javascripts/sharing_tags/share.js.coffee +45 -33
- data/app/assets/stylesheets/sharing_tags/icons.css.sass +6 -4
- data/app/assets/stylesheets/sharing_tags/themes.css.sass +21 -0
- data/app/assets/stylesheets/sharing_tags.css.sass +3 -3
- data/app/views/sharing_tags/buttons.html.slim +1 -1
- data/lib/sharing_tags/version.rb +1 -1
- data/spec/javascripts/fixtures/vkontakte.json +2 -1
- data/spec/javascripts/sharing_tags/share/callback_spec.coffee +58 -2
- data/spec/javascripts/sharing_tags/share/facebook_spec.coffee +19 -19
- data/spec/javascripts/sharing_tags/share_spec.coffee +6 -6
- data/spec/javascripts/sharing_tags/sharing_tags_spec.coffee +42 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4600530fcd767146095f9f85445425d33149df32
|
4
|
+
data.tar.gz: f40753ce534e15ab6efa1881ea45f414b5187bd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2f1289cf0fe412c372cec5869597b89588cc89cbd337b0394b295f17ca4faa2528efaa83b87094b2b3050ff036c7e0321016bb71e97f4c98639bae02e89eb92
|
7
|
+
data.tar.gz: e9232d62c2b0b870d2b4da6197419eb9d5bef8735a081ae806531bd651c50ab8d925f9dd89a3a69591f923c47fed49262f2bc3da5a0773e5561c77577ef38350
|
data/README.md
CHANGED
@@ -36,7 +36,7 @@ For the simplest way of using this gem, add this helper method to head in your v
|
|
36
36
|
```
|
37
37
|
|
38
38
|
|
39
|
-
###
|
39
|
+
### Usage example
|
40
40
|
```ruby
|
41
41
|
# initializers/sharings_tags.rb
|
42
42
|
SharingTags.configure do
|
@@ -108,18 +108,27 @@ You can subscribe to javascript events
|
|
108
108
|
jQuery("body").on "sharing_tags.click_action", ({network, context, target})->
|
109
109
|
# your code
|
110
110
|
|
111
|
-
#
|
112
|
-
jQuery(
|
111
|
+
# on start sharing
|
112
|
+
jQuery(window).on "sharing_tags.before_share", ({network, context, target})->
|
113
|
+
# your code
|
114
|
+
|
115
|
+
# on successful sharing
|
116
|
+
jQuery(window).on "sharing_tags.success_share", ({network, context, target, response})->
|
117
|
+
# your code
|
118
|
+
|
119
|
+
# on cancel sharing
|
120
|
+
jQuery(window).on "sharing_tags.cancel_share", ({network, context, target, response})->
|
113
121
|
# your code
|
114
|
-
```
|
115
122
|
|
116
|
-
|
117
|
-
|
118
|
-
|
123
|
+
# on success or cancel sharing
|
124
|
+
jQuery(window).on "sharing_tags.after_share", ({network, context, target, response})->
|
125
|
+
# your code
|
119
126
|
|
120
|
-
|
121
|
-
|
127
|
+
# on open sharing popup
|
128
|
+
jQuery(window).on "sharing_tags.open_popup", ({network, context, url, popup_window})->
|
129
|
+
# your code
|
122
130
|
|
131
|
+
```
|
123
132
|
|
124
133
|
## Recommendations
|
125
134
|
Facebook sharing images 1200x630 and add mimetype and size
|
data/Todo.md
CHANGED
@@ -13,4 +13,5 @@
|
|
13
13
|
* Update facebook info for fetching urls
|
14
14
|
* Add twitter card settings
|
15
15
|
* Add sharing through Vk js SDK
|
16
|
-
* Generate sass styles only for choiced icons
|
16
|
+
* Generate sass styles only for choiced icons
|
17
|
+
* if return nil in proc try get variable from parent settings
|
@@ -1 +1 @@
|
|
1
|
-
<svg viewBox="
|
1
|
+
<svg viewBox="-1 -1 36 36" xmlns="http://www.w3.org/2000/svg"><path class="gl-sharing-tags-icon-fill sharing-tags-icon-fill" d="M17.63 34.085c9.394 0 17.008-7.615 17.008-17.008C34.638 7.684 27.024.07 17.63.07 8.237.07.622 7.684.622 17.077S8.237 34.085 17.63 34.085"/><path class="gl-sharing-tags-icon-in sharing-tags-icon-in" d="M25.825 15.835h-2.05v-2.05h-1.65v2.05h-2.05v1.65h2.05v2.05h1.65v-2.05h2.05v-1.65zM18.16 18.32c-.475-.338-1.385-1.158-1.385-1.64 0-.565.162-.842 1.01-1.506.872-.682 1.49-1.64 1.49-2.75 0-1.326-.59-2.617-1.7-3.044h1.67l1.18-.85h-5.268c-2.36 0-4.583 1.788-4.583 3.86 0 2.117 1.61 3.827 4.012 3.827.167 0 .33-.004.488-.015-.156.298-.268.635-.268.983 0 .59.317 1.066.717 1.456-.302 0-.595.01-.912.01-2.923 0-5.175 1.863-5.175 3.795 0 1.902 2.468 3.092 5.393 3.092 3.334 0 5.176-1.89 5.176-3.794 0-1.526-.45-2.44-1.842-3.423zm-2.812-2.64c-1.357-.04-2.647-1.52-2.88-3.3-.236-1.783.675-3.146 2.032-3.106 1.356.04 2.646 1.47 2.88 3.252.234 1.782-.675 3.194-2.032 3.153zm-.532 9.015c-2.022 0-3.482-1.28-3.482-2.817 0-1.507 1.812-2.76 3.833-2.74.472.006.912.082 1.31.21 1.098.765 1.885 1.195 2.107 2.065.042.177.065.358.065.543 0 1.538-.99 2.74-3.835 2.74z"/></svg>
|
@@ -3,14 +3,30 @@ class @SharingTags.Share.Callback
|
|
3
3
|
@network = @share.network
|
4
4
|
@context = @share.context
|
5
5
|
|
6
|
-
|
7
|
-
@trigger("
|
6
|
+
before_share: (provider)=>
|
7
|
+
@trigger("before_share", provider: provider)
|
8
8
|
|
9
|
-
|
10
|
-
@trigger("
|
9
|
+
success_share: (response)->
|
10
|
+
@trigger("success_share", response: response)
|
11
11
|
|
12
|
-
|
12
|
+
cancel_share: (response)->
|
13
|
+
@trigger("cancel_share", response: response)
|
14
|
+
|
15
|
+
after_share: (response)->
|
16
|
+
@trigger("after_share", response: response)
|
17
|
+
|
18
|
+
open_popup: (open_url, popup_window)=>
|
13
19
|
@trigger("open_popup", url: open_url, popup_window: popup_window)
|
14
20
|
|
15
21
|
trigger: (trigger_name, params...)->
|
16
|
-
|
22
|
+
trigger_params = @_share_params(params)
|
23
|
+
jQuery?(window).trigger("sharing_tags.#{trigger_name}", [trigger_params])
|
24
|
+
|
25
|
+
_share_params: (params)->
|
26
|
+
properties = {
|
27
|
+
url: @share.url
|
28
|
+
network: @network
|
29
|
+
context: @context
|
30
|
+
}
|
31
|
+
params[key] = val for key, val of properties
|
32
|
+
params
|
@@ -18,29 +18,31 @@ class @SharingTags.FacebookShare extends @SharingTags.Share
|
|
18
18
|
# facebook locales support (https://www.facebook.com/translations/FacebookLocales.xml)
|
19
19
|
#
|
20
20
|
@init: (locale="en_US")->
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
dataType: "script"
|
29
|
-
cache: true
|
30
|
-
)
|
31
|
-
# `(function(d, s, id){
|
32
|
-
# var js, fjs = d.getElementsByTagName(s)[0];
|
33
|
-
# if (d.getElementById(id)) {return;}
|
34
|
-
# js = d.createElement(s); js.id = id;
|
35
|
-
# js.src = "http://connect.facebook.net/" + sdk_url;
|
36
|
-
# fjs.parentNode.insertBefore(js, fjs);
|
37
|
-
# }(document, 'script', 'facebook-jssdk'));`
|
21
|
+
return if FB?
|
22
|
+
sdk_url = locale + (if @debug then "/sdk/debug.js" else "/all.js")
|
23
|
+
jQuery.ajax(
|
24
|
+
url: "//connect.facebook.net/#{sdk_url}"
|
25
|
+
dataType: "script"
|
26
|
+
cache: true
|
27
|
+
)
|
38
28
|
|
39
29
|
share: (provider = @provider)->
|
40
|
-
@callback.
|
30
|
+
@callback.before_share(provider)
|
41
31
|
@["_#{provider}"]()
|
42
32
|
@
|
43
33
|
|
34
|
+
detect_provider: ->
|
35
|
+
provider =
|
36
|
+
if @_user_agent().match('CriOS')
|
37
|
+
"sharer"
|
38
|
+
else if @app_id
|
39
|
+
if @return_url then "dialog"
|
40
|
+
else "fb_ui_feed"
|
41
|
+
else
|
42
|
+
"sharer"
|
43
|
+
@constructor._debug("Facebook#detect_provider", provider)
|
44
|
+
provider
|
45
|
+
|
44
46
|
_sharer: ->
|
45
47
|
@_assert_vars "url"
|
46
48
|
@open_popup("http://www.facebook.com/sharer.php", u: @url)
|
@@ -48,15 +50,10 @@ class @SharingTags.FacebookShare extends @SharingTags.Share
|
|
48
50
|
# https://developers.facebook.com/docs/javascript/reference/FB.ui
|
49
51
|
_fb_ui: =>
|
50
52
|
@_assert_vars "url", "app_id"
|
51
|
-
FB
|
53
|
+
FB.ui(
|
52
54
|
method: 'share',
|
53
55
|
href: @url,
|
54
|
-
|
55
|
-
@callback.after_sharing(response)
|
56
|
-
# if response && !response.error_code
|
57
|
-
# @_after_callback(response)
|
58
|
-
# else
|
59
|
-
# # another callback
|
56
|
+
@_fb_ui_callback
|
60
57
|
)
|
61
58
|
|
62
59
|
_dialog: (display = 'page')->
|
@@ -70,8 +67,7 @@ class @SharingTags.FacebookShare extends @SharingTags.Share
|
|
70
67
|
FB.ui(
|
71
68
|
method: 'stream.share',
|
72
69
|
u: @url
|
73
|
-
|
74
|
-
@callback.after_sharing(response)
|
70
|
+
@_fb_ui_callback
|
75
71
|
)
|
76
72
|
|
77
73
|
# @note: iphone facebook browser - doesn't redirect to page after sharing
|
@@ -83,24 +79,17 @@ class @SharingTags.FacebookShare extends @SharingTags.Share
|
|
83
79
|
@_prepare_params(
|
84
80
|
method: 'feed'
|
85
81
|
link: @url
|
86
|
-
name: @
|
87
|
-
caption: @
|
88
|
-
description: @description
|
82
|
+
name: @title # The name of the link attachment.
|
83
|
+
caption: @caption # The caption of the link (appears beneath the link name). If not specified, this field is automatically populated with the URL of the link.
|
84
|
+
description: @description # The description of the link (appears beneath the link caption). If not specified, this field is automatically populated by information scraped from the link, typically the title of the page.
|
89
85
|
picture: @image
|
90
86
|
redirect_uri: @return_url
|
91
|
-
),
|
92
|
-
(response)=>
|
93
|
-
@callback.after_sharing(response)
|
87
|
+
), @_fb_ui_callback
|
94
88
|
)
|
95
89
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
else "fb_ui_feed"
|
103
|
-
else
|
104
|
-
"sharer"
|
105
|
-
@constructor._debug("Facebook#detect_provider", provider)
|
106
|
-
provider
|
90
|
+
_fb_ui_callback: (response)=>
|
91
|
+
@callback.after_share(response)
|
92
|
+
if response && !response.error_code
|
93
|
+
@callback.success_share(response)
|
94
|
+
else
|
95
|
+
@callback.cancel_share(response)
|
@@ -4,7 +4,8 @@ class @SharingTags
|
|
4
4
|
|
5
5
|
@debug: false
|
6
6
|
|
7
|
-
@share: (network, attributes)->
|
7
|
+
@share: (network, attributes = {})->
|
8
|
+
attributes.network = network
|
8
9
|
SharingTags.Share[network]?(attributes)
|
9
10
|
|
10
11
|
class @Error extends Error
|
@@ -12,66 +13,78 @@ class @SharingTags
|
|
12
13
|
|
13
14
|
class @Share
|
14
15
|
|
15
|
-
@line: ({title, url}) ->
|
16
|
+
@line: ({title, url, context, network}) ->
|
16
17
|
message = "#{title} #{url}"
|
17
18
|
@share_popup(
|
18
|
-
|
19
|
-
url: url,
|
19
|
+
url: url
|
20
20
|
popup_url: "http://line.me/R/msg/text/?#{encodeURIComponent(message)}"
|
21
21
|
popup_params: null
|
22
|
+
network: network
|
23
|
+
context: context
|
22
24
|
)
|
23
25
|
|
24
|
-
@facebook: ({url, app_id, caption, title, description, image, return_url, provider}) ->
|
26
|
+
@facebook: ({url, app_id, caption, title, description, image, return_url, provider, network}) ->
|
25
27
|
@_debug("Facebook sharing", arguments[0])
|
26
28
|
(new SharingTags.FacebookShare(arguments[0])).share()
|
27
29
|
|
28
|
-
@twitter: ({url, title}) ->
|
30
|
+
@twitter: ({url, title, context, network}) ->
|
29
31
|
@share_popup(
|
30
|
-
network: "twitter"
|
31
32
|
url: url
|
32
33
|
popup_url: "http://twitter.com/intent/tweet"
|
33
34
|
popup_params:
|
34
35
|
text: title
|
35
36
|
url: url
|
37
|
+
network: network
|
38
|
+
context: context
|
36
39
|
)
|
37
40
|
|
38
|
-
@vkontakte: ({title, url, description, image}) ->
|
41
|
+
@vkontakte: ({title, url, description, image, context, network}) ->
|
39
42
|
@share_popup(
|
40
|
-
|
41
|
-
|
42
|
-
popup_url: "http://vk.com/share.php",
|
43
|
+
url: url
|
44
|
+
popup_url: "http://vk.com/share.php"
|
43
45
|
popup_params:
|
44
|
-
url: url
|
45
|
-
title: title
|
46
|
-
description: description
|
46
|
+
url: url
|
47
|
+
title: title
|
48
|
+
description: description
|
47
49
|
image: image
|
50
|
+
network: network
|
51
|
+
context: context
|
48
52
|
)
|
49
53
|
|
50
|
-
@google: ({url}) ->
|
51
|
-
@share_popup(
|
54
|
+
@google: ({url, context, network}) ->
|
55
|
+
@share_popup(
|
56
|
+
url: url
|
57
|
+
popup_url: "https://plus.google.com/share"
|
58
|
+
popup_params: {url: url}
|
59
|
+
network: network
|
60
|
+
context: context
|
61
|
+
)
|
52
62
|
|
53
|
-
@odnoklassniki: ({url, description}) ->
|
63
|
+
@odnoklassniki: ({url, description, context, network}) ->
|
54
64
|
@share_popup(
|
55
|
-
|
56
|
-
|
57
|
-
popup_url: "http://www.odnoklassniki.ru/dk",
|
65
|
+
url: url
|
66
|
+
popup_url: "http://www.odnoklassniki.ru/dk"
|
58
67
|
popup_params: {'st._surl': url, 'st.comments': description, 'st.cmd': 'addShare', 'st.s': 1}
|
68
|
+
network: network
|
69
|
+
context: context
|
59
70
|
)
|
60
71
|
|
61
|
-
@mailru: ({url, title, image, description}) ->
|
72
|
+
@mailru: ({url, title, image, description, context, network}) ->
|
62
73
|
@share_popup(
|
63
|
-
|
64
|
-
|
65
|
-
popup_url: 'http://connect.mail.ru/share',
|
74
|
+
url: url
|
75
|
+
popup_url: 'http://connect.mail.ru/share'
|
66
76
|
popup_params: {url: url, title: title, description: description, imageurl: image}
|
77
|
+
network: network
|
78
|
+
context: context
|
67
79
|
)
|
68
80
|
|
69
|
-
@linkedin: ({url, title, description}) ->
|
81
|
+
@linkedin: ({url, title, description, context, network}) ->
|
70
82
|
@share_popup(
|
71
|
-
|
72
|
-
|
73
|
-
popup_url: 'http://www.linkedin.com/shareArticle',
|
83
|
+
url: url
|
84
|
+
popup_url: 'http://www.linkedin.com/shareArticle'
|
74
85
|
popup_params: {mini: true, url: url, title: title, summary: description}
|
86
|
+
network: network
|
87
|
+
context: context
|
75
88
|
)
|
76
89
|
|
77
90
|
@share_popup: ({network, url, popup_url, popup_params})->
|
@@ -85,10 +98,8 @@ class @SharingTags
|
|
85
98
|
constructor: ({@network, @context, @url, @title, @description, @image})->
|
86
99
|
@_assert_vars 'url'
|
87
100
|
@callback = new SharingTags.Share.Callback(@)
|
88
|
-
|
89
101
|
@constructor._debug("Init sharing #{@network}", {@url, @title, @description})
|
90
102
|
|
91
|
-
|
92
103
|
open_popup: (api_url, params, popup_attrs = 'width=550,height=420,toolbar=no')->
|
93
104
|
share_url = if params then "#{api_url}?#{$.param(params)}" else api_url
|
94
105
|
|
@@ -100,7 +111,7 @@ class @SharingTags
|
|
100
111
|
# when "vkontakte" then "width=550,height=420,toolbar=no"
|
101
112
|
|
102
113
|
share_window = window.open share_url, 'Sharing', popup_attrs
|
103
|
-
@callback.
|
114
|
+
@callback.open_popup(share_url, share_window)
|
104
115
|
|
105
116
|
clearInterval(@interval)
|
106
117
|
iteration = 0
|
@@ -108,12 +119,13 @@ class @SharingTags
|
|
108
119
|
iteration++
|
109
120
|
if @_open_popup_check(share_url, share_window, iteration)
|
110
121
|
clearInterval @interval
|
111
|
-
@callback.
|
122
|
+
@callback.success_share()
|
123
|
+
@callback.after_share()
|
112
124
|
), 500)
|
113
125
|
|
114
126
|
_open_popup_check: (share_url, share_window, iteration)=>
|
115
127
|
# console.log("check desktop sharing", share_url, share_window, iteration)
|
116
|
-
share_window?.closed || iteration >=
|
128
|
+
share_window?.closed || iteration >= 10
|
117
129
|
|
118
130
|
_assert_vars: (vars...)->
|
119
131
|
for var_name in vars
|
@@ -20,13 +20,11 @@
|
|
20
20
|
.sharing-tags-icon-in
|
21
21
|
fill-rule: evenodd
|
22
22
|
fill-opacity: 1
|
23
|
-
fill-rule: evenodd
|
24
23
|
|
25
24
|
.sharing-tags-icon-fill
|
26
25
|
stroke-linecap: butt
|
27
26
|
stroke-linejoin: miter
|
28
27
|
stroke-miterlimit: 2
|
29
|
-
stroke-width: 2
|
30
28
|
stroke-opacity: 1
|
31
29
|
|
32
30
|
// white
|
@@ -62,18 +60,22 @@
|
|
62
60
|
|
63
61
|
|
64
62
|
|
65
|
-
|
66
|
-
.fb-sharing-tags-icon-in
|
67
63
|
.fb-sharing-tags-icon-fill
|
64
|
+
stroke-width: 2
|
65
|
+
.fb-sharing-tags-icon-in
|
68
66
|
|
69
67
|
.od-sharing-tags-icon-fill
|
68
|
+
stroke-width: 2
|
70
69
|
.od-sharing-tags-icon-in
|
71
70
|
|
72
71
|
.vk-sharing-tags-icon-fill
|
72
|
+
stroke-width: 2
|
73
73
|
.vk-sharing-tags-icon-in
|
74
74
|
|
75
75
|
.tw-sharing-tags-icon-in
|
76
|
+
|
76
77
|
.tw-sharing-tags-icon-fill
|
78
|
+
stroke-width: 2
|
77
79
|
|
78
80
|
.li-sharing-tags-icon-fill
|
79
81
|
stroke-width: 1
|
@@ -1,3 +1,23 @@
|
|
1
|
+
|
2
|
+
%sharing_tags-white-theme
|
3
|
+
.sharing_tags-buttons__icon
|
4
|
+
.sharing-tags-icon-in
|
5
|
+
fill: #ffffff
|
6
|
+
stroke: none
|
7
|
+
|
8
|
+
.sharing-tags-icon-fill
|
9
|
+
fill: none
|
10
|
+
stroke: #ffffff
|
11
|
+
|
12
|
+
.sharing_tags-buttons__icon:hover
|
13
|
+
.sharing-tags-icon-in
|
14
|
+
fill: #4A4A4A
|
15
|
+
|
16
|
+
.sharing-tags-icon-fill
|
17
|
+
fill: #ffffff
|
18
|
+
stroke: none
|
19
|
+
|
20
|
+
|
1
21
|
%sharing_tags-squared-theme
|
2
22
|
.sharing_tags-buttons__item
|
3
23
|
border: 1px solid
|
@@ -23,6 +43,7 @@
|
|
23
43
|
.sharing-tags-icon-in
|
24
44
|
fill: #FFFFFF
|
25
45
|
|
46
|
+
|
26
47
|
//.sharing_tags-buttons__item:hover
|
27
48
|
background-color: #FFFFFF
|
28
49
|
border: 1px solid
|
@@ -1,3 +1,3 @@
|
|
1
|
-
ul.sharing_tags-buttons class="sharing_tags-buttons__#{context.name} #{options[:class]}"
|
1
|
+
ul.sharing_tags-buttons class="sharing_tags-buttons__#{context.name} #{options[:class]}" role="sharing_tags_share_#{context.name}"
|
2
2
|
- networks.each do |network|
|
3
3
|
li.sharing_tags-buttons__item class="sharing_tags-#{network}_buttons__item"= render "sharing_tags/button/#{network}"
|
data/lib/sharing_tags/version.rb
CHANGED
@@ -11,11 +11,67 @@ describe "SharingTags.Share.Callback", ->
|
|
11
11
|
beforeEach ->
|
12
12
|
@fb_fixture = fixture.load("facebook.json")[0]
|
13
13
|
@fb = @fb_fixture.fb_ui
|
14
|
+
@fb.context = "callback context"
|
14
15
|
@share = new SharingTags.Share @fb
|
15
16
|
@callback = new subject(@share)
|
16
17
|
|
17
|
-
|
18
18
|
it "expect get network and context attr from share", ->
|
19
19
|
expect( @callback.network ).toBe "facebook"
|
20
20
|
|
21
|
-
|
21
|
+
it "expect get context and context attr from share", ->
|
22
|
+
expect( @callback.context ).toBe "callback context"
|
23
|
+
|
24
|
+
describe "callbacks", ->
|
25
|
+
beforeEach ->
|
26
|
+
spyOn(@callback, "trigger")
|
27
|
+
@response = jasmine.createSpy('response')
|
28
|
+
|
29
|
+
it "#before_share", ->
|
30
|
+
@callback.before_share("auto")
|
31
|
+
expect(@callback.trigger).toHaveBeenCalledWith(
|
32
|
+
"before_share", jasmine.objectContaining(provider: "auto")
|
33
|
+
)
|
34
|
+
|
35
|
+
it "#success_share", ->
|
36
|
+
@callback.success_share(@response)
|
37
|
+
expect(@callback.trigger).toHaveBeenCalledWith(
|
38
|
+
"success_share", jasmine.objectContaining(response: @response)
|
39
|
+
)
|
40
|
+
|
41
|
+
it "#cancel_share", ->
|
42
|
+
@callback.cancel_share(@response)
|
43
|
+
expect(@callback.trigger).toHaveBeenCalledWith(
|
44
|
+
"cancel_share", jasmine.objectContaining(response: @response)
|
45
|
+
)
|
46
|
+
|
47
|
+
it "#after_share", ->
|
48
|
+
@callback.after_share(@response)
|
49
|
+
expect(@callback.trigger).toHaveBeenCalledWith(
|
50
|
+
"after_share", jasmine.objectContaining(response: @response)
|
51
|
+
)
|
52
|
+
|
53
|
+
it "open_popup", ->
|
54
|
+
window_obj = jasmine.createSpy('window')
|
55
|
+
@callback.open_popup("url", window_obj)
|
56
|
+
expect(@callback.trigger).toHaveBeenCalledWith(
|
57
|
+
"open_popup", jasmine.objectContaining(
|
58
|
+
url: "url", popup_window: window_obj
|
59
|
+
)
|
60
|
+
)
|
61
|
+
|
62
|
+
describe "#trigger", ->
|
63
|
+
beforeEach ->
|
64
|
+
@original_jquery = window.jQuery
|
65
|
+
# spyOn(jQuery(window), "trigger")
|
66
|
+
window.jQuery = jasmine.createSpyObj('jQuery', ['trigger'])
|
67
|
+
|
68
|
+
afterEach ->
|
69
|
+
window.jQuery = @original_jquery
|
70
|
+
|
71
|
+
xit "expect valid trigger params", ->
|
72
|
+
@callback.trigger("callback_name", {param1: "val1", param2: "val2"})
|
73
|
+
expect(jQuery(window).trigger).toHaveBeenCalledWith(
|
74
|
+
"sharing_tags.callback_name", jasmine.objectContaining(
|
75
|
+
param1: "val1", param2: "val2"
|
76
|
+
)
|
77
|
+
)
|
@@ -84,8 +84,8 @@ describe "SharingTags.FacebookShare", ->
|
|
84
84
|
@fb = @fb_fixture.full
|
85
85
|
@share = new subject(@fb)
|
86
86
|
spyOn(@share, "_open_popup_check").andCallThrough()
|
87
|
-
spyOn(@share.callback, "
|
88
|
-
spyOn(@share.callback, "
|
87
|
+
spyOn(@share.callback, "after_share").andCallThrough()
|
88
|
+
spyOn(@share.callback, "before_share").andCallThrough()
|
89
89
|
spyOn(@share.callback, "trigger")
|
90
90
|
jasmine.Clock.useMock()
|
91
91
|
window.FB = jasmine.createSpyObj('FB', ['ui', 'init'])
|
@@ -93,36 +93,36 @@ describe "SharingTags.FacebookShare", ->
|
|
93
93
|
afterEach ->
|
94
94
|
delete window.FB
|
95
95
|
|
96
|
-
it "expect called
|
96
|
+
it "expect called before_share on start sharing", ->
|
97
97
|
@share.share('fb_ui')
|
98
|
-
expect(@share.callback.
|
98
|
+
expect(@share.callback.before_share).toHaveBeenCalled()
|
99
99
|
expect(@share.callback.trigger).toHaveBeenCalled()
|
100
|
-
expect(@share.callback.trigger).toHaveBeenCalledWith("
|
100
|
+
expect(@share.callback.trigger).toHaveBeenCalledWith("before_share", provider: "fb_ui")
|
101
101
|
|
102
102
|
it "expect calling callback for fb_ui", ->
|
103
103
|
FB.ui.andCallFake (params, callback)-> callback()
|
104
104
|
|
105
105
|
@share.share("fb_ui")
|
106
|
-
expect(@share.callback.
|
107
|
-
expect(@share.callback.trigger).toHaveBeenCalledWith("
|
106
|
+
expect(@share.callback.after_share).toHaveBeenCalled()
|
107
|
+
expect(@share.callback.trigger).toHaveBeenCalledWith("before_share", provider: "fb_ui")
|
108
108
|
|
109
109
|
it "expect calling callback for sharer", ->
|
110
110
|
@share.share('sharer')
|
111
111
|
jasmine.Clock.tick(700)
|
112
112
|
expect(@share._open_popup_check).toHaveBeenCalled()
|
113
113
|
expect(@share.callback.trigger).toHaveBeenCalledWith("open_popup", url: jasmine.any(String), popup_window: jasmine.any(Object))
|
114
|
-
expect(@share.callback.
|
114
|
+
expect(@share.callback.after_share).not.toHaveBeenCalled()
|
115
115
|
|
116
|
-
jasmine.Clock.tick(500 *
|
117
|
-
expect(@share.callback.
|
116
|
+
jasmine.Clock.tick(500 * 10)
|
117
|
+
expect(@share.callback.after_share).toHaveBeenCalled()
|
118
118
|
|
119
|
-
it "expect calling callback for dialog
|
119
|
+
it "expect calling callback for dialog 5sec", ->
|
120
120
|
@share.share('dialog')
|
121
|
-
expect(@share.callback.
|
122
|
-
expect(@share.callback.trigger).toHaveBeenCalledWith("
|
121
|
+
expect(@share.callback.after_share).not.toHaveBeenCalled()
|
122
|
+
expect(@share.callback.trigger).toHaveBeenCalledWith("before_share", provider: "dialog")
|
123
123
|
|
124
|
-
jasmine.Clock.tick(500 *
|
125
|
-
expect(@share.callback.
|
124
|
+
jasmine.Clock.tick(500 * 10)
|
125
|
+
expect(@share.callback.after_share).toHaveBeenCalled()
|
126
126
|
expect(@share.callback.trigger).toHaveBeenCalledWith("open_popup", url: jasmine.any(String), popup_window: jasmine.any(Object))
|
127
127
|
|
128
128
|
describe "#_sharer", ->
|
@@ -213,8 +213,8 @@ describe "SharingTags.FacebookShare", ->
|
|
213
213
|
expect(FB.ui).toHaveBeenCalled()
|
214
214
|
expect(FB.ui).toHaveBeenCalledWith(
|
215
215
|
jasmine.objectContaining(
|
216
|
-
link: @fb.url, method: 'feed', caption: @fb.
|
217
|
-
description: @fb.description, name: @fb.
|
216
|
+
link: @fb.url, method: 'feed', caption: @fb.caption,
|
217
|
+
description: @fb.description, name: @fb.title,
|
218
218
|
picture: @fb.image, redirect_uri: @fb.return_url
|
219
219
|
),
|
220
220
|
jasmine.any(Function)
|
@@ -227,8 +227,8 @@ describe "SharingTags.FacebookShare", ->
|
|
227
227
|
expect(FB.ui).toHaveBeenCalled()
|
228
228
|
expect(FB.ui).toHaveBeenCalledWith(
|
229
229
|
jasmine.objectContaining(
|
230
|
-
link: @fb.url, method: 'feed', caption: @fb.
|
231
|
-
name: @fb.
|
230
|
+
link: @fb.url, method: 'feed', caption: @fb.caption,
|
231
|
+
name: @fb.title, picture: @fb.image
|
232
232
|
),
|
233
233
|
jasmine.any(Function)
|
234
234
|
)
|
@@ -81,7 +81,7 @@ describe "SharingTags.Share", ->
|
|
81
81
|
)
|
82
82
|
|
83
83
|
it "expect init new class with params", ->
|
84
|
-
expect(@share.network).toBe("twitter")
|
84
|
+
# expect(@share.network).toBe("twitter")
|
85
85
|
expect(@share.url).toBe(@f.url)
|
86
86
|
# expect(@share.title).toBe(@f.title)
|
87
87
|
|
@@ -100,7 +100,7 @@ describe "SharingTags.Share", ->
|
|
100
100
|
)
|
101
101
|
|
102
102
|
it "expect init new class with params", ->
|
103
|
-
expect(@share.network).toBe("google")
|
103
|
+
# expect(@share.network).toBe("google")
|
104
104
|
expect(@share.url).toBe(@f.url)
|
105
105
|
|
106
106
|
describe "odnoklassniki", ->
|
@@ -122,7 +122,7 @@ describe "SharingTags.Share", ->
|
|
122
122
|
)
|
123
123
|
|
124
124
|
it "expect init new class with params", ->
|
125
|
-
expect(@share.network).toBe("odnoklassniki")
|
125
|
+
# expect(@share.network).toBe("odnoklassniki")
|
126
126
|
expect(@share.url).toBe(@f.url)
|
127
127
|
|
128
128
|
describe "mailru", ->
|
@@ -144,7 +144,7 @@ describe "SharingTags.Share", ->
|
|
144
144
|
)
|
145
145
|
|
146
146
|
it "expect init new class with params", ->
|
147
|
-
expect(@share.network).toBe("mailru")
|
147
|
+
# expect(@share.network).toBe("mailru")
|
148
148
|
expect(@share.url).toBe(@f.url)
|
149
149
|
|
150
150
|
describe "linkedin", ->
|
@@ -166,7 +166,7 @@ describe "SharingTags.Share", ->
|
|
166
166
|
)
|
167
167
|
|
168
168
|
it "expect init new class with params", ->
|
169
|
-
expect(@share.network).toBe("linkedin")
|
169
|
+
# expect(@share.network).toBe("linkedin")
|
170
170
|
expect(@share.url).toBe(@f.url)
|
171
171
|
|
172
172
|
describe "line", ->
|
@@ -185,7 +185,7 @@ describe "SharingTags.Share", ->
|
|
185
185
|
)
|
186
186
|
|
187
187
|
it "expect init new class with params", ->
|
188
|
-
expect(@share.network).toBe("line")
|
188
|
+
# expect(@share.network).toBe("line")
|
189
189
|
expect(@share.url).toBe(@f.url)
|
190
190
|
|
191
191
|
|
@@ -21,7 +21,48 @@ describe "SharingTags.share", ->
|
|
21
21
|
beforeEach ->
|
22
22
|
spyOn(SharingTags.Share, "vkontakte")
|
23
23
|
|
24
|
-
it "expect
|
24
|
+
it "expect calling", ->
|
25
25
|
SharingTags.share('vkontakte')
|
26
26
|
expect(SharingTags.Share.vkontakte).toHaveBeenCalled()
|
27
27
|
|
28
|
+
describe "twitter", ->
|
29
|
+
beforeEach ->
|
30
|
+
spyOn(SharingTags.Share, "twitter")
|
31
|
+
|
32
|
+
it "expect calling", ->
|
33
|
+
SharingTags.share('twitter')
|
34
|
+
expect(SharingTags.Share.twitter).toHaveBeenCalled()
|
35
|
+
|
36
|
+
describe "line", ->
|
37
|
+
beforeEach ->
|
38
|
+
spyOn(SharingTags.Share, "line")
|
39
|
+
|
40
|
+
it "expect calling", ->
|
41
|
+
SharingTags.share('line')
|
42
|
+
expect(SharingTags.Share.line).toHaveBeenCalled()
|
43
|
+
|
44
|
+
describe "google", ->
|
45
|
+
beforeEach ->
|
46
|
+
spyOn(SharingTags.Share, "google")
|
47
|
+
|
48
|
+
it "expect calling", ->
|
49
|
+
SharingTags.share('google')
|
50
|
+
expect(SharingTags.Share.google).toHaveBeenCalled()
|
51
|
+
|
52
|
+
describe "odnoklassniki", ->
|
53
|
+
beforeEach ->
|
54
|
+
spyOn(SharingTags.Share, "odnoklassniki")
|
55
|
+
|
56
|
+
it "expect calling", ->
|
57
|
+
SharingTags.share('odnoklassniki')
|
58
|
+
expect(SharingTags.Share.odnoklassniki).toHaveBeenCalled()
|
59
|
+
|
60
|
+
|
61
|
+
describe "linkedin", ->
|
62
|
+
beforeEach ->
|
63
|
+
spyOn(SharingTags.Share, "linkedin")
|
64
|
+
|
65
|
+
it "expect calling", ->
|
66
|
+
SharingTags.share('linkedin')
|
67
|
+
expect(SharingTags.Share.linkedin).toHaveBeenCalled()
|
68
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sharing_tags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anatoliy Kovalchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|