diff --git a/module/index/control.php b/module/index/control.php index cb223a0c6a..2ff6424827 100644 --- a/module/index/control.php +++ b/module/index/control.php @@ -64,6 +64,20 @@ class index extends control $this->display(); } + /** + * 通过 iframe 的形式打开对话框。 + * Open url in iframe modal. + * + * @param string $url base64 encode string. + * @access public + * @return void + */ + public function iframeModal(string $url = '') + { + $this->view->url = helper::safe64Decode($url); + $this->display(); + } + /** * Get the log record according to the version. * diff --git a/module/index/css/iframemodal.ui.css b/module/index/css/iframemodal.ui.css new file mode 100644 index 0000000000..722e7e21a4 --- /dev/null +++ b/module/index/css/iframemodal.ui.css @@ -0,0 +1,5 @@ +body {--zt-page-bg: var(--color-canvas)} +.modal-actions > [data-dismiss="modal"] {display: none;} +.modal-dialog {box-shadow: none!important;} +.modal-content, .modal-dialog {height: auto!important; max-height: none!important} +.modal-body {overflow: visible!important;} diff --git a/module/index/js/iframemodal.ui.js b/module/index/js/iframemodal.ui.js new file mode 100644 index 0000000000..cb6679e6d5 --- /dev/null +++ b/module/index/js/iframemodal.ui.js @@ -0,0 +1,31 @@ +$.fn.triggerHandler = $.fn.trigger; + +$(function() +{ + $('.zin-page-css').appendTo('head'); + + function resizeModal() + { + const $modal = $('.modal-body'); + const width = $modal.outerWidth(); + const height = $modal.outerHeight(); + $modal.closest('body').height(height); + const $iframe = parent.$('iframe[name="' + window.name + '"]'); + $iframe.closest('.modal-dialog').css({width: width + 10}); + } + + $.ajax( + { + url: modalOpenUrl, + headers: {'X-ZUI-Modal': 'true'}, + success: function(data) + { + const $body = $('body'); + $body.html(data); + const resizeOb = new ResizeObserver(resizeModal); + resizeOb.observe($('.modal-body')[0]); + resizeModal(); + $body.removeClass('invisible'); + } + }); +}); diff --git a/module/index/js/index.ui.js b/module/index/js/index.ui.js index 156be9e76c..8f1c4e6580 100644 --- a/module/index/js/index.ui.js +++ b/module/index/js/index.ui.js @@ -834,19 +834,21 @@ $.get($.createLink('index', 'app'), html => $.apps = $.extend(apps, { - openApp: openApp, - open: openApp, // Compatiable with old version. - reloadApp: reloadApp, - showApp: showApp, - updateApp: updateApp, - getLastApp: getLastApp, - goBack: goBack, - logout: logout, - isOldPage: isOldPage, - getAppCode: getAppCode, - updateAppsMenu: updateAppsMenu, - changeAppsLang: changeAppsLang, - changeAppsTheme: changeAppsTheme, + openedApps: apps.openedMap, + openApp: openApp, + open: openApp, + reloadApp: reloadApp, + showApp: showApp, + updateApp: updateApp, + updateUrl: function(appCode, url, title) {return updateApp(appCode, url, title)}, + getLastApp: getLastApp, + goBack: goBack, + logout: logout, + isOldPage: isOldPage, + getAppCode: getAppCode, + updateAppsMenu: updateAppsMenu, + changeAppsLang: changeAppsLang, + changeAppsTheme: changeAppsTheme, updateUserToolbar: updateUserToolbar }); diff --git a/module/index/ui/iframemodal.html.php b/module/index/ui/iframemodal.html.php new file mode 100644 index 0000000000..fc345d08dd --- /dev/null +++ b/module/index/ui/iframemodal.html.php @@ -0,0 +1,8 @@ +