【Origin】jquery.barddialog.js
/// <reference path="jquery-2.1.1.min.js" />
/**
* @license jquery.bardDialog 1.0.0
* (c) 1986-infinity China, Shanghai. CalosChen
* License: MIT
* Description:A responsive dialog box which provides several simple interface methods. Free to use, do whatever you want to it, just customize it.
*/ ; (function (clothes, $) {
'use strict';
var female = {
bed: function () {
return '<div class="dlgbed"></div>';
},
blanket: function () {
return '<div class="dlgblanket" />';
},
costume: function () {
return '<div class="dlgcostume"></div>';
},
hat: function (name) {
return '<h2 class="dlghat">' + name + '</h2>'
},
body: function (discourse) {
return '<div class="dlgbody">' + discourse + '</div>'
},
feet: '<div class="dlgfeet"><button class="promise">OK</button><button class="deny">Cancel</button></div>'
};
var dialog = function (dummy) {
var birthday = new Date().getTime();
var $bed = $(female.bed());
var $blanket = $(female.blanket());
var $costume = $(female.costume());
var $makeup = $costume.addClass(birthday.toString());
var world = { height: $(window).height(), width: $(window).width() };
var treasure = {};
var Calos = {
name: 'discourse', discourse: 'discourse', permit: function () {
$bed.remove();
},
repel: function () {
$bed.remove();
}
};
var God = $.extend({}, Calos);
dummy = $.extend(God, typeof dummy === 'string' ? { discourse: encodeURIComponent(dummy) } : dummy);
var male = {
shift: function () {
treasure = {
bed: $bed,
blanket: $blanket,
costume: $costume,
hat: $makeup.find('.dlghat'),
body: $makeup.find('.dlgbody'),
promise: $makeup.find('.promise'),
deny: $makeup.find('.deny')
};
},
birth: function (dummy) {
var bone = female.hat(dummy.name) + female.body(decodeURIComponent(dummy.discourse)) + female.feet;
$bed.append($blanket).append($costume.html(bone)).appendTo('body');
male.shift();
return this;
},
masquerade: function () {
treasure.bed.css({
opacity: 1,
'z-index': 1000,
height: world.height,
width: '100%',
position: 'fixed',
top: 0,
left: 0
});
treasure.blanket.css({
background: '#000',
opacity: 0.5,
height: world.height,
width: '100%',
position: 'absolute',
top: 0,
left: 0
});
treasure.costume.css({
background: 'white',
position: 'relative',
'border-radius': '5px',
padding: '0.3em',
margin: '30px auto',
'min-width': '15%',
width: 'string' !== typeof dummy.discourse && $(dummy.discourse).width() ? ($(dummy.discourse).width() + 50) : world.width / 3
});
treasure.costume.find('.dlgbody').css({
'max-height': world.height - 300, padding: '0.1em',
overflow: 'auto'
});
var cosmetics = '<style type="text/css">.dlgbed .dlgcostume {border:1px solid #CCCCCC;} .dlgbed div{overflow:auto;} .dlgbed button { float:right; margin-left:1em; height:3em;color:white;background-color: #286090; border:none;padding:1em; border-radius:5px } .dlgbed .dlghat{ border-bottom: 1px solid #CCCCCC;padding-left:0.5em;margin-feet:0.5em;} .dlgbed .dlgbody{padding:0 0 0 0.5em; overflow:hidden;} .dlgbed .dlgfeet{border-top: 1px solid #CCCCCC;padding-top: 0.5em;} </style>';
$(cosmetics).appendTo('head');
}
};
male.birth(dummy).masquerade();
treasure.promise.on('click', function () {
dummy.permit();
Calos.permit();
});
treasure.deny.on('click', function () {
dummy.repel();
Calos.repel();
});
return this;
};
clothes.dialog = dialog;
clothes.info = function (discourse) {
dialog({
name: 'Info', discourse: discourse
});
};
clothes.question = function (problem, agree) {
dialog({
name: 'Prompt', discourse: problem, promise: agree
});
};
clothes.warn = function (admonish) {
dialog({
name: 'Warning', discourse: admonish
});
};
clothes.danger = function (hazard) {
dialog({
name: 'Danger', discourse: hazard
});
};
}
)(this.bardDialog = this.bardDialog || {}, jQuery); $(function () {
bardDialog.dialog({
name: 'Hello', discourse: '<div style="">Have fun, bro.</div>', repel: function () {
alert('Oh, you repel it!');
}, permit: function () {
alert('Oops, you permit it!');
}
});
});
【Origin】jquery.barddialog.js的更多相关文章
- 【转】jquery.cookie.js的使用
Cookie是由服务器端生成,发送给User-Agent(一般是浏览器),浏览器会将Cookie的key/value保存到某个目录下的文本文件内,下次请求同一网站时就发送该Cookie给服务器(前提是 ...
- 【转】jquery.validate.js表单验证
一.用前必备官方网站:http://bassistance.de/jquery-plugins/jquery-plugin-validation/ API: http://jquery.bassist ...
- 【学习】jquery.placeholder.js让IE浏览器支持html5的placeholder
type为text或password的input,其在实际应用时,往往有一个占位符,类似这样的: 在没有html5前,一般写成value,用js实现交互,文本框获得焦点时,提示文字消失,失去焦点时,文 ...
- 【前端】:jQuery下
前言: 接上一篇博客: [前端]:jQuery上 一.jQuery属性操作 ① attr(设置或返回自定义属性值) input.select.textarea框中的内容, 可以通过attr来获取,但是 ...
- 【JavaScript】jQuery
No1: jQuery能帮我们干这些事情: 消除浏览器差异:你不需要自己写冗长的代码来针对不同的浏览器来绑定事件,编写AJAX等代码: 简洁的操作DOM的方法:写$('#test')肯定比docume ...
- 【笔记】jQuery插件开发指南
原文链接:http://www.cnblogs.com/Wayou/p/jquery_plugin_tutorial.html (有部分增删和修改) jQuery插件开发模式 软件开发过程中是需要一定 ...
- 【jquery】jquery.cookie.js 的使用指南
之前有写过一篇原生 js 的 cookie 介绍,并且最后封装成 cookie.js 具体内容点击传送门. jquery.cookie.js 是一款轻量级的 cookie 插件,可以读取,写入和删除 ...
- 【转载】jQuery全屏滚动插件fullPage.js
文章转载自dowebok http://www.dowebok.com/ 原文链接:http://www.dowebok.com/77.html 简介 如今我们经常能见到全屏网站,尤其是国外网站.这些 ...
- 【jQuery】jquery.metadata.js验证失效
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
随机推荐
- Comparable与Comparator
转载 Comparable与Comparator的区别 (转载) Comparable & Comparator 都是用来实现集合中元素的比较.排序的,只是 Comparable 是在集合内部 ...
- 【Android开发学习笔记】【高级】【随笔】插件化——Activity生命周期
前言 如同第一章我们说的,宿主程序通过 dexclassloader 将插件的类加载进来,然后通过反射去调用它的方法,这样Activity就被当成了一个普通的类来执行了,因此系统不再接管它的生命周期, ...
- WIN 8.1使用常见问题及解决
WIN 8.1正式版64位(cn_windows_8_1_pro_vl_x64_dvd_2971907)使用问题及解决 一.IE11的输入框会变蓝: 如在百度中搜索时,搜索框和按钮均变成蓝色背景, ...
- ArcGIS API for Silverlight 绘制降雨路径动画
原文:ArcGIS API for Silverlight 绘制降雨路径动画 #region 降雨动画演示 2014-04-16 List<Graphic> graphics = new ...
- Linq世界走一走(LINQ TO XML)
前言:Linq to xml是一种使用XML的新方法.从本质上来说,它采用了多种当前使用的XML处理技术,如DOM和XPath,并直接在.NET Framework内将它们组合为一个单一的编程接口.L ...
- windows下memcache安装及配置
1.安装memcached服务,链接为http://i.cnblogs.com/Files.aspx, 下载解压后放在一个文件夹下,在开始搜索中输入cmd, 进入cmd黑框,cd 路径,进入memca ...
- 将一个UIView对象的内容保存为UIImage
+ (UIImage*)imageFromView:(UIView*)view{ UIGraphicsBeginImageContextWithOptions(view.bounds.size, YE ...
- Linux Bash Shell 快速入门
BASH 的基本语法 最简单的例子 —— Hello World! 关于输入.输出和错误输出 BASH 中对变量的规定(与 C 语言的异同) BASH 中的基本流程控制语法 函数的使用 2.1 ...
- http和webservice接口区别
httpservice通过post和get得到你想要的东西webservice就是使用soap协议得到你想要的东西,相比httpservice能处理些更加复杂的数据类型 http协议传输的都是字符 ...
- Android PickerView滚动选择器的使用方法
手机里设置闹钟需要选择时间,那个选择时间的控件就是滚动选择器,前几天用手机刷了MIUI,发现自带的那个时间选择器效果挺好看的,于是就自己仿写了一个,权当练手.先来看效果: 效果还行吧?实现思路就是自定 ...