PageSourceSearch

https://www.santeenjeux.be/includes/javascript/popup.js

js santeenjeux.be collected 2026-10-10 02:25:28 UTC 9,924 bytes, 292 lines download raw bytes

1// +-------------------------------------------------+
2// � 2002-2004 PMB Services / www.sigb.net [email protected] et contributeurs (voir www.sigb.net)
3// +-------------------------------------------------+
4// $Id: popup.js,v 1.15.2.1.2.2 2025/06/13 06:08:01 dgoron Exp $
5
6// openPopUp : permet d'afficher une popup de la taille et � la position donn�e
7//		la fonction gere aussi l'autoCentrage de la popup
8//		(ATTENTION au mode double ecran : la fonction ne gere pas le centrage par rapport � la fenetre mais par rapport � la taille �cran !!)
9//
10//MyFile :	nom du fichier contenant le code HTML du pop-up
11//MyWindow :	nom de la fenetre (ne pas mettre d'espace)
12//MyWidth :	entier indiquant la largeur de la fenetre en pixels
13//MyHeight :	entier indiquant la hauteur de la fenetre en pixels
14//MyLeft :	entier indiquant la position du haut de la fenetre en pixels (-1 pour centrer, -2 pour laisser le navigateur g�rer)
15//MyTop :	entier indiquant la position gauche de la fenetre en pixels (-1 pour centrer, -2 pour laisser le navigateur g�rer)
16//MyParam :	Les parametres supplementaires pour la methode open (par def :infobar=no, status=no, scrollbars=no, menubar=no)
17//ForceSelectorDialog : forçage de l'ouverture en pop-up
18function openPopUp(MyFile,MyWindow,MyWidth,MyHeight,MyLeft,MyTop,MyParam,ForceSelectorDialog) {
19	var ns4 = (document.layers)? true:false;		//NS 4
20	var ie4 = (document.all)? true:false;			//IE 4
21	var dom = (document.getElementById)? true:false;	//DOM
22	var xMax, yMax, xOffset, yOffset;
23
24	//les valeurs par d�faut
25	MyParam = MyParam || 'infobar=no, status=no, scrollbars=yes, toolbar=no, menubar=no';
26	ForceSelectorDialog = ForceSelectorDialog || false;
27	//MyTop = MyTop || -1;
28	MyTop=0;
29	//MyLeft = MyLeft || -1;
30	MyLeft=0;
31
32	xOffset = MyLeft;
33	yOffset = MyTop;
34
35	if(!MyWidth || !MyHeight) {
36		switch(MyWindow) {
37			case 'cart':
38				MyWidth = '600';
39				MyHeight = '700';
40				MyParam = 'toolbar=no, dependent=yes, resizable=yes, scrollbars=yes';
41				break;
42			case 'print_cart':
43			case 'print_dsi':
44				MyWidth = '500';
45				MyHeight = '400';
46				MyParam = 'toolbar=no, dependent=yes, resizable=yes, scrollbars=yes';
47				break;
48			case 'print_doc_dsi':
49				MyWidth = '800';
50				MyHeight = '600';
51				MyParam = 'scrollbars=yes, toolbar=yes, dependent=yes, resizable=yes';
52				break;
53			case 'audit_popup':
54				MyWidth = '700';
55				MyHeight = '500';
56				MyParam = 'toolbar=no, dependent=yes, resizable=yes, scrollbars=yes';
57				break;
58			case 'regex_howto':
59				MyWidth = '500';
60				MyHeight = '400';
61				MyParam = 'scrollbars=yes, resizable=yes';
62				break;
63			case 'lettre':
64			case 'print_PDF':
65				MyWidth = '600';
66				MyHeight = '500';
67				MyParam = 'toolbar=no, dependent=yes, resizable=yes';
68				break;
69			case 'mail':
70				MyWidth = '600';
71				MyHeight = '500';
72				MyParam = 'toolbar=no, dependent=yes, resizable=yes, scrollbars=yes';
73				break;
74			case 'print':
75				MyWidth = '500';
76				MyHeight = '600';
77				MyParam = 'scrollbars=yes,menubar=0,resizable=yes';
78				break;
79			case 'download':
80				MyWidth = '500';
81				MyHeight = '600';
82				MyParam = 'scrollbars=yes,menubar=0';
83				break;
84			case 'selector':
85				MyWidth = '500';
86				MyHeight = '400';
87				MyParam = 'scrollbars=yes, toolbar=no, dependent=yes, resizable=yes';
88				break;
89			case 'calendar':
90				MyWidth = '250';
91				MyHeight = '300';
92				MyParam = 'toolbar=no, dependent=yes, resizable=yes';
93				ForceSelectorDialog = true;
94				break;
95			case 'getcb':
96				MyWidth = '220';
97				MyHeight = '200';
98				MyParam = 'toolbar=no, resizable=yes';
99				break;
100			case 'selector_commande':
101				MyWidth = '600';
102				MyHeight = '400';
103				MyParam = 'infobar=no, status=no, scrollbars=yes, toolbar=no, menubar=no, dependent=yes, resizable=yes';
104				break;
105			case 'selector_notice':
106			case 'selector_category':
107			case 'selector_ontology':
108				MyWidth = '700';
109				MyHeight = '500';
110				MyParam = 'scrollbars=yes, toolbar=no, dependent=yes, resizable=yes';
111				break;
112			case 'options':
113				MyWidth = '550';
114				MyHeight = '600';
115				MyParam = 'menubars=no,resizable=yes,scrollbars=yes';
116				break;
117			case 'print_rel':
118				MyWidth = '600';
119				MyHeight = '500';
120				MyParam = 'scrollbars=yes,menubar=0,resizable=yes';
121				break;
122			case 'circulation':
123				MyWidth = '600';
124				MyHeight = '500';
125				MyParam = 'toolbar=no, dependent=yes, resizable=yes';
126				break;
127			case 'ajouter_un_tag':
128			case 'exporter_la_notice':
129			    MyWidth = '500';
130			    MyHeight = '400';
131			    MyParam = 'scrollbars=yes, resizable=yes';
132			    break;
133			case 'avis':
134			 	MyWidth = '600';
135			    MyHeight = '500';
136				MyParam = 'scrollbars=yes, resizable=yes';
137				break;
138		}
139	}
140		
141	//on precise la taille pour la methode open	
142	var fParam = 'width='+MyWidth
143			+',height='+MyHeight;
144
145	//on ajoute les parametres en plus 
146	var fParam = MyParam + ',' + fParam;
147	if(MyFile && (MyFile.indexOf('select.php') != -1)){
148		require(["apps/pmb/PMBSelectorDialog", 
149		         "dojo/dom", 
150		         "dojo/io-query",
151		         "dojo/dom-attr",
152		         "dojo/topic",
153		         "dojo/dom-construct",
154		         "dojo/on",
155		         "dojo/_base/lang"], function(PMBSelectorDialog, dom, ioQuery, domAttr, topic, domConstruct, on, lang){
156			
157			/** Récupération de l'élément courant **/
158			/** Pas très propre, mais pas ou peu de moyen annexe **/
159			var clickedElement = document.activeElement;
160			
161			//on teste la presence de l'id du schema de catalogage dans l'url
162			if (typeof catalogingSchemeId !== 'undefined') {
163				MyFile +="&cataloging_scheme_id=" + catalogingSchemeId + "&cataloging_scheme_level=" + (parseInt(catalogingSchemeLevel) + 1);
164				delete catalogingSchemeId;
165				delete catalogingSchemeLevel;
166			}
167			var params = ioQuery.queryToObject(MyFile.split('?')[1]);
168			var form = clickedElement.form;
169			
170			/*
171			 * Nous ne publions l'évenement que dans le cas ou les boutons sont dans un formulaire
172			 * marqué part l'attribut "data-advanced-form" et si l'url du openPopup pointe bien vers
173			 * une page select.php
174			 */
175			if(!ForceSelectorDialog && form && domAttr.get(form, 'data-advanced-form') && (MyFile.split('?')[0].indexOf('select.php') != -1)){
176				topic.publish('openPopup', 'openPopup', 'buttonClicked', {
177					params: params,
178					url: MyFile,
179					button: clickedElement
180				});
181			}else{ //Dans le reste des cas, on conserve le cas standard de la popup
182				var http = new http_request();
183		    	var MyFileTitleUrl = MyFile.replace('select.php?', 'ajax.php?module=selectors&is_iframe=1&')+'&action=title';
184		    	http.request(MyFileTitleUrl);
185		    	var MyFileTitle = http.get_text();
186				var dialog = new PMBSelectorDialog();
187				MyFile += '&iframe=1';
188				var iframe = domConstruct.create('iframe', {popupFrame: 'true', seamless: '', 'class': 'selectorsIframe', style:{minWidth:"200px", width: '100%', height:'100%'}, src: MyFile, title : MyFileTitle});				
189				dialog.set('content', iframe);
190				dialog.startup();
191				dialog.show();
192				
193				//Suppression du dialog au cas ou (peut être inutile grace à l'iframe mais permet de nettoyer le dom)
194				dialog.onHide = lang.hitch(dialog, function(){
195					this.destroyRecursive();
196				});
197			}
198			//Il serait interessant de voir si le retour de la fonction est utilisé de temps en temps 
199			return dialog;
200		});	
201	}else{
202		var selectedObjects = getSelectedObjects();
203		if(selectedObjects) {
204			var form = document.createElement("form");
205			form.setAttribute("method", "post");
206			form.setAttribute("id", MyWindow);
207			form.setAttribute("action", MyFile);
208			form.setAttribute("target", MyWindow);
209
210			var hiddenField = document.createElement("input"); 
211			hiddenField.setAttribute("type", "hidden");
212			hiddenField.setAttribute("name", "selected_objects");
213			hiddenField.setAttribute("value", selectedObjects);
214			form.appendChild(hiddenField);
215			
216			document.body.appendChild(form);
217			
218			w = window.open('', MyWindow,fParam);
219			form.submit();
220			document.body.removeChild(form);
221		} else {
222			//on ouvre la popup
223			w = window.open(MyFile,MyWindow,fParam);
224		}
225	
226		if(MyFile) {
227			//on force la taille 
228			w.window.resizeTo(MyWidth,MyHeight);
229			
230			//on force la position  uniquement si on est pas en mode -2 (position g�r�e par le navigateur)
231			if ((MyTop!=-2)&&(MyLeft!=-2)) {
232				w.window.moveTo(xOffset,yOffset);
233			}
234		
235			//on force le focus
236			w.window.focus();
237		}
238		return w;
239	}
240}
241
242function openPopUpSelector(MyFile,ForceSelectorDialog) {
243	switch(ForceSelectorDialog) {
244		case '1':
245			ForceSelectorDialog = true;
246			break;
247		case '0':
248			ForceSelectorDialog = false;
249			break;
250		default:
251			ForceSelectorDialog = ForceSelectorDialog || false;
252			break;
253	}
254	return openPopUp(MyFile,'selector',0,0,0,0,'',ForceSelectorDialog)
255}
256
257function openPopUpSelectorCategory(MyFile,ForceSelectorDialog) {
258	switch(ForceSelectorDialog) {
259		case '1':
260			ForceSelectorDialog = true;
261			break;
262		case '0':
263			ForceSelectorDialog = false;
264			break;
265		default:
266			ForceSelectorDialog = ForceSelectorDialog || false;
267			break;
268	}
269	return openPopUp(MyFile,'selector_category',0,0,0,0,'',ForceSelectorDialog)
270}
271
272function getSelectedObjects(context) {
273	if(context == 'opener') {
274		var selectionSelectedNodes = window.opener.document.querySelectorAll('input[name=objects_selection]:checked');
275	} else {
276		var selectionSelectedNodes = document.querySelectorAll('input[name=objects_selection]:checked');
277	}
278	var selectionSelectedObjects = new Array();
279	for(var i=0 ; i<selectionSelectedNodes.length ; i++){
280		selectionSelectedObjects.push(selectionSelectedNodes.item(i).value);
281	}
282	return selectionSelectedObjects.join(',');
283}
284
285function checkScrollPosition(id) {
286	var box = document.querySelector("#" + id + " .uk-overflow-container");
287	if (!((box.scrollHeight - box.clientHeight) > box.scrollTop)) {
288		document.getElementById(id).querySelector(".uk-modal-close")
289				.removeAttribute("disabled");
290		box.removeEventListener("scroll", eval("handleScroll_" + id));
291	}
292}

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.