SlideShow.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: Storytelling
  5. * (C) Copyright IBM Corp. 2014, 2019
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. define(['./SceneLayout', '../../navigation/NavigationController', '../../navigation/slideShow/AnimatedPathSlideShowTransitionController', '../../navigation/slideShow/SlideShowTransitionController', '../../navigation/slideShow/NoTransitionSlideShowTransitionController', '../../navigation/slideShow/SlideShowSceneLoader', 'text!./templates/SlideShow.html', 'text!./templates/SlideShowItems.html', 'underscore', '../../StoryService'], function (SceneLayout, NavigationController, AnimatedPathSlideShowTransitionController, SlideShowTransitionController, NoTransitionSlideShowTransitionController, SceneLoader, SlideShowTemplate, SlideShowItemsTemplate, _, StoryService) {
  9. var SlideShow = SceneLayout.extend({
  10. _pageNavigationController: null,
  11. transitionControllers: {
  12. animatedPath: AnimatedPathSlideShowTransitionController,
  13. scaleAndSlide: SlideShowTransitionController,
  14. none: NoTransitionSlideShowTransitionController
  15. },
  16. init: function init() {
  17. SlideShow.inherited('init', this, arguments);
  18. // upgrade older stories to use sweep transition
  19. if (!this.model.transition) {
  20. this.model.transition = 'scaleAndSlide';
  21. }
  22. // upgrade older stories to use animatedPath transition
  23. if (this.model.transition === 'progressive') {
  24. this.model.transition = 'animatedPath';
  25. }
  26. this._sceneLoader = new SceneLoader({
  27. logger: this.logger,
  28. dashboardApi: this.dashboardApi,
  29. layoutController: this.layoutController
  30. });
  31. this.transitionController = this.transitionControllers[this.model.transition];
  32. this._pageNavigationController = new NavigationController({
  33. sceneLayoutApi: this.getSceneLayoutApi(),
  34. transitionController: new this.transitionController({
  35. timeline: this.model.boardModel.timeline
  36. }),
  37. logger: this.logger,
  38. sceneLoader: this._sceneLoader
  39. });
  40. this.model.on('change:transition', this._setTransitionController, this);
  41. },
  42. destroy: function destroy() {
  43. this._sceneLoader.stopBackgroundLoad();
  44. SlideShow.inherited('destroy', this, arguments);
  45. },
  46. onLayoutReady: function onLayoutReady() {
  47. SlideShow.inherited('onLayoutReady', this, arguments);
  48. // Set the selected sceneId to the first scene in the list
  49. if (this.sceneId === null) {
  50. this.sceneId = this._scenes[0].id;
  51. }
  52. this._setupNavigationEvents();
  53. return this.onSceneSelected({
  54. modelId: this.sceneId,
  55. play: false
  56. });
  57. },
  58. getProperties: function getProperties() {
  59. var _this = this;
  60. return SlideShow.inherited('getProperties', this, arguments).then(function (properties) {
  61. properties.push({
  62. 'type': 'DropDown',
  63. 'label': _this.stringResources.get('sceneTransitionPropertyLabel'),
  64. 'name': 'sceneTransition',
  65. 'id': 'sceneTransition',
  66. 'defaultValue': _this.model.get('transition'),
  67. 'options': [{ label: _this.stringResources.get('noSceneTransitionLabel'), value: 'none' }, { label: _this.stringResources.get('animatedPathSceneTransitionLabel'), value: 'animatedPath' }, { label: _this.stringResources.get('sweepSceneTransitionLabel'), value: 'scaleAndSlide' }],
  68. 'tabName': _this.stringResources.get('tabName_general'),
  69. 'sectionName': _this.stringResources.get('scenesPropertiesSection'),
  70. 'coachMark': {
  71. render: function render(options) {
  72. var coachMarkOptions = {
  73. id: 'com.ibm.bi.dashboard.storyProperties.animatedPath',
  74. title: _this.stringResources.get('animatedPathCoachmarkTitle'),
  75. contents: _this.stringResources.get('animatedPathCoachmarkContents'),
  76. placement: 'top',
  77. domElement: options.$el[0]
  78. };
  79. _this.dashboardApi.prepareGlassOptions(coachMarkOptions);
  80. var coachMarkApi = _this.dashboardApi.getFeature('CoachMark');
  81. coachMarkApi.addCoachMark(coachMarkOptions);
  82. }
  83. },
  84. 'onChange': function onChange(propertyName, propertyValue) {
  85. if (_this.model.layoutPositioning !== 'relative') {
  86. _this._updateStory(propertyValue);
  87. } else {
  88. _this._changeTransition(propertyValue);
  89. }
  90. }
  91. });
  92. return properties;
  93. });
  94. },
  95. _updateStory: function _updateStory(propertyValue) {
  96. var storyService = new StoryService({
  97. dashboardApi: this.dashboardApi
  98. });
  99. storyService.updateStory({
  100. boardModel: this.model.boardModel,
  101. targetInfo: {
  102. type: 'slideshow',
  103. transition: propertyValue
  104. }
  105. });
  106. },
  107. _changeTransition: function _changeTransition(propertyValue) {
  108. var data = {
  109. undoRedoTransactionId: _.uniqueId('layout_transitionChange_')
  110. };
  111. this.model.set({
  112. transition: propertyValue
  113. }, {
  114. sender: this,
  115. payloadData: data
  116. });
  117. },
  118. _setupNavigationEvents: function _setupNavigationEvents() {
  119. this.$el.on('swiperight', this._onPlaybackPrevious.bind(this)).on('swipeleft', this._onPlaybackNext.bind(this));
  120. },
  121. _setTransitionController: function _setTransitionController(payload) {
  122. this.transitionController = this.transitionControllers[this.model.transition];
  123. this._pageNavigationController.setTransitionController(new this.transitionController({ timeline: this.model.boardModel.timeline }));
  124. this._refreshPropertiesPane(payload);
  125. },
  126. _refreshPropertiesPane: function _refreshPropertiesPane(payload) {
  127. if (payload && payload.sender === 'UndoRedoController') {
  128. this.eventRouter.trigger('properties:refreshPane');
  129. }
  130. }
  131. });
  132. /* used by HtmlTemplates.js */
  133. SlideShow.getTemplate = function () {
  134. return [SlideShowTemplate, SlideShowItemsTemplate];
  135. };
  136. return SlideShow;
  137. });
  138. //# sourceMappingURL=SlideShow.js.map