PageSourceSearch

https://www.worldfrenchrestaurant.com/global/javascript/jquery.selectMultiple.js?v=20260909_20200803

js worldfrenchrestaurant.com collected 2026-09-29 03:06:08 UTC 50,380 bytes, 1,239 lines download raw bytes

1/*
2* Changelog
3* v 0.1 - Fonctionnement basique
4* v 0.2 - Optimisation de code
5* v 0.3 - Ajout du support du plugin jquery.actual pour calculer la largeur optimale
6* v 0.31 - Ajout d'évènements pour pouvoir influer sur le plugin
7* v 0.32 - Optimisation de selecteurs > vitesse améliorée
8* v 0.33 - Ajout d'une option pour dérouler les suboptions quand le select est disabled
9*/
10
11function initSearchSelectMultiple(newSelect, opts, block) {
12    var search = $('<input type="text" class="input-search text">');
13    newSelect.prepend(search);
14    if( newSelect.find('.input-search').length > 1)
15        newSelect.find('.input-search:eq(1)').remove();
16
17	var prefix_url  = '';
18    if( typeof url_root != 'undefined' && url_root )
19		prefix_url = url_root;
20
21    search.after('<img src="' +prefix_url+ '/global/images/loupe_16x16.png" class="img-search">');
22    
23    if( newSelect.find('.img-search').length > 1)
24        newSelect.find('.img-search:eq(1)').remove();
25    
26    search.width(parseInt(newSelect.find('div:first').width()) - 57);
27
28	var callback = function ()
29	{
30		search.eventTimeout({
31								delay: 500,
32								callback:
33									function (elem)
34									{
35										elem.addClass('loading');
36
37										setTimeout(
38											function ()
39											{
40												var str = noAccentSpace($.trim(elem.val()));
41
42												if (str)
43												{
44													var pattern = new RegExp('.*' + str + '.*', 'i');
45
46													// options simples
47													elem.parent().find('> .nOption label').each(
48														function ()
49														{
50															var subject = noAccentSpace($(this).text());
51
52															if (!subject.match(pattern))
53																$(this).parent('.nOption').hide();
54															else
55																$(this).parent('.nOption').show();
56														}
57													);
58
59													if( block ) {
60														// options simples block
61														elem.parent().find('.nOption label').each(
62															function ()
63															{
64																var subject = noAccentSpace($(this).text());
65
66																$this = $(this).parent('.nOption');
67
68																if (!subject.match(pattern)) {
69																	$this.hide();
70																	$this.closest('tr').hide();
71																} else {
72																	$this.show();
73																	$this.closest('tr').show();
74																}
75															}
76														);
77													}
78													// options des optgroup
79													elem.parent().find('.optGroupList .nOption label').each(
80														function ()
81														{
82															var subject = noAccentSpace($(this).text());
83
84															if (!subject.match(pattern)) {
85																$(this).parent('.nOption').hide();
86																if( block && 0)
87																	$(this).parent('.nOption').closest('tr').hide();
88															}
89															else {
90																$(this).parent('.nOption').show();
91																if( block )
92																	$(this).parent('.nOption').closest('tr').show();
93															}
94														}
95													);
96
97													// optgroup
98													elem.parent().find('.optGroupList .optGroupDisplay label').each(
99														function ()
100														{
101															var subject = noAccentSpace($(this).text());
102															var parent = $(this).parents('.optGroupList');
103
104															if (!subject.match(pattern))
105															{
106																// si ya aucun enfant qui match on cache
107																if (!parent.find('.nOption:not(:hidden)').length )
108																	parent.hide();
109
110															}
111															else
112															{
113																//si ca match on affiche tous les enfants
114																parent.show().find('.nOption').show();
115																if( block )
116																	parent.find('.nOption').closest('tr').show();
117
118															}
119
120															if (!parent.find('.nOption:hidden').length)
121																parent.find('.optGroupDisplay img').attr('src', opts.lessPic);
122															else
123																parent.find('.optGroupDisplay img').attr('src', opts.morePic);
124														}
125													);
126
127												}
128												else
129												{
130
131													elem.parent().find('> .nOption').show();
132													if( block ) {
133														elem.parent().find('.nOption').show();
134														elem.parent().find('.nOption').closest('tr').show();
135													}
136													elem.parent().find('.optGroupList').show().find('.nOption').hide().end().find('.optGroupDisplay img').attr('src', opts.morePic);
137													elem.parent().find('.optGroupList .optGroupList').hide();
138												}
139
140												elem.removeClass('loading');
141
142											}, 50
143										);
144
145									}
146							});
147	}
148
149	if( typeof $LAB != 'undefined') {
150		$LAB.script(prefix_url + "/global/javascript/jquery.eventTimeout.js").wait(
151			callback
152		);
153	}
154	else {
155		$.getScript(prefix_url + '/global/javascript/jquery.eventTimeout.js',
156			callback
157		);
158	}
159}
160
161function initSelectMultiple (newSelect, opts ) {
162            
163    newSelect.find('input[type=checkbox]').unbind('click').click(function(e)
164    {
165        $this = $(this);
166        $thisClosestDiv = $this.closest('div');
167        $thisClosestOptgroup = $this.closest('.optGroupList');
168
169        if ($this.is(':checked'))
170        {
171            $thisClosestDiv.addClass('selected');
172
173            $(this).parents('.optGroupList').each(
174                function ()
175                {
176                    
177                    if ($(this).closest('.optGroupList').find('.inOptGroup:checked').length == $(this).closest('.optGroupList').find('.inOptGroup').length ||
178                        ($(this).find('.optGroupList .optGroupDisplay input:checked').length && ($(this).find('.optGroupList .optGroupDisplay input:checked').length == $(this).find('.optGroupList .optGroupDisplay input').length)))
179                        $(this).closest('.optGroupList')
180                            .find('.optGroupDisplay').removeClass('semiselected').addClass('selected')
181                            .find('input.optGroupCheck').attr('checked', 'checked');
182                    else
183                        $(this).closest('.optGroupList')
184                            .find('.optGroupDisplay:first').addClass('semiselected')
185                            .parents('.optGroupList').find('.optGroupDisplay:first').addClass('semiselected');
186                }
187            );
188        }
189        else
190        {
191            $thisClosestDiv.removeClass('selected');
192
193            // 2015-04-03 : Loic Fevrier
194            // Works with only 2 levels
195            // Needs some more work if more than 2 levels
196
197            if ($this.hasClass('inOptGroup'))
198            {
199                $thisClosestOptgroup.find('.optGroupDisplay')
200                    .removeClass('selected')
201                    .find('input[type=checkbox]')
202                    .removeAttr('checked');
203
204                if ($thisClosestOptgroup.find('.inOptGroup:checked').length)
205                    $thisClosestOptgroup.find('.optGroupDisplay').addClass('semiselected');
206                else
207                    $thisClosestOptgroup.find('.optGroupDisplay').removeClass('semiselected');
208            }
209
210        }
211
212        var	select = $(this).parents('.multipleSelect');
213
214        var nb = select.find('input[type="checkbox"]').length;
215        var nb_checked = select.find('input[type="checkbox"]:checked').length;
216
217        if (nb_checked == nb)
218            select.next('.checkall').find('.selectAll, .deselectPartial').hide().end().find('.deselectAll').show();
219        else if (nb_checked)
220            select.next('.checkall').find('.selectAll, .deselectAll').hide().end().find('.deselectPartial').show();
221        else
222            select.next('.checkall').find('.deselectAll, .deselectPartial').hide().end().find('.selectAll').show();
223
224        // gestion du shift
225
226        var last = select.find('input[type=checkbox].last-clicked');
227        if (e.shiftKey && last.length)
228        {
229            var checkboxes = select.find('input[type="checkbox"]');
230            var first_index = checkboxes.index(last);
231            var last_index = checkboxes.index($(this));
232
233            var min = first_index < last_index ? first_index : last_index;
234            var max = first_index > last_index ? first_index : last_index;
235
236            for (var i = min; i <= max; i++)
237            {
238                if (!checkboxes.eq(i).hasClass('optGroupCheck') || i == first_index)
239                    checkboxes.eq(i).attr('checked', $(this).is(':checked')).click().attr('checked', $(this).is(':checked'));
240            }
241        }
242        select.find('.last-clicked').removeClass('last-clicked');
243        $(this).addClass('last-clicked');
244
245    }); // End click
246
247    newSelect.find(".optGroupCheck").click(function() {
248
249        if (this.checked)
250        {
251            $(this).closest("div.optGroupList").find("input[type=checkbox]").each(
252                    function ()
253                    {
254                        if(!$(this).is(':disabled'))
255                            $(this).attr("checked", "checked").closest("div").addClass("selected");
256                    }
257                );
258
259            //$(this).closest("div.optGroupList").find("input[type=checkbox]").closest("div").addClass("selected")
260            $(this).closest("div").removeClass("semiselected").addClass("selected");
261        }
262        else
263        {
264            $(this).closest("div.optGroupList").find("input[type=checkbox]").removeAttr("checked").closest("div").removeClass("selected");
265            $(this).closest("div").removeClass("selected");
266
267            var	select = $(this).parents('.multipleSelect');
268
269            var nb = select.find('input[type="checkbox"]').length;
270            var nb_checked = select.find('input[type="checkbox"]:checked').length;
271
272            if (nb_checked == nb)
273                select.next('.checkall').find('.selectAll, .deselectPartial').hide().end().find('.deselectAll').show();
274            else if (nb_checked)
275                select.next('.checkall').find('.selectAll, .deselectAll').hide().end().find('.deselectPartial').show();
276            else
277                select.next('.checkall').find('.deselectAll, .deselectPartial').hide().end().find('.selectAll').show();
278        }
279    }); // End click
280
281    newSelect.find(".subOptions").click(function(e) {
282        e.stopImmediatePropagation();
283
284        if ($(this).closest("div").next().is(":visible"))
285        {
286            $(this).attr("src", opts.morePic);
287            $(this).closest(".optGroupList").find(">
287 div:not(.optGroupDisplay)").slideUp("fast");
288        }
289        else
290        {
291            $(this).attr("src", opts.lessPic);
292            $(this).closest(".optGroupList").find("> div:not(.optGroupDisplay)").slideDown("fast");
293        }
294    }); // End click
295}
296
297(function($) {
298    $.selectMultiple = {version: '0.33'};
299    $.fn.extend({
300        
301    	makeBlock: 
302			function (options)
303			{
304				var defaults = {
305						morePic: "/global/images/skills_more.png",
306						lessPic: "/global/images/skills_less.png",
307						width : 'ajust',
308						height : 'ajust',
309						defaultHeight : '150px',
310						optgroup : 'link'
311					};
312				
313				var opts = $.extend(defaults, options);
314                            $(this).each(
315                            function()
316		    	    {
317		    	    	var select = $(this);
318                                
319		    	    	var newSelect = $('<div id="' + select.attr('id') + '" class="multipleSelect ' + select.attr('class') + '" tabindex="100"></div>');
320
321		    	    	if (opts.height == 'css')
322		    	    	{
323		    	    		var height = (select.css("height") == '0px' ? opts.defaultHeight : select.css("height"));
324		    	    		newSelect.css("height", height);
325		    	    		
326		    	    		// patch IE7
327		    	    		newSelect.css('overflow', 'auto');
328		    	    	}
329		    	    	else if (opts.height != 'ajust' && !select.hasClass('custom'))
330		    	    		newSelect.css("height", 'auto');
331
332		    	    	if (opts.width == 'ajust')
333		    	    		newSelect.css("width", 'auto');
334		    	    	else if (opts.width && opts.width != 'ajust' && !select.hasClass('custom'))
335		    	    		newSelect.css("width", opts.width);
336		    	    	
337		    	    	if (select.hasClass('custom'))
338		    	    		newSelect.attr('style', select.attr('style'));
339		    	    	
340		    	    	if (select.css('max-width'))
341		    	    		newSelect.css('max-width', select.css('max-width'));
342
343		    	    	var idBase = select.attr("name").substr(0, select.attr("name").length - 2);
344
345		    	    	var left_items = new Array();
346		    	    	var right_items = new Array();
347		    	    	
348		    	    	// la 1ere moitié des options sont à gauche, l'autre a droite
349		    	    	var nb_children = select.children().length;
350		    	    	var nb_elem_per_col = Math.ceil(nb_children / 2);
351		    	    	var i = 0;
352		    	    	select.children().each(
353		    	    		function() 
354		    	    		{
355		    	    			if (i < nb_elem_per_col)
356		    	    				left_items[left_items.length] = $(this);
357		    	    			else
358		    	    				right_items[right_items.length] = $(this);
359		    	    			i++;
360		    	    		}
361		    	    	);
362		    	    	
363		    	    	var index = select.data('index') ? select.data('index') : 1;
364		    	    	
365		    	    	// construction colonne de gauche
366		    	    	var options_l = $('<table class="options_left"></table>');
367		    	    	for (i = 0; i < left_items.length; i++)
368	    	    		{
369		    	    		var item = left_items[i];
370		    	    		var name = typeof item.attr('name') != 'undefined' ? item.attr('name') : select.attr('name');
371		    	    		
372		    	    		var row = $('<tr> \
373	    	    							<td> \
374	    	    							</td> \
375	    	    						</tr>');
376		    	    		
377		    	    		var option = ''
378		    	    		if (item[0].nodeName == 'OPTION')
379	    	    			{
380	    	    				option = '	<div style="float: left; clear: left;" class="nOption' + (item.is(":selected") ? ' selected' : '') + '"> \
381						    	    			<input type="checkbox"' + 
382													(item.is(":selected") ? ' checked' : '') + 
383													' id="' + idBase + index + '"' +
384													' name="' + name + '"' +
385													' value="' + item.val() + '"' +
386													' style="float: left;"' + 
387												'> \
388    	    									<label for="' + (idBase + index) + '" style="float: left; width: 90%;"> \
389													<span style="float: right; width: 100%;">' + 
390														item.html() + 
391													'</span> \
392												</label> \
393											</div>';
394	    	    				index++;
395	    	    			}
396		    	    		else if (item[0].nodeName == 'OPTGROUP')
397	    	    			{
398		    	    			option = $('<div style="width: 100%;"> \
399    	    									<div class="optGroupList"> \
400    	    										<div class="optGroupDisplay' + (item.hasClass("selected") ? ' selected' : '') + '"> \
401    	    										</div> \
402    	    									</div> \
403    	    								</div>');
404		    	    			
405		    	    			var checkbox = $('<input type="checkbox" class="optGroupCheck"' +
406	        							' id="' + (idBase + index) + '" name="' + name + '" value="' + item.attr('value') + '"' + (item.hasClass("selected") ? ' checked="checked"' : '') + ' />');
407		    	    			
408		    	    			if (opts.optgroup == 'link')
409					        		checkbox.click(
410					    				function() 
411					    				{
412					    		        	if ($(this).is(":checked"))
413							        		{
414							        			$(this).closest("div.optGroupList").find("input[type=checkbox]").attr("checked", "checked")
415							        				.closest("div").addClass("selected");
416							        			
417					    	    				$(this).closest("div").removeClass("semiselected").addClass("selected");
418							        		}
419					    		        	else
420					    		        	{
421					    		        		$(this).closest("div.optGroupList").find("input[type=checkbox]").removeAttr("checked")
422					    		        			.closest("div").removeClass("selected");
423					    		        		
424					    	    				$(this).closest("div").removeClass("selected");
425					    		        	}
426					    				}
427									);
428		    	    			else
429		    	    				checkbox.click(
430					    				function() 
431					    				{
432					    		        	if ($(this).is(":checked"))
433							        		{
434					    		        		$(this).closest("div").removeClass("selected").addClass("selected");
435							        		}
436					    		        	else
437				    		        		{
438					    		        		$(this).closest("div").removeClass("selected");
439				    		        		}
440			    		        		}
441				    				);
442		    	    			
443				        		option.find('.optGroupDisplay').append(checkbox);
444				        		
445				        		var img = $('<img src="' + opts.morePic + '" class="subOptions">');
446    	    	        		img.click(
447    	    	    				function() 
448    	    	    				{
449    	    	    		            if ($(this).closest("div").next().is(":visible"))
450    	    	    		            {
451    	    	    			            $(this).attr("src", opts.morePic);
452    	    	    			            $(this).closest(".optGroupList").find("div:not(.optGroupDisplay)").slide
452Up("fast",
453    	    	    			            		function ()
454    	    	    			            		{
455    	    	    			            			var max_height = $(this).parents('.multipleSelect').find('.options_left').css('height');
456    	    	    			            			if (parseInt($(this).parents('.multipleSelect').find('.options_right').css('height')) > parseInt(max_height))
457    	    	    			            				max_height = $(this).parents('.multipleSelect').find('.options_right').css('height');
458    	    	    			            			
459    	    	    			            			$(this).parents('.multipleSelect').css('height', max_height);
460    	    	    			            		}
461    	    			            			);
462    	    	    		            }
463    	    	    		            else
464    	    	    		            {
465    	    	    		            	$(this).attr("src", opts.lessPic);
466    	    	    			            $(this).closest(".optGroupList").find("div:not(.optGroupDisplay)").slideDown("fast",
467    	    	    			            		function ()
468    	    	    			            		{
469		    	    			            			var max_height = $(this).parents('.multipleSelect').find('.options_left').css('height');
470		    	    			            			if (parseInt($(this).parents('.multipleSelect').find('.options_right').css('height')) > parseInt(max_height))
471		    	    			            				max_height = $(this).parents('.multipleSelect').find('.options_right').css('height');
472		    	    			            			
473		    	    			            			$(this).parents('.multipleSelect').css('height', max_height);
474    	    	    			            		}
475	    	    			            		);
476    	    				            }
477    	    	    				}
478    	    					);
479    	    	        		option.find('.optGroupDisplay').append(img).
480    	    	        			append('<label for="' + (idBase + index++) + '" style="font-weight : bold;">' + item.attr("label") + '</label>');
481    	    	        		
482    	    	        		item.children().each(
483    	    	        			function ()
484    	    	        			{
485    	    		    	    		var name = typeof $(this).attr('name') != 'undefined' ? $(this).attr('name') : select.attr('name');
486
487    	    	        				option.find('.optGroupList').append('<div style="float: left; clear: left;" class="nOption' + ($(this).is(":selected") ? ' selected' : '') + '"> \
488															    	    		<input type="checkbox" class="inOptGroup"' + 
489																						($(this).is(":selected") ? ' checked' : '') + 
490																						' id="' + idBase + index + '"' +
491																						' name="' + name + '"' +
492																						' value="' + $(this).val() + '"' +
493																						' style="float: left;"' + 
494																				'> \
495										    									<label for="' + (idBase + index) + '" style="float: left; width: 90%;"> \
496																					<span style="float: right; width: 100%;">' + 
497																						$(this).html() + 
498																					'</span> \
499																				</label> \
500																			</div>');
501    	    	        				index++;
502    	    	        			}
503    	        				);
504    	    	        		
505	    	    			}
506
507	    	        		
508	    	        		row.find('td').append(option);
509    	        			options_l.append(row);
510	    	    		}
511		    	    	newSelect.append(options_l);
512
513		    	    	// construction colonne de droite
514		    	    	var options_r = $('<table class="options_right"></table>');
515		    	    	for (i = 0; i < right_items.length; i++)
516	    	    		{
517		    	    		var item = right_items[i];
518		    	    		var name = typeof item.attr('name') != 'undefined' ? item.attr('name') : select.attr('name');
519		    	    		
520		    	    		var row = $('<tr> \
521	    	    							<td> \
522	    	    							</td> \
523	    	    						</tr>');
524		    	    		
525		    	    		var option = ''
526		    	    		if (item[0].nodeName == 'OPTION')
527	    	    			{
528	    	    				option = '	<div style="float: left; clear: left;" class="nOption' + (item.is(":selected") ? ' selected' : '') + '"> \
529						    	    			<input type="checkbox"' + 
530													(item.is(":selected") ? ' checked' : '') + 
531													' id="' + idBase + index + '"' +
532													' name="' + name + '"' +
533													' value="' + item.val() + '"' +
534													' style="float: left;"' + 
535												'> \
536    	    									<label for="' + (idBase + index) + '" style="float: left; width: 90%;"> \
537													<span style="float: right; width: 100%;">
537' + 
538														item.html() + 
539													'</span> \
540												</label> \
541											</div>';
542	    	    				index++;
543	    	    			}
544		    	    		else if (item[0].nodeName == 'OPTGROUP')
545	    	    			{
546		    	    			option = $('<div style="width: 100%;"> \
547    	    									<div class="optGroupList"> \
548    	    										<div class="optGroupDisplay' + (item.hasClass("selected") ? ' selected' : '') + '"> \
549    	    										</div> \
550    	    									</div> \
551    	    								</div>');
552		    	    			
553		    	    			var checkbox = $('<input type="checkbox" class="optGroupCheck"' +
554	        							' id="' + (idBase + index) + '" name="' + name + '" value="' + item.attr('value') + '"' + (item.hasClass("selected") ? ' checked="checked"' : '') + ' />');
555		    	    			
556		    	    			if (opts.optgroup == 'link')
557					        		checkbox.click(
558					    				function() 
559					    				{
560					    		        	if ($(this).is(":checked"))
561							        		{
562							        			$(this).closest("div.optGroupList").find("input[type=checkbox]").attr("checked", "checked")
563							        				.closest("div").addClass("selected");
564							        			$(this).closest("div").removeClass("semiselected").addClass("selected");
565							        		}
566					    		        	else
567					    		        	{
568					    		        		$(this).closest("div.optGroupList").find("input[type=checkbox]").removeAttr("checked")
569					    		        			.closest("div").removeClass("selected");
570					    		        		$(this).closest("div").removeClass("selected");
571					    		        	}
572					    				}
573									);
574		    	    			else
575		    	    				checkbox.click(
576					    				function() 
577					    				{
578					    		        	if ($(this).is(":checked"))
579							        		{
580					    		        		$(this).closest("div").removeClass("selected").addClass("selected");
581							        		}
582					    		        	else
583				    		        		{
584					    		        		$(this).closest("div").removeClass("selected");
585				    		        		}
586			    		        		}
587				    				);
588		    	    			
589				        		option.find('.optGroupDisplay').append(checkbox);
590				        		
591				        		var img = $('<img src="' + opts.morePic + '" class="subOptions">');
592    	    	        		img.click(
593    	    	    				function() 
594    	    	    				{
595    	    	    		            if ($(this).closest("div").next().is(":visible"))
596    	    	    		            {
597    	    	    			            $(this).attr("src", opts.morePic);
598    	    	    			            $(this).closest(".optGroupList").find("div:not(.optGroupDisplay)").slideUp("fast",
599    	    	    			            		function ()
600    	    	    			            		{
601		    	    			            			var max_height = $(this).parents('.multipleSelect').find('.options_left').css('height');
602		    	    			            			if (parseInt($(this).parents('.multipleSelect').find('.options_right').css('height')) > parseInt(max_height))
603		    	    			            				max_height = $(this).parents('.multipleSelect').find('.options_right').css('height');
604		    	    			            			
605		    	    			            			$(this).parents('.multipleSelect').css('height', max_height);
606    	    	    			            		}
607    	    			            			);
608    	    	    		            }
609    	    	    		            else
610    	    	    		            {
611    	    	    		            	$(this).attr("src", opts.lessPic);
612    	    	    			            $(this).closest(".optGroupList").find("div:not(.optGroupDisplay)").slideDown("fast",
613    	    	    			            		function ()
614    	    	    			            		{
615		    	    			            			var max_height = $(this).parents('.multipleSelect').find('.options_left').css('height');
616		    	    			            			if (parseInt($(this).parents('.multipleSelect').find('.options_right').css('height')) > parseInt(max_height))
617		    	    			            				max_height = $(this).parents('.multipleSelect').find('.options_right').css('height');
618		    	    			            			
619		    	    			            			$(this).parents('.multipleSelect').css('height', max_height);
620    	    	    			            		}
621	    	    			            		);
622
623    	    				            }
624    	    	    				}
625    	    					);
626    	    	        		option.find('.optGroupDisplay').append(img).
627    	    	        			append('<label for="' + (idBase + index++) + '" style="font-weight : bold;">' + item.attr("label") + '</label>');
628    	    	        		
629    	    	        		item.children().each(
630    	    	        			function ()
631    	    	        			{
632    	    		    	    		var name = typeof $(this).attr('name') != 'undefined' ? $(this).attr('name') : select.attr('name');
633
634    	    		    	    		option.find('.optGroupList').append('<div style="float: left; clear: left;" class="nOption' + ($(this).is(":selected") ? ' selected' : '') + '"> \
635															    	    		<input type="checkbox" class="inOptGroup"' + 
636																						($(this).is(":selected") ? ' checked' : '') + 
637																						' id="' + idBase + index + '"' +
638																						' name="' + name + '"' +
639																						' value="' + $(this).val() + '"' +
640																						' style="float: left;"' + 
641																				'> \
642										    									<label for="' + (idBase + index) + '" style="float: left; width: 90%;"> \
643																					<span style="float: right; width: 100%;">
643' + 
644																						$(this).html() + 
645																					'</span> \
646																				</label> \
647																			</div>');
648    	    	        				index++;
649    	    	        			}
650    	        				);
651    	    	        		
652	    	    			}
653
654	    	        		
655	    	        		row.find('td').append(option);
656    	        			options_r.append(row);
657	    	    		}
658		    	    	newSelect.append(options_r);
659
660		    	    	// surlignage au click
661		    	    	newSelect.find("input[type=checkbox]:not(.optGroupCheck)").click(
662		    	    		function() 
663		    	    		{
664		    	    			if ($(this).is(":checked")) 
665		    	    			{
666		    	    				$(this).closest("div").addClass("selected");
667		    	    				
668		    	    				if (opts.optgroup == 'link')
669	    	    					{
670			    	    				if ($(this).hasClass("inOptGroup"))
671			    	    				{
672			    	    					if ($(this).closest(".optGroupList").find(".inOptGroup:checked").length == $(this).closest(".optGroupList").find(".inOptGroup").length)
673			    	    					{
674			    	    						$(this).closest(".optGroupList").find(".optGroupDisplay").removeClass("semiselected").addClass("selected").find("input.optGroupCheck").attr("checked", "checked");
675			    	    					}
676			    	    					else
677			    	    					{
678			    	    						$(this).closest(".optGroupList").find(".optGroupDisplay").addClass("semiselected");
679			    	    					}
680			    	    				}
681	    	    					}
682		    	    				else
683	    	    					{
684		    	    					$(this).closest(".optGroupList").find(".optGroupDisplay").addClass("semiselected");
685	    	    					}
686		    	    			}
687		    	    	    	else 
688		    	    	    	{
689		    	    	    		$(this).closest("div").removeClass("selected");
690
691		    	    				if (opts.optgroup == 'link')
692	    	    					{
693	    	    						if ($(this).hasClass("inOptGroup"))
694			    	    				{
695			    	    					$(this).closest(".optGroupList").find(".optGroupDisplay").removeClass("selected")
696			    	    						.find("input[type=checkbox]")
697			    	    						.removeAttr("checked");
698	
699			    	    					if ($(this).closest(".optGroupList").find(".inOptGroup:checked").length)
700			    	    						$(this).closest(".optGroupList").find(".optGroupDisplay").addClass("semiselected");
701			    	    					else
702			    	    						$(this).closest(".optGroupList").find(".optGroupDisplay").removeClass("semiselected");
703			    	    				}
704	    	    					}
705		    	    				else
706	    	    					{
707		    	    					if (!$(this).closest(".optGroupList").find(".inOptGroup:checked").length)
708		    	    						$(this).closest(".optGroupList").find(".optGroupDisplay").removeClass("semiselected");
709	    	    					}
710		    	    	    	}
711		    	    		}
712		    	    	);
713
714		    	    	// on replit les sous options des optgroup
715		    	    	newSelect.find(".optGroupList div:not(.optGroupDisplay)").hide();
716
717		    	    	if (opts.optgroup == 'link')
718	    	    		{
719			    	    	// si tte les options d'un optgroup sont selectionnées alors on selectionne aussi l'optgroup
720			    	    	newSelect.find(".optGroupList").each(
721			    	    		function ()
722			    	    		{
723			    	    			if ($(this).find("div:not(.optGroupDisplay) input[type=checkbox]").length &&
724		    	    					$(this).find("div:not(.optGroupDisplay) input[type=checkbox]").length ==
725			    	    				$(this).find("div:not(.optGroupDisplay) input[type=checkbox]:checked").length)
726			    	    				$(this).find("div.optGroupDisplay").removeClass("semiselected").addClass("selected")
727			    	    					.find('input.optGroupCheck').attr("checked", "checked");
728			    	    			else if ($(this).find("div:not(.optGroupDisplay) input[type=checkbox]:checked").length)
729			    	    				$(this).find("div.optGroupDisplay").removeClass("selected").addClass("semiselected")
730			    	    					.find('input.optGroupCheck').attr("checked", false);
731			    	    		}
732			    	    	);
733	    	    		}
734
735		    	    	// remplacement du vieux select par le nouveau
736		    	    	select.after(newSelect).remove();
737		    	    	
738		    	    	// equilibrage options gauche / droite (dans le cas ou les options tiennent sur +ieur lignes)
739		    	    	while (options_l.actual('height') < options_r.actual('height'))
740	    	    		{
741		    	    		var item = options_r.find('tr:first');
742		    	    		options_l.append(item);
743	    	    		}
744		    	    	
745		    	    	if (opts.height == 'ajust' && !select.hasClass('custom'))
746		    	    		newSelect.css("height", options_l.actual('height'));
747
748
749                                if (select.hasClass('searchable') /* && (newSelect.height() < height) */)
750				{
751                                    initSearchSelectMultiple(newSelect, opts, 1);
752				}
753
754
755		    	    }
756	    		);
757			},
758			
759		selectMultiple: function(options)
760		{
761		    var defaults =
762		    {
763				morePic: '/global/images/skills_more.png',
764				lessPic: '/global/images/skills_less.png',
765				width : 'ajust',
766				height : 'clone',
767				beforeTransform: false,
768				afterTransform: false,
769				displayOptOnDisabledItem: false
770		    };
771		    var opts = $.extend(defaults, options);
772		    
773		    $(document).trigger('beforeTransform');
774
775		    $(this).each(function()
776		    {
777		    	originalSelect		= $(this);
778				originalSelectName	= originalSelect.attr('name');
779	            originalSelectDisabled	= originalSelect.is(':disabled');
780
781				if (typeof opts.beforeTransform == 'function')
782					opts.beforeTransform(originalSelect);
783
784		    	newSelect = $(document.createElement('div'));
785	            newSelect.addClass(originalSelect.attr('class') + ' multipleSelect').removeClass('select');
786	            
787		    	if (opts.height == 'clone')
788		    	{
789			    	newSelect.css('height', typeof $.actual == 'undefined' ? originalSelect.css('height') : originalSelect.actual('height'));
790			    }
791		    	else if (opts.height != 'css')
792		    	{
793			    	newSelect.css('height', opts.height);
794			    }
795
796				if (opts.width && opts.width != 'ajust')
797				{
798				    newSelect.css('width', opts.width);
799				}
800
801    	    	if (originalSelect.css('max-width'))
802    	    		newSelect.css('max-width', originalSelect.css('max-width'));
803
804				/*
805				* Then, insert the new select after the replaced item. Maybe not optimized!
806				*/
807
808				var optGroupStarted = false;
809				var current_optGroup = false;
810				nwidth = 0;
811				i = 1;
812				idBase = originalSelectName.substr(0, originalSelectName.length - 2);
813
814				var version = originalSelect.data('version');
815				
816				if (!version)
817				{
818					$('*', originalSelect).each(function()
819					{
820					    $_originalSelectItem		    = $(this);
821					    $_originalSelectItemIsSelected   = $_originalSelectItem.is(':selected') || $_originalSelectItem.hasClass('selected');
822                        //$_originalSelectItemIsSelected   = (typeof this.selected !== "undefined" && this.selected) || $_originalSelectItem.hasClass('selected');
823					    $_originalSelectItemName	    = $_originalSelectItem.attr('name');
824					    
825					    $_itemLine = $(document.createElement('div')).css('width', '100%');
826					    
827					    $_itemID = idBase + i;
828					    
829					    /*
830					     * If an optgroup is started and finish now
831					     */
832					    if (optGroupStarted && $_originalSelectItem.context.parentNode.nodeName != 'OPTGROUP')
833					    {
834							optGroupStarted = false;
835							insideCheckedOptGroup = current_optGroup.find('.inOptGroup:checked');
836							insideOptGroup = current_optGroup.find('.inOptGroup');
837							
838							if (insideCheckedOptGroup.length)
839							{
840							    optGroupDisplayButton = current_optGroup.find('.optGroupDisplay');
841							    
842							    if (insideCheckedOptGroup.length == insideOptGroup.length)
843							    {				
844									optGroupDisplayButton
845								    	.removeClass('semiselected')
846								    	.addClass('selected');
847									optGroupDisplayButton.find('.optGroupCheck').attr('checked', 'checked');
848							    }
849							    else
850							    {
851									optGroupDisplayButton.addClass('semiselected');
852							    }
853							}
854							/* This is the end of the inside item collections, so we're adding now the currentOptGroup to his containing line, not before! */
855							current_optGroup.appendTo(newSelect);
856					    } // Endif
857					    
858					    
859					    if ($_originalSelectItem[0].nodeName == 'OPTGROUP')
860						{
861						    optGroupStarted = true;
862						    current_optGroup = $(document.createElement('div')).addClass('optGroupList');
863						    
864						    optGroupLibelleContainer = $(document.createElement('div')).addClass('optGroupDisplay');
865						    
866						    if ($_originalSelectItemIsSelected)
867						    {
868						    	optGroupLibelleContainer.addClass('selected');
869						    }
870						    
871						    checkbox = $(document.createElement('input')).attr({
872								'type': 'checkbox',
873								'checked' : $_originalSelectItemIsSelected,
874								'value' : $_originalSelectItem.attr('value'),
875								'id' : $_itemID,
876								'disabled' : originalSelectDisabled
877						    }).addClass('optGroupCheck');
878	
879						    if (typeof $_originalSelectItemName != 'undefined')
880						    	checkbox.attr('name', $_originalSelectItemName);
881						    
882						    checkbox.appendTo(optGroupLibelleContainer);
883	
884						    img = $(document.createElement('img')).attr('src', opts.morePic).addClass('subOptions');
885	
886						    var label = $_originalSelectItem.attr("label") || $.trim($_originalSelectItem.html());
887						    					    
888						    var optgroupLibelle = $(document.createElement('label'))
889								.attr('for', $_itemID)
890								.css('font-weight', 'bold')
891								.html(label);
892	
893						    img.appendTo(optGroupLibelleContainer);
894	
895						    optgroupLibelle.appendTo(optGroupLibelleContainer);
896						    optGroupLibelleContainer.appendTo(current_optGroup);
897						}
898					    else if ($_originalSelectItem[0].nodeName == 'OPTION')
899						{
900						    if ($_originalSelectItemIsSelected)
901						    {
902								$_itemLine.addClass('selected');
903						    }
904	
905						    $_itemLine.addClass('nOption');
906	
907						    checkbox = $(document.createElement('input')).attr({
908								'type': 'checkbox',
909								'checked' : $_originalSelectItemIsSelected,
910								'name' : $_originalSelectItemName && (typeof $_originalSelectItemName != 'undefined') ? $_originalSelectItemName : originalSelectName,
911								'value' : $_originalSelectItem.val(),
912								'id' : $_itemID,
913								'disabled' : originalSelectDisabled || ($_originalSelectItem.attr('disabled') != 'undefined' && $_originalSelectItem.attr('disabled') == 'disabled'),
914                                'class' : $_originalSelectItem.attr('class') != 'undefined' ?  $_originalSelectItem.attr('class') : ''
915						    });
916						    
917                            var label = $(document.createElement('label'));
918                            label.attr('for', $_itemID);
919                            if( $_originalSelectItem.attr('class') != 'undefined' )
920                                label.attr('class', $_originalSelectItem.attr('class'));
921						    span = label.html($_originalSelectItem.html());
922						    
923						    /*
924						     * If we have a started optGroup, then, add the line inside!
925						     */
926						    if (optGroupStarted)
927						    {
928								checkbox
929								    .addClass('inOptGroup')
930								    .appendTo($_itemLine);
931								    
932								span.appendTo($_itemLine);
933								$_itemLine.appendTo(current_optGroup);
934						    }
935						    else
936						    {
937								checkbox.appendTo($_itemLine);
938								span.appendTo($_itemLine);
939								$_itemLine.appendTo(newSelect);
940						    }
941						}
942					   
943					    i++;
944					}); // End each
945					/*
946					 * If an optgroup is opened and is the first & last item, then we never close it and append it to the container
947					 */
948					if (optGroupStarted)
949					{
950					    optGroupStarted = false;
951					    insideCheckedOptGroup = current_optGroup.find('.inOptGroup:checked');
952					    insideOptGroup = current_optGroup.find('.inOptGroup');
953	
954					    if (insideCheckedOptGroup.length)
955					    {
956							optGroupDisplayButton = current_optGroup.find('.optGroupDisplay');
957	
958							if (insideCheckedOptGroup.length == insideOptGroup.length)
959							{				
960							    optGroupDisplayButton
961									.removeClass('semiselected')
962									.addClass('selected');
963							    optGroupDisplayButton.find('.optGroupCheck').attr('checked', 'checked');
964							}
965							else
966							{
967							    optGroupDisplayButton.addClass('semiselected');
968							}
969					    }
970					    /* This is the end of the inside item collections, so we're adding now the currentOptGroup to his containing line, not before! */
971					    current_optGroup.appendTo(newSelect);
972					} // End if
973				}
974				else if (version == 2)
975				{
976					$('*', originalSelect).each(
977						function()
978						{
979						    $_originalSelectItem		    = $(this);
980						    $_originalSelectItemIsSelected   = $_originalSelectItem.is(':selected') || $_originalSelectItem.hasClass('selected');
981						    $_originalSelectItemName	    = $_originalSelectItem.data('name');
982						    						    
983						    $_itemLine = $(document.createElement('div')).css('width', '100%');
984						    
985						    $_itemID = idBase + i;
986						    
987						    if ($_originalSelectItem.data('optgroup') || originalSelect.find('option[data-id_parent="' + $_originalSelectItem.val() + '"]').length)
988							{
989							    current_optGroup = $(document.createElement('div')).addClass('optGroupList').attr('id', 'group_' + $_originalSelectItem.val());
990							    optGroupLibelleContainer = $(document.createElement('div')).addClass('optGroupDisplay');
991							    
992							    if ($_originalSelectItemIsSelected)
993							    	optGroupLibelleContainer.addClass('selected');
994							    
995							    checkbox = $(document.createElement('input')).attr({
996									'type': 'checkbox',
997									'checked' : $_originalSelectItemIsSelected,
998									'value' : $_originalSelectItem.attr('value'),
999									'id' : $_itemID,
1000									'disabled' : originalSelectDisabled
1001							    }).addClass('optGroupCheck');
1002		
1003							    if (typeof $_originalSelectItemName != 'undefined')
1004							    	checkbox.attr('name', $_originalSelectItemName);
1005							    
1006							    optGroupLibelleContainer.append(checkbox);
1007		
1008							    img = $(document.createElement('img')).attr('src', opts.morePic).addClass('subOptions');
1009									    					    
1010							    var optgroupLibelle = $(document.createElement('label'))
1011									.attr('for', $_itemID)
1012									.css('font-weight', 'bold')
1013									.html($.trim($_originalSelectItem.html()));
1014		
1015							    optGroupLibelleContainer.append(img);
1016							    optGroupLibelleContainer.append(optgroupLibelle);
1017							    
1018							    current_optGroup.append(optGroupLibelleContainer);
1019							    
1020							    
1021							    // init selection
1022								insideCheckedOptGroup = current_optGroup.find('.inOptGroup:checked');
1023								insideOptGroup = current_optGroup.find('.inOptGroup');
1024								
1025								if (insideCheckedOptGroup.length)
1026								{
1027								    optGroupDisplayButton = current_optGroup.find('.optGroupDisplay');
1028								    
1029								    if (insideCheckedOptGroup.length == insideOptGroup.length)
1030								    {				
1031										optGroupDisplayButton
1032									    	.removeClass('semiselected')
1033									    	.addClass('selected');
1034										optGroupDisplayButton.find('.optGroupCheck').attr('checked', 'checked');
1035								    }
1036								    else
1037								    {
1038										optGroupDisplayButton.addClass('semiselected');
1039								    }
1040								}
1041								
1042								if (!$_originalSelectItem.data('id_parent'))
1043									newSelect.append(current_optGroup);
1044								else
1045								{
1046									var parent = newSelect.find('.optGroupList[id="group_' + $_originalSelectItem.attr('data-id_parent') + '"]').find('> div:last');
1047									
1048									parent.after(current_optGroup);
1049								}
1050							}
1051						    else if (!$_originalSelectItem.data('optgroup') && !originalSelect.find('option[data-id_parent="' + $_originalSelectItem.val() + '"]').length)
1052							{
1053							    if ($_originalSelectItemIsSelected)
1054							    {
1055									$_itemLine.addClass('selected');
1056							    }
1057		
1058							    $_itemLine.addClass('nOption');
1059		
1060							    checkbox = $(document.createElement('input')).attr({
1061									'type': 'checkbox',
1062									'checked' : $_originalSelectItemIsSelected,
1063									'name' : $_originalSelectItemName && (typeof $_originalSelectItemName != 'undefined') ? $_originalSelectItemName : originalSelectName,
1064									'value' : $_originalSelectItem.val(),
1065									'id' : $_itemID,
1066									'disabled' : originalSelectDisabled
1067							    });
1068		
1069							    span = $(document.createElement('label')).attr('for', $_itemID).html($_originalSelectItem.html());
1070							    
1071							    if (!$_originalSelectItem.data('id_parent'))
1072							    {
1073									$_itemLine.append(checkbox);
1074									$_itemLine.append(span);
1075									newSelect.append($_itemLine);
1076								}
1077								else
1078								{
1079									var parent = newSelect.find('.optGroupList[id="group_' + $_originalSelectItem.attr('data-id_parent') + '"]').find('> div:last');
1080									
1081									checkbox.addClass('inOptGroup');
1082									$_itemLine.append(checkbox);
1083									$_itemLine.append(span);
1084									parent.after($_itemLine);
1085								}
1086							}
1087						   
1088						    i++;
1089						}
1090					); // End each
1091					
1092				}
1093				
1094				newSelect.find('.optGroupList div:not(.optGroupDisplay)').hide();
1095				
1096				if (!newSelect.find('.optGroupList div:not(.optGroupDisplay) input[type=checkbox]:not(:checked)').length && newSelect.find('.optGroupList div:not(.optGroupDisplay) input[type=checkbox]').length) {
1097				    newSelect.find('.optGroupList div.optGroupDisplay input[type=checkbox]').attr('checked', 'checked');
1098				}
1099				
1100				newSelect.find('.optGroupList div.optGroupDisplay.selected').each(
1101						function ()
1102						{
1103							$(this).parent('.optGroupList').find('.nOption').addClass('selected').find('input[type=checkbox]').attr('checked', 'checked');
1104									
1105						}
1106					);
1107				
1108
1109				originalSelect.replaceWith(newSelect);
1110
1111				if (originalSelect.hasClass('custom')) {
1112                    //console.log(originalSelectName + " : " + originalSelect.width());
1113					newSelect.css('width', originalSelect.width());
1114                }
1115				else if (opts.width == 'ajust') {
1116                    var list = newSelect.find('label');
1117                    var nbLabels = list.length;
1118				    optimalWidth = Math.max.apply(Math, list.map(function(){
1119					    if (typeof $.actual !== 'undefined' && nbLabels <= 100)
1120				    	    return $(this).actual('width', { 'clone' : true});
1121				        return $(this).width();
1122				    }).get());
1123				    
1124				    if (optimalWidth > nwidth) {
1125				        nwidth = optimalWidth;
1126				    }
1127					newSelect.css('width', Math.max(nwidth, 150) + 60);
1128                    //console.log(originalSelectName + " : ajust " + (nwidth + 60));
1129				}
1130				
1131				if (originalSelect.hasClass('checkall'))
1132				{
1133					var checkall = $('<span class="checkall" style="margin-left: 5px; vertical-align: top;"> \
1134										<img src="/global/images/select_all.png" class="deselectAll" alt="Tout décocher" border="0" style="cursor: pointer; vertical-align: top;" title="Tout décocher"> \
1135										<img src="/global/images/select_partial.png" class="deselectPartial" alt="Tout décocher" border="0" style="cursor: pointer; display: inline; vertical-align: top;" title="Tout décocher"> \
1136										<img src="/global/images/deselect_all.png" class="selectAll" alt="Tout cocher" border="0" style="cursor: pointer; display: inline; vertical-align: top;" title="Tout cocher"> \
1137									</span>');
1138
1139					var nb = newSelect.find('input[type="checkbox"]').length;
1140					var nb_checked = newSelect.find('input[type="checkbox"]:checked').length;
1141					
1142					if (nb_checked == nb)
1143						checkall.find('.selectAll, .deselectPartial').hide();
1144					else if (nb_checked)
1145						checkall.find('.selectAll, .deselectAll').hide();
1146					else
1147						checkall.find('.deselectAll, .deselectPartial').hide();
1148					
1149					checkall.click(
1150							function ()
1151							{
1152								var select = $(this).prev('.multipleSelect');
1153								
1154								var checkboxes = select.find('input[type="checkbox"]');
1155								var nb_checked = select.find('input[type="checkbox"]:checked').length;
1156								
1157								if (nb_checked)
1158								{
1159									checkboxes.attr('checked', false);
1160									select.find('.selected, .semiSelected').removeClass('selected semiSelected');
1161									$(this).find('.deselectAll, .deselectPartial').hide().end().find('.selectAll').show();
1162								}
1163								else
1164								{
1165                                    checkboxes.each(
1166                                        function ()
1167                                        {
1168                                            if(!$(this).is(':disabled'))
1169                                                $(this).attr("checked", true).closest("div").addClass("selected");
1170                                        }
1171                                    );
1172                            
1173                                    //checkboxes.attr('checked', true);
1174									//select.find('.nOption, .optGroupDisplay').addClass('selected');
1175									$(this).find('.selectAll, .deselectPartial').hide().end().find('.deselectAll').show();
1176								}
1177							}
1178						);
1179					
1180					newSelect.css('display', 'inline-block').after(checkall);
1181				}
1182
1183				var height = 0;
1184				newSelect.find('> .nOption:visible, .optGroupList:visible').each(function () { height += parseInt($(this).height()) });
1185				
1186				if (originalSelect.hasClass('searchable') /* && (newSelect.height() < height) */)
1187				{
1188                                    initSearchSelectMultiple(newSelect, opts, 0);
1189				}
1190
1191				if (typeof opts.afterTransform == 'function')
1192					opts.afterTransform(newSelect);
1193
1194				/*
1195				 * Binding click
1196				 */
1197
1198				if (!originalSelectDisabled)
1199				{
1200					initSelectMultiple(newSelect, opts);
1201
1202					if (originalSelect.hasClass('alert-before-leaving'))
1203					{
1204						newSelect.find('input[type=checkbox]').one('click', function () { addAlertBeforeLeaving(); });
1205					}
1206
1207					if (originalSelect.hasClass('register-modify'))
1208					{
1209						newSelect.find('input[type=checkbox]').one('click', function () { setFormModified(); });
1210					}
1211				}
1212				else /* On ajoute un return si l'item est désactivé */
1213				{
1214					if (opts.displayOptOnDisabledItem)
1215					{
1216						newSelect.find(".subOptions").click(function(e) {
1217						    e.stopImmediatePropagation();
1218						    
1219						    if ($(this).closest("div").next().is(":visible"))
1220						    {
1221								$(this).attr("src", opts.morePic);
1222								$(this).closest(".optGroupList").find("div:not(.optGroupDisplay)").slide
1222Up("fast");
1223						    }
1224						    else
1225						    {
1226								$(this).attr("src", opts.lessPic);
1227								$(this).closest(".optGroupList").find("div:not(.optGroupDisplay)").slideDown("fast");
1228						    }
1229						});
1230					}
1231					else
1232					{
1233						newSelect.click(function() { return false; });	
1234					}
1235				}
1236			}); // End each
1237		} // End function
1238    });
1239})(jQuery);

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.