PersonalMenuController.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: CA Mobile
  5. *| (C) Copyright IBM Corp. 2019
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or disclosure
  8. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *+------------------------------------------------------------------------+
  10. */
  11. define([
  12. './nls/StringResource',
  13. 'bi/glass/app/plugins/MenuActionInterface'
  14. ], function(StringResources, MenuActionInterface) {
  15. 'use strict';
  16. var ActionHandler = MenuActionInterface.extend({
  17. /**
  18. * action handlers for mobile app item(s) in the personal menu
  19. */
  20. actionHandlers: {
  21. 'mobileApp': function(context) {
  22. return Promise.resolve().then(function() {
  23. var mobileAppSlideout;
  24. var options = context.target.plugin.itemSpec.items[context.target.specItemIndex].options;
  25. options.launchPoint = context.target.plugin.getButtonElement();
  26. options.label = StringResources.get('mobileAppSlideoutLabel');
  27. options.onHide = function() {
  28. mobileAppSlideout.hide();
  29. }.bind(this);
  30. options.width = '400px';
  31. mobileAppSlideout = context.glassContext.appController.showSlideOut(options);
  32. }.bind(this));
  33. }
  34. },
  35. /**
  36. * Called when the mobile button is clicked
  37. */
  38. onSelectItem: function(context) {
  39. var key = this._getKey(context.target.itemId);
  40. var handler = this.actionHandlers[key];
  41. if(handler) {
  42. var handle = handler.bind(this, context);
  43. return handle();
  44. }
  45. },
  46. _getKey: function(itemId) {
  47. var idTokens = itemId.split('.');
  48. return idTokens[idTokens.length - 1];
  49. }
  50. });
  51. return ActionHandler;
  52. });