Subversion Repositories bacoAlunos

Rev

Rev 1714 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1686 jmachado 1
<%@ page import="pt.estgp.estgweb.Globals" %>
2
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
3
<%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %>
4
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
5
<%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %>
6
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
7
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
8
<%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %>
9
<%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %>
10
<script>
11
    var actionAuthenticate = "<%=request.getContextPath()%>/authenticateWidget.do";
12
    function authenticateWidget()
13
    {
14
        var username = $("#formAuthenticationWidget input[name='username']").val();
15
        var password = $("#formAuthenticationWidget input[name='password']").val();
16
        widgetSimpleCallWithActionParameters(
17
                "<%=request.getContextPath()%>/authenticateWidget.do",
18
                "loginWidget",
19
                {
20
                    "username" : username,
21
                    "password" : password
22
                },
23
                "#formAuthenticationWidget",
24
                function()
25
                {
26
                    $('#modalAuthentication').modal('hide');
1714 jmachado 27
                    if(modalAuthReload)
28
                    {
29
                        window.location.reload();
30
                    }
31
                    else if(modalAuthHref != "")
32
                    {
33
                        window.location.href = modalAuthHref;
34
                    }
35
                    else if(modalAuthScript != "")
36
                    {
37
                        modalAuthHref = "";
38
                        modalAuthScript = "";
39
                        modalAuthReload = false;
40
                        eval(modalAuthScript);
41
                    }
1686 jmachado 42
                },
43
                function()
44
                {
45
                    //fail
46
                }
47
        );
48
    }
1714 jmachado 49
 
50
    function logoutWidget()
51
    {
52
        widgetSimpleCallWithActionParameters(
53
                "<%=request.getContextPath()%>/authenticateWidget.do",
54
                "logoutWidget",
55
                { },
56
                "body",
57
                function()
58
                {
59
                    window.location.href = window.location.href;
60
                },
61
                function()
62
                {
63
                    //fail
64
                }
65
        );
66
    }
1686 jmachado 67
</script>
68
 
69
 
70
 
71
<!--AUTENTICATION MODAL-->
72
<script>
1714 jmachado 73
    var modalAuthHref = "";
74
    var modalAuthScript = "";
75
    var modalAuthReload = false;
76
 
1686 jmachado 77
    $(document).ready(function(){
78
        $('#modalAuthentication').on('show.bs.modal', function(e)
79
        {
1714 jmachado 80
            modalAuthHref = "";
81
            modalAuthScript = "";
82
            modalAuthReload = false;
1686 jmachado 83
            $("#modalAuthentication .web-messages").html("");
1714 jmachado 84
 
85
            if($(e.relatedTarget) && $(e.relatedTarget).data('reload'))
86
            {
87
                modalAuthReload = true;
88
            }
89
            else if($(e.relatedTarget) && $(e.relatedTarget).data('href'))
90
            {
91
                modalAuthHref = $(e.relatedTarget).data('href');
92
            }
93
            else if($(e.relatedTarget) && $(e.relatedTarget).data('script'))
94
            {
95
                modalAuthHref = $(e.relatedTarget).data('script');
96
            }
97
 
98
 
1686 jmachado 99
        });
100
    });
1714 jmachado 101
 
102
 
103
 
1686 jmachado 104
</script>
105
<div class="modal fade" id="modalAuthentication" role="dialog" >
106
    <div class="modal-dialog" data-width="960" style="display: block; width: 960px; margin-top: 50px;" aria-hidden="false">
107
 
108
        <!-- Modal content-->
109
        <div class="modal-content">
110
            <div class="modal-header">
111
                <h1 class="modal-title">Formulário de Autenticação</h1>
112
            </div>
113
 
114
            <div class="modal-body">
115
                <div class="alert alert-info">
116
                    Caro utilizador, a sessão expirou, por favor introduza as suas credênciais
117
                    para voltar a autênticar-se no sistema
118
                    e poder repetir a última operação. Obrigado.
119
                </div>
120
 
121
                <div id="formAuthenticationWidget" class="clearfix">
122
 
123
                    <div class="web-messages" style="margin-bottom: 5px"></div>
124
 
125
                    <div class="form-horizontal col-md-12 clearfix">
126
                        <div class="form-group clearfix">
127
                            <label class="col-md-12" style="margin-bottom: 10px"><jomm:messageConfigKey config="authentication.policy.username.msg.key"/></label>
128
                            <div class="col-md-6">
129
                                <input type="text" class="form-control" name="username"/>
130
                            </div>
131
                        </div>
132
                        <div class="form-group clearfix">
133
                            <label class="col-md-12" style="margin-bottom: 10px"><jomm:messageConfigKey config="authentication.policy.password.msg.key"/></label>
134
                            <div class="col-md-6">
1763 jmachado 135
                                <input type="password" class="form-control" name="password" onkeyup="if(event.keyCode == 13){event.preventDefault();authenticateWidget();}"/>
1686 jmachado 136
                            </div>
137
                        </div>
138
                        <div class="col-sm-2">
139
                            <button type="button" class="btn btn-success" onclick="authenticateWidget()"><bean:message key="submit"/></button>
140
                        </div>
141
                    </div>
142
                </div>
143
 
144
 
145
            </div>
146
        </div>
147
 
148
    </div>
149
</div>
150