mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-16 00:19:50 -05:00
Updates fb and g+ functions to be called on api load, fixes #695
This commit is contained in:
parent
5825b2676b
commit
71294f14b2
2 changed files with 13 additions and 1 deletions
|
@ -74,6 +74,7 @@
|
|||
<script>
|
||||
// Additional JS functions here
|
||||
window.fbAsyncInit = function() {
|
||||
Backbone.Mediator.publish('fbapi-loaded')
|
||||
FB.init({
|
||||
appId : document.location.origin === 'http://localhost:3000' ? '607435142676437' : '148832601965463', // App ID
|
||||
channelUrl : document.location.origin +'/channel.html', // Channel File
|
||||
|
|
|
@ -24,6 +24,8 @@ module.exports = class LadderTabView extends CocoView
|
|||
'click .connect-facebook': 'onConnectFacebook'
|
||||
|
||||
subscriptions:
|
||||
'fbapi-loaded': 'onFacebookAPILoaded'
|
||||
'gapi-loaded': 'onGPlusAPILoaded'
|
||||
'facebook-logged-in': 'onConnectedWithFacebook'
|
||||
|
||||
constructor: (options, @level, @sessions) ->
|
||||
|
@ -31,7 +33,6 @@ module.exports = class LadderTabView extends CocoView
|
|||
@teams = teamDataFromLevel @level
|
||||
@leaderboards = {}
|
||||
@refreshLadder()
|
||||
@checkFriends()
|
||||
|
||||
checkFriends: ->
|
||||
@loadingFacebookFriends = true
|
||||
|
@ -45,8 +46,14 @@ module.exports = class LadderTabView extends CocoView
|
|||
else
|
||||
@gplusSessionStateLoaded()
|
||||
|
||||
apiLoaded: ->
|
||||
return unless @fbAPILoaded and @gplusAPILoaded
|
||||
@checkFriends()
|
||||
# FACEBOOK
|
||||
|
||||
onFacebookAPILoaded: ->
|
||||
@fbAPILoaded = true
|
||||
@apiLoaded()
|
||||
# Connect button pressed
|
||||
|
||||
onConnectFacebook: ->
|
||||
|
@ -80,6 +87,10 @@ module.exports = class LadderTabView extends CocoView
|
|||
|
||||
# GOOGLE PLUS
|
||||
|
||||
onGPlusAPILoaded: ->
|
||||
@gplusAPILoaded = true
|
||||
@apiLoaded()
|
||||
|
||||
gplusSessionStateLoaded: ->
|
||||
if application.gplusHandler.loggedIn
|
||||
@loadingGPlusFriends = true
|
||||
|
|
Loading…
Reference in a new issue