Code Monkey home page Code Monkey logo

custom-javascript-alert's Introduction

custom-javascript-alert

Get rid of your generic "confirm" and "alert" javascript function, be more UI friendly with your visitors.

Demo

Instructions

  1. link "dist/custom-alert.css" css file to the document.
  2. import "CustomAlert" class from "dist/custom-alert.js".
    import {CustomAlert} from './dist/custom-alert.js';
  1. instanciate an object with "CustomAlert" class.
  2. you ae good to go !

alert method

  import {CustomAlert} from './dist/custom-alert.js';
  const obj = new CustomAlert;
  obj.alert(str,boolean,time);
  • str : (string) message you want to alert
  • boolean :(boolean) you want 'OK' button or not in the alert [OPTIONAL : dwafult : false]
  • time : (int) time in ms, for how long the alert will appear. [OPTIONAL: deafult : 3000]

confirm method

  import {CustomAlert} from './dist/custom-alert.js';
  const obj = new CustomAlert;
  obj.confirm(str,callback1,callback2);
  • str : (string) message you want to confirm
  • callback1 : this callback will be exeuted after "Yes" (confirm) action.
  • callback2 : this callback will be exeuted after "No" (not confirm) action. [OPTIONAL: deafult : return]

Example

  • check "sample/sample.html" for working example.
    import {CustomAlert} from './dist/custom-alert.js';
    const obj = new CustomAlert;
    obj.alert("This is alert message !!",true,4000);
    obj.confirm("Are you sure that you want to delete ?",()=>{ console.log('deleted')} ,()=>{ console.log('not deleted')} );

Make it yours

  • make chamges in "custom-alert.css" file to edit the UI of alert box.
  • chanage colors of UI elements.
  • Warning : do not play with any transform property.

custom-javascript-alert's People

Contributors

ashkr808 avatar

Stargazers

 avatar

Watchers

 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.