<commit_before>define(['app', 'underscore', 'providers/extended-route', 'js/support'], function(app, _) { 'use strict';

    app.config(['extendedRouteProvider', '$locationProvider', function($routeProvider, $locationProvider) {

        $locationProvider.html5Mode(true);
        $locationProvider.hashPrefix('!');

        $routeProvider.
            when('/',                                         { templateUrl: 'views/index.html',                             resolveController: true,                                 resolveUser: true }).
            when('/database/',                                { templateUrl: 'views/database/index.html',                    resolveController: true,                                 resolveUser: true }).
            when('/database/countries/',                      { templateUrl: 'views/database/countries.html',                       controller: LEGACY_InnerPageController,           resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities']) } }).
            when('/database/countries/:code',                 { templateUrl: 'views/database/country.html',                         controller: LEGACY_InnerPageController,           resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities']) } }).
            when('/database/record',                          { templateUrl: 'views/database/record.html',                          controller: LEGACY_InnerPageController,           resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities', 'utilities/km-workflows', 'utilities/km-storage', 'directives/forms/form-controls', 'leaflet-directive']) } }).

            when('/management/',                              { templateUrl: 'views/management/register.html',                      controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities', 'utilities/km-workflows', 'utilities/km-storage']) } }).
            when('/management/register',                      { redirectTo:  '/management/' }).
            when('/management/requests',                      { templateUrl: 'views/management/index.html',                         controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities', 'utilities/km-workflows', 'utilities/km-storage']) } }).
            when('/management/national-reporting/:schema?',   { templateUrl: 'views/management/national-reporting.html',            controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities', 'utilities/km-workflows', 'utilities/km-storage']) } }).
            when('/management/my-records/:schema?',           { templateUrl: 'views/management/my-records.html',                    controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities', 'utilities/km-workflows', 'utilities/km-storage']) } }).
            when('/management/list/:schema?',                 { templateUrl: 'views/management/record-list.html',                   controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities', 'utilities/km-workflows', 'utilities/km-storage']) } }).
            when('/management/my-drafts',                     { templateUrl: 'views/management/my-drafts.html',                     controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities', 'utilities/km-workflows', 'utilities/km-storage']) } }).

            when('/management/tasks',                         { templateUrl: 'views/management/tasks/tasks.html',                   controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities']) } }).
            when('/management/tasks/:id',                     { templateUrl: 'views/management/tasks/tasks-id.html',                controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities']) } }).
            when('/management/tasks/:id/:activity',           { templateUrl: 'views/management/tasks/tasks-id-activity.html',       controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities']) } }).

            when('/management/signin',                        { templateUrl: '/app/views/management/signin.html',                 resolveController: true, resolveUser: true }).

        //  when('/management/meetings',                          { templateUrl: 'views/management/meetings/index.html',                 resolveController: true, resolveUser: true }).
        //  when('/management/meetings/:meetingId/documents',     { templateUrl: 'views/management/meetings/documents/index.html',       resolveController: true, resolveUser: true }).
        //  when('/management/meetings/:meetingId/documents/:id', { templateUrl: 'views/management/meetings/documents/document-id.html', resolveController: true, resolveUser: true }).

            when('/management/edit/aichiTarget',              { templateUrl: 'views/management/edit/aichi-target.html',             controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/caseStudy',                { templateUrl: 'views/management/edit/case-study.html',               controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/caseStudyHwb',             { templateUrl: 'views/management/edit/case-study-hwb.html',           controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/contact',                  { templateUrl: 'views/management/edit/contact.html',                  controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/database',                 { templateUrl: 'views/management/edit/database.html',                 controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/implementationActivity',   { templateUrl: 'views/management/edit/implementationActivity.html',   controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/marineEbsa',               { templateUrl: 'views/management/edit/marine-ebsa.html',              controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls', 'leaflet-directive']) } }).
            when('/management/edit/nationalIndicator',        { templateUrl: 'views/management/edit/nationalIndicator.html',        controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/nationalReport',           { templateUrl: 'views/management/edit/nationalReport.html',           controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/nationalSupportTool',      { templateUrl: 'views/management/edit/nationalSupportTool.html',      controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/nationalTarget',           { templateUrl: 'views/management/edit/nationalTarget.html',           controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/organization',             { templateUrl: 'views/management/edit/organization.html',             controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/progressAssessment',       { templateUrl: 'views/management/edit/progressAssessment.html',       controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/resource',                 { templateUrl: 'views/management/edit/resource.html',                 controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/resourceMobilisation',     { templateUrl: 'views/management/edit/resource-mobilisation.html',    controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/strategicPlanIndicator',   { templateUrl: 'views/management/edit/strategic-plan-indicator.html', controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).

            when('/about/',                                   { templateUrl: 'views/about.html',                                    controller: LEGACY_InnerPageController,           resolveUser: true, resolve : { dependencies : legacyResolver(['utilities/km-utilities']) } }).
            when('/network/',                                 { templateUrl: 'views/404.html',                                      controller: LEGACY_InnerPageController,           resolveUser: true, resolve : { dependencies : legacyResolver(['utilities/km-utilities']) } }).
            when('/resources/',                               { templateUrl: 'views/404.html',                                      controller: LEGACY_InnerPageController,           resolveUser: true, resolve : { dependencies : legacyResolver(['utilities/km-utilities']) } }).

            when('/help/404',                                 { templateUrl: 'views/404.html',                                      controller: LEGACY_InnerPageController,           resolveUser: true, resolve : { dependencies : legacyResolver(['utilities/km-utilities']) } }).
            when('/help/403',                                 { templateUrl: 'views/403.html',                                      controller: LEGACY_InnerPageController,           resolveUser: true, resolve : { dependencies : legacyResolver(['utilities/km-utilities']) } }).

            otherwise({ redirectTo: '/help/404' });

    }]);

    //============================================================
    //
    //
    //============================================================
    function securize(roles)
    {
        return ["$location", "authentication", "siteMapUrls", function ($location, authentication, siteMapUrls) {

            return authentication.getUser().then(function (user) {

                if (!user.isAuthenticated) {

                    console.log("securize: force sign in");

                    if (!$location.search().returnUrl)
                        $location.search({ returnUrl: $location.url() });

                    $location.path(siteMapUrls.user.signIn);

                }
                else if (roles && !_.isEmpty(roles) && _.isEmpty(_.intersection(roles, user.roles))) {

                    console.log("securize: not authorized");

                    $location.search({ path: $location.url() });
                    $location.path(siteMapUrls.errors.notAuthorized);
                }

                return user;
            });
        }];
    }

    //============================================================
    //
    //
    //============================================================
    function legacyResolver(deps)
    {
        return ['$q', function($q) {

            var deferred = $q.defer();

            require(deps, function () {
                deferred.resolve();
            });

            return deferred.promise;
        }];
    }

    ////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////

    //============================================================
    //
    //
    //============================================================
    function LEGACY_InnerPageController($rootScope, $scope, $route, $location, user) {

        $rootScope.homePage = false;
        $rootScope.userGovernment = user.government;
        $rootScope.portal = 'database';
        $rootScope.navigation = [
            { url: '/database/', title: 'Search' },
            { url: '/database/countries/', title: 'Parties and Country Profiles' }
        ];

        var subMenu = '';   // use ng-breadcrumbs instead
        switch ($location.path()) {
            case '/database/': {
                subMenu = 'Search';  // use ng-breadcrumbs instead
                break;
            }
            case '/database/countries/': {
                subMenu = 'Parties and Country Profiles';  // use ng-breadcrumbs instead
                break;
            }
            default: subMenu = '';  // use ng-breadcrumbs instead
        }

        $rootScope.navigationTree = {
            mainMenu: 'Finding Information', subMenu: subMenu   // use ng-breadcrumbs instead
        };
    }
    LEGACY_InnerPageController.$inject = ['$rootScope', '$scope', '$route', '$location', 'user'];

    //============================================================
    //
    //
    //============================================================
    function LEGACY_ManagementPageController($rootScope, $scope, $route, $location, siteMapUrls, navigation, user) {

        $rootScope.homePage = false;
        $rootScope.userGovernment = user.government;
        $rootScope.portal = 'management';
        $rootScope.navigation = [
        { url: '/management/',           title: 'My Dashboard' },
        { url: '/management/register',   title: 'Register a new record' },
        { url: '/management/my-records', title: 'Edit a published record' },
        { url: '/management/my-drafts',  title: 'Edit a draft record' },
        ];

        var subMenu = '';  // use ng-breadcrumbs instead

        switch ($location.path()) {
            case '/management/': {
                subMenu = 'My Dashboard';  // use ng-breadcrumbs instead
                break;
            }
            case '/management/register': {
                subMenu = 'Register a new record';  // use ng-breadcrumbs instead
                break;
            }
            case '/management/my-records': {
                subMenu = 'Edit a published record';  // use ng-breadcrumbs instead
                break;
            }
            case '/management/my-drafts': {
                subMenu = 'Edit a draft record';  // use ng-breadcrumbs instead
                break;
            }
            default: subMenu = '';  // use ng-breadcrumbs instead
        }

        $rootScope.navigationTree = {
            mainMenu: 'Registering Information', subMenu: subMenu  // use ng-breadcrumbs instead
        };
    }
    LEGACY_ManagementPageController.$inject = ['$rootScope', '$scope', '$route', '$location', 'siteMapUrls', 'navigation', 'user'];
});
<commit_msg>Prefect home view & search view (for r.js optimizer)<commit_after>define(['app', 'underscore', 'text!views/index.html', 'text!views/database/index.html',  'providers/extended-route', 'js/support'], function(app, _, rootTemplate, searchTemplate) { 'use strict';

    app.config(['extendedRouteProvider', '$locationProvider', function($routeProvider, $locationProvider) {

        $locationProvider.html5Mode(true);
        $locationProvider.hashPrefix('!');

        $routeProvider.
            when('/',                                         { template:    rootTemplate,                                   resolveController: 'views/index',                        resolveUser: true }).
            when('/database/',                                { template:    searchTemplate,                                 resolveController: 'views/database/index',               resolveUser: true }).
            when('/database/countries/',                      { templateUrl: 'views/database/countries.html',                       controller: LEGACY_InnerPageController,           resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities']) } }).
            when('/database/countries/:code',                 { templateUrl: 'views/database/country.html',                         controller: LEGACY_InnerPageController,           resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities']) } }).
            when('/database/record',                          { templateUrl: 'views/database/record.html',                          controller: LEGACY_InnerPageController,           resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities', 'utilities/km-workflows', 'utilities/km-storage', 'directives/forms/form-controls', 'leaflet-directive']) } }).

            when('/management/',                              { templateUrl: 'views/management/register.html',                      controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities', 'utilities/km-workflows', 'utilities/km-storage']) } }).
            when('/management/register',                      { redirectTo:  '/management/' }).
            when('/management/requests',                      { templateUrl: 'views/management/index.html',                         controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities', 'utilities/km-workflows', 'utilities/km-storage']) } }).
            when('/management/national-reporting/:schema?',   { templateUrl: 'views/management/national-reporting.html',            controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities', 'utilities/km-workflows', 'utilities/km-storage']) } }).
            when('/management/my-records/:schema?',           { templateUrl: 'views/management/my-records.html',                    controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities', 'utilities/km-workflows', 'utilities/km-storage']) } }).
            when('/management/list/:schema?',                 { templateUrl: 'views/management/record-list.html',                   controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities', 'utilities/km-workflows', 'utilities/km-storage']) } }).
            when('/management/my-drafts',                     { templateUrl: 'views/management/my-drafts.html',                     controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities', 'utilities/km-workflows', 'utilities/km-storage']) } }).

            when('/management/tasks',                         { templateUrl: 'views/management/tasks/tasks.html',                   controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities']) } }).
            when('/management/tasks/:id',                     { templateUrl: 'views/management/tasks/tasks-id.html',                controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities']) } }).
            when('/management/tasks/:id/:activity',           { templateUrl: 'views/management/tasks/tasks-id-activity.html',       controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['utilities/km-utilities']) } }).

            when('/management/signin',                        { templateUrl: '/app/views/management/signin.html',                 resolveController: true, resolveUser: true }).

        //  when('/management/meetings',                          { templateUrl: 'views/management/meetings/index.html',                 resolveController: true, resolveUser: true }).
        //  when('/management/meetings/:meetingId/documents',     { templateUrl: 'views/management/meetings/documents/index.html',       resolveController: true, resolveUser: true }).
        //  when('/management/meetings/:meetingId/documents/:id', { templateUrl: 'views/management/meetings/documents/document-id.html', resolveController: true, resolveUser: true }).

            when('/management/edit/aichiTarget',              { templateUrl: 'views/management/edit/aichi-target.html',             controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/caseStudy',                { templateUrl: 'views/management/edit/case-study.html',               controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/caseStudyHwb',             { templateUrl: 'views/management/edit/case-study-hwb.html',           controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/contact',                  { templateUrl: 'views/management/edit/contact.html',                  controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/database',                 { templateUrl: 'views/management/edit/database.html',                 controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/implementationActivity',   { templateUrl: 'views/management/edit/implementationActivity.html',   controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/marineEbsa',               { templateUrl: 'views/management/edit/marine-ebsa.html',              controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls', 'leaflet-directive']) } }).
            when('/management/edit/nationalIndicator',        { templateUrl: 'views/management/edit/nationalIndicator.html',        controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/nationalReport',           { templateUrl: 'views/management/edit/nationalReport.html',           controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/nationalSupportTool',      { templateUrl: 'views/management/edit/nationalSupportTool.html',      controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/nationalTarget',           { templateUrl: 'views/management/edit/nationalTarget.html',           controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/organization',             { templateUrl: 'views/management/edit/organization.html',             controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/progressAssessment',       { templateUrl: 'views/management/edit/progressAssessment.html',       controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/resource',                 { templateUrl: 'views/management/edit/resource.html',                 controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/resourceMobilisation',     { templateUrl: 'views/management/edit/resource-mobilisation.html',    controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).
            when('/management/edit/strategicPlanIndicator',   { templateUrl: 'views/management/edit/strategic-plan-indicator.html', controller: LEGACY_ManagementPageController,      resolveUser: true, resolve : { securized : securize(), dependencies : legacyResolver(['chm/services/editFormUtility', 'directives/forms/form-controls']) } }).

            when('/about/',                                   { templateUrl: 'views/about.html',                                    controller: LEGACY_InnerPageController,           resolveUser: true, resolve : { dependencies : legacyResolver(['utilities/km-utilities']) } }).
            when('/network/',                                 { templateUrl: 'views/404.html',                                      controller: LEGACY_InnerPageController,           resolveUser: true, resolve : { dependencies : legacyResolver(['utilities/km-utilities']) } }).
            when('/resources/',                               { templateUrl: 'views/404.html',                                      controller: LEGACY_InnerPageController,           resolveUser: true, resolve : { dependencies : legacyResolver(['utilities/km-utilities']) } }).

            when('/help/404',                                 { templateUrl: 'views/404.html',                                      controller: LEGACY_InnerPageController,           resolveUser: true, resolve : { dependencies : legacyResolver(['utilities/km-utilities']) } }).
            when('/help/403',                                 { templateUrl: 'views/403.html',                                      controller: LEGACY_InnerPageController,           resolveUser: true, resolve : { dependencies : legacyResolver(['utilities/km-utilities']) } }).

            otherwise({ redirectTo: '/help/404' });

    }]);

    //============================================================
    //
    //
    //============================================================
    function securize(roles)
    {
        return ["$location", "authentication", "siteMapUrls", function ($location, authentication, siteMapUrls) {

            return authentication.getUser().then(function (user) {

                if (!user.isAuthenticated) {

                    console.log("securize: force sign in");

                    if (!$location.search().returnUrl)
                        $location.search({ returnUrl: $location.url() });

                    $location.path(siteMapUrls.user.signIn);

                }
                else if (roles && !_.isEmpty(roles) && _.isEmpty(_.intersection(roles, user.roles))) {

                    console.log("securize: not authorized");

                    $location.search({ path: $location.url() });
                    $location.path(siteMapUrls.errors.notAuthorized);
                }

                return user;
            });
        }];
    }

    //============================================================
    //
    //
    //============================================================
    function legacyResolver(deps)
    {
        return ['$q', function($q) {

            var deferred = $q.defer();

            require(deps, function () {
                deferred.resolve();
            });

            return deferred.promise;
        }];
    }

    ////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////

    //============================================================
    //
    //
    //============================================================
    function LEGACY_InnerPageController($rootScope, $scope, $route, $location, user) {

        $rootScope.homePage = false;
        $rootScope.userGovernment = user.government;
        $rootScope.portal = 'database';
        $rootScope.navigation = [
            { url: '/database/', title: 'Search' },
            { url: '/database/countries/', title: 'Parties and Country Profiles' }
        ];

        var subMenu = '';   // use ng-breadcrumbs instead
        switch ($location.path()) {
            case '/database/': {
                subMenu = 'Search';  // use ng-breadcrumbs instead
                break;
            }
            case '/database/countries/': {
                subMenu = 'Parties and Country Profiles';  // use ng-breadcrumbs instead
                break;
            }
            default: subMenu = '';  // use ng-breadcrumbs instead
        }

        $rootScope.navigationTree = {
            mainMenu: 'Finding Information', subMenu: subMenu   // use ng-breadcrumbs instead
        };
    }
    LEGACY_InnerPageController.$inject = ['$rootScope', '$scope', '$route', '$location', 'user'];

    //============================================================
    //
    //
    //============================================================
    function LEGACY_ManagementPageController($rootScope, $scope, $route, $location, siteMapUrls, navigation, user) {

        $rootScope.homePage = false;
        $rootScope.userGovernment = user.government;
        $rootScope.portal = 'management';
        $rootScope.navigation = [
        { url: '/management/',           title: 'My Dashboard' },
        { url: '/management/register',   title: 'Register a new record' },
        { url: '/management/my-records', title: 'Edit a published record' },
        { url: '/management/my-drafts',  title: 'Edit a draft record' },
        ];

        var subMenu = '';  // use ng-breadcrumbs instead

        switch ($location.path()) {
            case '/management/': {
                subMenu = 'My Dashboard';  // use ng-breadcrumbs instead
                break;
            }
            case '/management/register': {
                subMenu = 'Register a new record';  // use ng-breadcrumbs instead
                break;
            }
            case '/management/my-records': {
                subMenu = 'Edit a published record';  // use ng-breadcrumbs instead
                break;
            }
            case '/management/my-drafts': {
                subMenu = 'Edit a draft record';  // use ng-breadcrumbs instead
                break;
            }
            default: subMenu = '';  // use ng-breadcrumbs instead
        }

        $rootScope.navigationTree = {
            mainMenu: 'Registering Information', subMenu: subMenu  // use ng-breadcrumbs instead
        };
    }
    LEGACY_ManagementPageController.$inject = ['$rootScope', '$scope', '$route', '$location', 'siteMapUrls', 'navigation', 'user'];
});
<|endoftext|>


<commit_before><commit_msg>remove unused params, also imports, also<commit_after><|endoftext|>


<commit_before><commit_msg>Create notes with blank text and show note placeholder instead.<commit_after><|endoftext|>


<commit_before>/**
 * Created by loren on 03/11/2017.
 */
$(document).ready(function() {
    indirizzo='../index.php';

    $.post
    (    indirizzo,
        JSON.stringify(
            {
                richiesta: {
                    controller: "CGestione",
                    metodo: "inviaOrario"
                },
                dati: ""
            }
        ),
        function(dati)
        {
            $(".result").html(dati);
            console.log(dati);
            creaTabella(dati);

        },
        "json");

    giorni={
        lun: "Lunedì",
        mar: "Martedì",
        mer: "Mercoledì",
        gio: "Giovedì",
        ven: "Venerdì",
        sab: "Sabato",
        dom: "Domenica"
    };

    function creaTabella(dati)
    {
        testo = "";
        testo = testo + '
';
        for (i in giorni) {

            day=giorni[i];
            ore=dati[day];

            testo = testo + '' +
                '
Mattina
' +
                '
' +
                'dalle' +
                '<input  type="text" name="' + i + '-matt-dalle" class="form-control" id="' + i + '-matt-dalle" value="'+ore.aperturaMattina.substr(0,5)+'">' +
                '
' +
                '
' +
                'alle' +
                '<input  type="text" name="' + i + '-matt-alle" class="form-control" id="' + i + '-matt-alle" value="'+ore.chiusuraMattina.substr(0,5)+'">' +
                '
' +
                '	';
        }
        testo = testo + '
';
        testo = testo + '
';
        for (i in giorni) {
            day=giorni[i];
            ore=dati[day];

            testo = testo + '' +
                '
Pomeriggio
' +
                '
' +
                'dalle' +
                '<input type="text" name="'+ i + '-pom-dalle" class="form-control" id="' + i + '-pom-dalle" value="'+ore.aperturaPomeriggio.substr(0,5)+'">' +
                '
' +
                '
' +
                'alle' +
                '<input type="text" name="' + i + '-pom-alle" class="form-control" id="' + i + '-pom-alle" value="'+ore.chiusuraPomeriggio.substr(0,5)+'">' +
                '
' +
                '	';
        }
        testo = testo + '
';

        $("#tabella").append(testo);

    }

    $("#salva_orari").click(function () {
        dati=FormattaDatiDaInviare();
        $.post
        (       indirizzo,
            JSON.stringify(
                {
                    richiesta: {
                        controller: "CGestione",
                        metodo: "modificaOrario"
                    },
                    dati: dati
                }
            ), function() {

            },
        "json")
    })

    function FormattaDatiDaInviare () {

        dati= new Array();
        for (i in giorni)
        {
            day= {
                    giorno: giorni[i],
                    aperturaMattina: $("#"+i+"-matt-dalle").val(),
                    chiusuraMattina: $("#"+i+"-matt-alle").val(),
                    aperturaPomeriggio: $("#"+i+"-pom-dalle").val(),
                    chiusuraPomeriggio: $("#"+i+"-pom-alle").val()
            };
            dati=dati.concat(day);
            console.log(dati);
        }

        return dati;
    }
});<commit_msg>modificata formattazione dei dati da inviare al server<commit_after>/**
 * Created by loren on 03/11/2017.
 */
$(document).ready(function() {
    indirizzo='../index.php';

    $.post
    (    indirizzo,
        JSON.stringify(
            {
                richiesta: {
                    controller: "CGestione",
                    metodo: "inviaOrario"
                },
                dati: ""
            }
        ),
        function(dati)
        {
            $(".result").html(dati);
            console.log(dati);
            creaTabella(dati);

        },
        "json");

    giorni={
        lun: "Lunedì",
        mar: "Martedì",
        mer: "Mercoledì",
        gio: "Giovedì",
        ven: "Venerdì",
        sab: "Sabato",
        dom: "Domenica"
    };

    function creaTabella(dati)
    {
        testo = "";
        testo = testo + '
';
        for (i in giorni) {

            day=giorni[i];
            ore=dati[day];

            testo = testo + '' +
                '
Mattina
' +
                '
' +
                'dalle' +
                '<input  type="text" name="' + i + '-matt-dalle" class="form-control" id="' + i + '-matt-dalle" value="'+ore.aperturaMattina.substr(0,5)+'">' +
                '
' +
                '
' +
                'alle' +
                '<input  type="text" name="' + i + '-matt-alle" class="form-control" id="' + i + '-matt-alle" value="'+ore.chiusuraMattina.substr(0,5)+'">' +
                '
' +
                '	';
        }
        testo = testo + '
';
        testo = testo + '
';
        for (i in giorni) {
            day=giorni[i];
            ore=dati[day];

            testo = testo + '' +
                '
Pomeriggio
' +
                '
' +
                'dalle' +
                '<input type="text" name="'+ i + '-pom-dalle" class="form-control" id="' + i + '-pom-dalle" value="'+ore.aperturaPomeriggio.substr(0,5)+'">' +
                '
' +
                '
' +
                'alle' +
                '<input type="text" name="' + i + '-pom-alle" class="form-control" id="' + i + '-pom-alle" value="'+ore.chiusuraPomeriggio.substr(0,5)+'">' +
                '
' +
                '	';
        }
        testo = testo + '
';

        $("#tabella").append(testo);

    }

    $("#salva_orari").click(function () {
        dati=FormattaDatiDaInviare();
        $.post
        (       indirizzo,
            JSON.stringify(
                {
                    richiesta: {
                        controller: "CGestione",
                        metodo: "modificaOrario"
                    },
                    dati: dati
                }
            ), function() {

            },
        "json")
    })

    function FormattaDatiDaInviare () {

        dati= new Array();

        for (i in giorni)
        {
            day= {
                    giorno: giorni[i],
                    aperturaMattina: $("#"+i+"-matt-dalle").val()+":00",
                    chiusuraMattina: $("#"+i+"-matt-alle").val()+":00",
                    aperturaPomeriggio: $("#"+i+"-pom-dalle").val()+":00",
                    chiusuraPomeriggio: $("#"+i+"-pom-alle").val()+":00"
            };
            dati[giorni[i]]=day;
            //dati=dati.concat(day);
            console.log(dati);
        }

        return dati;
    }
});<|endoftext|>


<commit_before>/*
 * jQuery Accessible Accordion system, using ARIA
 * Website: https://a11y.nicolas-hoffmann.net/accordion/
 * License MIT: https://github.com/nico3333fr/jquery-accessible-accordion-aria/blob/master/LICENSE
 */
(function ($) {
  'use strict';

  var defaultConfig = {
    headersSelector: '.js-accordion__header',
    panelsSelector: '.js-accordion__panel',
    buttonsSelector: 'button.js-accordion__header',
    button: $('<button></button>', {
      class: 'js-accordion__header',
      type: 'button'
    }),
    buttonSuffixId: '_tab',
    multiselectable: true,
    prefixClass: 'accordion',
    headerSuffixClass: '__title',
    buttonSuffixClass: '__header',
    panelSuffixClass: '__panel',
    direction: 'ltr'
  };

  var Accordion = function ($el, options) {
    this.options = $.extend({}, defaultConfig, options);

    this.$wrapper = $el;
    this.$panels = $(this.options.panelsSelector, this.$wrapper);

    this.initAttributes();
    this.initEvents();
  };

  Accordion.prototype.initAttributes = function () {
    this.$wrapper.attr({
      'role': 'tablist',
      'aria-multiselectable': this.options.multiselectable.toString()
    }).addClass(this.options.prefixClass);

    this.$panels.each($.proxy(function (index, el) {
      var $panel = $(el);
      var $header = $(this.options.headersSelector, $panel);
      var $button = this.options.button.clone().text($header.text());

      $header.attr('tabindex', '0').addClass(this.options.prefixClass + this.options.headerSuffixClass);
      $panel.before($button);

      var panelId = $panel.attr('id') || this.$wrapper.attr('id') + '-' + index;
      var buttonId = panelId + this.options.buttonSuffixId;

      $button.attr({
        'aria-controls': panelId,
        'aria-expanded': 'false',
        'role': 'tab',
        'id': buttonId,
        'tabindex': '-1',
        'aria-selected': 'false'
      }).addClass(this.options.prefixClass + this.options.buttonSuffixClass);

      $panel.attr({
        'aria-labelledby': buttonId,
        'role': 'tabpanel',
        'id': panelId,
        'aria-hidden': 'true'
      }).addClass(this.options.prefixClass + this.options.panelSuffixClass);

      // if opened by default
      if ($panel.attr('data-accordion-opened') === 'true') {
        $button.attr({
          'aria-expanded': 'true',
          'data-accordion-opened': null
        });

        $panel.attr({
          'aria-hidden': 'false'
        });
      }

      // init first one focusable
      if (index === 0) {
        $button.removeAttr('tabindex');
      }
    }, this));

    this.$buttons = $(this.options.buttonsSelector, this.$wrapper);
  };

  Accordion.prototype.initEvents = function () {
    this.$wrapper.on('focus', this.options.buttonsSelector, $.proxy(this.focusButtonEventHandler, this));

    this.$wrapper.on('click', this.options.buttonsSelector, $.proxy(this.clickButtonEventHandler, this));

    this.$wrapper.on('keydown', this.options.buttonsSelector, $.proxy(this.keydownButtonEventHandler, this));

    this.$wrapper.on('keydown', this.options.panelSelector, $.proxy(this.keydownPanelEventHandler, this));
  };

  Accordion.prototype.focusButtonEventHandler = function (e) {
    var $button = $(e.target);

    $(this.options.buttonsSelector, this.$wrapper).attr({
      'tabindex': '-1',
      'aria-selected': 'false'
    });

    $button.attr({
      'aria-selected': 'true',
      'tabindex': null
    });
  };

  Accordion.prototype.clickButtonEventHandler = function (e) {
    var $button = $(e.target);
    var $panel = $('#' + $button.attr('aria-controls'));

    this.$buttons.attr('aria-selected', 'false');
    $button.attr('aria-selected', 'true');

    // opened or closed?
    if ($button.attr('aria-expanded') === 'false') { // closed
      $button.attr('aria-expanded', 'true');
      $panel.attr('aria-hidden', 'false');
    }
    else { // opened
      $button.attr('aria-expanded', 'false');
      $panel.attr('aria-hidden', 'true');
    }

    if (this.options.multiselectable === false) {
      this.$panels.not($panel).attr( 'aria-hidden', 'true');
      this.$buttons.not($button).attr('aria-expanded', 'false');
    }

    setTimeout(function () {
      $button.focus();
    }, 0);

    e.preventDefault();
  };

  Accordion.prototype.keydownButtonEventHandler = function (e) {
    var $button = $(e.target);
    var $firstButton = this.$buttons.first();
    var $lastButton = this.$buttons.last();
    var $prevButton = $button.prevAll(this.options.buttonsSelector).first();
    var $nextButton = $button.nextAll(this.options.buttonsSelector).first();
    var $target = null;

    var k = this.options.direction === 'ltr' ? {
      prev: [38, 37], // up & left
      next: [40, 39], // down & right
      first: 36, // home
      last: 35 // end
    } : {
      prev: [38, 39], // up & left
      next: [40, 37], // down & right
      first: 36, // home
      last: 35 // end
    };

    var allKeyCode = [].concat(k.prev, k.next, k.first, k.last);

    if ($.inArray(e.keyCode, allKeyCode) >= 0 && !e.ctrlKey) {
      this.$buttons.attr({
        'tabindex': '-1',
        'aria-selected': 'false'
      });

      if (e.keyCode === 36) {
        $target = $firstButton;
      }
      // strike end in the tab => last tab
      else if (e.keyCode === 35) {
        $target = $lastButton;
      }
      // strike up or left in the tab => previous tab
      else if ($.inArray(e.keyCode, k.prev) >= 0) {
        // if we are on first one, activate last
        $target = $button.is($firstButton) ? $lastButton : $prevButton;
      }
      // strike down or right in the tab => next tab
      else if ($.inArray(e.keyCode, k.next) >= 0) {
        // if we are on last one, activate first
        $target = $button.is($lastButton) ? $firstButton : $nextButton;
      }

      if ($target !== null) {
        this.goToHeader($target);
      }

      e.preventDefault();
    }
  };

  Accordion.prototype.keydownPanelEventHandler = function (e) {
    var $panel = $(e.target);
    var $button = $('#' + $panel.attr('aria-labelledby'));
    var $firstButton = this.$wrapper.find(this.options.buttonsSelector).first();
    var $lastButton = this.$wrapper.find(this.options.buttonsSelector).last();
    var $prevButton = $button.prevAll(this.options.buttonsSelector).first();
    var $nextButton = $button.nextAll(this.options.buttonsSelector).first();
    var $target = null;

    // strike up + ctrl => go to header
    if ( e.keyCode === 38 && e.ctrlKey ) {
      $target = $button;
    }
    // strike pageup + ctrl => go to prev header
    else if ( e.keyCode === 33 && e.ctrlKey ) {
      $target = $button.is($firstButton) ? $lastButton : $prevButton;
    }
    // strike pagedown + ctrl => go to next header
    else if ( e.keyCode === 34 && e.ctrlKey ) {
      $target = $button.is($lastButton) ? $firstButton : $nextButton;
    }

    if ($target !== null) {
      this.goToHeader($target);
    }
  };

  Accordion.prototype.goToHeader = function ($target) {
    if ($target.length !== 1) {
      return;
    }

    $target.attr({
      'aria-selected': 'true',
      'tabindex': null
    });

    setTimeout(function () {
      $target.focus();
    }, 0);
  };

  var PLUGIN = 'accordion';

  $.fn[PLUGIN] = function (params) {
    var options = $.extend({}, $.fn[PLUGIN].defaults, params);

    return this.each(function () {
      var $el = $(this);

      var specificOptions = {
        multiselectable: $el.attr('data-accordion-multiselectable') === 'true' ? true : options.multiselectable,
        prefixClass: typeof($el.attr('data-accordion-prefix-classes')) !== 'undefined' ? $el.attr('data-accordion-prefix-classes') : options.prefixClass,
        direction: $el.closest('[dir="rtl"]').length > 0 ? 'rtl' : options.direction
      };
      specificOptions = $.extend({}, options, specificOptions);

      $el.data[PLUGIN] = new Accordion($el, specificOptions);
    });
  };

  $.fn[PLUGIN].defaults = defaultConfig;

})(window.jQuery);
<commit_msg>Adding support for module loaders.<commit_after>/*
 * jQuery Accessible Accordion system, using ARIA
 * Website: https://a11y.nicolas-hoffmann.net/accordion/
 * License MIT: https://github.com/nico3333fr/jquery-accessible-accordion-aria/blob/master/LICENSE
 */
(function(factory) {
    'use strict';
    if (typeof define === 'function' && define.amd) {
        define(['jquery'], factory);
    } else if (typeof exports !== 'undefined') {
        module.exports = factory(require('jquery'));
    } else {
        factory(jQuery);
    }
}(function ($) {
  'use strict';

  var defaultConfig = {
    headersSelector: '.js-accordion__header',
    panelsSelector: '.js-accordion__panel',
    buttonsSelector: 'button.js-accordion__header',
    button: $('<button></button>', {
      class: 'js-accordion__header',
      type: 'button'
    }),
    buttonSuffixId: '_tab',
    multiselectable: true,
    prefixClass: 'accordion',
    headerSuffixClass: '__title',
    buttonSuffixClass: '__header',
    panelSuffixClass: '__panel',
    direction: 'ltr'
  };

  var Accordion = function ($el, options) {
    this.options = $.extend({}, defaultConfig, options);

    this.$wrapper = $el;
    this.$panels = $(this.options.panelsSelector, this.$wrapper);

    this.initAttributes();
    this.initEvents();
  };

  Accordion.prototype.initAttributes = function () {
    this.$wrapper.attr({
      'role': 'tablist',
      'aria-multiselectable': this.options.multiselectable.toString()
    }).addClass(this.options.prefixClass);

    this.$panels.each($.proxy(function (index, el) {
      var $panel = $(el);
      var $header = $(this.options.headersSelector, $panel);
      var $button = this.options.button.clone().text($header.text());

      $header.attr('tabindex', '0').addClass(this.options.prefixClass + this.options.headerSuffixClass);
      $panel.before($button);

      var panelId = $panel.attr('id') || this.$wrapper.attr('id') + '-' + index;
      var buttonId = panelId + this.options.buttonSuffixId;

      $button.attr({
        'aria-controls': panelId,
        'aria-expanded': 'false',
        'role': 'tab',
        'id': buttonId,
        'tabindex': '-1',
        'aria-selected': 'false'
      }).addClass(this.options.prefixClass + this.options.buttonSuffixClass);

      $panel.attr({
        'aria-labelledby': buttonId,
        'role': 'tabpanel',
        'id': panelId,
        'aria-hidden': 'true'
      }).addClass(this.options.prefixClass + this.options.panelSuffixClass);

      // if opened by default
      if ($panel.attr('data-accordion-opened') === 'true') {
        $button.attr({
          'aria-expanded': 'true',
          'data-accordion-opened': null
        });

        $panel.attr({
          'aria-hidden': 'false'
        });
      }

      // init first one focusable
      if (index === 0) {
        $button.removeAttr('tabindex');
      }
    }, this));

    this.$buttons = $(this.options.buttonsSelector, this.$wrapper);
  };

  Accordion.prototype.initEvents = function () {
    this.$wrapper.on('focus', this.options.buttonsSelector, $.proxy(this.focusButtonEventHandler, this));

    this.$wrapper.on('click', this.options.buttonsSelector, $.proxy(this.clickButtonEventHandler, this));

    this.$wrapper.on('keydown', this.options.buttonsSelector, $.proxy(this.keydownButtonEventHandler, this));

    this.$wrapper.on('keydown', this.options.panelSelector, $.proxy(this.keydownPanelEventHandler, this));
  };

  Accordion.prototype.focusButtonEventHandler = function (e) {
    var $button = $(e.target);

    $(this.options.buttonsSelector, this.$wrapper).attr({
      'tabindex': '-1',
      'aria-selected': 'false'
    });

    $button.attr({
      'aria-selected': 'true',
      'tabindex': null
    });
  };

  Accordion.prototype.clickButtonEventHandler = function (e) {
    var $button = $(e.target);
    var $panel = $('#' + $button.attr('aria-controls'));

    this.$buttons.attr('aria-selected', 'false');
    $button.attr('aria-selected', 'true');

    // opened or closed?
    if ($button.attr('aria-expanded') === 'false') { // closed
      $button.attr('aria-expanded', 'true');
      $panel.attr('aria-hidden', 'false');
    }
    else { // opened
      $button.attr('aria-expanded', 'false');
      $panel.attr('aria-hidden', 'true');
    }

    if (this.options.multiselectable === false) {
      this.$panels.not($panel).attr( 'aria-hidden', 'true');
      this.$buttons.not($button).attr('aria-expanded', 'false');
    }

    setTimeout(function () {
      $button.focus();
    }, 0);

    e.preventDefault();
  };

  Accordion.prototype.keydownButtonEventHandler = function (e) {
    var $button = $(e.target);
    var $firstButton = this.$buttons.first();
    var $lastButton = this.$buttons.last();
    var $prevButton = $button.prevAll(this.options.buttonsSelector).first();
    var $nextButton = $button.nextAll(this.options.buttonsSelector).first();
    var $target = null;

    var k = this.options.direction === 'ltr' ? {
      prev: [38, 37], // up & left
      next: [40, 39], // down & right
      first: 36, // home
      last: 35 // end
    } : {
      prev: [38, 39], // up & left
      next: [40, 37], // down & right
      first: 36, // home
      last: 35 // end
    };

    var allKeyCode = [].concat(k.prev, k.next, k.first, k.last);

    if ($.inArray(e.keyCode, allKeyCode) >= 0 && !e.ctrlKey) {
      this.$buttons.attr({
        'tabindex': '-1',
        'aria-selected': 'false'
      });

      if (e.keyCode === 36) {
        $target = $firstButton;
      }
      // strike end in the tab => last tab
      else if (e.keyCode === 35) {
        $target = $lastButton;
      }
      // strike up or left in the tab => previous tab
      else if ($.inArray(e.keyCode, k.prev) >= 0) {
        // if we are on first one, activate last
        $target = $button.is($firstButton) ? $lastButton : $prevButton;
      }
      // strike down or right in the tab => next tab
      else if ($.inArray(e.keyCode, k.next) >= 0) {
        // if we are on last one, activate first
        $target = $button.is($lastButton) ? $firstButton : $nextButton;
      }

      if ($target !== null) {
        this.goToHeader($target);
      }

      e.preventDefault();
    }
  };

  Accordion.prototype.keydownPanelEventHandler = function (e) {
    var $panel = $(e.target);
    var $button = $('#' + $panel.attr('aria-labelledby'));
    var $firstButton = this.$wrapper.find(this.options.buttonsSelector).first();
    var $lastButton = this.$wrapper.find(this.options.buttonsSelector).last();
    var $prevButton = $button.prevAll(this.options.buttonsSelector).first();
    var $nextButton = $button.nextAll(this.options.buttonsSelector).first();
    var $target = null;

    // strike up + ctrl => go to header
    if ( e.keyCode === 38 && e.ctrlKey ) {
      $target = $button;
    }
    // strike pageup + ctrl => go to prev header
    else if ( e.keyCode === 33 && e.ctrlKey ) {
      $target = $button.is($firstButton) ? $lastButton : $prevButton;
    }
    // strike pagedown + ctrl => go to next header
    else if ( e.keyCode === 34 && e.ctrlKey ) {
      $target = $button.is($lastButton) ? $firstButton : $nextButton;
    }

    if ($target !== null) {
      this.goToHeader($target);
    }
  };

  Accordion.prototype.goToHeader = function ($target) {
    if ($target.length !== 1) {
      return;
    }

    $target.attr({
      'aria-selected': 'true',
      'tabindex': null
    });

    setTimeout(function () {
      $target.focus();
    }, 0);
  };

  var PLUGIN = 'accordion';

  $.fn[PLUGIN] = function (params) {
    var options = $.extend({}, $.fn[PLUGIN].defaults, params);

    return this.each(function () {
      var $el = $(this);

      var specificOptions = {
        multiselectable: $el.attr('data-accordion-multiselectable') === 'true' ? true : options.multiselectable,
        prefixClass: typeof($el.attr('data-accordion-prefix-classes')) !== 'undefined' ? $el.attr('data-accordion-prefix-classes') : options.prefixClass,
        direction: $el.closest('[dir="rtl"]').length > 0 ? 'rtl' : options.direction
      };
      specificOptions = $.extend({}, options, specificOptions);

      $el.data[PLUGIN] = new Accordion($el, specificOptions);
    });
  };

  $.fn[PLUGIN].defaults = defaultConfig;

}));
<|endoftext|>


<commit_before>// Copyright 2018-2019, University of Colorado Boulder

/**
 *
 * @author Michael Kauzmann (PhET Interactive Simulations)
 */

import GeneralKeyboardHelpSection from '../../scenery-phet/js/keyboard/help/GeneralKeyboardHelpSection.js';
import Node from '../../scenery/js/nodes/Node.js';
import joist from './joist.js';

class HomeScreenKeyboardHelpContent extends Node {

  constructor() {
    super( { children: [ new GeneralKeyboardHelpSection() ] } );
  }
}

joist.register( 'HomeScreenKeyboardHelpContent', HomeScreenKeyboardHelpContent );

export default HomeScreenKeyboardHelpContent;<commit_msg>update copyright dates from daily grunt work<commit_after>// Copyright 2020, University of Colorado Boulder

/**
 *
 * @author Michael Kauzmann (PhET Interactive Simulations)
 */

import GeneralKeyboardHelpSection from '../../scenery-phet/js/keyboard/help/GeneralKeyboardHelpSection.js';
import Node from '../../scenery/js/nodes/Node.js';
import joist from './joist.js';

class HomeScreenKeyboardHelpContent extends Node {

  constructor() {
    super( { children: [ new GeneralKeyboardHelpSection() ] } );
  }
}

joist.register( 'HomeScreenKeyboardHelpContent', HomeScreenKeyboardHelpContent );

export default HomeScreenKeyboardHelpContent;<|endoftext|>


<commit_before>define([
    "dojo/Evented", "dojo/_base/declare", "dojo/_base/lang", "dojo/has", "dojo/dom","esri/kernel",
    "dijit/_WidgetBase", "dijit/_TemplatedMixin", "dojo/on",
    "dojo/query", "dijit/registry",
    "dojo/text!application/LanguageSelect/templates/LanguageSelect.html",
    "dojo/i18n!application/nls/LanguageSelect",
    "dijit/form/DropDownButton", "dijit/DropDownMenu", "dijit/MenuItem",
    "dojo/dom-class", "dojo/dom-attr", "dojo/dom-style",
    "dojo/dom-construct", "dojo/_base/event",
    "dojo/NodeList-dom", "dojo/NodeList-traverse"

    ], function (
        Evented, declare, lang, has, dom, esriNS,
        _WidgetBase, _TemplatedMixin, on,
        query, registry,
        LanguageSelectTemplate, i18n,
        DropDownButton, DropDownMenu, MenuItem,
        domClass, domAttr, domStyle,
        domConstruct, event
    ) {
    var Widget = declare("esri.dijit.LanguageSelect", [_WidgetBase, _TemplatedMixin, Evented], {
        templateString: LanguageSelectTemplate,

        options: {
            locale: 'en-us',
            languages:{},
            textColor:null
        },

        constructor: function (options, srcRefNode) {
            this.defaults = lang.mixin({}, this.options, options);
            //this._i18n = i18n;
            this.domNode = srcRefNode;

            var link = document.createElement("link");
            link.href = "js/LanguageSelect/Templates/LanguageSelect.css";
            link.type = "text/css";
            link.rel = "stylesheet";
            document.getElementsByTagName("head")[0].appendChild(link);

        },

        Click: function(e) {
            //console.log(e.srcElement.parentElement);
            var locale=e.srcElement.dataset.code || e.srcElement.parentElement.dataset.code;
            var appId=e.srcElement.dataset.appid || e.srcElement.parentElement.dataset.appid;
            if(!appId || appId==='' || appId === "undefined" || appId === undefined) {
                appId = /(?:[?|&]appid=)([a-z0-9]*)/gi.exec(window.location.search);
                if(appId && appId.length===2) {
                    appId = appId[1];
                }
            }
            window.location.search=('?appid='+appId+'&locale='+locale).toLowerCase();
        },

        startup: function () {
            if(this.button) return;

            var menu = new DropDownMenu({ style: "display: none;"});
            var currentLocale = this.defaults.locale.substring(0,2).toUpperCase();
            var currentIcon = null;
            var currentLanguage = null;

            for(var i = 0; i<this.defaults.languages.length; i++)
            {
                var lang = this.defaults.languages[i];
                if(!lang.code || lang.code==='') continue;

                var menuItem = new MenuItem({
                    label: lang.name,
                    'data-code': lang.code,
                    'data-appId': lang.appId,
                });
                on(menuItem, 'click', this.Click);

                if(lang.img && lang.img !== '') {
                    var iconCell = query(".dijitMenuItemIconCell",menuItem.domNode)[0];
                    domConstruct.create("img",{
                        src:lang.img,
                        alt:'',
                        class: 'langMenuItemIcon',
                        'data-code': lang.code,
                        'data-appId': lang.appId,
                    }, iconCell);
                }
                dojo.attr(menuItem.domNode,'aria-label', i18n.widgets.languageSelect.aria.changeLanguage+" "+lang.name);
                dojo.attr(menuItem.domNode,'title', i18n.widgets.languageSelect.aria.changeLanguage+" "+lang.name);
                dojo.attr(menuItem.domNode,'data-code', lang.code);
                dojo.attr(menuItem.domNode,'data-appId', lang.appId);
                menu.addChild(menuItem);

                if(lang.code.toUpperCase() === this.defaults.locale.toUpperCase()) {
                    if(lang.img && lang.img !== '') {
                        currentIcon = domConstruct.create("img",{
                            src:lang.img,
                            alt:'',
                            class: 'langIcon',
                            'data-code': lang.code,
                            'data-appId': lang.appId,
                        });
                        if(lang.shortName && lang.shortName !== "") {
                            currentLocale = "";
                        }
                        currentLanguage = lang.name;
                    }
                }
            }

            menu.startup();

            this.button = new DropDownButton({
                label: currentLocale,
                dropDown: menu,
            });
            this.button.startup();

            if(currentIcon) {
                dojo.removeClass(this.button.iconNode, "dijitNoIcon");
                dojo.place(currentIcon, this.button.iconNode);
                dojo.attr(this.button.iconNode,'aria-label', i18n.widgets.languageSelect.aria.currentLanguage+" "+currentLanguage);
                dojo.attr(this.button.iconNode,'title', i18n.widgets.languageSelect.aria.currentLanguage+" "+currentLanguage);
            } else {
                if(this.defaults.textColor)
                    dojo.attr(this.button,'style', 'color:'+this.defaults.textColor+';');
            }

            dom.byId("languageSelectNode").appendChild(this.button.domNode);
        }
    });

    if (has("extend-esri")) {
        lang.setObject("dijit.LanguageSelect", Widget, esriNS);
    }
    return Widget;
});
<commit_msg>Fixed Lang Select for IE<commit_after>define([
    "dojo/Evented", "dojo/_base/declare", "dojo/_base/lang", "dojo/has", "dojo/dom","esri/kernel",
    "dijit/_WidgetBase", "dijit/_TemplatedMixin", "dojo/on",
    "dojo/query", "dijit/registry",
    "dojo/text!application/LanguageSelect/templates/LanguageSelect.html",
    "dojo/i18n!application/nls/LanguageSelect",
    "dijit/form/DropDownButton", "dijit/DropDownMenu", "dijit/MenuItem",
    "dojo/dom-class", "dojo/dom-attr", "dojo/dom-style",
    "dojo/dom-construct", "dojo/_base/event",
    "dojo/NodeList-dom", "dojo/NodeList-traverse"

    ], function (
        Evented, declare, lang, has, dom, esriNS,
        _WidgetBase, _TemplatedMixin, on,
        query, registry,
        LanguageSelectTemplate, i18n,
        DropDownButton, DropDownMenu, MenuItem,
        domClass, domAttr, domStyle,
        domConstruct, event
    ) {
    var Widget = declare("esri.dijit.LanguageSelect", [_WidgetBase, _TemplatedMixin, Evented], {
        templateString: LanguageSelectTemplate,

        options: {
            locale: 'en-us',
            languages:{},
            textColor:null
        },

        constructor: function (options, srcRefNode) {
            this.defaults = lang.mixin({}, this.options, options);
            //this._i18n = i18n;
            this.domNode = srcRefNode;

            var link = document.createElement("link");
            link.href = "js/LanguageSelect/Templates/LanguageSelect.css";
            link.type = "text/css";
            link.rel = "stylesheet";
            document.getElementsByTagName("head")[0].appendChild(link);

        },

        Click: function(e) {
            //console.log(e.srcElement.parentElement);
            var locale=e.srcElement.dataset.code || e.srcElement.parentElement.dataset.code;
            var appId=e.srcElement.dataset.appid || e.srcElement.parentElement.dataset.appid;
            if(!appId || appId==='' || appId === "undefined" || appId === undefined) {
                appId = /(?:[?|&]appid=)([a-z0-9]*)/gi.exec(window.location.search);
                if(appId && appId.length===2) {
                    appId = appId[1];
                }
            }
            window.location.search=('?appid='+appId+'&locale='+locale).toLowerCase();
        },

        startup: function () {
            if(this.button) return;

            var menu = new DropDownMenu({ style: "display: none;"});
            var currentLocale = this.defaults.locale.substring(0,2).toUpperCase();
            var currentIcon = null;
            var currentLanguage = null;

            for(var i = 0; i<this.defaults.languages.length; i++)
            {
                var lang = this.defaults.languages[i];
                if(!lang.code || lang.code==='') continue;

                var menuItem = new MenuItem({
                    label: lang.name,
                    'data-code': lang.code,
                    'data-apiId': lang.appId,
                });
                on(menuItem, 'click', this.Click);

                if(lang.img && lang.img !== '') {
                    var iconCell = query(".dijitMenuItemIconCell",menuItem.domNode)[0];
                    domConstruct.create("img",{
                        src:lang.img,
                        alt:'',
                        class: 'langMenuItemIcon',
                        'data-code': lang.code,
                        'data-appid': lang.appId,
                    }, iconCell);
                }
                dojo.attr(menuItem.domNode,'aria-label', i18n.widgets.languageSelect.aria.changeLanguage+" "+lang.name);
                dojo.attr(menuItem.domNode,'title', i18n.widgets.languageSelect.aria.changeLanguage+" "+lang.name);
                dojo.attr(menuItem.domNode,'data-code', lang.code);
                dojo.attr(menuItem.domNode,'data-appid', lang.appId);
                menu.addChild(menuItem);

                if(lang.code.toUpperCase() === this.defaults.locale.toUpperCase()) {
                    if(lang.img && lang.img !== '') {
                        currentIcon = domConstruct.create("img",{
                            src:lang.img,
                            alt:'',
                            class: 'langIcon',
                            'data-code': lang.code,
                            'data-appid': lang.appId,
                        });
                        if(lang.shortName && lang.shortName !== "") {
                            currentLocale = "";
                        }
                        currentLanguage = lang.name;
                    }
                }
            }

            menu.startup();

            this.button = new DropDownButton({
                label: currentLocale,
                dropDown: menu,
            });
            this.button.startup();

            if(currentIcon) {
                dojo.removeClass(this.button.iconNode, "dijitNoIcon");
                dojo.place(currentIcon, this.button.iconNode);
                dojo.attr(this.button.iconNode,'aria-label', i18n.widgets.languageSelect.aria.currentLanguage+" "+currentLanguage);
                dojo.attr(this.button.iconNode,'title', i18n.widgets.languageSelect.aria.currentLanguage+" "+currentLanguage);
            } else {
                if(this.defaults.textColor)
                    dojo.attr(this.button,'style', 'color:'+this.defaults.textColor+';');
            }

            dom.byId("languageSelectNode").appendChild(this.button.domNode);
        }
    });

    if (has("extend-esri")) {
        lang.setObject("dijit.LanguageSelect", Widget, esriNS);
    }
    return Widget;
});
<|endoftext|>


<commit_before>////////////////////////////////////////////////////////////////////////////////
/// @brief test attribute naming
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
///     http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////

var jsunity = require("jsunity");

var arangodb = require("org/arangodb");

var db = arangodb.db;
var wait = require("internal").wait;

// -----------------------------------------------------------------------------
// --SECTION--                                                        attributes
// -----------------------------------------------------------------------------

////////////////////////////////////////////////////////////////////////////////
/// @brief test attributes
////////////////////////////////////////////////////////////////////////////////

function AttributesSuite () {
  var ERRORS = require("internal").errors;
  var cn = "UnitTestsCollectionAttributes";
  var c = null;

  return {

////////////////////////////////////////////////////////////////////////////////
/// @brief set up
////////////////////////////////////////////////////////////////////////////////

    setUp : function () {
      db._drop(cn);
      c = db._create(cn);
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief tear down
////////////////////////////////////////////////////////////////////////////////

    tearDown : function () {
      c.unload();
      c.drop();
      c = null;
      wait(0.0);
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief no attributes
////////////////////////////////////////////////////////////////////////////////

    testNoAttributes : function () {
      var doc = { };

      var d1 = c.save(doc);
      var d2 = c.document(d1._id);
      delete d1.error;

      assertEqual(d1, d2);
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief empty attribute name
////////////////////////////////////////////////////////////////////////////////

    testEmptyAttribute : function () {
      var doc = { "" : "foo" };

      var d1 = c.save(doc);
      var d2 = c.document(d1._id);
      delete d1.error;

      var i;
      for (i in d2) {
        if (d2.hasOwnProperty(i)) {
          assertTrue(i !== "");
        }
      }

      assertEqual(d1, d2);
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief query empty attribute name
////////////////////////////////////////////////////////////////////////////////

    testQueryEmptyAttribute : function () {
      var doc = { "" : "foo" };
      c.save(doc);

      var docs = c.toArray();
      assertEqual(1, docs.length);
      var d = docs[0];

      var i;
      for (i in d) {
        if (d.hasOwnProperty(i)) {
          assertTrue(i !== "");
        }
      }
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief reserved attribute names
////////////////////////////////////////////////////////////////////////////////

    testReservedAttributes : function () {
      var doc = { "_id" : "foo", "_rev": "99", "_key" : "meow", "_from" : "33", "_to": "99", "_test" : false };

      var d1 = c.save(doc);
      var d2 = c.document(d1._id);

      assertEqual("meow", d1._key);
      assertEqual("meow", d2._key);
      assertEqual(cn + "/meow", d1._id);
      assertEqual(cn + "/meow", d2._id);
      assertEqual(d1._rev, d2._rev);

      // user specified _rev value must have been ignored
      assertTrue(d1._rev !== "99");

      // test attributes
      var i;
      for (i in d2) {
        if (d2.hasOwnProperty(i)) {
          assertTrue(i !== "_from" && i !== "_to" && i !== "_test");
        }
      }
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief attribute name with special chars
////////////////////////////////////////////////////////////////////////////////

    testSpecialAttributes : function () {
      var doc = { "-meow-" : 1, "mötör" : 2, " " : 3, "\t" : 4, "\r" : 5, "\n" : 6 };

      var d1 = c.save(doc);
      var d2 = c.document(d1._id);

      assertEqual(1, d2["-meow-"]);
      assertEqual(2, d2["mötör"]);
      assertEqual(3, d2[" "]);
      assertEqual(4, d2["\t"]);
      assertEqual(5, d2["\r"]);
      assertEqual(6, d2["\n"]);
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief shared attribute list
////////////////////////////////////////////////////////////////////////////////

    testSharedAttributesList : function () {
      var sub = { name: 1 };
      var doc = { a: [ sub, sub ] };

      var d1 = c.save(doc);
      var d2 = c.document(d1._id);

      assertEqual(sub, d2["a"][0]);
      assertEqual(sub, d2["a"][1]);
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief shared attribute object
////////////////////////////////////////////////////////////////////////////////

    testSharedAttributesObject : function () {
      var sub = { name: 1 };
      var doc = { a: sub, b: sub };

      var d1 = c.save(doc);
      var d2 = c.document(d1._id);

      assertEqual(sub, d2["a"]);
      assertEqual(sub, d2["b"]);
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief shared attribute list
////////////////////////////////////////////////////////////////////////////////

    testCyclicAttributesList : function () {
      var sub = {};
      var doc = { a: [ sub ] };

      sub.cycle = doc;

      try {
        c.save(doc);
        fail();
      }
      catch (err) {
        if (err && err.errorNum) {
          // we're on the server
          assertEqual(ERRORS.ERROR_ARANGO_SHAPER_FAILED.code, err.errorNum);
        }
        else {
          // we're on the client, and the JS engine just throws a generic type error
        }

      }
    }

  };
}

// -----------------------------------------------------------------------------
// --SECTION--                                                              main
// -----------------------------------------------------------------------------

////////////////////////////////////////////////////////////////////////////////
/// @brief executes the test suite
////////////////////////////////////////////////////////////////////////////////

jsunity.run(AttributesSuite);

return jsunity.done();

// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)"
// End:
<commit_msg>added test for numeric attribute names<commit_after>////////////////////////////////////////////////////////////////////////////////
/// @brief test attribute naming
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
///     http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////

var jsunity = require("jsunity");

var arangodb = require("org/arangodb");

var db = arangodb.db;
var wait = require("internal").wait;

// -----------------------------------------------------------------------------
// --SECTION--                                                        attributes
// -----------------------------------------------------------------------------

////////////////////////////////////////////////////////////////////////////////
/// @brief test attributes
////////////////////////////////////////////////////////////////////////////////

function AttributesSuite () {
  var ERRORS = require("internal").errors;
  var cn = "UnitTestsCollectionAttributes";
  var c = null;

  return {

////////////////////////////////////////////////////////////////////////////////
/// @brief set up
////////////////////////////////////////////////////////////////////////////////

    setUp : function () {
      db._drop(cn);
      c = db._create(cn);
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief tear down
////////////////////////////////////////////////////////////////////////////////

    tearDown : function () {
      c.unload();
      c.drop();
      c = null;
      wait(0.0);
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief no attributes
////////////////////////////////////////////////////////////////////////////////

    testNoAttributes : function () {
      var doc = { };

      var d1 = c.save(doc);
      var d2 = c.document(d1._id);
      delete d1.error;

      assertEqual(d1, d2);
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief empty attribute name
////////////////////////////////////////////////////////////////////////////////

    testEmptyAttribute : function () {
      var doc = { "" : "foo" };

      var d1 = c.save(doc);
      var d2 = c.document(d1._id);
      delete d1.error;

      var i;
      for (i in d2) {
        if (d2.hasOwnProperty(i)) {
          assertTrue(i !== "");
        }
      }

      assertEqual(d1, d2);
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief query empty attribute name
////////////////////////////////////////////////////////////////////////////////

    testQueryEmptyAttribute : function () {
      var doc = { "" : "foo" };
      c.save(doc);

      var docs = c.toArray();
      assertEqual(1, docs.length);
      var d = docs[0];

      var i;
      for (i in d) {
        if (d.hasOwnProperty(i)) {
          assertTrue(i !== "");
        }
      }
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief "numeric" attribute names
////////////////////////////////////////////////////////////////////////////////

    testNumericAttributes : function () {
      var doc = { "12345" : 1, "6669" : "foo", "7734" : true };

      var d1 = c.save(doc);
      var d2 = c.document(d1._id);

      assertEqual(1, d2["12345"]);
      assertEqual("foo", d2["6669"]);
      assertEqual(true, d2["7734"]);

      assertEqual(undefined, d2["999"]);

      d2 = c.toArray()[0];
      assertEqual(1, d2["12345"]);
      assertEqual("foo", d2["6669"]);
      assertEqual(true, d2["7734"]);

      assertEqual(undefined, d2["999"]);
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief reserved attribute names
////////////////////////////////////////////////////////////////////////////////

    testReservedAttributes : function () {
      var doc = { "_id" : "foo", "_rev": "99", "_key" : "meow", "_from" : "33", "_to": "99", "_test" : false };

      var d1 = c.save(doc);
      var d2 = c.document(d1._id);

      assertEqual("meow", d1._key);
      assertEqual("meow", d2._key);
      assertEqual(cn + "/meow", d1._id);
      assertEqual(cn + "/meow", d2._id);
      assertEqual(d1._rev, d2._rev);

      // user specified _rev value must have been ignored
      assertTrue(d1._rev !== "99");

      // test attributes
      var i;
      for (i in d2) {
        if (d2.hasOwnProperty(i)) {
          assertTrue(i !== "_from" && i !== "_to" && i !== "_test");
        }
      }
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief attribute name with special chars
////////////////////////////////////////////////////////////////////////////////

    testSpecialAttributes : function () {
      var doc = { "-meow-" : 1, "mötör" : 2, " " : 3, "\t" : 4, "\r" : 5, "\n" : 6 };

      var d1 = c.save(doc);
      var d2 = c.document(d1._id);

      assertEqual(1, d2["-meow-"]);
      assertEqual(2, d2["mötör"]);
      assertEqual(3, d2[" "]);
      assertEqual(4, d2["\t"]);
      assertEqual(5, d2["\r"]);
      assertEqual(6, d2["\n"]);
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief shared attribute list
////////////////////////////////////////////////////////////////////////////////

    testSharedAttributesList : function () {
      var sub = { name: 1 };
      var doc = { a: [ sub, sub ] };

      var d1 = c.save(doc);
      var d2 = c.document(d1._id);

      assertEqual(sub, d2["a"][0]);
      assertEqual(sub, d2["a"][1]);
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief shared attribute object
////////////////////////////////////////////////////////////////////////////////

    testSharedAttributesObject : function () {
      var sub = { name: 1 };
      var doc = { a: sub, b: sub };

      var d1 = c.save(doc);
      var d2 = c.document(d1._id);

      assertEqual(sub, d2["a"]);
      assertEqual(sub, d2["b"]);
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief shared attribute list
////////////////////////////////////////////////////////////////////////////////

    testCyclicAttributesList : function () {
      var sub = {};
      var doc = { a: [ sub ] };

      sub.cycle = doc;

      try {
        c.save(doc);
        fail();
      }
      catch (err) {
        if (err && err.errorNum) {
          // we're on the server
          assertEqual(ERRORS.ERROR_ARANGO_SHAPER_FAILED.code, err.errorNum);
        }
        else {
          // we're on the client, and the JS engine just throws a generic type error
        }

      }
    }

  };
}

// -----------------------------------------------------------------------------
// --SECTION--                                                              main
// -----------------------------------------------------------------------------

////////////////////////////////////////////////////////////////////////////////
/// @brief executes the test suite
////////////////////////////////////////////////////////////////////////////////

jsunity.run(AttributesSuite);

return jsunity.done();

// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)"
// End:
<|endoftext|>