mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-11 16:21:08 -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'
|
||||
loadingErrorTemplate = require 'templates/loading_error'
|
||||
|
||||
lastToggleModalCall = 0
|
||||
visibleModal = null
|
||||
waitingModal = null
|
||||
classCount = 0
|
||||
|
@ -15,9 +16,6 @@ module.exports = class CocoView extends Backbone.View
|
|||
template: -> ''
|
||||
|
||||
events:
|
||||
'click a': 'toggleModal'
|
||||
'click button': 'toggleModal'
|
||||
'click li': 'toggleModal'
|
||||
'click .retry-loading-resource': 'onRetryResource'
|
||||
'click .retry-loading-request': 'onRetryRequest'
|
||||
|
||||
|
@ -46,7 +44,6 @@ module.exports = class CocoView extends Backbone.View
|
|||
@subviews = {}
|
||||
@listenToShortcuts()
|
||||
@updateProgressBar = _.debounce @updateProgressBar, 100
|
||||
@toggleModal = _.debounce @toggleModal, 100
|
||||
# Backbone.Mediator handles subscription setup/teardown automatically
|
||||
|
||||
@listenTo(@supermodel, 'loaded-all', @onLoaded)
|
||||
|
@ -150,7 +147,15 @@ module.exports = class CocoView extends Backbone.View
|
|||
|
||||
# Modals
|
||||
|
||||
@lastToggleModalCall = 0
|
||||
|
||||
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'
|
||||
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.
|
||||
|
|
|
@ -7,6 +7,11 @@ module.exports = class ModalView extends CocoView
|
|||
modalWidthPercent: null
|
||||
plain: false
|
||||
|
||||
events:
|
||||
'click a': 'toggleModal'
|
||||
'click button': 'toggleModal'
|
||||
'click li': 'toggleModal'
|
||||
|
||||
shortcuts:
|
||||
'esc': 'hide'
|
||||
|
||||
|
|
|
@ -22,6 +22,9 @@ module.exports = class RootView extends CocoView
|
|||
'change .language-dropdown': 'onLanguageChanged'
|
||||
'click .toggle-fullscreen': 'toggleFullscreen'
|
||||
'click .auth-button': 'onClickAuthbutton'
|
||||
'click a': 'toggleModal'
|
||||
'click button': 'toggleModal'
|
||||
'click li': 'toggleModal'
|
||||
|
||||
subscriptions:
|
||||
'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