Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ben Centra
committed
Jul 17, 2016
1 parent
715eeae
commit 3b7e7b4
Showing
5 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*.js] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.DS_Store | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Blur Overlay Demo</title> | ||
<style> | ||
* { | ||
box-sizing: border-box; | ||
} | ||
html, body { | ||
padding: 0; | ||
margin: 0; | ||
} | ||
#content { | ||
padding: 0; | ||
margin: 0; | ||
font-family: sans-serif; | ||
width: 100%; | ||
height: 100%; | ||
text-align: center; | ||
background-image: url("https://bencentra.com/centrarium/assets/header_image.jpg"); | ||
color: white; | ||
text-shadow: 1px 1px #666; | ||
} | ||
img { | ||
box-shadow: 3px 3px 6px #333; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="content"> | ||
<h1>Just some demo content</h1> | ||
<p><button id="showOverlayButton">Show Overlay</button></p> | ||
<img src="https://bencentra.com/assets/images/bookshelf.jpg" width="400" height="300"> | ||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> | ||
<img src="https://bencentra.com/assets/images/bookshelf.jpg" width="400" height="300"> | ||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> | ||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> | ||
<img src="https://bencentra.com/assets/images/bookshelf.jpg" width="400" height="300"> | ||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> | ||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> | ||
</div> | ||
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> | ||
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js"></script> | ||
<script src="index.js"></script> | ||
<script> | ||
$(document).on('ready', function() { | ||
var $content = $('#content').blurOverlay(); | ||
$('#showOverlayButton').on('click', function() { | ||
var $overlay = $('<div>').attr('id', 'overlay'); | ||
$overlay.append($('<h1>').text('This is the overlay!')); | ||
$overlay.append($('<p>').text('The background is so blurry, it\'s great!')); | ||
var $hideButton= $('<button>').attr('id', 'hideOverlayButton').text('Hide Overlay'); | ||
$overlay.append($hideButton); | ||
$content.blurOverlay('content', $overlay); | ||
$content.blurOverlay('show'); | ||
$hideButton.on('click', function() { | ||
$content.blurOverlay('hide'); | ||
}); | ||
}); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
$(function() { | ||
|
||
$.widget('custom.blurOverlay', { | ||
|
||
// Defaults | ||
options: { | ||
prefix: 'blur-overlay', // Prefix for wrapper selectors | ||
content: '<h1>Hello, blur overlay!</h1>', // Default content to display | ||
blurAmount: '12px' // Amount of pixels to blur by | ||
}, | ||
|
||
_create: function() { | ||
// Initialize elements | ||
this.$wrapper = $('<div>').attr('id', this.options.prefix + '-wrapper'); | ||
this.$wrapper.css({ | ||
'position': 'absolute', | ||
'top': 0, | ||
'bottom': 0, | ||
'left': 0, | ||
'right': 0, | ||
'-webkit-filter': 'blur(' + this.options.blurAmount + ')', | ||
'filter': 'blur(' + this.options.blurAmount + ')' | ||
}); | ||
this.$overlay = $('<div>').attr('id', this.options.prefix + '-overlay'); | ||
this.$overlay.css({ | ||
'position': 'absolute', | ||
'top': 0, | ||
'bottom': 0, | ||
'left': 0, | ||
'right': 0, | ||
'z-index': 1000 | ||
}); | ||
this.$content = $('<div>').attr('id', this.options.prefix + '-content'); | ||
this.$overlay.append(this.$content); | ||
}, | ||
|
||
show: function() { | ||
// Wrap the target element | ||
$('body').css('overflow', 'hidden'); | ||
this.element.wrapAll(this.$wrapper); | ||
// Create the overlay | ||
this.$content.html(this.options.content); | ||
$('body').prepend(this.$overlay); | ||
}, | ||
|
||
hide: function() { | ||
$('body').css('overflow', 'auto'); | ||
this.element.unwrap(); | ||
this.$overlay.remove(); | ||
}, | ||
|
||
content: function(stringOrElement) { | ||
this.options.content = stringOrElement; | ||
} | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "blur-overlay", | ||
"version": "1.0.0", | ||
"description": "A jQuery plugin for displaying an overlay on a webpage that blurs the content behind it ", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/bencentra/blur-overlay.git" | ||
}, | ||
"keywords": [ | ||
"jquery", | ||
"blur", | ||
"overlay" | ||
], | ||
"author": "Ben Centra <blcentra@gmail.com>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/bencentra/blur-overlay/issues" | ||
}, | ||
"homepage": "https://github.com/bencentra/blur-overlay#readme", | ||
"devDependencies": { | ||
"http-server": "^0.9.0" | ||
}, | ||
"scripts": { | ||
"demo": "hs -p 8000 ." | ||
} | ||
} |