DHTMLGoodies_menuModel = function() { var menuItems; this.menuItems = new Array(); } /************************************************************************************************************ * DHTML menu model class * * Created: October, 30th, 2006 * @class Purpose of class: Saves menu item data * * * Demos of this class: demo-menu-strip.html * * Update log: * ************************************************************************************************************/ /** * @constructor * @class Purpose of class: Organize menu items for different menu widgets. demos of menus: (Demo) * @version 1.0 * @author Alf Magne Kalleland(www.dhtmlgoodies.com) */ DHTMLGoodies_menuModel.prototype = { // {{{ addItem() /** * Add separator (special type of menu item) * * @param int id of menu item * @param string itemText = text of menu item * @param string itemIcon = file name of menu icon(in front of menu text. Path will be imagePath for the DHTMLSuite + file name) * @param string url = Url of menu item * @param int parent id of menu item * @param String jsFunction Name of javascript function to execute. It will replace the url param. The function with this name will be called and the element triggering the action will be * sent as argument. Name of the element which triggered the menu action may also be sent as a second argument. That depends on the widget. The context menu is an example where * the element triggering the context menu is sent as second argument to this function. * * @public */ addItem : function(id,itemText,itemIcon,url,parentId,jsFunction) { this.menuItems[id] = new Array(); this.menuItems[id]['id'] = id; this.menuItems[id]['itemText'] = itemText; this.menuItems[id]['itemIcon'] = itemIcon; this.menuItems[id]['url'] = url; this.menuItems[id]['parentId'] = parentId; this.menuItems[id]['separator'] = false; this.menuItems[id]['jsFunction'] = jsFunction; } , // {{{ addSeparator() /** * Add separator (special type of menu item) * * @param int id of menu item * @param int parent id of menu item * @public */ addSeparator : function(id,parentId) { this.menuItems[id] = new Array(); this.menuItems[id]['parentId'] = parentId; this.menuItems[id]['separator'] = true; } , // {{{ init() /** * Initilizes the menu model. This method should be called when all items has been added to the model. * * * @public */ init : function() { this.__getDepths(); } // }}} , // {{{ __getDepths() /** * Create variable for the depth of each menu item. * * * @private */ getItems : function() { return this.menuItems; } , // {{{ __getDepths() /** * Create variable for the depth of each menu item. * * * @private */ __getDepths : function() { for(var no in this.menuItems){ this.menuItems[no]['depth'] = 1; if(this.menuItems[no]['parentId']){ this.menuItems[no]['depth'] = this.menuItems[this.menuItems[no]['parentId']]['depth']+1; } } } , // {{{ __hasSubs() /** * Does a menu item have sub elements ? * * * @private */ // }}} __hasSubs : function(id) { for(var no in this.menuItems){ // Looping through menu items if(this.menuItems[no]['parentId']==id)return true; } return false; } } var referenceToDHTMLSuiteContextMenu; DHTMLGoodies_contextMenu = function() { var menuModels; var menuItems; var menuObject; // Reference to context menu div var layoutCSS; var menuUls; // Array of