JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<a href="#" class="button js-open-overlay">Open the overlay</a>
html, body {
width: 100%;
height: 100%;
}
body {
display: flex;
justify-content: center;
align-items: center;
background: #ccc;
}
.button {
display: inline-block;
background: #333;
color: #fff;
text-decoration: none;
padding: 10px;
border-radius: 3px;
border-bottom: 3px solid #111;
transform: all ease .3s;
&:hover {
background: lighten(#333, 10%);
}
&:active {
border-bottom: 0px;
transform: translate3d(0, 3px, 0);
}
}
.c-overlay {
position: absolute;
display: none;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #fff;
}
'use strict';
/**
* Overlay
*
* Controls creating, showing, hiding and removing of overlays
*/
var Overlay = (function() {
var $body = $('body');
function Overlay() {
this.assignClass = 'c-overlay';
this.el = false;
this.animate = {
duration: 0.3,
visible: {
display: 'block',
autoAlpha: 0.7,
ease: Power3.easeInOut
},
hidden: {
display: 'none',
autoAlpha: 0,
ease: Power3.easeInOut
}
};
}
/**
* Check if the overlay has already been created
*/
Overlay.prototype.isCreated = function() {
return this.el === false || typeof this.el === 'undefined' ? false: true;
};
/**
* Create the overlay
*/
Overlay.prototype.create = function() {
var self = this;
this.el = $('<div/>', {
'class': this.assignClass
}).appendTo($body);
$(this.el).on('click', function() {
self.hide();
});
};
/**
* Show the overlay
*/
Overlay.prototype.show = function() {
$body.addClass('prevent-overflow');
TweenLite.fromTo(this.el, this.animate.duration, this.animate.hidden, this.animate.visible);
};
/**
* Hide the overlay
*/
Overlay.prototype.hide = function() {
$body.removeClass('prevent-overflow');
TweenLite.fromTo(this.el, this.animate.duration, this.animate.visible, this.animate.hidden);
};
/**
* Remove the overlay
*/
Overlay.prototype.destroy = function() {
$body.removeClass('prevent-overflow');
$(this.el).remove();
this.el = false;
};
return Overlay;
})();
var overlay = new Overlay(),
$openOverlay = $('.js-open-overlay');
overlay.create();
$openOverlay.on('click', function() {
overlay.show();
});
Also see: Tab Triggers