InfoFlyoutView.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. 'use strict';
  2. /*
  3. *+------------------------------------------------------------------------+
  4. *| Licensed Materials - Property of IBM
  5. *| IBM Cognos Products: BI Dashboard
  6. *| (C) Copyright IBM Corp. 2017, 2018
  7. *|
  8. *| US Government Users Restricted Rights - Use, duplication or disclosure
  9. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  10. *+------------------------------------------------------------------------+
  11. */
  12. /**
  13. * Light Flyout view for showing information for the current widget.
  14. * This class can used to show different level messages when required.
  15. */
  16. define(['jquery', '../../../lib/@waca/dashboard-common/dist/utils/FlyoutContentBase', 'doT', 'text!./templates/InfoList.html'], function ($, FlyoutContentBase, dot, template) {
  17. 'use strict';
  18. var infoTemplate = dot.template(template);
  19. var InfoFlyoutView = FlyoutContentBase.extend([], {
  20. init: function init(options) {
  21. InfoFlyoutView.inherited('init', this, arguments);
  22. this.setMessages(options.viewOptions.messages);
  23. },
  24. /**
  25. * @function setMessages
  26. * Set the information messages to the views
  27. * @param {Object[]} messages - array of info messages
  28. */
  29. setMessages: function setMessages(messages) {
  30. this.messages = messages;
  31. },
  32. setFocus: function setFocus() {
  33. $('.infoDiv').next().first('li').focus();
  34. },
  35. //@override
  36. onPopupShown: function onPopupShown() {
  37. this.onPopupClosed();
  38. var _fnDisableParentScroll = function _fnDisableParentScroll(evt) {
  39. var orgEvent = evt.originalEvent;
  40. var delta = orgEvent.wheelDelta || -orgEvent.detail;
  41. this.scrollTop += (delta < 0 ? 1 : -1) * 10;
  42. evt.preventDefault();
  43. };
  44. $('.infoDataScrollable').on('mousewheel DOMMouseScroll', _fnDisableParentScroll);
  45. },
  46. getRenderedHtml: function getRenderedHtml() {
  47. return infoTemplate({
  48. 'messages': this.messages,
  49. 'small': this.messages.length > 1
  50. });
  51. }
  52. });
  53. return InfoFlyoutView;
  54. });
  55. //# sourceMappingURL=InfoFlyoutView.js.map