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

dxy-dialog

v1.0.5

Published

丁香园前端对话框组件

Downloads

9

Readme

dxy-dialog

npm npm

丁香园前端对话框组件

Demo

DXY Dialog Demo

使用方法

1. 使用 npm 安装

安装

$ npm install dxy-dialog --save

使用

JS:

var dxy_dialog = require('dxy-dialog');
dxy_dialog.show({
    title: {
        txt: '标题',
        align: 'center',
        fontSize: '20px',
        color: '#167ce7',
        style: {'fontWeight': 400, 'textDecoration': 'underline'},
    },
    msg: '消息消息消息消息消息消息',
    width: '400px',
    buttons: [
        {
            text: '按钮1',
            cls: 'myBtn1',
            handler: function () {
                dxy_dialog.hide();
                alert('点击了按钮1');
            }
        },
        {
            text: '按钮2',
            cls: 'myBtn2',
            handler: function () {
                dxy_dialog.hide();
                alert('点击了按钮2');
            }
        }
    ],
    buttonsAlign: 'center',
    modal: true,
    opacity: 0.5,
    closable: true,
    cls: 'myDialog',
    onClose: function () {
        alert('弹窗关闭');
    },
    mainColor: '#fff',
    secondColor: '#1976D2'
});

CSS:

@import "dxy-dialog/dist/dxy-dialog.min.css";

2. 通过 <script> 直接引用

引用

<link rel="stylesheet" href="dxy-dialog.min.css">
<!--...-->
<script src="jquery.js"></script>
<script src="dxy-dialog.min.js"></script>

使用

var dialog = new dxy_dialog();    // 此时 dxy_dialog 为全局变量
dxy_dialog.show({
    title: {
        txt: '标题',
        align: 'center',
        fontSize: '20px',
        color: '#167ce7',
        style: {'fontWeight': 400, 'textDecoration': 'underline'},
    },
    msg: '消息消息消息消息消息消息',
    width: '400px',
    buttons: [
        {
            text: '按钮1',
            cls: 'myBtn1',
            handler: function () {
                dxy_dialog.hide();
                alert('点击了按钮1');
            }
        },
        {
            text: '按钮2',
            cls: 'myBtn2',
            handler: function () {
                dxy_dialog.hide();
                alert('点击了按钮2');
            }
        }
    ],
    buttonsAlign: 'center',
    modal: true,
    opacity: 0.5,
    closable: true,
    cls: 'myDialog',
    onClose: function () {
        alert('弹窗关闭');
    },
    mainColor: '#fff',
    secondColor: '#1976D2'
});

API

dialog.show(options);    // 显示
dialog.hide();           // 隐藏

options:

  • title: String, 可选, 对话框各项配置

    • txt: String, 可选, 对话框标题,此项不选,其余项无效

    • align: String, 可选, 对话框标题位置,默认居中,对应text-align属性

    • color: String, 可选, 对话框标题颜色

    • fontSize: String, 可选, 对话框标题字体大小

    • style: Object, 可选, 自定义的style

  • msg: String, 可选, 对话框内容

  • width: String, 可选, 对话框宽度, 默认350px

  • buttons: Array, 可选, 对话框按钮, 数组元素为对象

    • text: String, 可选, 按钮文字

    • cls: String, 可选, 自定义按钮的class

    • handler: Object, 可选, 点击按钮回调函数

  • buttonsAlign: String, 可选, 按钮组位置,默认居中, 对应text-align属性

  • modal: Boolean, 可选, 显示遮罩层, 默认为true

  • opacity: Number, 可选, 遮罩层透明度, 默认为0.5

  • closable: Boolean, 可选, 显示关闭按钮, 默认为true

  • cls: String, 可选, 自定义对话框的class

  • onClose: Object, 可选, 对话框关闭回调函数

  • mainColor: String, 对话框主色(背景)

  • secondColor: String, 对话框副色(边框、按钮颜色)