From 1118324b410e883214c34e085b473aa263e3d074 Mon Sep 17 00:00:00 2001 From: swapnesh Date: Wed, 26 Mar 2014 03:25:11 +0530 Subject: [PATCH 01/11] Migrate from .on, .once to .listenTo, .listenToOnce --- app/lib/LevelLoader.coffee | 8 ++++---- app/models/SuperModel.coffee | 8 ++++---- app/views/account/wizard_settings_view.coffee | 2 +- app/views/editor/thang/colors_tab_view.coffee | 4 ++-- app/views/play/level/modal/victory_modal.coffee | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/lib/LevelLoader.coffee b/app/lib/LevelLoader.coffee index 9d65a3d5d..79a47701e 100644 --- a/app/lib/LevelLoader.coffee +++ b/app/lib/LevelLoader.coffee @@ -60,13 +60,13 @@ module.exports = class LevelLoader extends CocoClass # Unless you specify cache:false, sometimes the browser will use a cached session # and players will 'lose' code @session.fetch({cache:false}) - @session.once 'sync', @onSessionLoaded, @ + @listenToOnce(@session, 'sync', @onSessionLoaded) if @opponentSessionID @opponentSession = new LevelSession() @opponentSession.url = "/db/level_session/#{@opponentSessionID}" @opponentSession.fetch() - @opponentSession.once 'sync', @onSessionLoaded, @ + @listenToOnce(@opponentSession, 'sync', @onSessionLoaded) sessionsLoaded: -> return true if @headless @@ -82,8 +82,8 @@ module.exports = class LevelLoader extends CocoClass # Supermodel (Level) Loading loadLevelModels: -> - @supermodel.on 'loaded-one', @onSupermodelLoadedOne, @ - @supermodel.once 'error', @onSupermodelError, @ + @listenTo(@supermodel, 'loaded-one', @onSupermodelLoadedOne) + @listenToOnce(@supermodel, 'error', @onSupermodelError) @level = @supermodel.getModel(Level, @levelID) or new Level _id: @levelID levelID = @levelID headless = @headless diff --git a/app/models/SuperModel.coffee b/app/models/SuperModel.coffee index 9ce14c75d..45977d48f 100644 --- a/app/models/SuperModel.coffee +++ b/app/models/SuperModel.coffee @@ -9,8 +9,8 @@ class SuperModel @mustPopulate = model model.saveBackups = @shouldSaveBackups(model) model.fetch() unless model.loaded or model.loading - model.once('sync', @modelLoaded, @) unless model.loaded - model.once('error', @modelErrored, @) unless model.loaded + @listenTo(model, 'sync', @modelLoaded) unless model.loaded + @listenToOnce(model, 'error', @modelErrored) unless model.loaded url = model.url() @models[url] = model unless @models[url]? @modelLoaded(model) if model.loaded @@ -30,7 +30,7 @@ class SuperModel schema = model.schema() unless schema.loaded @schemas[schema.urlRoot] = schema - return schema.once('sync', => @modelLoaded(model)) + return @listenToOnce(schema, 'sync', -> @modelLoaded(model)) refs = model.getReferencedModels(model.attributes, schema.attributes, '/', @shouldLoadProjection) refs = [] unless @mustPopulate is model or @shouldPopulate(model) # console.log 'Loaded', model.get('name') @@ -40,7 +40,7 @@ class SuperModel continue if @models[refURL] @models[refURL] = ref ref.fetch() - ref.once 'sync', @modelLoaded, @ + @listenToOnce(ref, 'sync', @modelLoaded) @trigger 'loaded-one', model: model @trigger 'loaded-all' if @finished() diff --git a/app/views/account/wizard_settings_view.coffee b/app/views/account/wizard_settings_view.coffee index 9a5e20e9c..1458f78de 100644 --- a/app/views/account/wizard_settings_view.coffee +++ b/app/views/account/wizard_settings_view.coffee @@ -24,7 +24,7 @@ module.exports = class WizardSettingsView extends CocoView @wizardThangType = new ThangType() @wizardThangType.url = -> '/db/thang.type/wizard' @wizardThangType.fetch() - @wizardThangType.once 'sync', @initCanvas, @ + @listenToOnce(@wizardThangType, 'sync', @initCanvas) initCanvas: -> @startsLoading = false diff --git a/app/views/editor/thang/colors_tab_view.coffee b/app/views/editor/thang/colors_tab_view.coffee index b1ba229dc..ed438fb46 100644 --- a/app/views/editor/thang/colors_tab_view.coffee +++ b/app/views/editor/thang/colors_tab_view.coffee @@ -11,8 +11,8 @@ module.exports = class ColorsTabView extends CocoView offset: 0 constructor: (@thangType, options) -> - @thangType.once 'sync', @tryToBuild, @ - @thangType.schema().once 'sync', @tryToBuild, @ + @listenToOnce(@thangType, 'sync', @tryToBuild) + @listenToOnce(@thangType.schema(), 'sync', @tryToBuild) @colorConfig = { hue: 0, saturation: 0.5, lightness: 0.5 } @spriteBuilder = new SpriteBuilder(@thangType) f = => diff --git a/app/views/play/level/modal/victory_modal.coffee b/app/views/play/level/modal/victory_modal.coffee index adf75f0d6..3eb7d21f5 100644 --- a/app/views/play/level/modal/victory_modal.coffee +++ b/app/views/play/level/modal/victory_modal.coffee @@ -38,8 +38,8 @@ module.exports = class VictoryModal extends View @feedback = new LevelFeedback() @feedback.url = -> url @feedback.fetch() - @feedback.once 'sync', => @onFeedbackLoaded() - @feedback.once 'error', => @onFeedbackNotFound() + @listenToOnce(@feedback, 'sync', -> @onFeedbackLoaded()) + @listenToOnce(@feedback, 'error', -> @onFeedbackNotFound()) onFeedbackLoaded: -> @feedback.url = -> '/db/level.feedback/' + @id From 132b22f14a133bdb836052676c3e35f778961027 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Wed, 26 Mar 2014 13:50:01 -0700 Subject: [PATCH 02/11] Got the gplus friends loading now. --- app/assets/index.html | 2 +- app/templates/play/ladder/ladder_tab.jade | 4 +-- app/views/play/ladder/ladder_tab.coffee | 42 +++++++++++++---------- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/app/assets/index.html b/app/assets/index.html index 2ebd22dcf..b558ff66f 100644 --- a/app/assets/index.html +++ b/app/assets/index.html @@ -74,7 +74,7 @@