PageSourceSearch

https://lyuban.by/templates/modern/js/modal.js?1666638717

js lyuban.by collected 2026-09-25 08:26:02 UTC 7,716 bytes, 204 lines download raw bytes

1var icms = icms || {};
2
3icms.modal = (function ($) {
4
5    var self = this;
6
7    var modal_el;
8
9    this.onDocumentReady = function() {
10        /** tinymce prevent bootstrap dialog from blocking focusin **/
11        $(document).on('focusin', function(e) {
12            if ($(e.target).closest(".tox-tinymce, .tox-tinymce-aux, .moxman-window, .tam-assetmanager-root").length) {
13                e.stopImmediatePropagation();
14            }
15        });
16        self.render();
17        self.bind('a.ajax-modal');
18        self.bind('.ajax-modal > a');
19        $('.ajax-modal').addClass('ajax-modal-ready');
20    };
21
22    this.render = function (){
23        $('body').prepend('<div class="modal" id="icms_modal" tabindex="-1" role="dialog" aria-modal="true"><div id="icms-modal-spinner" class="h-100 d-flex"><div class="sk-circle  m-auto"><div class="sk-circle1 sk-child"></div><div class="sk-circle2 sk-child"></div><div class="sk-circle3 sk-child"></div><div class="sk-circle4 sk-child"></div><div class="sk-circle5 sk-child"></div><div class="sk-circle6 sk-child"></div><div class="sk-circle7 sk-child"></div><div class="sk-circle8 sk-child"></div><div class="sk-circle9 sk-child"></div><div class="sk-circle10 sk-child"></div><div class="sk-circle11 sk-child"></div><div class="sk-circle12 sk-child"></div></div></div><div class="modal-dialog modal-lg modal-primary" role="document" style="display: none;"><div class="modal-content"><div class="modal-header"><h4 class="modal-title text-truncate"></h4><button class="btn ml-auto text-white modal-close p-0" type="button" data-dismiss="modal"><svg viewBox="0 0 352 512"><path d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"></path></svg></button></div><div class="modal-body"></div></div></div></div>');
24        modal_el = $('#icms_modal');
25        $(modal_el).on('hidden.bs.modal', function (e) {
26            self.onHide();
27        });
28        return this;
29    };
30
31    this.onHide = function (){
32        $('#icms-modal-spinner', modal_el).addClass('d-flex').removeClass('d-none');
33        $(modal_el).find('.modal-dialog').hide().find('.modal-body').html('');
34        $(modal_el).find('.modal-title').html('');
35        $(modal_el).find('.modal-header').show();
36        icms.forms.form_changed = false;
37        return this;
38    };
39
40    this.showSpinner = function (){
41        $(modal_el).modal('show'); return this;
42    };
43
44	this.open = function (selector, title, style) {
45        $(modal_el).modal('show');
46        var parent = $(selector).parent();
47        var content = $(selector).detach();
48        self.showContent(title, $(content).clone(true).removeClass('d-none').show(), style);
49        $(modal_el).on('hidden.bs.modal', function (e) {
50            content.appendTo(parent);
51        });
52    };
53
54    this.close = function(){
55        $(modal_el).modal('hide');
56    };
57
58    this.showContent = function (title, content, style, style_body){
59        style = style || false;
60        style_body = style_body || '';
61        if(style){
62            $(modal_el).find('.modal-dialog').addClass('modal-'+style);
63            $(modal_el).on('hidden.bs.modal', function (e) {
64                $(modal_el).find('.modal-dialog').removeClass('modal-'+style);
65            });
66        }
67        $('#icms-modal-spinner', modal_el).addClass('d-none').removeClass('d-flex');
68        $(modal_el).find('.modal-dialog').show().find('.modal-body').addClass(style_body).html(content);
69        $(modal_el).on('hidden.bs.modal', function (e) {
70            $(modal_el).find('.modal-body').removeClass(style_body);
71        });
72        if(title){
73            $(modal_el).find('.modal-title').show().html(title);
74        } else {
75            $(modal_el).find('.modal-title').hide();
76        }
77    };
78
79	this.bind = function(selector) {
80
81        $(selector).each(function (){
82
83            var url = $(this).attr('href');
84
85            if((new RegExp('[^\.]\.(jpg|jpeg|png|tiff|gif|webp)\\s*$', 'i')).test(url)){
86                self.bindGallery(this);
87            } else {
88
89                $(this).off('click').on('click', function (){
90
91                    var title = $(this).attr('title');
92                    if(!title){
93                        title = $(this).data('original-title');
94                    }
95
96                    var style = $(this).data('style');
97                    var params = $(this).data('params');
98
99                    if(url.charAt(0) === '#'){
100                        self.open(url, title, style);
101                    } else {
102                        self.openAjax(url, params, false, title);
103                    }
104
105                    return false;
106                });
107
108            }
109
110        });
111
112	};
113
114    this.loadPhotoSwipe = function (){
115        icms.head.addCss('photoswipe');
116        icms.head.addJs('vendors/photoswipe/photoswipe.min', 'photoswipe_ready');
117    };
118
119    this.bindGallery = function(selector){
120        icms.events.on('photoswipe_ready', function (){
121            $(selector).jqPhotoSwipe({
122                maxSpreadZoom: 1,
123                bgOpacity: 0.85,
124                shareEl: false,
125                forceSingleGallery: true
126            });
127        });
128        self.loadPhotoSwipe();
129    };
130
131	this.openHtml = function(html, title, style, style_body) {
132        $(modal_el).modal('show');
133		self.showContent(title, html, style, style_body);
134	};
135
136    this.openIframe = function(url, title){
137        this.openHtml('<div class="embed-responsive"><iframe class="embed-responsive-item" src="'+url+'"></iframe></div>', title, false, 'p-0');
138    };
139
140    this.openAjax = function(url, data, open_callback, title){
141
142        open_callback = open_callback || false;
143        title = title || false;
144        data = data || {};
145
146        if(data.is_iframe){
147            return this.openIframe(url+'?'+$.param(data), title);
148        }
149
150        this.showSpinner();
151
152        $.ajax({
153            url: url,
154            method: 'POST',
155            data: data,
156            beforeSend: function(request) {
157                request.setRequestHeader('ICMS-Request-Type', 1);
158            },
159            success: function(result){
160                self.showContent(title, result);
161                if(open_callback){
162                    open_callback();
163                }
164            },
165            error: function(result){
166                self.showContent(title, $('#data-wrap', result.responseText).html(), false, 'bg-dark');
167            },
168            dataType: 'html'
169        });
170
171        return false;
172    };
173
174    this.setCallback = function(event, callback){
175        switch(event){
176            case 'open':
177                $(document).on('shown.bs.modal', '#icms_modal', function (e) {
178                    callback();
179                });
180                break;
181            case 'close':
182                $(document).on('hidden.bs.modal', '#icms_modal', function (e) {
183                    callback();
184                });
185                break;
186        }
187    };
188
189    this.resize = function(){
190        $(modal_el).modal('handleUpdate');
191    };
192
193    this.setHeight = function(height){};
194
195	this.alert = function(text, type) {
196        type = type || 'primary';
197        type = type.replace('ui_', '');
198        type = type.replace('error', 'danger');
199		this.openHtml('<div class="alert alert-'+type+' border-0 rounded-0 m-n3">'+text+'</div>', '<b>ⓘ</b>', type);
200	};
201
202	return this;
203
204}).call(icms.modal || {},jQuery);

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.