metamaps--metamaps/frontend/src/Metamaps/index.js

110 lines
3.3 KiB
JavaScript
Raw Normal View History

2016-09-26 05:37:42 +00:00
/* global Metamaps */
2016-02-03 13:38:41 +00:00
import Account from './Account'
import Active from './Active'
import Admin from './Admin'
import AutoLayout from './AutoLayout'
import Backbone from './Backbone'
import Control from './Control'
import Create from './Create'
import Debug from './Debug'
import Filter from './Filter'
2016-09-29 16:20:16 +00:00
import GlobalUI, {
Search, CreateMap, ImportDialog, Account as GlobalUI_Account
2016-09-29 16:20:16 +00:00
} from './GlobalUI'
import Import from './Import'
import JIT from './JIT'
import Listeners from './Listeners'
2016-09-22 15:51:13 +00:00
import Map, { CheatSheet, InfoBox } from './Map'
import Mapper from './Mapper'
import Mobile from './Mobile'
2016-09-22 09:14:34 +00:00
import Mouse from './Mouse'
import Organize from './Organize'
import PasteInput from './PasteInput'
import Realtime from './Realtime'
import Router from './Router'
2016-09-22 09:14:34 +00:00
import Selected from './Selected'
import Settings from './Settings'
import Synapse from './Synapse'
import SynapseCard from './SynapseCard'
import Topic from './Topic'
import TopicCard from './TopicCard'
import Util from './Util'
2016-09-23 00:16:18 +00:00
import Views from './Views'
import Visualize from './Visualize'
2016-09-25 10:49:16 +00:00
Metamaps = window.Metamaps || {}
Metamaps.Account = Account
Metamaps.Active = Active
Metamaps.Admin = Admin
Metamaps.AutoLayout = AutoLayout
Metamaps.Backbone = Backbone
Metamaps.Control = Control
Metamaps.Create = Create
Metamaps.Debug = Debug
Metamaps.Filter = Filter
Metamaps.GlobalUI = GlobalUI
2016-09-29 16:20:16 +00:00
Metamaps.GlobalUI.Search = Search
Metamaps.GlobalUI.CreateMap = CreateMap
Metamaps.GlobalUI.Account = GlobalUI_Account
Metamaps.GlobalUI.ImportDialog = ImportDialog
Metamaps.Import = Import
Metamaps.JIT = JIT
Metamaps.Listeners = Listeners
Metamaps.Map = Map
2016-09-22 15:51:13 +00:00
Metamaps.Map.CheatSheet = CheatSheet
Metamaps.Map.InfoBox = InfoBox
2016-09-22 09:14:34 +00:00
Metamaps.Maps = {}
Metamaps.Mapper = Mapper
Metamaps.Mobile = Mobile
2016-09-22 09:14:34 +00:00
Metamaps.Mouse = Mouse
Metamaps.Organize = Organize
Metamaps.PasteInput = PasteInput
Metamaps.Realtime = Realtime
Metamaps.Router = Router
2016-09-22 09:14:34 +00:00
Metamaps.Selected = Selected
Metamaps.Settings = Settings
Metamaps.Synapse = Synapse
Metamaps.SynapseCard = SynapseCard
Metamaps.Topic = Topic
Metamaps.TopicCard = TopicCard
Metamaps.Util = Util
Metamaps.Views = Views
Metamaps.Visualize = Visualize
2016-09-22 06:25:49 +00:00
2016-09-29 16:20:16 +00:00
document.addEventListener('DOMContentLoaded', function () {
// initialize all the modules
for (const prop in Metamaps) {
2016-09-29 16:20:16 +00:00
// this runs the init function within each sub-object on the Metamaps one
if (Metamaps.hasOwnProperty(prop) &&
Metamaps[prop] != null &&
Metamaps[prop].hasOwnProperty('init') &&
typeof (Metamaps[prop].init) === 'function'
) {
Metamaps[prop].init()
}
}
// load whichever page you are on
2016-09-29 16:20:16 +00:00
if (Metamaps.currentSection === 'explore') {
const capitalize = Metamaps.currentPage.charAt(0).toUpperCase() + Metamaps.currentPage.slice(1)
2016-09-29 16:20:16 +00:00
Metamaps.Views.ExploreMaps.setCollection(Metamaps.Maps[capitalize])
if (Metamaps.currentPage === 'mapper') {
Views.ExploreMaps.fetchUserThenRender()
} else {
Views.ExploreMaps.render()
2016-09-29 16:20:16 +00:00
}
GlobalUI.showDiv('#explore')
} else if (Metamaps.currentSection === '' && Active.Mapper) {
Views.ExploreMaps.setCollection(Metamaps.Maps.Active)
Views.ExploreMaps.render()
GlobalUI.showDiv('#explore')
} else if (Active.Map || Active.Topic) {
Metamaps.Loading.show()
2016-09-22 10:31:56 +00:00
JIT.prepareVizData()
GlobalUI.showDiv('#infovis')
}
2016-09-29 16:20:16 +00:00
})
export default Metamaps