-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.mask.js
executable file
·51 lines (43 loc) · 1.63 KB
/
jquery.mask.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* jquery.mask - overlay dom elements with a mask element
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
(function( $ ) {
$.fn.extend({
mask: function( options ) {
if ( this.length === 0 ) { return; }
var defaults = {
opacity : 0.8,
backgroundColour : "#ccc",
zIndex : 9999
},
opts = $.extend( {}, defaults, options );
return this.each(function() {
var height = $( this ).height(),
width = $( this ).width(),
offset = $( this ).offset(),
top = offset.top,
left = offset.left;
$( this ).append( "<div class='element-mask'></div>" );
$( this ).find( ".element-mask" ).css({
"position" : "absolute",
"opacity" : opts.opacity,
"height" : height,
"width" : width,
"top" : top,
"left" : left,
"background-color" : opts.backgroundColour,
"z-index" : opts.zIndex
});
});
},
unmask: function() {
if ( this.length === 0 ) { return; }
return this.each(function() {
$( this ).find( ".element-mask" ).remove();
});
}
});
}( jQuery ));