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

View file

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

View file

@ -47,8 +47,6 @@ Metamaps.Views.init = function () {
}, },
render: function () { render: function () {
Metamaps.Loading.loader.hide();
var that = this; var that = this;
this.$el.empty(); this.$el.empty();
@ -57,12 +55,18 @@ Metamaps.Views.init = function () {
that.$el.append( view.render().el ); 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 () { handleSuccess: function () {
this.render(); this.render();
}, },
handleError: function () { handleError: function () {
alert('error!'); console.log('error loading maps!'); //TODO
} }
}); });