提交 dea95571 编写于 作者: C Catouse

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

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