mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-16 00:19:50 -05:00
Limited social media library loading to only those views that need it.
This commit is contained in:
parent
99e5941126
commit
9455199b39
8 changed files with 34 additions and 18 deletions
|
@ -12,6 +12,7 @@ module.exports = class CocoRouter extends Backbone.Router
|
|||
@bind 'route', @_trackPageView
|
||||
Backbone.Mediator.subscribe 'auth:gplus-api-loaded', @onGPlusAPILoaded, @
|
||||
Backbone.Mediator.subscribe 'router:navigate', @onNavigate, @
|
||||
@initializeSocialMediaServices = _.once @initializeSocialMediaServices
|
||||
|
||||
routes:
|
||||
'': go('HomeView') # This will go somewhere deprecated when FrontView is done.
|
||||
|
@ -125,7 +126,7 @@ module.exports = class CocoRouter extends Backbone.Router
|
|||
$('#page-container').empty().append view.el
|
||||
window.currentView = view
|
||||
@activateTab()
|
||||
@renderLoginButtons()
|
||||
@renderLoginButtons() if view.usesSocialMedia
|
||||
view.afterInsert()
|
||||
view.didReappear()
|
||||
|
||||
|
@ -139,8 +140,22 @@ module.exports = class CocoRouter extends Backbone.Router
|
|||
|
||||
onGPlusAPILoaded: =>
|
||||
@renderLoginButtons()
|
||||
|
||||
initializeSocialMediaServices: ->
|
||||
return if application.testing or application.demoing
|
||||
services = [
|
||||
'./lib/services/facebook'
|
||||
'./lib/services/google'
|
||||
'./lib/services/twitter'
|
||||
'./lib/services/linkedin'
|
||||
]
|
||||
|
||||
for service in services
|
||||
service = require service
|
||||
service()
|
||||
|
||||
renderLoginButtons: ->
|
||||
@initializeSocialMediaServices()
|
||||
$('.share-buttons, .partner-badges').addClass('fade-in').delay(10000).removeClass('fade-in', 5000)
|
||||
setTimeout(FB.XFBML.parse, 10) if FB?.XFBML?.parse # Handles FB login and Like
|
||||
twttr?.widgets?.load?()
|
||||
|
|
|
@ -24,9 +24,9 @@ init = ->
|
|||
watchForErrors()
|
||||
setUpIOSLogging()
|
||||
path = document.location.pathname
|
||||
testing = path.startsWith '/test'
|
||||
demoing = path.startsWith '/demo'
|
||||
initializeServices() unless testing or demoing
|
||||
app.testing = path.startsWith '/test'
|
||||
app.demoing = path.startsWith '/demo'
|
||||
initializeUtilityServices() unless app.testing or app.demoing
|
||||
setUpBackboneMediator()
|
||||
app.initialize()
|
||||
Backbone.history.start({ pushState: true })
|
||||
|
@ -74,15 +74,11 @@ setUpMoment = ->
|
|||
me.on 'change:preferredLanguage', (me) ->
|
||||
moment.lang me.get('preferredLanguage', true), {}
|
||||
|
||||
initializeServices = ->
|
||||
initializeUtilityServices = ->
|
||||
services = [
|
||||
'./lib/services/filepicker'
|
||||
'./lib/services/segmentio'
|
||||
'./lib/services/olark'
|
||||
'./lib/services/facebook'
|
||||
'./lib/services/google'
|
||||
'./lib/services/twitter'
|
||||
'./lib/services/linkedin'
|
||||
]
|
||||
|
||||
for service in services
|
||||
|
|
|
@ -75,14 +75,15 @@ body
|
|||
a(href='/teachers', data-i18n="nav.teachers") Teachers
|
||||
if me.isAdmin()
|
||||
a(href='/admin', data-i18n="nav.admin") Admin
|
||||
|
||||
.share-buttons
|
||||
if !isIE
|
||||
.g-plusone(data-href="http://codecombat.com", data-size="medium")
|
||||
.fb-like(data-href="https://www.facebook.com/codecombat", data-send="false", data-layout="button_count", data-width="350", data-show-faces="true", data-ref="coco_footer_#{fbRef}")
|
||||
if !isIE
|
||||
a.twitter-follow-button(href="https://twitter.com/CodeCombat", data-show-count="true", data-show-screen-name="false", data-dnt="true", data-align="right", data-i18n="nav.twitter_follow") Follow
|
||||
iframe.github-star-button(src="http://ghbtns.com/github-btn.html?user=codecombat&repo=codecombat&type=watch&count=true", allowtransparency="true", frameborder="0", scrolling="0", width="110", height="20")
|
||||
|
||||
if usesSocialMedia
|
||||
.share-buttons
|
||||
if !isIE
|
||||
.g-plusone(data-href="http://codecombat.com", data-size="medium")
|
||||
.fb-like(data-href="https://www.facebook.com/codecombat", data-send="false", data-layout="button_count", data-width="350", data-show-faces="true", data-ref="coco_footer_#{fbRef}")
|
||||
if !isIE
|
||||
a.twitter-follow-button(href="https://twitter.com/CodeCombat", data-show-count="true", data-show-screen-name="false", data-dnt="true", data-align="right", data-i18n="nav.twitter_follow") Follow
|
||||
iframe.github-star-button(src="http://ghbtns.com/github-btn.html?user=codecombat&repo=codecombat&type=watch&count=true", allowtransparency="true", frameborder="0", scrolling="0", width="110", height="20")
|
||||
|
||||
.partner-badges
|
||||
a.mixpanel-badge(href="https://mixpanel.com/f/partner")
|
||||
|
|
|
@ -70,6 +70,7 @@ module.exports = class RootView extends CocoView
|
|||
getRenderData: ->
|
||||
c = super()
|
||||
c.showBackground = @showBackground
|
||||
c.usesSocialMedia = @usesSocialMedia
|
||||
c
|
||||
|
||||
afterRender: ->
|
||||
|
|
|
@ -42,7 +42,7 @@ module.exports = class AuthModal extends ModalView
|
|||
|
||||
afterInsert: ->
|
||||
super()
|
||||
_.delay application.router.renderLoginButtons, 500
|
||||
_.delay (=> application.router.renderLoginButtons()), 500
|
||||
_.delay (=> $('input:visible:first', @$el).focus()), 500
|
||||
|
||||
onSignupInstead: (e) ->
|
||||
|
|
|
@ -25,6 +25,7 @@ class LevelSessionsCollection extends CocoCollection
|
|||
module.exports = class LadderView extends RootView
|
||||
id: 'ladder-view'
|
||||
template: require 'templates/play/ladder/ladder'
|
||||
usesSocialMedia: true
|
||||
|
||||
subscriptions:
|
||||
'application:idle-changed': 'onIdleChanged'
|
||||
|
|
|
@ -28,6 +28,7 @@ module.exports = class VictoryModal extends ModalView
|
|||
'enter': -> 'onPlayNextLevel'
|
||||
|
||||
constructor: (options) ->
|
||||
application.router.initializeSocialMediaServices()
|
||||
victory = options.level.get('victory')
|
||||
body = utils.i18n(victory, 'body') or 'Sorry, this level has no victory message yet.'
|
||||
@body = marked(body)
|
||||
|
|
|
@ -30,6 +30,7 @@ module.exports = class JobProfileView extends UserView
|
|||
id: 'profile-view'
|
||||
template: template
|
||||
showBackground: false
|
||||
usesSocialMedia: true
|
||||
|
||||
subscriptions:
|
||||
'auth:linkedin-api-loaded': 'onLinkedInLoaded'
|
||||
|
|
Loading…
Reference in a new issue