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/im/event-handler/src/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/im/event-handler/src/textarea-drag-handler.js
import {EventEmitter} from "main.core.events";
import {Utils} from "im.lib.utils";
import {Type} from "main.core";

export class TextareaDragHandler extends EventEmitter
{
	static events = {
		onHeightChange: 'onHeightChange',
		onStopDrag: 'onStopDrag'
	};

	isDragging: boolean = false;
	minimumHeight: number = 120;
	maximumHeight: number = 400;

	constructor(events)
	{
		super();
		this.setEventNamespace('BX.IM.TextareaDragHandler');
		this.subscribeToEvents(events);

		if (Utils.device.isMobile())
		{
			this.maximumHeight = 200;
		}
	}

	subscribeToEvents(configEvents)
	{
		const events = Type.isObject(configEvents) ? configEvents : {};
		Object.entries(events).forEach(([name, callback]) => {
			if (Type.isFunction(callback))
			{
				this.subscribe(name, callback);
			}
		});
	}

	onStartDrag(event, currentHeight)
	{
		if (this.isDragging)
		{
			return;
		}

		this.isDragging = true;

		event = event.changedTouches ? event.changedTouches[0] : event;

		this.textareaDragCursorStartPoint = event.clientY;
		this.textareaDragHeightStartPoint = currentHeight;

		this.addTextareaDragEvents();
	}

	onTextareaContinueDrag(event)
	{
		if (!this.isDragging)
		{
			return;
		}

		event = event.changedTouches ? event.changedTouches[0] : event;

		this.textareaDragCursorControlPoint = event.clientY;

		const maxPoint = Math.min(this.textareaDragHeightStartPoint + this.textareaDragCursorStartPoint - this.textareaDragCursorControlPoint, this.maximumHeight);
		const newTextareaHeight = Math.max(maxPoint, this.minimumHeight);

		this.emit(TextareaDragHandler.events.onHeightChange, {newHeight: newTextareaHeight});
	}

	onTextareaStopDrag()
	{
		if (!this.isDragging)
		{
			return;
		}

		this.isDragging = false;
		this.removeTextareaDragEvents();

		this.emit(TextareaDragHandler.events.onStopDrag);
	}

	addTextareaDragEvents()
	{
		this.onContinueDragHandler = this.onTextareaContinueDrag.bind(this);
		this.onStopDragHandler = this.onTextareaStopDrag.bind(this);
		document.addEventListener('mousemove', this.onContinueDragHandler);
		document.addEventListener('touchmove', this.onContinueDragHandler);
		document.addEventListener('touchend', this.onStopDragHandler);
		document.addEventListener('mouseup', this.onStopDragHandler);
		document.addEventListener('mouseleave', this.onStopDragHandler);
	}

	removeTextareaDragEvents()
	{
		document.removeEventListener('mousemove', this.onContinueDragHandler);
		document.removeEventListener('touchmove', this.onContinueDragHandler);
		document.removeEventListener('touchend', this.onStopDragHandler);
		document.removeEventListener('mouseup', this.onStopDragHandler);
		document.removeEventListener('mouseleave', this.onStopDragHandler);
	}

	destroy()
	{
		this.removeTextareaDragEvents();
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit