DOCTYPE html> head>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>基于JQ的自定义弹窗组件title>
<body>
<div id="box">
<a href="Javascript:;" class="btnModel">按钮弹窗a>
<a href="Javascript:;" class="tipModel">提示弹窗a>
<a href="Javascript:;" class="loadModel">加载弹窗a>
<input type="submit" value="提交">
div>
body>
html>
window.Onresize= function() {
/*
默认设置字体为可视区/7.5 -----max:256px min
*/
document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + ‘px‘;
var deviceWidth = document.documentElement.clientWidth;
if (deviceWidth > 640) {
deviceWidth = 640
}
};
onresize();
@charset "UTF-8";
body,div,dl,dt,dd,ul,li,pre,form,fieldset,select,input,textarea,button,p,img,iframe{ margin: 0; padding: 0; }
h1,h2,h3,h4,h5,h6{ font-weight:normal; margin: 0; padding: 0; }
body{ width: 100%; font-family: "microsoft yahei","SimSun","宋体"; background-color: #fff; -webkit-overflow-scrolling: touch;overflow-scrolling: touch; }
/* 重置button边框 */
button{ border: none; }
/* 去掉列表前的标识, li 会继承 */
ol,ul{list-style: none;}
/* 让链接默认不显示下划线*/
a{cursor: pointer;text-decoration: none;}
/* 清理浮动 */
.clearfix:before,.clearfix:after{ display: block; content: " "; clear: both; }
/* for ie67*/
.clearfix{zoom: 1;}
/* HTML5 媒体文件跟 img 保持一致 */
audio,canvas,video{ display: inline-block; *display: inline; *zoom: 1; }
address,caption,cite,code,dfn,em,th{ font-style: normal; font-weight: normal; }
.box-sizing{ -moz-box-sizing: border-box; -webkit-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box; }
/*p{ text-align:justify; text-justify:distribute;}*/
div, p, span { text-overflow: ellipsis; word-break: break-all; word-wrap: break-word; }
/*iphone及ipad下输入框默认内阴影*/
input, button { outline: none; -webkit-appearance: none; }
textarea { resize: none; outline: none; }
img { vertical-align: middle; border: 0; width: 100%; }
a:active, a:hover { outline: 0; }
/*ios和android下触摸元素时出现半透明灰色遮罩*/
a, input { border: none; outline: none; -webkit-tap-highlight-color: rgba(255, 255, 255, 0); }
input[type=button] { cursor: pointer; }
input[type=submit] { cursor: pointer; }
@charset "UTF-8";
/*
弹窗样式class --alert_Wrap 尽量不要修改样式名称,如若修改,JS文件中class也要做对应修改
*/
/*遮罩层*/
.alert_Wrap{
position: fixed;
width: 100%;
height: 100%;
left: 0;
top: 0;
background: rgba(0,0,0,0.7);
z-index: 99;
text-align: center
}
/*弹窗盒子*/
.alert_Wrap .alertCont{
position: absolute;
border-radius: 5px;
text-align: center;
width: 5.3rem;
background: white;
top:35%;
left:1.1rem;
box-sizing: border-box;
}
/*加载弹窗中的弹窗盒子*/
.alert_Wrap .alertLoad{
background: rgba(0,0,0,0);
}
/*弹窗标题*/
.alert_Wrap .alertTitle{
font-size: 0.28rem;
color: black;
text-align: center;
padding: 0.2rem;
word-wrap: break-word;
}
/*弹窗文本*/
.alert_Wrap .alertText{
font-size: 0.25rem;
color: black;
text-align: center;
padding-bottom: 0.15rem;
word-wrap: break-word;
}
/*弹窗文本域*/
.alert_Wrap .alertArea{
font-size: 0.28rem;
color: black;
text-align: center;
padding-top: 0.1rem;
padding-bottom: 0.15rem;
word-wrap: break-word;
}
/*弹窗按钮*/
.alert_Wrap .alertBtn{
width: 100%;
background: white;
text-align: center;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
height: auto;
}
.alert_Wrap .alertBtn input{
width: 50%;
float: left;
background: whitesmoke;
color: black;
cursor: pointer;
padding: 0.2rem;
font-size: 0.28rem;
}
/*取消按钮*/
.alert_Wrap .alertBtn .cancel_btn{
border-right: 1px solid #d3cdcd;
border-top: 1px solid #d3cdcd;
border-bottom-left-radius: 5px;
}
/*确认按钮*/
.alert_Wrap .alertBtn .alert_confirm_btn{
border-top: 1px solid #d3cdcd;
border-bottom-right-radius: 5px;
color: rgb(0, 174, 255);
}
.alert_Wrap .alertBtn .confirm_int{
width: 100%;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
}
/*加载图片*/
.alert_Wrap .load_img{
width: 40px;
height: 40px;
position: absolute;
left: 50%;
top:50%;
margin-left: -20px;
margin-top: -20px;
}
@media screen and (max-width:321px) {
html,
body {
font-size: 14px;
line-height: 18px;
}
.alert_Wrap .alertInput{
margin-left: 0.03rem;
}
}
@media screen and (min-width:321px) and (max-width:400px) {
html,
body {
font-size: 16px;
line-height: 22px;
}
.alert_Wrap .alertInput{
margin-left: 0.03rem;
}
}
@media screen and (min-width:400px) {
html,
body {
font-size: 18px;
line-height: 28px;
}
.alert_Wrap .alertInput{
margin-left: 0.04rem;
}
}
@media screen and (min-width:640px){
html,body {
font-size: 18px;
line-height: 28px;
}
.alert_Wrap .alertInput{
margin-left: 0.05rem;
}
}
/*
@description --model:1.btn 2.tip 3.load
@param --setting --存放配置 $.extend() 外部配置可以覆盖默认配置
*/
function Popup() {
this.alertWrap = null;//遮罩层
this.alertCOnt= null;//弹窗盒子
this.result = {}; //消息存放
//默认配置参数
this.setting = {
// title:‘标题‘,
// tipText:‘说明文字‘,
// textArea : ‘额外添加区域‘,
// loadImg : ‘加载图片url‘,
showBtn: false, //true 显示按钮 false 隐藏 (默认没有按钮)
showDouble: false, //true 双按钮 false 单按钮
cancelText: ‘取消‘,//默认,外部定义可覆盖
confirmText: ‘确认‘
}
}
Popup.prototype.init = function (options) {
$.extend(this.setting, options); //默认配置与自定义配置
this.mark();
this.create();
this.dir();
};
//遮罩
Popup.prototype.mark = function () {
this.alertWrap = $("