vigiboard / vigiboard / public / js / silence.js @ 703bd599
History | View | Annotate | Download (3.37 KB)
1 |
/*
|
---|---|
2 |
* Vigiboard
|
3 |
*
|
4 |
* Copyright (C) 2009-2014 CS-SI
|
5 |
*/
|
6 |
|
7 |
// Fonction d'échappement
|
8 |
function escapeXML(s) { |
9 |
return s.replace(/&/g, '&') |
10 |
.replace(/</g, '<') |
11 |
.replace(/>/g, '>') |
12 |
.replace(/'/g, ''') |
13 |
.replace(/"/g, '"'); |
14 |
} |
15 |
|
16 |
/*
|
17 |
* Classe représentant une boîte de dialogue demandant confirmation à
|
18 |
* l'utilisateur avant la suppression d'une règle de mise en silence.
|
19 |
*/
|
20 |
var DeleteDialog = new Class({ |
21 |
|
22 |
// Initialisation de la boîte de dialogue
|
23 |
initialize: function() { |
24 |
var header_height = $("header").getSize().y; |
25 |
this.dialog = new Jx.Dialog({ |
26 |
id: "delete", |
27 |
label: 'Delete', |
28 |
modal: true, |
29 |
width: 370, |
30 |
height: 160, |
31 |
//horizontal: "right -10",
|
32 |
//vertical: 'top ' + (header_height + 40),
|
33 |
resize: true |
34 |
}); |
35 |
this.dialog.addEvent("resize", function() { |
36 |
if (this.options.width < 200) { |
37 |
this.options.width = 200; |
38 |
return this.resize(this.options.width, |
39 |
this.options.height);
|
40 |
} |
41 |
if (this.options.height < 150) { |
42 |
this.options.height = 150; |
43 |
return this.resize(this.options.width, |
44 |
this.options.height);
|
45 |
} |
46 |
}); |
47 |
}, |
48 |
|
49 |
// Clôture de la boîte de dialogue
|
50 |
close: function() { |
51 |
this.dialog.close();
|
52 |
}, |
53 |
|
54 |
// Affichage de la boîte de dialogue
|
55 |
show: function(rule_id) { |
56 |
var sentence;
|
57 |
var label;
|
58 |
var confirmation;
|
59 |
var objtype;
|
60 |
var buttonOK;
|
61 |
var buttonCancel;
|
62 |
|
63 |
sentence = _("Are you sure you want to delete this rule?");
|
64 |
label = (_("Silence rule #{id}")).substitute({id: rule_id}); |
65 |
confirmation = _("Delete this rule");
|
66 |
|
67 |
sentence = "<p>" + sentence + "</p>"; |
68 |
this.dialog.setLabel(label);
|
69 |
this.dialog.setContent(
|
70 |
"<div class='confirmation_dialog'>" +
|
71 |
"<div class='confirmation_dialog_question'>" +
|
72 |
"<img src='/images/warning.png' alt='warning'/>" +
|
73 |
sentence + |
74 |
"</div>" +
|
75 |
"<div class='confirmation_dialog_buttons'>" +
|
76 |
"<input id='confirmation_button' class='submit_button'" +
|
77 |
" type='submit' value='" + escapeXML(confirmation) + "'/>" + |
78 |
"<input id='cancellation_button' class='submit_button'" +
|
79 |
" type='submit' value='" + escapeXML(_("No")) + "'/>" + |
80 |
"</div>" +
|
81 |
"</div>"
|
82 |
); |
83 |
confirmation_button = $("confirmation_button"); |
84 |
confirmation_button.removeEvents("click");
|
85 |
confirmation_button.addEvent("click", function() { |
86 |
new URI("delete?id=" + rule_id).go(); |
87 |
}); |
88 |
|
89 |
cancellation_button = $("cancellation_button"); |
90 |
cancellation_button.removeEvents("click");
|
91 |
cancellation_button.addEvent("click", function() { |
92 |
this.dialog.close();
|
93 |
}.bind(this));
|
94 |
|
95 |
this.dialog.open();
|
96 |
} |
97 |
}); |
98 |
|
99 |
// Appelé au chargement de la page
|
100 |
window.addEvent('domready', function (){ |
101 |
var dialog = new DeleteDialog(); |
102 |
$$(".deletion_link").addEvent( |
103 |
"click", function(e) { |
104 |
e.stop(); |
105 |
dialog.show(e.target.getParent().getProperty('href').split('=')[1]); |
106 |
}.bind(this)
|
107 |
); |
108 |
}); |