1.0.2 • Published 7 years ago

mvalert v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

mvalert

a mini alert component,which has no dependencies.

Supports

browserChromeEdgeFirefoxinternet ExplorerOperaSafari
version8.0Yes3.61011.505.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.

    	```javascript
    	//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

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago