alertifyjs
<%@ 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的更多相关文章
- 2016年最好的15个Web设计和开发工具
1.ai2html ai2html是适用于Adobe Illustrator的开源脚本,可以转换Illustrator文件为html和css. 官方网站:http://ai2html.org/ 2.A ...
- jQuery smartMenu右键自定义上下文菜单插件
http://www.zhangxinxu.com/wordpress/?p=1667 <%@ page contentType="text/html; charset=UTF-8&q ...
- 前端组件库 - 搭建web app常用的样式/组件等收集列表(移动优先)
0. 前端自动化(Workflow) 前端构建工具 Webpack - module bundler Yeoman - a set of tools for automating developmen ...
- IOS-2016年最好的15个Web设计和开发工具
设计师和开发者,web设计师和开发者遍地开花.这促使web开发人员也需要寻找最好的工具去设计出优于其他人的网站.作为一个web设计师或开发者,你必须寻找新的途径来提高自己的技能,提高自己的工作质量.下 ...
随机推荐
- win处navicat直接导出的sql脚本导入Linux mysql报错问题
最近几天在把win上的项目的数据库转移到Ubuntu,于是第一件事就是从win处的navicat直接导出sql脚本,然后进入Ubuntu导入的时候会报错误,跳过错误继续执行导致数据库表的缺失. 跨平台 ...
- Access是什么?
一种使用简单的数据库软件,非常实用! 是微软的一个小型数据库,是Microsoft office 中的一个组件. Access数据库能够进行数据表设计.可视查询设计.SQL查询语言.窗体设计.报表设计 ...
- dedecms织梦自定义表单发送到邮箱-用163邮箱发送邮件
https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=monline_3_dg&wd=dedecms 邮箱&oq=d ...
- Codeforces 897D. Ithea Plays With Chtholly (交互)
题目链接:D. Ithea Plays With Chtholly 题意: 给你n张纸,在纸上写字(在 1 - c之间)可以写m次数 (,).(主要是交互,让你判断) 题解: 首先,看到m>=n ...
- CCF系列之模板生成系统( 201509-3 )
试题名称: 模板生成系统 试题编号: 201509-3 时间限制: 1.0s 内存限制: 256.0MB 问题描述 成成最近在搭建一个网站,其中一些页面的部分内容来自数据库中不同的数据记录,但是页面的 ...
- JVM之GC算法
- banner无缝轮播【小封装】
转载:http://www.qdfuns.com/notes/23446/d1691a1edf5685396813cc85ae6ab10f.html 一直在重复的写banner,写了了好几个,然后每次 ...
- 新建maven项目,JRE System Library[J2SE-1.5]
上篇博文中搭建了maven多模块项目,发现全是JRE System Library[J2SE-1.5],如图. 怎么避免这种情况呢? windows-preferences-maven-user se ...
- ios MVVM实践 刷新网络请求+tableView展示数据
[实现效果] [目录结构相关] 此示例展示用的是MVVM结构形式,表述如下 M:数据Model的存储,可以用来对属性进行处理.(即胖model概念,上图中xx万人订阅这个处理方法写在Model内) V ...
- pat 1022 digital library
#include <iostream> #include <sstream> #include <string> #include <vector> # ...