Giter Site home page Giter Site logo

wanzbot1 / simple-popup Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dabeng/simple-popup

0.0 0.0 0.0 1.16 MB

Hope this small jquery snippet to help you replace all primitive popup boxes of native javascript including alert box, confirm box, prompt box.

Home Page: http://dabeng.github.io/Simple-Popup/

License: MIT License

CSS 18.24% JavaScript 81.76%

simple-popup's Introduction

Simple Popup

Hope this small jquery snippet to help you replace all primitive popup boxes of native javascript including alert box, confirm box, prompt box.

Demo

screen record

Usage

  • jQuery version

    1. Firstly, introduce jQuery(1.5+) into your page.
    2. Then, introduce assets(js + css) of Simple Popup into your page.
    3. Finally, replace any alert(), confirm() and prompt() method in page with simplePopup() method on page.
  • native javascript version

    1. First, introduce assets(js + css, obviously, both of the two version use the same css file) of Simple Popup into your page.
    2. Then, replace any alert(), confirm() and prompt() method in page with simplePopup()

built-in alert box

alert('An exception occurred.');
event.target.nextElementSibling.textContent = 'The application has just got an exception.';

Simple Popup alternative of jquery version

var alertBox = simplePopup(0, 'An exception occurred.');
$.when(alertBox).then(function() {
  $(event.target).next().text('The application has just got an exception.');
});

Simple Popup alternative of javascript version

simplePopup(0, 'An exception occurred.').then(function() {
  event.target.nextElementSibling.textContent = 'The application has just got an exception.';
});

built-in prompt box

var res = confirm('It\'s time to change. Do you agree with me?');
if (res) {
  event.target.nextElementSibling.textContent = 'Yes, let\'s go for it.';
} else {
  event.target.nextElementSibling.textContent = 'No, this is not the time.';
}

Simple Popup alternative of jquery version

var confirmBox = simplePopup(1, 'It\'s time to change. Do you agree with me?');
$.when(confirmBox).then(function(res) {
  if (res) {
    $(event.target).next().text('Yes, let\'s go for it.');
  } else {
    $(event.target).next().text('No, this is not the time.');
  }
});

Simple Popup alternative of javascript version

simplePopup(1, 'It\'s time to change. Do you agree with me?').then(function(res) {
  if (res) {
    event.target.nextElementSibling.textContent = 'Yes, let\'s go for it.';
  } else {
    event.target.nextElementSibling.textContent = 'No, this is not the time.';
  }
});

built-in prompt box

var username = prompt('Please enter your username', 'Michael Jordan');
if (username != null && username != '') {
  event.target.nextElementSibling.textContent = username + ', hey, welcome back.';
}

Simple Popup alternative of jquery version

var promptBox = simplePopup(2, 'Please enter your username', 'Michael Jordan');
$.when(promptBox).then(function(res) {
  if (res) {
    $(event.target).next().text(res + ', hey, welcome back.');
  } else {
    $(event.target).next().text('Anoymous user logs in.');
  }
});

Simple Popup alternative of javascript version

simplePopup(2, 'Please enter your username', 'Michael Jordan').then(function(res) {
  if (res) {
    event.target.nextElementSibling.textContent = res + ', hey, welcome back.';
  } else {
    event.target.nextElementSibling.textContent = 'Anoymous user logs in.';
  }
});

killer Feature

  1. When you toggle the popup boxes with simpelPopup() method, the overlayed background keeps its position just where it was.
  2. As you can see above, this plugin help you rewrite the current code With the least code modifications.

Browser Support

1. Simple Popup of jquery version

  • Chrome 8.0+
  • Firefox 3.6+
  • Safari 3.1.2+
  • Opera 9.64+

2. Simple Popup of javascript version

  • Chrome 32.0+
  • Firefox 29.0+
  • Safari 7.1+
  • Opera 19+

simple-popup's People

Contributors

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