changed approach to map creation. reorganized code to suit that.
This commit is contained in:
parent
ae8c711d27
commit
f817ce772c
33 changed files with 558 additions and 572 deletions
|
@ -10,18 +10,11 @@
|
||||||
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
||||||
// GO AFTER THE REQUIRES BELOW.
|
// GO AFTER THE REQUIRES BELOW.
|
||||||
//
|
//
|
||||||
// require autocomplete-rails-uncompressed
|
|
||||||
//
|
|
||||||
//= require jquery
|
//= require jquery
|
||||||
//= require jquery-ui
|
//= require jquery-ui
|
||||||
//= require jquery.purr
|
|
||||||
//= require jquery.lettering
|
|
||||||
//= require jquery.textillate
|
|
||||||
//= require jquery.roundabout.min
|
|
||||||
//= require bip
|
|
||||||
//= require jquery_ujs
|
//= require jquery_ujs
|
||||||
//= require typeahead
|
//= require ./orderedLibraries/underscore
|
||||||
//= require hogan-2.0.0
|
//= require ./orderedLibraries/backbone
|
||||||
//= require_directory ./scroll
|
//= require_directory ./librariesForAllPages
|
||||||
//= require_directory ./typing
|
|
||||||
//= require ./metamaps/Metamaps.GlobalUI
|
//= require ./metamaps/Metamaps.GlobalUI
|
||||||
|
//= require ./metamaps/Metamaps.Backbone
|
|
@ -10,10 +10,11 @@
|
||||||
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
||||||
// GO AFTER THE REQUIRES BELOW.
|
// GO AFTER THE REQUIRES BELOW.
|
||||||
//
|
//
|
||||||
//= require socket.io
|
//
|
||||||
//= require underscore
|
// can't use require directory because underscore needs to come before backbone
|
||||||
//= require backbone
|
//
|
||||||
//= require_directory ./carousel
|
//= require ./librariesForMapPages/cloudcarousel
|
||||||
|
//= require ./librariesForMapPages/socket.io
|
||||||
//= require ./metamaps/JIT
|
//= require ./metamaps/JIT
|
||||||
//= require ./metamaps/Metamaps
|
//= require ./metamaps/Metamaps
|
||||||
//= require ./metamaps/Metamaps.JIT
|
//= require ./metamaps/Metamaps.JIT
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
34
app/assets/javascripts/metamaps/Metamaps.Backbone.js
Normal file
34
app/assets/javascripts/metamaps/Metamaps.Backbone.js
Normal file
|
@ -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();
|
|
@ -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
|
* 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
|
GlobalUI
|
||||||
|
Active
|
||||||
|
Maps
|
||||||
|
Mappers
|
||||||
|
Backbone
|
||||||
|
|
||||||
* all these get added when you are on a page with the Javascript Infovis Toolkit
|
* all these get added when you are on a page with the Javascript Infovis Toolkit
|
||||||
Settings
|
Settings
|
||||||
Touch
|
Touch
|
||||||
Mouse
|
Mouse
|
||||||
Active
|
|
||||||
Selected
|
Selected
|
||||||
Maps
|
|
||||||
Mappers
|
|
||||||
Metacodes
|
Metacodes
|
||||||
Topics
|
Topics
|
||||||
Synapses
|
Synapses
|
||||||
Mappings
|
Mappings
|
||||||
Backbone
|
|
||||||
Create
|
Create
|
||||||
TopicCard
|
TopicCard
|
||||||
SynapseCard
|
SynapseCard
|
||||||
|
@ -28,13 +28,20 @@ Control
|
||||||
Filter
|
Filter
|
||||||
Listeners
|
Listeners
|
||||||
Organize
|
Organize
|
||||||
Topic
|
|
||||||
Synapse
|
|
||||||
Map
|
Map
|
||||||
Mapper
|
Mapper
|
||||||
|
Topic
|
||||||
|
Synapse
|
||||||
JIT
|
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 () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
|
@ -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 = {
|
Metamaps.GlobalUI = {
|
||||||
notifyTimeout: null,
|
notifyTimeout: null,
|
||||||
|
lightbox: null,
|
||||||
init: function () {
|
init: function () {
|
||||||
var self = Metamaps.GlobalUI;
|
var self = Metamaps.GlobalUI;
|
||||||
|
|
||||||
|
@ -76,9 +81,13 @@ Metamaps.GlobalUI = {
|
||||||
$('.alert.metamaps').delay(10000).fadeOut('fast');
|
$('.alert.metamaps').delay(10000).fadeOut('fast');
|
||||||
},
|
},
|
||||||
openLightbox: function (which) {
|
openLightbox: function (which) {
|
||||||
|
var self = Metamaps.GlobalUI;
|
||||||
|
|
||||||
$('.lightboxContent').hide();
|
$('.lightboxContent').hide();
|
||||||
$('#' + which).show();
|
$('#' + which).show();
|
||||||
|
|
||||||
|
self.lightbox = which;
|
||||||
|
|
||||||
$('#lightbox_overlay').show();
|
$('#lightbox_overlay').show();
|
||||||
$('#lightbox_main').css('margin-top', '-' + ($('#lightbox_main').height() / 2) + 'px');
|
$('#lightbox_main').css('margin-top', '-' + ($('#lightbox_main').height() / 2) + 'px');
|
||||||
|
|
||||||
|
@ -97,12 +106,16 @@ Metamaps.GlobalUI = {
|
||||||
},
|
},
|
||||||
|
|
||||||
closeLightbox: function () {
|
closeLightbox: function () {
|
||||||
|
var self = Metamaps.GlobalUI;
|
||||||
|
|
||||||
$('#lightbox_overlay').hide();
|
$('#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) {
|
if (Metamaps.Create && Metamaps.Create.isSwitchingSet) {
|
||||||
Metamaps.Create.cancelMetacodeSetSwitch();
|
Metamaps.Create.cancelMetacodeSetSwitch();
|
||||||
}
|
}
|
||||||
|
self.lightbox = null;
|
||||||
},
|
},
|
||||||
notifyUser: function (message) {
|
notifyUser: function (message) {
|
||||||
var self = Metamaps.GlobalUI;
|
var self = Metamaps.GlobalUI;
|
||||||
|
@ -186,33 +199,102 @@ Metamaps.GlobalUI.MainMenu = {
|
||||||
|
|
||||||
|
|
||||||
Metamaps.GlobalUI.CreateMap = {
|
Metamaps.GlobalUI.CreateMap = {
|
||||||
|
newMap: null,
|
||||||
|
emptyMapForm: "",
|
||||||
|
emptyForkMapForm: "",
|
||||||
|
topicsToMap: [],
|
||||||
|
synapsesToMap: [],
|
||||||
init: function () {
|
init: function () {
|
||||||
|
var self = Metamaps.GlobalUI.CreateMap;
|
||||||
|
|
||||||
// bind permission changer events on the createMap form
|
self.newMap = new Metamaps.Backbone.Map({ permission: 'commons' });
|
||||||
$('.permIcon').click(function () {
|
|
||||||
$(this).siblings('#map_permission').val($(this).attr('data-permission'));
|
self.bindFormEvents();
|
||||||
$(this).siblings('.permIcon').find('.mapPermIcon').removeClass('selected');
|
|
||||||
$(this).find('.mapPermIcon').addClass('selected');
|
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').unbind().bind('click', self.switchPermission);
|
||||||
|
},
|
||||||
|
generateSuccessMessage: function (id) {
|
||||||
|
var stringStart = "Success! Do you want to <br> <a href='/maps/";
|
||||||
|
stringStart += id;
|
||||||
|
stringStart += "'>Go to your new map?</a>";
|
||||||
|
stringStart += "<br>or<br><a href='#' onclick='Metamaps.GlobalUI.closeLightbox(); return false;'>Stay on this ";
|
||||||
|
var page = Metamaps.Active.Map ? 'map' : 'page';
|
||||||
|
var stringEnd = "?</a>";
|
||||||
|
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;
|
||||||
|
|
||||||
|
if (Metamaps.GlobalUI.lightbox === 'forkmap') {
|
||||||
|
self.newMap.set('topicsToMap', self.topicsToMap);
|
||||||
|
self.newMap.set('synapsesToMap', self.synapsesToMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
reset: function (id) {
|
||||||
|
var self = Metamaps.GlobalUI.CreateMap;
|
||||||
|
|
||||||
var form = $('#' + id);
|
var form = $('#' + id);
|
||||||
|
|
||||||
form.find('#map_name').val('');
|
if (id === "fork_map") {
|
||||||
form.find('#map_desc').val('');
|
self.topicsToMap = [];
|
||||||
form.find('#map_permission').val('commons');
|
self.synapsesToMap = [];
|
||||||
|
form.html(self.emptyForkMapForm);
|
||||||
if (id == "fork_map") {
|
}
|
||||||
form.find('#map_topicsToMap').val('0');
|
else {
|
||||||
form.find('#map_synapsesToMap').val('0');
|
form.html(self.emptyMapForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove a selected state from all three of them
|
self.bindFormEvents();
|
||||||
form.find('.mapPermIcon').removeClass('selected');
|
self.newMap = new Metamaps.Backbone.Map({ permission: 'commons' });
|
||||||
// add a selected state back to commons permission, the default
|
|
||||||
form.find('.mapCommonsIcon').addClass('selected');
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,7 +7,7 @@ Metamaps.JIT = {
|
||||||
init: function () {
|
init: function () {
|
||||||
var self = Metamaps.JIT;
|
var self = Metamaps.JIT;
|
||||||
|
|
||||||
|
self.prepareVizData();
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* convert our topic JSON into something JIT can use
|
* convert our topic JSON into something JIT can use
|
||||||
|
|
|
@ -59,19 +59,11 @@ Metamaps.Mouse = {
|
||||||
DOUBLE_CLICK_TOLERANCE: 300
|
DOUBLE_CLICK_TOLERANCE: 300
|
||||||
};
|
};
|
||||||
|
|
||||||
Metamaps.Active = {
|
|
||||||
Map: null,
|
|
||||||
Topic: null,
|
|
||||||
Mapper: null
|
|
||||||
};
|
|
||||||
|
|
||||||
Metamaps.Selected = {
|
Metamaps.Selected = {
|
||||||
Nodes: [],
|
Nodes: [],
|
||||||
Edges: []
|
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.Metacodes = {}; // will be initialized in Metamaps.Backbone.init as a MetacodeCollection
|
||||||
Metamaps.Topics = {}; // will be initialized in Metamaps.Backbone.init as a TopicCollection
|
Metamaps.Topics = {}; // will be initialized in Metamaps.Backbone.init as a TopicCollection
|
||||||
Metamaps.Synapses = {}; // will be initialized in Metamaps.Backbone.init as a SynapseCollection
|
Metamaps.Synapses = {}; // will be initialized in Metamaps.Backbone.init as a SynapseCollection
|
||||||
|
@ -83,8 +75,7 @@ Metamaps.Mappings = {}; // will be initialized in Metamaps.Backbone.init as a Ma
|
||||||
* BACKBONE
|
* BACKBONE
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Metamaps.Backbone = {
|
Metamaps.Backbone.init = function () {
|
||||||
init: function () {
|
|
||||||
var self = Metamaps.Backbone;
|
var self = Metamaps.Backbone;
|
||||||
|
|
||||||
self.Metacode = Backbone.Model.extend({});
|
self.Metacode = Backbone.Model.extend({});
|
||||||
|
@ -289,42 +280,8 @@ Metamaps.Backbone = {
|
||||||
url: '/mappings'
|
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'
|
|
||||||
});
|
|
||||||
|
|
||||||
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.Metacodes = new self.MetacodeCollection(Metamaps.Metacodes);
|
Metamaps.Metacodes = new self.MetacodeCollection(Metamaps.Metacodes);
|
||||||
|
|
||||||
Metamaps.Active.Mapper = new self.Mapper({
|
|
||||||
id: userid,
|
|
||||||
name: username
|
|
||||||
});
|
|
||||||
Metamaps.Mappers = new self.MapperCollection([Metamaps.Active.Mapper]);
|
|
||||||
|
|
||||||
Metamaps.Topics = new self.TopicCollection(Metamaps.Topics);
|
Metamaps.Topics = new self.TopicCollection(Metamaps.Topics);
|
||||||
|
|
||||||
Metamaps.Synapses = new self.SynapseCollection(Metamaps.Synapses);
|
Metamaps.Synapses = new self.SynapseCollection(Metamaps.Synapses);
|
||||||
|
@ -332,9 +289,8 @@ Metamaps.Backbone = {
|
||||||
Metamaps.Mappings = new self.MappingCollection(Metamaps.Mappings);
|
Metamaps.Mappings = new self.MappingCollection(Metamaps.Mappings);
|
||||||
|
|
||||||
Metamaps.Active.Map = new self.Map(Metamaps.Active.Map);
|
Metamaps.Active.Map = new self.Map(Metamaps.Active.Map);
|
||||||
Metamaps.Maps = new self.MapsCollection([Metamaps.Active.Map]);
|
Metamaps.Maps.add(Metamaps.Active.Map);
|
||||||
}
|
}; // end Metamaps.Backbone.init
|
||||||
}; // end Metamaps.Backbone
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -343,6 +299,14 @@ Metamaps.Backbone = {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Metamaps.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 () {
|
init: function () {
|
||||||
var self = Metamaps.Create;
|
var self = Metamaps.Create;
|
||||||
self.newTopic.init();
|
self.newTopic.init();
|
||||||
|
@ -356,7 +320,11 @@ Metamaps.Create = {
|
||||||
selected: self.selectedMetacodeSetIndex
|
selected: self.selectedMetacodeSetIndex
|
||||||
}).addClass("ui-tabs-vertical ui-helper-clearfix");
|
}).addClass("ui-tabs-vertical ui-helper-clearfix");
|
||||||
$("#metacodeSwitchTabs .ui-tabs-nav li").removeClass("ui-corner-top").addClass("ui-corner-left");
|
$("#metacodeSwitchTabs .ui-tabs-nav li").removeClass("ui-corner-top").addClass("ui-corner-left");
|
||||||
$('.customMetacodeList li').click(function () {
|
$('.customMetacodeList li').click(self.toggleMetacodeSelected); // within the custom metacode set tab
|
||||||
|
},
|
||||||
|
toggleMetacodeSelected: function () {
|
||||||
|
var self = Metamaps.Create;
|
||||||
|
|
||||||
if ($(this).attr('class') != 'toggledOff') {
|
if ($(this).attr('class') != 'toggledOff') {
|
||||||
$(this).addClass('toggledOff');
|
$(this).addClass('toggledOff');
|
||||||
var value_to_remove = $(this).attr('id');
|
var value_to_remove = $(this).attr('id');
|
||||||
|
@ -368,16 +336,7 @@ Metamaps.Create = {
|
||||||
self.newSelectedMetacodes.push($(this).attr('id'));
|
self.newSelectedMetacodes.push($(this).attr('id'));
|
||||||
self.newSelectedMetacodeNames.push($(this).attr('data-name'));
|
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) {
|
updateMetacodeSet: function (set, index, custom) {
|
||||||
|
|
||||||
if (custom && Metamaps.Create.newSelectedMetacodes.length == 0) {
|
if (custom && Metamaps.Create.newSelectedMetacodes.length == 0) {
|
||||||
|
@ -2503,6 +2462,8 @@ Metamaps.Map = {
|
||||||
self.fork();
|
self.fork();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Metamaps.GlobalUI.CreateMap.emptyForkMapForm = $('#fork_map').html();
|
||||||
|
|
||||||
self.InfoBox.init();
|
self.InfoBox.init();
|
||||||
self.CheatSheet.init();
|
self.CheatSheet.init();
|
||||||
},
|
},
|
||||||
|
@ -2570,8 +2531,8 @@ Metamaps.Map = {
|
||||||
synapses_data = synapses_array.join();
|
synapses_data = synapses_array.join();
|
||||||
nodes_data = nodes_data.slice(0, -1);
|
nodes_data = nodes_data.slice(0, -1);
|
||||||
|
|
||||||
$('#map_topicsToMap').val(nodes_data);
|
Metamaps.GlobalUI.CreateMap.topicsToMap = nodes_data;
|
||||||
$('#map_synapsesToMap').val(synapses_data);
|
Metamaps.GlobalUI.CreateMap.synapsesToMap = synapses_data;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2011,7 +2011,7 @@ div.mapInfoStat {
|
||||||
margin: 10px 0 0 131px;
|
margin: 10px 0 0 131px;
|
||||||
width: 254px;
|
width: 254px;
|
||||||
}
|
}
|
||||||
.onConsole .new_map button {
|
.onConsole .new_map button.cancel {
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
}
|
}
|
||||||
.onConsole .new_map button,
|
.onConsole .new_map button,
|
||||||
|
|
|
@ -98,18 +98,15 @@ class MapsController < ApplicationController
|
||||||
|
|
||||||
@user = current_user
|
@user = current_user
|
||||||
@map = Map.new()
|
@map = Map.new()
|
||||||
@map.name = params[:map][:name]
|
@map.name = params[:name]
|
||||||
@map.desc = params[:map][:desc]
|
@map.desc = params[:desc]
|
||||||
@map.permission = params[:map][:permission]
|
@map.permission = params[:permission]
|
||||||
@map.user = @user
|
@map.user = @user
|
||||||
@map.arranged = false
|
@map.arranged = false
|
||||||
@map.save
|
@map.save
|
||||||
|
|
||||||
#this variable specifies to the js file whether it's a brand new map or a forked one
|
if params[:topicsToMap]
|
||||||
@forked = false
|
@all = params[:topicsToMap]
|
||||||
|
|
||||||
if params[:map][:topicsToMap]
|
|
||||||
@all = params[:map][:topicsToMap]
|
|
||||||
@all = @all.split(',')
|
@all = @all.split(',')
|
||||||
@all.each do |topic|
|
@all.each do |topic|
|
||||||
topic = topic.split('/')
|
topic = topic.split('/')
|
||||||
|
@ -123,8 +120,8 @@ class MapsController < ApplicationController
|
||||||
@mapping.save
|
@mapping.save
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:map][:synapsesToMap]
|
if params[:synapsesToMap]
|
||||||
@synAll = params[:map][:synapsesToMap]
|
@synAll = params[:synapsesToMap]
|
||||||
@synAll = @synAll.split(',')
|
@synAll = @synAll.split(',')
|
||||||
@synAll.each do |synapse_id|
|
@synAll.each do |synapse_id|
|
||||||
@mapping = Mapping.new()
|
@mapping = Mapping.new()
|
||||||
|
@ -138,12 +135,10 @@ class MapsController < ApplicationController
|
||||||
|
|
||||||
@map.arranged = true
|
@map.arranged = true
|
||||||
@map.save
|
@map.save
|
||||||
|
|
||||||
@forked = true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js { respond_with(@map, @forked) }
|
format.json { render :json => @map }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -153,15 +148,15 @@ class MapsController < ApplicationController
|
||||||
@map = Map.find(params[:id]).authorize_to_edit(@current)
|
@map = Map.find(params[:id]).authorize_to_edit(@current)
|
||||||
|
|
||||||
if @map
|
if @map
|
||||||
if params[:map]
|
@map.name = params[:name] if params[:name]
|
||||||
@map.name = params[:map][:name] if params[:map][:name]
|
@map.desc = params[:desc] if params[:desc]
|
||||||
@map.desc = params[:map][:desc] if params[:map][:desc]
|
@map.permission = params[:permission] if params[:permission]
|
||||||
@map.permission = params[:map][:permission] if params[:map][:permission]
|
|
||||||
end
|
|
||||||
@map.save
|
@map.save
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_with @map
|
respond_to do |format|
|
||||||
|
format.json { render :json => @map }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# DELETE maps/:id
|
# DELETE maps/:id
|
||||||
|
|
|
@ -51,19 +51,15 @@
|
||||||
<h4>PRIVATE</h4>
|
<h4>PRIVATE</h4>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= form.hidden_field :permission, :value => "commons" %>
|
|
||||||
<div class="clearfloat"></div>
|
<div class="clearfloat"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="permText">*new topics and synapses take on the same permission as the map they are created on</p>
|
<p class="permText">*new topics and synapses take on the same permission as the map they are created on</p>
|
||||||
|
|
||||||
<div class="buttonWrapper">
|
<div class="buttonWrapper">
|
||||||
<button class="button" onclick="Metamaps.GlobalUI.closeLightbox(); return false;">Cancel</button>
|
<button class="button cancel">Cancel</button>
|
||||||
<%= form.submit "Create!", class: "add" %>
|
<button class="button submitMap">Create!</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= form.hidden_field :topicsToMap, :value => 0 %>
|
|
||||||
<%= form.hidden_field :synapsesToMap, :value => 0 %>
|
|
||||||
<div class="clearfloat"></div>
|
<div class="clearfloat"></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -46,15 +46,14 @@
|
||||||
<h4>PRIVATE</h4>
|
<h4>PRIVATE</h4>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= form.hidden_field :permission, :value => "commons" %>
|
|
||||||
<div class="clearfloat"></div>
|
<div class="clearfloat"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="permText">*new topics and synapses take on the same permission as the map they are created on</p>
|
<p class="permText">*new topics and synapses take on the same permission as the map they are created on</p>
|
||||||
|
|
||||||
<div class="buttonWrapper">
|
<div class="buttonWrapper">
|
||||||
<button class="button" onclick="Metamaps.GlobalUI.closeLightbox(); return false;">Cancel</button>
|
<button class="button cancel">Cancel</button>
|
||||||
<%= form.submit "Create!", class: "add" %>
|
<button class="button submitMap">Create!</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="clearfloat"></div>
|
<div class="clearfloat"></div>
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
/*
|
|
||||||
* @file
|
|
||||||
* Javascript run on creation of a new map
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
$('#map_name').val('');
|
|
||||||
$('#map_desc').val('');
|
|
||||||
$('#map_permission').val('commons');
|
|
||||||
|
|
||||||
<% if @forked %>
|
|
||||||
$('#map_topicsToMap').val('0');
|
|
||||||
$('#map_synapsesToMap').val('0');
|
|
||||||
|
|
||||||
var form = $('#fork_map');
|
|
||||||
<% else %>
|
|
||||||
var form = $('#new_map');
|
|
||||||
<% end %>
|
|
||||||
form.find('.mapPermIcon').removeClass('selected');
|
|
||||||
form.find('.mapCommonsIcon').addClass('selected');
|
|
||||||
|
|
||||||
|
|
||||||
var tempForm = form.html();
|
|
||||||
if (mapid == null) {
|
|
||||||
form.html("Success! Do you want to <br> <a href='/maps/" + '<%= @map.id %>' + "'>Go to your new map?</a><br>or<br><a href='#' onclick='closeIt(); return false;'>Stay on this page?</a>");
|
|
||||||
}
|
|
||||||
else if (mapid != null) {
|
|
||||||
form.html("Success! Do you want to <br> <a href='/maps/" + '<%= @map.id %>' + "'>Go to your new map?</a><br>or<br><a href='#' onclick='closeIt(); return false;'>Stay on this map?</a>");
|
|
||||||
}
|
|
||||||
$('#lightbox_main').css('margin-top', '-' + ($('#lightbox_main').height() / 2) + 'px' );
|
|
||||||
|
|
||||||
function closeIt() {
|
|
||||||
$('#lightbox_overlay').hide();
|
|
||||||
form.html(tempForm);
|
|
||||||
// bind permission changer events
|
|
||||||
form.find('.permIcon').click(function() {
|
|
||||||
$(this).siblings('#map_permission').val( $(this).attr('data-permission') );
|
|
||||||
$(this).siblings('.permIcon').find('.mapPermIcon').removeClass('selected');
|
|
||||||
$(this).find('.mapPermIcon').addClass('selected');
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
/*
|
|
||||||
* @file
|
|
||||||
* Javascript run on destruction of a map. Fades it out from map index.
|
|
||||||
*/
|
|
||||||
$('#<%= dom_id(@map) %>').fadeOut('slow');
|
|
|
@ -1,94 +0,0 @@
|
||||||
/*
|
|
||||||
* @file
|
|
||||||
* Javascript code for realtime callbacks
|
|
||||||
* TODO: Connor, could you explain this code sometime?
|
|
||||||
*/
|
|
||||||
var tempForT, tempForS, tempForM;
|
|
||||||
|
|
||||||
<% @topics.each do |topic| %>
|
|
||||||
var topic = <%= topic.selfonmap_as_json(@map.id).html_safe %>;
|
|
||||||
tempForT = Mconsole.graph.getNode(topic.id);
|
|
||||||
if (tempForT === undefined) {
|
|
||||||
Mconsole.graph.addNode(topic);
|
|
||||||
var tempForT = Mconsole.graph.getNode(topic.id);
|
|
||||||
tempForT.setData('dim', 1, 'start');
|
|
||||||
tempForT.setData('dim', 25, 'end');
|
|
||||||
var newPos = new $jit.Complex();
|
|
||||||
newPos.x = tempForT.data.$xloc;
|
|
||||||
newPos.y = tempForT.data.$yloc;
|
|
||||||
tempForT.setPos(newPos, 'start');
|
|
||||||
tempForT.setPos(newPos, 'current');
|
|
||||||
tempForT.setPos(newPos, 'end');
|
|
||||||
Mconsole.fx.plotNode(tempForT, Mconsole.canvas);
|
|
||||||
Mconsole.labels.plotLabel(Mconsole.canvas, tempForT, Mconsole.config);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var label = Mconsole.labels.getLabel(topic.id);
|
|
||||||
tempForT.setData('dim', 25, 'start');
|
|
||||||
tempForT.setData('dim', 25, 'current');
|
|
||||||
tempForT.setData('dim', 25, 'end');
|
|
||||||
if (tempForT.name != topic.name) {
|
|
||||||
tempForT.name = topic.name;
|
|
||||||
$(label).find('.best_in_place_name').html(topic.name);
|
|
||||||
$(label).find('.label').html(topic.name);
|
|
||||||
}
|
|
||||||
if (tempForT.data.$metacode != topic.data.$metacode) {
|
|
||||||
$(label).find('.best_in_place_metacode').html(topic.data.$metacode);
|
|
||||||
$(label).find('img.icon').attr('alt', topic.data.$metacode);
|
|
||||||
$(label).find('img.icon').attr('src', imgArray[topic.data.$metacode].src);
|
|
||||||
}
|
|
||||||
if (tempForT.data.$desc != topic.data.$desc) {
|
|
||||||
$(label).find('.best_in_place_desc').html(topic.data.$desc);
|
|
||||||
}
|
|
||||||
if (tempForT.data.$link != topic.data.$link) {
|
|
||||||
$(label).find('.best_in_place_link').html(topic.data.$link);
|
|
||||||
$(label).find('.link').attr('href',topic.data.$link);
|
|
||||||
}
|
|
||||||
tempForT.data = topic.data;
|
|
||||||
}
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% @synapses.each do |synapse| %>
|
|
||||||
var Node1 = Mconsole.graph.getNode(<%= synapse.topic1.id %>);
|
|
||||||
var Node2 = Mconsole.graph.getNode(<%= synapse.topic2.id %>);
|
|
||||||
Mconsole.graph.addAdjacence(Node1, Node2, {});
|
|
||||||
tempForS = Mconsole.graph.getAdjacence(Node1.id, Node2.id);
|
|
||||||
tempForS.setDataset('start', {
|
|
||||||
lineWidth: 0.4
|
|
||||||
});
|
|
||||||
tempForS.setDataset('end', {
|
|
||||||
lineWidth: 2
|
|
||||||
});
|
|
||||||
var d = new Array(<%= synapse.node1_id.to_s() %>, <%= synapse.node2_id.to_s() %>);
|
|
||||||
tempForS.setDataset('current', {
|
|
||||||
desc: '<%= synapse.desc %>',
|
|
||||||
showDesc: false,
|
|
||||||
category: '<%= synapse.category %>',
|
|
||||||
id: '<%= synapse.id %>',
|
|
||||||
userid: '<%= synapse.user.id %>',
|
|
||||||
username: '<%= synapse.user.name %>'
|
|
||||||
});
|
|
||||||
tempForS.data.$direction = d;
|
|
||||||
Mconsole.fx.plotLine(tempForS, Mconsole.canvas);
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% @mappings.each do |mapping| %>
|
|
||||||
tempForM = Mconsole.graph.getNode(<%= mapping.topic_id %>);
|
|
||||||
tempForM.data.$xloc = <%= mapping.xloc %>;
|
|
||||||
tempForM.data.$yloc = <%= mapping.yloc %>;
|
|
||||||
var newPos = new $jit.Complex();
|
|
||||||
newPos.x = tempForM.data.$xloc;
|
|
||||||
newPos.y = tempForM.data.$yloc;
|
|
||||||
tempForM.setPos(newPos, 'start');
|
|
||||||
tempForM.setPos(newPos, 'current');
|
|
||||||
tempForM.setPos(newPos, 'end');
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% if @topics.length > 0 || @synapses.length > 0 || @mappings.length > 0 %>
|
|
||||||
$('#map_time').val(Math.round((new Date()).getTime() / 1000));
|
|
||||||
Mconsole.fx.animate({
|
|
||||||
modes: ['linear','node-property:dim','edge-property:lineWidth'],
|
|
||||||
transition: $jit.Trans.Quad.easeInOut,
|
|
||||||
duration: 500
|
|
||||||
});
|
|
||||||
<% end %>
|
|
|
@ -1,6 +0,0 @@
|
||||||
/*
|
|
||||||
* @file
|
|
||||||
* Javascript executed when you save the layout of a map.
|
|
||||||
*/
|
|
||||||
$('.sidebarSave .tip').html('Saved!');
|
|
||||||
setTimeout(function(){ $('.sidebarSave .tip').html('Save Layout') },1500);
|
|
71
codeguide.txt
Normal file
71
codeguide.txt
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
FILE /app/views/layouts/application.html.erb
|
||||||
|
<head>
|
||||||
|
...
|
||||||
|
<%= javascript_include_tag "application" %>
|
||||||
|
<% if (controller_name == "maps" || controller_name == "topics") && action_name == "show" %>
|
||||||
|
<%= javascript_include_tag "compileMapPages" %>
|
||||||
|
<% end %>
|
||||||
|
...
|
||||||
|
</head>
|
||||||
|
|
||||||
|
WHAT DOES IT MEAN?
|
||||||
|
|
||||||
|
|
||||||
|
____________________________________________________________________
|
||||||
|
|
||||||
|
FILE /app/assets/javascripts/application.js
|
||||||
|
...
|
||||||
|
//= require jquery
|
||||||
|
//= require jquery-ui
|
||||||
|
//= require jquery_ujs
|
||||||
|
//= require ./orderedLibraries/underscore
|
||||||
|
//= require ./orderedLibraries/backbone
|
||||||
|
//= require_directory ./librariesForAllPages
|
||||||
|
//= require ./metamaps/Metamaps.GlobalUI
|
||||||
|
//= require ./metamaps/Metamaps.Backbone
|
||||||
|
|
||||||
|
WHAT DOES IT MEAN?
|
||||||
|
|
||||||
|
|
||||||
|
____________________________________________________________________
|
||||||
|
|
||||||
|
FILE /app/assets/javascripts/compileMapPages.js
|
||||||
|
...
|
||||||
|
//= require ./librariesForMapPages/cloudcarousel
|
||||||
|
//= require ./librariesForMapPages/socket.io
|
||||||
|
//= require ./metamaps/JIT
|
||||||
|
//= require ./metamaps/Metamaps
|
||||||
|
//= require ./metamaps/Metamaps.JIT
|
||||||
|
|
||||||
|
WHAT DOES IT MEAN?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
____________________________________________________________________
|
||||||
|
|
||||||
|
FILE /app/assets/javascripts/metamaps/Metamaps.GlobalUI.js
|
||||||
|
|
||||||
|
var Metamaps = {};
|
||||||
|
...
|
||||||
|
$(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') &&
|
||||||
|
typeof (Metamaps[prop].init) == 'function'
|
||||||
|
) {
|
||||||
|
Metamaps[prop].init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Metamaps.GlobalUI = {
|
||||||
|
...
|
||||||
|
};
|
||||||
|
|
||||||
|
WHAT DOES IT MEAN?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
____________________________________________________________________
|
||||||
|
|
Loading…
Add table
Reference in a new issue