jquery-foggy-rails 0.0.1 → 1.1.1.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f348ac738596a5aa13312c73605f5937c01bfb71
|
4
|
+
data.tar.gz: e8c5e3b988b109a87cf47c3af374d6e5b4d7f2a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84f7353d8c1b97d41c26831aab1386ca69b2d08798423e12edcaa0a6328c8669fb07c464ae3a2c60ec3cbad24d547e3045d53660540a25fa89d4ceec489475f4
|
7
|
+
data.tar.gz: ae2b551ed7c4b517725535005735bd06ed651578467385302c633a08fe082919def840fe7c77561fc984ae57809b41dd7f39b54d0bde9226360b6b58b453e44f
|
@@ -0,0 +1,149 @@
|
|
1
|
+
// Foggy, v1.1.1
|
2
|
+
//
|
3
|
+
// Description: jQuery plugin for blurring page elements
|
4
|
+
// Homepage: http://nbartlomiej.github.com/foggy
|
5
|
+
// Author: nbartlomiej@gmail.com
|
6
|
+
|
7
|
+
(function( $ ){
|
8
|
+
|
9
|
+
$.fn.foggy = function( options ) {
|
10
|
+
var defaultOptions = {
|
11
|
+
opacity: 0.8,
|
12
|
+
blurRadius: 2,
|
13
|
+
quality: 16,
|
14
|
+
cssFilterSupport: true
|
15
|
+
};
|
16
|
+
|
17
|
+
var noBlurOptions = {
|
18
|
+
opacity: 1,
|
19
|
+
blurRadius: 0
|
20
|
+
};
|
21
|
+
|
22
|
+
var settings;
|
23
|
+
if (options == false) {
|
24
|
+
settings = $.extend( defaultOptions, noBlurOptions );
|
25
|
+
} else {
|
26
|
+
settings = $.extend( defaultOptions, options);
|
27
|
+
}
|
28
|
+
|
29
|
+
|
30
|
+
var BlurPass = function(content, position, offset, opacity){
|
31
|
+
this.content = content;
|
32
|
+
this.position = position;
|
33
|
+
this.offset = offset;
|
34
|
+
this.opacity = opacity;
|
35
|
+
};
|
36
|
+
|
37
|
+
BlurPass.prototype.render = function(target){
|
38
|
+
$('<div/>', {
|
39
|
+
html: this.content, 'class': 'foggy-pass-'+this.position
|
40
|
+
}).css({
|
41
|
+
position: this.position,
|
42
|
+
opacity: this.opacity,
|
43
|
+
top: this.offset[0],
|
44
|
+
left: this.offset[1]
|
45
|
+
}).appendTo(target);
|
46
|
+
};
|
47
|
+
|
48
|
+
var Circle = function(radius){
|
49
|
+
this.radius = radius;
|
50
|
+
};
|
51
|
+
|
52
|
+
Circle.prototype.includes = function(x,y){
|
53
|
+
if (Math.pow(x,2) + Math.pow(y,2) <= Math.pow(this.radius, 2)){
|
54
|
+
return true;
|
55
|
+
} else {
|
56
|
+
return false;
|
57
|
+
}
|
58
|
+
};
|
59
|
+
|
60
|
+
Circle.prototype.points = function(){
|
61
|
+
var results = [];
|
62
|
+
for (var x = -this.radius; x<=this.radius; x++){
|
63
|
+
for (var y = -this.radius; y<=this.radius; y++){
|
64
|
+
if (this.includes(x,y)){
|
65
|
+
results.push([x,y]);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
69
|
+
return results;
|
70
|
+
};
|
71
|
+
|
72
|
+
var ManualFog = function(element, settings){
|
73
|
+
this.element = element;
|
74
|
+
this.settings = settings;
|
75
|
+
};
|
76
|
+
|
77
|
+
ManualFog.prototype.calculateOffsets = function(radius, quality){
|
78
|
+
var all_offsets = $.grep(
|
79
|
+
new Circle(radius).points(),
|
80
|
+
function(element){ return (element[0] != 0) || (element[1] != 0) }
|
81
|
+
);
|
82
|
+
var offsets;
|
83
|
+
if (all_offsets.length <= quality){
|
84
|
+
offsets = all_offsets;
|
85
|
+
} else {
|
86
|
+
var overhead = all_offsets.length - quality;
|
87
|
+
var targets = [];
|
88
|
+
for (var i = 0; i < overhead; i++){
|
89
|
+
targets.push(Math.round(i * (all_offsets.length / overhead)));
|
90
|
+
}
|
91
|
+
offsets = $.grep( all_offsets, function(element, index){
|
92
|
+
if ($.inArray(index, targets) >= 0){
|
93
|
+
return false;
|
94
|
+
} else {
|
95
|
+
return true;
|
96
|
+
}
|
97
|
+
});
|
98
|
+
}
|
99
|
+
return offsets;
|
100
|
+
};
|
101
|
+
|
102
|
+
ManualFog.prototype.getContent = function(){
|
103
|
+
var candidate = $(this.element).find('.foggy-pass-relative')[0];
|
104
|
+
if (candidate){
|
105
|
+
return $(candidate).html();
|
106
|
+
} else {
|
107
|
+
return $(this.element).html();
|
108
|
+
}
|
109
|
+
};
|
110
|
+
|
111
|
+
ManualFog.prototype.render = function(){
|
112
|
+
var content = this.getContent();
|
113
|
+
$(this.element).empty();
|
114
|
+
var wrapper = $('<div/>').css({ position: 'relative' });
|
115
|
+
var offsets = this.calculateOffsets(
|
116
|
+
this.settings.blurRadius*2, this.settings.quality
|
117
|
+
);
|
118
|
+
var opacity = (this.settings.opacity * 1.2) / (offsets.length + 1);
|
119
|
+
new BlurPass(content, 'relative', [0,0], opacity).render(wrapper);
|
120
|
+
$(offsets).each(function(index, offset){
|
121
|
+
new BlurPass(content, 'absolute', offset, opacity).render(wrapper);
|
122
|
+
});
|
123
|
+
wrapper.appendTo(this.element);
|
124
|
+
};
|
125
|
+
|
126
|
+
var FilterFog = function(element, settings){
|
127
|
+
this.element = element;
|
128
|
+
this.settings = settings;
|
129
|
+
}
|
130
|
+
|
131
|
+
FilterFog.prototype.render = function(){
|
132
|
+
var opacityPercent = (''+settings.opacity).slice(2,4);
|
133
|
+
var filterBlurRadius = this.settings.blurRadius;
|
134
|
+
$(this.element).css({
|
135
|
+
'-webkit-filter': 'blur('+filterBlurRadius+'px)',
|
136
|
+
opacity: settings.opacity
|
137
|
+
});
|
138
|
+
}
|
139
|
+
|
140
|
+
return this.each(function(index, element) {
|
141
|
+
if (settings.cssFilterSupport && '-webkit-filter' in document.body.style){
|
142
|
+
new FilterFog(element, settings).render();
|
143
|
+
} else {
|
144
|
+
new ManualFog(element, settings).render();
|
145
|
+
}
|
146
|
+
});
|
147
|
+
};
|
148
|
+
|
149
|
+
})( jQuery );
|
@@ -0,0 +1,7 @@
|
|
1
|
+
// Foggy, v1.1.1
|
2
|
+
//
|
3
|
+
// Description: jQuery plugin for blurring page elements
|
4
|
+
// Homepage: http://nbartlomiej.github.com/foggy
|
5
|
+
// Author: nbartlomiej@gmail.com
|
6
|
+
|
7
|
+
(function(e){e.fn.foggy=function(t){var n={opacity:.8,blurRadius:2,quality:16,cssFilterSupport:true};var r={opacity:1,blurRadius:0};var i;if(t==false){i=e.extend(n,r)}else{i=e.extend(n,t)}var s=function(e,t,n,r){this.content=e;this.position=t;this.offset=n;this.opacity=r};s.prototype.render=function(t){e("<div/>",{html:this.content,"class":"foggy-pass-"+this.position}).css({position:this.position,opacity:this.opacity,top:this.offset[0],left:this.offset[1]}).appendTo(t)};var o=function(e){this.radius=e};o.prototype.includes=function(e,t){if(Math.pow(e,2)+Math.pow(t,2)<=Math.pow(this.radius,2)){return true}else{return false}};o.prototype.points=function(){var e=[];for(var t=-this.radius;t<=this.radius;t++){for(var n=-this.radius;n<=this.radius;n++){if(this.includes(t,n)){e.push([t,n])}}}return e};var u=function(e,t){this.element=e;this.settings=t};u.prototype.calculateOffsets=function(t,n){var r=e.grep((new o(t)).points(),function(e){return e[0]!=0||e[1]!=0});var i;if(r.length<=n){i=r}else{var s=r.length-n;var u=[];for(var a=0;a<s;a++){u.push(Math.round(a*(r.length/s)))}i=e.grep(r,function(t,n){if(e.inArray(n,u)>=0){return false}else{return true}})}return i};u.prototype.getContent=function(){var t=e(this.element).find(".foggy-pass-relative")[0];if(t){return e(t).html()}else{return e(this.element).html()}};u.prototype.render=function(){var t=this.getContent();e(this.element).empty();var n=e("<div/>").css({position:"relative"});var r=this.calculateOffsets(this.settings.blurRadius*2,this.settings.quality);var i=this.settings.opacity*1.2/(r.length+1);(new s(t,"relative",[0,0],i)).render(n);e(r).each(function(e,r){(new s(t,"absolute",r,i)).render(n)});n.appendTo(this.element)};var a=function(e,t){this.element=e;this.settings=t};a.prototype.render=function(){var t=(""+i.opacity).slice(2,4);var n=this.settings.blurRadius;e(this.element).css({"-webkit-filter":"blur("+n+"px)",opacity:i.opacity})};return this.each(function(e,t){if(i.cssFilterSupport&&"-webkit-filter"in document.body.style){(new a(t,i)).render()}else{(new u(t,i)).render()}})}})(jQuery)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery-foggy-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo do Valle
|
@@ -50,6 +50,8 @@ files:
|
|
50
50
|
- LICENSE.txt
|
51
51
|
- README.md
|
52
52
|
- Rakefile
|
53
|
+
- app/assets/javascripts/jquery.foggy.js
|
54
|
+
- app/assets/javascripts/jquery.foggy.min.js
|
53
55
|
- jquery-foggy-rails.gemspec
|
54
56
|
- lib/jquery/foggy/rails.rb
|
55
57
|
- lib/jquery/foggy/rails/version.rb
|