Fix some demo views

This commit is contained in:
Scott Erickson 2016-01-07 09:40:35 -08:00
parent 5941c4b27f
commit 13b9d81e4c
8 changed files with 87 additions and 25 deletions

View file

@ -21,6 +21,7 @@ module.exports = ModuleLoader = class ModuleLoader extends CocoClass
# vendor libraries aren't actually wrapped with common.js, so short circuit those requires
return {} if _.string.startsWith(name, 'vendor/')
return {} if name is 'tests'
return {} if name is 'demo-app'
name = 'core/auth' if name is 'lib/auth' # proxy for iPad until it's been updated to use the new, refactored location. TODO: remove this
return func(name, loaderPath)
_.extend wrapped, window.require # for functions like 'list'

View file

@ -6,6 +6,9 @@ requireUtils = require 'lib/requireUtils'
DEMO_REQUIRE_PREFIX = 'test/demo/'
DEMO_URL_PREFIX = '/demo/'
require 'vendor/jasmine-bundle'
require 'demo-app'
###
What are demo files?
@ -33,24 +36,8 @@ module.exports = DemoView = class DemoView extends RootView
constructor: (options, @subPath='') ->
super(options)
@subPath = @subPath[1..] if @subPath[0] is '/'
@loadDemoingLibs() unless DemoView.loaded
loadDemoingLibs: ->
DemoView.loaded = true
@queue = new createjs.LoadQueue()
@queue.on('complete', @scriptsLoaded, @)
window.jasmine = {} # so that mock-ajax properly loads. It expects jasmine to be loaded
for f in ['mock-ajax', 'demo-app']
@queue.loadFile({
src: "/javascripts/#{f}.js"
type: createjs.LoadQueue.JAVASCRIPT
})
scriptsLoaded: ->
@initDemoFiles()
@children = requireUtils.parseImmediateChildren(@demoFiles, @subPath, DEMO_REQUIRE_PREFIX, DEMO_URL_PREFIX)
@render()
@runDemo()
# RENDER DATA
@ -62,6 +49,10 @@ module.exports = DemoView = class DemoView extends RootView
c.currentFolder = parts[parts.length-1] or parts[parts.length-2] or 'All'
c
afterInsert: ->
super()
@runDemo()
# RUNNING DEMOS
initDemoFiles: ->
@ -82,6 +73,7 @@ module.exports = DemoView = class DemoView extends RootView
jasmine.Ajax.install()
view = demoFunc()
return unless view
@ranDemo = true
if view instanceof ModalView
@openModalView(view)
else
@ -97,4 +89,5 @@ module.exports = DemoView = class DemoView extends RootView
destroy: ->
# hack to get jasmine tests to properly run again on clicking links, and make sure if you
# leave this page (say, back to the main site) that test stuff doesn't follow you.
if @ranDemo
document.location.reload()

View file

@ -130,7 +130,7 @@ exports.config =
#- test, demo libraries
'javascripts/app/tests.js': regJoin('^test/app/')
'javascripts/demo-app.js': regJoin('^test/demo/')
'javascripts/app/demo-app.js': regJoin('^test/demo/')
#- More output files are generated at the below

View file

@ -1,6 +1,6 @@
CocoModel = require 'models/CocoModel'
RootView = require 'views/kinds/RootView'
utils = require 'lib/utils'
RootView = require 'views/core/RootView'
utils = require 'core/utils'
Achievement = require 'models/Achievement'
EarnedAchievement = require 'models/EarnedAchievement'
fixtures = require '../../fixtures/achievements'

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,21 @@
module.exports = {
"_id": "53c997066567c600002a43d0",
"name": "Dungeon Arena",
"icon": "db/level/53173f76c269d400000543c2/11_dungeon.png",
"banner": "db/level/53173f76c269d400000543c2/dungeon_arena.png",
"employerDescription": "Players:\n* Attempt to destroy the enemy base.\n* Choose and control heroes to attack with.\n* Choose which types of lesser units to build and have limited control over them.\n* Try to write strategies that counter other enemy strategies.\n* Play on a small map.",
"systems": [],
"thangs": [],
"scripts": [],
"documentation": {
"generalArticles": [],
"specificArticles": []
},
"description": "This level is indescribably flarmy!",
"version": {
"minor": 0,
"major": 0,
"isLatestMajor": true,
"isLatestMinor": true
}
}

View file

@ -155,6 +155,6 @@ response =
module.exports = ->
view = new AddThangComponentsModal({skipOriginals:['52437c851d9e25b8dc000008']}) # FollowsNearest original
console.log jasmine.Ajax.requests.all()
jasmine.Ajax.requests.mostRecent().response({status: 200, responseText: JSON.stringify(response)})
jasmine.Ajax.requests.mostRecent().respondWith({status: 200, responseText: JSON.stringify(response)})
view.render()
return view