PageSourceSearch

https://mavt.ru/bitrix/js/sale/orderproperties.js?17192957484649

js mavt.ru collected 2026-10-04 00:16:25 UTC 4,649 bytes, 175 lines download raw bytes

1'use strict';
2
3BX.namespace('BX.Sale.PropertyCollection');
4
5BX.Sale.PropertyCollection = (function () {
6
7	// Iterator
8
9	var iterator = function (array)
10	{
11		var i = 0;
12		return function () {return array[i++];};
13	};
14
15	// Group
16
17	var Group = function (group, properties)
18	{
19		this.getId           = function () {return group.ID;};
20		this.getName         = function () {return group.NAME;};
21		this.getSort         = function () {return group.SORT;};
22		this.getPersonTypeId = function () {return group.PERSON_TYPE_ID;};
23		this.getIterator     = function () {return iterator(properties);};
24	};
25
26	// Property
27
28	var Editor = BX.Sale.Input.Manager.Editor;
29
30	var newProperty = function (property, publicMode)
31	{
32		var name = !!publicMode ? 'ORDER_PROP_' + property.ID : 'PROPERTIES[' + property.ID + ']';
33		var me = (property.TYPE == 'LOCATION' && !!publicMode) ? {} : new Editor(name, property);
34		me.getId           = function () {return property.ID;};
35		me.getName         = function () {return property.NAME;};
36		me.getType         = function () {return property.TYPE;};
37		me.isRequired      = function () {return property.REQUIRED === 'Y';};
38		me.isMultiple      = function () {return property.MULTIPLE === 'Y';};
39		me.getGroupId      = function () {return property.PROPS_GROUP_ID;};
40		me.getDescription  = function () {return property.DESCRIPTION;};
41		me.getPersonTypeId = function () {return property.PERSON_TYPE_ID;};
42		me.getAltLocation  = function () {return property.INPUT_FIELD_LOCATION;};
43		me.getSettings	   = function () {return property};
44		return me;
45	};
46
47	// Collection
48
49	var	bizFields = ['IS_EMAIL', 'IS_PAYER', 'IS_LOCATION', 'IS_LOCATION4TAX', 'IS_PROFILE_NAME', 'IS_ZIP', 'IS_PHONE', 'IS_ADDRESS'],
50		bizLength = bizFields.length;
51
52	return function (data)
53	{
54		// private
55
56		var	groups = [],
57			properties = [],
58			propertyIndex = {};
59
60		// temporary
61
62		var	list, length, i, item,
63			groupId, props, groupedProperties = {}, altLocations = [],
64			propertyId, property,
65			bizI, bizName,
66			publicMode = !!data.publicMode;
67
68		// create groups
69
70		list = data.groups;
71
72		for (i in list)
73		{
74			if(!list.hasOwnProperty(i))
75				continue;
76
77			item = list[i];
78			groupId = item.ID;
79
80			props = [];
81			groupedProperties[groupId] = props;
82			groups.push(new Group(item, props));
83		}
84
85		// create properties
86
87		list = data.properties;
88
89		for (i in list)
90		{
91			if(!list.hasOwnProperty(i))
92				continue;
93
94			item = list[i];
95			propertyId = item.ID;
96
97			groupId = item.PROPS_GROUP_ID;
98			property = newProperty(item, publicMode);
99
100			propertyIndex[propertyId] = property;
101			properties.push(property);
102
103			if (groupedProperties.hasOwnProperty(groupId))
104			{
105				groupedProperties[groupId].push(property);
106			}
107			else
108			{
109				throw 'undefined group';
110			}
111
112			if (item.TYPE == 'LOCATION' && item.INPUT_FIELD_LOCATION && !publicMode)
113				altLocations.push(property);
114
115			for (bizI = 0; bizI < bizLength; bizI++)
116			{
117				bizName = bizFields[bizI];
118				if (item[bizName] == 'Y')
119					propertyIndex[bizName] = property;
120			}
121		}
122
123		// assign alternative location field callback
124
125		length = altLocations.length;
126
127		for (i = 0; i < length; i++)
128		{
129			altLocations[i].addEvent('change', function (event, input)
130			{
131				var hasCity = false,
132					valuePath = input.getValuePath(),
133					i = 0, length = valuePath.length;
134
135				for (; i < length; i++)
136				{
137					if (valuePath[i].TYPE == 'CITY')
138					{
139						hasCity = true;
140						break;
141					}
142				}	
143
144				if (!!propertyIndex[input.getAltLocation()])
145					propertyIndex[input.getAltLocation()].setDisabled(hasCity);
146			});
147		}
148
149		// collect garbage
150
151		data = list = item = props = groupedProperties = altLocations = property = null;
152
153		// public interface
154
155		this.getIterator      = function () {return iterator(properties);};
156		this.getGroupIterator = function () {
157			groups.sort(function(a, b){
158				return a.getSort() - b.getSort();
159			});
160			return iterator(groups);
161		};
162
163		this.getById = function (propertyId) {return propertyIndex[propertyId];};
164
165		this.getUserEmail           = function () {return propertyIndex.IS_EMAIL;};
166		this.getPayerName           = function () {return propertyIndex.IS_PAYER;};
167		this.getDeliveryLocation    = function () {return propertyIndex.IS_LOCATION;};
168		this.getTaxLocation         = function () {return propertyIndex.IS_LOCATION4TAX;};
169		this.getProfileName         = function () {return propertyIndex.IS_PROFILE_NAME;};
170		this.getDeliveryLocationZip = function () {return propertyIndex.IS_ZIP;};
171		this.getPhone               = function () {return propertyIndex.IS_PHONE;};
172		this.getAddress             = function () {return propertyIndex.IS_ADDRESS;};
173	};
174
175})();

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.