(function() {
    'use strict';
    angular.module('chaise.navbar', ['chaise.utils', 'chaise.authen'])
    .directive('navbar', ['$window', '$rootScope', 'Session', function($window, $rootScope, Session) {

    // One-time transformation of chaiseConfig.navbarMenu to set the appropriate newTab setting at each node
        var root = chaiseConfig.navbarMenu;
        // Set default newTab property at root node
        if (!root.hasOwnProperty('newTab')) {
            root.newTab = true;
            if (chaiseConfig.hasOwnProperty('newTab')) {
                root.newTab = chaiseConfig.newTab;
            }
        }

        var q = [root];

        while (q.length > 0) {
    	    var obj = q.shift();
            var parentNewTab = obj.newTab;
            // If current node is a leaf, do nothing
            if (obj.url) {
                continue;
            }
            // If current node has children, set each child's newTab to its own existing newTab or parent's newTab
            for (var key in obj) {
                if (key == 'children') {
                    obj[key].forEach(function(child) {
                        q.push(child);
                        if (child.newTab === undefined) {
                            child.newTab = parentNewTab;
                        }
                    });
                }
            }
        }

        return {
            restrict: 'EA',
            scope: {},
            templateUrl: '../common/templates/navbar.html',
            link: function(scope) {
                scope.brandURL = chaiseConfig.navbarBrand;
                scope.brandText = chaiseConfig.navbarBrandText || chaiseConfig.headTitle;
                scope.brandImage = chaiseConfig.navbarBrandImage;
                scope.menu = chaiseConfig.navbarMenu.children || [];
                scope.signUpURL = chaiseConfig.signUpURL;
                scope.profileURL = chaiseConfig.profileURL;

                Session.getSession().then(function(session) {
                    $rootScope.session = session;

                    var user = session.client;
                    scope.user = user.display_name || user.full_name || user.email || user;
                }, function(error) {
                    // No session = no user
                    scope.user = null;
                });

                scope.login = function login() {
                    Session.login($window.location.href);
                };

                scope.logout = function logout() {
                    Session.logout();
                };
            }
        };
    }])

    .directive('navbarMenu', ['$compile', function($compile) {
        return {
            restrict: 'EA',
            scope: {
                menu: '='
            },
            templateUrl: '../common/templates/navbarMenu.html',
            compile: function(el) {
                var contents = el.contents().remove();
                var compiled;
                return function(scope, el) {
                    if (!compiled) {
                        compiled = $compile(contents);
                    }
                    compiled(scope, function(clone) {
                        el.append(clone);
                    });
                };
            }
        };
    }]);
})();

@@ -487,130 +487,8 @@
 ue;%0A
-            if (chaiseConfig.hasOwnProperty('newTab')) %7B%0A                root.newTab = chaiseConfig.newTab;%0A            %7D%0A
     

Remove redundant newTab chaiseConfig setting