GithubHelp home page GithubHelp logo

yangxin1994 / acc-msg-component Goto Github PK

View Code? Open in Web Editor NEW

This project forked from accelerator-feng/acc-msg-component

0.0 0.0 0.0 18 KB

原生JS模态框组件

Home Page: http://yinfengblog.xyz/Acc-msg-component/

JavaScript 67.70% HTML 17.89% CSS 14.41%

acc-msg-component's Introduction

Acc-msg-component

原生JS模态框组件

  • 可自定义模态框大小位置内容
  • 可设置皮肤
  • 可设置拖动
  • 可设置模态框遮罩
  • 可绑定多个回调函数,且支持链式调用
  • 支持AMD,ES6模块引入以及<script>标签引入

API:

.alert( config ):

config

类型: Object

各项属性默认值

   {
       width: 300,           // 模态框宽度
       title: '系统提示',     // 标题
       content: 'welcome!',   // 内容
       textAlertBtn: '确定',  // 按钮内容
       handlerAlertBtn: null,  // 回调函数
       skinClassName: null,    // 皮肤类名
       hasMask: true,          // 是否有遮罩层
       isDraggable: true       // 是否可拖动
   }  

.confirm( config ):

config

类型: Object

各项属性默认值

   {
       width: 300,           // 模态框宽度
       title: '系统提示',     // 标题
       content: 'welcome!',   // 内容
       textConfirmBtn: '确定', // 按钮内容
       textCancelBtn: '取消',
       handlerConfirmBtn: null, // 回调函数
       handlerCancelBtn: null,
       skinClassName: null,    // 皮肤类名
       hasMask: true,          // 是否有遮罩层
       isDraggable: true       // 是否可拖动
   }  

.prompt( config ):

config

类型: Object

各项属性默认值

   {
       width: 300,                    // 模态框宽度
       title: '系统提示',             // 标题
       content: 'welcome!',           // 内容
       textPromptBtn: '确定',         // 按钮内容
       textCancelBtn: '取消',
       isPromptInputPassword: false,  // 是否作为密码显示
       defaultValuePromptInput: '',   // 文本框默认值
       maxlengthPromptInput: 10,      // 输入字数限制
       handlerPromptBtn: null,        // 回调函数
       handlerCancelBtn: null,
       skinClassName: null,           // 皮肤类名
       hasMask: true,                 // 是否有遮罩层
       isDraggable: true,             // 是否可拖动
    }

.on( events , handler() )

events

类型: String

一个事件类型,比如"alert", "confirm", "prompt", 或者 "cancel"。

handler()

类型: Function()

事件被触发时,执行的函数。

使用示例:

import Acc from './Acc.js';
let modal = new Acc();
modal.confirm({
        title: 'confirm标题',
        content: 'confirm内容',
        handlerConfirmBtn: function() {
            alert('confirm第一个回调');
        },
        handlerCancelBtn: function() {
            alert('cancel第一个回调');
        },
        textConfirmBtn: 'hello',
        textCancelBtn: 'world',
        isDraggable: false,
    })
    .on('confirm', function() {
        alert('confirm第二个回调');
    })
    .on('confirm', function() {
        alert('confirm第三个回调');
    })
    .on('cancel', function() {
        alert('cancel第二个回调');
    })
    .on('cancel', function() {
        alert('cancel第二个回调');
    });

acc-msg-component's People

Contributors

accelerator-feng avatar

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.