1$.ajaxSetup({ 2 headers: 3 { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } 4}); 5 6let inputElement = document.createElement('input'); 7inputElement.setAttribute('type', 'hidden'); 8inputElement.setAttribute('name', 'secret_xss_lite'); 9inputElement.setAttribute('value', $('meta[name="csrf-token"]').attr('content')); 10 11let forms = document.getElementsByTagName("form"); 12 13setInterval(function() { 14 Object.values(forms).forEach( (key) =>{ 15 var current = key.getAttribute('class'); 16 if (current && current.includes('has_xss')) { 17 return; 18 } 19 20 var method = key.getAttribute('method'); 21 if (!method || method.toLowerCase() === 'get') { 22 return; 23 } 24 25 key.setAttribute('class', ((current ? current : '') + ' has_xss').trim()) 26 key.insertAdjacentHTML('afterbegin', inputElement.outerHTML); 27 }) 28}, 1000); 29 30window.NALib = Object; 31 32/******************************************************************************* 33 * Fonctionnalités sur les listes de paramètres 34 ******************************************************************************/ 35function showAddButton(elem, child, del) 36{ 37 if( !child || typeof child == 'undefined') 38 elem.find('.ajoutItem').hide(); 39 40 if( del && typeof del != 'undefined' && elem.find('tr:first').parent() && elem.find('tr:first').parent().children('tr:last.isParent').length) 41 elem.find('tr:first').parent().children('tr:last.isParent').find('.ajoutItem').show(); 42 else 43 elem.find('tr:first').parent().children('tr:last').find('.ajoutItem').show(); 44 45 elem.find('.ajoutDoc').hide(); 46 elem.find('tr:first').parent().children('tr:last').find('.ajoutDoc').show(); 47} 48 49function del_item(elem) 50{ 51 var limit = 1; 52 if (elem.closest('table').find('tr:first').children('th').size()) 53 limit += 1; 54 55 if( elem.closest('tr').hasClass('isParent')) { 56 if( elem.closest('tr').next('tr').hasClass('isChild') ) 57 { 58 alert('Vous devez supprimer les enfants'); 59 return false; 60 } 61 } 62 63 64 if (elem.closest('table').find('tr:first').parent().children('tr').size() > limit) 65 { 66 var tab_tmp = elem.closest('table'); 67 var deletedIdex = tab_tmp.find('tr:not(.form-head)').index(elem.closest('tr')); 68 elem.closest('tr').remove(); 69 showAddButton(tab_tmp, null, true); 70 71 var start = tab_tmp.find('tr:first').children('th').size() ? 1 : 0; 72 73 tab_tmp.find('tr:first').parent().children('tr').each( 74 function(index) 75 { 76 rename_item($(this), index - start); 77 } 78 ); 79 } 80 else 81 { 82 reset_item(elem, 0); 83 } 84 85 if (typeof tab_tmp != 'undefined') 86 tab_tmp.trigger('deleted-item', deletedIdex); 87} 88 89function addSousQuestion(elem) 90{ 91 clone = ajout_item(elem, false, true); 92 93 clone.find('.add_dom').hide(); 94 clone.find('.open-edit-popup-disabled').show().css('opacity', '0.2'); 95 clone.find('.open-edit-popup').hide(); 96 if( !clone.find('td:visible:first').find('.sous-question').length ) 97 clone.find('td:visible:first').prepend('<div class="sous-question"></div>'); 98 clone.find('.sous-question').html('<img src="/global/images/arrow_ltr2.g
98if" style="padding:10px;">'); 99 clone.find('.ajoutItem').hide(); 100 clone.find('.is_child').val(1); 101 //clone.find('.is_child').attr('data-default', 1); 102 103 104 if( typeof customChild == 'function') 105 customChild(clone); 106 107 //console.log(elem); 108} 109 110function rename_item(elem, index) 111{ 112 elem.closest('tr').find(".text, .datepicker-tabform, select.std_autocomplete ").each( 113 function() 114 { 115 console.log($(this).attr('name')); 116 var name = $(this).attr('name').lastIndexOf('[') != -1 ? $(this).attr('name').substr(0, 117 $(this).attr('name').lastIndexOf('[')) 118 + '[' + index + ']' : $(this).attr('name'); 119 $(this).attr('name', name); 120 121 if ($(this).data('name')) 122 { 123 name = $(this).data('name').lastIndexOf('[') != -1 ? $(this).data('name').substr(0, 124 $(this).data('name').lastIndexOf('[')) 125 + '[' + index + ']' : $(this).data('name'); 126 $(this).data('name', name); 127 } 128 }); 129 130 elem.closest('tr').find(".textarea").each( 131 function() 132 { 133 var name = $(this).attr('name').lastIndexOf('[') != -1 ? $(this).attr('name').substr(0, 134 $(this).attr('name').lastIndexOf('[')) 135 + '[' + index + ']' : $(this).attr('name'); 136 $(this).attr('name', name); 137 138 if ($(this).data('name')) 139 { 140 name= $(this).data('name').lastIndexOf('[') != -1 ? $(this).data('name').substr(0, 141 $(this).data('name').lastIndexOf('[')) 142 + '[' + index + ']' : $(this).data('name'); 143 $(this).data('name', name); 144 } 145 }); 146 147 elem.closest('tr').find(".checkbox").each( 148 function() 149 { 150 var name = $(this).attr('name').lastIndexOf('[') != -1 ? $(this).attr('name').substr(0, 151 $(this).attr('name').lastIndexOf('[')) 152 + '[' + index + ']' : $(this).attr('name'); 153 $(this).attr('name', name); 154 155 156 if ($(this).data('name')) 157 { 158 name= $(this).data('name').lastIndexOf('[') != -1 ? $(this).data('name').substr(0, 159 $(this).data('name').lastIndexOf('[')) 160 + '[' + index + ']' : $(this).data('name'); 161 $(this).data('name', name); 162 } 163 }); 164 165 elem.closest('tr').find(".radio").each( 166 function() 167 { 168 $(this).attr('value', index); 169 }); 170 171 elem.closest('tr').find("select.select").each( 172 function() 173 { 174 //return ; 175 176 var hook = ''; 177 if( $(this).attr('name').lastIndexOf('[]') != -1 ) 178 hook = '[]'; 179 180 $(this).attr('name', $(this).attr('name').replace(hook, '')); 181 182 var name = $(this).attr('name').lastIndexOf('[') != -1 ? 183 $(this).attr('name').substr(0, $(this).attr('name').lastIndexOf('[')) + '[' + index + ']' 184 : 185 $(this).attr('name'); 186 187 $(this).attr('name', name + hook); 188 189 if ($(this).data('name')) 190 { 191 name= $(this).data('name').lastIndexOf('[') != -1 ? $(this).data('name').substr(0, 192 $(this).data('name').lastIndexOf('[')) 193 + '[' + index + ']' : $(this).data('name'); 194 $(this).data('name', name); 195 } 196 }); 197 198 elem.closest('tr').find(".hidden,.slider").each( 199 function() 200 { 201 if ($(this).attr('name')) { 202 var name = $(this).attr('name').lastIndexOf('[') != -1 ? $(this).attr('name').substr(0, 203 $(this).attr('name').lastIndexOf('[')) 204 + '[' + index + ']' : $(this).attr('name'); 205 $(this).attr('name', name); 206 } 207 208 if ($(this).data('name')) 209 { 210 name= $(this).data('name').lastIndexOf('[') != -1 ? $(this).data('name').substr(0, 211 $(this).data('name').lastIndexOf('[')) 212 + '[' + index + ']' : $(this).data('name'); 213 $(this).data('name', name); 214 } 215 }); 216 217 218 elem.closest('tr').find(".file").each( 219 function() 220 { 221 var name = $(this).attr('name').lastIndexOf('[') != -1 ? $(this).attr('name').substr(0, 222 $(this).attr('name').lastIndexOf('[')) 223 + '[' + index + ']' : $(this).attr('name'); 224 $(this).attr('name', name); 225 226 if ($(this).data('name')) 227 { 228 name= $(this).data('name').lastIndexOf('[') != -1 ? $(this).data('name').substr(0, 229 $(this).data('name').lastIndexOf('[')) 230 + '[' + index + ']' : $(this).data('name'); 231 $(this).data('name', name); 232 } 233 }); 234 235 236 elem.closest('tr').find("[type=checkbox]:not(.optGroupCheck)").each( 237 function() 238 { 239 var hook = ''; 240 if( $(this).attr('name').lastIndexOf('[]') != -1 ) 241 hook = '[]'; 242 243 $(this).attr('name', $(this).attr('name').replace(hook, '')); 244 245 var name = $(this).attr('name').lastIndexOf('[') != -1 ? $(this).attr('name').substr(0, 246 $(this).attr('name').lastIndexOf('[')) 247 + '[' + index + ']' : $(this).attr('name'); 248 249 $(this).attr('name', name + hook); 250 251 if ($(this).data('name')) 252 { 253 name = $(this).data('name').lastIndexOf('[') != -1 ? $(this).data('name').substr(0, 254 $(this).data('name').lastIndexOf('[')) 255 + '[' + index + ']' : $(this).data('name'); 256 $(this).data('name', name); 257 } 258 }); 259} 260 261function reset_item(elem, index, notResetItem) 262{ 263 elem.closest('tr').find(".text, select.std_autocomplete").each( 264 function() 265 { 266 if (!$(this).attr('name')) { 267 // Might be a multipleSelect search input so no need to process 268 return; 269 } 270 271 var name = $(this).attr('name').lastIndexOf('[') != -1 ? $(this).attr('name').substr(0, 272 $(this).attr('name').lastIndexOf('[')) 273 + '[' + index + ']' : $(this).attr('name'); 274 275 if(typeof notResetItem != 'undefined' && notResetItem) 276 $(this).attr('name', name); 277 else 278 $(this).val('').attr('name', name); 279 280 if ($(this).data('name')) 281 { 282 name = $(this).data('name').lastIndexOf('[') != -1 ? $(this).data('name').substr(0, 283 $(this).data('name').lastIndexOf('[')) 284 + '[' + index + ']' : $(this).data('name'); 285 $(this).data('name', name); 286 } 287 288 if (typeof $(this).data('default') != 'undefined') 289 $(this).val($(this).data('default')); 290 }); 291 292 elem.closest('tr').find(".datepicker-tabform").each( 293 function() 294 { 295 var name = $(this).attr('name').lastIndexOf('[') != -1 ? $(this).attr('name').substr(0, 296 $(this).attr('name').lastIndexOf('[')) 297 + '[' + index + ']' : $(this).attr('name'); 298 299 if(typeof notResetItem != 'undefined' && notResetItem) 300 $(this).attr('name', name); 301 else 302 $(this).val('').attr('name', name); 303 304 if ($(this).data('name')) 305 { 306 name = $(this).data('name').lastIndexOf('[') != -1 ? $(this).data('name').substr(0, 307 $(this).data('name').lastIndexOf('[')) 308 + '[' + index + ']' : $(this).data('name'); 309 $(this).data('name', name); 310 } 311 312 if (typeof $(this).data('default') != 'undefined') 313 $(this).val($(this).data('default')); 314 315 $(this).removeAttr('id').removeClass('hasDatepicker').next('.ui-datepicker-trigger').remove().end() 316 }); 317 318 elem.closest('tr').find(".textarea").each( 319 function() 320 { 321 var name = $(this).attr('name').lastIndexOf('[') != -1 ? $(this).attr('name').substr(0, 322 $(this).attr('name').lastIndexOf('[')) 323 + '[' + index + ']' : $(this).attr('name'); 324 325 if(typeof notResetItem != 'undefined' && notResetItem) 326 $(this).attr('name', name); 327 else 328 $(this).val('').attr('name', name); 329 330 if ($(this).data('name')) 331 { 332 name = $(this).data('name').lastIndexOf('[') != -1 ? $(this).data('name').substr(0, 333 $(this).data('name').lastIndexOf('[')) 334 + '[' + index + ']' : $(this).data('name'); 335 $(this).data('name', name); 336 } 337 338 if (typeof $(this).data('default') != 'undefined') 339 $(this).val($(this).data('default')); 340 }); 341 342 elem.closest('tr').find(".checkbox").each( 343 function() 344 { 345 var name = $(this).attr('name').lastIndexOf('[') != -1 ? $(this).attr('name').substr(0, 346 $(this).attr('name').lastIndexOf('[')) 347 + '[' + index + ']' : $(this).attr('name'); 348 $(this).attr('checked', false).attr('name', name); 349 350 if ($(this).data('name')) 351 { 352 name = $(this).data('name').lastIndexOf('[') != -1 ? $(this).data('name').substr(0, 353 $(this).data('name').lastIndexOf('[')) 354 + '[' + index + ']' : $(this).data('name'); 355 $(this).data('name', name); 356 } 357 }); 358 359 elem.closest('tr').find(".radio").each( 360 function() 361 { 362 $(this).attr('checked', false).attr('value', index); 363 }); 364 365 elem.closest('tr').find("select.select").each( 366 function() 367 { 368 var hook = ''; 369 if( $(this).attr('name').lastIndexOf('[]') != -1 ) 370 hook = '[]'; 371 372 $(this).attr('name', $(this).attr('name').replace(hook, '')); 373 374 var name = $(this).attr('name').lastIndexOf('[') != -1 ? 375 $(this).attr('name').substr(0, $(this).attr('name').lastIndexOf('[')) + '[' + index + ']' 376 : 377 $(this).attr('name'); 378 379 $(this).attr('name', name + hook); 380 381 if ($(this).data('name')) 382 { 383 name = $(this).data('name').lastIndexOf('[') != -1 ? $(this).data('name').substr(0, 384 $(this).data('name').lastIndexOf('[')) 385 + '[' + index + ']' : $(this).data('name'); 386 $(this).data('name', name); 387 } 388 389 390 $(this).selectedIndex = 0; 391 $(this).prop('selectedIndex', 0); 392 393 if (typeof $(this).data('default') != 'undefined') { 394 $(this).val($(this).data('default')); 395 } 396 397 $(this).change(); 398 }); 399 400 elem.closest('tr').find(".hidden,.slider").each( 401 function() 402 { 403 if ($(this).attr('name')) { 404 var name = $(this).attr('name').lastIndexOf('[') != -1 ? $(this).attr('name').substr(0, 405 $(this).attr('name').lastIndexOf('[')) 406 + '[' + index + ']' : $(this).attr('name'); 407 $(this).attr('name', name); 408 } 409 410 if ($(this).data('name')) 411 { 412 name = $(this).data('name').lastIndexOf('[') != -1 ? $(this).data('name').substr(0, 413 $(this).data('name').lastIndexOf('[')) 414 + '[' + index + ']' : $(this).data('name'); 415 $(this).data('name', name); 416 } 417 418 $(this).val(typeof $(this).data('default') != 'undefined' ? $(this).data('default') : ''); 419 if ($(this).hasClass('true')) { 420 $(this).removeClass('true').addClass('false'); 421 } 422 }); 423 elem.closest('tr').find(".file").each( 424 function() 425 { 426 var name = $(this).attr('name').lastIndexOf('[') != -1 ? $(this).attr('name').substr(0, 427 $(this).attr('name').lastIndexOf('[')) 428 + '[' + index + ']' : $(this).attr('name'); 429 $(this).val('').attr('name', name); 430 431 if ($(this).data('name')) 432 { 433 name = $(this).data('name').lastIndexOf('[') != -1 ? $(this).data('name').substr(0, 434 $(this).data('name').lastIndexOf('[')) 435 + '[' + index + ']' : $(this).data('name'); 436 $(this).data('name', name); 437 } 438 439 $(this).prev('br').remove(); 440 $(this).prev('label').remove(); 441 $(this).prev('input.checkbox').remove(); 442 $(this).prev('a').remove(); 443 }); 444 445 elem.closest('tr').find(".optGroupCheck").each( 446 function() 447 { 448 $(this).attr('checked', false); 449 $(this).closest('div').removeClass('selected'); 450 $(this).closest('div').removeClass('semiselected'); 451 } 452 ); 453 454 elem.closest('tr').find(".multipleSelect").each( 455 function() 456 { 457 $(this).find('.input-search').val(''); 458 $(this).find('.input-search').trigger('input'); 459 460 $(this).find('.nOption').each(function() { 461 let input = $(this).find('input'); 462 let label = $(this).find('label'); 463 input.attr('id', input.attr('name') + input.attr('id')); 464 label.attr('for', input.attr('id')); 465 }); 466 } 467 ); 468 469 elem.closest('tr').find("[type=checkbox]:not(.optGroupCheck)").each( 470 function() 471 { 472 var hook = ''; 473 if( $(this).attr('name').lastIndexOf('[]') != -1 ) 474 hook = '[]'; 475 476 $(this).attr('name', $(this).attr('name').replace(hook, '')); 477 478 var name = $(this).attr('name').lastIndexOf('[') != -1 ? $(this).attr('name').substr(0, 479 $(this).attr('name').lastIndexOf('[')) 480 + '[' + index + ']' : $(this).attr('name'); 481 482 $(this).attr('checked', false).attr('name', name + hook); 483 $(this).closest('div').removeClass('selected'); 484 $(this).closest('div').removeClass('semiselected'); 485 486 if ($(this).data('name')) 487 { 488 name = $(this).data('name').lastIndexOf('[') != -1 ? $(this).data('name').substr(0, 489 $(this).data('name').lastIndexOf('[')) 490 + '[' + index + ']' : $(this).data('name'); 491 $(this).data('name', name); 492 } 493 494 $(this).prev('br').remove(); 495 $(this).prev('label').remove(); 496 $(this).prev('[type=checkbox]').remove(); 497 $(this).prev('a').remove(); 498 }); 499 500 elem.closest('tr').find(".lien_divers .delItem").attr('onClick', "del_item($(this)); return false;"); 501 502} 503 504function ajout_item(elem, callback, child) 505{ 506 var limit = parseInt(elem.closest('table').siblings('input.limit').val()); 507 if (limit && elem.closest('table').find('tr:first').children('th').size()) 508 limit += 1; 509 if (!limit || elem.closest('table').find('tr:first').parent().children('tr').size() < limit) 510 { 511 var clone = elem.closest('table').find('tr:first').parent().children('tr:last').clone(/* true */); 512 513 var index = elem.closest('table').find('tr:first').parent().children('tr').length; 514 if (elem.closest('table').find('tr:first').children('th').size()) 515 index--; 516 517 reset_item(clone, index, elem.hasClass('notResetItem')); 518 519 520 if( child && typeof child != 'undefined' && elem.closest('tr').nextAll('tr.isParent').length) 521 elem.closest('tr').nextAll('tr.isParent:first').before(clone); 522 else 523 elem.closest('table').append(clone); 524 525 showAddButton(elem.closest('table'), child); 526 elem.closest('table').find('tr:first').parent().children('tr:last').find('.delItem').show(); 527
528 make_calendar(); 529 530 clone.removeClass('isChild'); 531 clone.removeClass('isParent'); 532 clone.find('.hide_clone').hide(); 533 534 if( child && typeof child != 'undefined') { 535 clone.addClass('isChild'); 536 } 537 else { 538 clone.addClass('isParent'); 539 } 540 } 541 else 542 { 543 alert(polyglot.t("core.limit_is", {limit:parseInt(elem.closest('table').siblings('input.limit').val())})); 544 return false; 545 } 546 initUIAutocomplete(); 547 548 549 if( typeof clone != "undefined") 550 if (clone.has('.datepicker-tabform') && $.datepicker != 'undefined') 551 { 552 let minDate = clone.find('.datepicker-tabform').data('mindate') ? new Date(clone.find('.datepicker-tabform').data('mindate')) : null; 553 clone.find('.datepicker-tabform').datepicker( 554 { 555 showOn: 'button', 556 buttonImage: (typeof url_root != 'undefined' ? url_root : "" ) + '/global/images/calendar.gif', 557 buttonImageOnly: true, 558 dateFormat : 'dd/mm/yy', 559 numberOfMonths: 3, 560 showButtonPanel: true, 561 minDate: minDate, 562 onSelect: function(date) { 563 this.dispatchEvent(new Event("input")); 564 } 565 } 566 ); 567 } 568 569 clone.find('select').change(); 570 571 initAjoutItem(clone, callback); 572 initSelectColorPicker(); 573 574 if( typeof clone != "undefined") { 575 clone.find('.select2-container').each(function() 576 { 577 $(this).remove(); 578 }); 579 580 clone.find('.select2').each(function() 581 { 582 $(this).unbind(".select2") .attr({"tabIndex": this.elementTabIndex}).show(); 583 }); 584 clone.find('.simple-search').each(function() 585 { 586 $(this).unbind(".simple-search") .attr({"tabIndex": this.elementTabIndex}).show(); 587 // $(this).select2(); 588 }); 589 590 591 // LF : si on le fait pas 2 fois il initialise pas, je sais pas pquoi 592 var nbIter = 1; 593 var patt = /base=100/i; 594 if (!window.location.search.match(patt)) 595 nbIter = 2; 596 for (var i = 0; i < nbIter; i++) { 597 clone.find('div.autocomplete-initialized').each(function() { 598 $(this).remove(); 599 }); 600 clone.find('select.autocomplete-initialized-new').each(function() 601 { 602 $(this).data('libelle', ''); 603 $(this).val(''); 604 605 //$(this).unbind(".std_autocomplete").removeClass('autocomplete-initialized'); 606 $(this).removeClass('autocomplete-initialized-new'); 607 }); 608 609 let select = []; 610 if (clone[0].getElementsByClassName('na-select2')[0] && clone[0].getElementsByClassName('na-select2')[0].dataset.select2Id) 611 select = select.concat(Array.from(clone[0].getElementsByClassName('na-select2'))); 612 if (clone[0].getElementsByClassName('select2')[0] && clone[0].getElementsByClassName('select2')[0].dataset.select2Id) 613 select = select.concat(Array.from(clone[0].getElementsByClassName('select2'))); 614 if (clone[0].getElementsByClassName('simple-search')[0] && clone[0].getElementsByClassName('simple-search')[0].dataset.select2Id) 615 select = select.concat(Array.from(clone[0].getElementsByClassName('simple-search'))); 616 if (clone[0].getElementsByClassName('na-select2-autocomplete')[0] && clone[0].getElementsByClassName('na-select2-autocomplete')[0].dataset.select2Id) 617 select = select.concat(Array.from(clone[0].getElementsByClassName('na-select2-autocomplete'))); 618 if (clone[0].getElementsByClassName('std_autocomplete')[0] && clone[0].getElementsByClassName('std_autocomplete')[0].dataset.select2Id) 619 select = select.concat(Array.from(clone[0].getElementsByClassName('std_autocomplete'))); 620 621 if (select) 622 for (let index = 0; index < select.length; index++) { 623 let options = Array.from(select[index].getElementsByTagName('OPTION')); 624 let optionsGroups = Array.from(select[index].getElementsByTagName('OPTGROUP')); 625 options = options.concat(optionsGroups); 626 for (let i = 0; i < options.length; i++) 627 delete options[i].dataset.select2Id; 628 select[index].value = ''; 629 delete select[index].dataset.select2Id; 630 } 631 632 if (clone[0].getElementsByClassName('na-select2')[0] || clone[0].getElementsByClassName('na-select2-autocomplete')[0]) { 633 initSimpleSearch(); 634 initStdAutoComplete(); 635 } else if (typeof $.prototype != 'undefined' && typeof $.prototype.select2 != 'undefined') { 636 $(clone).find('select.simple-search, select.select2').each(function() { 637 var placeHolder = $(this).data('placeholder'); 638 let parent = this.closest('.modal.fade.in') ? this.parentElement : ''; 639 $(this).select2({ 640 width: 'resolve', 641 placeholder: placeHolder != undefined ? placeHolder : '', 642 allowClear: true, 643 dropdownParent: parent 644 }); 645 }); 646 } 647 } 648 } 649 650 /*var defaults = 651 { 652 morePic: (typeof url_root != 'undefined' ? url_root : "" ) + '/global/images/skills_more.png', 653 lessPic: (typeof url_root != 'undefined' ? url_root : "" ) + '/global/images/skills_less.png', 654 width : 'ajust', 655 height : 'clone', 656 beforeTransform: false, 657 afterTransform: false, 658 displayOptOnDisabledItem: false 659 }; 660 clone.find('.multipleSelect').each(function() 661 { 662 initSelectMultiple($(this), defaults); 663 initSearchSelectMultiple($(this), defaults); 664 });*/ 665 666 if( typeof cleanupdom == 'function') 667 cleanupdom(); 668 669 if( typeof customItem == 'function') 670 customItem(clone, child); 671 672 if( child && typeof child != 'undefined') { 673 var tab_tmp = elem.closest('table').find('tr:not(.form-head)'); 674 675 var start = 0; 676 tab_tmp.each(function(index) { 677 //console.log(index, '-----------'); 678 rename_item($(this), index - start); 679 }); 680 return clone; 681 } 682 683 684 return false;
685} 686 687function initUIAutocomplete() 688{ 689 $('.UIautoComplete').each(function() 690 { 691 if ($(this).attr('autocompletepage') != '') 692 { 693 $(this).UIautocomplete('destroy').UIautocomplete( 694 { 695 source : (typeof url_root != 'undefined' ? url_root : "" ) + '/global/ressources/ajax/autocomplete/' + $(this).attr('autoCompletePage') + '.php', 696 minLength : 2, 697 change: function () { 698 $(this).change(); 699 }, 700 select: function(event, ui) { 701 if (ui.item && ui.item.additional) { 702 const add = ui.item.additional; 703 Object.keys(add).forEach(element => { 704 $(".UIauto-" + element).val(add[element]).change(); 705 }); 706 } 707 } 708 }); 709 } 710 }); 711} 712 713function initSelectColorPicker() { 714 $('.colorPicker option').click(function() { 715 $(this).closest("select").css('background-color', '#' + $(this).val()); 716 }); 717 $('.colorPicker').each(function() { 718 $(this).css('background-color', '#' + $(this).val()); 719 }); 720 $('.colorPicker option').each(function() { 721 $(this).css('background-color', '#' + $(this).val()); 722 }); 723} 724 725/******************************************************************************* 726 * Fonctionnalités sur ajout de documents 727 ******************************************************************************/ 728function del_document(elem) 729{ 730 var limit = 1; 731 if (elem.closest('table').find('tr:first').find('th').size()) 732 limit += 1; 733 if (parseInt(elem.closest('table').find('tr').length) > limit) 734 { 735 var tab_tmp = elem.closest('table'); 736 elem.closest('tr').remove(); 737 showAddButton(tab_tmp); 738 } 739 else 740 { 741 reset_document(elem); 742 } 743} 744 745function reset_document(elem) 746{ 747 elem.closest('tr').find(".libelle_doc").html('').css('display', 'none'); 748 elem.closest('tr').find(".champ_doc").css('display', 'block').find('input').attr('disabled', false); 749 elem.closest('tr').find(".champ_doc").find('input').each(function(index) 750 { 751 $(this).val(''); 752 }); 753} 754 755function ajout_document(elem) 756{ 757 var limit = parseInt(elem.closest('table').siblings('input.limit').val()); 758 if (limit && elem.closest('table').find('tr:first').find('th').size()) 759 limit += 1; 760 if (!limit || parseInt(elem.closest('table').find('tr').length) < limit) 761 { 762 var clone = elem.closest('table').find('tr:last').clone(); 763 reset_document(clone); 764 clone.find('.ajoutDoc').click(function() 765 { 766 return ajout_item($(this)); 767 }) 768 elem.closest('table').append(clone); 769 770 showAddButton(elem.closest('table')); 771 } 772 else 773 { 774 alert(polyglot.t("core.limit_is", {limit:parseInt(elem.closest('table').siblings('input.limit').val())})); 775 } 776 initAjoutItem(); 777 return false; 778} 779 780function initAjoutItem(elem, callback) 781{ 782 if (typeof elem == 'undefined') 783 elem = $(document); 784 785 elem.on('click', ".ajoutItem", function() 786 { 787 ajout_item($(this), callback); 788 789 if (typeof callback == 'function') 790 callback($(this)); 791 792 return false; 793 }); 794 795 elem.on('click', ".ajoutDoc", function() 796 { 797 return ajout_item($(this)); 798 }); 799} 800 801function loadJsFile(jsFilename) 802{ 803 $.ajax( 804 { 805 url : jsFilename, 806 dataType : 'script', 807 async : false 808 }); 809} 810 811function replaceJQueryVersion(newJQueryVersion) 812{ 813 console.log(parseInt(jQuery.fn.jquery.replace(/\./g, ''))); 814 815 if (parseInt(jQuery.fn.jquery.replace(/\./g, '')) < parseInt(newJQueryVersion.replace(/\./g, ''))) 816 { 817 loadJsFile('/global/javascript/jquery-' + newJQueryVersion + '.min.js'); 818 } 819 820 console.log(parseInt(jQuery.fn.jquery.replace(/\./g, ''))); 821} 822 823function retoreOldJqueryVersion() 824{ 825 console.log(parseInt(jQuery.fn.jquery.replace(/\./g, ''))); 826 jQuery.noConflict(); 827 console.log(parseInt(jQuery.fn.jquery.replace(/\./g, ''))); 828} 829 830function replaceTimeAgoLine() 831{ 832 if($('span.hasTimeAgo').size()) 833 $('span.hasTimeAgo').timeago().removeClass('hasTimeAgo'); 834} 835 836function initTimeAgo() 837{ 838 if (typeof $.timeago == 'undefined') 839 { 840 var s = document.getElementsByTagName('script')[0]; 841 842 var a = document.createElement('script'); 843 a.src = (typeof url_root != 'undefined' ? url_root : "" ) + '/global/javascript/jquery.timeAgo/jquery.timeAgo.js?v=20190813'; 844 a.type = 'text/javascript'; 845 a.async = true; 846 a.onload = a.onreadystatechange = function() 847 { 848 a.onreadystatechange = a.onload = null; 849 850 var langue; 851 if ($('#langue_selectionne_du_site').length) 852 langue = $('#langue_selectionne_du_site').val(); 853 else 854 langue = typeof langue_selected != 'undefined' ? langue_selected : ''; 855 856 $().timeago.lang = langue; 857 858 if (langue == 'fr') 859 { 860 b = document.createElement('script'); 861 b.src = (typeof url_root != 'undefined' ? url_root : "" ) + '/global/javascript/jquery.timeAgo/languages/fr.js'; 862 b.type = 'text/javascript'; 863 b.async = true; 864 b.onload = b.onreadystatechange = function() 865 { 866 b.onreadystatechange = b.onload = null; 867 replaceTimeAgoLine(); 868 } 869 if (s && typeof s != 'undefined' && s.parentNode && typeof s.parentNode != 'undefined') 870 s.parentNode.insertBefore(b, s); 871 872 } 873 else 874 {
875 replaceTimeAgoLine(); 876 } 877 } 878 if (typeof s != 'undefined' && typeof s.parentNode != 'undefined') 879 s.parentNode.insertBefore(a, s); 880 } 881 else 882 { 883 replaceTimeAgoLine(); 884 } 885} 886 887function initFancyLink() 888{ 889 version = '1.3.4'; /* Fancybox version to use */ 890 891 if (typeof $.fancybox == 'undefined') 892 { 893 s = document.getElementsByTagName('script')[0]; 894 895 stylesheet = document.createElement('link'); 896 stylesheet.href = (typeof url_root != 'undefined' ? url_root : "" ) + '/global/javascript/jquery.fancybox/jquery.fancybox-' + version + '.css'; 897 stylesheet.rel = 'stylesheet'; 898 stylesheet.type = 'text/css'; 899 if (typeof s != 'undefined' && typeof s.parentNode != 'undefined') 900 s.parentNode.insertBefore(stylesheet, s); 901 902 a = document.createElement('script'); 903 a.src = (typeof url_root != 'undefined' ? url_root : "" ) + '/global/javascript/jquery.fancybox/jquery.fancybox-' + version + '.js'; 904 a.type = 'text/javascript'; 905 a.async = true; 906 a.onload = a.onreadystatechange = function() 907 { 908 a.onreadystatechange = a.onload = null; 909 if(typeof fancybox == 'function') 910 $('a[rel=fancybox], .fancybox').fancybox(); 911 } 912 if (typeof s != 'undefined' && typeof s.parentNode != 'undefined') 913 s.parentNode.insertBefore(a, s); 914 } 915 else 916 { 917 $('a[rel=fancybox], .fancybox').fancybox(); 918 } 919} 920 921function initCodePostal() 922{ 923 if ($.browser && $.browser.msie == true && parseInt($.browser.version, 10) <= 7) 924 return false; 925 926 /* Autocompletion de la ville en fonction du code postal */ 927 $('.autocompleteCP').UIautocomplete('destroy').UIautocomplete( 928 { 929 //'autoFill' : true, 930 'autoFillCallback' : function(res, field) 931 { 932 $(res).each(function() 933 { 934 field.val(this.cp); 935 var ville = this.ville.replace(new RegExp("[ ]*cedex.*", 'gi'), ''); 936 var villeComp = ''; 937 if( this.ville.indexOf('cedex') != -1 ) 938 villeComp = this.ville.replace(new RegExp(".*(cedex.*)", 'gi'), '$1'); 939 940 field.closest('table').find('.autocompleteVille').val(ville); 941 field.closest('table').find('.autocompleteVilleComp').val(villeComp); 942 }); 943 return false; 944 }, 945 'source' : function(request, response) 946 { 947 $.ajax( 948 { 949 'url' : (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/autocomplete/codePostal.php", 950 'dataType' : "json", 951 'data' : 952 { 953 'term' : request.term, 954 'country' : $(this.element).closest('table').find('.select.pays').val() 955 }, 956 'success' : function(data) 957 { 958 response(data); 959 } 960 }); 961 }, 962 'minLength' : 2, 963 'select' : function(event, ui) 964 { 965 var ville = ui.item.ville.replace(new RegExp("[ ]*cedex.*", 'gi'), ''); 966 var villeComp = ''; 967 if( ui.item.ville.indexOf('cedex') != -1 ) 968 villeComp = ui.item.ville.replace(new RegExp(".*(cedex.*)", 'gi'), '$1'); 969 970 if ($(this).closest('table').length) { 971 $(this).closest('table').find('.autocompleteVille').val(ville); 972 $(this).closest('table').find('.autocompleteVilleComp').val(villeComp); 973 } 974 else { 975 $('.autocompleteVille').val(ville); 976 $('.autocompleteVilleComp').val(villeComp); 977 } 978 }, 979 'open' : function(event, ui) 980 { 981 var acData = $(this).data('UIautocomplete'); 982 var currentValue = acData.term; 983 var pattern = '(' + utils.escapeRegExChars(currentValue) + ')'; 984 985 $("ul.ui-autocomplete li a").each(function() 986 { 987 var htmlString = $(this).html(); 988 htmlString = htmlString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); 989 $(this).html(htmlString); 990 }); 991 $("ul.ui-autocomplete").css({'height' : '170px', 'overflowY' : 'scroll', 'fontSize' : '11px'}); 992 } 993 }); 994} 995 996function initVilleEntreprise() 997{ 998 if ($.browser && $.browser.msie == true && parseInt($.browser.version, 10) <= 7) 999 return false; 1000 1001 /* Autocompletion de la ville en fonction du code postal */ 1002 $('.autocompleteVille').UIautocomplete('destroy').UIautocomplete( 1003 { 1004 //'autoFill' : true, 1005 'autoFillCallback' : function(res, field) 1006 { 1007 $(res).each(function() 1008 { 1009 field.val(this.ville); 1010 if (this.cp) 1011 field.closest('table').find('.autocompleteCP').val(this.cp); 1012 }); 1013 return false;
1014 }, 1015 'source' : function(request, response) 1016 { 1017 $.ajax( 1018 { 1019 // 'url': 1020 // (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/autocomplete/ajax_autocomplete_villesEntreprise.php", 1021 'url' : (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/autocomplete/ajax_autocomplete_villes.php", 1022 'dataType' : "json", 1023 'data' : 1024 { 1025 'term' : request.term, 1026 'country' : $(this.element).closest('table').find('.select.pays').val() 1027 }, 1028 'success' : function(data) 1029 { 1030 response(data); 1031 } 1032 }); 1033 }, 1034 'minLength' : 2, 1035 'select' : function(event, ui) 1036 { 1037 if (ui.item.cp) 1038 $(this).closest('table').find('.autocompleteCP').val(ui.item.cp); 1039 }, 1040 'open' : function(event, ui) 1041 { 1042 var acData = $(this).data('UIautocomplete'); 1043 var currentValue = acData.term; 1044 var pattern = '(' + utils.escapeRegExChars(currentValue) + ')'; 1045 1046 $("ul.ui-autocomplete li a").each(function() 1047 { 1048 var htmlString = $(this).html();//.replace(/</g, '<'); 1049 htmlString = htmlString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); 1050 $(this).html(htmlString); 1051 }); 1052 $("ul.ui-autocomplete").css({'height' : '170px', 'overflowY' : 'scroll', 'fontSize' : '11px'}); 1053 } 1054 }); 1055} 1056 1057function initEntreprise() 1058{ 1059 if ($.browser && $.browser.msie == true && parseInt($.browser.version, 10) <= 7) 1060 return false; 1061 1062 $('.autocompleteEntreprise').each(function() { 1063 var name = $(this).attr('name') + "_type"; 1064 1065 $(this).UIautocomplete('destroy').UIautocomplete( 1066 { 1067 //'autoFill' : true, 1068 'autoFillCallback' : function(res, field) 1069 { 1070 $(res).each(function() 1071 { 1072 field.val(this.c_nom); 1073 }); 1074 return false; 1075 }, 1076 'source' : function(request, response) 1077 { 1078 var radio = $("[name="+name+"]:checked"); 1079 $.ajax( 1080 { 1081 'url' : (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/autocomplete/ajax_autocomplete_entreprises.php", 1082 'dataType' : "json", 1083 'data' : 1084 { 1085 'term' : request.term, 1086 'type' : radio.val() 1087 }, 1088 'success' : function(data) 1089 { 1090 response(data); 1091 } 1092 }); 1093 }, 1094 'minLength' : 2, 1095 'open' : function(event, ui) 1096 { 1097 var acData = $(this).data('UIautocomplete'); 1098 var currentValue = acData.term; 1099 var pattern = '(' + utils.escapeRegExChars(currentValue) + ')'; 1100 1101 $("ul.ui-autocomplete li a").each(function() 1102 { 1103 var htmlString = $(this).html();//.replace(/</g, '<'); 1104 htmlString = htmlString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); 1105 $(this).html(htmlString); 1106 }); 1107 $("ul.ui-autocomplete").css({'height' : '170px', 'overflowY' : 'scroll', 'fontSize' : '11px'}); 1108 } 1109 }); 1110 }); 1111 1112} 1113 1114function initEntrepriseGroupe() 1115{ 1116 if ($.browser && $.browser.msie == true && parseInt($.browser.version, 10) <= 7) 1117 return false; 1118 1119 $('.autocompleteEntrepriseGroupe').each(function() { 1120 var name = $(this).attr('name') + "_type"; 1121 1122 $(this).UIautocomplete('destroy').UIautocomplete( 1123 { 1124 //'autoFill' : true, 1125 'autoFillCallback' : function(res, field) 1126 { 1127 $(res).each(function() 1128 { 1129 field.val(this.c_nom); 1130 }); 1131 return false; 1132 }, 1133 'source' : function(request, response) 1134 { 1135 var radio = $("[name="+name+"]:checked"); 1136 $.ajax( 1137 { 1138 'url' : (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/autocomplete/ajax_autocomplete_entreprisesGroupe.php", 1139 'dataType' : "json", 1140 'data' : 1141 { 1142 'term' : request.term, 1143 'type' : radio.val() 1144 }, 1145 'success' : function(data) 1146 { 1147 response(data); 1148 } 1149 }); 1150 }, 1151 'minLength' : 2, 1152 'open' : function(event, ui) 1153 { 1154 var acData = $(this).data('UIautocomplete'); 1155 var currentValue = acData.term; 1156 var pattern = '(' + utils.escapeRegExChars(currentValue) + ')'; 1157 1158 $("ul.ui-autocomplete li a").each(function() 1159 { 1160 var htmlString = $(this).html();//.replace(/</g, '<'); 1161 htmlString = htmlString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); 1162 $(this).html(htmlString); 1163 }); 1164 $("ul.ui-autocomplete").css({'height' : '170px', 'overflowY' : 'scroll', 'fontSize' : '11px'}); 1165 } 1166 }); 1167 }); 1168 1169} 1170 1171function initCNaf() 1172{ 1173 1174 if ($.browser && $.browser.msie == true && parseInt($.browser.version, 10) <= 7) 1175 return false;
1176 1177 /* Autocompletion de la ville en fonction du code postal */ 1178 $('.autocompleteCodeNaf').UIautocomplete('destroy').UIautocomplete( 1179 { 1180 ////'autoFill' : true, 1181 'autoFillCallback' : function(res, field) 1182 { 1183 $(res).each(function() 1184 { 1185 field.val(this.naf); 1186 }); 1187 return false; 1188 }, 1189 'source' : function(request, response) 1190 { 1191 $.ajax( 1192 { 1193 'url' : (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/autocomplete/ajax_autocomplete_cnaf.php", 1194 'dataType' : "json", 1195 'data' : 1196 { 1197 'term' : request.term 1198 }, 1199 'success' : function(data) 1200 { 1201 response(data); 1202 } 1203 }); 1204 }, 1205 'minLength' : 2, 1206 'select' : function(event, ui) 1207 { 1208 $(this).closest('table').find('.codenaf').val(ui.item.id); 1209 }, 1210 'open' : function(event, ui) 1211 { 1212 var acData = $(this).data('UIautocomplete'); 1213 var currentValue = acData.term; 1214 var pattern = '(' + utils.escapeRegExChars(currentValue) + ')'; 1215 1216 $("ul.ui-autocomplete li a").each(function() 1217 { 1218 var htmlString = $(this).html();//.replace(/</g, '<'); 1219 htmlString = htmlString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); 1220 $(this).html(htmlString); 1221 }); 1222 $("ul.ui-autocomplete").css({'height' : '170px', 'overflowY' : 'scroll', 'fontSize' : '11px'}); 1223 } 1224 }); 1225} 1226 1227function initVille() 1228{ 1229 1230 if ($.browser && $.browser.msie == true && parseInt($.browser.version, 10) <= 7) 1231 return false; 1232 1233 /* Autocompletion de la ville en fonction du code postal */ 1234 $('.autocompleteVilleEx').UIautocomplete('destroy').UIautocomplete( 1235 { 1236 //'autoFill' : true, 1237 'autoFillCallback' : function(res, field) 1238 { 1239 $(res).each(function() 1240 { 1241 field.val(this.ville); 1242 }); 1243 return false; 1244 }, 1245 'source' : function(request, response) 1246 { 1247 $.ajax( 1248 { 1249 'url' : (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/autocomplete/ajax_autocomplete_villes.php?"+($(this.element).hasClass('autocompleteFull') ? "full=1&country=all" : ""), 1250 'dataType' : "json", 1251 'data' : 1252 { 1253 'term' : request.term, 1254 'country' : $(this.element).closest('table').find('.select.pays').val() 1255 }, 1256 'success' : function(data) 1257 { 1258 response(data); 1259 } 1260 }); 1261 }, 1262 'minLength' : 2, 1263 'open' : function(event, ui) 1264 { 1265 var acData = $(this).data('UIautocomplete'); 1266 var currentValue = acData.term; 1267 var pattern = '(' + utils.escapeRegExChars(currentValue) + ')'; 1268 1269 $("ul.ui-autocomplete li a").each(function() 1270 { 1271 var htmlString = $(this).html();//.replace(/</g, '<'); 1272 htmlString = htmlString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); 1273 $(this).html(htmlString); 1274 }); 1275 $("ul.ui-autocomplete").css({'height' : '170px', 'overflowY' : 'scroll', 'fontSize' : '11px'}); 1276 } 1277 }); 1278} 1279 1280function initDiplome() 1281{ 1282 1283 if ($.browser && $.browser.msie == true && parseInt($.browser.version, 10) <= 7) 1284 return false; 1285 1286 /* Autocompletion de la ville en fonction du code postal */ 1287 $('.autocompleteDiplome').UIautocomplete('destroy').UIautocomplete( 1288 { 1289 //'autoFill' : true, 1290 'autoFillCallback' : 1291 function(res, field) 1292 { 1293 $(res).each(function() 1294 { 1295 field.val(this.value); 1296 field.parent().find('.autocompleteIDDiplome').val(this.id); 1297 }); 1298 return false; 1299 }, 1300 'source' : 1301 function(request, response) 1302 { 1303 $.ajax( 1304 { 1305 'url' : (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/autocomplete/ajax_diplome.php", 1306 'dataType' : "json", 1307 'data' : 1308 { 1309 'term' : request.term 1310 }, 1311 'success' : function(data) 1312 { 1313 response(data); 1314 } 1315 }); 1316 }, 1317 'minLength' : 2, 1318 'select' : 1319 function(event, ui) 1320 { 1321 $(this).parent().find('.autocompleteIDDiplome').val(ui.item.id); 1322 }, 1323 'open' : 1324 function(event, ui) 1325 { 1326 var acData = $(this).data('UIautocomplete'); 1327 var currentValue = acData.term; 1328 var pattern = '(' + utils.escapeRegExChars(currentValue) + ')'; 1329 1330 $("ul.ui-autocomplete li a").each(function() 1331 { 1332 var htmlString = $(this).html();//.replace(/</g, '<'); 1333 htmlString = htmlString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); 1334 $(this).html(htmlString); 1335 }); 1336 $("ul.ui-autocomplete").css({'height' : '170px', 'overflowY' : 'scroll', 'fontSize' : '11px'}); 1337 } 1338 }).on('input', 1339 function () 1340 { 1341 if (!$.trim($(this).val()).length) 1342 $(this).parent().find('.autocompleteIDDiplome').val(''); 1343 } 1344 ); 1345} 1346 1347function initDiplomeEtablissement() { 1348 if ($.browser && $.browser.msie == true && parseInt($.browser.version, 10) <= 7) 1349 return false;
1350 1351 $('.autocompleteDiplomeEtablissement').UIautocomplete('destroy').UIautocomplete({ 1352 //'autoFill' : true, 1353 'autoFillCallback' : function(res, field) { 1354 $(res).each(function() { 1355 field.val(this.poste); 1356 }); 1357 return false; 1358 }, 1359 'source': function(request, response) { 1360 $.ajax({ 1361 'url': (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/autocomplete/ajax_autocomplete_etablissements.php", 1362 'dataType': "json", 1363 'data': { 1364 'term' : request.term 1365 }, 1366 'success': function(data) { 1367 response(data); 1368 } 1369 }); 1370 }, 1371 'minLength': 2, 1372 'open' : 1373 function(event, ui) 1374 { 1375 var acData = $(this).data('UIautocomplete'); 1376 var currentValue = acData.term; 1377 var pattern = '(' + utils.escapeRegExChars(currentValue) + ')'; 1378 1379 $("ul.ui-autocomplete li a").each(function() 1380 { 1381 var htmlString = $(this).html();//.replace(/</g, '<'); 1382 htmlString = htmlString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); 1383 $(this).html(htmlString); 1384 }); 1385 $("ul.ui-autocomplete").css({'height' : '170px', 'overflowY' : 'scroll', 'fontSize' : '11px'}); 1386 } 1387 1388 }); 1389} 1390 1391 1392function initDiplomeFormation() { 1393 if ($.browser && $.browser.msie == true && parseInt($.browser.version, 10) <= 7) 1394 return false; 1395 1396 $('.autocompleteDiplomeFormation').UIautocomplete('destroy').UIautocomplete({ 1397 //'autoFill' : true, 1398 'autoFillCallback' : function(res, field) { 1399 $(res).each(function() { 1400 field.val(this.poste); 1401 }); 1402 return false; 1403 }, 1404 'source': function(request, response) { 1405 $.ajax({ 1406 'url': (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/autocomplete/ajax_autocomplete_formations.php", 1407 'dataType': "json", 1408 'data': { 1409 'term' : request.term 1410 }, 1411 'success': function(data) { 1412 response(data); 1413 } 1414 }); 1415 }, 1416 'minLength': 2, 1417 'open' : 1418 function(event, ui) 1419 { 1420 var acData = $(this).data('UIautocomplete'); 1421 var currentValue = acData.term; 1422 var pattern = '(' + utils.escapeRegExChars(currentValue) + ')'; 1423 1424 $("ul.ui-autocomplete li a").each(function() 1425 { 1426 var htmlString = $(this).html();//.replace(/</g, '<'); 1427 htmlString = htmlString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); 1428 $(this).html(htmlString); 1429 }); 1430 $("ul.ui-autocomplete").css({'height' : '170px', 'overflowY' : 'scroll', 'fontSize' : '11px'}); 1431 } 1432 1433 }); 1434} 1435 1436function initFonction() 1437{ 1438 1439 if ($.browser && $.browser.msie == true && parseInt($.browser.version, 10) <= 7) 1440 return false; 1441 1442 $('.autocompleteFonction').UIautocomplete('destroy').UIautocomplete({ 1443 //'autoFill' : true, 1444 'autoFillCallback' : function(res, field) { 1445 $(res).each(function() { 1446 field.val(this.poste); 1447 }); 1448 return false; 1449 }, 1450 'source': function(request, response) { 1451 $.ajax({ 1452 'url': (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/autocomplete/ajax_autocomplete_poste.php", 1453 'dataType': "json", 1454 'data': { 1455 'term' : request.term 1456 }, 1457 'success': function(data) { 1458 response(data); 1459 } 1460 }); 1461 }, 1462 'minLength': 2, 1463 'open' : 1464 function(event, ui) 1465 { 1466 var acData = $(this).data('UIautocomplete'); 1467 var currentValue = acData.term; 1468 var pattern = '(' + utils.escapeRegExChars(currentValue) + ')'; 1469 1470 $("ul.ui-autocomplete li a").each(function() 1471 { 1472 var htmlString = $(this).html();//.replace(/</g, '<'); 1473 htmlString = htmlString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); 1474 $(this).html(htmlString); 1475 }); 1476 $("ul.ui-autocomplete").css({'height' : '170px', 'overflowY' : 'scroll', 'fontSize' : '11px'}); 1477 } 1478 1479 }); 1480} 1481 1482function initSport() 1483{ 1484 1485 if ($.browser && $.browser.msie == true && parseInt($.browser.version, 10) <= 7) 1486 return false;
1487 1488 /* Autocompletion de la ville en fonction du code postal */ 1489 $('.autocompleteSport').UIautocomplete('destroy').UIautocomplete({ 1490 //'autoFill' : true, 1491 'autoFillCallback' : function(res, field) { 1492 $(res).each(function() { 1493 field.val(this.value); 1494 }); 1495 return false; 1496 }, 1497 'source': function(request, response) { 1498 $.ajax({ 1499 'url': (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/autocomplete/ajax_autocomplete_sports.php", 1500 'dataType': "json", 1501 'data': { 1502 'term' : request.term 1503 }, 1504 'success': function(data) { 1505 response(data); 1506 } 1507 }); 1508 }, 1509 'minLength': 2, 1510 'open' : 1511 function(event, ui) 1512 { 1513 var acData = $(this).data('UIautocomplete'); 1514 var currentValue = acData.term; 1515 var pattern = '(' + utils.escapeRegExChars(currentValue) + ')'; 1516 1517 $("ul.ui-autocomplete li a").each(function() 1518 { 1519 var htmlString = $(this).html();//.replace(/</g, '<'); 1520 htmlString = htmlString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); 1521 $(this).html(htmlString); 1522 }); 1523 $("ul.ui-autocomplete").css({'height' : '170px', 'overflowY' : 'scroll', 'fontSize' : '11px'}); 1524 } 1525 1526 }); 1527} 1528 1529function initCompetence() { 1530 1531 if ($.browser && $.browser.msie == true && parseInt($.browser.version, 10) <= 7) 1532 return false; 1533 1534 /* Autocompletion de la ville en fonction du code postal */ 1535 $('.autocompleteCompetence').UIautocomplete('destroy').UIautocomplete({ 1536 //'autoFill' : true, 1537 'autoFillCallback' : function(res, field) { 1538 $(res).each(function() { 1539 field.val(this.value); 1540 }); 1541 return false; 1542 }, 1543 'source': function(request, response) { 1544 $.ajax({ 1545 'url': (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/autocomplete/ajax_autocomplete_competences.php", 1546 'dataType': "json", 1547 'data': { 1548 'term' : request.term 1549 }, 1550 'success': function(data) { 1551 response(data); 1552 } 1553 }); 1554 }, 1555 'minLength': 2, 1556 'open' : 1557 function(event, ui) 1558 { 1559 var acData = $(this).data('UIautocomplete'); 1560 var currentValue = acData.term; 1561 var pattern = '(' + utils.escapeRegExChars(currentValue) + ')'; 1562 1563 $("ul.ui-autocomplete li a").each(function() 1564 { 1565 var htmlString = $(this).html();//.replace(/</g, '<'); 1566 htmlString = htmlString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); 1567 $(this).html(htmlString); 1568 }); 1569 $("ul.ui-autocomplete").css({'height' : '170px', 'overflowY' : 'scroll', 'fontSize' : '11px'}); 1570 } 1571 1572 }); 1573} 1574 1575function initDecoration() 1576{ 1577 1578 if ($.browser && $.browser.msie == true && parseInt($.browser.version, 10) <= 7) 1579 return false; 1580 1581 /* Autocompletion de la ville en fonction du code postal */ 1582 $('.autocompleteDecoration').UIautocomplete('destroy').UIautocomplete({ 1583 //'autoFill' : true, 1584 'autoFillCallback' : function(res, field) { 1585 $(res).each(function() { 1586 field.val(this.value); 1587 }); 1588 return false; 1589 }, 1590 'source': function(request, response) { 1591 $.ajax({ 1592 'url': (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/autocomplete/decorations.php", 1593 'dataType': "json", 1594 'data': { 1595 'term' : request.term 1596 }, 1597 'success': function(data) { 1598 response(data); 1599 } 1600 }); 1601 }, 1602 'minLength': 2, 1603 'open' : 1604 function(event, ui) 1605 { 1606 var acData = $(this).data('UIautocomplete'); 1607 var currentValue = acData.term; 1608 var pattern = '(' + utils.escapeRegExChars(currentValue) + ')'; 1609 1610 $("ul.ui-autocomplete li a").each(function() 1611 { 1612 var htmlString = $(this).html();//.replace(/</g, '<'); 1613 htmlString = htmlString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); 1614 $(this).html(htmlString); 1615 }); 1616 $("ul.ui-autocomplete").css({'height' : '170px', 'overflowY' : 'scroll', 'fontSize' : '11px'}); 1617 } 1618 1619 }); 1620} 1621 1622 1623function initActivite() 1624{ 1625 1626 if ($.browser && $.browser.msie == true && parseInt($.browser.version, 10) <= 7) 1627 return false;
1628 1629 /* Autocompletion de la ville en fonction du code postal */ 1630 $('.autocompleteActivite').UIautocomplete('destroy').UIautocomplete({ 1631 //'autoFill' : true, 1632 'autoFillCallback' : function(res, field) { 1633 $(res).each(function() { 1634 field.val(this.value); 1635 }); 1636 return false; 1637 }, 1638 'source': function(request, response) { 1639 $.ajax({ 1640 'url': (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/autocomplete/ajax_autocomplete_activites.php", 1641 'dataType': "json", 1642 'data': { 1643 'term' : request.term 1644 }, 1645 'success': function(data) { 1646 response(data); 1647 } 1648 }); 1649 }, 1650 'minLength': 2, 1651 'open' : 1652 function(event, ui) 1653 { 1654 var acData = $(this).data('UIautocomplete'); 1655 var currentValue = acData.term; 1656 var pattern = '(' + utils.escapeRegExChars(currentValue) + ')'; 1657 1658 $("ul.ui-autocomplete li a").each(function() 1659 { 1660 var htmlString = $(this).html();//.replace(/</g, '<'); 1661 htmlString = htmlString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); 1662 $(this).html(htmlString); 1663 }); 1664 $("ul.ui-autocomplete").css({'height' : '170px', 'overflowY' : 'scroll', 'fontSize' : '11px'}); 1665 } 1666 1667 }); 1668} 1669 1670function initCentreInteret() 1671{ 1672 1673 if ($.browser && $.browser.msie == true && parseInt($.browser.version, 10) <= 7) 1674 return false; 1675 1676 /* Autocompletion de la ville en fonction du code postal */ 1677 $('.autocompleteCentreInteret').UIautocomplete('destroy').UIautocomplete({ 1678 //'autoFill' : true, 1679 'autoFillCallback' : function(res, field) { 1680 $(res).each(function() { 1681 field.val(this.value); 1682 }); 1683 return false; 1684 }, 1685 'source': function(request, response) { 1686 $.ajax({ 1687 'url': (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/autocomplete/ajax_autocomplete_centres_dinterets.php", 1688 'dataType': "json", 1689 'data': { 1690 'term' : request.term 1691 }, 1692 'success': function(data) { 1693 response(data); 1694 } 1695 }); 1696 }, 1697 'minLength': 2, 1698 'open' : 1699 function(event, ui) 1700 { 1701 var acData = $(this).data('UIautocomplete'); 1702 var currentValue = acData.term; 1703 var pattern = '(' + utils.escapeRegExChars(currentValue) + ')'; 1704 1705 $("ul.ui-autocomplete li a").each(function() 1706 { 1707 var htmlString = $(this).html();//.replace(/</g, '<'); 1708 htmlString = htmlString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); 1709 $(this).html(htmlString); 1710 }); 1711 $("ul.ui-autocomplete").css({'height' : '170px', 'overflowY' : 'scroll', 'fontSize' : '11px'}); 1712 } 1713 1714 }); 1715} 1716 1717function initNom() 1718{ 1719 1720 if ($.browser && $.browser.msie == true && parseInt($.browser.version, 10) <= 7) 1721 return false; 1722 1723 /* Autocompletion de la ville en fonction du code postal */ 1724 $('.autocompleteNom').UIautocomplete('destroy').UIautocomplete({ 1725 //'autoFill' : true, 1726 'autoFillCallback' : function(res, field) { 1727 $(res).each(function() { 1728 field.val(this.value); 1729 }); 1730 return false; 1731 }, 1732 'source': function(request, response) { 1733 $.ajax({ 1734 'url': (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/autocomplete/ajax_autocomplete_noms.php", 1735 'dataType': "json", 1736 'data': { 1737 'term' : request.term 1738 }, 1739 'success': function(data) { 1740 response(data); 1741 } 1742 }); 1743 }, 1744 'minLength': 2, 1745 'open' : 1746 function(event, ui) 1747 { 1748 var acData = $(this).data('UIautocomplete'); 1749 var currentValue = acData.term; 1750 var pattern = '(' + utils.escapeRegExChars(currentValue) + ')'; 1751 1752 $("ul.ui-autocomplete li a").each(function() 1753 { 1754 var htmlString = $(this).html();//.replace(/</g, '<'); 1755 htmlString = htmlString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); 1756 $(this).html(htmlString); 1757 }); 1758 $("ul.ui-autocomplete").css({'height' : '170px', 'overflowY' : 'scroll', 'fontSize' : '11px'}); 1759 } 1760 1761 }); 1762} 1763 1764function initPersonne() 1765{ 1766 if ($.browser && $.browser.msie == true && parseInt($.browser.version, 10) <= 7) 1767 return false;
1768 1769 /* Autocompletion de la ville en fonction du code postal */ 1770 $('.autocompletePersonne').UIautocomplete('destroy').UIautocomplete( 1771 { 1772 //'autoFill' : true, 1773 'autoFillCallback': function (res, field) { 1774 $(res).each(function () { 1775 field.val(this.value); 1776 }); 1777 return false; 1778 }, 1779 'source': function (request, response) { 1780 $.ajax({ 1781 'url': (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/autocomplete/ajax_autocomplete_personnes.php", 1782 'dataType': "json", 1783 'data': { 1784 'term': request.term 1785 }, 1786 'success': function (data) { 1787 response(data); 1788 } 1789 }); 1790 }, 1791 'minLength': 2, 1792 'open': 1793 function (event, ui) { 1794 var acData = $(this).data('UIautocomplete'); 1795 var currentValue = acData.term; 1796 var pattern = '(' + utils.escapeRegExChars(currentValue) + ')'; 1797 1798 $("ul.ui-autocomplete li a").each(function () { 1799 var htmlString = $(this).html();//.replace(/</g, '<'); 1800 htmlString = htmlString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); 1801 $(this).html(htmlString); 1802 }); 1803 $("ul.ui-autocomplete").css({'height': '170px', 'overflowY': 'scroll', 'fontSize': '11px'}); 1804 }, 1805 'select': function(event, ui) { 1806 var target_id = $(this).data('for'); 1807 if (target_id) 1808 $('#'+target_id).val(ui.item.id); 1809 } 1810 }); 1811} 1812 1813function initVilleSimple() 1814{ 1815 1816 if ($.browser && $.browser.msie == true && parseInt($.browser.version, 10) <= 7) 1817 return false; 1818 1819 /* Autocompletion de la ville en fonction du code postal */ 1820 $('.autocompleteVilleSimple').UIautocomplete('destroy').UIautocomplete({ 1821 //'autoFill' : true, 1822 'autoFillCallback' : function(res, field) { 1823 $(res).each(function() { 1824 field.val(this.value); 1825 }); 1826 return false; 1827 }, 1828 'source': function(request, response) { 1829 $.ajax({ 1830 'url': (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/autocomplete/ajax_autocomplete_villes_simple.php", 1831 'dataType': "json", 1832 'data': { 1833 'term' : request.term 1834 }, 1835 'success': function(data) { 1836 response(data); 1837 } 1838 }); 1839 }, 1840 'minLength': 2, 1841 'open' : 1842 function(event, ui) 1843 { 1844 var acData = $(this).data('UIautocomplete'); 1845 var currentValue = acData.term; 1846 var pattern = '(' + utils.escapeRegExChars(currentValue) + ')'; 1847 1848 $("ul.ui-autocomplete li a").each(function() 1849 { 1850 var htmlString = $(this).html();//.replace(/</g, '<'); 1851 htmlString = htmlString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); 1852 $(this).html(htmlString); 1853 }); 1854 $("ul.ui-autocomplete").css({'height' : '170px', 'overflowY' : 'scroll', 'fontSize' : '11px'}); 1855 } 1856 1857 }); 1858} 1859 1860 1861/* 1862 * Complète le numéro de fixe et de mobile en fonction de l'indicatif du pays 1863 * choisi 1864 */ 1865function ChangePaysPerso(item) 1866{ 1867 $.get("/global/ressources/ajax/ajax_getTelPrefixByCountry.php", 1868 { 1869 'id_pays' : item.val() 1870 }, function(data) 1871 { 1872 item.closest('table').find('.indicatifTel').val(data); 1873 }); 1874} 1875 1876/* 1877 * Renvoi la longueur maximale du numéro de téléphone en vigueur dans le pays 1878 * sélectionné. 1879 */ 1880function LoadLengthNum(item, entreprise) 1881{ 1882 $.get("/global/ressources/ajax/ajax_loadLengthNum.php", 1883 { 1884 'id_pays' : item.val() 1885 }, function(data) 1886 { 1887 item.closest('table').find(".phoneNumber").attr('maxLength', data); 1888 1889 if (data != '') 1890 { 1891 if (item.closest('table').find(".chiffre_perso").size()) 1892 item.closest('table').find(".chiffre_perso").html(data); 1893 1894 if (item.closest('table').find(".phrase_perso").size()) 1895 { 1896 if (entreprise) 1897 item.closest('table').find(".phrase_perso").html( 1898 'vous ne pouvez saisir que ' + data 1899 + ' chiffres dans les champs "Tél. standard", "Fax standard"'); 1900 else 1901 item.closest('table').find(".phrase_perso").html( 1902 'vous ne pouvez saisir que ' + data 1903 + ' chiffres dans les champs "téléphone", "mobile", "fax"'); 1904 } 1905 1906 } 1907 else 1908 { 1909 item.closest('table').find(".phrase_perso").html('Merci de renseigner votre pays'); 1910 } 1911 }); 1912} 1913 1914function preg_replace(array_pattern, array_pattern_replace, my_string) 1915{ 1916 var new_string = String(my_string); 1917 1918 for (i = 0; i < array_pattern.length; i++) 1919 { 1920 var reg_exp = RegExp(array_pattern[i], "gi"); 1921 var val_to_replace = typeof array_pattern_replace[i] != 'undefined' ? array_pattern_replace[i] 1922 : (typeof array_pattern_replace == 'Array' ? array_pattern_replace[0] : array_pattern_replace); 1923 new_string = new_string.replace(reg_exp, val_to_replace); 1924 } 1925 1926 return new_string; 1927} 1928 1929function noAccentSpace(my_string) 1930{ 1931 var new_string = my_string.replace(/[\ ()''",.:!?\/#@&+]+/g, '-'); 1932 1933 var pattern_accent = new Array(" ", "--", "\351", "\350", " \352", "\353", "\347", "\340", "\342", "\344", "\356", "\357", "\371", "\364", "\363", "\366"); 1934 var pattern_replace_accent = new Array("-", "-", "e", "e", "e", "e", "c", "a", "a", "a", "i", "i", "u", "o", "o", "o"); 1935 1936 if (new_string && new_string != "") 1937 new_string = preg_replace(pattern_accent, pattern_replace_accent, new_string); 1938 1939 new_string = new_string.replace(/['']/g, '-'); 1940 new_string = new_string.replace(/[^0-9a-zA-Z-]+/g, ''); 1941 new_string = new_string.replace(/--+/g, '-'); 1942 1943 return new_string; 1944} 1945 1946function noArticles(url, end_space) 1947{ 1948 if (typeof end_space == 'undefined') 1949 end_space = false;
1950 1951 var to_del = new Array('un', 'une', 'des', 'de', 'le', 'la', 'les', 'ce', 'ces', 'ne', 'se', 's', 'd', 'l', 'n', 'c', 'a', '\340'); 1952 1953 if (typeof url != 'undefined' && url && url != "") 1954 { 1955 for ( var i = 0; i < to_del.length; i++) 1956 { 1957 var pattern = new RegExp('^' + to_del[i] + '-', 'g'); 1958 url = url.replace(pattern, ''); 1959 1960 pattern = new RegExp('-' + to_del[i] + '-', 'g'); 1961 url = url.replace(pattern, '-'); 1962 1963 pattern = new RegExp('-' + to_del[i] + '$', 'g'); 1964 url = url.replace(pattern, '-'); 1965 1966 pattern = new RegExp('^(-+)(.*?)$'); 1967 url = url.replace(pattern, '$2'); 1968 1969 pattern = new RegExp('^(.*?)(-+)$'); 1970 url = url.replace(pattern, '$1' + (end_space ? '-' : '')); 1971 1972 pattern = new RegExp('^(.*?)(-{2,})(.*?)$'); 1973 while (url.match(pattern)) 1974 url = url.replace(pattern, '$1-$3'); 1975 } 1976 } 1977 1978 return url; 1979} 1980 1981function setURLRewriting(elem) 1982{ 1983 var url = noAccentSpace(elem.val().toLowerCase()); 1984 1985 url = noArticles(url, elem[0] === $('#url_rewriting')[0] ? true : false); 1986 1987 $('#url_rewriting').val(url); 1988} 1989 1990function verifURLRewriting(type, id, display_alert) 1991{ 1992 var url = $('#url_rewriting').val(); 1993 1994 var ok = true; 1995 $.ajax( 1996 { 1997 url : (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/ajax_verifUrlRewriting.php", 1998 type : 'POST', 1999 async : false, 2000 data : 2001 { 2002 'type' : (typeof type != 'undefined' ? type : ''), 2003 'url' : url, 2004 'id' : (typeof id != 'undefined' ? id : '') 2005 }, 2006 success : function(data) 2007 { 2008 if (data == 'no') 2009 { 2010 if (display_alert) 2011 alert("L'url de redirection existe d\351j\340 pour un lien. veuillez la changer"); 2012 2013 $('#url_rewriting_error').show(); 2014 2015 $('#url_rewriting').removeClass('in_ok').addClass('in_error'); 2016 $('#url_rewriting').focus(); 2017 2018 ok = false; 2019 } 2020 else 2021 { 2022 $('#url_rewriting').removeClass('in_error').addClass('in_ok'); 2023 $('#url_rewriting_error').hide(); 2024 ok = true; 2025 } 2026 } 2027 }); 2028 2029 return ok; 2030} 2031 2032function make_calendar() 2033{ 2034 if($('.datepicker').length) 2035 $('.datepicker').datepicker( 2036 { 2037 showOn: 'button', 2038 buttonImage: (typeof url_root != 'undefined' ? url_root : "" ) + '/global/images/calendar.gif', 2039 buttonImageOnly: true, 2040 dateFormat : 'dd/mm/yy', 2041 numberOfMonths: 3, 2042 showButtonPanel: true 2043 } 2044 ); 2045 2046 2047 if($('.datepicker_naissance').length) 2048 $('.datepicker_naissance').datepicker( 2049 { 2050 changeMonth: true, 2051 changeYear: true, 2052 showOn: 'button', 2053 buttonImage: (typeof url_root != 'undefined' ? url_root : "" ) + '/global/images/calendar.gif', 2054 buttonImageOnly: true, 2055 dateFormat : 'dd/mm/yy', 2056 yearRange: "-100:-15", 2057 showButtonPanel: true 2058 } 2059 ); 2060 2061 if($('.datepicker_histo_debut').length) 2062 $('.datepicker_histo_debut').datepicker( 2063 { 2064 showOn: 'button', 2065 buttonImage: (typeof url_root != 'undefined' ? url_root : "" ) + '/global/images/calendar.gif', 2066 buttonImageOnly: true, 2067 dateFormat : 'dd/mm/yy', 2068 numberOfMonths: 3, 2069 showButtonPanel: true, 2070 maxDate : '+0m +0w', 2071 onSelect: function(selected) { 2072 $(".datepicker_histo_fin").datepicker("option","minDate", selected) 2073 } 2074 } 2075 ); 2076 2077 if($('.datepicker_histo_fin').length) 2078 $('.datepicker_histo_fin').datepicker( 2079 { 2080 showOn: 'button', 2081 buttonImage: (typeof url_root != 'undefined' ? url_root : "" ) + '/global/images/calendar.gif', 2082 buttonImageOnly: true, 2083 dateFormat : 'dd/mm/yy', 2084 numberOfMonths: 3, 2085 showButtonPanel: true, 2086 onSelect: function(selected) { 2087 $(".datepicker_histo_debut").datepicker("option","maxDate", selected) 2088 } 2089 } 2090 ); 2091} 2092 2093var utils = (function () { 2094 return { 2095 escapeRegExChars: function (value) { 2096 return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 2097 } 2098 }; 2099}()); 2100 2101$(document).ready(function () 2102{ 2103 initAjoutItem(); 2104 initUIAutocomplete(); 2105 2106 if ($.browser && !($.browser.msie == true && (parseInt($.browser.version, 10) == 6 || parseInt($.browser.version, 10) == 7))) 2107 initTimeAgo(); 2108 2109 initFancyLink(); 2110 2111 if ($.fn.UIautocomplete) 2112 {
2113 initCodePostal(); 2114 initEntreprise(); 2115 initEntrepriseGroupe(); 2116 initVilleEntreprise(); 2117 initVille(); 2118 initCNaf(); 2119 initFonction(); 2120 initSport(); 2121 initCentreInteret(); 2122 initActivite(); 2123 initDecoration(); 2124 initCompetence(); 2125 initNom(); 2126 initPersonne(); 2127 initVilleSimple(); 2128 initDiplomeEtablissement(); 2129 initDiplomeFormation(); 2130 2131 var isChromium = window.chrome; 2132 var winNav = window.navigator; 2133 var vendorName = winNav.vendor; 2134 var isOpera = typeof window.opr !== "undefined"; 2135 var isIEedge = winNav.userAgent.indexOf("Edge") > -1; 2136 var isIOSChrome = winNav.userAgent.match("CriOS"); 2137 2138 if (isIOSChrome) 2139 { 2140 $('.ui-autocomplete-input').attr('autocomplete', 'no'); 2141 } 2142 else if ( 2143 isChromium !== null && 2144 typeof isChromium !== "undefined" && 2145 vendorName === "Google Inc." && 2146 isOpera === false && 2147 isIEedge === false 2148 ) 2149 { 2150 $('.ui-autocomplete-input').attr('autocomplete', 'no'); 2151 } 2152 else 2153 { 2154 // not Google Chrome 2155 } 2156 } 2157 2158 make_calendar(); 2159 2160 $("input.integer").on({ 2161 'change':function() { 2162 this.value=this.value.replace(/[^0-9]/g,''); 2163 }, 2164 'input':function() { 2165 this.value=this.value.replace(/[^0-9]/g,''); 2166 } 2167 }); 2168 2169 // Pour afficher une alerte si on quitte la page alors qu'il y a des modifications 2170 $('form.alert-before-leaving input, form.alert-before-leaving select:not([multiple]), form.alert-before-leaving textarea').one('change input', 2171 function (event, params) 2172 { 2173 if ((typeof params === 'undefined' || !params['no-alert'])) 2174 { 2175 addAlertBeforeLeaving(); 2176 } 2177 }); 2178 $('form.alert-before-leaving select[multiple]').addClass('alert-before-leaving'); 2179 2180 // Pour ne plus afficher d'alerte si on valide 2181 $('form.alert-before-leaving .no-alert-before-Leaving').click(function (e) { removeAlertBeforeLeaving(); }).end() 2182 .submit(function () { removeAlertBeforeLeaving(); }); 2183 2184 // set juste la variable globale formModified a true s'il y a une modif dans le form. On peut tester ensuite cette variable dans du code JS specifique 2185 $('form.register-modify input, form.register-modify select:not([multiple]), form.register-modify textarea').one('change input', 2186 function (event, params) 2187 { 2188 setFormModified(); 2189 }); 2190 $('form.register-modify select[multiple]').addClass('register-modify'); 2191 2192}); 2193 2194var formModified = false; 2195function setFormModified() 2196{ 2197 formModified = true; 2198} 2199 2200function unsetFormModified() 2201{ 2202 formModified = false; 2203} 2204 2205var alertBinded = false; 2206function addAlertBeforeLeaving() 2207{ 2208 2209 if (!alertBinded) 2210 { 2211 alertBinded = true; 2212 $(window).bind('beforeunload', function () { 2213 // La phrase ici ne sert a rien, ce n'est pas elle qui est affichée 2214 return 'Vous avez des modifications en cours. Ãtes-vous sûr(e) de vouloir quitter cette page ?'; 2215 }); 2216 } 2217} 2218 2219function removeAlertBeforeLeaving() 2220{ 2221 if (alertBinded) 2222 { 2223 alertBinded = false; 2224 $(window).unbind('beforeunload'); 2225 } 2226} 2227 2228/****************** 2229 * Fonctionnalités Module Emailing 2230 *****************/ 2231function setEnvoiMail(ele, id_mailing) { 2232 2233 var element = ele.closest('td'); 2234 var statut_envoi = element.find('input').val(); 2235 element.find('img').attr({'src' : (typeof url_root != 'undefined' ? url_root : "" ) + "/global/images/ajax-loader.gif"}); 2236 $('#notificationStatutEnvoi').html('<center><img src="/global/images/ajax-loader.gif" /></center>'); 2237 2238 $.ajax( 2239 { 2240 url: (typeof url_root != 'undefined' ? url_root : "" ) + '/global/ressources/ajax/mailing/ajax_set_statut_envoi.php', 2241 type: 'POST', 2242 async: true, 2243 data : 2244 { 2245 'id_mailing' : (typeof id_mailing != 'undefined' ? id_mailing : ''), 2246 'statut_envoi' : (typeof statut_envoi != 'undefined' ? statut_envoi : '') 2247 }, 2248 success : 2249 function (data) 2250 { 2251 if (data) 2252 { 2253 $('#notificationStatutEnvoi').html(data).show()/*.delay(5000).slideUp('fast', function() {})*/; 2254 if(statut_envoi == 2 ) 2255 { 2256 element.find('img').attr({'src' : (typeof url_root != 'undefined' ? url_root : "" ) + '/global/images/media-pause.png', 'title' : polyglot.t('admin.stop_sending_mail')}); 2257 element.find('input').val('3'); 2258 } 2259 else 2260 { 2261 element.find('img').attr({'src' : (typeof url_root != 'undefined' ? url_root : "" ) + '/global/images/play_vert.png', 'title' : polyglot.t('admin.resend_email')}); 2262 element.find('input').val('2'); 2263 } 2264 } 2265 else 2266 { 2267 $('#notificationStatutEnvoi').html(polyglot.t('admin.an_error_occurred_while_editing._if_problem_persists')); 2268 } 2269 } 2270 } 2271 ); 2272} 2273/****************** 2274 * Fin Fonctionnalités Module Emailing 2275 *****************/ 2276 2277function alertSwal(title, type, txt, confirmButtonColor) { 2278 2279 if(typeof swal == 'function' ) { 2280 if (typeof confirmButtonColor == 'undefined') 2281 confirmButtonColor = '#888888'; 2282 2283 swal( 2284 { 2285 title: title, 2286 text: txt, 2287 confirmButtonColor: confirmButtonColor, 2288 html: true, 2289 type: typeof type != 'undefined' ? type : '' 2290 } 2291 ); 2292 } else { 2293 if( txt && typeof txt !== 'undefined') 2294 return alert(txt); 2295 else if (!txt && title) 2296 return alert(title); 2297 } 2298} 2299 2300function confirmSwal(title, callback, txt, type, closeOnConfirm, showCancelButton, confirmButtonColor, confirmButtonText, cancelButtonText, showConfirmButton = true) 2301{ 2302 if (typeof title == 'undefined' || !title) 2303 title = ''; 2304 2305 if (typeof closeOnConfirm == 'undefined') 2306 closeOnConfirm = true; 2307 2308 if (typeof showCancelButton == 'undefined') 2309 showCancelButton = true; 2310 2311 if (typeof cancelButtonColor == 'undefined') 2312 cancelButtonColor = '#C1C1C1'; 2313 2314 if (typeof confirmButtonColor == 'undefined') 2315 confirmButtonColor = '#888888'; 2316 2317 if (typeof confirmButtonText == 'undefined') 2318 confirmButtonText = "Ok"; 2319 2320 if (typeof swal == 'function') 2321 { 2322 var cancel = cancelButtonText; 2323 2324 if (typeof cancelButtonText == 'undefined') 2325 { 2326 polyglot.t("core.cancel"); 2327 } 2328 2329 swal( 2330 { 2331 title: title, 2332 text: txt, 2333 html:true, 2334 type: typeof type != 'undefined' ? type : '', 2335 showCancelButton: showCancelButton, 2336 cancelButtonText: cancel, 2337 cancelButtonColor: cancelButtonColor, 2338 confirmButtonText: confirmButtonText, 2339 confirmButtonColor: confirmButtonColor, 2340 closeOnConfirm: closeOnConfirm, 2341 showConfirmButton: showConfirmButton 2342 }, 2343 function (isConfirm) 2344 { 2345 if (isConfirm) 2346 callback(isConfirm); 2347 } 2348 ); 2349 } 2350 else 2351 { 2352 if (typeof title == 'undefined' || !title) 2353 title = txt; 2354 if (confirm(title)) 2355 return callback(); 2356 } 2357} 2358 2359function NA_check_log(etape) 2360{ 2361 var formu = $('form[name="formulaire_login' + etape + '"]:visible'); 2362 2363 if (formu.size() == 0) 2364 return false;
2365 2366 if (formu.find('input[name="login_s"]').val() == "") 2367 { 2368 if ( typeof msg_error_login != 'undefined' ) { 2369 var msg_alert = msg_error_login; 2370 } else { 2371 var msg_alert = polyglot.t("event.subscribe.please_enter_your_login"); 2372 } 2373 alertSwal(msg_alert); 2374 2375 formu.find('input[name="login_s"]').focus(); 2376 return false; 2377 } 2378 else if (formu.find('input[name="pswd_s"]').val() == "") 2379 { 2380 alertSwal(polyglot.t("profile.please_enter_your_password_exclamation")); 2381 2382 formu.find('input[name="pswd_s"]').focus(); 2383 return false; 2384 } 2385 else 2386 { 2387 var password = formu.find('input[name="pswd_s"]').val(); 2388 2389 if ($("#password_no_md5").val() != 1) 2390 password = md5(password); 2391 2392 formu.find('input[name="password_c"]').val(password); 2393 formu.find('input[name="pswd_s"]').val(""); 2394 2395 var ret = true; 2396 2397 if (formu.find('input[name="login_sites[]"]').size()) 2398 { 2399 var nb_log = 0; 2400 var login = formu.find('input[name="login_s"]').val(); 2401 var passwd = formu.find('input[name="password_c"]').val(); 2402 var setcookie = formu.find('input[name="setcookie"]:checked').size() ? 'true' : 0; 2403 var time = Math.floor(new Date().getTime() / 1000); 2404 2405 formu.append( "<input type='hidden' name='cookie_connect' value='"+time+"'>" ); 2406 2407 $.ajax({ 2408 type: "POST", 2409 url: (typeof url_root != 'undefined' ? url_root : "" ) + '/global/module/core/ressources/ajax/ajax_verif_connexion.php', 2410 data: 2411 { 2412 'login_s': login, 2413 'password_c': passwd, 2414 'setcookie': setcookie 2415 }, 2416 success: function(retur) { 2417 2418 if (retur=='ok') { 2419 2420 formu.find('input[name="login_sites[]"]').each( 2421 function () 2422 { 2423 if (!$(this).hasClass('redirect')) 2424 { 2425 _this = $(this); 2426 2427 crossDomainAjax('POST', $(this).val(), formu.serialize() + '&from_ajax=1&cookie_connect=' + time, 2428 null, 2429 function (data) 2430 { 2431 nb_log++; 2432 2433 console.log('complete ' + nb_log + ' / ' + formu.find('input[name="login_sites[]"]:not(.redirect)').size()); 2434 2435 2436 if (nb_log == formu.find('input[name="login_sites[]"]:not(.redirect)').length) 2437 { 2438 // le submit de form en JS ne fonctionne pas sur FF (mm si on fait un undoLoader() sur formu.find('.connection-submit')) 2439 // formu.attr('action', formu.find('input[name="login_sites[]"].redirect').val()); 2440 // formu.submit(); 2441 2442 // on a juste besoin de faire un reload car on est deja connecté via le ajax_verif_connexion.php 2443 location.reload(); 2444 } 2445 } 2446 ); 2447 } 2448 } 2449 ); 2450 2451 } 2452 else 2453 { 2454 if (formu.find('.connection-submit').size()) 2455 undoLoader(formu.find('.connection-submit')); 2456 alertSwal(retur); 2457 } 2458 } 2459 }); 2460 2461 return false; 2462 } 2463 2464 if (formu.find('.connection-submit').size()) 2465 setTimeout(function(){ 2466 makeLoader(formu.find('.connection-submit')); 2467 }, 100); 2468 2469 return formu.submit(); 2470 } 2471} 2472 2473 2474function animOngletAccueil(elem, elem_bis) 2475{ 2476 if( typeof elem_bis == 'undefined') 2477 elem_bis = 'titreRubriqueAccueilEP'; 2478 2479 $("."+elem).find("." + elem_bis).click ( function() 2480 { 2481 if($(this).siblings('div').is(":hidden")) 2482 { 2483 $(this).siblings('div').slideDown(); 2484 $(this).find('span').removeClass('ui-icon-triangle-1-e'); 2485 $(this).find('span').addClass('ui-icon-triangle-1-s'); 2486 } 2487 else 2488 { 2489 $(this).siblings('div').slideUp(); 2490 $(this).find('span').removeClass('ui-icon-triangle-1-s'); 2491 $(this).find('span').addClass('ui-icon-triangle-1-e'); 2492 } 2493 }); 2494} 2495 2496 2497function supprime_modele_mail(id) 2498{ 2499 if (id != undefined) 2500 { 2501 $.post('/global/ressources/ajax/mailing/supprimeModele.php', { 'id': id }, 2502 function (data) 2503 { 2504 if (data) 2505 { 2506 $('select#mail_content option').each( 2507 function () 2508 { 2509 if ($(this).val() == id) 2510 { 2511 $(this).remove(); 2512 return; 2513 } 2514 } 2515 ); 2516 } 2517 } 2518 ); 2519 } 2520} 2521 2522function selectUniqueCheckBox(elem, all) 2523{ 2524 if (elem.attr('checked')) 2525 { 2526 all.attr('checked', false); 2527 elem.attr('checked', true); 2528 } 2529} 2530 2531/*************************** 2532* code jquery 2533***************************/ 2534if (window.jQuery) { 2535 $( function() { 2536 var isPhone = false ; 2537 if( $.browser ) {
2538 $.browser.device = (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase())); 2539 var isPhone = $.browser.device ; 2540 } 2541 2542 /************** Menus Mobile ******************/ 2543 //if(isPhone){ 2544 if ($("#compactNavigation").length) { 2545 $("#compactNavigation ").click( 2546 function(){ 2547 if($("#compactNavigation>ul").is(':visible')){ 2548 $("#compactNavigation ul").css('display','none'); 2549 } else { 2550 $("#compactNavigation ul").css('display','block'); 2551 } 2552 } 2553 ); 2554 2555 }; 2556 //} 2557 /************** fin block Menu mobile **********/ 2558 }); 2559} 2560 2561 2562/* UTILITIES */ 2563 2564/* permet un debugg js dans la console olu alert */ 2565function var_dump(obj , toalert) { 2566 var out = ''; 2567 for (var i in obj) { 2568 out += i + ": " + obj[i] + "\n"; 2569 } 2570 2571 if(toalert) 2572 alert(out); 2573 else 2574 console.log(out); 2575 2576 var pre = document.createElement('pre'); 2577 pre.innerHTML = out; 2578 document.body.appendChild(pre) 2579} 2580 2581 2582 2583/***** 2584* Visualisation des contenu saisis en admin (mailings, actu ...) 2585******/ 2586function NA_visualisation(type, contenu, largeur, asso) 2587{ 2588 switch (type) 2589 { 2590 case "mailing" : 2591 if (typeof largeur == 'undefined') 2592 largeur = 700; 2593 2594 var param = "type=mailing"; 2595 2596 if ($('#groupe_mailing').val()) 2597 param += "&groupe_mailing=" + $('#groupe_mailing').val(); 2598 2599 if ($('#s_sujet').val()) 2600 param += "&sujet=" + $('#s_sujet').val(); 2601 2602 var template = 0; 2603 if ($('input[type="radio"][name="template_mail"]').size()) 2604 template = $('input[type="radio"][name="template_mail"]:checked').val(); 2605 else 2606 template = $('input[type="hidden"][name="template_mail"]').val(); 2607 2608 2609 if (typeof template != 'undefined' && template > 0) 2610 param += "&template=" + template; 2611 2612 if (asso != undefined) 2613 param += "&asso=" + asso; 2614 2615 param += "&contenu=" + encodeURIComponent(contenu); 2616 2617 afficheCalque("/global/gene/NA_visualisation.php", "", param, largeur); 2618 break; 2619 } 2620} 2621 2622function closeFancy() { 2623 // La page est ouverte dans une iframe fancybox : le plugin fancybox est charge par la page 2624 // parente, pas par le header popup (html_header_popup.html). Il faut donc tester le parent. 2625 try { 2626 if (window.parent !== window && window.parent.$ && typeof window.parent.$.fancybox != "undefined") { 2627 window.parent.$.fancybox.close(); 2628 return; 2629 } 2630 } catch (e) { 2631 // parent inaccessible (cross-origin) : on retombe sur window.close() 2632 } 2633 if (typeof $ != "undefined" && typeof $.fancybox != "undefined") { 2634 $.fancybox.close(); 2635 return; 2636 } 2637 // Ouverture via window.open() / MM_openBrWindow() 2638 window.close(); 2639} 2640 2641function makeLoader(elem) 2642{ 2643 elem.each( 2644 function () 2645 { 2646 $(this).addClass('uiLoader').data('html', $(this).html()).empty().html('<i class="fas fa-spinner fa-spin fa-3x fa-fw"></i>'); 2647 } 2648 ) 2649} 2650 2651function undoLoader(elem, html) 2652{ 2653 elem.each( 2654 function () 2655 { 2656 if (elem.hasClass('uiLoader')) 2657 { 2658 var data = html == undefined || html === false ? elem.data('html') : html; 2659 elem.removeClass('uiLoader').empty().html(data); 2660 } 2661 } 2662 ) 2663} 2664 2665function readmore(ele, tag) { 2666 2667 var ellipsestext = "..."; 2668 var moretext = "Lire la suite"; 2669 var lesstext = "R\351duire"; 2670 2671 ele.each(function() { 2672 2673 var content = $(this).html(); 2674 var showChar = content.indexOf(tag); 2675 if( content.length > showChar && showChar > 0) { 2676 var c = content.substr(0, showChar); 2677 var h = content.substr(showChar, content.length - showChar); 2678 2679 var html = c + '<span class="moreellipses">' + ellipsestext+ ' </span><span class="morecontent"><span style="display: none">' + h + '</span> <a href="" class="morelink" style="display: block;">' + moretext + '</a></span>'; 2680 2681 $(this).html(html); 2682 } 2683 2684 }); 2685 2686 ele.find(".morelink").click(function(){ 2687 if($(this).hasClass("less")) { 2688 $(this).removeClass("less"); 2689 $(this).html(moretext); 2690 } else { 2691 $(this).addClass("less"); 2692 $(this).html(lesstext); 2693 } 2694 $(this).parent().prev().toggle(); 2695 $(this).prev().toggle(); 2696 2697 return false;
2698 }); 2699} 2700 2701 2702function readmore2( options ) { 2703 var animspeed = 500; // animation speed in milliseconds 2704 var elem = options.elem; 2705 var $readmore = $('.' + elem); 2706 2707 var height = $readmore.height() + 30; 2708 var mini = options.min; // $('.' + elem + ' p').eq(0).height() + $('.' + elem + ' p').eq(1).height() + $('.' + elem + ' p').eq(2).height(); 2709 /*if( options.min <= 4) 2710 { 2711 mini = height * (options.min/4); 2712 }*/ 2713 2714 if( height > mini ) 2715 $( '<a class="expand">'+options.more+'</a><a class="contract hide">'+options.less+'</a>' ).insertAfter( '.' + elem ); 2716 else 2717 mini = height; 2718 2719 $readmore.attr('data-fullheight',height+'px'); 2720 $readmore.attr('data-miniheight',mini+'px'); 2721 $readmore.css('height',mini+'px'); 2722 $readmore.css('overflow','hidden'); 2723 2724 $('.expand').on('click', function(e){ 2725 $text = $(this).prev(); 2726 $text.animate({ 2727 'height': $text.attr('data-fullheight') 2728 }, animspeed); 2729 $(this).next('.contract').removeClass('hide'); 2730 $(this).addClass('hide'); 2731 }); 2732 2733 $('.contract').on('click', function(e){ 2734 $text = $(this).prev().prev(); 2735 2736 $text.animate({ 2737 'height': $text.attr('data-miniheight') 2738 }, animspeed); 2739 $(this).prev('.expand').removeClass('hide'); 2740 $(this).addClass('hide'); 2741 }); 2742} 2743 2744function initStdAutoComplete(defaultPlaceholder, context) { 2745 if (typeof _NASelect2 !== 'undefined') 2746 _NASelect2.InitAutoComplete(context); 2747 else if (typeof $('select').select2 === 'function') 2748 $('select').select2(); 2749} 2750 2751function iniTelInput(initial = 'fr') { 2752 $('.telInput').each(function() { 2753 let iti = window.intlTelInput(this, 2754 { 2755 autoHideDialCode: true, 2756 autoPlaceholder: true, 2757 separateDialCode: true, 2758 nationalMode: true, 2759 placeholderNumberType: $(this).data('isfix') ? "FIXED_LINE" : "MOBILE", 2760 formatOnDisplay : true, 2761 initialCountry : initial, 2762 preferredCountries : initial == 'fr' ? [initial] : [initial, 'fr'], 2763 utilsScript: (typeof url_root != 'undefined' ? url_root : "" ) + "/global/vendor/jackocnr/intl-tel-input/build/js/utils.js" // just for formatting/placeholders etc 2764 } 2765 ); 2766 2767 let withIndicatif = $(this).parent().parent().parent().find('.indicatifTelInput'); 2768 2769 $(this).on('input', function () { 2770 if (withIndicatif) { 2771 withIndicatif.val(iti.getNumber()); 2772 } 2773 iti.setNumber(iti.getNumber()); 2774 }); 2775 2776 if(!$(this).closest('table').find('.select.pays').val() && !$(this).val()) { 2777 iti.setCountry($(this).data('init-country') ?? initial); 2778 } 2779 //$(this).trigger("focus"); 2780 }) 2781} 2782 2783function initSimpleSearch(selector) { 2784 if (typeof _NASelect2 !== 'undefined') { 2785 _NASelect2.InitSimpleSearch(selector); 2786 _NASelect2.InitAutoComplete(selector); 2787 } 2788 else if (typeof $('select').select2 === 'function') 2789 $('select').select2(); 2790 2791 if (typeof $.prototype != 'undefined' && typeof $.prototype.select2 != 'undefined') { 2792 $(selector).find('select.simple-search').each(function() { 2793 if (!this.classList.contains('simple-search-initialized')) { 2794 var placeHolder = $(this).data('placeholder'); 2795 let parent = this.closest('.modal.fade.in') ? this.parentElement : ''; 2796 $(this).select2({ 2797 width: 'resolve', 2798 placeholder: placeHolder != undefined ? placeHolder : '', 2799 allowClear: true, 2800 dropdownParent: parent 2801 }); 2802 this.classList.add('simple-search-initialized'); 2803 } 2804 }); 2805 } 2806} 2807 2808$( function(){ 2809 $('.fancyForgotPass').each(function() { 2810 var link = $(this); 2811 2812 link.fancybox({ 2813 autoDimensions: false, 2814 width: ((($(window).width()/2) < 800)?(($(window).width() < 800)?$(window).width():800):($(window).width()/2)), 2815 height: ((($(window).height()/2) < 500)?(($(window).height() < 500)?$(window).height():500):($(window).height()/2)), 2816 type: 'iframe', 2817 title: link.attr('title'), 2818 hideOnOverlayClick : true 2819 }); 2820 }); 2821 $('.fancyForgotFirstConnexion').each(function() { 2822 var link = $(this); 2823 2824 link.fancybox({ 2825 autoDimensions: false, 2826 width: ((($(window).width()/2) < 800)?(($(window).width() < 800)?$(window).width():800):($(window).width()/2)), 2827 height: ((($(window).height()/2) < 500)?(($(window).height() < 500)?$(window).height():500):($(window).height()/2)), 2828 title: link.attr('title'), 2829 hideOnOverlayClick : true 2830 }); 2831 }); 2832 2833 $('.fancyForgotPhotoUser').each(function() { 2834 var link = $(this); 2835 link.fancybox({ 2836 autoDimensions: true, 2837 width: $(window).width() - 150, 2838 height: $(window).height() - 150, 2839 type: 'iframe', 2840 title: link.attr('title'), 2841 hideOnOverlayClick : true 2842 }); 2843 }); 2844 $('.fancyAgenda').each(function() { 2845 var link = $(this); 2846 link.fancybox({ 2847 autoDimensions: true, 2848 width: $(window).width() - 150, 2849 height: $(window).height() - 150, 2850 type: 'iframe', 2851 title: link.attr('title'), 2852 hideOnOverlayClick : true 2853 }); 2854 }); 2855 2856 /* LOADER , ceci ajoute les 3 spans necessaires au nouveau loader */ 2857 makeLoader($('.uiLoader')); 2858 2859 /* popup debug container ( global debugOn / Off ) */ 2860 if($('#pqp-container').length){ 2861 $('#pqp-container').dialog({ minWidth: 1010, minHeight: 300, position: 'center'}); 2862 } 2863 2864 let scriptCheck = setInterval( () => { 2865 if (polyglot) { 2866 clearInterval(scriptCheck); 2867 initStdAutoComplete(polyglot.t("core.select_value")); 2868 } 2869 }, 200); 2870 2871 2872 initSimpleSearch(document); 2873 2874 $(".btn_historique_doc").click( function() {
2875 $(".zoneHistoriqueDoc").slideUp(); 2876 $(this).siblings(".zoneHistoriqueDoc").slideDown(); 2877 }); 2878 $(".annulerHistoriqueDoc").click( function() { 2879 $(this).closest(".zoneHistoriqueDoc").slideUp(); 2880 }); 2881 2882 $("input.numeric").keyup( 2883 function () 2884 { 2885 var pattern = new RegExp(/^-?[0-9.,]*$/); 2886 while (!pattern.test($(this).val())) 2887 $(this).val($(this).val().substring(0, $(this).val().length - 1)); 2888 2889 }); 2890 2891 2892 var input_mail = $('.verif-mail-syntax'); 2893 2894 if (input_mail.length) 2895 { 2896 var mail_xhr = new AjaxHelper( 2897 { 2898 url: (typeof url_root != 'undefined' ? url_root : "" ) + "/global/ressources/ajax/testMail.php", 2899 type: 'POST', 2900 async: true, 2901 dataType: 'json' 2902 } 2903 ); 2904 2905 input_mail.eventTimeout( 2906 { 2907 callback : 2908 function (elem) 2909 { 2910 elem.removeClass('in_wait in_ok in_error verif-mail'); 2911 2912 if (elem.val() == "") 2913 return true; 2914 2915 elem.removeClass('in_ok in_error').addClass("in_wait"); 2916 2917 mail_xhr.send({'mail' : elem.val()}, true, 2918 function (data) 2919 { 2920 elem.removeClass('in_wait'); 2921 2922 if (data.result) 2923 elem.addClass("in_ok"); 2924 else 2925 elem.addClass("in_error verif-mail"); 2926 } 2927 ); 2928 } 2929 } 2930 ); 2931 2932 if (input_mail.val()) 2933 input_mail.eventTimeout('trigger'); 2934 } 2935 2936 // commenté car faisait une erreur js sur la nouvelle charte 2937 /* 2938 $( '.header-navigation > .nav-wrapper > .nav > ul > li.menuli').on( 'mouseleave touchend', function() { 2939 2940 $(this + "> .nav-dropdown").toggle(); 2941 }); 2942 */ 2943}); 2944 2945// Pour que ça existe même sur ancien admin / front 2946function addDatePickerGroupAddon() { 2947 2948} 2949 2950 2951function owner_changed(el, alertOnValid) 2952{ 2953 el = $(el); 2954 2955 el.removeClass('in_wait in_ok in_error'); 2956 2957 if (el.val() == "") 2958 return true; 2959 2960 el.removeClass('in_ok in_error').addClass("in_wait"); 2961 2962 $.get('/global/ressources/ajax/testMail.php', 2963 { 'mail': el.val() }, 2964 function (data) 2965 { 2966 el.removeClass('in_wait verif-mail'); 2967 2968 if (data.result) 2969 el.addClass("in_ok"); 2970 else 2971 el.addClass("in_error" + (typeof alertOnValid != 'undefined' && alertOnValid ? ' verif-mail' : '')); 2972 }, 2973 'json' 2974 ); 2975 return true; 2976} 2977 2978function geoloc(address, id_adresse) { 2979 2980 if( address && typeof address != 'undefined') { 2981 2982 var img = $('#addr_'+id_adresse).closest('td').find('img').attr('src'); 2983 2984 $('#addr_'+id_adresse).closest('td').find('img').attr('src', (typeof url_root != 'undefined' ? url_root : "" ) + '/global/images/ajax-loader.gif'); 2985 2986 $.get("https://nominatim.openstreetmap.org/search.php?format=json&q=" + address,{}, 2987 function(data) 2988 { 2989 if (typeof data[0] != 'undefined') { 2990 var lat = data[0].lat; 2991 var lng = data[0].lon; 2992 2993 $.post('/global/ressources/ajax/geoloc.php', { 'id_adresse': id_adresse, 'lat' : lat, 'lng' : lng }, 2994 function(data) { 2995 $this = $('#addr_'+id_adresse); 2996 $this.closest('td').find('img').attr('src', (typeof url_root != 'undefined' ? url_root : "" ) + '/global/images/geoloc_1.png'); 2997 $('.addr-'+id_adresse).smallipop('show'); 2998 $('.addr-'+id_adresse).smallipop('update', $('.na-tooltip-content-temp-'+id_adresse).html()); 2999 } 3000 ); 3001 3002 } else { 3003 $('#addr_'+id_adresse).closest('td').find('img').attr('src', img); 3004 alert("Géolocalisation n'a pas réussi"); 3005 } 3006 3007 }); 3008 } 3009} 3010 3011function get_html_translation_table (table, quote_style) { 3012 // Returns the internal translation table used by htmlspecialchars and mb_htmlentities 3013 // 3014 // version: 1109.2015 3015 // discuss at: http://phpjs.org/functions/get_html_translation_table 3016 // + original by: Philip Peterson 3017 // + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 3018 // + bugfixed by: noname 3019 // + bugfixed by: Alex 3020 // + bugfixed by: Marco 3021 // + bugfixed by: madipta 3022 // + improved by: KELAN 3023 // + improved by: Brett Zamir (http://brett-zamir.me) 3024 // + bugfixed by: Brett Zamir (http://brett-zamir.me) 3025 // + input by: Frank Forte 3026 // + bugfixed by: T.Wild 3027 // + input by: Ratheous 3028 // % note: It has been decided that we're not going to add global 3029 // % note: dependencies to php.js, meaning the constants are not 3030 // % note: real constants, but strings instead. Integers are also supported if someone 3031 // % note: chooses to create the constants themselves. 3032 // * example 1: get_html_translation_table('HTML_SPECIALCHARS'); 3033 // * returns 1: {'"': '"', '&': '&', '<': '<', '>': '>'} 3034 var entities = {}, 3035 hash_map = {}, 3036 decimal; 3037 var constMappingTable = {}, 3038 constMappingQuoteStyle = {}; 3039 var useTable = {}, 3040 useQuoteStyle = {}; 3041 3042 // Translate arguments 3043 constMappingTable[0] = 'HTML_SPECIALCHARS'; 3044 constMappingTable[1] = 'HTML_ENTITIES'; 3045 constMappingQuoteStyle[0] = 'ENT_NOQUOTES'; 3046 constMappingQuoteStyle[2] = 'ENT_COMPAT'; 3047 constMappingQuoteStyle[3] = 'ENT_QUOTES'; 3048 3049 useTable = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS'; 3050 useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT'; 3051 3052 if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') { 3053 throw new Error("Table: " + useTable + ' not supported'); 3054 // return false;
3055 } 3056 3057 entities['38'] = '&'; 3058 if (useTable === 'HTML_ENTITIES') { 3059 entities['160'] = ' '; 3060 entities['161'] = '¡'; 3061 entities['162'] = '¢'; 3062 entities['163'] = '£'; 3063 entities['164'] = '¤'; 3064 entities['165'] = '¥'; 3065 entities['166'] = '¦'; 3066 entities['167'] = '§'; 3067 entities['168'] = '¨'; 3068 entities['169'] = '©'; 3069 entities['170'] = 'ª'; 3070 entities['171'] = '«'; 3071 entities['172'] = '¬'; 3072 entities['173'] = '­'; 3073 entities['174'] = '®'; 3074 entities['175'] = '¯'; 3075 entities['176'] = '°'; 3076 entities['177'] = '±'; 3077 entities['178'] = '²'; 3078 entities['179'] = '³'; 3079 entities['180'] = '´'; 3080 entities['181'] = 'µ'; 3081 entities['182'] = '¶'; 3082 entities['183'] = '·'; 3083 entities['184'] = '¸'; 3084 entities['185'] = '¹'; 3085 entities['186'] = 'º'; 3086 entities['187'] = '»'; 3087 entities['188'] = '¼'; 3088 entities['189'] = '½'; 3089 entities['190'] = '¾'; 3090 entities['191'] = '¿'; 3091 entities['192'] = 'À'; 3092 entities['193'] = 'Á'; 3093 entities['194'] = 'Â'; 3094 entities['195'] = 'Ã'; 3095 entities['196'] = 'Ä'; 3096 entities['197'] = 'Å'; 3097 entities['198'] = 'Æ'; 3098 entities['199'] = 'Ç'; 3099 entities['200'] = 'È'; 3100 entities['201'] = 'É'; 3101 entities['202'] = 'Ê'; 3102 entities['203'] = 'Ë'; 3103 entities['204'] = 'Ì'; 3104 entities['205'] = 'Í'; 3105 entities['206'] = 'Î'; 3106 entities['207'] = 'Ï'; 3107 entities['208'] = 'Ð'; 3108 entities['209'] = 'Ñ'; 3109 entities['210'] = 'Ò'; 3110 entities['211'] = 'Ó'; 3111 entities['212'] = 'Ô'; 3112 entities['213'] = 'Õ'; 3113 entities['214'] = 'Ö'; 3114 entities['215'] = '×'; 3115 entities['216'] = 'Ø'; 3116 entities['217'] = 'Ù'; 3117 entities['218'] = 'Ú'; 3118 entities['219'] = 'Û'; 3119 entities['220'] = 'Ü'; 3120 entities['221'] = 'Ý'; 3121 entities['222'] = 'Þ'; 3122 entities['223'] = 'ß'; 3123 entities['224'] = 'à'; 3124 entities['225'] = 'á'; 3125 entities['226'] = 'â'; 3126 entities['227'] = 'ã'; 3127 entities['228'] = 'ä'; 3128 entities['229'] = 'å'; 3129 entities['230'] = 'æ'; 3130 entities['231'] = 'ç'; 3131 entities['232'] = 'è'; 3132 entities['233'] = 'é'; 3133 entities['234'] = 'ê'; 3134 entities['235'] = 'ë'; 3135 entities['236'] = 'ì'; 3136 entities['237'] = 'í'; 3137 entities['238'] = 'î'; 3138 entities['239'] = 'ï'; 3139 entities['240'] = 'ð'; 3140 entities['241'] = 'ñ'; 3141 entities['242'] = 'ò'; 3142 entities['243'] = 'ó'; 3143 entities['244'] = 'ô'; 3144 entities['245'] = 'õ'; 3145 entities['246'] = 'ö'; 3146 entities['247'] = '÷'; 3147 entities['248'] = 'ø'; 3148 entities['249'] = 'ù'; 3149 entities['250'] = 'ú'; 3150 entities['251'] = 'û'; 3151 entities['252'] = 'ü'; 3152 entities['253'] = 'ý'; 3153 entities['254'] = 'þ'; 3154 entities['255'] = 'ÿ'; 3155 } 3156 3157 if (useQuoteStyle !== 'ENT_NOQUOTES') { 3158 entities['34'] = '"'; 3159 } 3160 if (useQuoteStyle === 'ENT_QUOTES') { 3161 entities['39'] = '''; 3162 } 3163 entities['60'] = '<'; 3164 entities['62'] = '>'; 3165 3166 3167 // ascii decimals to real symbols 3168 for (decimal in entities) { 3169 if (entities.hasOwnProperty(decimal)) { 3170 hash_map[String.fromCharCode(decimal)] = entities[decimal]; 3171 } 3172 } 3173 3174 return hash_map; 3175} 3176function html_entity_decode (string, quote_style) { 3177 // Convert all HTML entities to their applicable characters 3178 // 3179 // version: 1109.2015 3180 // discuss at: http://phpjs.org/functions/html_entity_decode 3181 // + original by: john (http://www.jd-tech.net) 3182 // + input by: ger 3183 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 3184 // + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 3185 // + bugfixed by: Onno Marsman 3186 // + improved by: marc andreu 3187 // + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 3188 // + input by: Ratheous 3189 // + bugfixed by: Brett Zamir (http://brett-zamir.me) 3190 // + input by: Nick Kolosov (http://sammy.ru) 3191 // + bugfixed by: Fox 3192 // - depends on: get_html_translation_table 3193 // * example 1: html_entity_decode('Kevin & van Zonneveld'); 3194 // * returns 1: 'Kevin & van Zonneveld' 3195 // * example 2: html_entity_decode('&lt;'); 3196 // * returns 2: '<' 3197 var hash_map = {}, 3198 symbol = '', 3199 tmp_str = '', 3200 entity = ''; 3201 tmp_str = string.toString(); 3202 3203 if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) { 3204 return false;
3205 } 3206 3207 // fix & problem 3208 // http://phpjs.org/functions/get_html_translation_table:416#comment_97660 3209 delete(hash_map['&']); 3210 hash_map['&'] = '&'; 3211 3212 for (symbol in hash_map) { 3213 entity = hash_map[symbol]; 3214 tmp_str = tmp_str.split(entity).join(symbol); 3215 } 3216 tmp_str = tmp_str.split(''').join("'"); 3217 3218 return tmp_str; 3219} 3220function upload_substr(string) 3221{ 3222 if(string.length>20) 3223 string = string.substr(0,20)+'...' ; 3224 3225 return string; 3226} 3227 3228function initTinyMCE() 3229{ 3230 na.tinymce.init_all(); 3231 na.tinymce.init_all_specific(); 3232 if( typeof tinymce != "undefined") 3233 { 3234 tinymce.init(na.tinymce.all); 3235 tinymce.init(na.tinymce.all_reduced); 3236 tinymce.init(na.tinymce.standard); 3237 tinymce.init(na.tinymce.simple); 3238 tinymce.init(na.tinymce.newsletter); 3239 tinymce.init(na.tinymce.mail); 3240 tinymce.init(na.tinymce.mail_fullpage); 3241 tinymce.init(na.tinymce.histo); 3242 tinymce.init(na.tinymce.emploi); 3243 tinymce.init(na.tinymce.model_doc); 3244 tinymce.init(na.tinymce.gls); 3245 tinymce.init(na.tinymce.mobile); 3246 } 3247} 3248 3249function copyToClipboard(elementId, imageId, text) { 3250 const $temp = $("<input>"); 3251 $("body").append($temp); 3252 $temp.val($('#' + elementId).text()).select(); 3253 document.execCommand("copy"); 3254 3255 const $image = $('#' + imageId); 3256 $image.removeClass('fa-copy'); 3257 $image.addClass('fa-paste'); 3258 $image.find(">:first-child").text(text); 3259 $temp.remove(); 3260} 3261 3262 3263function rech_as_no_modal(url, modal) { 3264 if(modal) { 3265 $('#modal_rech_asno').find('.modal-body').html('<center style="margin:50px;"><i class="fas fa-spinner fa-spin fa-3x fa-fw"></i></center>'); 3266 $('#modal_rech_asno').find('.modal-body').load(url+'&modal=1',function(){ 3267 initLegacy('.rech_as_no'); 3268 }); 3269 } 3270 else { 3271 fen = window.open(url , "", "width=580,height=400,scrollbars=yes"); 3272 if (!fen.opener) fen.opener = self; 3273 } 3274} 3275 3276function initTribute(selectorId) { 3277 3278 if(typeof Tribute == 'undefined') 3279 return; 3280 3281 var tribute = new Tribute({ 3282 trigger: '@', 3283 allowSpaces : true, 3284 lookup: 'id', 3285 searchOpts: { 3286 pre: '<span>', 3287 post: '</span>', 3288 skip: true // true will skip local search, useful if doing server-side search 3289 }, 3290 values: function (text, cb) { 3291 remoteSearchName(text, users => cb(users)); 3292 }, 3293 noMatchTemplate: function () { 3294 return $('.not_found').html(); 3295 } 3296 /*menuItemTemplate: function(item) { 3297 3298 return item.string; 3299 3300 console.log(item); 3301 var label = item.original.label; 3302 console.log('label -> ' + label.replace('affiche_nom', item.string)); 3303 return label.replace('affiche_nom', item.string); 3304 },*/ 3305 }); 3306 3307 tribute.attach(document.getElementById(selectorId)); 3308} 3309 3310function remoteSearchName(text, cb) { 3311 var URL = "/global/module/admin/ressources/ajax/ajax_stdAutocomplete.php?criterion=Elastic.PersonneNomPrenom"; 3312 xhr = new XMLHttpRequest(); 3313 xhr.onreadystatechange = function() { 3314 if (xhr.readyState === 4) { 3315 if (xhr.status === 200) { 3316 var data = JSON.parse(xhr.responseText); 3317 cb(data); 3318 } else if (xhr.status === 403) { 3319 cb([]); 3320 } 3321 } 3322 }; 3323 xhr.open("GET", URL + "&mention=1&term=" + text, true); 3324 xhr.send(); 3325} 3326 3327 3328function UpdateElementOfParent(id, val) { 3329 $('#'+id).val(val); 3330} 3331 3332function getElementOfParent(id) { 3333 return $('#'+id).val(); 3334} 3335 3336function hasElementOfParent(id) { 3337 return $('#'+id).length; 3338} 3339 3340function submitForm(id) { 3341 $('#'+id).submit(); 3342} 3343 3344function loadCalqueImportInscription(elem, url) { 3345 $.fancybox( 3346 { 3347 'hideOnContentClick': false, 3348 'width':900, 3349 'height':700, 3350 'autoScale':false, 3351 'autoDimensions':false, 3352 'href': typeof url != "undefined" ? url : elem.attr('href'), 3353 'titleShow':false, 3354 'type':'iframe', 3355 'frameHeight': '100%', 3356 'frameWidth': '100%', 3357 'onClosed': function() {} 3358 }); 3359 return false; 3360} 3361 3362function DropDown(el) { 3363 this.dd = el; 3364 this.initEvents(); 3365} 3366 3367function setDateFocusIn(dateInput) { 3368 dateInput.type = 'date'; 3369} 3370 3371function setDateFocusOut(dateInput) { 3372 if (!dateInput.value) { 3373 dateInput.type = 'text'; 3374 } 3375} 3376 3377function initDateWithPlaceholder() { 3378 document.querySelectorAll('input[type="date"]').forEach(function(element) { 3379 if (element.placeholder) { 3380 element.addEventListener('focus', () => setDateFocusIn(element), false); 3381 element.addEventListener('focusout', () => setDateFocusOut(element), false); 3382 setDateFocusOut(element); 3383 } 3384 }); 3385} 3386 3387document.addEventListener('DOMContentLoaded', function() { 3388 initDateWithPlaceholder(); 3389}) 3390 3391function formatResultEtablissement(val) { 3392 if (!val.id) 3393 return val.text; // optgroup 3394 return "<div style='display:inline-block;text-align:left'>" + "<b>" + val.text + "</b>" + " <br />" + $(val.element).data('addr') + "</div> "; 3395} 3396function formatSelectionEtablissement(val) { 3397 if (!val.id) return val.text; // optgroup 3398 3399 var txt = val.text; 3400 return "<b>" + txt + "</b>" + " > " + $(val.element).data('addr'); 3401} 3402 3403function fenetre_etat_civil(formulaire, personne) {
3404 rech_as_no_modal("/global/gene/rech_as_no.php?nom_formulaire=" + formulaire + "&personne=" + personne, '1'); 3405} 3406 3407function changeSlide(oldSlide, newSlide, oldPreview, newPreview) { 3408 newSlide.classList.add('active'); 3409 newPreview.classList.add('active'); 3410 oldPreview.classList.remove('active'); 3411 oldSlide.classList.remove('active'); 3412 newSlide.style.display = 'block'; 3413 oldSlide.classList.remove('active'); 3414 oldSlide.style.display = 'none'; 3415} 3416 3417function selectSlide(sliderID, index) { 3418 const slider = document.querySelector('#' + sliderID); 3419 const activeSlide = slider.querySelector('.main-image.active'); 3420 const activePreview = slider.querySelector('.preview.active'); 3421 const nextPreview = slider.querySelectorAll('.preview')[index]; 3422 const nextSlide = slider.querySelectorAll('.main-image')[index]; 3423 3424 if (activeSlide && nextSlide && activePreview && nextPreview && !nextSlide.classList.contains('active')) { 3425 changeSlide(activeSlide, nextSlide, activePreview, nextPreview); 3426 } 3427} 3428 3429function nextSlide(sliderID) { 3430 const slider = document.querySelector('#' + sliderID); 3431 const activeSlide = slider.querySelector('.main-image.active'); 3432 let index = 0; 3433 if (activeSlide.nextElementSibling?.classList?.contains('main-image')) { 3434 index = [].indexOf.call(slider.querySelectorAll('.main-image'), activeSlide.nextElementSibling); 3435 } 3436 3437 selectSlide(sliderID, index); 3438} 3439 3440function prevSlide(sliderID) { 3441 const slider = document.querySelector('#' + sliderID); 3442 const activeSlide = slider.querySelector('.main-image.active'); 3443 let index = slider.querySelectorAll('.main-image').length - 1; 3444 if (activeSlide.previousElementSibling?.classList?.contains('main-image')) { 3445 index = [].indexOf.call(slider.querySelectorAll('.main-image'), activeSlide.previousElementSibling); 3446 } 3447 3448 selectSlide(sliderID, index); 3449}
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.