spoiler-alert-rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/lib/spoiler-alert-rails.rb +1 -0
- data/lib/spoiler-alert/rails.rb +7 -0
- data/lib/spoiler-alert/rails/engine.rb +6 -0
- data/lib/spoiler-alert/rails/version.rb +5 -0
- data/spoiler-alert-rails.gemspec +22 -0
- data/vendor/assets/javascripts/spoiler.js +101 -0
- data/vendor/assets/javascripts/spoiler.min.js +1 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 09c69778c610cbf9a3650302f8d78c89e5830a85
|
4
|
+
data.tar.gz: 091a3f5f40c00e3eac7e89ea6369eec0afb48c58
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 98deabb16f3cc92eea56853d663c710cdd12acccf44baadaf3865f4f73c04b827f72cc7ca4f725931d79aaa07e4c53432fb9382ad702d062cc2d4d575bb45f71
|
7
|
+
data.tar.gz: aaaa849c8e27a02df1f084afbd5b2072e747235456976a52297ef69efbd2c692613087fa23fc28150001bf12d0977a006cbd9ca7d94a60a6564ea4fe0fc71f45
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Andreas N.
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# spoiler-alert-rails
|
2
|
+
|
3
|
+
Nice SVG blur spoilers for your Rails asset pipeline!
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'spoiler-alert-rails'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install spoiler-alert-rails
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Read the documentation from the repository where this project is originating from, [here](https://github.com/joshbuddy/spoiler-alert).
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/retrospring/spoiler-alert-rails/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'spoiler-alert/rails'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'spoiler-alert/rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "spoiler-alert-rails"
|
8
|
+
spec.version = SpoilerAlert::Rails::VERSION
|
9
|
+
spec.authors = ["Andreas N."]
|
10
|
+
spec.email = ["andy@pixelde.su"]
|
11
|
+
spec.summary = %q{SVG blur spoilers for your Rails asset pipeline}
|
12
|
+
spec.homepage = "https://github.com/retrospring/spoiler-alert-rails"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
(function( $ ) {
|
2
|
+
var userAgent = navigator.userAgent.toLowerCase();
|
3
|
+
var browser = {}
|
4
|
+
browser.mozilla = /mozilla/.test(userAgent) && !/webkit/.test(userAgent);
|
5
|
+
browser.webkit = /webkit/.test(userAgent);
|
6
|
+
browser.opera = /opera/.test(userAgent);
|
7
|
+
browser.msie = /msie/.test(userAgent);
|
8
|
+
|
9
|
+
var defaults = {
|
10
|
+
max: 4,
|
11
|
+
partial: 2,
|
12
|
+
hintText: 'Click to reveal completely'
|
13
|
+
}
|
14
|
+
|
15
|
+
var alertShown = false
|
16
|
+
|
17
|
+
$.fn.spoilerAlert = function(opts) {
|
18
|
+
opts = $.extend(defaults, opts || {})
|
19
|
+
var maxBlur = opts.max
|
20
|
+
var partialBlur = opts.partial
|
21
|
+
var hintText = opts.hintText
|
22
|
+
if (!alertShown && browser.msie) {
|
23
|
+
alert("WARNING, this site contains spoilers!")
|
24
|
+
alertShown = true
|
25
|
+
}
|
26
|
+
return this.each(function() {
|
27
|
+
var $spoiler = $(this)
|
28
|
+
$spoiler.data('spoiler-alert-state', 'shrouded')
|
29
|
+
|
30
|
+
var animationTimer = null
|
31
|
+
var currentBlur = maxBlur
|
32
|
+
|
33
|
+
var cancelTimer = function() {
|
34
|
+
if (animationTimer) {
|
35
|
+
clearTimeout(animationTimer)
|
36
|
+
animationTimer = null
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
var applyBlur = function(radius) {
|
41
|
+
currentBlur = radius
|
42
|
+
if (browser.msie) {
|
43
|
+
var filterValue = "progid:DXImageTransform.Microsoft.Blur(pixelradius="+radius+")"
|
44
|
+
$spoiler.css('filter', filterValue)
|
45
|
+
} else if (browser.mozilla) {
|
46
|
+
var filterValue = radius > 0 ? "url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'>" +
|
47
|
+
"<filter id='blur'><feGaussianBlur stdDeviation='" + radius + "' /></filter></svg>#blur\")" : ''
|
48
|
+
$spoiler.css('filter', filterValue)
|
49
|
+
} else {
|
50
|
+
var filterValue = radius > 0 ? 'blur('+radius+'px)' : ''
|
51
|
+
$spoiler.css('filter', filterValue)
|
52
|
+
.css('-webkit-filter', filterValue)
|
53
|
+
.css('-moz-filter', filterValue)
|
54
|
+
.css('-o-filter', filterValue)
|
55
|
+
.css('-ms-filter', filterValue)
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
var performBlur = function(targetBlur, direction) {
|
60
|
+
cancelTimer()
|
61
|
+
if (currentBlur != targetBlur) {
|
62
|
+
applyBlur(currentBlur + direction)
|
63
|
+
animationTimer = setTimeout(function() { performBlur(targetBlur, direction) }, 10)
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
// Does the user have IE 9 or less?
|
68
|
+
var ieLessThanTen = function() {
|
69
|
+
// This conditional check will return true if browser supports CANVAS
|
70
|
+
// IE9 and under do not support CANVAS and this function is only ever
|
71
|
+
// called by the IE checking function anyway
|
72
|
+
return !document.createElement('canvas').getContext
|
73
|
+
}
|
74
|
+
|
75
|
+
applyBlur(currentBlur)
|
76
|
+
|
77
|
+
$spoiler.on('mouseover', function(e) {
|
78
|
+
$spoiler.css('cursor', 'pointer')
|
79
|
+
.attr('title', hintText)
|
80
|
+
if ($spoiler.data('spoiler-alert-state') == 'shrouded') performBlur(partialBlur, -1)
|
81
|
+
})
|
82
|
+
$spoiler.on('mouseout', function(e) {
|
83
|
+
if ($spoiler.data('spoiler-alert-state') == 'shrouded') performBlur(maxBlur, 1)
|
84
|
+
})
|
85
|
+
$spoiler.on('click', function(e) {
|
86
|
+
if ($spoiler.data('spoiler-alert-state') == 'shrouded') {
|
87
|
+
$spoiler.data('spoiler-alert-state', 'revealed')
|
88
|
+
.attr('title', '')
|
89
|
+
.css('cursor', 'auto')
|
90
|
+
performBlur(0, -1)
|
91
|
+
} else {
|
92
|
+
$spoiler.data('spoiler-alert-state', 'shrouded')
|
93
|
+
.attr('title', hintText)
|
94
|
+
.css('cursor', 'pointer')
|
95
|
+
performBlur(partialBlur, 1)
|
96
|
+
}
|
97
|
+
})
|
98
|
+
})
|
99
|
+
|
100
|
+
};
|
101
|
+
})( jQuery );
|
@@ -0,0 +1 @@
|
|
1
|
+
(function($){var browser={};browser.mozilla=/mozilla/.test(navigator.userAgent.toLowerCase())&&!/webkit/.test(navigator.userAgent.toLowerCase());browser.webkit=/webkit/.test(navigator.userAgent.toLowerCase());browser.opera=/opera/.test(navigator.userAgent.toLowerCase());browser.msie=/msie/.test(navigator.userAgent.toLowerCase());var defaults={max:4,partial:2,hintText:"Click to reveal completely"};var alertShown=false;$.fn.spoilerAlert=function(opts){opts=$.extend(defaults,opts||{});var maxBlur=opts.max;var partialBlur=opts.partial;var hintText=opts.hintText;if(!alertShown&&browser.msie){alert("WARNING, this site contains spoilers!");alertShown=true}return this.each(function(){var $spoiler=$(this);$spoiler.data("spoiler-alert-state","shrouded");var animationTimer=null;var currentBlur=maxBlur;var cancelTimer=function(){if(animationTimer){clearTimeout(animationTimer);animationTimer=null}};var applyBlur=function(radius){currentBlur=radius;if(browser.msie){}else if(browser.mozilla){var filterValue=radius>0?"url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><filter id='blur'><feGaussianBlur stdDeviation='"+radius+"' /></filter></svg>#blur\")":"";$spoiler.css("filter",filterValue)}else{var filterValue=radius>0?"blur("+radius+"px)":"";$spoiler.css("filter",filterValue);$spoiler.css("-webkit-filter",filterValue);$spoiler.css("-moz-filter",filterValue);$spoiler.css("-o-filter",filterValue);$spoiler.css("-ms-filter",filterValue)}};var performBlur=function(targetBlur,direction){cancelTimer();if(currentBlur!=targetBlur){applyBlur(currentBlur+direction);animationTimer=setTimeout(function(){performBlur(targetBlur,direction)},10)}};applyBlur(currentBlur);$(this).on("mouseover",function(e){$spoiler.css("cursor","pointer");$spoiler.attr("title",hintText);if($spoiler.data("spoiler-alert-state")=="shrouded")performBlur(partialBlur,-1)});$(this).on("mouseout",function(e){if($spoiler.data("spoiler-alert-state")=="shrouded")performBlur(maxBlur,1)});$(this).on("click",function(e){if($spoiler.data("spoiler-alert-state")=="shrouded"){$spoiler.data("spoiler-alert-state","revealed");$spoiler.attr("title","");$spoiler.css("cursor","auto");performBlur(0,-1)}else{$spoiler.data("spoiler-alert-state","shrouded");$spoiler.attr("title",hintText);$spoiler.css("cursor","pointer");performBlur(partialBlur,1)}})})}})(jQuery);
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spoiler-alert-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andreas N.
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- andy@pixelde.su
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/spoiler-alert-rails.rb
|
54
|
+
- lib/spoiler-alert/rails.rb
|
55
|
+
- lib/spoiler-alert/rails/engine.rb
|
56
|
+
- lib/spoiler-alert/rails/version.rb
|
57
|
+
- spoiler-alert-rails.gemspec
|
58
|
+
- vendor/assets/javascripts/spoiler.js
|
59
|
+
- vendor/assets/javascripts/spoiler.min.js
|
60
|
+
homepage: https://github.com/retrospring/spoiler-alert-rails
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.4.5
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: SVG blur spoilers for your Rails asset pipeline
|
84
|
+
test_files: []
|
85
|
+
has_rdoc:
|