PageSourceSearch

https://anatomystudy.ru/nassets/e6953c0c/js/modal.js?v=1790428180

js anatomystudy.ru collected 2026-09-28 09:02:57 UTC 7,953 bytes, 267 lines download raw bytes

1var createFactory = function() {
2    var active;
3    var initVal = 0;
4
5    var bugfixIosMethod = function() {
6        if ( window.bugfixIosMethodRunned ) {
7            return;
8        }
9        // Detect ios 11_0_x affected
10        // NEED TO BE UPDATED if new versions are affected
11        var ua = navigator.userAgent,
12            iOS = /iPad|iPhone|iPod/.test(ua),
13            iOS11 = /OS 11_0_1|OS 11_0_2|OS 11_0_3|OS 11_1/.test(ua);
14
15        // ios 11 bug caret position
16        if ( iOS && iOS11 ) {
17
18            // Add CSS class to body
19            $("body").addClass("iosBugFixCaret");
20
21        }
22        window.bugfixIosMethodRunned = true;
23    };
24
25    var modal = function(params, $existingModal) {
26        bugfixIosMethod();
27
28        params = undefined === params ? {} : params;
29        var self = this;
30        var isActive = false;
31		var createdFromExisting = false;
32        /** @type boolean */
33        const isLessonRedesignEnabled = window.gcRedesign.isLessonRedesignEnabled;
34
35        var loaderHtml = "<div class='loader'><i class='fa fa-spinner fa-spin'></i></div>";
36        var closeButtonHtml = '<div class="close-btn"><i class="fa fa-times"></i></div>';
37
38        let $modal;
39		if ($existingModal) {
40			$modal = $existingModal;
41			createdFromExisting = true;
42		} else {
43            const modalId = initVal++;
44            const modalContentId = initVal++;
45
46            let redesignModalTitleHtml = '';
47            if (isLessonRedesignEnabled) {
48                redesignModalTitleHtml = `
49                    <div class="gc-modal-title">
50                        <div class="gc-modal-close"></div>
51                    </div>
52                `;
53            }
54
55            const modalHtml = `
56                <div class="modal gc-modal" id="gc-modal-${modalId}">
57                    <div class="modal-dialog">
58                        <div class="modal-content">
59                            <div class="modal-body">
60                               ${redesignModalTitleHtml}
61                               <div class="gc-modal-content" id="gc-modal-content-${modalContentId}">
62                                   ${loaderHtml}
63                               </div>
64                            </div>
65                        </div>
66                    </div>
67                    ${closeButtonHtml}
68                </div>
69            `;
70            $modal = $(modalHtml);
71		}
72
73        if ( params.width) {
74            $modal.find('.modal-dialog').css('max-width', params.width );
75        }
76
77        $modal.on('hide.bs.modal', function (event) {
78            self.setIsActive(false);
79            params.onHide && params.onHide();
80        });
81        $modal.on('show.bs.modal', function (event) {
82            self.setIsActive(true);
83            params.onShow && params.onShow();
84        });
85        $modal.on('hidden.bs.modal', function (event) {
86            $(`#gc-modal-content-${initVal-1} [id^='vhplayeriframe-']`).each(function() {
87                this.contentWindow.postMessage('vh-stop-video', '*');
88            });
89            $(`#gc-modal-content-${initVal-1} .fotorama__video iframe`).each(function() {
90                this.contentWindow.postMessage('vh-stop-video', '*');
91            });
92            $(`#gc-modal-content-${initVal-1} [id*="videoSlider"], #gc-modal-content-${initVal-1} [id*="fotorama"]`).each(function() {
93                $(this).data('fotorama').stopVideo();
94            });
95
96            let activeModals = $(".modal").filter(function () {
97                return $(this).css("display") === "block";
98            });
99            if (activeModals.length > 0) {
100                $('body').addClass('modal-open');
101            }
102        });
103
104        $('.close-btn', $modal).click(function(){
105            $modal.modal('hide');
106        });
107
108        $('.gc-modal-close', $modal).click(() => {
109            $modal.modal('hide');
110        });
111
112        this.isActive = function() {
113            return isActive;
114        };
115
116        this.setIsActive = function(value) {
117            if (value) {
118                active = this;
119            }
120            isActive= value;
121        };
122
123        this.show = function (t) {
124            $modal.modal('show');
125        };
126
127        this.hide = function () {
128            $modal.modal('hide');
129        };
130
131        this.getTopSelector = function() {
132            return '.gc-modal';
133        };
134
135        this.getBodyEl = function() {
136            return $modal.find('.modal-body');
137        };
138
139        this.getContentSelector = function () {
140            return '.gc-modal-content';
141        };
142
143        this.reset = function() {
144            this.setContent(loaderHtml);
145        };
146
147        this.setContent = function(content) {
148            $modal.find(this.getContentSelector()).html(content);
149        };
150
151        this.getContent = function() {
152            return $modal.find(this.getContentSelector()).html();
153        };
154
155        this.getContentEl = function() {
156            return $modal.find(this.getContentSelector());
157        };
158
159        this.getModalEl = function() {
160            return $modal;
161        };
162
163        this.get$Modal = function() {
164            return $modal;
165        };
166
167        this.getId = function() {
168            return this.get$Modal().attr('id');
169        };
170
171        this.getContentId = function() {
172            return this.get$Modal().find('.gc-modal-content').attr('id');
173        };
174
175        this.getFooterEl = function() {
176            if ( ! this.footerEl ) {
177                var $contentEl = this.get$Modal().find('.modal-content');
178
179                this.footerEl = $('<div class="modal-footer"/>');
180                this.footerEl.appendTo( $contentEl );
181            }
182            return this.footerEl;
183        };
184
185        this.setTitle = function( title ) {
186            this.getHeaderEl().html( title );
187        };
188
189        this.headerEl = null;
190        this.getHeaderEl = function() {
191            if ( ! this.headerEl ) {
192                var $contentEl = this.get$Modal().find('.modal-content');
193
194                this.headerEl = $('<div class="modal-header"/>');
195                this.headerEl.prependTo( $contentEl );
196            }
197            return this.headerEl;
198        };
199
200        this.alignVertical = function() {
201            var $dialogEl = $modal.find('.modal-dialog');
202            if ( $dialogEl ) {
203                $dialogEl.css('top', (($(window).height() / 2) - ($dialogEl.height() /2) - 150) + "px" );
204            }
205        };
206
207		this.isCreatedFromExisting = function() {
208			return createdFromExisting;
209		};
210
211		if (!createdFromExisting) {
212			$modal.modal(params);
213		}
214    };
215
216    var factory = function() {
217        var registry = [];
218
219        this.create = function(params) {
220            var w = new modal(params);
221            registry.push(w);
222            return w;
223        };
224
225		this.createFromExisting = function(params, $existingModal) {
226			var w = new modal(params, $existingModal);
227			registry.push(w);
228			return w;
229		};
230    };
231
232    window.gcModalFactory = new factory();
233
234    window.gcModalActive = function() {
235        return active;
236    };
237
238    $(document).keyup(function (event) {
239        if (active && active.isActive) {
240            if (event.keyCode == 27) {
241                active.hide();
242            }
243        }
244    });
245
246    $(document).on('mousedown', function (e) {
247        if (!window.isPageRedesigned) return;
248
249        var $target = $(e.target);
250
251        if ($target.closest('.modal-body').length) return;
252
253        var clickedBackdrop = $target.hasClass('modal-backdrop');
254        var $gcModal = $target.closest('.modal.gc-modal');
255
256        var clickedOutsideContent = $gcModal.length && !$target.closest('.modal-content').length;
257
258        var clickedDialogOutsideContent =
259            $target.hasClass('modal-dialog') && !$target.closest('.modal-content').length;
260
261        if (clickedBackdrop || clickedOutsideContent || clickedDialogOutsideContent) {
262            $('.modal.gc-modal.in').modal('hide');
263        }
264    });
265};
266
267createFactory();

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.