Creativa - Popup This is a simple library that allows you to create awesome popups importing just one JavaScript file.
You can import the JS file in two ways:
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.
Everything aspect of the popup is customizable.
The popup will adapt to every screen.
You can open multiple popups one over another.
It doesn’t work with the old Internet Explorer.
You can download the archive from GitHub and try the example.html file. Or you can go here: https://creativajs.altervista.org/popup/example.html
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.
popup('title', 'text', 'icon', 'image', options);
This is a simple string that defines the title for the popup.
Here you can write the text that will be shown inside the popup. You can use HTML too.
This parameter defines the popup icon that will be on top of the box. You can use default icons:
…or you can put your own URL (or local path) to the image of the icon (png, jpg, gif).
Here you can write the URL of an image that will be shown inside the popup.
This is an object where you can specify other parameters to personalize the popup.
// Including text content
popup('Title', 'Text', 'icon', 'image', { content: '<button>Test</button>', isPage: false }
// Including content from another page
// This function might not work with Safari Browser due to Cross Origin problem; try to use HTTPS.
popup('Title', 'Text', 'icon', 'image', { content: 'another-page.html', isPage: true }
popup('Title', 'Text', 'icon', 'image', { isBlocked: true }
popup('Title', 'Text', 'icon', 'image', { openAnimation: 'card-left', closeAnimation: 'card-right' }
… or you can create your own animation inside your CSS file. Just give a name to the animation an 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.
popup('Title', 'Text', 'icon', 'image', { openAnimation: 'card-left', closeAnimation: 'card-right', animationSpeed: 400 }
popup('Title', 'Text', 'icon', 'image', { width: '300px', height: '400px' }
This is CSS so you can use every type of unit of measure (px, %, em ecc…).
popup('Title', 'Text', 'icon', 'image', { position: 'top' }
popup('Title', 'Text', 'icon', 'image', { position: 'bottom' }
// Red background using HEX code
popup('Title', 'Text', 'icon', 'image', { bgColor: '#ff0000' }
// Red opaque background using HEX code with alpha
popup('Title', 'Text', 'icon', 'image', { bgColor: '#ff000055' }
// Red background using RGB code.
popup('Title', 'Text', 'icon', 'image', { bgColor: 'rgb(255, 0, 0)' }
// Red opaque background using RGBA code.
popup('Title', 'Text', 'icon', 'image', { bgColor: 'rgba(255, 0, 0, 0.4)' }
// Red title and text using HEX code
popup('Title', 'Text', 'icon', 'image', { titleColor: '#ff0000', textColor: '#ff0000' }
// Red opaque title and text using HEX code with alpha
popup('Title', 'Text', 'icon', 'image', { titleColor: '#ff000055', textColor: '#ff000055' }
// Red title and text using RGB code.
popup('Title', 'Text', 'icon', 'image', { titleColor: 'rgb(255, 0, 0)', textColor: 'rgb(255, 255, 0)' }
// Red opaque title and text using RGBA code.
popup('Title', 'Text', 'icon', 'image', { titleColor: 'rgba(255, 0, 0, 0.4)', textColor: 'rgba(255, 255, 0, 0.4)' }
popup('Title', 'Text', 'icon', 'image', { borderRadius: '20px' }
popup('Title', 'Text', 'icon', 'image', { fontFamily: 'Times New Roman' }
popup('Title', 'Text', 'icon', 'image', { closeButton: false }
popup('Title', 'Text', 'icon', 'image', { noBackground: true }
popup('Title', 'Text', 'icon', 'image', { timer: 3 }
Of course you can use every option you want and mix them together.
Author: molloeduardo
GitHub: https://github.com/molloeduardo/creativa-popup
#javascript