1 | <%@ page import="com.ether.Context" %> |
---|
2 | |
---|
3 | <script type="text/javascript"> |
---|
4 | var InterfaceTemplate = Class.create( { |
---|
5 | |
---|
6 | initialize: function() |
---|
7 | { |
---|
8 | /** *********** CONTAINERS *********** **/ |
---|
9 | this.containerTools = $( "#tools" ); |
---|
10 | this.containerLogin = $( "#loginModule" ); |
---|
11 | this.containerMenuData = $( "#menuData" ); |
---|
12 | |
---|
13 | /** *********** VARIABLES *********** **/ |
---|
14 | this.isLanguageFr = <%=Context.getLangue(request).equals( "fr" )%>; |
---|
15 | this.webmaster = "<%=Context.getWebmaster(request)%>"; |
---|
16 | <%--this.jSONUser = <%=Context.getJSONUser( request )%> ? <%=Context.getJSONUser( request )%> : false;--%> |
---|
17 | |
---|
18 | /** ************ CREATE ************ **/ |
---|
19 | // this.createLogin(); |
---|
20 | this.createTools(); |
---|
21 | this.updateLoginOrLogout(); |
---|
22 | }, |
---|
23 | |
---|
24 | // CREATES ******************************************************** |
---|
25 | createTools: function() |
---|
26 | { |
---|
27 | var mailButton = new Button( {value:templateTexts["label.mail"], parent:this.containerTools, id:"button_mail", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickMail, this )} ); |
---|
28 | |
---|
29 | // var valueLanguage = templateTexts["label.language.fr"]; |
---|
30 | // if( this.isLanguageFr ) |
---|
31 | // valueLanguage = templateTexts["label.language.en"]; |
---|
32 | |
---|
33 | <%--var languageButton = new Button( {value: templateTexts["label.language.<%=Context.getLocale( request )%>"], parent:this.containerTools, id:"button_language", className: "red_button_text", onClick:jQuery.proxy( this.onClickLanguage, this )} );--%> |
---|
34 | var languageButton = new Button( {value:templateTexts["label.language.to.<%=Context.getLocale( request )%>"], parent:this.containerTools, id:"button_language", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickLanguage, this )} ); |
---|
35 | var homeButton = new Button( {value:templateTexts["label.home"], parent:this.containerTools, id:"button_home", className: "red_button", classNameText:"red_button_text", onClick:this.onClickHome} ); |
---|
36 | }, |
---|
37 | |
---|
38 | createLogin: function() |
---|
39 | { |
---|
40 | this.loginModule = new LoginButton( {parent:this.containerLogin, urlLogin:"project?methodName=login", urlLogout:"project?methodName=logout", isNeededInscription:true, callbackInscription:jQuery.proxy( this.onClickInscription, this ), anotherOnClickLogin:this.updateLoginOrLogout, anotherOnClickLogout:this.updateLoginOrLogout } ); |
---|
41 | this.loginModule.setJSONUser( this.jSONUser ); |
---|
42 | this.loginModule.display(); |
---|
43 | setLoginModule( this.loginModule ); |
---|
44 | }, |
---|
45 | |
---|
46 | // REQUESTS ******************************************************** |
---|
47 | |
---|
48 | // EVENTS ******************************************************** |
---|
49 | onClickHome: function() |
---|
50 | { |
---|
51 | document.location.href = "index.jsp"; |
---|
52 | }, |
---|
53 | |
---|
54 | onClickLanguage: function() |
---|
55 | { |
---|
56 | this.path = "<%=request.getContextPath()%>"; |
---|
57 | this.webmaster = "<%=Context.getWebmaster(request)%>"; |
---|
58 | |
---|
59 | alert("<%=request.getQueryString()%>||<%=Context.getRelativePath( request )%>||<%=Context.getRelativePageURI(request)%>"); |
---|
60 | |
---|
61 | this.relativePageUri = <%=request.getQueryString() != null%> ? "<%=Context.getRelativePath( request )%>?<%=request.getQueryString()%>" : "<%=Context.getRelativePageURI(request)%>"; |
---|
62 | |
---|
63 | alert( this.relativePageUri + " " +<%=Context.isFrench(request)%> ); |
---|
64 | if( <%=Context.isFrench(request)%> ) |
---|
65 | document.location.href = this.path + this.relativePageUri + "&language=en"; |
---|
66 | else |
---|
67 | document.location.href = this.path + this.relativePageUri + "&language=fr"; |
---|
68 | }, |
---|
69 | |
---|
70 | onClickMail: function() |
---|
71 | { |
---|
72 | document.location.href = "mailto:" + this.webmaster + "?subject=[TAPAS]"; |
---|
73 | }, |
---|
74 | |
---|
75 | onClickInscription: function() |
---|
76 | { |
---|
77 | var dataProtocol = "resources/jsp/dataProtocol_fr.jsp"; |
---|
78 | if( !this.isLanguageFr ) |
---|
79 | dataProtocol = "resources/jsp/dataProtocol_en.jsp"; |
---|
80 | |
---|
81 | var $dialog = $( '<div></div>' ) |
---|
82 | .load( dataProtocol ) |
---|
83 | .dialog( { |
---|
84 | autoOpen: false, |
---|
85 | title: loginTexts["login.inscription"], |
---|
86 | height: 800, |
---|
87 | width: 750 |
---|
88 | } ); |
---|
89 | $dialog.dialog( 'open' ); |
---|
90 | |
---|
91 | // TODO : see with $dialog.ready() to manage buttons |
---|
92 | }, |
---|
93 | |
---|
94 | updateLoginOrLogout: function() |
---|
95 | { |
---|
96 | <%--if( "<%=UserRole.ADMINISTRATOR%>" == getJSONUserRole() )--%> |
---|
97 | <%--$( "#button_bo" ).show();--%> |
---|
98 | <%--else--%> |
---|
99 | <%--$( "#button_bo" ).hide();--%> |
---|
100 | } |
---|
101 | |
---|
102 | } ); |
---|
103 | |
---|
104 | /** ******************************* **/ |
---|
105 | /** *********** ACCOUNT *********** **/ |
---|
106 | /** ******************************* **/ |
---|
107 | function onClickAcceptDataProtocol() |
---|
108 | { |
---|
109 | if( '' == $( "#lastName" ).val() || '' == $( "#email" ).val() || '' == $( "#password" ).val() ) |
---|
110 | { |
---|
111 | showErrorAccount( null, templateTexts["login.dataProtocolFields"] ); |
---|
112 | return; |
---|
113 | } |
---|
114 | |
---|
115 | if( $( "#checkboxUser" ).attr( 'checked' ) ) |
---|
116 | createAccount(); |
---|
117 | else |
---|
118 | showErrorAccount( null, templateTexts["login.dataProtocolAccept"] ); |
---|
119 | } |
---|
120 | |
---|
121 | function createAccount() |
---|
122 | { |
---|
123 | var parametersUrl = "name=" + $( "#lastName" ).val() + "&firstName=" + $( "#firstName" ).val() + "&email=" + $( "#email" ).val() + "&pwd=" + $( "#password" ).val(); |
---|
124 | var request = $.ajax( { |
---|
125 | url: "project?methodName=createAccount&" + parametersUrl, |
---|
126 | success:handleCreateAccount, |
---|
127 | error: showErrorAccount |
---|
128 | } ); |
---|
129 | } |
---|
130 | |
---|
131 | function handleCreateAccount() |
---|
132 | { |
---|
133 | $( "#infosAccount" ).hide(); |
---|
134 | $( "#infosAccount" ).removeClass( "containerErrors" ); |
---|
135 | $( "#infosAccount" ).addClass( "containerInfos" ); |
---|
136 | $( "#infosAccount" ).html( templateTexts["login.dataProtocol.account"] ); |
---|
137 | $( "#infosAccount" ).show(); |
---|
138 | } |
---|
139 | |
---|
140 | function showErrorAccount( result, text ) |
---|
141 | { |
---|
142 | $( "#infosAccount" ).hide(); |
---|
143 | $( "#infosAccount" ).removeClass( "containerInfos" ); |
---|
144 | $( "#infosAccount" ).addClass( "containerErrors" ); |
---|
145 | if( null != result ) |
---|
146 | $( "#infosAccount" ).html( templateTexts[result.responseText] ); |
---|
147 | else |
---|
148 | $( "#infosAccount" ).html( text ); |
---|
149 | |
---|
150 | $( "#infosAccount" ).show(); |
---|
151 | } |
---|
152 | </script> |
---|