ez.no / ezpublish / documentation / incoming / javascript popupmenu
These documentation pages are no longer maintained. Please visit the new documentation site.
Introduced in eZ publish 3.5.
The file ezpopupmenu.js located in design/standard/javascript/popupmenu provides a very cool and flexible DHTML popupmenu. In order to use this javascript you must also include design/standard/javascript/lib/ezjslibdomsupport.js and design/standard/javascript/lib/ezjslibmousetracker.js
|
Function name |
Description |
|---|---|
|
ezpopmenu_showTopLevel |
Display a new top-level popupmenu. |
|
ezpopmenu_showSubLevel |
Display a sublevel popupmenu. It does not hide any parent menus. |
|
ezpopmenu_submitForm |
Activate a form. |
|
ezpopmenu_mouseOver |
This method should be called by all menuitems when a mouseover event occurs. It currently hides and submenus that should not be shown. |
|
ezpopmenu_initOffsets |
Controls the popup offsets of new menus relative to the mouse position or parent item. Typically called once right after the inclusion of the javascript. |
|
ez_createAArray |
Helper method to create associative arrays (really an object). It takes an array with an even number of elements and makes a associate element out of every two array elements. |
Display a new top-level popupmenu. Other visible top-level menus will be hidden.
Calling this method automatically invokes string substitution for the elements in the new menu.
The following steps are executed for each menu item present in the menuArray configuration:
|
Parameter |
Description |
|
event |
The mouse event triggering the call to this method. Putting "event" here does the trick |
|
menuID |
The identification of the menu to display |
|
substituteValues |
An associative array containing the substitute values to use. |
|
menuHeader |
If the menu has a header, the contents are replaced with this value. |
Display a sublevel popupmenu. It does not hide any parent menus. Substitute values are taken from the last call to showTopLevel.
|
Parameter |
Description |
|
event |
The mouse event triggering the call to this method. Putting "event" here does the trick |
|
menuID |
The identification of the menu to display |
|
overItem |
The id of the HTML item triggering the call to showSubLevel. The new menu is positioned relative to this item. |
Activate a form. All fields of type hidden within this form are target to string substitution.
|
Parameter |
Description |
|
formID |
The identification of the form to activate. |
This method should be called by all menuitems when a mouseover event occurs. It currently hides and submenus that should not be shown.
|
Parameter |
Description |
|
id |
The identification of the HTML element triggering the call to mouseOver |
Controls the popup offsets of new menus relative to the mouse position or parent item. Typically called once right after the inclusion of the javascript.
The default values are 8 for the x axis and 4 for the Y axis.
|
Parameter |
Description |
|
offsetX |
The offset of the new menu on the X axis. Both positive and negative values are allowed |
|
offsetY |
The offset of the new menu on the Y axis. Both positive and negative values are allowed |
In order to use the popupmenu javascript you need to provide:
eZ publish provides a default template for this purpose. It is located in popupmenu/popup_menu.tpl. You are encouraged to override this file in the siteacess where you want to use the menu.
Your menu should be set up completely with all elements. The following requirements apply:
example with a main menu and a submenu:
<!-- The main menu --> <div class="menu" id="mainmenu"> <a id="menu-main" href="http://www.ez.no" onmouseover="ezpopmenu_mouseOver( 'mainmenu' )" >ez.no</a> <a id="menu-substitute" href="#" onmouseover="ezpopmenu_mouseOver( 'mainmenu' )" >Dynamic node view</a> <a id="menu-spawn" href="#" onmouseover="ezpopmenu_showSubLevel( event, 'submenu', 'menu-spawn' )" >Show submenu</a> </div> <!-- The submenu --> <div class="menu" id="submenu"> <a id="submenu-item" href="#" onmouseover="ezpopmenu_submitForm( 'myform' )">Form submitter</a> </div>
The menuArray is a multilevel array describing the features of your menus. The structure of the menuArray array is flat. This means that each menu is described in the first level of the array.
Each menu can have the following properties set:
Each element is again, an array. Currently we only support one option (may change in the future):
The following example configures the menu created in step 1.
<script language="JavaScript1.2" type="text/javascript"> var menuArray = new Array(); <!-- main menu --> menuArray['mainmenu'] = new Array(); menuArray['mainmenu']['depth'] = 0; menuArray['mainmenu']['elements'] = new Array(); menuArray['mainmenu']['elements']['menu-substitute'] = new Array(); menuArray['mainmenu']['elements']['menu-substitute']['url'] = {'/content/view/%nodeID%'|ezurl}; <!-- submenu --> menuArray['submenu'] = new Array(); menuArray['submenu']['depth'] = 1; // this is a first level submenu of ContextMenu </script> <!-- The form submitted by the submenu --> {* Remove a node. *} <form id="myform" method="post" action="someactionhere"> <!-- Notice that there is autoamatic string translation for the contents of value --> <input type="hidden" name="example" value="%nodeID%" /> </form>
Finally you will need to activate the "mainmenu" menu somehow. This is achieved through a call to ezpopmenu_showToplevel. In the eaxample case links in the setup array containing the string %nodeID% will be substituted by 42.
example:
<a onmouseclick="ezpopmenu_showTopLevel( event, 'ContextMenu', ez_createAArray( array( %nodeID%, 42) ) ); return false;">show</a><br />
Comments