PageSourceSearch

https://legimonaco.mc/libs/lib-sc/scDynUiMgr.js

js legimonaco.mc collected 2026-10-02 07:50:11 UTC 14,490 bytes, 434 lines download raw bytes

1
2 
3var scDynUiMgr = {
4
5
6	collBlkToggle: function(pTitle, pCo, pClassOpen, pClassClosed) {
7		if (pTitle.nodeType != 1 || pCo.nodeType != 1){
8			scCoLib.log("scDynUiMgr.collBlkToggle error : pTitle or pCo not an element.");
9			return null;
10		}
11		if (typeof pCo.fCollapsed == "undefined") {
12			pCo.fClassName = pCo.className;
13			pCo.fTitle = pTitle;
14			if (this.collBlk.fMode == 1) pCo.fCollapsed = false;
15			else pCo.fCollapsed = pCo.style.display == "none";
16		}
17		pTitle.className = pCo.fCollapsed ? pClassOpen : pClassClosed;
18		pCo.className = pCo.fClassName + " " + this.collBlk.fClassPrefix + (pCo.fCollapsed ? "open" : "closed");
19		if (this.collBlk.fMode == 0) pCo.style.display = pCo.fCollapsed ? "" : "none";
20		if (pTitle.getAttribute("role")) pTitle.setAttribute("aria-expanded", pCo.fCollapsed);
21		if (pCo.fCollapsed) for (var i=0; i<this.collBlk.fOpenListeners.length; i++) try{this.collBlk.fOpenListeners[i](pCo,pTitle);}catch(e){}
22		else for (var i=0; i<this.collBlk.fCloseListeners.length; i++) try{this.collBlk.fCloseListeners[i](pCo,pTitle);}catch(e){}
23		if (scCoLib.isIE) {
24			var vTags = pCo.getElementsByTagName("IFRAME");
25			if (pCo.fCollapsed) {
26				for(var i=0; i<vTags.length; i++) vTags[i].src = vTags[i].bkpSrc ? vTags[i].bkpSrc : vTags[i].src;
27			} else {
28				for(var i=0; i<vTags.length; i++) {
29					vTags[i].bkpSrc = vTags[i].src;
30					vTags[i].src = "";
31				}
32			}
33		}
34		if("scSiLib" in window) scSiLib.fireResizedNode(pCo);
35		pCo.fCollapsed = !pCo.fCollapsed;
36		return !pCo.fCollapsed;
37	},
38	
39
40	displaySubWindow: function(pAnc,pUrl,pName,pOpt) {
41		scCoLib.log("scDynUiMgr.displaySubWindow("+pUrl+","+pName+","+pOpt+")");
42		var vOpt = (this.subWindow.fOpt.OVERRIDE ? this.subWindow.fOpt : pOpt || this.subWindow.fOpt);
43
44		try{if (!vOpt.IMBR && window.frameElement && window.frameElement.scSubWin) {
45			window.location = pUrl;
46			return;
47		}}catch(e){}
48		if (typeof pAnc.fSwId == "undefined") this.subWindow.xInitSw(pAnc, pName, vOpt);
49		this.subWindow.xShow(pAnc.fSwId,pUrl);
50		for (var i=0; i<this.subWindow.fOpenListeners.length; i++) try{this.subWindow.fOpenListeners[i](pAnc.fSwId);}catch(e){}
51	},
52
53	hideSubWindow: function(pId) {
54		scCoLib.log("scDynUiMgr.hideSubWindow("+pId+")");
55		this.subWindow.xHide(pId);
56		for (var i=0; i<this.subWindow.fCloseListeners.length; i++) try{this.subWindow.fCloseListeners[i](pId);}catch(e){}
57	},
58	
59
60	handleBtnKeyUp: function(pEvent) {
61		pEvent = pEvent || window.pEvent;
62		if (pEvent.keyCode === 32) pEvent.target.click();
63	},
64	handleBtnKeyDwn: function(pEvent) {
65		pEvent = pEvent || window.pEvent;
66		if (pEvent.keyCode === 32) pEvent.preventDefault();
67	},
68	
69
70	addElement : function(pName, pParent, pClassName, pNxtSib, pStyle){
71		var vElt;
72		if(scCoLib.isIE && pName.toLowerCase() == "iframe") {
73			var vFrmHolder = this.getDocument(pParent).createElement("div");
74			pParent.appendChild(vFrmHolder);
75			vFrmHolder.innerHTML = '<iframe marginheight="0" marginwidth="0" frameborder="0" allowtransparency="true" allowfullscreen="true" title=""></iframe>';
76			vElt = vFrmHolder.firstChild;
77			if (pNxtSib) pParent.insertBefore(vElt,pNxtSib)
78			else pParent.appendChild(vElt);
79			pParent.removeChild(vFrmHolder);
80		} else {
81			vElt = this.getDocument(pParent).createElement(pName);
82			if(pName.toLowerCase() == "iframe") {
83				vElt.setAttribute("frameborder","0");
84				vElt.setAttribute("allowfullscreen","true");
85			}
86			if (pNxtSib) pParent.insertBefore(vElt,pNxtSib)
87			else pParent.appendChild(vElt);
88		}
89		if (pClassName) vElt.className = pClassName;
90		if (pStyle) {
91			for (var vSelect in pStyle) vElt.style[vSelect] = pStyle[vSelect]
92		}
93		return vElt;
94	},
95	
96
97	readStyle : function(pElt, pProp) {
98		try {
99			if (pElt.nodeType!=1) return null;
100			var vVal = null;
101			if (pElt.style && pElt.style[pProp]) {
102				vVal = pElt.style[pProp];
103			} else if (pElt.currentStyle) {
104				vVal = pElt.currentStyle[pProp];
105			} else {
106				var vDefaultView = pElt.ownerDocument.defaultView;
107				if (vDefaultView && vDefaultView.getComputedStyle) {
108					var vStyle = vDefaultView.getComputedStyle(pElt, null);
109					var vProp = pProp.replace(/([A-Z])/g,"-$1").toLowerCase();
110					if (vStyle[vProp]) return vStyle[vProp];
111					else vVal = vStyle.getPropertyValue(vProp);
112				}
113			}
114			return vVal.replace(/\"/g,""); //Opera returns certain values quoted (literal colors).
115		} catch (e) {
116			return null;
117		}
118	},
119
120	getDocument: function(pElt) {
121		if(pElt.ownerDocument) return pElt.ownerDocument;
122		else if (pElt.document) return pElt.document;
123		else return document;
124	}
125}
126
127scDynUiMgr.collBlk = {
128	fMode : 0, // 0=collapse by style (default), 1=collapse by class
129	fClassPrefix : "collBlk_",
130	fOpenListeners : new Array(),
131	fCloseListeners : new Array(),
132	addOpenListener: function(pFunc) {this.fOpenListeners.push(pFunc)},
133	addCloseListener: function(pFunc) {this.fCloseListeners.push(pFunc)}
134}
135
136
137scDynUiMgr.subWindow = {
138	fMode : 0, // 0=collapse by style (default), 1=collapse by class
139	fClassPrefix : "subWin_",
140	fZIndex : 1000,
141	fOpt : {},
142	fSubWins : [],
143	fOpenListeners : new Array(),
144	fCloseListeners : new Array(),
145	fOnLoadListeners : new Array(),
146	addOpenListener: function(pFunc) {this.fOpenListeners.push(pFunc)},
147	addCloseListener: function(pFunc) {this.fCloseListeners.push(pFunc)},
148	addOnLoadListener: function(pFunc) {this.fOnLoadListeners.push(pFunc)},
149	xInitSw: function(pAnc,pName,pOpt) {
150		var vSubWinTi = pOpt.SUBWINTI || "";
151		var vCloseBtnCo = pOpt.CLOSEBTNCO || "X";
152		var vCloseBtnTi = pOpt.CLOSEBTNTI || "";
153		var vBody = scDynUiMgr.getDocument(pAnc).body;
154		var vCont = pOpt.ANCHORPATH ? scPaLib.findNode(pOpt.ANCHORPATH, (pOpt.ANCHORCTX ? pOpt.ANCHORCTX : pAnc)) || vBody : vBody;
155		var vId = scDynUiMgr.subWindow.fSubWins.length;
156		var vWin = scDynUiMgr.addElement("div",vCont,this.xBuildCls(pName,"win"),null,{position:"absolute"});
157		vWin.setAttribute("role", "dialog");
158		vWin.fClassName = vWin.className
159		vWin.fAnc = pAnc;
160		vWin.fOpt = pOpt;
161		vWin.fOver = scDynUiMgr.addElement("div",vCont,this.xBuildCls(pName,"over"),vWin,{position:"absolute"});
162		vWin.fOver.fClassName = vWin.fOver.className
163		if (!pOpt.NOSUBWINTI) {
164			var vTi = scDynUiMgr.addElement("div",vWin,this.xBuildCls(pName,"ti"));
165			var vBtnCls = scDynUiMgr.addElement("a",vTi,this.xBuildCls(pName,"x"));
166			if (vCloseBtnTi) vBtnCls.title = vCloseBtnTi;
167			vBtnCls.href = "#";
168			vBtnCls.onclick = function() {
169				scDynUiMgr.hideSubWindow(vId);
170				return false;
171			}
172			var vBtnClsCo = scDynUiMgr.addElement("span",vBtnCls);
173			vBtnClsCo.innerHTML = vCloseBtnCo;
174			vWin.fTi = scDynUiMgr.addElement("span",vTi);
175			vWin.fTi.innerHTML = vSubWinTi;
176		}
177		var vCo = scDynUiMgr.addElement("div",vWin,this.xBuildCls(pName,"co"));
178		vWin.fFra = scDynUiMgr.addElement("iframe",vCo,this.xBuildCls(pName,"fra"));
179		vWin.fFra.scSubWin = true;
180		vWin.fFra.fWin = vWin;
181		vWin.fFra.title = vSubWinTi;
182		vWin.fFra.setSubWindowTitle = function(pTitle){
183			var vSubWin = scDynUiMgr.subWindow.fSubWins[vId];
184			if(vSubWin.fTi) vSubWin.fTi.innerHTML = pTitle;
185			vSubWin.fFra.title = pTitle;
186			vSubWin.setAttribute("aria-label", pTitle);
187		}
188		vWin.fFra.hideSubWindow = function(){
189			scDynUiMgr.hideSubWindow(vId);
190		}
191		if(scCoLib.isIE) vWin.fFra.onreadystatechange = scDynUiMgr.subWindow.sOnLoad;
192		else vWin.fFra.onload = scDynUiMgr.subWindow.sOnLoad;
193		this.fSubWins[vId] = vWin;
194		pAnc.fSwId = vId;
195	},
196	xShow: function(pId,pUrl) {
197		var vCurrSw = this.fSubWins[pId];
198		if (vCurrSw){
199			vCurrSw.fFra.src = pUrl;
200			vCurrSw.fOver.style.zIndex = this.fZIndex++;
201			vCurrSw.style.zIndex = this.fZIndex++;
202			if (this.fMode == 1){
203				vCurrSw.fOver.className = vCurrSw.fOver.fClassName + " " + this.fClassPrefix + "show";
204				vCurrSw.className = vCurrSw.fClassName + " " + this.fClassPrefix + "show";
205			} else {
206				vCurrSw.fOver.style.display = "";
207				vCurrSw.style.display = "";
208			}
209		}
210	},
211	xHide: function(pId) {
212		var vCurrSw = this.fSubWins[pId];
213		if (vCurrSw){
214			if (this.fMode == 1){
215				vCurrSw.fOver.className = vCurrSw.fOver.fClassName + " " + this.fClassPrefix + "hide";
216				vCurrSw.className = vCurrSw.fClassName + " " + this.fClassPrefix + "hide";
217			} else {
218				vCurrSw.fOver.style.display = "none";
219				vCurrSw.style.display = "none";
220			}
221			vCurrSw.fFra.src = "";
222			vCurrSw.fAnc.focus();
223		}
224	},
225	xBuildCls: function(pCls, pSufx) {
226		var vCls = pCls.split(" ");
227		var vRetCls = "";
228		for(var i=0; i<vCls.length; i++) vRetCls += vCls[i]+(pSufx ? ("_"+pSufx) : "")+" ";
229		return(vRetCls);
230	},
231	sOnLoad: function() {
232		if(scCoLib.isIE && this.readyState != "complete") return;
233		for (var i=0; i<scDynUiMgr.subWindow.fOnLoadListeners.length; i++) try{scDynUiMgr.subWindow.fOnLoadListeners[i](this);}catch(e){}
234	}
235}
236
237
238var dom = {
239
240	/** Clone le contenu d'un noeud (dans le cas d'un template, la propriété content est utilisée) */
241	cloneContents: function (pNode) {
242		if (pNode.content) return pNode.content.cloneNode(true);
243		else {
244			var vRange = document.createRange();
245			vRange.selectNodeContents(pNode);
246			return vRange.cloneContents();
247		}
248	},
249
250	/** Retourne le premier ancêtre correspondant a un sélecteur CSS */
251	selectAncestor: function (pNode, pSelector) {
252		if (pNode.closest){
253			return pNode.closest(pSelector);
254		} else {
255			var vMatches = pNode.matches || pNode.webkitMatchesSelector || pNode.mozMatchesSelector || pNode.msMatchesSelector || pNode.oMatchesSelector,
256				vParent = pNode.parentNode;
257			while (vParent && vParent.nodeType != Node.DOCUMENT_NODE) {
258				if (vMatches.call(vParent, pSelector)) return vParent;
259				vParent = vParent.parentNode;
260			}
261		}
262		return null;
263	},
264
265	createAndDispatchEvent: function (pElement, pType, pDetail) {
266		var vEvent = document.createEvent('CustomEvent');
267		vEvent.initCustomEvent(pType, true, true, pDetail);
268		return pElement.dispatchEvent(vEvent);
269	}
270};
271
272dom.newBd = function (pNode) {
273	return new dom.DomBuilder(pNode);
274}
275
276dom.DomBuilder = function (pNode) {
277	if (pNode) this.setCurrent(pNode);
278}
279dom.DomBuilder.prototype = {
280	setCurrent: function (pNode) {
281		this.fDoc = pNode.nodeType == 9 ? pNode : pNode.ownerDocument;
282		this.fNode = pNode;
283		return this;
284	},
285	elt: function (pName, pClass, pNxtSib) {
286		var vNode = this.fDoc.createElement(pName);
287		if (pClass) vNode.setAttribute("class", pClass);
288		if (this.fOutRoot === this.fNode) this.fOut.push(vNode);
289		else if (pNxtSib) this.fNode.insertBefore(vNode, pNxtSib);
290		else this.fNode.appendChild(vNode);
291		this.fNode = vNode;
292		return this;
293	},
294	/** Si pValue==null l'attribut n'est pas ajouté. */
295	att: function (pName, pValue) {
296		if (pValue != null) this.fNode.setAttribute(pName, pValue);
297		return this;
298	},
299	prop: function (pProp, pValue) {
300		this.fNode[pProp] = pValue;
301		return this;
302	},
303	style: function (pProp, pValue) {
304		if (typeof pProp == "string") this.fNode.style[pProp] = pValue;
305		else for (var i in pProp) this.fNode.style[i] = pProp[i];
306		return this;
307	},
308	call: function (pMethodName, pArgs) {
309		if (Array.isArray(pArgs)) this.fNode[pMethodName].apply(this.fNode, pArgs);
310		else this.fNode[pMethodName].call(this.fNode, pArgs);
311		return this;
312	},
313	listen: function (pEventName, pListener, pUseCapture) {
314		this.fNode.addEventListener(pEventName, pListener, pUseCapture || false);
315		return this;
316	},
317	text: function (pText) {
318		if (pText != null) this.fNode.appendChild(this.fDoc.createTextNode(pText));
319		return this;
320	},
321	up: function () {
322		if (this.fNode === this.fOutRoot) this.inTree();
323		this.fNode = this.fNode.parentNode;
324		if (this.fNode == null) this.fNode = this.fOutRoot;
325		return this;
326	},
327	outTree: function () {
328		if (this.fOut) return this;
329		this.fOut = [];
330		this.fOutRoot = this.fNode;
331		return this;
332	},
333	inTree: function () {
334		if (this.fOut) {
335			for (var i = 0; i < this.fOut.length; i++) this.fOutRoot.appendChild(this.fOut[i]);
336			delete this.fOut;
337			delete this.fOutRoot;
338		}
339		return this;
340	},
341	clear: function () {
342		this.fNode.innerHTML = "";
343		return this;
344	},
345	current: function () {
346		return this.fNode;
347	},
348	currentUp: function () {
349		var vCurr = this.fNode;
350		this.up();
351		return vCurr;
352	}
353}
354
355
356var io = {
357	/** Retourne un objet xmlHttpRequest */
358	createHttpRequest: function () {
359		if (window.XMLHttpRequest && ( !window.location.protocol == "file:" || !window.ActiveXObject)) {
360			return new XMLHttpRequest();
361		} else {
362			return new ActiveXObject("Microsoft.XMLHTTP");
363		}
364	},
365
366	/**
367	 * Retourne une XmlHttpRequest asynchrone qui peut être complétée (headers + listeners) avant d'appeler la méthode send().
368	 */
369	openHttpRequest: function (pUrl, pMethod) {
370		var vReq = io.createHttpRequest();
371		vReq.open(pMethod || "GET", pUrl, true);
372		return vReq;
373	},
374
375	/** Retourne un objet contenant les key/value des paramètres d'une QueryString de la forme "?aa=bb&cc=dd"  */
376	parseQueryString: function (pQueryString) {
377		var vMap = {};
378		pQueryString.replace(/[?&]+([^=&]+)=?([^&]*)/gi, function (pMatch, pKey, pValue) {
379			var vKey = decodeURIComponent(pKey);
380			var vValue = pValue ? decodeURIComponent(pValue) : true;
381			vMap[vKey] ? vMap[vKey] instanceof Array ? vMap[vKey].push(vValue) : vMap[vKey] = [vMap[vKey], vValue] : vMap[vKey] = vValue;
382		});
383		return vMap;
384	},
385
386	/** Ajoute des params à une url. Attention, pValue est échappé, mais pas pKey.*/
387	appendParamsToUrl: function (pUrl /*[, pKey, pValue]...*/) {
388		var vUrl = [pUrl];
389		var vSep = pUrl.indexOf('?') >= 0 ? '&' : '?';
390		for (var i = 1; i < arguments.length;) {
391			vUrl.push(vSep);
392			vSep = '&';
393			vUrl.push(arguments[i++]);
394			var vVal = arguments[i++];
395			if (vVal != null) {
396				vUrl.push('=');
397				vUrl.push(encodeURIComponent(vVal));
398			}
399		}
400		return vUrl.join("");
401	},
402
403	/** Retourne un objet contenant les key/value des cookies d'un document. */
404	parseCookies: function (pDocument) {
405		var vMap = {};
406		var vC = pDocument.cookie;
407		if (!vC) return vMap;
408		var vEntries = vC.split(";");
409		for (var i = 0; i < vEntries.length; i++) {
410			var vEntry = vEntries[i];
411			var vIdx = vEntry.indexOf("=");
412			vMap[vEntry.substring(0, vIdx).trim()] = decodeURIComponent(vEntry.substring(vIdx + 1));
413		}
414		return vMap;
415	},
416
417	/**
418	 * Retourne une callback pour une requete XHR retournant un json avec un code retour normal 200.
419	 * @param pCb function(pJson, pError)
420	 */
421	jsonXhrCb: function (pCb, pCbThis) {
422		return function (pEvt) {
423			try {
424				if (pEvt.target.status == 200) {
425					pCb.call(pCbThis, JSON.parse(pEvt.target.responseText));
426				} else {
427					pCb.call(pCbThis, null, pEvt.target.status);
428				}
429			} catch (e) {
430				pCb.call(pCbThis, null, e);
431			}
432		}
433	}
434}

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.