Modal plugin

jSuites brings a very lightweight responsive and mobile compatible modal to your applications.


1

Examples


Modal javascript webcomponent

This is an example how to create a modal based on the custom HTML javascript modal.
<html>
<script src="https://bossanova.uk/jsuites/v2/jsuites.js"></script>
<script src="https://bossanova.uk/jsuites/v2/jsuites.webcomponents.js"></script>
<link rel="stylesheet" href="https://bossanova.uk/jsuites/v2/jsuites.css" type="text/css" />

// Create modal with closed as default
<jsuites-modal title="Webcomponent Modal" closed="true" width="600" height="480">
This is an example how to create a
modal based on the custom HTML javascript modal.
</jsuites-modal>

<input type='button' value='Open the modal' onclick="document.querySelector('jsuites-modal').modal.open()" class='plain'>

</script>
document.querySelector('jsuites-modal').addEventListener('onopen', function() {
    console.log('Modal is open');
});
document.querySelector('jsuites-modal').addEventListener('onclose', function() {
    console.log('Modal is closed');
});
</script>
</html>

Simple modal plugin


<html>
<script src="https://bossanova.uk/jsuites/v2/jsuites.js"></script>
<link rel="stylesheet" href="https://bossanova.uk/jsuites/v2/jsuites.css" type="text/css" />

<div id='modal' title='Modal Example'>
    <div>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
    the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type
    and scrambled it to make a type specimen book. It has survived not only five centuries, but also the
    leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s
    with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with
    desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>
</div>

<input type='button' value='Click here to open the modal' onclick='modal.open()' class='plain'>

<script>
var modal = jSuites.modal(document.getElementById('modal'), {
    width:'600px',
    height:'480px',
    closed:true,
    onclose:function() {
        console.log('Modal is closed');
    },
    onopen:function() {
        console.log('Modal is opened');
    },
});
</script>
</html>

Simple modal with external content


<html>
<script src="https://bossanova.uk/jsuites/v2/jsuites.js"></script>
<link rel="stylesheet" href="https://bossanova.uk/jsuites/v2/jsuites.css" type="text/css" />

<div id='modal2' title='Remote content'></div>

<input type='button' value='Click here to open the modal' onclick='modal.open()' class='plain'>

<script>
var external = jSuites.modal(document.getElementById('modal2'), {
    src: '/jsuites/test.html',
    width: '600px',
    height: '480px',
    closed: true
});
</script>

</script>
</html>

Modal without title

Modal without title

<html>
<script src="https://bossanova.uk/jsuites/v2/jsuites.js"></script>
<link rel="stylesheet" href="https://bossanova.uk/jsuites/v2/jsuites.css" type="text/css" />

<div id='modal3'>
    <div style='padding:10px;'>Modal without title</div>
</div>

<input type='button' value='Click here to open the modal' onclick='modal.open()' class='plain'>

<script>
var notitle = jSuites.modal(document.getElementById('modal3'), {
    width: '600px',
    height: '480px',
    closed: true,
});
</script>

</script>
</html>


2

Methods

open();Open the modal
close();Close the modal


3

Events

onopenTrigger a method on the modal is opened.
oncloseTrigger a method on the modal is closed.


4

Initialization options

var defaults = {
    url: null,
    onopen: null,
    onclose: null,
    closed: false,
    width: null,
    height: null,
    title: null,
};