Refactored to make TreemaUtils generally available but TreemaNode only available for views that need it.

This commit is contained in:
Scott Erickson 2014-11-29 17:51:32 -08:00
parent a1ce2fbf32
commit be809337c4
23 changed files with 41 additions and 5 deletions

View file

@ -85,6 +85,12 @@ module.exports = ModuleLoader = class ModuleLoader extends CocoClass
console.debug 'loaded', @recentPaths.length, 'files,', parseInt(@recentLoadedBytes/1024), 'KB'
@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) ->
bits = raw.match(/(require\(['"](.+?)['"])|(register\(['"].+?['"])/g) or []
rootFolder = null

View file

@ -33,8 +33,6 @@ init = ->
Backbone.history.start({ pushState: true })
handleNormalUrls()
setUpMoment() # Set up i18n for moment
treemaExt = require 'core/treema-ext'
treemaExt.setup()
handleNormalUrls = ->
# http://artsy.github.com/blog/2012/06/25/replacing-hashbang-routes-with-pushstate/

View file

@ -78,7 +78,7 @@ class CocoModel extends Backbone.Model
thisTV4 = tv4.freshApi()
thisTV4.addSchema('#', @schema())
thisTV4.addSchema('metaschema', require('schemas/metaschema'))
TreemaNode.utils.populateDefaults(clone, @schema(), thisTV4)
TreemaUtils.populateDefaults(clone, @schema(), thisTV4)
@attributesWithDefaults = clone
duration = new Date() - t0
console.debug "Populated defaults for #{@type()}#{if @attributes.name then ' ' + @attributes.name else ''} in #{duration}ms" if duration > 10

View file

@ -1,6 +1,7 @@
CocoView = require 'views/core/CocoView'
template = require 'templates/account/job-profile-treema-view'
{me} = require 'core/auth'
require 'vendor/treema'
module.exports = class JobProfileTreemaView extends CocoView
id: 'job-profile-view'

View file

@ -3,6 +3,7 @@ template = require 'templates/editor/delta'
deltasLib = require 'core/deltas'
require 'vendor/diffview'
require 'vendor/difflib'
require 'vendor/treema'
TEXTDIFF_OPTIONS =
baseTextName: "Old"

View file

@ -5,6 +5,7 @@ Article = require 'models/Article'
SaveVersionModal = require 'views/editor/modal/SaveVersionModal'
PatchesView = require 'views/editor/PatchesView'
require 'views/modal/RevertModal'
require 'vendor/treema'
module.exports = class ArticleEditView extends RootView
id: 'editor-article-edit-view'

View file

@ -4,6 +4,7 @@ template = require 'templates/editor/component/thang-component-config-view'
Level = require 'models/Level'
LevelComponent = require 'models/LevelComponent'
nodes = require '../level/treema_nodes'
require 'vendor/treema'
module.exports = class ThangComponentConfigView extends CocoView
className: 'thang-component-config-view'

View file

@ -8,6 +8,7 @@ ComponentsCollection = require 'collections/ComponentsCollection'
ThangComponentConfigView = require './ThangComponentConfigView'
AddThangComponentsModal = require './AddThangComponentsModal'
nodes = require '../level/treema_nodes'
require 'vendor/treema'
ThangType = require 'models/ThangType'
CocoCollection = require 'collections/CocoCollection'

View file

@ -27,6 +27,7 @@ LevelFeedbackView = require 'views/editor/level/LevelFeedbackView'
storage = require 'core/storage'
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
id: 'editor-level-view'

View file

@ -4,6 +4,7 @@ ThangType = require 'models/ThangType'
LevelComponent = require 'models/LevelComponent'
LevelComponentEditView = require './LevelComponentEditView'
LevelComponentNewView = require './NewLevelComponentModal'
require 'vendor/treema'
class LevelComponentCollection extends Backbone.Collection
url: '/db/level.component'

View file

@ -4,6 +4,7 @@ LevelComponent = require 'models/LevelComponent'
ComponentVersionsModal = require 'views/editor/component/ComponentVersionsModal'
PatchesView = require 'views/editor/PatchesView'
SaveVersionModal = require 'views/editor/modal/SaveVersionModal'
require 'vendor/treema'
module.exports = class LevelComponentEditView extends CocoView
id: 'level-component-edit-view'

View file

@ -4,6 +4,7 @@ Level = require 'models/Level'
Surface = require 'lib/surface/Surface'
nodes = require './../treema_nodes'
defaultScripts = require 'lib/DefaultScripts'
require 'vendor/treema'
module.exports = class ScriptsTabView extends CocoView
id: 'editor-level-scripts-tab-view'

View file

@ -4,6 +4,7 @@ Level = require 'models/Level'
Surface = require 'lib/surface/Surface'
nodes = require './../treema_nodes'
{me} = require 'core/auth'
require 'vendor/treema'
module.exports = class SettingsTabView extends CocoView
id: 'editor-level-settings-tab-view'

View file

@ -4,6 +4,7 @@ LevelSystem = require 'models/LevelSystem'
SystemVersionsModal = require 'views/editor/level/systems/SystemVersionsModal'
PatchesView = require 'views/editor/PatchesView'
SaveVersionModal = require 'views/editor/modal/SaveVersionModal'
require 'vendor/treema'
module.exports = class LevelSystemEditView extends CocoView
id: 'level-system-edit-view'

View file

@ -6,6 +6,7 @@ LevelSystemEditView = require './LevelSystemEditView'
NewLevelSystemModal = require './NewLevelSystemModal'
AddLevelSystemModal = require './AddLevelSystemModal'
nodes = require '../treema_nodes'
require 'vendor/treema'
module.exports = class SystemsTabView extends CocoView
id: 'systems-tab-view'

View file

@ -10,6 +10,7 @@ Surface = require 'lib/surface/Surface'
Thang = require 'lib/world/thang'
LevelThangEditView = require './LevelThangEditView'
ComponentsCollection = require 'collections/ComponentsCollection'
require 'vendor/treema'
# Moving the screen while dragging thangs constants
MOVE_MARGIN = 0.15

View file

@ -2,6 +2,7 @@ WorldSelectModal = require './modals/WorldSelectModal'
ThangType = require '/models/ThangType'
LevelComponent = require 'models/LevelComponent'
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>')
shorten = (f) -> parseFloat(f.toFixed(1))

View file

@ -2,6 +2,7 @@ CocoView = require 'views/core/CocoView'
template = require 'templates/editor/thang/colors_tab'
SpriteBuilder = require 'lib/sprites/SpriteBuilder'
{hexToHSL} = require 'core/utils'
require 'vendor/treema'
module.exports = class ThangTypeColorsTabView extends CocoView
id: 'editor-thang-colors-tab-view'

View file

@ -5,6 +5,7 @@ Lank = require 'lib/surface/Lank'
LayerAdapter = require 'lib/surface/LayerAdapter'
Camera = require 'lib/surface/Camera'
DocumentFiles = require 'collections/DocumentFiles'
require 'vendor/treema'
# in the template, but need to require to load them
require 'views/modal/RevertModal'

View file

@ -1,5 +1,6 @@
ModalView = require 'views/core/ModalView'
template = require 'templates/modal/model-modal'
require 'vendor/treema'
module.exports = class ModelModal extends ModalView
id: 'model-modal'

View file

@ -10,6 +10,7 @@ UserRemark = require 'models/UserRemark'
forms = require 'core/forms'
ModelModal = require 'views/modal/ModelModal'
JobProfileCodeModal = require './JobProfileCodeModal'
require 'vendor/treema'
class LevelSessionsCollection extends CocoCollection
url: -> "/db/user/#{@userID}/level.sessions/employer"

View file

@ -71,6 +71,13 @@
"src/formatters/html.css"
]
},
"treema": {
"main": [
"treema.js",
"treema.css",
"treema-utils.js"
]
},
"jquery.tablesorter": {
"main": [
"js/jquery.tablesorter.js",

View file

@ -16,7 +16,12 @@ exports.config =
paths:
public: 'public'
watched: ['app', 'vendor', 'test/app', 'test/demo']
watched: [
'app',
'vendor',
'test/app',
'test/demo'
]
conventions:
ignored: (path) -> _.str.startsWith(sysPath.basename(path), '_')
@ -64,7 +69,8 @@ exports.config =
#- vendor.js, all the vendor libraries
'javascripts/vendor.js': [
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
@ -81,6 +87,7 @@ exports.config =
'javascripts/app/vendor/coffeescript.js': 'vendor/scripts/coffeescript.js'
'javascripts/app/vendor/difflib.js': 'vendor/scripts/difflib.js'
'javascripts/app/vendor/diffview.js': 'vendor/scripts/diffview.js'
'javascripts/app/vendor/treema.js': regJoin('^bower_components/treema\\.js')
#- test, demo libraries
'javascripts/test-app.js': regJoin('^test/app/')