Vertical menu and image menu : Menu 2 « GUI Components « JavaScript DHTML






Vertical menu and image menu

 

<html>
<head>
<title>DynAPI Examples - HTML Menu with Images</title>
<script language="JavaScript" src="./dynapisrc/dynapi.js"></script>
<script language="Javascript">
dynapi.library.setPath('./dynapisrc/');
dynapi.library.include('dynapi.api');
dynapi.library.include('HTMLMenu');
dynapi.library.include('Image');

</script>
<script language="Javascript">

// Write Style to browser
HTMLComponent.writeStyle({
  MNUItm:     'border: 1px solid #E0E0E0',
  MNUItmText:  'cursor: default; text-decoration: none; color: #000000; font: 12px Arial, Helvetica;'
});

var  p ={align:"top"}
var i1 = dynapi.functions.getImage('./dynapiexamples/images/btn_new.gif',16,16,p);
var i2 = dynapi.functions.getImage('./dynapiexamples/images/btn_save.gif',16,16,p);
var i3 = dynapi.functions.getImage('./dynapiexamples/images/eicon3.gif',32,32,p);
var i4 = dynapi.functions.getImage('./dynapiexamples/images/eicon2.gif',32,32,p);
var i5 = dynapi.functions.getImage('./dynapiexamples/images/eicon1.gif',32,32,p);
var px = dynapi.functions.getImage('./dynapiexamples/images/pixel.gif',16,16,p);

var mnu = dynapi.document.addChild(new HTMLMenu(),'mnu');
mnu.backCol = "#EFEBD7"
mnu.selBgCol = '#C1D2EE';
mnu.cssMenu = 'MNU';
mnu.cssMenuText = 'MNUItmText';
mnu.cssMenuItem = 'MNUItm';

var mbar;
// Main Menu
mbar= mnu.createMenuBar('main',40,20);
mbar.addItem(null,'File','file');
mbar.addItem(null,'Edit','edit');
mbar.addItem(null,'View','view');
  //File menu
  mbar = mnu.createMenuBar('file',130);
  mbar.addItem(null,{image:i1,text:' New'});
  mbar.addItem(null,{image:px,text:' Open'},null,'alert("Open files")');
  mbar.addItem(null,{image:i2,text:' Save'});
  mbar.addItem(null,'Save As ...');
  mbar.addItem(null,'Recent Files','recent');
  mbar.addItem(null,'Exit');
    //Recent menu
    mbar = mnu.createMenuBar('recent',120);
    mbar.addItem(null,'Dynapi.js');
    mbar.addItem(null,'Quickref.html');
    mbar.addItem(null,'Changelog.html');
    mbar.addItem(null,'Index.html');
  //edit menu
  mbar = mnu.createMenuBar('edit',120);
  mbar.addItem(null,'Undo');
  mbar.addItem(null,'Cut');
  mbar.addItem(null,'Copy');
  mbar.addItem(null,'Paste');
  //view menu
  mbar = mnu.createMenuBar('view',130);
  mbar.addItem(null,{image:px,text:'Icon #1'},'eicon1');
  mbar.addItem(null,{image:px,text:'Icon #2'},'eicon2');
  mbar.addItem(null,{image:px,text:'Icon #3'},'eicon3');
    mbar = mnu.createMenuBar('eicon1',40,36);
    mbar.addItem(null,i3.getHTML());
    mbar = mnu.createMenuBar('eicon2',40,36);
    mbar.addItem(null,i4.getHTML());
    mbar = mnu.createMenuBar('eicon3',40,36);
    mbar.addItem(null,i5.getHTML());

// Vertical Menu
var mnu2 = dynapi.document.addChild(new HTMLMenu(null,'vert'),'mnu2');
mbar= mnu2.createMenuBar('main',90,20);
mbar.addItem(null,'Products','prods');
mbar.addItem(null,'Services','edit');
mbar.addItem(null,'Contacts','file');
  //File menu
  mbar = mnu2.createMenuBar('file',130);
  mbar.addItem(null,{image:i1,text:' New'});
  mbar.addItem(null,{image:px,text:'Open'},null,'alert("Open files")');
  mbar.addItem(null,{image:i2,text:' Save'});
  mbar.addItem(null,'Save As ...');
  mbar.addItem(null,'Recent Files','recent');
  mbar.addItem(null,'Exit');
    //Recent menu
    mbar = mnu2.createMenuBar('recent',120);
    mbar.addItem(null,'Dynapi.js');
    mbar.addItem(null,'Quickref.html');
    mbar.addItem(null,'Changelog.html');
    mbar.addItem(null,'Index.html');
  //edit menu
  mbar = mnu2.createMenuBar('edit',120);
  mbar.addItem(null,'Undo');
  mbar.addItem(null,'Cut');
  mbar.addItem(null,'Copy');
  mbar.addItem(null,'Paste');
  //view menu
  mbar = mnu2.createMenuBar('prods',130);
  mbar.addItem(null,{image:px,text:'Icon #1'},'eicon1');
  mbar.addItem(null,{image:px,text:'Icon #2'},'eicon2');
  mbar.addItem(null,{image:px,text:'Icon #3'},'eicon3');
    mbar = mnu2.createMenuBar('eicon1',40,36);
    mbar.addItem(null,i3.getHTML());
    mbar = mnu2.createMenuBar('eicon2',40,36);
    mbar.addItem(null,i4.getHTML());
    mbar = mnu2.createMenuBar('eicon3',40,36);
    mbar.addItem(null,i5.getHTML());

</script>
</head>
<body>
<h1>The Image Menu</h1>
<script>
  dynapi.document.insertChild(mnu);
</script>
<p>This is a great way to start your web page</p>
<p>&nbsp;</p>
<h2>A Vertical Way to start your day</h2>
<script>
  dynapi.document.insertChild(mnu2);
</script>
</body>
</html>

           
         
  








dynapi.zip( 791 k)

Related examples in the same category

1.Popup Menu
2.AtJsMenu Demo
3.Example 1: Basic Menu From Existing Markup
4.Example 2: Basic Menu From Pure JavaScript
5.Example 3: Grouped MenuItem Instances From Existing Markup
6.Example 4: Grouped MenuItem Instances Using Pure JavaScript
7.Example 5: Grouped MenuItem Instances With Titles From Existing Markup
8.Example 6: Grouped MenuItem Instances With Titles Using Pure JavaScript
9.Example 7: Multi-tiered Menu From Existing Markup
10.Example 8: Multi-tiered Menu From Pure JavaScript
11.Example 9: Handling Click Events
12.Example 10: Listening For DOM-Related Events
13.Example 11: MenuItem Configuration Properties
14.Example 12: Setting Configuration Properties At Runtime
15.Example 13: Multi-tiered Menu with Progressive Rendering of Submenus
16.Website Left Nav Example (with submenus built from JavaScript) 1
17.Website Left Nav Example (with submenus built from markup) 2
18.OS-Style Programs Menu Example
19.Website Top Nav (with submenus built from JavaScript) 3
20.Website Top Nav (with submenus built from markup) 4
21.Drop down menu and sub menu
22.Emulate XP start menu
23.xmenu-xlayer-3
24.tree-menu
25.menu for applications