site.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. function wrap(){
  2. $('#start > div:nth-child(-n+3)').wrapAll('<div class="top"></div> ')
  3. $('#start > div:nth-child(n+2)').wrapAll('<div class="bottom"></div> ')
  4. };
  5. function scrollbar(){
  6. $(window).on("load",function(){
  7. $("#start > div > div").mCustomScrollbar({
  8. axis:"y",
  9. setTop: 0,
  10. });
  11. });
  12. }
  13. function clickhand(){
  14. $(".handler").on("mousedown", function (e) {
  15. e.preventDefault();
  16. $(this).addClass("mouseDown");
  17. }).on("mouseup", function () {
  18. $(this).removeClass("mouseDown");
  19. });
  20. };
  21. function drag() {
  22. var $hand1 = $( ".hand1" );
  23. var $hand2 = $( ".hand2" );
  24. $hand1.draggable({
  25. containment: "#start",
  26. scroll: false,
  27. // grid: [ 5, 5 ],
  28. drag: function(){
  29. // handler
  30. // dimension handler
  31. var $Hhand = $(this).outerHeight();
  32. var $Whand = $(this).outerWidth();
  33. // ajust handler
  34. var ajustH = $Hhand / 2;
  35. var ajustW = $Whand / 2;
  36. // position handler
  37. var offset = $(this).offset();
  38. var xPos = offset.left + ajustW;
  39. var yPos = offset.top - ajustH;
  40. var xPos2 = xPos + (ajustW * 2);
  41. var yPos2 = yPos + (ajustH * 2);
  42. // Blocs
  43. // top
  44. var $recits = $(this).parent('#page').find('#recits');
  45. var $itw = $(this).parent('#page').find("#interviews");
  46. var $img = $(this).parent('#page').find("#images");
  47. // bottom
  48. var $bottom = $(this).parent('#page').find(".bottom");
  49. var $links = $(this).parent('#page').find("#links");
  50. var $rs = $(this).parent('#page').find("#reseaux-sociaux");
  51. var $stmp = $(this).parent('#page').find("#streetmap");
  52. // dimension blocs
  53. var Dw0 = $(window).outerWidth(true);
  54. var Dw1 = $recits.outerWidth(true);
  55. var Dw2 = $itw.outerWidth(true);
  56. var Dw3 = $img.outerWidth(true);
  57. // var Bw1 = (Dw0 - (Dw2 + Dw3));
  58. var Bw2 = (Dw0 - (Dw1 + Dw3));
  59. var Bw3 = (Dw0 - (Dw1 + Dw2));
  60. var Bl3 = Dw1 + Dw2;
  61. // app dimension
  62. var $handler2 = $(this).parent().find('.hand2');
  63. $handler2.css({
  64. "top": yPos + 25,
  65. "left": xPos + Bw2 - 25,
  66. });
  67. $recits.css({
  68. "width": xPos,
  69. "height": yPos - 2,
  70. });
  71. $itw.css({
  72. "width": Bw2,
  73. "height": yPos - 2,
  74. });
  75. $img.css({
  76. // "width": '33%',
  77. "height": yPos - 2,
  78. });
  79. $bottom.css({
  80. "top": yPos2 + 2,
  81. })
  82. $links.css({
  83. "width": xPos,
  84. "top": yPos2 + 2,
  85. })
  86. $rs.css({
  87. "width": Bw2,
  88. });
  89. // $stmp.css({
  90. // "width": '33%',
  91. // });
  92. }
  93. });
  94. $hand2.draggable({
  95. containment: "#start",
  96. scroll: false,
  97. drag: function(){
  98. // handler
  99. // dimension handler
  100. var $Hhand = $(this).outerHeight(true);
  101. var $Whand = $(this).outerWidth(true);
  102. // ajust handler
  103. var ajustH = $Hhand / 2;
  104. var ajustW = $Whand / 2;
  105. // position handler
  106. var offset = $(this).offset();
  107. var xPos = offset.left + ajustW;
  108. var yPos = offset.top - ajustH;
  109. var xPos2 = xPos + (ajustW * 2);
  110. var yPos2 = yPos + (ajustH * 2);
  111. // Blocs
  112. // top
  113. var $recits = $(this).parent('#page').find('#recits');
  114. var $itw = $(this).parent('#page').find("#interviews");
  115. var $img = $(this).parent('#page').find("#images");
  116. // bottom
  117. var $bottom = $(this).parent('#page').find(".bottom");
  118. var $links = $(this).parent('#page').find("#links");
  119. var $rs = $(this).parent('#page').find("#reseaux-sociaux");
  120. var $stmp = $(this).parent('#page').find("#streetmap");
  121. // dimension blocs
  122. var Dw0 = $(window).outerWidth(true);
  123. var Dw1 = $recits.outerWidth(true);
  124. var Dw2 = $itw.outerWidth(true);
  125. var Dw3 = $img.outerWidth(true);
  126. var xPos3 = Dw0 - xPos;
  127. // var Bw1 = (Dw0 - (Dw2 + Dw3));
  128. var Bw2 = (Dw0 - (Dw1 + Dw3));
  129. var Bw3 = (Dw0 - (Dw1 + Dw2));
  130. var Bl3 = Dw1 + Dw2;
  131. // app dimension
  132. var $handler1 = $(this).parent().find('.hand1');
  133. $handler1.css({
  134. "top": yPos + 25,
  135. "left": xPos - Bw2 - 25,
  136. });
  137. $recits.css({
  138. // "width": xPos,
  139. "height": yPos - 2,
  140. });
  141. $itw.css({
  142. "width": Bw2,
  143. "height": yPos - 2,
  144. });
  145. $img.css({
  146. "width": xPos3,
  147. "height": yPos - 2,
  148. });
  149. $bottom.css({
  150. "top": yPos2 + 2,
  151. })
  152. $rs.css({
  153. "width": Bw2,
  154. });
  155. $stmp.css({
  156. "width": xPos3,
  157. });
  158. }
  159. });
  160. };
  161. $(document).ready(function() {
  162. wrap();
  163. scrollbar();
  164. clickhand();
  165. drag();
  166. });