Server IP : 85.193.89.191 / Your IP : 3.148.117.177 Web Server : Apache System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64 User : bitrix ( 600) PHP Version : 8.1.27 Disable Function : NONE MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/bitrix/www/bitrix/js/ui/tour/src/ |
Upload File : |
import { Type} from 'main.core'; import { Guide } from './guide.js'; class Manager { constructor() { this.guides = new Map(); this.autoStartQueue = []; this.currentGuide = null; } create(options) { options = Type.isPlainObject(options) ? options : {}; const id = options.id; if (!Type.isString(id) && id !== '') { throw new Error("'id' parameter is required.") } if (this.get(id)) { throw new Error("The tour instance with the same 'id' already exists."); } const guide = new Guide(options); this.guides.set(guide, true); return guide; } add(options) { const guide = this.create(options); guide.subscribe("UI.Tour.Guide:onFinish", () => { this.handleTourFinish(guide); }); if (!this.currentGuide) { this.currentGuide = guide; guide.start(); } else { this.autoStartQueue.push(guide); } } /** * @public * @param {string} id * @returns {Guide|null} */ get(id) { return this.guides.get(id); } /** * @public * @param {string} id */ remove(id) { this.guides.delete(id); } /** * @public * @returns {Guide|null} */ getCurrentGuide() { return this.currentGuide; } /** * @private * @param {Guide} guide */ handleTourFinish(guide) { this.currentGuide = null; this.remove(guide.getId()); const autoStartGuide = this.autoStartQueue.shift(); if (autoStartGuide) { this.currentGuide = autoStartGuide; autoStartGuide.start(); } } } export default new Manager();