Fix mapper page bugs + other things (#611)

* fix centering of explore headers

* make sure the mobile map title updates

* styling was broken on admin pages

* fixup callbacks when fetching user

* enable loading more
This commit is contained in:
Connor Turland 2016-08-17 10:00:37 -04:00 committed by GitHub
parent 4cb1dfe401
commit c89a6771ea
6 changed files with 32 additions and 9 deletions

View file

@ -157,6 +157,8 @@ Metamaps.Backbone.Map = Backbone.Model.extend({
if (isActiveMap) { if (isActiveMap) {
Metamaps.Map.InfoBox.updateNameDescPerm(this.get('name'), this.get('desc'), this.get('permission')) Metamaps.Map.InfoBox.updateNameDescPerm(this.get('name'), this.get('desc'), this.get('permission'))
this.updateMapWrapper() this.updateMapWrapper()
// mobile menu
$('#header_content').html(this.get('name'))
} }
}, },
updateMapWrapper: function () { updateMapWrapper: function () {

View file

@ -552,6 +552,8 @@ Metamaps.Map.InfoBox = {
var name = $(this).html() var name = $(this).html()
Metamaps.Active.Map.set('name', name) Metamaps.Active.Map.set('name', name)
Metamaps.Active.Map.trigger('saved') Metamaps.Active.Map.trigger('saved')
// mobile menu
$('#header_content').html(name)
}) })
$('.mapInfoDesc .best_in_place_desc').unbind('ajax:success').bind('ajax:success', function () { $('.mapInfoDesc .best_in_place_desc').unbind('ajax:success').bind('ajax:success', function () {

View file

@ -47,9 +47,9 @@
Metamaps.GlobalUI.hideDiv('#yield') Metamaps.GlobalUI.hideDiv('#yield')
Metamaps.Header.changeSection(!!Metamaps.Active.Mapper, 'active') Metamaps.Header.changeSection(!!Metamaps.Active.Mapper, 'active')
//Metamaps.Famous.maps.resetScroll() // sets the scroll back to the top
Metamaps.GlobalUI.showDiv('#exploreMapsHeader') Metamaps.GlobalUI.showDiv('#exploreMapsHeader')
Metamaps.GlobalUI.showDiv('#exploreMaps') Metamaps.GlobalUI.showDiv('#exploreMaps')
$('#exploreMaps').scrollTop(0)
Metamaps.GlobalUI.Search.open() Metamaps.GlobalUI.Search.open()
Metamaps.GlobalUI.Search.lock() Metamaps.GlobalUI.Search.lock()
@ -124,7 +124,7 @@
if (Metamaps.Router.currentPage === 'mapper') { if (Metamaps.Router.currentPage === 'mapper') {
path += '/' + Metamaps.Maps.Mapper.mapperId path += '/' + Metamaps.Maps.Mapper.mapperId
} }
Metamaps.Router.navigate(path) Metamaps.Router.navigate(path)
} }
var navigateTimeout = function () { var navigateTimeout = function () {
@ -147,9 +147,9 @@
Metamaps.GlobalUI.Search.lock() Metamaps.GlobalUI.Search.lock()
Metamaps.GlobalUI.showDiv('#exploreMaps') Metamaps.GlobalUI.showDiv('#exploreMaps')
Metamaps.GlobalUI.showDiv('#exploreMapsHeader') Metamaps.GlobalUI.showDiv('#exploreMapsHeader')
// Metamaps.Famous.maps.resetScroll() // sets scroll back to top $('#exploreMaps').scrollTop(0)
if (id) { if (id) {
Metamaps.Header.fetchUserThenchangeSection(!!Metamaps.Active.Mapper, id) Metamaps.Header.fetchUserThenChangeSection(!!Metamaps.Active.Mapper, id)
} }
else Metamaps.Header.changeSection(!!Metamaps.Active.Mapper, section) else Metamaps.Header.changeSection(!!Metamaps.Active.Mapper, section)
Metamaps.GlobalUI.hideDiv('#yield') Metamaps.GlobalUI.hideDiv('#yield')

View file

@ -57,11 +57,11 @@ Metamaps.Views.init = function () {
this.listenTo(this.collection, 'successOnFetch', this.handleSuccess) this.listenTo(this.collection, 'successOnFetch', this.handleSuccess)
this.listenTo(this.collection, 'errorOnFetch', this.handleError) this.listenTo(this.collection, 'errorOnFetch', this.handleError)
}, },
render: function (mapperObj, cbArg) { render: function (mapperObj, cb) {
var that = this var that = this
if (typeof mapperObj === 'function') { if (typeof mapperObj === 'function') {
var cb = mapperObj cb = mapperObj
mapperObj = null mapperObj = null
} }
@ -80,10 +80,25 @@ Metamaps.Views.init = function () {
that.el.appendChild(view.render().el) that.el.appendChild(view.render().el)
}) })
this.$el.append('<div class="clearfloat"></div>') this.$el.append('<div class="clearfloat"></div>')
if (this.collection.length >= 20 && this.collection.page != "loadedAll") {
this.$el.append('<button class="button loadMore">load more</button>')
this.$el.append('<div class="clearfloat"></div>')
}
$('#exploreMaps').empty().html(this.el) $('#exploreMaps').empty().html(this.el)
this.$el.find('.loadMore').click(that.loadMore.bind(that))
if (cb) cb() if (cb) cb()
Metamaps.Loading.hide() Metamaps.Loading.hide()
}, },
loadMore: function () {
if (this.collection.page != "loadedAll") {
this.collection.getMaps();
}
else {
this.$el.find('.loadMore').hide()
}
},
handleSuccess: function (cb) { handleSuccess: function (cb) {
if (this.collection && this.collection.id === 'mapper') { if (this.collection && this.collection.id === 'mapper') {
this.fetchUserThenRender(cb) this.fetchUserThenRender(cb)

View file

@ -63,7 +63,7 @@
.blackBox { .blackBox {
width: 760px; width: 760px;
margin: 0 auto; margin: 0 auto;
padding: 20px 0 60px 20px; padding: 80px 0 60px 20px;
background: rgba(0, 0, 0, 0.4); background: rgba(0, 0, 0, 0.4);
color: white; color: white;
overflow: hidden; overflow: hidden;

View file

@ -603,6 +603,11 @@
margin-top: 110px; margin-top: 110px;
} }
.button.loadMore {
margin: 10px auto 20px;
display: block;
}
.appsPage #exploreMapsHeader { .appsPage #exploreMapsHeader {
display: block; display: block;
} }
@ -626,12 +631,11 @@
height:42px; height:42px;
background-color:#EEEEEE; background-color:#EEEEEE;
box-shadow: 0px 3px 3px rgba(0,0,0,0.23), 0 3px 3px rgba(0,0,0,0.16); box-shadow: 0px 3px 3px rgba(0,0,0,0.23), 0 3px 3px rgba(0,0,0,0.16);
text-align: center;
} }
.exploreMapsCenter { .exploreMapsCenter {
margin: 0 auto;
display: block; display: block;
width: 419px;
} }
.exploreMapsButton { .exploreMapsButton {