-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2363 from WikiWatershed/arr/account-page-skelly
Create Account Page Skeleton
- Loading branch information
Showing
12 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"use strict"; | ||
|
||
var App = require('../app'), | ||
views = require('./views'), | ||
models = require('./models'), | ||
router = require('../router').router, | ||
coreUtils= require('../core/utils'); | ||
|
||
var AccountController = { | ||
accountPrepare: function() { | ||
App.rootView.geocodeSearchRegion.empty(); | ||
}, | ||
|
||
account: function() { | ||
showLoginOrAccountView(); | ||
}, | ||
|
||
accountCleanUp: function() { | ||
App.rootView.footerRegion.empty(); | ||
App.showLayerPicker(); | ||
} | ||
}; | ||
|
||
function showAccountView() { | ||
App.rootView.footerRegion.show( | ||
new views.AccountContainerView({ | ||
model: new models.AccountContainerModel() | ||
}) | ||
); | ||
App.rootView.layerPickerRegion.empty(); | ||
|
||
App.state.set('active_page', coreUtils.accountPageTitle); | ||
} | ||
|
||
function showLoginOrAccountView() { | ||
App.user.fetch().always(function() { | ||
if (App.user.get('guest')) { | ||
var loginSuccess = function() { | ||
router.navigate("/account", { trigger: true }); | ||
}; | ||
App.showLoginModal(loginSuccess); | ||
// Until the user has logged in, show the main page | ||
router.navigate("/", { trigger: true }); | ||
} else { | ||
showAccountView(); | ||
} | ||
}); | ||
} | ||
|
||
module.exports = { | ||
AccountController: AccountController | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"use strict"; | ||
|
||
var Backbone = require('../../shim/backbone'); | ||
|
||
var ACCOUNT = 'account'; | ||
var PROFILE = 'profile'; | ||
|
||
var AccountContainerModel = Backbone.Model.extend({ | ||
defaults: { | ||
active_page: PROFILE | ||
} | ||
}); | ||
|
||
module.exports = { | ||
ACCOUNT: ACCOUNT, | ||
PROFILE: PROFILE, | ||
AccountContainerModel: AccountContainerModel | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h3>Account</h3> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<div id="account-container"> | ||
<div class="page-toggle-column"> | ||
<button | ||
class="page-toggle-button {{'active' if active_page == 'profile' }}" | ||
data-action="viewprofile" | ||
> | ||
Profile | ||
</button> | ||
<button | ||
class="page-toggle-button {{'active' if active_page == 'account' }}" | ||
data-action="viewaccount" | ||
> | ||
Account | ||
</button> | ||
</div> | ||
<div class="account-page-column"> | ||
<div class="account-page-container"></div> | ||
</div> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h3>Profile</h3> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
"use strict"; | ||
|
||
var Marionette = require('../../shim/backbone.marionette'), | ||
models = require('./models'), | ||
containerTmpl = require('./templates/container.html'), | ||
profileTmpl = require('./templates/profile.html'), | ||
accountTmpl = require('./templates/account.html'); | ||
|
||
var ProfileView = Marionette.ItemView.extend({ | ||
template: profileTmpl | ||
}); | ||
|
||
var AccountView = Marionette.ItemView.extend({ | ||
template: accountTmpl | ||
}); | ||
|
||
var AccountContainerView = Marionette.LayoutView.extend({ | ||
// model AccountContainerModel | ||
|
||
template: containerTmpl, | ||
|
||
ui: { | ||
profile: '[data-action="viewprofile"]', | ||
account: '[data-action="viewaccount"]' | ||
}, | ||
|
||
events: { | ||
'click @ui.profile': 'viewProfile', | ||
'click @ui.account': 'viewAccount' | ||
}, | ||
|
||
modelEvents: { | ||
'change:active_page': 'render' | ||
}, | ||
|
||
regions: { | ||
infoContainer: '.account-page-container' | ||
}, | ||
|
||
showActivePage: function() { | ||
var activePage = this.model.get('active_page'); | ||
|
||
switch(activePage) { | ||
case models.PROFILE: | ||
this.infoContainer.show(new ProfileView()); | ||
break; | ||
case models.ACCOUNT: | ||
this.infoContainer.show(new AccountView()); | ||
break; | ||
default: | ||
console.error("Account page, ", activePage, | ||
", is not supported."); | ||
} | ||
}, | ||
|
||
onRender: function() { | ||
this.showActivePage(); | ||
}, | ||
|
||
viewProfile: function() { | ||
this.model.set('active_page', models.PROFILE); | ||
}, | ||
|
||
viewAccount: function() { | ||
this.model.set('active_page', models.ACCOUNT); | ||
} | ||
}); | ||
|
||
module.exports = { | ||
AccountContainerView: AccountContainerView | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#account-container { | ||
padding: 2em; | ||
display: flex; | ||
flex-direction: row; | ||
position: absolute; | ||
top: 44px; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
z-index: 100; | ||
background-color: #eceff1; | ||
transition: 0.3s ease left, 0.3s ease right; | ||
|
||
> .page-toggle-column { | ||
width: 100px; | ||
} | ||
|
||
> .account-page-column { | ||
flex-grow: 1; | ||
} | ||
} | ||
|
||
#account-container .page-toggle-button { | ||
background: none; | ||
border: none; | ||
display: block; | ||
font-size: $font-size-h4; | ||
font-weight: lighter; | ||
|
||
&.active { | ||
font-weight: bolder; | ||
color: $brand-primary; | ||
} | ||
} | ||
|
||
#account-container .account-page-container { | ||
background: $paper; | ||
padding: 2rem; | ||
box-sizing: content-box; | ||
box-shadow: 1px 1px 1px 0px rgba(0, 0, 0, 0.5); | ||
margin-left: 8em; | ||
max-width: 700px; | ||
} |