Download the PHP package model/context-menu without Composer

On this page you can find all versions of the php package model/context-menu. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package context-menu

model/context-menu

A nice context menu you can append wherever you like.

This is the ModEl 4 port of the legacy ContextMenu module. It ships the menu's CSS/JS as an asset library declared through an AssetsProvider, so model/assets discovers and serves them automatically — no manual file inclusion needed.

Unlike the v3 module, it has no hard dependency on the legacy FrontEnd module: the helpers it used to borrow from it (_, getMouseCoords, addClass, removeClass) are now implemented internally or replaced by their native equivalents. onHtmlChange is still used to re-scan dynamically loaded HTML, but only if FrontEnd happens to be loaded.

Installation

Enabling the assets

The library is registered under the name context-menu but is not auto-enabled. Enable it (typically from a controller's init) wherever a page uses the context menu:

This adds style.css (in the head) and js.js (in the foot) to the asset render list.

Usage

A menu is a plain object mapping the label of each voice (HTML is allowed) to the callback to run when it is picked. Attach it to any element with ctxMenu:

Inside the callbacks, this is the element the menu is attached to.

Right-clicking the element then opens the menu at the cursor; it flips itself back over the cursor if it would otherwise overflow the bottom or the right edge of the window.

Since the voices are the keys of an object, two voices cannot share the same label.

Declarative usage

Instead of calling ctxMenu by hand, the menu can be declared directly in the markup, via the data-context-menu attribute:

The attribute is a JavaScript object literal (it contains functions, so it is eval'd rather than parsed as JSON). It is scanned at DOMContentLoaded and, if the legacy FrontEnd module is present, on every onHtmlChange — so elements loaded later via ajax get their menu too. Already processed elements are flagged with data-set-context-menu and skipped. Call checkZkMenu() yourself if you inject markup without FrontEnd.

Closing the menu

The menu closes on its own when a voice is picked, when Esc is pressed, when the page is scrolled, and when the mouse is pressed anywhere outside of it. To close it programmatically:

Keyboard

While the menu is open, ↑/↓ move the selection (wrapping from nothing to the last/first voice), Enter runs the selected voice, and Esc closes the menu.


All versions of context-menu with dependencies

PHP Build Version
Package Version
Requires model/assets Version ^0.4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package model/context-menu contains the following files

Loading the files please wait ...