A Simple yet extendable jQuery modal script built for use with inline HTML, images, videos, and galleries.

Overview

jQuery Chaos Modal

A Simple yet extendable jQuery modal script built for use with inline HTML, forms, and images in mind.

There are many other modal plugins out there. The goal of this project is to make one that is dead simple to use and implement, while still allowing for easy customization.

Example Usage

<html>
	<head>
		<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
		<script src="jquery-modal.js"></script>
	</head>
	<body>
		<h1>jQuery Chaos Modal Examples</h1>
		<h2>Image modals</h2>
		<a href="test_image.png" class="chaos-modal-link" title="caption"><img src="test_image.png" /></a>
		<div class="chaos-modal-link">
			<a href="test_image.png" title="caption"><img src="test_image.png" /></a>
		</div>
		<h2>Html Content Modals</h2>
		<div class="content-wrap">
			<a href="#" class="chaos-modal-link">Click Here to open the modal</a>
			<div class="chaos-modal-box">
				All HTML in here is used as the modal's content.
			</div>
		</div>
		<h2>Html Content ID Modals</h2>
		<div class="content-wrap">
			<a href="#" class="chaos-modal-link" data-chaos-modal-box-id="modal-content-id">Click Here to open the modal</a>
		</div>
		<div id="modal-content-id">
			All HTML in here is used as the modal's content.
		</div>
	</body>
</html>

Events Usage

<html>
	...
	<!-- Put data-preprocess='true' on link of modal you wish to pre-process -->
	<div class='chaos-modal-link' data-preprocess='true'>Link</div>
	...
</html>
var modal_links = $('.chaos-modal-link');

//Runs on modal link selector before modal is displayed
//Modal variable contains the modal associated with the modal link.
modal_links.on('chaos-modal-preprocess', function( event, modal){

	$(window).on('chaos-modal-preprocess-interrupt', function( event ){
		//Event fires when modal/loading screen is closed.
	});
	
	//If you do not want to pre-process every time, set data-preprocess to false
	//When done pre-processing
	$(this).attr('data-preprocess','false');
	
	//Preprocessing function MUST call openModal when preprocessing complete
	modal.openModal();
});

Options Usage

Attach data attributes to the modal's link as so;

<a class="chaos-modal-link" data-chaos-modal-max-width="710"> Link </a>

Supported options:

data-chaos-modal-max-width :

Sets the maximum width of the modal in pixels. Default 960.

data-chaos-modal-css-class :

Sets the css class attribute on the current modal div. Default false.

data-chaos-modal-close-link :

Sets whether or not to display the default close link. Default true.

data-chaos-modal-print-link :

Sets whether or not to display the print link. Default false.

data-chaos-modal-click-passthrough :

Sets whether or not to pass the value of the href attribute on the open modal link to a window.open call. This allows the model to be used for download prerolls. Default false.

data-chaos-modal-iframe-add-autoplay :

Sets whether or not to add 'autoplay=1' to the query string in the src and 'allow="autoplay"' of an iframe in the modals content if the modal contains a single iframe. This is useful for video modals especially youtube videos. Default true.

data-chaos-modal-caption :

Sets HTML content to use as a caption for the modal content. Default none, for image modals the value of the title attribute on the full image link.

Galleries

Modals can be linked into galleries with next/prev buttons for traversing the gallery by adding the data-chaos-modal-gallery attribute to container elements that contain modal links.

<div data-chaos-modal-gallery="gallery1">
	Modal links in here are part of gallery1.
</div>
<div data-chaos-modal-gallery="gallery2">
	Modal links in here are part of gallery2.
</div>
<div data-chaos-modal-gallery="gallery1">
	Modal links in here are also part of gallery1.
</div>

Features

  • Stand alone JS file. No additional CSS file required.
  • Window resize handling for better performance on responsive websites.
  • Vertical scroll position retention to maintain the user's position on the webpage.
  • On-the-fly modal HTML generation. No preprocessing loops before the page is shown to the user.
  • Content type handling:
    • Image tags
    • Links to images
    • Inline HTML
    • Inline HTML defined by element id
  • Iframe lazy loading for iframes in hidden modal content to improve page load.
  • Internet Explorer support back to version 11.
  • Microsoft Edge support.
  • Event support for pre-processing the modal content.
  • Options for changing default behavior.
You might also like...

Make use of your favicon with badges, images or videos

favico.js More info here. Author Miroslav Magda Version 0.3.9 Contributors: Serge Barysiuk, pissflaps, Yaroslav Yakovlev, LoicMahieu, Renan Gonçalves,

Dec 21, 2022

A lightweight, extendable front-end developer tool for mobile web page.

A lightweight, extendable front-end developer tool for mobile web page.

English | 简体中文 vConsole A lightweight, extendable front-end developer tool for mobile web page. vConsole is framework-free, you can use it in Vue or R

Jan 2, 2023

Simple yet powerful to-do list app to manage your daily tasks! Built with: CSS, HTML, JavaScript

Simple yet powerful to-do list app to manage your daily tasks! Built with: CSS, HTML, JavaScript

To-Do List Simple yet powerful to-do app to manage your daily tasks! Built With HTML, CSS Fameworks: N/A Technologies: Linters, Git, GitHub, Webpack L

Jul 21, 2022

Simple to use and manage modal.

vue-modal-provider nice-modal-react vue implementation. Simple to use and manage modal. benefit: Create modal without losing context No need to mainta

Nov 10, 2022

A simple way of loading inline es-modules on modern browser.

ES inline module A simple way of loading inline es-modules on modern browser. Usage Use inlineImport to dynamically import inline scripts. script typ

Dec 22, 2022

Asciifly is a webapp where you can asciify images and youtube videos on the fly.

Asciifly is a webapp where you can asciify images and youtube videos on the fly.

Asciifly Asciifly is a webapp where you can asciify images and youtube videos on the fly. Come visit at https://asciifly.com Hosting I'm hosting this

May 23, 2022

A full screen slide show for images and videos

A full screen slide show for images and videos

Vanilla JS Slide full screen slide show for videos and images Why? This is a scratch-your-own-itch project as I wanted a way to see images and videos

Oct 26, 2022

Easiest 1-click way to install and use Stable Diffusion on your own computer. Provides a browser UI for generating images from text prompts and images. Just enter your text prompt, and see the generated image.

Easiest 1-click way to install and use Stable Diffusion on your own computer. Provides a browser UI for generating images from text prompts and images. Just enter your text prompt, and see the generated image.

Stable Diffusion UI Easiest way to install and use Stable Diffusion on your own computer. No dependencies or technical knowledge required. 1-click ins

Dec 30, 2022

Fancytree - JavaScript tree view / tree grid plugin with support for keyboard, inline editing, filtering, checkboxes, drag'n'drop, and lazy loading

Fancytree - JavaScript tree view / tree grid plugin with support for keyboard, inline editing, filtering, checkboxes, drag'n'drop, and lazy loading

Fancytree Fancytree (sequel of DynaTree 1.x) is a JavaScript tree view / tree grid plugin with support for keyboard, inline editing, filtering, checkb

Jan 9, 2023
Releases(1.14.0)
Owner
Matthew Sigley
Matthew Sigley
jQuery plugin for horizontally scrolling galleries

jQuery Horiztonal Scroll Gallery This jQuery plugin slides through a horiztonal gallery of items as you scroll down. It makes use of position:sticky s

Jeremy Rue 3 Feb 23, 2022
Lightweight vanilla js modal component (just 2kb) , pure javascript Modal

Lightweight vanilla js modal component (just 2kb) pure javascript Modal , This is just 2kb Lightweight vanilla js modal component with zero dependenci

Salah Eddine Lalami 12 Dec 12, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
A tiny, plugin extendable JavaScript utility library with a JQuery-like syntax.

Tiny Friggin' Utility Zapper What is it? A tiny ~7kb extendable JavaScript utility library with a JQuery like syntax for getting work done fast! If yo

Bret 4 Jun 25, 2022
zieeco 12 Jul 8, 2022
App that allows you to control and watch YouTube videos using hand gestures. Additionally, app that allows you to search for videos, playlists, and channels.

YouTube Alternative Interaction App An app I made with Edward Wu that allows you to search and watch videos from YouTube. Leverages Google's YouTube D

Aaron Lam 2 Dec 28, 2021