11 Star 12 Fork 7

testnulldefined / PostbirdAlertBox.js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

PostbirdAlertBox.js

原生javascript弹框插件

在线体验:

http://postbird.oschina.io/postbirdalertbox.js/

更新

  • 2018-07-08

    • 修复由于 button focus 状态未清除导致的 enter 下重复触发的问题
    • 将 focus 重定向到弹框的 button 中,默认 enter 键操作时 alert/confirm 的确认操作

优点:

  • 无需手动写入html
  • 支持回调
  • 可配置性高,多种显示选择

使用方式:

1. 引入文件:

postbirdAlertBox.js
postbirdAlertBox.css

2. 调用方式:

1) alert

        PostbirdAlertBox.alert({
            'title': '提示',
            'content': '提示内容主体',
            'okBtn': '好的',
            'contentColor': 'red',
            'onConfirm': function () {
                console.log("回调触发后隐藏提示框");
                alert("回调触发后隐藏提示框");
            }
        });

2) confirm

        PostbirdAlertBox.confirm({
            'title': '提示',
            'content': '离开本页面进行跳转',
            'okBtn': '好的',
            'contentColor': 'red',
            'onConfirm': function () {
                console.log("OK - 回调触发后隐藏提示框");
                alert("OK - 回调触发后隐藏提示框");
            },
            'onCancel': function () {
                console.log("Cancel-回调触发后隐藏提示框");
                alert("Cancel-回调触发后隐藏提示框");
            }
        });

3) prompt

        PostbirdAlertBox.prompt({
            'title': '请输入姓名',
            'okBtn': '提交',
            onConfirm: function (data) {
                console.log("输入框内容是:" + data);
                alert("输入框内容是:" + data);
            },
            onCancel: function (data) {
                console.log("输入框内容是:" + data);
                alert("输入框内容是:" + data);
            },
        });

配置选项:

参数属性 意义 适用方法 是否必须
title 弹框标题 alert、confirm(不适用于prompt) 否,默认 : 提示信息
promptTitle prompt标题 prompt 否,默认 :请输入内容
content 提示内容主体 alert、confirm(不适用于prompt) 否,默认 : 提示内容
contentColor 提示内容颜色 alert、confirm 否,默认 : #000000
okBtn 确认按钮文字 alert、confirm (不适用于prompt) 否,默认 : 好的
promptOkBtn prompt确认按钮文字 prompt 否,默认 : 确认
okBtnColor 确认按钮颜色 alert、confirm、prompt 否,默认 : #0e90d2
cancelBtn 取消按钮文字 alert、confirm、prompt 否,默认 : 取消
onConfirm 确认按钮事件 alert、confirm、prompt(存在参数data) 否,默认 : 不触发事件
onCancel 取消按钮事件 alert、confirm、prompt(存在参数data) 否,默认 : 不触发事件

效果:

Alert

Confirn

Prompt

The MIT License (MIT) Copyright (c) 2016 postbird Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

原生javascript弹框插件,模拟 alert/confirm/prompt 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/postbird/PostbirdAlertBox.js.git
git@gitee.com:postbird/PostbirdAlertBox.js.git
postbird
PostbirdAlertBox.js
PostbirdAlertBox.js
master

搜索帮助