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 fade-scale" 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 $(modal_el).removeClass('in'); 72 }); 73 if(title){ 74 $(modal_el).find('.modal-title').show().html(title); 75 } else {
76 $(modal_el).find('.modal-title').hide(); 77 } 78 $(modal_el).addClass('in'); 79 }; 80 81 this.bind = function (selector) { 82 83 $(selector).each(function () { 84 85 if ((new RegExp('[^\.]\.(jpg|jpeg|png|tiff|gif|webp)\\s*$', 'i')).test($(this).attr('href'))) { 86 self.bindGallery(this); 87 } else { 88 89 $(this).off('click').on('click', function () { 90 91 let url = $(this).attr('href'); 92 93 let title = $(this).attr('title'); 94 if (!title) { 95 title = $(this).data('original-title'); 96 } 97 98 let style = $(this).data('style'); 99 let params = $(this).data('params'); 100 101 if (url.charAt(0) === '#') { 102 self.open(url, title, style); 103 } else { 104 self.openAjax(url, params, false, title, style); 105 } 106 107 return false; 108 }); 109 } 110 }); 111 }; 112 113 this.loadPhotoSwipe = function (){ 114 icms.head.addCss('photoswipe'); 115 icms.head.addJs('vendors/photoswipe/photoswipe.min', 'photoswipe_ready'); 116 }; 117 118 this.bindGallery = function(selector){ 119 icms.events.on('photoswipe_ready', function (){ 120 $(selector).jqPhotoSwipe({ 121 maxSpreadZoom: 1, 122 bgOpacity: 0.85, 123 shareEl: false, 124 forceSingleGallery: true 125 }); 126 }); 127 self.loadPhotoSwipe(); 128 }; 129 130 this.openHtml = function(html, title, style, style_body) { 131 $(modal_el).modal('show'); 132 self.showContent(title, html, style, style_body); 133 }; 134 135 this.openIframe = function(url, title){ 136 this.openHtml('<div class="embed-responsive"><iframe class="embed-responsive-item" src="'+url+'"></iframe></div>', title, false, 'p-0'); 137 }; 138 139 this.openAjax = function(url, data, open_callback, title, style){ 140 141 open_callback = open_callback || false; 142 style = style || 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, style); 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.