make userlike button work with sign in and out
This commit is contained in:
parent
72f323bce4
commit
a7bc36cba7
|
@ -54,17 +54,20 @@ App = Ember.Application.extend(Ember.Evented,
|
|||
|
||||
@on 'user:refreshed', (user) ->
|
||||
Travis.onUserUpdate(user)
|
||||
Travis.setupUserlike(user)
|
||||
|
||||
@on 'user:synced', (user) ->
|
||||
Travis.onUserUpdate(user)
|
||||
|
||||
@on 'user:signed_out', () ->
|
||||
Travis.removeUserlike()
|
||||
|
||||
currentDate: ->
|
||||
new Date()
|
||||
|
||||
onUserUpdate: (user) ->
|
||||
if config.pro
|
||||
@identifyCustomer(user)
|
||||
@setupUserlike(user)
|
||||
|
||||
@subscribePusher(user)
|
||||
|
||||
|
@ -83,7 +86,7 @@ App = Ember.Application.extend(Ember.Evented,
|
|||
setupUserlike: (user) ->
|
||||
|
||||
btn = document.getElementById('userlikeCustomTab')
|
||||
btn.className = btn.className + " logged-in"
|
||||
btn.classList.add("logged-in")
|
||||
|
||||
userlikeData = window.userlikeData = {}
|
||||
userlikeData.user = {}
|
||||
|
@ -91,12 +94,15 @@ App = Ember.Application.extend(Ember.Evented,
|
|||
userlikeData.user.name= user.login;
|
||||
userlikeData.user.email = user.email;
|
||||
|
||||
s = document.createElement('script')
|
||||
s.src = '//userlike-cdn-widgets.s3-eu-west-1.amazonaws.com/0327dbb23382ccbbb91b445b76e8a91d4b37d90ef9f2faf84e11177847ff7bb9.js'
|
||||
document.body.appendChild(s)
|
||||
unless document.getElementById('userlike-script')
|
||||
s = document.createElement('script')
|
||||
s.id = 'userlike-script'
|
||||
s.src = '//userlike-cdn-widgets.s3-eu-west-1.amazonaws.com/0327dbb23382ccbbb91b445b76e8a91d4b37d90ef9f2faf84e11177847ff7bb9.js'
|
||||
document.body.appendChild(s)
|
||||
|
||||
# displayCharm: ->
|
||||
# __CHARM.show()
|
||||
removeUserlike: () ->
|
||||
btn = document.getElementById('userlikeCustomTab')
|
||||
btn.classList.remove("logged-in")
|
||||
|
||||
identifyCustomer: (user) ->
|
||||
if _cio && _cio.identify
|
||||
|
|
|
@ -25,6 +25,7 @@ Auth = Ember.Object.extend
|
|||
@store.unloadAll('user')
|
||||
@set('currentUser', null)
|
||||
@sendToApp('afterSignOut')
|
||||
Travis.trigger('user:signed_out')
|
||||
|
||||
signIn: (data) ->
|
||||
if data
|
||||
|
|
Loading…
Reference in New Issue
Block a user