diff --git a/app/application.coffee b/app/application.coffee
index 1d25ab07b..11dc4ba15 100644
--- a/app/application.coffee
+++ b/app/application.coffee
@@ -5,20 +5,31 @@ locale = require 'locale/locale'
Tracker = require 'lib/Tracker'
CocoView = require 'views/kinds/CocoView'
+preventBackspace = (event) ->
+ if event.keyCode is 8 and not elementAcceptsKeystrokes(event.srcElement or event.target)
+ event.preventDefault()
+
+elementAcceptsKeystrokes = (el) ->
+ # http://stackoverflow.com/questions/1495219/how-can-i-prevent-the-backspace-key-from-navigating-back
+ el ?= document.activeElement
+ tag = el.tagName.toLowerCase()
+ type = el.type?.toLowerCase()
+ textInputTypes = ['text', 'password', 'file', 'number', 'search', 'url', 'tel', 'email', 'date', 'month', 'week', 'time', 'datetimelocal']
+ # not radio, checkbox, range, or color
+ return (tag is 'textarea' or (tag is 'input' and type in textInputTypes) or el.contentEditable in ["", "true"]) and not (el.readOnly or el.disabled)
+
COMMON_FILES = ['/images/modal_background.png', '/images/level/code_palette_background.png']
preload = (arrayOfImages) ->
$(arrayOfImages).each ->
$('')[0].src = @
-
Application = initialize: ->
Router = require('lib/Router')
@tracker = new Tracker()
new FacebookHandler()
new GPlusHandler()
$(document).bind 'keydown', preventBackspace
- console.log 'done applied it'
-
+
preload(COMMON_FILES)
$.i18n.init {
lng: me?.lang() ? 'en'
@@ -36,19 +47,3 @@ Application = initialize: ->
module.exports = Application
window.application = Application
-
-
-preventBackspace = (event) ->
- console.log 'PREVENT', event
- if event.keyCode is 8 and not elementAcceptsKeystrokes(event.srcElement or event.target)
- event.preventDefault()
-# event.preventDefault()
-
-elementAcceptsKeystrokes = (el) ->
- # http://stackoverflow.com/questions/1495219/how-can-i-prevent-the-backspace-key-from-navigating-back
- el ?= document.activeElement
- tag = el.tagName.toLowerCase()
- type = el.type?.toLowerCase()
- textInputTypes = ['text', 'password', 'file', 'number', 'search', 'url', 'tel', 'email', 'date', 'month', 'week', 'time', 'datetimelocal']
- # not radio, checkbox, range, or color
- return (tag is 'textarea' or (tag is 'input' and type in textInputTypes) or el.contentEditable in ["", "true"]) and not (el.readOnly or el.disabled)
diff --git a/app/assets/images/pages/base/firebase.png b/app/assets/images/pages/base/firebase.png
new file mode 100644
index 000000000..5ecfb5e2d
Binary files /dev/null and b/app/assets/images/pages/base/firebase.png differ
diff --git a/app/lib/LevelLoader.coffee b/app/lib/LevelLoader.coffee
index c8894a3ba..15223d44d 100644
--- a/app/lib/LevelLoader.coffee
+++ b/app/lib/LevelLoader.coffee
@@ -14,13 +14,13 @@ app = require 'application'
# * Connecting to Firebase
module.exports = class LevelLoader extends CocoClass
-
+
spriteSheetsBuilt: 0
spriteSheetsToBuild: 0
-
+
subscriptions:
'god:new-world-created': 'loadSoundsForWorld'
-
+
constructor: (@levelID, @supermodel, @sessionID) ->
super()
@loadSession()
@@ -28,20 +28,20 @@ module.exports = class LevelLoader extends CocoClass
@loadAudio()
@playJingle()
setTimeout (=> @update()), 1 # lets everything else resolve first
-
+
playJingle: ->
jingles = ["ident_1", "ident_2"]
AudioPlayer.playInterfaceSound jingles[Math.floor Math.random() * jingles.length]
# Session Loading
-
+
loadSession: ->
url = if @sessionID then "/db/level_session/#{@sessionID}" else "/db/level/#{@levelID}/session"
@session = new LevelSession()
@session.url = -> url
@session.fetch()
@session.once 'sync', @onSessionLoaded
-
+
onSessionLoaded: =>
# TODO: maybe have all non versioned models do this? Or make it work to PUT/PATCH to relative urls
@session.url = -> '/db/level.session/' + @id
@@ -54,20 +54,20 @@ module.exports = class LevelLoader extends CocoClass
@supermodel.on 'loaded-one', @onSupermodelLoadedOne
@supermodel.once 'error', @onSupermodelError
@level = @supermodel.getModel(Level, @levelID) or new Level _id: @levelID
-
+
@supermodel.shouldPopulate = (model) =>
# if left unchecked, the supermodel would load this level
# and every level next on the chain. This limits the population
handles = [model.id, model.get 'slug']
return model.constructor.className isnt "Level" or @levelID in handles
-
+
@supermodel.populateModel @level
-
+
onSupermodelError: =>
msg = $.i18n.t('play_level.level_load_error',
defaultValue: "Level could not be loaded.")
@$el.html('
' + msg + '
')
-
+
onSupermodelLoadedOne: (e) =>
@notifyProgress()
if e.model.type() is 'ThangType'
@@ -83,8 +83,8 @@ module.exports = class LevelLoader extends CocoClass
@trigger 'loaded-supermodel'
@stopListening(@supermodel)
@update()
-
- # Things to do when either the Session or Supermodel load
+
+ # Things to do when either the Session or Supermodel load
update: ->
@notifyProgress()
@@ -95,7 +95,7 @@ module.exports = class LevelLoader extends CocoClass
@loadLevelSounds()
app.tracker.updatePlayState(@level, @session)
@updateCompleted = true
-
+
denormalizeSession: ->
return if @session.get 'levelName'
patch =
@@ -108,12 +108,12 @@ module.exports = class LevelLoader extends CocoClass
tempSession = new LevelSession _id: @session.id
tempSession.save(patch, {patch: true})
@sessionDenormalized = true
-
+
# Initial Sound Loading
loadAudio: ->
AudioPlayer.preloadInterfaceSounds ["victory"]
-
+
loadLevelSounds: ->
scripts = @level.get 'scripts'
return unless scripts
@@ -129,7 +129,7 @@ module.exports = class LevelLoader extends CocoClass
AudioPlayer.preloadSoundReference sound for sound in sounds
# Dynamic sound loading
-
+
loadSoundsForWorld: (e) ->
world = e.world
thangTypes = @supermodel.getModels(ThangType)
@@ -137,12 +137,12 @@ module.exports = class LevelLoader extends CocoClass
continue unless thangType = _.find thangTypes, (m) -> m.get('name') is spriteName
continue unless sound = AudioPlayer.soundForDialogue message, thangType.get('soundTriggers')
filename = AudioPlayer.preloadSoundReference sound
-
+
# everything else sound wise is loaded as needed as worlds are generated
-
+
allDone: ->
@supermodel.finished() and @session.loaded and @spriteSheetsBuilt is @spriteSheetsToBuild
-
+
progress: ->
return 0 unless @level.loaded
overallProgress = 0
@@ -161,4 +161,3 @@ module.exports = class LevelLoader extends CocoClass
destroy: ->
@supermodel.off 'loaded-one', @onSupermodelLoadedOne
super()
-
diff --git a/app/lib/Router.coffee b/app/lib/Router.coffee
index 77bace1ab..909562d6c 100644
--- a/app/lib/Router.coffee
+++ b/app/lib/Router.coffee
@@ -1,4 +1,3 @@
-application = require 'application'
{me} = require 'lib/auth'
gplusClientID = "800329290710-j9sivplv2gpcdgkrsis9rff3o417mlfa.apps.googleusercontent.com"
@@ -62,7 +61,7 @@ module.exports = class CocoRouter extends Backbone.Router
@renderLoginButtons()
renderLoginButtons: ->
- $('.share-buttons').addClass('fade-in').delay(10000).removeClass('fade-in', 5000)
+ $('.share-buttons, .partner-badges').addClass('fade-in').delay(10000).removeClass('fade-in', 5000)
setTimeout(FB.XFBML.parse, 10) if FB? # Handles FB login and Like
twttr?.widgets?.load()
diff --git a/app/styles/base.sass b/app/styles/base.sass
index 862fc7074..d89558292 100644
--- a/app/styles/base.sass
+++ b/app/styles/base.sass
@@ -88,10 +88,9 @@ h1 h2 h3 h4
padding-top: 25px
text-align: center
- .mixpanel-badge
- display: block
+ .mixpanel-badge, .firebase-badge
width: 100px
- margin: 10px auto 0px
+ margin: 10px 10px 0px
.footer-link-text a
font-family: 'Bangers', cursive
@@ -103,7 +102,7 @@ h1 h2 h3 h4
a[data-toggle="modal"]
cursor: pointer
-.share-buttons
+.share-buttons, .partner-badges
margin-top: 10px
text-align: center
@include opacity(75)
diff --git a/app/templates/base.jade b/app/templates/base.jade
index 73b5085bb..4a9ff4fcf 100644
--- a/app/templates/base.jade
+++ b/app/templates/base.jade
@@ -58,5 +58,8 @@ body
.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}")
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(src="https://www.lendyour.net/embed/lendbutton?account_id=6&campaign_id=7", frameBorder="0")
+ .partner-badges
a.mixpanel-badge(href="https://mixpanel.com/f/partner")
img(src="//cdn.mxpnl.com/site_media/images/partner/badge_light.png", alt="Mobile Analytics")
+ a.firebase-bade(href="https://www.firebase.com/")
+ img(src="/images/pages/base/firebase.png", alt="Powered by Firebase")
\ No newline at end of file
diff --git a/app/views/contribute/contribute_class_view.coffee b/app/views/contribute/contribute_class_view.coffee
index bdce7c68c..42fc49b3f 100644
--- a/app/views/contribute/contribute_class_view.coffee
+++ b/app/views/contribute/contribute_class_view.coffee
@@ -1,3 +1,4 @@
+SignupModalView = require 'views/modal/signup_modal'
View = require 'views/kinds/RootView'
{me} = require('lib/auth')
diff --git a/app/views/editor/article/edit.coffee b/app/views/editor/article/edit.coffee
index fb334c925..5ce0388fb 100644
--- a/app/views/editor/article/edit.coffee
+++ b/app/views/editor/article/edit.coffee
@@ -1,7 +1,6 @@
View = require 'views/kinds/RootView'
template = require 'templates/editor/article/edit'
Article = require 'models/Article'
-app = require 'application'
module.exports = class ArticleEditView extends View
id: "editor-article-edit-view"
@@ -10,7 +9,7 @@ module.exports = class ArticleEditView extends View
events:
'click #preview-button': 'openPreview'
-
+
subscriptions:
'save-new-version': 'saveNewArticle'
@@ -40,7 +39,7 @@ module.exports = class ArticleEditView extends View
change: @pushChangesToPreview
options.readOnly = true unless me.isAdmin()
@treema = @$el.find('#article-treema').treema(options)
-
+
@treema.build()
pushChangesToPreview: =>
@@ -65,7 +64,7 @@ module.exports = class ArticleEditView extends View
@treema.endExistingEdits()
for key, value of @treema.data
@article.set(key, value)
-
+
newArticle = if e.major then @article.cloneNewMajorVersion() else @article.cloneNewMinorVersion()
newArticle.set('commitMessage', e.commitMessage)
res = newArticle.save()
diff --git a/app/views/editor/level/edit.coffee b/app/views/editor/level/edit.coffee
index c7a097e6f..cbd4288cf 100644
--- a/app/views/editor/level/edit.coffee
+++ b/app/views/editor/level/edit.coffee
@@ -3,7 +3,6 @@ template = require 'templates/editor/level/edit'
Level = require 'models/Level'
LevelSystem = require 'models/LevelSystem'
World = require 'lib/world/world'
-app = require 'application'
DocumentFiles = require 'collections/DocumentFiles'
ThangsTabView = require './thangs_tab_view'
diff --git a/app/views/editor/level/fork_view.coffee b/app/views/editor/level/fork_view.coffee
index e9f2c134b..3a27111de 100644
--- a/app/views/editor/level/fork_view.coffee
+++ b/app/views/editor/level/fork_view.coffee
@@ -2,7 +2,6 @@ View = require 'views/kinds/ModalView'
template = require 'templates/editor/level/fork'
forms = require 'lib/forms'
Level = require 'models/Level'
-application = require('application')
module.exports = class LevelForkView extends View
id: "editor-level-fork-modal"
@@ -44,4 +43,4 @@ module.exports = class LevelForkView extends View
forms.applyErrorsToForm(@$el.find('form'), JSON.parse(res.responseText))
res.success =>
@hide()
- application.router.navigate('editor/level/' + newLevel.get('slug'), {trigger: true})
\ No newline at end of file
+ application.router.navigate('editor/level/' + newLevel.get('slug'), {trigger: true})
diff --git a/app/views/editor/level/save_view.coffee b/app/views/editor/level/save_view.coffee
index 23e954736..d2c079f72 100644
--- a/app/views/editor/level/save_view.coffee
+++ b/app/views/editor/level/save_view.coffee
@@ -3,7 +3,6 @@ template = require 'templates/editor/level/save'
forms = require 'lib/forms'
LevelComponent = require 'models/LevelComponent'
LevelSystem = require 'models/LevelSystem'
-application = require('application')
module.exports = class LevelSaveView extends SaveVersionModal
template: template
diff --git a/app/views/editor/thang/edit.coffee b/app/views/editor/thang/edit.coffee
index 3c6adfb41..ae9966fdd 100644
--- a/app/views/editor/thang/edit.coffee
+++ b/app/views/editor/thang/edit.coffee
@@ -4,7 +4,6 @@ ThangType = require 'models/ThangType'
SpriteParser = require 'lib/sprites/SpriteParser'
SpriteBuilder = require 'lib/sprites/SpriteBuilder'
CocoSprite = require 'lib/surface/CocoSprite'
-app = require 'application'
Camera = require 'lib/surface/Camera'
ThangComponentEditView = require 'views/editor/components/main'
DocumentFiles = require 'collections/DocumentFiles'
@@ -104,7 +103,7 @@ module.exports = class ThangTypeEditView extends View
createjs.Ticker.setFPS(30)
createjs.Ticker.addEventListener("tick", @stage)
-
+
toggleDots: ->
@showDots = not @showDots
@updateDots()
diff --git a/app/views/kinds/CocoView.coffee b/app/views/kinds/CocoView.coffee
index 4384961b8..debb13f56 100644
--- a/app/views/kinds/CocoView.coffee
+++ b/app/views/kinds/CocoView.coffee
@@ -1,4 +1,3 @@
-application = require 'application'
SuperModel = require 'models/SuperModel'
utils = require 'lib/utils'
CocoClass = require 'lib/CocoClass'
diff --git a/app/views/play/level_view.coffee b/app/views/play/level_view.coffee
index eef6f3789..41369f8a9 100644
--- a/app/views/play/level_view.coffee
+++ b/app/views/play/level_view.coffee
@@ -1,7 +1,6 @@
View = require 'views/kinds/RootView'
template = require 'templates/play/level'
{me} = require('lib/auth')
-application = require('application')
ThangType = require 'models/ThangType'
# temp hard coded data
@@ -202,7 +201,6 @@ module.exports = class PlayLevelView extends View
window.tracker?.identify {skipBreakThePrison: skip}
url = '/play/level/taunt' if skip
-# application.router.navigate url, trigger: true
Backbone.Mediator.publish 'router:navigate', {
route: url,
viewClass: PlayLevelView,