diff --git a/frontend/src/Metamaps/Account.js b/frontend/src/Metamaps/Account.js
index f424019f..10311cbd 100644
--- a/frontend/src/Metamaps/Account.js
+++ b/frontend/src/Metamaps/Account.js
@@ -1,12 +1,11 @@
-/* uses window.Metamaps.Erb */
+/*
+ * Metamaps.Erb
+ */
const Account = {
listenersInitialized: false,
- init: function () {
- var self = Metamaps.Account
- },
initListeners: function () {
- var self = Metamaps.Account
+ var self = Account
$('#user_image').change(self.showImagePreview)
self.listenersInitialized = true
diff --git a/frontend/src/Metamaps/AutoLayout.js b/frontend/src/Metamaps/AutoLayout.js
index 386b61ef..ee9dc33c 100644
--- a/frontend/src/Metamaps/AutoLayout.js
+++ b/frontend/src/Metamaps/AutoLayout.js
@@ -8,7 +8,7 @@ const AutoLayout = {
timeToTurn: 0,
getNextCoord: function () {
- var self = Metamaps.AutoLayout
+ var self = AutoLayout
var nextX = self.nextX
var nextY = self.nextY
@@ -55,7 +55,7 @@ const AutoLayout = {
}
},
resetSpiral: function () {
- var self = Metamaps.AutoLayout
+ var self = AutoLayout
self.nextX = 0
self.nextY = 0
self.nextXshift = 1
diff --git a/frontend/src/Metamaps/Backbone.js b/frontend/src/Metamaps/Backbone.js
index ce62c6be..9f18ef32 100644
--- a/frontend/src/Metamaps/Backbone.js
+++ b/frontend/src/Metamaps/Backbone.js
@@ -26,9 +26,9 @@ window.Metamaps = window.Metamaps || {}
* - Metamaps.Visualize
*/
-Metamaps.Backbone = {}
+const _Backbone = {}
-Metamaps.Backbone.Map = Backbone.Model.extend({
+_Backbone.Map = Backbone.Model.extend({
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'],
toJSON: function (options) {
@@ -82,7 +82,7 @@ Metamaps.Backbone.Map = Backbone.Model.extend({
return Metamaps.Mapper.get(this.get('user_id'))
},
fetchContained: function () {
- var bb = Metamaps.Backbone
+ var bb = _Backbone
var that = this
var start = function (data) {
that.set('mappers', new bb.MapperCollection(data.mappers))
@@ -143,8 +143,8 @@ Metamaps.Backbone.Map = Backbone.Model.extend({
}
}
})
-Metamaps.Backbone.MapsCollection = Backbone.Collection.extend({
- model: Metamaps.Backbone.Map,
+_Backbone.MapsCollection = Backbone.Collection.extend({
+ model: _Backbone.Map,
initialize: function (models, options) {
this.id = options.id
this.sortBy = options.sortBy
@@ -211,7 +211,7 @@ Metamaps.Backbone.MapsCollection = Backbone.Collection.extend({
}
})
-Metamaps.Backbone.Message = Backbone.Model.extend({
+_Backbone.Message = Backbone.Model.extend({
urlRoot: '/messages',
blacklist: ['created_at', 'updated_at'],
toJSON: function (options) {
@@ -227,12 +227,12 @@ Metamaps.Backbone.Message = Backbone.Model.extend({
*/
}
})
-Metamaps.Backbone.MessageCollection = Backbone.Collection.extend({
- model: Metamaps.Backbone.Message,
+_Backbone.MessageCollection = Backbone.Collection.extend({
+ model: _Backbone.Message,
url: '/messages'
})
-Metamaps.Backbone.Mapper = Backbone.Model.extend({
+_Backbone.Mapper = Backbone.Model.extend({
urlRoot: '/users',
blacklist: ['created_at', 'updated_at'],
toJSON: function (options) {
@@ -248,13 +248,13 @@ Metamaps.Backbone.Mapper = Backbone.Model.extend({
}
})
-Metamaps.Backbone.MapperCollection = Backbone.Collection.extend({
- model: Metamaps.Backbone.Mapper,
+_Backbone.MapperCollection = Backbone.Collection.extend({
+ model: _Backbone.Mapper,
url: '/users'
})
-Metamaps.Backbone.init = function () {
- var self = Metamaps.Backbone
+_Backbone.init = function () {
+ var self = _Backbone
self.Metacode = Backbone.Model.extend({
initialize: function () {
@@ -694,6 +694,6 @@ Metamaps.Backbone.init = function () {
}
}
self.attachCollectionEvents()
-}; // end Metamaps.Backbone.init
+}; // end _Backbone.init
-export default Metamaps.Backbone
+export default _Backbone
diff --git a/frontend/src/Metamaps/Control.js b/frontend/src/Metamaps/Control.js
index 3eecb126..9e13e40c 100644
--- a/frontend/src/Metamaps/Control.js
+++ b/frontend/src/Metamaps/Control.js
@@ -2,6 +2,7 @@
import Active from './Active'
import Filter from './Filter'
+import GlobalUI from './GlobalUI'
import JIT from './JIT'
import Mouse from './Mouse'
import Selected from './Selected'
@@ -12,7 +13,6 @@ import Visualize from './Visualize'
* Metamaps.Control.js
*
* Dependencies:
- * - Metamaps.GlobalUI
* - Metamaps.Mappings
* - Metamaps.Metacodes
* - Metamaps.Synapses
@@ -57,7 +57,7 @@ const Control = {
var authorized = Active.Map.authorizeToEdit(Active.Mapper)
if (!authorized) {
- Metamaps.GlobalUI.notifyUser('Cannot edit Public map.')
+ GlobalUI.notifyUser('Cannot edit Public map.')
return
}
@@ -73,7 +73,7 @@ const Control = {
var authorized = Active.Map.authorizeToEdit(Active.Mapper)
if (!authorized) {
- Metamaps.GlobalUI.notifyUser('Cannot edit Public map.')
+ GlobalUI.notifyUser('Cannot edit Public map.')
return
}
@@ -89,7 +89,7 @@ const Control = {
var authorized = Active.Map.authorizeToEdit(Active.Mapper)
if (!authorized) {
- Metamaps.GlobalUI.notifyUser('Cannot edit Public map.')
+ GlobalUI.notifyUser('Cannot edit Public map.')
return
}
@@ -107,7 +107,7 @@ const Control = {
}])
Control.hideNode(nodeid)
} else {
- Metamaps.GlobalUI.notifyUser('Only topics you created can be deleted')
+ GlobalUI.notifyUser('Only topics you created can be deleted')
}
},
removeSelectedNodes: function () { // refers to removing topics permanently from a map
@@ -132,7 +132,7 @@ const Control = {
authorized = Active.Map.authorizeToEdit(Active.Mapper)
if (!authorized) {
- Metamaps.GlobalUI.notifyUser('Cannot edit Public map.')
+ GlobalUI.notifyUser('Cannot edit Public map.')
return
}
@@ -148,7 +148,7 @@ const Control = {
var node = Visualize.mGraph.graph.getNode(nodeid)
if (!authorized) {
- Metamaps.GlobalUI.notifyUser('Cannot edit Public map.')
+ GlobalUI.notifyUser('Cannot edit Public map.')
return
}
@@ -251,7 +251,7 @@ const Control = {
var authorized = Active.Map.authorizeToEdit(Active.Mapper)
if (!authorized) {
- Metamaps.GlobalUI.notifyUser('Cannot edit Public map.')
+ GlobalUI.notifyUser('Cannot edit Public map.')
return
}
@@ -266,7 +266,7 @@ const Control = {
var authorized = Active.Map.authorizeToEdit(Active.Mapper)
if (!authorized) {
- Metamaps.GlobalUI.notifyUser('Cannot edit Public map.')
+ GlobalUI.notifyUser('Cannot edit Public map.')
return
}
@@ -294,7 +294,7 @@ const Control = {
mappableid: mappableid
}])
} else {
- Metamaps.GlobalUI.notifyUser('Only synapses you created can be deleted')
+ GlobalUI.notifyUser('Only synapses you created can be deleted')
}
},
removeSelectedEdges: function () {
@@ -308,7 +308,7 @@ const Control = {
var authorized = Active.Map.authorizeToEdit(Active.Mapper)
if (!authorized) {
- Metamaps.GlobalUI.notifyUser('Cannot edit Public map.')
+ GlobalUI.notifyUser('Cannot edit Public map.')
return
}
@@ -324,7 +324,7 @@ const Control = {
var authorized = Active.Map.authorizeToEdit(Active.Mapper)
if (!authorized) {
- Metamaps.GlobalUI.notifyUser('Cannot edit Public map.')
+ GlobalUI.notifyUser('Cannot edit Public map.')
return
}
@@ -378,7 +378,7 @@ const Control = {
updateSelectedPermissions: function (permission) {
var edge, synapse, node, topic
- Metamaps.GlobalUI.notifyUser('Working...')
+ GlobalUI.notifyUser('Working...')
// variables to keep track of how many nodes and synapses you had the ability to change the permission of
var nCount = 0,
@@ -416,12 +416,12 @@ const Control = {
var sString = sCount == 1 ? (sCount.toString() + ' synapse') : (sCount.toString() + ' synapses')
var message = nString + sString + ' you created updated to ' + permission
- Metamaps.GlobalUI.notifyUser(message)
+ GlobalUI.notifyUser(message)
},
updateSelectedMetacodes: function (metacode_id) {
var node, topic
- Metamaps.GlobalUI.notifyUser('Working...')
+ GlobalUI.notifyUser('Working...')
var metacode = Metamaps.Metacodes.get(metacode_id)
@@ -445,7 +445,7 @@ const Control = {
var nString = nCount == 1 ? (nCount.toString() + ' topic') : (nCount.toString() + ' topics')
var message = nString + ' you can edit updated to ' + metacode.get('name')
- Metamaps.GlobalUI.notifyUser(message)
+ GlobalUI.notifyUser(message)
Visualize.mGraph.plot()
},
}
diff --git a/frontend/src/Metamaps/Create.js b/frontend/src/Metamaps/Create.js
index 49267d6d..c9252aba 100644
--- a/frontend/src/Metamaps/Create.js
+++ b/frontend/src/Metamaps/Create.js
@@ -5,13 +5,13 @@ import Selected from './Selected'
import Synapse from './Synapse'
import Topic from './Topic'
import Visualize from './Visualize'
+import GlobalUI from './GlobalUI'
/*
* Metamaps.Create.js
*
* Dependencies:
* - Metamaps.Backbone
- * - Metamaps.GlobalUI
* - Metamaps.Metacodes
*/
@@ -101,7 +101,7 @@ const Create = {
bringToFront: true
})
- Metamaps.GlobalUI.closeLightbox()
+ GlobalUI.closeLightbox()
$('#topic_name').focus()
var mdata = {
diff --git a/frontend/src/Metamaps/Debug.js b/frontend/src/Metamaps/Debug.js
index e8e40e69..0fe5f769 100644
--- a/frontend/src/Metamaps/Debug.js
+++ b/frontend/src/Metamaps/Debug.js
@@ -1,6 +1,6 @@
-const Debug = () => {
- console.debug(window.Metamaps)
- console.debug(`Metamaps Version: ${window.Metamaps.VERSION}`)
+const Debug = (arg = window.Metamaps) => {
+ console.debug(arg)
+ console.debug(`Metamaps Version: ${arg.VERSION}`)
}
export default Debug
diff --git a/frontend/src/Metamaps/Filter.js b/frontend/src/Metamaps/Filter.js
index aed9964d..38c4f369 100644
--- a/frontend/src/Metamaps/Filter.js
+++ b/frontend/src/Metamaps/Filter.js
@@ -2,6 +2,7 @@
import Active from './Active'
import Control from './Control'
+import GlobalUI from './GlobalUI'
import Settings from './Settings'
import Visualize from './Visualize'
@@ -10,7 +11,6 @@ import Visualize from './Visualize'
*
* Dependencies:
* - Metamaps.Creators
- * - Metamaps.GlobalUI
* - Metamaps.Mappers
* - Metamaps.Metacodes
* - Metamaps.Synapses
@@ -56,7 +56,7 @@ const Filter = {
open: function () {
var self = Filter
- Metamaps.GlobalUI.Account.close()
+ GlobalUI.Account.close()
$('.sidebarFilterIcon div').addClass('hide')
if (!self.isOpen && !self.changing) {
diff --git a/frontend/src/Metamaps/GlobalUI.js b/frontend/src/Metamaps/GlobalUI.js
index 5abf25ee..b24b31c7 100644
--- a/frontend/src/Metamaps/GlobalUI.js
+++ b/frontend/src/Metamaps/GlobalUI.js
@@ -1,317 +1,326 @@
-window.Metamaps = window.Metamaps || {};
+import Active from './Active'
+import Create from './Create'
+import Filter from './Filter'
+import Router from './Router'
+
+/*
+ * Metamaps.Backbone
+ * Metamaps.Erb
+ * Metamaps.Maps
+ */
const GlobalUI = {
- notifyTimeout: null,
- lightbox: null,
- init: function () {
- var self = GlobalUI;
+ notifyTimeout: null,
+ lightbox: null,
+ init: function () {
+ var self = GlobalUI;
- self.Search.init();
- self.CreateMap.init();
- self.Account.init();
-
- if ($('#toast').html().trim()) self.notifyUser($('#toast').html())
+ self.Search.init();
+ self.CreateMap.init();
+ self.Account.init();
- //bind lightbox clicks
- $('.openLightbox').click(function (event) {
- self.openLightbox($(this).attr('data-open'));
- event.preventDefault();
- return false;
- });
+ if ($('#toast').html().trim()) self.notifyUser($('#toast').html())
- $('#lightbox_screen, #lightbox_close').click(self.closeLightbox);
+ //bind lightbox clicks
+ $('.openLightbox').click(function (event) {
+ self.openLightbox($(this).attr('data-open'));
+ event.preventDefault();
+ return false;
+ });
- // initialize global backbone models and collections
- if (Metamaps.Active.Mapper) Metamaps.Active.Mapper = new Metamaps.Backbone.Mapper(Metamaps.Active.Mapper);
+ $('#lightbox_screen, #lightbox_close').click(self.closeLightbox);
- var myCollection = Metamaps.Maps.Mine ? Metamaps.Maps.Mine : [];
- var sharedCollection = Metamaps.Maps.Shared ? Metamaps.Maps.Shared : [];
- var starredCollection = Metamaps.Maps.Starred ? Metamaps.Maps.Starred : [];
- var mapperCollection = [];
- var mapperOptionsObj = {id: 'mapper', sortBy: 'updated_at' };
- if (Metamaps.Maps.Mapper) {
- mapperCollection = Metamaps.Maps.Mapper.models;
- mapperOptionsObj.mapperId = Metamaps.Maps.Mapper.id;
- }
- var featuredCollection = Metamaps.Maps.Featured ? Metamaps.Maps.Featured : [];
- var activeCollection = Metamaps.Maps.Active ? Metamaps.Maps.Active : [];
- Metamaps.Maps.Mine = new Metamaps.Backbone.MapsCollection(myCollection, {id: 'mine', sortBy: 'updated_at' });
- Metamaps.Maps.Shared = new Metamaps.Backbone.MapsCollection(sharedCollection, {id: 'shared', sortBy: 'updated_at' });
- Metamaps.Maps.Starred = new Metamaps.Backbone.MapsCollection(starredCollection, {id: 'starred', sortBy: 'updated_at' });
- // 'Mapper' refers to another mapper
- Metamaps.Maps.Mapper = new Metamaps.Backbone.MapsCollection(mapperCollection, mapperOptionsObj);
- Metamaps.Maps.Featured = new Metamaps.Backbone.MapsCollection(featuredCollection, {id: 'featured', sortBy: 'updated_at' });
- Metamaps.Maps.Active = new Metamaps.Backbone.MapsCollection(activeCollection, {id: 'active', sortBy: 'updated_at' });
- },
- showDiv: function (selector) {
- $(selector).show()
- $(selector).animate({
- opacity: 1
- }, 200, 'easeOutCubic')
- },
- hideDiv: function (selector) {
- $(selector).animate({
- opacity: 0
- }, 200, 'easeInCubic', function () { $(this).hide() })
- },
- openLightbox: function (which) {
- var self = GlobalUI;
+ // initialize global backbone models and collections
+ if (Active.Mapper) Active.Mapper = new Metamaps.Backbone.Mapper(Active.Mapper);
- $('.lightboxContent').hide();
- $('#' + which).show();
-
- self.lightbox = which;
-
- $('#lightbox_overlay').show();
-
- var heightOfContent = '-' + ($('#lightbox_main').height() / 2) + 'px';
- // animate the content in from the bottom
- $('#lightbox_main').animate({
- 'top': '50%',
- 'margin-top': heightOfContent
- }, 200, 'easeOutCubic');
-
- // fade the black overlay in
- $('#lightbox_screen').animate({
- 'opacity': '0.42'
- }, 200);
-
- if (which == "switchMetacodes") {
- Metamaps.Create.isSwitchingSet = true;
- }
- },
-
- closeLightbox: function (event) {
- var self = GlobalUI;
-
- if (event) event.preventDefault();
-
- // animate the lightbox content offscreen
- $('#lightbox_main').animate({
- 'top': '100%',
- 'margin-top': '0'
- }, 200, 'easeInCubic');
-
- // fade the black overlay out
- $('#lightbox_screen').animate({
- 'opacity': '0.0'
- }, 200, function () {
- $('#lightbox_overlay').hide();
- });
-
- if (self.lightbox === 'forkmap') GlobalUI.CreateMap.reset('fork_map');
- if (self.lightbox === 'newmap') GlobalUI.CreateMap.reset('new_map');
- if (Metamaps.Create && Metamaps.Create.isSwitchingSet) {
- Metamaps.Create.cancelMetacodeSetSwitch();
- }
- self.lightbox = null;
- },
- notifyUser: function (message, leaveOpen) {
- var self = GlobalUI;
-
- $('#toast').html(message)
- self.showDiv('#toast')
- clearTimeout(self.notifyTimeOut);
- if (!leaveOpen) {
- self.notifyTimeOut = setTimeout(function () {
- self.hideDiv('#toast')
- }, 8000);
- }
- },
- clearNotify: function() {
- var self = GlobalUI;
-
- clearTimeout(self.notifyTimeOut);
- self.hideDiv('#toast')
- },
- shareInvite: function(inviteLink) {
- window.prompt("To copy the invite link, press: Ctrl+C, Enter", inviteLink);
+ var myCollection = Metamaps.Maps.Mine ? Metamaps.Maps.Mine : [];
+ var sharedCollection = Metamaps.Maps.Shared ? Metamaps.Maps.Shared : [];
+ var starredCollection = Metamaps.Maps.Starred ? Metamaps.Maps.Starred : [];
+ var mapperCollection = [];
+ var mapperOptionsObj = {id: 'mapper', sortBy: 'updated_at' };
+ if (Metamaps.Maps.Mapper) {
+ mapperCollection = Metamaps.Maps.Mapper.models;
+ mapperOptionsObj.mapperId = Metamaps.Maps.Mapper.id;
}
+ var featuredCollection = Metamaps.Maps.Featured ? Metamaps.Maps.Featured : [];
+ var activeCollection = Metamaps.Maps.Active ? Metamaps.Maps.Active : [];
+ Metamaps.Maps.Mine = new Metamaps.Backbone.MapsCollection(myCollection, {id: 'mine', sortBy: 'updated_at' });
+ Metamaps.Maps.Shared = new Metamaps.Backbone.MapsCollection(sharedCollection, {id: 'shared', sortBy: 'updated_at' });
+ Metamaps.Maps.Starred = new Metamaps.Backbone.MapsCollection(starredCollection, {id: 'starred', sortBy: 'updated_at' });
+ // 'Mapper' refers to another mapper
+ Metamaps.Maps.Mapper = new Metamaps.Backbone.MapsCollection(mapperCollection, mapperOptionsObj);
+ Metamaps.Maps.Featured = new Metamaps.Backbone.MapsCollection(featuredCollection, {id: 'featured', sortBy: 'updated_at' });
+ Metamaps.Maps.Active = new Metamaps.Backbone.MapsCollection(activeCollection, {id: 'active', sortBy: 'updated_at' });
+ },
+ showDiv: function (selector) {
+ $(selector).show()
+ $(selector).animate({
+ opacity: 1
+ }, 200, 'easeOutCubic')
+ },
+ hideDiv: function (selector) {
+ $(selector).animate({
+ opacity: 0
+ }, 200, 'easeInCubic', function () { $(this).hide() })
+ },
+ openLightbox: function (which) {
+ var self = GlobalUI;
+
+ $('.lightboxContent').hide();
+ $('#' + which).show();
+
+ self.lightbox = which;
+
+ $('#lightbox_overlay').show();
+
+ var heightOfContent = '-' + ($('#lightbox_main').height() / 2) + 'px';
+ // animate the content in from the bottom
+ $('#lightbox_main').animate({
+ 'top': '50%',
+ 'margin-top': heightOfContent
+ }, 200, 'easeOutCubic');
+
+ // fade the black overlay in
+ $('#lightbox_screen').animate({
+ 'opacity': '0.42'
+ }, 200);
+
+ if (which == "switchMetacodes") {
+ Create.isSwitchingSet = true;
+ }
+ },
+
+ closeLightbox: function (event) {
+ var self = GlobalUI;
+
+ if (event) event.preventDefault();
+
+ // animate the lightbox content offscreen
+ $('#lightbox_main').animate({
+ 'top': '100%',
+ 'margin-top': '0'
+ }, 200, 'easeInCubic');
+
+ // fade the black overlay out
+ $('#lightbox_screen').animate({
+ 'opacity': '0.0'
+ }, 200, function () {
+ $('#lightbox_overlay').hide();
+ });
+
+ if (self.lightbox === 'forkmap') GlobalUI.CreateMap.reset('fork_map');
+ if (self.lightbox === 'newmap') GlobalUI.CreateMap.reset('new_map');
+ if (Create && Create.isSwitchingSet) {
+ Create.cancelMetacodeSetSwitch();
+ }
+ self.lightbox = null;
+ },
+ notifyUser: function (message, leaveOpen) {
+ var self = GlobalUI;
+
+ $('#toast').html(message)
+ self.showDiv('#toast')
+ clearTimeout(self.notifyTimeOut);
+ if (!leaveOpen) {
+ self.notifyTimeOut = setTimeout(function () {
+ self.hideDiv('#toast')
+ }, 8000);
+ }
+ },
+ clearNotify: function() {
+ var self = GlobalUI;
+
+ clearTimeout(self.notifyTimeOut);
+ self.hideDiv('#toast')
+ },
+ shareInvite: function(inviteLink) {
+ window.prompt("To copy the invite link, press: Ctrl+C, Enter", inviteLink);
+ }
}
GlobalUI.CreateMap = {
- newMap: null,
- emptyMapForm: "",
- emptyForkMapForm: "",
- topicsToMap: [],
- synapsesToMap: [],
- init: function () {
- var self = GlobalUI.CreateMap;
+ newMap: null,
+ emptyMapForm: "",
+ emptyForkMapForm: "",
+ topicsToMap: [],
+ synapsesToMap: [],
+ init: function () {
+ var self = GlobalUI.CreateMap;
- self.newMap = new Metamaps.Backbone.Map({ permission: 'commons' });
+ self.newMap = new Metamaps.Backbone.Map({ permission: 'commons' });
- self.bindFormEvents();
+ self.bindFormEvents();
- self.emptyMapForm = $('#new_map').html();
+ self.emptyMapForm = $('#new_map').html();
- },
- bindFormEvents: function () {
- var self = GlobalUI.CreateMap;
+ },
+ bindFormEvents: function () {
+ var self = GlobalUI.CreateMap;
- $('.new_map input, .new_map div').unbind('keypress').bind('keypress', function(event) {
- if (event.keyCode === 13) self.submit()
- })
+ $('.new_map input, .new_map div').unbind('keypress').bind('keypress', function(event) {
+ if (event.keyCode === 13) self.submit()
+ })
- $('.new_map button.cancel').unbind().bind('click', function (event) {
- event.preventDefault();
- GlobalUI.closeLightbox();
- });
- $('.new_map button.submitMap').unbind().bind('click', self.submit);
+ $('.new_map button.cancel').unbind().bind('click', function (event) {
+ event.preventDefault();
+ GlobalUI.closeLightbox();
+ });
+ $('.new_map button.submitMap').unbind().bind('click', self.submit);
- // bind permission changer events on the createMap form
- $('.permIcon').unbind().bind('click', self.switchPermission);
- },
- closeSuccess: function () {
- $('#mapCreatedSuccess').fadeOut(300, function(){
- $(this).remove();
- });
- },
- generateSuccessMessage: function (id) {
- var stringStart = "
";
- return stringStart + page + stringEnd;
- },
- switchPermission: function () {
- var self = GlobalUI.CreateMap;
+ // bind permission changer events on the createMap form
+ $('.permIcon').unbind().bind('click', self.switchPermission);
+ },
+ closeSuccess: function () {
+ $('#mapCreatedSuccess').fadeOut(300, function(){
+ $(this).remove();
+ });
+ },
+ generateSuccessMessage: function (id) {
+ var stringStart = "";
+ return stringStart + page + stringEnd;
+ },
+ switchPermission: function () {
+ var self = GlobalUI.CreateMap;
- self.newMap.set('permission', $(this).attr('data-permission'));
- $(this).siblings('.permIcon').find('.mapPermIcon').removeClass('selected');
- $(this).find('.mapPermIcon').addClass('selected');
+ self.newMap.set('permission', $(this).attr('data-permission'));
+ $(this).siblings('.permIcon').find('.mapPermIcon').removeClass('selected');
+ $(this).find('.mapPermIcon').addClass('selected');
- var permText = $(this).find('.tip').html();
- $(this).parents('.new_map').find('.permText').html(permText);
- },
- submit: function (event) {
- if (event) event.preventDefault();
+ var permText = $(this).find('.tip').html();
+ $(this).parents('.new_map').find('.permText').html(permText);
+ },
+ submit: function (event) {
+ if (event) event.preventDefault();
- var self = GlobalUI.CreateMap;
+ var self = GlobalUI.CreateMap;
- if (GlobalUI.lightbox === 'forkmap') {
- self.newMap.set('topicsToMap', self.topicsToMap);
- self.newMap.set('synapsesToMap', self.synapsesToMap);
- }
+ if (GlobalUI.lightbox === 'forkmap') {
+ self.newMap.set('topicsToMap', self.topicsToMap);
+ self.newMap.set('synapsesToMap', self.synapsesToMap);
+ }
- var formId = GlobalUI.lightbox === 'forkmap' ? '#fork_map' : '#new_map';
- var $form = $(formId);
+ var formId = GlobalUI.lightbox === 'forkmap' ? '#fork_map' : '#new_map';
+ var $form = $(formId);
- self.newMap.set('name', $form.find('#map_name').val());
- self.newMap.set('desc', $form.find('#map_desc').val());
+ self.newMap.set('name', $form.find('#map_name').val());
+ self.newMap.set('desc', $form.find('#map_desc').val());
- if (self.newMap.get('name').length===0){
- self.throwMapNameError();
- return;
- }
+ if (self.newMap.get('name').length===0){
+ self.throwMapNameError();
+ return;
+ }
- self.newMap.save(null, {
- success: self.success
- // TODO add error message
- });
+ self.newMap.save(null, {
+ success: self.success
+ // TODO add error message
+ });
- GlobalUI.closeLightbox();
- GlobalUI.notifyUser('Working...');
- },
- throwMapNameError: function () {
- var self = GlobalUI.CreateMap;
+ GlobalUI.closeLightbox();
+ GlobalUI.notifyUser('Working...');
+ },
+ throwMapNameError: function () {
+ var self = GlobalUI.CreateMap;
- var formId = GlobalUI.lightbox === 'forkmap' ? '#fork_map' : '#new_map';
- var $form = $(formId);
+ var formId = GlobalUI.lightbox === 'forkmap' ? '#fork_map' : '#new_map';
+ var $form = $(formId);
- var message = $("Please enter a map name...
");
+ var message = $("Please enter a map name...
");
- $form.find('#map_name').after(message);
- setTimeout(function(){
- message.fadeOut('fast', function(){
- message.remove();
- });
- }, 5000);
- },
- success: function (model) {
- var self = GlobalUI.CreateMap;
+ $form.find('#map_name').after(message);
+ setTimeout(function(){
+ message.fadeOut('fast', function(){
+ message.remove();
+ });
+ }, 5000);
+ },
+ success: function (model) {
+ var self = GlobalUI.CreateMap;
- //push the new map onto the collection of 'my maps'
- Metamaps.Maps.Mine.add(model);
+ //push the new map onto the collection of 'my maps'
+ Metamaps.Maps.Mine.add(model);
- var formId = GlobalUI.lightbox === 'forkmap' ? '#fork_map' : '#new_map';
- var form = $(formId);
+ var formId = GlobalUI.lightbox === 'forkmap' ? '#fork_map' : '#new_map';
+ var form = $(formId);
- GlobalUI.clearNotify();
- $('#wrapper').append(self.generateSuccessMessage(model.id));
+ GlobalUI.clearNotify();
+ $('#wrapper').append(self.generateSuccessMessage(model.id));
- },
- reset: function (id) {
- var self = GlobalUI.CreateMap;
+ },
+ reset: function (id) {
+ var self = GlobalUI.CreateMap;
- var form = $('#' + id);
+ var form = $('#' + id);
- if (id === "fork_map") {
- self.topicsToMap = [];
- self.synapsesToMap = [];
- form.html(self.emptyForkMapForm);
- }
- else {
- form.html(self.emptyMapForm);
- }
+ if (id === "fork_map") {
+ self.topicsToMap = [];
+ self.synapsesToMap = [];
+ form.html(self.emptyForkMapForm);
+ }
+ else {
+ form.html(self.emptyMapForm);
+ }
- self.bindFormEvents();
- self.newMap = new Metamaps.Backbone.Map({ permission: 'commons' });
+ self.bindFormEvents();
+ self.newMap = new Metamaps.Backbone.Map({ permission: 'commons' });
- return false;
- },
+ return false;
+ },
}
GlobalUI.Account = {
- isOpen: false,
- changing: false,
- init: function () {
- var self = GlobalUI.Account;
+ isOpen: false,
+ changing: false,
+ init: function () {
+ var self = GlobalUI.Account;
- $('.sidebarAccountIcon').click(self.toggleBox);
- $('.sidebarAccountBox').click(function(event){
- event.stopPropagation();
- });
- $('body').click(self.close);
- },
- toggleBox: function (event) {
- var self = GlobalUI.Account;
+ $('.sidebarAccountIcon').click(self.toggleBox);
+ $('.sidebarAccountBox').click(function(event){
+ event.stopPropagation();
+ });
+ $('body').click(self.close);
+ },
+ toggleBox: function (event) {
+ var self = GlobalUI.Account;
- if (self.isOpen) self.close();
- else self.open();
+ if (self.isOpen) self.close();
+ else self.open();
- event.stopPropagation();
- },
- open: function () {
- var self = GlobalUI.Account;
+ event.stopPropagation();
+ },
+ open: function () {
+ var self = GlobalUI.Account;
- Metamaps.Filter.close();
- $('.sidebarAccountIcon .tooltipsUnder').addClass('hide');
+ Filter.close();
+ $('.sidebarAccountIcon .tooltipsUnder').addClass('hide');
- if (!self.isOpen && !self.changing) {
- self.changing = true;
- $('.sidebarAccountBox').fadeIn(200, function () {
- self.changing = false;
- self.isOpen = true;
- $('.sidebarAccountBox #user_email').focus();
- });
- }
- },
- close: function () {
- var self = GlobalUI.Account;
-
- $('.sidebarAccountIcon .tooltipsUnder').removeClass('hide');
- if (!self.changing) {
- self.changing = true;
- $('.sidebarAccountBox #user_email').blur();
- $('.sidebarAccountBox').fadeOut(200, function () {
- self.changing = false;
- self.isOpen = false;
- });
- }
+ if (!self.isOpen && !self.changing) {
+ self.changing = true;
+ $('.sidebarAccountBox').fadeIn(200, function () {
+ self.changing = false;
+ self.isOpen = true;
+ $('.sidebarAccountBox #user_email').focus();
+ });
}
+ },
+ close: function () {
+ var self = GlobalUI.Account;
+
+ $('.sidebarAccountIcon .tooltipsUnder').removeClass('hide');
+ if (!self.changing) {
+ self.changing = true;
+ $('.sidebarAccountBox #user_email').blur();
+ $('.sidebarAccountBox').fadeOut(200, function () {
+ self.changing = false;
+ self.isOpen = false;
+ });
+ }
+ }
}
GlobalUI.Search = {
@@ -425,8 +434,8 @@ GlobalUI.Search = {
startTypeahead: function () {
var self = GlobalUI.Search;
- var mapheader = Metamaps.Active.Mapper ? '' : '';
- var topicheader = Metamaps.Active.Mapper ? '' : '';
+ var mapheader = Active.Mapper ? '' : '';
+ var topicheader = Active.Mapper ? '' : '';
var mapperheader = '';
var topics = {
@@ -455,8 +464,8 @@ GlobalUI.Search = {
url: '/search/topics',
prepare: function(query, settings) {
settings.url += '?term=' + query;
- if (Metamaps.Active.Mapper && self.limitTopicsToMe) {
- settings.url += "&user=" + Metamaps.Active.Mapper.id.toString();
+ if (Active.Mapper && self.limitTopicsToMe) {
+ settings.url += "&user=" + Active.Mapper.id.toString();
}
return settings;
},
@@ -488,8 +497,8 @@ GlobalUI.Search = {
url: '/search/maps',
prepare: function(query, settings) {
settings.url += '?term=' + query;
- if (Metamaps.Active.Mapper && self.limitMapsToMe) {
- settings.url += "&user=" + Metamaps.Active.Mapper.id.toString();
+ if (Active.Mapper && self.limitMapsToMe) {
+ settings.url += "&user=" + Active.Mapper.id.toString();
}
return settings;
},
@@ -578,11 +587,11 @@ GlobalUI.Search = {
self.close(0, true);
var win;
if (datum.rtype == "topic") {
- Metamaps.Router.topics(datum.id);
+ Router.topics(datum.id);
} else if (datum.rtype == "map") {
- Metamaps.Router.maps(datum.id);
+ Router.maps(datum.id);
} else if (datum.rtype == "mapper") {
- Metamaps.Router.explore("mapper", datum.id);
+ Router.explore("mapper", datum.id);
}
}
},
diff --git a/frontend/src/Metamaps/Import.js b/frontend/src/Metamaps/Import.js
index bc0bab30..d5a4b4e1 100644
--- a/frontend/src/Metamaps/Import.js
+++ b/frontend/src/Metamaps/Import.js
@@ -1,7 +1,10 @@
/* global Metamaps, $ */
import Active from './Active'
+import GlobalUI from './GlobalUI'
import Map from './Map'
+import Synapse from './Synapse'
+import Topic from './Topic'
/*
* Metamaps.Import.js.erb
@@ -290,11 +293,11 @@ const Import = {
Metamaps.Mappings.add(mapping)
// this function also includes the creation of the topic in the database
- Metamaps.Topic.renderTopic(mapping, topic, true, true, {
+ Topic.renderTopic(mapping, topic, true, true, {
success: opts.success
})
- Metamaps.GlobalUI.hideDiv('#instructions')
+ GlobalUI.hideDiv('#instructions')
},
createSynapseWithParameters: function (desc, category, permission,
@@ -322,7 +325,7 @@ const Import = {
})
Metamaps.Mappings.add(mapping)
- Metamaps.Synapse.renderSynapse(mapping, synapse, node1, node2, true)
+ Synapse.renderSynapse(mapping, synapse, node1, node2, true)
}
}
diff --git a/frontend/src/Metamaps/JIT.js b/frontend/src/Metamaps/JIT.js
index ec8195de..50c48985 100644
--- a/frontend/src/Metamaps/JIT.js
+++ b/frontend/src/Metamaps/JIT.js
@@ -1,5 +1,30 @@
/* global Metamaps */
+import Active from './Active'
+import Control from './Control'
+import Create from './Create'
+import Filter from './Filter'
+import GlobalUI from './GlobalUI'
+import Map from './Map'
+import Mouse from './Mouse'
+import Realtime from './Realtime'
+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'
+import Visualize from './Visualize'
+
+/*
+ * Metamaps.Erb
+ * Metamaps.Mappings
+ * Metamaps.Metacodes
+ * Metamaps.Synapses
+ * Metamaps.Topics
+ */
+
let panningInt
const JIT = {
@@ -30,11 +55,11 @@ const JIT = {
$('.zoomOut').click(self.zoomOut)
var zoomExtents = function (event) {
- self.zoomExtents(event, Metamaps.Visualize.mGraph.canvas)
+ self.zoomExtents(event, Visualize.mGraph.canvas)
}
$('.zoomExtents').click(zoomExtents)
- $('.takeScreenshot').click(Metamaps.Map.exportImage)
+ $('.takeScreenshot').click(Map.exportImage)
self.topicDescImage = new Image()
self.topicDescImage.src = Metamaps.Erb['topic_description_signifier.png']
@@ -80,7 +105,7 @@ const JIT = {
if (existingEdge) {
// for when you're dealing with multiple relationships between the same two topics
- if (Metamaps.Active.Map) {
+ if (Active.Map) {
mapping = s.getMapping()
existingEdge.data['$mappingIDs'].push(mapping.id)
}
@@ -105,7 +130,7 @@ const JIT = {
// reset/empty vizData
self.vizData = []
- Metamaps.Visualize.loadLater = false
+ Visualize.loadLater = false
var results = self.convertModelsToJIT(Metamaps.Topics, Metamaps.Synapses)
@@ -121,12 +146,12 @@ const JIT = {
if (self.vizData.length == 0) {
$('#instructions div').hide()
$('#instructions div.addTopic').show()
- Metamaps.GlobalUI.showDiv('#instructions')
- Metamaps.Visualize.loadLater = true
+ GlobalUI.showDiv('#instructions')
+ Visualize.loadLater = true
}
- else Metamaps.GlobalUI.hideDiv('#instructions')
+ else GlobalUI.hideDiv('#instructions')
- Metamaps.Visualize.render()
+ Visualize.render()
}, // prepareVizData
edgeRender: function (adj, canvas) {
// get nodes cartesian coordinates
@@ -151,7 +176,7 @@ const JIT = {
// label placement on edges
if (canvas.denySelected) {
- var color = Metamaps.Settings.colors.synapses.normal
+ var color = Settings.colors.synapses.normal
canvas.getCtx().fillStyle = canvas.getCtx().strokeStyle = color
}
JIT.renderEdgeArrows($jit.Graph.Plot.edgeHelper, adj, synapse, canvas)
@@ -191,7 +216,7 @@ const JIT = {
if (!canvas.denySelected && desc != '' && showDesc) {
// '&' to '&'
- desc = Metamaps.Util.decodeEntities(desc)
+ desc = Util.decodeEntities(desc)
// now adjust the label placement
var ctx = canvas.getCtx()
@@ -199,7 +224,7 @@ const JIT = {
ctx.fillStyle = '#FFF'
ctx.textBaseline = 'alphabetic'
- var arrayOfLabelLines = Metamaps.Util.splitLine(desc, 30).split('\n')
+ var arrayOfLabelLines = Util.splitLine(desc, 30).split('\n')
var index, lineWidths = []
for (index = 0; index < arrayOfLabelLines.length; ++index) {
lineWidths.push(ctx.measureText(arrayOfLabelLines[index]).width)
@@ -258,7 +283,7 @@ const JIT = {
transition: $jit.Trans.Quad.easeInOut,
duration: 800,
onComplete: function () {
- Metamaps.Visualize.mGraph.busy = false
+ Visualize.mGraph.busy = false
$(document).trigger(JIT.events.animationDone)
}
},
@@ -267,7 +292,7 @@ const JIT = {
transition: $jit.Trans.Elastic.easeOut,
duration: 800,
onComplete: function () {
- Metamaps.Visualize.mGraph.busy = false
+ Visualize.mGraph.busy = false
}
},
graphSettings: {
@@ -306,7 +331,7 @@ const JIT = {
},
Edge: {
overridable: true,
- color: Metamaps.Settings.colors.synapses.normal,
+ color: Settings.colors.synapses.normal,
type: 'customEdge',
lineWidth: 2,
alpha: 1
@@ -317,7 +342,7 @@ const JIT = {
size: 20,
family: 'arial',
textBaseline: 'alphabetic',
- color: Metamaps.Settings.colors.labels.text
+ color: Settings.colors.labels.text
},
// Add Tips
Tips: {
@@ -359,26 +384,26 @@ const JIT = {
// remove the rightclickmenu
$('.rightclickmenu').remove()
- if (Metamaps.Mouse.boxStartCoordinates) {
+ if (Mouse.boxStartCoordinates) {
if (e.ctrlKey) {
- Metamaps.Visualize.mGraph.busy = false
- Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos()
+ Visualize.mGraph.busy = false
+ Mouse.boxEndCoordinates = eventInfo.getPos()
- var bS = Metamaps.Mouse.boxStartCoordinates
- var bE = Metamaps.Mouse.boxEndCoordinates
+ var bS = Mouse.boxStartCoordinates
+ var bE = Mouse.boxEndCoordinates
if (Math.abs(bS.x - bE.x) > 20 && Math.abs(bS.y - bE.y) > 20) {
JIT.zoomToBox(e)
return
} else {
- Metamaps.Mouse.boxStartCoordinates = null
- Metamaps.Mouse.boxEndCoordinates = null
+ Mouse.boxStartCoordinates = null
+ Mouse.boxEndCoordinates = null
}
// console.log('called zoom to box')
}
if (e.shiftKey) {
- Metamaps.Visualize.mGraph.busy = false
- Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos()
+ Visualize.mGraph.busy = false
+ Mouse.boxEndCoordinates = eventInfo.getPos()
JIT.selectWithBox(e)
// console.log('called select with box')
return
@@ -404,9 +429,9 @@ const JIT = {
// remove the rightclickmenu
$('.rightclickmenu').remove()
- if (Metamaps.Mouse.boxStartCoordinates) {
- Metamaps.Visualize.mGraph.busy = false
- Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos()
+ if (Mouse.boxStartCoordinates) {
+ Visualize.mGraph.busy = false
+ Mouse.boxEndCoordinates = eventInfo.getPos()
JIT.selectWithBox(e)
return
}
@@ -441,7 +466,7 @@ const JIT = {
if (!canvas.denySelected && node.selected) {
ctx.beginPath()
ctx.arc(pos.x, pos.y, dim + 3, 0, 2 * Math.PI, false)
- ctx.strokeStyle = Metamaps.Settings.colors.topics.selected
+ ctx.strokeStyle = Settings.colors.topics.selected
ctx.lineWidth = 2
ctx.stroke()
}
@@ -482,8 +507,8 @@ const JIT = {
'contains': function (node, pos) {
var npos = node.pos.getc(true),
dim = node.getData('dim'),
- arrayOfLabelLines = Metamaps.Util.splitLine(node.name, 30).split('\n'),
- ctx = Metamaps.Visualize.mGraph.canvas.getCtx()
+ arrayOfLabelLines = Util.splitLine(node.name, 30).split('\n'),
+ ctx = Visualize.mGraph.canvas.getCtx()
var height = 25 * arrayOfLabelLines.length
@@ -528,7 +553,7 @@ const JIT = {
transition: $jit.Trans.Elastic.easeOut,
duration: 2500,
onComplete: function () {
- Metamaps.Visualize.mGraph.busy = false
+ Visualize.mGraph.busy = false
}
},
graphSettings: {
@@ -589,13 +614,13 @@ const JIT = {
onMouseMove: function (node, eventInfo, e) {
// if(this.i++ % 3) return
var pos = eventInfo.getPos()
- Metamaps.Visualize.cameraPosition.x += (pos.x - Metamaps.Visualize.cameraPosition.x) * 0.5
- Metamaps.Visualize.cameraPosition.y += (-pos.y - Metamaps.Visualize.cameraPosition.y) * 0.5
- Metamaps.Visualize.mGraph.plot()
+ Visualize.cameraPosition.x += (pos.x - Visualize.cameraPosition.x) * 0.5
+ Visualize.cameraPosition.y += (-pos.y - Visualize.cameraPosition.y) * 0.5
+ Visualize.mGraph.plot()
},
onMouseWheel: function (delta) {
- Metamaps.Visualize.cameraPosition.z += -delta * 20
- Metamaps.Visualize.mGraph.plot()
+ Visualize.cameraPosition.z += -delta * 20
+ Visualize.mGraph.plot()
},
onClick: function () {}
},
@@ -616,7 +641,7 @@ const JIT = {
modes: ['polar'],
duration: 800,
onComplete: function () {
- Metamaps.Visualize.mGraph.busy = false
+ Visualize.mGraph.busy = false
}
},
// this will just be used to patch the ForceDirected graphsettings with the few things which actually differ
@@ -636,10 +661,10 @@ const JIT = {
// don't do anything if the edge is filtered
// or if the canvas is animating
- if (filtered || Metamaps.Visualize.mGraph.busy) return
+ if (filtered || Visualize.mGraph.busy) return
$('canvas').css('cursor', 'pointer')
- var edgeIsSelected = Metamaps.Selected.Edges.indexOf(edge)
+ var edgeIsSelected = Selected.Edges.indexOf(edge)
// following if statement only executes if the edge being hovered over is not selected
if (edgeIsSelected == -1) {
edge.setData('showDesc', true, 'current')
@@ -648,16 +673,16 @@ const JIT = {
edge.setDataset('end', {
lineWidth: 4
})
- Metamaps.Visualize.mGraph.fx.animate({
+ Visualize.mGraph.fx.animate({
modes: ['edge-property:lineWidth'],
duration: 100
})
- Metamaps.Visualize.mGraph.plot()
+ Visualize.mGraph.plot()
}, // onMouseEnter
onMouseLeave: function (edge) {
if (edge.getData('alpha') === 0) return; // don't do anything if the edge is filtered
$('canvas').css('cursor', 'default')
- var edgeIsSelected = Metamaps.Selected.Edges.indexOf(edge)
+ var edgeIsSelected = Selected.Edges.indexOf(edge)
// following if statement only executes if the edge being hovered over is not selected
if (edgeIsSelected == -1) {
edge.setData('showDesc', false, 'current')
@@ -666,65 +691,65 @@ const JIT = {
edge.setDataset('end', {
lineWidth: 2
})
- Metamaps.Visualize.mGraph.fx.animate({
+ Visualize.mGraph.fx.animate({
modes: ['edge-property:lineWidth'],
duration: 100
})
- Metamaps.Visualize.mGraph.plot()
+ Visualize.mGraph.plot()
}, // onMouseLeave
onMouseMoveHandler: function (node, eventInfo, e) {
var self = JIT
- if (Metamaps.Visualize.mGraph.busy) return
+ if (Visualize.mGraph.busy) return
var node = eventInfo.getNode()
var edge = eventInfo.getEdge()
// if we're on top of a node object, act like there aren't edges under it
if (node != false) {
- if (Metamaps.Mouse.edgeHoveringOver) {
- self.onMouseLeave(Metamaps.Mouse.edgeHoveringOver)
+ if (Mouse.edgeHoveringOver) {
+ self.onMouseLeave(Mouse.edgeHoveringOver)
}
$('canvas').css('cursor', 'pointer')
return
}
- if (edge == false && Metamaps.Mouse.edgeHoveringOver != false) {
+ if (edge == false && Mouse.edgeHoveringOver != false) {
// mouse not on an edge, but we were on an edge previously
- self.onMouseLeave(Metamaps.Mouse.edgeHoveringOver)
- } else if (edge != false && Metamaps.Mouse.edgeHoveringOver == false) {
+ self.onMouseLeave(Mouse.edgeHoveringOver)
+ } else if (edge != false && Mouse.edgeHoveringOver == false) {
// mouse is on an edge, but there isn't a stored edge
self.onMouseEnter(edge)
- } else if (edge != false && Metamaps.Mouse.edgeHoveringOver != edge) {
+ } else if (edge != false && Mouse.edgeHoveringOver != edge) {
// mouse is on an edge, but a different edge is stored
- self.onMouseLeave(Metamaps.Mouse.edgeHoveringOver)
+ self.onMouseLeave(Mouse.edgeHoveringOver)
self.onMouseEnter(edge)
}
// could be false
- Metamaps.Mouse.edgeHoveringOver = edge
+ Mouse.edgeHoveringOver = edge
if (!node && !edge) {
$('canvas').css('cursor', 'default')
}
}, // onMouseMoveHandler
enterKeyHandler: function () {
- var creatingMap = Metamaps.GlobalUI.lightbox
+ var creatingMap = GlobalUI.lightbox
if (creatingMap === 'newmap' || creatingMap === 'forkmap') {
- Metamaps.GlobalUI.CreateMap.submit()
+ GlobalUI.CreateMap.submit()
}
// this is to submit new topic creation
- else if (Metamaps.Create.newTopic.beingCreated) {
- Metamaps.Topic.createTopicLocally()
+ else if (Create.newTopic.beingCreated) {
+ Topic.createTopicLocally()
}
// to submit new synapse creation
- else if (Metamaps.Create.newSynapse.beingCreated) {
- Metamaps.Synapse.createSynapseLocally()
+ else if (Create.newSynapse.beingCreated) {
+ Synapse.createSynapseLocally()
}
}, // enterKeyHandler
escKeyHandler: function () {
- Metamaps.Control.deselectAllEdges()
- Metamaps.Control.deselectAllNodes()
+ Control.deselectAllEdges()
+ Control.deselectAllNodes()
}, // escKeyHandler
onDragMoveTopicHandler: function (node, eventInfo, e) {
var self = JIT
@@ -734,7 +759,7 @@ const JIT = {
var positionsToSend = {}
var topic
- var authorized = Metamaps.Active.Map && Metamaps.Active.Map.authorizeToEdit(Metamaps.Active.Mapper)
+ var authorized = Active.Map && Active.Map.authorizeToEdit(Active.Mapper)
if (node && !node.nodeFrom) {
var pos = eventInfo.getPos()
@@ -750,7 +775,7 @@ const JIT = {
} else if (whatToDo == 'only-drag-this-one') {
node.pos.setc(pos.x, pos.y)
- if (Metamaps.Active.Map) {
+ if (Active.Map) {
topic = node.getData('topic')
// we use the topic ID not the node id
// because we can't depend on the node id
@@ -760,24 +785,24 @@ const JIT = {
$(document).trigger(JIT.events.topicDrag, [positionsToSend])
}
} else {
- var len = Metamaps.Selected.Nodes.length
+ var len = Selected.Nodes.length
// first define offset for each node
var xOffset = []
var yOffset = []
for (var i = 0; i < len; i += 1) {
- var n = Metamaps.Selected.Nodes[i]
+ var n = Selected.Nodes[i]
xOffset[i] = n.pos.x - node.pos.x
yOffset[i] = n.pos.y - node.pos.y
} // for
for (var i = 0; i < len; i += 1) {
- var n = Metamaps.Selected.Nodes[i]
+ var n = Selected.Nodes[i]
var x = pos.x + xOffset[i]
var y = pos.y + yOffset[i]
n.pos.setc(x, y)
- if (Metamaps.Active.Map) {
+ if (Active.Map) {
topic = n.getData('topic')
// we use the topic ID not the node id
// because we can't depend on the node id
@@ -787,15 +812,15 @@ const JIT = {
}
} // for
- if (Metamaps.Active.Map) {
+ if (Active.Map) {
$(document).trigger(JIT.events.topicDrag, [positionsToSend])
}
} // if
if (whatToDo == 'deselect') {
- Metamaps.Control.deselectNode(node)
+ Control.deselectNode(node)
}
- Metamaps.Visualize.mGraph.plot()
+ Visualize.mGraph.plot()
}
// if it's a right click or holding down alt, start synapse creation ->third option is for firefox
else if ((e.button == 2 || (e.button == 0 && e.altKey) || e.buttons == 2) && authorized) {
@@ -803,48 +828,48 @@ const JIT = {
JIT.tempNode = node
JIT.tempInit = true
- Metamaps.Create.newTopic.hide()
- Metamaps.Create.newSynapse.hide()
+ Create.newTopic.hide()
+ Create.newSynapse.hide()
// set the draw synapse start positions
- var l = Metamaps.Selected.Nodes.length
+ var l = Selected.Nodes.length
if (l > 0) {
for (var i = l - 1; i >= 0; i -= 1) {
- var n = Metamaps.Selected.Nodes[i]
- Metamaps.Mouse.synapseStartCoordinates.push({
+ var n = Selected.Nodes[i]
+ Mouse.synapseStartCoordinates.push({
x: n.pos.getc().x,
y: n.pos.getc().y
})
}
} else {
- Metamaps.Mouse.synapseStartCoordinates = [{
+ Mouse.synapseStartCoordinates = [{
x: JIT.tempNode.pos.getc().x,
y: JIT.tempNode.pos.getc().y
}]
}
- Metamaps.Mouse.synapseEndCoordinates = {
+ Mouse.synapseEndCoordinates = {
x: pos.x,
y: pos.y
}
}
//
let temp = eventInfo.getNode()
- if (temp != false && temp.id != node.id && Metamaps.Selected.Nodes.indexOf(temp) == -1) { // this means a Node has been returned
+ if (temp != false && temp.id != node.id && Selected.Nodes.indexOf(temp) == -1) { // this means a Node has been returned
JIT.tempNode2 = temp
- Metamaps.Mouse.synapseEndCoordinates = {
+ Mouse.synapseEndCoordinates = {
x: JIT.tempNode2.pos.getc().x,
y: JIT.tempNode2.pos.getc().y
}
// before making the highlighted one bigger, make sure all the others are regular size
- Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
+ Visualize.mGraph.graph.eachNode(function (n) {
n.setData('dim', 25, 'current')
})
temp.setData('dim', 35, 'current')
- Metamaps.Visualize.mGraph.plot()
+ Visualize.mGraph.plot()
} else if (!temp) {
JIT.tempNode2 = null
- Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
+ Visualize.mGraph.graph.eachNode(function (n) {
n.setData('dim', 25, 'current')
})
// pop up node creation :)
@@ -852,21 +877,21 @@ const JIT = {
var myY = e.clientY - 30
$('#new_topic').css('left', myX + 'px')
$('#new_topic').css('top', myY + 'px')
- Metamaps.Create.newTopic.x = eventInfo.getPos().x
- Metamaps.Create.newTopic.y = eventInfo.getPos().y
- Metamaps.Visualize.mGraph.plot()
+ Create.newTopic.x = eventInfo.getPos().x
+ Create.newTopic.y = eventInfo.getPos().y
+ Visualize.mGraph.plot()
- Metamaps.Mouse.synapseEndCoordinates = {
+ Mouse.synapseEndCoordinates = {
x: pos.x,
y: pos.y
}
}
}
- else if ((e.button == 2 || (e.button == 0 && e.altKey) || e.buttons == 2) && Metamaps.Active.Topic) {
- Metamaps.GlobalUI.notifyUser('Cannot create in Topic view.')
+ else if ((e.button == 2 || (e.button == 0 && e.altKey) || e.buttons == 2) && Active.Topic) {
+ GlobalUI.notifyUser('Cannot create in Topic view.')
}
else if ((e.button == 2 || (e.button == 0 && e.altKey) || e.buttons == 2) && !authorized) {
- Metamaps.GlobalUI.notifyUser('Cannot edit Public map.')
+ GlobalUI.notifyUser('Cannot edit Public map.')
}
}
}, // onDragMoveTopicHandler
@@ -876,30 +901,30 @@ const JIT = {
JIT.tempNode2 = null
JIT.tempInit = false
// reset the draw synapse positions to false
- Metamaps.Mouse.synapseStartCoordinates = []
- Metamaps.Mouse.synapseEndCoordinates = null
- Metamaps.Visualize.mGraph.plot()
+ Mouse.synapseStartCoordinates = []
+ Mouse.synapseEndCoordinates = null
+ Visualize.mGraph.plot()
}, // onDragCancelHandler
onDragEndTopicHandler: function (node, eventInfo, e) {
var midpoint = {}, pixelPos, mapping
if (JIT.tempInit && JIT.tempNode2 == null) {
// this means you want to add a new topic, and then a synapse
- Metamaps.Create.newTopic.addSynapse = true
- Metamaps.Create.newTopic.open()
+ Create.newTopic.addSynapse = true
+ Create.newTopic.open()
} else if (JIT.tempInit && JIT.tempNode2 != null) {
// this means you want to create a synapse between two existing topics
- Metamaps.Create.newTopic.addSynapse = false
- Metamaps.Create.newSynapse.topic1id = JIT.tempNode.getData('topic').id
- Metamaps.Create.newSynapse.topic2id = JIT.tempNode2.getData('topic').id
+ Create.newTopic.addSynapse = false
+ Create.newSynapse.topic1id = JIT.tempNode.getData('topic').id
+ Create.newSynapse.topic2id = JIT.tempNode2.getData('topic').id
JIT.tempNode2.setData('dim', 25, 'current')
- Metamaps.Visualize.mGraph.plot()
+ Visualize.mGraph.plot()
midpoint.x = JIT.tempNode.pos.getc().x + (JIT.tempNode2.pos.getc().x - JIT.tempNode.pos.getc().x) / 2
midpoint.y = JIT.tempNode.pos.getc().y + (JIT.tempNode2.pos.getc().y - JIT.tempNode.pos.getc().y) / 2
- pixelPos = Metamaps.Util.coordsToPixels(midpoint)
+ pixelPos = Util.coordsToPixels(midpoint)
$('#new_synapse').css('left', pixelPos.x + 'px')
$('#new_synapse').css('top', pixelPos.y + 'px')
- Metamaps.Create.newSynapse.open()
+ Create.newSynapse.open()
JIT.tempNode = null
JIT.tempNode2 = null
JIT.tempInit = false
@@ -908,17 +933,17 @@ const JIT = {
// check whether to save mappings
var checkWhetherToSave = function () {
- var map = Metamaps.Active.Map
+ var map = Active.Map
if (!map) return false
- var mapper = Metamaps.Active.Mapper
+ var mapper = Active.Mapper
// this case
// covers when it is a public map owned by you
// and also when it's a private map
var activeMappersMap = map.authorizePermissionChange(mapper)
var commonsMap = map.get('permission') === 'commons'
- var realtimeOn = Metamaps.Realtime.status
+ var realtimeOn = Realtime.status
// don't save if commons map, and you have realtime off,
// even if you're map creator
@@ -932,9 +957,9 @@ const JIT = {
yloc: node.getPos().y
})
// also save any other selected nodes that also got dragged along
- var l = Metamaps.Selected.Nodes.length
+ var l = Selected.Nodes.length
for (var i = l - 1; i >= 0; i -= 1) {
- var n = Metamaps.Selected.Nodes[i]
+ var n = Selected.Nodes[i]
if (n !== node) {
mapping = n.getData('mapping')
mapping.save({
@@ -948,61 +973,61 @@ const JIT = {
}, // onDragEndTopicHandler
canvasClickHandler: function (canvasLoc, e) {
// grab the location and timestamp of the click
- var storedTime = Metamaps.Mouse.lastCanvasClick
+ var storedTime = Mouse.lastCanvasClick
var now = Date.now() // not compatible with IE8 FYI
- Metamaps.Mouse.lastCanvasClick = now
+ Mouse.lastCanvasClick = now
- var authorized = Metamaps.Active.Map && Metamaps.Active.Map.authorizeToEdit(Metamaps.Active.Mapper)
+ var authorized = Active.Map && Active.Map.authorizeToEdit(Active.Mapper)
- if (now - storedTime < Metamaps.Mouse.DOUBLE_CLICK_TOLERANCE && !Metamaps.Mouse.didPan) {
- if (Metamaps.Active.Map && !authorized) {
- Metamaps.GlobalUI.notifyUser('Cannot edit Public map.')
+ if (now - storedTime < Mouse.DOUBLE_CLICK_TOLERANCE && !Mouse.didPan) {
+ if (Active.Map && !authorized) {
+ GlobalUI.notifyUser('Cannot edit Public map.')
return
}
- else if (Metamaps.Active.Topic) {
- Metamaps.GlobalUI.notifyUser('Cannot create in Topic view.')
+ else if (Active.Topic) {
+ GlobalUI.notifyUser('Cannot create in Topic view.')
return
}
// DOUBLE CLICK
// pop up node creation :)
- Metamaps.Create.newTopic.addSynapse = false
- Metamaps.Create.newTopic.x = canvasLoc.x
- Metamaps.Create.newTopic.y = canvasLoc.y
+ Create.newTopic.addSynapse = false
+ Create.newTopic.x = canvasLoc.x
+ Create.newTopic.y = canvasLoc.y
$('#new_topic').css('left', e.clientX + 'px')
$('#new_topic').css('top', e.clientY + 'px')
- Metamaps.Create.newTopic.open()
- } else if (!Metamaps.Mouse.didPan) {
+ Create.newTopic.open()
+ } else if (!Mouse.didPan) {
// SINGLE CLICK, no pan
- Metamaps.Filter.close()
- Metamaps.TopicCard.hideCard()
- Metamaps.SynapseCard.hideCard()
- Metamaps.Create.newTopic.hide()
+ Filter.close()
+ TopicCard.hideCard()
+ SynapseCard.hideCard()
+ Create.newTopic.hide()
$('.rightclickmenu').remove()
// reset the draw synapse positions to false
- Metamaps.Mouse.synapseStartCoordinates = []
- Metamaps.Mouse.synapseEndCoordinates = null
+ Mouse.synapseStartCoordinates = []
+ Mouse.synapseEndCoordinates = null
JIT.tempInit = false
JIT.tempNode = null
JIT.tempNode2 = null
if (!e.ctrlKey && !e.shiftKey) {
- Metamaps.Control.deselectAllEdges()
- Metamaps.Control.deselectAllNodes()
+ Control.deselectAllEdges()
+ Control.deselectAllNodes()
}
}
}, // canvasClickHandler
nodeDoubleClickHandler: function (node, e) {
- Metamaps.TopicCard.showCard(node)
+ TopicCard.showCard(node)
}, // nodeDoubleClickHandler
edgeDoubleClickHandler: function (adj, e) {
- Metamaps.SynapseCard.showCard(adj, e)
+ SynapseCard.showCard(adj, e)
}, // nodeDoubleClickHandler
nodeWasDoubleClicked: function () {
// grab the timestamp of the click
- var storedTime = Metamaps.Mouse.lastNodeClick
+ var storedTime = Mouse.lastNodeClick
var now = Date.now() // not compatible with IE8 FYI
- Metamaps.Mouse.lastNodeClick = now
+ Mouse.lastNodeClick = now
- if (now - storedTime < Metamaps.Mouse.DOUBLE_CLICK_TOLERANCE) {
+ if (now - storedTime < Mouse.DOUBLE_CLICK_TOLERANCE) {
return true
} else {
return false
@@ -1015,12 +1040,12 @@ const JIT = {
// 3 others are selected only, no shift: drag only this one
// 4 this node and others were selected, so drag them (just return false)
// return value: deselect node again after?
- if (Metamaps.Selected.Nodes.length == 0) {
+ if (Selected.Nodes.length == 0) {
return 'only-drag-this-one'
}
- if (Metamaps.Selected.Nodes.indexOf(node) == -1) {
+ if (Selected.Nodes.indexOf(node) == -1) {
if (e.shiftKey) {
- Metamaps.Control.selectNode(node, e)
+ Control.selectNode(node, e)
return 'nothing'
} else {
return 'only-drag-this-one'
@@ -1040,18 +1065,18 @@ const JIT = {
},
selectWithBox: function (e) {
var self = this
- var sX = Metamaps.Mouse.boxStartCoordinates.x,
- sY = Metamaps.Mouse.boxStartCoordinates.y,
- eX = Metamaps.Mouse.boxEndCoordinates.x,
- eY = Metamaps.Mouse.boxEndCoordinates.y
+ var sX = Mouse.boxStartCoordinates.x,
+ sY = Mouse.boxStartCoordinates.y,
+ eX = Mouse.boxEndCoordinates.x,
+ eY = Mouse.boxEndCoordinates.y
if (!e.shiftKey) {
- Metamaps.Control.deselectAllNodes()
- Metamaps.Control.deselectAllEdges()
+ Control.deselectAllNodes()
+ Control.deselectAllEdges()
}
// select all nodes that are within the box
- Metamaps.Visualize.mGraph.graph.eachNode(function(n) {
+ Visualize.mGraph.graph.eachNode(function(n) {
var pos = self.getNodeXY(n)
var x = pos.x,
y = pos.y
@@ -1064,12 +1089,12 @@ const JIT = {
(sX < x && x < eX && sY > y && y > eY)) {
if (e.shiftKey) {
if (n.selected) {
- Metamaps.Control.deselectNode(n)
+ Control.deselectNode(n)
} else {
- Metamaps.Control.selectNode(n, e)
+ Control.selectNode(n, e)
}
} else {
- Metamaps.Control.selectNode(n, e)
+ Control.selectNode(n, e)
}
}
})
@@ -1170,30 +1195,30 @@ const JIT = {
if (selectTest) {
// shiftKey = toggleSelect, otherwise
if (e.shiftKey) {
- if (Metamaps.Selected.Edges.indexOf(edge) != -1) {
- Metamaps.Control.deselectEdge(edge)
+ if (Selected.Edges.indexOf(edge) != -1) {
+ Control.deselectEdge(edge)
} else {
- Metamaps.Control.selectEdge(edge)
+ Control.selectEdge(edge)
}
} else {
- Metamaps.Control.selectEdge(edge)
+ Control.selectEdge(edge)
}
}
})
- Metamaps.Mouse.boxStartCoordinates = false
- Metamaps.Mouse.boxEndCoordinates = false
- Metamaps.Visualize.mGraph.plot()
+ Mouse.boxStartCoordinates = false
+ Mouse.boxEndCoordinates = false
+ Visualize.mGraph.plot()
}, // selectWithBox
drawSelectBox: function (eventInfo, e) {
- var ctx = Metamaps.Visualize.mGraph.canvas.getCtx()
+ var ctx = Visualize.mGraph.canvas.getCtx()
- var startX = Metamaps.Mouse.boxStartCoordinates.x,
- startY = Metamaps.Mouse.boxStartCoordinates.y,
+ var startX = Mouse.boxStartCoordinates.x,
+ startY = Mouse.boxStartCoordinates.y,
currX = eventInfo.getPos().x,
currY = eventInfo.getPos().y
- Metamaps.Visualize.mGraph.canvas.clear()
- Metamaps.Visualize.mGraph.plot()
+ Visualize.mGraph.canvas.clear()
+ Visualize.mGraph.plot()
ctx.beginPath()
ctx.moveTo(startX, startY)
@@ -1205,7 +1230,7 @@ const JIT = {
ctx.stroke()
}, // drawSelectBox
selectNodeOnClickHandler: function (node, e) {
- if (Metamaps.Visualize.mGraph.busy) return
+ if (Visualize.mGraph.busy) return
var self = JIT
@@ -1216,8 +1241,8 @@ const JIT = {
}
// if on a topic page, let alt+click center you on a new topic
- if (Metamaps.Active.Topic && e.altKey) {
- Metamaps.RGraph.centerOn(node.id)
+ if (Active.Topic && e.altKey) {
+ JIT.RGraph.centerOn(node.id)
return
}
@@ -1232,24 +1257,24 @@ const JIT = {
var nodeAlreadySelected = node.selected
if (!e.shiftKey) {
- Metamaps.Control.deselectAllNodes()
- Metamaps.Control.deselectAllEdges()
+ Control.deselectAllNodes()
+ Control.deselectAllEdges()
}
if (nodeAlreadySelected) {
- Metamaps.Control.deselectNode(node)
+ Control.deselectNode(node)
} else {
- Metamaps.Control.selectNode(node, e)
+ Control.selectNode(node, e)
}
// trigger animation to final styles
- Metamaps.Visualize.mGraph.fx.animate({
+ Visualize.mGraph.fx.animate({
modes: ['edge-property:lineWidth:color:alpha'],
duration: 500
})
- Metamaps.Visualize.mGraph.plot()
+ Visualize.mGraph.plot()
}
- }, Metamaps.Mouse.DOUBLE_CLICK_TOLERANCE)
+ }, Mouse.DOUBLE_CLICK_TOLERANCE)
}
}, // selectNodeOnClickHandler
selectNodeOnRightClickHandler: function (node, e) {
@@ -1259,10 +1284,10 @@ const JIT = {
e.preventDefault()
e.stopPropagation()
- if (Metamaps.Visualize.mGraph.busy) return
+ if (Visualize.mGraph.busy) return
// select the node
- Metamaps.Control.selectNode(node, e)
+ Control.selectNode(node, e)
// delete old right click menu
$('.rightclickmenu').remove()
@@ -1272,20 +1297,20 @@ const JIT = {
// add the proper options to the menu
var menustring = ''
- var authorized = Metamaps.Active.Map && Metamaps.Active.Map.authorizeToEdit(Metamaps.Active.Mapper)
+ var authorized = Active.Map && Active.Map.authorizeToEdit(Active.Mapper)
var disabled = authorized ? '' : 'disabled'
- if (Metamaps.Active.Map) menustring += '- Hide until refresh
Ctrl+H
'
- if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += '- Remove from map
Ctrl+M
'
- if (Metamaps.Active.Topic) menustring += '- Remove from view
Ctrl+M
'
- if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += '- Delete
Ctrl+D
'
+ if (Active.Map) menustring += '- Hide until refresh
Ctrl+H
'
+ if (Active.Map && Active.Mapper) menustring += '- Remove from map
Ctrl+M
'
+ if (Active.Topic) menustring += '- Remove from view
Ctrl+M
'
+ if (Active.Map && Active.Mapper) menustring += '- Delete
Ctrl+D
'
- if (Metamaps.Active.Topic) {
+ if (Active.Topic) {
menustring += '- Center this topic
Alt+E
'
}
menustring += '- Open in new tab
'
- if (Metamaps.Active.Mapper) {
+ if (Active.Mapper) {
var options = '- commons
\
- public
\
- private
\
@@ -1299,8 +1324,8 @@ const JIT = {
menustring += '- Change metacode' + metacodeOptions + '
'
}
- if (Metamaps.Active.Topic) {
- if (!Metamaps.Active.Mapper) {
+ if (Active.Topic) {
+ if (!Active.Mapper) {
menustring += ''
}
@@ -1358,30 +1383,30 @@ const JIT = {
if (authorized) {
$('.rc-delete').click(function () {
$('.rightclickmenu').remove()
- Metamaps.Control.deleteSelected()
+ Control.deleteSelected()
})
}
// remove the selected things from the map
- if (Metamaps.Active.Topic || authorized) {
+ if (Active.Topic || authorized) {
$('.rc-remove').click(function () {
$('.rightclickmenu').remove()
- Metamaps.Control.removeSelectedEdges()
- Metamaps.Control.removeSelectedNodes()
+ Control.removeSelectedEdges()
+ Control.removeSelectedNodes()
})
}
// hide selected nodes and synapses until refresh
$('.rc-hide').click(function () {
$('.rightclickmenu').remove()
- Metamaps.Control.hideSelectedEdges()
- Metamaps.Control.hideSelectedNodes()
+ Control.hideSelectedEdges()
+ Control.hideSelectedNodes()
})
// when in radial, center on the topic you picked
$('.rc-center').click(function () {
$('.rightclickmenu').remove()
- Metamaps.Topic.centerOn(node.id)
+ Topic.centerOn(node.id)
})
// open the entity in a new tab
@@ -1395,14 +1420,14 @@ const JIT = {
$('.rc-permission li').click(function () {
$('.rightclickmenu').remove()
// $(this).text() will be 'commons' 'public' or 'private'
- Metamaps.Control.updateSelectedPermissions($(this).text())
+ Control.updateSelectedPermissions($(this).text())
})
// change the metacode of all the selected nodes that you have edit permission for
$('.rc-metacode li li').click(function () {
$('.rightclickmenu').remove()
//
- Metamaps.Control.updateSelectedMetacodes($(this).attr('data-id'))
+ Control.updateSelectedMetacodes($(this).attr('data-id'))
})
// fetch relatives
@@ -1416,7 +1441,7 @@ const JIT = {
$('.rc-siblings .fetchAll').click(function () {
$('.rightclickmenu').remove()
// data-id is a metacode id
- Metamaps.Topic.fetchRelatives(node)
+ Topic.fetchRelatives(node)
})
}, // selectNodeOnRightClickHandler,
populateRightClickSiblings: function (node) {
@@ -1448,7 +1473,7 @@ const JIT = {
$('.rc-siblings .getSiblings').click(function () {
$('.rightclickmenu').remove()
// data-id is a metacode id
- Metamaps.Topic.fetchRelatives(node, $(this).attr('data-id'))
+ Topic.fetchRelatives(node, $(this).attr('data-id'))
})
}
@@ -1460,7 +1485,7 @@ const JIT = {
})
},
selectEdgeOnClickHandler: function (adj, e) {
- if (Metamaps.Visualize.mGraph.busy) return
+ if (Visualize.mGraph.busy) return
var self = JIT
@@ -1478,22 +1503,22 @@ const JIT = {
// wait a certain length of time, then check again, then run this code
setTimeout(function () {
if (!JIT.nodeWasDoubleClicked()) {
- var edgeAlreadySelected = Metamaps.Selected.Edges.indexOf(adj) !== -1
+ var edgeAlreadySelected = Selected.Edges.indexOf(adj) !== -1
if (!e.shiftKey) {
- Metamaps.Control.deselectAllNodes()
- Metamaps.Control.deselectAllEdges()
+ Control.deselectAllNodes()
+ Control.deselectAllEdges()
}
if (edgeAlreadySelected) {
- Metamaps.Control.deselectEdge(adj)
+ Control.deselectEdge(adj)
} else {
- Metamaps.Control.selectEdge(adj)
+ Control.selectEdge(adj)
}
- Metamaps.Visualize.mGraph.plot()
+ Visualize.mGraph.plot()
}
- }, Metamaps.Mouse.DOUBLE_CLICK_TOLERANCE)
+ }, Mouse.DOUBLE_CLICK_TOLERANCE)
}
}, // selectEdgeOnClickHandler
selectEdgeOnRightClickHandler: function (adj, e) {
@@ -1507,9 +1532,9 @@ const JIT = {
e.preventDefault()
e.stopPropagation()
- if (Metamaps.Visualize.mGraph.busy) return
+ if (Visualize.mGraph.busy) return
- Metamaps.Control.selectEdge(adj)
+ Control.selectEdge(adj)
// delete old right click menu
$('.rightclickmenu').remove()
@@ -1520,18 +1545,18 @@ const JIT = {
// add the proper options to the menu
var menustring = ''
- var authorized = Metamaps.Active.Map && Metamaps.Active.Map.authorizeToEdit(Metamaps.Active.Mapper)
+ var authorized = Active.Map && Active.Map.authorizeToEdit(Active.Mapper)
var disabled = authorized ? '' : 'disabled'
- if (Metamaps.Active.Map) menustring += '- Hide until refresh
Ctrl+H
'
- if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += '- Remove from map
Ctrl+M
'
- if (Metamaps.Active.Topic) menustring += '- Remove from view
Ctrl+M
'
- if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += '- Delete
Ctrl+D
'
+ if (Active.Map) menustring += '- Hide until refresh
Ctrl+H
'
+ if (Active.Map && Active.Mapper) menustring += '- Remove from map
Ctrl+M
'
+ if (Active.Topic) menustring += '- Remove from view
Ctrl+M
'
+ if (Active.Map && Active.Mapper) menustring += '- Delete
Ctrl+D
'
- if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += ''
+ if (Active.Map && Active.Mapper) menustring += ''
- if (Metamaps.Active.Mapper) {
+ if (Active.Mapper) {
var permOptions = '- commons
\
- public
\
- private
\
@@ -1582,7 +1607,7 @@ const JIT = {
if (authorized) {
$('.rc-delete').click(function () {
$('.rightclickmenu').remove()
- Metamaps.Control.deleteSelected()
+ Control.deleteSelected()
})
}
@@ -1590,30 +1615,30 @@ const JIT = {
if (authorized) {
$('.rc-remove').click(function () {
$('.rightclickmenu').remove()
- Metamaps.Control.removeSelectedEdges()
- Metamaps.Control.removeSelectedNodes()
+ Control.removeSelectedEdges()
+ Control.removeSelectedNodes()
})
}
// hide selected nodes and synapses until refresh
$('.rc-hide').click(function () {
$('.rightclickmenu').remove()
- Metamaps.Control.hideSelectedEdges()
- Metamaps.Control.hideSelectedNodes()
+ Control.hideSelectedEdges()
+ Control.hideSelectedNodes()
})
// change the permission of all the selected nodes and synapses that you were the originator of
$('.rc-permission li').click(function () {
$('.rightclickmenu').remove()
// $(this).text() will be 'commons' 'public' or 'private'
- Metamaps.Control.updateSelectedPermissions($(this).text())
+ Control.updateSelectedPermissions($(this).text())
})
}, // selectEdgeOnRightClickHandler
SmoothPanning: function () {
- var sx = Metamaps.Visualize.mGraph.canvas.scaleOffsetX,
- sy = Metamaps.Visualize.mGraph.canvas.scaleOffsetY,
- y_velocity = Metamaps.Mouse.changeInY, // initial y velocity
- x_velocity = Metamaps.Mouse.changeInX, // initial x velocity
+ var sx = Visualize.mGraph.canvas.scaleOffsetX,
+ sy = Visualize.mGraph.canvas.scaleOffsetY,
+ y_velocity = Mouse.changeInY, // initial y velocity
+ x_velocity = Mouse.changeInX, // initial x velocity
easing = 1 // frictional value
easing = 1
@@ -1623,7 +1648,7 @@ const JIT = {
}, 1)
function myTimer () {
- Metamaps.Visualize.mGraph.canvas.translate(x_velocity * easing * 1 / sx, y_velocity * easing * 1 / sy)
+ Visualize.mGraph.canvas.translate(x_velocity * easing * 1 / sx, y_velocity * easing * 1 / sy)
$(document).trigger(JIT.events.pan)
easing = easing * 0.75
@@ -1725,11 +1750,11 @@ const JIT = {
}
}, // renderEdgeArrows
zoomIn: function (event) {
- Metamaps.Visualize.mGraph.canvas.scale(1.25, 1.25)
+ Visualize.mGraph.canvas.scale(1.25, 1.25)
$(document).trigger(JIT.events.zoom, [event])
},
zoomOut: function (event) {
- Metamaps.Visualize.mGraph.canvas.scale(0.8, 0.8)
+ Visualize.mGraph.canvas.scale(0.8, 0.8)
$(document).trigger(JIT.events.zoom, [event])
},
centerMap: function (canvas) {
@@ -1743,12 +1768,12 @@ const JIT = {
canvas.translate(-1 * offsetX, -1 * offsetY)
},
zoomToBox: function (event) {
- var sX = Metamaps.Mouse.boxStartCoordinates.x,
- sY = Metamaps.Mouse.boxStartCoordinates.y,
- eX = Metamaps.Mouse.boxEndCoordinates.x,
- eY = Metamaps.Mouse.boxEndCoordinates.y
+ var sX = Mouse.boxStartCoordinates.x,
+ sY = Mouse.boxStartCoordinates.y,
+ eX = Mouse.boxEndCoordinates.x,
+ eY = Mouse.boxEndCoordinates.y
- var canvas = Metamaps.Visualize.mGraph.canvas
+ var canvas = Visualize.mGraph.canvas
JIT.centerMap(canvas)
var height = $(document).height(),
@@ -1778,9 +1803,9 @@ const JIT = {
canvas.translate(-1 * cogX, -1 * cogY)
$(document).trigger(JIT.events.zoom, [event])
- Metamaps.Mouse.boxStartCoordinates = false
- Metamaps.Mouse.boxEndCoordinates = false
- Metamaps.Visualize.mGraph.plot()
+ Mouse.boxStartCoordinates = false
+ Mouse.boxEndCoordinates = false
+ Visualize.mGraph.plot()
},
zoomExtents: function (event, canvas, denySelected) {
JIT.centerMap(canvas)
@@ -1788,10 +1813,10 @@ const JIT = {
width = canvas.getSize().width,
maxX, minX, maxY, minY, counter = 0
- if (!denySelected && Metamaps.Selected.Nodes.length > 0) {
- var nodes = Metamaps.Selected.Nodes
+ if (!denySelected && Selected.Nodes.length > 0) {
+ var nodes = Selected.Nodes
} else {
- var nodes = _.values(Metamaps.Visualize.mGraph.graph.nodes)
+ var nodes = _.values(Visualize.mGraph.graph.nodes)
}
if (nodes.length > 1) {
@@ -1806,7 +1831,7 @@ const JIT = {
minY = y
}
- var arrayOfLabelLines = Metamaps.Util.splitLine(n.name, 30).split('\n'),
+ var arrayOfLabelLines = Util.splitLine(n.name, 30).split('\n'),
dim = n.getData('dim'),
ctx = canvas.getCtx()
diff --git a/frontend/src/Metamaps/Listeners.js b/frontend/src/Metamaps/Listeners.js
index 1c56b679..78e881d4 100644
--- a/frontend/src/Metamaps/Listeners.js
+++ b/frontend/src/Metamaps/Listeners.js
@@ -1,57 +1,59 @@
-/* global Metamaps, $ */
+/* global $ */
+
+import Active from './Active'
+import Control from './Control'
+import JIT from './JIT'
+import Mobile from './Mobile'
+import Realtime from './Realtime'
+import Selected from './Selected'
+import Topic from './Topic'
+import Visualize from './Visualize'
-/*
- * Dependencies:
- * - Metamaps.Active
- * - Metamaps.Control
- * - Metamaps.JIT
- * - Metamaps.Visualize
- */
const Listeners = {
init: function () {
var self = this
$(document).on('keydown', function (e) {
- if (!(Metamaps.Active.Map || Metamaps.Active.Topic)) return
+ if (!(Active.Map || Active.Topic)) return
switch (e.which) {
case 13: // if enter key is pressed
- Metamaps.JIT.enterKeyHandler()
+ JIT.enterKeyHandler()
e.preventDefault()
break
case 27: // if esc key is pressed
- Metamaps.JIT.escKeyHandler()
+ JIT.escKeyHandler()
break
case 65: // if a or A is pressed
if (e.ctrlKey) {
- Metamaps.Control.deselectAllNodes()
- Metamaps.Control.deselectAllEdges()
+ Control.deselectAllNodes()
+ Control.deselectAllEdges()
e.preventDefault()
- Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
- Metamaps.Control.selectNode(n, e)
+ Visualize.mGraph.graph.eachNode(function (n) {
+ Control.selectNode(n, e)
})
- Metamaps.Visualize.mGraph.plot()
+ Visualize.mGraph.plot()
}
break
case 68: // if d or D is pressed
if (e.ctrlKey) {
e.preventDefault()
- Metamaps.Control.deleteSelected()
+ Control.deleteSelected()
}
break
case 69: // if e or E is pressed
- if (e.ctrlKey && Metamaps.Active.Map) {
+ if (e.ctrlKey && Active.Map) {
e.preventDefault()
- Metamaps.JIT.zoomExtents(null, Metamaps.Visualize.mGraph.canvas)
+ JIT.zoomExtents(null, Visualize.mGraph.canvas)
break
}
- if (e.altKey && Metamaps.Active.Topic) {
+ if (e.altKey && Active.Topic) {
e.preventDefault()
- if (Metamaps.Active.Topic) {
- self.centerAndReveal(Metamaps.Selected.Nodes, {
+ if (Active.Topic) {
+ self.centerAndReveal(Selected.Nodes, {
center: true,
reveal: false
})
@@ -62,30 +64,30 @@ const Listeners = {
case 72: // if h or H is pressed
if (e.ctrlKey) {
e.preventDefault()
- Metamaps.Control.hideSelectedNodes()
- Metamaps.Control.hideSelectedEdges()
+ Control.hideSelectedNodes()
+ Control.hideSelectedEdges()
}
break
case 77: // if m or M is pressed
if (e.ctrlKey) {
e.preventDefault()
- Metamaps.Control.removeSelectedNodes()
- Metamaps.Control.removeSelectedEdges()
+ Control.removeSelectedNodes()
+ Control.removeSelectedEdges()
}
break
case 82: // if r or R is pressed
- if (e.altKey && Metamaps.Active.Topic) {
+ if (e.altKey && Active.Topic) {
e.preventDefault()
- self.centerAndReveal(Metamaps.Selected.Nodes, {
+ self.centerAndReveal(Selected.Nodes, {
center: false,
reveal: true
})
}
break
case 84: // if t or T is pressed
- if (e.altKey && Metamaps.Active.Topic) {
+ if (e.altKey && Active.Topic) {
e.preventDefault()
- self.centerAndReveal(Metamaps.Selected.Nodes, {
+ self.centerAndReveal(Selected.Nodes, {
center: true,
reveal: true
})
@@ -98,23 +100,22 @@ const Listeners = {
})
$(window).resize(function () {
- if (Metamaps.Visualize && Metamaps.Visualize.mGraph) Metamaps.Visualize.mGraph.canvas.resize($(window).width(), $(window).height())
- if ((Metamaps.Active.Map || Metamaps.Active.Topic) && Metamaps.Famous && Metamaps.Famous.maps.surf) Metamaps.Famous.maps.reposition()
- if (Metamaps.Active.Map && Metamaps.Realtime.inConversation) Metamaps.Realtime.positionVideos()
- Metamaps.Mobile.resizeTitle()
+ if (Visualize && Visualize.mGraph) Visualize.mGraph.canvas.resize($(window).width(), $(window).height())
+ if (Active.Map && Realtime.inConversation) Realtime.positionVideos()
+ Mobile.resizeTitle()
})
},
centerAndReveal: function(nodes, opts) {
if (nodes.length < 1) return
var node = nodes[nodes.length - 1]
if (opts.center && opts.reveal) {
- Metamaps.Topic.centerOn(node.id, function() {
- Metamaps.Topic.fetchRelatives(nodes)
+ Topic.centerOn(node.id, function() {
+ Topic.fetchRelatives(nodes)
})
} else if (opts.center) {
- Metamaps.Topic.centerOn(node.id)
+ Topic.centerOn(node.id)
} else if (opts.reveal) {
- Metamaps.Topic.fetchRelatives(nodes)
+ Topic.fetchRelatives(nodes)
}
}
}
diff --git a/frontend/src/Metamaps/Map.js b/frontend/src/Metamaps/Map.js
index 690c2a6d..cd2c3d2e 100644
--- a/frontend/src/Metamaps/Map.js
+++ b/frontend/src/Metamaps/Map.js
@@ -1,30 +1,29 @@
-window.Metamaps = window.Metamaps || {}
-
/* global Metamaps, $ */
+import Active from './Active'
+import AutoLayout from './AutoLayout'
+import Create from './Create'
+import Filter from './Filter'
+import GlobalUI from './GlobalUI'
+import JIT from './JIT'
+import Realtime from './Realtime'
+import Selected from './Selected'
+import SynapseCard from './SynapseCard'
+import TopicCard from './TopicCard'
+import Visualize from './Visualize'
+
/*
* Metamaps.Map.js.erb
*
* Dependencies:
- * - Metamaps.AutoLayout
- * - Metamaps.Create
- * - Metamaps.Erb
- * - Metamaps.Filter
- * - Metamaps.JIT
- * - Metamaps.Loading
- * - Metamaps.Maps
- * - Metamaps.Realtime
- * - Metamaps.Router
- * - Metamaps.Selected
- * - Metamaps.SynapseCard
- * - Metamaps.TopicCard
- * - Metamaps.Visualize
- * - Metamaps.Active
* - Metamaps.Backbone
- * - Metamaps.GlobalUI
+ * - Metamaps.Erb
+ * - Metamaps.Loading
* - Metamaps.Mappers
* - Metamaps.Mappings
+ * - Metamaps.Maps
* - Metamaps.Messages
+ * - Metamaps.Router
* - Metamaps.Synapses
* - Metamaps.Topics
*
@@ -33,6 +32,7 @@ window.Metamaps = window.Metamaps || {}
* - Metamaps.Map.InfoBox
*/
+window.Metamaps = window.Metamaps || {}
Metamaps.Map = {
events: {
editedByActiveMapper: 'Metamaps:Map:events:editedByActiveMapper'
@@ -54,7 +54,7 @@ Metamaps.Map = {
self.fork()
})
- Metamaps.GlobalUI.CreateMap.emptyForkMapForm = $('#fork_map').html()
+ GlobalUI.CreateMap.emptyForkMapForm = $('#fork_map').html()
self.updateStar()
self.InfoBox.init()
@@ -65,7 +65,7 @@ Metamaps.Map = {
launch: function (id) {
var bb = Metamaps.Backbone
var start = function (data) {
- Metamaps.Active.Map = new bb.Map(data.map)
+ Active.Map = new bb.Map(data.map)
Metamaps.Mappers = new bb.MapperCollection(data.mappers)
Metamaps.Collaborators = new bb.MapperCollection(data.collaborators)
Metamaps.Topics = new bb.TopicCollection(data.topics)
@@ -75,8 +75,8 @@ Metamaps.Map = {
Metamaps.Stars = data.stars
Metamaps.Backbone.attachCollectionEvents()
- var map = Metamaps.Active.Map
- var mapper = Metamaps.Active.Mapper
+ var map = Active.Map
+ var mapper = Active.Mapper
// add class to .wrapper for specifying whether you can edit the map
if (map.authorizeToEdit(mapper)) {
@@ -95,24 +95,24 @@ Metamaps.Map = {
$('#filter_by_mapper h3').html('MAPPERS')
// build and render the visualization
- Metamaps.Visualize.type = 'ForceDirected'
- Metamaps.JIT.prepareVizData()
+ Visualize.type = 'ForceDirected'
+ JIT.prepareVizData()
// update filters
- Metamaps.Filter.reset()
+ Filter.reset()
// reset selected arrays
- Metamaps.Selected.reset()
+ Selected.reset()
// set the proper mapinfobox content
Metamaps.Map.InfoBox.load()
// these three update the actual filter box with the right list items
- Metamaps.Filter.checkMetacodes()
- Metamaps.Filter.checkSynapses()
- Metamaps.Filter.checkMappers()
+ Filter.checkMetacodes()
+ Filter.checkSynapses()
+ Filter.checkMappers()
- Metamaps.Realtime.startActiveMap()
+ Realtime.startActiveMap()
Metamaps.Loading.hide()
// for mobile
@@ -125,24 +125,24 @@ Metamaps.Map = {
})
},
end: function () {
- if (Metamaps.Active.Map) {
+ if (Active.Map) {
$('.wrapper').removeClass('canEditMap commonsMap')
- Metamaps.AutoLayout.resetSpiral()
+ AutoLayout.resetSpiral()
$('.rightclickmenu').remove()
- Metamaps.TopicCard.hideCard()
- Metamaps.SynapseCard.hideCard()
- Metamaps.Create.newTopic.hide(true) // true means force (and override pinned)
- Metamaps.Create.newSynapse.hide()
- Metamaps.Filter.close()
+ TopicCard.hideCard()
+ SynapseCard.hideCard()
+ Create.newTopic.hide(true) // true means force (and override pinned)
+ Create.newSynapse.hide()
+ Filter.close()
Metamaps.Map.InfoBox.close()
- Metamaps.Realtime.endActiveMap()
+ Realtime.endActiveMap()
}
},
updateStar: function () {
- if (!Metamaps.Active.Mapper || !Metamaps.Stars) return
+ if (!Active.Mapper || !Metamaps.Stars) return
// update the star/unstar icon
- if (Metamaps.Stars.find(function (s) { return s.user_id === Metamaps.Active.Mapper.id })) {
+ if (Metamaps.Stars.find(function (s) { return s.user_id === Active.Mapper.id })) {
$('.starMap').addClass('starred')
$('.starMap .tooltipsAbove').html('Unstar')
} else {
@@ -153,31 +153,31 @@ Metamaps.Map = {
star: function () {
var self = Metamaps.Map
- if (!Metamaps.Active.Map) return
- $.post('/maps/' + Metamaps.Active.Map.id + '/star')
- Metamaps.Stars.push({ user_id: Metamaps.Active.Mapper.id, map_id: Metamaps.Active.Map.id })
- Metamaps.Maps.Starred.add(Metamaps.Active.Map)
- Metamaps.GlobalUI.notifyUser('Map is now starred')
+ if (!Active.Map) return
+ $.post('/maps/' + Active.Map.id + '/star')
+ Metamaps.Stars.push({ user_id: Active.Mapper.id, map_id: Active.Map.id })
+ Metamaps.Maps.Starred.add(Active.Map)
+ GlobalUI.notifyUser('Map is now starred')
self.updateStar()
},
unstar: function () {
var self = Metamaps.Map
- if (!Metamaps.Active.Map) return
- $.post('/maps/' + Metamaps.Active.Map.id + '/unstar')
- Metamaps.Stars = Metamaps.Stars.filter(function (s) { return s.user_id != Metamaps.Active.Mapper.id })
- Metamaps.Maps.Starred.remove(Metamaps.Active.Map)
+ if (!Active.Map) return
+ $.post('/maps/' + Active.Map.id + '/unstar')
+ Metamaps.Stars = Metamaps.Stars.filter(function (s) { return s.user_id != Active.Mapper.id })
+ Metamaps.Maps.Starred.remove(Active.Map)
self.updateStar()
},
fork: function () {
- Metamaps.GlobalUI.openLightbox('forkmap')
+ GlobalUI.openLightbox('forkmap')
var nodes_data = '',
synapses_data = ''
var nodes_array = []
var synapses_array = []
// collect the unfiltered topics
- Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
+ Visualize.mGraph.graph.eachNode(function (n) {
// if the opacity is less than 1 then it's filtered
if (n.getData('alpha') === 1) {
var id = n.getData('topic').id
@@ -197,7 +197,7 @@ Metamaps.Map = {
Metamaps.Synapses.each(function (synapse) {
var desc = synapse.get('desc')
- var descNotFiltered = Metamaps.Filter.visible.synapses.indexOf(desc) > -1
+ var descNotFiltered = Filter.visible.synapses.indexOf(desc) > -1
// make sure that both topics are being added, otherwise, it
// doesn't make sense to add the synapse
var topicsNotFiltered = nodes_array.indexOf(synapse.get('node1_id')) > -1
@@ -210,32 +210,32 @@ Metamaps.Map = {
synapses_data = synapses_array.join()
nodes_data = nodes_data.slice(0, -1)
- Metamaps.GlobalUI.CreateMap.topicsToMap = nodes_data
- Metamaps.GlobalUI.CreateMap.synapsesToMap = synapses_data
+ GlobalUI.CreateMap.topicsToMap = nodes_data
+ GlobalUI.CreateMap.synapsesToMap = synapses_data
},
leavePrivateMap: function () {
- var map = Metamaps.Active.Map
+ var map = Active.Map
Metamaps.Maps.Active.remove(map)
Metamaps.Maps.Featured.remove(map)
Metamaps.Router.home()
- Metamaps.GlobalUI.notifyUser('Sorry! That map has been changed to Private.')
+ GlobalUI.notifyUser('Sorry! That map has been changed to Private.')
},
cantEditNow: function () {
- Metamaps.Realtime.turnOff(true); // true is for 'silence'
- Metamaps.GlobalUI.notifyUser('Map was changed to Public. Editing is disabled.')
- Metamaps.Active.Map.trigger('changeByOther')
+ Realtime.turnOff(true); // true is for 'silence'
+ GlobalUI.notifyUser('Map was changed to Public. Editing is disabled.')
+ Active.Map.trigger('changeByOther')
},
canEditNow: function () {
var confirmString = "You've been granted permission to edit this map. "
confirmString += 'Do you want to reload and enable realtime collaboration?'
var c = confirm(confirmString)
if (c) {
- Metamaps.Router.maps(Metamaps.Active.Map.id)
+ Metamaps.Router.maps(Active.Map.id)
}
},
editedByActiveMapper: function () {
- if (Metamaps.Active.Mapper) {
- Metamaps.Mappers.add(Metamaps.Active.Mapper)
+ if (Active.Mapper) {
+ Metamaps.Mappers.add(Active.Mapper)
}
},
exportImage: function () {
@@ -282,14 +282,14 @@ Metamaps.Map = {
// center it
canvas.getCtx().translate(1880 / 2, 1260 / 2)
- var mGraph = Metamaps.Visualize.mGraph
+ var mGraph = Visualize.mGraph
var id = mGraph.root
var root = mGraph.graph.getNode(id)
var T = !!root.visited
// pass true to avoid basing it on a selection
- Metamaps.JIT.zoomExtents(null, canvas, true)
+ JIT.zoomExtents(null, canvas, true)
var c = canvas.canvas,
ctx = canvas.getCtx(),
@@ -327,7 +327,7 @@ Metamaps.Map = {
encoded_image: canvas.canvas.toDataURL()
}
- var map = Metamaps.Active.Map
+ var map = Active.Map
var today = new Date()
var dd = today.getDate()
@@ -346,12 +346,12 @@ Metamaps.Map = {
downloadMessage += 'Captured map screenshot! '
downloadMessage += "DOWNLOAD"
- Metamaps.GlobalUI.notifyUser(downloadMessage)
+ GlobalUI.notifyUser(downloadMessage)
$.ajax({
type: 'POST',
dataType: 'json',
- url: '/maps/' + Metamaps.Active.Map.id + '/upload_screenshot',
+ url: '/maps/' + Active.Map.id + '/upload_screenshot',
data: imageData,
success: function (data) {
console.log('successfully uploaded map screenshot')
@@ -461,12 +461,12 @@ Metamaps.Map.InfoBox = {
load: function () {
var self = Metamaps.Map.InfoBox
- var map = Metamaps.Active.Map
+ var map = Active.Map
var obj = map.pick('permission', 'topic_count', 'synapse_count')
- var isCreator = map.authorizePermissionChange(Metamaps.Active.Mapper)
- var canEdit = map.authorizeToEdit(Metamaps.Active.Mapper)
+ var isCreator = map.authorizePermissionChange(Active.Mapper)
+ var canEdit = map.authorizeToEdit(Active.Mapper)
var relevantPeople = map.get('permission') === 'commons' ? Metamaps.Mappers : Metamaps.Collaborators
var shareable = map.get('permission') !== 'private'
@@ -519,8 +519,8 @@ Metamaps.Map.InfoBox = {
$('.mapInfoName .best_in_place_name').unbind('ajax:success').bind('ajax:success', function () {
var name = $(this).html()
- Metamaps.Active.Map.set('name', name)
- Metamaps.Active.Map.trigger('saved')
+ Active.Map.set('name', name)
+ Active.Map.trigger('saved')
// mobile menu
$('#header_content').html(name)
$('.mapInfoBox').removeClass('mapRequestTitle')
@@ -529,8 +529,8 @@ Metamaps.Map.InfoBox = {
$('.mapInfoDesc .best_in_place_desc').unbind('ajax:success').bind('ajax:success', function () {
var desc = $(this).html()
- Metamaps.Active.Map.set('desc', desc)
- Metamaps.Active.Map.trigger('saved')
+ Active.Map.set('desc', desc)
+ Active.Map.trigger('saved')
})
$('.yourMap .mapPermission').unbind().click(self.onPermissionClick)
@@ -558,7 +558,7 @@ Metamaps.Map.InfoBox = {
addTypeahead: function () {
var self = Metamaps.Map.InfoBox
- if (!Metamaps.Active.Map) return
+ if (!Active.Map) return
// for autocomplete
var collaborators = {
@@ -589,7 +589,7 @@ Metamaps.Map.InfoBox = {
}
// for adding map collaborators, who will have edit rights
- if (Metamaps.Active.Mapper && Metamaps.Active.Mapper.id === Metamaps.Active.Map.get('user_id')) {
+ if (Active.Mapper && Active.Mapper.id === Active.Map.get('user_id')) {
$('.collaboratorSearchField').typeahead(
{
highlight: false,
@@ -606,23 +606,23 @@ Metamaps.Map.InfoBox = {
var self = Metamaps.Map.InfoBox
Metamaps.Collaborators.remove(Metamaps.Collaborators.get(collaboratorId))
var mapperIds = Metamaps.Collaborators.models.map(function (mapper) { return mapper.id })
- $.post('/maps/' + Metamaps.Active.Map.id + '/access', { access: mapperIds })
+ $.post('/maps/' + Active.Map.id + '/access', { access: mapperIds })
self.updateNumbers()
},
addCollaborator: function (newCollaboratorId) {
var self = Metamaps.Map.InfoBox
if (Metamaps.Collaborators.get(newCollaboratorId)) {
- Metamaps.GlobalUI.notifyUser('That user already has access')
+ GlobalUI.notifyUser('That user already has access')
return
}
function callback(mapper) {
Metamaps.Collaborators.add(mapper)
var mapperIds = Metamaps.Collaborators.models.map(function (mapper) { return mapper.id })
- $.post('/maps/' + Metamaps.Active.Map.id + '/access', { access: mapperIds })
+ $.post('/maps/' + Active.Map.id + '/access', { access: mapperIds })
var name = Metamaps.Collaborators.get(newCollaboratorId).get('name')
- Metamaps.GlobalUI.notifyUser(name + ' will be notified by email')
+ GlobalUI.notifyUser(name + ' will be notified by email')
self.updateNumbers()
}
@@ -642,13 +642,13 @@ Metamaps.Map.InfoBox = {
},
createContributorList: function () {
var self = Metamaps.Map.InfoBox
- var relevantPeople = Metamaps.Active.Map.get('permission') === 'commons' ? Metamaps.Mappers : Metamaps.Collaborators
- var activeMapperIsCreator = Metamaps.Active.Mapper && Metamaps.Active.Mapper.id === Metamaps.Active.Map.get('user_id')
+ var relevantPeople = Active.Map.get('permission') === 'commons' ? Metamaps.Mappers : Metamaps.Collaborators
+ var activeMapperIsCreator = Active.Mapper && Active.Mapper.id === Active.Map.get('user_id')
var string = ''
string += ''
relevantPeople.each(function (m) {
- var isCreator = Metamaps.Active.Map.get('user_id') === m.get('id')
+ var isCreator = Active.Map.get('user_id') === m.get('id')
string += '- ' + '' + m.get('name')
if (isCreator) string += ' (creator)'
string += ''
@@ -664,11 +664,11 @@ Metamaps.Map.InfoBox = {
return string
},
updateNumbers: function () {
- if (!Metamaps.Active.Map) return
+ if (!Active.Map) return
var self = Metamaps.Map.InfoBox
- var mapper = Metamaps.Active.Mapper
- var relevantPeople = Metamaps.Active.Map.get('permission') === 'commons' ? Metamaps.Mappers : Metamaps.Collaborators
+ var mapper = Active.Mapper
+ var relevantPeople = Active.Map.get('permission') === 'commons' ? Metamaps.Mappers : Metamaps.Collaborators
var contributors_class = ''
if (relevantPeople.length === 2) contributors_class = 'multiple mTwo'
@@ -720,10 +720,10 @@ Metamaps.Map.InfoBox = {
self.selectingPermission = false
var permission = $(this).attr('class')
- Metamaps.Active.Map.save({
+ Active.Map.save({
permission: permission
})
- Metamaps.Active.Map.updateMapWrapper()
+ Active.Map.updateMapWrapper()
shareable = permission === 'private' ? '' : 'shareable'
$('.mapPermission').removeClass('commons public private minimize').addClass(permission)
$('.mapPermission .permissionSelect').remove()
@@ -735,8 +735,8 @@ Metamaps.Map.InfoBox = {
confirmString += 'This action is irreversible. It will not delete the topics and synapses on the map.'
var doIt = confirm(confirmString)
- var map = Metamaps.Active.Map
- var mapper = Metamaps.Active.Mapper
+ var map = Active.Map
+ var mapper = Active.Mapper
var authorized = map.authorizePermissionChange(mapper)
if (doIt && authorized) {
@@ -747,7 +747,7 @@ Metamaps.Map.InfoBox = {
Metamaps.Maps.Shared.remove(map)
map.destroy()
Metamaps.Router.home()
- Metamaps.GlobalUI.notifyUser('Map eliminated!')
+ GlobalUI.notifyUser('Map eliminated!')
}
else if (!authorized) {
alert("Hey now. We can't just go around willy nilly deleting other people's maps now can we? Run off and find something constructive to do, eh?")
diff --git a/frontend/src/Metamaps/Mapper.js b/frontend/src/Metamaps/Mapper.js
index ac93c34d..3858101d 100644
--- a/frontend/src/Metamaps/Mapper.js
+++ b/frontend/src/Metamaps/Mapper.js
@@ -1,4 +1,6 @@
-import Backbone from './Backbone'
+/*
+ * Metamaps.Backbone
+ */
const Mapper = {
// this function is to retrieve a mapper JSON object from the database
@@ -9,7 +11,7 @@ const Mapper = {
if (!response.ok) throw response
return response.json()
}).then(payload => {
- callback(new Backbone.Mapper(payload))
+ callback(new Metamaps.Backbone.Mapper(payload))
})
}
}
diff --git a/frontend/src/Metamaps/PasteInput.js b/frontend/src/Metamaps/PasteInput.js
index ebe1d944..e0620329 100644
--- a/frontend/src/Metamaps/PasteInput.js
+++ b/frontend/src/Metamaps/PasteInput.js
@@ -2,6 +2,8 @@
import AutoLayout from './AutoLayout'
import Import from './Import'
+import TopicCard from './TopicCard'
+import Util from './Util'
const PasteInput = {
// thanks to https://github.com/kevva/url-regex
@@ -19,7 +21,7 @@ const PasteInput = {
window.addEventListener("drop", function(e) {
e = e || event;
e.preventDefault();
- var coords = Metamaps.Util.pixelsToCoords({ x: e.clientX, y: e.clientY })
+ var coords = Util.pixelsToCoords({ x: e.clientX, y: e.clientY })
if (e.dataTransfer.files.length > 0) {
var fileReader = new FileReader()
var text = fileReader.readAsText(e.dataTransfer.files[0])
@@ -86,7 +88,7 @@ const PasteInput = {
import_id,
{
success: function(topic) {
- Metamaps.TopicCard.showCard(topic.get('node'), function() {
+ TopicCard.showCard(topic.get('node'), function() {
$('#showcard #titleActivator').click()
.find('textarea, input').focus()
})
diff --git a/frontend/src/Metamaps/Realtime.js b/frontend/src/Metamaps/Realtime.js
index 35d00f06..1eef6408 100644
--- a/frontend/src/Metamaps/Realtime.js
+++ b/frontend/src/Metamaps/Realtime.js
@@ -1,27 +1,27 @@
/* global Metamaps, $ */
+import Active from './Active'
+import Control from './Control'
+import GlobalUI from './GlobalUI'
+import JIT from './JIT'
+import Map from './Map'
+import Mapper from './Mapper'
+import Topic from './Topic'
+import Util from './Util'
+import Views from './Views'
+import Visualize from './Visualize'
+
/*
* Metamaps.Realtime.js
*
* Dependencies:
- * - Metamaps.Active
* - Metamaps.Backbone
- * - Metamaps.Backbone
- * - Metamaps.Control
* - Metamaps.Erb
- * - Metamaps.GlobalUI
- * - Metamaps.JIT
- * - Metamaps.Map
- * - Metamaps.Mapper
* - Metamaps.Mappers
* - Metamaps.Mappings
* - Metamaps.Messages
* - Metamaps.Synapses
- * - Metamaps.Topic
* - Metamaps.Topics
- * - Metamaps.Util
- * - Metamaps.Views
- * - Metamaps.Visualize
*/
const Realtime = {
@@ -52,7 +52,7 @@ const Realtime = {
self.disconnected = true
})
- if (Metamaps.Active.Mapper) {
+ if (Active.Mapper) {
self.webrtc = new SimpleWebRTC({
connection: self.socket,
localVideoEl: self.videoId,
@@ -69,23 +69,23 @@ const Realtime = {
video: true,
audio: true
},
- nick: Metamaps.Active.Mapper.id
+ nick: Active.Mapper.id
})
var $video = $('').attr('id', self.videoId)
self.localVideo = {
$video: $video,
- view: new Metamaps.Views.videoView($video[0], $('body'), 'me', true, {
+ view: new Views.videoView($video[0], $('body'), 'me', true, {
DOUBLE_CLICK_TOLERANCE: 200,
- avatar: Metamaps.Active.Mapper ? Metamaps.Active.Mapper.get('image') : ''
+ avatar: Active.Mapper ? Active.Mapper.get('image') : ''
})
}
- self.room = new Metamaps.Views.room({
+ self.room = new Views.room({
webrtc: self.webrtc,
socket: self.socket,
- username: Metamaps.Active.Mapper ? Metamaps.Active.Mapper.get('name') : '',
- image: Metamaps.Active.Mapper ? Metamaps.Active.Mapper.get('image') : '',
+ username: Active.Mapper ? Active.Mapper.get('name') : '',
+ image: Active.Mapper ? Active.Mapper.get('image') : '',
room: 'global',
$video: self.localVideo.$video,
myVideoView: self.localVideo.view,
@@ -93,35 +93,35 @@ const Realtime = {
})
self.room.videoAdded(self.handleVideoAdded)
- if (!Metamaps.Active.Map) {
+ if (!Active.Map) {
self.room.chat.$container.hide()
}
$('body').prepend(self.room.chat.$container)
- } // if Metamaps.Active.Mapper
+ } // if Active.Mapper
},
addJuntoListeners: function () {
var self = Realtime
- $(document).on(Metamaps.Views.chatView.events.openTray, function () {
+ $(document).on(Views.chatView.events.openTray, function () {
$('.main').addClass('compressed')
self.chatOpen = true
self.positionPeerIcons()
})
- $(document).on(Metamaps.Views.chatView.events.closeTray, function () {
+ $(document).on(Views.chatView.events.closeTray, function () {
$('.main').removeClass('compressed')
self.chatOpen = false
self.positionPeerIcons()
})
- $(document).on(Metamaps.Views.chatView.events.videosOn, function () {
+ $(document).on(Views.chatView.events.videosOn, function () {
$('#wrapper').removeClass('hideVideos')
})
- $(document).on(Metamaps.Views.chatView.events.videosOff, function () {
+ $(document).on(Views.chatView.events.videosOff, function () {
$('#wrapper').addClass('hideVideos')
})
- $(document).on(Metamaps.Views.chatView.events.cursorsOn, function () {
+ $(document).on(Views.chatView.events.cursorsOn, function () {
$('#wrapper').removeClass('hideCursors')
})
- $(document).on(Metamaps.Views.chatView.events.cursorsOff, function () {
+ $(document).on(Views.chatView.events.cursorsOff, function () {
$('#wrapper').addClass('hideCursors')
})
},
@@ -187,8 +187,8 @@ const Realtime = {
startActiveMap: function () {
var self = Realtime
- if (Metamaps.Active.Map && Metamaps.Active.Mapper) {
- if (Metamaps.Active.Map.authorizeToEdit(Metamaps.Active.Mapper)) {
+ if (Active.Map && Active.Mapper) {
+ if (Active.Map.authorizeToEdit(Active.Mapper)) {
self.turnOn()
self.setupSocket()
} else {
@@ -219,15 +219,15 @@ const Realtime = {
self.status = true
$('.collabCompass').show()
self.room.chat.$container.show()
- self.room.room = 'map-' + Metamaps.Active.Map.id
+ self.room.room = 'map-' + Active.Map.id
self.checkForACallToJoin()
self.activeMapper = {
- id: Metamaps.Active.Mapper.id,
- name: Metamaps.Active.Mapper.get('name'),
- username: Metamaps.Active.Mapper.get('name'),
- image: Metamaps.Active.Mapper.get('image'),
- color: Metamaps.Util.getPastelColor(),
+ id: Active.Mapper.id,
+ name: Active.Mapper.get('name'),
+ username: Active.Mapper.get('name'),
+ image: Active.Mapper.get('image'),
+ color: Util.getPastelColor(),
self: true
}
self.localVideo.view.$container.find('.video-cutoff').css({
@@ -237,7 +237,7 @@ const Realtime = {
},
checkForACallToJoin: function () {
var self = Realtime
- self.socket.emit('checkForCall', { room: self.room.room, mapid: Metamaps.Active.Map.id })
+ self.socket.emit('checkForCall', { room: self.room.room, mapid: Active.Map.id })
},
promptToJoin: function () {
var self = Realtime
@@ -245,7 +245,7 @@ const Realtime = {
var notifyText = "There's a conversation happening, want to join?"
notifyText += ' '
notifyText += ' '
- Metamaps.GlobalUI.notifyUser(notifyText, true)
+ GlobalUI.notifyUser(notifyText, true)
self.room.conversationInProgress()
},
conversationHasBegun: function () {
@@ -255,7 +255,7 @@ const Realtime = {
var notifyText = "There's a conversation starting, want to join?"
notifyText += ' '
notifyText += ' '
- Metamaps.GlobalUI.notifyUser(notifyText, true)
+ GlobalUI.notifyUser(notifyText, true)
self.room.conversationInProgress()
},
countOthersInConversation: function () {
@@ -275,7 +275,7 @@ const Realtime = {
if (self.inConversation) {
var username = mapper.name
var notifyText = username + ' joined the call'
- Metamaps.GlobalUI.notifyUser(notifyText)
+ GlobalUI.notifyUser(notifyText)
}
mapper.inConversation = true
@@ -290,7 +290,7 @@ const Realtime = {
if (self.inConversation) {
var username = mapper.name
var notifyText = username + ' left the call'
- Metamaps.GlobalUI.notifyUser(notifyText)
+ GlobalUI.notifyUser(notifyText)
}
mapper.inConversation = false
@@ -332,7 +332,7 @@ const Realtime = {
notifyText += username + ' is inviting you to a conversation. Join live?'
notifyText += ' '
notifyText += ' '
- Metamaps.GlobalUI.notifyUser(notifyText, true)
+ GlobalUI.notifyUser(notifyText, true)
},
invitedToJoin: function (inviter) {
var self = Realtime
@@ -344,55 +344,55 @@ const Realtime = {
var notifyText = username + ' is inviting you to the conversation. Join?'
notifyText += ' '
notifyText += ' '
- Metamaps.GlobalUI.notifyUser(notifyText, true)
+ GlobalUI.notifyUser(notifyText, true)
},
acceptCall: function (userid) {
var self = Realtime
self.room.chat.sound.stop('sessioninvite')
self.socket.emit('callAccepted', {
- mapid: Metamaps.Active.Map.id,
- invited: Metamaps.Active.Mapper.id,
+ mapid: Active.Map.id,
+ invited: Active.Mapper.id,
inviter: userid
})
- $.post('/maps/' + Metamaps.Active.Map.id + '/events/conversation')
+ $.post('/maps/' + Active.Map.id + '/events/conversation')
self.joinCall()
- Metamaps.GlobalUI.clearNotify()
+ GlobalUI.clearNotify()
},
denyCall: function (userid) {
var self = Realtime
self.room.chat.sound.stop('sessioninvite')
self.socket.emit('callDenied', {
- mapid: Metamaps.Active.Map.id,
- invited: Metamaps.Active.Mapper.id,
+ mapid: Active.Map.id,
+ invited: Active.Mapper.id,
inviter: userid
})
- Metamaps.GlobalUI.clearNotify()
+ GlobalUI.clearNotify()
},
denyInvite: function (userid) {
var self = Realtime
self.room.chat.sound.stop('sessioninvite')
self.socket.emit('inviteDenied', {
- mapid: Metamaps.Active.Map.id,
- invited: Metamaps.Active.Mapper.id,
+ mapid: Active.Map.id,
+ invited: Active.Mapper.id,
inviter: userid
})
- Metamaps.GlobalUI.clearNotify()
+ GlobalUI.clearNotify()
},
inviteACall: function (userid) {
var self = Realtime
self.socket.emit('inviteACall', {
- mapid: Metamaps.Active.Map.id,
- inviter: Metamaps.Active.Mapper.id,
+ mapid: Active.Map.id,
+ inviter: Active.Mapper.id,
invited: userid
})
self.room.chat.invitationPending(userid)
- Metamaps.GlobalUI.clearNotify()
+ GlobalUI.clearNotify()
},
inviteToJoin: function (userid) {
var self = Realtime
self.socket.emit('inviteToJoin', {
- mapid: Metamaps.Active.Map.id,
- inviter: Metamaps.Active.Mapper.id,
+ mapid: Active.Map.id,
+ inviter: Active.Mapper.id,
invited: userid
})
self.room.chat.invitationPending(userid)
@@ -401,7 +401,7 @@ const Realtime = {
var self = Realtime
var username = self.mappersOnMap[userid].name
- Metamaps.GlobalUI.notifyUser('Conversation starting...')
+ GlobalUI.notifyUser('Conversation starting...')
self.joinCall()
self.room.chat.invitationAnswered(userid)
},
@@ -409,14 +409,14 @@ const Realtime = {
var self = Realtime
var username = self.mappersOnMap[userid].name
- Metamaps.GlobalUI.notifyUser(username + " didn't accept your invitation")
+ GlobalUI.notifyUser(username + " didn't accept your invitation")
self.room.chat.invitationAnswered(userid)
},
inviteDenied: function (userid) {
var self = Realtime
var username = self.mappersOnMap[userid].name
- Metamaps.GlobalUI.notifyUser(username + " didn't accept your invitation")
+ GlobalUI.notifyUser(username + " didn't accept your invitation")
self.room.chat.invitationAnswered(userid)
},
joinCall: function () {
@@ -436,22 +436,22 @@ const Realtime = {
})
self.inConversation = true
self.socket.emit('mapperJoinedCall', {
- mapid: Metamaps.Active.Map.id,
- id: Metamaps.Active.Mapper.id
+ mapid: Active.Map.id,
+ id: Active.Mapper.id
})
self.webrtc.startLocalVideo()
- Metamaps.GlobalUI.clearNotify()
- self.room.chat.mapperJoinedCall(Metamaps.Active.Mapper.id)
+ GlobalUI.clearNotify()
+ self.room.chat.mapperJoinedCall(Active.Mapper.id)
},
leaveCall: function () {
var self = Realtime
self.socket.emit('mapperLeftCall', {
- mapid: Metamaps.Active.Map.id,
- id: Metamaps.Active.Mapper.id
+ mapid: Active.Map.id,
+ id: Active.Mapper.id
})
- self.room.chat.mapperLeftCall(Metamaps.Active.Mapper.id)
+ self.room.chat.mapperLeftCall(Active.Mapper.id)
self.room.leaveVideoOnly()
self.inConversation = false
self.localVideo.view.$container.hide()
@@ -479,63 +479,63 @@ const Realtime = {
setupSocket: function () {
var self = Realtime
var socket = Realtime.socket
- var myId = Metamaps.Active.Mapper.id
+ var myId = Active.Mapper.id
socket.emit('newMapperNotify', {
userid: myId,
- username: Metamaps.Active.Mapper.get('name'),
- userimage: Metamaps.Active.Mapper.get('image'),
- mapid: Metamaps.Active.Map.id
+ username: Active.Mapper.get('name'),
+ userimage: Active.Mapper.get('image'),
+ mapid: Active.Map.id
})
- socket.on(myId + '-' + Metamaps.Active.Map.id + '-invitedToCall', self.invitedToCall) // new call
- socket.on(myId + '-' + Metamaps.Active.Map.id + '-invitedToJoin', self.invitedToJoin) // call already in progress
- socket.on(myId + '-' + Metamaps.Active.Map.id + '-callAccepted', self.callAccepted)
- socket.on(myId + '-' + Metamaps.Active.Map.id + '-callDenied', self.callDenied)
- socket.on(myId + '-' + Metamaps.Active.Map.id + '-inviteDenied', self.inviteDenied)
+ socket.on(myId + '-' + Active.Map.id + '-invitedToCall', self.invitedToCall) // new call
+ socket.on(myId + '-' + Active.Map.id + '-invitedToJoin', self.invitedToJoin) // call already in progress
+ socket.on(myId + '-' + Active.Map.id + '-callAccepted', self.callAccepted)
+ socket.on(myId + '-' + Active.Map.id + '-callDenied', self.callDenied)
+ socket.on(myId + '-' + Active.Map.id + '-inviteDenied', self.inviteDenied)
// receive word that there's a conversation in progress
- socket.on('maps-' + Metamaps.Active.Map.id + '-callInProgress', self.promptToJoin)
- socket.on('maps-' + Metamaps.Active.Map.id + '-callStarting', self.conversationHasBegun)
+ socket.on('maps-' + Active.Map.id + '-callInProgress', self.promptToJoin)
+ socket.on('maps-' + Active.Map.id + '-callStarting', self.conversationHasBegun)
- socket.on('maps-' + Metamaps.Active.Map.id + '-mapperJoinedCall', self.mapperJoinedCall)
- socket.on('maps-' + Metamaps.Active.Map.id + '-mapperLeftCall', self.mapperLeftCall)
+ socket.on('maps-' + Active.Map.id + '-mapperJoinedCall', self.mapperJoinedCall)
+ socket.on('maps-' + Active.Map.id + '-mapperLeftCall', self.mapperLeftCall)
// if you're the 'new guy' update your list with who's already online
- socket.on(myId + '-' + Metamaps.Active.Map.id + '-UpdateMapperList', self.updateMapperList)
+ socket.on(myId + '-' + Active.Map.id + '-UpdateMapperList', self.updateMapperList)
// receive word that there's a new mapper on the map
- socket.on('maps-' + Metamaps.Active.Map.id + '-newmapper', self.newPeerOnMap)
+ socket.on('maps-' + Active.Map.id + '-newmapper', self.newPeerOnMap)
// receive word that a mapper left the map
- socket.on('maps-' + Metamaps.Active.Map.id + '-lostmapper', self.lostPeerOnMap)
+ socket.on('maps-' + Active.Map.id + '-lostmapper', self.lostPeerOnMap)
// receive word that there's a mapper turned on realtime
- socket.on('maps-' + Metamaps.Active.Map.id + '-newrealtime', self.newCollaborator)
+ socket.on('maps-' + Active.Map.id + '-newrealtime', self.newCollaborator)
// receive word that there's a mapper turned on realtime
- socket.on('maps-' + Metamaps.Active.Map.id + '-lostrealtime', self.lostCollaborator)
+ socket.on('maps-' + Active.Map.id + '-lostrealtime', self.lostCollaborator)
//
- socket.on('maps-' + Metamaps.Active.Map.id + '-topicDrag', self.topicDrag)
+ socket.on('maps-' + Active.Map.id + '-topicDrag', self.topicDrag)
//
- socket.on('maps-' + Metamaps.Active.Map.id + '-newTopic', self.newTopic)
+ socket.on('maps-' + Active.Map.id + '-newTopic', self.newTopic)
//
- socket.on('maps-' + Metamaps.Active.Map.id + '-newMessage', self.newMessage)
+ socket.on('maps-' + Active.Map.id + '-newMessage', self.newMessage)
//
- socket.on('maps-' + Metamaps.Active.Map.id + '-removeTopic', self.removeTopic)
+ socket.on('maps-' + Active.Map.id + '-removeTopic', self.removeTopic)
//
- socket.on('maps-' + Metamaps.Active.Map.id + '-newSynapse', self.newSynapse)
+ socket.on('maps-' + Active.Map.id + '-newSynapse', self.newSynapse)
//
- socket.on('maps-' + Metamaps.Active.Map.id + '-removeSynapse', self.removeSynapse)
+ socket.on('maps-' + Active.Map.id + '-removeSynapse', self.removeSynapse)
// update mapper compass position
- socket.on('maps-' + Metamaps.Active.Map.id + '-updatePeerCoords', self.updatePeerCoords)
+ socket.on('maps-' + Active.Map.id + '-updatePeerCoords', self.updatePeerCoords)
// deletions
socket.on('deleteTopicFromServer', self.removeTopic)
@@ -551,7 +551,7 @@ const Realtime = {
x: event.pageX,
y: event.pageY
}
- var coords = Metamaps.Util.pixelsToCoords(pixels)
+ var coords = Util.pixelsToCoords(pixels)
self.sendCoords(coords)
}
$(document).on('mousemove.map', sendCoords)
@@ -562,54 +562,54 @@ const Realtime = {
x: e.pageX,
y: e.pageY
}
- var coords = Metamaps.Util.pixelsToCoords(pixels)
+ var coords = Util.pixelsToCoords(pixels)
self.sendCoords(coords)
}
self.positionPeerIcons()
}
- $(document).on(Metamaps.JIT.events.zoom + '.map', zoom)
+ $(document).on(JIT.events.zoom + '.map', zoom)
- $(document).on(Metamaps.JIT.events.pan + '.map', self.positionPeerIcons)
+ $(document).on(JIT.events.pan + '.map', self.positionPeerIcons)
var sendTopicDrag = function (event, positions) {
self.sendTopicDrag(positions)
}
- $(document).on(Metamaps.JIT.events.topicDrag + '.map', sendTopicDrag)
+ $(document).on(JIT.events.topicDrag + '.map', sendTopicDrag)
var sendNewTopic = function (event, data) {
self.sendNewTopic(data)
}
- $(document).on(Metamaps.JIT.events.newTopic + '.map', sendNewTopic)
+ $(document).on(JIT.events.newTopic + '.map', sendNewTopic)
var sendDeleteTopic = function (event, data) {
self.sendDeleteTopic(data)
}
- $(document).on(Metamaps.JIT.events.deleteTopic + '.map', sendDeleteTopic)
+ $(document).on(JIT.events.deleteTopic + '.map', sendDeleteTopic)
var sendRemoveTopic = function (event, data) {
self.sendRemoveTopic(data)
}
- $(document).on(Metamaps.JIT.events.removeTopic + '.map', sendRemoveTopic)
+ $(document).on(JIT.events.removeTopic + '.map', sendRemoveTopic)
var sendNewSynapse = function (event, data) {
self.sendNewSynapse(data)
}
- $(document).on(Metamaps.JIT.events.newSynapse + '.map', sendNewSynapse)
+ $(document).on(JIT.events.newSynapse + '.map', sendNewSynapse)
var sendDeleteSynapse = function (event, data) {
self.sendDeleteSynapse(data)
}
- $(document).on(Metamaps.JIT.events.deleteSynapse + '.map', sendDeleteSynapse)
+ $(document).on(JIT.events.deleteSynapse + '.map', sendDeleteSynapse)
var sendRemoveSynapse = function (event, data) {
self.sendRemoveSynapse(data)
}
- $(document).on(Metamaps.JIT.events.removeSynapse + '.map', sendRemoveSynapse)
+ $(document).on(JIT.events.removeSynapse + '.map', sendRemoveSynapse)
var sendNewMessage = function (event, data) {
self.sendNewMessage(data)
}
- $(document).on(Metamaps.Views.room.events.newMessage + '.map', sendNewMessage)
+ $(document).on(Views.room.events.newMessage + '.map', sendNewMessage)
},
attachMapListener: function () {
var self = Realtime
@@ -623,9 +623,9 @@ const Realtime = {
// send this new mapper back your details, and the awareness that you're online
var update = {
- username: Metamaps.Active.Mapper.get('name'),
- userid: Metamaps.Active.Mapper.id,
- mapid: Metamaps.Active.Map.id
+ username: Active.Mapper.get('name'),
+ userid: Active.Mapper.id,
+ mapid: Active.Map.id
}
socket.emit('notifyStartRealtime', update)
},
@@ -635,9 +635,9 @@ const Realtime = {
// send this new mapper back your details, and the awareness that you're online
var update = {
- username: Metamaps.Active.Mapper.get('name'),
- userid: Metamaps.Active.Mapper.id,
- mapid: Metamaps.Active.Map.id
+ username: Active.Mapper.get('name'),
+ userid: Active.Mapper.id,
+ mapid: Active.Map.id
}
socket.emit('notifyStopRealtime', update)
},
@@ -655,7 +655,7 @@ const Realtime = {
name: data.username,
username: data.username,
image: data.userimage,
- color: Metamaps.Util.getPastelColor(),
+ color: Util.getPastelColor(),
realtime: data.userrealtime,
inConversation: data.userinconversation,
coords: {
@@ -664,7 +664,7 @@ const Realtime = {
}
}
- if (data.userid !== Metamaps.Active.Mapper.id) {
+ if (data.userid !== Active.Mapper.id) {
self.room.chat.addParticipant(self.mappersOnMap[data.userid])
if (data.userinconversation) self.room.chat.mapperJoinedCall(data.userid)
@@ -687,7 +687,7 @@ const Realtime = {
name: data.username,
username: data.username,
image: data.userimage,
- color: Metamaps.Util.getPastelColor(),
+ color: Util.getPastelColor(),
realtime: true,
coords: {
x: 0,
@@ -696,7 +696,7 @@ const Realtime = {
}
// create an item for them in the realtime box
- if (data.userid !== Metamaps.Active.Mapper.id && self.status) {
+ if (data.userid !== Active.Mapper.id && self.status) {
self.room.chat.sound.play('joinmap')
self.room.chat.addParticipant(self.mappersOnMap[data.userid])
@@ -707,17 +707,17 @@ const Realtime = {
if (firstOtherPerson) {
notifyMessage += ' '
}
- Metamaps.GlobalUI.notifyUser(notifyMessage)
+ GlobalUI.notifyUser(notifyMessage)
// send this new mapper back your details, and the awareness that you've loaded the map
var update = {
userToNotify: data.userid,
- username: Metamaps.Active.Mapper.get('name'),
- userimage: Metamaps.Active.Mapper.get('image'),
- userid: Metamaps.Active.Mapper.id,
+ username: Active.Mapper.get('name'),
+ userimage: Active.Mapper.get('image'),
+ userid: Active.Mapper.id,
userrealtime: self.status,
userinconversation: self.inConversation,
- mapid: Metamaps.Active.Map.id
+ mapid: Active.Map.id
}
socket.emit('updateNewMapperList', update)
}
@@ -753,7 +753,7 @@ const Realtime = {
$('#compass' + data.userid).remove()
self.room.chat.removeParticipant(data.username)
- Metamaps.GlobalUI.notifyUser(data.username + ' just left the map')
+ GlobalUI.notifyUser(data.username + ' just left the map')
if ((self.inConversation && self.countOthersInConversation() === 0) ||
(!self.inConversation && self.countOthersInConversation() === 1)) {
@@ -772,7 +772,7 @@ const Realtime = {
// $('#mapper' + data.userid).removeClass('littleRtOff').addClass('littleRtOn')
$('#compass' + data.userid).show()
- Metamaps.GlobalUI.notifyUser(data.username + ' just turned on realtime')
+ GlobalUI.notifyUser(data.username + ' just turned on realtime')
},
lostCollaborator: function (data) {
var self = Realtime
@@ -786,7 +786,7 @@ const Realtime = {
// $('#mapper' + data.userid).removeClass('littleRtOn').addClass('littleRtOff')
$('#compass' + data.userid).hide()
- Metamaps.GlobalUI.notifyUser(data.username + ' just turned off realtime')
+ GlobalUI.notifyUser(data.username + ' just turned off realtime')
},
updatePeerCoords: function (data) {
var self = Realtime
@@ -819,7 +819,7 @@ const Realtime = {
var compassDiameter = 56
var compassArrowSize = 24
- var origPixels = Metamaps.Util.coordsToPixels(mapper.coords)
+ var origPixels = Util.coordsToPixels(mapper.coords)
var pixels = self.limitPixelsToScreen(origPixels)
$('#compass' + id).css({
left: pixels.x + 'px',
@@ -867,14 +867,14 @@ const Realtime = {
var self = Realtime
var socket = Realtime.socket
- var map = Metamaps.Active.Map
- var mapper = Metamaps.Active.Mapper
+ var map = Active.Map
+ var mapper = Active.Mapper
if (self.status && map.authorizeToEdit(mapper) && socket) {
var update = {
usercoords: coords,
- userid: Metamaps.Active.Mapper.id,
- mapid: Metamaps.Active.Map.id
+ userid: Active.Mapper.id,
+ mapid: Active.Map.id
}
socket.emit('updateMapperCoords', update)
}
@@ -883,8 +883,8 @@ const Realtime = {
var self = Realtime
var socket = self.socket
- if (Metamaps.Active.Map && self.status) {
- positions.mapid = Metamaps.Active.Map.id
+ if (Active.Map && self.status) {
+ positions.mapid = Active.Map.id
socket.emit('topicDrag', positions)
}
},
@@ -895,13 +895,13 @@ const Realtime = {
var topic
var node
- if (Metamaps.Active.Map && self.status) {
+ if (Active.Map && self.status) {
for (var key in positions) {
topic = Metamaps.Topics.get(key)
if (topic) node = topic.get('node')
if (node) node.pos.setc(positions[key].x, positions[key].y)
} // for
- Metamaps.Visualize.mGraph.plot()
+ Visualize.mGraph.plot()
}
},
sendTopicChange: function (topic) {
@@ -960,23 +960,23 @@ const Realtime = {
socket.emit('mapChangeFromClient', data)
},
mapChange: function (data) {
- var map = Metamaps.Active.Map
+ var map = Active.Map
var isActiveMap = map && data.mapId === map.id
if (isActiveMap) {
- var couldEditBefore = map.authorizeToEdit(Metamaps.Active.Mapper)
+ var couldEditBefore = map.authorizeToEdit(Active.Mapper)
var idBefore = map.id
map.fetch({
success: function (model, response) {
var idNow = model.id
- var canEditNow = model.authorizeToEdit(Metamaps.Active.Mapper)
+ var canEditNow = model.authorizeToEdit(Active.Mapper)
if (idNow !== idBefore) {
- Metamaps.Map.leavePrivateMap() // this means the map has been changed to private
+ Map.leavePrivateMap() // this means the map has been changed to private
}
else if (couldEditBefore && !canEditNow) {
- Metamaps.Map.cantEditNow()
+ Map.cantEditNow()
}
else if (!couldEditBefore && canEditNow) {
- Metamaps.Map.canEditNow()
+ Map.canEditNow()
} else {
model.fetchContained()
model.trigger('changeByOther')
@@ -991,7 +991,7 @@ const Realtime = {
var socket = self.socket
var message = data.attributes
- message.mapid = Metamaps.Active.Map.id
+ message.mapid = Active.Map.id
socket.emit('newMessage', message)
},
newMessage: function (data) {
@@ -1005,14 +1005,14 @@ const Realtime = {
var self = Realtime
var socket = self.socket
- if (Metamaps.Active.Map && self.status) {
- data.mapperid = Metamaps.Active.Mapper.id
- data.mapid = Metamaps.Active.Map.id
+ if (Active.Map && self.status) {
+ data.mapperid = Active.Mapper.id
+ data.mapid = Active.Map.id
socket.emit('newTopic', data)
}
},
newTopic: function (data) {
- var topic, mapping, mapper, mapperCallback, cancel
+ var topic, mapping, mapper, cancel
var self = Realtime
var socket = self.socket
@@ -1021,7 +1021,7 @@ const Realtime = {
function waitThenRenderTopic () {
if (topic && mapping && mapper) {
- Metamaps.Topic.renderTopic(mapping, topic, false, false)
+ Topic.renderTopic(mapping, topic, false, false)
}
else if (!cancel) {
setTimeout(waitThenRenderTopic, 10)
@@ -1030,11 +1030,10 @@ const Realtime = {
mapper = Metamaps.Mappers.get(data.mapperid)
if (mapper === undefined) {
- mapperCallback = function (m) {
+ Mapper.get(data.mapperid, function(m) {
Metamaps.Mappers.add(m)
mapper = m
- }
- Metamaps.Mapper.get(data.mapperid, mapperCallback)
+ })
}
$.ajax({
url: '/topics/' + data.mappableid + '.json',
@@ -1064,7 +1063,7 @@ const Realtime = {
var self = Realtime
var socket = self.socket
- if (Metamaps.Active.Map) {
+ if (Active.Map) {
socket.emit('deleteTopicFromClient', data)
}
},
@@ -1073,8 +1072,8 @@ const Realtime = {
var self = Realtime
var socket = self.socket
- if (Metamaps.Active.Map) {
- data.mapid = Metamaps.Active.Map.id
+ if (Active.Map) {
+ data.mapid = Active.Map.id
socket.emit('removeTopic', data)
}
},
@@ -1088,7 +1087,7 @@ const Realtime = {
if (topic) {
var node = topic.get('node')
var mapping = topic.getMapping()
- Metamaps.Control.hideNode(node.id)
+ Control.hideNode(node.id)
Metamaps.Topics.remove(topic)
Metamaps.Mappings.remove(mapping)
}
@@ -1098,9 +1097,9 @@ const Realtime = {
var self = Realtime
var socket = self.socket
- if (Metamaps.Active.Map) {
- data.mapperid = Metamaps.Active.Mapper.id
- data.mapid = Metamaps.Active.Map.id
+ if (Active.Map) {
+ data.mapperid = Active.Mapper.id
+ data.mapid = Active.Map.id
socket.emit('newSynapse', data)
}
},
@@ -1119,7 +1118,7 @@ const Realtime = {
topic2 = synapse.getTopic2()
node2 = topic2.get('node')
- Metamaps.Synapse.renderSynapse(mapping, synapse, node1, node2, false)
+ Synapse.renderSynapse(mapping, synapse, node1, node2, false)
}
else if (!cancel) {
setTimeout(waitThenRenderSynapse, 10)
@@ -1128,11 +1127,10 @@ const Realtime = {
mapper = Metamaps.Mappers.get(data.mapperid)
if (mapper === undefined) {
- mapperCallback = function (m) {
+ Mapper.get(data.mapperid, function(m) {
Metamaps.Mappers.add(m)
mapper = m
- }
- Metamaps.Mapper.get(data.mapperid, mapperCallback)
+ })
}
$.ajax({
url: '/synapses/' + data.mappableid + '.json',
@@ -1161,8 +1159,8 @@ const Realtime = {
var self = Realtime
var socket = self.socket
- if (Metamaps.Active.Map) {
- data.mapid = Metamaps.Active.Map.id
+ if (Active.Map) {
+ data.mapid = Active.Map.id
socket.emit('deleteSynapseFromClient', data)
}
},
@@ -1171,8 +1169,8 @@ const Realtime = {
var self = Realtime
var socket = self.socket
- if (Metamaps.Active.Map) {
- data.mapid = Metamaps.Active.Map.id
+ if (Active.Map) {
+ data.mapid = Active.Map.id
socket.emit('removeSynapse', data)
}
},
@@ -1187,7 +1185,7 @@ const Realtime = {
var edge = synapse.get('edge')
var mapping = synapse.getMapping()
if (edge.getData('mappings').length - 1 === 0) {
- Metamaps.Control.hideEdge(edge)
+ Control.hideEdge(edge)
}
var index = _.indexOf(edge.getData('synapses'), synapse)
diff --git a/frontend/src/Metamaps/Router.js b/frontend/src/Metamaps/Router.js
index 8aacadd1..d5c07e12 100644
--- a/frontend/src/Metamaps/Router.js
+++ b/frontend/src/Metamaps/Router.js
@@ -1,19 +1,19 @@
-window.Metamaps = window.Metamaps || {}
/* global Metamaps, Backbone, $ */
+import Active from './Active'
+import GlobalUI from './GlobalUI'
+import JIT from './JIT'
+import Map from './Map'
+import Topic from './Topic'
+import Views from './Views'
+import Visualize from './Visualize'
+
/*
* Metamaps.Router.js.erb
*
* Dependencies:
- * - Metamaps.Active
- * - Metamaps.GlobalUI
- * - Metamaps.JIT
* - Metamaps.Loading
- * - Metamaps.Map
* - Metamaps.Maps
- * - Metamaps.Topic
- * - Metamaps.Views
- * - Metamaps.Visualize
*/
const _Router = Backbone.Router.extend({
@@ -24,53 +24,53 @@ const _Router = Backbone.Router.extend({
'maps/:id': 'maps' // #maps/7
},
home: function () {
- clearTimeout(Metamaps.Router.timeoutId)
+ clearTimeout(this.timeoutId)
- if (Metamaps.Active.Mapper) document.title = 'Explore Active Maps | Metamaps'
+ if (Active.Mapper) document.title = 'Explore Active Maps | Metamaps'
else document.title = 'Home | Metamaps'
- Metamaps.Router.currentSection = ''
- Metamaps.Router.currentPage = ''
+ this.currentSection = ''
+ this.currentPage = ''
$('.wrapper').removeClass('mapPage topicPage')
- var classes = Metamaps.Active.Mapper ? 'homePage explorePage' : 'homePage'
+ var classes = Active.Mapper ? 'homePage explorePage' : 'homePage'
$('.wrapper').addClass(classes)
var navigate = function () {
- Metamaps.Router.timeoutId = setTimeout(function () {
- Metamaps.Router.navigate('')
+ this.timeoutId = setTimeout(function () {
+ this.navigate('')
}, 300)
}
// all this only for the logged in home page
- if (Metamaps.Active.Mapper) {
+ if (Active.Mapper) {
$('.homeButton a').attr('href', '/')
- Metamaps.GlobalUI.hideDiv('#yield')
+ GlobalUI.hideDiv('#yield')
- Metamaps.GlobalUI.showDiv('#explore')
+ GlobalUI.showDiv('#explore')
- Metamaps.Views.exploreMaps.setCollection(Metamaps.Maps.Active)
+ Views.exploreMaps.setCollection(Metamaps.Maps.Active)
if (Metamaps.Maps.Active.length === 0) {
Metamaps.Maps.Active.getMaps(navigate) // this will trigger an explore maps render
} else {
- Metamaps.Views.exploreMaps.render(navigate)
+ Views.exploreMaps.render(navigate)
}
} else {
// logged out home page
- Metamaps.GlobalUI.hideDiv('#explore')
- Metamaps.GlobalUI.showDiv('#yield')
- Metamaps.Router.timeoutId = setTimeout(navigate, 500)
+ GlobalUI.hideDiv('#explore')
+ GlobalUI.showDiv('#yield')
+ this.timeoutId = setTimeout(navigate, 500)
}
- Metamaps.GlobalUI.hideDiv('#infovis')
- Metamaps.GlobalUI.hideDiv('#instructions')
- Metamaps.Map.end()
- Metamaps.Topic.end()
- Metamaps.Active.Map = null
- Metamaps.Active.Topic = null
+ GlobalUI.hideDiv('#infovis')
+ GlobalUI.hideDiv('#instructions')
+ Map.end()
+ Topic.end()
+ Active.Map = null
+ Active.Topic = null
},
explore: function (section, id) {
- clearTimeout(Metamaps.Router.timeoutId)
+ clearTimeout(this.timeoutId)
// just capitalize the variable section
// either 'featured', 'mapper', or 'active'
@@ -90,12 +90,12 @@ const _Router = Backbone.Router.extend({
document.title = 'Explore My Maps | Metamaps'
}
- if (Metamaps.Active.Mapper && section != 'mapper') $('.homeButton a').attr('href', '/explore/' + section)
+ if (Active.Mapper && section != 'mapper') $('.homeButton a').attr('href', '/explore/' + section)
$('.wrapper').removeClass('homePage mapPage topicPage')
$('.wrapper').addClass('explorePage')
- Metamaps.Router.currentSection = 'explore'
- Metamaps.Router.currentPage = section
+ this.currentSection = 'explore'
+ this.currentPage = section
// this will mean it's a mapper page being loaded
if (id) {
@@ -108,20 +108,20 @@ const _Router = Backbone.Router.extend({
Metamaps.Maps.Mapper.mapperId = id
}
- Metamaps.Views.exploreMaps.setCollection(Metamaps.Maps[capitalize])
+ Views.exploreMaps.setCollection(Metamaps.Maps[capitalize])
var navigate = function () {
- var path = '/explore/' + Metamaps.Router.currentPage
+ var path = '/explore/' + this.currentPage
// alter url if for mapper profile page
- if (Metamaps.Router.currentPage === 'mapper') {
+ if (this.currentPage === 'mapper') {
path += '/' + Metamaps.Maps.Mapper.mapperId
}
- Metamaps.Router.navigate(path)
+ this.navigate(path)
}
var navigateTimeout = function () {
- Metamaps.Router.timeoutId = setTimeout(navigate, 300)
+ this.timeoutId = setTimeout(navigate, 300)
}
if (Metamaps.Maps[capitalize].length === 0) {
Metamaps.Loading.show()
@@ -130,77 +130,77 @@ const _Router = Backbone.Router.extend({
}, 300) // wait 300 milliseconds till the other animations are done to do the fetch
} else {
if (id) {
- Metamaps.Views.exploreMaps.fetchUserThenRender(navigateTimeout)
+ Views.exploreMaps.fetchUserThenRender(navigateTimeout)
} else {
- Metamaps.Views.exploreMaps.render(navigateTimeout)
+ Views.exploreMaps.render(navigateTimeout)
}
}
- Metamaps.GlobalUI.showDiv('#explore')
- Metamaps.GlobalUI.hideDiv('#yield')
- Metamaps.GlobalUI.hideDiv('#infovis')
- Metamaps.GlobalUI.hideDiv('#instructions')
- Metamaps.Map.end()
- Metamaps.Topic.end()
- Metamaps.Active.Map = null
- Metamaps.Active.Topic = null
+ GlobalUI.showDiv('#explore')
+ GlobalUI.hideDiv('#yield')
+ GlobalUI.hideDiv('#infovis')
+ GlobalUI.hideDiv('#instructions')
+ Map.end()
+ Topic.end()
+ Active.Map = null
+ Active.Topic = null
},
maps: function (id) {
- clearTimeout(Metamaps.Router.timeoutId)
+ clearTimeout(this.timeoutId)
document.title = 'Map ' + id + ' | Metamaps'
- Metamaps.Router.currentSection = 'map'
- Metamaps.Router.currentPage = id
+ this.currentSection = 'map'
+ this.currentPage = id
$('.wrapper').removeClass('homePage explorePage topicPage')
$('.wrapper').addClass('mapPage')
// another class will be added to wrapper if you
// can edit this map '.canEditMap'
- Metamaps.GlobalUI.hideDiv('#yield')
- Metamaps.GlobalUI.hideDiv('#explore')
+ GlobalUI.hideDiv('#yield')
+ GlobalUI.hideDiv('#explore')
// clear the visualization, if there was one, before showing its div again
- if (Metamaps.Visualize.mGraph) {
- Metamaps.Visualize.mGraph.graph.empty()
- Metamaps.Visualize.mGraph.plot()
- Metamaps.JIT.centerMap(Metamaps.Visualize.mGraph.canvas)
+ if (Visualize.mGraph) {
+ Visualize.mGraph.graph.empty()
+ Visualize.mGraph.plot()
+ JIT.centerMap(Visualize.mGraph.canvas)
}
- Metamaps.GlobalUI.showDiv('#infovis')
- Metamaps.Topic.end()
- Metamaps.Active.Topic = null
+ GlobalUI.showDiv('#infovis')
+ Topic.end()
+ Active.Topic = null
Metamaps.Loading.show()
- Metamaps.Map.end()
- Metamaps.Map.launch(id)
+ Map.end()
+ Map.launch(id)
},
topics: function (id) {
- clearTimeout(Metamaps.Router.timeoutId)
+ clearTimeout(this.timeoutId)
document.title = 'Topic ' + id + ' | Metamaps'
- Metamaps.Router.currentSection = 'topic'
- Metamaps.Router.currentPage = id
+ this.currentSection = 'topic'
+ this.currentPage = id
$('.wrapper').removeClass('homePage explorePage mapPage')
$('.wrapper').addClass('topicPage')
- Metamaps.GlobalUI.hideDiv('#yield')
- Metamaps.GlobalUI.hideDiv('#explore')
+ GlobalUI.hideDiv('#yield')
+ GlobalUI.hideDiv('#explore')
// clear the visualization, if there was one, before showing its div again
- if (Metamaps.Visualize.mGraph) {
- Metamaps.Visualize.mGraph.graph.empty()
- Metamaps.Visualize.mGraph.plot()
- Metamaps.JIT.centerMap(Metamaps.Visualize.mGraph.canvas)
+ if (Visualize.mGraph) {
+ Visualize.mGraph.graph.empty()
+ Visualize.mGraph.plot()
+ JIT.centerMap(Visualize.mGraph.canvas)
}
- Metamaps.GlobalUI.showDiv('#infovis')
- Metamaps.Map.end()
- Metamaps.Active.Map = null
+ GlobalUI.showDiv('#infovis')
+ Map.end()
+ Active.Map = null
- Metamaps.Topic.end()
- Metamaps.Topic.launch(id)
+ Topic.end()
+ Topic.launch(id)
}
})
@@ -227,9 +227,9 @@ Router.intercept = function (evt) {
segments.splice(0, 1) // pop off the element created by the first /
if (href.attr === '') {
- Metamaps.Router.home()
+ Router.home()
} else {
- Metamaps.Router[segments[0]](segments[1], segments[2])
+ Router[segments[0]](segments[1], segments[2])
}
}
}
@@ -240,7 +240,7 @@ Router.init = function () {
pushState: true,
root: '/'
})
- $(document).on('click', 'a[data-router="true"]', Metamaps.Router.intercept)
+ $(document).on('click', 'a[data-router="true"]', Router.intercept)
}
export default Router
diff --git a/frontend/src/Metamaps/Synapse.js b/frontend/src/Metamaps/Synapse.js
index 5258de3b..b50e50e6 100644
--- a/frontend/src/Metamaps/Synapse.js
+++ b/frontend/src/Metamaps/Synapse.js
@@ -1,20 +1,22 @@
/* global Metamaps, $ */
+import Active from './Active'
+import Control from './Control'
+import Create from './Create'
+import JIT from './JIT'
+import Map from './Map'
+import Selected from './Selected'
+import Settings from './Settings'
+import Visualize from './Visualize'
+
/*
* Metamaps.Synapse.js.erb
*
* Dependencies:
* - Metamaps.Backbone
- * - Metamaps.Control
- * - Metamaps.Create
- * - Metamaps.JIT
- * - Metamaps.Map
* - Metamaps.Mappings
- * - Metamaps.Selected
- * - Metamaps.Settings
* - Metamaps.Synapses
* - Metamaps.Topics
- * - Metamaps.Visualize
*/
const Synapse = {
@@ -52,18 +54,18 @@ const Synapse = {
*
*/
renderSynapse: function (mapping, synapse, node1, node2, createNewInDB) {
- var self = Metamaps.Synapse
+ var self = Synapse
var edgeOnViz
var newedge = synapse.createEdge(mapping)
- Metamaps.Visualize.mGraph.graph.addAdjacence(node1, node2, newedge.data)
- edgeOnViz = Metamaps.Visualize.mGraph.graph.getAdjacence(node1.id, node2.id)
+ Visualize.mGraph.graph.addAdjacence(node1, node2, newedge.data)
+ edgeOnViz = Visualize.mGraph.graph.getAdjacence(node1.id, node2.id)
synapse.set('edge', edgeOnViz)
synapse.updateEdge() // links the synapse and the mapping to the edge
- Metamaps.Control.selectEdge(edgeOnViz)
+ Control.selectEdge(edgeOnViz)
var mappingSuccessCallback = function (mappingModel, response) {
var newSynapseData = {
@@ -71,17 +73,17 @@ const Synapse = {
mappableid: mappingModel.get('mappable_id')
}
- $(document).trigger(Metamaps.JIT.events.newSynapse, [newSynapseData])
+ $(document).trigger(JIT.events.newSynapse, [newSynapseData])
}
var synapseSuccessCallback = function (synapseModel, response) {
- if (Metamaps.Active.Map) {
+ if (Active.Map) {
mapping.save({ mappable_id: synapseModel.id }, {
success: mappingSuccessCallback
})
}
}
- if (!Metamaps.Settings.sandbox && createNewInDB) {
+ if (!Settings.sandbox && createNewInDB) {
if (synapse.isNew()) {
synapse.save(null, {
success: synapseSuccessCallback,
@@ -89,7 +91,7 @@ const Synapse = {
console.log('error saving synapse to database')
}
})
- } else if (!synapse.isNew() && Metamaps.Active.Map) {
+ } else if (!synapse.isNew() && Active.Map) {
mapping.save(null, {
success: mappingSuccessCallback
})
@@ -105,27 +107,27 @@ const Synapse = {
synapse,
mapping
- $(document).trigger(Metamaps.Map.events.editedByActiveMapper)
+ $(document).trigger(Map.events.editedByActiveMapper)
// for each node in this array we will create a synapse going to the position2 node.
var synapsesToCreate = []
- topic2 = Metamaps.Topics.get(Metamaps.Create.newSynapse.topic2id)
+ topic2 = Metamaps.Topics.get(Create.newSynapse.topic2id)
node2 = topic2.get('node')
- var len = Metamaps.Selected.Nodes.length
+ var len = Selected.Nodes.length
if (len == 0) {
- topic1 = Metamaps.Topics.get(Metamaps.Create.newSynapse.topic1id)
+ topic1 = Metamaps.Topics.get(Create.newSynapse.topic1id)
synapsesToCreate[0] = topic1.get('node')
} else if (len > 0) {
- synapsesToCreate = Metamaps.Selected.Nodes
+ synapsesToCreate = Selected.Nodes
}
for (var i = 0; i < synapsesToCreate.length; i++) {
node1 = synapsesToCreate[i]
topic1 = node1.getData('topic')
synapse = new Metamaps.Backbone.Synapse({
- desc: Metamaps.Create.newSynapse.description,
+ desc: Create.newSynapse.description,
node1_id: topic1.isNew() ? topic1.cid : topic1.id,
node2_id: topic2.isNew() ? topic2.cid : topic2.id,
})
@@ -141,7 +143,7 @@ const Synapse = {
self.renderSynapse(mapping, synapse, node1, node2, true)
} // for each in synapsesToCreate
- Metamaps.Create.newSynapse.hide()
+ Create.newSynapse.hide()
},
getSynapseFromAutocomplete: function (id) {
var self = Synapse,
@@ -158,11 +160,11 @@ const Synapse = {
})
Metamaps.Mappings.add(mapping)
- topic1 = Metamaps.Topics.get(Metamaps.Create.newSynapse.topic1id)
+ topic1 = Metamaps.Topics.get(Create.newSynapse.topic1id)
node1 = topic1.get('node')
- topic2 = Metamaps.Topics.get(Metamaps.Create.newSynapse.topic2id)
+ topic2 = Metamaps.Topics.get(Create.newSynapse.topic2id)
node2 = topic2.get('node')
- Metamaps.Create.newSynapse.hide()
+ Create.newSynapse.hide()
self.renderSynapse(mapping, synapse, node1, node2, true)
}
diff --git a/frontend/src/Metamaps/SynapseCard.js b/frontend/src/Metamaps/SynapseCard.js
index e0315486..28ff1e32 100644
--- a/frontend/src/Metamaps/SynapseCard.js
+++ b/frontend/src/Metamaps/SynapseCard.js
@@ -1,4 +1,4 @@
-/* global Metamaps, $ */
+/* global $ */
import Active from './Active'
import Control from './Control'
import Mapper from './Mapper'
diff --git a/frontend/src/Metamaps/Topic.js b/frontend/src/Metamaps/Topic.js
index ab93e419..412f7ef2 100644
--- a/frontend/src/Metamaps/Topic.js
+++ b/frontend/src/Metamaps/Topic.js
@@ -1,26 +1,29 @@
/* global Metamaps, $ */
import Active from './Active'
+import AutoLayout from './AutoLayout'
+import Create from './Create'
+import Filter from './Filter'
+import GlobalUI from './GlobalUI'
import JIT from './JIT'
+import Map from './Map'
+import Router from './Router'
import Selected from './Selected'
import Settings from './Settings'
+import SynapseCard from './SynapseCard'
+import TopicCard from './TopicCard'
import Util from './Util'
+import Visualize from './Visualize'
/*
* Metamaps.Topic.js.erb
*
* Dependencies:
* - Metamaps.Backbone
- * - Metamaps.Create
* - Metamaps.Creators
- * - Metamaps.Filter
- * - Metamaps.GlobalUI
* - Metamaps.Mappings
- * - Metamaps.SynapseCard
* - Metamaps.Synapses
- * - Metamaps.TopicCard
* - Metamaps.Topics
- * - Metamaps.Visualize
*/
const Topic = {
@@ -67,19 +70,19 @@ const Topic = {
$('#filter_by_mapper h3').html('CREATORS')
// build and render the visualization
- Metamaps.Visualize.type = 'RGraph'
+ Visualize.type = 'RGraph'
JIT.prepareVizData()
// update filters
- Metamaps.Filter.reset()
+ Filter.reset()
// reset selected arrays
Selected.reset()
// these three update the actual filter box with the right list items
- Metamaps.Filter.checkMetacodes()
- Metamaps.Filter.checkSynapses()
- Metamaps.Filter.checkMappers()
+ Filter.checkMetacodes()
+ Filter.checkSynapses()
+ Filter.checkMappers()
// for mobile
$('#header_content').html(Active.Topic.get('name'))
@@ -93,22 +96,22 @@ const Topic = {
end: function () {
if (Active.Topic) {
$('.rightclickmenu').remove()
- Metamaps.TopicCard.hideCard()
- Metamaps.SynapseCard.hideCard()
- Metamaps.Filter.close()
+ TopicCard.hideCard()
+ SynapseCard.hideCard()
+ Filter.close()
}
},
centerOn: function (nodeid, callback) {
// don't clash with fetchRelatives
- if (!Metamaps.Visualize.mGraph.busy) {
- Metamaps.Visualize.mGraph.onClick(nodeid, {
+ if (!Visualize.mGraph.busy) {
+ Visualize.mGraph.onClick(nodeid, {
hideLabels: false,
duration: 1000,
onComplete: function () {
if (callback) callback()
}
})
- Metamaps.Router.navigate('/topics/' + nodeid)
+ Router.navigate('/topics/' + nodeid)
Active.Topic = Metamaps.Topics.get(nodeid)
}
},
@@ -127,7 +130,7 @@ const Topic = {
var successCallback;
successCallback = function (data) {
- if (Metamaps.Visualize.mGraph.busy) {
+ if (Visualize.mGraph.busy) {
// don't clash with centerOn
window.setTimeout(function() { successCallback(data) }, 100)
return
@@ -141,7 +144,7 @@ const Topic = {
var synapseColl = new Metamaps.Backbone.SynapseCollection(data.synapses)
var graph = JIT.convertModelsToJIT(topicColl, synapseColl)[0]
- Metamaps.Visualize.mGraph.op.sum(graph, {
+ Visualize.mGraph.op.sum(graph, {
type: 'fade',
duration: 500,
hideLabels: false
@@ -149,7 +152,7 @@ const Topic = {
var i, l, t, s
- Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
+ Visualize.mGraph.graph.eachNode(function (n) {
t = Metamaps.Topics.get(n.id)
t.set({ node: n }, { silent: true })
t.updateNode()
@@ -186,7 +189,7 @@ const Topic = {
// opts is additional options in a hash
// TODO: move createNewInDB and permitCerateSYnapseAfter into opts
renderTopic: function (mapping, topic, createNewInDB, permitCreateSynapseAfter, opts) {
- var self = Metamaps.Topic
+ var self = Topic
var nodeOnViz, tempPos
@@ -194,37 +197,37 @@ const Topic = {
var midpoint = {}, pixelPos
- if (!$.isEmptyObject(Metamaps.Visualize.mGraph.graph.nodes)) {
- Metamaps.Visualize.mGraph.graph.addNode(newnode)
- nodeOnViz = Metamaps.Visualize.mGraph.graph.getNode(newnode.id)
+ if (!$.isEmptyObject(Visualize.mGraph.graph.nodes)) {
+ Visualize.mGraph.graph.addNode(newnode)
+ nodeOnViz = Visualize.mGraph.graph.getNode(newnode.id)
topic.set('node', nodeOnViz, {silent: true})
topic.updateNode() // links the topic and the mapping to the node
nodeOnViz.setData('dim', 1, 'start')
nodeOnViz.setData('dim', 25, 'end')
- if (Metamaps.Visualize.type === 'RGraph') {
+ if (Visualize.type === 'RGraph') {
tempPos = new $jit.Complex(mapping.get('xloc'), mapping.get('yloc'))
tempPos = tempPos.toPolar()
nodeOnViz.setPos(tempPos, 'current')
nodeOnViz.setPos(tempPos, 'start')
nodeOnViz.setPos(tempPos, 'end')
- } else if (Metamaps.Visualize.type === 'ForceDirected') {
+ } else if (Visualize.type === 'ForceDirected') {
nodeOnViz.setPos(new $jit.Complex(mapping.get('xloc'), mapping.get('yloc')), 'current')
nodeOnViz.setPos(new $jit.Complex(mapping.get('xloc'), mapping.get('yloc')), 'start')
nodeOnViz.setPos(new $jit.Complex(mapping.get('xloc'), mapping.get('yloc')), 'end')
}
- if (Metamaps.Create.newTopic.addSynapse && permitCreateSynapseAfter) {
- Metamaps.Create.newSynapse.topic1id = JIT.tempNode.getData('topic').id
+ if (Create.newTopic.addSynapse && permitCreateSynapseAfter) {
+ Create.newSynapse.topic1id = JIT.tempNode.getData('topic').id
// position the form
midpoint.x = JIT.tempNode.pos.getc().x + (nodeOnViz.pos.getc().x - JIT.tempNode.pos.getc().x) / 2
midpoint.y = JIT.tempNode.pos.getc().y + (nodeOnViz.pos.getc().y - JIT.tempNode.pos.getc().y) / 2
- pixelPos = Metamaps.Util.coordsToPixels(midpoint)
+ pixelPos = Util.coordsToPixels(midpoint)
$('#new_synapse').css('left', pixelPos.x + 'px')
$('#new_synapse').css('top', pixelPos.y + 'px')
// show the form
- Metamaps.Create.newSynapse.open()
- Metamaps.Visualize.mGraph.fx.animate({
+ Create.newSynapse.open()
+ Visualize.mGraph.fx.animate({
modes: ['node-property:dim'],
duration: 500,
onComplete: function () {
@@ -234,16 +237,16 @@ const Topic = {
}
})
} else {
- Metamaps.Visualize.mGraph.fx.plotNode(nodeOnViz, Metamaps.Visualize.mGraph.canvas)
- Metamaps.Visualize.mGraph.fx.animate({
+ Visualize.mGraph.fx.plotNode(nodeOnViz, Visualize.mGraph.canvas)
+ Visualize.mGraph.fx.animate({
modes: ['node-property:dim'],
duration: 500,
onComplete: function () {}
})
}
} else {
- Metamaps.Visualize.mGraph.loadJSON(newnode)
- nodeOnViz = Metamaps.Visualize.mGraph.graph.getNode(newnode.id)
+ Visualize.mGraph.loadJSON(newnode)
+ nodeOnViz = Visualize.mGraph.graph.getNode(newnode.id)
topic.set('node', nodeOnViz, {silent: true})
topic.updateNode() // links the topic and the mapping to the node
@@ -252,8 +255,8 @@ const Topic = {
nodeOnViz.setPos(new $jit.Complex(mapping.get('xloc'), mapping.get('yloc')), 'current')
nodeOnViz.setPos(new $jit.Complex(mapping.get('xloc'), mapping.get('yloc')), 'start')
nodeOnViz.setPos(new $jit.Complex(mapping.get('xloc'), mapping.get('yloc')), 'end')
- Metamaps.Visualize.mGraph.fx.plotNode(nodeOnViz, Metamaps.Visualize.mGraph.canvas)
- Metamaps.Visualize.mGraph.fx.animate({
+ Visualize.mGraph.fx.plotNode(nodeOnViz, Visualize.mGraph.canvas)
+ Visualize.mGraph.fx.animate({
modes: ['node-property:dim'],
duration: 500,
onComplete: function () {}
@@ -284,8 +287,8 @@ const Topic = {
})
}
- if (Metamaps.Create.newTopic.addSynapse) {
- Metamaps.Create.newSynapse.topic2id = topicModel.id
+ if (Create.newTopic.addSynapse) {
+ Create.newSynapse.topic2id = topicModel.id
}
}
@@ -305,58 +308,58 @@ const Topic = {
}
},
createTopicLocally: function () {
- var self = Metamaps.Topic
+ var self = Topic
- if (Metamaps.Create.newTopic.name === '') {
- Metamaps.GlobalUI.notifyUser('Please enter a topic title...')
+ if (Create.newTopic.name === '') {
+ GlobalUI.notifyUser('Please enter a topic title...')
return
}
// hide the 'double-click to add a topic' message
- Metamaps.GlobalUI.hideDiv('#instructions')
+ GlobalUI.hideDiv('#instructions')
- $(document).trigger(Metamaps.Map.events.editedByActiveMapper)
+ $(document).trigger(Map.events.editedByActiveMapper)
- var metacode = Metamaps.Metacodes.get(Metamaps.Create.newTopic.metacode)
+ var metacode = Metamaps.Metacodes.get(Create.newTopic.metacode)
var topic = new Metamaps.Backbone.Topic({
- name: Metamaps.Create.newTopic.name,
+ name: Create.newTopic.name,
metacode_id: metacode.id,
defer_to_map_id: Active.Map.id
})
Metamaps.Topics.add(topic)
- if (Metamaps.Create.newTopic.pinned) {
- var nextCoords = Metamaps.AutoLayout.getNextCoord()
+ if (Create.newTopic.pinned) {
+ var nextCoords = AutoLayout.getNextCoord()
}
var mapping = new Metamaps.Backbone.Mapping({
- xloc: nextCoords ? nextCoords.x : Metamaps.Create.newTopic.x,
- yloc: nextCoords ? nextCoords.y : Metamaps.Create.newTopic.y,
+ xloc: nextCoords ? nextCoords.x : Create.newTopic.x,
+ yloc: nextCoords ? nextCoords.y : Create.newTopic.y,
mappable_id: topic.cid,
mappable_type: 'Topic',
})
Metamaps.Mappings.add(mapping)
// these can't happen until the value is retrieved, which happens in the line above
- Metamaps.Create.newTopic.hide()
+ Create.newTopic.hide()
self.renderTopic(mapping, topic, true, true) // this function also includes the creation of the topic in the database
},
getTopicFromAutocomplete: function (id) {
- var self = Metamaps.Topic
+ var self = Topic
- $(document).trigger(Metamaps.Map.events.editedByActiveMapper)
+ $(document).trigger(Map.events.editedByActiveMapper)
- Metamaps.Create.newTopic.hide()
+ Create.newTopic.hide()
var topic = self.get(id)
- if (Metamaps.Create.newTopic.pinned) {
- var nextCoords = Metamaps.AutoLayout.getNextCoord()
+ if (Create.newTopic.pinned) {
+ var nextCoords = AutoLayout.getNextCoord()
}
var mapping = new Metamaps.Backbone.Mapping({
- xloc: nextCoords ? nextCoords.x : Metamaps.Create.newTopic.x,
- yloc: nextCoords ? nextCoords.y : Metamaps.Create.newTopic.y,
+ xloc: nextCoords ? nextCoords.x : Create.newTopic.x,
+ yloc: nextCoords ? nextCoords.y : Create.newTopic.y,
mappable_type: 'Topic',
mappable_id: topic.id,
})
@@ -365,13 +368,13 @@ const Topic = {
self.renderTopic(mapping, topic, true, true)
},
getTopicFromSearch: function (event, id) {
- var self = Metamaps.Topic
+ var self = Topic
- $(document).trigger(Metamaps.Map.events.editedByActiveMapper)
+ $(document).trigger(Map.events.editedByActiveMapper)
var topic = self.get(id)
- var nextCoords = Metamaps.AutoLayout.getNextCoord()
+ var nextCoords = AutoLayout.getNextCoord()
var mapping = new Metamaps.Backbone.Mapping({
xloc: nextCoords.x,
yloc: nextCoords.y,
@@ -382,7 +385,7 @@ const Topic = {
self.renderTopic(mapping, topic, true, true)
- Metamaps.GlobalUI.notifyUser('Topic was added to your map!')
+ GlobalUI.notifyUser('Topic was added to your map!')
event.stopPropagation()
event.preventDefault()
diff --git a/frontend/src/Metamaps/TopicCard.js b/frontend/src/Metamaps/TopicCard.js
index ebc79575..7320d285 100644
--- a/frontend/src/Metamaps/TopicCard.js
+++ b/frontend/src/Metamaps/TopicCard.js
@@ -1,7 +1,9 @@
/* global Metamaps, $ */
import Active from './Active'
+import GlobalUI from './GlobalUI'
import Mapper from './Mapper'
+import Router from './Router'
import Util from './Util'
import Visualize from './Visualize'
@@ -9,9 +11,7 @@ import Visualize from './Visualize'
* Metamaps.TopicCard.js
*
* Dependencies:
- * - Metamaps.GlobalUI
* - Metamaps.Metacodes
- * - Metamaps.Router
*/
const TopicCard = {
openTopicCard: null, // stores the topic that's currently open
@@ -332,7 +332,7 @@ const TopicCard = {
$('.showcard .hoverTip').removeClass('hide')
})
- $('.mapCount .tip li a').click(Metamaps.Router.intercept)
+ $('.mapCount .tip li a').click(Router.intercept)
var originalText = $('.showMore').html()
$('.mapCount .tip .showMore').unbind().toggle(
@@ -353,7 +353,7 @@ const TopicCard = {
var self = TopicCard
self.removeLink()
- Metamaps.GlobalUI.notifyUser('Invalid link')
+ GlobalUI.notifyUser('Invalid link')
},
populateShowCard: function (topic) {
var self = TopicCard
diff --git a/frontend/src/Metamaps/Visualize.js b/frontend/src/Metamaps/Visualize.js
index 9e44e8e8..678c7c64 100644
--- a/frontend/src/Metamaps/Visualize.js
+++ b/frontend/src/Metamaps/Visualize.js
@@ -2,6 +2,8 @@
import Active from './Active'
import JIT from './JIT'
+import Router from './Router'
+import TopicCard from './TopicCard'
/*
* Metamaps.Visualize
@@ -9,9 +11,7 @@ import JIT from './JIT'
* Dependencies:
* - Metamaps.Loading
* - Metamaps.Metacodes
- * - Metamaps.Router
* - Metamaps.Synapses
- * - Metamaps.TopicCard
* - Metamaps.Topics
*/
@@ -42,7 +42,7 @@ const Visualize = {
// prevent touch events on the canvas from default behaviour
$('#infovis-canvas').bind('touchend touchcancel', function (event) {
lastDist = 0
- if (!self.mGraph.events.touchMoved && !Visualize.touchDragNode) Metamaps.TopicCard.hideCurrentCard()
+ if (!self.mGraph.events.touchMoved && !Visualize.touchDragNode) TopicCard.hideCurrentCard()
self.mGraph.events.touched = self.mGraph.events.touchMoved = false
Visualize.touchDragNode = false
})
@@ -204,16 +204,16 @@ const Visualize = {
hold()
// update the url now that the map is ready
- clearTimeout(Metamaps.Router.timeoutId)
- Metamaps.Router.timeoutId = setTimeout(function () {
+ clearTimeout(Router.timeoutId)
+ Router.timeoutId = setTimeout(function () {
var m = Active.Map
var t = Active.Topic
if (m && window.location.pathname !== '/maps/' + m.id) {
- Metamaps.Router.navigate('/maps/' + m.id)
+ Router.navigate('/maps/' + m.id)
}
else if (t && window.location.pathname !== '/topics/' + t.id) {
- Metamaps.Router.navigate('/topics/' + t.id)
+ Router.navigate('/topics/' + t.id)
}
}, 800)
}
diff --git a/frontend/src/Metamaps/index.js b/frontend/src/Metamaps/index.js
index 37e93492..9fe8925b 100644
--- a/frontend/src/Metamaps/index.js
+++ b/frontend/src/Metamaps/index.js
@@ -83,22 +83,22 @@ document.addEventListener("DOMContentLoaded", function() {
Metamaps.Views.exploreMaps.setCollection( Metamaps.Maps[capitalize] )
if (Metamaps.currentPage === "mapper") {
- Metamaps.Views.exploreMaps.fetchUserThenRender()
+ Views.exploreMaps.fetchUserThenRender()
}
else {
- Metamaps.Views.exploreMaps.render()
+ Views.exploreMaps.render()
}
- Metamaps.GlobalUI.showDiv('#explore')
+ GlobalUI.showDiv('#explore')
}
- else if (Metamaps.currentSection === "" && Metamaps.Active.Mapper) {
- Metamaps.Views.exploreMaps.setCollection(Metamaps.Maps.Active)
- Metamaps.Views.exploreMaps.render()
- Metamaps.GlobalUI.showDiv('#explore')
+ else if (Metamaps.currentSection === "" && Active.Mapper) {
+ Views.exploreMaps.setCollection(Metamaps.Maps.Active)
+ Views.exploreMaps.render()
+ GlobalUI.showDiv('#explore')
}
- else if (Metamaps.Active.Map || Metamaps.Active.Topic) {
+ else if (Active.Map || Active.Topic) {
Metamaps.Loading.show()
- Metamaps.JIT.prepareVizData()
- Metamaps.GlobalUI.showDiv('#infovis')
+ JIT.prepareVizData()
+ GlobalUI.showDiv('#infovis')
}
});