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 !userIsAuthorized
.modal-footer.linkedin
b.signin-text Sign in with LinkedIn to complete the registration process.
script(type="in/Login" id="linkedInAuthButton" data-onAuth="contractCallback")
button.btn.btn-primary(id="create-account-button") Create Account
br
br
| 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.
else if !userIsAnonymous && !userIsAuthorized
.modal-footer.linkedin
| We will record your name and work history for verification purposes.
else if userIsAuthorized && !userHasSignedContract
.modal-footer.linkedin
button.btn.btn-primary(id="contract-agreement-button") I agree

View file

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

View file

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

View file

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