<%@ page contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>alertifyjsDemo</title>
<!-- resource http://alertifyjs.com/guide.html -->
<!-- see http://alertifyjs.com/guide.html -->
<link rel="stylesheet" href="../component/alertifyjs/css/themes/bootstrap.min.css">
<link rel="stylesheet" href="../component/alertifyjs/css/alertify.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Droid+Sans:400,700">
<script src="../component/alertifyjs/alertify.js"></script>
<script type="text/javascript" src="../component/jquery-1.11.1.js"></script>
<script type="text/javascript">
alertify.defaults.transition = "slide";
alertify.defaults.theme.ok = "btn btn-primary";
alertify.defaults.theme.cancel = "btn btn-danger";
alertify.defaults.theme.input = "form-control";
function interval(e){
alertify.dismissAll();
setCookie("a","c");
}
//设置cookie
function setCookie(name, value) {
var Days = 30;
var exp = new Date();
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name){
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
if(arr=document.cookie.match(reg))
return unescape(arr[2]);
else
return null;
}
$(function(){
$('#alert').click(function(){
alertify.alert('Bootstrap');
}); $('#confirm').click(function(){
alertify.confirm('Bootstrap');
}); $('#prompt').click(function(){
alertify.prompt('Bootstrap');
}); $("#notify").click(function() {
alertify.notify('sample', 'success', 5, function(){ console.log('dismissed'); });
}); $("#alert1").click(function() {
var closable = alertify.alert().setting('closable');
alertify.confirm('labels changed!')
.set('labels', {ok:'确定!', cancel:'取消!'})
.set('onok', function(closeEvent){ alertify.success('Ok');}); ;
}); $("#notify1").click(function() {
if(getCookie("a") != "c") {
var msg = alertify.message("<button onclick='interval(\"aaa\");'>不再显示</button>", 100, function(){ });
}
});
});
</script>
<style type="text/css">
body {
font-family:"Droid Sans","Helvetica Neue","Helvetica","Arial",sans-serif;
-webkit-overflow-scrolling: touch;
}
.btn{
margin: .25em;
}
</style>
</head>
<body>
----------基本功能-----------------
<div style="text-align:center;padding:40px;">
<a id="alert" class="btn btn-primary btn-lg">
Alert
</a> <a id="confirm" class="btn btn-primary btn-lg">
Confirm
</a> <a id="prompt" class="btn btn-primary btn-lg">
Prompt
</a> <a id="notify" class="btn btn-primary btn-lg">
Notify
</a>
</div>
<hr> <div style="text-align:center;padding:40px;">
<a id="alert1" class="btn btn-primary btn-lg">
alert1
</a> <a id="notify1" class="btn btn-primary btn-lg">
Notify1
</a>
</div> </body>
</html>

公司使用插件,随便封装一下非常好用,这里我们预想做一个不再显示的功能,修改了alertify.js里面的一个create函数function clickDelegate,屏蔽了点击消失的功能,然后把这个alert记录到Cookie中,以后读取cookie有值则不再显示,

 builder.append("window.ep.alert=function(msg,callback,cls){alertify.set({labels:{ok:'确定',cancel:'取消'},delay:2000,buttonReverse:true,buttonFocus:'ok'});alertify.alert(msg,callback,cls);};\n");
builder.append("window.ep.confirm=function(msg,callback,cls){alertify.set({labels:{ok:'确定',cancel:'取消'},delay:2000,buttonReverse:true,buttonFocus:'ok'});alertify.confirm(msg,callback,cls);};\n");
builder.append("window.ep.prompt=function(msg,defaultValue,callback,cls){alertify.set({labels:{ok:'确定',cancel:'取消'},delay:2000,buttonReverse:true,buttonFocus:'ok'});alertify.prompt(msg,function(e,str){callback.call(window, e?(!!str?str:''):null);},defaultValue,cls);};\n");
builder.append("window.ep.notify=function(msg,type,time){alertify.set({delay:2000});if(!time&&time!==0){time=2000;}if(type=='success'){alertify.success(msg,time);}else if(type=='error'){alertify.error(msg,time);}else{alertify.log(msg,type,time);}};\n");

alertifyjs的更多相关文章

  1. 2016年最好的15个Web设计和开发工具

    1.ai2html ai2html是适用于Adobe Illustrator的开源脚本,可以转换Illustrator文件为html和css. 官方网站:http://ai2html.org/ 2.A ...

  2. jQuery smartMenu右键自定义上下文菜单插件

    http://www.zhangxinxu.com/wordpress/?p=1667 <%@ page contentType="text/html; charset=UTF-8&q ...

  3. 前端组件库 - 搭建web app常用的样式/组件等收集列表(移动优先)

    0. 前端自动化(Workflow) 前端构建工具 Webpack - module bundler Yeoman - a set of tools for automating developmen ...

  4. IOS-2016年最好的15个Web设计和开发工具

    设计师和开发者,web设计师和开发者遍地开花.这促使web开发人员也需要寻找最好的工具去设计出优于其他人的网站.作为一个web设计师或开发者,你必须寻找新的途径来提高自己的技能,提高自己的工作质量.下 ...

随机推荐

  1. dedecms幻灯片调用图片模糊的解决办法

    dedecms幻灯片调用的是缩略图,如果图片尺寸比例和幻灯片的大小相差太大的话,图片就会自动拉伸模糊,比较影响美观和用户体验,下面就有常用的2个方法来解决这个图片模糊的问题. 第一种:手动制图 我们用 ...

  2. vuejs中执行npm run dev出现页面cannot GET/问题

    1.问题描述 最近用vue-cli搭建了一个小项目,其中在对项目进行打包测试时修改了webpack.base.conf.js中的配置信息,之后再用npm run dev之后出现如下的情况: 最近又有网 ...

  3. client和nginx简易交互过程

    # client和nginx简易交互过程- step1:client发起http请求- step2:dns服务器解析域名得到主机ip- step3:默认端口为80,通过ip+port建立tcp/ip链 ...

  4. 织梦dedecmsV5.7联动类型无法显示的处理方法

    最近织梦dedecms在新的功能中添加了一个联动类型这样的一个功能.所谓的联动类型,类似于一级目录下有二级目录,二级目录下又有三级目录,可以理解为数据结构中树形结构.级和级之间都是有着联系的.为了让大 ...

  5. DedeCMS实现自定义表单提交后发送指定QQ邮箱法

    https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=monline_3_dg&wd=dedecms 邮箱&oq=d ...

  6. vue 开发2017年变化回顾及2018年展望

    vue.js 变化 从 github 的发布记录我们可以看到2017年 vue.js 的第一个发布为 v2.1.9,最后一个为 v2.5.13,主要发布小版本 2.2~2.5.这些发布提升了vue 与 ...

  7. 如何用vue实现树形菜单?

    在公司培训了2周,布置的作业是从树形,grid分页以及echarts中选一个.由于都不是很熟,就挑了第一个.本来想在网上找找参考,然后模仿着做一个,但是网上的代码多少参差不齐,写到一半没了,所以只要自 ...

  8. 新手数据比赛中数据处理方法小结(python)

    第一次参加,天池大数据竞赛(血糖预测),初赛排名1%.因为自己对python不熟悉,所以记录一下在比赛中用到的一些python方法的使用(比较基础细节,大佬绕道): 1.数据初探 data.info( ...

  9. ASP.NETCore的Kestrel服务器

    什么是Kestrel服务器 Kestrel是开源的(GitHub提供的源代码),事件驱动的异步I / O服务器,用于在任何平台上托管ASP.NET应用程序.这是一个监听服务器和一个命令行界面.您将侦听 ...

  10. Docker部署Elasticsearch集群

    http://blog.sina.com.cn/s/blog_8ea8e9d50102wwik.html Docker部署Elasticsearch集群 参考文档: https://hub.docke ...