2 // Copyright 2008 Grégory Burri
4 // This file is part of Euphorik.
6 // Euphorik is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
11 // Euphorik is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with Euphorik. If not, see <http://www.gnu.org/licenses/>.
19 /*jslint laxbreak:true */
25 euphorik
.Pages = function() {
26 this.pageCourante
= undefined;
31 * Accepte soit un objet soit un string.
32 * un string correspond au nom de la page, par exemple : "page" -> "page.html"
34 euphorik
.Pages
.prototype.ajouterPage = function(page
) {
35 if (typeof page
=== "string") {
36 this.pages
[page
] = page
;
38 page
.pages
= this; // la magie des langages dynamiques : le foutoire
39 this.pages
[page
.nom
] = page
;
43 euphorik
.Pages
.prototype.afficherPage = function(nomPage
, forcerChargement
) {
44 forcerChargement
= forcerChargement
|| false;
46 var page
= this.pages
[nomPage
];
47 if (!page
|| (!forcerChargement
&& page
=== this.pageCourante
)) {
51 if (this.pageCourante
&& this.pageCourante
.decharger
) {
52 this.pageCourante
.decharger();
55 $("#menu li").removeClass("courante");
56 $("#menu li." + nomPage
).addClass("courante");
58 this.pageCourante
= page
;
60 if (typeof page
=== "string") {
61 $.ajax({async: false, url: "pages/" + page
+ ".html", success : function(page
) { contenu
+= page
; }});
63 contenu
+= this.pageCourante
.contenu();
66 $("#page").html(contenu
).removeClass().addClass(
67 this.pageCourante
.nom
+
68 (this.pageCourante
.classes
? " " + this.pageCourante
.classes() : "") // l'objet peut fournire des classes css supplémentaires sous la forme d'un string
71 if (this.pageCourante
.charger
) {
72 this.pageCourante
.charger();