~ubuntu-branches/ubuntu/natty/ntop/natty

« back to all changes in this revision

Viewing changes to html/JSCookMenu.js

  • Committer: Bazaar Package Importer
  • Author(s): Ludovico Cavedon, Jordan Metzmeier, Ludovico Cavedon
  • Date: 2010-12-15 20:06:19 UTC
  • mfrom: (5.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20101215200619-0ojz3iak95ihibun
Tags: 3:4.0.3+dfsg1-1
[ Jordan Metzmeier ]
* New upstream release (Closes: #522042)
* Move data files to /usr/share/ntop (Closes: #595450).
* Package architecture independent data in a separate ntop-data package.
* Use debhelper 7.
* Update Standards-Version to 3.9.1.
* Depend on python-mako.
* Do not include ntop.txt in binary packages as it is a copy of the man
  page.
* Do not include NEWS, as it is outdated.
* Switch to package source version 3.0 (quilt).
* Add password creation to debconf
* Changed init script to fix localization problems (thanks to Alejandro
  Varas <alej0varas@gmail.com>, LP: #257466)
* Remove manual update-rc.d calls from postrm and postinst. debhelper adds
  this for us.
* Add pre-depends on adduser for postinst script.
* Fix errors in the manpages: fix-manpage-errors.patch.
* Added fixes for matching active interfaces.
* Added a watch file.

[ Ludovico Cavedon ]
* Remove direct changes to upstream tree, and move them into specific patch
  files:
  - fix-manpage-errors.patch: fix typos in ntop.8.
  - dot-path.patch: fix path of /usr/bin/dot executable
* Add patches:
  - reduce-autogen-purged-files.patch: prevent agutogen.sh from reamoving
  too many files during cleanup.
  - Add build-without-ntop-darwin.patch, to fix compilation without
  ntop_darwin.c.
* No longer add faq.html, as it is not distributed in the upstream tarball.
* Use ${source:Version} in control file. Have ntop-data recommend
  ntop.
* Rename dirs to ntop.dirs and keep only empty directories that need
  to be created.
* Remove var/lib from ntop.install file, as it is empty (keeping it in
  ntop.dirs).
* Update po files.
* Breaks and Replaces instead of Conflitcs for ntop-data.
* Use a longer package description.
* Remove useless configure options from debian/rules.
* Move private shared libraries libraries in /usr/lib/ntop.
* Add change-plugin-dir.patch for adjusting plugin directory.
* Remove development files.
* Use system library for MochiKit.js.
* Rewrite DEP5 copyright file.
* Repackage upstream tarball in order to remove non-DFSG-compliant code. Add
  get-orig-source.sh script and get-orig-source target in debian/rules.
* Add explanation to README.Debian why geolocation is no longer working.
* Add avoid-copy-maxmind-db.patch to prevent copying of Geo*.dat
  files.
* Remove old unused patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
        JSCookMenu v1.31.  (c) Copyright 2002-2005 by Heng Yuan
 
2
        JSCookMenu v2.0.4 (c) Copyright 2002-2006 by Heng Yuan
 
3
 
 
4
        http://jscook.sourceforge.net/JSCookMenu/
3
5
 
4
6
        Permission is hereby granted, free of charge, to any person obtaining a
5
7
        copy of this software and associated documentation files (the "Software"),
20
22
        DEALINGS IN THE SOFTWARE.
21
23
*/
22
24
 
23
 
// Globals
24
 
var _cmIDCount = 0;
25
 
var _cmIDName = 'cmSubMenuID';          // for creating submenu id
26
 
 
27
 
var _cmTimeOut = null;                  // how long the menu would stay
28
 
var _cmCurrentItem = null;              // the current menu item being selected;
29
 
 
30
 
var _cmNoAction = new Object ();        // indicate that the item cannot be hovered.
31
 
var _cmNoClick = new Object ();         // similar to _cmNoAction but does not respond to mouseup/mousedown events
32
 
var _cmSplit = new Object ();           // indicate that the item is a menu split
33
 
 
34
 
var _cmItemList = new Array ();         // a simple list of items
35
 
 
36
25
// default node properties
37
26
var _cmNodeProperties =
38
27
{
 
28
        // theme prefix
 
29
        prefix: '',
 
30
 
39
31
        // main menu display attributes
40
32
        //
41
33
        // Note.  When the menu bar is horizontal,
51
43
        // HTML code to the left of the regular item
52
44
        mainItemLeft: '',
53
45
        // HTML code to the right of the regular item
54
 
        mainItemRight: '',
 
46
        mainItemRight:  '',
55
47
 
56
48
        // sub menu display attributes
57
49
 
58
50
        // HTML code to the left of the folder item
59
 
        folderLeft: '',
 
51
        folderLeft:             '',
60
52
        // HTML code to the right of the folder item
61
 
        folderRight: '',
 
53
        folderRight:    '',
62
54
        // HTML code to the left of the regular item
63
 
        itemLeft: '',
 
55
        itemLeft:               '',
64
56
        // HTML code to the right of the regular item
65
 
        itemRight: '',
 
57
        itemRight:              '',
66
58
        // cell spacing for main menu
67
 
        mainSpacing: 0,
 
59
        mainSpacing:    0,
68
60
        // cell spacing for sub menus
69
 
        subSpacing: 0,
 
61
        subSpacing:             0,
 
62
 
 
63
        // optional settings
 
64
        // If not set, use the default
 
65
 
70
66
        // auto disappear time for submenus in milli-seconds
71
 
        delay: 500
 
67
        delay:                  500,
 
68
 
 
69
        // 1st layer sub menu starting index
 
70
        zIndexStart:    1000,
 
71
        // z-index incremental step for subsequent layers
 
72
        zIndexInc:              5,
 
73
 
 
74
        // sub menu header appears before the sub menu table
 
75
        subMenuHeader:  null,
 
76
        // sub menu header appears after the sub menu table
 
77
        subMenuFooter:  null,
 
78
 
 
79
        // submenu location adjustments
 
80
        //
 
81
        // offsetHMainAdjust for adjusting the first submenu
 
82
        //              of a 'hbr' menu.
 
83
        // offsetVMainAdjust for adjusting the first submenu
 
84
        //              of a 'vbr' menu.
 
85
        // offsetSubAdjust for subsequent level of submenus
 
86
        //
 
87
        offsetHMainAdjust:      [0, 0],
 
88
        offsetVMainAdjust:      [0, 0],
 
89
        offsetSubAdjust:        [0, 0],
 
90
 
 
91
        // act on click to open sub menu
 
92
        // not yet implemented
 
93
        // 0 : use default behavior
 
94
        // 1 : hover open in all cases
 
95
        // 2 : click on main, hover on sub
 
96
        // 3 : click open in all cases (illegal as of 1.5)
 
97
        clickOpen:              1,
 
98
 
 
99
        // special effects on open/closing a sub menu
 
100
        effect:                 null
72
101
};
73
102
 
 
103
// Globals
 
104
var _cmIDCount = 0;
 
105
var _cmIDName = 'cmSubMenuID';          // for creating submenu id
 
106
 
 
107
var _cmTimeOut = null;                          // how long the menu would stay
 
108
var _cmCurrentItem = null;                      // the current menu item being selected;
 
109
 
 
110
var _cmNoAction = new Object ();        // indicate that the item cannot be hovered.
 
111
var _cmNoClick = new Object ();         // similar to _cmNoAction but does not respond to mouseup/mousedown events
 
112
var _cmSplit = new Object ();           // indicate that the item is a menu split
 
113
 
 
114
var _cmMenuList = new Array ();         // a list of the current menus
 
115
var _cmItemList = new Array ();         // a simple list of items
 
116
 
 
117
var _cmFrameList = new Array ();        // a pool of reusable iframes
 
118
var _cmFrameListSize = 0;                       // keep track of the actual size
 
119
var _cmFrameIDCount = 0;                        // keep track of the frame id
 
120
var _cmFrameMasking = true;                     // use the frame masking
 
121
 
 
122
// disable iframe masking for IE7
 
123
/*@cc_on
 
124
        @if (@_jscript_version >= 5.6)
 
125
                if (_cmFrameMasking)
 
126
                {
 
127
                        var v = navigator.appVersion;
 
128
                        var i = v.indexOf ("MSIE ");
 
129
                        if (i >= 0)
 
130
                        {
 
131
                                if (parseInt (navigator.appVersion.substring (i + 5)) >= 7)
 
132
                                        _cmFrameMasking = false;
 
133
                        }
 
134
                }
 
135
        @end
 
136
@*/
 
137
 
 
138
var _cmClicked = false;                         // for onClick
 
139
 
 
140
// flag for turning on off hiding objects
 
141
//
 
142
// 0: automatic
 
143
// 1: hiding
 
144
// 2: no hiding
 
145
var _cmHideObjects = 0;
 
146
 
 
147
// Utility function to do a shallow copy a node property
 
148
function cmClone (nodeProperties)
 
149
{
 
150
        var returnVal = new Object ();
 
151
        for (v in nodeProperties)
 
152
                returnVal[v] = nodeProperties[v];
 
153
        return returnVal;
 
154
}
 
155
 
 
156
//
 
157
// store the new menu information into a structure to retrieve it later
 
158
//
 
159
function cmAllocMenu (id, menu, orient, nodeProperties, prefix)
 
160
{
 
161
        var info = new Object ();
 
162
        info.div = id;
 
163
        info.menu = menu;
 
164
        info.orient = orient;
 
165
        info.nodeProperties = nodeProperties;
 
166
        info.prefix = prefix;
 
167
        var menuID = _cmMenuList.length;
 
168
        _cmMenuList[menuID] = info;
 
169
        return menuID;
 
170
}
 
171
 
 
172
//
 
173
// request a frame
 
174
//
 
175
function cmAllocFrame ()
 
176
{
 
177
        if (_cmFrameListSize > 0)
 
178
                return cmGetObject (_cmFrameList[--_cmFrameListSize]);
 
179
        var frameObj = document.createElement ('iframe');
 
180
        var id = _cmFrameIDCount++;
 
181
        frameObj.id = 'cmFrame' + id;
 
182
        frameObj.frameBorder = '0';
 
183
        frameObj.style.display = 'none';
 
184
        frameObj.src = 'javascript:false';
 
185
        document.body.appendChild (frameObj);
 
186
        frameObj.style.filter = 'alpha(opacity=0)';
 
187
        frameObj.style.zIndex = 99;
 
188
        frameObj.style.position = 'absolute';
 
189
        frameObj.style.border = '0';
 
190
        frameObj.scrolling = 'no';
 
191
        return frameObj;
 
192
}
 
193
 
 
194
//
 
195
// make a frame resuable later
 
196
//
 
197
function cmFreeFrame (frameObj)
 
198
{
 
199
        _cmFrameList[_cmFrameListSize++] = frameObj.id;
 
200
}
 
201
 
74
202
//////////////////////////////////////////////////////////////////////
75
203
//
76
204
// Drawing Functions and Utility Functions
88
216
//
89
217
// return the property string for the menu item
90
218
//
91
 
function cmActionItem (item, prefix, isMain, idSub, orient, nodeProperties)
 
219
function cmActionItem (item, isMain, idSub, menuInfo, menuID)
92
220
{
93
 
        // var index = _cmItemList.push (item) - 1;
94
221
        _cmItemList[_cmItemList.length] = item;
95
222
        var index = _cmItemList.length - 1;
96
223
        idSub = (!idSub) ? 'null' : ('\'' + idSub + '\'');
97
 
        orient = '\'' + orient + '\'';
98
 
        prefix = '\'' + prefix + '\'';
99
 
        return ' onmouseover="cmItemMouseOver (this,' + prefix + ',' + isMain + ',' + idSub + ',' + orient + ',' + index + ')" onmouseout="cmItemMouseOut (this,' + nodeProperties.delay + ')" onmousedown="cmItemMouseDown (this,' + index + ')" onmouseup="cmItemMouseUp (this,' + index + ')"';
 
224
 
 
225
        var clickOpen = menuInfo.nodeProperties.clickOpen;
 
226
        var onClick = (clickOpen == 3) || (clickOpen == 2 && isMain);
 
227
 
 
228
        var param = 'this,' + isMain + ',' + idSub + ',' + menuID + ',' + index;
 
229
 
 
230
        var returnStr;
 
231
        if (onClick)
 
232
                returnStr = ' onmouseover="cmItemMouseOver(' + param + ',false)" onmousedown="cmItemMouseDownOpenSub (' + param + ')"';
 
233
        else
 
234
                returnStr = ' onmouseover="cmItemMouseOverOpenSub (' + param + ')" onmousedown="cmItemMouseDown (' + param + ')"';
 
235
        return returnStr + ' onmouseout="cmItemMouseOut (' + param + ')" onmouseup="cmItemMouseUp (' + param + ')"';
100
236
}
101
237
 
102
238
//
103
239
// this one is used by _cmNoClick to only take care of onmouseover and onmouseout
104
240
// events which are associated with menu but not actions associated with menu clicking/closing
105
241
//
106
 
function cmNoClickItem (item, prefix, isMain, idSub, orient, nodeProperties)
 
242
function cmNoClickItem (item, isMain, idSub, menuInfo, menuID)
107
243
{
108
244
        // var index = _cmItemList.push (item) - 1;
109
245
        _cmItemList[_cmItemList.length] = item;
110
246
        var index = _cmItemList.length - 1;
111
247
        idSub = (!idSub) ? 'null' : ('\'' + idSub + '\'');
112
 
        orient = '\'' + orient + '\'';
113
 
        prefix = '\'' + prefix + '\'';
114
 
        return ' onmouseover="cmItemMouseOver (this,' + prefix + ',' + isMain + ',' + idSub + ',' + orient + ',' + index + ')" onmouseout="cmItemMouseOut (this,' + nodeProperties.delay + ')"';
 
248
 
 
249
        var param = 'this,' + isMain + ',' + idSub + ',' + menuID + ',' + index;
 
250
 
 
251
        return ' onmouseover="cmItemMouseOver (' + param + ')" onmouseout="cmItemMouseOut (' + param + ')"';
115
252
}
116
253
 
117
 
function cmNoActionItem (item, prefix)
 
254
function cmNoActionItem (item)
118
255
{
119
256
        return item[1];
120
257
}
132
269
        }
133
270
        else
134
271
                classStr += 'HSplit';
135
 
        var item = eval (classStr);
136
 
        return cmNoActionItem (item, prefix);
 
272
        return eval (classStr);
137
273
}
138
274
 
139
275
//
140
276
// draw the sub menu recursively
141
277
//
142
 
function cmDrawSubMenu (subMenu, prefix, id, orient, nodeProperties)
 
278
function cmDrawSubMenu (subMenu, prefix, id, nodeProperties, zIndexStart, menuInfo, menuID)
143
279
{
144
 
        var str = '<div class="' + prefix + 'SubMenu" id="' + id + '"><table summary="sub menu" cellspacing="' + nodeProperties.subSpacing + '" class="' + prefix + 'SubMenuTable">';
 
280
        var str = '<div class="' + prefix + 'SubMenu" id="' + id + '" style="z-index: ' + zIndexStart + ';position: absolute; top: 0px; left: 0px;">';
 
281
        if (nodeProperties.subMenuHeader)
 
282
                str += nodeProperties.subMenuHeader;
 
283
 
 
284
        str += '<table summary="sub menu" id="' + id + 'Table" cellspacing="' + nodeProperties.subSpacing + '" class="' + prefix + 'SubMenuTable">';
 
285
 
145
286
        var strSub = '';
146
287
 
147
288
        var item;
158
299
                if (!item)
159
300
                        continue;
160
301
 
 
302
                if (item == _cmSplit)
 
303
                        item = cmSplitItem (prefix, 0, true);
 
304
                item.parentItem = subMenu;
 
305
                item.subMenuID = id;
 
306
 
161
307
                hasChild = (item.length > 5);
162
308
                idSub = hasChild ? cmNewID () : null;
163
309
 
164
310
                str += '<tr class="' + prefix + 'MenuItem"';
165
311
                if (item[0] != _cmNoClick)
166
 
                        str += cmActionItem (item, prefix, 0, idSub, orient, nodeProperties);
 
312
                        str += cmActionItem (item, 0, idSub, menuInfo, menuID);
167
313
                else
168
 
                        str += cmNoClickItem (item, prefix, 0, idSub, orient, nodeProperties);
169
 
                str += '>'
170
 
 
171
 
                if (item == _cmSplit)
172
 
                {
173
 
                        str += cmSplitItem (prefix, 0, true);
174
 
                        str += '</tr>';
175
 
                        continue;
176
 
                }
 
314
                        str += cmNoClickItem (item, 0, idSub, menuInfo, menuID);
 
315
                str += '>';
177
316
 
178
317
                if (item[0] == _cmNoAction || item[0] == _cmNoClick)
179
318
                {
180
 
                        str += cmNoActionItem (item, prefix);
 
319
                        str += cmNoActionItem (item);
181
320
                        str += '</tr>';
182
321
                        continue;
183
322
                }
192
331
                else
193
332
                        str += hasChild ? nodeProperties.folderLeft : nodeProperties.itemLeft;
194
333
 
195
 
                str += '<td class="' + classStr + 'Text">' + item[1];
 
334
                str += '</td><td class="' + classStr + 'Text">' + item[1];
196
335
 
197
 
                str += '<td class="' + classStr + 'Right">';
 
336
                str += '</td><td class="' + classStr + 'Right">';
198
337
 
199
338
                if (hasChild)
200
339
                {
201
340
                        str += nodeProperties.folderRight;
202
 
                        strSub += cmDrawSubMenu (item, prefix, idSub, orient, nodeProperties);
 
341
                        strSub += cmDrawSubMenu (item, prefix, idSub, nodeProperties, zIndexStart + nodeProperties.zIndexInc, menuInfo, menuID);
203
342
                }
204
343
                else
205
344
                        str += nodeProperties.itemRight;
206
345
                str += '</td></tr>';
207
346
        }
208
347
 
209
 
        str += '</table></div>' + strSub;
 
348
        str += '</table>';
 
349
 
 
350
        if (nodeProperties.subMenuFooter)
 
351
                str += nodeProperties.subMenuFooter;
 
352
        str += '</div>' + strSub;
210
353
        return str;
211
354
}
212
355
 
213
356
//
214
357
// The function that builds the menu inside the specified element id.
215
358
//
216
 
// @param       id      id of the element
217
 
//              orient  orientation of the menu in [hv][ab][lr] format
218
 
//              menu    the menu object to be drawn
219
 
//              nodeProperties  properties for each menu node
 
359
// id                           id of the element
 
360
// orient                       orientation of the menu in [hv][ub][lr] format
 
361
// menu                         the menu object to be drawn
 
362
// nodeProperties       properties for the theme
 
363
// prefix                       prefix of the theme
220
364
//
221
365
function cmDraw (id, menu, orient, nodeProperties, prefix)
222
366
{
223
367
        var obj = cmGetObject (id);
224
368
 
 
369
        if (!prefix)
 
370
                prefix = nodeProperties.prefix;
 
371
        if (!prefix)
 
372
                prefix = '';
225
373
        if (!nodeProperties)
226
374
                nodeProperties = _cmNodeProperties;
227
 
        if (!prefix)
228
 
                prefix = '';
229
 
 
230
 
        var str = '<table summary="main menu" class="' + prefix + 'Menu" cellspacing="' + nodeProperties.mainSpacing + '">';
231
 
        var strSub = '';
232
 
 
233
375
        if (!orient)
234
376
                orient = 'hbr';
235
377
 
236
 
        var orientStr = String (orient);
237
 
        var orientSub;
 
378
        var menuID = cmAllocMenu (id, menu, orient, nodeProperties, prefix);
 
379
        var menuInfo = _cmMenuList[menuID];
 
380
 
 
381
        // setup potentially missing properties
 
382
        if (!nodeProperties.delay)
 
383
                nodeProperties.delay = _cmNodeProperties.delay;
 
384
        if (!nodeProperties.clickOpen)
 
385
                nodeProperties.clickOpen = _cmNodeProperties.clickOpen;
 
386
        if (!nodeProperties.zIndexStart)
 
387
                nodeProperties.zIndexStart = _cmNodeProperties.zIndexStart;
 
388
        if (!nodeProperties.zIndexInc)
 
389
                nodeProperties.zIndexInc = _cmNodeProperties.zIndexInc;
 
390
        if (!nodeProperties.offsetHMainAdjust)
 
391
                nodeProperties.offsetHMainAdjust = _cmNodeProperties.offsetHMainAdjust;
 
392
        if (!nodeProperties.offsetVMainAdjust)
 
393
                nodeProperties.offsetVMainAdjust = _cmNodeProperties.offsetVMainAdjust;
 
394
        if (!nodeProperties.offsetSubAdjust)
 
395
                nodeProperties.offsetSubAdjust = _cmNodeProperties.offsetSubAdjust;
 
396
        // save user setting on frame masking
 
397
        menuInfo.cmFrameMasking = _cmFrameMasking;
 
398
 
 
399
        var str = '<table summary="main menu" class="' + prefix + 'Menu" cellspacing="' + nodeProperties.mainSpacing + '">';
 
400
        var strSub = '';
 
401
 
238
402
        var vertical;
239
403
 
240
404
        // draw the main menu items
241
 
        if (orientStr.charAt (0) == 'h')
 
405
        if (orient.charAt (0) == 'h')
242
406
        {
243
 
                // horizontal menu
244
 
                orientSub = 'v' + orientStr.substr (1, 2);
245
407
                str += '<tr>';
246
408
                vertical = false;
247
409
        }
248
410
        else
249
411
        {
250
 
                // vertical menu
251
 
                orientSub = 'v' + orientStr.substr (1, 2);
252
412
                vertical = true;
253
413
        }
254
414
 
266
426
                if (!item)
267
427
                        continue;
268
428
 
 
429
                item.menu = menu;
 
430
                item.subMenuID = id;
 
431
 
269
432
                str += vertical ? '<tr' : '<td';
270
433
                str += ' class="' + prefix + 'MainItem"';
271
434
 
272
435
                hasChild = (item.length > 5);
273
436
                idSub = hasChild ? cmNewID () : null;
274
437
 
275
 
                str += cmActionItem (item, prefix, 1, idSub, orient, nodeProperties) + '>';
 
438
                str += cmActionItem (item, 1, idSub, menuInfo, menuID) + '>';
276
439
 
277
440
                if (item == _cmSplit)
278
 
                {
279
 
                        str += cmSplitItem (prefix, 1, vertical);
280
 
                        str += vertical? '</tr>' : '</td>';
281
 
                        continue;
282
 
                }
 
441
                        item = cmSplitItem (prefix, 1, vertical);
283
442
 
284
443
                if (item[0] == _cmNoAction || item[0] == _cmNoClick)
285
444
                {
286
 
                        str += cmNoActionItem (item, prefix);
 
445
                        str += cmNoActionItem (item);
287
446
                        str += vertical? '</tr>' : '</td>';
288
447
                        continue;
289
448
                }
313
472
                str += vertical ? '</tr>' : '</td>';
314
473
 
315
474
                if (hasChild)
316
 
                        strSub += cmDrawSubMenu (item, prefix, idSub, orientSub, nodeProperties);
 
475
                        strSub += cmDrawSubMenu (item, prefix, idSub, nodeProperties, nodeProperties.zIndexStart, menuInfo, menuID);
317
476
        }
318
477
        if (!vertical)
319
478
                str += '</tr>';
320
479
        str += '</table>' + strSub;
321
480
        obj.innerHTML = str;
322
 
        //document.write ("<xmp>" + str + "</xmp>");
 
481
}
 
482
 
 
483
//
 
484
// The function builds the menu inside the specified element id.
 
485
//
 
486
// This function is similar to cmDraw except that menu is taken from HTML node
 
487
// rather a javascript tree.  This feature allows links to be scanned by search
 
488
// bots.
 
489
//
 
490
// This function basically converts HTML node to a javascript tree, and then calls
 
491
// cmDraw to draw the actual menu, replacing the hidden menu tree.
 
492
//
 
493
// Format:
 
494
//      <div id="menu">
 
495
//              <ul style="visibility: hidden">
 
496
//                      <li><span>icon</span><a href="link" title="description">main menu text</a>
 
497
//                              <ul>
 
498
//                                      <li><span>icon</span><a href="link" title="description">submenu item</a>
 
499
//                                      </li>
 
500
//                              </ul>
 
501
//                      </li>
 
502
//              </ul>
 
503
//      </div>
 
504
//
 
505
function cmDrawFromText (id, orient, nodeProperties, prefix)
 
506
{
 
507
        var domMenu = cmGetObject (id);
 
508
        var menu = null;
 
509
        for (var currentDomItem = domMenu.firstChild; currentDomItem; currentDomItem = currentDomItem.nextSibling)
 
510
        {
 
511
                if (!currentDomItem.tagName)
 
512
                        continue;
 
513
                var tag = currentDomItem.tagName.toLowerCase ();
 
514
                if (tag != 'ul' && tag != 'ol')
 
515
                        continue;
 
516
                menu = cmDrawFromTextSubMenu (currentDomItem);
 
517
                break;
 
518
        }
 
519
        if (menu)
 
520
                cmDraw (id, menu, orient, nodeProperties, prefix);
 
521
}
 
522
 
 
523
//
 
524
// a recursive function that build menu tree structure
 
525
//
 
526
function cmDrawFromTextSubMenu (domMenu)
 
527
{
 
528
        var items = new Array ();
 
529
        for (var currentDomItem = domMenu.firstChild; currentDomItem; currentDomItem = currentDomItem.nextSibling)
 
530
        {
 
531
                if (!currentDomItem.tagName || currentDomItem.tagName.toLowerCase () != 'li')
 
532
                        continue;
 
533
                if (currentDomItem.firstChild == null)
 
534
                {
 
535
                        items[items.length] = _cmSplit;
 
536
                        continue;
 
537
                }
 
538
                var item = new Array ();
 
539
                var currentItem = currentDomItem.firstChild;
 
540
                var hasAction = false;
 
541
                for (; currentItem; currentItem = currentItem.nextSibling)
 
542
                {
 
543
                        // scan for span or div tag
 
544
                        if (!currentItem.tagName)
 
545
                                continue;
 
546
                        if (currentItem.className == 'cmNoClick')
 
547
                        {
 
548
                                item[0] = _cmNoClick;
 
549
                                item[1] = getActionHTML (currentItem);
 
550
                                hasAction = true;
 
551
                                break;
 
552
                        }
 
553
                        if (currentItem.className == 'cmNoAction')
 
554
                        {
 
555
                                item[0] = _cmNoAction;
 
556
                                item[1] = getActionHTML (currentItem);
 
557
                                hasAction = true;
 
558
                                break;
 
559
                        }
 
560
                        var tag = currentItem.tagName.toLowerCase ();
 
561
                        if (tag != 'span')
 
562
                                continue;
 
563
                        if (!currentItem.firstChild)
 
564
                                item[0] = null;
 
565
                        else
 
566
                                item[0] = currentItem.innerHTML;
 
567
                        currentItem = currentItem.nextSibling;
 
568
                        break;
 
569
                }
 
570
                if (hasAction)
 
571
                {
 
572
                        items[items.length] = item;
 
573
                        continue;
 
574
                }
 
575
                if (!currentItem)
 
576
                        continue;
 
577
                for (; currentItem; currentItem = currentItem.nextSibling)
 
578
                {
 
579
                        if (!currentItem.tagName)
 
580
                                continue;
 
581
                        var tag = currentItem.tagName.toLowerCase ();
 
582
                        if (tag == 'a')
 
583
                        {
 
584
                                item[1] = currentItem.innerHTML;
 
585
                                item[2] = currentItem.href;
 
586
                                item[3] = currentItem.target;
 
587
                                item[4] = currentItem.title;
 
588
                                if (item[4] == '')
 
589
                                        item[4] = null;
 
590
                        }
 
591
                        else if (tag == 'span' || tag == 'div')
 
592
                        {
 
593
                                item[1] = currentItem.innerHTML;
 
594
                                item[2] = null;
 
595
                                item[3] = null;
 
596
                                item[4] = null;
 
597
                        }
 
598
                        break;
 
599
                }
 
600
 
 
601
                for (; currentItem; currentItem = currentItem.nextSibling)
 
602
                {
 
603
                        // scan for span tag
 
604
                        if (!currentItem.tagName)
 
605
                                continue;
 
606
                        var tag = currentItem.tagName.toLowerCase ();
 
607
                        if (tag != 'ul' && tag != 'ol')
 
608
                                continue;
 
609
                        var subMenuItems = cmDrawFromTextSubMenu (currentItem);
 
610
                        for (i = 0; i < subMenuItems.length; ++i)
 
611
                                item[i + 5] = subMenuItems[i];
 
612
                        break;
 
613
                }
 
614
                items[items.length] = item;
 
615
        }
 
616
        return items;
 
617
}
 
618
 
 
619
//
 
620
// obtain the actual action item's action, which is inside a
 
621
// table.  The first row should be it
 
622
//
 
623
function getActionHTML (htmlNode)
 
624
{
 
625
        var returnVal = '<td></td><td></td><td></td>';
 
626
        var currentDomItem;
 
627
        // find the table first
 
628
        for (currentDomItem = htmlNode.firstChild; currentDomItem; currentDomItem = currentDomItem.nextSibling)
 
629
        {
 
630
                if (currentDomItem.tagName && currentDomItem.tagName.toLowerCase () == 'table')
 
631
                        break;
 
632
        }
 
633
        if (!currentDomItem)
 
634
                return returnVal;
 
635
        // skip over tbody
 
636
        for (currentDomItem = currentDomItem.firstChild; currentDomItem; currentDomItem = currentDomItem.nextSibling)
 
637
        {
 
638
                if (currentDomItem.tagName && currentDomItem.tagName.toLowerCase () == 'tbody')
 
639
                        break;
 
640
        }
 
641
        if (!currentDomItem)
 
642
                return returnVal;
 
643
        // get the first tr
 
644
        for (currentDomItem = currentDomItem.firstChild; currentDomItem; currentDomItem = currentDomItem.nextSibling)
 
645
        {
 
646
                if (currentDomItem.tagName && currentDomItem.tagName.toLowerCase () == 'tr')
 
647
                        break;
 
648
        }
 
649
        if (!currentDomItem)
 
650
                return returnVal;
 
651
        return currentDomItem.innerHTML;
 
652
}
 
653
 
 
654
//
 
655
// get the DOM object associated with the item
 
656
//
 
657
function cmGetMenuItem (item)
 
658
{
 
659
        if (!item.subMenuID)
 
660
                return null;
 
661
        var subMenu = cmGetObject (item.subMenuID);
 
662
        // we are dealing with a main menu item
 
663
        if (item.menu)
 
664
        {
 
665
                var menu = item.menu;
 
666
                // skip over table, tbody, tr, reach td
 
667
                subMenu = subMenu.firstChild.firstChild.firstChild.firstChild;
 
668
                var i;
 
669
                for (i = 0; i < menu.length; ++i)
 
670
                {
 
671
                        if (menu[i] == item)
 
672
                                return subMenu;
 
673
                        subMenu = subMenu.nextSibling;
 
674
                }
 
675
        }
 
676
        else if (item.parentItem) // sub menu item
 
677
        {
 
678
                var menu = item.parentItem;
 
679
                var table = cmGetObject (item.subMenuID + 'Table');
 
680
                if (!table)
 
681
                        return null;
 
682
                // skip over table, tbody, reach tr
 
683
                subMenu = table.firstChild.firstChild;
 
684
                var i;
 
685
                for (i = 5; i < menu.length; ++i)
 
686
                {
 
687
                        if (menu[i] == item)
 
688
                                return subMenu;
 
689
                        subMenu = subMenu.nextSibling;
 
690
                }
 
691
        }
 
692
        return null;
 
693
}
 
694
 
 
695
//
 
696
// disable a menu item
 
697
//
 
698
function cmDisableItem (item, prefix)
 
699
{
 
700
        if (!item)
 
701
                return;
 
702
        var menuItem = cmGetMenuItem (item);
 
703
        if (!menuItem)
 
704
                return;
 
705
        if (item.menu)
 
706
                menuItem.className = prefix + 'MainItemDisabled';
 
707
        else
 
708
                menuItem.className = prefix + 'MenuItemDisabled';
 
709
        item.isDisabled = true;
 
710
}
 
711
 
 
712
//
 
713
// enable a menu item
 
714
//
 
715
function cmEnableItem (item, prefix)
 
716
{
 
717
        if (!item)
 
718
                return;
 
719
        var menuItem = cmGetMenuItem (item);
 
720
        if (!menuItem)
 
721
                return;
 
722
        if (item.menu)
 
723
                menu.className = prefix + 'MainItem';
 
724
        else
 
725
                menu.className = prefix + 'MenuItem';
 
726
        item.isDisabled = false;
323
727
}
324
728
 
325
729
//////////////////////////////////////////////////////////////////////
331
735
//
332
736
// action should be taken for mouse moving in to the menu item
333
737
//
334
 
function cmItemMouseOver (obj, prefix, isMain, idSub, orient, index)
 
738
// Here we just do things concerning this menu item, w/o opening sub menus.
 
739
//
 
740
function cmItemMouseOver (obj, isMain, idSub, menuID, index, calledByOpenSub)
335
741
{
 
742
        if (!calledByOpenSub && _cmClicked)
 
743
        {
 
744
                cmItemMouseOverOpenSub (obj, isMain, idSub, menuID, index);
 
745
                return;
 
746
        }
 
747
 
336
748
        clearTimeout (_cmTimeOut);
337
749
 
338
 
        if (!obj.cmPrefix)
 
750
        if (_cmItemList[index].isDisabled)
 
751
                return;
 
752
 
 
753
        var prefix = _cmMenuList[menuID].prefix;
 
754
 
 
755
        if (!obj.cmMenuID)
339
756
        {
340
 
                obj.cmPrefix = prefix;
 
757
                obj.cmMenuID = menuID;
341
758
                obj.cmIsMain = isMain;
342
759
        }
343
760
 
363
780
        {
364
781
                // occationally, we get this case when user
365
782
                // move the mouse slowly to the border
366
 
                if (_cmCurrentItem == thisMenu)
 
783
                if (_cmCurrentItem == obj || _cmCurrentItem == thisMenu)
 
784
                {
 
785
                        var item = _cmItemList[index];
 
786
                        cmSetStatus (item);
367
787
                        return;
 
788
                }
368
789
 
369
 
                var thatPrefix = _cmCurrentItem.cmPrefix;
 
790
                var thatMenuInfo = _cmMenuList[_cmCurrentItem.cmMenuID];
 
791
                var thatPrefix = thatMenuInfo.prefix;
370
792
                var thatMenu = cmGetThisMenu (_cmCurrentItem, thatPrefix);
 
793
 
371
794
                if (thatMenu != thisMenu.cmParentMenu)
372
795
                {
373
796
                        if (_cmCurrentItem.cmIsMain)
375
798
                        else
376
799
                                _cmCurrentItem.className = thatPrefix + 'MenuItem';
377
800
                        if (thatMenu.id != idSub)
378
 
                                cmHideMenu (thatMenu, thisMenu, thatPrefix);
 
801
                                cmHideMenu (thatMenu, thisMenu, thatMenuInfo);
379
802
                }
380
803
        }
381
804
 
396
819
                        obj.className = prefix + 'MenuItemHover';
397
820
        }
398
821
 
 
822
        cmSetStatus (item);
 
823
}
 
824
 
 
825
//
 
826
// action should be taken for mouse moving in to the menu item
 
827
//
 
828
// This function also opens sub menu
 
829
//
 
830
function cmItemMouseOverOpenSub (obj, isMain, idSub, menuID, index)
 
831
{
 
832
        clearTimeout (_cmTimeOut);
 
833
 
 
834
        if (_cmItemList[index].isDisabled)
 
835
                return;
 
836
 
 
837
        cmItemMouseOver (obj, isMain, idSub, menuID, index, true);
 
838
 
399
839
        if (idSub)
400
840
        {
401
841
                var subMenu = cmGetObject (idSub);
402
 
                cmShowSubMenu (obj, prefix, subMenu, orient);
 
842
                var menuInfo = _cmMenuList[menuID];
 
843
                var orient = menuInfo.orient;
 
844
                var prefix = menuInfo.prefix;
 
845
                cmShowSubMenu (obj, isMain, subMenu, menuInfo);
403
846
        }
404
 
 
405
 
        var descript = '';
406
 
        if (item.length > 4)
407
 
                descript = (item[4] != null) ? item[4] : (item[2] ? item[2] : descript);
408
 
        else if (item.length > 2)
409
 
                descript = (item[2] ? item[2] : descript);
410
 
 
411
 
        window.defaultStatus = descript;
412
847
}
413
848
 
414
849
//
415
850
// action should be taken for mouse moving out of the menu item
416
851
//
417
 
function cmItemMouseOut (obj, delayTime)
 
852
function cmItemMouseOut (obj, isMain, idSub, menuID, index)
418
853
{
419
 
        if (!delayTime)
420
 
                delayTime = _cmNodeProperties.delay;
 
854
        var delayTime = _cmMenuList[menuID].nodeProperties.delay;
421
855
        _cmTimeOut = window.setTimeout ('cmHideMenuTime ()', delayTime);
422
856
        window.defaultStatus = '';
423
857
}
425
859
//
426
860
// action should be taken for mouse button down at a menu item
427
861
//
428
 
function cmItemMouseDown (obj, index)
 
862
function cmItemMouseDown (obj, isMain, idSub, menuID, index)
429
863
{
 
864
        if (_cmItemList[index].isDisabled)
 
865
                return;
 
866
 
430
867
        if (cmIsDefaultItem (_cmItemList[index]))
431
868
        {
 
869
                var prefix = _cmMenuList[menuID].prefix;
432
870
                if (obj.cmIsMain)
433
 
                        obj.className = obj.cmPrefix + 'MainItemActive';
 
871
                        obj.className = prefix + 'MainItemActive';
434
872
                else
435
 
                        obj.className = obj.cmPrefix + 'MenuItemActive';
 
873
                        obj.className = prefix + 'MenuItemActive';
 
874
        }
 
875
}
 
876
 
 
877
//
 
878
// action should be taken for mouse button down at a menu item
 
879
// this is one also opens submenu if needed
 
880
//
 
881
function cmItemMouseDownOpenSub (obj, isMain, idSub, menuID, index)
 
882
{
 
883
        if (_cmItemList[index].isDisabled)
 
884
                return;
 
885
 
 
886
        _cmClicked = true;
 
887
        cmItemMouseDown (obj, isMain, idSub, menuID, index);
 
888
 
 
889
        if (idSub)
 
890
        {
 
891
                var subMenu = cmGetObject (idSub);
 
892
                var menuInfo = _cmMenuList[menuID];
 
893
                cmShowSubMenu (obj, isMain, subMenu, menuInfo);
436
894
        }
437
895
}
438
896
 
439
897
//
440
898
// action should be taken for mouse button up at a menu item
441
899
//
442
 
function cmItemMouseUp (obj, index)
 
900
function cmItemMouseUp (obj, isMain, idSub, menuID, index)
443
901
{
 
902
        if (_cmItemList[index].isDisabled)
 
903
                return;
 
904
 
444
905
        var item = _cmItemList[index];
445
906
 
446
907
        var link = null, target = '_self';
452
913
 
453
914
        if (link != null)
454
915
        {
 
916
                _cmClicked = false;
455
917
                window.open (link, target);
456
918
        }
457
919
 
458
 
        var prefix = obj.cmPrefix;
 
920
        var menuInfo = _cmMenuList[menuID];
 
921
        var prefix = menuInfo.prefix;
459
922
        var thisMenu = cmGetThisMenu (obj, prefix);
460
923
 
461
924
        var hasChild = (item.length > 5);
468
931
                        else
469
932
                                obj.className = prefix + 'MenuItem';
470
933
                }
471
 
                cmHideMenu (thisMenu, null, prefix);
 
934
                cmHideMenu (thisMenu, null, menuInfo);
472
935
        }
473
936
        else
474
937
        {
491
954
//
492
955
// move submenu to the appropriate location
493
956
//
494
 
// @param       obj     the menu item that opens up the subMenu
495
 
//              subMenu the sub menu to be shown
496
 
//              orient  the orientation of the subMenu
497
 
//
498
 
function cmMoveSubMenu (obj, subMenu, orient)
 
957
function cmMoveSubMenu (obj, isMain, subMenu, menuInfo)
499
958
{
 
959
        var orient = menuInfo.orient;
 
960
 
 
961
        var offsetAdjust;
 
962
 
 
963
        if (isMain)
 
964
        {
 
965
                if (orient.charAt (0) == 'h')
 
966
                        offsetAdjust = menuInfo.nodeProperties.offsetHMainAdjust;
 
967
                else
 
968
                        offsetAdjust = menuInfo.nodeProperties.offsetVMainAdjust;
 
969
        }
 
970
        else
 
971
                offsetAdjust = menuInfo.nodeProperties.offsetSubAdjust;
 
972
 
 
973
        if (!isMain && orient.charAt (0) == 'h')
 
974
                orient = 'v' + orient.charAt (1) + orient.charAt (2);
 
975
 
500
976
        var mode = String (orient);
501
977
        var p = subMenu.offsetParent;
502
978
        var subMenuWidth = cmGetWidth (subMenu);
504
980
        if (mode.charAt (0) == 'h')
505
981
        {
506
982
                if (mode.charAt (1) == 'b')
507
 
                        subMenu.style.top = (cmGetYAt (obj, p) + cmGetHeight (obj)) + 'px';
 
983
                        subMenu.style.top = (cmGetYAt (obj, p) + cmGetHeight (obj) + offsetAdjust[1]) + 'px';
508
984
                else
509
 
                        subMenu.style.top = (cmGetYAt (obj, p) - cmGetHeight (subMenu)) + 'px';
 
985
                        subMenu.style.top = (cmGetYAt (obj, p) - cmGetHeight (subMenu) - offsetAdjust[1]) + 'px';
510
986
                if (horiz == 'r')
511
 
                        subMenu.style.left = (cmGetXAt (obj, p)) + 'px';
 
987
                        subMenu.style.left = (cmGetXAt (obj, p) + offsetAdjust[0]) + 'px';
512
988
                else
513
 
                        subMenu.style.left = (cmGetXAt (obj, p) + cmGetWidth (obj) - subMenuWidth) + 'px';
 
989
                        subMenu.style.left = (cmGetXAt (obj, p) + cmGetWidth (obj) - subMenuWidth - offsetAdjust[0]) + 'px';
514
990
        }
515
991
        else
516
992
        {
517
993
                if (horiz == 'r')
518
 
                        subMenu.style.left = (cmGetXAt (obj, p) + cmGetWidth (obj)) + 'px';
 
994
                        subMenu.style.left = (cmGetXAt (obj, p) + cmGetWidth (obj) + offsetAdjust[0]) + 'px';
519
995
                else
520
 
                        subMenu.style.left = (cmGetXAt (obj, p) - subMenuWidth) + 'px';
 
996
                        subMenu.style.left = (cmGetXAt (obj, p) - subMenuWidth - offsetAdjust[0]) + 'px';
521
997
                if (mode.charAt (1) == 'b')
522
 
                        subMenu.style.top = (cmGetYAt (obj, p)) + 'px';
 
998
                        subMenu.style.top = (cmGetYAt (obj, p) + offsetAdjust[1]) + 'px';
523
999
                else
524
 
                        subMenu.style.top = (cmGetYAt (obj, p) + cmGetHeight (obj) - cmGetHeight (subMenu)) + 'px';
 
1000
                        subMenu.style.top = (cmGetYAt (obj, p) + cmGetHeight (obj) - cmGetHeight (subMenu) + offsetAdjust[1]) + 'px';
525
1001
        }
 
1002
 
 
1003
        // IE specific iframe masking method
 
1004
        /*@cc_on
 
1005
                @if (@_jscript_version >= 5.5)
 
1006
                        if (menuInfo.cmFrameMasking)
 
1007
                        {
 
1008
                                if (!subMenu.cmFrameObj)
 
1009
                                {
 
1010
                                        var frameObj = cmAllocFrame ();
 
1011
                                        subMenu.cmFrameObj = frameObj;
 
1012
                                }
 
1013
 
 
1014
                                var frameObj = subMenu.cmFrameObj;
 
1015
                                frameObj.style.zIndex = subMenu.style.zIndex - 1;
 
1016
                                frameObj.style.left = (cmGetX (subMenu) - cmGetX (frameObj.offsetParent)) + 'px';
 
1017
                                frameObj.style.top = (cmGetY (subMenu)  - cmGetY (frameObj.offsetParent)) + 'px';
 
1018
                                frameObj.style.width = cmGetWidth (subMenu) + 'px';
 
1019
                                frameObj.style.height = cmGetHeight (subMenu) + 'px';
 
1020
                                frameObj.style.display = 'block';
 
1021
                        }
 
1022
                @end
 
1023
        @*/
 
1024
        if (horiz != orient.charAt (2))
 
1025
                orient = orient.charAt (0) + orient.charAt (1) + horiz;
 
1026
        return orient;
526
1027
}
527
1028
 
528
1029
//
572
1073
// show the subMenu w/ specified orientation
573
1074
// also move it to the correct coordinates
574
1075
//
575
 
// @param       obj     the menu item that opens up the subMenu
576
 
//              subMenu the sub menu to be shown
577
 
//              orient  the orientation of the subMenu
578
 
//
579
 
function cmShowSubMenu (obj, prefix, subMenu, orient)
 
1076
function cmShowSubMenu (obj, isMain, subMenu, menuInfo)
580
1077
{
 
1078
        var prefix = menuInfo.prefix;
 
1079
 
581
1080
        if (!subMenu.cmParentMenu)
582
1081
        {
583
1082
                // establish the tree w/ back edge
585
1084
                subMenu.cmParentMenu = thisMenu;
586
1085
                if (!thisMenu.cmSubMenu)
587
1086
                        thisMenu.cmSubMenu = new Array ();
588
 
                //thisMenu.cmSubMenu.push (subMenu);
589
1087
                thisMenu.cmSubMenu[thisMenu.cmSubMenu.length] = subMenu;
590
1088
        }
591
1089
 
592
 
        // position the sub menu
593
 
        cmMoveSubMenu (obj, subMenu, orient);
594
 
        subMenu.style.visibility = 'visible';
595
 
 
596
 
        //
597
 
        // On IE, controls such as SELECT, OBJECT, IFRAME (before 5.5)
598
 
        // are window based controls.  So, if the sub menu and these
599
 
        // controls overlap, sub menu would be hidden behind them.  Thus
600
 
        // one needs to turn the visibility of these controls off when the
601
 
        // sub menu is showing, and turn their visibility back on
602
 
        // when the sub menu is hiding.
603
 
        //
604
 
        if (document.all)       // it is IE
605
 
        {
606
 
                /* part of Felix Zaslavskiy's fix on hiding controls
607
 
                   not really sure if this part is necessary, but shouldn't
608
 
                   hurt. */
 
1090
        var effectInstance = subMenu.cmEffect;
 
1091
        if (effectInstance)
 
1092
                effectInstance.showEffect (true);
 
1093
        else
 
1094
        {
 
1095
                // position the sub menu only if we are not already showing the submenu
 
1096
                var orient = cmMoveSubMenu (obj, isMain, subMenu, menuInfo);
 
1097
                subMenu.cmOrient = orient;
 
1098
 
 
1099
                var forceShow = false;
 
1100
                if (subMenu.style.visibility != 'visible' && menuInfo.nodeProperties.effect)
 
1101
                {
 
1102
                        try
 
1103
                        {
 
1104
                                effectInstance = menuInfo.nodeProperties.effect.getInstance (subMenu, orient);
 
1105
                                effectInstance.showEffect (false);
 
1106
                        }
 
1107
                        catch (e)
 
1108
                        {
 
1109
                                forceShow = true;
 
1110
                                subMenu.cmEffect = null;
 
1111
                        }
 
1112
                }
 
1113
                else
 
1114
                        forceShow = true;
 
1115
 
 
1116
                if (forceShow)
 
1117
                {
 
1118
                        subMenu.style.visibility = 'visible';
 
1119
                        /*@cc_on
 
1120
                                @if (@_jscript_version >= 5.5)
 
1121
                                        if (subMenu.cmFrameObj)
 
1122
                                                subMenu.cmFrameObj.style.display = 'block';
 
1123
                                @end
 
1124
                        @*/
 
1125
                }
 
1126
        }
 
1127
 
 
1128
        if (!_cmHideObjects)
 
1129
        {
 
1130
                _cmHideObjects = 2;     // default = not hide, may change behavior later
 
1131
                try
 
1132
                {
 
1133
                        if (window.opera)
 
1134
                        {
 
1135
                                if (parseInt (navigator.appVersion) < 9)
 
1136
                                        _cmHideObjects = 1;
 
1137
                        }
 
1138
                }
 
1139
                catch (e)
 
1140
                {
 
1141
                }
 
1142
        }
 
1143
 
 
1144
        if (_cmHideObjects == 1)
 
1145
        {
609
1146
                if (!subMenu.cmOverlap)
610
1147
                        subMenu.cmOverlap = new Array ();
611
 
/*@cc_on @*/
612
 
/*@if (@_jscript_version >= 5.5)
613
 
@else @*/
614
1148
                cmHideControl ("IFRAME", subMenu);
615
 
/*@end @*/
616
 
                cmHideControl ("SELECT", subMenu);
617
1149
                cmHideControl ("OBJECT", subMenu);
618
1150
        }
619
1151
}
631
1163
                for (i = 0; i < items.length; ++i)
632
1164
                {
633
1165
                        if (items[i].cmIsMain)
 
1166
                        {
 
1167
                                if (items[i].className == (prefix + 'MainItemDisabled'))
 
1168
                                        continue;
 
1169
                        }
 
1170
                        else
 
1171
                        {
 
1172
                                if (items[i].className == (prefix + 'MenuItemDisabled'))
 
1173
                                        continue;
 
1174
                        }
 
1175
                        if (items[i].cmIsMain)
634
1176
                                str = prefix + 'MainItem';
635
1177
                        else
636
1178
                                str = prefix + 'MenuItem';
645
1187
//
646
1188
function cmHideMenuTime ()
647
1189
{
 
1190
        _cmClicked = false;
648
1191
        if (_cmCurrentItem)
649
1192
        {
650
 
                var prefix = _cmCurrentItem.cmPrefix;
651
 
                cmHideMenu (cmGetThisMenu (_cmCurrentItem, prefix), null, prefix);
652
 
        }
 
1193
                var menuInfo = _cmMenuList[_cmCurrentItem.cmMenuID];
 
1194
                var prefix = menuInfo.prefix;
 
1195
                cmHideMenu (cmGetThisMenu (_cmCurrentItem, prefix), null, menuInfo);
 
1196
                _cmCurrentItem = null;
 
1197
        }
 
1198
}
 
1199
 
 
1200
//
 
1201
// Only hides this menu
 
1202
//
 
1203
function cmHideThisMenu (thisMenu, menuInfo)
 
1204
{
 
1205
        var effectInstance = thisMenu.cmEffect;
 
1206
        if (effectInstance)
 
1207
                effectInstance.hideEffect (true);
 
1208
        else
 
1209
        {
 
1210
                thisMenu.style.visibility = 'hidden';
 
1211
                thisMenu.style.top = '0px';
 
1212
                thisMenu.style.left = '0px';
 
1213
                thisMenu.cmOrient = null;
 
1214
                /*@cc_on
 
1215
                        @if (@_jscript_version >= 5.5)
 
1216
                                if (thisMenu.cmFrameObj)
 
1217
                                {
 
1218
                                        var frameObj = thisMenu.cmFrameObj;
 
1219
                                        frameObj.style.display = 'none';
 
1220
                                        frameObj.style.width = '1px';
 
1221
                                        frameObj.style.height = '1px';
 
1222
                                        thisMenu.cmFrameObj = null;
 
1223
                                        cmFreeFrame (frameObj);
 
1224
                                }
 
1225
                        @end
 
1226
                @*/
 
1227
        }
 
1228
 
 
1229
        cmShowControl (thisMenu);
 
1230
        thisMenu.cmItems = null;
653
1231
}
654
1232
 
655
1233
//
657
1235
// of thisMenu until currentMenu is encountered.  currentMenu
658
1236
// will not be hidden
659
1237
//
660
 
function cmHideMenu (thisMenu, currentMenu, prefix)
 
1238
function cmHideMenu (thisMenu, currentMenu, menuInfo)
661
1239
{
 
1240
        var prefix = menuInfo.prefix;
662
1241
        var str = prefix + 'SubMenu';
663
1242
 
664
1243
        // hide the down stream menus
667
1246
                var i;
668
1247
                for (i = 0; i < thisMenu.cmSubMenu.length; ++i)
669
1248
                {
670
 
                        cmHideSubMenu (thisMenu.cmSubMenu[i], prefix);
 
1249
                        cmHideSubMenu (thisMenu.cmSubMenu[i], menuInfo);
671
1250
                }
672
1251
        }
673
1252
 
677
1256
                cmResetMenu (thisMenu, prefix);
678
1257
                if (thisMenu.className == str)
679
1258
                {
680
 
                        thisMenu.style.visibility = 'hidden';
681
 
                        cmShowControl (thisMenu);
 
1259
                        cmHideThisMenu (thisMenu, menuInfo);
682
1260
                }
683
1261
                else
684
1262
                        break;
690
1268
// hide thisMenu as well as its sub menus if thisMenu is not
691
1269
// already hidden
692
1270
//
693
 
function cmHideSubMenu (thisMenu, prefix)
 
1271
function cmHideSubMenu (thisMenu, menuInfo)
694
1272
{
695
1273
        if (thisMenu.style.visibility == 'hidden')
696
1274
                return;
699
1277
                var i;
700
1278
                for (i = 0; i < thisMenu.cmSubMenu.length; ++i)
701
1279
                {
702
 
                        cmHideSubMenu (thisMenu.cmSubMenu[i], prefix);
 
1280
                        cmHideSubMenu (thisMenu.cmSubMenu[i], menuInfo);
703
1281
                }
704
1282
        }
 
1283
        var prefix = menuInfo.prefix;
705
1284
        cmResetMenu (thisMenu, prefix);
706
 
        thisMenu.style.visibility = 'hidden';
707
 
        cmShowControl (thisMenu);
 
1285
        cmHideThisMenu (thisMenu, menuInfo);
708
1286
}
709
1287
 
710
1288
//
740
1318
                // submenu then we dont want to put it on overlap list of
741
1319
                // of a submenu a second time.
742
1320
                // - bug fixed by Felix Zaslavskiy
743
 
                if(obj.style.visibility == "hidden")
 
1321
                if(obj.style.visibility == 'hidden')
744
1322
                        continue;
745
1323
 
746
1324
                //subMenu.cmOverlap.push (obj);
747
1325
                subMenu.cmOverlap[subMenu.cmOverlap.length] = obj;
748
 
                obj.style.visibility = "hidden";
 
1326
                obj.style.visibility = 'hidden';
749
1327
        }
750
1328
}
751
1329
 
781
1359
}
782
1360
 
783
1361
//
 
1362
// A special effect function to hook the menu which contains
 
1363
// special effect object to the timer.
 
1364
//
 
1365
function cmTimeEffect (menuID, show, delayTime)
 
1366
{
 
1367
        window.setTimeout ('cmCallEffect("' + menuID + '",' + show + ')', delayTime);
 
1368
}
 
1369
 
 
1370
//
 
1371
// A special effect function.  Called by timer.
 
1372
//
 
1373
function cmCallEffect (menuID, show)
 
1374
{
 
1375
        var menu = cmGetObject (menuID);
 
1376
        if (!menu || !menu.cmEffect)
 
1377
                return;
 
1378
        try
 
1379
        {
 
1380
                if (show)
 
1381
                        menu.cmEffect.showEffect (false);
 
1382
                else
 
1383
                        menu.cmEffect.hideEffect (false);
 
1384
        }
 
1385
        catch (e)
 
1386
        {
 
1387
        }
 
1388
}
 
1389
 
 
1390
//
784
1391
// return true if this item is handled using default handlers
785
1392
//
786
1393
function cmIsDefaultItem (item)
836
1443
//
837
1444
function cmGetX (obj)
838
1445
{
 
1446
        if (!obj)
 
1447
                return 0;
839
1448
        var x = 0;
840
1449
 
841
1450
        do
863
1472
 
864
1473
function cmGetY (obj)
865
1474
{
 
1475
        if (!obj)
 
1476
                return 0;
866
1477
        var y = 0;
867
1478
        do
868
1479
        {
906
1517
}
907
1518
 
908
1519
//
 
1520
// extract description from the menu item and set the status text
 
1521
//
 
1522
function cmSetStatus (item)
 
1523
{
 
1524
        var descript = '';
 
1525
        if (item.length > 4)
 
1526
                descript = (item[4] != null) ? item[4] : (item[2] ? item[2] : descript);
 
1527
        else if (item.length > 2)
 
1528
                descript = (item[2] ? item[2] : descript);
 
1529
 
 
1530
        window.defaultStatus = descript;
 
1531
}
 
1532
 
 
1533
//
909
1534
// debug function, ignore :)
910
1535
//
911
1536
function cmGetProperties (obj)
922
1547
        return msg;
923
1548
}
924
1549
 
 
1550
/* v2.0.4                       1. Fixed the bug that cmEnableItem setting the wrong isDisabled value.
 
1551
                                        2. Fixed a missing semicolon issue.
 
1552
*/
 
1553
/* v2.0.3                       1. Fix an issue with IE6 displaying menu over HTTPS connection.
 
1554
                                                Thanks to Paul Horton for reporting the bug and testing
 
1555
                                                possible solutions.
 
1556
*/
 
1557
/* v2.0.2                       1. Minor clean up and some attempts to reduce memory leak in IE.
 
1558
*/
 
1559
/* v2.0.1                       1. Disable iframe masking for IE7 since it is no longer necessary.
 
1560
*/
 
1561
/* v2.0                         1. improves the way handling flash/iframe/select boxes in IE
 
1562
                                                and firefox and Opera 9.  Hiding these elements is no
 
1563
                                                longer necessary.  For older versions of Opera, flash/iframe
 
1564
                                                still need to be hidden.
 
1565
                                        2. Improves cmDrawFromText ().  Also allows custom actions.
 
1566
                                        3. Improves clickOpen behavior.  Now once a submenu is opened,
 
1567
                                                opening other sub menus no longer requires clicking.
 
1568
                                        4. Special Effects.  This version has hooks that allow people
 
1569
                                                to install special effects to various themes.
 
1570
                                        5. For a given menu item, cmGetMenuitem(item) provides the ability
 
1571
                                                to find the corresponding DOM element.
 
1572
                                        6. Disable API.  If you know which item to disable, you can call
 
1573
                                                cmDisableItem(item, themePrefix) and cmEnableItem(item, themePrefix).
 
1574
                                                However, you will have to provide your own CSS for the item.
 
1575
                                                For purposes other than to disable an item, cmGetMenuItem (item)
 
1576
                                                is provided for locating HTML DOM element of the menu item in concern.
 
1577
                                        7. Better z-index.  Now you can specify in the theme property the
 
1578
                                                starting z-index and incremental step for submenus.
 
1579
                                        8. Allow themes to insert additional elements before and after
 
1580
                                                the sub menu table.
 
1581
                                        9. Improved themes.  More organized and easier to customize.
 
1582
                                        10. Add a flag to control hiding/nohiding objects/iframes.  By default,
 
1583
                                                only Opera before 9 hides objects.
 
1584
                                        11. Add new property options to control submenu positions to fine tune
 
1585
                                                the look.
 
1586
                                        12. It is no longer necessary to specify the theme name while calling
 
1587
                                                cmDraw and cmDrawFromText.  Currently it still accepts it, but it
 
1588
                                                will not in the future.
 
1589
*/
 
1590
/* v1.4.4                       1. a quick fix for a bug for _cmSplit checking.  reported by
 
1591
                                                Son Nguyen.
 
1592
*/
 
1593
/* v1.4.3                       1. changed how _cmSplit is handled a bit so that _cmNoClick can work
 
1594
                                                properly.  All splits in predefined themes are changed to use
 
1595
                                                _cmNoClick instead of _cmNoAction.
 
1596
*/
 
1597
/* v1.4.2                       1. fixed _cmNoClick mouse hoover bug.
 
1598
                                        2. fixed a statusbar text problem that cause text to disappear when
 
1599
                                                hoovering mouse within the same menu item.
 
1600
                                        3. changed the behavior of cmDrawFromText s.t. if the title of the
 
1601
                                                of a link is empty, the actual url is used as text.  To clear
 
1602
                                                this link information, title needs to be ' '.
 
1603
*/
 
1604
/* v1.4.1                       1. fixed a problem introduced in 1.4 where re-entering a main menu
 
1605
                                                item which doesn't have a child can disable its hover setting.
 
1606
                                                Apparently I deleted an extra line of code when I was doing
 
1607
                                                cleaning up.  Reported by David Maliachi and a few others.
 
1608
*/
 
1609
/* JSCookMenu v1.4      1. fixed a minor td cell closure problem.  Thanks to Georg Lorenz
 
1610
                                           <georg@lonux.de> for discovering that.
 
1611
                                        2. added clickOpen to nodeProperties.  See _cmNodeProperties for
 
1612
                                                description.  Basically menus can be opened on click only.
 
1613
                                        3. added an ability to draw menu from an html node instead of a javascript
 
1614
                                                tree, making this script search bot friendly (I hope?).
 
1615
*/
925
1616
/* JSCookMenu v1.31 1. fix a bug on IE with causes submenus to display at the top
926
1617
                                           left corner due to doctype.  The fix was provided by
927
1618
                                           Burton Strauss <Burton@ntopsupport.com>.