npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

proudsmart-message-box

v1.2.2

Published

一个提示框插件,兼容AMD规范,既可以直接使用script标签引用,也可以使用requirejs等引入

Downloads

5

Readme

proudsmart-message-box

一个提示框插件,兼容AMD规范,既可以直接使用script标签引用,也可以使用requirejs等引入

MessageBox的主要方法

alert(options, [confirmFn])
  • options类型是字符串或对象,当options为对象时,第二个参数将被自动忽略
  • 当options为字符串时,options将作为信息内容显示在弹出框内。
  • confirmFn作为点击确定按钮时的回调,其默认行为是关闭弹窗。点击事件作为该函数的参数,可调用preventDefault阻止默认行为
  • 当options为对象时,则必须包含message属性,否则会抛出错误。
  • 当options为对象时,可以包含confirmFn属性,作为点击确定按钮时的回调。
MessageBox.alert('这是一条提示信息!', function (e) {
    //点击确定按钮时触发此回调函数,此回调的参数是事件对象
    //调用事件对象的preventDefault方法,可阻止默认的关闭事件
    //e.preventDefault();
    console.log('> _ <')
});
MessageBox.alert({
    message: '这是一条提示信息!',
    confirmFn: function (e) {
        e.preventDefault();
    }
});
confirm(options, [confirmFn, cancelFn])
  • cancelFn为点击取消按钮时触发的回调函数,默认行为是关闭弹窗。函数的参数是事件对象,调用preventDefault阻止其默认行为
MessageBox.confirm({
    message: '这是一条确认信息!',
    confirmFn: function (e) {
        e.preventDefault();
        // doSomething
    },
    cancelFn: function (e) {
        //e.preventDefault();
        // ...
    }
});
prompt(options, [confirmFn, cancelFn])
  • confirmFn作为点击确定按钮的回调函数,有两个参数,
  • 第一个参数是事件对象,该对象的inputValue是输入框的值
  • 第二个参数是input中输入的值
MessageBox.prompt('请输入姓名', function (e, value) {
    console.log(value); // 在控制台打印输入框的值
    console.log(e.inputValue); // 在控制台打印输入框的值
}, function (e) {
    e.preventDefault();
    // doSomething
});
  • placeholder 可选,输入框的plactholder,默认为空
  • reg 可选,输入框的输入规则,应该是一个正则表达式
  • errorTip 可选,输入错误时的提示文字,当reg为空时,该属性不起作用
  • defaultValue 可选,输入框的默认文字
MessageBox.prompt({
    message: '输入一个数字',
    placeholder: '输入数字,长度为1到5',
    reg: /[0-9]{1,5}/,
    errorTip: '请输入数字',
    confirmFn: function (e, value) {
        // do something...
    }
});
其他参数

以上三个方法,还可设置下述参数

  • cancelButtonText 取消按钮的文字,默认为 "确定"
  • confirmButtonText 确定按钮的文字,默认为 "取消"
  • disableAnimation 是否禁用动画,默认为 false
dismiss()
  • 关闭弹窗,需要手动关闭弹窗时调用
MessageBox.prompt('请输入姓名', function (e) {
    console.log(e.inputValue);
}, function (e) {
    e.preventDefault();
    MessageBox.dismiss();//手动关闭弹窗
    //this.dismiss();//也可以关闭弹窗~
});