'use strict'; /** * Licensed Materials - Property of IBM * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2014, 2019 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['gemini/dashboard/layout/authoring/views/PageCollectionView', 'baglass/core-client/js/core-client/utils/EventHelper'], function (PageCollectionView) { var SlideShow = PageCollectionView.extend({ layoutName: 'slideshow', init: function init() { SlideShow.inherited('init', this, arguments); this.specializeConsumeView(['onPlaybackNext', 'onPlaybackPrevious']); }, /** * Called when a new scene is added or existing scene is updated * * @param {Object} layoutView The scene layout model that is being added/moved * @param {String} [insertBefore] The id value of the scene model to use as the next sibling * * @returns {Promise} */ add: function add(layoutView, insertBefore) { if (!this.consumeView._hasScene(layoutView.model)) { this._addNewScene(layoutView, insertBefore); } else { this._reorderScenes(layoutView, insertBefore); } // Once the add/update of the scene is done we want to select it return this.consumeView._selectScene(layoutView.model.id); }, /** * Called when a view is removed * * @param node */ removeChild: function removeChild(layoutView) { var model = layoutView.model; // Remove the content nodes layoutView.$el.parent().remove(); this.consumeView._removeScene(model); SlideShow.inherited('remove', this, arguments); }, /** * @param {Object} layoutView The scene layout model that is being added/moved * @param {String} [insertBefore] The id value of the scene model to use as the next sibling */ _addNewScene: function _addNewScene(layoutView, insertBefore) { var model = layoutView.model; var template = this.htmlTemplate.getItemTemplate(this.layoutName, '', model); var sceneContent = this.htmlTemplate.replaceLayoutValues(template, this.model); var htmlNode = document.createElement('div'); htmlNode.innerHTML = sceneContent.trim(); var sceneHtml = htmlNode.firstChild; sceneHtml.appendChild(layoutView.domNode); this.$el.find('.tabCntr').append(sceneHtml); this.consumeView._addScene(model); if (insertBefore) { this._reorderScenes(layoutView, insertBefore); } }, /** * @param {Object} layoutView The scene layout model that is being added/moved * @param {String} [insertBefore] The id value of the scene model to use as the next sibling */ _reorderScenes: function _reorderScenes(layoutView, insertBefore) { var model = layoutView.model; var scene = this.consumeView._getScene(model); scene.$el.detach().append(layoutView.domNode); if (insertBefore) { var beforeScene = this.consumeView._getSceneById(insertBefore); scene.$el.insertBefore(beforeScene.$el); } else { scene.$el.appendTo(this.$el.find('.tabCntr')); } this.consumeView._updateSceneList(model, insertBefore); this.layoutController.eventRouter.trigger('scene:reorder', { model: model, insertBefore: insertBefore }); }, // Overrides consume-mode behavior onPlaybackNext: function onPlaybackNext() { return this; }, onPlaybackPrevious: function onPlaybackPrevious() { return this; } }); return SlideShow; }); //# sourceMappingURL=SlideShow.js.map