Advertisement
AlenaLP

static_menu

Jan 27th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. <script>
  2. jq_144(function($) {
  3. $(document).ready(function() {
  4.  
  5.  
  6. var sm_bg_block = "#block-new10"; //идентификатор основной панели меню
  7. var sm_gap = 10; //сдвиг меню (в пикселях) от верней границы окна
  8.  
  9.  
  10.  
  11.  
  12. /* Для корректной работы menu дальнейший код изменять не рекомендуется */
  13.  
  14. var sm_menu = "";
  15. var sm_x_crd = [];
  16. var sm_y_crd = [];
  17. var sm_bg_top, sm_bg_left, sm_bg_bot, sm_bg_right, sm_bg_zi;
  18. var sm_i = 0;
  19. var sm_x = 0;
  20. var sm_y = 0;
  21. var sm_bg_w = 0;
  22.  
  23. sm_bg_zi = parseInt($(sm_bg_block).css("z-Index"));
  24. sm_bg_top = parseInt($(sm_bg_block).css('top'));
  25. sm_bg_left = parseInt($(sm_bg_block).css('left'));
  26. sm_bg_right = sm_bg_left + $(sm_bg_block).width();
  27. sm_bg_bottom = sm_bg_top + $(sm_bg_block).height();
  28.  
  29. $('div').each(function()
  30. {
  31. if (
  32. (sm_bg_zi<parseInt($(this).css("z-Index"))) &&
  33. (sm_bg_top<parseInt($(this).css('top'))) &&
  34. (sm_bg_left<parseInt($(this).css('left'))) &&
  35. (sm_bg_right>(parseInt($(this).css('left'))+$(this).width()) &&
  36. (sm_bg_bottom>(parseInt($(this).css('top'))+$(this).height())))
  37. )
  38. {
  39. sm_menu += ("#"+$(this).attr('id')+", ");
  40. }
  41. });
  42.  
  43. sm_menu = sm_menu.substring(0, sm_menu.length-2);
  44.  
  45. $(sm_bg_block).css('position','fixed');
  46. $(sm_bg_block).css('z-index',parseInt($(sm_bg_block).css('z-index'))+500);
  47. $(sm_menu).each(function()
  48. {
  49. $(this).css('position','fixed');
  50. $(this).css('z-index',parseInt($(this).css('z-index'))+500);
  51. });
  52.  
  53. sm_bg_top = $(sm_bg_block).position().top;
  54. sm_bg_left = $(sm_bg_block).position().left;
  55.  
  56. $(sm_menu).each(function()
  57. {
  58. sm_x_crd[sm_i] = $(this).position().left - sm_bg_left;
  59. sm_y_crd[sm_i] = $(this).position().top - sm_bg_top;
  60. sm_i++;
  61. });
  62.  
  63. sm_bg_w = $(sm_bg_block).width();
  64. sm_y = sm_gap;
  65. sm_i = 0;
  66.  
  67. $(sm_menu).each(function()
  68. {
  69. $(this).css('top', sm_y + sm_y_crd[sm_i]);
  70. sm_i++;
  71. });
  72. $(sm_bg_block).css('top',sm_y);
  73.  
  74. $(window).resize(function()
  75. {
  76. sm_i = 0;
  77. sm_x = ($(window).width() - sm_bg_w)/2;
  78. $(sm_bg_block).css('left',sm_x);
  79. $(sm_menu).each(function()
  80. {
  81. $(this).css('left', sm_x + sm_x_crd[sm_i]);
  82. sm_i++;
  83. });
  84.  
  85. });
  86. $(window).resize();
  87.  
  88. });
  89. });
  90.  
  91. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement