403Webshell
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/location/widget/src/autocomplete/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/location/widget/src/autocomplete/menu.js
import {Menu as MainMenu} from 'main.popup';
import './css/menu.css';
import MenuBottom from './menubottom';

export default class Menu extends MainMenu
{
	choseItemIdx = -1;
	#bottom;

	constructor(options)
	{
		super(options);

		const elRect = options.bindElement.getBoundingClientRect();
		this.popupWindow.setMaxWidth(elRect.width);
		this.#bottom = new MenuBottom();
		this.layout.menuContainer.appendChild(
			this.#bottom.render()
		);
	}

	isMenuEmpty(): boolean
	{
		return this.menuItems.length <= 0;
	}

	isChoseLastItem(): boolean
	{
		return this.choseItemIdx >= this.menuItems.length - 1;
	}

	isChoseFirstItem(): boolean
	{
		return this.choseItemIdx === 0;
	}

	isItemChosen(): boolean
	{
		return this.choseItemIdx >= 0;
	}

	isDestroyed(): boolean
	{
		return this.getPopupWindow().isDestroyed();
	}

	isItemExist(index: number): boolean
	{
		return typeof this.menuItems[index] !== 'undefined';
	}

	getChosenItem()
	{
		let result = null;

		if(this.isItemChosen() && this.isItemExist(this.choseItemIdx))
		{
			result = this.menuItems[this.choseItemIdx];
		}

		return result;
	}

	chooseNextItem(): void
	{
		if(!this.isMenuEmpty() && !this.isChoseLastItem())
		{
			this.chooseItem(this.choseItemIdx + 1);
		}

		return this.getChosenItem();
	}

	choosePrevItem(): void
	{
		if(!this.isMenuEmpty() && !this.isChoseFirstItem())
		{
			this.chooseItem(this.choseItemIdx - 1);
		}

		return this.getChosenItem();
	}

	highlightItem(index: number): void
	{
		if(this.isItemExist(index))
		{
			const item = this.getChosenItem();

			if(item && item.layout.item)
			{
				item.layout.item.classList.add('highlighted');
			}
		}
	}

	unHighlightItem(index: number): void
	{
		if(this.isItemExist(index))
		{
			const item = this.getChosenItem();

			if(item && item.layout.item)
			{
				item.layout.item.classList.remove('highlighted');
			}
		}
	}

	chooseItem(index: number)
	{
		let idx = index;

		if(idx < 0)
		{
			idx = this.menuItems.length - 1;
		}
		else if(idx > this.menuItems.length - 1)
		{
			idx = 0;
		}

		this.unHighlightItem(this.choseItemIdx);
		this.choseItemIdx = idx;
		this.highlightItem(this.choseItemIdx);
	}

	clearItems()
	{
		while(this.menuItems.length > 0)
		{
			this.removeMenuItem(this.menuItems[0].id);
		}
	}

	isShown(): boolean
	{
		return this.getPopupWindow().isShown();
	}

	setBottomRightItemNode(node: Element): void
	{
		this.#bottom.setRightItemNode(node);
	}

	setBottomLeftItemNode(node: Element): void
	{
		this.#bottom.setLeftItemNode(node);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit