Le repo des sources pour le site web des JM2L
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

187 lines
6.0 KiB

  1. function DoPost(TargetURL) {
  2. var Datas=$('#ModalForm').serialize();
  3. $.ajax({
  4. type:'post',
  5. url:TargetURL,
  6. data:Datas,
  7. success:function(result, status, jqXHR){
  8. var regexp = /(javascript)/gi;
  9. if (!jqXHR.getResponseHeader('content-type').match(regexp))
  10. $("#AjaxModal").html(result);
  11. },
  12. error:function(result, error){
  13. alert(error);
  14. },
  15. });
  16. }
  17. function DoPostLieu(TargetURL) {
  18. var Datas=$('#ModalPlaceForm').serialize();
  19. $.ajax({
  20. type:'post',
  21. url:TargetURL,
  22. data:Datas,
  23. success:function(result, status, jqXHR){
  24. var regexp = /(javascript)/gi;
  25. if (!jqXHR.getResponseHeader('content-type').match(regexp))
  26. $("#AjaxPlaceModal").html(result);
  27. },
  28. error:function(result, error){
  29. alert(error);
  30. },
  31. });
  32. }
  33. function DoGet(TargetURL) {
  34. $.ajax({
  35. url:TargetURL,
  36. success:function(result, status, jqXHR){
  37. var regexp = /(javascript)/gi;
  38. if (!jqXHR.getResponseHeader('content-type').match(regexp)) {
  39. $("#AjaxModal").html(result);
  40. $("#AjaxModal").modal('show');
  41. }
  42. },
  43. error:function(result, error){
  44. alert(error);
  45. },
  46. });
  47. }
  48. function DoGetLieu(TargetURL) {
  49. $('#AjaxModal').modal("hide");
  50. $.ajax({
  51. url:TargetURL,
  52. success:function(result, status, jqXHR){
  53. var regexp = /(javascript)/gi;
  54. if (!jqXHR.getResponseHeader('content-type').match(regexp)) {
  55. $("#AjaxPlaceModal").html(result);
  56. $("#AjaxPlaceModal").modal('show');
  57. }
  58. },
  59. error:function(result, error){
  60. alert(error);
  61. },
  62. });
  63. }
  64. $(document).ready(function() {
  65. $.fn.modal.Constructor.prototype.enforceFocus = function() {};
  66. $('[handle="modal"]').click(function(e) {
  67. e.preventDefault();
  68. var url = $(this).attr('Myhref');
  69. var target = $(this).attr('data-target');
  70. $(target).html('');
  71. $(target).addClass("Loading");
  72. $(target).modal("show");
  73. $(target).load(url, function() {
  74. $(target).removeClass("Loading");
  75. });
  76. return false;
  77. });
  78. $('#AjaxModal').on('hidden', function(bla){
  79. if (bla.target.id.endsWith('-help'))
  80. return;
  81. if (bla.target.id=='AjaxModal') {
  82. if ($(this).children().length)
  83. $(this).children()[0].remove();
  84. if (typeof map === "undefined")
  85. return;
  86. if (map)
  87. map.remove();
  88. }
  89. });
  90. $('#AjaxPlaceModal').on('hidden', function(bla){
  91. $("#place_type").select2("destroy");
  92. if (bla.target.id.endsWith('-help'))
  93. return;
  94. if ($(this).children().length)
  95. $(this).children()[0].remove();
  96. $("#place_type");
  97. });
  98. $('#AjaxPlaceModal').on('shown', function(bla){
  99. if (map)
  100. setTimeout(function() {
  101. map.invalidateSize();
  102. }, 10);
  103. });
  104. $('#AjaxModal').on('shown', function(bla){
  105. if (bla.target.id=="ItinMap")
  106. setTimeout(function() {
  107. map.invalidateSize();
  108. great_route.route();
  109. $('#map_Itineraire').eq(0).html( $('.leaflet-routing-alt').eq(0).html() );
  110. $('.leaflet-routing-container').eq(0).attr("style","display:none;")
  111. $('#map_Itineraire > table').eq(0).attr("style","width:100%;");
  112. }, 10);
  113. });
  114. $('[data-toggle="modal"]').click(function(e) {
  115. e.preventDefault();
  116. var url = $(this).attr('href');
  117. //var modal_id = $(this).attr('data-target');
  118. $.get(url, function(data) {
  119. $(data).modal();
  120. });
  121. });
  122. if (location.hash !== '') {
  123. var SavHash = location.hash;
  124. if (Array('#Miam','#Covoiturage','#Hebergement',
  125. '#Materiel','#ResumeInt').indexOf(location.hash)>=0)
  126. $('a[href="#Logistique"]').tab('show')
  127. .on('shown', function(e) {
  128. $('a[href="' + SavHash + '"]').tab('show');
  129. });
  130. else {
  131. if (Array('#ResumePart','#Conference','#Stand','#Atelier',
  132. '#TableRonde','#Organisation').indexOf(location.hash)>=0)
  133. $('a[href="#Interventions"]').tab('show')
  134. .on('shown', function(e) {
  135. $('a[href="' + SavHash + '"]').tab('show');
  136. });
  137. else
  138. $('a[href="' + SavHash + '"]').tab('show');
  139. }
  140. }
  141. jQuery(function() {
  142. jQuery('.repeat').each(function() {
  143. jQuery(this).repeatable_fields(
  144. {
  145. is_ready: function(container, therow) {
  146. var numrow=$(container).attr('data-rf-row-count');
  147. $("#tiersship-"+ (numrow-1) +"-tiers_uid").select2(
  148. {
  149. placeholder: 'Entrez ici votre entité',
  150. minimumInputLength: 2, allowClear: true,
  151. ajax: {
  152. quietMillis: 250, url: "/json-tiers", dataType: 'json',
  153. data: function (term, page) {
  154. return { pageSize: 8, pageNum: page, searchTerm: term };
  155. },
  156. results: function (data, page) {
  157. var more = (page * 8) < data.Total;
  158. return { results: data.Results, more: more };
  159. }
  160. }
  161. });
  162. }
  163. });
  164. });
  165. });
  166. $('a[data-toggle="tab"]')
  167. .on('shown', function(e) {
  168. stateObj = { tab: $(e.target).attr('href').substr(1) };
  169. history.replaceState(stateObj, "", "/MesJM2L" + $(e.target).attr('href') );
  170. });
  171. });