项目作者: TheRolfFR

项目描述 :
Create custom context menus easily
高级语言: JavaScript
项目地址: git://github.com/TheRolfFR/custoMenu.git
创建时间: 2017-11-09T17:12:38Z
项目社区:https://github.com/TheRolfFR/custoMenu

开源协议:GNU Lesser General Public License v3.0

下载


custoMenu


Drop, enjoy
Author
License: LGPL--3.0
Repo Size
jsDelivr Hits

Create custom context menus easily

Usage

1. Import js and css

Import custoMenu :

  1. <script src="path/to/custoMenu.js"></script>
  2. <link href="path/to/custoMenu.css" rel="stylesheet" />

You can use jsDelivr links to keep updated your custoMenu : https://www.jsdelivr.com/package/gh/TheRolfFR/custoMenu

2. Create your context menu object

The menu itself has this these properties :

Required Type Desc
name X String Name of the custoMenu
items X Object Contains your items

And each item has these properties :

Required Type Desc
text X HTML Text of the custoMenu item
desc String Description of the custoMenu item
func X Function Function associated to the custoMenu item

Example :

  1. var filectxmenu = {
  2. name: 'file',
  3. items: {
  4. 'openfile' : { // function name must be unique throught every object. If not the last function will be choosed
  5. text: '<i class="material-icons"></i>',
  6. desc: 'Open',
  7. func: function() {
  8. // your function
  9. } // etc...
  10. }
  11. }
  12. }

3. Add your object to CustoMenu in your script

  1. custoMenu.addMenu(filectxmenu);

4. Add class and data attributes to your elements

  • class : custoMe
  • data-name: file (name of your function)
    1. <div class="custoMe" data-name="file">file.txt</div>

    5. Enjoy !

License: GNU Lesser General Public License v3.0