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/ui/uploader/tile-widget/src/components/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/ui/uploader/tile-widget/src/components/error-popup.js
import { Popup } from 'main.popup';
import { Type } from 'main.core';

import type { UploaderError } from 'ui.uploader.core';
import type { BitrixVueComponentProps } from 'ui.vue3';

/**
 * @memberof BX.UI.Uploader
 */
export const ErrorPopup: BitrixVueComponentProps = {
	props: {
		error: {
			type: [Object, String],
		},
		alignArrow: {
			type: Boolean,
			default: true,
		},
		popupOptions: {
			type: Object,
			default(): {}
			{
				return {};
			},
		},
	},
	emits: ['onDestroy'],
	watch: {
		error(newValue): void
		{
			if (this.errorPopup)
			{
				this.errorPopup.destroy();
			}

			this.errorPopup = this.createPopup(newValue);
			this.errorPopup.show();
		},
	},
	created(): void
	{
		this.errorPopup = null;
	},
	mounted(): void
	{
		if (this.error)
		{
			this.errorPopup = this.createPopup(this.error);
			this.errorPopup.show();
		}
	},
	beforeUnmount(): void
	{
		if (this.errorPopup)
		{
			this.errorPopup.destroy();
			this.errorPopup = null;
		}
	},
	methods: {
		createContent(error: UploaderError | string): string
		{
			if (Type.isStringFilled(error))
			{
				return error;
			}
			else if (Type.isObject(error))
			{
				return error.message + '<br>' + error.description;
			}

			return '';
		},

		createPopup(error: UploaderError | string): Popup
		{
			const content = this.createContent(error);
			let defaultOptions;
			if (this.alignArrow && Type.isElementNode(this.popupOptions.bindElement))
			{
				const targetNode = this.popupOptions.bindElement;
				const targetNodeWidth = targetNode.offsetWidth;

				defaultOptions = {
					cacheable: false,
					animation: 'fading-slide',
					content,
					// minWidth: 300,
					events: {
						onDestroy: () => {
							this.$emit('onDestroy', error);
							this.errorPopup = null;
						},
						onShow: function(event) {
							const popup = event.getTarget();
							popup.getPopupContainer().style.display = 'block';

							const popupWidth = popup.getPopupContainer().offsetWidth;
							const offsetLeft = (targetNodeWidth / 2) - (popupWidth / 2);
							const angleShift = Popup.getOption('angleLeftOffset') - Popup.getOption('angleMinTop');

							popup.setAngle({ offset: popupWidth / 2 - angleShift });
							popup.setOffset({ offsetLeft: offsetLeft + Popup.getOption('angleLeftOffset') });
						},
					},
				};
			}
			else
			{
				defaultOptions = {
					cacheable: false,
					animation: 'fading-slide',
					content,
					events: {
						onDestroy: () => {
							this.$emit('onDestroy', error);
							this.errorPopup = null;
						},
					}
				};
			}

			const options = Object.assign({}, defaultOptions, this.popupOptions);

			return new Popup(options);
		},
	},
	template: '<span></span>',
};

Youez - 2016 - github.com/yon3zu
LinuXploit