all files / components/welcome/ welcome.controller.js

5.26% Statements 1/19
0% Branches 0/2
0% Functions 0/3
5.26% Lines 1/19
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61                                                                                                                        
angular.module('webmapp')
 
.controller('WelcomeController', function WelcomeController(
    $location,
    $rootScope,
    MapService,
    Model,
    Utils,
    CONFIG,
    $translate
) {
    var vm = {},
        baseUrl = '',
        menuItems = {
            label: 'Welcome',
            top: [
                $translate.instant("Cosa fare"),
                $translate.instant("Percorsi"),
                $translate.instant("Eventi")
            ],
            bottom: [
                $translate.instant("Card"),
                $translate.instant("Offerte")
            ]
        },
        menuMap = Model.getMenuMap();
 
    // console.log(menuMap)
 
    if (document.getElementsByTagName('base').length > 0) {
        baseUrl = document.getElementsByTagName('base')[0].href;
        baseUrl = baseUrl.slice(0, -1);
    }
 
    vm.goTo = Utils.goTo;
    vm.menuItems = {};
    vm.menuItems.top = {};
    vm.menuItems.bottom = {};
 
    for (var i in menuItems.top) {
        vm.menuItems.top[menuItems.top[i]] = menuMap[menuItems.top[i]];
        vm.menuItems.top[menuItems.top[i]].url = Model.buildItemUrl(menuMap[menuItems.top[i]]);
    }
    // for (var j in menuItems.bottom) {
    //     vm.menuItems.bottom[menuItems.bottom[i]] = menuMap[menuItems.bottom[i]];
    //     vm.menuItems.bottom[menuItems.bottom[i]].url = Model.buildItemUrl(menuMap[menuItems.bottom[i]]);
    // }
 
    vm.goToSubLayer = function(path, event) {
        event.stopPropagation();
        event.preventDefault();
 
        Utils.goTo(path);
    };
 
    vm.openLoginOrRegistration = function(isRegistration) {
        $rootScope.showLogin(isRegistration);
    };
 
    return vm;
});