PageSourceSearch

https://www.lesedc.org/global/javascript/navigation.js?v=20250410

js lesedc.org collected 2026-10-01 14:46:43 UTC 12,124 bytes, 385 lines download raw bytes

1
2if (typeof init_navigation_js == 'undefined' || !init_navigation_js)
3{
4	/* Simple pagination */
5	function simplePaginationInit(callback) {
6		$.getCss('/global/vendor/flaviusmatis/simplepagination.js/simplePagination.css');
7		$LAB.script("/global/vendor/flaviusmatis/simplepagination.js/jquery.simplePagination.js").wait(function(){
8			callback()
9		})
10	}
11
12	function simplePaginationSearch(selector) {
13		if (typeof selector === "undefined")
14			selector = document;
15
16		$(selector).find("[pagination]").each(function() {
17			var nb = $(this).attr("pagination");
18			var position = $(this).attr("pagination-pos");
19
20			simplePaginationInstantiate(this, nb, position);
21		});
22	}
23
24	function simplePaginationInstantiate(selector, nbByPage, position) {
25		simplePaginationInit(function() {
26			var pager = $("<div></div>");
27			if( position == 'after' ) {
28				$(selector).after(pager);
29			} else  {
30				$(selector).before(pager);
31			}
32
33			var prevText = $(selector).attr('pagination-prev') || 'Précédent';
34			var nextText = $(selector).attr('pagination-next') || 'Suivant';
35            let items = $(selector).attr("pagination-total") ?? $(selector).children().not(".filtered").size();
36
37			// langue_selectionne_du_site?value fait bugger le script si il n'existe pas = A corriger
38			$(pager).pagination({
39				items: items,
40				itemsOnPage: nbByPage,
41				cssStyle: 'light-theme',
42				prevText:prevText,
43				nextText:nextText,
44				displayedPages:3,
45				onPageClick:function(page, event) {
46                    const _callback = $(selector).attr("pagination-callback");
47                    if (event) {
48                        if (_callback != '') {
49                            window[_callback](page);
50                        } else {
51                            $(selector).children().not(".filtered").hide().slice((page - 1) * nbByPage, page * nbByPage).show();
52                        }
53                    }
54
55                    if (page != 1) {
56                        $('html, body').animate({
57                            scrollTop: $(selector).offset().top - 200
58                        }, 500);
59                    }
60				},
61				onInit:function() {
62					$(pager).pagination('selectPage', $(selector).attr("pagination-current") ?? 1);
63				}
64			});
65		});
66	}
67
68	/* Data table */
69	function dataTablesInit(callback) {
70		$.getCss('/global/vendor/datatables/datatables/media/css/demo_page.css');
71		$.getCss('/global/vendor/datatables/datatables/media/css/demo_table.css');
72		$LAB.script("/global/vendor/datatables/datatables/media/js/jquery.dataTables.js").wait(function(){
73			callback()
74		})
75	}
76
77	/* Data table */
78	function dataTableInit(callback) {
79		$LAB.script("/global/javascript/jquery.dataTables.js").wait(function(){
80			dataTableCustomize(callback);
81		})
82	}
83
84	/* Table sorter */
85	function tablesorterInit(callback) {
86		$.getCss('/global/vendor/mottie/tablesorter/css/theme.blue.css');
87		$.getCss('/global/vendor/mottie/tablesorter/addons/pager/jquery.tablesorter.pager.css');
88		$LAB.script("/global/vendor/mottie/tablesorter/js/jquery.tablesorter.js").wait().
89			script("/global/vendor/mottie/tablesorter/js/jquery.tablesorter.widgets.js").
90			script("/global/vendor/mottie/tablesorter/js/widgets/widget-math.js").
91			script("/global/vendor/mottie/tablesorter/js/parsers/parser-input-select.js?v=20150617").
92			script("/global/vendor/mottie/tablesorter/addons/pager/jquery.tablesorter.pager.js").wait(function(){
93				tableSorterCustomize(callback);
94		})
95	}
96
97	function dataTableCustomize(callback) {
98		$.extend(true, $.fn.dataTable.defaults, {
99			searching: false,
100			"oLanguage": {
101 				"sLengthMenu": polyglot.t('datatables.sLengthMenu'),
102				"sInfo": polyglot.t('datatables.sInfo'),
103				"sInfoEmpty": polyglot.t('datatables.sInfoEmpty'),
104				"sZeroRecords": polyglot.t('datatables.sZeroRecords'),
105				'sProcessing' : polyglot.t('datatables.sProcessing'),
106				'sLoadingRecords' :  polyglot.t('datatables.sLoadingRecords'),
107				'sInfoFiltered' :  polyglot.t('datatables.sInfoFiltered'),
108				'sEmptyTable' :  polyglot.t('datatables.sEmptyTable')
109			}
110		});
111
112
113		$.extend(true, $.fn.dataTableExt.oSort, {
114			"date-uk-pre": function ( a ) {
115				var ukDatea = a.split('/');
116				return (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
117			},
118
119			"date-uk-asc": function ( a, b ) {
120				return ((a < b) ? -1 : ((a > b) ? 1 : 0));
121			},
122
123			"date-uk-desc": function ( a, b ) {
124				return ((a < b) ? 1 : ((a > b) ? -1 : 0));
125			}
126		} );
127
128		$.extend(true, $.fn.dataTableExt.oSort, {
129			"num-html-pre": function ( a ) {
130				var x = String(a).replace(/[^0-9\.]+/g, '');
131				return parseFloat( x );
132			},
133			"num-html-asc": function ( a, b ) {
134				return ((a < b) ? -1 : ((a > b) ? 1 : 0));
135			},
136			"num-html-desc": function ( a, b ) {
137				return ((a < b) ? 1 : ((a > b) ? -1 : 0));
138			}
139		});
140
141		callback();
142	}
143
144	function tableSorterCustomize(callback) {
145		$.tablesorter.addParser({
146			id: "currencyFR",
147			is: function(s, table, cell) {
148				return true;
149			},
150			format: function(s, table, cell, cellIndex) {
151				if (!(/,/).test(s))
152					s += ",00";
153				var n = $.tablesorter.formatFloat((s || '').replace(/[^\w,. \-()]/g, ""), table);
154				return s && typeof n === 'number' ? n : s ? $.trim( s && table.config.ignoreCase ? s.toLocaleLowerCase() : s ) : s;
155			},
156			type: "numeric"
157		});
158
159		$.tablesorter.addParser({
160			id: "fancyNumber",
161			is: function (s) {
162				return /^[0-9]?[0-9,\.\ ]*$/.test(s);
163			},
164			format: function (s) {
165				return $.tablesorter.formatFloat(s.replace(/ /g, ''));
166			},
167			type: "numeric"
168		});
169
170		$.tablesorter.addParser({
171			id: "nom",
172			is: function(s, table, cell) {
173				return false;
174			},
175			format: function(s, table, cell, cellIndex) {
176				return $(cell).find('.nom').val();
177			},
178			type: "text"
179		});
180
181		$.tablesorter.addParser({
182			id: 'ddmmyy',
183			is: function() {
184				return false;
185			},
186			format: function(s, table) {
187
188				s = s
189				// replace separators
190					.replace(/\s+/g," ").replace(/[\-|\.|\,]/g, "/")
191					// reformat dd/mm/yy to mm/dd/yy
192					.replace(/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{2})/, "$2/$1/$3");
193				var d = new Date(s), y = d.getFullYear();
194				// if date > 50 years old, add 100 years
195				// this will work when people start using "70" and mean "2070"
196				if (new Date().getFullYear() - y > 50) {
197					d.setFullYear( y + 100 );
198				}
199				return d.getTime();
200			},
201			type: 'numeric'
202		});
203
204		callback();
205	}
206
207	function tablesorterSearch() {
208        $("[tablesorter]").each(function() {
209            tablesorterInstantiate(this);
210        });
211
212        $(document).one('DOMNodeInserted', '[tablesorter]', function() {
213			tablesorterInstantiate(this);
214		});
215	}
216
217	function tablesorterInstantiate(selector) {
218
219		var currency = $(selector).data('currency') ?  $(selector).data('currency') : '&#8364;';
220		tablesorterInit(function() {
221
222			var widgets = ["filter", 'math'];
223			var sortList = [];
224
225			if ($(selector).data('sortList'))
226				sortList.push($(selector).data('sortList'));
227
228			// fait car sur certain tableau, lorsqu'on selectionne un item dans un select, ca scroll vers le haut dans le tableau.
229			// S'il y a ce pb il faut mettre data-nostickyheaders="1"
230			if (!$(selector).data('nostickyheaders'))
231				widgets.push('stickyHeaders');
232
233			$(selector).tablesorter({
234				theme : 'blue',
235				dateFormat : "ddmmyyyy",
236				sortLocaleCompare : true,
237				widgets: widgets,
238				sortList : sortList,
239				widgetOptions : {
240					filter_columnFilters : true,
241					filter_hideFilters : false,
242					stickyHeaders_offset: 46,
243					filter_ignoreCase : true,
244					filter_liveSearch : true,
245					filter_defaultAttrib : 'data-value',
246					math_data     : 'math', // data-math attribute
247					math_ignore   : [0, 1],
248					math_mask     : '# ##0.00',
249					math_complete : function($cell, wo, result, value, arry) {
250					  var txt = result + currency;
251					  /*if ($cell.attr('data-math') === 'all-sum') {
252						// when the "all-sum" is processed, add a count to the end
253						return txt + ' (Sum of ' + arry.length + ' cells)';
254					  }*/
255					  return txt;
256					}
257				}
258			});
259
260			var filterEndCallback;
261			if ($(selector).data('filter-end-callback'))
262			{
263				filterEndCallback = window[$(selector).data('filter-end-callback')];
264				if (typeof filterEndCallback === 'function')
265					$(selector).bind('filterEnd', filterEndCallback);
266			}
267
268			var pager = $(selector).attr('pager');
269			if (pager) {
270				$(selector).tablesorterPager(window[pager]);
271			}
272		});
273	}
274
275
276	/* Color picker */
277	function colorPickerInit(callback) {
278		$.getCss('/global/vendor/bgrins/spectrum/spectrum.css');
279		$LAB.script("/global/vendor/bgrins/spectrum/spectrum.js").wait(function(){
280			callback()
281		})
282	}
283
284	function colorPickerSearch(selector) {
285		if (typeof selector === "undefined")
286			selector = document;
287
288		$(selector).find(".paramColorPicker").each(function() {
289			colorPickerInstantiate(this);
290		});
291	}
292
293	function colorPickerInstantiate(selector) {
294		colorPickerInit(function() {
295		   $(selector).spectrum({
296			   showPalette: true,
297			   palette: [],
298			   maxSelectionSize: 30,
299			   localStorageKey: "spectrum",
300			   showInitial: true,
301			   showInput: true,
302			   preferredFormat: "hex"
303		   });
304		});
305	}
306
307	/* Quill editor */
308	function quillEditorInit(callback) {
309		$.getCss('https://cdn.quilljs.com/1.3.6/quill.snow.css');
310        $.getCss('/global/vendor/contentco/quill-emoji/dist/quill-emoji.css');
311		$LAB.script("https://cdn.quilljs.com/1.3.6/quill.js").wait().
312			script("/global/vendor/contentco/quill-emoji/dist/quill-emoji.js").wait(function(){
313				callback()
314		})
315	}
316
317	function quillEditorSearch(selector) {
318		if (typeof selector === "undefined")
319			selector = document;
320
321		$(selector).find(".quill-editor:not('.quill-editor-instantiate')").each(function() {
322            $(this).addClass('quill-editor-instantiate');
323			quillEditorInstantiate(this);
324		});
325	}
326
327	function quillEditorInstantiate(selector) {
328		quillEditorInit(function() {
329            if ($(selector).hasClass('quill-editor-simple')) {
330                var nameInput = $(selector).data('input');
331                $(selector).before('<input type="hidden" name="' + nameInput + '" />');
332
333                var quill = new Quill(selector, {
334                    theme: 'snow',
335
336                    modules: {
337                        toolbar: [['bold', 'italic', 'underline'], ['link'],[{ 'list': 'ordered' }, { 'list': 'bullet'}],['emoji'],['clean']],
338                        "emoji-toolbar": true,
339                    },
340
341                    formats: ['bold', 'italic', 'underline', 'link', 'list', 'emoji'],
342                    handlers: {
343                        'emoji': function () {}
344                    }
345                });
346                quill.on('text-change', function(delta, oldDelta, source) {
347                    $("[name='"+nameInput+"']").val(quill.root.innerHTML);
348                });
349                $("[name='"+nameInput+"']").val(quill.root.innerHTML);
350            }
351            if ($(selector).hasClass('quill-editor-fonts')) {
352                var nameInput = $(selector).data('input');
353                $(selector).before('<input type="hidden" name="' + nameInput + '" />');
354
355                var quill = new Quill(selector, {
356                    theme: 'snow',
357
358                    modules: {
359                        toolbar: [['bold', 'italic', 'underline'],[{'font':[]}, {'size':[]}, {'color' : []}, {'align':[]}], ['link'],[{ 'list': 'ordered' }, { 'list': 'bullet'}],['emoji'],['clean']],
360                        "emoji-toolbar": true,
361                    },
362
363                    formats: ['bold', 'italic', 'underline', 'link', 'list', 'emoji', 'color', 'font', 'align', 'size'],
364                    handlers: {
365                        'emoji': function () {}
366                    }
367                });
368                quill.on('text-change', function(delta, oldDelta, source) {
369                    $("[name='"+nameInput+"']").val(quill.root.innerHTML);
370                });
371                $("[name='"+nameInput+"']").val(quill.root.innerHTML);
372            }
373		});
374	}
375
376	$(function() {
377		simplePaginationSearch();
378		tablesorterSearch();
379		colorPickerSearch();
380        quillEditorSearch();
381	});
382
383}
384
385var init_navigation_js = true;

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.