Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 32fa785e

Von Moritz Bunkus vor mehr als 16 Jahren hinzugefügt

  • ID 32fa785e63db8d0b0629be988589e89a92986d3e
  • Vorgänger 3acaa523
  • Nachfolger 06af498f

Das Javascript-Menü durch eine andere Implementation ersetzt, die auch unter dem Internet Explorer 7 funktioniert.

Unterschiede anzeigen:

bin/mozilla/menunew.pl
30 30
#
31 31
# thre frame layout with refractured menu
32 32
#
33
# CHANGE LOG:
34
#   DS. 2002-03-25  Created
35
#  2004-12-14 - New Optik - Marco Welter <mawe@linux-studio.de>
36 33
#######################################################################
37 34

  
38
$menufile = "menu.ini";
35
use English qw(-no_match_vars);
36
use List::Util qw(max);
37

  
39 38
use SL::Menu;
40
use CGI::Carp qw(fatalsToBrowser);
41 39

  
42 40
1;
43 41

  
44 42
# end of main
45 43

  
46 44
sub display {
45
  $form->header();
47 46

  
48
  $form->header;
49

  
50
  &clock_line;
51

  
52
  &acc_menu;
53

  
54
  print qq|
55
<iframe id="win1" src="login.pl?action=company_logo" width="100%" height="93%" name="main_window" style="position: absolute; border:0px;">
56
<p>Ihr Browser kann leider keine eingebetteten Frames anzeigen.
57
</p>
58
</iframe>
59
</body>
60
</html>
61

  
62
|;
47
#   $form->{force_ul_width} = $ENV{HTTP_USER_AGENT} =~ m/MSIE\s+6\./;
48
  $form->{force_ul_width} = $ENV{HTTP_USER_AGENT} !~ m/Opera/;
49
#   $form->{force_ul_width} = 1;
50
  $form->{date}           = clock_line();
51
  $form->{menu_items}     = acc_menu();
63 52

  
53
  print $form->parse_html_template("menu/menunew");
64 54
}
65 55

  
66 56
sub clock_line {
67

  
68
  $fensterlink="menunew.pl?action=display";
69
  $fenster = "["."<a href=\"$fensterlink\" target=\"_blank\">neues Fenster</a>]";
70

  
71
  $login = "[Nutzer "
72
    . $form->{login}
73
    . " - <a href=\"login.pl?action=logout\" target=\"_top\">"
74
    . $locale->text('Logout')
75
    . "</a>] ";
76 57
  my ($Sekunden, $Minuten,   $Stunden,   $Monatstag, $Monat,
77 58
      $Jahr,     $Wochentag, $Jahrestag, $Sommerzeit)
78 59
    = localtime(time);
79
  my $CTIME_String = localtime(time);
80 60
  $Monat     += 1;
81 61
  $Jahrestag += 1;
82 62
  $Monat     = $Monat < 10     ? $Monat     = "0" . $Monat     : $Monat;
......
88 68
                     "April",  "Mai",       "Juni",    "Juli",
89 69
                     "August", "September", "Oktober", "November",
90 70
                     "Dezember");
91
  $datum =
71
  return
92 72
      $Wochentage[$Wochentag] . ", der "
93 73
    . $Monatstag . "."
94 74
    . $Monat . "."
95 75
    . $Jahr . " - ";
96

  
97
  #$zeit="<div id='Uhr'>".$Stunden.":".$Minuten.":".$Sekunden."</div>";
98
  $zeit = "<div id='Uhr'>" . $Stunden . ":" . $Minuten . "</div>";
99
  print qq|
100
<script type="text/javascript">
101
<!--
102
function clockon() {
103
  var now = new Date();
104
  var h = now.getHours();
105
  var m = now.getMinutes();
106
  document.getElementById('clock_id').innerHTML = (h<10?'0'+h:h)+":"+(m<10?'0'+m:m);
107
  var timer=setTimeout("clockon()", 10000);
108
}
109
window.onload=clockon
110
//-->
111
</script>
112
<table border="0" width="100%" background="image/bg_titel.gif" cellpadding="0" cellspacing="0">
113
  <tr>
114
    <td style="color:white; font-family:verdana,arial,sans-serif; font-size: 12px;"> &nbsp; $fenster &nbsp; [<a href="JavaScript:top.main_window.print()">drucken</a>]</td>
115
    <td align="right" style="vertical-align:middle; color:white; font-family:verdana,arial,sans-serif; font-size: 12px;" nowrap>
116
      $login $datum <span id='clock_id' style='position:relative'></span>&nbsp;
117
    </td>
118
  </tr>
119
</table>
120
|;
121 76
}
122 77

  
123 78
sub acc_menu {
124
  $mainlevel = $form->{level};
125
  $mainlevel =~ s/\Q$mainlevel\E--//g;
126
  my $menu = new Menu "$menufile";
79
  $locale = Locale->new($language, "menu");
127 80

  
128
  $| = 1;
81
  my $mainlevel =  $form->{level};
82
  $mainlevel    =~ s/\Q$mainlevel\E--//g;
83
  my $menu      = Menu->new('menu.ini');
129 84

  
130
  print qq|
131
<style>
132
<!--
85
  $AUTOFLUSH    =  1;
133 86

  
134
.itemBorder {
135
  border: 1px solid black
136
}
87
  my $all_items = [];
88
  create_menu($menu, $all_items);
137 89

  
138
.itemText {
139
  text-decoration: none;
140
  color: #000000;
141
  font: 12px Arial, Helvetica
142
}
143

  
144
.rootItemText {
145
  text-decoration: none;
146
  color: #ffffff;
147
  font: 12px Arial, Helvetica
148
}
149

  
150
.menu {
151
  color:#ffffff;
152
  background:url(image/bg_css_menu.png) repeat bottom;
153
  border:1px solid;
154
  border-color:#ccc #888 #555 #bbb;
155
}
156

  
157
-->
158
</style>
159

  
160
<script type="text/javascript">
161
<!--
162
var isDOM = (document.getElementById ? true : false); 
163
var isIE4 = ((document.all && !isDOM) ? true : false);
164
var isNS4 = (document.layers ? true : false);
165
//var KO = (navigator.appName=="Konqueror" \|\| navigator.appName=="Opera") ;
166
var KO = ((navigator.userAgent.indexOf('Opera',0) != -1) \|\| (navigator.userAgent.indexOf('Konqueror',0) != -1));
167
function getRef(id) {
168
	if (isDOM) return document.getElementById(id);
169
	if (isIE4) return document.all[id];
170
	if (isNS4) return document.layers[id];
171
}
172
function getSty(id) {
173
	return (isNS4 ? getRef(id) : getRef(id).style);
174
} 
175
var popTimer = 0;
176
var litNow = new Array();
177
function popOver(menuNum, itemNum) {
178
	if (KO) document.getElementById("win1").style.visibility = "hidden";
179
	clearTimeout(popTimer);
180
	hideAllBut(menuNum);
181
	litNow = getTree(menuNum, itemNum);
182
	changeCol(litNow, true);
183
	targetNum = menu[menuNum][itemNum].target;
184
	if (targetNum > 0) {
185
		thisX = parseInt(menu[menuNum][0].ref.left) + parseInt(menu[menuNum][itemNum].ref.left);
186
		thisY = parseInt(menu[menuNum][0].ref.top) + parseInt(menu[menuNum][itemNum].ref.top);
187
		with (menu[targetNum][0].ref) {
188
			left = parseInt(thisX + menu[targetNum][0].x);
189
			top = parseInt(thisY + menu[targetNum][0].y);
190
			visibility = 'visible';
191
		}
192
	}
193
}
194
function popOut(menuNum, itemNum) {
195
	if ((menuNum == 0) && !menu[menuNum][itemNum].target)
196
		hideAllBut(0)
197
		if (KO) document.getElementById("win1").style.visibility = "visible";
198
	else
199
		popTimer = setTimeout('hideAllBut(0)', 500);
200
}
201
function getTree(menuNum, itemNum) {
202
	itemArray = new Array(menu.length);
203
	while(1) {
204
		itemArray[menuNum] = itemNum;
205
		if (menuNum == 0) return itemArray;
206
		itemNum = menu[menuNum][0].parentItem;
207
		menuNum = menu[menuNum][0].parentMenu;
208
	}
209
}
210
function changeCol(changeArray, isOver) {
211
	for (menuCount = 0; menuCount < changeArray.length; menuCount++) {
212
		if (changeArray[menuCount]) {
213
			newCol = isOver ? menu[menuCount][0].overCol : menu[menuCount][0].backCol;
214
			with (menu[menuCount][changeArray[menuCount]].ref) {
215
				if (isNS4) bgColor = newCol;
216
				else backgroundColor = newCol;
217
			}
218
		}
219
	}
220
}
221
function hideAllBut(menuNum) {
222
	var keepMenus = getTree(menuNum, 1);
223
	for (count = 0; count < menu.length; count++)
224
		if (!keepMenus[count])
225
			menu[count][0].ref.visibility = 'hidden';
226
	changeCol(litNow, false);
227
}
90
  my $item = { 'subitems' => $all_items };
91
  calculate_width($item);
228 92

  
229
function Menu(isVert, popInd, x, y, width, overCol, backCol, borderClass, textClass) {
230
	this.isVert = isVert;
231
	this.popInd = popInd
232
	this.x = x;
233
	this.y = y;
234
	this.width = width;
235
	this.overCol = overCol;
236
	this.backCol = backCol;
237
	this.borderClass = borderClass;
238
	this.textClass = textClass;
239
	this.parentMenu = null;
240
	this.parentItem = null;
241
	this.ref = null;
242
}
243
function Item(text, href, frame, length, spacing, target) {
244
	this.text = text;
245
	this.href = href;
246
	this.frame = frame;
247
	this.length = length;
248
	this.spacing = spacing;
249
	this.target = target;
250
	this.ref = null;
93
  return $all_items;
251 94
}
252
function go(link,frame) {
253
	tmp=eval("top."+frame);
254
	tmp.location=link;
255
        //top.main_window.location=link;
256
}
257
function writeMenus() {
258
	if (!isDOM && !isIE4 && !isNS4) return;
259
	for (currMenu = 0; currMenu < menu.length; currMenu++) with (menu[currMenu][0]) {
260
		var str = '', itemX = 0, itemY = 0;
261
		for (currItem = 1; currItem < menu[currMenu].length; currItem++) with (menu[currMenu][currItem]) {
262
			var itemID = 'menu' + currMenu + 'item' + currItem;
263
			var w = (isVert ? width : length);
264
			var h = (isVert ? length : width);
265
			if (isDOM \|\| isIE4) {
266
				str += '<div id="' + itemID + '" style="position: absolute; left: ' + itemX + '; top: ' + itemY + '; width: ' + w + '; height: ' + h + '; visibility: inherit; ';
267
				if (backCol) str += 'background: ' + backCol + '; ';
268
				str += '" ';
269
			}
270
			if (isNS4) {
271
				str += '<layer id="' + itemID + '" left="' + itemX + '" top="' + itemY + '" width="' +  w + '" height="' + h + '" visibility="inherit" ';
272
				if (backCol) str += 'bgcolor="' + backCol + '" ';
273
			}
274
			if (borderClass) str += 'class="' + borderClass + '" "';
275
			str += 'onMouseOver="popOver(' + currMenu + ',' + currItem + ')" onMouseOut="popOut(' + currMenu + ',' + currItem + ')">';
276
			str += '<table width="' + (w - 8) + '" border="0" cellspacing="0" cellpadding="' + (!isNS4 && borderClass ? 3 : 0) + '">';
277
			str +='<tr><td class="' + textClass + '" style="cursor:pointer;" align="left" height="' + (h - 7) + '" onClick=\\'go("' + href + '","' + frame + '")\\'>' + text + '</a></td>';
278
			if (target > 0) {
279
				menu[target][0].parentMenu = currMenu;
280
				menu[target][0].parentItem = currItem;
281
				if (popInd) str += '<td class="' + textClass + '" align="right">' + popInd + '</td>';
282
			}
283
			str += '</tr></table>' + (isNS4 ? '</layer>' : '</div>');
284
			if (isVert) itemY += length + spacing;
285
			else itemX += length + spacing;
286
		}
287
		if (isDOM) {
288
			var newDiv = document.createElement('div');
289
			document.getElementsByTagName('body').item(0).appendChild(newDiv);
290
			newDiv.innerHTML = str;
291
			ref = newDiv.style;
292
			ref.position = 'absolute';
293
			ref.visibility = 'hidden';
294
		}
295
		if (isIE4) {
296
			document.body.insertAdjacentHTML('beforeEnd', '<div id="menu' + currMenu + 'div" ' + 'style="position: absolute; visibility: hidden">' + str + '</div>');
297
			ref = getSty('menu' + currMenu + 'div');
298
		}
299
		if (isNS4) {
300
			ref = new Layer(0);
301
			ref.document.write(str);
302
			ref.document.close();
303
		}
304
		for (currItem = 1; currItem < menu[currMenu].length; currItem++) {
305
			itemName = 'menu' + currMenu + 'item' + currItem;
306
			if (isDOM \|\| isIE4) menu[currMenu][currItem].ref = getSty(itemName);
307
			if (isNS4) menu[currMenu][currItem].ref = ref.document[itemName];
308
		}
309
	}
310
	with(menu[0][0]) {
311
		ref.left = x;
312
		ref.top = y;
313
		ref.visibility = 'visible';
314
   }
315
}
316
var menu = new Array();
317
var defOver = '#cccccc';
318
var defBack = '#dddddd';
319
var defLength = 22;
320
menu[0] = new Array();
321
menu[0][0] = new Menu(false, '', 5, 18, 19, '#cccccc', '', '', 'rootItemText');
322 95

  
323
|;
96
sub calculate_width {
97
  my $item           = shift;
324 98

  
325
  &section_menu($menu);
99
  $item->{max_width} = max map { length $_->{title} } @{ $item->{subitems} };
326 100

  
327
  print qq|
328
var popOldWidth = window.innerWidth;
329
nsResizeHandler = new Function('if (popOldWidth != window.innerWidth) location.reload()');
330
if (isNS4) document.captureEvents(Event.CLICK);
331
document.onclick = clickHandle;
332
function clickHandle(evt) {
333
	if (isNS4) document.routeEvent(evt);
334
	hideAllBut(0);
335
	if (KO) document.getElementById("win1").style.visibility = "visible";
336
}
337
function moveRoot() {
338
	with(menu[0][0].ref) left = ((parseInt(left) < 100) ? 100 : 5);
101
  foreach my $subitem (@{ $item->{subitems} }) {
102
    calculate_width($subitem) if ($subitem->{subitems});
103
  }
339 104
}
340
//  End -->
341
</script>
342 105

  
343
<BODY scrolling="no" topmargin="0" leftmargin="0"  marginwidth="0" marginheight="0" style="margin: 0" onLoad="writeMenus(); clockon();" onResize="if (isNS4) nsResizeHandler()">
106
sub create_menu {
107
  my ($menu, $all_items, $parent, $depth) = @_;
108
  my $html;
344 109

  
110
  die if ($depth * 1 > 5);
345 111

  
346
<table class="menu" width="100%" border="0" cellpadding="0" cellspacing="0">
347
<tr><td height="21"><font size="1"> </font></td></tr></table>
112
  my @menuorder  = $menu->access_control(\%myconfig, $parent);
113
  $parent       .= "--" if ($parent);
348 114

  
115
  foreach my $name (@menuorder) {
116
    substr($name, 0, length($parent), "");
117
    next if (($name eq "") || ($name =~ /--/));
349 118

  
350
|;
119
    my $menu_item = $menu->{"${parent}${name}"};
120
    my $item      = { 'title' => $locale->text($name) };
121
    push @{ $all_items }, $item;
351 122

  
352
  print qq|
353
  
354
|;
123
    if ($menu_item->{submenu} || !defined($menu_item->{module}) || ($menu_item->{module} eq "menu.pl")) {
124
      $item->{subitems} = [];
125
      create_menu($menu, $item->{subitems}, "${parent}${name}", $depth * 1 + 1);
355 126

  
356
}
357

  
358
sub section_menu {
359
  my ($menu, $level) = @_;
360

  
361
  # build tiered menus
362
  my @menuorder = $menu->access_control(\%myconfig, $level);
363
  $main = 0;
364

  
365
  #$pm=0;
366
  $shlp=0;
367
  while (@menuorder) {
368
    $item  = shift @menuorder;
369
    $label = $item;
370
    $ml    = $item;
371
    $label =~ s/\Q$level\E--//g;
372
    $ml    =~ s/--.*//;
373
    $label = $locale->text($label);
374
    $label =~ s/ /&nbsp;/g;
375
    $menu->{$item}{target} = "main_window" unless $menu->{$item}{target};
376

  
377
    if ($menu->{$item}{submenu}) {
378
      $menu->{$item}{$item} = !$form->{$item};
379

  
380
      # Untermen
381
      if ($mlz{"s$ml"} > 1) { 
382
		$z++; 
383
		$sm = 1; 
384
      } else { 
385
		$z = $sm; 
386
		$mlz{"s$ml"}++; 
387
      }
388
      print
389
        qq|menu[$mlz{$ml}][$z] = new Item('$label', '#', '', defLength, 0, |
390
        . ++$pm
391
        . qq|);\n|;
392
      $sm = 1;
393
      print qq|menu[$pm] = new Array();\n|;
394
      print
395
        qq|menu[$pm][0] = new Menu(true, '', 85, 0, 180, defOver, defBack, 'itemBorder', 'itemText');\n|;
396
      map { shift @menuorder } grep /^$item/, @menuorder;
397
      &section_menu($menu, $item);
398
      map { shift @menuorder } grep /^$item/, @menuorder;
399 127
    } else {
400
      if ($menu->{$item}{module}) {
401

  
402
        #Untermen?punkte
403
        $target = $menu->{$item}{target};
404
        $uri    = $menu->menuitemNew(\%myconfig, \%$form, $item, $level);
405

  
406
        #print qq|<tr><td class="hover" height="13" >$spacer<img src="image/unterpunkt.png"  style="vertical-align:text-top">|.$menu->menuitem(\%myconfig, \%$form, $item, $level).qq|$label</a></td></tr>\n|;
407
        print
408
          qq|menu[$pm][$sm] = new Item('$label', '$uri', '$target', defLength, 0, 0);\n|;
409
        $sm++;
410
      } else {    # Hauptmenu
411
        my $ml_ = $form->escape($ml);
412
        $mm++;
413
        $pm++;
414
        %mlz   = ($ml, $pm, "s$ml", 1);
415
        $shlp = $sm;
416
        $sm    = 1;
417
        $breit = 15 + length($label) * 6;
418
        print
419
          qq|menu[0][$mm] = new Item('  $label', '#', '', $breit, 10, $pm);	\n|;
420
        print qq|menu[$pm] = new Array();\n|;
421
        print
422
          qq|menu[$pm][0] = new Menu(true, '>', 0, 20, 180, defOver, defBack, 'itemBorder', 'itemText');\n|;
423

  
424
        #print qq|<tr><td class="bg" height="22" align="left" valign="middle" ><img src="image/$item.png" style="vertical-align:middle">&nbsp;<a href="menu.pl?action=acc_menu&level=$ml_" class="nohover">$label</a>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>\n|;
425
        &section_menu($menu, $item);
426

  
427
        #print qq|<br>\n|;
428
      }
128
      $menu->menuitem_new("${parent}${name}", $item);
429 129
    }
430 130
  }
431 131
}

Auch abrufbar als: Unified diff