main-authorize.js revision 9ba40ae6bb2e09b87a01a3a9e7e1a42228b68026
3867N/A/**
3867N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3867N/A *
3867N/A * Copyright (c) 2014-2015 ForgeRock AS. All rights reserved.
3867N/A *
3867N/A * The contents of this file are subject to the terms
3867N/A * of the Common Development and Distribution License
3867N/A * (the License). You may not use this file except in
3867N/A * compliance with the License.
3867N/A *
3867N/A * You can obtain a copy of the License at
3867N/A * http://forgerock.org/license/CDDLv1.0.html
3867N/A * See the License for the specific language governing
3867N/A * permission and limitations under the License.
3867N/A *
3867N/A * When distributing Covered Code, include this CDDL
3867N/A * Header Notice in each file and include the License file
3867N/A * at http://forgerock.org/license/CDDLv1.0.html
3867N/A * If applicable, add the following below the CDDL Header,
3867N/A * with the fields enclosed by brackets [] replaced by
3867N/A * your own identifying information:
3867N/A * "Portions Copyrighted [year] [name of copyright owner]"
3867N/A */
3867N/A
3867N/Arequire.config({
3867N/A
3867N/A map: {
3867N/A "*" : {
3867N/A "ThemeManager" : "org/forgerock/openam/ui/common/util/ThemeManager",
3867N/A "Router": "org/forgerock/openam/ui/common/SingleRouteRouter",
3867N/A // TODO: Remove this when there are no longer any references to the "underscore" dependency
3867N/A "underscore" : "lodash"
3867N/A }
3867N/A },
3867N/A
3867N/A paths: {
3867N/A "lodash": "libs/lodash-3.10.1-min",
3867N/A "handlebars": "libs/handlebars-3.0.3-min",
3867N/A "i18next": "libs/i18next-1.7.3-min",
3867N/A "jquery": "libs/jquery-2.1.1-min",
3867N/A "text": "libs/text"
3867N/A },
3867N/A
3867N/A shim: {
3867N/A "handlebars": {
3867N/A exports: "handlebars"
3867N/A },
3867N/A "i18next": {
3867N/A deps: ["jquery", "handlebars"],
3867N/A exports: "i18next"
3867N/A },
3867N/A "underscore": {
3867N/A exports: "_"
3867N/A }
3867N/A }
4254N/A});
3867N/A
3867N/Arequire([
3867N/A "jquery",
3867N/A "underscore",
3867N/A "handlebars",
4254N/A "org/forgerock/commons/ui/common/main/Configuration",
4254N/A "org/forgerock/openam/ui/common/util/Constants",
4254N/A "text!templates/user/AuthorizeTemplate.html",
4254N/A "text!templates/common/LoginBaseTemplate.html",
4254N/A "text!templates/common/FooterTemplate.html",
4254N/A "text!templates/common/LoginHeaderTemplate.html",
4254N/A "org/forgerock/commons/ui/common/main/i18nManager",
4254N/A "ThemeManager",
4254N/A "Router"
3867N/A], function ($, _, HandleBars, Configuration, Constants, AuthorizeTemplate,
3867N/A LoginBaseTemplate, FooterTemplate, LoginHeaderTemplate, i18nManager, ThemeManager, Router) {
3867N/A
3867N/A // Helpers for the code that hasn't been properly migrated to require these as explicit dependencies:
3867N/A window.$ = $;
3867N/A window._ = _;
4254N/A
4254N/A var formTemplate,
4254N/A baseTemplate,
3867N/A footerTemplate,
3867N/A loginHeaderTemplate,
3867N/A data = window.pageData,
3867N/A KEY_CODE_ENTER = 13,
3867N/A KEY_CODE_SPACE = 32;
3867N/A
3867N/A i18nManager.init({
3867N/A paramLang: {
3867N/A locale: data.locale
3867N/A },
3867N/A defaultLang: Constants.DEFAULT_LANGUAGE,
3867N/A nameSpace: "authorize"
4032N/A });
3867N/A
3867N/A Configuration.globalData = { realm : data.realm };
4032N/A Router.currentRoute = {
3867N/A navGroup: "user"
3867N/A };
3867N/A
3867N/A ThemeManager.getTheme().always(function (theme) {
3867N/A data.theme = theme;
3867N/A baseTemplate = HandleBars.compile(LoginBaseTemplate);
3867N/A formTemplate = HandleBars.compile(AuthorizeTemplate);
3867N/A footerTemplate = HandleBars.compile(FooterTemplate);
3867N/A loginHeaderTemplate = HandleBars.compile(LoginHeaderTemplate);
3867N/A
3867N/A $("#wrapper").html(baseTemplate(data));
3867N/A $("#footer").html(footerTemplate(data));
3867N/A $("#loginBaseLogo").html(loginHeaderTemplate(data));
3867N/A $("#content").html(formTemplate(data)).find(".panel-heading").bind("click keyup", function (e) {
3867N/A // keyup is required so that the collasped panel can be opened with the keyboard alone,
3867N/A // and without relying on a mouse click event.
3867N/A if (e.type === "keyup" && e.keyCode !== KEY_CODE_ENTER && e.keyCode !== KEY_CODE_SPACE) {
3867N/A return;
3867N/A }
3867N/A $(this).toggleClass("expanded").next(".panel-collapse").slideToggle();
3867N/A });
3867N/A
3867N/A });
3867N/A
3867N/A});
3867N/A