source: tapas/web/resources/templates/templateEther_script.jsp @ 784

Last change on this file since 784 was 767, checked in by rboipsl, 11 years ago

V2 ajout infobulles + textes

File size: 7.2 KB
Line 
1<%@ page import="com.ether.WebHelper" %>
2<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
3
4<script type="text/javascript">
5    var InterfaceTemplate = Class.create( {
6
7        initialize: function()
8        {
9            /** *********** CONTAINERS *********** **/
10            this.containerTools = $( "#tools" );
11            this.containerLogin = $( "#loginModule" );
12            this.containerMenuData = $( "#menuData" );
13
14            /** *********** VARIABLES *********** **/
15            this.language = '<spring:message code="language"/>';
16            this.languagetoswitch='<spring:message code="label.language.value.to.switch"/>';
17            this.webmaster = "<%=WebHelper.getProperty(request, "mail.webmaster")%>";
18            this.jSONUser = <%=WebHelper.getJSONUser( request )%> ? <%=WebHelper.getJSONUser( request )%> : false;
19
20            /** ************ CREATE ************ **/
21            this.createLogin();
22            this.createTools();
23            //onclick="javascript:desactiveOnglet();"
24            $( "#amenu" ).bind( 'click', this, jQuery.proxy( this.desactiveOnglet, this ) );
25
26        },
27
28        // CREATES ********************************************************
29        createTools: function()
30        {
31            var backofficeButton = new Button( {value:'<spring:message code="label.backoffice"/>', parent:this.containerTools, id:"button_bo", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickBO, this )} );
32
33            var mailButton = new Button( {value:'<spring:message code="label.mail"/>', parent:this.containerTools, id:"button_mail", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickMail, this )} );
34            //var languageButton = new Button( {value:'<spring:message code="label.language.to.switch"/>', parent:this.containerTools, id:"button_language", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickLanguage, this )} );
35            var languageButton = new Button( {value:'<spring:message code="label.language.to.switch"/>', parent:this.containerTools, id:"button_language", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickLanguage, this )} );
36            //var homeButton = new Button( {value:'<spring:message code="label.home"/>', parent:this.containerTools, id:"button_home", className: "red_button", classNameText:"red_button_text", onClick:this.onClickHome} );
37        },
38
39        createLogin: function()
40        {
41            var loginModule = new LoginButton( {parent:this.containerLogin, urlLogin:"project?methodName=login", urlLogout:"project?methodName=logout", webmaster: this.webmaster, isNeededInscription:true, callbackInscription:jQuery.proxy( this.onClickInscription, this ) } );
42            loginModule.setJSONUser( this.jSONUser );
43            loginModule.display();
44            setLoginModule( this.loginModule );
45        },
46
47        // REQUESTS ********************************************************
48        requestChangeLocale: function()
49        {
50            $.ajax( {
51                url: "project?methodName=setLocale&language=<spring:message code="label.language.value.to.switch"/>",
52
53                success:jQuery.proxy(function()
54                {
55                    location.href = "project?methodName=home_"+this.languagetoswitch;
56
57                    //location.reload();
58                },this)
59
60                /*success:function()
61                {
62                    location.href = "project?methodName=home_"+this.language;
63                    //location.reload();
64                }*/
65
66            } );
67        },
68
69        // HANDLES ******************************************************** = retours ajax
70
71        // EVENTS ********************************************************
72        ttt: function()
73        {
74             alert("ok");
75            //document.location.href = "project?methodName=mentionsl_fr";
76        },
77
78        onClickBO: function()
79        {
80            document.location.href = "backoffice?methodName=home";
81        },
82
83        onClickHome: function()
84        {
85            document.location.href = "index.jsp";
86        },
87
88
89        onClickLegals: function()
90        {
91            document.location.href = "index.jsp";
92        },
93
94        onClickLanguage: function()
95        {
96            if (confirm("This action will cancel all your selection."))
97                this.requestChangeLocale();
98        },
99
100        onClickMail: function()
101        {
102            document.location.href = "mailto:" + this.webmaster + "?subject=[TAPAS]";
103        },
104
105        onClickInscription: function()
106        {
107            var dataProtocol = "resources/jsp/dataProtocol_fr.jsp";
108            if( "fr" != this.language )
109                dataProtocol = "resources/jsp/dataProtocol_en.jsp";
110
111            var $dialog = $( '<div></div>' )
112                    .load( dataProtocol )
113                    .dialog( {
114                                 autoOpen: false,
115                                 title: '<spring:message code="login.inscription" />',
116                                 height:800,
117                                 width:750
118                             } );
119            $dialog.dialog( 'open' );
120        },
121
122        desactiveOnglet:function() {
123            //alert("toto");
124            //$("#liamenu").addClass("hover");
125        },
126
127        getLanguage: function() {
128            return this.language;
129
130        }
131
132    } )
133            ;
134
135    /** ******************************* **/
136    /** *********** ACCOUNT *********** **/
137    /** ******************************* **/
138    function onClickAcceptDataProtocol()
139    {
140        if( '' == $( "#lastName" ).val() || '' == $( "#email" ).val() || '' == $( "#password" ).val() )
141        {
142            showErrorAccount( null, "<spring:message code='login.dataProtocolFields'/>" );
143            return;
144        }
145
146        if( $( "#checkboxUser" ).attr( 'checked' ) )
147            createAccount();
148        else
149            showErrorAccount( null, "<spring:message code='login.dataProtocolAccept'/>" );
150    }
151
152    function createAccount()
153    {
154        var parametersUrl = "name=" + $( "#lastName" ).val() + "&firstName=" + $( "#firstName" ).val() + "&email=" + $( "#email" ).val() + "&pwd=" + $( "#password" ).val() + "&laboratory=" + $( "#laboratory" ).val() + "&country=" + $( "#country" ).val();
155        var request = $.ajax( {
156            url: "project?methodName=createAccount&" + parametersUrl,
157            success:handleCreateAccount,
158            error: showErrorAccount
159        } );
160    }
161
162    function handleCreateAccount()
163    {
164        $( "#infosAccount" ).hide();
165        $( "#infosAccount" ).removeClass( "containerErrors" );
166        $( "#infosAccount" ).addClass( "containerInfos" );
167        $( "#infosAccount" ).html( '<spring:message code="login.dataProtocol.account"/>' );
168        $( "#infosAccount" ).show();
169    }
170
171    function showErrorAccount( result, text )
172    {
173        $( "#infosAccount" ).hide();
174        $( "#infosAccount" ).removeClass( "containerInfos" );
175        $( "#infosAccount" ).addClass( "containerErrors" );
176        if( null != result )
177            $( "#infosAccount" ).html( templateTexts[result.responseText] );
178        else
179            $( "#infosAccount" ).html( text );
180
181        $( "#infosAccount" ).show();
182    }
183
184</script>
Note: See TracBrowser for help on using the repository browser.