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

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

correction structure fichier xml
creation repertoire user
v2

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