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