{"html":"<%\n\tvar userSessionSeparator = util.isNull(config.userSessionSeparator) ? 'or' : fp.S.getString(config.userSessionSeparator),\n        routeStates = fp.config.routeStates,\n        accountUrl = stateManager.href(routeStates.account),\n\t\tloggedInLabel = config.loggedInLabel != null ? config.loggedInLabel : fp.ui.locale('user-session-indicator-welcome', 'Welcome,'),\n\t\tnotLoggedInLabel = config.notLoggedInLabel != null ? config.notLoggedInLabel : '',\n\t\thasTwoLines = config.hasTwoLines != null ? config.hasTwoLines : false,\n\t\tnotLoggedInLoginLink = config.notLoggedInLoginLink != null ? config.notLoggedInLoginLink : fp.ui.locale('user-session-indicator-sign-in', 'Sign In'),\n\t\tnotLoggedInCreateLink = config.notLoggedInCreateLink != null ? config.notLoggedInCreateLink : fp.ui.locale('user-session-indicator-create-an-account', 'Create an Account'),\n\t\tuserSessionSeparatorVariation = config.userSessionSeparatorVariation != null ? config.userSessionSeparatorVariation : '|';\n\n\tif(fp.S(userSessionSeparator).eq('or', true) && util.isAuthenticated()) {\n\t\tuserSessionSeparator = '';\n\t\tif(config.userSessionSeparatorVariationEnabled) userSessionSeparator = userSessionSeparatorVariation;\n\t}\n%>\n<% if(!config.disableIcon) { %>\n<span class=\"fp-icon-user-indicator fp-icon-layered\"></span>\n<% } %>\n<span class=\"fp-welcome\" aria-controls=\"aria-my-account-popup-control\" aria-label=\"My account popup\" aria-expanded=\"false\">\n\t<a id=\"aria-my-account-popup-control\" href=\"<%= accountUrl %>\" data-action=\"account-popover\" aria-haspopup=\"true\">\n\t\t<% if(loggedInLabel) { %><span class=\"fp-welcome-label\"><%- loggedInLabel %></span><% } %>\n\t\t<span class=\"fp-user-name\"><%- fp.S.getString(fp.user.first_name) %></span><% if(hasTwoLines){ %><br /><% } %><% if(userSessionSeparator) { %><span class=\"fp-welcome-separator\"><%= userSessionSeparator %></span><% } %><span class=\"fp-welcome-account\"><%= fp.ui.locale('user-session-indicator-my-account', 'My Account') %></span><span class=\"fp-icon-angle-down fp-icon-dropdown-expand fp-welcome-angle-down\"></span>\n\t</a>\n</span>\n<span class=\"fp-not-logged-in\">\n\t<% if(notLoggedInLabel) { %><span class=\"fp-welcome-label\"><%= notLoggedInLabel %> </span><% } %><% if (notLoggedInLoginLink) { %><a href=\"<%= stateManager.href(routeStates.login.name) %>\" class=\"fp-login-link\" ><%= notLoggedInLoginLink %></a><% } %><% if (notLoggedInLoginLink && notLoggedInCreateLink) { %><% if(hasTwoLines){ %><br /><% } %><% if(userSessionSeparator) { %><span class=\"fp-welcome-separator\"><%- userSessionSeparator %></span><% } %><% } %><% if (notLoggedInCreateLink) { %><a href=\"<%= stateManager.href(routeStates.accountCreate.name) %>\" class=\"fp-register-link\" ><%- notLoggedInCreateLink %></a><% } %>\n</span>\n<div class=\"fp-your-account\" data-action=\"account-popover\">\n\t<a href=\"<%= accountUrl %>\" class=\"fp-your-account-link\"><%= fp.ui.locale('user-session-indicator-my-account', 'My Account') %></a>\n\t<span class=\"fp-icon-angle-down fp-icon-dropdown-expand fp-welcome-angle-down\"></span>\n</div>\n\n<div class=\"fp-user-session-menu fp-popover-item-added\">\n\t<ul>\n\t\t<% if (!config.customUrls) { %>\n\t\t\t<li>\n\t\t\t\t<a href=\"<%= accountUrl %>\"><%= fp.ui.locale('user-session-indicator-my-account', 'My Account') %></a>\n\t\t\t</li>\n\t\t\t<% if (config.customUrl) { %>\n\t\t\t<li>\n\t\t\t\t<a href=\"<%- config.customUrl %>\"><%- config.customUrlText %></a>\n\t\t\t</li>\n\t\t\t<% } %>\n\t\t\t<li>\n\t\t\t\t<a href=\"<%= stateManager.href(routeStates.logout.name) %>\" data-action=\"sign-out\"><%= fp.ui.locale('shared-sign-out', 'Sign Out') %></a>\n\t\t\t</li>\n\t\t<% } %>\n\t\t<% if (config.customUrls) { %>\n\t\t\t<% _.each(config.customUrls, function(value, key) { %>\n\t\t\t\t<li>\n\t\t\t\t\t<a <%= value %>><%= key %></a>\n\t\t\t\t</li>\n\t\t\t<% });%>\n\t\t<% } %>\n\t</ul>\n</div>\n","js":"fp.Module.UserSessionIndicator = fp.Module.extend({\n    construct: function (element, config, template) {\n        config = _.defaults(config, {\n            enableLocale: true,\n            secondaryOnly: false,\n            logoutRedirect: '/',\n            enableModuleCss: fp.config.enableModuleCss && !fp.config.enableMobile\n        });\n\n        this._super(element, config, template);\n    },\n    render: function (params) {\n        this._super(params);\n\n        var self = this,\n            urlParams = fp.ui.router.routeManager.urlParams;\n\n        if(urlParams.error && urlParams.error_code === 'login_error') {      \n            stateManager.go(fp.config.routeStates.login, {error: urlParams.error});\n        }\n\n        this.$element\n            .on('click', function(event){\n                if(!util.isAuthenticated()) return;\n\n                if($(event.target).closest('[data-action=\"account-popover\"]').length) {\n                    event.preventDefault();\n                    event.stopPropagation();\n                }\n                \n                var $this = $(this).toggleClass('open'),\n                    $document = $(document).off('click.accountmenuopen');\n                var $myAccount = $this.find('.fp-welcome');\n                    $myAccount.attr('aria-expanded', 'false');\n                if($this.hasClass('open')) {\n                    $myAccount.attr('aria-expanded', 'true');\n                    $document\n                        .one('click.accountmenuopen', function () {\n                            $this.removeClass('open');\n                        });\n                }\n            });\n\n            this.$element.find('[data-action=\"sign-out\"]')\n                .off('click')\n                .on('click', function(event){\n                    event.preventDefault();\n                    fp.trigger(fp.events.ACCOUNT_LOGOUT, self.config.logoutRedirect);\n                });\n            this.$element.find('[data-action=\"create\"]')\n                .off('click')\n                .on('click', function(event) {\n                    var intent = urlParams.intent;\n                        \n                    if(intent) stateManager.go(fp.config.routeStates.accountCreate.name, {intent: intent}, {preventDefault: true, inherit: true});\n                });\n    },\n    __attachScopeEvents: function() {\n        this._super();\n\n        var self = this,\n            onUserChanged = function() {\n                if(fp.loaded) self.render();\n            };\n\n        $(this.scope)\n            .on(fp.events.USER_LOADED, onUserChanged)\n            .on(fp.events.USER_CHANGED, onUserChanged);\n    }\n});\n\nreturn fp.Module.UserSessionIndicator; \n//# sourceURL=module/user-session-indicator/user-session-indicator.js"}