• Stars
    star
    168
  • Rank 225,507 (Top 5 %)
  • Language
    JavaScript
  • Created over 10 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create modal windows that can be morphed from anything

#Adaptive Modal by Pete R. Adaptive modal will let you create a modal window that can be morphed from any elements on your website into a beautifully animate modal windows.

Created by Pete R., Founder of Travelistly and BucketListly

License: Attribution-ShareAlike 4.0 International

Demo

View demo

Compatibility

Modern browsers such as Chrome, Firefox, and Safari on both desktop and mobile have been tested. Not tested on IE.

Basic Usage

To use this plugin, simply include the latest jQuery library (preferably version 2.0.0 or higher) together with jquery.adaptive-modal.js and adaptive-modal.css into your document's <head> follow by an HTML markup as follows:

<body>
  ..
  <a href="#" data-toggle="adaptive-modal" data-title="...">...</a>
  ..
</body>

Surprise, surprise, that's all you have to do. Follow the HTML markup shown above without calling any JS function and the modal will morphed from this link when trigger. The content inside data-title will be used on the modal window. The data-title also supports HTML tags.

Show Existing Content

Instead of storing your content inside data-title, you can have them separately in another div container and reference the id of that container in the href attribute like this:

<body>
  ..
  <a href="#form" data-toggle="adaptive-modal">...</a>
  <form id="form">
    ..
  </form>
  ..
</body>

Show Remote Content

You can utilize the built-in ajax request by simply define the AJAX URL inside href attribute and add data-remote="true" to the markup:

<body>
  ..
  <a href="http://www.remote-ajax-url.com" data-type=".." data-datatype=".." data-remote="true" data-toggle="adaptive-modal">...</a>
  ..
</body>

You can also define your own ajax type and datatype with data-type and data-datatype attributes respectively.

Custom Class Names On Each Modal

You can define your own class name in case you want to customize the modal for each link by following the markup below:

<body>
  ..
  <a href="#" data-toggle="adaptive-modal" data-title="..." data-am-custom-class="custom-class-name">...</a>
  ..
</body>

Custom BG Color On Show

You can define your own background color instead of using the link background color by default by simply adding the data-am-custom-bgcolor attribute to your markup:

<body>
  ..
  <a href="#" data-toggle="adaptive-modal" data-title="..." data-am-custom-bgcolor="#000">...</a>
  ..
</body>

Via Javascript

You can initiate the function with javascript instead of an HTML markup in case you want to define global options you want to apply to all links.

 $(".am-remote-link").adaptiveModal({
   elementAnimateTime: 100,                   // Define the animation time for each element to animate when the modal is openned/closed. The option accepts milliseconds. The default value is 100.
   customBgColor: "#333",                     // In case the link have no background color to derive from you can set the background color of the modal here. The option accepts HEX, RGB, and RGBA The default value is "#333333".
   remoteUrl: false,                          //  You can define the remote URL here as well as the markup. The option accepts generic URL. The default value is false.
   elementAnimateIn: "scaleShow",             // Require Animate.css extension: You can define the element inside the modal its own entrance animation by putting the Animate.css class name here. The default value is the built-in scaleShow animation.
   elementAnimateOut: "scaleHide",            // Require Animate.css extension: You can define the element inside the modal its own exit animation by putting the Animate.css class name here. The default value is the built-in scaleHide animation.
   beforeAnimate: function(el, status) {},    // Callback function execute before the animation begins. Parameters available are el, and status which returns the jQuery object and the status of the animation, ie "open" will return when the animation is opening the modal, and vice versa, respectively. 
   afterAnimate: function(el, status) {},     // Callback function execute after the animation stops. Parameters available are el, and status which returns the jQuery object and the status of the animation, ie "close" will return when the animation is closing the modal, and vice versa, respectively. 
   
   // Deafult Ajax Parameters. See here for more info: http://api.jquery.com/jquery.ajax/
   type: "GET",
   async: true,
   complete: function(xhr, text) {},
   cache: true,
   error: function(xhr, text, e) {},
   global: true,
   headers: {},
   statusCode: {},
   success: function(data, text, xhr) {},
   dataType: "html"
 });

Callbacks

Here are callbacks available for you to play around with:

beforeAnimate: function(el, status)

This callback function will be called right before the animation starts. Parameters returned are el which returns the jQuery object and status which returns the status of the animation, ie "open" will be returned when the animation is opening the modal, and "close" will be returned when the animation is closing the modal

  $(".am-remote-link").adaptiveModal({
    beforeAnimate: function(el, status) {
      ...
    }
  });

afterAnimation: function(el,status)

This callback function will be called right after the animation stops. Parameters returned are el which returns the jQuery object and status which returns the status of the animation, ie "open" will be returned when the animation is opening the modal, and "close" will be returned when the animation is closing the modal

  $(".am-remote-link").adaptiveModal({
    afterAnimate: function(el, status) {
      ...
    }
  });

Public Methods

You can call these methods to programmatically interact with the plugin:

$.fn.openModal()

You can open the modal prgrapmatically by calling this function as shown below:

  $(".am-remote-link").openModal()

$.fn.closeModal()

You can close the modal programmatically by calling this function as shown below:

  $(".am-remote-link").closeModal()

If you want to see more of my plugins, visit The Pete Design, or follow me on Twitter and Github.

Other Resources

  • Tutorial (Coming Soon)

More Repositories

1

onepage-scroll

Create an Apple-like one page scroller website (iPhone 5S website) with One Page Scroll plugin
JavaScript
9,544
star
2

purejs-onepage-scroll

The javascript version of the infamous jQuery One Page Scroll without relying on jQuery.
JavaScript
770
star
3

simple-text-rotator

Add a super simple rotating text to your website with little to no markup
HTML
748
star
4

loading-bar

Add a Youtube-like loading bar to all your ajax links
HTML
661
star
5

label_better

Label your form input like a boss with beautiful animation and without taking up space
JavaScript
517
star
6

flat-shadow

A small jQuery plugin that will automatically cast a shadow creating depth for your flat UI elements
HTML
483
star
7

panorama_viewer

Embed panorama photos on your website with Panorama Viewer
JavaScript
473
star
8

wheel-menu

Add a fully customisable Path-like wheel menu button to your website
HTML
403
star
9

interactive_3d

Create a 3D interactive object using images and one simple JS call
JavaScript
378
star
10

notify-better

An all in one jQuery plugin that let you change your favicon, browser's title and more to reflect new notifications
JavaScript
373
star
11

tiltedpage_scroll

Create a beautiful 3D tilted effect on scroll with jQuery Tilted Page Scroll plugin
JavaScript
323
star
12

autofix_anything

Fix position of anything on your website automatically with one js call
JavaScript
314
star
13

interactive_bg

Create an interactive moving background/object that reacts to viewer's cursor
JavaScript
232
star
14

shuffle-images

The Simplest Way to shuffle through images in a Creative Way
JavaScript
212
star
15

tip_cards

Create a card layout that let your user flip through it like you see on Google Tips
JavaScript
211
star
16

zepto-onepage-scroll

Zepto One Page Scroll is the javascript version of the infamous jQuery One Page Scroll.
JavaScript
186
star
17

fancy-scroll

Add Overflow Scroll Effect like on iOS/Android but for your website
HTML
157
star
18

immersive-slider

Create an immersive slider that changes the whole container to match the viewing slide
JavaScript
138
star
19

square_menu

Create a Square-like Menu Animation for Website using jQuery and CSS3
CSS
124
star
20

fly_sidemenu

Recreate an Airbnb iOS7 App Menu Animation using CSS3 and jQuery
CSS
113
star
21

flipout_cards

Create a Dynamic Multi Level Flip Out Cards
CSS
110
star
22

fullpage-menu

Create a Full Page, Fully CSS3 Animated Menu for your Navigation with Full Page Menu
CSS
106
star
23

jumpto

A plugin that let you create a smooth jump to sub navigational menu in one JS call
JavaScript
105
star
24

zoom-scroller

Create a Subtle Zoom Animation on Images while Scrolling
JavaScript
99
star
25

let_it_snow

Create and Control a Festive Snow on Your Website using HTML5 Canvas
JavaScript
92
star
26

endpage-box

A plugin that let you add an end page box that will display when scrolled to the bottom.
HTML
86
star
27

flipping_gallery

Create a simple but beautiful 3D flipping gallery with on JS call
JavaScript
79
star
28

subscribe-better

Create a better, highly customizable subscription modal or newsletter signup window with jQuery Subscribe Better
CSS
74
star
29

planetarium

Construct an Interactive Planet and Build the Universe on your website
JavaScript
58
star
30

flipping_text

Create a ticking text intro animation for your typography.
JavaScript
55
star
31

fullpagenav

Create a fully responsive and dynamic full page navigation with one JS call
JavaScript
35
star
32

parallax-scroller

Scroll through lists with a smooth parallax effect
JavaScript
27
star
33

flatline_icon_free

180+ high quality & minimal icons webfont for Bootstrap Framework
26
star
34

endpage_next

Navigate without moving your mouse. Pull to refresh/Hold to go next functionality on the web,
JavaScript
12
star