Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/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.autoStartQueue.push(guide); } else { this.currentGuide = guide; guide.start(); } } /** * @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();