diff --git a/app/core/ModuleLoader.coffee b/app/core/ModuleLoader.coffee index 6fa72db91..8ab2d7f43 100644 --- a/app/core/ModuleLoader.coffee +++ b/app/core/ModuleLoader.coffee @@ -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 diff --git a/app/core/initialize.coffee b/app/core/initialize.coffee index f3ad262e8..159fe627b 100644 --- a/app/core/initialize.coffee +++ b/app/core/initialize.coffee @@ -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/ diff --git a/app/models/CocoModel.coffee b/app/models/CocoModel.coffee index e68e36f36..dad2bc043 100644 --- a/app/models/CocoModel.coffee +++ b/app/models/CocoModel.coffee @@ -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 diff --git a/app/views/account/JobProfileTreemaView.coffee b/app/views/account/JobProfileTreemaView.coffee index cb9ea69cf..3e7d13153 100644 --- a/app/views/account/JobProfileTreemaView.coffee +++ b/app/views/account/JobProfileTreemaView.coffee @@ -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' diff --git a/app/views/editor/DeltaView.coffee b/app/views/editor/DeltaView.coffee index 8e40f75c6..a01cc9378 100644 --- a/app/views/editor/DeltaView.coffee +++ b/app/views/editor/DeltaView.coffee @@ -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" diff --git a/app/views/editor/article/ArticleEditView.coffee b/app/views/editor/article/ArticleEditView.coffee index f808b5a01..583df2891 100644 --- a/app/views/editor/article/ArticleEditView.coffee +++ b/app/views/editor/article/ArticleEditView.coffee @@ -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' diff --git a/app/views/editor/component/ThangComponentConfigView.coffee b/app/views/editor/component/ThangComponentConfigView.coffee index 2d7a90957..5b624d2a5 100644 --- a/app/views/editor/component/ThangComponentConfigView.coffee +++ b/app/views/editor/component/ThangComponentConfigView.coffee @@ -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' diff --git a/app/views/editor/component/ThangComponentsEditView.coffee b/app/views/editor/component/ThangComponentsEditView.coffee index 86fbf624e..344815b57 100644 --- a/app/views/editor/component/ThangComponentsEditView.coffee +++ b/app/views/editor/component/ThangComponentsEditView.coffee @@ -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' diff --git a/app/views/editor/level/LevelEditView.coffee b/app/views/editor/level/LevelEditView.coffee index 66c2d83c2..f00d52cbf 100644 --- a/app/views/editor/level/LevelEditView.coffee +++ b/app/views/editor/level/LevelEditView.coffee @@ -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' diff --git a/app/views/editor/level/components/ComponentsTabView.coffee b/app/views/editor/level/components/ComponentsTabView.coffee index e92e37027..9260af573 100644 --- a/app/views/editor/level/components/ComponentsTabView.coffee +++ b/app/views/editor/level/components/ComponentsTabView.coffee @@ -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' diff --git a/app/views/editor/level/components/LevelComponentEditView.coffee b/app/views/editor/level/components/LevelComponentEditView.coffee index fab0f5fc4..65e0672ac 100644 --- a/app/views/editor/level/components/LevelComponentEditView.coffee +++ b/app/views/editor/level/components/LevelComponentEditView.coffee @@ -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' diff --git a/app/views/editor/level/scripts/ScriptsTabView.coffee b/app/views/editor/level/scripts/ScriptsTabView.coffee index 98b48f7c1..aa772d4f6 100644 --- a/app/views/editor/level/scripts/ScriptsTabView.coffee +++ b/app/views/editor/level/scripts/ScriptsTabView.coffee @@ -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' diff --git a/app/views/editor/level/settings/SettingsTabView.coffee b/app/views/editor/level/settings/SettingsTabView.coffee index 0b30038b8..aa3308464 100644 --- a/app/views/editor/level/settings/SettingsTabView.coffee +++ b/app/views/editor/level/settings/SettingsTabView.coffee @@ -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' diff --git a/app/views/editor/level/systems/LevelSystemEditView.coffee b/app/views/editor/level/systems/LevelSystemEditView.coffee index 1bf4c1098..c76a5372e 100644 --- a/app/views/editor/level/systems/LevelSystemEditView.coffee +++ b/app/views/editor/level/systems/LevelSystemEditView.coffee @@ -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' diff --git a/app/views/editor/level/systems/SystemsTabView.coffee b/app/views/editor/level/systems/SystemsTabView.coffee index 3969a9e12..c02e78a19 100644 --- a/app/views/editor/level/systems/SystemsTabView.coffee +++ b/app/views/editor/level/systems/SystemsTabView.coffee @@ -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' diff --git a/app/views/editor/level/thangs/ThangsTabView.coffee b/app/views/editor/level/thangs/ThangsTabView.coffee index fcf0ce8e0..dbeaa0873 100644 --- a/app/views/editor/level/thangs/ThangsTabView.coffee +++ b/app/views/editor/level/thangs/ThangsTabView.coffee @@ -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 diff --git a/app/views/editor/level/treema_nodes.coffee b/app/views/editor/level/treema_nodes.coffee index e04092c8b..2cc00b7c3 100644 --- a/app/views/editor/level/treema_nodes.coffee +++ b/app/views/editor/level/treema_nodes.coffee @@ -2,6 +2,7 @@ WorldSelectModal = require './modals/WorldSelectModal' ThangType = require '/models/ThangType' LevelComponent = require 'models/LevelComponent' CocoCollection = require 'collections/CocoCollection' +require 'vendor/treema' makeButton = -> $('') shorten = (f) -> parseFloat(f.toFixed(1)) diff --git a/app/views/editor/thang/ThangTypeColorsTabView.coffee b/app/views/editor/thang/ThangTypeColorsTabView.coffee index 40c6b2ca2..293bef1d7 100644 --- a/app/views/editor/thang/ThangTypeColorsTabView.coffee +++ b/app/views/editor/thang/ThangTypeColorsTabView.coffee @@ -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' diff --git a/app/views/editor/thang/ThangTypeEditView.coffee b/app/views/editor/thang/ThangTypeEditView.coffee index a4cd81969..9ced01ee0 100644 --- a/app/views/editor/thang/ThangTypeEditView.coffee +++ b/app/views/editor/thang/ThangTypeEditView.coffee @@ -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' diff --git a/app/views/modal/ModelModal.coffee b/app/views/modal/ModelModal.coffee index ab3cc02d3..f074148d9 100644 --- a/app/views/modal/ModelModal.coffee +++ b/app/views/modal/ModelModal.coffee @@ -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' diff --git a/app/views/user/JobProfileView.coffee b/app/views/user/JobProfileView.coffee index 9f056d48d..ae31f5894 100644 --- a/app/views/user/JobProfileView.coffee +++ b/app/views/user/JobProfileView.coffee @@ -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" diff --git a/bower.json b/bower.json index 5a2fd714b..5d4718fb0 100644 --- a/bower.json +++ b/bower.json @@ -71,6 +71,13 @@ "src/formatters/html.css" ] }, + "treema": { + "main": [ + "treema.js", + "treema.css", + "treema-utils.js" + ] + }, "jquery.tablesorter": { "main": [ "js/jquery.tablesorter.js", diff --git a/config.coffee b/config.coffee index 5276f26cd..fd54de400 100644 --- a/config.coffee +++ b/config.coffee @@ -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/')