<%@ 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. 【自制工具类】Java删除字符串中的元素

    这几天做项目需要把多个item的id存储到一个字符串中,保存进数据库.保存倒是简单,只需要判断之前是否为空,如果空就直接添加,非空则拼接个"," 所以这个字符串的数据结构是这样的 ...

  2. mysql之repair table 修复表札记

    REPAIR [LOCAL | NO_WRITE_TO_BINLOG] TABLE   tbl_name[,tbl_name] ... [QUICK] [EXTENDED] [USE_FRM] REP ...

  3. SQL语句order by两个字段同时排序。

    ORDER BY  后可加2个字段,用英文逗号隔开.理解:对两个字段都排序,并不是之排序其中的一个字段: f1用升序, f2降序,sql该这样写 ORDERBY  f1, f2  DESC 也可以这样 ...

  4. asp.net -mvc框架复习(4)-ASP.NET MVC中的约定规则

    1.路由规则 using System;using System.Collections.Generic;using System.Linq;using System.Web;using System ...

  5. MYSQL主从库同步配置过程

    MYSQL主从库同步配置过程 为了实现网站数据库的异地备份,采用了MySQL数据库主从同步配置,需要两台服务器分别作为主从库,当主库发生增删改等操作,会实时反映到从库,我的个人服务器配置如下: 主库为 ...

  6. linux unzip 解压后文件名乱码

    在windows上zip的包,rz上传到linux下,发现出现乱码.记录下解决过程: 1.确定windows上的默认字符集 在Windows平台下,直接在命令行中,输入:chcp 在显示的结果中,会出 ...

  7. 关于win10企业版1607累积更新(KB4013429)安装失败后,个人的解决办法

    最近连续一个多星期更新(1607-KB4013429)失败,更抓狂的是windows不厌其烦的,不断下载,不断更新,导致每天打开电脑都要等个十几分钟,看来不解决是不行了. 网上一查,有各种解决版本 1 ...

  8. python3 第三章 - 程序的基本结构

    1.编码 默认情况下,Python 3 源码文件以 UTF-8 编码,所有字符串都是 unicode 字符串. 当然你也可以为源码文件指定不同的编码: # -*- coding: cp-1252 -* ...

  9. 在Tomcat中采用基于表单的安全验证

    .概述   (1)基于表单的验证 基于From的安全认证可以通过TomcatServer对Form表单中所提供的数据进行验证,基于表单的验证使系统开发者可以自定义用户的登陆页面和报错页面.这种验证方法 ...

  10. java web response提供文件下载功能

    */ .hljs { display: block; overflow-x: auto; padding: 0.5em; color: #333; background: #f8f8f8; } .hl ...