jQuery-contextMenu icon indicating copy to clipboard operation
jQuery-contextMenu copied to clipboard

Allow options for html5

Open mustanggb opened this issue 8 years ago • 3 comments

It doesn't seem like you can specify options when using as an html5 polyfill.

Currently I'm testing the following:

  case 'html5':
      // if <command> or <menuitem> are not handled by the browser,
      // or options was a bool true,
      // initialize $.contextMenu for them
-     if ((!$.support.htmlCommand && !$.support.htmlMenuitem) || (typeof options === 'boolean' && options)) {
+     if ((!$.support.htmlCommand && !$.support.htmlMenuitem) || (typeof options === 'boolean' && options) || (typeof options === 'object' && options.ignoreNative)) {
          $('menu[type="context"]').each(function () {
              if (this.id) {
-                 $.contextMenu({
-                     selector: '[contextmenu=' + this.id + ']',
-                     items: $.contextMenu.fromMenu(this)
-                 });
+                 var createOptions = $.extend(true, {}, o, {
+                     selector: '[contextmenu=' + this.id + ']',
+                     items: $.contextMenu.fromMenu(this)
+                 } || {});
+                 $.contextMenu(createOptions);
              }
          }).css('display', 'none');
      }
      break;

mustanggb avatar Mar 23 '17 17:03 mustanggb

The HTML 5 polyfill is exactly a polifill, it should only convert the html menu to a working menu on browser that don't support the menu element. If you want full control, don't use it as a polyfill afaik.

bbrala avatar Mar 25 '17 06:03 bbrala

I see where you're coming from, at least for many of the options, however there are some that I believe that it would be fine if we could use them for html5.

Namely I'm currently using it to disable the show/hide animations (well technically just the hide animations because the show is broken), to give a behaviour more similar to the native context menu experience.

I guess there may be a few more options that you might like to use, but animations is the main one for me right now. I suppose you could implement a filter so that only a few carefully selected options are passed through.

mustanggb avatar Mar 28 '17 09:03 mustanggb

@bbrala: Any more I can do to help move this along?

mustanggb avatar Aug 23 '17 15:08 mustanggb