This commit is contained in:
Nick Winter 2014-04-29 15:25:39 -07:00
commit 8a6bec9d40
4 changed files with 40 additions and 12 deletions

View file

@ -46,8 +46,7 @@ block modal-footer
if userIsAnonymous if userIsAnonymous
if !userIsAuthorized if !userIsAuthorized
.modal-footer.linkedin .modal-footer.linkedin
b.signin-text Sign in with LinkedIn to complete the registration process. button.btn.btn-primary(id="create-account-button") Create Account
script(type="in/Login" id="linkedInAuthButton" data-onAuth="contractCallback")
br br
br br
| Already have a CodeCombat account? | Already have a CodeCombat account?
@ -57,7 +56,6 @@ block modal-footer
a.login-link(data-toggle="coco-modal", data-target="modal/login") Please log in to continue. a.login-link(data-toggle="coco-modal", data-target="modal/login") Please log in to continue.
else if !userIsAnonymous && !userIsAuthorized else if !userIsAnonymous && !userIsAuthorized
.modal-footer.linkedin .modal-footer.linkedin
| We will record your name and work history for verification purposes.
else if userIsAuthorized && !userHasSignedContract else if userIsAuthorized && !userHasSignedContract
.modal-footer.linkedin .modal-footer.linkedin
button.btn.btn-primary(id="contract-agreement-button") I agree button.btn.btn-primary(id="contract-agreement-button") I agree

View file

@ -20,7 +20,9 @@ module.exports = class ProfileView extends View
@user = me @user = me
else else
@user = User.getByID(@userID) @user = User.getByID(@userID)
@addResourceToLoad @user, 'user_profile' @user.fetch()
@listenTo @user, "sync", =>
@render()
getRenderData: -> getRenderData: ->
context = super() context = super()

View file

@ -21,10 +21,19 @@ module.exports = class EmployersView extends View
super options super options
@getCandidates() @getCandidates()
checkForEmployerSignupHash: =>
if window.location.hash is "#employerSignupLoggingIn"
@openModalView application.router.getView("modal/employer_signup","_modal")
window.location.hash = ""
afterRender: -> afterRender: ->
super() super()
@sortTable() if @candidates.models.length @sortTable() if @candidates.models.length
afterInsert: ->
super()
_.delay @checkForEmployerSignupHash, 500
getRenderData: -> getRenderData: ->
c = super() c = super()
c.candidates = @candidates.models c.candidates = @candidates.models

View file

@ -13,10 +13,13 @@ module.exports = class EmployerSignupView extends View
subscriptions: subscriptions:
"server-error": "onServerError" "server-error": "onServerError"
"created-user-without-reload": "linkedInAuth" 'linkedin-loaded': 'onLinkedInLoaded'
"created-user-without-reload": 'createdAccount'
events: events:
"click #contract-agreement-button": "agreeToContract" "click #contract-agreement-button": "agreeToContract"
"click #create-account-button": "createAccount"
"click .login-link": "setHashToOpenModalAutomatically"
constructor: (options) -> constructor: (options) ->
@ -24,20 +27,31 @@ module.exports = class EmployerSignupView extends View
@authorizedWithLinkedIn = IN?.User?.isAuthorized() @authorizedWithLinkedIn = IN?.User?.isAuthorized()
window.tracker?.trackEvent 'Started Employer Signup' window.tracker?.trackEvent 'Started Employer Signup'
@reloadWhenClosed = false @reloadWhenClosed = false
@linkedinLoaded = Boolean(IN.parse)
@waitingForLinkedIn = false
window.contractCallback = => window.contractCallback = =>
@authorizedWithLinkedIn = IN?.User?.isAuthorized() @authorizedWithLinkedIn = IN?.User?.isAuthorized()
@render() @render()
onLinkedInLoaded: =>
@linkedinLoaded = true
if @waitingForLinkedIn
@renderLinkedInButton()
renderLinkedInButton: =>
IN.parse()
onServerError: (e) -> onServerError: (e) ->
@disableModalInProgress(@$el) @disableModalInProgress(@$el)
afterInsert: -> afterInsert: ->
super() super()
linkedInButtonParentElement = document.getElementById("linkedInAuthButton")?.parentNode linkedInButtonParentElement = document.getElementById("linkedInAuthButton")
if linkedInButtonParentElement if linkedInButtonParentElement
IN.parse() if @linkedinLoaded
if me.get('anonymous') @renderLinkedInButton()
$(".IN-widget").get(0).addEventListener('click', @createAccount, true) else
@waitingForLinkedIn = true
getRenderData: -> getRenderData: ->
context = super() context = super()
@ -78,11 +92,16 @@ module.exports = class EmployerSignupView extends View
return forms.applyErrorsToForm(@$el, res.errors) unless res.valid return forms.applyErrorsToForm(@$el, res.errors) unless res.valid
@enableModalInProgress(@$el) @enableModalInProgress(@$el)
auth.createUserWithoutReload userObject, null auth.createUserWithoutReload userObject, null
IN.User.authorize @render, @
linkedInAuth: (e) -> setHashToOpenModalAutomatically: (e) ->
me.fetch() window.location.hash = "employerSignupLoggingIn"
createdAccount: ->
@reloadWhenClosed = true @reloadWhenClosed = true
@listenTo me,"sync", =>
@render()
IN.parse()
me.fetch()
destroy: -> destroy: ->
reloadWhenClosed = @reloadWhenClosed reloadWhenClosed = @reloadWhenClosed