diff --git a/app/assets/images/shattered_@2X.png b/app/assets/images/shattered_@2X.png new file mode 100644 index 00000000..19322777 Binary files /dev/null and b/app/assets/images/shattered_@2X.png differ diff --git a/vendor/assets/images/ui-bg_flat_0_aaaaaa_40x100.png b/app/assets/images/ui-bg_flat_0_aaaaaa_40x100.png similarity index 100% rename from vendor/assets/images/ui-bg_flat_0_aaaaaa_40x100.png rename to app/assets/images/ui-bg_flat_0_aaaaaa_40x100.png diff --git a/vendor/assets/images/ui-bg_flat_75_ffffff_40x100.png b/app/assets/images/ui-bg_flat_75_ffffff_40x100.png similarity index 100% rename from vendor/assets/images/ui-bg_flat_75_ffffff_40x100.png rename to app/assets/images/ui-bg_flat_75_ffffff_40x100.png diff --git a/vendor/assets/images/ui-bg_glass_55_fbf9ee_1x400.png b/app/assets/images/ui-bg_glass_55_fbf9ee_1x400.png similarity index 100% rename from vendor/assets/images/ui-bg_glass_55_fbf9ee_1x400.png rename to app/assets/images/ui-bg_glass_55_fbf9ee_1x400.png diff --git a/vendor/assets/images/ui-bg_glass_65_ffffff_1x400.png b/app/assets/images/ui-bg_glass_65_ffffff_1x400.png similarity index 100% rename from vendor/assets/images/ui-bg_glass_65_ffffff_1x400.png rename to app/assets/images/ui-bg_glass_65_ffffff_1x400.png diff --git a/vendor/assets/images/ui-bg_glass_75_dadada_1x400.png b/app/assets/images/ui-bg_glass_75_dadada_1x400.png similarity index 100% rename from vendor/assets/images/ui-bg_glass_75_dadada_1x400.png rename to app/assets/images/ui-bg_glass_75_dadada_1x400.png diff --git a/vendor/assets/images/ui-bg_glass_75_e6e6e6_1x400.png b/app/assets/images/ui-bg_glass_75_e6e6e6_1x400.png similarity index 100% rename from vendor/assets/images/ui-bg_glass_75_e6e6e6_1x400.png rename to app/assets/images/ui-bg_glass_75_e6e6e6_1x400.png diff --git a/vendor/assets/images/ui-bg_glass_95_fef1ec_1x400.png b/app/assets/images/ui-bg_glass_95_fef1ec_1x400.png similarity index 100% rename from vendor/assets/images/ui-bg_glass_95_fef1ec_1x400.png rename to app/assets/images/ui-bg_glass_95_fef1ec_1x400.png diff --git a/vendor/assets/images/ui-bg_highlight-soft_75_cccccc_1x100.png b/app/assets/images/ui-bg_highlight-soft_75_cccccc_1x100.png similarity index 100% rename from vendor/assets/images/ui-bg_highlight-soft_75_cccccc_1x100.png rename to app/assets/images/ui-bg_highlight-soft_75_cccccc_1x100.png diff --git a/vendor/assets/images/ui-icons_222222_256x240.png b/app/assets/images/ui-icons_222222_256x240.png similarity index 100% rename from vendor/assets/images/ui-icons_222222_256x240.png rename to app/assets/images/ui-icons_222222_256x240.png diff --git a/vendor/assets/images/ui-icons_2e83ff_256x240.png b/app/assets/images/ui-icons_2e83ff_256x240.png similarity index 100% rename from vendor/assets/images/ui-icons_2e83ff_256x240.png rename to app/assets/images/ui-icons_2e83ff_256x240.png diff --git a/vendor/assets/images/ui-icons_454545_256x240.png b/app/assets/images/ui-icons_454545_256x240.png similarity index 100% rename from vendor/assets/images/ui-icons_454545_256x240.png rename to app/assets/images/ui-icons_454545_256x240.png diff --git a/vendor/assets/images/ui-icons_888888_256x240.png b/app/assets/images/ui-icons_888888_256x240.png similarity index 100% rename from vendor/assets/images/ui-icons_888888_256x240.png rename to app/assets/images/ui-icons_888888_256x240.png diff --git a/vendor/assets/images/ui-icons_cd0a0a_256x240.png b/app/assets/images/ui-icons_cd0a0a_256x240.png similarity index 100% rename from vendor/assets/images/ui-icons_cd0a0a_256x240.png rename to app/assets/images/ui-icons_cd0a0a_256x240.png diff --git a/app/assets/javascripts/metamaps/Metamaps.Backbone.js b/app/assets/javascripts/metamaps/Metamaps.Backbone.js index 6b858bda..d73623de 100644 --- a/app/assets/javascripts/metamaps/Metamaps.Backbone.js +++ b/app/assets/javascripts/metamaps/Metamaps.Backbone.js @@ -1,7 +1,7 @@ Metamaps.Backbone = {}; Metamaps.Backbone.Map = Backbone.Model.extend({ urlRoot: '/maps', - blacklist: ['created_at', 'updated_at', 'map', 'topics', 'synapses', 'mappings', 'mappers'], + blacklist: ['created_at', 'updated_at', 'topics', 'synapses', 'mappings', 'mappers'], toJSON: function (options) { return _.omit(this.attributes, this.blacklist); }, @@ -12,25 +12,52 @@ Metamaps.Backbone.Map = Backbone.Model.extend({ getUser: function () { return Metamaps.Mapper.get(this.get('user_id')); }, + fetchContained: function () { + var bb = Metamaps.Backbone; + var start = function (data) { + this.set('mappers', new bb.MapperCollection(data.mappers)); + this.set('topics', new bb.TopicCollection(data.topics)); + this.set('synapses', new bb.SynapseCollection(data.synapses)); + this.set('mappings', new bb.MappingCollection(data.mappings)); + } + + $.ajax({ + url: "/maps/" + this.id + "/contains", + success: start, + async: false + }); + }, getTopics: function () { if (!this.get('topics')) { - this.fetch({async: false}); + this.fetchContained(); } return this.get('topics'); }, getSynapses: function () { if (!this.get('synapses')) { - this.fetch({async: false}); + this.fetchContained(); } return this.get('synapses'); }, + getMappings: function () { + if (!this.get('mappings')) { + this.fetchContained(); + } + return this.get('mappings'); + }, + getMappers: function () { + if (!this.get('mappers')) { + this.fetchContained(); + } + return this.get('mappers'); + }, attrForCards: function () { var obj = { id: this.id, name: this.get('name'), desc: this.get('desc'), username: this.getUser().get('name'), - mkPermission: this.get("permission").substring(0, 2), + mkPermission: this.get("permission") ? this.get("permission").substring(0, 2) : "commons", editPermission: this.authorizeToEdit(Metamaps.Active.Mapper) ? 'canEdit' : 'cannotEdit', topicCount: this.getTopics().length, synapseCount: this.getSynapses().length, @@ -52,8 +79,8 @@ Metamaps.Backbone.MapsCollection = Backbone.Collection.extend({ a = a.get(this.sortBy); b = b.get(this.sortBy); if (this.sortBy === 'name') { - a = a.toLowerCase(); - b = b.toLowerCase(); + a = a ? a.toLowerCase() : ""; + b = b ? b.toLowerCase() : ""; } return a > b ? 1 : a < b ? -1 : 0; }, diff --git a/app/assets/javascripts/metamaps/Metamaps.GlobalUI.js b/app/assets/javascripts/metamaps/Metamaps.GlobalUI.js index c7551761..4ecec60b 100644 --- a/app/assets/javascripts/metamaps/Metamaps.GlobalUI.js +++ b/app/assets/javascripts/metamaps/Metamaps.GlobalUI.js @@ -555,13 +555,13 @@ Metamaps.GlobalUI.Search = { self.close(0, true); var win; if (dataset == "topics") { - win = window.open('/topics/' + datum.id, '_blank'); + Metamaps.Router.topics(datum.id); } else if (dataset == "maps") { - win = window.open('/maps/' + datum.id, '_blank'); + Metamaps.Router.maps(datum.id); } else if (dataset == "mappers") { win = window.open('/maps/mappers/' + datum.id, '_blank'); + win.focus(); } - win.focus(); } }, initSearchOptions: function () { diff --git a/app/assets/javascripts/metamaps/Metamaps.Router.js b/app/assets/javascripts/metamaps/Metamaps.Router.js index 30cbe567..43c2482b 100644 --- a/app/assets/javascripts/metamaps/Metamaps.Router.js +++ b/app/assets/javascripts/metamaps/Metamaps.Router.js @@ -22,10 +22,12 @@ // all this only for the logged in home page if (Metamaps.Active.Mapper) { + + Metamaps.Famous.yield.hide(); + Metamaps.Famous.explore.set('mine'); Metamaps.Famous.explore.show(); - $('.yield').fadeOut(300); $('.mapsWrapper').fadeIn(300); Metamaps.GlobalUI.Search.open(); @@ -41,17 +43,20 @@ } // logged out home page else { + + Metamaps.Famous.yield.show(); + Metamaps.Famous.explore.hide(); Metamaps.GlobalUI.Search.unlock(); Metamaps.GlobalUI.Search.close(0, true); - $('.yield').fadeIn(300); $('.mapsWrapper').fadeOut(300); } Metamaps.Famous.viz.hide(); Metamaps.Active.Map = null; + Metamaps.Active.Topic = null; setTimeout(function(){ Metamaps.Router.navigate(""); @@ -79,8 +84,9 @@ Metamaps.GlobalUI.Search.open(); Metamaps.GlobalUI.Search.lock(); - - $('.yield').fadeOut(300); + + Metamaps.Famous.yield.hide(); + $('.mapsWrapper').fadeIn(300); Metamaps.Famous.explore.set(section); @@ -88,6 +94,7 @@ Metamaps.Famous.viz.hide(); Metamaps.Active.Map = null; + Metamaps.Active.Topic = null; setTimeout(function(){ Metamaps.Router.navigate("/explore/" + section); @@ -103,9 +110,8 @@ $('.wrapper').removeClass('homePage explorePage'); $('.wrapper').addClass('mapPage'); - $('.yield').fadeOut(300); + Metamaps.Famous.yield.hide(); $('.mapsWrapper').fadeOut(300); - Metamaps.Famous.explore.hide(); // clear the visualization, if there was one, before showing its div again @@ -115,11 +121,40 @@ Metamaps.JIT.centerMap(); } Metamaps.Famous.viz.show(); + Metamaps.Active.Topic = null; Metamaps.GlobalUI.Search.unlock(); Metamaps.GlobalUI.Search.close(0, true); Metamaps.Map.launch(id); + }, + topics: function (id) { + + document.title = 'Topic ' + id + ' | Metamaps'; + + Metamaps.currentSection = "topic"; + Metamaps.currentPage = id; + + $('.wrapper').removeClass('homePage explorePage'); + $('.wrapper').addClass('mapPage'); + + Metamaps.Famous.yield.hide(); + $('.mapsWrapper').fadeOut(300); + Metamaps.Famous.explore.hide(); + + // 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.Famous.viz.show(); + Metamaps.Active.Map = null; + + Metamaps.GlobalUI.Search.unlock(); + Metamaps.GlobalUI.Search.close(0, true); + + Metamaps.Topic.launch(id); } }); diff --git a/app/assets/javascripts/metamaps/Metamaps.Views.js b/app/assets/javascripts/metamaps/Metamaps.Views.js index 91588f33..fc4da130 100644 --- a/app/assets/javascripts/metamaps/Metamaps.Views.js +++ b/app/assets/javascripts/metamaps/Metamaps.Views.js @@ -46,6 +46,9 @@ Metamaps.Views.init = function () { this.listenTo(this.collection, 'errorOnFetch', this.handleError); }, render: function () { + + Metamaps.Loading.loader.hide(); + var that = this; this.$el.empty(); @@ -56,7 +59,6 @@ Metamaps.Views.init = function () { }); }, handleSuccess: function () { - Metamaps.Loading.loader.hide(); this.render(); }, handleError: function () { diff --git a/app/assets/javascripts/metamaps/Metamaps.js b/app/assets/javascripts/metamaps/Metamaps.js index 6b608034..9e1700b3 100644 --- a/app/assets/javascripts/metamaps/Metamaps.js +++ b/app/assets/javascripts/metamaps/Metamaps.js @@ -177,12 +177,7 @@ Metamaps.Backbone.init = function () { 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; - } + url: '/topics' }); self.Synapse = Backbone.Model.extend({ @@ -1196,7 +1191,7 @@ Metamaps.Visualize = { render: function () { var self = Metamaps.Visualize, RGraphSettings, FDSettings; - if (self.type == "RGraph" && !self.mGraph) { + if (self.type == "RGraph" && (!self.mGraph || self.mGraph instanceof $jit.ForceDirected)) { RGraphSettings = $.extend(true, {}, Metamaps.JIT.ForceDirected.graphSettings); @@ -1204,13 +1199,13 @@ Metamaps.Visualize = { $jit.RGraph.Plot.EdgeTypes.implement(Metamaps.JIT.ForceDirected.edgeSettings); RGraphSettings.width = $(document).width(); - RgraphSettings.height = $(document).height(); + RGraphSettings.height = $(document).height(); RGraphSettings.background = Metamaps.JIT.RGraph.background; RGraphSettings.levelDistance = Metamaps.JIT.RGraph.levelDistance; self.mGraph = new $jit.RGraph(RGraphSettings); - } else if (self.type == "ForceDirected" && !self.mGraph) { + } else if (self.type == "ForceDirected" && (!self.mGraph || self.mGraph instanceof $jit.RGraph)) { FDSettings = $.extend(true, {}, Metamaps.JIT.ForceDirected.graphSettings); @@ -1235,11 +1230,18 @@ Metamaps.Visualize = { // load JSON data, if it's not empty if (!self.loadLater) { //load JSON data. - self.mGraph.loadJSON(Metamaps.JIT.vizData); + var rootIndex = 0; + if (Metamaps.Active.Topic) { + var node = _.find(Metamaps.JIT.vizData, function(node){ + return node.id === Metamaps.Active.Topic.id; + }); + rootIndex = _.indexOf(Metamaps.JIT.vizData, node); + } + self.mGraph.loadJSON(Metamaps.JIT.vizData, rootIndex); //compute positions and plot. self.computePositions(); if (self.type == "RGraph") { - self.mGraph.animate(Metamaps.JIT.RGraph.animate); + self.mGraph.fx.animate(Metamaps.JIT.RGraph.animate); } else if (self.type == "ForceDirected") { self.mGraph.animate(Metamaps.JIT.ForceDirected.animateSavedLayout); } else if (self.type == "ForceDirected3D") { @@ -1250,10 +1252,14 @@ Metamaps.Visualize = { // update the url now that the map is ready setTimeout(function(){ var m = Metamaps.Active.Map; + var t = Metamaps.Active.Topic; if (m && window.location.pathname !== "/maps/" + m.id) { Metamaps.Router.navigate("/maps/" + m.id); } + else if (t && window.location.pathname !== "/topics/" + t.id) { + Metamaps.Router.navigate("/topics/" + t.id); + } }, 800); } @@ -1272,7 +1278,7 @@ Metamaps.Util = { // you may copy this code but please keep the copyright notice as well splitLine: function (st, n) { var b = ''; - var s = st; + var s = st ? st : ''; while (s.length > n) { var c = s.substring(0, n); var d = c.lastIndexOf(' '); @@ -1339,7 +1345,7 @@ Metamaps.Realtime = { var mapperm = Metamaps.Active.Map && Metamaps.Active.Map.authorizeToEdit(Metamaps.Active.Mapper); if (mapperm) { - self.socket = io.connect('http://localhost:5001'); + self.socket = io.connect('http://localhost:5001'); self.socket.on('connect', function () { console.log('socket connected'); self.setupSocket(); @@ -1996,6 +2002,36 @@ Metamaps.Filter = { } }, time); }, + reset: function () { + var self = Metamaps.Filter; + + self.filters.metacodes = []; + self.filters.mappers = []; + self.filters.synapses = []; + self.visible.metacodes = []; + self.visible.mappers = []; + self.visible.synapses = []; + + $('#filter_by_metacode ul').empty(); + $('#filter_by_mapper ul').empty(); + $('#filter_by_synapse ul').empty(); + }, + initializeFilterData: function () { + var self = Metamaps.Filter; + + var check = function (filtersToUse, topicsOrSynapses, propertyToCheck) { + Metamaps[topicsOrSynapses].each(function(model) { + var prop = model.get(propertyToCheck) ? model.get(propertyToCheck).toString() : false; + if (prop && self.visible[filtersToUse].indexOf(prop) === -1) { + self.visible[filtersToUse].push(prop); + } + }); + }; + check('metacodes', 'Topics', 'metacode_id'); + check('mappers', 'Topics', 'user_id'); + check('mappers', 'Synapses', 'user_id'); + check('synapses', 'Synapses', 'desc'); + }, /* Most of this data essentially depends on the ruby function which are happening for filter inside view filterBox But what these function do is load this data into three accessible array within java : metacodes, mappers and synapses @@ -2410,7 +2446,32 @@ Metamaps.Topic = { } } }, + launch: function (id) { + var bb = Metamaps.Backbone; + var start = function (data) { + Metamaps.Active.Topic = new bb.Topic(data.topic); + Metamaps.Topics = new bb.TopicCollection([data.topic].concat(data.relatives)); + Metamaps.Synapses = new bb.SynapseCollection(data.synapses); + // build and render the visualization + Metamaps.Visualize.type = "RGraph"; + Metamaps.JIT.prepareVizData(); + + // update filters + Metamaps.Filter.reset(); + Metamaps.Filter.initializeFilterData(); // this sets all the visible filters to true + + // these three update the actual filter box with the right list items + Metamaps.Filter.checkMetacodes(); + Metamaps.Filter.checkSynapses(); + Metamaps.Filter.checkMappers(); + } + + $.ajax({ + url: "/topics/" + id + "/network.json", + success: start + }); + }, /* * * @@ -2724,16 +2785,21 @@ Metamaps.Map = { Metamaps.Mappings = new bb.MappingCollection(data.mappings); // build and render the visualization + Metamaps.Visualize.type = "ForceDirected"; Metamaps.JIT.prepareVizData(); // update filters - Metamaps.Filter.checkMappers(); + Metamaps.Filter.reset(); + Metamaps.Filter.initializeFilterData(); // this sets all the visible filters to true + + // these three update the actual filter box with the right list items Metamaps.Filter.checkMetacodes(); Metamaps.Filter.checkSynapses(); + Metamaps.Filter.checkMappers(); } $.ajax({ - url: "/maps/" + id + ".json", + url: "/maps/" + id + "/contains.json", success: start }); }, diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 649f2e2c..148c20c2 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -9,7 +9,6 @@ * compiled file, but it's generally better to create a new file per style scope. * *= require_self - *= require_tree ../../../vendor/assets/stylesheets *= require_tree . *= require base *= require ForceDirected @@ -84,7 +83,7 @@ html { } body { - background: #d8d9da; + background: #d8d9da url(/assets/shattered_@2X.png); font-family: 'din-medium', helvetica, sans-serif; color: #424242; } diff --git a/app/assets/stylesheets/clean.css b/app/assets/stylesheets/clean.css index bb137d21..d8bd7550 100644 --- a/app/assets/stylesheets/clean.css +++ b/app/assets/stylesheets/clean.css @@ -22,10 +22,14 @@ margin:0; } -.yield { +#yield { display:none; } +#toast { + display: none; +} + /*.animations { -webkit-transition-duration: .5s; -moz-transition-duration: .5s; @@ -488,6 +492,65 @@ /* end upperRightUI */ + +/* homepage */ + +.homeWrapper { + width: 560px; + margin: 0 auto; + color: #424242; +} + +.homeTitle { + font-size: 48px; + line-height: 48px; + text-align: center; + margin-bottom: 20px; +} + +.homeIntro { + font-size: 23px; + line-height: 26px; + text-align: justify; + margin-bottom: 20px; +} + +.homeWrapper .green { + color: #4fc059; +} + +.homeVideo { + margin-bottom: 20px; +} + +.callToAction a { + display: block; + width: 220px; + height: 12px; + padding: 16px 0; + text-align: center; + border-radius: 2px; + font-size: 12px; + box-shadow: 0px 1px 1.5px rgba(0,0,0,0.12), 0 1px 1px rgba(0,0,0,0.24); + margin: 0 auto; + color: #FFFFFF; +} +.callToAction .requestInviteCTA { + background-color: #4fc059; + margin-bottom: 15px; +} +.callToAction .requestInviteCTA:hover { + background-color: #49ad4e; +} +.callToAction .exploreFeaturedCTA { + background-color: #a354cd; +} +.callToAction .exploreFeaturedCTA:hover { + background-color: #9150bc; +} + +/* end home page */ + /* infoAndHelp */ .infoAndHelp { diff --git a/app/controllers/maps_controller.rb b/app/controllers/maps_controller.rb index b8ab6f79..933f29e1 100644 --- a/app/controllers/maps_controller.rb +++ b/app/controllers/maps_controller.rb @@ -76,6 +76,29 @@ class MapsController < ApplicationController redirect_to root_url and return end + respond_to do |format| + format.html { + @allmappers = @map.contributors + @alltopics = @map.topics # should limit to topics visible to user + @allsynapses = @map.synapses # should also be limited + @allmappings = @map.mappings + + respond_with(@allmappers, @allmappings, @allsynapses, @alltopics, @map) + } + format.json { render json: @map } + end + end + + # GET maps/:id/contains + def contains + + @current = current_user + @map = Map.find(params[:id]).authorize_to_show(@current) + + if not @map + redirect_to root_url and return + end + @allmappers = @map.contributors @alltopics = @map.topics # should limit to topics visible to user @allsynapses = @map.synapses # should also be limited @@ -89,11 +112,11 @@ class MapsController < ApplicationController @json['mappers'] = @allmappers respond_to do |format| - format.html { respond_with(@allmappers, @allmappings, @allsynapses, @alltopics, @map, @user) } format.json { render json: @json } end end + # GET maps/:id/embed def embed @current = current_user diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index dc7ee02d..c1672290 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -32,13 +32,36 @@ class TopicsController < ApplicationController redirect_to root_url and return end - @alltopics = [@topic] + @topic.relatives # should limit to topics visible to user + respond_to do |format| + format.html { + @alltopics = [@topic] + @topic.relatives # should limit to topics visible to user + @allsynapses = @topic.synapses # should also be limited + + respond_with(@allsynapses, @alltopics, @topic) + } + format.json { render json: @topic } + end + end + + # GET topics/:id/network + def network + @current = current_user + @topic = Topic.find(params[:id]).authorize_to_show(@current) + + if not @topic + redirect_to root_url and return + end + + @alltopics = @topic.relatives # should limit to topics visible to user @allsynapses = @topic.synapses # should also be limited - @allmetacodes = Metacode.all + + @json = Hash.new() + @json['topic'] = @topic + @json['relatives'] = @alltopics + @json['synapses'] = @allsynapses respond_to do |format| - format.html { respond_with(@allmetacodes, @allsynapses, @alltopics, @topic, @user) } - format.json { render json: @topic } + format.json { render json: @json } end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 7099fce3..ef50717c 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -34,7 +34,7 @@ @@ -42,10 +42,7 @@
<% if notice %> - - <% end %> - <% if alert %> - +<%= notice %>
<% end %> <%= content_tag :div, class: authenticated? ? "main authenticated" : "main unauthenticated" do %> @@ -61,7 +58,7 @@ <%= render :partial => 'layouts/upperelements' %> <%= render :partial => 'layouts/exploremaps' %> -- Request Invite - Explore Featured -