123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- 'use strict';
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: Storytelling
- * (C) Copyright IBM Corp. 2014, 2018
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['baglass/core-client/js/core-client/ui/core/Class', 'underscore'], function (Class, _) {
- /**
- * Base controller for scene transitions.
- * Rejects calls while transitions are in progress.
- * Subclasses override '_next' and '_previous' to perform transitions
- */
- var TransitionController = Class.extend({
- _deck: [],
- init: function init() {
- TransitionController.inherited('init', this, arguments);
- },
- jumpTo: function jumpTo(from, to) {
- var _this = this;
- return this._beforeJump(from, to).then(function () {
- return _this._jump(from, to);
- }).then(function () {
- return _this._afterJump(from, to);
- }).then(function () {
- return { overview: to.id === 'end' || to.id === 'start' };
- }).catch(function (err) {
- return _this._afterJump(from, to).then(function () {
- return Promise.reject(err);
- });
- });
- },
- forward: function forward(from, to) {
- var _this2 = this;
- return this._beforeNext(from, to).then(function () {
- return _this2._next(from, to);
- }).then(function () {
- return _this2._afterNext(from, to);
- }).then(function () {
- return { overview: false };
- });
- },
- backward: function backward(from, to) {
- var _this3 = this;
- return this._beforePrevious(from, to).then(function () {
- return _this3._previous(from, to);
- }).then(function () {
- return _this3._afterPrevious(from, to);
- }).then(function () {
- return { overview: false };
- });
- },
- _beforeJump: function _beforeJump(from, to) {
- this._setNextSceneScrollPosition(from, to);
- return Promise.resolve();
- },
- _jump: function _jump() {
- return Promise.resolve();
- },
- _afterJump: function _afterJump() {
- return Promise.resolve();
- },
- _beforeNext: function _beforeNext(from, to) {
- this._setNextSceneScrollPosition(from, to);
- return Promise.resolve();
- },
- _next: function _next() {
- return Promise.resolve();
- },
- _afterNext: function _afterNext() {
- return Promise.resolve();
- },
- _beforePrevious: function _beforePrevious(from, to) {
- this._setNextSceneScrollPosition(from, to);
- return Promise.resolve();
- },
- _previous: function _previous() {
- return Promise.resolve();
- },
- _afterPrevious: function _afterPrevious() {
- return Promise.resolve();
- },
- _setNextSceneScrollPosition: function _setNextSceneScrollPosition(from, to) {
- if (from && to && from.getLayoutView && to.getLayoutView) {
- var fromSceneScrollPosition = from.getLayoutView().$el.scrollTop();
- to.getLayoutView().$el.scrollTop(fromSceneScrollPosition);
- }
- },
- deckScenes: function deckScenes(scenes) {
- var _this4 = this;
- var setOnDeck = function setOnDeck($el) {
- if ($el.length) {
- $el.addClass('onDeck');
- $el.removeClass('hiddenScene');
- }
- };
- _.each(scenes, function (scene) {
- setOnDeck(scene.$el);
- _this4._showWidgets(scene);
- _this4._hideWidgets(scene);
- });
- this._deck = scenes;
- },
- undeckScenes: function undeckScenes(scenes) {
- var _this5 = this;
- var setOffDeck = function setOffDeck($el) {
- if ($el.length) {
- $el.removeClass('onDeck');
- $el.addClass('hiddenScene');
- $el.attr('aria-hidden', 'true');
- }
- };
- _.each(scenes, function (scene) {
- if (!(_this5._deck.indexOf(scene) !== -1)) {
- setOffDeck(scene.$el);
- }
- });
- },
- _hideWidgets: function _hideWidgets(view) {
- if (view && view.getLayoutView) {
- view.getLayoutView().onHide();
- }
- },
- _showWidgets: function _showWidgets(view) {
- if (view && view.getLayoutView) {
- view.getLayoutView().onShow();
- }
- }
- });
- return TransitionController;
- });
- //# sourceMappingURL=TransitionController.js.map
|