source: branches/1.2/contactcenter/js/menu.js @ 2

Revision 2, 39.1 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1function Menu(label) {
2    this.version = "020903 [Menu; menu.js]";
3    this.type = "Menu";
4    this.fontSize = 14;
5    this.fontWeight = "plain";
6    this.fontFamily = "arial,helvetica,espy,sans-serif";
7    this.fontColor = "#000000";
8    this.fontColorHilite = "#ffffff";
9    this.bgColor = "#555555";
10    this.menuBorder = 1;
11    this.menuItemBorder = 1;
12    this.menuItemBgColor = "#cccccc";
13    this.menuLiteBgColor = "#ffffff";
14    this.menuBorderBgColor = "#777777";
15    this.menuHiliteBgColor = "#000084";
16    this.menuContainerBgColor = "#cccccc";
17    this.childMenuIcon = "images/arrows.gif";
18    this.childMenuIconHilite = "images/arrows2.gif";
19    this.items = new Array();
20    this.actions = new Array();
21    this.colors = new Array();
22    this.mouseovers = new Array();
23    this.mouseouts = new Array();
24    this.childMenus = new Array();
25
26    this.addMenuItem = addMenuItem;
27    this.addMenuSeparator = addMenuSeparator;
28    this.writeMenus = writeMenus;
29    this.showMenu = showMenu;
30    this.onMenuItemOver = onMenuItemOver;
31    this.onMenuItemOut = onMenuItemOut;
32    this.onMenuItemDown = onMenuItemDown;
33    this.onMenuItemAction = onMenuItemAction;
34    this.hideMenu = hideMenu;
35    //this.hideChildMenu = hideChildMenu;
36    this.mouseTracker = mouseTracker;
37    this.setMouseTracker = setMouseTracker;
38
39    if (!window.menus) window.menus = new Array();
40    this.label = label || "menuLabel" + window.menus.length;
41    window.menus[this.label] = this;
42    window.menus[window.menus.length] = this;
43    if (!window.activeMenus) window.activeMenus = new Array();
44    if (!window.menuContainers) window.menuContainers = new Array();
45    if (!window.mDrag) {
46        window.mDrag    = new Object();
47        //mDrag.startMenuDrag = startMenuDrag;
48        //mDrag.doMenuDrag    = doMenuDrag;
49        this.setMouseTracker();
50    }
51    if (window.MenuAPI) MenuAPI(this);
52}
53
54function addMenuItem(label, action, color, mouseover, mouseout) {
55    this.items[this.items.length] = label;
56    this.actions[this.actions.length] = action;
57    this.colors[this.colors.length] = color;
58    this.mouseovers[this.mouseovers.length] = mouseover;
59    this.mouseouts[this.mouseouts.length] = mouseout;
60}
61
62function addMenuSeparator() {
63    this.items[this.items.length] = "separator";
64    this.actions[this.actions.length] = "";
65    this.menuItemBorder = 0;
66}
67
68function writeMenus(container) {
69    if (!container && document.layers) {
70        if (eval("document.width"))
71            container = new Layer(1000);
72    } else if (!container && document.all) {
73        if (!document.all["menuContainer"])
74            document.writeln('<SPAN ID="menuContainer"></SPAN>');
75        container = document.all["menuContainer"];
76    }else if (!container && document.getElementById) {
77      if (!document.getElementById("menuContainer")){
78        container = document.createElement("span");
79                container.id="menuContainer"
80            document.body.appendChild(container);
81          }
82    }
83               
84    if (!container && !window.delayWriteMenus) {
85        window.delayWriteMenus = this.writeMenus;
86        window.menuContainerBgColor = this.menuContainerBgColor;
87        setTimeout('delayWriteMenus()', 3000);
88        return;
89    }
90    container.isContainer = "menuContainer" + menuContainers.length;
91    menuContainers[menuContainers.length] = container;
92    container.menus = new Array();
93    for (var i=0; i<window.menus.length; i++)
94        container.menus[i] = window.menus[i];
95    window.menus.length = 0;
96    var countMenus = 0;
97    var countItems = 0;
98    var top = 0;
99    var content = '';
100    var proto;
101    for (var i=0; i<container.menus.length; i++, countMenus++) {
102        var menu = container.menus[i];
103        proto = menu.prototypeStyles || this.prototypeStyles || menu;
104        content += ''+
105        '<DIV ID="menuLayer'+ countMenus +'" STYLE="cursor:hand;position:absolute;left:10px;top:'+ (i * 100) +'px;visibility:hidden;">\n'+
106        '  <DIV ID="menuLite'+ countMenus +'" STYLE="cursor:hand;position:absolute;left:'+ proto.menuBorder +'px;top:'+ proto.menuBorder +'px;visibility:hide;" onMouseOut="hideMenu(event);">\n'+
107        '    <DIV ID="menuFg'+ countMenus +'" STYLE="cursor:hand;position:absolute;left:1px;top:1px;visibility:hide;">\n'+
108        '';
109        var x=i;
110        for (var i=0; i<menu.items.length; i++) {
111            var item = menu.items[i];
112            var childMenu = false;
113            var defaultHeight = 20;
114            var defaultIndent = 15;
115            if (item.label) {
116                item = item.label;
117                childMenu = true;
118            } else if (item.indexOf(".gif") != -1 && item.indexOf("<IMG") == -1) {
119                item = '<IMG SRC="' + item + '" NAME="menuItem'+ countItems +'Img">';
120                defaultIndent = 0;
121                if (document.layers) {
122                    defaultHeight = null;
123                }
124            }
125            proto.menuItemHeight = proto.menuItemHeight || defaultHeight;
126            proto.menuItemIndent = proto.menuItemIndent || defaultIndent;
127            var itemProps = 'visibility:hide;font-Family:' + proto.fontFamily +';font-Weight:' + proto.fontWeight + ';fontSize:' + proto.fontSize + ';';
128            if (document.getElementById || document.all)
129                itemProps += 'font-size:' + proto.fontSize + ';" onMouseOver="onMenuItemOver(event,this);" onMouseOut="onMenuItemOut(event,this);" onClick="onMenuItemAction(event,this);';
130            var dTag    = '<DIV  class="menuItemText" ID="menuItem'+ countItems +'" STYLE="cursor:hand;position:absolute;left:0;top:'+ (i * proto.menuItemHeight) +';'+ itemProps +'">';
131            var dText   = '<DIV ID="menuItemText'+ countItems +'" STYLE="cursor:hand;position:absolute;left:' + proto.menuItemIndent + 'px;top:0;color:'+ proto.fontColor +';">'+ item +'</DIV>\n<DIV ID="menuItemHilite'+ countItems +'" STYLE="cursor:hand;position:absolute;left:' + proto.menuItemIndent + 'px;top:0;color:'+ proto.fontColorHilite +';visibility:hidden;">'+ item +'</DIV>';
132            if (item == "separator") {
133                content += ( dTag + '<DIV ID="menuSeparator'+ countItems +'" STYLE="position:absolute;left:1;top:2;"></DIV>\n<DIV ID="menuSeparatorLite'+ countItems +'" STYLE="position:absolute;left:1;top:2;"></DIV>\n</DIV>');
134            } else if (childMenu) {
135                content += ( dTag + dText + '<DIV ID="childMenu'+ countItems +'" STYLE="cursor:hand;position:absolute;left:0;top:3;'+ itemProps +'"><IMG SRC="'+ proto.childMenuIcon +'"></DIV>\n</DIV>');
136            } else {
137                content += ( dTag + dText + '</DIV>');
138            }
139            countItems++;
140        }
141        content += '      <DIV ID="focusItem'+ countMenus +'" STYLE="cursor:hand;position:absolute;left:0;top:0;visibility:hide;" onClick="onMenuItemAction(null,this);">&nbsp;</DIV>\n';
142        content += '   </DIV>\n  </DIV>\n</DIV>\n';
143        i=x;
144    }
145    if (!container) return;
146    if (container.innerHTML) {
147        container.innerHTML=content;
148    } else {
149        if (document.getElementById && !document.all)
150          container.innerHTML=content;         
151                else{
152          container.document.open("text/html");
153          container.document.writeln(content);
154          container.document.close();
155                } 
156    }
157    proto = null;
158    if (document.layers) {
159        container.clip.width = window.innerWidth;
160        container.clip.height = window.innerHeight;
161        container.onmouseout = this.hideMenu;
162        container.menuContainerBgColor = this.menuContainerBgColor;
163        for (var i=0; i<container.document.layers.length; i++) {
164            proto = container.menus[i].prototypeStyles || this.prototypeStyles || container.menus[i];
165            var menu = container.document.layers[i];
166            container.menus[i].menuLayer = menu;
167            container.menus[i].menuLayer.Menu = container.menus[i];
168            container.menus[i].menuLayer.Menu.container = container;
169            var body = menu.document.layers[0].document.layers[0];
170            body.clip.width = proto.menuWidth || body.clip.width;
171            body.clip.height = proto.menuHeight || body.clip.height;
172            for (var n=0; n<body.document.layers.length-1; n++) {
173                var l = body.document.layers[n];
174                l.Menu = container.menus[i];
175                l.menuHiliteBgColor = proto.menuHiliteBgColor;
176                l.document.bgColor = proto.menuItemBgColor;
177                l.saveColor = proto.menuItemBgColor;
178                l.mouseout  = l.Menu.mouseouts[n];
179                l.mouseover = l.Menu.mouseovers[n];
180                l.onmouseover = proto.onMenuItemOver;
181                l.onclick = proto.onMenuItemAction;
182                l.action = container.menus[i].actions[n];
183                l.focusItem = body.document.layers[body.document.layers.length-1];
184                l.clip.width = proto.menuItemWidth || body.clip.width + proto.menuItemIndent;
185                l.clip.height = proto.menuItemHeight || l.clip.height;
186                if (n>0) l.top = body.document.layers[n-1].top + body.document.layers[n-1].clip.height + proto.menuItemBorder;
187                l.hilite = l.document.layers[1];
188                l.document.layers[1].isHilite = true;
189                if (l.document.layers[0].id.indexOf("menuSeparator") != -1) {
190                    l.hilite = null;
191                    l.clip.height -= l.clip.height / 2;
192                    l.document.layers[0].document.bgColor = proto.bgColor;
193                    l.document.layers[0].clip.width = l.clip.width -2;
194                    l.document.layers[0].clip.height = 1;
195                    l.document.layers[1].document.bgColor = proto.menuLiteBgColor;
196                    l.document.layers[1].clip.width = l.clip.width -2;
197                    l.document.layers[1].clip.height = 1;
198                    l.document.layers[1].top = l.document.layers[0].top + 1;
199                } else if (l.document.layers.length > 2) {
200                    l.childMenu = container.menus[i].items[n].menuLayer;
201                    l.icon = proto.childMenuIcon;
202                    l.iconHilite = proto.childMenuIconHilite;
203                    l.document.layers[2].left = l.clip.width -13;
204                    l.document.layers[2].top = (l.clip.height / 2) -4;
205                    l.document.layers[2].clip.left += 3;
206                    l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
207                }
208            }
209            body.document.bgColor = proto.bgColor;
210            body.clip.width  = l.clip.width +1;
211            body.clip.height = l.top + l.clip.height +1;
212            body.document.layers[n].clip.width = body.clip.width;
213            body.document.layers[n].captureEvents(Event.MOUSEDOWN);
214            body.document.layers[n].onmousedown = proto.onMenuItemDown;
215            //body.document.layers[n].onfocus = proto.onMenuItemDown;
216            body.document.layers[n].onmouseout = proto.onMenuItemOut;
217            body.document.layers[n].Menu = l.Menu;
218            body.document.layers[n].top = -30;
219            menu.document.bgColor = proto.menuBorderBgColor;
220            menu.document.layers[0].document.bgColor = proto.menuLiteBgColor;
221            menu.document.layers[0].clip.width = body.clip.width +1;
222            menu.document.layers[0].clip.height = body.clip.height +1;
223            menu.clip.width = body.clip.width + (proto.menuBorder * 2) +1;
224            menu.clip.height = body.clip.height + (proto.menuBorder * 2) +1;
225            if (menu.Menu.enableTracker) {
226                menu.Menu.disableHide = true;
227                //setMenuTracker(menu.Menu);
228            }
229        }
230    } else if (document.all) {
231        var menuCount = 0;
232        for (var x=0; x<container.menus.length; x++) {
233            var menu = container.document.all("menuLayer" + x);
234            container.menus[x].menuLayer = menu;
235            container.menus[x].menuLayer.Menu = container.menus[x];
236            container.menus[x].menuLayer.Menu.container = menu;
237            proto = container.menus[x].prototypeStyles || this.prototypeStyles || container.menus[x];
238            proto.menuItemWidth = proto.menuItemWidth || 200;
239            menu.style.backgroundColor = proto.menuBorderBgColor;
240            for (var i=0; i<container.menus[x].items.length; i++) {
241                var l = container.document.all["menuItem" + menuCount];
242                l.Menu = container.menus[x];
243                proto = container.menus[x].prototypeStyles || this.prototypeStyles || container.menus[x];
244                l.style.pixelWidth = proto.menuItemWidth;
245                l.style.pixelHeight = proto.menuItemHeight;
246                if (i>0) l.style.pixelTop = container.document.all["menuItem" + (menuCount -1)].style.pixelTop + container.document.all["menuItem" + (menuCount -1)].style.pixelHeight + proto.menuItemBorder;
247                l.style.fontSize = proto.fontSize;
248                l.style.backgroundColor = proto.menuItemBgColor;
249                l.style.visibility = "inherit";
250                l.saveColor = proto.menuItemBgColor;
251                l.menuHiliteBgColor = proto.menuHiliteBgColor;
252                l.action = container.menus[x].actions[i];
253                l.hilite = container.document.all["menuItemHilite" + menuCount];
254                l.focusItem = container.document.all["focusItem" + x];
255                l.focusItem.style.pixelTop = -30;
256                l.mouseover = l.Menu.mouseovers[x];
257                l.mouseout  = l.Menu.mouseouts[x];
258                var childItem = container.document.all["childMenu" + menuCount];
259                if (childItem) {
260                    l.childMenu = container.menus[x].items[i].menuLayer;
261                    childItem.style.pixelLeft = l.style.pixelWidth -11;
262                    childItem.style.pixelTop = (l.style.pixelHeight /2) -4;
263                    childItem.style.pixelWidth = 30 || 7;
264                    childItem.style.clip = "rect(0 7 7 3)";
265                    l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
266                }
267                var sep = container.document.all["menuSeparator" + menuCount];
268                if (sep) {
269                    sep.style.clip = "rect(0 " + (proto.menuItemWidth - 3) + " 1 0)";
270                    sep.style.backgroundColor = proto.bgColor;
271                    sep = container.document.all["menuSeparatorLite" + menuCount];
272                    sep.style.clip = "rect(1 " + (proto.menuItemWidth - 3) + " 2 0)";
273                    sep.style.backgroundColor = proto.menuLiteBgColor;
274                    l.style.pixelHeight = proto.menuItemHeight/2;
275                    l.isSeparator = true
276                }
277                menuCount++;
278            }
279            proto.menuHeight = (l.style.pixelTop + l.style.pixelHeight);
280            var lite = container.document.all["menuLite" + x];
281            lite.style.pixelHeight = proto.menuHeight +2;
282            lite.style.pixelWidth = proto.menuItemWidth + 2;
283            lite.style.backgroundColor = proto.menuLiteBgColor;
284            var body = container.document.all["menuFg" + x];
285            body.style.pixelHeight = proto.menuHeight + 1;
286            body.style.pixelWidth = proto.menuItemWidth + 1;
287            body.style.backgroundColor = proto.bgColor;
288            container.menus[x].menuLayer.style.pixelWidth  = proto.menuWidth || proto.menuItemWidth + (proto.menuBorder * 2) +2;
289            container.menus[x].menuLayer.style.pixelHeight = proto.menuHeight + (proto.menuBorder * 2) +2;
290            if (menu.Menu.enableTracker) {
291                menu.Menu.disableHide = true;
292                //setMenuTracker(menu.Menu);
293            }
294        }
295        container.document.all("menuContainer").style.backgroundColor = container.menus[0].menuContainerBgColor;
296        container.document.saveBgColor = container.document.bgColor;
297    }else if (document.getElementById) {
298        var menuCount = 0;
299        for (var x=0; x<container.menus.length; x++) {
300            var menu = document.getElementById("menuLayer" + x);
301            container.menus[x].menuLayer = menu;
302            container.menus[x].menuLayer.Menu = container.menus[x];
303            container.menus[x].menuLayer.Menu.container = menu;
304            proto = container.menus[x].prototypeStyles || this.prototypeStyles || container.menus[x];
305            proto.menuItemWidth = proto.menuItemWidth || 200;
306            menu.style.backgroundColor = proto.menuBorderBgColor;
307            var l = document.getElementById("menuItem" + menuCount)
308
309            for (var i=0; i<container.menus[x].items.length; i++) {
310                l = document.getElementById("menuItem" + menuCount);
311                l.Menu = container.menus[x];
312                proto = container.menus[x].prototypeStyles || this.prototypeStyles || container.menus[x];               
313                l.style.width = proto.menuItemWidth + "px";
314                l.style.height = proto.menuItemHeight + "px";
315                if (i>0) l.style.top = (parseInt(document.getElementById("menuItem" + (menuCount -1)).style.top,10) + parseInt(document.getElementById("menuItem" + (menuCount -1)).style.height,10) + proto.menuItemBorder) + "px";
316                l.style.fontSize = proto.fontSize;
317                l.style.backgroundColor = proto.menuItemBgColor;
318                l.style.visibility = "inherit";
319                l.saveColor = proto.menuItemBgColor;
320                l.menuHiliteBgColor = proto.menuHiliteBgColor;
321                l.action = container.menus[x].actions[i];
322                l.hilite = document.getElementById("menuItemHilite" + menuCount);
323                l.focusItem = document.getElementById("focusItem" + x);
324                l.focusItem.style.top = -30 + "px";
325                               
326                l.mouseover = l.Menu.mouseovers[x];
327                l.mouseout  = l.Menu.mouseouts[x];
328                var childItem = document.getElementById("childMenu" + menuCount);
329                if (childItem) {
330                    l.childMenu = container.menus[x].items[i].menuLayer;
331                    childItem.style.left = (l.style.width -11) + "px";
332                    childItem.style.top = ((l.style.height /2) -4) + "px";
333                    childItem.style.width = (30 || 7) + "px";
334                    childItem.style.clip = "rect(0px 7px 7px 3px)";
335                    l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
336                }
337                var sep = document.getElementById("menuSeparator" + menuCount);
338                if (sep) {
339                    sep.style.clip = "rect(0 " + (proto.menuItemWidth - 3) + "px 1px 0)";
340                    sep.style.backgroundColor = proto.bgColor;
341                    sep = document.getElementById("menuSeparatorLite" + menuCount);
342                    sep.style.clip = "rect(1px " + (proto.menuItemWidth - 3) + "px 2px 0)";
343                    sep.style.backgroundColor = proto.menuLiteBgColor;
344                    l.style.height = (proto.menuItemHeight/2) + "px" ;
345                    l.isSeparator = true
346                }
347                menuCount++;
348            }
349            proto.menuHeight = (parseInt(l.style.top,10) + parseInt(l.style.height,10));
350            var lite = document.getElementById("menuLite" + x);
351            lite.style.height = (proto.menuHeight +2) + "px";
352            lite.style.width = (proto.menuItemWidth + 2) + "px";
353            lite.style.backgroundColor = proto.menuLiteBgColor;
354            var body = document.getElementById("menuFg" + x);
355            body.style.height = (proto.menuHeight + 1) + "px";
356            body.style.width = (proto.menuItemWidth + 1) + "px";
357            body.style.backgroundColor = proto.bgColor;
358
359            container.menus[x].menuLayer.style.width  = (proto.menuWidth || proto.menuItemWidth + (proto.menuBorder * 2) +2) + "px";
360            container.menus[x].menuLayer.style.height = (proto.menuHeight + (proto.menuBorder * 2) +2) + "px";
361            if (menu.Menu.enableTracker) {
362                menu.Menu.disableHide = true;
363                //setMenuTracker(menu.Menu);
364            }
365        }
366        document.getElementById("menuContainer").style.backgroundColor = container.menus[0].menuContainerBgColor;
367        container.saveBgColor = container.bgColor;
368    }   
369    window.wroteMenu = true;
370}
371
372function onMenuItemOver(e, l, a) {
373    l = l || this;
374    a = a || window.ActiveMenuItem;
375    if (document.layers) {
376        if (a) {
377            a.document.bgColor = a.saveColor;
378            if (a.hilite) a.hilite.visibility = "hidden";
379            if (a.childMenu) a.document.layers[1].document.images[0].src = a.icon;
380        } else {
381            a = new Object();
382        }
383        if (this.mouseover && this.id != a.id) {
384            if (this.mouseover.length > 4) {
385                var ext = this.mouseover.substring(this.mouseover.length-4);
386                if (ext == ".gif" || ext == ".jpg") {
387                    this.document.layers[1].document.images[0].src = this.mouseover;
388                } else {
389                    eval("" + this.mouseover);
390                }
391            }
392        }
393        if (l.hilite) {
394            l.document.bgColor = l.menuHiliteBgColor;
395            l.zIndex = 1;
396            l.hilite.visibility = "inherit";
397            l.hilite.zIndex = 2;
398            l.document.layers[1].zIndex = 1;
399            l.focusItem.zIndex = this.zIndex +2;
400        }
401        l.focusItem.top = this.top;
402        //l.Menu.hideChildMenu(l);
403    } else if (document.all && l.style && l.Menu) {
404        document.onmousedown=l.Menu.onMenuItemDown;
405        if (a) {
406            a.style.backgroundColor = a.saveColor;
407            if (a.hilite) a.hilite.style.visibility = "hidden";
408        } else {
409            a = new Object();
410                }
411        if (l.mouseover && l.id != a.id) {
412            if (l.mouseover.length > 4) {
413                var ext = l.mouseover.substring(l.mouseover.length-4);
414                if (ext == ".gif" || ext == ".jpg") {
415                    l.document.images[l.id + "Img"].src = l.mouseover;
416                } else {
417                    eval("" + l.mouseover);
418                }
419            }
420        }
421                if (l.isSeparator) return;
422        l.style.backgroundColor = l.menuHiliteBgColor;
423        if (l.hilite) {
424            l.style.backgroundColor = l.menuHiliteBgColor;
425            l.hilite.style.visibility = "inherit";
426        }
427        l.focusItem.style.pixelTop = l.style.pixelTop;
428        l.focusItem.style.zIndex = l.zIndex +1;
429        l.zIndex = 1;
430        //l.Menu.hideChildMenu(l);
431    } else if (document.getElementById){
432        document.onmousedown=l.Menu.onMenuItemDown;     
433        if (a) {
434                a.style.backgroundColor = a.saveColor;
435            if (a.hilite) a.hilite.style.visibility = "hidden";
436        } else {
437            a = new Object();
438        }
439        if (this.mouseover && this.id != a.id) {
440            if (this.mouseover.length > 4) {
441                var ext = this.mouseover.substring(this.mouseover.length-4);
442                if (ext == ".gif" || ext == ".jpg") {
443                    document.images[l.id + "Img"].src = this.mouseover;
444                } else {
445                    eval("" + this.mouseover);
446                }
447            }
448        }
449        if (l.hilite) {
450                l.style.backgroundColor = l.menuHiliteBgColor;
451            l.hilite.style.visibility = "inherit";
452        }
453        l.focusItem.style.top = l.style.top;
454        l.focusItem.style.zIndex = l.zIndex +1;
455        l.zIndex = 1;
456        //l.Menu.hideChildMenu(l);
457        }               
458    window.ActiveMenuItem = l;
459}
460
461function onMenuItemOut(e, l, a) {
462    if (!document.all && !document.layers && e.currentTarget.nodeType == 1 && e.currentTarget.tagName == 'DIV')
463      return true;
464    l = l || this;
465        a = a || window.ActiveMenuItem;
466    if (l.id.indexOf("focusItem")) {
467        if (a && l.top) {
468            l.top = -30;
469                        if (a.mouseout && a.id != l.id) {
470                                if (a.mouseout.length > 4) {
471                                        var ext = a.mouseout.substring(a.mouseout.length-4);
472                                        if (ext == ".gif" || ext == ".jpg") {
473                                                a.document.layers[1].document.images[0].src = a.mouseout;
474                                        } else {
475                                                eval("" + a.mouseout);
476                                        }
477                                }
478                        }
479        } else if (a && l.style) {
480            document.onmousedown=null;
481                        if(window.event)
482              window.event.cancelBubble=true;
483                        else
484                          e.cancelBubble=true;
485                if (l.mouseout) {
486                                if (l.mouseout.length > 4) {
487                                        var ext = l.mouseout.substring(l.mouseout.length-4);
488                                        if (ext == ".gif" || ext == ".jpg") {
489                                                l.document.images[l.id + "Img"].src = l.mouseout;
490                                        } else {
491                                                eval("" + l.mouseout);
492                                        }
493                                }
494                        }
495        }
496    }
497}
498
499function onMenuItemAction(e, l) {
500    l = window.ActiveMenuItem;
501    if (!l) return;
502//    if (!ActiveMenu.Menu.disableHide) hideActiveMenus(ActiveMenu.menuLayer);
503    if (l.action) {
504        eval("" + l.action);
505    }
506}
507
508function showMenu(menu, x, y, child) {
509    if (!window.wroteMenu) return;
510    if (document.layers) {
511        if (menu) {
512            var l = menu.menuLayer || menu;
513            if (typeof(menu) == "string") {
514                for (var n=0; n < menuContainers.length; n++) {
515                    l = menuContainers[n].menus[menu];
516                    for (var i=0; i<menuContainers[n].menus.length; i++) {
517                        if (menu == menuContainers[n].menus[i].label) l = menuContainers[n].menus[i].menuLayer;
518                        if (l) break;
519                    }
520                }
521                                if (!l) return;
522            }
523            l.Menu.container.document.bgColor = null;
524            l.left = 1;
525            l.top = 1;
526            hideActiveMenus(l);
527            if (this.visibility) l = this;
528            window.ActiveMenu = l;
529            window.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);
530            setTimeout('if(window.ActiveMenu)window.ActiveMenu.Menu.setMouseTracker();', 300);
531        } else {
532            var l = child;
533        }
534        if (!l) return;
535        for (var i=0; i<l.layers.length; i++) {               
536            if (!l.layers[i].isHilite)
537                l.layers[i].visibility = "inherit";
538            if (l.layers[i].document.layers.length > 0)
539                showMenu(null, "relative", "relative", l.layers[i]);
540        }
541        if (l.parentLayer) {
542            if (x != "relative")
543                l.parentLayer.left = x || window.pageX || 0;
544            if (l.parentLayer.left + l.clip.width > window.innerWidth)
545                l.parentLayer.left -= (l.parentLayer.left + l.clip.width - window.innerWidth);
546            if (y != "relative")
547                l.parentLayer.top = y || window.pageY || 0;
548            if (l.parentLayer.isContainer) {
549                l.Menu.xOffset = window.pageXOffset;
550                l.Menu.yOffset = window.pageYOffset;
551                l.parentLayer.clip.width = window.ActiveMenu.clip.width +2;
552                l.parentLayer.clip.height = window.ActiveMenu.clip.height +2;
553                if (l.parentLayer.menuContainerBgColor) l.parentLayer.document.bgColor = l.parentLayer.menuContainerBgColor;
554            }
555        }
556        l.visibility = "inherit";
557        if (l.Menu) l.Menu.container.visibility = "inherit";
558    } else if (document.all) {
559        var l = menu.menuLayer || menu;
560        hideActiveMenus(l);
561        if (typeof(menu) == "string") {
562            l = document.all[menu];
563            for (var n=0; n < menuContainers.length; n++) {
564                l = menuContainers[n].menus[menu];
565                for (var i=0; i<menuContainers[n].menus.length; i++) {
566                    if (menu == menuContainers[n].menus[i].label) l = menuContainers[n].menus[i].menuLayer;
567                    if (l) break;
568                }
569            }
570        }
571        window.ActiveMenu = l;
572        l.style.visibility = "inherit";
573        if (x != "relative")
574            l.style.pixelLeft = x || (window.pageX + document.body.scrollLeft) || 0;
575        if (y != "relative")
576            l.style.pixelTop = y || (window.pageY + document.body.scrollTop) || 0;
577        l.Menu.xOffset = document.body.scrollLeft;
578        l.Menu.yOffset = document.body.scrollTop;
579    } else if (document.getElementById) {
580        var l = menu.menuLayer || menu;
581        hideActiveMenus(l);
582        if (typeof(menu) == "string") {
583            l = document.getElementById(menu);
584            for (var n=0; n < menuContainers.length; n++) {
585                l = menuContainers[n].menus[menu];
586                for (var i=0; i<menuContainers[n].menus.length; i++) {
587                    if (menu == menuContainers[n].menus[i].label) l = menuContainers[n].menus[i].menuLayer;
588                    if (l) break;
589                }
590            }
591        }
592        window.ActiveMenu = l;
593        l.style.visibility = "inherit";
594        if (x != "relative")
595            l.style.left = (x || (window.pageX) || 0) + "px";
596        if (y != "relative")
597            l.style.top = (y || (window.pageY) || 0) + "px";
598        l.Menu.xOffset = document.body.scrollLeft;
599        l.Menu.yOffset = document.body.scrollTop;
600    }
601       
602    if (menu) {
603        window.activeMenus[window.activeMenus.length] = l;
604    }
605}
606
607function hideMenu(e) {
608    if (!document.all && e.currentTarget && e.currentTarget.tagName && e.currentTarget.tagName == 'DIV')
609      return true;
610         
611    var l = e || window.ActiveMenu;
612    if (!l) return true;
613    if (l.menuLayer) {
614        l = l.menuLayer;
615    } else if (this.visibility) {
616        l = this;
617    }
618    if (l.menuLayer) {
619        l = l.menuLayer;
620    }
621    var a = window.ActiveMenuItem;
622    document.saveMousemove = document.onmousemove;
623    document.onmousemove = mouseTracker;
624    if (a && document.layers) {
625        a.document.bgColor = a.saveColor;
626        a.focusItem.top = -30;
627        if (a.hilite) a.hilite.visibility = "hidden";
628        if (a.childMenu) a.document.layers[1].document.images[0].src = a.icon;
629        if (mDrag.oldX <= e.pageX+3 && mDrag.oldX >= e.pageX-3 && mDrag.oldY <= e.pageY+3 && mDrag.oldY >= e.pageY-3) {
630            if (a.action && window.ActiveMenu) setTimeout('window.ActiveMenu.Menu.onMenuItemAction();', 2);
631        }// else if (document.saveMousemove == mDrag.doMenuDrag) {
632         //   if (window.ActiveMenu) return true;
633        //}
634    } else if (window.ActiveMenu && document.all) {
635        document.onmousedown=null;
636        if (a) {
637            a.style.backgroundColor = a.saveColor;
638            if (a.hilite) a.hilite.style.visibility = "hidden";
639        }
640        //if (document.saveMousemove == mDrag.doMenuDrag) {
641        //    return true;
642        //}
643    } else if (window.ActiveMenu && document.getElementById) {
644        document.onmousedown=null;
645        if (a) {
646            a.style.backgroundColor = a.saveColor;
647            if (a.hilite) a.hilite.style.visibility = "hidden";
648        }
649        //if (document.saveMousemove == mDrag.doMenuDrag) {
650        //    return true;
651        //}
652        }               
653    if (window.ActiveMenu) {
654        if (window.ActiveMenu.Menu) {
655            if (window.ActiveMenu.Menu.disableHide) return true;
656            e = window.event || e;
657            if (!window.ActiveMenu.Menu.enableHideOnMouseOut && e.type == "mouseout") return true;
658        }
659    }
660    hideActiveMenus(l);
661    return true;
662}
663/*
664function hideChildMenu(menuLayer) {
665    var l = menuLayer || this;
666    for (var i=0; i < l.Menu.childMenus.length; i++) {
667        if (document.getElementById || document.all) {
668            l.Menu.childMenus[i].style.visibility = "hidden";
669        } else if (document.layers) {
670            l.Menu.childMenus[i].visibility = "hidden";
671        }
672        l.Menu.childMenus[i].Menu.hideChildMenu(l.Menu.childMenus[i]);
673    }
674    if (l.childMenu) {
675        if (document.layers) {
676            l.Menu.container.document.bgColor = null;
677            l.Menu.showMenu(null,null,null,l.childMenu.layers[0]);
678            l.childMenu.zIndex = l.parentLayer.zIndex +1;
679            l.childMenu.top = l.top + l.parentLayer.top + l.Menu.menuLayer.top;
680            if (l.childMenu.left + l.childMenu.clip.width > window.innerWidth) {
681                l.childMenu.left = l.parentLayer.left - l.childMenu.clip.width + l.Menu.menuLayer.top + 15;
682                l.Menu.container.clip.left -= l.childMenu.clip.width;
683            } else if (l.Menu.childMenuDirection == "left") {
684                l.childMenu.left = l.parentLayer.left - l.parentLayer.clip.width;
685                l.Menu.container.clip.left -= l.childMenu.clip.width;
686            } else {
687                l.childMenu.left = l.parentLayer.left + l.parentLayer.clip.width  + l.Menu.menuLayer.left -5;
688            }
689            l.Menu.container.clip.width += l.childMenu.clip.width +100;
690            l.Menu.container.clip.height += l.childMenu.clip.height;
691            l.document.layers[1].zIndex = 0;
692            l.document.layers[1].document.images[0].src = l.iconHilite;
693            l.childMenu.visibility = "inherit";
694        } else if (document.all) {
695            l.childMenu.style.zIndex = l.Menu.menuLayer.style.zIndex +1;
696            l.childMenu.style.pixelTop = l.style.pixelTop + l.Menu.menuLayer.style.pixelTop;
697            if (l.childMenu.style.pixelLeft + l.childMenu.style.pixelWidth > document.width) {
698                l.childMenu.style.pixelLeft = l.childMenu.style.pixelWidth + l.Menu.menuLayer.style.pixelTop + 15;
699            } else if (l.Menu.childMenuDirection == "left") {
700                //l.childMenu.style.pixelLeft = l.parentLayer.left - l.parentLayer.clip.width;
701            } else {
702                l.childMenu.style.pixelLeft = l.Menu.menuLayer.style.pixelWidth + l.Menu.menuLayer.style.pixelLeft -5;
703            }
704            l.childMenu.style.visibility = "inherit";
705        } else if (document.getElementById) {
706            l.childMenu.style.zIndex = l.Menu.menuLayer.style.zIndex +1;
707            l.childMenu.style.top = (parseInt(l.style.top,10) + parseInt(l.Menu.menuLayer.style.top, 10)) + "px";
708            if ( parseInt(l.childMenu.style.left) + parseInt(l.childMenu.style.width) > document.width) {
709                l.childMenu.style.left = (parseInt(l.childMenu.style.width,10) + parseInt(l.Menu.menuLayer.style.top,10) + 15) + "px";
710            } else if (l.Menu.childMenuDirection == "left") {
711                //l.childMenu.style.pixelLeft = l.parentLayer.left - l.parentLayer.clip.width;
712            } else {
713                l.childMenu.style.left = (parseInt(l.Menu.menuLayer.style.width,10) + parseInt(l.Menu.menuLayer.style.left,10) -5) + "px";
714            }
715            l.childMenu.style.visibility = "inherit";
716        }               
717               
718        if (!l.childMenu.disableHide)
719            window.activeMenus[window.activeMenus.length] = l.childMenu;
720    }
721}
722*/
723function hideActiveMenus(l) {
724    if (!window.activeMenus) return;
725    for (var i=0; i < window.activeMenus.length; i++) {
726    if (!activeMenus[i]) return;
727            if (document.layers && activeMenus[i].visibility && activeMenus[i].Menu) {
728            activeMenus[i].visibility = "hidden";
729            activeMenus[i].Menu.container.visibility = "hidden";
730            activeMenus[i].Menu.container.clip.left = 0;
731        } else if (activeMenus[i].style) {
732            activeMenus[i].style.visibility = "hidden";
733        }
734    }
735    document.onmousemove = mouseTracker;
736    window.activeMenus.length = 0;
737}
738
739function mouseTracker(e) {
740    e = e || window.Event || window.event;
741    window.pageX = parseInt(e.pageX,10) || e.clientX;
742    window.pageY = parseInt(e.pageY,10) || e.clientY;
743}
744
745function setMouseTracker() {
746    if (document.captureEvents) {
747        document.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
748    }
749    document.onmousemove = this.mouseTracker;
750    document.onmouseup = this.hideMenu;
751}
752/*
753function setMenuTracker(menu) {
754    if (!window.menuTrackers) window.menuTrackers = new Array();
755    menuTrackers[menuTrackers.length] = menu;
756    window.menuTrackerID = setInterval('menuTracker()',10);
757}
758
759function menuTracker() {
760    for (var i=0; i < menuTrackers.length; i++) {
761        if (!isNaN(menuTrackers[i].xOffset) && document.layers) {
762            var off = parseInt((menuTrackers[i].xOffset - window.pageXOffset) / 10);
763            if (isNaN(off)) off = 0;
764            if (off < 0) {
765                menuTrackers[i].container.left += -off;
766                menuTrackers[i].xOffset += -off;
767            } else if (off > 0) {
768                menuTrackers[i].container.left += -off;
769                menuTrackers[i].xOffset += -off;
770            }
771        }
772        if (!isNaN(menuTrackers[i].yOffset) && document.layers) {
773            var off = parseInt((menuTrackers[i].yOffset - window.pageYOffset) / 10);
774            if (isNaN(off)) off = 0;
775            if (off < 0) {
776                menuTrackers[i].container.top += -off;
777                menuTrackers[i].yOffset += -off;
778            } else if (off > 0) {
779                menuTrackers[i].container.top += -off;
780                menuTrackers[i].yOffset += -off;
781            }
782        }
783        if (!isNaN(menuTrackers[i].xOffset) && document.body) {
784            var off = parseInt((menuTrackers[i].xOffset - document.body.scrollLeft) / 10);
785            if (isNaN(off)) off = 0;
786            if (off < 0) {
787                menuTrackers[i].menuLayer.style.pixelLeft += -off;
788                menuTrackers[i].xOffset += -off;
789            } else if (off > 0) {
790                menuTrackers[i].menuLayer.style.pixelLeft += -off;
791                menuTrackers[i].xOffset += -off;
792            }
793        }
794        if (!isNaN(menuTrackers[i].yOffset) && document.body) {
795            var off = parseInt((menuTrackers[i].yOffset - document.body.scrollTop) / 10);
796            if (isNaN(off)) off = 0;
797            if (off < 0) {
798                menuTrackers[i].menuLayer.style.pixelTop += -off;
799                menuTrackers[i].yOffset += -off;
800            } else if (off > 0) {
801                menuTrackers[i].menuLayer.style.pixelTop += -off;
802                menuTrackers[i].yOffset += -off;
803            }
804        }
805    }
806}
807*/
808function onMenuItemDown(e, l) {
809    l = l || window.ActiveMenuItem || this;
810    if (!l.Menu) {
811    } else {
812        if (document.layers) {
813            mDrag.dragLayer = l.Menu.container;
814            //mDrag.startMenuDrag(e);
815            document.captureEvents(Event.MOUSEMOVE);                   
816        } else if (document.all) {
817            mDrag.dragLayer = l.Menu.container.style;
818            //mDrag.startMenuDrag(e);
819            window.event.cancelBubble=true;
820        } else if (document.getElementById) {
821            mDrag.dragLayer = l.Menu.container.style;
822            //mDrag.startMenuDrag(e);
823            document.captureEvents(Event.MOUSEMOVE);                   
824        }
825        var x = !document.all? e.pageX : window.event.clientX;
826        var y = !document.all? e.pageY : window.event.clientY;
827   
828    }
829}
830/*
831function startMenuDrag(e) {
832    if (document.layers) {
833        if (e.which > 1) {
834            if (window.ActiveMenu) ActiveMenu.Menu.container.visibility = "hidden";
835            window.ActiveMenu = null;
836            return true;
837        }
838        document.captureEvents(Event.MOUSEMOVE);
839        var x = e.pageX;
840        var y = e.pageY;
841    } else if (document.all) {
842        var x = window.event.clientX;
843        var y = window.event.clientY;
844    } else if (document.getElementById) {
845        if (e.which > 1) {
846            if (window.ActiveMenu) ActiveMenu.Menu.container.visibility = "hidden";
847            window.ActiveMenu = null;
848            return true;
849        }
850        document.captureEvents(Event.MOUSEMOVE);
851        var x = e.pageX;
852        var y = e.pageY;
853    }
854       
855    mDrag.offX = x;
856    mDrag.offY = y;
857    mDrag.oldX = x;
858    mDrag.oldY = y;
859    if (!ActiveMenu.Menu.disableDrag) document.onmousemove = mDrag.doMenuDrag;
860    return false;
861}
862
863function doMenuDrag(e) {
864    if (document.layers) {
865        mDrag.dragLayer.moveBy(e.pageX-mDrag.offX,e.pageY-mDrag.offY);
866        mDrag.offX = e.pageX;
867        mDrag.offY = e.pageY;
868    } else if(document.all) {
869        mDrag.dragLayer.pixelLeft = window.event.offsetX;
870        mDrag.dragLayer.pixelTop  = window.event.offsetY;
871        return false; //for IE
872    } else if (document.getElementById){
873//    alert(mDrag.dragLayer.left)
874        mDrag.dragLayer.left = e.pageX + "px";
875        mDrag.dragLayer.top  = e.pageY  + "px";
876        }
877}*/
Note: See TracBrowser for help on using the repository browser.