mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
Maybe fixing the toggleModal system once and for all.
This commit is contained in:
parent
59654da24b
commit
d651885524
2 changed files with 15 additions and 6 deletions
|
@ -150,12 +150,6 @@ module.exports = class CocoView extends Backbone.View
|
|||
@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.
|
||||
|
@ -163,6 +157,7 @@ module.exports = class CocoView extends Backbone.View
|
|||
return unless elem.data('toggle') is 'coco-modal'
|
||||
target = elem.data('target')
|
||||
view = application.router.getView(target, '_modal') # could set up a system for loading cached modals, if told to
|
||||
e.stopPropagation()
|
||||
@openModalView(view)
|
||||
|
||||
openModalView: (modalView, softly=false) ->
|
||||
|
|
14
test/app/views/editor/level/EditorLevelView.spec.coffee
Normal file
14
test/app/views/editor/level/EditorLevelView.spec.coffee
Normal file
|
@ -0,0 +1,14 @@
|
|||
EditorLevelView = require 'views/editor/level/edit'
|
||||
|
||||
emptyLevel = {"_id":"53a0a1e2d9048dbc3a793c81","name":"Emptiness","description":"Tis nothing..","documentation":{"generalArticles":[],"specificArticles":[]},"scripts":[],"thangs":[],"systems":[],"victory":{},"version":{"minor":0,"major":0,"isLatestMajor":true,"isLatestMinor":true},"index":"5388f9ac9a904d0000d94f87","slug":"emptiness","creator":"5388f9ac9a904d0000d94f87","original":"53a0a1e2d9048dbc3a793c81","watchers":["5388f9ac9a904d0000d94f87"],"__v":0,"created":"2014-06-17T20:15:30.207Z","permissions":[{"access":"owner","target":"5388f9ac9a904d0000d94f87"}]}
|
||||
|
||||
describe 'EditorLevelView', ->
|
||||
describe 'revert button', ->
|
||||
it 'opens just one modal when you click it', ->
|
||||
view = new EditorLevelView({}, 'something')
|
||||
request = jasmine.Ajax.requests.first()
|
||||
request.response {status:200, responseText: JSON.stringify(emptyLevel)}
|
||||
view.render()
|
||||
spyOn(view, 'openModalView')
|
||||
view.$el.find('#revert-button').click()
|
||||
expect(view.openModalView.calls.count()).toBe(1)
|
Loading…
Reference in a new issue