Coder Social home page Coder Social logo

alertkit's Introduction

AlertKit

A Javascript Alert Framework.

Functions

AlertKit.init

Sets up AlertKit for use.

Parameters Type Purpose Default Value
__alert   boolean sets alert() to AlertKit.alert() if true false
__prompt   boolean sets prompt() to AlertKit.alert() if true false
body_fix boolean sets <body>'s margin to 0 if true true
nef boolean priorities alerts yet to show up while delaying new alerts if true false
manualDismiss boolean if an alert is on screen while this is true, new alerts will be added to needsExecuted false

AlertKit.read

Returns class names in use by AlertKit.

Parameters Type Purpose
what   string or number class index / static name

AlertKit.alert

Displays an alert.

Parameters Type Purpose Default Value
title string Sets the title of the alert null
text string Sets the text of the alert null
buttons array or object creates buttons with actions. see buttons array below or creates prompt with callback. see prompt object below null
enableClickOut boolean If true, the user will be able to click outside the alert to dismiss it true
enterKey_ boolean If true, the user will be able to press the enter key to dismiss an alert without buttons or submit a prompt true
HTML boolean if true, html will be allowed in the alert's title and text. If false you will not be able to write html in title or text. To leave a new line if this is false, use \n false
seconds number sets the amount of seconds the alert will be displayed for false

Buttons

  [
    [
      "Button title", // This is this button title
      "alert('I was clicked!');", // This is the command you could run right when this button is clicked
      "#007aff", // This is the background hex of this button
      "#1987ff", // This is the background hex of this button when it's :active (held on to)
      null, // This is the colour hex
      null, // This is the colour hex when it's :active
      null, // This is the border css
      null, // This is the border hex when it's :active
      null, // This is the transition transition of this button
    ],
    [
      // this is another button, same as the layout above ^
    ]
  ]

Example:

AlertKit.alert("Example Alert", "Hello, world!", [
  ["Google", `location = "http://google.com/";`, "f44242", "41cdf4", null, null, null, null, "250ms"]
]);

Prompt

  {
  fields: ["Type here"], // This is the input field's placeholder
  okButtonTitle: "OK", // This is the title of the OK button
  cancelButtonTitle: "Cancel", // This is the title of the cancel button
  callback: function() { alert(arguments[0]); } // This is the function which handles the input
  }

Example:

AlertKit.alert("Example Alert", "Hello, world!", {
  fields: ["Type here..."],
  okButtonTitle: "Continue",
  cancelButtonTitle: "Nevermind",
  callback: function(input) { alert(input); }
  });

AlertKit.alert.close

Dismisses an open alert.

Example:

AlertKit.alert.close();

AlertKit.AlertKitDaemon

Replaces 'static' AlertKit class names in the innerHTML of all <style> tags with the dynamic class name.

Parameters Type Purpose
control   string command to control AlertKitDaemon

Example:

AlertKit.AlertKitDaemon("start"); / AlertKit.AlertKitDaemon(AlertKit.AlertKitDaemon.DAEMON_START);

Live Demo

Check this project out at https://1gamerdev.github.io/AlertKit/AlertKit.html!

Known Bugs

None

Credits

AlertKit by 1GamerDev, most of this README by S0n1c_Dev.

alertkit's People

Contributors

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