improved explore maps pages

This commit is contained in:
Connor Turland 2014-08-11 22:31:28 -04:00
parent 3be9dcfd74
commit 278b6213bb
3 changed files with 23 additions and 16 deletions

View file

@ -14,15 +14,16 @@ Metamaps.Backbone.Map = Backbone.Model.extend({
},
fetchContained: function () {
var bb = Metamaps.Backbone;
var that = this;
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));
that.set('mappers', new bb.MapperCollection(data.mappers));
that.set('topics', new bb.TopicCollection(data.topics));
that.set('synapses', new bb.SynapseCollection(data.synapses));
that.set('mappings', new bb.MappingCollection(data.mappings));
}
$.ajax({
url: "/maps/" + this.id + "/contains",
url: "/maps/" + this.id + "/contains.json",
success: start,
async: false
});
@ -78,10 +79,17 @@ Metamaps.Backbone.MapsCollection = Backbone.Collection.extend({
comparator: function (a, b) {
a = a.get(this.sortBy);
b = b.get(this.sortBy);
var temp;
if (this.sortBy === 'name') {
a = a ? a.toLowerCase() : "";
b = b ? b.toLowerCase() : "";
}
else {
// this is for updated_at and created_at
temp = a;
a = b;
b = temp;
}
return a > b ? 1 : a < b ? -1 : 0;
},
getMaps: function () {

View file

@ -52,15 +52,14 @@
Metamaps.GlobalUI.Search.close(0, true);
$('.mapsWrapper').fadeOut(300);
setTimeout(function(){
Metamaps.Router.navigate("");
}, 500);
}
Metamaps.Famous.viz.hide();
Metamaps.Active.Map = null;
Metamaps.Active.Topic = null;
setTimeout(function(){
Metamaps.Router.navigate("");
}, 500);
},
explore: function (section) {
@ -95,10 +94,6 @@
Metamaps.Famous.viz.hide();
Metamaps.Active.Map = null;
Metamaps.Active.Topic = null;
setTimeout(function(){
Metamaps.Router.navigate("/explore/" + section);
}, 500);
},
maps: function (id) {

View file

@ -47,8 +47,6 @@ Metamaps.Views.init = function () {
},
render: function () {
Metamaps.Loading.loader.hide();
var that = this;
this.$el.empty();
@ -57,12 +55,18 @@ Metamaps.Views.init = function () {
that.$el.append( view.render().el );
});
Metamaps.Loading.loader.hide();
setTimeout(function(){
var path = Metamaps.currentSection == "" ? "" : "/explore/" + Metamaps.currentPage;
Metamaps.Router.navigate(path);
}, 500);
},
handleSuccess: function () {
this.render();
},
handleError: function () {
alert('error!');
console.log('error loading maps!'); //TODO
}
});