1 // Copyright (C) 2005 Rod Roark <rod@sunsetsystems.com>
2 // Copyright (C) 2018-2020 Jerry Padgett <sjpadgett@gmail.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
10 define(['jquery'], function ($, root) {
11 let opts_default = {};
15 root.confirm = confirm;
16 root.closeAjax = closeAjax;
23 buttons: data.buttons,
24 allowDrag: data.allowDrag,
25 allowResize: data.allowResize,
26 sizeHeight: data.sizeHeight,
28 resolvePromiseOn: data.resolvePromiseOn,
31 dataType: data.dataType // xml/json/text etc.
34 let title = data.title;
36 return dlgopen('', '', data.size, 300, '', title, opts);
39 function alert(data, title) {
40 title = title ? title : 'Alert';
41 let alertTitle = '<i class="fa fa-warning alert-danger"></i> <span>' + title + '</span>';
42 return dlgopen('', '', 675, 250, '', alertTitle, {
44 {text: '<i class="fa fa-thumbs-up"> OK</i>', close: true, style: 'primary'}
47 html: '<blockquote class="blockquote">' + data + '</blockquote>'
51 function confirm(data, title) {
52 title = title ? title : 'Confirm';
53 let alertTitle = '<i class="fa fa-warning alert-info"></i> <span>' + title + '</span>';
54 return dlgopen('', '', 675, 250, '', alertTitle, {
56 {text: '<i class="fa fa-thumbs-up"> Yes</i>', close: false, id:'confirmYes', style: 'primary btn-sm'},
57 {text: '<i class="fa fa-thumbs-down"> No</i>', close: false, id:'confirmNo', style: 'primary btn-sm'},
58 {text: 'Nevermind', close: true, style: 'secondary'}
61 resolvePromiseOn: 'confirm',
63 html: '<blockquote class="blockquote">' + data + '</blockquote>'
67 function closeAjax() {
76 if (typeof window.xl !== 'function') {
78 await includeScript(utilfn, 'script');
79 })(top.webroot_url + '/library/js/utility.js').then(() => {
80 console.log('Utilities Unavailable! loading:[ ' + utilfn + ' ] For: [ ' + location + ' ]');
83 }(typeof define == 'function' && define.amd ?
85 function (args, mName) {
86 this.dialog = typeof module != 'undefined' && module.exports ?
87 mName(require(args[0], {}), module.exports) :
92 // open a new cascaded window
93 function cascwin(url, winname, width, height, options) {
94 var mywin = window.parent ? window.parent : window;
95 var newx = 25, newy = 25;
96 if (!isNaN(mywin.screenX)) {
97 newx += mywin.screenX;
98 newy += mywin.screenY;
99 } else if (!isNaN(mywin.screenLeft)) {
100 newx += mywin.screenLeft;
101 newy += mywin.screenTop;
103 if ((newx + width) > screen.width || (newy + height) > screen.height) {
107 top.restoreSession();
109 // MS IE version detection taken from
110 // http://msdn2.microsoft.com/en-us/library/ms537509.aspx
111 // to adjust the height of this box for IE only -- JRM
112 if (navigator.appName == 'Microsoft Internet Explorer') {
113 var ua = navigator.userAgent;
114 var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
115 if (re.exec(ua) != null)
116 rv = parseFloat(RegExp.$1); // this holds the version number
117 height = height + 28;
120 retval = window.open(url, winname, options +
121 ",width=" + width + ",height=" + height +
122 ",left=" + newx + ",top=" + newy +
123 ",screenX=" + newx + ",screenY=" + newy);
128 // recursive window focus-event grabber
129 function grabfocus(w) {
130 for (var i = 0; i < w.frames.length; ++i) grabfocus(w.frames[i]);
131 w.onfocus = top.imfocused;
134 // Call this when a "modal" windowed dialog is desired.
135 // Note that the below function is free standing for either
136 // ui's.Use dlgopen() for responsive b.s modal dialogs.
137 // Can now use anywhere to cascade natives...12/1/17 sjp
139 function dlgOpenWindow(url, winname, width, height) {
140 if (top.modaldialog && !top.modaldialog.closed) {
141 if (window.focus) top.modaldialog.focus();
142 if (top.modaldialog.confirm(top.oemr_dialog_close_msg)) {
143 top.modaldialog.close();
144 top.modaldialog = null;
149 top.modaldialog = cascwin(url, winname, width, height,
150 "resizable=1,scrollbars=1,location=0,toolbar=0");
155 // This is called from del_related() which in turn is invoked by find_code_dynamic.php.
156 // Deletes the specified codetype:code from the indicated input text element.
157 function my_del_related(s, elem, usetitle) {
159 // Deleting everything.
166 // Convert the codes and their descriptions to arrays for easy manipulation.
167 var acodes = elem.value.split(';');
168 var i = acodes.indexOf(s);
170 return; // not found, should not happen
172 // Delete the indicated code and description and convert back to strings.
174 elem.value = acodes.join(';');
176 var atitles = elem.title.split(';');
177 atitles.splice(i, 1);
178 elem.title = atitles.join(';');
182 function dialogID() {
184 return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
187 return s4() + s4() + s4() + s4() + s4() + +s4() + s4() + s4();
190 // test for and/or remove dependency.
191 function inDom(dependency, type, remove) {
193 let attr = type === 'script' ? 'src' : type === 'link' ? 'href' : 'none';
194 let all = document.getElementsByTagName(el);
195 for (let i = all.length; i > -1; i--) {
196 if (all[i] && all[i].getAttribute(attr) !== null && all[i].getAttribute(attr).indexOf(dependency) !== -1) {
198 all[i].parentNode.removeChild(all[i]);
199 console.log("Removed from DOM: " + dependency);
209 // test to see if bootstrap theming is loaded (via standard or custom bootstrap library)
210 // Will check for the badge-secondary class
211 // - if exist, then assume bootstrap loaded
212 // - if not exist, then assume bootstrap not loaded
213 function isBootstrapCss() {
214 for (let i = 0; i < document.styleSheets.length; i++) {
215 let rules = document.styleSheets[i].rules || document.styleSheets[i].cssRules;
216 for (let x in rules) {
217 if (rules[x].selectorText == '.badge-secondary') {
225 // These functions may be called from scripts that may be out of scope with top so...
226 // if opener is tab then we need to be in tabs UI scope and while we're at it, let's bring webroot along...
228 if (typeof top.webroot_url === "undefined" && opener) {
229 if (typeof opener.top.webroot_url !== "undefined") {
230 top.webroot_url = opener.top.webroot_url;
233 // We'll need these if out of scope
235 if (typeof top.set_opener !== "function") {
236 var opener_list = [];
238 function set_opener(window, opener) {
239 top.opener_list[window] = opener;
242 function get_opener(window) {
243 return top.opener_list[window];
247 // universal alert popup message
248 if (typeof alertMsg !== "function") {
249 function alertMsg(message, timer = 5000, type = 'danger', size = '', persist = '') {
250 // this xl() is just so cool.
251 let gotIt = xl("Got It");
252 let title = xl("Alert");
253 let dismiss = xl("Dismiss");
254 $('#alert_box').remove();
256 oHidden = !persist ? "hidden" : '';
257 let oSize = (size == 'lg') ? 'left:10%;width:80%;' : 'left:25%;width:50%;';
258 let style = "position:fixed;top:25%;" + oSize + " bottom:0;z-index:9999;";
259 $("body").prepend("<div class='container text-center' id='alert_box' style='" + style + "'></div>");
260 let mHtml = '<div id="alertmsg" class="alert alert-' + type + ' alert-dismissable">' +
261 '<button type="button" class="btn btn-link ' + oHidden + '" id="dontShowAgain" data-dismiss="alert">' +
262 gotIt + ' <i class="fa fa-thumbs-up"></i></button>' +
263 '<h4 class="alert-heading text-center">' + title + '!</h4><hr>' + '<p style="color:#000;">' + message + '</p>' +
264 '<button type="button" class="pull-right btn btn-link" data-dismiss="alert">' + dismiss + '</button><br /></div>';
265 $('#alert_box').append(mHtml);
266 $('#alertmsg').on('closed.bs.alert', function () {
267 clearTimeout(AlertMsg);
268 $('#alert_box').remove();
271 $('#dontShowAgain').on('click', function (e) {
272 persistUserOption(persist, 1);
274 let AlertMsg = setTimeout(function () {
275 $('#alertmsg').fadeOut(800, function () {
276 $('#alert_box').remove();
281 const persistUserOption = function (option, value) {
283 url: top.webroot_url + "/library/ajax/user_settings.php",
285 contentType: 'application/x-www-form-urlencoded',
287 csrf_token_form: top.csrf_token_js,
291 beforeSend: function () {
292 top.restoreSession();
294 error: function (jqxhr, status, errorThrown) {
295 console.log(errorThrown);
302 // Test if supporting dialog callbacks and close dependencies are in scope.
303 // This is useful when opening and closing the dialog is in the same scope. Still use include_opener.js
304 // in script that will close a dialog that is not in the same scope dlgopen was used
305 // or use parent.dlgclose() if known decedent.
306 // dlgopen() will always have a name whether assigned by dev or created by function.
307 // Callback, onClosed and button clicks are still available either way.
308 // For a callback on close use: dlgclose(functionName, farg1, farg2 ...) which becomes: functionName(farg1,farg2, etc)
310 if (typeof dlgclose !== "function") {
315 function dlgclose(call, args) {
316 var frameName = window.name;
318 if (frameName === '') {
319 // try to find dialog. dialogModal is embedded dialog class
320 // It has to be here somewhere.
321 frameName = $(".dialogModal").attr('id');
323 frameName = parent.$(".dialogModal").attr('id');
325 console.log("Unable to find dialog.");
330 var dialogModal = top.$('div#' + frameName);
332 var removeFrame = dialogModal.find("iframe[name='" + frameName + "']");
333 if (removeFrame.length > 0) {
334 removeFrame.remove();
337 if (dialogModal.length > 0) {
339 wframe.setCallBack(call, args); // sets/creates callback function in dialogs scope.
341 dialogModal.modal('hide');
347 * function dlgopen(url, winname, width, height, forceNewWindow, title, opts)
349 * @summary Stackable, resizable and draggable responsive ajax/iframe dialog modal.
351 * @param {url} string Content location.
352 * @param {String} winname If set becomes modal id and/or iframes name. Or, one is created/assigned(iframes).
353 * @param {Number| String} width|modalSize(modal-xl) For sizing: an number will be converted to a percentage of view port width.
354 * @param {Number} height Initial minimum height. For iframe auto resize starts at this height.
355 * @param {boolean} forceNewWindow Force using a native window.
356 * @param {String} title If exist then header with title is created otherwise no header and content only.
357 * @param {Object} opts Dialogs options.
358 * @returns {Object} dialog object reference.
360 function dlgopen(url, winname, width, height, forceNewWindow, title, opts) {
361 // First things first...
362 top.restoreSession();
363 // A matter of Legacy
364 if (forceNewWindow) {
365 return dlgOpenWindow(url, winname, width, height);
368 // wait for DOM then check dependencies needed to run this feature.
369 // dependency duration is while 'this' is in scope, temporary...
370 // seldom will this get used as more of U.I is moved to Bootstrap
371 // but better to continue than stop because of a dependency...
373 let jqurl = top.webroot_url + '/public/assets/jquery/dist/jquery.min.js';
374 if (typeof jQuery === 'undefined') {
376 await includeScript(utilfn, 'script');
380 // Check for dependencies we will need.
381 // webroot_url is a global defined in main_screen.php or main.php.
382 let bscss = top.webroot_url + '/public/assets/bootstrap/dist/css/bootstrap.min.css';
383 let bscssRtl = top.webroot_url + '/public/assets/bootstrap-v4-rtl/dist/css/bootstrap-rtl.min.css';
384 let bsurl = top.webroot_url + '/public/assets/bootstrap/dist/js/bootstrap.bundle.min.js';
386 let version = jQuery.fn.jquery.split(' ')[0].split('.');
387 if ((version[0] < 2 && version[1] < 9) || (version[0] === 1 && version[1] === 9 && version[2] < 1)) {
388 inDom('jquery-min', 'script', true);
390 await includeScript(utilfn, 'script');
391 })(jqurl).then(() => {
392 console.log('Replacing jQuery version:[ ' + version + ' ]');
395 if (!isBootstrapCss()) {
397 await includeScript(utilfn, 'link');
399 if (top.jsLanguageDirection == 'rtl') {
401 await includeScript(utilfn, 'link');
405 if (typeof jQuery.fn.modal === 'undefined') {
406 if (!inDom('bootstrap.bundle.min.js', 'script', false)) {
408 await includeScript(utilfn, 'script');
415 var opts_defaults = {
416 type: 'iframe', // POST, GET (ajax) or iframe
418 frameContent: "", // for iframe embedded content
419 html: "", // content for alerts, comfirm etc ajax
422 sizeHeight: 'auto', // 'full' will use as much height as allowed
423 // use is onClosed: fnName ... args not supported however, onClosed: 'reload' is auto defined and requires no function to be created.
425 callBack: false, // use {call: 'functionName, args: args, args} if known or use dlgclose.
426 resolvePromiseOn: '' // this may be useful values are init, shown, show, confirm, alert and closed which coincide with dialog events.
432 opts = jQuery.extend({}, opts_defaults, opts);
433 opts.type = opts.type ? opts.type.toLowerCase() : '';
434 opts.resolvePromiseOn = opts.resolvePromiseOn ?? 'init';
435 var mHeight, mWidth, mSize, msSize, dlgContainer, fullURL, where; // a growing list...
437 where = (opts.type === 'iframe') ? top : window;
439 // get url straight...
445 if (url[0] === "/") {
448 fullURL = window.location.href.substr(0, window.location.href.lastIndexOf("/") + 1) + url;
452 // what's a window without a name. important for stacking and opener.
453 winname = (winname === "_blank" || !winname) ? dialogID() : winname;
455 // for small screens or request width is larger than viewport.
456 if (where.innerWidth <= 768) {
459 // Convert dialog size to percentages and/or css class.
460 var sizeChoices = ['modal-sm', 'modal-md', 'modal-mlg', 'modal-lg', 'modal-xl', 'modal-full'];
461 if (Math.abs(width) > 0) {
462 width = Math.abs(width);
463 mWidth = (width / where.innerWidth * 100).toFixed(1) + '%';
464 msSize = '<style>.modal-custom-' + winname + ' {max-width:' + mWidth + ' !important;}</style>';
465 mSize = 'modal-custom' + winname;
466 } else if (jQuery.inArray(width, sizeChoices) !== -1) {
467 mSize = width; // is a modal class
469 msSize = '<style>.modal-custom-' + winname + ' {max-width:35% !important;}</style>'; // standard B.S. modal default (modal-md)
471 // leave below for legacy
472 if (mSize === 'modal-sm') {
473 msSize = '<style>.modal-custom-' + winname + ' {max-width:25% !important;}</style>';
474 } else if (mSize === 'modal-md') {
475 msSize = '<style>.modal-custom-' + winname + ' {max-width:40% !important;}</style>';
476 } else if (mSize === 'modal-mlg') {
477 msSize = '<style>.modal-custom-' + winname + ' {max-width:55% !important;}</style>';
478 } else if (mSize === 'modal-lg') {
479 msSize = '<style>.modal-custom-' + winname + ' {max-width:75% !important;}</style>';
480 } else if (mSize === 'modal-xl') {
481 msSize = '<style>.modal-custom-' + winname + ' {max-width:92% !important;}</style>';
482 } else if (mSize === 'modal-full') {
483 msSize = '<style>.modal-custom-' + winname + ' {max-width:97% !important;}</style>';
485 mSize = 'modal-custom-' + winname;
487 // Initial responsive height.
488 var vpht = where.innerHeight;
489 mHeight = height > 0 ? (height / vpht * 100).toFixed(1) + 'vh' : '';
491 // Build modal template. For now !title = !header and modal full height.
492 var mTitle = title > "" ? '<h5 class=modal-title>' + title + '</h5>' : '';
495 '<div class="loadProgress text-center">' +
496 '<span class="fa fa-circle-o-notch fa-spin fa-3x text-primary"></span>' +
500 ('<div class="modal-header">%title%<button type="button" class="close" data-dismiss="modal">' +
501 '×</button></div>').replace('%title%', mTitle);
504 ('<iframe id="modalframe" class="w-100 h-100 modalIframe" name="%winname%" %url% frameborder=0></iframe>').replace('%winname%', winname).replace('%url%', fullURL ? 'src=' + fullURL : '');
506 var bodyStyles = ('style="height:%initHeight%;"').replace('%initHeight%', opts.sizeHeight !== 'full' ? mHeight : '80vh');
508 var altClose = '<div class="closeDlgIframe" data-dismiss="modal" ></div>';
511 ('<div id="%id%" class="modal fade dialogModal" tabindex="-1" role="dialog">%sizeStyle%' +
512 '<style>.drag-resize {touch-action:none;user-select:none;}</style>' +
513 '<div %dialogId% class="modal-dialog %drag-action% %sizeClass%" role="document">' +
514 '<div class="modal-content %resize-action%" style="max-height: 94vh">' + '%head%' + '%altclose%' + '%wait%' +
515 '<div class="modal-body overflow-auto px-1" %bodyStyles%>' + '%body%' + '</div></div></div></div>').replace('%id%', winname).replace('%sizeStyle%', msSize ? msSize : '').replace('%dialogId%', opts.dialogId ? ('id=' + opts.dialogId + '"') : '').replace('%sizeClass%', mSize ? mSize : '').replace('%head%', mTitle !== '' ? headerhtml : '').replace('%altclose%', mTitle === '' ? altClose : '').replace('%drag-action%', (opts.allowDrag) ? 'drag-action' : '').replace('%resize-action%', (opts.allowResize) ? 'resize-action' : '').replace('%wait%', '').replace('%bodyStyles%', bodyStyles).replace('%body%', opts.type === 'iframe' ? frameHtml : '');
517 // Write modal template.
518 dlgContainer = where.jQuery(mhtml);
519 dlgContainer.attr("name", winname);
521 // No url and just iframe content
522 if (opts.frameContent && opts.type === 'iframe') {
523 var ipath = 'data:text/html,' + encodeURIComponent(opts.frameContent);
524 dlgContainer.find("iframe[name='" + winname + "']").attr("src", ipath);
528 dlgContainer.find('.modal-content').append(buildFooter());
531 if (opts.type === 'alert') {
532 dlgContainer.find('.modal-body').html(opts.html);
534 if (opts.type === 'confirm') {
535 dlgContainer.find('.modal-body').html(opts.html);
537 if (opts.type !== 'iframe' && opts.type !== 'alert' && opts.type !== 'confirm') {
540 method: opts.type || '', // if empty and has data object, then post else get.
541 content: opts.data || opts.html, // ajax loads fetched content.
542 url: opts.url || fullURL,
543 dataType: opts.dataType || '' // xml/json/text etc.
546 dialogAjax(params, dlgContainer, opts);
549 // let opener array know about us.
550 top.set_opener(winname, window);
552 // Write the completed template to calling document or 'where' window.
553 where.jQuery("body").append(dlgContainer);
556 return new Promise((resolve, reject) => {
558 // DOM Ready. Handle events and cleanup.
559 if (opts.type === 'iframe') {
560 var modalwin = where.jQuery('body').find("[name='" + winname + "']");
561 jQuery('div.modal-dialog', modalwin).css({'margin': "15px auto auto"});
562 modalwin.on('load', function (e) {
563 setTimeout(function () {
564 if (opts.sizeHeight === 'auto') {
565 SizeModaliFrame(e, height);
566 } else if (opts.sizeHeight === 'fixed') {
569 sizing(e, height); // must be full height of container
574 var modalwin = where.jQuery('body').find("[name='" + winname + "']");
575 jQuery('div.modal-dialog', modalwin).css({'margin': '15px auto auto'});
576 modalwin.on('show.bs.modal', function (e) {
577 setTimeout(function () {
582 if (opts.resolvePromiseOn === 'confirm') {
583 jQuery("#confirmYes").on('click', function (e) {
586 jQuery("#confirmNo").on('click', function (e) {
591 dlgContainer.on('show.bs.modal', function () {
592 if (opts.allowResize || opts.allowDrag) {
593 initDragResize(where.document, where.document);
596 if (opts.resolvePromiseOn === 'show') {
597 resolve(dlgContainer);
599 }).on('shown.bs.modal', function () {
600 // Remove waitHtml spinner/loader etc.
601 jQuery(this).parent().find('div.loadProgress').fadeOut(function () {
602 jQuery(this).remove();
604 dlgContainer.modal('handleUpdate'); // allow for scroll bar
606 if (opts.resolvePromiseOn === 'shown') {
607 resolve(dlgContainer);
609 }).on('hidden.bs.modal', function (e) {
611 e.target.style.cursor = "pointer";
613 jQuery(this).remove();
614 // now we can run functions in our window.
616 console.log('Doing onClosed:[' + opts.onClosed + ']');
617 if (opts.onClosed === 'reload') {
618 window.location.reload();
620 window[opts.onClosed]();
623 if (opts.callBack.call) {
624 console.log('Doing callBack:[' + opts.callBack.call + '|' + opts.callBack.args + ']');
625 if (opts.callBack.call === 'reload') {
626 window.location.reload();
628 window[opts.callBack.call](opts.callBack.args);
632 if (opts.resolvePromiseOn == 'close') {
633 resolve(dlgContainer);
637 // define local dialog close() function. openers scope
638 window.dlgCloseAjax = function (calling, args) {
640 opts.callBack = {call: calling, args: args};
642 dlgContainer.modal('hide'); // important to clean up in only one place, hide event....
646 // define local callback function. Set with opener or from opener, will exe on hide.
647 window.dlgSetCallBack = function (calling, args) {
648 opts.callBack = {call: calling, args: args};
652 // in residents dialog scope
653 where.setCallBack = function (calling, args) {
654 opts.callBack = {call: calling, args: args};
658 where.getOpener = function () {
661 // dialog is completely built and events set
662 // this is default returning our dialog container reference.
663 if (opts.resolvePromiseOn == 'init') {
664 resolve(dlgContainer);
666 // Finally Show Dialog after DOM settles
667 dlgContainer.modal({backdrop: 'static', keyboard: true}, 'show');
669 }); /* Returning Promise */
671 // Ajax call with promise via dialog
672 function dialogAjax(data, $dialog, opts) {
675 method: data.method || '',
678 dataType: data.dataType || 'html'
682 jQuery.extend(params, data);
685 jQuery.ajax(params).done(aOkay).fail(oops);
689 function aOkay(html) {
691 $dialog.find('.modal-body').html(data.success ? data.success(html) : html);
696 function oops(r, s) {
697 var msg = data.error ?
698 data.error(r, s, params) :
699 '<div class="alert alert-danger">' +
700 '<strong>XHR Failed:</strong> [ ' + params.url + '].' + '</div>';
702 $dialog.find('.modal-body').html(msg);
708 function buildFooter() {
709 if (opts.buttons === false) {
712 var oFoot = jQuery('<div>').addClass('modal-footer').prop('id', 'oefooter');
714 for (var i = 0, k = opts.buttons.length; i < k; i++) {
715 var btnOp = opts.buttons[i];
716 if (typeof btnOp.class !== 'undefined') {
717 btnOp.class = btnOp.class.replace(/default/gi, 'secondary');
718 var btn = jQuery('<button>').addClass('btn ' + (btnOp.class || 'btn-primary'));
720 btnOp.style = btnOp.style.replace(/default/gi, 'secondary');
721 var btn = jQuery('<button>').addClass('btn btn-' + (btnOp.style || 'primary'));
724 for (var index in btnOp) {
725 if (btnOp.hasOwnProperty(index)) {
730 btn.attr('data-dismiss', 'modal');
734 //binds button to click event of fn defined in calling document/form
735 var fn = btnOp.click.bind(dlgContainer.find('.modal-content'));
739 btn.html(btnOp[index]);
744 //all other possible HTML attributes to button element
746 btn.attr(index, btnOp[index]);
754 return oFoot; // jquery object of modal footer.
757 // dynamic sizing - special case for full height
758 function sizing(e, height) {
760 let $idoc = jQuery(e.currentTarget);
761 viewPortHt = Math.max(window.document.documentElement.clientHeight, window.innerHeight || 0);
762 let frameContentHt = opts.sizeHeight === 'full' ? viewPortHt : height;
763 frameContentHt = frameContentHt >= viewPortHt ? viewPortHt : frameContentHt;
764 size = (frameContentHt / viewPortHt * 100).toFixed(2);
766 $idoc.find('div.modal-content').css({'height': size});
771 // sizing for modals with iframes
772 function SizeModaliFrame(e, minSize) {
774 let idoc = e.currentTarget.contentDocument ? e.currentTarget.contentDocument : e.currentTarget.contentWindow.document;
775 jQuery(e.currentTarget).parents('div.modal-body').css({'height': 0});
776 viewPortHt = top.window.innerHeight;
777 let frameContentHt = Math.max(jQuery(idoc).height(), idoc.body.offsetHeight) + 40;
778 frameContentHt = frameContentHt < minSize ? minSize : frameContentHt;
779 frameContentHt = frameContentHt >= viewPortHt ? viewPortHt : frameContentHt;
780 size = (frameContentHt / viewPortHt * 100).toFixed(1);
781 size = size + 'vh'; // will start the dialog as responsive. Any resize by user turns dialog to absolute positioning.
782 jQuery(e.currentTarget).parents('div.modal-body').css({'height': size});