ContentUtil.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /*
  4. *+------------------------------------------------------------------------+
  5. *| Licensed Materials - Property of IBM
  6. *| IBM Cognos Products: BI Dashboard
  7. *| (C) Copyright IBM Corp. 2019
  8. *|
  9. *| US Government Users Restricted Rights - Use, duplication or disclosure
  10. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  11. *+------------------------------------------------------------------------+
  12. */
  13. /**
  14. * Event helper class
  15. **/
  16. define([], function () {
  17. var ContentUtil = function () {
  18. function ContentUtil() {
  19. _classCallCheck(this, ContentUtil);
  20. }
  21. /**
  22. * Recursively walk the content and it's parent to find the page content.
  23. * @param {ContentAPI} content
  24. * @param {String} [type='page'] the content type.
  25. * @returns {ContentAPI} page content. If the type can not be found, returns null
  26. */
  27. ContentUtil.getPageContent = function getPageContent(content) {
  28. var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'page';
  29. var pageContent = null;
  30. while (content) {
  31. if (type && content.getType() === type) {
  32. pageContent = content;
  33. }
  34. content = content.getContainer();
  35. }
  36. return pageContent;
  37. };
  38. return ContentUtil;
  39. }();
  40. return ContentUtil;
  41. });
  42. //# sourceMappingURL=ContentUtil.js.map