PageSourceSearch

https://marketmedia.ru/bitrix/js/main/core/core_ui_date.js?15312380194801

js marketmedia.ru collected 2026-10-02 17:26:59 UTC 4,801 bytes, 212 lines download raw bytes

1;(function() {
2	'use strict';
3
4	BX.namespace('BX.Main.ui');
5	BX.namespace('BX.Main.ui.block');
6
7	BX.Main.ui.date = function(node) {
8		this.node = null;
9		this.classControl = 'main-ui-date';
10		this.classButton = 'main-ui-date-button';
11		this.classInput = 'main-ui-date-input';
12		this.classValueDelete = 'main-ui-control-value-delete';
13		this.classHide = 'main-ui-hide';
14		this.button = null;
15		this.input = null;
16		this.valueDeleteButton = null;
17		this.enableTime = false;
18		this.init(node);
19	};
20
21	BX.Main.ui.date.prototype = {
22		init: function(node)
23		{
24			if (BX.type.isDomNode(node) && BX.hasClass(node, this.classControl))
25			{
26				this.node = node;
27				this.enableTime = (BX.data(this.getInput(), 'time') == 'true');
28
29				BX.bind(this.getButton(), 'click', BX.delegate(this.calendar, this));
30				BX.bind(this.getInput(), 'input', BX.delegate(this._onInputInput, this));
31				BX.bind(this.getInput(), 'focus', BX.delegate(this._onInputFocus, this));
32				BX.bind(this.getInput(), 'click', BX.delegate(this._onInputClick, this));
33				BX.bind(this.getValueDeleteButton(), 'click', BX.delegate(this._onValueDeleteButtonClick, this));
34				this.controlDeleteButton();
35			}
36		},
37
38		_onInputInput: function()
39		{
40			this.controlDeleteButton();
41		},
42
43		controlDeleteButton: function()
44		{
45			if (this.getInput().value.length)
46			{
47				BX.removeClass(this.getValueDeleteButton(), this.classHide);
48			}
49			else
50			{
51				BX.addClass(this.getValueDeleteButton(), this.classHide);
52			}
53		},
54
55		_onInputFocus: function(event)
56		{
57			this.isFocus = true;
58			this.eventTimestamp = event.timeStamp;
59			this.calendar();
60		},
61
62		_onInputClick: function(event)
63		{
64			var calendar = this.calendar();
65			var focusTime = new Date(this.eventTimestamp).getSeconds();
66			var clickTime = new Date(event.timeStamp).getSeconds();
67			event.preventDefault();
68			event.stopPropagation();
69
70			if (!this.isFocus || Math.abs(focusTime - clickTime) < 0)
71			{
72				if (calendar.popup.isShown())
73				{
74					this.getNode().click();
75				}
76			}
77
78			this.isFocus = false;
79		},
80
81		_onValueDeleteButtonClick: function(event)
82		{
83			var target = event.currentTarget;
84			var input;
85
86			if (BX.type.isDomNode(target))
87			{
88				input = this.getInput();
89
90				if (BX.type.isDomNode(input))
91				{
92					input.value = '';
93					this.controlDeleteButton();
94				}
95			}
96		},
97
98		getValueDeleteButton: function()
99		{
100			if (!BX.type.isDomNode(this.valueDeleteButton))
101			{
102				this.valueDeleteButton = BX.findChild(this.getNode(), {className: this.classValueDelete}, true, false);
103			}
104
105			return this.valueDeleteButton;
106		},
107
108		calendar: function()
109		{
110			var input = this.getInput();
111			var button = this.getButton();
112
113			var params = {node: button, field: input, bTime: this.enableTime, bHideTime: false, callback_after: BX.delegate(this.controlDeleteButton, this)};
114
115			return BX.calendar(params);
116		},
117
118		getNode: function()
119		{
120			return this.node;
121		},
122
123		getButton: function()
124		{
125			if (!BX.type.isDomNode(this.button))
126			{
127				this.button = BX.findChild(this.getNode(), {class: this.classButton}, true, false);
128			}
129
130			return this.button;
131		},
132
133		getInput: function()
134		{
135			if (!BX.type.isDomNode(this.input))
136			{
137				this.input = BX.findChild(this.getNode(), {class: this.classInput}, true, false);
138			}
139
140			return this.input;
141		}
142	};
143
144
145	BX.Main.ui.block['main-ui-date'] = function(data)
146	{
147		var control, calendarButton, input, valueDelete;
148
149		control = {
150			block: 'main-ui-date',
151			mix: ['main-ui-control'],
152			content: []
153		};
154
155		if ('mix' in data && BX.type.isArray(data.mix))
156		{
157			data.mix.forEach(function(current) {
158				control.mix.push(current);
159			});
160		}
161
162		if ('calendarButton' in data && data.calendarButton === true && (!('type' in data) || 'type' in data && data.type !== 'hidden'))
163		{
164			calendarButton = {
165				block: 'main-ui-date-button',
166				tag: 'span'
167			};
168
169			control.content.push(calendarButton);
170		}
171
172		input = {
173			block: 'main-ui-date-input',
174			mix: ['main-ui-control-input'],
175			tag: 'input',
176			attrs: {
177				type: 'type' in data ? data.type : 'text',
178				name: 'name' in data ? data.name : '',
179				tabindex: 'tabindex' in data ? data.tabindex : '',
180				value: 'value' in data ? data.value : '',
181				placeholder: 'placeholder' in data ? data.placeholder : '',
182				autocomplete: 'off',
183				'data-time': data.enableTime
184			}
185		};
186
187
188		control.content.push(input);
189
190		if ('valueDelete' in data && data.valueDelete === true && (!('type' in data) || 'type' in data && data.type !== 'hidden'))
191		{
192			valueDelete = {
193				block: 'main-ui-control-value-delete',
194				mix: ['main-ui-hide'],
195				content: {
196					block: 'main-ui-control-value-delete-item',
197					tag: 'span'
198				}
199			};
200
201			control.content.push(valueDelete);
202		}
203
204		if (input.attrs.type === 'hidden')
205		{
206			control = input;
207		}
208
209		return control;
210	};
211
212})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.