Personal portfolio website for Regina Carvalho. Built with Famous.js library.

navigation.js 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. 'use strict';
  2. /**
  3. * @ngdoc function
  4. * @name domainManagerApp.controller:AboutCtrl
  5. * @description
  6. * # AboutCtrl
  7. * Controller of the domainManagerApp
  8. */
  9. angular.module('goApp.navigation', ['famous.angular', 'ngRoute', 'ngFx', 'ngAnimate', 'goApp.data'])
  10. .controller('NavigationController',['$scope', '$rootScope', '$famous', '$timeline', '$http', '$location', '$route', '$timeout', 'Data', function ($scope, $rootScope, $famous, $timeline, $http, $location, $route, $timeout, Data) {
  11. $rootScope.$on('data:loaded', function(data) {
  12. if(!$scope.$$phase) {
  13. $scope.$apply(function(){
  14. $scope.navigation = Data.get();
  15. });
  16. }
  17. });
  18. $http({
  19. method: 'GET',
  20. url: 'scripts/data.json'
  21. }).success(function(data) {
  22. $timeout(function(){
  23. $scope.navigation = data.navigation;
  24. },500);
  25. });
  26. $scope.subNavigation = []
  27. $scope.sub2Navigation = []
  28. $scope.last_click = ""
  29. $scope.last_click2 = ""
  30. $scope.btnNavclick = function(index){
  31. if($scope.navigation[index].link == 'submenu') {
  32. if($scope.last_click != $scope.navigation[index].title){
  33. console.log("Opening submenu: " + $scope.navigation[index].title)
  34. $scope.sub2Navigation = [];
  35. $scope.subNavigation = $scope.navigation[index].submenu;
  36. } else if ($scope.last_click == $scope.navigation[index].title && $scope.subNavigation.length == 0) {
  37. $scope.subNavigation = $scope.navigation[index].submenu;
  38. console.log("Opening submenu: " + $scope.navigation[index].title)
  39. } else {
  40. $scope.subNavigation = [];
  41. $scope.sub2Navigation = [];
  42. console.log("Closing submenu: " + $scope.navigation[index].title)
  43. }
  44. $scope.last_click = $scope.navigation[index].title
  45. } else {
  46. console.log("> Redirecting to page " + $scope.navigation[index].link)
  47. $location.path($scope.navigation[index].link);
  48. }
  49. }
  50. $scope.btnSubNavclick = function(index){
  51. if($scope.subNavigation[index].link == "submenu") {
  52. if($scope.last_click2 != $scope.subNavigation[index].title){
  53. $scope.sub2Navigation = [];
  54. $scope.sub2Navigation = $scope.subNavigation[index].submenu;
  55. } else if ($scope.last_click2 == $scope.subNavigation[index].title && $scope.sub2Navigation.length == 0){
  56. $scope.sub2Navigation = $scope.subNavigation[index].submenu;
  57. console.log("Opening submenu: " + $scope.subNavigation[index].title)
  58. } else {
  59. $scope.sub2Navigation = [];
  60. console.log("Closing submenu: " + $scope.subNavigation[index].title)
  61. }
  62. $scope.last_click2 = $scope.subNavigation[index].title
  63. } else {
  64. console.log("> Redirecting to page " + $scope.subNavigation[index].link)
  65. $location.path($scope.subNavigation[index].link);
  66. }
  67. }
  68. $scope.btnSub2Navclick = function(index) {
  69. if($scope.sub2Navigation[index].link != "submenu") {
  70. console.log("> Redirecting to page " + $scope.sub2Navigation[index].link)
  71. $location.path($scope.sub2Navigation[index].link);
  72. } else {
  73. console.log("* Error: Only 2 levels of submenu allowed.")
  74. }
  75. }
  76. }]);