[SPIP] +spip v3.0.17
[lhc/web/clavette_www.git] / www / prive / javascript / gadgets.js
1 function init_gadgets(url_menu_rubrique){
2 jQuery('#boutonbandeautoutsite').one('mouseover',function(){
3 jQuery(this).siblings('ul').find('li:first>a').animeajax();
4 jQuery.ajax({
5 url: url_menu_rubrique,
6 success: function(c){
7 jQuery('#boutonbandeautoutsite').siblings('ul').remove();
8 jQuery('#boutonbandeautoutsite')
9 .after(c)
10 .parent().find('li').menuFocus();
11 }
12 });
13 });
14 }
15 function focus_zone(selecteur){
16 jQuery(selecteur).eq(0).find('a,input:visible').get(0).focus();
17 return false;
18 }
19 jQuery(document).ready(function(){
20 init_gadgets(url_menu_rubrique);
21 var is_open = 0;
22 jQuery.fn.menuItemOpen = function(){
23 jQuery(this)
24 .addClass('actif')
25 .parents('li').addClass('actif');
26 jQuery(this).siblings('li').removeClass('actif_tempo');
27 is_open = true;
28 return this;
29 }
30 jQuery.fn.menuItemClose = function(){
31 jQuery(this)
32 .removeClass('actif_tempo');
33 is_open = (jQuery(this).parents('ul').eq(-1).find('li.actif').length>0);
34 return this;
35 }
36 // deplier le menu au focus clavier,
37 // enlever ce depliement si passage a la souris,
38 // delai de fermeture.
39 jQuery.fn.menuFocus = function(){
40 jQuery(this)
41 // le replier si un hover de souris sur un autre onglet,
42 // timer sur la fermeture des onglets pour ne pas que ca aille trop vite
43 // timer sur l'ouverture des onglets pour ne tolerer les derapages
44 .hover(
45 function(){
46 if (this.timerout)
47 clearTimeout(this.timerout);
48 this.timerout = null;
49 this.timerin = null;
50 if (is_open)
51 jQuery(this).menuItemOpen();
52 else {
53 var me = jQuery(this);
54 this.timerin= setTimeout(function(){
55 me.menuItemOpen(null);
56 }, 200);
57 }
58 }
59 ,
60 function(){
61 if (this.timerin)
62 clearTimeout(this.timerin);
63 this.timerin = null;
64 if (is_open){
65 var me = jQuery(this).removeClass('actif').addClass('actif_tempo');
66 this.timerout = setTimeout(function(){
67 me.menuItemClose();
68 }, 400);
69 }
70 }
71 )
72 // navigation au clavier :
73 // deplier le ul enfant
74 .find('>a').focus(function(){
75 //jQuery(this).parents('ul').find('>li.actif').removeClass('actif');
76 jQuery(this).parents('li').addClass('actif');
77 })
78 // cacher en partant de l'onglet...
79 .blur(function(){
80 jQuery(this).parents('li').removeClass('actif');
81 });
82 return this;
83 }
84
85 // Controler la position verticale des sous-menus
86 // pour l'instant, effectuer a chaque hover, en cas de changement de taille d'affichage par exemple
87 jQuery('#bando_navigation').hover(function(){
88 hauteur = parseInt(jQuery('#bando_navigation .largeur').height())
89 + parseInt(jQuery('#bando_navigation').css("padding-top"))
90 + parseInt(jQuery('#bando_navigation').css("padding-bottom"));
91 jQuery('#bando_navigation ul li>ul').css({'top':hauteur});
92 });
93
94 jQuery('#bando_navigation li').menuFocus();
95 jQuery('#bando_outils ul.bandeau_rubriques li').menuFocus();
96
97 jQuery('#bandeau_haut #formRecherche input').hover(function(){
98 jQuery('#bandeau_haut ul.actif').trigger('mouseout');
99 });
100 jQuery('#bando_liens_rapides a')
101 .focus(function(){
102 jQuery('#bando_liens_rapides').addClass('actif');
103 })
104 .blur(function(){
105 jQuery('#bando_liens_rapides').removeClass('actif');
106 });
107 if (typeof window.test_accepte_ajax != "undefined")
108 test_accepte_ajax();
109 });