'use strict';

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

angular.module('navigation.services', [
])
    .service('NavigationService', [
        '$http',
        '$q',
        'Config',
        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 data = {
                main: [
                    { name: 'dashboard', title: 'Home', cssClass: 'dashboard' },
                    { name: 'pages', title: 'Pages', cssClass: 'pages' },
                    {
                        name: 'content',
                        title: 'Content',
                        cssClass: 'content',
                        items: [
                            { name: 'generic', title: 'Generic', cssClass: 'generic' },
                            { name: 'articles', title: 'Articles', cssClass: 'articles' },
                            { name: 'blogs', title: 'Blogs', cssClass: 'blogs' },
                            { name: 'events', title: 'Events', cssClass: 'events' },
                            { name: 'polls', title: 'Polls', cssClass: 'polls' }
                        ]
                    },
                    {
                        name: 'media',
                        title: 'Media',
                        cssClass: 'media',
                        items: [
                            { name: 'images', title: 'Images', cssClass: 'images' },
                            { name: 'documents', title: 'Documents', cssClass: 'documents' },
                            { name: 'videos', title: 'Videos', cssClass: 'videos' }
                        ]
                    },
                    {
                        name: 'design',
                        title: 'Design',
                        cssClass: 'design',
                        items: [
                            { name: 'templates', title: 'Templejti', cssClass: 'templates' },
                            { name: 'widgets', title: 'Widgeti', cssClass: 'widgets' }
                        ]
                    },
                    { name: 'users', title: 'Users', cssClass: 'users' },
                    { name: 'settings', title: 'Settings', cssClass: 'settings' }
                ]
            };

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