PageSourceSearch

https://kapitan16.ru/bitrix/components/aspro/marketing.popup/js/script.js

js kapitan16.ru collected 2026-10-07 17:41:40 UTC 6,256 bytes, 253 lines download raw bytes

1window.appAspro = window.appAspro || {}
2
3if (!window.appAspro.marketing) {
4	window.appAspro.marketing = {
5		inited: false,
6		showPopup: function (action = '') {
7			let selectorPopups = '.dyn_mp_jqm' + (action ? '[data-js-action="leave"]' : ':not([data-js-action])');
8			let popupItems = $(selectorPopups);
9			if(popupItems.length)
10			{
11				var allDelays = [];
12				popupItems.each(function(i, el) {
13					var jqmBlock = $(el),
14						delay = 0;
15		
16					if(!jqmBlock.hasClass('initied')) // first load
17					{
18						jqmBlock.addClass('initied');
19						
20						if(jqmBlock.data('param-delay'))
21							delay = jqmBlock.data('param-delay')*1000;
22		
23						while(allDelays.indexOf(delay) !== -1) {
24							delay += 100;
25						}
26		
27						allDelays.push(delay);
28		
29						if(typeof localStorage !== 'undefined')
30						{
31							let lsKey = jqmBlock.data('ls');
32							var dataLS = localStorage.getItem(lsKey),
33								ls = '';
34							try{
35								ls = JSON.parse(dataLS);
36							}
37							catch(e){
38								ls = dataLS
39							}
40		
41							let bShowOnCurrentDevice = true;
42							try {
43								let mediaSelector = jqmBlock.data('media-query');
44								if (mediaSelector) {
45									if (!matchMedia(mediaSelector).matches) { 
46										bShowOnCurrentDevice = false;
47									}
48								}
49							} catch (error) {
50							}
51		
52							if(bShowOnCurrentDevice && (!ls || (ls && (ls.SHOW_ALWAYS === 'Y' || (ls.TIMESTAMP < Date.now() && ls.TIMESTAMP)))))
53							{
54								timeoutID = setTimeout(function(){
55									jqmBlock.click();
56								}, delay);
57							}
58							if (ls && (ls.SHOW_ALWAYS === 'N' && (ls.TIMESTAMP < Date.now() && ls.TIMESTAMP))) { 
59								ls.SHOW_ALWAYS = 'Y';
60								localStorage.setItem(lsKey, JSON.stringify(ls));
61							}
62						}
63						else
64						{
65							var ls = $.cookie(jqmBlock.data('ls'));
66							if(!ls)
67							{
68								timeoutID = setTimeout(function(){
69									jqmBlock.click();
70								}, delay);
71							}
72						}
73		
74					}
75					else // ajax popup
76					{
77						
78					}
79		
80				});
81			}
82		},
83		
84		stopShowAlways: function (lsKey) { 
85			if(typeof localStorage !== 'undefined')
86			{
87				let dataLS = localStorage.getItem(lsKey),
88					ls = '';
89				try{
90					ls = JSON.parse(dataLS);
91				}
92				catch(e){
93					ls = dataLS
94				}
95				if(ls)
96				{
97					ls.SHOW_ALWAYS = 'N';
98					localStorage.setItem(lsKey, JSON.stringify(ls));
99				}
100			}
101		
102		},
103		
104		checkStopAction: function (lsKey, action) {
105			let allStopActions = $('.dyn_mp_jqm[data-ls=' + lsKey + ']').data('stop-actions');
106			let bNeedStopShow = false;
107		
108			if (allStopActions) {
109				let arStopActions = allStopActions.split(',');
110				bNeedStopShow = arStopActions.indexOf(action) !== -1;
111			}
112		
113			return bNeedStopShow;
114		}, 
115
116		addJSEvents: function () {
117			// client leave site
118			let jsPopupLeave = $('.dyn_mp_jqm[data-js-action="leave"]');
119			if (jsPopupLeave.length) {
120				_this = this;
121				document.addEventListener("mouseleave", function(event){
122					_this.showPopup('leave');
123				});
124			}
125		}
126	}
127}
128
129
130if (!appAspro.marketing.inited) { 
131	appAspro.marketing.inited = true;
132	
133
134	$(document).ready(function () {
135		BX.addCustomEvent("onMarketingPopupClose", function (eventdata) {
136			if (eventdata) {
137				let mpFrame = eventdata.hash.w,
138					popupWrap = mpFrame.find('.marketing-popup'),
139					lsKey = popupWrap.data('ls');
140					
141				if (lsKey) {
142					let bNeedStopShow = appAspro.marketing.checkStopAction(lsKey, 'close');
143	
144					if (bNeedStopShow) {
145						appAspro.marketing.stopShowAlways(lsKey);
146					}
147				}
148			}
149		});
150	
151		BX.addCustomEvent("onMarketingPopupShow", function (eventdata) {
152			if (eventdata) {
153				let hash = eventdata.hash;
154				if (typeof $(hash.t).data("ls") !== " undefined" && $(hash.t).data("ls")) {
155					var ls = $(hash.t).data("ls"),
156						ls_timeout = 0,
157						v = "";
158			
159					if ($(hash.t).data("ls_timeout")) ls_timeout = $(hash.t).data("ls_timeout");
160			
161					ls_timeout = ls_timeout ? Date.now() + ls_timeout * 1000 : "";
162			
163					if (typeof localStorage !== "undefined") {
164						var val = localStorage.getItem(ls);
165						try {
166							v = JSON.parse(val);
167						} catch (e) {
168							v = val;
169						}
170						if (v != null) {
171							localStorage.removeItem(ls);
172						}
173						v = {};
174						v["VALUE"] = "Y";
175						v["TIMESTAMP"] = ls_timeout; // default: seconds for 1 day
176						
177						if ($(hash.t).data("show_always"))
178							v["SHOW_ALWAYS"] = $(hash.t).data("show_always");
179			
180						localStorage.setItem(ls, JSON.stringify(v));
181					} else {
182						var val = $.cookie(ls);
183						if (!val) $.cookie(ls, "Y", { expires: ls_timeout }); // default: seconds for 1 day
184					}
185	
186					var dopClasses = hash.w.find(".marketing-popup").data("classes");
187					if (dopClasses) {
188						hash.w.addClass(dopClasses);
189					}
190				}
191			}
192		});
193
194		appAspro.marketing.showPopup();
195		appAspro.marketing.addJSEvents();
196		
197		if(typeof window.frameCacheVars !== "undefined"){
198			BX.addCustomEvent("onFrameDataReceived", function (json){
199				appAspro.marketing.showPopup();
200				appAspro.marketing.addJSEvents();
201			});
202		}
203	})
204
205	$(document).on('click', '.dyn_mp_jqm_frame [data-marketing-action]', function (e) {
206		let mpFrame = $(this).closest('.dyn_mp_jqm_frame'),
207			popupWrap = $(this).closest('.marketing-popup'),
208			lsKey = popupWrap.data('ls'),
209			bNeedStopShow = false,
210			btnAction = $(this).attr('data-marketing-action'),
211			bLockClose = mpFrame.hasClass('jqm-lock-close');
212			
213		bNeedStopShow = appAspro.marketing.checkStopAction(lsKey, btnAction);
214
215		if (btnAction === 'btn1') {
216			if (bLockClose) {
217				mpFrame.removeClass('jqm-lock-close');
218				bNeedStopShow = true;
219			}
220		} else {
221			let disagreePopup = mpFrame.find('.marketing-popup-disagree');
222
223			if (bLockClose) {
224				if (popupWrap.length) { 
225					popupWrap.hide();
226				}
227				if (disagreePopup.length) { 
228					disagreePopup.removeClass('hidden');
229				}
230				bNeedStopShow = false;
231			}
232		}
233
234		if (bNeedStopShow) { 
235			appAspro.marketing.stopShowAlways(lsKey);
236		}
237
238		mpFrame.jqmHide();
239	});
240
241	$(document).on('click', '.coupon-block', function (e) {
242		let couponText = this.querySelector('.coupon-block__text').textContent.trim();
243
244		if(navigator.clipboard){
245			navigator.clipboard.writeText(couponText).then(() => {
246				// console.log('ok');
247			}).catch(() => {
248				console.log('error copy');
249			});
250		}
251	});
252	
253}

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.