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

Last change on this file since 481 was 481, checked in by rboipsl, 12 years ago

modif design
modif menu formulaire

File size: 6.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.webmaster = "<%=WebHelper.getProperty(request, "mail.webmaster")%>";
17            this.jSONUser = <%=WebHelper.getJSONUser( request )%> ? <%=WebHelper.getJSONUser( request )%> : false;
18
19            /** ************ CREATE ************ **/
20            this.createLogin();
21            this.createTools();
22            //onclick="javascript:desactiveOnglet();"
23            $( "#amenu" ).bind( 'click', this, jQuery.proxy( this.desactiveOnglet, this ) );
24
25        },
26
27        // CREATES ********************************************************
28        createTools: function()
29        {
30            //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 )} );
31
32            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 )} );
33            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 )} );
34            //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} );
35        },
36
37        createLogin: function()
38        {
39            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 ) } );
40            loginModule.setJSONUser( this.jSONUser );
41            loginModule.display();
42            setLoginModule( this.loginModule );
43        },
44
45        // REQUESTS ********************************************************
46        requestChangeLocale: function()
47        {
48            $.ajax( {
49                url: "project?methodName=setLocale&language=<spring:message code="label.language.value.to.switch"/>",
50                success:function()
51                {
52                    location.reload();
53                }
54            } );
55        },
56
57        // HANDLES ******************************************************** = retours ajax
58
59        // EVENTS ********************************************************
60        onClickBO: function()
61        {
62            document.location.href = "backoffice?methodName=home";
63        },
64
65        onClickHome: function()
66        {
67            document.location.href = "index.jsp";
68        },
69
70        onClickLanguage: function()
71        {
72            this.requestChangeLocale();
73        },
74
75        onClickMail: function()
76        {
77            document.location.href = "mailto:" + this.webmaster + "?subject=[TAPAS]";
78        },
79
80        onClickInscription: function()
81        {
82            var dataProtocol = "resources/jsp/dataProtocol_fr.jsp";
83            if( "fr" != this.language )
84                dataProtocol = "resources/jsp/dataProtocol_en.jsp";
85
86            var $dialog = $( '<div></div>' )
87                    .load( dataProtocol )
88                    .dialog( {
89                                 autoOpen: false,
90                                 title: '<spring:message code="login.inscription" />',
91                                 height:800,
92                                 width:750
93                             } );
94            $dialog.dialog( 'open' );
95        },
96
97        desactiveOnglet:function() {
98            //alert("toto");
99            //$("#liamenu").addClass("hover");
100        }
101
102    } )
103            ;
104
105    /** ******************************* **/
106    /** *********** ACCOUNT *********** **/
107    /** ******************************* **/
108    function onClickAcceptDataProtocol()
109    {
110        if( '' == $( "#lastName" ).val() || '' == $( "#email" ).val() || '' == $( "#password" ).val() )
111        {
112            showErrorAccount( null, "<spring:message code='login.dataProtocolFields'/>" );
113            return;
114        }
115
116        if( $( "#checkboxUser" ).attr( 'checked' ) )
117            createAccount();
118        else
119            showErrorAccount( null, "<spring:message code='login.dataProtocolAccept'/>" );
120    }
121
122    function createAccount()
123    {
124        var parametersUrl = "name=" + $( "#lastName" ).val() + "&firstName=" + $( "#firstName" ).val() + "&email=" + $( "#email" ).val() + "&pwd=" + $( "#password" ).val() + "&laboratory=" + $( "#laboratory" ).val() + "&country=" + $( "#country" ).val();
125        var request = $.ajax( {
126            url: "project?methodName=createAccount&" + parametersUrl,
127            success:handleCreateAccount,
128            error: showErrorAccount
129        } );
130    }
131
132    function handleCreateAccount()
133    {
134        $( "#infosAccount" ).hide();
135        $( "#infosAccount" ).removeClass( "containerErrors" );
136        $( "#infosAccount" ).addClass( "containerInfos" );
137        $( "#infosAccount" ).html( '<spring:message code="login.dataProtocol.account"/>' );
138        $( "#infosAccount" ).show();
139    }
140
141    function showErrorAccount( result, text )
142    {
143        $( "#infosAccount" ).hide();
144        $( "#infosAccount" ).removeClass( "containerInfos" );
145        $( "#infosAccount" ).addClass( "containerErrors" );
146        if( null != result )
147            $( "#infosAccount" ).html( templateTexts[result.responseText] );
148        else
149            $( "#infosAccount" ).html( text );
150
151        $( "#infosAccount" ).show();
152    }
153
154</script>
Note: See TracBrowser for help on using the repository browser.