mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-04 21:01:06 -05:00
Fixed #1153.
This commit is contained in:
parent
8f4e1b4bf0
commit
a1dd9a714e
4 changed files with 29 additions and 4 deletions
|
@ -4,6 +4,7 @@ CocoClass = require 'lib/CocoClass'
|
||||||
loadingScreenTemplate = require 'templates/loading'
|
loadingScreenTemplate = require 'templates/loading'
|
||||||
loadingErrorTemplate = require 'templates/loading_error'
|
loadingErrorTemplate = require 'templates/loading_error'
|
||||||
|
|
||||||
|
lastToggleModalCall = 0
|
||||||
visibleModal = null
|
visibleModal = null
|
||||||
waitingModal = null
|
waitingModal = null
|
||||||
classCount = 0
|
classCount = 0
|
||||||
|
@ -15,9 +16,6 @@ module.exports = class CocoView extends Backbone.View
|
||||||
template: -> ''
|
template: -> ''
|
||||||
|
|
||||||
events:
|
events:
|
||||||
'click a': 'toggleModal'
|
|
||||||
'click button': 'toggleModal'
|
|
||||||
'click li': 'toggleModal'
|
|
||||||
'click .retry-loading-resource': 'onRetryResource'
|
'click .retry-loading-resource': 'onRetryResource'
|
||||||
'click .retry-loading-request': 'onRetryRequest'
|
'click .retry-loading-request': 'onRetryRequest'
|
||||||
|
|
||||||
|
@ -46,7 +44,6 @@ module.exports = class CocoView extends Backbone.View
|
||||||
@subviews = {}
|
@subviews = {}
|
||||||
@listenToShortcuts()
|
@listenToShortcuts()
|
||||||
@updateProgressBar = _.debounce @updateProgressBar, 100
|
@updateProgressBar = _.debounce @updateProgressBar, 100
|
||||||
@toggleModal = _.debounce @toggleModal, 100
|
|
||||||
# Backbone.Mediator handles subscription setup/teardown automatically
|
# Backbone.Mediator handles subscription setup/teardown automatically
|
||||||
|
|
||||||
@listenTo(@supermodel, 'loaded-all', @onLoaded)
|
@listenTo(@supermodel, 'loaded-all', @onLoaded)
|
||||||
|
@ -150,7 +147,15 @@ module.exports = class CocoView extends Backbone.View
|
||||||
|
|
||||||
# Modals
|
# Modals
|
||||||
|
|
||||||
|
@lastToggleModalCall = 0
|
||||||
|
|
||||||
toggleModal: (e) ->
|
toggleModal: (e) ->
|
||||||
|
if new Date().getTime() - CocoView.lastToggleModalCall < 5
|
||||||
|
# Defensive move. This function has had a history of messing things up.
|
||||||
|
console.error 'toggleModal is getting called too often!'
|
||||||
|
return
|
||||||
|
CocoView.lastToggleModalCall = new Date().getTime()
|
||||||
|
|
||||||
if $(e.currentTarget).prop('target') is '_blank'
|
if $(e.currentTarget).prop('target') is '_blank'
|
||||||
return true
|
return true
|
||||||
# special handler for opening modals that are dynamically loaded, rather than static in the page. It works (or should work) like Bootstrap's modals, except use coco-modal for the data-toggle value.
|
# special handler for opening modals that are dynamically loaded, rather than static in the page. It works (or should work) like Bootstrap's modals, except use coco-modal for the data-toggle value.
|
||||||
|
|
|
@ -7,6 +7,11 @@ module.exports = class ModalView extends CocoView
|
||||||
modalWidthPercent: null
|
modalWidthPercent: null
|
||||||
plain: false
|
plain: false
|
||||||
|
|
||||||
|
events:
|
||||||
|
'click a': 'toggleModal'
|
||||||
|
'click button': 'toggleModal'
|
||||||
|
'click li': 'toggleModal'
|
||||||
|
|
||||||
shortcuts:
|
shortcuts:
|
||||||
'esc': 'hide'
|
'esc': 'hide'
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,9 @@ module.exports = class RootView extends CocoView
|
||||||
'change .language-dropdown': 'onLanguageChanged'
|
'change .language-dropdown': 'onLanguageChanged'
|
||||||
'click .toggle-fullscreen': 'toggleFullscreen'
|
'click .toggle-fullscreen': 'toggleFullscreen'
|
||||||
'click .auth-button': 'onClickAuthbutton'
|
'click .auth-button': 'onClickAuthbutton'
|
||||||
|
'click a': 'toggleModal'
|
||||||
|
'click button': 'toggleModal'
|
||||||
|
'click li': 'toggleModal'
|
||||||
|
|
||||||
subscriptions:
|
subscriptions:
|
||||||
'achievements:new': 'handleNewAchievements'
|
'achievements:new': 'handleNewAchievements'
|
||||||
|
|
12
test/app/views/modal/AuthModalView.spec.coffee
Normal file
12
test/app/views/modal/AuthModalView.spec.coffee
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
AuthModalView = require 'views/modal/auth_modal'
|
||||||
|
RecoverModalView = require 'views/modal/recover_modal'
|
||||||
|
|
||||||
|
describe 'AuthModalView', ->
|
||||||
|
it 'opens the recover modal when you click the recover link', ->
|
||||||
|
m = new AuthModalView()
|
||||||
|
m.render()
|
||||||
|
spyOn(m, 'openModalView')
|
||||||
|
m.$el.find('#link-to-recover').click()
|
||||||
|
expect(m.openModalView.calls.count()).toEqual(1)
|
||||||
|
args = m.openModalView.calls.argsFor(0)
|
||||||
|
expect(args[0] instanceof RecoverModalView).toBeTruthy()
|
Loading…
Reference in a new issue