Non Bootstrap tiles and modal
Change class name on click in jQuery
by Shawn Wood
HTML
<div id="banner-message">
<p>Launch Modal</p>
<button class="tool-btn" data-toggle="tool-modal">launch Modal</button>
</div>
CSS
body {
font-family: Arial, Helvetica, sans-serif;
}
.tool-btn {
text-shadow: 0 -1px 0 rgba(0, 0, 0, .2);
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 1px rgba(0, 0, 0, .075);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 1px rgba(0, 0, 0, .075);
text-shadow: 0 1px 0 #fff;
background-image: -webkit-linear-gradient(top, #fff 0%, #e0e0e0 100%);
background-image: -o-linear-gradient(top, #fff 0%, #e0e0e0 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#e0e0e0));
background-image: linear-gradient(to bottom, #fff 0%, #e0e0e0 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe0e0e0', GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
background-repeat: repeat-x;
border-color: #dbdbdb;
border-color: #ccc;
display: inline-block;
font-weight: 400;
color: #212529;
text-align: center;
vertical-align: middle;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-color: transparent;
border: 1px solid transparent;
padding: 0.375rem 0.75rem;
font-size: 1rem;
line-height: 1.5;
border-radius: 0.25rem;
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.tool-btn:active {
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
background-image: none;
background-color: #e0e0e0;
border-color: #dbdbdb;
}
.tool-btn:hover,
.tool-btn:focus {
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
background-image: none;
background-color: #e0e0e0;
background-position: 0 -15px;
}
.tool-btn:hover {
color: #212529;
text-decoration: none;
}
.tool-btn:focus {
outline: 0;
box-shadow: 0 0 0 0.2rem...
JavaScript
var buildToolModal = function(modalID) {
if (typeof modalID === 'undefined' || modalID === null) {
modalID = 'toolModal';
}
function writeToolModal() {
var d = $.Deferred(); // set the promise
let thisToolModal = '<!-- Tool Modal -->' +
'<div id="' + modalID + '" class="tool-modal">' +
'<!-- Modal content -->' +
'<div class="tool-modal-content">' +
'<div class="tool-modal-header">' +
'<span class="tool-close" data-dismiss="tool-modal">×</span>' +
'<h3 id="toolModalTitle" class="tool-modal-title">Modal Header</h3>' +
'</div>' +
'<div id="toolModalBody" class="tool-modal-body">' +
'Load content here.' +
'</div>' +
'<div id="toolModalFooter" class="tool-modal-footer">' +
'<button type="button" class="tool-btn" data-dismiss="tool-modal">Close</button>' +
'</div>' +
'</div>' +
'</div>';
// Append body to modal
$('body').append(thisToolModal);
d.resolve(); //Resolve the promise
return d.promise(); //Return the promise
}
function BuildFormEvents() {
var d = $.Deferred(); // set the promise
$('[data-toggle="tool-modal"]').on('click', function(event) {
$('#' + modalID).css('display', 'block');
console.log('clicked open')
});
$('[data-dismiss="tool-modal"]').on('click', function(event) {
console.log('clicked');
$('#' + modalID).css('display', 'none');
});
d.resolve(); //Resolve the promise
return d.promise(); //Return the promise
}
writeToolModal().then(BuildFormEvents);
}
$(document).ready(function() {
buildToolModal();
});