提交 dea95571 编写于 作者: C Catouse

* improve UI of modal, add handLinkInIframe and iframeStyle option to modal trigger.

上级 c9bbca9d
......@@ -47,6 +47,8 @@
waittime: 0,
loadingIcon: 'icon-spinner-indicator',
scrollInside: false,
// handleLinkInIframe: false,
// iframeStyle: ''
// headerHeight: 'auto',
};
......@@ -167,7 +169,7 @@
if(options.type === 'iframe') $body.css('height', $dialog.height() - $header.outerHeight());
}
that.ajustPosition(options.position);
$modal.removeClass('modal-loading');
$modal.removeClass('modal-loading').removeClass('modal-updating');
if(isShown) {
$body.removeClass('loading');
}
......@@ -224,7 +226,7 @@
}
var frame = document.getElementById(iframeName);
frame.onload = frame.onreadystatechange = function() {
frame.onload = frame.onreadystatechange = function(e) {
var scrollInside = !!options.scrollInside;
if(that.firstLoad) $modal.addClass('modal-loading');
if(this.readyState && this.readyState != 'complete') return;
......@@ -287,6 +289,18 @@
} else {
readyToShow();
}
var handleLinkInIframe = options.handleLinkInIframe;
if (handleLinkInIframe) {
frame$('body').on('click', handleLinkInIframe === 'string' ? handleLinkInIframe : 'a[href]', function() {
if ($(this).is('[data-toggle="modal"]')) return;
$modal.addClass('modal-updating');
});
}
if (options.iframeStyle) {
frame$('head').append('<style>' + options.iframeStyle + '</style>');
}
} catch(e) {
readyToShow();
}
......@@ -401,6 +415,9 @@
var getModal = function(modal) {
if (!modal) {
modal = $('.modal.modal-trigger');
if (!modal.length) {
}
} else {
modal = $(modal);
}
......
......@@ -46,9 +46,9 @@
> .loader { display: none; }
&.modal-loading
&.modal-loading,
&.modal-updating
{
.modal-dialog { opacity: 0; }
.loader {
position: absolute;
display: block;
......@@ -61,6 +61,19 @@
margin-left: -40px;
}
}
&.modal-loading {
.modal-dialog {opacity: 0;}
}
&.modal-updating {
.modal-dialog {
opacity: 1;
}
.modal-body {opacity: 0;}
.loader {
color: #eee;
z-index: 1;
}
}
}
.modal-open .modal {
overflow-x: hidden;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册