3 |
david |
1 |
/*
|
|
|
2 |
* Application for Facebox (for jQuery)
|
|
|
3 |
* Adaptation pour le Squelette SPIP
|
|
|
4 |
* Ce fichier peut également contenir toutes les scripts custom
|
|
|
5 |
* (06/01/2008)
|
|
|
6 |
* @requires jQuery v1.2 or later
|
|
|
7 |
*/
|
|
|
8 |
jQuery(document).ready(function($) {
|
|
|
9 |
$('a[rel*=facebox]').facebox({
|
|
|
10 |
loading_image : 'squelettes/images/loading.gif',
|
|
|
11 |
close_image : 'squelettes/images/closelabel.gif'
|
|
|
12 |
})
|
8 |
aurelien |
13 |
})
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
function changerAccordeonOuOnglets(ongletId) {
|
|
|
17 |
|
|
|
18 |
i = 0 ;
|
|
|
19 |
max = $(".lien_onglet").length ;
|
|
|
20 |
|
|
|
21 |
if(consultation) {
|
|
|
22 |
|
|
|
23 |
$("#lien_onglet_0").parent().nextAll().each(function () {
|
|
|
24 |
$(this).hide();
|
|
|
25 |
});
|
|
|
26 |
|
|
|
27 |
$("#lien_onglet_"+ongletId).parent().nextAll().each(function () {
|
|
|
28 |
$(this).show();
|
|
|
29 |
});
|
|
|
30 |
|
|
|
31 |
$("#lien_onglet_"+(ongletId+1)).parent().nextAll().each(function () {
|
|
|
32 |
$(this).hide();
|
|
|
33 |
});
|
|
|
34 |
|
34 |
aurelien |
35 |
for(i = 0 ; i <= max - 1 ; i++) {
|
8 |
aurelien |
36 |
$("#lien_onglet_"+i).parent().show();
|
34 |
aurelien |
37 |
$("#lien_onglet_"+i).removeClass("item_actif")
|
8 |
aurelien |
38 |
}
|
|
|
39 |
|
|
|
40 |
$("#lien_onglet_"+ongletId).addClass("item_actif");
|
|
|
41 |
$("#fin_onglet").parent().nextAll().each(function () {
|
|
|
42 |
$(this).show();
|
|
|
43 |
});
|
|
|
44 |
}
|
|
|
45 |
else {
|
|
|
46 |
|
|
|
47 |
$("#lien_onglet_0").parent().parent().nextAll().each(function () {
|
|
|
48 |
$(this).hide();
|
|
|
49 |
});
|
|
|
50 |
|
|
|
51 |
$("#lien_onglet_"+ongletId).parent().parent().nextAll().each(function () {
|
|
|
52 |
$(this).show();
|
|
|
53 |
});
|
|
|
54 |
|
|
|
55 |
$("#lien_onglet_"+(ongletId+1)).parent().parent().nextAll().each(function () {
|
|
|
56 |
$(this).hide();
|
|
|
57 |
});
|
|
|
58 |
|
34 |
aurelien |
59 |
for(i = 0 ; i <= max - 1 ; i++) {
|
8 |
aurelien |
60 |
$("#onglet_"+i).removeClass("onglet_actif");
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
$("#onglet_"+ongletId).addClass("onglet_actif") ;
|
|
|
64 |
|
|
|
65 |
$("#fin_onglet").parent().parent().nextAll().each(function () {
|
|
|
66 |
$(this).show();
|
|
|
67 |
});
|
|
|
68 |
}
|
|
|
69 |
}
|
|
|
70 |
|
34 |
aurelien |
71 |
function changerOngletsConsultation(idOngletConsulte) {
|
|
|
72 |
|
|
|
73 |
$("#consultation_fiche").hide();
|
|
|
74 |
$("#lien_forum_general").hide();
|
|
|
75 |
$("#zone_commentaires").hide();
|
|
|
76 |
$("#lien_demo_general").hide();
|
|
|
77 |
$("#lien_telechargement_general").hide();
|
|
|
78 |
$("#lien_forge_general").hide();
|
|
|
79 |
|
|
|
80 |
if(idOngletConsulte == "onglet_lien_ici") {
|
|
|
81 |
|
|
|
82 |
$("#consultation_fiche").show();
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
if(idOngletConsulte == "onglet_lien_forum") {
|
|
|
86 |
|
|
|
87 |
$("#lien_forum_general").show(); $("#zone_commentaires").show();
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
if(idOngletConsulte == "onglet_lien_demo") {
|
|
|
91 |
|
|
|
92 |
$("#lien_demo_general").show();
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
if(idOngletConsulte == "onglet_lien_forge") {
|
|
|
96 |
|
|
|
97 |
$("#lien_telechargement_general").show();
|
|
|
98 |
$("#lien_forge_general").show();
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
function initialiserLiens() {
|
|
|
104 |
|
|
|
105 |
lien_forge = $("#bf_lien_forge") ;
|
|
|
106 |
lien_demo = $("#bf_lien_demo") ;
|
|
|
107 |
lien_telechargement = $("#bf_lien_telechargement") ;
|
|
|
108 |
|
|
|
109 |
if(lien_forge.attr("value").indexOf("http://") == -1) {
|
|
|
110 |
lien_forge.attr("value","http://"+lien_forge.attr("value")) ;
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
if(lien_demo.attr("value").indexOf("http://") == -1) {
|
|
|
114 |
lien_demo.attr("value","http://"+lien_demo.attr("value")) ;
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
if(lien_telechargement.attr("value").indexOf("http://") == -1) {
|
|
|
118 |
lien_telechargement.attr("value","http://"+lien_telechargement.attr("value")) ;
|
|
|
119 |
}
|
|
|
120 |
}
|
|
|
121 |
|
8 |
aurelien |
122 |
function ajouterAccordeonOuOnglets() {
|
|
|
123 |
|
|
|
124 |
onglets = $(".lien_onglet") ;
|
|
|
125 |
consultation = false;
|
|
|
126 |
|
|
|
127 |
fiche_consultation = $(".BAZ_fiche_titre_application");
|
|
|
128 |
bouton_valider = $("input[name=\"valider\"]");
|
|
|
129 |
if(fiche_consultation.length != 0 || bouton_valider.html() == null) {
|
|
|
130 |
consultation = true ;
|
|
|
131 |
}
|
|
|
132 |
else {
|
|
|
133 |
htmlOnglets = '<div id="selecteur_onglets" class="onglets"> <ul id="liste_onglets">';
|
34 |
aurelien |
134 |
initialiserLiens() ;
|
|
|
135 |
|
8 |
aurelien |
136 |
}
|
|
|
137 |
|
|
|
138 |
for(i = 0 ; i < onglets.length; i++)
|
|
|
139 |
{
|
|
|
140 |
lienEnCours = onglets[i];
|
|
|
141 |
lienEnCours.setAttribute("id","lien_onglet_"+(i));
|
|
|
142 |
|
|
|
143 |
if(!consultation) {
|
|
|
144 |
htmlOnglets += '<li><a id="onglet_'+i+'" href="javascript:changerAccordeonOuOnglets('+i+','+consultation+');">'+$('#lien_onglet_'+(i)).html()+'</a></li>';
|
|
|
145 |
}
|
|
|
146 |
}
|
|
|
147 |
|
|
|
148 |
if(!consultation) {
|
|
|
149 |
htmlOnglets += '</ul></div><hr style="clear: both; visibility: hidden">' ;
|
|
|
150 |
$("#formulaire").before(htmlOnglets);
|
|
|
151 |
$(".lien_onglet").parent().hide();
|
|
|
152 |
|
|
|
153 |
$("input[type=\"submit\"][name=\"valider\"]").bind("click",function(event)
|
|
|
154 |
{
|
|
|
155 |
event.preventDefault();
|
|
|
156 |
validerFormulaire(true);
|
|
|
157 |
});
|
|
|
158 |
|
13 |
aurelien |
159 |
bouton_valider = $("input[type=\"submit\"][name=\"valider\"]");
|
8 |
aurelien |
160 |
|
13 |
aurelien |
161 |
if(bouton_valider.length != 0) {
|
|
|
162 |
bouton_valider[0].setAttribute("title","Enregistrer la fiche et la soumettre au copil pour publication");
|
|
|
163 |
}
|
|
|
164 |
|
|
|
165 |
bouton_valider.before("<input type=\"button\" title=\"Sauvegarder la fiche sans la vérifier (celle ci ne sera pas publiée)\" id=\"sauvegarde_form\" onclick=\"validerFormulaire(false)\" value=\"sauvegarder\" />");
|
|
|
166 |
|
|
|
167 |
|
8 |
aurelien |
168 |
}
|
|
|
169 |
else
|
|
|
170 |
{
|
34 |
aurelien |
171 |
// fabrication du contenu de l'onglet Application
|
8 |
aurelien |
172 |
lien_ici = '<li><a id="onglet_lien_ici" href="#">Application</a></li>' ;
|
|
|
173 |
htmlOnglets = '<div id="selecteur_onglets" class="onglets"> <ul id="liste_onglets">';
|
|
|
174 |
htmlOnglets += lien_ici ;
|
34 |
aurelien |
175 |
|
|
|
176 |
|
|
|
177 |
|
|
|
178 |
// fabrication du contenu de l'onglet Communauté
|
|
|
179 |
htmlOnglets += '<li><a id="onglet_lien_forum" href="#">Communauté</a></li>' ;
|
|
|
180 |
|
|
|
181 |
// On crée le lien qui sera placé au dessus de la liste des commentaires
|
|
|
182 |
laius_forum = 'Prochainement, un forum sera mis à votre disposition afin de vous permetre de partager vos commentaires avec la communauté d\'une manière plus complète ' ;
|
|
|
183 |
lien_forum_general = "<div id=\"lien_forum_general\"><h2> Forum</h2><p>"+laius_forum+"</p></div><hr style=\"clear: both; visibility: hidden\">"
|
|
|
184 |
zone_commentaires = $("#zone_commentaires");
|
|
|
185 |
zone_commentaires.after(lien_forum_general);
|
|
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
|
189 |
// fabrication du contenu de l'onglet espace de démo
|
|
|
190 |
htmlOnglets += '<li><a id="onglet_lien_demo" href="#">Espace démo</a></li>' ;
|
|
|
191 |
|
|
|
192 |
// on récupère le lien vers l'espace démo et on le cache
|
|
|
193 |
lien_demo = $("#bf_lien_demo_description");
|
|
|
194 |
if(lien_demo.html() == null || lien_demo.html().replace(/^\s+/g,'').replace(/\s+$/g,'') == "http://") {
|
|
|
195 |
lien_demo_html = " " ;
|
13 |
aurelien |
196 |
}
|
|
|
197 |
else {
|
34 |
aurelien |
198 |
lien_demo_html = "<a href="+lien_demo.html()+" >"+lien_demo.html()+"</a>" ;
|
13 |
aurelien |
199 |
}
|
34 |
aurelien |
200 |
lien_demo.hide();
|
|
|
201 |
|
|
|
202 |
// on récupère le commentaire associé et on le cache aussi
|
|
|
203 |
comm_demo = $("#bf_com_demo_description");
|
|
|
204 |
if(comm_demo.html() == null) {
|
|
|
205 |
comm_demo_html = " Aucune description renseignée " ;
|
13 |
aurelien |
206 |
}
|
|
|
207 |
else {
|
34 |
aurelien |
208 |
comm_demo_html = comm_demo.html();
|
13 |
aurelien |
209 |
}
|
34 |
aurelien |
210 |
comm_demo.hide();
|
|
|
211 |
|
|
|
212 |
lien_demo_general = "<div id=\"lien_demo_general\"><h2> Espace de démonstration</h2><p id=laius_demo>"+comm_demo_html+"</p>"+lien_demo_html+"</div><hr style=\"clear: both; visibility: hidden\">" ;
|
|
|
213 |
zone_commentaires.after(lien_demo_general);
|
|
|
214 |
|
|
|
215 |
|
|
|
216 |
// fabrication du contenu de l'onglet téléchargement et forge
|
|
|
217 |
htmlOnglets += '<li><a id="onglet_lien_forge" href="#">Téléchargement et forge</a></li>' ;
|
|
|
218 |
|
|
|
219 |
// on récupère les liens vers l'espace téléchargement et forge et on les cache
|
|
|
220 |
lien_forge = $("#bf_lien_forge_description");
|
|
|
221 |
if(lien_forge.html() == null || lien_forge.html().replace(/^\s+/g,'').replace(/\s+$/g,'') == "http://") {
|
|
|
222 |
lien_forge_html = " " ;
|
13 |
aurelien |
223 |
}
|
|
|
224 |
else {
|
34 |
aurelien |
225 |
lien_forge_html = "<a href="+lien_forge.html()+" >"+lien_forge.html()+"</a>" ;
|
13 |
aurelien |
226 |
}
|
34 |
aurelien |
227 |
lien_forge.hide();
|
|
|
228 |
|
|
|
229 |
lien_telechargement = $("#bf_lien_telechargement_description");
|
|
|
230 |
if(lien_telechargement.html() == null || lien_telechargement.html().replace(/^\s+/g,'').replace(/\s+$/g,'') == "http://") {
|
|
|
231 |
lien_telechargement_html = " " ;
|
|
|
232 |
}
|
|
|
233 |
else {
|
|
|
234 |
lien_telechargement_html = "<a href="+lien_telechargement.html()+" >"+lien_telechargement.html()+"</a>" ;
|
|
|
235 |
}
|
|
|
236 |
lien_telechargement.hide();
|
|
|
237 |
|
|
|
238 |
// on récupère les commentaires associés à l'espace téléchargement et forge et on les cache
|
|
|
239 |
comm_forge = $("#bf_com_forge_description");
|
|
|
240 |
if(comm_forge.html() == null) {
|
|
|
241 |
comm_forge_html = " Aucune description renseignée " ;
|
|
|
242 |
}
|
|
|
243 |
else {
|
|
|
244 |
comm_forge_html = comm_forge.html();
|
|
|
245 |
}
|
|
|
246 |
comm_forge.hide()
|
|
|
247 |
|
|
|
248 |
comm_telechargement = $("#bf_com_telechargement_description");
|
|
|
249 |
if(comm_telechargement.html() == null) {
|
|
|
250 |
comm_telechargement_html = " Aucune description renseignée " ;
|
|
|
251 |
}
|
|
|
252 |
else {
|
|
|
253 |
comm_telechargement_html = comm_telechargement.html();
|
|
|
254 |
}
|
|
|
255 |
comm_telechargement.hide();
|
|
|
256 |
|
|
|
257 |
lien_telechargement_general = "<div id=\"lien_telechargement_general\"><h2> Téléchargement </h2><p id=laius_telechargement>"+comm_telechargement_html+"</p>"+lien_telechargement_html+"</div><hr style=\"clear: both; visibility: hidden\"><br />" ;
|
|
|
258 |
lien_forge_general = "<div id=\"lien_forge_general\"><h2> Forge </h2> <p id=laius_forge>"+comm_forge_html+"</p>"+lien_forge_html+"</div><hr style=\"clear: both; visibility: hidden\">" ;
|
|
|
259 |
|
|
|
260 |
$("#lien_demo_general").after(lien_telechargement_general+lien_forge_general);
|
|
|
261 |
|
|
|
262 |
|
|
|
263 |
// on ferme la liste des onglets
|
8 |
aurelien |
264 |
htmlOnglets += '</ul></div><hr style="clear: both; visibility: hidden">' ;
|
|
|
265 |
|
34 |
aurelien |
266 |
// et on la positionne à l'endroit indiqué par un id spécifique
|
|
|
267 |
$("#ancre_onglets").after(htmlOnglets);
|
8 |
aurelien |
268 |
|
34 |
aurelien |
269 |
// on cache la rubrique lien
|
|
|
270 |
$("#lien_onglet_"+(onglets.length - 1)).hide();
|
|
|
271 |
|
|
|
272 |
|
|
|
273 |
// et tous les intitulés concernant les information de la fiche qui ont été
|
|
|
274 |
// déplacées dans les onglet
|
8 |
aurelien |
275 |
$("#bf_lien_forge_rubrique").hide();
|
|
|
276 |
$("#bf_lien_demo_rubrique").hide();
|
|
|
277 |
$("#bf_lien_forum_rubrique").hide();
|
34 |
aurelien |
278 |
$("#bf_com_demo_rubrique").hide();
|
|
|
279 |
$("#bf_com_forge_rubrique").hide();
|
|
|
280 |
$("#bf_com_telechargement_rubrique").hide();
|
8 |
aurelien |
281 |
|
34 |
aurelien |
282 |
// on ajoute ensuite la gestion du clic pour le changement d'onglet
|
|
|
283 |
$("#onglet_lien_ici").bind("click", function() { changerOngletsConsultation("onglet_lien_ici"); });
|
|
|
284 |
$("#onglet_lien_forum").bind("click", function() { changerOngletsConsultation("onglet_lien_forum"); });
|
|
|
285 |
$("#onglet_lien_demo").bind("click", function() { changerOngletsConsultation("onglet_lien_demo"); });
|
|
|
286 |
$("#onglet_lien_forge").bind("click", function() { changerOngletsConsultation("onglet_lien_forge"); });
|
|
|
287 |
|
|
|
288 |
// et enfin on laisse visible quel le contenu du premier onglet
|
|
|
289 |
changerOngletsConsultation("onglet_lien_ici");
|
8 |
aurelien |
290 |
}
|
|
|
291 |
|
|
|
292 |
$(".BAZ_bulle_corps_application").before('<hr style="clear: both; visibility: hidden">');
|
|
|
293 |
|
|
|
294 |
for(j = 0 ; j < onglets.length; j++)
|
|
|
295 |
{
|
|
|
296 |
ajouterListenersAccordeonOuOnglets(j,consultation) ;
|
|
|
297 |
}
|
34 |
aurelien |
298 |
|
|
|
299 |
cacherAfficherLiensListe(false);
|
8 |
aurelien |
300 |
changerAccordeonOuOnglets(0,consultation);
|
|
|
301 |
}
|
|
|
302 |
|
34 |
aurelien |
303 |
function cacherAfficherLiensListe(afficher) {
|
|
|
304 |
|
|
|
305 |
max = $(".lien_onglet").length
|
|
|
306 |
|
|
|
307 |
if(afficher == true) {
|
|
|
308 |
|
|
|
309 |
}
|
|
|
310 |
else {
|
|
|
311 |
$("#lien_onglet_"+(max)).parent().nextAll().each(function () {
|
|
|
312 |
$(this).hide();
|
|
|
313 |
});
|
|
|
314 |
}
|
|
|
315 |
}
|
|
|
316 |
|
8 |
aurelien |
317 |
function ajouterListenersAccordeonOuOnglets(id,consultation) {
|
|
|
318 |
if(consultation) {
|
|
|
319 |
$("#lien_onglet_"+id).bind("click", function() {changerAccordeonOuOnglets(id,consultation);});
|
|
|
320 |
}
|
|
|
321 |
}
|
|
|
322 |
|
|
|
323 |
function validerFormulaire(verifier) {
|
|
|
324 |
if(verifier == true) {
|
|
|
325 |
try { if(validate_formulaire(document.getElementById("formulaire"))) { $("#formulaire").submit();} } catch(e) { window.alert(e.message); return true; };
|
|
|
326 |
}
|
|
|
327 |
else {
|
34 |
aurelien |
328 |
|
|
|
329 |
var url_origine = $("#formulaire").attr("action") ;
|
|
|
330 |
|
|
|
331 |
modif = false ;
|
|
|
332 |
|
|
|
333 |
url_ajax = $("#formulaire").attr("action") ;
|
|
|
334 |
url_ajax += "&valider_fiche=0"
|
|
|
335 |
|
|
|
336 |
var callback = function(reponse_json) {
|
|
|
337 |
|
|
|
338 |
var reponse = eval('('+reponse_json+')');
|
|
|
339 |
|
|
|
340 |
if(reponse.success == true) {
|
|
|
341 |
window.alert('Votre fiche a été sauvegardée');
|
|
|
342 |
|
|
|
343 |
// cas de la nouvelle fiche on passe en mode modification
|
|
|
344 |
if(url_origine.indexOf("bazar_action=11") != -1) {
|
|
|
345 |
url_origine = url_origine.replace("bazar_action=11","bazar_action=13") ;
|
|
|
346 |
url_origine += "&id_fiche="+reponse.id_fiche ;
|
|
|
347 |
}
|
|
|
348 |
|
|
|
349 |
$("#formulaire").attr("action",url_origine);
|
|
|
350 |
|
|
|
351 |
}
|
|
|
352 |
else {
|
|
|
353 |
window.alert('Problème de sauvegarde de la fiche');
|
|
|
354 |
$("#formulaire").attr("action",url_origine);
|
|
|
355 |
}
|
|
|
356 |
};
|
|
|
357 |
|
|
|
358 |
$("#formulaire").attr("action",url_ajax);
|
|
|
359 |
$("#formulaire").ajaxSubmit(callback);
|
|
|
360 |
|
|
|
361 |
$("#formulaire").attr("action",url_origine);
|
|
|
362 |
|
|
|
363 |
return false ;
|
8 |
aurelien |
364 |
}
|
|
|
365 |
}
|
|
|
366 |
|
|
|
367 |
$(document).ready(ajouterAccordeonOuOnglets);
|