Skip to content

Instantly share code, notes, and snippets.

@danielrw7
Last active April 28, 2017 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielrw7/83f4e762c0bd0c8cb97b2d87cfbd48c9 to your computer and use it in GitHub Desktop.
Save danielrw7/83f4e762c0bd0c8cb97b2d87cfbd48c9 to your computer and use it in GitHub Desktop.
var overlay = {
el: false,
class: 'overlay',
show: function(clickCallback) {
this.el.show()
if (clickCallback && typeof clickCallback == "function") {
this.el.off('click').click(clickCallback)
}
},
hide: function() {
this.el.hide()
},
init: function() {
if (!this.el || !this.el.length) {
this.el = $('.'+this.class)
}
if (!this.el || !this.el.length) {
this.el = $('<div>', {
class: this.class
})
}
$('body').append(this.el)
},
}
overlay.show = overlay.show.bind(overlay)
overlay.hide = overlay.hide.bind(overlay)
overlay.init = overlay.init.bind(overlay)
.overlay {
display: none;
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
background-color: rgba(0,0,0,0.3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment