/**
  @module ember-ui-components
*/
import Ember from 'ember';

/**
  ## OpenContextMenu

  ```
  {{open-context-menu "menu-name"}}
  ```

  ```
  <div oncontextmenu={{open-context-menu "menu-name"}}>
    // ...
  </div>
  ```

  ```
  <div {{action (open-context-menu "menu-name") on="contextMenu"}}>
    // ...
  </div>
  ```

  @class OpenContextMenuHelper
  @namespace Helpers
*/
export default Ember.Helper.extend({

  /**
    @property contextMenuService
    @type {Object}
    @private
  */
  contextMenuService: Ember.inject.service('context-menu'),

  /**
    @method compute
    @param {Array} params
    @private
    @return {Function}
  */
  compute(params/*, hash*/) {
    let contextMenuService = this.get('contextMenuService');
    let menuId = params[0];
    return function (event) {
      return contextMenuService.open(menuId, event);
    };
  }
});

@@ -84,16 +84,186 @@
 xtMenu%0A%0A
+  The %60%7B%7Bopen-context-menu%7D%7D%60 helper can be used to open a context-menu from within templates.%0A%0A  ### MenuId%0A%0A  Pass the %60id%60 of the menu to open as the first argument.%0A%0A
   %60%60%60%0A  
@@ -288,20 +288,18 @@
 u %22menu-
-name
+id
 %22%7D%7D%0A  %60%60
@@ -293,32 +293,118 @@
 nu-id%22%7D%7D%0A  %60%60%60%0A%0A
+  The %60%7B%7Bopen-context-menu%7D%7D%60 helper returns a function that can be used in actions:%0A%0A
   %60%60%60%0A  %3Cdiv onc
@@ -440,20 +440,18 @@
 u %22menu-
-name
+id
 %22%7D%7D%3E%0A   
@@ -525,60 +525,750 @@
 enu-
-name%22) on=%22contextMenu%22%7D%7D%3E%0A    // ...%0A  %3C/div%3E%0A  %60%60%60
+id%22) on=%22contextMenu%22%7D%7D%3E%0A    // ...%0A  %3C/div%3E%0A  %60%60%60%0A%0A  in a component:%0A%0A  %60%60%60%0A  %7B%7Bmy-component contextMenu=(open-context-menu %22menu-id%22)%7D%7D%0A  %60%60%60%0A%0A  ### Model%0A%0A  Optionally, you can pass in a model or object as the second argument.  This%0A  object will be available as the %60contextMenuParams.model%60 property within the%0A  %60context-menu%60 component.%0A%0A  %60%60%60%0A  %3Cdiv oncontextmenu=%7B%7Bopen-context-menu %22menu-id%22 model%7D%7D%3E%0A    // ...%0A  %3C/div%3E%0A%0A  %7B%7B#uic-context-menu as %7Cparams%7C%7D%7D%0A    // model is available at params.model%0A  %7B%7B/uic-context-menu%7D%7D%0A  %60%60%60%0A%0A  In the example above, the %60model%60 property passed as the second argument to%0A  the %60%7B%7Bopen-context-menu%7D%7D%60 helper is available in the %60%7B%7Buic-context-menu%7D%7D%60%0A  component as the %60params.model%60 property.
 %0A%0A  
@@ -1707,16 +1707,43 @@
 ams%5B0%5D;%0A
+    let model = params%5B1%5D;%0A
     retu
@@ -1814,16 +1814,23 @@
 d, event
+, model
 );%0A    %7D

update open-context-menu helper