Code Monkey home page Code Monkey logo

dialog.js's Introduction

移动端弹窗插件第二版已经上线,GitHub地址 ###新特性

  • 弹窗可选 IOS 或者 Material Design 风格
  • 可自定义多个按钮
  • 按钮排版样式,并排或者堆叠
  • notice 弹窗的位置,居中或者底部
  • 支持同时显示多个弹窗

dialog.js

移动端Dialog弹出对话框插件,同时支持jQuery和Zepto

特性:

  • 支持四种类型的弹窗展示:alert、confirm、info、tips;
  • 方便定制,可以自定义按钮的文字、样式、回调函数;
  • 支持 jQuery 和 Zepto JavaScript工具库;
  • 4个状态事件,用来监听状态改变;对话框默认样式主要针对移动端展示做优化。

DEMO:

查看效果,请点击→:demo示例

项目地址二维码

三种类型的对话框:

1)alert 类型; alert类型

2)confirm 类型 confirm类型

3)info 类型; info类型

引用文件:

1、CSS

<link rel="stylesheet" href="css/dialog.css">

2、JS

<script src="js/zepto.min.js"></script>
<script src="js/dialog.js"></script>

3、JS 调用

$.dialog({
    contentHtml : '弹出对话框的内容部分'
});

参数

选项 类型 默认值 说明
type string 'alert' 对话框的种类(alert-确定; confirm-确定/取消; info)
titleText string '信息提示' 标题文字
showTitle bool true 是否显示标题。值为:true、false
contentHtml string '' 主体部分的HTML内容。默认值为空
dialogClass string '' 对话框自定义的 class。默认值为空
autoClose number 0 自动关闭的延时时间(单位:毫秒)。为0时表示不自动关闭;大于0时,表示自动关闭对话框
overlayClose bool fasle 是否可点击遮罩层关闭对话框。值为:true、false
buttonText string { ok : '确定', cancel : '取消' } 按钮的文字
buttonClass string {ok : '', cancel : ''} 按钮的自定义 class
infoText string '' info 类型对话框的提示文字
infoIcon string '' info 类型对话框的提示图标。值为图标的路径
onClickOk fn function(){} 回调函数,点击“确定”按钮时执行
onClickCancel fn function(){} 回调函数,点击“取消”按钮时执行
onBeforeShow fn function(){} 回调函数,对话框显示前时执行
onShow fn function(){} 回调函数,对话框显示后时执行
onBeforeClosed fn function(){} 回调函数,对话框关闭前时执行
onClosed fn function(){} 回调函数,对话框关闭后时执行

方法

方法 说明
$.dialog.close 关闭对话框。用法:dialogObj.dialog.close()
$.dialog.update 更新info、tips类型对话框的状态(图标、提示文字),该方法可传入autoClose、infoText、infoIcon三个参数。
dialogObj.dialog.update({ autoClose : 1500, infoText : '操作成功', infoIcon : 'images/icon/success.png' })

#最新版本

1.0.3 (2016-07-15)

  • 修复弹窗在低版本安卓手机无法居中显示;
  • 修复连续点击遮罩层后,弹窗会自动关闭;
  • 延迟阻止Tap点透层的关闭时间;
  • 增加 info 和 tips 类型弹窗的关闭前与关闭后的回调函数;
  • 通过CSS3启用GPU硬件加速

全部更新日志

dialog.js's People

Contributors

sufangyu avatar amiraslanaslani avatar

Stargazers

 avatar  avatar OrangBus avatar  avatar  avatar Guanchen Ding avatar peade avatar James avatar c avatar  avatar  avatar wangxingwen avatar  avatar lairong avatar will avatar MK avatar  avatar kyrie avatar  avatar  avatar  avatar Xiaodong Che avatar kid avatar xxoo avatar liruli avatar Ainto avatar  avatar Yufeng Lian avatar 董智含 avatar 学数学的程序猿 avatar Tom Tran avatar  avatar 煎饼果子 avatar kedachen avatar kibf avatar yindz avatar Erix avatar shijun Hou avatar Amy avatar Manu avatar Today.sun avatar 二月 avatar  avatar jimmy lin avatar theScoreONE avatar  avatar storyflow avatar jack avatar lichia avatar jyolo avatar 3en avatar  avatar Steven avatar  avatar  avatar faith avatar Haoz03 avatar 木白 avatar  avatar BuildIteazy avatar  avatar topul avatar 铁锤 avatar  avatar  avatar  avatar  avatar yuuk avatar

Watchers

yindz avatar James Cloos avatar  avatar 铁锤 avatar 木白 avatar  avatar  avatar

dialog.js's Issues

有文本框时不能输入

发现contentHtml有文本框时,在手机(iphone)上不能输入,请问如何解决
$.dialog({ type : 'confirm', contentHtml : '<input type="text" /> ', onClickOk : function(){ alert('你点了确定~~'); } });

问题

弹出框之后背景都变成了白色

onClickOk方法返回false为啥不能阻止对话框关闭

我需要验证一个表单,当onClickOk返回return false,不能阻止关闭动作了
$.dialog({ type : 'confirm', titleText:'', html:'', onClickOk:function(){ if($.trim($('#xxx').val()) == ''){ alert('该字段不能为空') return false; }else{ ... } } });

306行,delete是关键字

buttonText : {
ok : '确定',
cancel : '取消',
delete : '删除'
},
delete是关键字,且没有使用,是否可以移除

配合其他插件使用时有冲突

页面上同时使用了dialog.js和一个前端markdown的插件(markdown-plus.min.js):http://mdp.tylingsoft.com/
dialog.js使用的是confirm类型,但是click之后提示:Uncaught TypeError: $.dialog is not a function

调试时能看到$符号使用的并不是dialog.js内部的,而是markdown-plus.min.js内的对象。

是否有办法避免这种冲突?

ajax 的时候不用能两个 dialog吗?

$.ajax({
type:'post',
url:url,
beforeSend:function () {
$.dialog({
type : 'info',
infoText : '加载中…',
infoIcon : 'images/icon/loading.gif',
autoClose : 2500
});
},
success:function (msg) {
$.dialog.close();

                    if(msg.state == 'fail'){
                        $.dialog({
                            contentHtml : msg.info,
                        });
                    }
                }
            })

这种情况下,只显示 beforeSend 里面的 loading ,无法显示 success 里面的 dialog !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.