alert.html 3.19 KB
Newer Older
Rafael Ostertag's avatar
Rafael Ostertag committed
1
2
3
4
5
6
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/bootstrap-theme.min.css">
7
    <link rel="stylesheet" href="../css/qfq-bs.css">
Rafael Ostertag's avatar
Rafael Ostertag committed
8
9
10
    <title>Alert</title>
</head>
<body>
bbaer's avatar
bbaer committed
11
<div class="container">
Rafael Ostertag's avatar
Rafael Ostertag committed
12
13
14
<button id="showalert1">Show Alert 1</button>
<button id="showalert2">Show Alert 2</button>
<button id="showalert3">Show Alert 3 primed</button>
15
<button id="showmanyalert1">Show Many Alert 1</button>
16
<button id="showmodalalert1">Show Modal Alert 1</button>
17
18
19
20
21
<a id="alertinlink" onclick="
var alert = new QfqNS.Alert('Text being displayed', 'info', [
  { label: 'OK', eventName: 'ok' },
  { label: 'Cancel', eventName: 'cancel'}
]);
Rafael Ostertag's avatar
Rafael Ostertag committed
22

23
24
25
26
27
28
29
alert.on('alert.ok', function() {
  window.location = $('#alertinlink').attr('href');
});

alert.show();
return false;
" href="http://www.google.ch">Link alert</a>
Rafael Ostertag's avatar
Rafael Ostertag committed
30

31
32
33
34
<div style="margin-top: 20ex">
    <button onclick="alert('Button clicked')">Modal test button</button>
</div>

Rafael Ostertag's avatar
Rafael Ostertag committed
35
36
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
37
<script src="../js/EventEmitter.min.js"></script>
38
<script src="../js/qfq.debug.js"></script>
Rafael Ostertag's avatar
Rafael Ostertag committed
39
40
41
42

<script>
    $(function () {
        $('#showalert1').click(function () {
43
            var alert = new QfqNS.Alert("This is alert 1", 'error', [{label: "OK", eventName: "ok", focus: true},
44
45
                {label: "Cancel", eventName: "cancel"}]);
            alert.on('alert.ok', function () {
Rafael Ostertag's avatar
Rafael Ostertag committed
46
47
                console.log("OK button alert 1");
            });
48
            alert.on('alert.cancel', function () {
Rafael Ostertag's avatar
Rafael Ostertag committed
49
50
                console.log("Cancel button alert 1");
            });
Rafael Ostertag's avatar
Rafael Ostertag committed
51
52
53
54
            alert.show();
        });

        $('#showalert2').click(function () {
Rafael Ostertag's avatar
Rafael Ostertag committed
55
            var alert = new QfqNS.Alert("This is alert 2", 'warning');
Rafael Ostertag's avatar
Rafael Ostertag committed
56
57
58
59
            alert.show();
        });

        $('#showalert3').click(function () {
60
61
62
63
            var alert = new QfqNS.Alert({
                message: "This is alert 3. Disappears after 3 secs.",
                timeout: 3000
            });
Rafael Ostertag's avatar
Rafael Ostertag committed
64
65
            alert.show();
        });
66
67
68
69
70
71
72
73
74
75
76

        $('#showmanyalert1').click(function () {
            var alert = new QfqNS.Alert("This is alert 1", "info");
            alert.show();

            alert = new QfqNS.Alert("This is alert 2", "warning");
            alert.show();

            alert = new QfqNS.Alert("This is alert 3", "error");
            alert.show();
        });
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

        $('#showmodalalert1').click(function () {
            var alert = new QfqNS.Alert(
                    {
                        message: "This is modal alert 1",
                        type: 'error',
                        buttons: [
                            {label: "OK", eventName: "ok", focus: true},
                            {label: "Cancel", eventName: "cancel"}
                        ],
                        modal: true
                    }
            );
            alert.on('alert.ok', function () {
                console.log("OK button modal alert 1");
            });
            alert.on('alert.cancel', function () {
                console.log("Cancel button modal alert 1");
            });
            alert.show();
        });
Rafael Ostertag's avatar
Rafael Ostertag committed
98
99
    });
</script>
bbaer's avatar
bbaer committed
100
</div>
Rafael Ostertag's avatar
Rafael Ostertag committed
101
102
</body>
</html>