source: ether_megapoli/trunk/web/resources/jsp/backofficeHead.jsp @ 251

Last change on this file since 251 was 251, checked in by vmipsl, 13 years ago

login

File size: 5.6 KB
Line 
1<%@ page import="com.medias.Context" %>
2
3<script type="text/javascript">
4    var InterfaceTemplate = Class.create( {
5
6        initialize: function()
7        {
8            /** *********** CONTAINERS *********** **/
9            this.containerTitle = $( "#title" );
10            this.containerTools = $( "#tools" );
11
12            /** *********** VARIABLES *********** **/
13            this.isLanguageFr = <%=Context.getLangue(request).equals( "fr" )%>;
14            this.path = "<%=request.getContextPath()%>";
15            this.webmaster = "<%=Context.getWebmaster(request)%>";
16            this.relativePageUri = <%=request.getQueryString() != null%> ? "<%=Context.getRelativePath( request )%>?<%=request.getQueryString()%>" : "<%=Context.getRelativePageURI(request)%>";
17            this.jSONUser = <%=Context.getJSONUser( request )%> ? <%=Context.getJSONUser( request )%> : false;
18            this.screenWidthLimit = 1336;
19
20            /** ************ CREATE ************ **/
21            this.createTitleTools();
22        },
23
24        // CREATES ********************************************************
25        createTitleTools: function()
26        {
27            this.containerTitle.addClass( "containerTitle" );
28            this.containerTitle.html( templateTexts["bo.fulltitle"] );
29
30            this.createLogin();
31
32            var valueLanguage = templateTexts["app.fr"];
33            if( this.isLanguageFr )
34                valueLanguage = templateTexts["app.en"];
35
36            var languageButton = new Button( {value:valueLanguage, parent:this.containerTools, id:"button_language", className: "gray_button", classNameText:"blue_button_text", onClick:jQuery.proxy( this.onClickLanguage, this )} );
37            var homeButton = new Button( {value:templateTexts["app.home"], parent:this.containerTools, id:"button_home", className: "gray_button", classNameText:"blue_button_text", onClick:this.onClickHome} );
38
39            var divSmallLogoEther = $( document.createElement( "div" ) );
40            divSmallLogoEther.attr( {id:"smallLogoEther", class:"containerSmallLogoEther"} );
41            divSmallLogoEther.append( '<a href="http://ether.ipsl.jussieu.fr" target="help"><img src="resources/images/logo_Ether.jpg" width="40px" height="40px"/></a>' );
42            this.containerTools.append( divSmallLogoEther );
43            $( "#smallLogoEther" ).show();
44        },
45
46        createLogin: function()
47        {
48            var containerLoginButton = $( "#button_login" );
49
50            if( this.jSONUser )
51            {
52                var textLogin = this.jSONUser.name + " " + this.jSONUser.firstName;
53                if( this.jSONUser.role && this.jSONUser.role == "coordinateur" )
54                    textLogin += " (" + templateTexts["app.admin"] + ")";
55
56                var loginButton = new ComplexButton( {value:textLogin, parent:this.containerTools, id:"button_login"} );
57
58                $( "#button_login #button_middle #button_text" ).addClass( "containerUserLogout" );
59
60                var loginMiddle = $( "#button_login #button_middle" );
61                var divImgLogout = $( document.createElement( "div" ) );
62                divImgLogout.addClass( "containerImgLogout" );
63                divImgLogout.append( "<img src='resources/images/utils/logout.png' width='15px' height='15px/>" );
64                divImgLogout.bind( "click", this.onClickLogout );
65                loginMiddle.append( divImgLogout );
66            }
67            else
68            {
69                var loginButton = new ComplexButton( {value:templateTexts["app.connexion"], parent:this.containerTools, id:"button_login"} );
70
71                var loginMiddle = $( "#button_login #button_middle" );
72                loginMiddle.empty();
73                loginMiddle.attr( {id:"topnav", class:"topnav complexButton_middle"} );
74                var aLogin = $( document.createElement( "a" ) );
75                aLogin.attr( {id:"button_login_a", href:"login", class:"signin"} );
76                aLogin.html( "<span>" + templateTexts["app.connexion"] + "</span>" );
77                loginMiddle.append( aLogin );
78
79                $( document ).ready( function()
80                {
81                    $( ".signin" ).click( function( e )
82                    {
83                        e.preventDefault();
84                        $( "fieldset#signin_menu" ).toggle();
85                        $( ".signin" ).toggleClass( "menu-open" );
86                    } );
87
88                    $( "fieldset#signin_menu" ).mouseup( function()
89                    {
90                        return false
91                    } );
92
93                    $( document ).mouseup( function( e )
94                    {
95                        if( $( e.target ).parent( "a.signin" ).length == 0 )
96                        {
97                            $( ".signin" ).removeClass( "menu-open" );
98                            $( "fieldset#signin_menu" ).hide();
99                        }
100                    } );
101                } );
102
103                $( function()
104                {
105                    $( '#forgot_username_link' ).tipsy( {gravity: 'w'} );
106                } );
107            }
108        },
109
110        // EVENTS ********************************************************
111        onClickHome: function()
112        {
113            document.location.href = "backoffice?methodName=view";
114        },
115
116        onClickLogout: function()
117        {
118            document.location.href = "Disconnect.do";
119        },
120
121        onClickLanguage: function()
122        {
123            if( this.isLanguageFr )
124                document.location.href = this.path + "/English.do?requestUri=" + this.relativePageUri;
125            else
126                document.location.href = this.path + "/French.do?requestUri=" + this.relativePageUri;
127        }
128    } );
129
130</script>
Note: See TracBrowser for help on using the repository browser.