handle page title and mobile title updates
This commit is contained in:
parent
bc67644ba9
commit
4d3741c3b4
5 changed files with 34 additions and 12 deletions
|
@ -5,7 +5,7 @@
|
||||||
# %>
|
# %>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
<% content_for :title, "Explore My Maps | Metamaps" %>
|
<% content_for :title, "My Maps | Metamaps" %>
|
||||||
<% content_for :mobile_title, "My Maps" %>
|
<% content_for :mobile_title, "My Maps" %>
|
||||||
|
|
||||||
Metamaps.currentPage = "mine";
|
Metamaps.currentPage = "mine";
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
# %>
|
# %>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
<% content_for :title, "Explore Shared Maps | Metamaps" %>
|
<% content_for :title, "Shared Maps | Metamaps" %>
|
||||||
<% content_for :mobile_title, "Shared With Me" %>
|
<% content_for :mobile_title, "Shared With Me" %>
|
||||||
|
|
||||||
Metamaps.currentPage = "shared";
|
Metamaps.currentPage = "shared";
|
||||||
|
|
|
@ -46,7 +46,6 @@ const ReactApp = {
|
||||||
handleUpdate: function(location) {
|
handleUpdate: function(location) {
|
||||||
const self = ReactApp
|
const self = ReactApp
|
||||||
const pathname = this.state.location.pathname
|
const pathname = this.state.location.pathname
|
||||||
// TODO: also handle page title updates
|
|
||||||
switch (pathname.split('/')[1]) {
|
switch (pathname.split('/')[1]) {
|
||||||
case '':
|
case '':
|
||||||
if (Active.Mapper && Active.Mapper.id) {
|
if (Active.Mapper && Active.Mapper.id) {
|
||||||
|
|
|
@ -16,15 +16,37 @@ const ExploreMaps = {
|
||||||
mapper: null,
|
mapper: null,
|
||||||
updateFromPath: function(path) {
|
updateFromPath: function(path) {
|
||||||
const self = ExploreMaps
|
const self = ExploreMaps
|
||||||
const test = path.split('/')[1]
|
const [_unused, generalSection, specificSection, id] = path.split('/')
|
||||||
const section = path.split('/')[2]
|
|
||||||
const id = path.split('/')[3]
|
|
||||||
|
|
||||||
if (test === 'explore') {
|
if (generalSection === 'explore') {
|
||||||
const capitalize = section.charAt(0).toUpperCase() + section.slice(1)
|
const capitalize = specificSection.charAt(0).toUpperCase() + specificSection.slice(1)
|
||||||
self.setCollection(DataModel.Maps[capitalize])
|
self.setCollection(DataModel.Maps[capitalize])
|
||||||
} else if (test === '') {
|
switch (capitalize) {
|
||||||
|
case 'Active':
|
||||||
|
document.title = 'Explore Active Maps | Metamaps'
|
||||||
|
ReactApp.mobileTitle='Recently Active'
|
||||||
|
break
|
||||||
|
case 'Featured':
|
||||||
|
document.title = 'Explore Featured Maps | Metamaps'
|
||||||
|
ReactApp.mobileTitle='Featured Maps'
|
||||||
|
break
|
||||||
|
case 'Starred':
|
||||||
|
document.title = 'Starred Maps | Metamaps'
|
||||||
|
ReactApp.mobileTitle='Starred Maps'
|
||||||
|
break
|
||||||
|
case 'Shared':
|
||||||
|
document.title = 'Shared Maps | Metamaps'
|
||||||
|
ReactApp.mobileTitle='Shared With Me'
|
||||||
|
break
|
||||||
|
case 'Mine':
|
||||||
|
document.title = 'My Maps | Metamaps'
|
||||||
|
ReactApp.mobileTitle = 'My Maps'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} else if (generalSection === '') {
|
||||||
self.setCollection(DataModel.Maps.Active)
|
self.setCollection(DataModel.Maps.Active)
|
||||||
|
document.title = 'Explore Active Maps | Metamaps'
|
||||||
|
ReactApp.mobileTitle='Recently Active'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
|
@ -98,6 +120,8 @@ const ExploreMaps = {
|
||||||
url: '/users/' + self.collection.mapperId + '/details.json',
|
url: '/users/' + self.collection.mapperId + '/details.json',
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
self.mapper = response
|
self.mapper = response
|
||||||
|
document.title = self.mapper.name + ' | Metamaps'
|
||||||
|
ReactApp.mobileTitle = self.mapper.name
|
||||||
self.render()
|
self.render()
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
|
|
|
@ -25,13 +25,12 @@ class App extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
static childContextTypes = {
|
static childContextTypes = {
|
||||||
currentUser: PropTypes.object,
|
|
||||||
location: PropTypes.object
|
location: PropTypes.object
|
||||||
}
|
}
|
||||||
|
|
||||||
getChildContext () {
|
getChildContext () {
|
||||||
const { route, location } = this.props
|
const { location } = this.props
|
||||||
return {currentUser: route.currentUser, location}
|
return {location}
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue