/**
 * Created by fran lopez on 8/12/15.
 */

    /**
     * Javascript file to define the AngularJS application connected to the Express
     * application
     */

    /**
     * Definition of AngularJS particular modules to use.
     */

    angular.module('index', []);
    angular.module('films', []);
    angular.module('filmTrailers', []);
    angular.module('filmImages', []);
    angular.module('filmReviews', []);
    angular.module('tvSeries', []);
    angular.module('tvSerieTrailers', []);
    angular.module('tvSerieImages', []);
    angular.module('tvSerieReviews', []);
    angular.module('books', []);
    angular.module('bookImages', []);
    angular.module('bookReviews', []);

    /**
     * The variable "mainApplicationModuleName" contain the main application's
     * module name. The variable "mainApplicationModule" creates the main
     * application module using the "angular.module()" method. The second
     * parameter is an array with AngularJS modules as dependencies of the
     * "mainApplicationModule" module. These modules are
     * "ngResource", "ngRoute", "index", "films", "filmTrailers",
     * "filmImages", "filmReviews", "tvSeries", "books", "bookImages"
     * and "bookReviews".
     *
     * The "door3.css" dependency, is a particular dependency, necessary for
     * third party AngularJS module called "angular-css". Is used to include
     * stylesheet per AngularJS view.
     */

    var mainApplicationModuleName   = 'mean';
    var mainApplicationModule       = angular.module(mainApplicationModuleName,
        ['ngResource', 'ngRoute', 'index', 'films', 'filmTrailers',
            'filmImages', 'filmReviews', 'tvSeries', 'tvSerieTrailers',
            'tvSerieImages', 'tvSerieReviews', 'books', 'bookImages',
            'bookReviews', 'door3.css']);

    /**
     * Configuration of AngularJS routing. To mark application routes as single-page
     * application routes, will be necessary a routing scheme called Hashbangs.
     * Hashbangs are implemented by adding an exclamation mark right after the hash
     * sign.
     */

    mainApplicationModule.config(['$locationProvider', function($locationProvider) {
        $locationProvider.hashPrefix('!');
    }]);

    if (window.location.hash === '#_=_')
        window.location.hash = '#!';

    /**
     * Use of the jqLite functionality defined for the angular object to bind a
     * function to the document-ready event. In that function, the
     * "angular.bootstrap() method" is used to initiate a new AngularJS application
     * using the main application module.
     */

    angular.element(document).ready(function() {
        angular.bootstrap(document, [mainApplicationModuleName]);
    });