Giter Site home page Giter Site logo

deawx / alerty Goto Github PK

View Code? Open in Web Editor NEW

This project forked from undead25/alerty

0.0 2.0 0.0 99 KB

A simple, light and pretty pure javascript for developing browser dialogs and notifications which is following Google's Material Design guidelines. Obviously, it is responsive and no need other library

License: MIT License

JavaScript 73.34% HTML 12.24% CSS 14.42%

alerty's Introduction

Alerty npm

A simple, light and pretty pure javascript for developing browser dialogs and notifications which is following Google's Material Design guidelines. Obviously, it is responsive and no need other library.

Usage

you can install alerty with npm

npm install alerty
var alerty = require('alerty');

or with bower

bower install alerty

Alternatively, download the package and reference the JavaScript and CSS files manually:

<script src="dist/js/alerty.min.js"></script>
<link rel="stylesheet" type="text/css" href="dist/css/alerty.min.css">

Examples

you can run example local with gulp if node has been installed:

cd alerty
npm install
gulp

or test it on jsfiddle

Usage

For alert dialog

alerty.alert('Hello, World!');

For toasts

alerty.toasts('Something has been done!');

For confirm dialog

alerty.confirm('Are you sure?', funtion() {
  console.log('ok callback'); // do something
}, function(){
  console.log('cancel callback'); // do something
})

For prompt dialog

alerty.prompt(
  'Please write some thing', 
  {
    inputType: 'email', // input type
    inputPlaceholder: 'fill the blank'
  },
  function(value){
    alerty.alert('value you typed is: <b>'+value+'</b>')
  }
)

API

alerty.toasts(content[, opts], callback)

param type description
content string message to display
opts object options, optional
callback function callback after alerty closed

opts:

name type default description
place string 'bottom' 'top' can be choosed
bgColor string '#323232' background color of dialog body
fontColor string '#fff' font color of dialog message
time number 2000 time delay for dialog auto closed

alerty.alert(content[, opts], onOk)

param type description
content string message to display
opts object options, optional
onOk function callback after click ok button

opts:

name type default description
title string '' title of dialog
okLabel string 确定 ok button text

alerty.confirm(content[, opts], onOk, onCancel)

param type description
content string message to display
opts object options
onOk function callback after click ok button
onCancel function callback after click cancel button

opts:

name type default description
title string '' title of dialog
okLabel string 确定 ok button text
okLabel string 取消 cancel button text

alerty.prompt(content[, opts], onOk, onCancel)

param type description
content string message to display
opts object options
onOk function callback after click ok button, argument value, like above example
onCancel function callback after click cancel button

opts:

name type default description
title string '' title of dialog
okLabel string 确定 ok button text
okLabel string 取消 cancel button text
inputType string 'text' input type, such as 'password', 'email'
inputPlaceholder 'text' '' input placeholder text
inputValue 'text' '' default input value

Browser support

Alerty is tested and works in:

  • IE8+
  • Latest Stable: Firefox, Chrome, Safari, Edge
  • Android 4.0 and Latest
  • iOS7 and Latest

Contributing

If you have good ideas or suggestions, please issue or pull request

License

Alerty is licensed under MIT

alerty's People

Contributors

undead25 avatar

Watchers

 avatar  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.