adaptive-evil-blocks-rails 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cc1d58386aab008c545c2e9048551b8ecffff316
4
+ data.tar.gz: ed60ff8e523a878bbbab3d6751cf391fcf5f4bbb
5
+ SHA512:
6
+ metadata.gz: 07eab5a85749d8f8a02cb67731048079f76c15e0a6be66107ade42f945861ba5f58f2529a8c96af284c50f60c201cebbef747dac8ee56601953a02a9b0583a45
7
+ data.tar.gz: ced7ac0ddf59d30d25b6b2c96137c8502c9420265212b47303739f950ca5c76385a7474024cb552247afba81592de8d3bceedfc311538d22b433482a135fb7d9
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright 2014 Alexander Madyankin <alexander@madyankin.name>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Adaptive Evil Blocks
2
+
3
+ [Evil Blocks]: https://github.com/ai/evil-blocks/
4
+ [matchMedia.js]: https://github.com/paulirish/matchMedia.js/
5
+ [media queries]: http://www.w3.org/TR/css3-mediaqueries/
6
+
7
+ Adaptive Evil Blocks is a filter that adds adaptivity to [Evil Blocks].
8
+ The [matchMedia.js] polyfill is used for old browsers.
9
+
10
+ The adaptivity is provided by the `@media` method powered by underlying
11
+ matchMedia API. So you can use [media queries] syntax.
12
+
13
+ ## Usage
14
+
15
+ Run code once only if it matches a query:
16
+ ```
17
+ evil.block '@@block',
18
+
19
+ init: -> ...
20
+ @media '(max-width: 399px)', -> ...
21
+ @media '(min-width: 400px)', -> ...
22
+
23
+ ```
24
+
25
+ The `match` callback is executed every time on query match, the `mismatch`
26
+ callback is executed every time on query mismatch.
27
+ ```
28
+ evil.block '@@block',
29
+
30
+ init: -> ...
31
+ @media '(max-width: 399px), match: -> ...
32
+ @media '(min-width: 400px), match: -> ...
33
+
34
+ @media '(max-width: 399px), match: -> ... , mismatch: -> ...
35
+ @media '(min-width: 400px), match: -> ... , mismatch: -> ...
36
+ ```
@@ -0,0 +1,14 @@
1
+ module AdaptiveEvilBlocks
2
+ # Add assets paths to standalone Sprockets environment.
3
+ def self.install(sprockets)
4
+ sprockets.append_path(Pathname(__FILE__).dirname)
5
+ end
6
+
7
+ if defined? ::Rails
8
+ class Engine < ::Rails::Engine
9
+ initializer 'adaptive-evil-blocks' do
10
+ AdaptiveEvilBlocks.install(Rails.application.assets)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,27 @@
1
+ evil = window.evil
2
+
3
+
4
+ media = (query, callback) ->
5
+ mql = window.matchMedia(query)
6
+
7
+ if typeof(callback) is 'function' and mql.matches
8
+ callback()
9
+ return
10
+
11
+ if typeof(callback) is 'object'
12
+ match = callback['match']
13
+ mismatch = callback['mismatch']
14
+
15
+ return unless match
16
+
17
+ handler = (mql) ->
18
+ if mql.matches
19
+ match()
20
+ else
21
+ mismatch() if mismatch
22
+
23
+ mql.addListener(handler)
24
+ handler(mql)
25
+
26
+
27
+ evil.block.filters.splice 0, 0, (obj) -> obj.media = media
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: adaptive-evil-blocks-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Madyankin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sprockets
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: evil-blocks
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0.6'
41
+ description:
42
+ email: alexander@madyankin.name
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files:
46
+ - LICENSE
47
+ - README.md
48
+ files:
49
+ - lib/adaptive-evil-blocks.coffee
50
+ - lib/adaptive-evil-blocks-rails.rb
51
+ - LICENSE
52
+ - README.md
53
+ homepage: https://github.com/outpunk/adaptive-evil-blocks
54
+ licenses:
55
+ - MIT
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 2.0.14
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Adaptive JS for Evil Blocks
77
+ test_files: []
78
+ has_rdoc: