ie-compat 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ /*!
2
+ * selectivizr v1.0.2 - (c) Keith Clark, freely distributable under the terms of the MIT license.
3
+ * selectivizr.com
4
+ */
5
+ (function(j){function A(a){return a.replace(B,h).replace(C,function(a,d,b){for(var a=b.split(","),b=0,e=a.length;b<e;b++){var s=D(a[b].replace(E,h).replace(F,h))+o,l=[];a[b]=s.replace(G,function(a,b,c,d,e){if(b){if(l.length>0){var a=l,f,e=s.substring(0,e).replace(H,i);if(e==i||e.charAt(e.length-1)==o)e+="*";try{f=t(e)}catch(k){}if(f){e=0;for(c=f.length;e<c;e++){for(var d=f[e],h=d.className,j=0,m=a.length;j<m;j++){var g=a[j];if(!RegExp("(^|\\s)"+g.className+"(\\s|$)").test(d.className)&&g.b&&(g.b===!0||g.b(d)===!0))h=u(h,g.className,!0)}d.className=h}}l=[]}return b}else{if(b=c?I(c):!v||v.test(d)?{className:w(d),b:!0}:null)return l.push(b),"."+b.className;return a}})}return d+a.join(",")})}function I(a){var c=!0,d=w(a.slice(1)),b=a.substring(0,5)==":not(",e,f;b&&(a=a.slice(5,-1));var l=a.indexOf("(");l>-1&&(a=a.substring(0,l));if(a.charAt(0)==":")switch(a.slice(1)){case "root":c=function(a){return b?a!=p:a==p};break;case "target":if(m==8){c=function(a){function c(){var d=location.hash,e=d.slice(1);return b?d==i||a.id!=e:d!=i&&a.id==e}k(j,"hashchange",function(){g(a,d,c())});return c()};break}return!1;case "checked":c=function(a){J.test(a.type)&&k(a,"propertychange",function(){event.propertyName=="checked"&&g(a,d,a.checked!==b)});return a.checked!==b};break;case "disabled":b=!b;case "enabled":c=function(c){if(K.test(c.tagName))return k(c,"propertychange",function(){event.propertyName=="$disabled"&&g(c,d,c.a===b)}),q.push(c),c.a=c.disabled,c.disabled===b;return a==":enabled"?b:!b};break;case "focus":e="focus",f="blur";case "hover":e||(e="mouseenter",f="mouseleave");c=function(a){k(a,b?f:e,function(){g(a,d,!0)});k(a,b?e:f,function(){g(a,d,!1)});return b};break;default:if(!L.test(a))return!1}return{className:d,b:c}}function w(a){return M+"-"+(m==6&&N?O++:a.replace(P,function(a){return a.charCodeAt(0)}))}function D(a){return a.replace(x,h).replace(Q,o)}function g(a,c,d){var b=a.className,c=u(b,c,d);if(c!=b)a.className=c,a.parentNode.className+=i}function u(a,c,d){var b=RegExp("(^|\\s)"+c+"(\\s|$)"),e=b.test(a);return d?e?a:a+o+c:e?a.replace(b,h).replace(x,h):a}function k(a,c,d){a.attachEvent("on"+c,d)}function r(a,c){if(/^https?:\/\//i.test(a))return c.substring(0,c.indexOf("/",8))==a.substring(0,a.indexOf("/",8))?a:null;if(a.charAt(0)=="/")return c.substring(0,c.indexOf("/",8))+a;var d=c.split(/[?#]/)[0];a.charAt(0)!="?"&&d.charAt(d.length-1)!="/"&&(d=d.substring(0,d.lastIndexOf("/")+1));return d+a}function y(a){if(a)return n.open("GET",a,!1),n.send(),(n.status==200?n.responseText:i).replace(R,i).replace(S,function(c,d,b,e,f){return y(r(b||f,a))}).replace(T,function(c,d,b){d=d||i;return" url("+d+r(b,a)+d+") "});return i}function U(){var a,c;a=f.getElementsByTagName("BASE");for(var d=a.length>0?a[0].href:f.location.href,b=0;b<f.styleSheets.length;b++)if(c=f.styleSheets[b],c.href!=i&&(a=r(c.href,d)))c.cssText=A(y(a));q.length>0&&setInterval(function(){for(var a=0,c=q.length;a<c;a++){var b=q[a];if(b.disabled!==b.a)b.disabled?(b.disabled=!1,b.a=!0,b.disabled=!0):b.a=b.disabled}},250)}if(!/*@cc_on!@*/true){var f=document,p=f.documentElement,n=function(){if(j.XMLHttpRequest)return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(a){return null}}(),m=/MSIE (\d+)/.exec(navigator.userAgent)[1];if(!(f.compatMode!="CSS1Compat"||m<6||m>8||!n)){var z={NW:"*.Dom.select",MooTools:"$$",DOMAssistant:"*.$",Prototype:"$$",YAHOO:"*.util.Selector.query",Sizzle:"*",jQuery:"*",dojo:"*.query"},t,q=[],O=0,N=!0,M="slvzr",R=/(\/\*[^*]*\*+([^\/][^*]*\*+)*\/)\s*/g,S=/@import\s*(?:(?:(?:url\(\s*(['"]?)(.*)\1)\s*\))|(?:(['"])(.*)\3))[^;]*;/g,T=/\burl\(\s*(["']?)(?!data:)([^"')]+)\1\s*\)/g,L=/^:(empty|(first|last|only|nth(-last)?)-(child|of-type))$/,B=/:(:first-(?:line|letter))/g,C=/(^|})\s*([^\{]*?[\[:][^{]+)/g,G=/([ +~>])|(:[a-z-]+(?:\(.*?\)+)?)|(\[.*?\])/g,H=/(:not\()?:(hover|enabled|disabled|focus|checked|target|active|visited|first-line|first-letter)\)?/g,P=/[^\w-]/g,K=/^(INPUT|SELECT|TEXTAREA|BUTTON)$/,J=/^(checkbox|radio)$/,v=m>6?/[\$\^*]=(['"])\1/:null,E=/([(\[+~])\s+/g,F=/\s+([)\]+~])/g,Q=/\s+/g,x=/^\s*((?:[\S\s]*\S)?)\s*$/,i="",o=" ",h="$1";(function(a,c){function d(){try{p.doScroll("left")}catch(a){setTimeout(d,50);return}b("poll")}function b(d){if(!(d.type=="readystatechange"&&f.readyState!="complete")&&((d.type=="load"?a:f).detachEvent("on"+d.type,b,!1),!e&&(e=!0)))c.call(a,d.type||d)}var e=!1,g=!0;if(f.readyState=="complete")c.call(a,i);else{if(f.createEventObject&&p.doScroll){try{g=!a.frameElement}catch(h){}g&&d()}k(f,"readystatechange",b);k(a,"load",b)}})(j,function(){for(var a in z){var c,d,b=j;if(j[a]){for(c=z[a].replace("*",a).split(".");(d=c.shift())&&(b=b[d]););if(typeof b=="function"){t=b;U();break}}}})}}})(this);
data/ie-compat.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ie/compat/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'ie-compat'
8
+ spec.version = IE::Compat::VERSION
9
+ spec.authors = ['Elia Schito']
10
+ spec.email = ['elia@schito.me']
11
+ spec.summary = %q{The usual set of IE 9 and <9 compatibility assets}
12
+ spec.description = %q{Sick of reimplementing `console.log` every time you have to support Microsoft Internet Explorer < 10?}
13
+ spec.homepage = 'https://github.com/mikamai/ie-compat#readme'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.6'
22
+ spec.add_development_dependency 'rake'
23
+ end
data/lib/ie/compat.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'ie/compat/version'
2
+ require 'ie/compat/assets_path'
3
+ require 'ie/compat/sprockets'
4
+ require 'ie/compat/opal'
5
+ require 'ie/compat/railtie'
6
+
@@ -0,0 +1,22 @@
1
+ if defined? ActiveAdmin
2
+ module IE; module Compat
3
+
4
+ module ActiveAdminBasePage
5
+ def build(*args)
6
+ super
7
+ add_ie_compat_tag
8
+ end
9
+
10
+ def add_ie_compat_tag
11
+ within @head do
12
+ text_node(ie_compat_tags)
13
+ end
14
+ end
15
+ end
16
+
17
+ end; end
18
+
19
+ ActiveAdmin::Views::Pages::Base.class_eval do
20
+ include IE::Compat::ActiveAdminBasePage
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ module IE
2
+ module Compat
3
+ IE_COMPAT_ASSETS_PATH = File.expand_path('../../../assets', __FILE__).freeze
4
+
5
+ def ie_compat_assets_path
6
+ IE_COMPAT_ASSETS_PATH
7
+ end
8
+
9
+ def self.assets_path
10
+ IE_COMPAT_ASSETS_PATH
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ require 'ie/compat/assets_path'
2
+
3
+ Opal.append_path IE::Compat.assets_path if defined? Opal
@@ -0,0 +1,19 @@
1
+ module IE
2
+ module Compat
3
+ class Railtie < ::Rails::Railtie
4
+ config.ie_compat = ActiveSupport::OrderedOptions.new
5
+
6
+ initializer 'ie-compat.initialize' do
7
+ require 'ie/compat/assets_path'
8
+ require 'ie/compat/view_helper'
9
+ require 'ie/compat/active_admin'
10
+
11
+ ActiveSupport.on_load(:action_view) do
12
+ include ::IE::Compat::ViewHelper
13
+ end
14
+
15
+ config.assets.precompile += %w[ie-compat/*.js]
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ require 'ie/compat/assets_path'
2
+
3
+ Sprockets.append_path IE::Compat.assets_path if defined? Sprockets
@@ -0,0 +1,5 @@
1
+ module IE
2
+ module Compat
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,12 @@
1
+ module IE
2
+ module Compat
3
+ module ViewHelper
4
+ def ie_compat_tags
5
+ [
6
+ "<!--[if lt IE 9]>#{javascript_include_tag 'ie-compat/lt-9'}<![endif]-->",
7
+ "<!--[if IE 9]> #{javascript_include_tag 'ie-compat/9'} <![endif]-->",
8
+ ].join("\n").html_safe
9
+ end
10
+ end
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ie-compat
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Elia Schito
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-17 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.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Sick of reimplementing `console.log` every time you have to support Microsoft
42
+ Internet Explorer < 10?
43
+ email:
44
+ - elia@schito.me
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - assets/ie-compat/9.js
55
+ - assets/ie-compat/array_foreach.js
56
+ - assets/ie-compat/console.js
57
+ - assets/ie-compat/function_bind.js
58
+ - assets/ie-compat/lt-9.js
59
+ - assets/ie-compat/vendor/html5shiv-printshiv.js
60
+ - assets/ie-compat/vendor/html5shiv.js
61
+ - assets/ie-compat/vendor/json2.js
62
+ - assets/ie-compat/vendor/selectivizr-min.js
63
+ - ie-compat.gemspec
64
+ - lib/ie/compat.rb
65
+ - lib/ie/compat/active_admin.rb
66
+ - lib/ie/compat/assets_path.rb
67
+ - lib/ie/compat/opal.rb
68
+ - lib/ie/compat/railtie.rb
69
+ - lib/ie/compat/sprockets.rb
70
+ - lib/ie/compat/version.rb
71
+ - lib/ie/compat/view_helper.rb
72
+ homepage: https://github.com/mikamai/ie-compat#readme
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.2.2
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: The usual set of IE 9 and <9 compatibility assets
96
+ test_files: []