// (C) Copyright 2015 Martin Dougiamas // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. import { Component } from '@angular/core'; import { IonicPage, ViewController, NavParams } from 'ionic-angular'; /** * Modal that renders the lesson menu and media file. */ @IonicPage({ segment: 'addon-mod-lesson-menu-modal' }) @Component({ selector: 'page-addon-mod-lesson-menu-modal', templateUrl: 'menu-modal.html', }) export class AddonModLessonMenuModalPage { /** * The instance of the page that opened the modal. We use the instance instead of the needed attributes for these reasons: * - We want the user to be able to see the media file while the menu is being loaded, so we need to be able to update * the menu dynamically based on the data retrieved by the page that opened the modal. * - The onDidDismiss function takes a while to be called, making the app seem slow. This way we can directly call * the functions we need without having to wait for the modal to be dismissed. * @type {any} */ pageInstance: any; constructor(params: NavParams, protected viewCtrl: ViewController) { this.pageInstance = params.get('page'); } /** * Close modal. */ closeModal(): void { this.viewCtrl.dismiss(); } /** * Load a certain page. * * @param {number} pageId The page ID to load. */ loadPage(pageId: number): void { this.pageInstance.changePage && this.pageInstance.changePage(pageId); this.closeModal(); } }