diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 521bc782..b35dfc1e 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -10,18 +10,11 @@
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
-// require autocomplete-rails-uncompressed
-//
//= require jquery
//= require jquery-ui
-//= require jquery.purr
-//= require jquery.lettering
-//= require jquery.textillate
-//= require jquery.roundabout.min
-//= require bip
//= require jquery_ujs
-//= require typeahead
-//= require hogan-2.0.0
-//= require_directory ./scroll
-//= require_directory ./typing
-//= require ./metamaps/Metamaps.GlobalUI
\ No newline at end of file
+//= require ./orderedLibraries/underscore
+//= require ./orderedLibraries/backbone
+//= require_directory ./librariesForAllPages
+//= require ./metamaps/Metamaps.GlobalUI
+//= require ./metamaps/Metamaps.Backbone
\ No newline at end of file
diff --git a/app/assets/javascripts/compileMapPages.js b/app/assets/javascripts/compileMapPages.js
index 0d793858..24a98f84 100644
--- a/app/assets/javascripts/compileMapPages.js
+++ b/app/assets/javascripts/compileMapPages.js
@@ -10,10 +10,11 @@
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
-//= require socket.io
-//= require underscore
-//= require backbone
-//= require_directory ./carousel
+//
+// can't use require directory because underscore needs to come before backbone
+//
+//= require ./librariesForMapPages/cloudcarousel
+//= require ./librariesForMapPages/socket.io
//= require ./metamaps/JIT
//= require ./metamaps/Metamaps
//= require ./metamaps/Metamaps.JIT
\ No newline at end of file
diff --git a/app/assets/javascripts/bip.js b/app/assets/javascripts/librariesForAllPages/bip.js
similarity index 100%
rename from app/assets/javascripts/bip.js
rename to app/assets/javascripts/librariesForAllPages/bip.js
diff --git a/app/assets/javascripts/hogan-2.0.0.js b/app/assets/javascripts/librariesForAllPages/hogan-2.0.0.js
similarity index 100%
rename from app/assets/javascripts/hogan-2.0.0.js
rename to app/assets/javascripts/librariesForAllPages/hogan-2.0.0.js
diff --git a/app/assets/javascripts/scroll/jquery-ui-1.8.23.custom.min.js b/app/assets/javascripts/librariesForAllPages/jquery-ui-1.8.23.custom.min.js
similarity index 100%
rename from app/assets/javascripts/scroll/jquery-ui-1.8.23.custom.min.js
rename to app/assets/javascripts/librariesForAllPages/jquery-ui-1.8.23.custom.min.js
diff --git a/app/assets/javascripts/jquery.lettering.js b/app/assets/javascripts/librariesForAllPages/jquery.lettering.js
similarity index 100%
rename from app/assets/javascripts/jquery.lettering.js
rename to app/assets/javascripts/librariesForAllPages/jquery.lettering.js
diff --git a/app/assets/javascripts/scroll/jquery.mCustomScrollbar.min.js b/app/assets/javascripts/librariesForAllPages/jquery.mCustomScrollbar.min.js
similarity index 100%
rename from app/assets/javascripts/scroll/jquery.mCustomScrollbar.min.js
rename to app/assets/javascripts/librariesForAllPages/jquery.mCustomScrollbar.min.js
diff --git a/app/assets/javascripts/scroll/jquery.mousewheel.min.js b/app/assets/javascripts/librariesForAllPages/jquery.mousewheel.min.js
similarity index 100%
rename from app/assets/javascripts/scroll/jquery.mousewheel.min.js
rename to app/assets/javascripts/librariesForAllPages/jquery.mousewheel.min.js
diff --git a/app/assets/javascripts/jquery.purr.js b/app/assets/javascripts/librariesForAllPages/jquery.purr.js
similarity index 100%
rename from app/assets/javascripts/jquery.purr.js
rename to app/assets/javascripts/librariesForAllPages/jquery.purr.js
diff --git a/app/assets/javascripts/jquery.roundabout.min.js b/app/assets/javascripts/librariesForAllPages/jquery.roundabout.min.js
similarity index 100%
rename from app/assets/javascripts/jquery.roundabout.min.js
rename to app/assets/javascripts/librariesForAllPages/jquery.roundabout.min.js
diff --git a/app/assets/javascripts/jquery.textillate.js b/app/assets/javascripts/librariesForAllPages/jquery.textillate.js
similarity index 100%
rename from app/assets/javascripts/jquery.textillate.js
rename to app/assets/javascripts/librariesForAllPages/jquery.textillate.js
diff --git a/app/assets/javascripts/typing/jquery.typing-0.2.0.min.js b/app/assets/javascripts/librariesForAllPages/jquery.typing-0.2.0.min.js
similarity index 100%
rename from app/assets/javascripts/typing/jquery.typing-0.2.0.min.js
rename to app/assets/javascripts/librariesForAllPages/jquery.typing-0.2.0.min.js
diff --git a/app/assets/javascripts/scroll/mCSB_buttons.png b/app/assets/javascripts/librariesForAllPages/mCSB_buttons.png
similarity index 100%
rename from app/assets/javascripts/scroll/mCSB_buttons.png
rename to app/assets/javascripts/librariesForAllPages/mCSB_buttons.png
diff --git a/app/assets/javascripts/typeahead.js b/app/assets/javascripts/librariesForAllPages/typeahead.js
similarity index 100%
rename from app/assets/javascripts/typeahead.js
rename to app/assets/javascripts/librariesForAllPages/typeahead.js
diff --git a/app/assets/javascripts/WebSocketMain.swf b/app/assets/javascripts/librariesForMapPages/WebSocketMain.swf
similarity index 100%
rename from app/assets/javascripts/WebSocketMain.swf
rename to app/assets/javascripts/librariesForMapPages/WebSocketMain.swf
diff --git a/app/assets/javascripts/WebSocketMainInsecure.swf b/app/assets/javascripts/librariesForMapPages/WebSocketMainInsecure.swf
similarity index 100%
rename from app/assets/javascripts/WebSocketMainInsecure.swf
rename to app/assets/javascripts/librariesForMapPages/WebSocketMainInsecure.swf
diff --git a/app/assets/javascripts/carousel/cloud-carousel.1.0.5.js b/app/assets/javascripts/librariesForMapPages/cloudcarousel.js
similarity index 100%
rename from app/assets/javascripts/carousel/cloud-carousel.1.0.5.js
rename to app/assets/javascripts/librariesForMapPages/cloudcarousel.js
diff --git a/app/assets/javascripts/socket.io.js b/app/assets/javascripts/librariesForMapPages/socket.io.js
similarity index 100%
rename from app/assets/javascripts/socket.io.js
rename to app/assets/javascripts/librariesForMapPages/socket.io.js
diff --git a/app/assets/javascripts/metamaps/Metamaps.Backbone.js b/app/assets/javascripts/metamaps/Metamaps.Backbone.js
new file mode 100644
index 00000000..b36e77a9
--- /dev/null
+++ b/app/assets/javascripts/metamaps/Metamaps.Backbone.js
@@ -0,0 +1,34 @@
+Metamaps.Backbone = {};
+Metamaps.Backbone.Map = Backbone.Model.extend({
+ urlRoot: '/maps',
+ blacklist: ['created_at', 'updated_at'],
+ toJSON: function (options) {
+ return _.omit(this.attributes, this.blacklist);
+ },
+ authorizeToEdit: function (mapper) {
+ if (mapper && (this.get('permission') === "commons" || this.get('user_id') === mapper.get('id'))) return true;
+ else return false;
+ }
+});
+Metamaps.Backbone.MapsCollection = Backbone.Collection.extend({
+ model: Metamaps.Backbone.Map,
+ url: '/maps'
+});
+
+Metamaps.Backbone.Mapper = Backbone.Model.extend({
+ urlRoot: '/users',
+ blacklist: ['created_at', 'updated_at'],
+ toJSON: function (options) {
+ return _.omit(this.attributes, this.blacklist);
+ },
+});
+Metamaps.Backbone.MapperCollection = Backbone.Collection.extend({
+ model: Metamaps.Backbone.Mapper,
+ url: '/users'
+});
+Metamaps.Active.Mapper = new Metamaps.Backbone.Mapper({
+ id: userid,
+ name: username
+});
+Metamaps.Mappers = new Metamaps.Backbone.MapperCollection([Metamaps.Active.Mapper]);
+Metamaps.Maps = new Metamaps.Backbone.MapsCollection();
\ No newline at end of file
diff --git a/app/assets/javascripts/metamaps/Metamaps.GlobalUI.js b/app/assets/javascripts/metamaps/Metamaps.GlobalUI.js
index 1c577c6d..0dff8295 100644
--- a/app/assets/javascripts/metamaps/Metamaps.GlobalUI.js
+++ b/app/assets/javascripts/metamaps/Metamaps.GlobalUI.js
@@ -2,22 +2,22 @@ var Metamaps = {}; // this variable declaration defines a Javascript object that
/*
* unless you are on a page with the Javascript InfoVis Toolkit (Topic or Map) the only section in the metamaps
-* object will be this one
+* object will be these
GlobalUI
+Active
+Maps
+Mappers
+Backbone
* all these get added when you are on a page with the Javascript Infovis Toolkit
Settings
Touch
Mouse
-Active
Selected
-Maps
-Mappers
Metacodes
Topics
Synapses
Mappings
-Backbone
Create
TopicCard
SynapseCard
@@ -28,18 +28,25 @@ Control
Filter
Listeners
Organize
-Topic
-Synapse
Map
Mapper
+Topic
+Synapse
JIT
*/
+Metamaps.Active = {
+ Map: null,
+ Topic: null,
+ Mapper: null
+};
+Metamaps.Maps = {}; // will be initialized in Metamaps.Backbone.js as a MapCollection
+Metamaps.Mappers = {}; // will be initialized in Metamaps.Backbone.js as a MapperCollection
$(document).ready(function () {
for (var prop in Metamaps) {
-
+
// this runs the init function within each sub-object on the Metamaps one
if (Metamaps.hasOwnProperty(prop) &&
Metamaps[prop].hasOwnProperty('init') &&
@@ -49,13 +56,11 @@ $(document).ready(function () {
}
}
- //Metamaps.Visualize.type = "ForceDirected3D";
- // this line could maybe go at the end of the Metamaps.JIT init function
- if (Metamaps.JIT) Metamaps.JIT.prepareVizData();
});
Metamaps.GlobalUI = {
notifyTimeout: null,
+ lightbox: null,
init: function () {
var self = Metamaps.GlobalUI;
@@ -76,8 +81,12 @@ Metamaps.GlobalUI = {
$('.alert.metamaps').delay(10000).fadeOut('fast');
},
openLightbox: function (which) {
+ var self = Metamaps.GlobalUI;
+
$('.lightboxContent').hide();
$('#' + which).show();
+
+ self.lightbox = which;
$('#lightbox_overlay').show();
$('#lightbox_main').css('margin-top', '-' + ($('#lightbox_main').height() / 2) + 'px');
@@ -97,16 +106,20 @@ Metamaps.GlobalUI = {
},
closeLightbox: function () {
+ var self = Metamaps.GlobalUI;
+
$('#lightbox_overlay').hide();
- Metamaps.GlobalUI.CreateMap.reset('fork_map');
- Metamaps.GlobalUI.CreateMap.reset('new_map');
+
+ if (self.lightbox === 'forkmap') Metamaps.GlobalUI.CreateMap.reset('fork_map');
+ if (self.lightbox === 'newmap') Metamaps.GlobalUI.CreateMap.reset('new_map');
if (Metamaps.Create && Metamaps.Create.isSwitchingSet) {
Metamaps.Create.cancelMetacodeSetSwitch();
}
+ self.lightbox = null;
},
notifyUser: function (message) {
var self = Metamaps.GlobalUI;
-
+
if ($('.notice.metamaps').length == 0) {
$('body').prepend('
');
}
@@ -186,33 +199,102 @@ Metamaps.GlobalUI.MainMenu = {
Metamaps.GlobalUI.CreateMap = {
+ newMap: null,
+ emptyMapForm: "",
+ emptyForkMapForm: "",
+ topicsToMap: [],
+ synapsesToMap: [],
init: function () {
+ var self = Metamaps.GlobalUI.CreateMap;
+
+ self.newMap = new Metamaps.Backbone.Map({ permission: 'commons' });
+
+ self.bindFormEvents();
+
+ self.emptyMapForm = $('#new_map').html();
+
+ },
+ bindFormEvents: function () {
+ var self = Metamaps.GlobalUI.CreateMap;
+
+ $('.new_map button.cancel').unbind().bind('click', function (event) {
+ event.preventDefault();
+ Metamaps.GlobalUI.closeLightbox();
+ });
+ $('.new_map button.submitMap').unbind().bind('click', self.submit);
// bind permission changer events on the createMap form
- $('.permIcon').click(function () {
- $(this).siblings('#map_permission').val($(this).attr('data-permission'));
- $(this).siblings('.permIcon').find('.mapPermIcon').removeClass('selected');
- $(this).find('.mapPermIcon').addClass('selected');
- });
-
+ $('.permIcon').unbind().bind('click', self.switchPermission);
},
- reset: function (id) {
+ generateSuccessMessage: function (id) {
+ var stringStart = "Success! Do you want to Go to your new map?";
+ stringStart += " or Stay on this ";
+ var page = Metamaps.Active.Map ? 'map' : 'page';
+ var stringEnd = "?";
+ return stringStart + page + stringEnd;
+ },
+ switchPermission: function () {
+ var self = Metamaps.GlobalUI.CreateMap;
+
+ self.newMap.set('permission', $(this).attr('data-permission'));
+ $(this).siblings('.permIcon').find('.mapPermIcon').removeClass('selected');
+ $(this).find('.mapPermIcon').addClass('selected');
+ },
+ submit: function (event) {
+ event.preventDefault();
+
+ var self = Metamaps.GlobalUI.CreateMap;
- var form = $('#' + id);
-
- form.find('#map_name').val('');
- form.find('#map_desc').val('');
- form.find('#map_permission').val('commons');
-
- if (id == "fork_map") {
- form.find('#map_topicsToMap').val('0');
- form.find('#map_synapsesToMap').val('0');
+ if (Metamaps.GlobalUI.lightbox === 'forkmap') {
+ self.newMap.set('topicsToMap', self.topicsToMap);
+ self.newMap.set('synapsesToMap', self.synapsesToMap);
}
- // remove a selected state from all three of them
- form.find('.mapPermIcon').removeClass('selected');
- // add a selected state back to commons permission, the default
- form.find('.mapCommonsIcon').addClass('selected');
+ var formId = Metamaps.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());
+
+ // TODO validate map attributes
+
+ self.newMap.save(null, {
+ success: self.success
+ // TODO add error message
+ });
+
+ if (Metamaps.GlobalUI.lightbox === 'forkmap') {
+ form.html('Working...');
+ }
+ },
+ success: function (model) {
+ var self = Metamaps.GlobalUI.CreateMap;
+
+ var formId = Metamaps.GlobalUI.lightbox === 'forkmap' ? '#fork_map' : '#new_map';
+ var form = $(formId);
+
+ form.html(self.generateSuccessMessage(model.id));
+
+ $('#lightbox_main').css('margin-top', '-' + ($('#lightbox_main').height() / 2) + 'px');
+ },
+ reset: function (id) {
+ var self = Metamaps.GlobalUI.CreateMap;
+
+ var form = $('#' + id);
+
+ 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' });
return false;
},
@@ -300,7 +382,7 @@ Metamaps.GlobalUI.Search = {
break; //console.log(e.which);
}
});
-
+
self.startTypeahead();
},
open: function () {
diff --git a/app/assets/javascripts/metamaps/Metamaps.JIT.js b/app/assets/javascripts/metamaps/Metamaps.JIT.js
index 5534d9e0..08a2b906 100644
--- a/app/assets/javascripts/metamaps/Metamaps.JIT.js
+++ b/app/assets/javascripts/metamaps/Metamaps.JIT.js
@@ -7,7 +7,7 @@ Metamaps.JIT = {
init: function () {
var self = Metamaps.JIT;
-
+ self.prepareVizData();
},
/**
* convert our topic JSON into something JIT can use
diff --git a/app/assets/javascripts/metamaps/metamaps.js b/app/assets/javascripts/metamaps/metamaps.js
index 358c945e..6b7be77e 100644
--- a/app/assets/javascripts/metamaps/metamaps.js
+++ b/app/assets/javascripts/metamaps/metamaps.js
@@ -59,19 +59,11 @@ Metamaps.Mouse = {
DOUBLE_CLICK_TOLERANCE: 300
};
-Metamaps.Active = {
- Map: null,
- Topic: null,
- Mapper: null
-};
-
Metamaps.Selected = {
Nodes: [],
Edges: []
};
-Metamaps.Maps = {}; // will be initialized in Metamaps.Backbone.init as a MapCollection
-Metamaps.Mappers = {}; // will be initialized in Metamaps.Backbone.init as a MapperCollection
Metamaps.Metacodes = {}; // will be initialized in Metamaps.Backbone.init as a MetacodeCollection
Metamaps.Topics = {}; // will be initialized in Metamaps.Backbone.init as a TopicCollection
Metamaps.Synapses = {}; // will be initialized in Metamaps.Backbone.init as a SynapseCollection
@@ -79,270 +71,242 @@ Metamaps.Mappings = {}; // will be initialized in Metamaps.Backbone.init as a Ma
/*
-*
-* BACKBONE
-*
-*/
-Metamaps.Backbone = {
- init: function () {
- var self = Metamaps.Backbone;
+ *
+ * BACKBONE
+ *
+ */
+Metamaps.Backbone.init = function () {
+ var self = Metamaps.Backbone;
- self.Metacode = Backbone.Model.extend({});
- self.MetacodeCollection = Backbone.Collection.extend({
- model: this.Metacode,
- url: '/metacodes'
- });
+ self.Metacode = Backbone.Model.extend({});
+ self.MetacodeCollection = Backbone.Collection.extend({
+ model: this.Metacode,
+ url: '/metacodes'
+ });
- self.Topic = Backbone.Model.extend({
- urlRoot: '/topics',
- blacklist: ['node', 'created_at', 'updated_at'],
- toJSON: function (options) {
- return _.omit(this.attributes, this.blacklist);
- },
- initialize: function () {
- if (this.isNew()) {
- this.set({
- "user_id": Metamaps.Active.Mapper.id,
- "desc": '',
- "link": '',
- "permission": Metamaps.Active.Map ? Metamaps.Active.Map.get('permission') : 'commons'
- });
- }
- },
- authorizeToEdit: function (mapper) {
- if (mapper && (this.get('permission') === "commons" || this.get('user_id') === mapper.get('id'))) return true;
- else return false;
- },
- authorizePermissionChange: function (mapper) {
- if (mapper && this.get('user_id') === mapper.get('id')) return true;
- else return false;
- },
- getDate: function () {
-
- },
- getUser: function () {
- return Metamaps.Mapper.get(this.get('user_id'));
- },
- getMetacode: function () {
- return Metamaps.Metacodes.get(this.get('metacode_id'));
- },
- getMapping: function () {
- return Metamaps.Mappings.findWhere({
- map_id: Metamaps.Active.Map.id,
- topic_id: this.isNew() ? this.cid : this.id
+ self.Topic = Backbone.Model.extend({
+ urlRoot: '/topics',
+ blacklist: ['node', 'created_at', 'updated_at'],
+ toJSON: function (options) {
+ return _.omit(this.attributes, this.blacklist);
+ },
+ initialize: function () {
+ if (this.isNew()) {
+ this.set({
+ "user_id": Metamaps.Active.Mapper.id,
+ "desc": '',
+ "link": '',
+ "permission": Metamaps.Active.Map ? Metamaps.Active.Map.get('permission') : 'commons'
});
- },
- updateMapping: function () {
- var mapping = this.getMapping();
-
- if (mapping) {
- mapping.set('topic_id', this.id);
- }
- },
- createNode: function () {
- var mapping = this.getMapping();
- var node = {
- adjacencies: [],
- data: {
- $mapping: null,
- $mappingID: mapping ? mapping.id : null
- },
- id: this.isNew() ? this.cid : this.id,
- name: this.get('name')
- };
- return node;
- },
- updateNode: function () {
- var mapping = this.getMapping();
- var node = this.get('node');
- node.setData('topic', this);
- node.setData('mapping', mapping);
- node.id = this.isNew() ? this.cid : this.id;
- return node;
- },
- });
-
- self.TopicCollection = Backbone.Collection.extend({
- model: self.Topic,
- url: '/topics',
- comparator: function (a, b) {
- a = a.get('name').toLowerCase();
- b = b.get('name').toLowerCase();
- return a > b ? 1 : a < b ? -1 : 0;
}
- });
+ },
+ authorizeToEdit: function (mapper) {
+ if (mapper && (this.get('permission') === "commons" || this.get('user_id') === mapper.get('id'))) return true;
+ else return false;
+ },
+ authorizePermissionChange: function (mapper) {
+ if (mapper && this.get('user_id') === mapper.get('id')) return true;
+ else return false;
+ },
+ getDate: function () {
- self.Synapse = Backbone.Model.extend({
- urlRoot: '/synapses',
- blacklist: ['edge', 'created_at', 'updated_at'],
- toJSON: function (options) {
- return _.omit(this.attributes, this.blacklist);
- },
- initialize: function () {
- if (this.isNew()) {
- this.set({
- "user_id": Metamaps.Active.Mapper.id,
- "permission": Metamaps.Active.Map.get('permission'),
- "category": "from-to"
- });
- }
- },
- authorizeToEdit: function (mapper) {
- if (mapper && (this.get('permission') === "commons" || this.get('user_id') === mapper.get('id'))) return true;
- else return false;
- },
- authorizePermissionChange: function (mapper) {
- if (mapper && this.get('user_id') === mapper.get('id')) return true;
- else return false;
- },
- getUser: function () {
- return Metamaps.Mapper.get(this.get('user_id'));
- },
- getTopic1: function () {
- return Metamaps.Topic.get(this.get('node1_id'));
- },
- getTopic2: function () {
- return Metamaps.Topic.get(this.get('node2_id'));
- },
- getDirection: function () {
- return [
+ },
+ getUser: function () {
+ return Metamaps.Mapper.get(this.get('user_id'));
+ },
+ getMetacode: function () {
+ return Metamaps.Metacodes.get(this.get('metacode_id'));
+ },
+ getMapping: function () {
+ return Metamaps.Mappings.findWhere({
+ map_id: Metamaps.Active.Map.id,
+ topic_id: this.isNew() ? this.cid : this.id
+ });
+ },
+ updateMapping: function () {
+ var mapping = this.getMapping();
+
+ if (mapping) {
+ mapping.set('topic_id', this.id);
+ }
+ },
+ createNode: function () {
+ var mapping = this.getMapping();
+ var node = {
+ adjacencies: [],
+ data: {
+ $mapping: null,
+ $mappingID: mapping ? mapping.id : null
+ },
+ id: this.isNew() ? this.cid : this.id,
+ name: this.get('name')
+ };
+ return node;
+ },
+ updateNode: function () {
+ var mapping = this.getMapping();
+ var node = this.get('node');
+ node.setData('topic', this);
+ node.setData('mapping', mapping);
+ node.id = this.isNew() ? this.cid : this.id;
+ return node;
+ },
+ });
+
+ self.TopicCollection = Backbone.Collection.extend({
+ model: self.Topic,
+ url: '/topics',
+ comparator: function (a, b) {
+ a = a.get('name').toLowerCase();
+ b = b.get('name').toLowerCase();
+ return a > b ? 1 : a < b ? -1 : 0;
+ }
+ });
+
+ self.Synapse = Backbone.Model.extend({
+ urlRoot: '/synapses',
+ blacklist: ['edge', 'created_at', 'updated_at'],
+ toJSON: function (options) {
+ return _.omit(this.attributes, this.blacklist);
+ },
+ initialize: function () {
+ if (this.isNew()) {
+ this.set({
+ "user_id": Metamaps.Active.Mapper.id,
+ "permission": Metamaps.Active.Map.get('permission'),
+ "category": "from-to"
+ });
+ }
+ },
+ authorizeToEdit: function (mapper) {
+ if (mapper && (this.get('permission') === "commons" || this.get('user_id') === mapper.get('id'))) return true;
+ else return false;
+ },
+ authorizePermissionChange: function (mapper) {
+ if (mapper && this.get('user_id') === mapper.get('id')) return true;
+ else return false;
+ },
+ getUser: function () {
+ return Metamaps.Mapper.get(this.get('user_id'));
+ },
+ getTopic1: function () {
+ return Metamaps.Topic.get(this.get('node1_id'));
+ },
+ getTopic2: function () {
+ return Metamaps.Topic.get(this.get('node2_id'));
+ },
+ getDirection: function () {
+ return [
this.get('node1_id'),
this.get('node2_id')
];
- },
- getMapping: function () {
- return Metamaps.Mappings.findWhere({
- map_id: Metamaps.Active.Map.id,
- synapse_id: this.isNew() ? this.cid : this.id
+ },
+ getMapping: function () {
+ return Metamaps.Mappings.findWhere({
+ map_id: Metamaps.Active.Map.id,
+ synapse_id: this.isNew() ? this.cid : this.id
+ });
+ },
+ updateMapping: function () {
+ var mapping = this.getMapping();
+
+ if (mapping) {
+ mapping.set('synapse_id', this.id);
+ }
+ },
+ createEdge: function () {
+ var mapping = this.getMapping();
+ var mappingID = mapping.isNew() ? mapping.cid : mapping.id;
+ var synapseID = this.isNew() ? this.cid : this.id;
+
+ var edge = {
+ nodeFrom: this.get('node1_id'),
+ nodeTo: this.get('node2_id'),
+ data: {
+ $mappings: [],
+ $mappingIDs: [mappingID],
+ $synapses: [],
+ $synapseIDs: [synapseID],
+ }
+ };
+ return edge;
+ },
+ updateEdge: function () {
+ var mapping = this.getMapping();
+ var edge = this.get('edge');
+ edge.getData('mappings').push(mapping);
+ edge.getData('synapses').push(this);
+ return edge;
+ },
+ });
+
+ self.SynapseCollection = Backbone.Collection.extend({
+ model: self.Synapse,
+ url: '/synapses'
+ });
+
+ self.Mapping = Backbone.Model.extend({
+ urlRoot: '/mappings',
+ blacklist: ['created_at', 'updated_at'],
+ toJSON: function (options) {
+ return _.omit(this.attributes, this.blacklist);
+ },
+ initialize: function () {
+ if (this.isNew()) {
+ this.set({
+ "user_id": Metamaps.Active.Mapper.id,
+ "map_id": Metamaps.Active.Map ? Metamaps.Active.Map.id : null
});
- },
- updateMapping: function () {
- var mapping = this.getMapping();
-
- if (mapping) {
- mapping.set('synapse_id', this.id);
- }
- },
- createEdge: function () {
- var mapping = this.getMapping();
- var mappingID = mapping.isNew() ? mapping.cid : mapping.id;
- var synapseID = this.isNew() ? this.cid : this.id;
-
- var edge = {
- nodeFrom: this.get('node1_id'),
- nodeTo: this.get('node2_id'),
- data: {
- $mappings: [],
- $mappingIDs: [mappingID],
- $synapses: [],
- $synapseIDs: [synapseID],
- }
- };
- return edge;
- },
- updateEdge: function () {
- var mapping = this.getMapping();
- var edge = this.get('edge');
- edge.getData('mappings').push(mapping);
- edge.getData('synapses').push(this);
- return edge;
- },
- });
-
- self.SynapseCollection = Backbone.Collection.extend({
- model: self.Synapse,
- url: '/synapses'
- });
-
- self.Mapping = Backbone.Model.extend({
- urlRoot: '/mappings',
- blacklist: ['created_at', 'updated_at'],
- toJSON: function (options) {
- return _.omit(this.attributes, this.blacklist);
- },
- initialize: function () {
- if (this.isNew()) {
- this.set({
- "user_id": Metamaps.Active.Mapper.id,
- "map_id": Metamaps.Active.Map ? Metamaps.Active.Map.id : null
- });
- }
- },
- getUser: function () {
- return Metamaps.Mapper.get(this.get('user_id'));
- },
- getMap: function () {
- return Metamaps.Map.get(this.get('map_id'));
- },
- getTopic: function () {
- if (this.get('category') === 'Topic') return Metamaps.Topic.get(this.get('topic_id'));
- else return false;
- },
- getSynapse: function () {
- if (this.get('category') === 'Synapse') return Metamaps.Synapse.get(this.get('synapse_id'));
- else return false;
}
- });
+ },
+ getUser: function () {
+ return Metamaps.Mapper.get(this.get('user_id'));
+ },
+ getMap: function () {
+ return Metamaps.Map.get(this.get('map_id'));
+ },
+ getTopic: function () {
+ if (this.get('category') === 'Topic') return Metamaps.Topic.get(this.get('topic_id'));
+ else return false;
+ },
+ getSynapse: function () {
+ if (this.get('category') === 'Synapse') return Metamaps.Synapse.get(this.get('synapse_id'));
+ else return false;
+ }
+ });
- self.MappingCollection = Backbone.Collection.extend({
- model: self.Mapping,
- url: '/mappings'
- });
+ self.MappingCollection = Backbone.Collection.extend({
+ model: self.Mapping,
+ url: '/mappings'
+ });
- self.Map = Backbone.Model.extend({
- urlRoot: '/maps',
- blacklist: ['created_at', 'updated_at'],
- toJSON: function (options) {
- return _.omit(this.attributes, this.blacklist);
- },
- authorizeToEdit: function (mapper) {
- if (mapper && (this.get('permission') === "commons" || this.get('user_id') === mapper.get('id'))) return true;
- else return false;
- }
- });
- self.MapsCollection = Backbone.Collection.extend({
- model: self.Map,
- url: '/maps'
- });
+ Metamaps.Metacodes = new self.MetacodeCollection(Metamaps.Metacodes);
- self.Mapper = Backbone.Model.extend({
- urlRoot: '/users',
- blacklist: ['created_at', 'updated_at'],
- toJSON: function (options) {
- return _.omit(this.attributes, this.blacklist);
- },
- });
- self.MapperCollection = Backbone.Collection.extend({
- model: self.Mapper,
- url: '/users'
- });
+ Metamaps.Topics = new self.TopicCollection(Metamaps.Topics);
- Metamaps.Metacodes = new self.MetacodeCollection(Metamaps.Metacodes);
+ Metamaps.Synapses = new self.SynapseCollection(Metamaps.Synapses);
- Metamaps.Active.Mapper = new self.Mapper({
- id: userid,
- name: username
- });
- Metamaps.Mappers = new self.MapperCollection([Metamaps.Active.Mapper]);
+ Metamaps.Mappings = new self.MappingCollection(Metamaps.Mappings);
- Metamaps.Topics = new self.TopicCollection(Metamaps.Topics);
-
- Metamaps.Synapses = new self.SynapseCollection(Metamaps.Synapses);
-
- Metamaps.Mappings = new self.MappingCollection(Metamaps.Mappings);
-
- Metamaps.Active.Map = new self.Map(Metamaps.Active.Map);
- Metamaps.Maps = new self.MapsCollection([Metamaps.Active.Map]);
- }
-}; // end Metamaps.Backbone
+ Metamaps.Active.Map = new self.Map(Metamaps.Active.Map);
+ Metamaps.Maps.add(Metamaps.Active.Map);
+}; // end Metamaps.Backbone.init
/*
-*
-* CREATE
-*
-*/
+ *
+ * CREATE
+ *
+ */
Metamaps.Create = {
+ isSwitchingSet: false, // indicates whether the metacode set switch lightbox is open
+ metacodeScrollerInit: false, // indicates whether the scrollbar in the custom metacode set space has been init
+ selectedMetacodeSet: null,
+ selectedMetacodeSetIndex: null,
+ selectedMetacodeNames: [],
+ newSelectedMetacodeNames: [],
+ selectedMetacodes: [],
+ newSelectedMetacodes: [],
init: function () {
var self = Metamaps.Create;
self.newTopic.init();
@@ -356,28 +320,23 @@ Metamaps.Create = {
selected: self.selectedMetacodeSetIndex
}).addClass("ui-tabs-vertical ui-helper-clearfix");
$("#metacodeSwitchTabs .ui-tabs-nav li").removeClass("ui-corner-top").addClass("ui-corner-left");
- $('.customMetacodeList li').click(function () {
- if ($(this).attr('class') != 'toggledOff') {
- $(this).addClass('toggledOff');
- var value_to_remove = $(this).attr('id');
- var name_to_remove = $(this).attr('data-name');
- self.newSelectedMetacodes.splice(self.newSelectedMetacodes.indexOf(value_to_remove), 1);
- self.newSelectedMetacodeNames.splice(self.newSelectedMetacodeNames.indexOf(name_to_remove), 1);
- } else if ($(this).attr('class') == 'toggledOff') {
- $(this).removeClass('toggledOff');
- self.newSelectedMetacodes.push($(this).attr('id'));
- self.newSelectedMetacodeNames.push($(this).attr('data-name'));
- }
- });
+ $('.customMetacodeList li').click(self.toggleMetacodeSelected); // within the custom metacode set tab
+ },
+ toggleMetacodeSelected: function () {
+ var self = Metamaps.Create;
+
+ if ($(this).attr('class') != 'toggledOff') {
+ $(this).addClass('toggledOff');
+ var value_to_remove = $(this).attr('id');
+ var name_to_remove = $(this).attr('data-name');
+ self.newSelectedMetacodes.splice(self.newSelectedMetacodes.indexOf(value_to_remove), 1);
+ self.newSelectedMetacodeNames.splice(self.newSelectedMetacodeNames.indexOf(name_to_remove), 1);
+ } else if ($(this).attr('class') == 'toggledOff') {
+ $(this).removeClass('toggledOff');
+ self.newSelectedMetacodes.push($(this).attr('id'));
+ self.newSelectedMetacodeNames.push($(this).attr('data-name'));
+ }
},
- isSwitchingSet: false, // indicates whether the metacode set switch lightbox is open
- metacodeScrollerInit: false, // indicates whether the scrollbar in the custom metacode set space has been init
- selectedMetacodeSet: null,
- selectedMetacodeSetIndex: null,
- selectedMetacodeNames: [],
- newSelectedMetacodeNames: [],
- selectedMetacodes: [],
- newSelectedMetacodes: [],
updateMetacodeSet: function (set, index, custom) {
if (custom && Metamaps.Create.newSelectedMetacodes.length == 0) {
@@ -606,10 +565,10 @@ Metamaps.Create = {
/*
-*
-* TOPICCARD
-*
-*/
+ *
+ * TOPICCARD
+ *
+ */
Metamaps.TopicCard = {
openTopicCard: null, //stores the JIT local ID of the topic with the topic card open
init: function () {
@@ -864,10 +823,10 @@ Metamaps.TopicCard = {
/*
-*
-* SYNAPSECARD
-*
-*/
+ *
+ * SYNAPSECARD
+ *
+ */
Metamaps.SynapseCard = {
openSynapseCard: null,
showCard: function (edge, e) {
@@ -1080,10 +1039,10 @@ Metamaps.SynapseCard = {
/*
-*
-* VISUALIZE
-*
-*/
+ *
+ * VISUALIZE
+ *
+ */
Metamaps.Visualize = {
mGraph: {}, // a reference to the graph object.
cameraPosition: null, // stores the camera position when using a 3D visualization
@@ -1219,10 +1178,10 @@ Metamaps.Visualize = {
/*
-*
-* UTIL
-*
-*/
+ *
+ * UTIL
+ *
+ */
Metamaps.Util = {
// helper function to determine how many lines are needed
// Line Splitter Function
@@ -1271,10 +1230,10 @@ Metamaps.Util = {
/*
-*
-* REALTIME
-*
-*/
+ *
+ * REALTIME
+ *
+ */
Metamaps.Realtime = {
// this is for the heroku staging environment
//Metamaps.Realtime.socket = io.connect('http://gentle-savannah-1303.herokuapp.com');
@@ -1524,7 +1483,7 @@ Metamaps.Realtime = {
}
},
addTopicToMap: function (topic) {
-
+
// TODO
var newPos, tempForT;
Metamaps.Visualize.mGraph.graph.addNode(topic);
@@ -1540,7 +1499,7 @@ Metamaps.Realtime = {
Metamaps.Visualize.mGraph.fx.plotNode(tempForT, Metamaps.Visualize.mGraph.canvas);
},
updateTopicOnMap: function (topic) {
-
+
// TODO
var newPos, tempForT;
tempForT = Metamaps.Visualize.mGraph.graph.getNode(topic.id);
@@ -1562,7 +1521,7 @@ Metamaps.Realtime = {
});
},
addSynapseToMap: function (synapse) {
-
+
// TODO
var Node1, Node2, tempForS;
Node1 = Metamaps.Visualize.mGraph.graph.getNode(synapse.data.$direction[0]);
@@ -1584,7 +1543,7 @@ Metamaps.Realtime = {
});
},
updateSynapseOnMap: function (synapse) {
-
+
// TODO
var k, tempForS, v, wasShowDesc, _ref;
tempForS = Metamaps.Visualize.mGraph.graph.getAdjacence(synapse.data.$direction[0], synapse.data.$direction[1]);
@@ -1600,14 +1559,14 @@ Metamaps.Realtime = {
}
return Metamaps.Visualize.mGraph.plot();
}
-}; // end Metamaps.Realtime
+}; // end Metamaps.Realtime
/*
-*
-* CONTROL
-*
-*/
+ *
+ * CONTROL
+ *
+ */
Metamaps.Control = {
init: function () {
@@ -1874,10 +1833,10 @@ Metamaps.Control = {
/*
-*
-* FILTER
-*
-*/
+ *
+ * FILTER
+ *
+ */
Metamaps.Filter = {
filters: {
name: "",
@@ -2008,10 +1967,10 @@ Metamaps.Filter = {
/*
-*
-* LISTENERS
-*
-*/
+ *
+ * LISTENERS
+ *
+ */
Metamaps.Listeners = {
init: function () {
@@ -2038,10 +1997,10 @@ Metamaps.Listeners = {
/*
-*
-* ORGANIZE
-*
-*/
+ *
+ * ORGANIZE
+ *
+ */
Metamaps.Organize = {
init: function () {
@@ -2167,10 +2126,10 @@ Metamaps.Organize = {
/*
-*
-* TOPIC
-*
-*/
+ *
+ * TOPIC
+ *
+ */
Metamaps.Topic = {
// this function is to retrieve a topic JSON object from the database
// @param id = the id of the topic to retrieve
@@ -2347,10 +2306,10 @@ Metamaps.Topic = {
/*
-*
-* SYNAPSE
-*
-*/
+ *
+ * SYNAPSE
+ *
+ */
Metamaps.Synapse = {
// this function is to retrieve a synapse JSON object from the database
// @param id = the id of the synapse to retrieve
@@ -2486,10 +2445,10 @@ Metamaps.Synapse = {
/*
-*
-* MAP
-*
-*/
+ *
+ * MAP
+ *
+ */
Metamaps.Map = {
init: function () {
var self = Metamaps.Map;
@@ -2503,6 +2462,8 @@ Metamaps.Map = {
self.fork();
});
+ Metamaps.GlobalUI.CreateMap.emptyForkMapForm = $('#fork_map').html();
+
self.InfoBox.init();
self.CheatSheet.init();
},
@@ -2570,17 +2531,17 @@ Metamaps.Map = {
synapses_data = synapses_array.join();
nodes_data = nodes_data.slice(0, -1);
- $('#map_topicsToMap').val(nodes_data);
- $('#map_synapsesToMap').val(synapses_data);
+ Metamaps.GlobalUI.CreateMap.topicsToMap = nodes_data;
+ Metamaps.GlobalUI.CreateMap.synapsesToMap = synapses_data;
}
};
/*
-*
-* CHEATSHEET
-*
-*/
+ *
+ * CHEATSHEET
+ *
+ */
Metamaps.Map.CheatSheet = {
init: function () {
// tab the cheatsheet
@@ -2591,10 +2552,10 @@ Metamaps.Map.CheatSheet = {
/*
-*
-* INFOBOX
-*
-*/
+ *
+ * INFOBOX
+ *
+ */
Metamaps.Map.InfoBox = {
isOpen: false,
timeOut: null,
@@ -2675,10 +2636,10 @@ Metamaps.Map.InfoBox = {
/*
-*
-* MAPPER
-*
-*/
+ *
+ * MAPPER
+ *
+ */
Metamaps.Mapper = {
// this function is to retrieve a mapper JSON object from the database
// @param id = the id of the mapper to retrieve
@@ -2709,4 +2670,4 @@ Metamaps.Mapper = {
}
}
},
-}; // end Metamaps.Mapper
\ No newline at end of file
+}; // end Metamaps.Mapper
\ No newline at end of file
diff --git a/app/assets/javascripts/backbone.js b/app/assets/javascripts/orderedLibraries/backbone.js
similarity index 100%
rename from app/assets/javascripts/backbone.js
rename to app/assets/javascripts/orderedLibraries/backbone.js
diff --git a/app/assets/javascripts/underscore.js b/app/assets/javascripts/orderedLibraries/underscore.js
similarity index 100%
rename from app/assets/javascripts/underscore.js
rename to app/assets/javascripts/orderedLibraries/underscore.js
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
index c7e84755..73671bf0 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.css
@@ -2011,7 +2011,7 @@ div.mapInfoStat {
margin: 10px 0 0 131px;
width: 254px;
}
-.onConsole .new_map button {
+.onConsole .new_map button.cancel {
margin-right: 20px;
}
.onConsole .new_map button,
diff --git a/app/controllers/maps_controller.rb b/app/controllers/maps_controller.rb
index cdc403f8..37d9fdc3 100644
--- a/app/controllers/maps_controller.rb
+++ b/app/controllers/maps_controller.rb
@@ -98,18 +98,15 @@ class MapsController < ApplicationController
@user = current_user
@map = Map.new()
- @map.name = params[:map][:name]
- @map.desc = params[:map][:desc]
- @map.permission = params[:map][:permission]
+ @map.name = params[:name]
+ @map.desc = params[:desc]
+ @map.permission = params[:permission]
@map.user = @user
- @map.arranged = false
- @map.save
-
- #this variable specifies to the js file whether it's a brand new map or a forked one
- @forked = false
+ @map.arranged = false
+ @map.save
- if params[:map][:topicsToMap]
- @all = params[:map][:topicsToMap]
+ if params[:topicsToMap]
+ @all = params[:topicsToMap]
@all = @all.split(',')
@all.each do |topic|
topic = topic.split('/')
@@ -123,8 +120,8 @@ class MapsController < ApplicationController
@mapping.save
end
- if params[:map][:synapsesToMap]
- @synAll = params[:map][:synapsesToMap]
+ if params[:synapsesToMap]
+ @synAll = params[:synapsesToMap]
@synAll = @synAll.split(',')
@synAll.each do |synapse_id|
@mapping = Mapping.new()
@@ -137,13 +134,11 @@ class MapsController < ApplicationController
end
@map.arranged = true
- @map.save
-
- @forked = true
+ @map.save
end
respond_to do |format|
- format.js { respond_with(@map, @forked) }
+ format.json { render :json => @map }
end
end
@@ -153,15 +148,15 @@ class MapsController < ApplicationController
@map = Map.find(params[:id]).authorize_to_edit(@current)
if @map
- if params[:map]
- @map.name = params[:map][:name] if params[:map][:name]
- @map.desc = params[:map][:desc] if params[:map][:desc]
- @map.permission = params[:map][:permission] if params[:map][:permission]
- end
+ @map.name = params[:name] if params[:name]
+ @map.desc = params[:desc] if params[:desc]
+ @map.permission = params[:permission] if params[:permission]
@map.save
- end
+ end
- respond_with @map
+ respond_to do |format|
+ format.json { render :json => @map }
+ end
end
# DELETE maps/:id
diff --git a/app/views/maps/_fork.html.erb b/app/views/maps/_fork.html.erb
index 15cd12c8..3b3b4d7f 100644
--- a/app/views/maps/_fork.html.erb
+++ b/app/views/maps/_fork.html.erb
@@ -51,19 +51,15 @@