work in progress on explore maps pages

This commit is contained in:
Connor Turland 2014-08-06 10:09:01 -04:00
parent 0a29bed856
commit e7a445423d
10 changed files with 100 additions and 26 deletions

View file

@ -82,9 +82,13 @@ Metamaps.GlobalUI = {
$('.alert.metamaps').delay(10000).fadeOut('fast');
// initialize global backbone models and collections
Metamaps.Active.Mapper = new Metamaps.Backbone.Mapper(Metamaps.Active.Mapper);
if (Metamaps.Active.Mapper) Metamaps.Active.Mapper = new Metamaps.Backbone.Mapper(Metamaps.Active.Mapper);
Metamaps.Mappers = new Metamaps.Backbone.MapperCollection([Metamaps.Active.Mapper]);
Metamaps.Maps = new Metamaps.Backbone.MapsCollection();
Metamaps.Maps = {};
Metamps.Maps.Mine = new Metamaps.Backbone.MapsCollection();
Metamps.Maps.Featured = new Metamaps.Backbone.MapsCollection();
Metamps.Maps.Active = new Metamaps.Backbone.MapsCollection();
Metamps.Maps.New = new Metamaps.Backbone.MapsCollection();
},
openLightbox: function (which) {
var self = Metamaps.GlobalUI;

View file

@ -5,18 +5,29 @@
"explore/:section": "explore", // #explore/active
"maps/:id": "maps" // #maps/7
},
home: function () {
document.title = 'My Maps | Metamaps';
$('#cards').show();
},
explore: function (section) {
console.log(section);
var capitalize = section.charAt(0).toUpperCase() + section.slice(1);
document.title = 'Explore ' + capitalize + ' Maps | Metamaps';
//$('#cards').hide();
},
maps: function (id) {
console.log(id);
document.title = 'Map ' + id + ' | Metamaps';
$('#cards').hide();
}
});
Metamaps.Router = new Router();
Metamaps.Router.init = function () {
/*Backbone.history.start({
Backbone.history.start({
pushState: true,
root: ''
root: '/'
});
console.log('router started');
$(document).on("click", "a:not([data-bypass])", function (evt) {
@ -25,11 +36,13 @@
attr: $(this).attr("href")
};
var root = location.protocol + "//" + location.host + Backbone.history.options.root;
if (href.prop && href.prop === root) href.attr = ""
if (href.prop && href.prop.slice(0, root.length) === root) {
evt.preventDefault();
Backbone.history.navigate(href.attr, true);
}
});*/
});
}
})();

View file

@ -0,0 +1,26 @@
(function () {
Metamaps.Views = {};
Metamaps.Views.MapCard = Backbone.View.extend({
tagName: "div",
className: "map",
events: {
"click .icon": "open",
"click .button.edit": "openEditDialog",
"click .button.delete": "destroy"
},
initialize: function () {
this.listenTo(this.model, "change", this.render);
},
render: function () {
}
});
})();

View file

@ -1632,9 +1632,8 @@ Metamaps.Control = {
},
deleteNode: function (nodeid) { // refers to deleting topics permanently
var node = Metamaps.Visualize.mGraph.graph.getNode(nodeid);
var id = node.getData('id');
Metamaps.Control.deselectNode(node);
Metamaps.Topics.get(id).destroy();
Metamaps.Topics.get(nodeid).destroy();
Metamaps.Control.hideNode(nodeid);
},
removeSelectedNodes: function () { // refers to removing topics permanently from a map
@ -1653,11 +1652,10 @@ Metamaps.Control = {
removeNode: function (nodeid) { // refers to removing topics permanently from a map
var mapperm = Metamaps.Active.Map.authorizeToEdit(Metamaps.Active.Mapper);
var node = Metamaps.Visualize.mGraph.graph.getNode(nodeid);
var mappingid = node.getData("mapping").id;
if (mapperm) {
Metamaps.Control.deselectNode(node);
Metamaps.Mappings.get(mappingid).destroy();
node.getData('mapping').destroy();
Metamaps.Control.hideNode(nodeid);
}
},

View file

@ -12,22 +12,22 @@ class MapsController < ApplicationController
# GET /maps/mappers/:id
def index
if request.path == "/maps"
if request.path == "/explore"
redirect_to activemaps_url and return
end
@current = current_user
@user = nil
if request.path =="/maps/active"
if request.path =="/explore/active"
@maps = Map.order("updated_at DESC").limit(20)
@request = "active"
elsif request.path =="/maps/featured"
elsif request.path =="/explore/featured"
@maps = Map.order("name ASC").find_all_by_featured(true)
@request = "featured"
elsif request.path == "/maps/new"
elsif request.path == "/explore/new"
@maps = Map.order("created_at DESC").limit(20)
@request = "new"

View file

@ -4,7 +4,40 @@
#%>
<div class="templates">
<script type="text/template" id="mapCardTemplate">
<div class="map" id="{{id}}">
<div class="permission {{editPermission}}"> <!-- must be canEdit or cannotEdit -->
<div class="mapCard">
<span class="title">
<span class="best_in_place best_in_place_name" id="best_in_place_map_{{id}}_name" data-url="/maps/{{id}}" data-object="map" data-attribute="name" data-type="textarea">{{name}}</span>
</span>
<div class="links">
<div class="linkItem icon">
<div class="metacodeImage" style="background-image:url(/assets/map.png);"></div>
</div>
<div class="linkItem contributor hoverForTip">
<div class="tip">Created by {{username}} on {{createdAt}}</div>
</div>
<div class="linkItem topicCount">{{topicCount}}</div>
<div class="linkItem synapseCount">[{synapseCount}}</div>
<div class="linkItem mapPerm {{mkPermission}}"></div>
<a href="/maps/{{id}}" class="linkItem topicPopout"></a>
<div class="clearfloat"></div>
</div>
<div class="scroll">
<div class="desc">
<span class="best_in_place best_in_place_desc" id="best_in_place_map_{{id}}_desc" data-url="/maps/{{id}}" data-object="map" data-attribute="desc" data-nil="Click to add description." data-type="textarea">{{desc}}</span>
<div class="clearfloat"></div>
</div>
</div>
<div class="clearfloat"></div>
</div>
</div>
</div>
</script>
<script type="text/template" id="topicSearchTemplate">
<div class="result{{rtype}}">
<div class="topicMetacode">

View file

@ -36,7 +36,7 @@
<div class="wrapper <%= controller_name == "main" && action_name == "home" ? "homePage" : "" %>" id="wrapper">
<div class="homeButton">
<a href="/"></a>
<a href="<%= root_url %>"></a>
</div>
<div class="sidebarSearch">

View file

@ -101,7 +101,7 @@ $(document).ready(function() {
<div class="mapOrder">
<span class="displaying">Displaying:</span>
<div class="whichMaps">
<a href="/maps/mappers/<%= @current.id %>" class="active">Yours</a> /
<a href="/" class="active">My Maps</a> /
<a href="/explore/active">Recently Active</a> /
<a href="/explore/featured">Featured</a> /
<a href="/explore/new">Newest First</a>

View file

@ -17,12 +17,12 @@
<% end %>
<% if @request != "topic" %>
<a href="/maps/active" class="<%= @request == "active" ? "active" : "" %>">Recently Active</a> /
<a href="/maps/featured" class="<%= @request == "featured" ? "active" : "" %>">Featured</a> /
<a href="/maps/new" class="<%= @request == "new" ? "active" : "" %>">Newest First</a>
<% if authenticated? %>
/ <a href="/maps/mappers/<%= @current.id %>" class="<%= @request == "you" ? "active" : "" %>">Yours</a>
<a href="/maps/mappers/<%= @current.id %>" class="<%= @request == "you" ? "active" : "" %>">My Maps</a> /
<% end %>
<a href="/explore/active" class="<%= @request == "active" ? "active" : "" %>">Recently Active</a> /
<a href="/explore/featured" class="<%= @request == "featured" ? "active" : "" %>">Featured</a> /
<a href="/explore/new" class="<%= @request == "new" ? "active" : "" %>">Newest First</a>
<% end %>
</div>
<div class="clearfloat"></div>

View file

@ -19,9 +19,9 @@ Metamaps::Application.routes.draw do
get :autocomplete_topic, :on => :collection
end
match 'maps/active', to: 'maps#index', via: :get, as: :activemaps
match 'maps/featured', to: 'maps#index', via: :get, as: :featuredmaps
match 'maps/new', to: 'maps#index', via: :get, as: :newmaps
match 'explore/active', to: 'maps#index', via: :get, as: :activemaps
match 'explore/featured', to: 'maps#index', via: :get, as: :featuredmaps
match 'explore/new', to: 'maps#index', via: :get, as: :newmaps
match 'maps/mappers/:id', to: 'maps#index', via: :get, as: :usermaps
match 'maps/topics/:id', to: 'maps#index', via: :get, as: :topicmaps
resources :maps, except: [:new, :edit]