This repository was archived by the owner on Mar 19, 2020. It is now read-only.
File tree 2 files changed +57
-0
lines changed 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ # FacebookSDK
2
+ # https://developers.facebook.com/docs/plugins/page-plugin/
3
+ ((d , s , id ) ->
4
+ js = undefined
5
+ fjs = d .getElementsByTagName (s)[0 ]
6
+ if d .getElementById (id)
7
+ return
8
+ js = d .createElement (s)
9
+ js .id = id
10
+ js .src = ' //connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8'
11
+ fjs .parentNode .insertBefore js, fjs
12
+ return
13
+ ) document , ' script' , ' facebook-jssdk'
14
+ # Replace 'facebook-jssdk' with your page id.
15
+ # Compatibility with Turbolinks 5
16
+ (($ ) ->
17
+ fbRoot = undefined
18
+
19
+ saveFacebookRoot = ->
20
+ if $ (' #fb-root' ).length
21
+ fbRoot = $ (' #fb-root' ).detach ()
22
+ return
23
+
24
+ restoreFacebookRoot = ->
25
+ if fbRoot != null
26
+ if $ (' #fb-root' ).length
27
+ $ (' #fb-root' ).replaceWith fbRoot
28
+ else
29
+ $ (' body' ).append fbRoot
30
+ if typeof FB != ' undefined' and FB != null
31
+ # Instance of FacebookSDK
32
+ FB .XFBML .parse ()
33
+ return
34
+
35
+ document .addEventListener ' turbolinks:request-start' , saveFacebookRoot
36
+ document .addEventListener ' turbolinks:load' , restoreFacebookRoot
37
+ return
38
+ ) jQuery
Original file line number Diff line number Diff line change
1
+ twttr_events_bound = false
2
+
3
+ $ ->
4
+ loadTwitterSDK ->
5
+ bindTwitterEventHandlers () unless twttr_events_bound
6
+
7
+ bindTwitterEventHandlers = ->
8
+ $ (document ).on ' turbolinks:load' , renderTweetButtons
9
+ twttr_events_bound = true
10
+
11
+ renderTweetButtons = ->
12
+ $ (' .twitter-share-button' ).each ->
13
+ button = $ (this )
14
+ button .attr (' data-url' , document .location .href ) unless button .data (' url' )?
15
+ button .attr (' data-text' , document .title ) unless button .data (' text' )?
16
+ twttr .widgets .load ()
17
+
18
+ loadTwitterSDK = (callback ) ->
19
+ $ .getScript (' //platform.twitter.com/widgets.js' , callback)
You can’t perform that action at this time.
0 commit comments