'use strict';

/**
 * Navigation modules provides services for navigation.
 */

var NavigationService = angular.module('navigation.services', [
])
    .service('NavigationService', [
        '$http',
        '$q',
        function ($http, $q) {
            var main = function (key) {
                var deferred = $q.defer();
                if (!key) key = 'main';

                deferred.resolve(data[key]);
                return deferred.promise;
            };

            var find = function(items, name) {
                for (var i = 0; i < items.length; i++) {
                    if (items[i].name == name)
                        return items[i];
                }
                return null;
            };

            var language = function (key) {
                var deferred = $q.defer();
                if (!key) key = 'main';

                deferred.resolve(jezici[key]);
                return deferred.promise;
            };

            var data = {
                main: [
                    { name: 'dashboard', title: 'Почетна', cssClass: 'dashboard' },
                    {
                        name: 'pages', title: 'Странице', cssClass: 'pages',
                    },
                    {
                        name: 'content',
                        title: 'Садржаји',
                        cssClass: 'content',
                        items: [
                            { name: 'contents', title: 'Садржаји', cssClass: 'generic' },
                            { name: 'articles', title: 'Вијести', cssClass: 'articles' },
                            { name: 'blogs', title: 'FAQ', cssClass: 'blogs' },
                            { name: 'events', title: 'Најаве', cssClass: 'events' },
                            { name: 'polls', title: 'Анкете', cssClass: 'polls' },
                            { name: 'classifications/category', title: 'Категорије', cssClass: 'classifications' },
                            { name: 'classifications/tag', title: 'Тагови', cssClass: 'classifications' },
                            { name: 'classifications/team', title: 'Тимови', cssClass: 'classifications' },
                            { name: 'classifications', title: 'Групе', cssClass: 'classifications' }
                        ]
                    },
                    {
                        name: 'media',
                        title: 'Медији',
                        cssClass: 'media',
                        items: [

                            { name: 'glibrarystype', title: 'Типови докумената', cssClass: 'glibrarystype' },
                            { name: 'images', title: 'Слике', cssClass: 'images' },
                            { name: 'eimages', title: 'Акредитације', cssClass: 'images' },
                            { name: 'gimages', title: 'Галерије', cssClass: 'images' },
                            { name: 'documents', title: 'Документи', cssClass: 'documents' },
                            { name: 'videos', title: 'Аудио-Видео', cssClass: 'videos' }

                        ]
                    },
                  
                    {
                        name: 'karta',
                        title: 'Karta',
                        cssClass: 'karta',
                        items: [
                              { name: 'karta', title: 'Локације', cssClass: 'images' }
                        ]
                    },
                    { name: 'users', title: 'Корисници', cssClass: 'users' },
                    { name: 'newsletters', title: 'Вијест/Примаоци', cssClass: 'sales' },
                    { name: 'settings', title: 'Поставке система', cssClass: 'settings' }
                ]
            };
            var jezici = {
                main: [
                    { name: 'en', title: 'Engleski', cssClass: 'engleski' },
                    { name: 'sr', title: 'Latinica', cssClass: 'latinica' },
                    { name: 'de', title: 'Njemacki', cssClass: 'njemacki' }
                ]
            };

            return {
                main: main,
                find: find,
                language: language
            };
        }
    ]);