PageSourceSearch

https://vasilinaref.ru/nassets/f5a1761/notice.js?v=1784624046

js vasilinaref.ru collected 2026-09-26 09:52:59 UTC 7,770 bytes, 245 lines download raw bytes

1if (typeof window.tt !== 'function') {
2	window.tt = function (category, text, params) {
3		return (typeof Yii !== 'undefined' && typeof Yii.t === 'function')
4			? Yii.t(category, text, params)
5			: text;
6	};
7}
8
9jQuery.widget( 'gc.noticeWidget', {
10	containerElemDOMSelector: '.gc-both-main-content',
11
12	isRedesign: false,
13	options: {
14		needLoad: false,
15	},
16
17	_create: function() {
18		var self = this;
19		this.load();
20	},
21	load: function() {
22	},
23
24	setContainer: function(selector) {
25		this.containerElemDOMSelector = selector;
26	},
27	setIsRedesign: function (isRedesign) {
28		this.isRedesign = isRedesign;
29	},
30
31	getContainer: function() {
32		return this.containerElemDOMSelector;
33	},
34
35	addNotice: function( noticeData ) {
36		this.showNotice( noticeData );
37	},
38
39	showNotice: function( noticeData ) {
40
41		switch( noticeData.type ) {
42			case "modal":
43				this.showModal( noticeData );
44            	break;
45			default:
46				this.showTopPanel( noticeData );
47				break;
48		}
49	},
50
51	showTopPanel: function( noticeData ) {
52		var self = this;
53
54		var $el = $('<div class="notice-top-panel"></div>')
55		$el.addClass( 'gc-into-main-content' );
56		if (this.isRedesign) {
57			$el.addClass('redesigned-notice-top-panel');
58			$el.addClass('redesigned-notice-' + noticeData.messageType);
59		}
60		//$el.addClass('alert alert-' + noticeData.messageType )
61
62		$el.html( noticeData.text );
63		if (this.isRedesign) {
64			$el.html('<div class="redesigned-notice-content"><span class="redesigned-notice-text">' + noticeData.text + '</span></div>');
65		}
66
67		if ( noticeData.button ) {
68			$buttonEl = $('<button class="btn btn-default">' +  noticeData.button + '</button>')
69			if (this.isRedesign) {
70				$buttonEl.addClass('rd-btn rd-btn-notice');
71				$buttonEl.appendTo($el.find('.redesigned-notice-content'));
72			} else {
73				$buttonEl.appendTo( $el )
74			}
75		}
76
77        if (this.isRedesign) {
78            window.recountInformers = function () {
79                const container = $('#redesignedNoticeTopPanel');
80                const currentInformers = container.children('.notice-top-panel:visible');
81                const counterNode = $('#redesignedNoticeTopPanel .notice-top-panel .notice-count');
82                if (!counterNode) return;
83                if (currentInformers.length > 1) {
84                    counterNode.text(
85                        '+' + window.tt('apps.teach', '{n} уведомление|{n} уведомления', (currentInformers.length - 1))
86                    );
87                } else {
88                    counterNode.remove();
89                }
90            }
91        }
92
93		if (noticeData.showCloseControl) {
94			$closeEl = $('<span class="close-link">&times;</span>');
95            const isRedesign = this.isRedesign;
96			if (isRedesign) {
97				let fillColor = noticeData.messageType === 'important' ? 'white' : 'black';
98				const svgClose = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
99				<path fill-rule="evenodd" clip-rule="evenodd" d="M11.4237 10.0005L15.9137 5.51039L14.9945 4.59116L10.5044 9.08124L6.01433
100				 4.59116L5.09509 5.51039L9.58517 10.0005L5.09509 14.4906L6.01433 15.4098L10.5044 10.9197L14.9945 15.4098L15.9137 14.4906L11.4237 10.0005Z" fill="${fillColor}"/></svg>`;
101				$closeEl = $(`<span class="close-link">${svgClose}</span>`);
102			}
103			$closeEl.prependTo($el);
104
105			$closeEl.click( function(e) {
106				$el.hide();
107				e.preventDefault();
108				e.stopPropagation();
109
110                if (isRedesign) {
111                    window.recountInformers();
112                } else {
113					$('.margin-top-notice, .margin-top-notice-style').remove();
114				}
115			});
116		}
117
118		if (self.isRedesign) {
119            $el.appendTo($('#redesignedNoticeTopPanel'));
120
121        } else {
122			$el.appendTo($(self.getContainer()));
123			$(self.getContainer()).prepend($('<div class="margin-top-notice"></div>').css({"margin-top": (Math.floor($el.height() * 2)) + "px"}));
124
125			if (location.pathname.indexOf('/pl/helpdesk/helpdesk') !== -1) {
126				$(
127					'<style class="margin-top-notice-style" type="text/css">.v-application__wrap '
128						+ '{ min-height: calc(100dvh - ' + Math.floor($el.height() * 2) + 'px) !important; }</style>'
129				).appendTo($(self.getContainer()));
130			}
131		}
132
133		var isOpen = $('#' + noticeData.popupType).is(':visible');
134
135		if ( noticeData.popupType && noticeData.showPopupByTimeout && !isOpen) {
136			if (document.cookie.indexOf(noticeData.popupType) == -1) {
137				window.setTimeout(function() {
138					document.cookie = noticeData.popupType + "=true";
139
140					if (!isOpen) {
141						gcFixIncident('show-modal-by-time', noticeData.showPopupByTimeout + '');
142						self.openPopup(noticeData);
143					}
144				}, noticeData.showPopupByTimeout * 1000);
145			}
146		}
147
148		if (noticeData.noticeActionJs) {
149			eval(noticeData.noticeActionJs);
150		}
151
152		$el.click( function() {
153			if ( noticeData.popupType ) {
154				self.openPopup( noticeData );
155			}
156			if ( noticeData.callback ) {
157				noticeData.callback();
158			}
159			else {
160				eval( noticeData.actionJs );
161			}
162		} );
163	},
164
165	showModal: function( noticeData ) {
166	},
167
168	openPopup: function( noticeData ) {
169		var self = this;
170        var isPageRedesigned = window.isPageRedesigned || window.isAccountRedesignEnabledForNotice;
171        if (isPageRedesigned) {
172            var url = "/pl/cms/popup/get?isRedesign=1&type=" + noticeData.popupType +
173                '&parentUrl=' + window.encodeURIComponent(noticeData.parentUrl);
174        } else {
175            var url = "/pl/cms/popup/get?type=" + noticeData.popupType +
176                '&parentUrl=' + window.encodeURIComponent(noticeData.parentUrl)
177        }
178		ajaxCall( url, {}, {}, function( response ) {
179			if ( ! self.modal ) {
180				self.modal = window.gcModalFactory.create({show: false, width: response.data.width });
181				self.modal.getModalEl().addClass( 'gc-notice-modal' )
182                if (self.isRedesign) {
183                    self.modal.getModalEl().addClass( 'rd-notice-modal' )
184                }
185			}
186            if ( response.data.title ) {
187                self.modal.getHeaderEl().html( response.data.title );
188            }
189            self.modal.setContent( response.data.html );
190            self.modal.getModalEl().find('.modal-dialog').css('top', response.data.topMargin);
191            self.modal.show();
192            //self.modal.alignVertical();
193
194            self.initModal( noticeData.popupType, self.modal.getContentEl() );
195        });
196
197		//alert( noticeData.popupType )
198	},
199
200	initModal: function( type, $contentEl ) {
201		var self = this;
202
203		$contentEl.find('.btn-cancel-modal').click( function() {
204            self.modal.hide();
205        })
206
207        if (this.isRedesign) {
208            const $modal = $('.modal-backdrop');
209            const $modalContent = $('.gc-modal');
210            const $closeBtn = $modalContent.find('.close-btn');
211            $modal.addClass( 'rd-notice-modal-backdrop' )
212
213            $modal.on('click', function (event) {
214                if (!$modalContent.is(event.target) && !$modalContent.has(event.target).length) {
215                    $closeBtn.trigger('click');
216                }
217            });
218        }
219
220		$contentEl.find( 'form' ).submit( function() {
221
222			var data = $(this).serialize();
223			var $form = $(this);
224
225			$form.addClass('loading')
226			$contentEl.find('.error-block').hide();
227
228			ajaxCall( "/pl/cms/popup/process?type=" + type, data, {}, function( response ) {
229				if ( response.data.htmlErrorMessage ) {
230                    $contentEl.find('.error-block').html( response.data.htmlErrorMessage );
231                    $contentEl.find('.error-block').show();
232                }
233				if ( response.data.htmlAfterProcess ) {
234					var $addEl = $(response.data.htmlAfterProcess);
235					$addEl.appendTo( $contentEl );
236				}
237			}, function() {
238				$form.removeClass('loading')
239			} );
240
241			return false;
242		})
243	}
244} );
245

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.