mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 09:35:39 -05:00
Refactored to make TreemaUtils generally available but TreemaNode only available for views that need it.
This commit is contained in:
parent
a1ce2fbf32
commit
be809337c4
23 changed files with 41 additions and 5 deletions
|
@ -85,6 +85,12 @@ module.exports = ModuleLoader = class ModuleLoader extends CocoClass
|
||||||
console.debug 'loaded', @recentPaths.length, 'files,', parseInt(@recentLoadedBytes/1024), 'KB'
|
console.debug 'loaded', @recentPaths.length, 'files,', parseInt(@recentLoadedBytes/1024), 'KB'
|
||||||
@trigger 'load-complete'
|
@trigger 'load-complete'
|
||||||
|
|
||||||
|
# get treema set up only when the library loads, if it loads
|
||||||
|
if e.item.id is 'vendor/treema'
|
||||||
|
console.log 'setting up treema-ext'
|
||||||
|
treemaExt = require 'core/treema-ext'
|
||||||
|
treemaExt.setup()
|
||||||
|
|
||||||
parseDependencies: (raw) ->
|
parseDependencies: (raw) ->
|
||||||
bits = raw.match(/(require\(['"](.+?)['"])|(register\(['"].+?['"])/g) or []
|
bits = raw.match(/(require\(['"](.+?)['"])|(register\(['"].+?['"])/g) or []
|
||||||
rootFolder = null
|
rootFolder = null
|
||||||
|
|
|
@ -33,8 +33,6 @@ init = ->
|
||||||
Backbone.history.start({ pushState: true })
|
Backbone.history.start({ pushState: true })
|
||||||
handleNormalUrls()
|
handleNormalUrls()
|
||||||
setUpMoment() # Set up i18n for moment
|
setUpMoment() # Set up i18n for moment
|
||||||
treemaExt = require 'core/treema-ext'
|
|
||||||
treemaExt.setup()
|
|
||||||
|
|
||||||
handleNormalUrls = ->
|
handleNormalUrls = ->
|
||||||
# http://artsy.github.com/blog/2012/06/25/replacing-hashbang-routes-with-pushstate/
|
# http://artsy.github.com/blog/2012/06/25/replacing-hashbang-routes-with-pushstate/
|
||||||
|
|
|
@ -78,7 +78,7 @@ class CocoModel extends Backbone.Model
|
||||||
thisTV4 = tv4.freshApi()
|
thisTV4 = tv4.freshApi()
|
||||||
thisTV4.addSchema('#', @schema())
|
thisTV4.addSchema('#', @schema())
|
||||||
thisTV4.addSchema('metaschema', require('schemas/metaschema'))
|
thisTV4.addSchema('metaschema', require('schemas/metaschema'))
|
||||||
TreemaNode.utils.populateDefaults(clone, @schema(), thisTV4)
|
TreemaUtils.populateDefaults(clone, @schema(), thisTV4)
|
||||||
@attributesWithDefaults = clone
|
@attributesWithDefaults = clone
|
||||||
duration = new Date() - t0
|
duration = new Date() - t0
|
||||||
console.debug "Populated defaults for #{@type()}#{if @attributes.name then ' ' + @attributes.name else ''} in #{duration}ms" if duration > 10
|
console.debug "Populated defaults for #{@type()}#{if @attributes.name then ' ' + @attributes.name else ''} in #{duration}ms" if duration > 10
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
CocoView = require 'views/core/CocoView'
|
CocoView = require 'views/core/CocoView'
|
||||||
template = require 'templates/account/job-profile-treema-view'
|
template = require 'templates/account/job-profile-treema-view'
|
||||||
{me} = require 'core/auth'
|
{me} = require 'core/auth'
|
||||||
|
require 'vendor/treema'
|
||||||
|
|
||||||
module.exports = class JobProfileTreemaView extends CocoView
|
module.exports = class JobProfileTreemaView extends CocoView
|
||||||
id: 'job-profile-view'
|
id: 'job-profile-view'
|
||||||
|
|
|
@ -3,6 +3,7 @@ template = require 'templates/editor/delta'
|
||||||
deltasLib = require 'core/deltas'
|
deltasLib = require 'core/deltas'
|
||||||
require 'vendor/diffview'
|
require 'vendor/diffview'
|
||||||
require 'vendor/difflib'
|
require 'vendor/difflib'
|
||||||
|
require 'vendor/treema'
|
||||||
|
|
||||||
TEXTDIFF_OPTIONS =
|
TEXTDIFF_OPTIONS =
|
||||||
baseTextName: "Old"
|
baseTextName: "Old"
|
||||||
|
|
|
@ -5,6 +5,7 @@ Article = require 'models/Article'
|
||||||
SaveVersionModal = require 'views/editor/modal/SaveVersionModal'
|
SaveVersionModal = require 'views/editor/modal/SaveVersionModal'
|
||||||
PatchesView = require 'views/editor/PatchesView'
|
PatchesView = require 'views/editor/PatchesView'
|
||||||
require 'views/modal/RevertModal'
|
require 'views/modal/RevertModal'
|
||||||
|
require 'vendor/treema'
|
||||||
|
|
||||||
module.exports = class ArticleEditView extends RootView
|
module.exports = class ArticleEditView extends RootView
|
||||||
id: 'editor-article-edit-view'
|
id: 'editor-article-edit-view'
|
||||||
|
|
|
@ -4,6 +4,7 @@ template = require 'templates/editor/component/thang-component-config-view'
|
||||||
Level = require 'models/Level'
|
Level = require 'models/Level'
|
||||||
LevelComponent = require 'models/LevelComponent'
|
LevelComponent = require 'models/LevelComponent'
|
||||||
nodes = require '../level/treema_nodes'
|
nodes = require '../level/treema_nodes'
|
||||||
|
require 'vendor/treema'
|
||||||
|
|
||||||
module.exports = class ThangComponentConfigView extends CocoView
|
module.exports = class ThangComponentConfigView extends CocoView
|
||||||
className: 'thang-component-config-view'
|
className: 'thang-component-config-view'
|
||||||
|
|
|
@ -8,6 +8,7 @@ ComponentsCollection = require 'collections/ComponentsCollection'
|
||||||
ThangComponentConfigView = require './ThangComponentConfigView'
|
ThangComponentConfigView = require './ThangComponentConfigView'
|
||||||
AddThangComponentsModal = require './AddThangComponentsModal'
|
AddThangComponentsModal = require './AddThangComponentsModal'
|
||||||
nodes = require '../level/treema_nodes'
|
nodes = require '../level/treema_nodes'
|
||||||
|
require 'vendor/treema'
|
||||||
|
|
||||||
ThangType = require 'models/ThangType'
|
ThangType = require 'models/ThangType'
|
||||||
CocoCollection = require 'collections/CocoCollection'
|
CocoCollection = require 'collections/CocoCollection'
|
||||||
|
|
|
@ -27,6 +27,7 @@ LevelFeedbackView = require 'views/editor/level/LevelFeedbackView'
|
||||||
storage = require 'core/storage'
|
storage = require 'core/storage'
|
||||||
|
|
||||||
require 'vendor/coffeescript' # this is tenuous, since the LevelSession and LevelComponent models are what compile the code
|
require 'vendor/coffeescript' # this is tenuous, since the LevelSession and LevelComponent models are what compile the code
|
||||||
|
require 'vendor/treema'
|
||||||
|
|
||||||
module.exports = class LevelEditView extends RootView
|
module.exports = class LevelEditView extends RootView
|
||||||
id: 'editor-level-view'
|
id: 'editor-level-view'
|
||||||
|
|
|
@ -4,6 +4,7 @@ ThangType = require 'models/ThangType'
|
||||||
LevelComponent = require 'models/LevelComponent'
|
LevelComponent = require 'models/LevelComponent'
|
||||||
LevelComponentEditView = require './LevelComponentEditView'
|
LevelComponentEditView = require './LevelComponentEditView'
|
||||||
LevelComponentNewView = require './NewLevelComponentModal'
|
LevelComponentNewView = require './NewLevelComponentModal'
|
||||||
|
require 'vendor/treema'
|
||||||
|
|
||||||
class LevelComponentCollection extends Backbone.Collection
|
class LevelComponentCollection extends Backbone.Collection
|
||||||
url: '/db/level.component'
|
url: '/db/level.component'
|
||||||
|
|
|
@ -4,6 +4,7 @@ LevelComponent = require 'models/LevelComponent'
|
||||||
ComponentVersionsModal = require 'views/editor/component/ComponentVersionsModal'
|
ComponentVersionsModal = require 'views/editor/component/ComponentVersionsModal'
|
||||||
PatchesView = require 'views/editor/PatchesView'
|
PatchesView = require 'views/editor/PatchesView'
|
||||||
SaveVersionModal = require 'views/editor/modal/SaveVersionModal'
|
SaveVersionModal = require 'views/editor/modal/SaveVersionModal'
|
||||||
|
require 'vendor/treema'
|
||||||
|
|
||||||
module.exports = class LevelComponentEditView extends CocoView
|
module.exports = class LevelComponentEditView extends CocoView
|
||||||
id: 'level-component-edit-view'
|
id: 'level-component-edit-view'
|
||||||
|
|
|
@ -4,6 +4,7 @@ Level = require 'models/Level'
|
||||||
Surface = require 'lib/surface/Surface'
|
Surface = require 'lib/surface/Surface'
|
||||||
nodes = require './../treema_nodes'
|
nodes = require './../treema_nodes'
|
||||||
defaultScripts = require 'lib/DefaultScripts'
|
defaultScripts = require 'lib/DefaultScripts'
|
||||||
|
require 'vendor/treema'
|
||||||
|
|
||||||
module.exports = class ScriptsTabView extends CocoView
|
module.exports = class ScriptsTabView extends CocoView
|
||||||
id: 'editor-level-scripts-tab-view'
|
id: 'editor-level-scripts-tab-view'
|
||||||
|
|
|
@ -4,6 +4,7 @@ Level = require 'models/Level'
|
||||||
Surface = require 'lib/surface/Surface'
|
Surface = require 'lib/surface/Surface'
|
||||||
nodes = require './../treema_nodes'
|
nodes = require './../treema_nodes'
|
||||||
{me} = require 'core/auth'
|
{me} = require 'core/auth'
|
||||||
|
require 'vendor/treema'
|
||||||
|
|
||||||
module.exports = class SettingsTabView extends CocoView
|
module.exports = class SettingsTabView extends CocoView
|
||||||
id: 'editor-level-settings-tab-view'
|
id: 'editor-level-settings-tab-view'
|
||||||
|
|
|
@ -4,6 +4,7 @@ LevelSystem = require 'models/LevelSystem'
|
||||||
SystemVersionsModal = require 'views/editor/level/systems/SystemVersionsModal'
|
SystemVersionsModal = require 'views/editor/level/systems/SystemVersionsModal'
|
||||||
PatchesView = require 'views/editor/PatchesView'
|
PatchesView = require 'views/editor/PatchesView'
|
||||||
SaveVersionModal = require 'views/editor/modal/SaveVersionModal'
|
SaveVersionModal = require 'views/editor/modal/SaveVersionModal'
|
||||||
|
require 'vendor/treema'
|
||||||
|
|
||||||
module.exports = class LevelSystemEditView extends CocoView
|
module.exports = class LevelSystemEditView extends CocoView
|
||||||
id: 'level-system-edit-view'
|
id: 'level-system-edit-view'
|
||||||
|
|
|
@ -6,6 +6,7 @@ LevelSystemEditView = require './LevelSystemEditView'
|
||||||
NewLevelSystemModal = require './NewLevelSystemModal'
|
NewLevelSystemModal = require './NewLevelSystemModal'
|
||||||
AddLevelSystemModal = require './AddLevelSystemModal'
|
AddLevelSystemModal = require './AddLevelSystemModal'
|
||||||
nodes = require '../treema_nodes'
|
nodes = require '../treema_nodes'
|
||||||
|
require 'vendor/treema'
|
||||||
|
|
||||||
module.exports = class SystemsTabView extends CocoView
|
module.exports = class SystemsTabView extends CocoView
|
||||||
id: 'systems-tab-view'
|
id: 'systems-tab-view'
|
||||||
|
|
|
@ -10,6 +10,7 @@ Surface = require 'lib/surface/Surface'
|
||||||
Thang = require 'lib/world/thang'
|
Thang = require 'lib/world/thang'
|
||||||
LevelThangEditView = require './LevelThangEditView'
|
LevelThangEditView = require './LevelThangEditView'
|
||||||
ComponentsCollection = require 'collections/ComponentsCollection'
|
ComponentsCollection = require 'collections/ComponentsCollection'
|
||||||
|
require 'vendor/treema'
|
||||||
|
|
||||||
# Moving the screen while dragging thangs constants
|
# Moving the screen while dragging thangs constants
|
||||||
MOVE_MARGIN = 0.15
|
MOVE_MARGIN = 0.15
|
||||||
|
|
|
@ -2,6 +2,7 @@ WorldSelectModal = require './modals/WorldSelectModal'
|
||||||
ThangType = require '/models/ThangType'
|
ThangType = require '/models/ThangType'
|
||||||
LevelComponent = require 'models/LevelComponent'
|
LevelComponent = require 'models/LevelComponent'
|
||||||
CocoCollection = require 'collections/CocoCollection'
|
CocoCollection = require 'collections/CocoCollection'
|
||||||
|
require 'vendor/treema'
|
||||||
|
|
||||||
makeButton = -> $('<a class="btn btn-primary btn-xs treema-map-button"><span class="glyphicon glyphicon-screenshot"></span></a>')
|
makeButton = -> $('<a class="btn btn-primary btn-xs treema-map-button"><span class="glyphicon glyphicon-screenshot"></span></a>')
|
||||||
shorten = (f) -> parseFloat(f.toFixed(1))
|
shorten = (f) -> parseFloat(f.toFixed(1))
|
||||||
|
|
|
@ -2,6 +2,7 @@ CocoView = require 'views/core/CocoView'
|
||||||
template = require 'templates/editor/thang/colors_tab'
|
template = require 'templates/editor/thang/colors_tab'
|
||||||
SpriteBuilder = require 'lib/sprites/SpriteBuilder'
|
SpriteBuilder = require 'lib/sprites/SpriteBuilder'
|
||||||
{hexToHSL} = require 'core/utils'
|
{hexToHSL} = require 'core/utils'
|
||||||
|
require 'vendor/treema'
|
||||||
|
|
||||||
module.exports = class ThangTypeColorsTabView extends CocoView
|
module.exports = class ThangTypeColorsTabView extends CocoView
|
||||||
id: 'editor-thang-colors-tab-view'
|
id: 'editor-thang-colors-tab-view'
|
||||||
|
|
|
@ -5,6 +5,7 @@ Lank = require 'lib/surface/Lank'
|
||||||
LayerAdapter = require 'lib/surface/LayerAdapter'
|
LayerAdapter = require 'lib/surface/LayerAdapter'
|
||||||
Camera = require 'lib/surface/Camera'
|
Camera = require 'lib/surface/Camera'
|
||||||
DocumentFiles = require 'collections/DocumentFiles'
|
DocumentFiles = require 'collections/DocumentFiles'
|
||||||
|
require 'vendor/treema'
|
||||||
|
|
||||||
# in the template, but need to require to load them
|
# in the template, but need to require to load them
|
||||||
require 'views/modal/RevertModal'
|
require 'views/modal/RevertModal'
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
ModalView = require 'views/core/ModalView'
|
ModalView = require 'views/core/ModalView'
|
||||||
template = require 'templates/modal/model-modal'
|
template = require 'templates/modal/model-modal'
|
||||||
|
require 'vendor/treema'
|
||||||
|
|
||||||
module.exports = class ModelModal extends ModalView
|
module.exports = class ModelModal extends ModalView
|
||||||
id: 'model-modal'
|
id: 'model-modal'
|
||||||
|
|
|
@ -10,6 +10,7 @@ UserRemark = require 'models/UserRemark'
|
||||||
forms = require 'core/forms'
|
forms = require 'core/forms'
|
||||||
ModelModal = require 'views/modal/ModelModal'
|
ModelModal = require 'views/modal/ModelModal'
|
||||||
JobProfileCodeModal = require './JobProfileCodeModal'
|
JobProfileCodeModal = require './JobProfileCodeModal'
|
||||||
|
require 'vendor/treema'
|
||||||
|
|
||||||
class LevelSessionsCollection extends CocoCollection
|
class LevelSessionsCollection extends CocoCollection
|
||||||
url: -> "/db/user/#{@userID}/level.sessions/employer"
|
url: -> "/db/user/#{@userID}/level.sessions/employer"
|
||||||
|
|
|
@ -71,6 +71,13 @@
|
||||||
"src/formatters/html.css"
|
"src/formatters/html.css"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"treema": {
|
||||||
|
"main": [
|
||||||
|
"treema.js",
|
||||||
|
"treema.css",
|
||||||
|
"treema-utils.js"
|
||||||
|
]
|
||||||
|
},
|
||||||
"jquery.tablesorter": {
|
"jquery.tablesorter": {
|
||||||
"main": [
|
"main": [
|
||||||
"js/jquery.tablesorter.js",
|
"js/jquery.tablesorter.js",
|
||||||
|
|
|
@ -16,7 +16,12 @@ exports.config =
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
public: 'public'
|
public: 'public'
|
||||||
watched: ['app', 'vendor', 'test/app', 'test/demo']
|
watched: [
|
||||||
|
'app',
|
||||||
|
'vendor',
|
||||||
|
'test/app',
|
||||||
|
'test/demo'
|
||||||
|
]
|
||||||
|
|
||||||
conventions:
|
conventions:
|
||||||
ignored: (path) -> _.str.startsWith(sysPath.basename(path), '_')
|
ignored: (path) -> _.str.startsWith(sysPath.basename(path), '_')
|
||||||
|
@ -64,7 +69,8 @@ exports.config =
|
||||||
#- vendor.js, all the vendor libraries
|
#- vendor.js, all the vendor libraries
|
||||||
'javascripts/vendor.js': [
|
'javascripts/vendor.js': [
|
||||||
regJoin('^vendor/scripts/(?!(Box2d|coffeescript|difflib|diffview))')
|
regJoin('^vendor/scripts/(?!(Box2d|coffeescript|difflib|diffview))')
|
||||||
regJoin('^bower_components/(?!(aether|d3))')
|
regJoin('^bower_components/(?!(aether|d3|treema))')
|
||||||
|
'bower_components/treema/treema-utils.js'
|
||||||
]
|
]
|
||||||
|
|
||||||
#- Other vendor libraries in separate bunches
|
#- Other vendor libraries in separate bunches
|
||||||
|
@ -81,6 +87,7 @@ exports.config =
|
||||||
'javascripts/app/vendor/coffeescript.js': 'vendor/scripts/coffeescript.js'
|
'javascripts/app/vendor/coffeescript.js': 'vendor/scripts/coffeescript.js'
|
||||||
'javascripts/app/vendor/difflib.js': 'vendor/scripts/difflib.js'
|
'javascripts/app/vendor/difflib.js': 'vendor/scripts/difflib.js'
|
||||||
'javascripts/app/vendor/diffview.js': 'vendor/scripts/diffview.js'
|
'javascripts/app/vendor/diffview.js': 'vendor/scripts/diffview.js'
|
||||||
|
'javascripts/app/vendor/treema.js': regJoin('^bower_components/treema\\.js')
|
||||||
|
|
||||||
#- test, demo libraries
|
#- test, demo libraries
|
||||||
'javascripts/test-app.js': regJoin('^test/app/')
|
'javascripts/test-app.js': regJoin('^test/app/')
|
||||||
|
|
Loading…
Reference in a new issue