Giter Site home page Giter Site logo

hbyhby / jquery-contextmenu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from swisnl/jquery-contextmenu

0.0 1.0 0.0 8.83 MB

jQuery contextMenu plugin & polyfill

Home Page: https://swisnl.github.io/jQuery-contextMenu/

License: MIT License

HTML 82.63% JavaScript 16.15% Smarty 0.05% SCSS 1.17%

jquery-contextmenu's Introduction

jQuery contextMenu plugin & polyfill

Greenkeeper badge

Travis npm npm CDNJS npm

$.contextMenu is a management facility for - you guessed it - context menus. It was designed for an application where there are hundreds of elements that may show a context menu - so intialization speed and memory usage are kept fairly small. It also allows to register context menus without providing actual markup, as $.contextMenu generates DOMElements as needed.

features - demo - documentation

Sauce Test Status

Dependencies

  • jQuery >=1.8.2
  • jQuery UI position (optional but recommended)

Usage

register contextMenu from javascript:

$.contextMenu({
    // define which elements trigger this menu
    selector: ".with-cool-menu",
    // define the elements of the menu
    items: {
        foo: {name: "Foo", callback: function(key, opt){ alert("Foo!"); }},
        bar: {name: "Bar", callback: function(key, opt){ alert("Bar!") }}
    }
    // there's more, have a look at the demos and docs...
});

have a look at the demos.

Version 3.0 beta

Version 3.0 is a restructure of the javascript into something more sane written in ES6. It consolidates all API's so callbacks are better documented and more concise. The basics are still the same, but all callbacks are structured differently.

The goal of this refactor was mostly to make the ContextMenu easier to maintain, and make the API's more consise. It also adds JSdoc comments so the API documentation is generated from the code and it enables code completion.

Check out the 3.x branch, or install with npm install jquery-contextmenu@next.

HTML5 Compatibility

Firefox 8 implemented contextmenu using the <menuitem> tags for menu-structure. The specs however state that <command> tags should be used for this purpose. $.contextMenu accepts both.

Firefox 8 does not yet fully implement the contextmenu specification (Ticket #617528). The elements a, button, input and option usable as commands are being ignored altogether. It also doesn't (optically) distinguish between checkbox/radio and regular commands (Bug #705292).

Note: While the specs note <option>s to be renderd as regular commands, $.contextMenu will render an actual <select>. import contextMenu from HTML5 <menu>:

$.contextMenu("html5");

Interaction Principles

You're (obviously) able to use the context menu with your mouse. Once it is opened, you can also use the keyboard to (fully) navigate it.

  • ↑ (up) previous item in list, will skip disabled elements and wrap around
  • ↓ (down) next item in, will skip disabled elements and wrap around
  • → (right) dive into sub-menu
  • ← (left) rise from sub-menu
  • ↵ (return) invoke command
  • ⇥ (tab) next item or input element, will skip disabled elements and wrap around
  • ⇪ ⇥ (shift tab) previous item or input element, will skip disabled elements and wrap around
  • ⎋ (escape) close menu
  • ⌴ (space) captured and ignore to avoid page scrolling (for consistency with native menus)
  • ⇞ (page up) captured and ignore to avoid page scrolling (for consistency with native menus)
  • ⇟ (page down) captured and ignore to avoid page scrolling (for consistency with native menus)
  • ↖ (home) first item in list, will skip disabled elements
  • ↘ (end) last item in list, will skip disabled elements

Besides the obvious, browser also react to alphanumeric key strokes. Hitting r in a context menu will make Firefox (8) reload the page immediately. Chrome selects the option to see infos on the page, Safari selects the option to print the document. Awesome, right? Until trying the same on Windows I did not realize that the browsers were using the access-key for this. I would've preferred typing the first character of something, say "s" for "save" and then iterate through all the commands beginning with s. But that's me - what do I know about UX? Anyways, $.contextMenu now also supports accesskey handling.

Authors

License

$.contextMenu is published under the MIT license

Special thanks

Font-Awesome icons used from encharm/Font-Awesome-SVG-PNG.

SWIS ❤️ Open Source

SWIS is a web agency from Leiden, the Netherlands. We love working with open source software.

jquery-contextmenu's People

Contributors

adjohu avatar alishahrivarian avatar andreasrosdal avatar anseki avatar arai-a avatar bbrala avatar coderaiser avatar dtex avatar eldeveloper avatar greenkeeper[bot] avatar jzelenkov avatar kagant15 avatar kccarter76 avatar lelouch77 avatar micnigh avatar mrmarco avatar nelson6e65 avatar praveen-srinivasan avatar raredevil avatar rentectravis avatar rhain avatar roachmech avatar rodneyrehm avatar rvictory avatar shayanelhami avatar stealthduck avatar sweet-bob avatar terwarf avatar wizzard0 avatar zyuhel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.