Adding some iPad event publishing optimizations. Fixed #1623.

This commit is contained in:
Nick Winter 2014-10-01 10:58:19 -07:00
parent b67d83b868
commit 5dd7c3ffa1
6 changed files with 19 additions and 2 deletions

View file

@ -177,3 +177,7 @@ module.exports = class CocoRouter extends Backbone.Router
@openView view
else
@openView e.view
navigate: (fragment, options) ->
super fragment, options
Backbone.Mediator.publish 'router:navigated', route: fragment

View file

@ -61,10 +61,12 @@ setUpBackboneMediator = ->
Backbone.Mediator.addChannelSchemas schemas for channel, schemas of channelSchemas
Backbone.Mediator.setValidationEnabled document.location.href.search(/codecombat.com/) is -1
if webkit?.messageHandlers
window.iPadSubscriptions = 'application:error': true # We try to subscribe to this one before it's all set up, so just do it.
originalPublish = Backbone.Mediator.publish
Backbone.Mediator.publish = ->
originalPublish.apply Backbone.Mediator, arguments
webkit.messageHandlers.backboneEventHandler?.postMessage channel: arguments[0], event: serializeForIOS(arguments[1] ? {})
if window.iPadSubscriptions[arguments[0]]
webkit.messageHandlers.backboneEventHandler?.postMessage channel: arguments[0], event: serializeForIOS(arguments[1] ? {})
setUpMoment = ->
{me} = require 'lib/auth'
@ -106,6 +108,12 @@ watchForErrors = ->
noty text: message, layout: 'topCenter', type: 'error', killer: false, timeout: 5000, dismissQueue: true, maxVisible: 3, callback: {onClose: -> --currentErrors}
Backbone.Mediator.publish 'application:error', message: msg # For iOS app
window.addIPadSubscription = (channel) ->
window.iPadSubscriptions[channel] = true
window.removeIPadSubscription = (channel) ->
window.iPadSubscriptions[channel] = false
setUpIOSLogging = ->
return unless webkit?.messageHandlers
for level in ['debug', 'log', 'info', 'warn', 'error']

View file

@ -59,6 +59,7 @@
about: "About"
contact: "Contact"
twitter_follow: "Follow"
teachers: "Teachers"
employers: "Employers"
versions:

View file

@ -29,6 +29,9 @@ module.exports =
viewClass: {type: 'function'}
viewArgs: {type: 'array'}
'router:navigated': c.object {required: ['route']},
route: {type: 'string'}
'achievements:new': c.object {required: ['earnedAchievements']},
earnedAchievements: {type: 'object'}

View file

@ -75,7 +75,7 @@ body
a(title='Contact', tabindex=-1, data-toggle="coco-modal", data-target="modal/ContactModal", data-i18n="nav.contact") Contact
a(href='http://blog.codecombat.com/', data-i18n="nav.blog") Blog
a(href='http://discourse.codecombat.com/', data-i18n="nav.forum") Forum
a(href='/teachers', data-i18n="nav.forum") Teachers
a(href='/teachers', data-i18n="nav.teachers") Teachers
if me.isAdmin()
a(href='/admin', data-i18n="nav.admin") Admin

View file

@ -94,6 +94,7 @@ exports.config =
semicolons: false
sass:
mode: 'ruby'
allowCache: true
onCompile: (files) ->
exec = require('child_process').exec