'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