123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>JSDoc: Source: api/sharing/ShareController.js</title>
- <script src="scripts/prettify/prettify.js"> </script>
- <script src="scripts/prettify/lang-css.js"> </script>
- <!--[if lt IE 9]>
- <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
- <![endif]-->
- <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
- <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
- </head>
- <body>
- <div id="main">
- <h1 class="page-title">Source: api/sharing/ShareController.js</h1>
-
-
- <section>
- <article>
- <pre class="prettyprint source linenums"><code>/**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: Collaboration
- * (C) Copyright IBM Corp. 2015, 2019
- *
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define([
- 'underscore',
- '../../lib/@waca/core-client/js/core-client/ui/core/Class',
- '../../messaging/Connectors',
- './ShareableItems',
- '../../nls/StringResources',
- '../../utils/AssetTypeUtil'
- ], function (_, Class, Connectors, ShareableItems, StringResources, AssetTypeUtil) {
- var PERSPECTIVE_SUBTITLE_MAP = {
- 'dashboard': function (view) {
- var tabName = view.boardController && view.boardController.layoutController && view.boardController.layoutController.getCurrentSubViewTitle && view.boardController.layoutController.getCurrentSubViewTitle();
- return tabName && StringResources.get('subview_title_tab', { tabName: tabName });
- },
- 'story': function (view) {
- var sceneInfo = view.storyPaneController && view.storyPaneController.getCurrentSceneInfo && view.storyPaneController.getCurrentSceneInfo();
- var sceneTitle = sceneInfo && sceneInfo.title;
- return sceneTitle && StringResources.get('subview_title_scene', { sceneTitle: sceneTitle });
- },
- 'explore': function (view) {
- const layoutModel = view.exploreContainerLayoutModel;
- if (layoutModel.exploreVM.isEmptyCard()) {
- return StringResources.get('cardless_exploration', { title: view.getTitle() });
- } else {
- const cardId = layoutModel.exploreVM.getDisplayedCard();
- const cardTitle = layoutModel.findModel(cardId).getTitle();
- return cardTitle ? StringResources.get('subview_title_explore', { cardTitle }) : StringResources.get('cardless_exploration', { title: view.getTitle() });
- }
- }
- };
- var PERSPECTIVE_SUBTITLE_OBJ_MAP = {
- 'dashboard': function (view) {
- var tabName = view.boardController && view.boardController.layoutController && view.boardController.layoutController.getCurrentSubViewTitle && view.boardController.layoutController.getCurrentSubViewTitle();
- return tabName && {
- type: removeQuotationMarks(StringResources.get('subview_title_tab', { tabName: '' })),
- name: tabName
- };
- },
- 'story': function (view) {
- var sceneInfo = view.storyPaneController && view.storyPaneController.getCurrentSceneInfo && view.storyPaneController.getCurrentSceneInfo();
- var sceneTitle = sceneInfo && sceneInfo.title;
- return sceneTitle && {
- type: removeQuotationMarks(StringResources.get('subview_title_scene', { sceneTitle: '' })),
- name: (typeof sceneTitle === 'string') ? sceneTitle : sceneTitle.translationTable.Default
- };
- },
- 'explore': function (view) {
- const layoutModel = view.exploreContainerLayoutModel;
- if (layoutModel.exploreVM.isEmptyCard()) {
- return null;
- } else {
- const cardId = layoutModel.exploreVM.getDisplayedCard();
- const cardTitle = layoutModel.findModel(cardId).getTitle();
- return cardTitle ? {
- type: removeQuotationMarks(StringResources.get('subview_title_explore', { cardTitle: '' })),
- name: cardTitle
- } : null;
- }
- }
- };
- function removeQuotationMarks (str) {
- return str.replace(/[\u201C\u201D"]/g, '').trim();
- }
- var ShareController = Class.extend( /** @lends ShareController */ {
- /**
- * @desc Constructor for ShareController.
- * @constructs ShareController
- * @extends Class
- * @public
- * @param {object} options
- * @param {object} options.slideout The share panel slideout
- * @param {object} options.glassContext The glass context
- * @param {object} options.logger The logger service
- * @param {function} options.errorHandler Function to call when an error occurs
- */
- init: function (options) {
- ShareController.inherited('init', this, arguments);
- this.slideout = options.slideout;
- this.glassContext = options.glassContext;
- this._shareableItems = new ShareableItems(options);
- this._connectors = new Connectors(options);
- this.perspective = (this.glassContext && typeof this.glassContext.getCurrentContentView === 'function') ?
- this.glassContext.getCurrentContentView().perspective : '';
- },
- /**
- * @instance
- * @returns {promise}
- */
- getConnectors: function () {
- return this._connectors.discover();
- },
- /**
- * @instance
- * @returns perspective
- */
- getPerspective: function () {
- return this.perspective;
- },
- /**
- * @instance
- * @returns {promise}
- */
- getScreenshot: function (context) {
- return this._shareableItems.getScreenshot(context);
- },
- /**
- * @instance
- * @returns {promise}
- */
- canCaptureImage: function(context) {
- return this._shareableItems.canCaptureImage(context);
- },
- /**
- * @instance
- * @returns {promise}
- */
- getLink: function (context) {
- return this._shareableItems.getLink(context);
- },
- /**
- * @instance
- * @returns {promise}
- */
- close: function () {
- return Promise.resolve();
- },
- /**
- * Gets localized strings for asset properties such as type and title.
- * @return {{assetTitle: string, assetSubTitle: string, assetType: string, assetSubTitleObj: object}}
- */
- getAssetStrings: function () {
- const view = this.glassContext.getCurrentContentView();
- const type = this.slideout && this.slideout.content && this.slideout.content.type;
- return {
- assetType: type ? type.assetType : this.getAssetType(view.perspective),
- assetTitle: type ? type.assetTitle : (view.getTitle && view.getTitle()),
- assetSubTitle: this.getSubviewTitle(view),
- assetSubTitleObj: this.getSubviewTitleObj(view)
- };
- },
- /**
- * @instance
- * @param {object} connector
- * @param {object} data
- * @returns {promise}
- */
- send: function (connector, data) {
- return connector.send(Object.assign(data, this.getAssetStrings()));
- },
- /**
- * Gets asset subview title.
- * @param {string} view
- * @return {string}
- */
- getSubviewTitle: function (view) {
- var func = PERSPECTIVE_SUBTITLE_MAP[view.perspective];
- return func && func(view);
- },
- /**
- * Gets asset subview title of the object.
- * @param {string} view
- * @return {string}
- */
- getSubviewTitleObj: function (view) {
- var func = PERSPECTIVE_SUBTITLE_OBJ_MAP[view.perspective];
- return func && func(view);
- },
- /**
- * Gets asset type by perspective
- * @param {string} perspective
- * @return {string}
- */
- getAssetType: function (perspective) {
- return AssetTypeUtil.getLocalizedTypeByPerspective(perspective);
- },
- /**
- * Notifies share action controller after share slideout shows.
- *
- * @instance
- * @returns {Promise}
- */
- enterShareState: function () {
- return this._shareableItems.enterShareState(_.pick(this, ['slideout', 'glassContext']));
- },
- /**
- * Notifies share action controller after share slideout hides.
- *
- * @instance
- * @returns {Promise}
- */
- leaveShareState: function () {
- return this._shareableItems.leaveShareState(_.pick(this, ['slideout', 'glassContext']));
- },
- /**
- * Asks the share action controller if export is supported.
- *
- * @instance
- * @returns {Promise}
- */
- canExportToPDF: function (glassContext) {
- return this._shareableItems.getActionController(glassContext)
- .then(function (actionController) {
- if (actionController && actionController.canExportToPDF) {
- return actionController.canExportToPDF({ glassContext });
- }
- return false;
- }.bind(this));
- },
- /**
- * Tells the share action controller if export is supported. This will
- * only ever be called if canExportToPDF() returned true
- *
- * @instance
- * @returns {Promise}
- */
- exportToPDF: function (glassContext, pageSize, printFilters) {
- return this._shareableItems.getActionController(glassContext)
- .then(function (actionController) {
- if (actionController && actionController.exportToPDF) {
- return actionController.exportToPDF({ glassContext }, pageSize, printFilters);
- }
- }.bind(this));
- },
- /**
- * Instrument a Share gesture.
- *
- * @instance
- * @returns {Promise}
- */
- getInstrumentation: function (glassContext) {
- return this._shareableItems.getActionController(glassContext)
- .then((actionController) => {
- let instrumentData;
- if (actionController && typeof actionController.getInstrumentation === 'function') {
- instrumentData = actionController.getInstrumentation({ glassContext });
- }
- return instrumentData || {};
- });
- }
- });
- return ShareController;
- });
- </code></pre>
- </article>
- </section>
- </div>
- <nav>
- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="ConnectorBase.html">ConnectorBase</a></li><li><a href="Connectors.html">Connectors</a></li><li><a href="EmailClient.html">EmailClient</a></li><li><a href="EmailConnector.html">EmailConnector</a></li><li><a href="MSTeamsAuth.html">MSTeamsAuth</a></li><li><a href="MSTeamsClient.html">MSTeamsClient</a></li><li><a href="MSTeamsConnector.html">MSTeamsConnector</a></li><li><a href="ShareableItems.html">ShareableItems</a></li><li><a href="ShareController.html">ShareController</a></li><li><a href="ShareView.html">ShareView</a></li><li><a href="SlackAuth.html">SlackAuth</a></li><li><a href="SlackClient.html">SlackClient</a></li><li><a href="SlackConnector.html">SlackConnector</a></li></ul><h3>Interfaces</h3><ul><li><a href="ShareInterface.html">ShareInterface</a></li></ul>
- </nav>
- <br class="clear">
- <footer>
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed May 25 2022 13:54:53 GMT+0000 (UTC)
- </footer>
- <script> prettyPrint(); </script>
- <script src="scripts/linenumber.js"> </script>
- </body>
- </html>
|