热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

开发笔记:基于JQ的自定义弹窗组件

本文由编程笔记#小编为大家整理,主要介绍了基于JQ的自定义弹窗组件相关的知识,希望对你有一定的参考价值。
本文由编程笔记#小编为大家整理,主要介绍了基于JQ的自定义弹窗组件相关的知识,希望对你有一定的参考价值。




DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>基于JQ的自定义弹窗组件title>
    

    

head>
  
  <body>
<div id="box">
<a href="Javascript:;" class="btnModel">按钮弹窗a>
<a href="Javascript:;" class="tipModel">提示弹窗a>
<a href="Javascript:;" class="loadModel">加载弹窗a>
<input type="submit" value="提交">
div>
body>

html>


技术分享图片技术分享图片

window.Onresize= function() {
/*
默认设置字体为可视区/7.5 -----max:256px min
*/
document.documentElement.style.fontSize
= document.documentElement.clientWidth / 7.5 + ‘px‘;

var deviceWidth = document.documentElement.clientWidth;

if (deviceWidth > 640) {
deviceWidth
= 640
}
};
onresize();


rem.js

技术分享图片技术分享图片

@charset "UTF-8";
body,div,dl,dt,dd,ul,li,pre,form,fieldset,select,input,textarea,button,p,img,iframe
{ margin: 0; padding: 0; }
h1,h2,h3,h4,h5,h6
{ font-weight:normal; margin: 0; padding: 0; }
body
{ width: 100%; font-family: "microsoft yahei","SimSun","宋体"; background-color: #fff; -webkit-overflow-scrolling: touch;overflow-scrolling: touch; }
/* 重置button边框 */
button
{ border: none; }
/* 去掉列表前的标识, li 会继承 */
ol,ul
{list-style: none;}
/* 让链接默认不显示下划线*/
a
{cursor: pointer;text-decoration: none;}
/* 清理浮动 */
.clearfix:before,.clearfix:after
{ display: block; content: " "; clear: both; }
/* for ie67*/
.clearfix
{zoom: 1;}
/* HTML5 媒体文件跟 img 保持一致 */
audio,canvas,video
{ display: inline-block; *display: inline; *zoom: 1; }
address,caption,cite,code,dfn,em,th
{ font-style: normal; font-weight: normal; }
.box-sizing
{ -moz-box-sizing: border-box; -webkit-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box; }
/*p{ text-align:justify; text-justify:distribute;}*/
div, p, span
{ text-overflow: ellipsis; word-break: break-all; word-wrap: break-word; }
/*iphone及ipad下输入框默认内阴影*/
input, button
{ outline: none; -webkit-appearance: none; }
textarea
{ resize: none; outline: none; }
img
{ vertical-align: middle; border: 0; width: 100%; }
a:active, a:hover
{ outline: 0; }
/*iosandroid下触摸元素时出现半透明灰色遮罩*/
a, input
{ border: none; outline: none; -webkit-tap-highlight-color: rgba(255, 255, 255, 0); }
input[type=button]
{ cursor: pointer; }
input[type=submit]
{ cursor: pointer; }


reset.css

技术分享图片技术分享图片

@charset "UTF-8";
/*
弹窗样式class --alert_Wrap 尽量不要修改样式名称,如若修改,JS文件中class也要做对应修改
*/
/*遮罩层*/
.alert_Wrap
{
position
: fixed;
width
: 100%;
height
: 100%;
left
: 0;
top
: 0;
background
: rgba(0,0,0,0.7);
z-index
: 99;
text-align
: center
}
/*弹窗盒子*/
.alert_Wrap .alertCont
{
position
: absolute;
border-radius
: 5px;
text-align
: center;
width
: 5.3rem;
background
: white;
top
:35%;
left
:1.1rem;
box-sizing
: border-box;
}
/*加载弹窗中的弹窗盒子*/
.alert_Wrap .alertLoad
{
background
: rgba(0,0,0,0);
}
/*弹窗标题*/
.alert_Wrap .alertTitle
{
font-size
: 0.28rem;
color
: black;
text-align
: center;
padding
: 0.2rem;
word-wrap
: break-word;
}
/*弹窗文本*/
.alert_Wrap .alertText
{
font-size
: 0.25rem;
color
: black;
text-align
: center;
padding-bottom
: 0.15rem;
word-wrap
: break-word;
}
/*弹窗文本域*/
.alert_Wrap .alertArea
{
font-size
: 0.28rem;
color
: black;
text-align
: center;
padding-top
: 0.1rem;
padding-bottom
: 0.15rem;
word-wrap
: break-word;
}
/*弹窗按钮*/
.alert_Wrap .alertBtn
{
width
: 100%;
background
: white;
text-align
: center;
border-bottom-right-radius
: 5px;
border-bottom-left-radius
: 5px;
height
: auto;
}
.alert_Wrap .alertBtn input
{
width
: 50%;
float
: left;
background
: whitesmoke;
color
: black;
cursor
: pointer;
padding
: 0.2rem;
font-size
: 0.28rem;
}
/*取消按钮*/
.alert_Wrap .alertBtn .cancel_btn
{
border-right
: 1px solid #d3cdcd;
border-top
: 1px solid #d3cdcd;
border-bottom-left-radius
: 5px;
}
/*确认按钮*/
.alert_Wrap .alertBtn .alert_confirm_btn
{
border-top
: 1px solid #d3cdcd;
border-bottom-right-radius
: 5px;
color
: rgb(0, 174, 255);
}
.alert_Wrap .alertBtn .confirm_int
{
width
: 100%;
border-bottom-right-radius
: 5px;
border-bottom-left-radius
: 5px;
}
/*加载图片*/
.alert_Wrap .load_img
{
width
: 40px;
height
: 40px;
position
: absolute;
left
: 50%;
top
:50%;
margin-left
: -20px;
margin-top
: -20px;
}
@media screen and (max-width:321px)
{
html,
body {
font-size
: 14px;
line-height
: 18px;
}
.alert_Wrap .alertInput
{
margin-left
: 0.03rem;
}
}
@media screen and (min-width:321px) and (max-width:400px)
{
html,
body {
font-size
: 16px;
line-height
: 22px;
}
.alert_Wrap .alertInput
{
margin-left
: 0.03rem;
}
}
@media screen and (min-width:400px)
{
html,
body {
font-size
: 18px;
line-height
: 28px;
}
.alert_Wrap .alertInput
{
margin-left
: 0.04rem;
}
}
@media screen and (min-width:640px)
{
html,body {
font-size
: 18px;
line-height
: 28px;
}
.alert_Wrap .alertInput
{
margin-left
: 0.05rem;
}
}


popup.css

技术分享图片技术分享图片

/*
@description --model:1.btn 2.tip 3.load
@param --setting --存放配置 $.extend() 外部配置可以覆盖默认配置
*/
function Popup() {
this.alertWrap = null;//遮罩层
this.alertCOnt= null;//弹窗盒子
this.result = {}; //消息存放
//默认配置参数
this.setting = {
// title:‘标题‘,
// tipText:‘说明文字‘,
// textArea : ‘额外添加区域‘,
// loadImg : ‘加载图片url‘,
showBtn: false, //true 显示按钮 false 隐藏 (默认没有按钮)
showDouble: false, //true 双按钮 false 单按钮
cancelText: ‘取消‘,//默认,外部定义可覆盖
confirmText: ‘确认‘
}
}
Popup.prototype.init
= function (options) {
$.extend(
this.setting, options); //默认配置与自定义配置
this.mark();
this.create();
this.dir();
};
//遮罩
Popup.prototype.mark = function () {
this.alertWrap = $("

");
};
//弹窗
Popup.prototype.create = function () {
this.alertCOnt= $("
");
//title
if (this.setting.title) {
this.alertTitle = $("
" + this.setting.title + "
");
this.alertCont.append(this.alertTitle);
}
//tipText
if (this.setting.tipText) {
this.alertText = $("
" + this.setting.tipText + "
");
this.alertCont.append(this.alertText);
}
//textArea
if (this.setting.textArea) {
this.alertArea = $("
" + this.setting.textArea + "
");
this.alertCont.append(this.alertArea);
}
//loadImg
if (this.setting.loadImg) {
this.alertCont.addClass("alertLoad");
this.alertLoadImg = $("this.setting.loadImg + "‘ />");
this.alertCont.append(this.alertLoadImg);
}
//showBtn
if (this.setting.showBtn && this.setting.showDouble === true) {
//
this.alertBtn = $("
");
this.cancel_btn = $("");
this.confirm_btn = $("");
this.alertBtn.append(this.cancel_btn);
this.alertBtn.append(this.confirm_btn);
this.alertCont.append(this.alertBtn);
}
else if (this.setting.showBtn && this.setting.showDouble === false) {
//
this.alertBtn = $("
");
this.confirm_btn = $("");
this.alertBtn.append(this.confirm_btn);
this.alertCont.append(this.alertBtn);
}
this.alertWrap.append(this.alertCont);
$(
"body").append(this.alertWrap);
};
//自定义函数
Popup.prototype.dir = function () {
var _this = this;
if (this.cancel_btn) {
this.cancel_btn.on("click", function () {
_this.alertWrap.remove();
_this.result
= {
cancel:
true,
showCancel:
"取消操作!"
};
if (_this.setting.success) {
_this.setting.success(_this.result);
}
})
}
if (this.confirm_btn) {
this.confirm_btn.on("click", function () {
_this.alertWrap.remove();
_this.result
= {
confirm:
true,
showCancel:
"确认操作!"
};
if (_this.setting.success) {
_this.setting.success(_this.result);
}
})
}
};
//关闭
Popup.prototype.close = function () {
this.alertWrap.remove();
};


popup.js

 

 




















































推荐阅读
  • 开发笔记:加密&json&StringIO模块&BytesIO模块
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了加密&json&StringIO模块&BytesIO模块相关的知识,希望对你有一定的参考价值。一、加密加密 ... [详细]
  • 本文介绍了前端人员必须知道的三个问题,即前端都做哪些事、前端都需要哪些技术,以及前端的发展阶段。初级阶段包括HTML、CSS、JavaScript和jQuery的基础知识。进阶阶段涵盖了面向对象编程、响应式设计、Ajax、HTML5等新兴技术。高级阶段包括架构基础、模块化开发、预编译和前沿规范等内容。此外,还介绍了一些后端服务,如Node.js。 ... [详细]
  • Android实战——jsoup实现网络爬虫,糗事百科项目的起步
    本文介绍了Android实战中使用jsoup实现网络爬虫的方法,以糗事百科项目为例。对于初学者来说,数据源的缺乏是做项目的最大烦恼之一。本文讲述了如何使用网络爬虫获取数据,并以糗事百科作为练手项目。同时,提到了使用jsoup需要结合前端基础知识,以及如果学过JS的话可以更轻松地使用该框架。 ... [详细]
  • 本文介绍了Java后台Jsonp处理方法及其应用场景。首先解释了Jsonp是一个非官方的协议,它允许在服务器端通过Script tags返回至客户端,并通过javascript callback的形式实现跨域访问。然后介绍了JSON系统开发方法,它是一种面向数据结构的分析和设计方法,以活动为中心,将一连串的活动顺序组合成一个完整的工作进程。接着给出了一个客户端示例代码,使用了jQuery的ajax方法请求一个Jsonp数据。 ... [详细]
  • 本文介绍了使用Java实现大数乘法的分治算法,包括输入数据的处理、普通大数乘法的结果和Karatsuba大数乘法的结果。通过改变long类型可以适应不同范围的大数乘法计算。 ... [详细]
  • 开发笔记:Java是如何读取和写入浏览器Cookies的
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了Java是如何读取和写入浏览器Cookies的相关的知识,希望对你有一定的参考价值。首先我 ... [详细]
  • Ihavethefollowingonhtml我在html上有以下内容<html><head><scriptsrc..3003_Tes ... [详细]
  • IjustinheritedsomewebpageswhichusesMooTools.IneverusedMooTools.NowIneedtoaddsomef ... [详细]
  • 从零基础到精通的前台学习路线
    随着互联网的发展,前台开发工程师成为市场上非常抢手的人才。本文介绍了从零基础到精通前台开发的学习路线,包括学习HTML、CSS、JavaScript等基础知识和常用工具的使用。通过循序渐进的学习,可以掌握前台开发的基本技能,并有能力找到一份月薪8000以上的工作。 ... [详细]
  • JS实现一键分享功能
    本文介绍了如何使用JS实现一键分享功能,并提供了2019独角兽企业招聘Python工程师的标准。同时,给出了分享到QQ空间、新浪微博和人人网的链接。 ... [详细]
  • Node.js学习笔记(一)package.json及cnpm
    本文介绍了Node.js中包的概念,以及如何使用包来统一管理具有相互依赖关系的模块。同时还介绍了NPM(Node Package Manager)的基本介绍和使用方法,以及如何通过NPM下载第三方模块。 ... [详细]
  • 本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ... [详细]
  • Python爬虫中使用正则表达式的方法和注意事项
    本文介绍了在Python爬虫中使用正则表达式的方法和注意事项。首先解释了爬虫的四个主要步骤,并强调了正则表达式在数据处理中的重要性。然后详细介绍了正则表达式的概念和用法,包括检索、替换和过滤文本的功能。同时提到了re模块是Python内置的用于处理正则表达式的模块,并给出了使用正则表达式时需要注意的特殊字符转义和原始字符串的用法。通过本文的学习,读者可以掌握在Python爬虫中使用正则表达式的技巧和方法。 ... [详细]
  • iOS超签签名服务器搭建及其优劣势
    本文介绍了搭建iOS超签签名服务器的原因和优势,包括不掉签、用户可以直接安装不需要信任、体验好等。同时也提到了超签的劣势,即一个证书只能安装100个,成本较高。文章还详细介绍了超签的实现原理,包括用户请求服务器安装mobileconfig文件、服务器调用苹果接口添加udid等步骤。最后,还提到了生成mobileconfig文件和导出AppleWorldwideDeveloperRelationsCertificationAuthority证书的方法。 ... [详细]
  • SpringMVC接收请求参数的方式总结
    本文总结了在SpringMVC开发中处理控制器参数的各种方式,包括处理使用@RequestParam注解的参数、MultipartFile类型参数和Simple类型参数的RequestParamMethodArgumentResolver,处理@RequestBody注解的参数的RequestResponseBodyMethodProcessor,以及PathVariableMapMethodArgumentResol等子类。 ... [详细]
author-avatar
安徒生笔下苍老了谁1_120
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有