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HR3FwaTT5saR06bHorOkDkjh7rvvzr97JfsdHM+yFo7TTz89rr322tEuCpwU/vkXnTHppT0x6fn2fBBp9juYdblkA0kzozKQtHzSckGa92yPx/edFpe+YUpM6BrffwRhLFAJA/XW2TgxfvbMC/G2V9qiqRQ2MsNt6TjuZojKppby1JnstrHw9AWnvxj/418OFB43He9pAICEsrr7zp/uj/Mm74umxsY+dfxwu1nq1vdR3dKRz+Hdsz3OnHAo7ttxKBoadbMAwIkgCxz37Tgcr2s+HBOe29FnXY7MqLV09C1kY58tK+S0Pf8Shw4eiK/95GB0NhptDgBj2ZGG5vjbJw9Ex0svRkuhDs/CRjlwlLfhqtuU2WxAaXnmSuUAk8xr926JqdNb40uPdsX5M06Nt79+UpzRnH1PQ6f59gAwivK6u7Ep9nU0xI9/dSie2P1CXHjGi9H8XHs0TZiQNyA0VnSvHM8MlrqvSForAeWFfb49LonG6Dh4Tnxv26vjlwe649kDHXG40zoeADBaJjY1xpmTm2PGaRGvbXgxLunaFQ3Pd8aE5uaeFo7Klo7jUdfZK+VWi8pCZc9nU2nLt43PbY+zCrczstUTGwtbw8mziiIAjCU9C3293JAv/tUbMJr7dalU1+3DUfdl0KuDR+XKZdlr2UUUv/a6N2xUhg4BBABGTmVgqF7Ys7Fqlkrl/VrvP1Yj8oVvlcGj8n4WNsqhIzNQ8AAARlZ14MiUw0Xlba2QMlx1Dx2ZyuCR3c+CRnmgaXZbDiOCBgCMvuoBorW+W6Ue3yA/IqEjUy5cZfiofk7oAIDRN9iMlHqEjbIRCx1llYWtDCDVrwEAY8NI1c8jHjoqCRkAcPKyNjkAkITQAQAkIXQAAEkIHQBAEkIHAJCE0AEAJCF0AABJCB0AQBJCBwCQhNABACQhdAAASQgdAEASQgcAkITQAQAkIXQAAEkIHQBAEkIHAJCE0AEAJCF0AABJCB0AQBL/H6WIJrz+0HlJAAAAAElFTkSuQmCC" alt="" width="440" height="289" />
一、自定义alert弹框知识点总结
利用requireJS实现模块化管理;
组合使用构造函数和原型模式实现弹框对象的创建;
- 巧妙利用命名空间实现换肤功能;
依赖jquery实现DOM操作;
依赖$.extend()方法实现对象的扩展,即实现默认参数和用户传入参数;
依赖jqueryUI实现弹框的拖动;
自定义事件的实现原理。
二、HTML代码(index.html)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>自定义alert弹框</title>
<link rel="stylesheet" href="style/window_alertBox.css"/>
<script data-main="js/main.js" src="http://apps.bdimg.com/libs/require.js/2.1.11/require.min.js"></script>
</head>
<body>
<button id="btn">弹框</button>
</body>
</html>
三、入口文件代码(main.js)
// 配置路径及别名
require.config({
baseUrl:'js',
paths:{
jquery : 'jquery-1.9.1',
jqueryUI : 'https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min'
}
})
// 初始化window弹框
require(['jquery','window'],function($,w){
$('#btn').on('click',function(){
var win = new w.Window();
win.alert({
title : '提示',
content : '换肤功能实现喽',
btnText : '确定按钮',
width : 500,
height : 300,
skinClassName : 'window_skin_a',
hasMask : true,
dragHandel : '.window_header',
handlerSureBtn : function(){
alert('我是点击确定按钮后的回调...');
},
hasCloseBtn : true,
handlerCloseBtn : function(){
alert('我是点击关闭按钮后的回调...');
}
});
win.on('alert',function(){ alert('点击确定按钮事件01') });
win.on('alert',function(){ alert('点击确定按钮事件02') });
win.on('close',function(){ alert('点击关闭按钮事件01') });
win.on('close',function(){ alert('点击关闭按钮事件02') });
})
})
四、弹框模块实现(window.js)
define(['jquery','jqueryUI'],function($,$UI){
var Window = function(){
this.config = {
title : '系统消息', // 弹框的标题文字
content : '内容', // 弹框的内容问题
btnText : '确定', // 弹框的按钮文字
width : 800, // 弹框的宽度
height : 500, // 弹框的高度
handlerSureBtn : null, // 弹框的按钮触发的事件
hasCloseBtn : false, // 弹框中是否显示关闭按钮
handlerCloseBtn : null, // 弹框关闭按钮触发的事件
skinClassName : null, // 弹框换肤
hasMask : true, // 弹框遮罩
isDraggable : true, // 弹框是否可拖动
dragHandel : null // 弹框中拖动的'把手':'.window_title'
};
this.handlers = {}; // 弹框中的自定义事件集合
};
Window.prototype = {
// 自定义事件
on : function(type, handler){
if( typeof this.handlers[type] == "undefined" ){
this.handlers[type] = [];
}
this.handlers[type].push(handler);
}, fire : function(type, data){
if( this.handlers[type] instanceof Array ){
var handlers = this.handlers[type];
for( var i = 0; i < handlers.length; i++ ){
handlers[i](data);
}
}
},
// 弹框事件
alert : function(cfg){
var that = this;
var config = $.extend(this.config, cfg); // 弹框盒子
var boundingBox = $('<div class="window_boundingBox">' +
'<div class="window_header">' + config.title + '</div>' +
'<div class="window_body">' + config.content + '</div>' +
'<div class="window_footer">' +
'<input type="button" id="btn_sure" value=' + config.btnText + '>' + '</div>' +
'</div>'); boundingBox.appendTo('body'); // 定制皮肤
if(config.skinClassName){
boundingBox.addClass(config.skinClassName);
} //模态弹窗
if(config.hasMask){
var mask = $('<div class="window_mask"></div>');
mask.appendTo('body');
} //拖动属性
if(config.isDraggable){
if(config.dragHandel){
boundingBox.draggable({handle:config.dragHandel});
}else{
boundingBox.draggable();
}
} // 设置宽、高、坐标
boundingBox.css({
width: config.width,
height: config.height,
left: (config.x || (window.innerWidth - config.width)/2) + 'px',
top: (config.y || (window.innerHeight - config.height)/2) + 'px'
}) // 关闭按钮
if(config.hasCloseBtn){
var closeBtn = $('<div class="closeBtn">X</div>');
boundingBox.append(closeBtn);
$('.closeBtn').on('click',function(){
// config.handlerCloseBtn && handlerCloseBtn();
that.fire('close');
boundingBox.remove();
mask && mask.remove();
})
} // 确定按钮点击事件
$('#btn_sure').on('click',function(){
// config.handlerSureBtn && config.handlerSureBtn();
that.fire('alert');
boundingBox.remove();
mask && mask.remove();
}) // 为关闭按钮添加'close'事件
if( config.handlerCloseBtn ){
this.on('close',config.handlerCloseBtn);
} // 为确定按钮添加'alert'事件
if( config.handlerSureBtn ){
this.on('alert',config.handlerSureBtn);
}
}
}
return {
Window : Window
}
})
五、CSS样式(window_alertBox.css)
*{
margin:; padding:;
}
html,body{
width: 100%; height: 100%;
}
body{
font: 14/1.5 normal 'Microsoft YaHei'; background-color: #fff;
} /*默认样式*/
.window_boundingBox{
background-color: #fff; width: 600px; height: 360px; border: 1px solid #4d99cb; border-radius: 10px;
box-shadow: 0 0 5px rgba(0,0,0,0.3); position: fixed; overflow: hidden; z-index:;
}
.window_header{
color: #fff; width: 100%; background-color: #4d99cb; height: 36px; line-height: 36px; text-align: center;
}
.window_body{
padding: 10px;
}
.window_footer{
background-color: #dcdcdc; width: 100%; height: 36px; line-height: 36px; text-align: center;
position: absolute; bottom:;
}
.closeBtn{
border-radius: 50%; cursor: pointer; width: 20px; height: 20px; padding: 2px; text-align: center;
line-height: 20px; background-color: #fff; color: #333; position: absolute; right: 6px; top: 6px; color: #4d99cb;
}
.window_mask{
background-color: #000; opacity: 0.3; width: 100%; height: 100%; position: fixed; left:; top:; z-index:;
} /*定制皮肤*/
.window_skin_a.window_boundingBox{
border: 1px solid red;
}
.window_skin_a .window_header{
background-color:red;
}
.window_skin_a .closeBtn{
color: red;
}
JavaScript实现自定义alert弹框的更多相关文章
- 自定义alert弹框,title不显示域名
问题: 系统默认的alert弹框的title会默认显示网页域名 解决办法: (修改弹框样式) (function() { window.alert = function(name) { $(" ...
- 自定义alert弹框,title不显示域名(重写alert)
问题: 系统默认的alert弹框的title会默认显示网页域名 解决办法: (修改弹框样式) (function() { window.alert = function(name) { $(" ...
- 自定义alert弹框
/**************** UIAlertControllerStyleAlert *************************/ /*创建一个 可以自定义文字颜色和字体大小的IAler ...
- [转]自定义alert弹框,title不显示域名
//(仅去掉网址) (function(){ window.alert = function(name){ var iframe = document.createElement("IFRA ...
- 操作JavaScript的Alert弹框
@Testpublic void testHandleAlert(){ WebElement button =driver.findElement(By.xpath("input" ...
- CodePush自定义更新弹框及下载进度条
CodePush 热更新之自定义更新弹框及下载进度 先来几张弹框效果图 非强制更新场景 image 强制更新场景 image 更新包下载进度效果 image 核心代码 这里的热更新Modal框,是封装 ...
- selenium对Alert弹框的多种处理
Alert弹框是一个很烦人的控件,因为当前页面如果弹出了该弹框,你必须要处理它,不然你就不能操作页面的其它元素,下面我列出了alert弹框在多种场景下的处理办法. 明确知道系统哪个地方会弹alert ...
- python工具 - alert弹框输出姓名年龄、求和
使用python自带的tkinter库进行GUI编程,完成两个功能: (1)要求用户输入姓名和年龄然后打印出来 (2)要求用户输入一个数字,然后计算1到该数字之间的和 代码部分: # 导入tkinte ...
- 仿写confirm和alert弹框
在工作中,我们常常会遇到原生的样式感觉比较丑,又和我们做的项目风格不搭.于是就有了仿写原生一些组件的念头,今天我就带大家仿写一下confirm和alert样式都可以自己修改. 有些的不好的地方请指出来 ...
随机推荐
- Jenkins一天中构建多次
Build after other projects are built:在其他项目触发的时候触发,里面有分为三种情况,也就是其他项目构建成功.失败.或者不稳定的时候触发项目: Poll SCM:定时 ...
- maven filter插件只替换了部分变量问题
maven filter简介 maven的resources插件,有一个filter的作用,能够在打包的时候,从特定文件里读取key-value对,替换配置文件中的占位符变量.很多线上线下有不同环境的 ...
- Openssl crl2pkcs7命令
一.简介 crl2pkcs命令用来根据CRL或证书来生成pkcs#7消息. 二.语法 openssl crl2pkcs7 [-inform PEM|DER ] [-outform PEM|DER ...
- linux环境下搭建osm_web服务器二(Mapnik及apache2mod_tile配置):
Mapnik及apache2mod_tile配置 上一篇,我们配置好了PostgreSQL服务器,导入了测试数据.今天,我们来配置 mapnik2 + apache2 + mod_tile 的WMS服 ...
- Oracle——序列、索引、同义词
一.常见的数据库对象 二.序列 序列: 可供多个用户用来产生唯一数值的数据库对象 自动提供唯一的数值 共享对象 主要用于提供主键值 将序列值装入内存可以提高访问效率 ①.创建序列 CREATE SEQ ...
- 设计模式(java)--Bridge模式之蜡笔与毛笔的故事
转自:吕震宇 http://www.cnblogs.com/zhenyulu/articles/67016.html#!comments 我想大家小时候都有用蜡笔画画的经历吧.红红绿绿的蜡笔一大盒,根 ...
- 一起做RGB-D SLAM (4)
第四讲 点云拼接 广告:“一起做”系列的代码网址:https://github.com/gaoxiang12/rgbd-slam-tutorial-gx 当博客更新时代码也会随着更新. SLAM技术交 ...
- 001 KNN分类 最邻近算法
1.文件5.0,3.5,1.6,0.6,apple5.1,3.8,1.9,0.4,apple4.8,3.0,1.4,0.3,apple5.1,3.8,1.6,0.2,apple4.6,3.2,1.4, ...
- windows 安装 mysql5.7.17
下载mysql 进入官网:https://www.mysql.com/ 单击[Downloads]选项卡 最下面有个[ MySQL Community Edition (GPL)],单击[Commu ...
- 编写高质量代码改善C#程序的157个建议——建议131:用PascalCasing命名公开元素
建议131:用PascalCasing命名公开元素 开放给调用者的属性.字段和方法都应该采用PascalCasing命名方法,比如: class Person { public string Firs ...