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