/mvalert

a mini alter component

Primary LanguageJavaScriptMIT LicenseMIT

mvalert

a mini alert component,which has no dependencies.

Supports

browser Chrome Edge Firefox internet Explorer Opera Safari
version 8.0 Yes 3.6 10 11.50 5.1

Installation

Via npm

npm install mvalert --save

Via bower

bower install mvalert --save

##Usage

The mvalert component will return an object which containe two method alert and confirm,the same function as browser.

###alert(title,message,[options],[callback])

  • title , the title of the popup window,can not be null and undefined

  • message,the message will be shown in the popup window body,can be a string or basic html tag,can not be null and undefined

  • callback,when click button in the popup window ,will invoke the callback with a paramter.

  • options, configure popup window.There is default value.

     //default options config
     var options = {
         ok: '确定',//ok button text
         cancel: '取消',//cancel button text
         id: null,//default to timestamp 
         icon: null//icon class name,popup window have not icon in default.
     };

###confirm(title,message,[options],[callback]) These params are the same as alert.

##Examples more details see example.

###alert

function $$(selector) {
    return document.querySelector(selector);
}
var mv = Object.create(MvAlert);
$$('#alert').addEventListener('click', function (e) {
    mv.alert('标题', '这里是提示消息,可以是html标签', function (isOk) {
        console.log(isOk);
    });
});

###confirm

$$('#confirm').addEventListener('click', function (e) {
    mv.confirm('标题', '这里是提示消息,可以是html标签', function (isOk) {
        console.log(isOk);
    });
});

Contributing

I welcome contributions of all kinds from anyone.

Changelog

v1.0.2

optimise and fix some problems

v1.0.1

  • remove img and use css for icon
  • fix callback closures problem
  • remove alert className to avoid conflict

v1.0.0

first release,complete basic functions.

License

Licensed under the MIT License