12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- 'use strict';
- * @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', function ($scope, $rootScope, $famous, $timeline, $http, $location, $route, $timeout, Data) {
- $rootScope.$on('data:loaded', function(data) {
- if(!$scope.$$phase) {
- $scope.$apply(function(){
- $scope.navigation = Data.get();
- });
- }
- });
- $http({
- method: 'GET',
- url: 'scripts/data.json'
- }).success(function(data) {
- $timeout(function(){
- $scope.navigation = data.navigation;
- },500);
- });
- $scope.subNavigation = []
- $scope.sub2Navigation = []
- $scope.last_click = ""
- $scope.last_click2 = ""
- $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.")
- }
- }
- }]);
|