-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
514 additions
and
297 deletions.
There are no files selected for viewing
135 changes: 72 additions & 63 deletions
135
modules/core/client/controllers/app.client.controller.js
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 |
---|---|---|
@@ -1,82 +1,91 @@ | ||
(function(){ | ||
'use strict'; | ||
|
||
/* | ||
/** | ||
* Application wide view controller | ||
*/ | ||
angular.module('core').controller('AppController', ['$scope', '$rootScope', '$window', '$state', 'Authentication', 'SettingsFactory', 'Languages', | ||
function($scope, $rootScope, $window, $state, Authentication, SettingsFactory, Languages) { | ||
|
||
// ViewModel | ||
var vm = this; | ||
|
||
// Exposed to the view | ||
vm.user = Authentication.user; | ||
vm.appSettings = SettingsFactory.get(); | ||
vm.languageNames = Languages.get('object'); | ||
vm.goHome = goHome; | ||
|
||
// Used as a cache buster with ng-include | ||
// Includes a hash of latest git commit | ||
vm.cacheBust = vm.appSettings.commit || ''; | ||
|
||
/** | ||
* Determine where to direct user from "home" links | ||
*/ | ||
function goHome() { | ||
if(Authentication.user) { | ||
$state.go('search'); | ||
} | ||
else { | ||
$state.go('home'); | ||
} | ||
angular | ||
.module('core') | ||
.controller('AppController', AppController); | ||
|
||
/* @ngInject */ | ||
function AppController($scope, $rootScope, $window, $state, Authentication, SettingsFactory, Languages) { | ||
|
||
// ViewModel | ||
var vm = this; | ||
|
||
// Exposed to the view | ||
vm.user = Authentication.user; | ||
vm.appSettings = SettingsFactory.get(); | ||
vm.languageNames = Languages.get('object'); | ||
vm.goHome = goHome; | ||
|
||
// Used as a cache buster with ng-include | ||
// Includes a hash of latest git commit | ||
vm.cacheBust = vm.appSettings.commit || ''; | ||
|
||
/** | ||
* Determine where to direct user from "home" links | ||
*/ | ||
function goHome() { | ||
if(Authentication.user) { | ||
$state.go('search'); | ||
} | ||
else { | ||
$state.go('home'); | ||
} | ||
} | ||
|
||
// Receive user changes | ||
$scope.$on('userUpdated', function(){ | ||
vm.user = Authentication.user; | ||
}); | ||
/** | ||
* Snif and apply user changes | ||
*/ | ||
$scope.$on('userUpdated', function(){ | ||
vm.user = Authentication.user; | ||
}); | ||
|
||
// Before page change | ||
$scope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) { | ||
/** | ||
* Before page change | ||
*/ | ||
$scope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) { | ||
|
||
// Redirect away from frontpage if user is authenticated | ||
if(toState.name === 'home' && Authentication.user) { | ||
event.preventDefault(); | ||
$state.go('search'); | ||
} | ||
// Redirect away from frontpage if user is authenticated | ||
if(toState.name === 'home' && Authentication.user) { | ||
event.preventDefault(); | ||
$state.go('search'); | ||
} | ||
|
||
// Redirect to login page if no user | ||
if(toState.requiresAuth && !Authentication.user) { | ||
// Cancel stateChange | ||
event.preventDefault(); | ||
// Redirect to login page if no user | ||
if(toState.requiresAuth && !Authentication.user) { | ||
// Cancel stateChange | ||
event.preventDefault(); | ||
|
||
// Save previous state | ||
// See modules/users/client/controllers/authentication.client.controller.js for how they're used | ||
$rootScope.signinState = toState.name; | ||
$rootScope.signinStateParams = toParams; | ||
$state.go('signin-continue', {'continue': true}); | ||
} | ||
// Save previous state | ||
// See modules/users/client/controllers/authentication.client.controller.js for how they're used | ||
$rootScope.signinState = toState.name; | ||
$rootScope.signinStateParams = toParams; | ||
$state.go('signin-continue', {'continue': true}); | ||
} | ||
|
||
}); | ||
}); | ||
|
||
// After page change | ||
$scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) { | ||
/** | ||
* After page change | ||
*/ | ||
$scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) { | ||
|
||
// Reset page scroll on page change | ||
$window.scrollTo(0,0); | ||
// Reset page scroll on page change | ||
$window.scrollTo(0,0); | ||
|
||
// Analytics | ||
if (typeof(ga) === 'function') { | ||
ga('send', 'pageview', { | ||
'page': toState.url, | ||
//'title': '' | ||
}); | ||
} | ||
// Analytics | ||
if (typeof(ga) === 'function') { | ||
ga('send', 'pageview', { | ||
'page': toState.url, | ||
//'title': '' | ||
}); | ||
} | ||
|
||
}); | ||
}); | ||
|
||
} | ||
]); | ||
} | ||
|
||
})(); |
148 changes: 75 additions & 73 deletions
148
modules/core/client/controllers/footer.client.controller.js
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 |
---|---|---|
@@ -1,89 +1,91 @@ | ||
(function(){ | ||
'use strict'; | ||
|
||
angular.module('core').controller('FooterController', ['$scope', | ||
function($scope) { | ||
angular | ||
.module('core') | ||
.controller('FooterController', FooterController); | ||
|
||
// ViewModel | ||
var vm = this; | ||
/* @ngInject */ | ||
function FooterController($scope) { | ||
|
||
// Exposed | ||
vm.isTransparent = false; | ||
vm.isHidden = false; | ||
vm.photoCredits = []; | ||
// ViewModel | ||
var vm = this; | ||
|
||
/* | ||
* Please try to keep this updated while you add/change/remove images from different pages | ||
*/ | ||
var photos = { | ||
// Exposed | ||
vm.isTransparent = false; | ||
vm.isHidden = false; | ||
vm.photoCredits = []; | ||
|
||
'bokehblue': { | ||
'name': 'Sandra', | ||
'url': 'https://www.flickr.com/photos/artfullife/3589991695', | ||
'license': 'CC', | ||
'license_url': 'https://creativecommons.org/licenses/by-sa/2.0/' | ||
}, | ||
'sierranevada': { | ||
'name': 'Simona', | ||
'url': 'http://www.wanderlust.lt', | ||
'license': 'CC', | ||
'license_url': 'http://creativecommons.org/licenses/by-nc-nd/4.0/' | ||
}, | ||
'hitchroad': { | ||
'name': 'Andrew W Bugelli', | ||
'url': 'http://www.containstraces.blogspot.com/' | ||
}, | ||
'forestpath': { | ||
'name': 'Johnson', | ||
'url': 'https://www.flickr.com/photos/54459164@N00/15506455245', | ||
'license': 'CC', | ||
'license_url': 'https://creativecommons.org/licenses/by-nc-sa/2.0/' | ||
}, | ||
'horizonballoon': { | ||
'name': 'Wesley Stanford', | ||
'url': 'http://www.dualhorizons.blogspot.co.uk/' | ||
}, | ||
'rainbowpeople': { | ||
'name': 'Antonio Fulghieri', | ||
'url': 'https://aaoutthere.wordpress.com/', | ||
'license': 'CC', | ||
'license_url': 'http://creativecommons.org/licenses/by-nc-nd/4.0/' | ||
}, | ||
/* | ||
* Please try to keep this updated while you add/change/remove images from different pages | ||
*/ | ||
var photos = { | ||
|
||
}; | ||
'bokehblue': { | ||
'name': 'Sandra', | ||
'url': 'https://www.flickr.com/photos/artfullife/3589991695', | ||
'license': 'CC', | ||
'license_url': 'https://creativecommons.org/licenses/by-sa/2.0/' | ||
}, | ||
'sierranevada': { | ||
'name': 'Simona', | ||
'url': 'http://www.wanderlust.lt', | ||
'license': 'CC', | ||
'license_url': 'http://creativecommons.org/licenses/by-nc-nd/4.0/' | ||
}, | ||
'hitchroad': { | ||
'name': 'Andrew W Bugelli', | ||
'url': 'http://www.containstraces.blogspot.com/' | ||
}, | ||
'forestpath': { | ||
'name': 'Johnson', | ||
'url': 'https://www.flickr.com/photos/54459164@N00/15506455245', | ||
'license': 'CC', | ||
'license_url': 'https://creativecommons.org/licenses/by-nc-sa/2.0/' | ||
}, | ||
'horizonballoon': { | ||
'name': 'Wesley Stanford', | ||
'url': 'http://www.dualhorizons.blogspot.co.uk/' | ||
}, | ||
'rainbowpeople': { | ||
'name': 'Antonio Fulghieri', | ||
'url': 'https://aaoutthere.wordpress.com/', | ||
'license': 'CC', | ||
'license_url': 'http://creativecommons.org/licenses/by-nc-nd/4.0/' | ||
}, | ||
|
||
// Changing footer styles/contents after navigation | ||
$scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams){ | ||
}; | ||
|
||
// Footer is transparent on these pages | ||
vm.isTransparent = (angular.isDefined(toState.footerTransparent) && toState.footerTransparent === true) ? true : false; | ||
// Changing footer styles/contents after navigation | ||
$scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams){ | ||
|
||
// Footer is hidden on these pages | ||
vm.isHidden = (angular.isDefined(toState.footerHidden) && toState.footerHidden === true) ? true : false; | ||
// Footer is transparent on these pages | ||
vm.isTransparent = (angular.isDefined(toState.footerTransparent) && toState.footerTransparent === true) ? true : false; | ||
|
||
// Set photo credits for these pages | ||
if( ['home'].indexOf(toState.name) > -1 ) { | ||
vm.photoCredits = [ photos.rainbowpeople, photos.hitchroad ]; | ||
} | ||
else if( ['forgot', 'signin', 'welcome', 'statistics', 'media'].indexOf(toState.name) > -1 ) { | ||
vm.photoCredits = [ photos.bokehblue ]; | ||
} | ||
else if( ['about'].indexOf(toState.name) > -1 ) { | ||
vm.photoCredits = [ photos.bokehblue, photos.forestpath ]; | ||
} | ||
else if( ['foundation', 'donate', 'donate-help', 'donate-policy'].indexOf(toState.name) > -1 ) { | ||
vm.photoCredits = [ photos.forestpath ]; | ||
} | ||
else if( ['faq'].indexOf(toState.name) > -1 ) { | ||
vm.photoCredits = [ photos.horizonballoon ]; | ||
} | ||
else { | ||
vm.photoCredits = []; | ||
} | ||
// Footer is hidden on these pages | ||
vm.isHidden = (angular.isDefined(toState.footerHidden) && toState.footerHidden === true) ? true : false; | ||
|
||
}); | ||
// Set photo credits for these pages | ||
if( ['home'].indexOf(toState.name) > -1 ) { | ||
vm.photoCredits = [ photos.rainbowpeople, photos.hitchroad ]; | ||
} | ||
else if( ['forgot', 'signin', 'welcome', 'statistics', 'media'].indexOf(toState.name) > -1 ) { | ||
vm.photoCredits = [ photos.bokehblue ]; | ||
} | ||
else if( ['about'].indexOf(toState.name) > -1 ) { | ||
vm.photoCredits = [ photos.bokehblue, photos.forestpath ]; | ||
} | ||
else if( ['foundation', 'donate', 'donate-help', 'donate-policy'].indexOf(toState.name) > -1 ) { | ||
vm.photoCredits = [ photos.forestpath ]; | ||
} | ||
else if( ['faq'].indexOf(toState.name) > -1 ) { | ||
vm.photoCredits = [ photos.horizonballoon ]; | ||
} | ||
else { | ||
vm.photoCredits = []; | ||
} | ||
}); | ||
|
||
} | ||
]); | ||
} | ||
|
||
})(); |
42 changes: 22 additions & 20 deletions
42
modules/core/client/controllers/header.client.controller.js
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 |
---|---|---|
@@ -1,33 +1,35 @@ | ||
(function(){ | ||
'use strict'; | ||
|
||
angular.module('core').controller('HeaderController', ['$scope', '$state', | ||
function($scope, $state) { | ||
angular | ||
.module('core') | ||
.controller('HeaderController', HeaderController); | ||
|
||
// ViewModel | ||
var vm = this; | ||
/* @ngInject */ | ||
function HeaderController($scope, $state) { | ||
|
||
// Exposed | ||
vm.isCollapsed = false; | ||
vm.isHidden = false; | ||
vm.toggleCollapsibleMenu = toggleCollapsibleMenu; | ||
// ViewModel | ||
var vm = this; | ||
|
||
function toggleCollapsibleMenu() { | ||
vm.isCollapsed = !vm.isCollapsed; | ||
} | ||
// Exposed | ||
vm.isCollapsed = false; | ||
vm.isHidden = false; | ||
vm.toggleCollapsibleMenu = toggleCollapsibleMenu; | ||
|
||
// Perform actions at page change | ||
$scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) { | ||
function toggleCollapsibleMenu() { | ||
vm.isCollapsed = !vm.isCollapsed; | ||
} | ||
|
||
// Collapsing the menu after navigation | ||
vm.isCollapsed = false; | ||
// Perform actions at page change | ||
$scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) { | ||
|
||
// Hide header at certain pages | ||
vm.isHidden = (angular.isDefined(toState.headerHidden) && toState.headerHidden === true) ? true : false; | ||
// Collapsing the menu after navigation | ||
vm.isCollapsed = false; | ||
|
||
}); | ||
// Hide header at certain pages | ||
vm.isHidden = (angular.isDefined(toState.headerHidden) && toState.headerHidden === true) ? true : false; | ||
}); | ||
|
||
} | ||
]); | ||
} | ||
|
||
})(); |
Oops, something went wrong.