match_media_js 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # match_media_js
2
+ a ruby gem for use in rails 3.2
3
+
4
+ Gemfile
5
+ gem 'match_media_js'
6
+
7
+ application.js
8
+ //= require match_media
9
+
10
+ Individual Files
11
+ //= require match_media/matchMedia
12
+ //= require match_media/matchMedia.addListener
13
+
14
+ License: MIT (http://www.opensource.org/licenses/mit-license.php)
15
+
16
+
17
+ Original repository: [github.com/paulirish/matchMedia.js](https://github.com/paulirish/matchMedia.js)
18
+
@@ -0,0 +1,8 @@
1
+ require "match_media_js/version"
2
+
3
+ module MatchMediaJs
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module MatchMediaJs
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,2 @@
1
+ //= require match_media/matchMedia
2
+ //= require match_media/matchMedia.addListener
@@ -0,0 +1,47 @@
1
+ /*! matchMedia() polyfill addListener/removeListener extension. Author & copyright (c) 2012: Scott Jehl. Dual MIT/BSD license */
2
+ (function(){
3
+ // monkeypatch unsupported addListener/removeListener with polling
4
+ if( !window.matchMedia( "" ).addListener ){
5
+ var oldMM = window.matchMedia;
6
+
7
+ window.matchMedia = function( q ){
8
+ var ret = oldMM( q ),
9
+ listeners = [],
10
+ last = ret.matches,
11
+ timer,
12
+ check = function(){
13
+ var list = oldMM( q ),
14
+ unmatchToMatch = list.matches && !last,
15
+ matchToUnmatch = !list.matches && last;
16
+
17
+ //fire callbacks only if transitioning to or from matched state
18
+ if( unmatchToMatch || matchToUnmatch ){
19
+ for( var i =0, il = listeners.length; i< il; i++ ){
20
+ listeners[ i ].call( ret, list );
21
+ }
22
+ }
23
+ last = list.matches;
24
+ };
25
+
26
+ ret.addListener = function( cb ){
27
+ listeners.push( cb );
28
+ if( !timer ){
29
+ timer = setInterval( check, 1000 );
30
+ }
31
+ };
32
+
33
+ ret.removeListener = function( cb ){
34
+ for( var i =0, il = listeners.length; i< il; i++ ){
35
+ if( listeners[ i ] === cb ){
36
+ listeners.splice( i, 1 );
37
+ }
38
+ }
39
+ if( !listeners.length && timer ){
40
+ clearInterval( timer );
41
+ }
42
+ };
43
+
44
+ return ret;
45
+ };
46
+ }
47
+ }());
@@ -0,0 +1,36 @@
1
+ /*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */
2
+
3
+ window.matchMedia = window.matchMedia || (function( doc, undefined ) {
4
+
5
+ "use strict";
6
+
7
+ var bool,
8
+ docElem = doc.documentElement,
9
+ refNode = docElem.firstElementChild || docElem.firstChild,
10
+ // fakeBody required for <FF4 when executed in <head>
11
+ fakeBody = doc.createElement( "body" ),
12
+ div = doc.createElement( "div" );
13
+
14
+ div.id = "mq-test-1";
15
+ div.style.cssText = "position:absolute;top:-100em";
16
+ fakeBody.style.background = "none";
17
+ fakeBody.appendChild(div);
18
+
19
+ return function(q){
20
+
21
+ div.innerHTML = "&shy;<style media=\"" + q + "\"> #mq-test-1 { width: 42px; }</style>";
22
+
23
+ docElem.insertBefore( fakeBody, refNode );
24
+ bool = div.offsetWidth === 42;
25
+ docElem.removeChild( fakeBody );
26
+
27
+ return {
28
+ matches: bool,
29
+ media: q
30
+ };
31
+
32
+ };
33
+
34
+ }( document ));
35
+
36
+
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: match_media_js
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - rheaton
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2013-06-17 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: railties
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 3
29
+ - 1
30
+ version: "3.1"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ description: a ruby gem for use in rails 3.2
34
+ email:
35
+ - rachelmheaton@gmail.com
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files: []
41
+
42
+ files:
43
+ - lib/match_media_js/version.rb
44
+ - lib/match_media_js.rb
45
+ - vendor/assets/javascripts/match_media/matchMedia.addListener.js
46
+ - vendor/assets/javascripts/match_media/matchMedia.js
47
+ - vendor/assets/javascripts/match_media.js
48
+ - README.md
49
+ has_rdoc: true
50
+ homepage: https://github.com/rheaton/match_media_js
51
+ licenses: []
52
+
53
+ post_install_message:
54
+ rdoc_options: []
55
+
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ requirements: []
73
+
74
+ rubyforge_project: match_media_js
75
+ rubygems_version: 1.3.6
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: matchMedia.js
79
+ test_files: []
80
+