Merge pull request from codecombat/soffes/ipad

[WIP] Changes for iPad app
This commit is contained in:
Nick Winter 2015-10-29 16:24:39 -07:00
commit f100d6dba6
4 changed files with 6 additions and 11 deletions

View file

@ -46,7 +46,7 @@ console.debug ?= console.log # Needed for IE10 and earlier
Application = initialize: ->
Router = require('core/Router')
@isProduction = -> document.location.href.search('https?://localhost:3000') is -1
@isIPadApp = webkit?.messageHandlers? and navigator.userAgent?.indexOf('iPhone OS') isnt -1
@isIPadApp = webkit?.messageHandlers? and navigator.userAgent?.indexOf('CodeCombat-iPad') isnt -1
$('body').addClass 'ipad' if @isIPadApp
if $.browser.msie and parseInt($.browser.version) is 10
$("html").addClass("ie10")

View file

@ -68,13 +68,6 @@ setUpBackboneMediator = ->
Backbone.Mediator.addDefSchemas schemas for definition, schemas of definitionSchemas
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
if window.iPadSubscriptions[arguments[0]]
webkit.messageHandlers.backboneEventHandler?.postMessage channel: arguments[0], event: serializeForIOS(arguments[1] ? {})
setUpMoment = ->
{me} = require 'core/auth'

View file

@ -37,7 +37,7 @@ module.exports = class AccountSettingsView extends CocoView
#- Form input callbacks
onChangePanelInput: (e) ->
$(e.target).addClass 'changed'
if (JSON.stringify(document.getElementById('email1').className)).indexOf("changed") > -1 or (JSON.stringify(document.getElementById('password1').className)).indexOf("changed") > -1
if (JSON.stringify(document.getElementById('email1').className)).indexOf("changed") > -1 or (JSON.stringify(document.getElementById('password1').className)).indexOf("changed") > -1
$(e.target).removeClass 'changed'
else
@trigger 'input-changed'
@ -66,7 +66,7 @@ module.exports = class AccountSettingsView extends CocoView
#- Just copied from OptionsView, TODO refactor
onClickDeleteAccountButton: ->
forms.clearFormAlerts(@$el)
myEmail = me.get 'email'
myEmail = me.get 'email'
email1 = document.getElementById('email1').value
password1 = document.getElementById('password1').value
if Boolean(email1) and email1 is myEmail
@ -106,7 +106,7 @@ module.exports = class AccountSettingsView extends CocoView
message = $.i18n.t('account_settings.wrong_password', defaultValue: 'Wrong Password.')
err = [message: message, property: 'password1', formatted: true]
forms.applyErrorsToForm(@$el, err)
$('.nano').nanoScroller({scrollTo: @$el.find('.has-error')})
$('.nano').nanoScroller({scrollTo: @$el.find('.has-error')})
setTimeout callback, 100
else
message = $.i18n.t('account_settings.wrong_email', defaultValue: 'Wrong Email.')
@ -126,6 +126,7 @@ module.exports = class AccountSettingsView extends CocoView
type: 'success'
layout: 'topCenter'
_.delay ->
window?.webkit?.messageHandlers?.notification?.postMessage(name: "signOut") if window.application.isIPadApp
Backbone.Mediator.publish("auth:logging-out", {})
window.tracker?.trackEvent 'Log Out', category:'Homepage' if @id is 'home-view'
logoutUser($('#login-email').val())

View file

@ -50,6 +50,7 @@ module.exports = class RootView extends CocoView
cache: false
logoutAccount: ->
window?.webkit?.messageHandlers?.notification?.postMessage(name: "signOut") if window.application.isIPadApp
Backbone.Mediator.publish("auth:logging-out", {})
window.tracker?.trackEvent 'Log Out', category:'Homepage', ['Google Analytics'] if @id is 'home-view'
logoutUser($('#login-email').val())