|
/**
* @ngdoc function
* @name domainManagerApp.controller:AboutCtrl
* @description
* # AboutCtrl
* Controller of the domainManagerApp
*/
angular.module('goApp.navigation', ['famous.angular', 'ngRoute', 'ngFx', 'ngAnimate', 'goApp.data'])
.controller('NavigationController',['$scope', '$rootScope', '$famous', '$timeline', '$http', '$location', '$route', '$timeout', 'Data', '$mixpanel', function ($scope, $rootScope, $famous, $timeline, $http, $location, $route, $timeout, Data, $mixpanel) {
'use strict';
$mixpanel.track('Index View');
$rootScope.$on('background:loaded', function() {
if(!$scope.$$phase) {
$scope.$apply(function(){
$scope.navigation = Data.getNavigation();
});
} else {
$scope.navigation = Data.getNavigation();
}
});
$scope.subNavigation = [];
$scope.sub2Navigation = [];
$scope.last_click = "";
$scope.last_click2 = "";
$scope.hoverLink = function(index) {
$rootScope.$broadcast('change-bg-video', index);
};
$scope.leaveLink = function() {
$rootScope.$broadcast('change-bg-video', 0);
};
$scope.btnNavclick = function(index){
if($scope.navigation[index].link == 'submenu') {
if($scope.last_click != $scope.navigation[index].title){
console.log("Opening submenu: " + $scope.navigation[index].title);
$scope.sub2Navigation = [];
$scope.subNavigation = $scope.navigation[index].submenu;
} else if ($scope.last_click === $scope.navigation[index].title && $scope.subNavigation.length === 0) {
$scope.subNavigation = $scope.navigation[index].submenu;
console.log("Opening submenu: " + $scope.navigation[index].title);
} else {
$scope.subNavigation = [];
$scope.sub2Navigation = [];
console.log("Closing submenu: " + $scope.navigation[index].title);
}
$scope.last_click = $scope.navigation[index].title;
} else {
console.log("> Redirecting to page " + $scope.navigation[index].link);
$location.path($scope.navigation[index].link);
}
};
$scope.btnSubNavclick = function(index){
if($scope.subNavigation[index].link == "submenu") {
if($scope.last_click2 != $scope.subNavigation[index].title){
$scope.sub2Navigation = [];
$scope.sub2Navigation = $scope.subNavigation[index].submenu;
} else if ($scope.last_click2 === $scope.subNavigation[index].title && $scope.sub2Navigation.length === 0){
$scope.sub2Navigation = $scope.subNavigation[index].submenu;
console.log("Opening submenu: " + $scope.subNavigation[index].title);
} else {
$scope.sub2Navigation = [];
console.log("Closing submenu: " + $scope.subNavigation[index].title);
}
$scope.last_click2 = $scope.subNavigation[index].title;
} else {
console.log("> Redirecting to page " + $scope.subNavigation[index].link);
$location.path($scope.subNavigation[index].link);
}
};
$scope.btnSub2Navclick = function(index) {
if($scope.sub2Navigation[index].link != "submenu") {
console.log("> Redirecting to page " + $scope.sub2Navigation[index].link);
$location.path($scope.sub2Navigation[index].link);
} else {
console.log("* Error: Only 2 levels of submenu allowed.");
}
};
}]);
|