attach menu as per type
545663
function attachMenu(item) {
        var menuType = item.find('a').hasClass(FOLDER_TYPE) ? "folderMenu" : "itemMenu";
        item.contextMenu({
                menu:menuType
            },
            function (action, el, pos) {
                switch (action) {
                    case ADD_SUBFOLDER_MENU_COMMAND:
                        var parentFolderId = el.find('a').attr('id');
                        addFolder(parentFolderId);
                        break;
                    case DOWNLOAD_MENU_COMMAND:
                        download(el.find('a').attr('id'));
                        break;
                    case RENAME_MENU_COMMAND:
                        rename(el.find('a').attr('id'), true);
                        break;
                    case DELETE_MENU_COMMAND:
                        var link = el.find('a');
                        remove(link.attr('id'), link.hasClass(FOLDER_TYPE) ? FOLDER_TYPE : "");
                        break;
                    default:
                        alert("Todo: apply action '" + action + "' to node " + el);
                }
            });

    }
1091505
function( editor, buttonName, buttonLabel, commandName, command, menugroup, menuOrder )
	{
		editor.addCommand( commandName, command );

		// If the "menu" plugin is loaded, register the menu item.
		editor.addMenuItem( commandName,
			{
				label : buttonLabel,
				command : commandName,
				group : menugroup,
				order : menuOrder
			});
	}
830260
def section_menu(
    context, show_section_root=True, show_multiple_levels=True,
    apply_active_classes=True, allow_repeating_parents=True,
    max_levels=settings.DEFAULT_SECTION_MENU_MAX_LEVELS,
    template='', sub_menu_template='', sub_menu_templates=None,
    use_specific=settings.DEFAULT_SECTION_MENU_USE_SPECIFIC,
    use_absolute_page_urls=False, add_sub_menus_inline=None, **kwargs
):
    """"""
    validate_supplied_values('section_menu', max_levels=max_levels,
                             use_specific=use_specific)

    if not show_multiple_levels:
        max_levels = 1

    menu_class = settings.objects.SECTION_MENU_CLASS
    return menu_class.render_from_tag(
        context=context,
        max_levels=max_levels,
        use_specific=use_specific,
        apply_active_classes=apply_active_classes,
        allow_repeating_parents=allow_repeating_parents,
        use_absolute_page_urls=use_absolute_page_urls,
        add_sub_menus_inline=add_sub_menus_inline,
        template_name=template,
        sub_menu_template_name=sub_menu_template,
        sub_menu_template_names=split_if_string(sub_menu_templates),
        show_section_root=show_section_root,
        **kwargs
    )
248979
private void createMenus(Collection<ActionRef> parents, Collection<ActionRef> actions)
    {
        for (final ActionRef action : actions)
        {
            final Featurable menu = createMenu(action);
            if (!action.getRefs().isEmpty())
            {
                generateSubMenu(actions, action, menu);
            }
            else if (action.hasCancel())
            {
                previous.put(action, parents);
                generateCancel(action, menu);
            }
        }
        for (final Featurable current : menus)
        {
            handler.add(current);
        }
    }
768455
function menu(t) {
			var i, j, a, html, l, src = self.fm.options.contextmenu[t]||[];
			for (i=0; i < src.length; i++) {
				if (src[i] == 'delim') {
					self.menu.children().length && !self.menu.children(':last').hasClass('delim') && self.menu.append('<div class="delim" />');
				} else if (self.fm.ui.includeInCm(src[i], t)) {
					a = self.cmd[src[i]].argc();
					html = '';

					if (a.length) {
						html = '<span/><div class="el-finder-contextmenu-sub" style="z-index:'+(parseInt(self.menu.css('z-index'))+1)+'">';
						for (var j=0; j < a.length; j++) {
							html += '<div name="'+src[i]+'" argc="'+a[j].argc+'" class="'+a[j]['class']+'">'+a[j].text+'</div>';
						};
						html += '</div>';
					}
					self.menu.append('<div class="'+src[i]+'" name="'+src[i]+'">'+html+self.cmdName(src[i])+'</div>');
				}
			};
		}
1088776
def add(title_or_item, element_id=nil, options={}, &block)
      if element_id.is_a?(NSDictionary)
        options = element_id
        element_id = nil
      end

      if title_or_item.is_a?(NSMenuItem)
        item = title_or_item
        menu = nil
        retval = item
      elsif title_or_item.is_a?(NSMenu)
        menu = title_or_item
        item = self.item(menu.title, options)
        item.submenu = menu
        retval = menu
      else
        title = title_or_item
        item = self.item(title, options)

        if block
          menu = create(title)
          item.submenu = menu
          retval = menu
        else
          retval = item
        end
      end

      self.apply(:add_child, item)

      if menu && block
        menuitem_was = @menu_item
        @menu_item = item
        context(menu, &block)
        @menu_item = menuitem_was
      end

      if element_id
        create(retval, element_id)
      end

      return retval
    end
1165751
function MenuItem (opts) {
    MenuItem.superclass.constructor.call(this, opts)

    var callback = opts.callback

    this.anchorPoint = ccp(0.5, 0.5)
    this.callback = callback
}
643061
function(oThis){
		var iVisibleItems = getVisibleItemCount(oThis);
		var _iVisibleItems = iVisibleItems;

		var jAreaRef = oThis.$("area");
		var jItems = jAreaRef.children();
		var jOvrFlwRef = oThis.$("ovrflw");

		var bUpdateFocus = false;

		if (iVisibleItems < jItems.length - 1) {
			jOvrFlwRef.attr("style", "display:block;");
			if (!oThis.oOvrFlwMnu) {
				oThis.oOvrFlwMnu = new Menu(oThis.getId() + "-ovrflwmnu");
				oThis.oOvrFlwMnu.bUseTopStyle = oThis.getDesign() == MenuBarDesign.Header;
				oThis.oOvrFlwMnu.attachItemSelect(function(oEvent){
					var oItem = oEvent.getParameter("item");
					if (!(oItem instanceof _DelegatorMenuItem)) {
						var oItemRootMenu = Menu.prototype.getRootMenu.apply(oItem.getParent());
						oItemRootMenu.fireItemSelect({item: oItem});
					} else if (oItem.bNoSubMenu && oItem instanceof _DelegatorMenuItem) {
						oItem.oAlterEgoItm.fireSelect({item: oItem.oAlterEgoItm});
					}
				});
			}
			oThis.oOvrFlwMnu.destroyItems();
			var aItems = oThis.getItems();
			for (var i = 0; i < aItems.length; i++) {
				var oItem = aItems[i];
				if (iVisibleItems != 0) {
					if (oItem.getVisible()) {
						iVisibleItems--;
					}
					if (iVisibleItems == 0) {
						oThis.sLastVisibleItemId = oItem.getId();
					}
				} else {
					oThis.oOvrFlwMnu.addItem(new _DelegatorMenuItem(oItem));
					if (oItem.getId() == oThis.sCurrentFocusedItemRefId) {
						bUpdateFocus = true;
					}
				}
			}
			if (sap.ui.getCore().getConfiguration().getAccessibility()) {
				jItems.attr("aria-setsize", _iVisibleItems + 1);
				jOvrFlwRef.attr("aria-posinset", _iVisibleItems + 1);
			}
		} else {
			jOvrFlwRef.attr("style", "display:none;");
			if (oThis.oOvrFlwMnu) {
				oThis.oOvrFlwMnu.destroyItems();
			}
			oThis.sLastVisibleItemId = null;
			if (sap.ui.getCore().getConfiguration().getAccessibility()) {
				jItems.attr("aria-setsize", _iVisibleItems);
				jOvrFlwRef.attr("aria-posinset", 0);
			}
		}

		jAreaRef.scrollTop(0);

		if (bUpdateFocus) {
			oThis.sCurrentFocusedItemRefId = oThis.sLastVisibleItemId;
			document.getElementById(oThis.sLastVisibleItemId).focus();
		}
	}
35159
private static void attachToDecor(Activity activity, MenuDrawer menuDrawer) {
        ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
        ViewGroup decorChild = (ViewGroup) decorView.getChildAt(0);

        decorView.removeAllViews();
        decorView.addView(menuDrawer, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

        menuDrawer.mContentContainer.addView(decorChild, decorChild.getLayoutParams());
    }
1164740
def persistent_menu(menu):
    
    if len(menu) > 3:
        raise Invalid('menu should not exceed 3 call to actions')

    if any(len(item['call_to_actions']) > 5 for item in menu if item['type'] == 'nested'):
        raise Invalid('call_to_actions is limited to 5 for sub-levels')

    for item in menu:
        if len(item['title']) > 30:
            raise Invalid('menu item title should not exceed 30 characters')

        if item['type'] == 'postback' and len(item['payload']) > 1000:
            raise Invalid('menu item payload should not exceed 1000 characters')
583998
function _setupGoLiveMenu() {
        LiveDevImpl.on("statusChange", function statusChange(event, status) {
            // Update the checkmark next to 'Live Preview' menu item
            // Add checkmark when status is STATUS_ACTIVE; otherwise remove it
            CommandManager.get(Commands.FILE_LIVE_FILE_PREVIEW).setChecked(status === LiveDevImpl.STATUS_ACTIVE);
            CommandManager.get(Commands.FILE_LIVE_HIGHLIGHT).setEnabled(status === LiveDevImpl.STATUS_ACTIVE);
        });
    }
593734
function MenuItem(arg,opt) {
        
        if ($.isPlainObject(arg)) { opt = arg; arg = null; }
        
        if (!arg) arg = '<a>';
        
        this.container = $(arg)[0];
        
        if (opt) this.set(opt);
    }
1217003
function (p_sType, p_aArgs) {

    this.cfg.subscribeToConfigEvent(_VISIBLE, this._onVisibleChange);

    var bRootMenu = !this.parent,
        bLazyLoad = this.lazyLoad;


    /*
        Automatically initialize a menu's subtree if:

        1) This is the root menu and lazyload is off
        
        2) This is the root menu, lazyload is on, but the menu is 
           already visible

        3) This menu is a submenu and lazyload is off
    */



    if (((bRootMenu && !bLazyLoad) || 
        (bRootMenu && (this.cfg.getProperty(_VISIBLE) || 
        this.cfg.getProperty(_POSITION) == _STATIC)) || 
        (!bRootMenu && !bLazyLoad)) && this.getItemGroups().length === 0) {

        if (this.srcElement) {

            this._initSubTree();
        
        }


        if (this.itemData) {

            this.addItems(this.itemData);

        }
    
    }
    else if (bLazyLoad) {

        this.cfg.fireQueue();
    
    }

}
1345792
def set_menu(self, menu):
        
        self.menu = menu
        self.submenu.parent = menu
517313
function(el, type, func) {
      if(el.addEventListener) {
        el.addEventListener(type, func, false);
      } else if(el.attachEvent){ 
        el.attachEvent('on' + type, func);
      } else{ 
        el['on' + type] = func; 
      }  
    }
1204465
def create_context_menu(self, extended):
        """"""
        menu = Gtk.Menu()
        self._menu(menu, extended)
        return menu
669184
def setup_context_menu(self):
        """"""
        self.menu = QMenu(self)
        self.cut_action = create_action(self, _("Cut"),
                                        shortcut=keybinding('Cut'),
                                        icon=ima.icon('editcut'),
                                        triggered=self.cut)
        self.copy_action = create_action(self, _("Copy"),
                                         shortcut=keybinding('Copy'),
                                         icon=ima.icon('editcopy'),
                                         triggered=self.copy)
        paste_action = create_action(self, _("Paste"),
                                     shortcut=keybinding('Paste'),
                                     icon=ima.icon('editpaste'),
                                     triggered=self.paste)
        save_action = create_action(self, _("Save history log..."),
                                    icon=ima.icon('filesave'),
                                    tip=_("Save current history log (i.e. all "
                                          "inputs and outputs) in a text file"),
                                    triggered=self.save_historylog)
        self.delete_action = create_action(self, _("Delete"),
                                    shortcut=keybinding('Delete'),
                                    icon=ima.icon('editdelete'),
                                    triggered=self.delete)
        selectall_action = create_action(self, _("Select All"),
                                    shortcut=keybinding('SelectAll'),
                                    icon=ima.icon('selectall'),
                                    triggered=self.selectAll)
        add_actions(self.menu, (self.cut_action, self.copy_action,
                                paste_action, self.delete_action, None,
                                selectall_action, None, save_action) )