Progress towards LinkedIn integration

This commit is contained in:
Michael Schmatz 2014-04-23 11:25:36 -07:00
parent f7035d4220
commit 628a784ac4
7 changed files with 89 additions and 5 deletions

View file

@ -1,5 +1,6 @@
FacebookHandler = require 'lib/FacebookHandler'
GPlusHandler = require 'lib/GPlusHandler'
LinkedInHandler = require 'lib/LinkedInHandler'
locale = require 'locale/locale'
{me} = require 'lib/auth'
Tracker = require 'lib/Tracker'
@ -33,7 +34,7 @@ Application = initialize: ->
@facebookHandler = new FacebookHandler()
@gplusHandler = new GPlusHandler()
$(document).bind 'keydown', preventBackspace
@linkedinHandler = new LinkedInHandler()
preload(COMMON_FILES)
$.i18n.init {
lng: me?.lang() ? 'en'

View file

@ -42,7 +42,18 @@
<script>require('initialize');</script>
<!-- begin LinkedIn code -->
<script>
window.linkedInAsyncInit = function() {
Backbone.Mediator.publish('linkedin-loaded');
};
</script>
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: 75v8mv4ictvmx6
onLoad: linkedInAsyncInit
authorize: true
</script>
<!-- end LinkedIn code -->
<!-- begin segment.io code -->
<script type="text/javascript">
var analytics=analytics||[];(function(){var e=["identify","track","trackLink","trackForm","trackClick","trackSubmit","page","pageview","ab","alias","ready","group"],t=function(e){return function(){analytics.push([e].concat(Array.prototype.slice.call(arguments,0)))}};for(var n=0;n<e.length;n++)analytics[e[n]]=t(e[n])})(),analytics.load=function(e){var t=document.createElement("script");t.type="text/javascript",t.async=!0,t.src=("https:"===document.location.protocol?"https://":"http://")+"d2dq2ahtl5zl1z.cloudfront.net/analytics.js/v1/"+e+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n)};
@ -70,6 +81,7 @@
/* custom configuration goes here (www.olark.com/documentation) */
olark.identify('1451-787-10-5544');/*]]>*/</script>
<!-- end olark code -->
</head>
<body class="nano clearfix">

View file

@ -0,0 +1,27 @@
CocoClass = require 'lib/CocoClass'
{me} = require 'lib/auth'
{backboneFailure} = require 'lib/errors'
storage = require 'lib/storage'
module.exports = LinkedInHandler = class LinkedInHandler extends CocoClass
constructor: ->
super()
@linkedInData = {}
@loaded = false
subscriptions:
'linkedin-loaded':'onLinkedInLoaded'
onLinkedInLoaded: (e) =>
console.log "Loaded LinkedIn!"
IN.Event.on IN, "auth", @onLinkedInAuth
onLinkedInAuth: (e) => IN.API.Profile("me").result(@cacheProfileInformation)
cacheProfileInformation: (profiles) =>
@linkedInData = profiles.values[0]
console.log "LinkedIn data is #{@linkedInData}"
destroy: ->
super()

View file

@ -133,6 +133,9 @@ a[data-toggle="modal"]
background-color: transparent
margin: 0 14px
border-bottom-color: #ccc
.modal-footer.linkedin
text-align: center
// Bigger versions of some Bootstrap icons
// TODO: make the non-white versions of these if we ever need them

View file

@ -1,4 +1,6 @@
h3(data-i18n="account_settings.job_profile") Job Profile
script(type="in/Login")
Hello, <?js= firstName?> <?js= lastName?>.
.row
.col-md-9

View file

@ -4,6 +4,21 @@ block modal-header-content
h3(data-i18n="employer_signup.title") Hire CodeCombat Players
block modal-body-content
h4(data-i18n="employer_signup.sub_heading") Let us find your next brilliant developers.
p(data-i18n="employer_signup.pitch_body") When you hire one of our players, you will pay CodeCombat 18% of her first-year salary, payable within 30 days of when she starts working. We will fully refund our placement fee if she leaves or is fired within 90 days. Cool? Email george@codecombat.com to get set up with employer permissions to see our candidates.
if userIsAuthorized
h4 Contract
p Check out this fancy-schmancy contract. You should sign it.
else
h4(data-i18n="employer_signup.sub_heading") Let us find your next brilliant developers.
p(data-i18n="employer_signup.pitch_body") When you hire one of our players, you will pay CodeCombat 18% of her first-year salary, payable within 30 days of when she starts working. We will fully refund our placement fee if she leaves or is fired within 90 days. Cool? Email george@codecombat.com to get set up with employer permissions to see our candidates.
block modal-footer
if userIsAuthorized
.modal-footer.linkedin
| Thanks #{firstName}! You've already agreed to the contract.
else
.modal-footer.linkedin
script(type="in/Login" id="linkedInAuthButton" data-onAuth="contractCallback")
| Thanks, <?js= firstName?>! You've agreed to the contract.

View file

@ -5,3 +5,27 @@ module.exports = class EmployerSignupView extends View
id: "employer-signup"
template: template
closeButton: true
subscriptions:
'employer-linkedin-auth': 'showContractScreen'
constructor: (options) ->
super(options)
@authorizedWithLinkedIn = IN?.User?.isAuthorized()
window.contractCallback = -> window.Backbone.Mediator.publish("employer-linkedin-auth")
afterInsert: ->
super()
unless @authorizedWithLinkedIn
linkedInButtonParentElement = document.getElementById("linkedInAuthButton").parentNode
IN.parse(linkedInButtonParentElement) if linkedInButtonParentElement
showContractScreen: =>
@render()
getRenderData: ->
context = super()
context.userIsAuthorized = @authorizedWithLinkedIn
if @authorizedWithLinkedIn
context.firstName = application.linkedinHandler.linkedInData.firstName
context