work in progress on explore maps pages
This commit is contained in:
parent
0a29bed856
commit
e7a445423d
10 changed files with 100 additions and 26 deletions
|
@ -82,9 +82,13 @@ Metamaps.GlobalUI = {
|
||||||
$('.alert.metamaps').delay(10000).fadeOut('fast');
|
$('.alert.metamaps').delay(10000).fadeOut('fast');
|
||||||
|
|
||||||
// initialize global backbone models and collections
|
// 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.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) {
|
openLightbox: function (which) {
|
||||||
var self = Metamaps.GlobalUI;
|
var self = Metamaps.GlobalUI;
|
||||||
|
|
|
@ -5,18 +5,29 @@
|
||||||
"explore/:section": "explore", // #explore/active
|
"explore/:section": "explore", // #explore/active
|
||||||
"maps/:id": "maps" // #maps/7
|
"maps/:id": "maps" // #maps/7
|
||||||
},
|
},
|
||||||
|
home: function () {
|
||||||
|
|
||||||
|
document.title = 'My Maps | Metamaps';
|
||||||
|
$('#cards').show();
|
||||||
|
},
|
||||||
explore: function (section) {
|
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) {
|
maps: function (id) {
|
||||||
console.log(id);
|
|
||||||
|
document.title = 'Map ' + id + ' | Metamaps';
|
||||||
|
$('#cards').hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Metamaps.Router = new Router();
|
Metamaps.Router = new Router();
|
||||||
Metamaps.Router.init = function () {
|
Metamaps.Router.init = function () {
|
||||||
/*Backbone.history.start({
|
Backbone.history.start({
|
||||||
pushState: true,
|
pushState: true,
|
||||||
root: ''
|
root: '/'
|
||||||
});
|
});
|
||||||
console.log('router started');
|
console.log('router started');
|
||||||
$(document).on("click", "a:not([data-bypass])", function (evt) {
|
$(document).on("click", "a:not([data-bypass])", function (evt) {
|
||||||
|
@ -25,11 +36,13 @@
|
||||||
attr: $(this).attr("href")
|
attr: $(this).attr("href")
|
||||||
};
|
};
|
||||||
var root = location.protocol + "//" + location.host + Backbone.history.options.root;
|
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) {
|
if (href.prop && href.prop.slice(0, root.length) === root) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
Backbone.history.navigate(href.attr, true);
|
Backbone.history.navigate(href.attr, true);
|
||||||
}
|
}
|
||||||
});*/
|
});
|
||||||
}
|
}
|
||||||
})();
|
})();
|
26
app/assets/javascripts/metamaps/Metamaps.Views.js
Normal file
26
app/assets/javascripts/metamaps/Metamaps.Views.js
Normal 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 () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
})();
|
|
@ -1632,9 +1632,8 @@ Metamaps.Control = {
|
||||||
},
|
},
|
||||||
deleteNode: function (nodeid) { // refers to deleting topics permanently
|
deleteNode: function (nodeid) { // refers to deleting topics permanently
|
||||||
var node = Metamaps.Visualize.mGraph.graph.getNode(nodeid);
|
var node = Metamaps.Visualize.mGraph.graph.getNode(nodeid);
|
||||||
var id = node.getData('id');
|
|
||||||
Metamaps.Control.deselectNode(node);
|
Metamaps.Control.deselectNode(node);
|
||||||
Metamaps.Topics.get(id).destroy();
|
Metamaps.Topics.get(nodeid).destroy();
|
||||||
Metamaps.Control.hideNode(nodeid);
|
Metamaps.Control.hideNode(nodeid);
|
||||||
},
|
},
|
||||||
removeSelectedNodes: function () { // refers to removing topics permanently from a map
|
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
|
removeNode: function (nodeid) { // refers to removing topics permanently from a map
|
||||||
var mapperm = Metamaps.Active.Map.authorizeToEdit(Metamaps.Active.Mapper);
|
var mapperm = Metamaps.Active.Map.authorizeToEdit(Metamaps.Active.Mapper);
|
||||||
var node = Metamaps.Visualize.mGraph.graph.getNode(nodeid);
|
var node = Metamaps.Visualize.mGraph.graph.getNode(nodeid);
|
||||||
var mappingid = node.getData("mapping").id;
|
|
||||||
|
|
||||||
if (mapperm) {
|
if (mapperm) {
|
||||||
Metamaps.Control.deselectNode(node);
|
Metamaps.Control.deselectNode(node);
|
||||||
Metamaps.Mappings.get(mappingid).destroy();
|
node.getData('mapping').destroy();
|
||||||
Metamaps.Control.hideNode(nodeid);
|
Metamaps.Control.hideNode(nodeid);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,22 +12,22 @@ class MapsController < ApplicationController
|
||||||
# GET /maps/mappers/:id
|
# GET /maps/mappers/:id
|
||||||
def index
|
def index
|
||||||
|
|
||||||
if request.path == "/maps"
|
if request.path == "/explore"
|
||||||
redirect_to activemaps_url and return
|
redirect_to activemaps_url and return
|
||||||
end
|
end
|
||||||
|
|
||||||
@current = current_user
|
@current = current_user
|
||||||
@user = nil
|
@user = nil
|
||||||
|
|
||||||
if request.path =="/maps/active"
|
if request.path =="/explore/active"
|
||||||
@maps = Map.order("updated_at DESC").limit(20)
|
@maps = Map.order("updated_at DESC").limit(20)
|
||||||
@request = "active"
|
@request = "active"
|
||||||
|
|
||||||
elsif request.path =="/maps/featured"
|
elsif request.path =="/explore/featured"
|
||||||
@maps = Map.order("name ASC").find_all_by_featured(true)
|
@maps = Map.order("name ASC").find_all_by_featured(true)
|
||||||
@request = "featured"
|
@request = "featured"
|
||||||
|
|
||||||
elsif request.path == "/maps/new"
|
elsif request.path == "/explore/new"
|
||||||
@maps = Map.order("created_at DESC").limit(20)
|
@maps = Map.order("created_at DESC").limit(20)
|
||||||
@request = "new"
|
@request = "new"
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,40 @@
|
||||||
#%>
|
#%>
|
||||||
|
|
||||||
<div class="templates">
|
<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">
|
<script type="text/template" id="topicSearchTemplate">
|
||||||
<div class="result{{rtype}}">
|
<div class="result{{rtype}}">
|
||||||
<div class="topicMetacode">
|
<div class="topicMetacode">
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
<div class="wrapper <%= controller_name == "main" && action_name == "home" ? "homePage" : "" %>" id="wrapper">
|
<div class="wrapper <%= controller_name == "main" && action_name == "home" ? "homePage" : "" %>" id="wrapper">
|
||||||
|
|
||||||
<div class="homeButton">
|
<div class="homeButton">
|
||||||
<a href="/"></a>
|
<a href="<%= root_url %>"></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="sidebarSearch">
|
<div class="sidebarSearch">
|
||||||
|
|
|
@ -101,7 +101,7 @@ $(document).ready(function() {
|
||||||
<div class="mapOrder">
|
<div class="mapOrder">
|
||||||
<span class="displaying">Displaying:</span>
|
<span class="displaying">Displaying:</span>
|
||||||
<div class="whichMaps">
|
<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/active">Recently Active</a> /
|
||||||
<a href="/explore/featured">Featured</a> /
|
<a href="/explore/featured">Featured</a> /
|
||||||
<a href="/explore/new">Newest First</a>
|
<a href="/explore/new">Newest First</a>
|
||||||
|
|
|
@ -17,12 +17,12 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @request != "topic" %>
|
<% 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? %>
|
<% 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 %>
|
<% 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 %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfloat"></div>
|
<div class="clearfloat"></div>
|
||||||
|
|
|
@ -19,9 +19,9 @@ Metamaps::Application.routes.draw do
|
||||||
get :autocomplete_topic, :on => :collection
|
get :autocomplete_topic, :on => :collection
|
||||||
end
|
end
|
||||||
|
|
||||||
match 'maps/active', to: 'maps#index', via: :get, as: :activemaps
|
match 'explore/active', to: 'maps#index', via: :get, as: :activemaps
|
||||||
match 'maps/featured', to: 'maps#index', via: :get, as: :featuredmaps
|
match 'explore/featured', to: 'maps#index', via: :get, as: :featuredmaps
|
||||||
match 'maps/new', to: 'maps#index', via: :get, as: :newmaps
|
match 'explore/new', to: 'maps#index', via: :get, as: :newmaps
|
||||||
match 'maps/mappers/:id', to: 'maps#index', via: :get, as: :usermaps
|
match 'maps/mappers/:id', to: 'maps#index', via: :get, as: :usermaps
|
||||||
match 'maps/topics/:id', to: 'maps#index', via: :get, as: :topicmaps
|
match 'maps/topics/:id', to: 'maps#index', via: :get, as: :topicmaps
|
||||||
resources :maps, except: [:new, :edit]
|
resources :maps, except: [:new, :edit]
|
||||||
|
|
Loading…
Reference in a new issue