rename Metamaps.Backbone to Metamaps.DataModel
This commit is contained in:
parent
e4d193572f
commit
9cb3074245
13 changed files with 92 additions and 102 deletions
|
@ -11,7 +11,7 @@ import GlobalUI from './GlobalUI'
|
||||||
* Metamaps.Create.js
|
* Metamaps.Create.js
|
||||||
*
|
*
|
||||||
* Dependencies:
|
* Dependencies:
|
||||||
* - Metamaps.Backbone
|
* - Metamaps.DataModel
|
||||||
* - Metamaps.Metacodes
|
* - Metamaps.Metacodes
|
||||||
* - Metamaps.Topics
|
* - Metamaps.Topics
|
||||||
*/
|
*/
|
||||||
|
@ -59,7 +59,7 @@ const Create = {
|
||||||
}
|
}
|
||||||
|
|
||||||
var codesToSwitchToIds
|
var codesToSwitchToIds
|
||||||
var metacodeModels = new Metamaps.Backbone.MetacodeCollection()
|
var metacodeModels = new Metamaps.DataModel.MetacodeCollection()
|
||||||
Create.selectedMetacodeSetIndex = index
|
Create.selectedMetacodeSetIndex = index
|
||||||
Create.selectedMetacodeSet = 'metacodeset-' + set
|
Create.selectedMetacodeSet = 'metacodeset-' + set
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ import TopicCard from '../TopicCard'
|
||||||
import Visualize from '../Visualize'
|
import Visualize from '../Visualize'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Metamaps.Backbone.js.erb
|
* Metamaps.DataModel.js
|
||||||
*
|
*
|
||||||
* Dependencies:
|
* Dependencies:
|
||||||
* - Metamaps.Collaborators
|
* - Metamaps.Collaborators
|
||||||
|
@ -30,9 +30,9 @@ import Visualize from '../Visualize'
|
||||||
* - Metamaps.Topics
|
* - Metamaps.Topics
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const _Backbone = {}
|
const DataModel = {}
|
||||||
|
|
||||||
_Backbone.Map = Backbone.Model.extend({
|
DataModel.Map = Backbone.Model.extend({
|
||||||
urlRoot: '/maps',
|
urlRoot: '/maps',
|
||||||
blacklist: ['created_at', 'updated_at', 'created_at_clean', 'updated_at_clean', 'user_name', 'contributor_count', 'topic_count', 'synapse_count', 'topics', 'synapses', 'mappings', 'mappers'],
|
blacklist: ['created_at', 'updated_at', 'created_at_clean', 'updated_at_clean', 'user_name', 'contributor_count', 'topic_count', 'synapse_count', 'topics', 'synapses', 'mappings', 'mappers'],
|
||||||
toJSON: function (options) {
|
toJSON: function (options) {
|
||||||
|
@ -106,8 +106,8 @@ _Backbone.Map = Backbone.Model.extend({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
_Backbone.MapsCollection = Backbone.Collection.extend({
|
DataModel.MapsCollection = Backbone.Collection.extend({
|
||||||
model: _Backbone.Map,
|
model: DataModel.Map,
|
||||||
initialize: function (models, options) {
|
initialize: function (models, options) {
|
||||||
this.id = options.id
|
this.id = options.id
|
||||||
this.sortBy = options.sortBy
|
this.sortBy = options.sortBy
|
||||||
|
@ -174,7 +174,7 @@ _Backbone.MapsCollection = Backbone.Collection.extend({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
_Backbone.Message = Backbone.Model.extend({
|
DataModel.Message = Backbone.Model.extend({
|
||||||
urlRoot: '/messages',
|
urlRoot: '/messages',
|
||||||
blacklist: ['created_at', 'updated_at'],
|
blacklist: ['created_at', 'updated_at'],
|
||||||
toJSON: function (options) {
|
toJSON: function (options) {
|
||||||
|
@ -190,12 +190,12 @@ _Backbone.Message = Backbone.Model.extend({
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
_Backbone.MessageCollection = Backbone.Collection.extend({
|
DataModel.MessageCollection = Backbone.Collection.extend({
|
||||||
model: _Backbone.Message,
|
model: DataModel.Message,
|
||||||
url: '/messages'
|
url: '/messages'
|
||||||
})
|
})
|
||||||
|
|
||||||
_Backbone.Mapper = Backbone.Model.extend({
|
DataModel.Mapper = Backbone.Model.extend({
|
||||||
urlRoot: '/users',
|
urlRoot: '/users',
|
||||||
blacklist: ['created_at', 'updated_at'],
|
blacklist: ['created_at', 'updated_at'],
|
||||||
toJSON: function (options) {
|
toJSON: function (options) {
|
||||||
|
@ -211,13 +211,13 @@ _Backbone.Mapper = Backbone.Model.extend({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
_Backbone.MapperCollection = Backbone.Collection.extend({
|
DataModel.MapperCollection = Backbone.Collection.extend({
|
||||||
model: _Backbone.Mapper,
|
model: DataModel.Mapper,
|
||||||
url: '/users'
|
url: '/users'
|
||||||
})
|
})
|
||||||
|
|
||||||
_Backbone.init = function () {
|
DataModel.init = function () {
|
||||||
var self = _Backbone
|
var self = DataModel
|
||||||
|
|
||||||
self.Metacode = Backbone.Model.extend({
|
self.Metacode = Backbone.Model.extend({
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
|
@ -658,6 +658,6 @@ _Backbone.init = function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.attachCollectionEvents()
|
self.attachCollectionEvents()
|
||||||
}; // end _Backbone.init
|
}; // end DataModel.init
|
||||||
|
|
||||||
export default _Backbone
|
export default DataModel
|
|
@ -4,7 +4,7 @@ import Active from '../Active'
|
||||||
import GlobalUI from './index'
|
import GlobalUI from './index'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Metamaps.Backbone
|
* Metamaps.DataModel
|
||||||
* Metamaps.Maps
|
* Metamaps.Maps
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ const CreateMap = {
|
||||||
init: function () {
|
init: function () {
|
||||||
var self = CreateMap
|
var self = CreateMap
|
||||||
|
|
||||||
self.newMap = new Metamaps.Backbone.Map({ permission: 'commons' })
|
self.newMap = new Metamaps.DataModel.Map({ permission: 'commons' })
|
||||||
|
|
||||||
self.bindFormEvents()
|
self.bindFormEvents()
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ const CreateMap = {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bindFormEvents()
|
self.bindFormEvents()
|
||||||
self.newMap = new Metamaps.Backbone.Map({ permission: 'commons' })
|
self.newMap = new Metamaps.DataModel.Map({ permission: 'commons' })
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import Account from './Account'
|
||||||
import ImportDialog from './ImportDialog'
|
import ImportDialog from './ImportDialog'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Metamaps.Backbone
|
* Metamaps.DataModel
|
||||||
* Metamaps.Maps
|
* Metamaps.Maps
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ const GlobalUI = {
|
||||||
$('#lightbox_screen, #lightbox_close').click(self.closeLightbox)
|
$('#lightbox_screen, #lightbox_close').click(self.closeLightbox)
|
||||||
|
|
||||||
// initialize global backbone models and collections
|
// initialize global backbone models and collections
|
||||||
if (Active.Mapper) Active.Mapper = new Metamaps.Backbone.Mapper(Active.Mapper)
|
if (Active.Mapper) Active.Mapper = new Metamaps.DataModel.Mapper(Active.Mapper)
|
||||||
|
|
||||||
var myCollection = Metamaps.Maps.Mine ? Metamaps.Maps.Mine : []
|
var myCollection = Metamaps.Maps.Mine ? Metamaps.Maps.Mine : []
|
||||||
var sharedCollection = Metamaps.Maps.Shared ? Metamaps.Maps.Shared : []
|
var sharedCollection = Metamaps.Maps.Shared ? Metamaps.Maps.Shared : []
|
||||||
|
@ -51,13 +51,13 @@ const GlobalUI = {
|
||||||
}
|
}
|
||||||
var featuredCollection = Metamaps.Maps.Featured ? Metamaps.Maps.Featured : []
|
var featuredCollection = Metamaps.Maps.Featured ? Metamaps.Maps.Featured : []
|
||||||
var activeCollection = Metamaps.Maps.Active ? Metamaps.Maps.Active : []
|
var activeCollection = Metamaps.Maps.Active ? Metamaps.Maps.Active : []
|
||||||
Metamaps.Maps.Mine = new Metamaps.Backbone.MapsCollection(myCollection, { id: 'mine', sortBy: 'updated_at' })
|
Metamaps.Maps.Mine = new Metamaps.DataModel.MapsCollection(myCollection, { id: 'mine', sortBy: 'updated_at' })
|
||||||
Metamaps.Maps.Shared = new Metamaps.Backbone.MapsCollection(sharedCollection, { id: 'shared', sortBy: 'updated_at' })
|
Metamaps.Maps.Shared = new Metamaps.DataModel.MapsCollection(sharedCollection, { id: 'shared', sortBy: 'updated_at' })
|
||||||
Metamaps.Maps.Starred = new Metamaps.Backbone.MapsCollection(starredCollection, { id: 'starred', sortBy: 'updated_at' })
|
Metamaps.Maps.Starred = new Metamaps.DataModel.MapsCollection(starredCollection, { id: 'starred', sortBy: 'updated_at' })
|
||||||
// 'Mapper' refers to another mapper
|
// 'Mapper' refers to another mapper
|
||||||
Metamaps.Maps.Mapper = new Metamaps.Backbone.MapsCollection(mapperCollection, mapperOptionsObj)
|
Metamaps.Maps.Mapper = new Metamaps.DataModel.MapsCollection(mapperCollection, mapperOptionsObj)
|
||||||
Metamaps.Maps.Featured = new Metamaps.Backbone.MapsCollection(featuredCollection, { id: 'featured', sortBy: 'updated_at' })
|
Metamaps.Maps.Featured = new Metamaps.DataModel.MapsCollection(featuredCollection, { id: 'featured', sortBy: 'updated_at' })
|
||||||
Metamaps.Maps.Active = new Metamaps.Backbone.MapsCollection(activeCollection, { id: 'active', sortBy: 'updated_at' })
|
Metamaps.Maps.Active = new Metamaps.DataModel.MapsCollection(activeCollection, { id: 'active', sortBy: 'updated_at' })
|
||||||
},
|
},
|
||||||
showDiv: function (selector) {
|
showDiv: function (selector) {
|
||||||
$(selector).show()
|
$(selector).show()
|
||||||
|
|
|
@ -14,7 +14,7 @@ import Topic from './Topic'
|
||||||
* Metamaps.Import.js.erb
|
* Metamaps.Import.js.erb
|
||||||
*
|
*
|
||||||
* Dependencies:
|
* Dependencies:
|
||||||
* - Metamaps.Backbone
|
* - Metamaps.DataModel
|
||||||
* - Metamaps.Mappings
|
* - Metamaps.Mappings
|
||||||
* - Metamaps.Metacodes
|
* - Metamaps.Metacodes
|
||||||
* - Metamaps.Synapses
|
* - Metamaps.Synapses
|
||||||
|
@ -299,7 +299,7 @@ const Import = {
|
||||||
|
|
||||||
var topic_permission = permission || Active.Map.get('permission')
|
var topic_permission = permission || Active.Map.get('permission')
|
||||||
var defer_to_map_id = permission === topic_permission ? Active.Map.get('id') : null
|
var defer_to_map_id = permission === topic_permission ? Active.Map.get('id') : null
|
||||||
var topic = new Metamaps.Backbone.Topic({
|
var topic = new Metamaps.DataModel.Topic({
|
||||||
name: name,
|
name: name,
|
||||||
metacode_id: metacode.id,
|
metacode_id: metacode.id,
|
||||||
permission: topic_permission,
|
permission: topic_permission,
|
||||||
|
@ -314,7 +314,7 @@ const Import = {
|
||||||
self.cidMappings[import_id] = topic.cid
|
self.cidMappings[import_id] = topic.cid
|
||||||
}
|
}
|
||||||
|
|
||||||
var mapping = new Metamaps.Backbone.Mapping({
|
var mapping = new Metamaps.DataModel.Mapping({
|
||||||
xloc: xloc,
|
xloc: xloc,
|
||||||
yloc: yloc,
|
yloc: yloc,
|
||||||
mappable_id: topic.cid,
|
mappable_id: topic.cid,
|
||||||
|
@ -340,7 +340,7 @@ const Import = {
|
||||||
return
|
return
|
||||||
} // if
|
} // if
|
||||||
|
|
||||||
var synapse = new Metamaps.Backbone.Synapse({
|
var synapse = new Metamaps.DataModel.Synapse({
|
||||||
desc: desc || '',
|
desc: desc || '',
|
||||||
category: category || 'from-to',
|
category: category || 'from-to',
|
||||||
permission: permission,
|
permission: permission,
|
||||||
|
@ -349,7 +349,7 @@ const Import = {
|
||||||
})
|
})
|
||||||
Metamaps.Synapses.add(synapse)
|
Metamaps.Synapses.add(synapse)
|
||||||
|
|
||||||
var mapping = new Metamaps.Backbone.Mapping({
|
var mapping = new Metamaps.DataModel.Mapping({
|
||||||
mappable_type: 'Synapse',
|
mappable_type: 'Synapse',
|
||||||
mappable_id: synapse.cid
|
mappable_id: synapse.cid
|
||||||
})
|
})
|
||||||
|
|
|
@ -22,7 +22,7 @@ import InfoBox from './InfoBox'
|
||||||
* Metamaps.Map.js.erb
|
* Metamaps.Map.js.erb
|
||||||
*
|
*
|
||||||
* Dependencies:
|
* Dependencies:
|
||||||
* - Metamaps.Backbone
|
* - Metamaps.DataModel
|
||||||
* - Metamaps.Erb
|
* - Metamaps.Erb
|
||||||
* - Metamaps.Loading
|
* - Metamaps.Loading
|
||||||
* - Metamaps.Mappers
|
* - Metamaps.Mappers
|
||||||
|
@ -82,17 +82,16 @@ const Map = {
|
||||||
$('.viewOnly').removeClass('sendRequest sentRequest requestDenied').addClass(className)
|
$('.viewOnly').removeClass('sendRequest sentRequest requestDenied').addClass(className)
|
||||||
},
|
},
|
||||||
launch: function (id) {
|
launch: function (id) {
|
||||||
var bb = Metamaps.Backbone
|
|
||||||
var start = function (data) {
|
var start = function (data) {
|
||||||
Active.Map = new bb.Map(data.map)
|
Active.Map = new Metamaps.DataModel.Map(data.map)
|
||||||
Metamaps.Mappers = new bb.MapperCollection(data.mappers)
|
Metamaps.Mappers = new Metamaps.DataModel.MapperCollection(data.mappers)
|
||||||
Metamaps.Collaborators = new bb.MapperCollection(data.collaborators)
|
Metamaps.Collaborators = new Metamaps.DataModel.MapperCollection(data.collaborators)
|
||||||
Metamaps.Topics = new bb.TopicCollection(data.topics)
|
Metamaps.Topics = new Metamaps.DataModel.TopicCollection(data.topics)
|
||||||
Metamaps.Synapses = new bb.SynapseCollection(data.synapses)
|
Metamaps.Synapses = new Metamaps.DataModel.SynapseCollection(data.synapses)
|
||||||
Metamaps.Mappings = new bb.MappingCollection(data.mappings)
|
Metamaps.Mappings = new Metamaps.DataModel.MappingCollection(data.mappings)
|
||||||
Metamaps.Messages = data.messages
|
Metamaps.Messages = data.messages
|
||||||
Metamaps.Stars = data.stars
|
Metamaps.Stars = data.stars
|
||||||
Metamaps.Backbone.attachCollectionEvents()
|
Metamaps.DataModel.attachCollectionEvents()
|
||||||
|
|
||||||
var map = Active.Map
|
var map = Active.Map
|
||||||
var mapper = Active.Mapper
|
var mapper = Active.Mapper
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dependencies:
|
* Dependencies:
|
||||||
* Metamaps.Backbone
|
* Metamaps.DataModel
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const Mapper = {
|
const Mapper = {
|
||||||
|
@ -12,7 +12,7 @@ const Mapper = {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `/users/${id}.json`,
|
url: `/users/${id}.json`,
|
||||||
success: data => {
|
success: data => {
|
||||||
callback(new Metamaps.Backbone.Mapper(data))
|
callback(new Metamaps.DataModel.Mapper(data))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,11 @@
|
||||||
/* global Metamaps, $ */
|
/* global $ */
|
||||||
|
|
||||||
/*
|
|
||||||
* Metamaps.Realtime.js
|
|
||||||
*
|
|
||||||
* Dependencies:
|
|
||||||
* - Metamaps.Backbone
|
|
||||||
* - Metamaps.Erb
|
|
||||||
* - Metamaps.Mappers
|
|
||||||
* - Metamaps.Mappings
|
|
||||||
* - Metamaps.Messages
|
|
||||||
* - Metamaps.Synapses
|
|
||||||
* - Metamaps.Topics
|
|
||||||
*/
|
|
||||||
|
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import SimpleWebRTC from 'simplewebrtc'
|
import SimpleWebRTC from 'simplewebrtc'
|
||||||
import SocketIoConnection from 'simplewebrtc/socketioconnection'
|
import SocketIoConnection from 'simplewebrtc/socketioconnection'
|
||||||
|
|
||||||
import Active from '../Active'
|
import Active from '../Active'
|
||||||
|
import DataModel from '../DataModel'
|
||||||
import GlobalUI from '../GlobalUI'
|
import GlobalUI from '../GlobalUI'
|
||||||
import JIT from '../JIT'
|
import JIT from '../JIT'
|
||||||
import Synapse from '../Synapse'
|
import Synapse from '../Synapse'
|
||||||
|
@ -121,12 +109,14 @@ let Realtime = {
|
||||||
broadcastingStatus: false,
|
broadcastingStatus: false,
|
||||||
inConversation: false,
|
inConversation: false,
|
||||||
localVideo: null,
|
localVideo: null,
|
||||||
init: function () {
|
'junto_spinner_darkgrey.gif': '',
|
||||||
|
init: function (serverData) {
|
||||||
var self = Realtime
|
var self = Realtime
|
||||||
|
|
||||||
self.addJuntoListeners()
|
self.addJuntoListeners()
|
||||||
|
|
||||||
self.socket = new SocketIoConnection({ url: Metamaps.Erb['REALTIME_SERVER']})
|
self.socket = new SocketIoConnection({ url: serverData['REALTIME_SERVER']})
|
||||||
|
self['junto_spinner_darkgrey.gif'] = serverData['junto_spinner_darkgrey.gif']
|
||||||
|
|
||||||
self.socket.on('connect', function () {
|
self.socket.on('connect', function () {
|
||||||
console.log('connected')
|
console.log('connected')
|
||||||
|
@ -230,7 +220,7 @@ let Realtime = {
|
||||||
self.setupSocket()
|
self.setupSocket()
|
||||||
self.setupLocalSendables()
|
self.setupLocalSendables()
|
||||||
}
|
}
|
||||||
self.room.addMessages(new Metamaps.Backbone.MessageCollection(Metamaps.Messages), true)
|
self.room.addMessages(new DataModel.MessageCollection(DataModel.Messages), true)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
endActiveMap: function () {
|
endActiveMap: function () {
|
||||||
|
|
|
@ -7,6 +7,7 @@ everthing in this file happens as a result of websocket events
|
||||||
import { JUNTO_UPDATED } from './events'
|
import { JUNTO_UPDATED } from './events'
|
||||||
|
|
||||||
import Active from '../Active'
|
import Active from '../Active'
|
||||||
|
import DataModel from '../DataModel'
|
||||||
import GlobalUI from '../GlobalUI'
|
import GlobalUI from '../GlobalUI'
|
||||||
import Control from '../Control'
|
import Control from '../Control'
|
||||||
import Map from '../Map'
|
import Map from '../Map'
|
||||||
|
@ -22,7 +23,7 @@ export const juntoUpdated = self => state => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const synapseRemoved = self => data => {
|
export const synapseRemoved = self => data => {
|
||||||
var synapse = Metamaps.Synapses.get(data.mappableid)
|
var synapse = DataModel.Synapses.get(data.mappableid)
|
||||||
if (synapse) {
|
if (synapse) {
|
||||||
var edge = synapse.get('edge')
|
var edge = synapse.get('edge')
|
||||||
var mapping = synapse.getMapping()
|
var mapping = synapse.getMapping()
|
||||||
|
@ -36,8 +37,8 @@ export const synapseRemoved = self => data => {
|
||||||
if (edge.getData('displayIndex')) {
|
if (edge.getData('displayIndex')) {
|
||||||
delete edge.data.$displayIndex
|
delete edge.data.$displayIndex
|
||||||
}
|
}
|
||||||
Metamaps.Synapses.remove(synapse)
|
DataModel.Synapses.remove(synapse)
|
||||||
Metamaps.Mappings.remove(mapping)
|
DataModel.Mappings.remove(mapping)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,18 +64,18 @@ export const synapseCreated = self => data => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mapper = Metamaps.Mappers.get(data.mapperid)
|
mapper = DataModel.Mappers.get(data.mapperid)
|
||||||
if (mapper === undefined) {
|
if (mapper === undefined) {
|
||||||
Mapper.get(data.mapperid, function(m) {
|
Mapper.get(data.mapperid, function(m) {
|
||||||
Metamaps.Mappers.add(m)
|
DataModel.Mappers.add(m)
|
||||||
mapper = m
|
mapper = m
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/synapses/' + data.mappableid + '.json',
|
url: '/synapses/' + data.mappableid + '.json',
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
Metamaps.Synapses.add(response)
|
DataModel.Synapses.add(response)
|
||||||
synapse = Metamaps.Synapses.get(response.id)
|
synapse = DataModel.Synapses.get(response.id)
|
||||||
},
|
},
|
||||||
error: function () {
|
error: function () {
|
||||||
cancel = true
|
cancel = true
|
||||||
|
@ -83,8 +84,8 @@ export const synapseCreated = self => data => {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/mappings/' + data.mappingid + '.json',
|
url: '/mappings/' + data.mappingid + '.json',
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
Metamaps.Mappings.add(response)
|
DataModel.Mappings.add(response)
|
||||||
mapping = Metamaps.Mappings.get(response.id)
|
mapping = DataModel.Mappings.get(response.id)
|
||||||
},
|
},
|
||||||
error: function () {
|
error: function () {
|
||||||
cancel = true
|
cancel = true
|
||||||
|
@ -94,13 +95,13 @@ export const synapseCreated = self => data => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const topicRemoved = self => data => {
|
export const topicRemoved = self => data => {
|
||||||
var topic = Metamaps.Topics.get(data.mappableid)
|
var topic = DataModel.Topics.get(data.mappableid)
|
||||||
if (topic) {
|
if (topic) {
|
||||||
var node = topic.get('node')
|
var node = topic.get('node')
|
||||||
var mapping = topic.getMapping()
|
var mapping = topic.getMapping()
|
||||||
Control.hideNode(node.id)
|
Control.hideNode(node.id)
|
||||||
Metamaps.Topics.remove(topic)
|
DataModel.Topics.remove(topic)
|
||||||
Metamaps.Mappings.remove(mapping)
|
DataModel.Mappings.remove(mapping)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,18 +121,18 @@ export const topicCreated = self => data => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mapper = Metamaps.Mappers.get(data.mapperid)
|
mapper = DataModel.Mappers.get(data.mapperid)
|
||||||
if (mapper === undefined) {
|
if (mapper === undefined) {
|
||||||
Mapper.get(data.mapperid, function(m) {
|
Mapper.get(data.mapperid, function(m) {
|
||||||
Metamaps.Mappers.add(m)
|
DataModel.Mappers.add(m)
|
||||||
mapper = m
|
mapper = m
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/topics/' + data.mappableid + '.json',
|
url: '/topics/' + data.mappableid + '.json',
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
Metamaps.Topics.add(response)
|
DataModel.Topics.add(response)
|
||||||
topic = Metamaps.Topics.get(response.id)
|
topic = DataModel.Topics.get(response.id)
|
||||||
},
|
},
|
||||||
error: function () {
|
error: function () {
|
||||||
cancel = true
|
cancel = true
|
||||||
|
@ -140,8 +141,8 @@ export const topicCreated = self => data => {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/mappings/' + data.mappingid + '.json',
|
url: '/mappings/' + data.mappingid + '.json',
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
Metamaps.Mappings.add(response)
|
DataModel.Mappings.add(response)
|
||||||
mapping = Metamaps.Mappings.get(response.id)
|
mapping = DataModel.Mappings.get(response.id)
|
||||||
},
|
},
|
||||||
error: function () {
|
error: function () {
|
||||||
cancel = true
|
cancel = true
|
||||||
|
@ -152,7 +153,7 @@ export const topicCreated = self => data => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const messageCreated = self => data => {
|
export const messageCreated = self => data => {
|
||||||
self.room.addMessages(new Metamaps.Backbone.MessageCollection(data))
|
self.room.addMessages(new DataModel.MessageCollection(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const mapUpdated = self => data => {
|
export const mapUpdated = self => data => {
|
||||||
|
@ -182,7 +183,7 @@ export const mapUpdated = self => data => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const topicUpdated = self => data => {
|
export const topicUpdated = self => data => {
|
||||||
var topic = Metamaps.Topics.get(data.topicId)
|
var topic = DataModel.Topics.get(data.topicId)
|
||||||
if (topic) {
|
if (topic) {
|
||||||
var node = topic.get('node')
|
var node = topic.get('node')
|
||||||
topic.fetch({
|
topic.fetch({
|
||||||
|
@ -195,7 +196,7 @@ export const topicUpdated = self => data => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const synapseUpdated = self => data => {
|
export const synapseUpdated = self => data => {
|
||||||
var synapse = Metamaps.Synapses.get(data.synapseId)
|
var synapse = DataModel.Synapses.get(data.synapseId)
|
||||||
if (synapse) {
|
if (synapse) {
|
||||||
// edge reset necessary because fetch causes model reset
|
// edge reset necessary because fetch causes model reset
|
||||||
var edge = synapse.get('edge')
|
var edge = synapse.get('edge')
|
||||||
|
@ -214,7 +215,7 @@ export const topicDragged = self => positions => {
|
||||||
|
|
||||||
if (Active.Map) {
|
if (Active.Map) {
|
||||||
for (var key in positions) {
|
for (var key in positions) {
|
||||||
topic = Metamaps.Topics.get(key)
|
topic = DataModel.Topics.get(key)
|
||||||
if (topic) node = topic.get('node')
|
if (topic) node = topic.get('node')
|
||||||
if (node) node.pos.setc(positions[key].x, positions[key].y)
|
if (node) node.pos.setc(positions[key].x, positions[key].y)
|
||||||
} // for
|
} // for
|
||||||
|
@ -332,7 +333,7 @@ export const invitedToCall = self => inviter => {
|
||||||
self.soundId = self.room.chat.sound.play('sessioninvite')
|
self.soundId = self.room.chat.sound.play('sessioninvite')
|
||||||
|
|
||||||
var username = self.mappersOnMap[inviter].name
|
var username = self.mappersOnMap[inviter].name
|
||||||
var notifyText = '<img src="' + Metamaps.Erb['junto_spinner_darkgrey.gif'] + '" style="display: inline-block; margin-top: -12px; margin-bottom: -6px; vertical-align: top;" />'
|
var notifyText = '<img src="' + self['junto_spinner_darkgrey.gif'] + '" style="display: inline-block; margin-top: -12px; margin-bottom: -6px; vertical-align: top;" />'
|
||||||
notifyText += username + ' is inviting you to a conversation. Join live?'
|
notifyText += username + ' is inviting you to a conversation. Join live?'
|
||||||
notifyText += ' <button type="button" class="toast-button button" onclick="Metamaps.Realtime.acceptCall(' + inviter + ')">Yes</button>'
|
notifyText += ' <button type="button" class="toast-button button" onclick="Metamaps.Realtime.acceptCall(' + inviter + ')">Yes</button>'
|
||||||
notifyText += ' <button type="button" class="toast-button button btn-no" onclick="Metamaps.Realtime.denyCall(' + inviter + ')">No</button>'
|
notifyText += ' <button type="button" class="toast-button button btn-no" onclick="Metamaps.Realtime.denyCall(' + inviter + ')">No</button>'
|
||||||
|
|
|
@ -13,7 +13,7 @@ import Visualize from './Visualize'
|
||||||
* Metamaps.Synapse.js.erb
|
* Metamaps.Synapse.js.erb
|
||||||
*
|
*
|
||||||
* Dependencies:
|
* Dependencies:
|
||||||
* - Metamaps.Backbone
|
* - Metamaps.DataModel
|
||||||
* - Metamaps.Mappings
|
* - Metamaps.Mappings
|
||||||
* - Metamaps.Synapses
|
* - Metamaps.Synapses
|
||||||
* - Metamaps.Topics
|
* - Metamaps.Topics
|
||||||
|
@ -112,14 +112,14 @@ const Synapse = {
|
||||||
for (var i = 0; i < synapsesToCreate.length; i++) {
|
for (var i = 0; i < synapsesToCreate.length; i++) {
|
||||||
node1 = synapsesToCreate[i]
|
node1 = synapsesToCreate[i]
|
||||||
topic1 = node1.getData('topic')
|
topic1 = node1.getData('topic')
|
||||||
synapse = new Metamaps.Backbone.Synapse({
|
synapse = new Metamaps.DataModel.Synapse({
|
||||||
desc: Create.newSynapse.description,
|
desc: Create.newSynapse.description,
|
||||||
topic1_id: topic1.isNew() ? topic1.cid : topic1.id,
|
topic1_id: topic1.isNew() ? topic1.cid : topic1.id,
|
||||||
topic2_id: topic2.isNew() ? topic2.cid : topic2.id,
|
topic2_id: topic2.isNew() ? topic2.cid : topic2.id,
|
||||||
})
|
})
|
||||||
Metamaps.Synapses.add(synapse)
|
Metamaps.Synapses.add(synapse)
|
||||||
|
|
||||||
mapping = new Metamaps.Backbone.Mapping({
|
mapping = new Metamaps.DataModel.Mapping({
|
||||||
mappable_type: 'Synapse',
|
mappable_type: 'Synapse',
|
||||||
mappable_id: synapse.cid,
|
mappable_id: synapse.cid,
|
||||||
})
|
})
|
||||||
|
@ -139,7 +139,7 @@ const Synapse = {
|
||||||
node2
|
node2
|
||||||
|
|
||||||
self.get(id, synapse => {
|
self.get(id, synapse => {
|
||||||
var mapping = new Metamaps.Backbone.Mapping({
|
var mapping = new Metamaps.DataModel.Mapping({
|
||||||
mappable_type: 'Synapse',
|
mappable_type: 'Synapse',
|
||||||
mappable_id: synapse.id,
|
mappable_id: synapse.id,
|
||||||
})
|
})
|
||||||
|
|
|
@ -22,7 +22,7 @@ import Visualize from './Visualize'
|
||||||
* Metamaps.Topic.js.erb
|
* Metamaps.Topic.js.erb
|
||||||
*
|
*
|
||||||
* Dependencies:
|
* Dependencies:
|
||||||
* - Metamaps.Backbone
|
* - Metamaps.DataModel
|
||||||
* - Metamaps.Creators
|
* - Metamaps.Creators
|
||||||
* - Metamaps.Mappings
|
* - Metamaps.Mappings
|
||||||
* - Metamaps.Synapses
|
* - Metamaps.Synapses
|
||||||
|
@ -45,13 +45,13 @@ const Topic = {
|
||||||
} else callback(Metamaps.Topics.get(id))
|
} else callback(Metamaps.Topics.get(id))
|
||||||
},
|
},
|
||||||
launch: function (id) {
|
launch: function (id) {
|
||||||
var bb = Metamaps.Backbone
|
var bb = Metamaps.DataModel
|
||||||
var start = function (data) {
|
var start = function (data) {
|
||||||
Active.Topic = new bb.Topic(data.topic)
|
Active.Topic = new bb.Topic(data.topic)
|
||||||
Metamaps.Creators = new bb.MapperCollection(data.creators)
|
Metamaps.Creators = new bb.MapperCollection(data.creators)
|
||||||
Metamaps.Topics = new bb.TopicCollection([data.topic].concat(data.relatives))
|
Metamaps.Topics = new bb.TopicCollection([data.topic].concat(data.relatives))
|
||||||
Metamaps.Synapses = new bb.SynapseCollection(data.synapses)
|
Metamaps.Synapses = new bb.SynapseCollection(data.synapses)
|
||||||
Metamaps.Backbone.attachCollectionEvents()
|
Metamaps.DataModel.attachCollectionEvents()
|
||||||
|
|
||||||
document.title = Active.Topic.get('name') + ' | Metamaps'
|
document.title = Active.Topic.get('name') + ' | Metamaps'
|
||||||
|
|
||||||
|
@ -128,9 +128,9 @@ const Topic = {
|
||||||
if (data.topics.length > 0) Metamaps.Topics.add(data.topics)
|
if (data.topics.length > 0) Metamaps.Topics.add(data.topics)
|
||||||
if (data.synapses.length > 0) Metamaps.Synapses.add(data.synapses)
|
if (data.synapses.length > 0) Metamaps.Synapses.add(data.synapses)
|
||||||
|
|
||||||
var topicColl = new Metamaps.Backbone.TopicCollection(data.topics)
|
var topicColl = new Metamaps.DataModel.TopicCollection(data.topics)
|
||||||
topicColl.add(topic)
|
topicColl.add(topic)
|
||||||
var synapseColl = new Metamaps.Backbone.SynapseCollection(data.synapses)
|
var synapseColl = new Metamaps.DataModel.SynapseCollection(data.synapses)
|
||||||
|
|
||||||
var graph = JIT.convertModelsToJIT(topicColl, synapseColl)[0]
|
var graph = JIT.convertModelsToJIT(topicColl, synapseColl)[0]
|
||||||
Visualize.mGraph.op.sum(graph, {
|
Visualize.mGraph.op.sum(graph, {
|
||||||
|
@ -311,7 +311,7 @@ const Topic = {
|
||||||
|
|
||||||
var metacode = Metamaps.Metacodes.get(Create.newTopic.metacode)
|
var metacode = Metamaps.Metacodes.get(Create.newTopic.metacode)
|
||||||
|
|
||||||
var topic = new Metamaps.Backbone.Topic({
|
var topic = new Metamaps.DataModel.Topic({
|
||||||
name: Create.newTopic.name,
|
name: Create.newTopic.name,
|
||||||
metacode_id: metacode.id,
|
metacode_id: metacode.id,
|
||||||
defer_to_map_id: Active.Map.id
|
defer_to_map_id: Active.Map.id
|
||||||
|
@ -321,7 +321,7 @@ const Topic = {
|
||||||
if (Create.newTopic.pinned) {
|
if (Create.newTopic.pinned) {
|
||||||
var nextCoords = AutoLayout.getNextCoord({ mappings: Metamaps.Mappings })
|
var nextCoords = AutoLayout.getNextCoord({ mappings: Metamaps.Mappings })
|
||||||
}
|
}
|
||||||
var mapping = new Metamaps.Backbone.Mapping({
|
var mapping = new Metamaps.DataModel.Mapping({
|
||||||
xloc: nextCoords ? nextCoords.x : Create.newTopic.x,
|
xloc: nextCoords ? nextCoords.x : Create.newTopic.x,
|
||||||
yloc: nextCoords ? nextCoords.y : Create.newTopic.y,
|
yloc: nextCoords ? nextCoords.y : Create.newTopic.y,
|
||||||
mappable_id: topic.cid,
|
mappable_id: topic.cid,
|
||||||
|
@ -377,7 +377,7 @@ const Topic = {
|
||||||
})
|
})
|
||||||
Metamaps.Topics.add(topic)
|
Metamaps.Topics.add(topic)
|
||||||
|
|
||||||
var mapping = new Metamaps.Backbone.Mapping({
|
var mapping = new Metamaps.DataModel.Mapping({
|
||||||
xloc: Metamaps.Create.newTopic.x,
|
xloc: Metamaps.Create.newTopic.x,
|
||||||
yloc: Metamaps.Create.newTopic.y,
|
yloc: Metamaps.Create.newTopic.y,
|
||||||
mappable_id: topic.cid,
|
mappable_id: topic.cid,
|
||||||
|
@ -400,7 +400,7 @@ const Topic = {
|
||||||
|
|
||||||
self.get(id, (topic) => {
|
self.get(id, (topic) => {
|
||||||
var nextCoords = AutoLayout.getNextCoord({ mappings: Metamaps.Mappings })
|
var nextCoords = AutoLayout.getNextCoord({ mappings: Metamaps.Mappings })
|
||||||
var mapping = new Metamaps.Backbone.Mapping({
|
var mapping = new Metamaps.DataModel.Mapping({
|
||||||
xloc: nextCoords.x,
|
xloc: nextCoords.x,
|
||||||
yloc: nextCoords.y,
|
yloc: nextCoords.y,
|
||||||
mappable_type: 'Topic',
|
mappable_type: 'Topic',
|
||||||
|
|
|
@ -14,7 +14,7 @@ import VideoView from './VideoView'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dependencies:
|
* Dependencies:
|
||||||
* Metamaps.Backbone
|
* Metamaps.DataModel
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const Room = function(opts) {
|
const Room = function(opts) {
|
||||||
|
@ -170,14 +170,14 @@ Room.prototype.init = function () {
|
||||||
var self = this
|
var self = this
|
||||||
//this.roomRef.child('messages').push(data)
|
//this.roomRef.child('messages').push(data)
|
||||||
if (self.chat.alertSound) self.chat.sound.play('sendchat')
|
if (self.chat.alertSound) self.chat.sound.play('sendchat')
|
||||||
var m = new Metamaps.Backbone.Message({
|
var m = new Metamaps.DataModel.Message({
|
||||||
message: data.message,
|
message: data.message,
|
||||||
resource_id: Active.Map.id,
|
resource_id: Active.Map.id,
|
||||||
resource_type: "Map"
|
resource_type: "Map"
|
||||||
})
|
})
|
||||||
m.save(null, {
|
m.save(null, {
|
||||||
success: function (model, response) {
|
success: function (model, response) {
|
||||||
self.addMessages(new Metamaps.Backbone.MessageCollection(model), false, true)
|
self.addMessages(new Metamaps.DataModel.MessageCollection(model), false, true)
|
||||||
$(document).trigger(Room.events.newMessage, [model])
|
$(document).trigger(Room.events.newMessage, [model])
|
||||||
},
|
},
|
||||||
error: function (model, response) {
|
error: function (model, response) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import Account from './Account'
|
||||||
import Active from './Active'
|
import Active from './Active'
|
||||||
import Admin from './Admin'
|
import Admin from './Admin'
|
||||||
import AutoLayout from './AutoLayout'
|
import AutoLayout from './AutoLayout'
|
||||||
import Backbone from './Backbone'
|
import DataModel from './DataModel'
|
||||||
import Control from './Control'
|
import Control from './Control'
|
||||||
import Create from './Create'
|
import Create from './Create'
|
||||||
import Debug from './Debug'
|
import Debug from './Debug'
|
||||||
|
@ -38,7 +38,7 @@ Metamaps.Account = Account
|
||||||
Metamaps.Active = Active
|
Metamaps.Active = Active
|
||||||
Metamaps.Admin = Admin
|
Metamaps.Admin = Admin
|
||||||
Metamaps.AutoLayout = AutoLayout
|
Metamaps.AutoLayout = AutoLayout
|
||||||
Metamaps.Backbone = Backbone
|
Metamaps.DataModel = DataModel
|
||||||
Metamaps.Control = Control
|
Metamaps.Control = Control
|
||||||
Metamaps.Create = Create
|
Metamaps.Create = Create
|
||||||
Metamaps.Debug = Debug
|
Metamaps.Debug = Debug
|
||||||
|
|
Loading…
Reference in a new issue