source: ether_megapoli/trunk/web/resources/jsp/megapoliHead.jsp @ 265

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

loginModule

File size: 8.3 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            this.containerLogin = $( "#loginModule" );
12            this.containerMenuData = $( "#menuData" );
13
14            /** *********** VARIABLES *********** **/
15            this.isLanguageFr = <%=Context.getLangue(request).equals( "fr" )%>;
16            this.path = "<%=request.getContextPath()%>";
17            setPath( this.path );
18            this.webmaster = "<%=Context.getWebmaster(request)%>";
19            this.relativePageUri = <%=request.getQueryString() != null%> ? "<%=Context.getRelativePath( request )%>?<%=request.getQueryString()%>" : "<%=Context.getRelativePageURI(request)%>";
20            this.jSONUser = <%=Context.getJSONUser( request )%> ? <%=Context.getJSONUser( request )%> : false;
21            this.screenWidthLimit = 1336;
22
23            /** ************ CREATE ************ **/
24            this.createTitle();
25            this.createTools();
26            this.createLogin();
27            this.createMenuData();
28            jQuery.proxy( this.createLeftSlides(), this );
29        },
30
31        // CREATES ********************************************************
32        createTitle: function()
33        {
34            this.containerTitle.addClass( "containerTitle" );
35            this.containerTitle.html( templateTexts["app.fulltitle"] );
36        },
37
38        createTools: function()
39        {
40            var mailButton = new Button( {value:templateTexts["data.upload.metadata.contact.mail"], parent:this.containerTools, id:"button_mail", className: "blue_button", classNameText:"blue_button_text", onClick:jQuery.proxy( this.onClickMail, this )} );
41
42            var valueLanguage = templateTexts["app.fr"];
43            if( this.isLanguageFr )
44                valueLanguage = templateTexts["app.en"];
45
46            var languageButton = new Button( {value:valueLanguage, parent:this.containerTools, id:"button_language", className: "blue_button", classNameText:"blue_button_text", onClick:jQuery.proxy( this.onClickLanguage, this )} );
47            var homeButton = new Button( {value:templateTexts["app.home"], parent:this.containerTools, id:"button_home", className: "blue_button", classNameText:"blue_button_text", onClick:this.onClickHome} );
48
49            var divSmallLogoEther = $( document.createElement( "div" ) );
50            divSmallLogoEther.attr( {id:"smallLogoEther", class:"containerSmallLogoEther"} );
51            divSmallLogoEther.append( '<a href="http://ether.ipsl.jussieu.fr" target="help"><img src="resources/images/logo_Ether.jpg" width="40px" height="40px"/></a>' );
52            this.containerTools.append( divSmallLogoEther );
53
54            this.updateLogoEther();
55        },
56
57        createLogin: function()
58        {
59            this.loginModule = new LoginButton( {parent:this.containerLogin, urlLogin:"project?methodName=login", urlLogout:"project?methodName=logout" } );
60            this.loginModule.setJSONUser( this.jSONUser );
61            this.loginModule.display();
62            setLoginModule( this.loginModule );
63        },
64
65        createMenuData: function()
66        {
67            this.containerMenuData.empty();
68
69            var ulData = $( document.createElement( "ul" ) );
70            this.containerMenuData.append( ulData );
71
72            var liExtract = $( document.createElement( "li" ) );
73            var aExtract = $( document.createElement( "a" ) );
74            aExtract.attr( {onclick:'javascript:neededLogin("/DataAccess.do")'} );
75            aExtract.html( "<span>" + templateTexts["data.access.extract.short"] + "</span>" );
76            liExtract.append( aExtract );
77            ulData.append( liExtract );
78            var liDownload = $( document.createElement( "li" ) );
79            var aDownload = $( document.createElement( "a" ) );
80            aDownload.attr( {onclick:'javascript:neededLogin("/PrepareTree.do")'} );
81            aDownload.html( "<span>" + templateTexts["data.upload.short"] + "</span>" );
82            liDownload.append( aDownload );
83            ulData.append( liDownload );
84        },
85
86        createLeftSlides: function()
87        {
88            var contentSlideCredits = "resources/jsp/credits_fr.jsp";
89            var contentSlideMentions = "resources/jsp/mentions_fr.jsp";
90            var contentSlideInfos = "resources/jsp/informations_fr.jsp";
91
92            var contentButtonCredits = "<button class='big_blue_button' title='" + templateTexts["app.credits"] + "'><div class='big_blue_button_text'>C</div></button>";
93            var contentButtonMentions = "<button class='big_blue_button' title='" + templateTexts["app.mentions"] + "'><div class='big_blue_button_text'>M</div></button>";
94            var contentButtonInfos = "<button class='big_blue_button' title='" + templateTexts["app.infos"] + "'><div class='big_blue_button_text'>I</div></button>";
95
96            if( !this.isLanguageFr )
97            {
98                contentSlideCredits = "resources/jsp/credits_en.jsp";
99                contentSlideMentions = "resources/jsp/mentions_en.jsp";
100                contentSlideInfos = "resources/jsp/informations_en.jsp";
101            }
102            var divSlideCredits = new Slide( { contentId:"slideContentCredits", buttonId: "slideCredits", parent:$( "#creditSlide" ), isIndexToChange:true,
103                contentButton:contentButtonCredits , contentPageSlide:contentSlideCredits} );
104
105            var divSlideMentions = new Slide( { contentId:"slideContentMentions", buttonId: "slideMentions", parent:$( "#mentionSlide" ),specificButtonClass:"containerSlideButtonMentions", isIndexToChange:true,
106                contentButton:contentButtonMentions, contentPageSlide:contentSlideMentions} );
107
108            var divSlideInfos = new Slide( { contentId:"slideContentInfos", buttonId: "slideInfos", parent:$( "#infoSlide" ), specificButtonClass:"containerSlideButtonInfos", isIndexToChange:true,
109                contentButton:contentButtonInfos, contentPageSlide:contentSlideInfos} );
110        },
111
112        // REQUESTS ********************************************************
113
114        // EVENTS ********************************************************
115        onClickHome: function()
116        {
117            document.location.href = "index.jsp";
118        },
119
120        onClickLanguage: function()
121        {
122            if( this.isLanguageFr )
123                document.location.href = this.path + "/English.do?requestUri=" + this.relativePageUri;
124            else
125                document.location.href = this.path + "/French.do?requestUri=" + this.relativePageUri;
126        },
127
128        onClickMail: function()
129        {
130            document.location.href = "mailto:" + this.webmaster + "?subject=[MEGAPOLI]";
131        },
132
133        /**
134         * This method display a small Ether logo if the screen is too small to contain the big one
135         */
136        updateLogoEther: function()
137        {
138            if( this.screenWidthLimit > innerWidth )
139            {
140                $( "#logoEther" ).hide();
141                $( "#linkLogoEther" ).hide();
142                $( "#smallLogoEther" ).show();
143            }
144            else
145            {
146                $( "#logoEther" ).show();
147                $( "#linkLogoEther" ).show();
148                $( "#smallLogoEther" ).hide();
149            }
150        }
151
152    } );
153
154    /** *********************************************** **/
155    /** ******************** USER ********************* **/
156    /** *********************************************** **/
157    function getJSONUser()
158    {
159        alert( getLoginModule().getJSONUser() );
160        return getLoginModule().getJSONUser();
161    }
162
163    function getPath()
164    {
165        return InterfaceTemplate.path;
166    }
167
168    function setPath( path )
169    {
170        InterfaceTemplate.path = path;
171    }
172
173    function getLoginModule()
174    {
175        return InterfaceTemplate.loginModule;
176    }
177
178    function setLoginModule( loginModule )
179    {
180        InterfaceTemplate.loginModule = loginModule;
181    }
182
183    function neededLogin( href )
184    {
185        $( "#signin_menu" ).ready( function()
186        {
187            if( !getJSONUser() )
188                getLoginModule().showLogin( loginTexts["data.authentification.text"] );
189            else
190                document.location.href = getPath() + href;
191        } );
192    }
193</script>
Note: See TracBrowser for help on using the repository browser.