【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 ...
随机推荐
- anti-pattern - Hard coding
https://en.wikipedia.org/wiki/Hard_coding Considered an anti-pattern, hard coding requires the progr ...
- 【故障处理】ORA-12162: TNS:net service name is incorrectly specified (转)
本文将给大家阐述一个因未设置系统环境变量ORACLE_SID导致ORA-12162错误的案例.希望大家有所思考. 1.获得有关ORA-12162报错信息的通用表述信息 [oracle@asdlabdb ...
- java new synchronized
java provides the synchronized keyword for synchronizing thread access to critical sections. Because ...
- 在Windows 环境下编译Qt静态库(QT5.32)
参考链接 Qt5.3 Tools and Versions MinGW ICU ActivePerl Qt 安装MinGW工具链环境 这里在Win32环境下要安装一个MinGW工具链,这里最好是先安装 ...
- SQL Server存储机制二
http://blog.csdn.net/ltylove2007/article/details/21084585 http://www.cnblogs.com/anding/p/3254674.ht ...
- JS-005-常见下拉列表 Select 和 datalist
下拉列表在我们日常的网页浏览的过程中,随处可见,是 web 编程过程中大家非常熟悉的一个页面元素,随着 HTML 语言的日益强大,其在广大攻城狮的手中可谓是千变万化,有了很多不同的实现方式.本文主要以 ...
- c#设计模式之单例模式
单例模式(Singleton Pattern )就是为了整个应用程序的生命周期内的任何时刻,类只能创建一个实例. 单线程下的单例模式代码: public class Singleton { priva ...
- [代码片段]读取BMP文件(二)
#include <stdio.h> #include <stdlib.h> #pragma pack(2) /*定义WORD为两个字节的类型*/ typedef unsign ...
- 什么是webshell?
webshell是web入侵的脚本攻击工具. 简单的说来,webshell就是一个asp或php木马后门,黑客在入侵了一个网站后,常常在将这些 asp或php木马后门文件放置在网站服务器的web目录中 ...
- idea 的问题
IDEA的maven项目中,默认源代码目录下的xml等资源文件并不会在编译的时候一块打包进classes文件夹,而是直接舍弃掉. 如果使用的是Eclipse,Eclipse的src目录下的xml等资源 ...