This simple library allows you to create awesome responsive and highly customizable popups importing just one JavaScript file.

Overview

Creativa - Popup

This is a simple library that allows you to create awesome popups importing just one JavaScript file.

Getting started

You can import the JS file in two ways:

  1. Using the HTTPS link to the file: https://creativajs.altervista.org/popup/0.2/creativa-popup.js
  2. With offline file. If you want to use the offline file just download the archive, import the creativa-popup.js file in your project and use it into your HTML.

Examples

Basic example:

<html>
    <head>
        <script src="https://creativajs.altervista.org/popup/0.2/creativa-popup.js"></script>
        <title>Creativa Popup - Example</title>
    </head>
    <body>
        <button onclick="popup()">Open popup</button>
    </body>
    <script>
        function popup() {
            CreativaPopup.create('This is the text of the popup.');
        }
    </script>
</html>

You can download the archive from GitHub and try the example.html file. Or you can go here: https://creativajs.altervista.org/popup/0.2/example.html

Where is the CSS?

The CSS will be automatically included from the creativa-popup.js file inside the HTML head. If this not happens or you want to use it locally, just import and use the CSS file too.

Customizable

Every aspect of the popup is customizable.

Responsive

The popup will adapt to every screen.

Multiple popups

You can open multiple popups one over another.

Tested browsers

  • Chrome
  • Firefox
  • Microsoft Edge
  • Safari

It doesn't work with the old Internet Explorer.

Slow loading icons and CSS

The reason why the icons are loading too slow is that they are loaded from an external CDN. You can open the JavaScript file and replace that CDN link with your own local folder and put the icons inside it, so they will be loaded from your local storage. The same thing has to be done for the CSS file.

Syntax

CreativaPopup.create('text', 'title', 'icon', options);
  • Text

Here you can write the text that will be shown inside the popup. You can use HTML too.

  • Title

This is a simple string that defines the title for the popup.

  • Icon

This parameter defines the popup icon that will be on top of the box. You can use default icons:

  • info
  • success
  • error

...or you can put your own URL (or local path) to the image of the icon (png, jpg, gif).

  • Options

This is an object where you can specify other parameters to personalize the popup.

  • Image: you can write the URL of an image that will be shown inside the popup.
// Including text content
CreativaPopup.create('Text', 'Title', 'icon', { image: 'imageURL or path' });
  • Content: you can put a string that specify custom content for the poup (such as HTML, or other text) that will be shown under the text.
  • isPage: this is a boolean that says if the content (specified above) is text content or it is an URL to another page that will be loaded as content inside the popup.
// Including text content
CreativaPopup.create('Text', 'Title', 'icon', { content: '<button>Test</button>' });

// Including content from another page
// This function does not work without an HTTP server due to Cross Origin problems.
CreativaPopup.create('Text', 'Title', 'icon', { content: 'another-page.html', isPage: true });
  • Unclosable popup: you can specify this parameter to avoid the popup to close.
CreativaPopup.create('Text', 'Title', 'icon', { isBlocked: true });
  • Open/close animations: the default open/close animation for the popup is the card-bottom/card-top but you can set other animations:
    • fade
    • bubble
    • card-left
    • card-right
    • card-bottom
    • card-top
    • newspaper
    • unfold
CreativaPopup.create('Text', 'icon', 'icon', { openAnimation: 'card-left', closeAnimation: 'card-right' });

... or you can create your own animation inside your CSS file. Just give a name to the animation and then add -ct-popup-animation-open or -ct-popup-animation-close at the end of the class name. For example, if my animation is called dragon I'll create the CSS animations with these names: dragon-ct-popup-animation-open and dragon-ct-popup-animation-close and inside the popup function I'll set the dragon string.

  • Custom speed animation: you can change the open/close speed animation by setting the time in milliseconds. The default value is 150.
CreativaPopup.create('Text', 'Title', 'icon', { openAnimation: 'card-left', closeAnimation: 'card-right', animationSpeed: 400 });
  • Custom animation type: you can change the animation type by setting the CSS timing function name. The default value is ease.
CreativaPopup.create('Text', 'Title', 'icon', { animationType: 'ease-out' });
  • Custom size: you can use different width and height for your popup.
CreativaPopup.create('Text', 'Title', 'icon', { width: '300px', height: '400px' });

This is CSS so you can use every type of unit of measure (px, %, em ecc...).

  • Positioning: you can set the position of the popup (top, bottom).
CreativaPopup.create('Text', 'Title', 'icon', { position: 'top' });
CreativaPopup.create('Text', 'Title', 'icon', { position: 'bottom' });
  • Background color: you can set the background color using HEX, RGB, RGBA codes.
// Red background using HEX code
CreativaPopup.create('Text', 'Title', 'icon', { bgColor: '#ff0000' });

// Red opaque background using HEX code with alpha
CreativaPopup.create('Text', 'Title', 'icon', { bgColor: '#ff000055' });

// Red background using RGB code.
CreativaPopup.create('Text', 'Title', 'icon', { bgColor: 'rgb(255, 0, 0)' });

// Red opaque background using RGBA code.
CreativaPopup.create('Text', 'Title', 'icon', { bgColor: 'rgba(255, 0, 0, 0.4)' });
  • Remove Background: you can remove the background panel with this simple option.
CreativaPopup.create('Text', 'Title', 'icon', { background: true });
  • Remove Box Container: you can remove the box container with this option.
CreativaPopup.create('Text', 'Title', 'icon', { box: false });
  • Title/text color: you can set the title and text color using HEX, RGB, RGBA codes.
// Red title and text using HEX code
CreativaPopup.create('Text', 'icon', 'icon', { titleColor: '#ff0000', textColor: '#ff0000' });

// Red opaque title and text using HEX code with alpha
CreativaPopup.create('Text', 'icon', 'icon', { titleColor: '#ff000055', textColor: '#ff000055' });

// Red title and text using RGB code.
CreativaPopup.create('Text', 'icon', 'icon', { titleColor: 'rgb(255, 0, 0)', textColor: 'rgb(255, 255, 0)' });

// Red opaque title and text using RGBA code.
CreativaPopup.create('Text', 'icon', 'icon', { titleColor: 'rgba(255, 0, 0, 0.4)', textColor: 'rgba(255, 255, 0, 0.4)' });
  • Border radius: you can change the popup border radius by adding a simple option.
CreativaPopup.create('Text', 'Title', 'icon', { borderRadius: '20px' });
  • Custom font: you can change the font for the popup box.
CreativaPopup.create('Text', 'Title', 'icon', { fontFamily: 'Times New Roman' });
  • Custom box shadow: by default the popup has a black box shadow but you can change it. This option uses CSS like the others do.
CreativaPopup.create('Text', 'Title', 'icon', { boxShadow: '0px 6px 12px 2px #red' });
  • Close button: by default the popup has a red close button on the top right corner, but you can hide it.
CreativaPopup.create('Text', 'Title', 'icon', { closeButton: false });
  • Timer: you can set a timer (in seconds) and the popup will close after the time ends.
CreativaPopup.create('Text', 'Title', 'icon', { timer: 3 });
  • Closing functions

  • If you want to close a specific popup you can call the function CreativaPopup.close(popupID).
  • If you want to close all the opened popups you can call the method CreativaPopup.closeAll().
  • If you want to close the popup after a certain time you can call the method CreativaPopup.timerClose(popupID, timeSeconds).
  • Close event listener

If you want to know when and what popup has been closed use this event listener:

document.addEventListener('onPopupClose', function (e) { 
    console.log('Popup closed ID: ' + e.detail); 
});

Conclusions

Of course you can use every option you want and mix them together.

You might also like...

Type Identity - a powerful and highly customizable authentication and authrozation and access-control framework

Type Identity is a powerful and highly customizable authentication and authrozation and access-control framework. It is the de-facto standard for securing Type Script api beta release

Jan 1, 2023

`raaghu-mfe` is an opensource micro front end framework built on top of `raaghu-elements`, Bootstrap 5 and Storybook offering highly customizable UI components and built-in pages

 `raaghu-mfe` is an opensource micro front end framework built on top of `raaghu-elements`, Bootstrap 5 and Storybook offering highly customizable UI components and built-in pages

`raaghu-mfe` is an opensource micro front end framework built on top of `raaghu-elements`, Bootstrap 5 and Storybook offering highly customizable UI components and built-in pages. Raaghu mfe can be used as a base to build complex components and UI layouts whilst maintaining a high level of reusability,flexibility with ease of maintenance.

Dec 30, 2022

Highly customizable checkboxes and radio buttons (jQuery & Zepto)

iCheck plugin 1.0.3 Highly customizable checkboxes and radio buttons for jQuery and Zepto. Refer to the iCheck website for examples. Note: iCheck v2.0

Dec 25, 2022

Highly customizable checkboxes and radio buttons (jQuery & Zepto)

iCheck plugin 1.0.3 Highly customizable checkboxes and radio buttons for jQuery and Zepto. Refer to the iCheck website for examples. Note: iCheck v2.0

Aug 24, 2022

A highly customizable homepage (or startpage / application dashboard) with Docker and service API integrations.

A highly customizable homepage (or startpage / application dashboard) with Docker and service API integrations.

Features Web Bookmarks Service Bookmarks Docker Integration Status light + CPU, Memory & Network Reporting (click on the status light) Service Integra

Dec 30, 2022

jQuery easy ticker is a news ticker like plugin, which scrolls the list infinitely. It is highly customizable, flexible with lot of features and works in all browsers.

jQuery Easy Ticker plugin jQuery easy ticker is a news ticker like plugin which scrolls a list infinitely. It is highly customizable, flexible with lo

Dec 20, 2022

A highly customizable platform ready to be a portfolio website, and become a lot more with some of your own components

A highly customizable platform ready to be a portfolio website, and become a lot more with some of your own components

Vextra Elegant and animated portfolio website. Demo: vextra.vercel.app Vextra is a portfolio template, packed with animations with a satisfying flow t

Sep 19, 2022

Easy to setup and highly customizable leaderboard with built-in score validation system.

EasyLeaderboard Add a leaderboard to your game in under 10 minutes! 🏃 Ready to go game clients make adding a leaderboard quick and easy 🕵️ Extendabl

Sep 30, 2022

🔨 A more engineered, highly customizable, standard output format commitizen adapter.

🔨 A more engineered, highly customizable, standard output format commitizen adapter.

cz-git Github | Installation | Website | 简体中文文档 Introduction A more engineered, highly customizable, standard output format commitizen adapter. What i

Dec 31, 2022
Releases(0.2)
Owner
Eduardo Mollo
Eduardo Mollo
EggyJS is a Javascript micro Library for simple, lightweight toast popups focused on being dependency-less, lightweight, quick and efficient.

EggyJS EggyJS is a Javascript micro Library for simple, lightweight toast popups. The goal of this library was to create something that meets the foll

Sam 10 Jan 8, 2023
A beautiful, responsive, highly customizable and accessible replacement for JavaScript's popup boxes. Zero dependencies.Alerts ,dialogs

AsgarAlert (v1) for JS Install <script defer src="/asgar-alert.js"></script> Examples The most basic message: asgar("Hello world!"); A message signali

Asgar Aliyev 5 Dec 20, 2022
Hadmean is an internal tool generator. It is language agnostic, schema driven, extremely customizable, featured packed, user-friendly and has just one installation step.

Hadmean Report a Bug · Request a Feature · Ask a Question Table of Contents About Quick Demo Motivation Why you should try Hadmean Getting Started Pre

Hadmean 344 Dec 29, 2022
🛡️ Dead-simple, yet highly customizable security middleware for Apollo GraphQL servers and Envelop 🛡️

GraphQL Armor ??️ GraphQL Armor is a dead-simple yet highly customizable security middleware for various GraphQL server engines. Contents Contents Sup

Escape – GraphQL Security 267 Jan 9, 2023
Feel free to create new file, don't hesitate to pull your code, the most important thing is that the file name here must match your nickname so that file does not conflict with other people.

Hacktoberfest Indonesia Apa Itu Hacktoberfest ? Hacktoberfest adalah acara tahunan yang bertujuan untuk mendorong berkontribusi kedalam ekosistem open

Juan Daniel 5 Dec 15, 2022
"Awesome books" is a simple website that displays a list of books and allows you to add ang remove books from that list. Also you can store your data in your local storage. Build with JavaScript, HTML and CSS.

Awesome Books Creating an app that adds and delete books from a list. Built With HTML CSS JavaScript Application Page url https://TimmyChan99.github.i

Fatima Ezzahra elmenoun 5 Jan 28, 2022
Cindy Dorantes 12 Oct 18, 2022
A tool to simplify importing custom assets in Minecraft

BAMO - Block And Move On A tool to simplify importing custom assets in Minecraft Currently only allows you to quickly prototype models in-game, but fu

Tom Mudway 3 Jul 15, 2022
three.js loader for importing M2 assets from World of Warcraft.

three-m2loader · M2 Loader for three.js three-m2loader allows you to import M2 assets from World of Warcraft into your three.js app. druidcat2.m2 7ne_

Michael Herzog 14 Dec 30, 2022