Changeset 265 for ether_megapoli


Ignore:
Timestamp:
11/24/11 17:32:33 (12 years ago)
Author:
vmipsl
Message:

loginModule

Location:
ether_megapoli/trunk/web
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • ether_megapoli/trunk/web/resources/css/backoffice.css

    r247 r265  
    2727.containerTitle { 
    2828    font-size: 20px; 
    29     color: #808080; 
     29    color: #778899; 
    3030    font-weight: bold; 
    3131    float: left; 
     
    5454    float: right; 
    5555    position: relative; 
    56     top: 11px; 
     56    top: 13px; 
    5757} 
    5858 
     
    9797    width: 800px; 
    9898    height: 26px; 
    99     color: #646464; 
     99    color: #778899; 
    100100    font-weight: bold; 
    101101    padding-left: 10px; 
     
    106106    -moz-border-radius-topright: 0; 
    107107    -webkit-border-radius: 0; 
    108     background: -moz-linear-gradient(white, #C0C0C0); 
     108    background: -moz-linear-gradient(white, #778899); 
    109109    min-height: 400px; 
    110110    text-align: justify; 
     
    120120 
    121121.containerBottom { 
    122     background-color: #C0C0C0; 
     122    background-color: #778899; 
    123123    color: #FFFFFF; 
    124124    height: 26px; 
  • ether_megapoli/trunk/web/resources/css/button.css

    r261 r265  
    121121/* GRAY BUTTON */ 
    122122button.gray_button { 
    123     background-color: #646464; 
     123    background-color: #778899; 
    124124    height: 39px; 
    125125    float: right; 
  • ether_megapoli/trunk/web/resources/css/complexButton.css

    r249 r265  
    88} 
    99 
    10 .complexButton_left { 
    11     background-image: url("../images/elements/button_left_3.png"); /*background-image: url("../images/elements/button_left.png");*/ 
     10.complexButton_left, .complexButton_left_gray { 
     11    background-image: url("../images/elements/button_left_3.png"); 
    1212    background-repeat: no-repeat; 
    1313    background-position: top left; 
     
    1818} 
    1919 
    20 .complexButton_middle { 
     20.complexButton_left_gray { 
     21    background-image: url("../images/elements/button_left_gray.png"); /*background-image: url("../images/elements/button_left.png");*/ 
     22} 
     23 
     24 
     25.complexButton_middle, .complexButton_middle_gray { 
    2126    background-image: url("../images/elements/button_middle_3.png"); /*background-image: url("../images/elements/button_middle.png");*/ 
    2227    background-repeat: repeat-x; 
    2328    height: 39px; 
    2429    float: left; 
     30} 
     31 
     32.complexButton_middle_gray  { 
     33    background-image: url("../images/elements/button_middle_gray.png"); /*background-image: url("../images/elements/button_middle.png");*/ 
    2534} 
    2635 
     
    4453} 
    4554 
    46 .complexButton_right { 
    47     background-image: url("../images/elements/button_right_3.png"); /*background-image: url("../images/elements/button_right.png");*/ 
     55.complexButton_right, .complexButton_right_gray { 
     56    background-image: url("../images/elements/button_right_3.png"); 
    4857    background-repeat: no-repeat; 
    4958    background-position: top right; 
     
    5261    width: 0; 
    5362    float: left; 
     63} 
     64 
     65.complexButton_right_gray { 
     66    background-image: url("../images/elements/button_right_gray.png"); 
    5467} 
    5568 
  • ether_megapoli/trunk/web/resources/js/classesForJQuery/LoginButton.js

    r238 r265  
    11//******************************************************** 
    2 // Class Button 
    3 // Display a button 
     2// Class LoginButton 
     3// Display a button to login or logout 
    44// 
    5 // use jQuery 
    6 // str value: Value to display in the button 
    7 // dom parent: in which dom element to draw the button 
    8 // int id: id of the dom element 
    9 // func onclick: callback function when button clicked 
    10 // str specificClass 
    11 // classNameToAdd : use to avoid button's style for button_left, button_right and button_middle when button.css is used with pagination.css 
    12 // useLonelyMidleImage : if true, we use image for parts left and right, otherwise, we only use an image for the middle 
     5// use jQuery && librairies from TwitterLogin 
    136//******************************************************** 
    147 
    15 var ComplexButton = Class.create( { 
     8var LoginButton = Class.create( { 
    169 
    1710    initialize: function( param ) 
    1811    { 
    1912        // Init 
    20         this.id = param.id ? param.id : ""; 
    21         this.parent = param.parent ? param.parent : false; 
    22         this.value = param.value ? param.value : ""; 
    23         this.specificClass = param.specificClass ? param.specificClass : false; 
    24         this.callbackOnClick = param.onClick ? param.onClick : false; 
    25         this.classNameToAdd = param.classNameToAdd ? param.classNameToAdd : false; 
    26         this.useLonelyMidleImage = param.useLonelyMidleImage ? param.useLonelyMidleImage : false; 
    27         this.boolDisabled = false; 
    28         this.boolSelected = false; 
    29         this.boolDisplayed = false; 
    30  
    31         // Create button elements 
    32         this.divContainer = $( document.createElement( "div" ) ); 
    33         this.divContainer.attr( {id:this.id, class:"complexButton"} ); 
    34         if( this.specificClass ) 
    35             this.divContainer.addClass( this.specificClass ); 
    36         if( this.parent ) 
    37             this.parent.append( this.divContainer ); 
    38  
    39         this.divLeft = $( document.createElement( "div" ) ); 
    40         if( this.classNameToAdd ) 
    41             this.divLeft.addClass( "complexButton_left_" + this.classNameToAdd ); 
    42         else if( !this.useLonelyMidleImage ) 
    43             this.divLeft.addClass( "complexButton_left" ); 
    44         this.divContainer.append( this.divLeft ); 
    45  
    46         this.divMiddle = $( document.createElement( "div" ) ); 
    47         this.divMiddle.attr( {id:"button_middle"} ); 
    48         if( this.classNameToAdd ) 
    49             this.divMiddle.addClass( "complexButton_middle_" + this.classNameToAdd ); 
    50         else if( this.useLonelyMidleImage ) 
    51             this.divMiddle.addClass( "complexButton_lonely_middle" ); 
    52         else 
    53             this.divMiddle.addClass( "complexButton_middle" ); 
    54         this.divContainer.append( this.divMiddle ); 
    55  
    56         this.divText = $( document.createElement( "div" ) ); 
    57         this.divText.attr( {id:"button_text"} ); 
    58         this.divText.addClass( "complexButton_text" ); 
    59         this.divText.html( this.value ); 
    60         this.divMiddle.append( this.divText ); 
    61  
    62         this.divRight = $( document.createElement( "div" ) ); 
    63         if( this.classNameToAdd ) 
    64             this.divRight.addClass( "complexButton_right_" + this.classNameToAdd ); 
    65         else if( !this.useLonelyMidleImage ) 
    66             this.divRight.addClass( "complexButton_right" ); 
    67         this.divContainer.append( this.divRight ); 
    68  
    69         // Define button events 
    70         this.divContainer.bind( 'click', this, this.onClick ); 
    71     }, 
    72  
    73     // Actions ******************************************************** 
    74  
    75     appendChild :function( parent ) 
    76     { 
    77         this.parent = parent; 
    78         this.parent.append( this.divContainer ); 
    79     }, 
    80  
    81     setDisabled:function( value ) 
    82     { 
    83         if( value ) 
    84             this.disable(); 
    85         else 
    86             this.enable(); 
    87     }, 
    88  
    89     disable : function() 
    90     { 
    91         this.boolDisabled = true; 
    92         this.divContainer.addClassName( "disable" ); 
    93     }, 
    94  
    95     enable : function() 
    96     { 
    97         this.boolDisabled = false; 
    98         this.divContainer.removeClassName( "disable" ); 
    99     }, 
    100  
    101     setSelected : function( value ) 
    102     { 
    103         this.boolSelected = value; 
    104         if( this.boolSelected ) 
    105             this.divContainer.addClassName( "selected" ); 
    106         else 
    107             this.divContainer.removeClassName( "selected" ); 
    108     }, 
    109  
    110     show : function() 
    111     { 
    112         this.boolDisplayed = true; 
    113         this.divContainer.style.display = ""; 
    114     }, 
    115  
    116     hide : function() 
    117     { 
    118         this.boolDisplayed = false; 
    119         this.divContainer.style.display = "none"; 
    120     }, 
    121  
    122     // Getter / Setter ******************************************************** 
    123  
    124     getContainer: function() 
    125     { 
    126         return this.divContainer; 
    127     }, 
    128  
    129     getDisable : function() 
    130     { 
    131         return this.boolDisabled; 
    132     }, 
    133  
    134     getSelect: function() 
    135     { 
    136         return this.boolSelected; 
    137     }, 
    138  
    139     setValue : function( value ) 
    140     { 
    141         this.value = value; 
    142         this.divText.html( this.value ); 
    143     }, 
    144  
    145     setCallbackOnClick : function( value ) 
    146     { 
    147         this.callbackOnClick = value; 
    148     }, 
    149  
    150     // Events ******************************************************** 
    151  
    152     onClick : function( event ) 
    153     { 
    154         var contextEvent = event.data; 
    155         if( !contextEvent.getDisable() && (undefined == event.detail || 1 == event.detail) && contextEvent.callbackOnClick ) 
    156             contextEvent.callbackOnClick(); 
     13        this.parent = param.parent ? param.parent : document.body; 
     14        this.onClickLogin = param.anotherOnClickLogin ? param.anotherOnClickLogin : this.onClickLogin; 
     15        this.onClickLogout = param.anotherOnClickLogout ? param.anotherOnClickLogout : this.onClickLogout; 
     16        this.jSONUser = param.jSONUser ? param.jSONUser : false; 
     17        this.urlLogin = param.urlLogin ? param.urlLogin : false; 
     18        this.urlLogout = param.urlLogout ? param.urlLogout : false; 
     19 
     20        // Texts 
     21        this.connexionText = param.connexionText ? param.connexionText : loginTexts["app.connexion"]; 
     22        this.loginText = param.loginText ? param.loginText : loginTexts["data.authentification.login"]; 
     23        this.pwdText = param.pwdText ? param.pwdText : loginTexts["data.authentification.pwd"]; 
     24        this.submitText = param.submitText ? param.submitText : loginTexts["data.authentification.sign"]; 
     25        this.forgotPText = param.forgotPText ? param.forgotPText : loginTexts["data.authentification.pwdForget"]; 
     26        this.forgotUNPHelpText = param.forgotUNPHelpText ? param.forgotUNPHelpText : loginTexts["data.authentification.loginForget.help"]; 
     27        this.forgotUNPText = param.forgotUNPText ? param.forgotUNPText : loginTexts["data.authentification.loginForget"]; 
     28        this.text1 = param.text1 ? param.text1 : loginTexts["app.admin"]; 
     29        this.errorText = param.errorText ? param.errorText : loginTexts[this.errors]; 
     30    }, 
     31 
     32    // GETTER / SETTER ******************************************************** 
     33    setJSONUser: function( jSONUser ) 
     34    { 
     35        this.jSONUser = jSONUser; 
     36    }, 
     37 
     38    getJSONUser: function() 
     39    { 
     40        return this.jSONUser; 
     41    }, 
     42 
     43    // ACTIONS ******************************************************** 
     44    createLoginForm: function() 
     45    { 
     46        var containerLoginForm = $( document.createElement( "fieldset" ) ); 
     47        containerLoginForm.attr( {id:"signin_menu"} ); 
     48        this.parent.append( containerLoginForm ); 
     49 
     50        var labelLogin = $( document.createElement( "label" ) ); 
     51        labelLogin.attr( {for:"login"} ); 
     52        labelLogin.append( this.loginText ); 
     53        var inputLogin = $( document.createElement( "input" ) ); 
     54        inputLogin.attr( {id:"login", name:"login", tabIndex:"4", type:"text"} ); 
     55        containerLoginForm.append( labelLogin ); 
     56        containerLoginForm.append( inputLogin ); 
     57 
     58        var labelPwd = $( document.createElement( "label" ) ); 
     59        labelPwd.attr( {for:"pwd"} ); 
     60        labelPwd.append( this.pwdText ); 
     61        var inputPwd = $( document.createElement( "input" ) ); 
     62        inputPwd.attr( {id:"pwd", name:"pwd", tabIndex:"5", type:"password"} ); 
     63        containerLoginForm.append( labelPwd ); 
     64        containerLoginForm.append( inputPwd ); 
     65 
     66        var inputSubmitP = $( document.createElement( "p" ) ); 
     67        inputSubmitP.addClass( "remember" ); 
     68        var inputSubmit = $( document.createElement( "input" ) ); 
     69        inputSubmit.attr( {id:"signin_submit", value:this.submitText, tabIndex:"6", type:"submit"} ); 
     70        inputSubmit.bind( "click", jQuery.proxy( this.onClickLogin, this ) ); 
     71        inputSubmitP.append( inputSubmit ); 
     72        containerLoginForm.append( inputSubmitP ); 
     73 
     74        var inputForgotP = $( document.createElement( "p" ) ); 
     75        inputForgotP.addClass( "forgot" ); 
     76        var aForgotP = $( document.createElement( "a" ) ); 
     77        aForgotP.attr( {id:"resend_password_link", href:"mailto:${webmaster}?subject=[MEGAPOLI] login"} ); 
     78        aForgotP.append( this.forgotPText ); 
     79        inputForgotP.append( aForgotP ); 
     80        containerLoginForm.append( inputForgotP ); 
     81 
     82        var inputForgotUNP = $( document.createElement( "p" ) ); 
     83        inputForgotUNP.addClass( "username" ); 
     84        var aForgotUNP = $( document.createElement( "a" ) ); 
     85        aForgotUNP.attr( {id:"forgot_username_link", href:"mailto:${webmaster}?subject=[MEGAPOLI] password", title:this.forgotUNPHelpText} ); 
     86        aForgotUNP.append( this.forgotUNPText ); 
     87        inputForgotUNP.append( aForgotUNP ); 
     88        containerLoginForm.append( inputForgotUNP ); 
     89 
     90        var divErrors = $( document.createElement( "div" ) ); 
     91        divErrors.attr( {id:"errors", class:"containerErrors"} ); 
     92        containerLoginForm.append( divErrors ); 
     93        this.containerErrors = $( "#errors" ); 
     94    }, 
     95 
     96    display: function() 
     97    { 
     98        if( this.jSONUser ) 
     99        { 
     100            var textLogin = this.jSONUser.name + " " + this.jSONUser.firstName; 
     101            if( this.jSONUser.role && "coordinateur" == this.jSONUser.role ) 
     102                textLogin += " (" + this.text1 + ")"; 
     103 
     104            var loginButton = new ComplexButton( {value:textLogin, parent:this.parent, id:"button_login"} ); 
     105 
     106            $( "#button_login #button_middle #button_text" ).addClass( "containerUserLogout" ); 
     107 
     108            var loginMiddle = $( "#button_login #button_middle" ); 
     109            var divImgLogout = $( document.createElement( "div" ) ); 
     110            divImgLogout.addClass( "containerImgLogout" ); 
     111            divImgLogout.append( "<img src='resources/images/utils/logout.png' width='15px' height='15px/>" ); 
     112            divImgLogout.bind( "click", jQuery.proxy( this.onClickLogout, this ) ); 
     113            loginMiddle.append( divImgLogout ); 
     114        } 
     115        else 
     116        { 
     117            this.createLoginForm(); 
     118 
     119            var loginButton = new ComplexButton( {value:this.connexionText, parent:this.parent, id:"button_login"} ); 
     120 
     121            var loginMiddle = $( "#button_login #button_middle" ); 
     122            loginMiddle.empty(); 
     123            loginMiddle.attr( {id:"topnav", class:"topnav complexButton_middle"} ); 
     124            var aLogin = $( document.createElement( "a" ) ); 
     125            aLogin.attr( {id:"button_login_a", href:"login", class:"signin"} ); 
     126            aLogin.html( "<span>" + this.connexionText + "</span>" ); 
     127            loginMiddle.append( aLogin ); 
     128 
     129            $( ".signin" ).click( function( e ) 
     130            { 
     131                e.preventDefault(); 
     132                $( "fieldset#signin_menu" ).toggle(); 
     133                $( ".signin" ).toggleClass( "menu-open" ); 
     134            } ); 
     135 
     136            $( "fieldset#signin_menu" ).mouseup( function() 
     137            { 
     138                return false 
     139            } ); 
     140 
     141            $( document ).mouseup( function( e ) 
     142            { 
     143                if( 0 == $( e.target ).parent( "a.signin" ).length ) 
     144                { 
     145                    $( ".signin" ).removeClass( "menu-open" ); 
     146                    $( "fieldset#signin_menu" ).hide(); 
     147                } 
     148            } ); 
     149        } 
     150    }, 
     151 
     152    updateLogin: function() 
     153    { 
     154        this.parent.empty(); 
     155        this.display(); 
     156    }, 
     157 
     158    displayLoginErrors: function ( text ) 
     159    { 
     160        $( "#errors" ).show(); 
     161        $( "#errors" ).html( text ); 
     162    }, 
     163 
     164    // TODO : vérifier cette méthode 
     165    showLogin: function( text ) 
     166    { 
     167        if( $( "fieldset#signin_menu" ) && $( ".signin" ) ) 
     168        { 
     169            $( "fieldset#signin_menu" ).toggle(); 
     170            $( ".signin" ).toggleClass( "menu-open" ); 
     171            if( text ) 
     172                this.displayLoginErrors( text ); 
     173        } 
     174        else 
     175            alert( this.displayLoginErrors( text ) ); 
     176    }, 
     177 
     178    // REQUESTS ******************************************************** 
     179    requestLogin: function() 
     180    { 
     181        if( !this.urlLogin ) 
     182            return; 
     183 
     184        // TODO : passer en crypter ces infos !!!!! 
     185        var login = $( "#login" ).val(); 
     186        var pwd = $( "#pwd" ).val(); 
     187        $.ajax( { 
     188            url: this.urlLogin + "&login=" + login + "&pwd=" + pwd, 
     189            success:jQuery.proxy( this.onHandleLogin, this ) 
     190        } ); 
     191    }, 
     192 
     193    requestLogout: function() 
     194    { 
     195        if( !this.urlLogout ) 
     196            return; 
     197 
     198        $.ajax( { 
     199            url: this.urlLogout, 
     200            success:jQuery.proxy( this.onHandleLogout, this ) 
     201        } ); 
     202    }, 
     203 
     204    // HANDLES ******************************************************** 
     205    onHandleLogin: function( result ) 
     206    { 
     207        this.errors = jQuery.parseJSON( result ).errors; 
     208        this.setJSONUser( null != jQuery.parseJSON( result ).jSONPeople ? jQuery.parseJSON( result ).jSONPeople : false ); 
     209        if( null == this.errors ) 
     210            this.updateLogin(); 
     211        else 
     212            this.displayLoginErrors( loginTexts[this.errors] ); 
     213    }, 
     214 
     215    onHandleLogout: function( result ) 
     216    { 
     217        this.errors = jQuery.parseJSON( result ).errors; 
     218        if( null == this.errors ) 
     219        { 
     220            this.setJSONUser( false ); 
     221            this.updateLogin(); 
     222        } 
     223        else 
     224            this.displayLoginErrors( loginTexts[this.errors] ); 
     225    }, 
     226 
     227    // EVENTS ******************************************************** 
     228    onClickLogin: function() 
     229    { 
     230        this.containerErrors.hide(); 
     231        this.requestLogin(); 
     232    }, 
     233 
     234    onClickLogout: function() 
     235    { 
     236        this.requestLogout(); 
    157237    } 
     238 
    158239} ); 
     240 
  • ether_megapoli/trunk/web/resources/jsp/backofficeHead.jsp

    r251 r265  
    99            this.containerTitle = $( "#title" ); 
    1010            this.containerTools = $( "#tools" ); 
     11            this.containerLogin = $( "#loginModule" ); 
    1112 
    1213            /** *********** VARIABLES *********** **/ 
     
    2021            /** ************ CREATE ************ **/ 
    2122            this.createTitleTools(); 
     23            this.createMenu(); 
    2224        }, 
    2325 
     
    3032            this.createLogin(); 
    3133 
    32             var valueLanguage = templateTexts["app.fr"]; 
    33             if( this.isLanguageFr ) 
    34                 valueLanguage = templateTexts["app.en"]; 
    35  
    36             var languageButton = new Button( {value:valueLanguage, parent:this.containerTools, id:"button_language", className: "gray_button", classNameText:"blue_button_text", onClick:jQuery.proxy( this.onClickLanguage, this )} ); 
    3734            var homeButton = new Button( {value:templateTexts["app.home"], parent:this.containerTools, id:"button_home", className: "gray_button", classNameText:"blue_button_text", onClick:this.onClickHome} ); 
    3835 
     
    4643        createLogin: function() 
    4744        { 
    48             var containerLoginButton = $( "#button_login" ); 
     45            var buttonLogin = new LoginButton( {parent:this.containerLogin, urlLogin:"project?methodName=login", urlLogout:"project?methodName=logout" } ); 
     46            buttonLogin.setJSONUser( this.jSONUser ); 
     47            buttonLogin.display(); 
     48        }, 
    4949 
    50             if( this.jSONUser ) 
    51             { 
    52                 var textLogin = this.jSONUser.name + " " + this.jSONUser.firstName; 
    53                 if( this.jSONUser.role && this.jSONUser.role == "coordinateur" ) 
    54                     textLogin += " (" + templateTexts["app.admin"] + ")"; 
    55  
    56                 var loginButton = new ComplexButton( {value:textLogin, parent:this.containerTools, id:"button_login"} ); 
    57  
    58                 $( "#button_login #button_middle #button_text" ).addClass( "containerUserLogout" ); 
    59  
    60                 var loginMiddle = $( "#button_login #button_middle" ); 
    61                 var divImgLogout = $( document.createElement( "div" ) ); 
    62                 divImgLogout.addClass( "containerImgLogout" ); 
    63                 divImgLogout.append( "<img src='resources/images/utils/logout.png' width='15px' height='15px/>" ); 
    64                 divImgLogout.bind( "click", this.onClickLogout ); 
    65                 loginMiddle.append( divImgLogout ); 
    66             } 
    67             else 
    68             { 
    69                 var loginButton = new ComplexButton( {value:templateTexts["app.connexion"], parent:this.containerTools, id:"button_login"} ); 
    70  
    71                 var loginMiddle = $( "#button_login #button_middle" ); 
    72                 loginMiddle.empty(); 
    73                 loginMiddle.attr( {id:"topnav", class:"topnav complexButton_middle"} ); 
    74                 var aLogin = $( document.createElement( "a" ) ); 
    75                 aLogin.attr( {id:"button_login_a", href:"login", class:"signin"} ); 
    76                 aLogin.html( "<span>" + templateTexts["app.connexion"] + "</span>" ); 
    77                 loginMiddle.append( aLogin ); 
    78  
    79                 $( document ).ready( function() 
    80                 { 
    81                     $( ".signin" ).click( function( e ) 
    82                     { 
    83                         e.preventDefault(); 
    84                         $( "fieldset#signin_menu" ).toggle(); 
    85                         $( ".signin" ).toggleClass( "menu-open" ); 
    86                     } ); 
    87  
    88                     $( "fieldset#signin_menu" ).mouseup( function() 
    89                     { 
    90                         return false 
    91                     } ); 
    92  
    93                     $( document ).mouseup( function( e ) 
    94                     { 
    95                         if( $( e.target ).parent( "a.signin" ).length == 0 ) 
    96                         { 
    97                             $( ".signin" ).removeClass( "menu-open" ); 
    98                             $( "fieldset#signin_menu" ).hide(); 
    99                         } 
    100                     } ); 
    101                 } ); 
    102  
    103                 $( function() 
    104                 { 
    105                     $( '#forgot_username_link' ).tipsy( {gravity: 'w'} ); 
    106                 } ); 
    107             } 
     50        createMenu: function() 
     51        { 
    10852        }, 
    10953 
     
    11660        onClickLogout: function() 
    11761        { 
     62            alert( "BO" ); 
    11863            document.location.href = "Disconnect.do"; 
    11964        }, 
    12065 
    121         onClickLanguage: function() 
     66        onClickLogout: function() 
    12267        { 
    123             if( this.isLanguageFr ) 
    124                 document.location.href = this.path + "/English.do?requestUri=" + this.relativePageUri; 
    125             else 
    126                 document.location.href = this.path + "/French.do?requestUri=" + this.relativePageUri; 
     68            alert( "BO" ); 
     69            document.location.href = "Disconnect.do"; 
    12770        } 
    12871    } ); 
  • ether_megapoli/trunk/web/resources/jsp/megapoliHead.jsp

    r263 r265  
    22 
    33<script type="text/javascript"> 
    4 var InterfaceTemplate = Class.create( { 
     4    var InterfaceTemplate = Class.create( { 
    55 
    6     initialize: function() 
     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() 
    7158    { 
    8         /** *********** CONTAINERS *********** **/ 
    9         this.containerTitle = $( "#title" ); 
    10         this.containerTools = $( "#tools" ); 
    11         this.containerMenuData = $( "#menuData" ); 
     159        alert( getLoginModule().getJSONUser() ); 
     160        return getLoginModule().getJSONUser(); 
     161    } 
    12162 
    13         /** *********** VARIABLES *********** **/ 
    14         this.isLanguageFr = <%=Context.getLangue(request).equals( "fr" )%>; 
    15         this.path = "<%=request.getContextPath()%>"; 
    16         setPath( this.path ); 
    17         this.webmaster = "<%=Context.getWebmaster(request)%>"; 
    18         this.relativePageUri = <%=request.getQueryString() != null%> ? "<%=Context.getRelativePath( request )%>?<%=request.getQueryString()%>" : "<%=Context.getRelativePageURI(request)%>"; 
    19         this.jSONUser = <%=Context.getJSONUser( request )%> ? <%=Context.getJSONUser( request )%> : false; 
    20         setJSONUser( this.jSONUser ); 
    21         this.screenWidthLimit = 1336; 
     163    function getPath() 
     164    { 
     165        return InterfaceTemplate.path; 
     166    } 
    22167 
    23         /** ************ CREATE ************ **/ 
    24         this.createTitle(); 
    25         this.createTools(); 
    26         this.createMenuData(); 
    27         jQuery.proxy( this.createLeftSlides(), this ); 
    28     }, 
     168    function setPath( path ) 
     169    { 
     170        InterfaceTemplate.path = path; 
     171    } 
    29172 
    30     // CREATES ******************************************************** 
    31     createTitle: function() 
     173    function getLoginModule() 
    32174    { 
    33         this.containerTitle.addClass( "containerTitle" ); 
    34         this.containerTitle.html( templateTexts["app.fulltitle"] ); 
    35     }, 
     175        return InterfaceTemplate.loginModule; 
     176    } 
    36177 
    37     createTools: function() 
     178    function setLoginModule( loginModule ) 
    38179    { 
    39         this.createLoginForm(); 
    40         this.createLogin(); 
    41         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 )} ); 
     180        InterfaceTemplate.loginModule = loginModule; 
     181    } 
    42182 
    43         var valueLanguage = templateTexts["app.fr"]; 
    44         if( this.isLanguageFr ) 
    45             valueLanguage = templateTexts["app.en"]; 
    46  
    47         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 )} ); 
    48         var homeButton = new Button( {value:templateTexts["app.home"], parent:this.containerTools, id:"button_home", className: "blue_button", classNameText:"blue_button_text", onClick:this.onClickHome} ); 
    49  
    50         var divSmallLogoEther = $( document.createElement( "div" ) ); 
    51         divSmallLogoEther.attr( {id:"smallLogoEther", class:"containerSmallLogoEther"} ); 
    52         divSmallLogoEther.append( '<a href="http://ether.ipsl.jussieu.fr" target="help"><img src="resources/images/logo_Ether.jpg" width="40px" height="40px"/></a>' ); 
    53         this.containerTools.append( divSmallLogoEther ); 
    54  
    55         this.updateLogoEther(); 
    56     }, 
    57  
    58     createLogin: function() 
     183    function neededLogin( href ) 
    59184    { 
    60         var containerLoginButton = $( "#button_login" ); 
    61  
    62         if( getJSONUser() ) 
     185        $( "#signin_menu" ).ready( function() 
    63186        { 
    64             var textLogin = getJSONUser().name + " " + getJSONUser().firstName; 
    65             if( getJSONUser().role && "coordinateur" == getJSONUser().role ) 
    66                 textLogin += " (" + templateTexts["app.admin"] + ")"; 
    67  
    68             var loginButton = new ComplexButton( {value:textLogin, parent:this.containerTools, id:"button_login"} ); 
    69  
    70             $( "#button_login #button_middle #button_text" ).addClass( "containerUserLogout" ); 
    71  
    72             var loginMiddle = $( "#button_login #button_middle" ); 
    73             var divImgLogout = $( document.createElement( "div" ) ); 
    74             divImgLogout.addClass( "containerImgLogout" ); 
    75             divImgLogout.append( "<img src='resources/images/utils/logout.png' width='15px' height='15px/>" ); 
    76             divImgLogout.bind( "click", jQuery.proxy( this.onClickLogout, this ) ); 
    77             loginMiddle.append( divImgLogout ); 
    78         } 
    79         else 
    80         { 
    81             var loginButton = new ComplexButton( {value:templateTexts["app.connexion"], parent:this.containerTools, id:"button_login"} ); 
    82  
    83             var loginMiddle = $( "#button_login #button_middle" ); 
    84             loginMiddle.empty(); 
    85             loginMiddle.attr( {id:"topnav", class:"topnav complexButton_middle"} ); 
    86             var aLogin = $( document.createElement( "a" ) ); 
    87             aLogin.attr( {id:"button_login_a", href:"login", class:"signin"} ); 
    88             aLogin.html( "<span>" + templateTexts["app.connexion"] + "</span>" ); 
    89             loginMiddle.append( aLogin ); 
    90  
    91             $( document ).ready( function() 
    92             { 
    93                 $( ".signin" ).click( function( e ) 
    94                 { 
    95                     e.preventDefault(); 
    96                     $( "fieldset#signin_menu" ).toggle(); 
    97                     $( ".signin" ).toggleClass( "menu-open" ); 
    98                 } ); 
    99  
    100                 $( "fieldset#signin_menu" ).mouseup( function() 
    101                 { 
    102                     return false 
    103                 } ); 
    104  
    105                 $( document ).mouseup( function( e ) 
    106                 { 
    107                     if( $( e.target ).parent( "a.signin" ).length == 0 ) 
    108                     { 
    109                         $( ".signin" ).removeClass( "menu-open" ); 
    110                         $( "fieldset#signin_menu" ).hide(); 
    111                     } 
    112                 } ); 
    113             } ); 
    114  
    115             $( function() 
    116             { 
    117                 $( '#forgot_username_link' ).tipsy( {gravity: 'w'} ); 
    118             } ); 
    119         } 
    120     }, 
    121  
    122     createLoginForm: function() 
    123     { 
    124         var containerLoginForm = $( document.createElement( "fieldset" ) ); 
    125         containerLoginForm.attr( {id:"signin_menu"} ); 
    126         this.containerTools.append( containerLoginForm ); 
    127  
    128         var labelLogin = $( document.createElement( "label" ) ); 
    129         labelLogin.attr( {for:"login"} ); 
    130         labelLogin.append( templateTexts["data.authentification.login"] ); 
    131         var inputLogin = $( document.createElement( "input" ) ); 
    132         inputLogin.attr( {id:"login", name:"login", tabIndex:"4", type:"text"} ); 
    133         containerLoginForm.append( labelLogin ); 
    134         containerLoginForm.append( inputLogin ); 
    135  
    136         var labelPwd = $( document.createElement( "label" ) ); 
    137         labelPwd.attr( {for:"pwd"} ); 
    138         labelPwd.append( templateTexts["data.authentification.pwd"] ); 
    139         var inputPwd = $( document.createElement( "input" ) ); 
    140         inputPwd.attr( {id:"pwd", name:"pwd", tabIndex:"5", type:"password"} ); 
    141         containerLoginForm.append( labelPwd ); 
    142         containerLoginForm.append( inputPwd ); 
    143  
    144         var inputSubmitP = $( document.createElement( "p" ) ); 
    145         inputSubmitP.addClass( "remember" ); 
    146         var inputSubmit = $( document.createElement( "input" ) ); 
    147         inputSubmit.attr( {id:"signin_submit", value:templateTexts["data.authentification.sign"], tabIndex:"6", type:"submit"} ); 
    148         inputSubmit.bind( "click", jQuery.proxy( this.onClickLogin, this ) ); 
    149         inputSubmitP.append( inputSubmit ); 
    150         containerLoginForm.append( inputSubmitP ); 
    151  
    152         var inputForgotP = $( document.createElement( "p" ) ); 
    153         inputForgotP.addClass( "forgot" ); 
    154         var aForgot = $( document.createElement( "a" ) ); 
    155         aForgot.attr( {id:"resend_password_link", href:"mailto:${webmaster}?subject=[MEGAPOLI] login"} ); 
    156         aForgot.append( templateTexts["data.authentification.pwdForget"] ); 
    157         inputForgotP.append( aForgot ); 
    158         containerLoginForm.append( inputForgotP ); 
    159  
    160         var inputForgotUNP = $( document.createElement( "p" ) ); 
    161         inputForgotUNP.addClass( "username" ); 
    162         var aForgot = $( document.createElement( "a" ) ); 
    163         aForgot.attr( {id:"forgot_username_link", href:"mailto:${webmaster}?subject=[MEGAPOLI] password", title:templateTexts["data.authentification.loginForget.help"]} ); 
    164         aForgot.append( templateTexts["data.authentification.loginForget"] ); 
    165         inputForgotUNP.append( aForgot ); 
    166         containerLoginForm.append( inputForgotUNP ); 
    167  
    168         var divErrors = $( document.createElement( "div" ) ); 
    169         divErrors.attr( {id:"errors", class:"containerErrors"} ); 
    170         containerLoginForm.append( divErrors ); 
    171     }, 
    172  
    173     createMenuData: function() 
    174     { 
    175         this.containerMenuData.empty(); 
    176  
    177         var ulData = $( document.createElement( "ul" ) ); 
    178         this.containerMenuData.append( ulData ); 
    179  
    180         var liExtract = $( document.createElement( "li" ) ); 
    181         var aExtract = $( document.createElement( "a" ) ); 
    182         aExtract.html( "<span>" + templateTexts["data.access.extract.short"] + "</span>" ); 
    183         liExtract.append( aExtract ); 
    184         ulData.append( liExtract ); 
    185         var liDownload = $( document.createElement( "li" ) ); 
    186         var aDownload = $( document.createElement( "a" ) ); 
    187         aDownload.html( "<span>" + templateTexts["data.upload.short"] + "</span>" ); 
    188         liDownload.append( aDownload ); 
    189         ulData.append( liDownload ); 
    190  
    191         if( getJSONUser() ) 
    192         { 
    193             aExtract.attr( {href:"DataAccess.do"} ); 
    194             aDownload.attr( {href:"PrepareTree.do"} ); 
    195         } 
    196         else 
    197         { 
    198             aExtract.attr( {href:"project?methodName=viewLogin"} ); 
    199             aDownload.attr( {href:"project?methodName=viewLogin"} ); 
    200         } 
    201     }, 
    202  
    203     createLeftSlides: function() 
    204     { 
    205         var contentSlideCredits = "resources/jsp/credits_fr.jsp"; 
    206         var contentSlideMentions = "resources/jsp/mentions_fr.jsp"; 
    207         var contentSlideInfos = "resources/jsp/informations_fr.jsp"; 
    208  
    209         var contentButtonCredits = "<button class='big_blue_button' title='" + templateTexts["app.credits"] + "'><div class='big_blue_button_text'>C</div></button>"; 
    210         var contentButtonMentions = "<button class='big_blue_button' title='" + templateTexts["app.mentions"] + "'><div class='big_blue_button_text'>M</div></button>"; 
    211         var contentButtonInfos = "<button class='big_blue_button' title='" + templateTexts["app.infos"] + "'><div class='big_blue_button_text'>I</div></button>"; 
    212  
    213         if( !this.isLanguageFr ) 
    214         { 
    215             contentSlideCredits = "resources/jsp/credits_en.jsp"; 
    216             contentSlideMentions = "resources/jsp/mentions_en.jsp"; 
    217             contentSlideInfos = "resources/jsp/informations_en.jsp"; 
    218         } 
    219         var divSlideCredits = new Slide( { contentId:"slideContentCredits", buttonId: "slideCredits", parent:$( "#creditSlide" ), isIndexToChange:true, 
    220             contentButton:contentButtonCredits , contentPageSlide:contentSlideCredits} ); 
    221  
    222         var divSlideMentions = new Slide( { contentId:"slideContentMentions", buttonId: "slideMentions", parent:$( "#mentionSlide" ),specificButtonClass:"containerSlideButtonMentions", isIndexToChange:true, 
    223             contentButton:contentButtonMentions, contentPageSlide:contentSlideMentions} ); 
    224  
    225         var divSlideInfos = new Slide( { contentId:"slideContentInfos", buttonId: "slideInfos", parent:$( "#infoSlide" ), specificButtonClass:"containerSlideButtonInfos", isIndexToChange:true, 
    226             contentButton:contentButtonInfos, contentPageSlide:contentSlideInfos} ); 
    227     }, 
    228  
    229     // REQUESTS ******************************************************** 
    230     requestLogin: function() 
    231     { 
    232         // TODO : passer en crypter ces infos !!!!! 
    233         var login = $( "#login" ).val(); 
    234         var pwd = $( "#pwd" ).val(); 
    235         $.ajax( { 
    236             url: "project?methodName=login&login=" + login + "&pwd=" + pwd, 
    237             success:jQuery.proxy( this.onHandleLogin, this ) 
     187            if( !getJSONUser() ) 
     188                getLoginModule().showLogin( loginTexts["data.authentification.text"] ); 
     189            else 
     190                document.location.href = getPath() + href; 
    238191        } ); 
    239     }, 
    240  
    241     requestLogout: function() 
    242     { 
    243         $.ajax( { 
    244             url: "project?methodName=logout", 
    245             success:jQuery.proxy( this.onHandleLogout, this ) 
    246         } ); 
    247     }, 
    248  
    249     // HANDLES ******************************************************** 
    250     onHandleLogin: function( result ) 
    251     { 
    252         this.errors = jQuery.parseJSON( result ).errors; 
    253         setJSONUser( null != jQuery.parseJSON( result ).jSONPeople ? jQuery.parseJSON( result ).jSONPeople : false ); 
    254         if( null == this.errors ) 
    255             this.updateLogin(); 
    256         else 
    257             displayLoginErrors( templateTexts[this.errors] ); 
    258     }, 
    259  
    260     onHandleLogout: function( result ) 
    261     { 
    262         this.errors = jQuery.parseJSON( result ).errors; 
    263         if( null == this.errors ) 
    264         { 
    265             setJSONUser( false ); 
    266             this.updateLogin(); 
    267         } 
    268         else 
    269             displayLoginErrors( templateTexts[this.errors] ); 
    270     }, 
    271  
    272     // EVENTS ******************************************************** 
    273     onClickHome: function() 
    274     { 
    275         document.location.href = "index.jsp"; 
    276     }, 
    277  
    278     onClickLogin: function() 
    279     { 
    280         $( "#errors" ).hide(); 
    281         this.requestLogin(); 
    282     }, 
    283  
    284     onClickLogout: function() 
    285     { 
    286         this.requestLogout(); 
    287     }, 
    288  
    289     onClickLanguage: function() 
    290     { 
    291         if( this.isLanguageFr ) 
    292             document.location.href = this.path + "/English.do?requestUri=" + this.relativePageUri; 
    293         else 
    294             document.location.href = this.path + "/French.do?requestUri=" + this.relativePageUri; 
    295     }, 
    296  
    297     onClickMail: function() 
    298     { 
    299         document.location.href = "mailto:" + this.webmaster + "?subject=[MEGAPOLI]"; 
    300     }, 
    301  
    302     /** 
    303      * This method display a small Ether logo if the screen is too small to contain the big one 
    304      */ 
    305     updateLogoEther: function() 
    306     { 
    307         if( this.screenWidthLimit > innerWidth ) 
    308         { 
    309             $( "#logoEther" ).hide(); 
    310             $( "#linkLogoEther" ).hide(); 
    311             $( "#smallLogoEther" ).show(); 
    312         } 
    313         else 
    314         { 
    315             $( "#logoEther" ).show(); 
    316             $( "#linkLogoEther" ).show(); 
    317             $( "#smallLogoEther" ).hide(); 
    318         } 
    319     }, 
    320  
    321     updateLogin: function() 
    322     { 
    323         this.containerTools.empty(); 
    324         this.createTools(); 
    325         this.createMenuData(); 
    326192    } 
    327 } ); 
    328  
    329 /** *********************************************** **/ 
    330 /** ******************** LOGIN ******************** **/ 
    331 /** *********************************************** **/ 
    332 function displayLoginErrors( text ) 
    333 { 
    334     $( "#errors" ).show(); 
    335     $( "#errors" ).html( text ); 
    336 } 
    337  
    338 function showLogin( text ) 
    339 { 
    340     if( $( "fieldset#signin_menu" ) && $( ".signin" ) ) 
    341     { 
    342         $( "fieldset#signin_menu" ).toggle(); 
    343         $( ".signin" ).toggleClass( "menu-open" ); 
    344         if( text ) 
    345             displayLoginErrors( text ); 
    346     } 
    347     else 
    348         alert( templateTexts["data.authentification.text"] ); 
    349 } 
    350  
    351 function neededLogin( href ) 
    352 { 
    353     $( "#signin_menu" ).ready( function() 
    354     { 
    355         if( !getJSONUser() ) 
    356             showLogin( templateTexts["data.authentification.text"] ); 
    357         else 
    358             document.location.href = getPath() + href; 
    359     } ); 
    360 } 
    361  
    362 /** *********************************************** **/ 
    363 /** ******************** USER ********************* **/ 
    364 /** *********************************************** **/ 
    365 function getJSONUser() 
    366 { 
    367     return InterfaceTemplate.jSONUser; 
    368 } 
    369  
    370 function setJSONUser( user ) 
    371 { 
    372     InterfaceTemplate.jSONUser = user; 
    373 } 
    374  
    375 function getPath() 
    376 { 
    377     return InterfaceTemplate.path; 
    378 } 
    379  
    380 function setPath( path ) 
    381 { 
    382     InterfaceTemplate.path = path; 
    383 } 
    384  
    385193</script> 
  • ether_megapoli/trunk/web/resources/templates/templateBackoffice.jsp

    r247 r265  
    2121    <ether:htmlCss cssFile="TwitterLogin/front"/> 
    2222    <ether:htmlCss cssFile="ether"/> 
     23    <ether:htmlCss cssFile="megapoli"/> 
    2324    <ether:htmlCss cssFile="backoffice"/> 
    2425 
     
    2930    <ether:htmlJs jsFile="classesForJQuery/Button"/> 
    3031    <ether:htmlJs jsFile="classesForJQuery/ComplexButton"/> 
     32    <ether:htmlJs jsFile="classesForJQuery/LoginButton"/> 
    3133    <ether:htmlJs jsFile="apycom.com-4-steel-blue/menu"/> 
    3234    <ether:htmlJs jsFile="TwitterLogin/javascripts/jquery.tipsy"/> 
     
    4042<BODY> 
    4143 
    42 <bean:define type="java.lang.String" id="lastModified" value="<%=Context.getLastModified(request, application)%>"/> 
    43 <bean:define type="java.lang.String" id="webmaster" value="<%=Context.getWebmaster(request)%>"/> 
    44  
    45 <bean:define id="upload" value="upload"/> 
    46 <bean:define id="access" value="access"/> 
    47  
    4844<%-- ************************************************************************************************************** --%> 
    4945<%-- **************************************************** WRAPPER ************************************************* --%> 
     
    5652 
    5753        <div id="tools" align="right"> 
    58             <fieldset id="signin_menu"> 
    59                 <html:form action="/LogonAccess"> 
    60                     <label for="username"><bean:message key="data.authentification.login"/></label> 
    61                     <input id="login" name="login" tabindex="4" type="text"> 
    62  
    63                     <label for="password"><bean:message key="data.authentification.pwd"/></label> 
    64                     <input id="pwd" name="pwd" tabindex="5" type="password"> 
    65  
    66                     <p class="remember"> 
    67                         <input id="signin_submit" value="Sign in" tabindex="6" type="submit"> 
    68                     </p> 
    69  
    70                     <p class="forgot"> 
    71                         <a id="resend_password_link" href="mailto:${webmaster}?subject=[MEGAPOLI] password"><bean:message key="data.authentification.pwdForget"/></a> 
    72                     </p> 
    73  
    74                     <p class="forgot-username"> 
    75                         <a id=forgot_username_link href="mailto:${webmaster}?subject=[MEGAPOLI] login" title='<bean:message key="data.authentification.loginForget.help"/>'><bean:message key="data.authentification.loginForget"/></a> 
    76                     </p> 
    77                 </html:form> 
    78             </fieldset> 
     54            <div id="loginModule" align="right"></div> 
    7955        </div> 
    8056 
     
    9268 
    9369    <%-- ****************** MENU ****************** --%> 
    94     <div id="menu" class="containerMenu"> 
    95         <ul class="menu"> 
    96             <li> 
    97                 <html:link page="/data?methodName=viewCatalogResume" paramName="access" paramId="source"> 
    98                     <span><bean:message key="data.access"/></span> 
    99                 </html:link> 
    100                 <div> 
    101                     <ul> 
    102                         <li><html:link page="/JeuxAccess.do"><span><bean:message key="data.access.jeux"/></span></html:link></li> 
    103                         <li><html:link page="/ParametresAccess.do"><span><bean:message key="data.access.param"/></span></html:link></li> 
    104                         <li><html:link page="/CapteursAccess.do"><span><bean:message key="data.access.capt"/></span></html:link></li> 
    105                         <li><html:link page="/PlateformesAccess.do"><span><bean:message key="data.access.plat"/></span></html:link></li> 
    106                     </ul> 
    107                 </div> 
    108             </li> 
    109  
    110             <li> 
    111                 <html:link page="/data?methodName=viewDataResume"> 
    112                     <span><bean:message key="app.data"/></span> 
    113                 </html:link> 
    114                 <div> 
    115                     <ul> 
    116                         <logic:notPresent name="SES_USER" scope="session"> 
    117                             <li><html:link page="/InitLogonAccess.do" paramName="access" paramId="source"><span><bean:message key="data.access.extract.short"/></span></html:link></li> 
    118                             <li><html:link page="/InitLogonAccess.do" paramName="upload" paramId="source"><span><bean:message key="data.upload.short"/></span></html:link></li> 
    119                         </logic:notPresent> 
    120                         <logic:present name="SES_USER" scope="session"> 
    121                             <li><html:link page="/DataAccess.do"><span><bean:message key="data.access.extract.short"/></span></html:link></li> 
    122                             <li><html:link page="/PrepareTree.do"><span><bean:message key="data.upload.short"/></span></html:link></li> 
    123                         </logic:present> 
    124                     </ul> 
    125                 </div> 
    126             </li> 
    127  
    128             <li class="last"> 
    129                 <html:link page="/visualization?methodName=view"><span><bean:message key="all.visualization"/></span></html:link> 
    130                 <div> 
    131                     <ul> 
    132                         <li><html:link page="/visualization?methodName=viewParametersByPlateform"><span><bean:message key="data.visualization"/></span></html:link></li> 
    133                         <li><html:link page="/visualization?methodName=viewInWork"><span><bean:message key="simulation.visualization"/></span></html:link></li> 
    134                     </ul> 
    135                 </div> 
    136             </li> 
    137  
    138         </ul> 
    139     </div> 
     70    <div id="menuBO" class="containerMenu"></div> 
    14071 
    14172    <%-- ****************** TITLE CONTENT ****************** --%> 
     
    15283    <div id="containerBottom" class="containerMegapoli containerBottom" align="right"> 
    15384        &copy; 2010-2011 <html:link href="http://ether.ipsl.jussieu.fr" target="help">ETHER&nbsp;</html:link>/ CNRS 
    154         <%--<td align="center"><bean:message key="app.infonavig"/></td>--%> 
    155         <%--<td align="right"><i><bean:message key="app.lastModified"/> : <bean:write name="lastModified"/></i></td>--%> 
    15685    </div> 
    15786 
     
    171100    templateTexts["app.en"] = '<bean:message key="app.en"/>'; 
    172101    templateTexts["app.fr"] = '<bean:message key="app.fr"/>'; 
    173     templateTexts["app.connexion"] = '<bean:message key="app.connexion"/>'; 
    174102    templateTexts["data.upload.metadata.contact.mail"] = '<bean:message key="data.upload.metadata.contact.mail"/>'; 
    175103    templateTexts["app.admin"] = '<bean:message key="app.admin"/>'; 
     104 
     105    // Needed texts if you use the library LoginButton.js 
     106    var loginTexts = $A( "" ); 
     107    loginTexts["app.connexion"] = '<bean:message key="app.connexion"/>'; 
     108    loginTexts["data.authentification.login"] = '<bean:message key="data.authentification.login"/>'; 
     109    loginTexts["data.authentification.pwd"] = '<bean:message key="data.authentification.pwd"/>'; 
     110    loginTexts["data.authentification.sign"] = '<bean:message key="data.authentification.sign"/>'; 
     111    loginTexts["data.authentification.pwdForget"] = '<bean:message key="data.authentification.pwdForget"/>'; 
     112    loginTexts["data.authentification.loginForget.help"] = '<bean:message key="data.authentification.loginForget.help"/>'; 
     113    loginTexts["data.authentification.loginForget"] = '<bean:message key="data.authentification.loginForget"/>'; 
     114    loginTexts["errors.logon.notFound"] = "<bean:message key='errors.logon.notFound' arg0="<%=Context.getWebmaster( request )%>"/>"; 
     115    loginTexts["errors.logon.failed"] = "<bean:message key='errors.logon.failed' arg0="<%=Context.getWebmaster( request )%>"/>"; 
     116    loginTexts["app.admin"] = '<bean:message key="app.admin"/>'; 
    176117 
    177118    var interfaceTemplate = new InterfaceTemplate(); 
  • ether_megapoli/trunk/web/resources/templates/templateMegapoli.jsp

    r261 r265  
    2929    <ether:htmlJs jsFile="classesForJQuery/Button"/> 
    3030    <ether:htmlJs jsFile="classesForJQuery/ComplexButton"/> 
     31    <ether:htmlJs jsFile="classesForJQuery/LoginButton"/> 
    3132    <ether:htmlJs jsFile="classesForJQuery/Slide"/> 
    3233    <ether:htmlJs jsFile="apycom.com-4-steel-blue/menu"/> 
     
    6364        <div id="title"></div> 
    6465 
    65         <div id="tools" align="right"></div> 
     66        <div id="tools" align="right"> 
     67            <div id="loginModule" align="right"></div> 
     68        </div> 
    6669 
    6770    </div> 
     
    144147    templateTexts["app.en"] = '<bean:message key="app.en"/>'; 
    145148    templateTexts["app.fr"] = '<bean:message key="app.fr"/>'; 
    146     templateTexts["app.connexion"] = '<bean:message key="app.connexion"/>'; 
    147149    templateTexts["data.upload.metadata.contact.mail"] = '<bean:message key="data.upload.metadata.contact.mail"/>'; 
    148     templateTexts["app.admin"] = '<bean:message key="app.admin"/>'; 
    149     templateTexts["data.authentification.login"] = '<bean:message key="data.authentification.login"/>'; 
    150     templateTexts["data.authentification.pwd"] = '<bean:message key="data.authentification.pwd"/>'; 
    151     templateTexts["data.authentification.sign"] = '<bean:message key="data.authentification.sign"/>'; 
    152     templateTexts["data.authentification.pwdForget"] = '<bean:message key="data.authentification.pwdForget"/>'; 
    153     templateTexts["data.authentification.loginForget.help"] = '<bean:message key="data.authentification.loginForget.help"/>'; 
    154     templateTexts["data.authentification.loginForget"] = '<bean:message key="data.authentification.loginForget"/>'; 
    155     templateTexts["errors.logon.notFound"] = "<bean:message key='errors.logon.notFound' arg0="<%=Context.getWebmaster( request )%>"/>"; 
    156     templateTexts["errors.logon.failed"] = "<bean:message key='errors.logon.failed' arg0="<%=Context.getWebmaster( request )%>"/>"; 
    157     templateTexts["data.authentification"] = "<bean:message key="data.authentification"/>"; 
    158     templateTexts["data.authentification.text"] = "<bean:message key="data.authentification.text"/>"; 
    159150    templateTexts["data.access.extract.short"] = '<bean:message key="data.access.extract.short"/>'; 
    160151    templateTexts["data.upload.short"] = '<bean:message key="data.upload.short"/>'; 
     
    163154    templateTexts["app.mentions"] = '<bean:message key="app.mentions"/>'; 
    164155    templateTexts["app.infos"] = '<bean:message key="app.infos"/>'; 
     156 
     157    // Needed texts if you use the library LoginButton.js 
     158    var loginTexts = $A( "" ); 
     159    loginTexts["app.connexion"] = '<bean:message key="app.connexion"/>'; 
     160    loginTexts["data.authentification.login"] = '<bean:message key="data.authentification.login"/>'; 
     161    loginTexts["data.authentification.pwd"] = '<bean:message key="data.authentification.pwd"/>'; 
     162    loginTexts["data.authentification.sign"] = '<bean:message key="data.authentification.sign"/>'; 
     163    loginTexts["data.authentification.pwdForget"] = '<bean:message key="data.authentification.pwdForget"/>'; 
     164    loginTexts["data.authentification.loginForget.help"] = '<bean:message key="data.authentification.loginForget.help"/>'; 
     165    loginTexts["data.authentification.loginForget"] = '<bean:message key="data.authentification.loginForget"/>'; 
     166    loginTexts["errors.logon.notFound"] = "<bean:message key='errors.logon.notFound' arg0="<%=Context.getWebmaster( request )%>"/>"; 
     167    loginTexts["errors.logon.failed"] = "<bean:message key='errors.logon.failed' arg0="<%=Context.getWebmaster( request )%>"/>"; 
     168    loginTexts["app.admin"] = '<bean:message key="app.admin"/>'; 
     169    loginTexts["data.authentification.text"] = "<bean:message key="data.authentification.text"/>"; 
    165170 
    166171    var interfaceTemplate = new InterfaceTemplate(); 
  • ether_megapoli/trunk/web/visualization/visu_parameter_by_pf-script.jsp

    r259 r265  
    325325        if( !getJSONUser() ) 
    326326        // Method showLogin writen in megapoliHead.jsp 
    327             showLogin( templateTexts["data.authentification.text"] ); 
     327            getLoginModule().showLogin( templateTexts["data.authentification.text"] ); 
    328328        else 
    329329            this.requestDownload(); 
Note: See TracChangeset for help on using the changeset viewer.