PageSourceSearch

https://bibliotheques-clermontmetropole.eu/iguana/js/applications/KeyboardNavigation.js

js bibliotheques-clermontmetropole.eu collected 2026-10-02 07:52:34 UTC 5,050 bytes, 178 lines download raw bytes

1/*-- ;vc; Version KeyboardNavigation.js/IGU.5 Date 2022-12-08 By TorontoQA Location IGU45QASYNC --*/
2/***
3 *	KEYBOARDNAVIGATION.JS
4 *
5 *	For details, see: http://adviesenzo.nl/examples/cssjsmenu/
6 */
7
8if (window["KeyboardNavigation"]==undefined) {
9	var KeyboardNavigation = {
10		start: function(root) {
11			if (arguments.length==0) return;
12			if (document.getElementsByTagName) {
13				var myMenu = root.getElementsByTagName("A");
14				if (!myMenu) { return; }
15				else {
16					for (var i=0;i<myMenu.length;i++) {
17						//myMenu[i].onmouseover = KeyboardNavigation.checkMO;
18						myMenu[i].onfocus = KeyboardNavigation.checkF;
19						//myMenu[i].onblur = KeyboardNavigation.checkB;
20						myMenu[i].onclick = KeyboardNavigation.checkClick;
21					}
22					root.style.visibility = "visible";
23					root.className += " kbNavVisible";
24					root.onmouseout = KeyboardNavigation.checkOut;
25				}
26			}
27		},
28
29		// Stores the currently open UL objects
30		openMenus: [],
31
32		// Stores the timer for closing the menu
33		navTimer: null,
34		
35		checkB: function(e) {
36			KeyboardNavigation.blurred = true;
37			var f = function () {
38				if (KeyboardNavigation.blurred) KeyboardNavigation.closeAll(0);
39			}
40			KeyboardNavigation.blurTimeout = setTimeout(f,150);
41		},
42		
43		checkMO: function(e) {
44			if (!e) var e = window.event;
45			KeyboardNavigation.navHoverStyle(e,0);
46		},
47		
48		checkF:function(e) {
49			if (!e) var e = window.event;
50			KeyboardNavigation.navHoverStyle(e,1);
51		},
52
53		navHoverStyle: function(e,focus) {
54			KeyboardNavigation.blurred = false;
55			var kb = KeyboardNavigation;
56			if (!e) var e = window.event;
57			if (e.target) var tg = e.target;
58			else if (e.srcElement) var tg = e.srcElement;
59
60			var linkElm = tg;
61			while (linkElm.nodeName != 'A') {
62				linkElm = linkElm.parentNode;
63			}
64
65			while (tg.nodeName != 'LI')
66				tg = tg.parentNode;
67
68			// Determine if and if so, which submenu items to close
69			var tgParent = tg.parentNode;
70			while (tgParent.nodeName != 'UL')
71				tgParent = tgParent.parentNode;
72
73			if (tgParent.className.indexOf('kbNav')>-1) {
74				kb.closeAll(0);
75			}
76			else {
77				var j=0;
78				while (kb.openMenus[j] != tgParent && j<kb.openMenus.length) {
79					j++;
80				}
81				kb.closeAll(j+1);
82			}
83
84			// Determine if the current item has a submenu and if so, open it
85			var subMenuElm = false;
86			for (var i=0;i<tg.childNodes.length;i++) {
87				if ( tg.childNodes[i].nodeName == 'UL') {
88					subMenuElm = tg.childNodes[i];
89				}
90			}
91
92			if (subMenuElm) {
93				var li = linkElm;
94				while (li.nodeName!="LI") li=li.parentNode;
95				if (li.className!="") li.className += " ";
96				if (focus) li.className += 'focus';
97				subMenuElm.style.display = 'block';
98				kb.openMenus.push(subMenuElm);
99			}
100
101			// Set the timer
102			// 20200805-eh
103			kb.checkNavTimer();
104
105			return false;
106		},
107
108		checkNavTimer: function() {
109			var kb = KeyboardNavigation;
110			if (kb.navTimer) clearTimeout(kb.navTimer);
111			kb.navTimer = setTimeout('KeyboardNavigation.closeAll(0)',5000);
112		},
113
114		closeAll: function(lvl) {
115			var kb = KeyboardNavigation;
116			var oMl = kb.openMenus.length-1;
117			if (lvl<0) return;
118			for (var i=oMl;i>=lvl;i--) {
119				var linkElm = kb.openMenus[i].previousSibling;
120				while (linkElm.nodeName.toUpperCase() != 'A') linkElm = linkElm.previousSibling;
121				var li = linkElm;
122				while (li.nodeName.toUpperCase()!="LI") li=li.parentNode;
123				var cls = li.className.split(" ");
124				var cName = "";
125				for (var c=0;c<cls.length;++c) {
126					if (cls[c]!="focus") {
127						cName += (cName==""?"":" ")+cls[c];
128					}
129				}
130				li.className = cName;
131				kb.openMenus[i].style.display = 'none';
132				KeyboardNavigation.openMenus.pop();
133			}
134		},
135		
136		// 20200805-eh
137		checkOut: function () {
138			KeyboardNavigation.blurred = true;
139			setTimeout(KeyboardNavigation.checkOutST, 10);
140		},
141		checkOutST: function () {
142			if (KeyboardNavigation.blurred) KeyboardNavigation.closeAll(0);
143		},
144		currentFocused: null,
145		checkClick: function (e) {
146			e = e || window.event;
147			var tg = e.target;
148			if (!tg) return;
149			while (tg.nodeName!='A') tg = tg.parentNode;
150			if (KeyboardNavigation.currentFocused && tg!=KeyboardNavigation.currentFocused) {
151				KeyboardNavigation.currentFocused.classList.remove('focused');
152			}
153			KeyboardNavigation.currentFocused = tg;
154			KeyboardNavigation.currentFocused.classList.toggle('focused');
155		}
156	}
157	
158	var kbf = function () {
159		if (Vfocus["loadCSS"]!=undefined&&window["Data"]!=undefined&&Data["Files"]!=undefined) {
160			Vfocus.loadCSS(Vfocus.Settings.cssDir+"applications/KeyboardNavigation.css");
161			delete kbf;
162		} else {
163			setTimeout(kbf,200);
164		}
165	}
166	kbf();
167	// default check
168	var kbq = function () {
169		if (Vfocus["query"]!=undefined) {
170			var kbNavs=Vfocus.query("ul.kbNav");
171			if (kbNavs.length) for (var i=0;i<kbNavs.length;++i) KeyboardNavigation.start(kbNavs[i]);
172			delete kbq;
173		} else {
174			setTimeout(kbq,200);
175		}
176	}
177	setTimeout(kbq,400);
vendor: 3 bytes, line 178
178}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.