// Menubar.js // Javascript Behaviour for the Menubar Control // Copyright (c) by Matthias Hertel, http://www.mathertel.de // This work is licensed under a BSD style license. See http://www.mathertel.de/License.aspx // ----- // 24.04.2007 created by Matthias Hertel // this is a basic behavior definition for menubars // 17.06.2007 OpenAjax event publishing added. // 12.07.2007 no event is fired when the element is disabled. // 15.09.2007 now using jcl.BuildFullEventname. // 05.01.2008 documentation added. var MenubarBehavior = { /// <summary>This JavaScript behavior implements a menubar functionality that publishes OpenAjax events.</summary> init: function () { /// <summary>Initialize the control. Enable the hover effect on all menuitems.</summary> var allitems = this.getElementsByTagName("*"); for (var o in allitems) if (allitems[o].className == "VEMenu") { allitems[o].hover = true; } // if }, // init onkeypress: function(evt) { /// <summary>If the focus is on a menu item and if the spacebar is pressed the onclick function is called.</summary> evt = evt || window.event; var kc = String.fromCharCode(evt.keyCode); if ((evt != null) && ((evt.keyCode == 32) || (evt.charCode == 32) || (kc == " ") || (kc == "\r"))) { if (this._attachedBehaviour.onclick != null) { this._attachedBehaviour.onclick.call(this, evt); } else { var src = evt.srcElement; if (src.onclick != null) src.onclick.call(src, evt); } // if } // if }, // onkeypressed onclick: function(evt) { /// <summary>If an event attribute is pressent then start the event by using the OpenAjax hub publishing mechanism.</summary> evt = evt || window.event; var src = evt.srcElement; var cmd = jcl.BuildFullEventname(src); if ((cmd) && (src.className.indexOf("disabled") < 0)) { cmd = cmd.split(';'); OpenAjax.hub.publish(cmd[0], cmd[1]); } // if } // onclick } // MenubarBehavior
This page is part of the http://www.mathertel.de/AJAXEngine/default.aspx project. For updates and discussions see The AJAX Engine blog.
For updates and discussions see http://ajaxaspects.blogspot.com/.