summaryrefslogtreecommitdiff
path: root/bin/mozilla/menu.pl
blob: 715efcfa42a7ecdc3d6bc391437c49a5f3418151 (plain)
  1. #=====================================================================
  2. # LedgerSMB
  3. # Small Medium Business Accounting software
  4. #
  5. # See COPYRIGHT file for copyright information
  6. #======================================================================
  7. #
  8. # This file has undergone whitespace cleanup.
  9. #
  10. #======================================================================
  11. #
  12. # two frame layout with refractured menu
  13. #
  14. #######################################################################
  15. $menufile = "menu.ini";
  16. use LedgerSMB::Menu;
  17. 1;
  18. # end of main
  19. sub display {
  20. $menuwidth = ($ENV{HTTP_USER_AGENT} =~ /links/i) ? "240" : "155";
  21. $menuwidth = $myconfig{menuwidth} if $myconfig{menuwidth};
  22. $form->header(!$form->{duplicate});
  23. print qq|
  24. <frameset cols="$menuwidth,*" border="1">
  25. <frame name="acc_menu" src="$form->{script}?login=$form->{login}&amp;sessionid=$form->{sessionid}&amp;action=acc_menu&amp;path=$form->{path}&amp;js=$form->{js}" />
  26. <frame name="main_window" src="am.pl?login=$form->{login}&amp;sessionid=$form->{sessionid}&amp;action=$form->{main}&amp;path=$form->{path}" />
  27. </frameset>
  28. </html>
  29. |;
  30. }
  31. sub acc_menu {
  32. my $menu = new Menu "$menufile";
  33. $menu->add_file("custom_$menufile") if -f "custom_$menufile";
  34. $menu->add_file("$form->{login}_$menufile") if -f "$form->{login}_$menufile";
  35. $form->{title} = $locale->text('Accounting Menu');
  36. my $headeradd = q|
  37. <script type="text/javascript">
  38. function SwitchMenu(obj) {
  39. if (document.getElementById) {
  40. var el = document.getElementById(obj);
  41. if (el.style.display == "none") {
  42. el.style.display = "block"; //display the block of info
  43. } else {
  44. el.style.display = "none";
  45. }
  46. }
  47. }
  48. function ChangeClass(menu, newClass) {
  49. if (document.getElementById) {
  50. document.getElementById(menu).className = newClass;
  51. }
  52. }
  53. document.onselectstart = new Function("return false");
  54. </script>|;
  55. $form->header(undef, $headeradd);
  56. print q|
  57. <body class="menu">
  58. <img class="cornderlogo" src="ledger-smb_small.png" width="100" height="50" border="1" alt="ledger-smb" />
  59. |;
  60. if ($form->{js}) {
  61. &js_menu($menu);
  62. } else {
  63. &section_menu($menu);
  64. }
  65. print q|
  66. </body>
  67. </html>
  68. |;
  69. }
  70. sub section_menu {
  71. my ($menu, $level) = @_;
  72. # build tiered menus
  73. my @menuorder = $menu->access_control(\%myconfig, $level);
  74. while (@menuorder) {
  75. $item = shift @menuorder;
  76. $label = $item;
  77. $label =~ s/$level--//g;
  78. my $spacer = "&nbsp;" x (($item =~ s/--/--/g) * 2);
  79. $label =~ s/.*--//g;
  80. $label = $locale->text($label);
  81. $label =~ s/ /&nbsp;/g if $label !~ /<img /i;
  82. $menu->{$item}{target} = "main_window" unless $menu->{$item}{target};
  83. if ($menu->{$item}{submenu}) {
  84. $menu->{$item}{$item} = !$form->{$item};
  85. if ($form->{level} && $item =~ $form->{level}) {
  86. # expand menu
  87. print qq|<br />\n$spacer|.$menu->menuitem(\%myconfig, \%$form, $item, $level).qq|$label</a>|;
  88. # remove same level items
  89. map { shift @menuorder } grep /^$item/, @menuorder;
  90. &section_menu($menu, $item);
  91. print qq|<br />\n|;
  92. } else {
  93. print qq|<br />\n$spacer|.$menu->menuitem(\%myconfig, \%$form, $item, $level).qq|$label&nbsp;...</a>|;
  94. # remove same level items
  95. map { shift @menuorder } grep /^$item/, @menuorder;
  96. }
  97. } else {
  98. if ($menu->{$item}{module}) {
  99. print qq|<br />\n$spacer|.$menu->menuitem(\%myconfig, \%$form, $item, $level).qq|$label</a>|;
  100. } else {
  101. $form->{tag}++;
  102. print qq|<a name="id$form->{tag}"></a><p><b>$label</b></p>|;
  103. &section_menu($menu, $item);
  104. print qq|<br />\n|;
  105. }
  106. }
  107. }
  108. }
  109. sub js_menu {
  110. my ($menu, $level) = @_;
  111. print qq| <div id="div_$menu_$level"> |;
  112. # build tiered menus
  113. my @menuorder = $menu->access_control(\%myconfig, $level);
  114. while (@menuorder){
  115. $i++;
  116. $item = shift @menuorder;
  117. $label = $item;
  118. $label =~ s/.*--//g;
  119. $label = $locale->text($label);
  120. $menu->{$item}{target} = "main_window" unless $menu->{$item}{target};
  121. if ($menu->{$item}{submenu}) {
  122. $display = "display: none;" unless $level eq ' ';
  123. print qq|
  124. <div id="menu$i" class="menuOut" onclick="SwitchMenu('sub$i')" onmouseover="ChangeClass('menu$i','menuOver')" onmouseout="ChangeClass('menu$i','menuOut')">$label</div>
  125. <div class="submenu" id="sub$i" style="$display">|;
  126. # remove same level items
  127. map { shift @menuorder } grep /^$item/, @menuorder;
  128. &js_menu($menu, $item);
  129. print qq|
  130. </div>
  131. |;
  132. } else {
  133. if ($menu->{$item}{module}) {
  134. if ($level eq "") {
  135. print qq|<div id="menu$i" class="menuOut" onmouseover="ChangeClass('menu$i','menuOver')" onmouseout="ChangeClass('menu$i','menuOut')"> |.
  136. $menu->menuitem(\%myconfig, \%$form, $item, $level).qq|$label</a></div>|;
  137. # remove same level items
  138. map { shift @menuorder } grep /^$item/, @menuorder;
  139. &js_menu($menu, $item);
  140. } else {
  141. print qq|<div class="submenu"> |.
  142. $menu->menuitem(\%myconfig, \%$form, $item, $level).qq|$label</a></div>|;
  143. }
  144. } else {
  145. $display = "display: none;" unless $item eq ' ';
  146. print qq|
  147. <div id="menu$i" class="menuOut" onclick="SwitchMenu('sub$i')" onmouseover="ChangeClass('menu$i','menuOver')" onmouseout="ChangeClass('menu$i','menuOut')">$label</div>
  148. <div class="submenu" id="sub$i" style="$display">|;
  149. &js_menu($menu, $item);
  150. print qq| </div> |;
  151. }
  152. }
  153. }
  154. print qq| </div> |;
  155. }
  156. sub menubar {
  157. 1;
  158. }