jquery.jmpopups.js 弹出层 进行进度显示(遮罩层)
效果如:

/**
* 显示loading画面
* @param desc
* @return
*/
function showLoading(desc) {
$("body").append("<div id=\"processingdiv\" style=\"display:none;\"><div class=\"popup\"> <div class=\"popup-body\"><div class=\"loading\"><span>"+desc+"</span></div></div></div></div>");
//alert($("head").html());
$.openPopupLayer({
name: "processing",
width: 500,
target: "processingdiv"
});
}
/**
* 关闭loading画面
* @param desc
* @return
*/
function hideLoading() {
$.closePopupLayer('processing');
$("#processingdiv").remove();
}
showLoading--表示显示进度条
hideLoading-表示隐藏
参考:
jquery.jmpopups.js
/**
* jmpopups
* Copyright (c) 2009 Otavio Avila (http://otavioavila.com)
* Licensed under GNU Lesser General Public License
*
* @docs http://jmpopups.googlecode.com/
* @version 0.5.1
*
*/
(function($) {
var openedPopups = [];
var popupLayerScreenLocker = false;
var focusableElement = [];
var setupJqueryMPopups = {
screenLockerBackground: "#000",
screenLockerOpacity: "0.5"
};
$.setupJMPopups = function(settings) {
setupJqueryMPopups = jQuery.extend(setupJqueryMPopups, settings);
return this;
}
$.openPopupLayer = function(settings) {
if (typeof(settings.name) != "undefined" && !checkIfItExists(settings.name)) {
settings = jQuery.extend({
width: "auto",
height: "auto",
parameters: {},
target: "",
success: function() {},
error: function() {},
beforeClose: function() {},
afterClose: function() {},
reloadSuccess: null,
cache: false
}, settings);
loadPopupLayerContent(settings, true);
return this;
}
}
$.closePopupLayer = function(name) {
if (name) {
for (var i = 0; i < openedPopups.length; i++) {
if (openedPopups[i].name == name) {
var thisPopup = openedPopups[i];
openedPopups.splice(i,1)
thisPopup.beforeClose();
$("#popupLayer_" + name).fadeOut(0,function(){
$("#popupLayer_" + name).remove();
focusableElement.pop();
if (focusableElement.length > 0) {
$(focusableElement[focusableElement.length-1]).focus();
}
thisPopup.afterClose();
hideScreenLocker(name);
});
break;
}
}
} else {
if (openedPopups.length > 0) {
$.closePopupLayer(openedPopups[openedPopups.length-1].name);
}
}
return this;
}
$.reloadPopupLayer = function(name, callback) {
if (name) {
for (var i = 0; i < openedPopups.length; i++) {
if (openedPopups[i].name == name) {
if (callback) {
openedPopups[i].reloadSuccess = callback;
}
loadPopupLayerContent(openedPopups[i], false);
break;
}
}
} else {
if (openedPopups.length > 0) {
$.reloadPopupLayer(openedPopups[openedPopups.length-1].name);
}
}
return this;
}
function setScreenLockerSize() {
if (popupLayerScreenLocker) {
$('#popupLayerScreenLocker').height($(document).height() + "px");
$('#popupLayerScreenLocker').width($(document.body).outerWidth(true) + "px");
}
}
function checkIfItExists(name) {
if (name) {
for (var i = 0; i < openedPopups.length; i++) {
if (openedPopups[i].name == name) {
return true;
}
}
}
return false;
}
function showScreenLocker() {
if ($("#popupLayerScreenLocker").length) {
if (openedPopups.length == 1) {
popupLayerScreenLocker = true;
setScreenLockerSize();
$('#popupLayerScreenLocker').fadeIn(0);
}
if ($.browser.msie && $.browser.version < 7) {
$("select:not(.hidden-by-jmp)").addClass("hidden-by-jmp hidden-by-" + openedPopups[openedPopups.length-1].name).css("visibility","hidden");
}
$('#popupLayerScreenLocker').css("z-index",parseInt(openedPopups.length == 1 ? 999 : $("#popupLayer_" + openedPopups[openedPopups.length - 2].name).css("z-index")) + 1);
} else {
$("body").append("<div id='popupLayerScreenLocker'><!-- --></div>");
$("#popupLayerScreenLocker").css({
position: "absolute",
background: setupJqueryMPopups.screenLockerBackground,
left: "0",
top: "0",
opacity: setupJqueryMPopups.screenLockerOpacity,
display: "none"
});
showScreenLocker();
$("#popupLayerScreenLocker").click(function() {
// $.closePopupLayer();
});
}
}
function hideScreenLocker(popupName) {
if (openedPopups.length == 0) {
screenlocker = false;
$('#popupLayerScreenLocker').fadeOut(0);
} else {
$('#popupLayerScreenLocker').css("z-index",parseInt($("#popupLayer_" + openedPopups[openedPopups.length - 1].name).css("z-index")) - 1);
}
if ($.browser.msie && $.browser.version < 7) {
$("select.hidden-by-" + popupName).removeClass("hidden-by-jmp hidden-by-" + popupName).css("visibility","visible");
}
}
function setPopupLayersPosition(popupElement, animate) {
if (popupElement) {
if (popupElement.width() < $(window).width()) {
var leftPosition = (document.documentElement.offsetWidth - popupElement.width()) / 2;
} else {
var leftPosition = document.documentElement.scrollLeft + 5;
}
if (popupElement.height() < $(window).height()) {
var topPosition = document.documentElement.scrollTop + ($(window).height() - popupElement.height()) / 2;
} else {
var topPosition = document.documentElement.scrollTop + 5;
}
var positions = {
left: leftPosition + "px",
top: topPosition + "px"
};
if (!animate) {
popupElement.css(positions);
} else {
popupElement.animate(positions, "10");
}
setScreenLockerSize();
} else {
for (var i = 0; i < openedPopups.length; i++) {
setPopupLayersPosition($("#popupLayer_" + openedPopups[i].name), true);
}
}
}
function showPopupLayerContent(popupObject, newElement, data) {
var idElement = "popupLayer_" + popupObject.name;
if (newElement) {
showScreenLocker();
$("body").append("<div id='" + idElement + "'><!-- --></div>");
var zIndex = parseInt(openedPopups.length == 1 ? 1000 : $("#popupLayer_" + openedPopups[openedPopups.length - 2].name).css("z-index")) + 2;
} else {
var zIndex = $("#" + idElement).css("z-index");
}
var popupElement = $("#" + idElement);
popupElement.css({
visibility: "hidden",
width: popupObject.width == "auto" ? "" : popupObject.width + "px",
height: popupObject.height == "auto" ? "" : popupObject.height + "px",
position: "absolute",
"z-index": zIndex
});
var linkAtTop = "<a href='#' class='jmp-link-at-top' style='position:absolute; left:-9999px; top:-1px;'></a><input class='jmp-link-at-top' style='position:absolute; left:-9999px; top:-1px;' />";
var linkAtBottom = "<a href='#' class='jmp-link-at-bottom' style='position:absolute; left:-9999px; bottom:-1px;'></a><input class='jmp-link-at-bottom' style='position:absolute; left:-9999px; top:-1px;' />";
popupElement.html(linkAtTop + data + linkAtBottom);
setPopupLayersPosition(popupElement);
popupElement.css("display","none");
popupElement.css("visibility","visible");
if (newElement) {
popupElement.fadeIn(0);
} else {
popupElement.show(0);
}
$("#" + idElement + " .jmp-link-at-top, " +
"#" + idElement + " .jmp-link-at-bottom").focus(function(){
$(focusableElement[focusableElement.length-1]).focus();
});
var jFocusableElements = $("#" + idElement + " a:visible:not(.jmp-link-at-top, .jmp-link-at-bottom), " +
"#" + idElement + " *:input:visible:not(.jmp-link-at-top, .jmp-link-at-bottom)");
if (jFocusableElements.length == 0) {
var linkInsidePopup = "<a href='#' class='jmp-link-inside-popup' style='position:absolute; left:-9999px;'></a>";
popupElement.find(".jmp-link-at-top").after(linkInsidePopup);
focusableElement.push($(popupElement).find(".jmp-link-inside-popup")[0]);
} else {
jFocusableElements.each(function(){
if (!$(this).hasClass("jmp-link-at-top") && !$(this).hasClass("jmp-link-at-bottom")) {
focusableElement.push(this);
return false;
}
});
}
$(focusableElement[focusableElement.length-1]).focus();
popupObject.success();
if (popupObject.reloadSuccess) {
popupObject.reloadSuccess();
popupObject.reloadSuccess = null;
}
}
function loadPopupLayerContent(popupObject, newElement) {
if (newElement) {
openedPopups.push(popupObject);
}
if (popupObject.target != "") {
showPopupLayerContent(popupObject, newElement, $("#" + popupObject.target).html());
} else {
$.ajax({
url: popupObject.url,
data: popupObject.parameters,
cache: popupObject.cache,
dataType: "html",
method: "GET",
success: function(data) {
showPopupLayerContent(popupObject, newElement, data);
},
error: popupObject.error
});
}
}
$(window).resize(function(){
setScreenLockerSize();
setPopupLayersPosition();
});
$(document).keydown(function(e){
if (e.keyCode == 27) {
$.closePopupLayer();
}
});
})(jQuery);
分享到:
相关推荐
标题中的“弹出层jquery.jmpopups”指的是一个基于jQuery的弹出窗口插件,主要用于在网页上创建各种类型的弹出层,如提示框、对话框或模态窗口。这个插件通常可以帮助开发者轻松地实现动态显示和隐藏的内容区域,以...
`jquery.base64.js` 提供了方便的API,使得开发者能轻松地在JavaScript中进行Base64的处理,特别对于中文字符,该插件可以确保编码和解码过程中的正确性,避免出现乱码问题。 这两个文件在实际开发中的结合使用,...
弹出框jquery.弹出框jquery.弹出框jquery.弹出框jquery.弹出框jquery.弹出框jquery.弹出框jquery.弹出框jquery.弹出框jquery.弹出框jquery.弹出框jquery.弹出框jquery.弹出框jquery.弹出框jquery.弹出框jquery.弹出...
jquery.lightbox.js遮罩层图片幻灯片自适应图片 jquery.lightbox.js遮罩层图片幻灯片自适应图片 jquery.lightbox.js遮罩层图片幻灯片自适应图片 jquery.lightbox.js遮罩层图片幻灯片自适应图片
jQuery.UI.Impromptu.js jQuery 弹出层 浮动层 提示框 并随页面滚动而滚动 实现弹出层不再难,只要引用jQuery.UI.Impromptu.js这个js文件后,想要弹出哪个tag都行了 如:我想要这里是弹出浮动遮罩层</div> 并随页面...
Jquery.barrager.js 是一款优雅的网页弹幕插件,支持显示图片,文字以及超链接。支持速度、高度、颜色、数量等自定义。能轻松集成到论坛,博客等网站中。 使用 发布弹幕 弹幕文字必选,图片,链接为空则不显示,其他的可...
本文将对jquery.marquee.js进行深入讲解,并结合实际应用,帮助开发者更好地理解和使用这个插件。 首先,让我们了解jQuery.marquee.js的核心功能。这个插件主要提供了以下特性: 1. **方向控制**:支持上下左右四...
`jQuery.dialog.js`是基于jQuery库的一个经典弹出框插件,它为网页开发者提供了方便、灵活的对话框功能。这个插件使得在网页中创建模态或非模态的对话框变得轻而易举,无需复杂的HTML和CSS布局,大大简化了前端交互...
jquery-3.7.0.min.js(jQuery下载)jquery-3.7.0.min.js(jQuery下载)jquery-3.7.0.min.js(jQuery下载)jquery-3.7.0.min.js(jQuery下载)jquery-3.7.0.min.js(jQuery下载)jquery-3.7.0.min.js(jQuery下载)...
jquery.form.js jquery.form.js
总结,`jQuery.json.js`这个文件可能是jQuery的一个扩展插件,专门用于增强jQuery对JSON的支持。在实际项目中,通过使用jQuery提供的这些方法,开发者可以轻松地处理JSON数据,实现与服务器的高效通信。同时,理解...
在JavaScript的世界里,jQuery库为我们提供了实现这一功能的强大工具——`jquery.autocomplete.js`。本文将深入探讨这个资源压缩包,了解其工作原理,以及如何在项目中应用。 `jquery.autocomplete.js`是jQuery的一...
在jQuery的基础上,`jquery.json2xml.js` 和 `jquery.xml2json.js` 这两个脚本提供了方便的方法来在JSON和XML之间进行转换,从而让开发者无需深入了解这两种格式的复杂性,就能轻松地在它们之间进行数据互换。...
《jQuery.paginate.js插件详解及其应用》 在网页开发中,当数据量过大时,分页功能就显得尤为重要,它能帮助用户更好地浏览和管理大量信息。jQuery是一个广泛使用的JavaScript库,它提供了丰富的功能来简化DOM操作...
jQuery.Lazyload.js是一个高效实用的JavaScript插件,它能够显著提升网页加载速度,同时赋予网页图片渐显效果,从而创造出既美观又高效的网页浏览体验。 jQuery.Lazyload.js的核心原理在于"懒加载"(Lazy Loading)...
jquery.pagination.js 下载,优秀的jquery分页插件,使用IP代理国外网站下载而来
jquery.qrcode.min.js 二维码的jquery插件
jquery.easings.min.js
jquery.cookie.js下载 jquery.cookie.js下载
JQuery.md5.js