summaryrefslogtreecommitdiff
path: root/bin/mozilla/menu.pl
blob: 848cf14bb60d7a1356b4959e7b2b219ad146d5dc (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}&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 q|
  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 q|
  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><p><b>$label</b></p>|;
  104. &section_menu($menu, $item);
  105. print qq|<br />\n|;
  106. }
  107. }
  108. }
  109. }
  110. sub js_menu {
  111. my ($menu, $level) = @_;
  112. print qq| <div id="cont"> |;
  113. # build tiered menus
  114. my @menuorder = $menu->access_control(\%myconfig, $level);
  115. while (@menuorder){
  116. $i++;
  117. $item = shift @menuorder;
  118. $label = $item;
  119. $label =~ s/.*--//g;
  120. $label = $locale->text($label);
  121. $menu->{$item}{target} = "main_window" unless $menu->{$item}{target};
  122. if ($menu->{$item}{submenu}) {
  123. $display = "display: none;" unless $level eq ' ';
  124. print qq|
  125. <div id="menu$i" class="menuOut" onclick="SwitchMenu('sub$i')" onmouseover="ChangeClass('menu$i','menuOver')" onmouseout="ChangeClass('menu$i','menuOut')">$label</div>
  126. <div class="submenu" id="sub$i" style="$display">|;
  127. # remove same level items
  128. map { shift @menuorder } grep /^$item/, @menuorder;
  129. &js_menu($menu, $item);
  130. print qq|
  131. </div>
  132. |;
  133. } else {
  134. if ($menu->{$item}{module}) {
  135. if ($level eq "") {
  136. print qq|<div id="menu$i" class="menuOut" onmouseover="ChangeClass('menu$i','menuOver')" onmouseout="ChangeClass('menu$i','menuOut')"> |.
  137. $menu->menuitem(\%myconfig, \%$form, $item, $level).qq|$label</a></div>|;
  138. # remove same level items
  139. map { shift @menuorder } grep /^$item/, @menuorder;
  140. &js_menu($menu, $item);
  141. } else {
  142. print qq|<div class="submenu"> |.
  143. $menu->menuitem(\%myconfig, \%$form, $item, $level).qq|$label</a></div>|;
  144. }
  145. } else {
  146. $display = "display: none;" unless $item eq ' ';
  147. print qq|
  148. <div id="menu$i" class="menuOut" onclick="SwitchMenu('sub$i')" onmouseover="ChangeClass('menu$i','menuOver')" onmouseout="ChangeClass('menu$i','menuOut')">$label</div>
  149. <div class="submenu" id="sub$i" style="$display">|;
  150. &js_menu($menu, $item);
  151. print qq| </div> |;
  152. }
  153. }
  154. }
  155. print qq| </div> |;
  156. }
  157. sub menubar {
  158. 1;
  159. }