Revision 5f31d0dd
[#1457] Rafraichissement AJAX dans VigiBoard
Change le mécanisme de rafraichissement du tableau de VigiBoard pour
utiliser de l'AJAX.
Réutilise le fichier "loader.js" pour obtenir un sablier lors du
chargement (et donc suppression des copies dans VigiMap/VigiGraph).
Le script "loader.js" est enrichi pour pouvoir ajouter la notion d'un
calque qui est rendu semi-opaque lors de l'exécution de la requête.
Change-Id: I1caf0cc7be56f50743e9071fbcedb46c537cedac
Refs: #1457.
Reviewed-on: https://vigilo-dev.si.c-s.fr/review/1901
Tested-by: Build system <qa@vigilo-dev.si.c-s.fr>
Reviewed-by: Francois POIROTTE <francois.poirotte@c-s.fr>
vigigraph/public/js/loader.js | ||
---|---|---|
1 |
/* |
|
2 |
* VigiGraph, composant de Vigilo. |
|
3 |
* Copyright (C) 2009-2015 CS-SI |
|
4 |
* Licence : GNU GPL v2 ou superieure |
|
5 |
* |
|
6 |
*/ |
|
7 |
/* |
|
8 |
* Icone de chargement |
|
9 |
*/ |
|
10 |
var Loader = new Class({ |
|
11 |
|
|
12 |
clients: 0, // Nombre de demandes d'affichage |
|
13 |
|
|
14 |
initialize: function() { |
|
15 |
this.element = null; |
|
16 |
window.addEvent('domready', function () { |
|
17 |
this.element = $("loading"); |
|
18 |
}.bind(this)); |
|
19 |
this.logger = (new Log()).enableLog(); |
|
20 |
}, |
|
21 |
|
|
22 |
show: function() { |
|
23 |
this.clients += 1; |
|
24 |
if (!$chk(this.element) || this.element.getStyle("display") == "block") { |
|
25 |
return this; |
|
26 |
} |
|
27 |
this.logger.log("Showing spinner"); |
|
28 |
this.element.setStyle("display", "block"); |
|
29 |
return this; |
|
30 |
}, |
|
31 |
|
|
32 |
hide: function() { |
|
33 |
this.clients -= 1; |
|
34 |
// Encore des demandes d'affichage en attente |
|
35 |
if (!$chk(this.element) || this.clients > 0) return this; |
|
36 |
if (this.element.getStyle("display") == "none") return this; |
|
37 |
this.logger.log("Hiding spinner"); |
|
38 |
this.element.setStyle("display", "none"); |
|
39 |
return this; |
|
40 |
} |
|
41 |
}); |
|
42 |
|
|
43 |
loader = new Loader(); |
|
44 |
|
|
45 |
// Affichage du loader pour chaque requete |
|
46 |
window.Request = Class.refactor(Request, { |
|
47 |
initialize: function(options){ |
|
48 |
this.previous(options); |
|
49 |
this.addEvent("onRequest", loader.show.bind(loader)); |
|
50 |
['onComplete', 'onException', 'onCancel'].each(function(event){ |
|
51 |
this.addEvent(event, loader.hide.bind(loader)); |
|
52 |
}, this); |
|
53 |
} |
|
54 |
}); |
Also available in: Unified diff