shoestrap 1.0.0.pre2 → 1.0.0.pre3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -1
- data/features/shoestrap/commands/new_command_spec.rb +7 -8
- data/features/shoestrap/generators/cms_generator_spec.rb +2 -0
- data/features/shoestrap/generators/foundation_generator_spec.rb +4 -2
- data/features/shoestrap/generators/smacss_files_generator_spec.rb +13 -8
- data/lib/generators/shoestrap/cms_generator.rb +11 -5
- data/lib/generators/shoestrap/foundation_generator.rb +5 -2
- data/lib/generators/shoestrap/smacss_file_generator.rb +14 -5
- data/lib/shoestrap/cli.rb +5 -0
- data/lib/shoestrap/version.rb +1 -1
- data/shoestrap.gemspec +7 -0
- data/spec/shoestrap/application_generator_spec.rb +1 -2
- data/templates/application_generator/_typekit.html.haml +1 -1
- data/templates/application_generator/application.html.haml +26 -7
- data/templates/application_generator/application_template.rb +6 -1
- data/templates/application_generator/modernizr.js +812 -0
- data/templates/coffee_files_generator/application.js.coffee +4 -0
- data/templates/foundation_generator/_mixin.css.sass +13 -0
- data/templates/foundation_generator/_settings.css.sass +27 -1
- data/templates/foundation_generator/ie.css.sass +5 -0
- data/templates/foundation_generator/{_ie8_grid.css → large/_ie8_grid.css} +0 -0
- data/templates/foundation_generator/large/_ie8_top_bar.css.sass +124 -0
- data/templates/smacss_files_generator/application.css.sass +10 -4
- data/templates/smacss_files_generator/ie8.css.sass +3 -0
- data/templates/smacss_files_generator/large/_layout.css.sass +0 -0
- data/templates/smacss_files_generator/large/_states.css.sass +0 -0
- data/templates/smacss_files_generator/large/modules/.empty_directory +0 -0
- data/templates/smacss_files_generator/large/modules/_empty.css +0 -0
- data/templates/smacss_files_generator/partials/_footer.html.haml +3 -0
- data/templates/smacss_files_generator/partials/_header.html.haml +12 -0
- data/templates/smacss_files_generator/small/_base.css.sass +0 -0
- data/templates/smacss_files_generator/small/_layout.css.sass +0 -0
- data/templates/smacss_files_generator/small/_states.css.sass +0 -0
- data/templates/smacss_files_generator/small/modules/.empty_directory +0 -0
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dd1664ff03eceb5244ebbe95ed3bf3820019621
|
4
|
+
data.tar.gz: b85a06876965e48d6cd18d01fc3dfafcc20bd886
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f20b5a995193ed3903de4bcae6b0c591fa08255b87521063d0e05eb7aa7245838e86d36d5b45793d56ecfe6899d342305cd4bceee80f8a227f89f627c3eea8f
|
7
|
+
data.tar.gz: 8f72be11198fd660455aeb916886d458d2de588ea104a6910bf107ae0617f643621ceab9993ef349509abdea66041053586a3a6d35ab6b030f5c1a969662839c
|
data/CHANGELOG.md
CHANGED
@@ -8,6 +8,8 @@ describe 'application generated with shoestrap new <application_name>' do
|
|
8
8
|
let (:gemfile_content) { application_file('Gemfile') }
|
9
9
|
let (:application_rb_content) { application_file('config/application.rb') }
|
10
10
|
let (:application_layout) { application_file('app/views/layouts/application.html.haml') }
|
11
|
+
let (:application_header) { application_file('app/views/partials/_header.html.haml') }
|
12
|
+
let (:application_footer) { application_file('app/views/partials/_footer.html.haml') }
|
11
13
|
let (:application_layout_typekit) { application_file('app/views/layouts/_typekit.html.haml') }
|
12
14
|
let (:application_helper) { application_file('app/helpers/application_helper.rb') }
|
13
15
|
let (:development_rb_content) { application_file('config/environments/development.rb') }
|
@@ -59,7 +61,7 @@ describe 'application generated with shoestrap new <application_name>' do
|
|
59
61
|
end
|
60
62
|
|
61
63
|
%w[
|
62
|
-
pry
|
64
|
+
pry-rails
|
63
65
|
database_cleaner
|
64
66
|
guard-rspec
|
65
67
|
guard-spring
|
@@ -94,7 +96,7 @@ describe 'application generated with shoestrap new <application_name>' do
|
|
94
96
|
|
95
97
|
it 'has meta tags' do
|
96
98
|
expect(application_layout).to match "%meta{ charset: 'utf-8' }"
|
97
|
-
expect(application_layout).to match "%meta{ 'http-equiv' => 'X-UA-Compatible', content: 'IE=edge
|
99
|
+
expect(application_layout).to match "%meta{ 'http-equiv' => 'X-UA-Compatible', content: 'IE=edge' }"
|
98
100
|
expect(application_layout).to match "%meta{ name: 'keywords', content: '' }"
|
99
101
|
expect(application_layout).to match "%meta{ name: 'description', content: '' }"
|
100
102
|
expect(application_layout).to match "%meta{ name: 'viewport', content: 'width=device-width, initial-scale=1.0' }"
|
@@ -122,7 +124,7 @@ describe 'application generated with shoestrap new <application_name>' do
|
|
122
124
|
end
|
123
125
|
|
124
126
|
it 'renders the navigation' do
|
125
|
-
expect(
|
127
|
+
expect(application_header).to match "= render_navigation"
|
126
128
|
end
|
127
129
|
|
128
130
|
it 'renders the content' do
|
@@ -134,10 +136,7 @@ describe 'application generated with shoestrap new <application_name>' do
|
|
134
136
|
end
|
135
137
|
|
136
138
|
it 'has google analytics integrated' do
|
137
|
-
expect(application_layout).to match(/
|
138
|
-
expect(application_layout).to match(/\(function\(d,t\)\{var\ g=d\.createElement\(t\),s=d\.getElementsByTagName\(t\)\[0\];g\.async=1;/)
|
139
|
-
expect(application_layout).to match(/g\.src=\('https:'==location\.protocol\?'\/\/ssl':'\/\/www'\)\+'\.google\-analytics\.com\/ga\.js';/)
|
140
|
-
expect(application_layout).to match(/s\.parentNode\.insertBefore\(g,s\)\}\(document,'script'\)\);/)
|
139
|
+
expect(application_layout).to match(/e\.src = \"\/\/www\.google-analytics\.com\/analytics\.js\"/)
|
141
140
|
end
|
142
141
|
end
|
143
142
|
|
@@ -174,7 +173,7 @@ describe 'application generated with shoestrap new <application_name>' do
|
|
174
173
|
end
|
175
174
|
|
176
175
|
it 'has the typekit js integrated' do
|
177
|
-
expect(application_layout_typekit).to match(/javascript_include_tag\ "\/\/use\.typekit\.net\/\#\{Rails\.application\.config\.typekit_key\}\.js"
|
176
|
+
expect(application_layout_typekit).to match(/javascript_include_tag\ "\/\/use\.typekit\.net\/\#\{Rails\.application\.config\.typekit_key\}\.js"/)
|
178
177
|
expect(application_layout_typekit).to match(/try\{Typekit\.load\(\);\}catch\(e\)\{\}/)
|
179
178
|
end
|
180
179
|
end
|
@@ -53,6 +53,8 @@ describe 'rails generate shoestrap:cms' do
|
|
53
53
|
expect(cars_controller).to match(/Shoestrap..BaseController/)
|
54
54
|
expect(cars_controller).to match('respond_to :html')
|
55
55
|
expect(cars_controller).to match(/action.+all.+except.+show/)
|
56
|
+
expect(cars_controller).not_to match(/Cms::Car\./)
|
57
|
+
expect(cars_controller).not_to match(/params\[:cms_car\]/)
|
56
58
|
end
|
57
59
|
|
58
60
|
it 'generates inherited CRUD views' do
|
@@ -24,8 +24,10 @@ describe 'application generated with shoestrap new <name> --css=foundation' do
|
|
24
24
|
expect(application_file('app/assets/stylesheets/application.css.sass', options)).to match /@import\ ie8_grid/
|
25
25
|
end
|
26
26
|
|
27
|
-
it 'has the ie8
|
28
|
-
expect(application_file('app/assets/stylesheets/_ie8_grid.css', options)).not_to be_nil
|
27
|
+
it 'has the ie8 support' do
|
28
|
+
expect(application_file('app/assets/stylesheets/large/_ie8_grid.css', options)).not_to be_nil
|
29
|
+
expect(application_file('app/assets/stylesheets/large/_ie8_top_bar.css.sass', options)).not_to be_nil
|
30
|
+
expect(application_file('app/assets/stylesheets/ie8.css.sass', options)).not_to be_nil
|
29
31
|
end
|
30
32
|
|
31
33
|
it 'has the foundation settings file' do
|
@@ -11,16 +11,18 @@ describe 'application generated with shoestrap new <name>' do
|
|
11
11
|
|
12
12
|
it 'has the modules directory and at least one module stylesheet' do
|
13
13
|
expect(File.directory?('app/assets/stylesheets/modules/')).not_to be_nil
|
14
|
-
expect(application_file('app/assets/stylesheets/modules/_main_nav.css.sass')).not_to be_nil
|
14
|
+
expect(application_file('app/assets/stylesheets/small/modules/_main_nav.css.sass')).not_to be_nil
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'has the initial stylesheet partials' do
|
18
|
-
expect(application_file('app/assets/stylesheets/_base.css.sass')).not_to be_nil
|
18
|
+
expect(application_file('app/assets/stylesheets/small/_base.css.sass')).not_to be_nil
|
19
|
+
expect(application_file('app/assets/stylesheets/small/_layout.css.sass')).not_to be_nil
|
20
|
+
expect(application_file('app/assets/stylesheets/small/_states.css.sass')).not_to be_nil
|
21
|
+
expect(application_file('app/assets/stylesheets/large/_layout.css.sass')).not_to be_nil
|
22
|
+
expect(application_file('app/assets/stylesheets/large/_states.css.sass')).not_to be_nil
|
19
23
|
expect(application_file('app/assets/stylesheets/_fonts.css.sass')).not_to be_nil
|
20
|
-
expect(application_file('app/assets/stylesheets/_layout.css.sass')).not_to be_nil
|
21
24
|
expect(application_file('app/assets/stylesheets/_mixins.css.sass')).not_to be_nil
|
22
25
|
expect(application_file('app/assets/stylesheets/_settings.css.sass')).not_to be_nil
|
23
|
-
expect(application_file('app/assets/stylesheets/_states.css.sass')).not_to be_nil
|
24
26
|
end
|
25
27
|
|
26
28
|
context 'application.css.sass' do
|
@@ -32,10 +34,13 @@ describe 'application generated with shoestrap new <name>' do
|
|
32
34
|
settings
|
33
35
|
bourbon
|
34
36
|
mixins
|
35
|
-
base
|
36
|
-
layout
|
37
|
-
|
38
|
-
|
37
|
+
small/base
|
38
|
+
large/layout
|
39
|
+
small/layout
|
40
|
+
large/states
|
41
|
+
small/states
|
42
|
+
small/modules/*
|
43
|
+
large/modules/*
|
39
44
|
].each do |stylesheet_import|
|
40
45
|
it "has #{stylesheet_import} in the application.css.sass" do
|
41
46
|
expect(application_file('app/assets/stylesheets/application.css.sass')).to match "@import #{stylesheet_import}"
|
@@ -9,8 +9,8 @@ module Shoestrap
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def add_navigation_link
|
12
|
-
link_definition = "primary.item #{model_name.to_sym.inspect}, #{model_name.pluralize.inspect}, cms_#{model_name.pluralize}_path"
|
13
|
-
inject_into_file 'config/navigation.rb', link_definition, after: /navigation.items.+do.+primary
|
12
|
+
link_definition = "\n primary.item #{model_name.to_sym.inspect}, #{model_name.pluralize.inspect}, cms_#{model_name.pluralize}_path\n"
|
13
|
+
inject_into_file 'config/navigation.rb', link_definition, after: /navigation.items.+do.+primary.*$/
|
14
14
|
end
|
15
15
|
|
16
16
|
def add_model
|
@@ -24,10 +24,16 @@ module Shoestrap
|
|
24
24
|
|
25
25
|
base_controller = kuhsaft_is_used? ? 'Kuhsaft::Cms::AdminController' : 'Shoestrap::BaseController'
|
26
26
|
controller_content.gsub!('ApplicationController', base_controller)
|
27
|
+
|
28
|
+
model_class = resource_route_name.camelize
|
29
|
+
controller_content.gsub!(/#{model_class}\./, model_class.gsub('Cms::','')+'.')
|
30
|
+
|
31
|
+
controller_content.gsub!("params\[:cms_#{model_name}]", "params\[:#{model_name}]")
|
32
|
+
|
27
33
|
File.open(controller_path, 'w') { |file| file.puts controller_content }
|
28
34
|
|
29
|
-
inject_into_file controller_path,
|
30
|
-
inject_into_file controller_path,
|
35
|
+
inject_into_file controller_path, " respond_to :html\n", after: /class Cms::.+Controller < #{base_controller}/
|
36
|
+
inject_into_file controller_path, "\n actions :all, :except => [ :show ]\n", after: /class Cms::.+Controller < #{base_controller}/
|
31
37
|
end
|
32
38
|
|
33
39
|
def create_shoestrap_basecontroller_if_kuhsaft_isnt_used
|
@@ -49,7 +55,7 @@ module Shoestrap
|
|
49
55
|
end
|
50
56
|
|
51
57
|
def model_name
|
52
|
-
ARGV.first
|
58
|
+
ARGV.first.downcase
|
53
59
|
end
|
54
60
|
|
55
61
|
def scaffold_controller_options
|
@@ -7,14 +7,17 @@ module Shoestrap
|
|
7
7
|
copy_file '_settings.css.sass', 'app/assets/stylesheets/_settings.css.sass', force: true
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
copy_file '_ie8_grid.css', 'app/assets/stylesheets/_ie8_grid.css'
|
10
|
+
def copy_ie_files
|
11
|
+
copy_file 'large/_ie8_grid.css', 'app/assets/stylesheets/large/_ie8_grid.css'
|
12
|
+
copy_file 'large/_ie8_top_bar.css.sass', 'app/assets/stylesheets/large/_ie8_top_bar.css.sass'
|
12
13
|
end
|
13
14
|
|
14
15
|
def add_foundation_requirements
|
15
16
|
inject_into_file 'app/assets/javascripts/application.js.coffee', "#= require foundation", after: "#= require turbolinks\n"
|
17
|
+
inject_into_file 'app/assets/javascripts/application.js.coffee', "\n$(document).foundation()", after: "window.html5.shivDocument document\n"
|
16
18
|
inject_into_file 'app/assets/stylesheets/application.css.sass', "// Foundation\n@import foundation\n\n", after: "@import settings\n\n"
|
17
19
|
inject_into_file 'app/assets/stylesheets/application.css.sass', "// IE8 Foundation Grid Fix\n@import ie8_grid\n\n", after: "@import foundation\n\n"
|
20
|
+
inject_into_file 'app/assets/stylesheets/ie8.css.sass', "@import large/ie8_grid\n@import large/ie8_top_bar\n", before: "@import large/layout\n"
|
18
21
|
end
|
19
22
|
|
20
23
|
def install_simple_form
|
@@ -12,18 +12,27 @@ module Shoestrap
|
|
12
12
|
copy_file 'application.css.sass', 'app/assets/stylesheets/application.css.sass'
|
13
13
|
end
|
14
14
|
|
15
|
+
def copy_ie8_sass
|
16
|
+
copy_file 'ie8.css.sass', 'app/assets/stylesheets/ie8.css.sass'
|
17
|
+
end
|
18
|
+
|
19
|
+
def copy_partials
|
20
|
+
directory 'partials', 'app/views/partials'
|
21
|
+
end
|
22
|
+
|
23
|
+
def copy_small_large_styles
|
24
|
+
directory "large", "app/assets/stylesheets/large"
|
25
|
+
directory "small", "app/assets/stylesheets/small"
|
26
|
+
end
|
27
|
+
|
15
28
|
def create_initial_stylesheets
|
16
|
-
create_file 'app/assets/stylesheets/_base.css.sass'
|
17
29
|
create_file 'app/assets/stylesheets/_fonts.css.sass'
|
18
|
-
create_file 'app/assets/stylesheets/_layout.css.sass'
|
19
30
|
create_file 'app/assets/stylesheets/_mixins.css.sass'
|
20
31
|
create_file 'app/assets/stylesheets/_settings.css.sass'
|
21
|
-
create_file 'app/assets/stylesheets/_states.css.sass'
|
22
32
|
end
|
23
33
|
|
24
34
|
def create_modules_directory
|
25
|
-
|
26
|
-
create_file 'app/assets/stylesheets/modules/_main_nav.css.sass'
|
35
|
+
create_file 'app/assets/stylesheets/small/modules/_main_nav.css.sass'
|
27
36
|
end
|
28
37
|
end
|
29
38
|
end
|
data/lib/shoestrap/cli.rb
CHANGED
@@ -26,6 +26,11 @@ module Shoestrap
|
|
26
26
|
application_generator.start(application_name, options)
|
27
27
|
end
|
28
28
|
|
29
|
+
desc 'run_generator <generator>', 'Run the generator in the current app'
|
30
|
+
|
31
|
+
def run_generator(generator_name)
|
32
|
+
application_generator.call_generator(generator_name)
|
33
|
+
end
|
29
34
|
private
|
30
35
|
|
31
36
|
def application_generator
|
data/lib/shoestrap/version.rb
CHANGED
data/shoestrap.gemspec
CHANGED
@@ -33,6 +33,13 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency "bootstrap-sass"
|
34
34
|
spec.add_development_dependency "kuhsaft"
|
35
35
|
spec.add_development_dependency "zurb-foundation"
|
36
|
+
spec.add_development_dependency "modernizr-rails"
|
37
|
+
spec.add_development_dependency "pry-rails"
|
38
|
+
spec.add_development_dependency "rails-i18n"
|
39
|
+
spec.add_development_dependency "i18n-missing_translations"
|
40
|
+
spec.add_development_dependency "capybara"
|
41
|
+
spec.add_development_dependency "capybara-webkit"
|
42
|
+
spec.add_development_dependency "launchy"
|
36
43
|
end
|
37
44
|
|
38
45
|
spec.add_dependency 'rails', '4.0.0'
|
@@ -171,8 +171,7 @@ module Shoestrap
|
|
171
171
|
|
172
172
|
describe '#required_gems' do
|
173
173
|
it 'includes kuhsaft by default' do
|
174
|
-
|
175
|
-
#expect(ApplicationGenerator.required_gems(default_options)).to include('kuhsaft')
|
174
|
+
expect(ApplicationGenerator.required_gems(default_options)).to include('kuhsaft')
|
176
175
|
end
|
177
176
|
|
178
177
|
it 'includes bootstrap-sass by default' do
|
@@ -1,4 +1,4 @@
|
|
1
1
|
- if Rails.application.config.typekit_key.present?
|
2
|
-
= javascript_include_tag "//use.typekit.net/#{Rails.application.config.typekit_key}.js"
|
2
|
+
= javascript_include_tag "//use.typekit.net/#{Rails.application.config.typekit_key}.js"
|
3
3
|
:javascript
|
4
4
|
try{Typekit.load();}catch(e){}
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<!--<![endif]-->
|
11
11
|
%head
|
12
12
|
%meta{ charset: 'utf-8' }
|
13
|
-
%meta{ 'http-equiv' => 'X-UA-Compatible', content: 'IE=edge
|
13
|
+
%meta{ 'http-equiv' => 'X-UA-Compatible', content: 'IE=edge' }
|
14
14
|
%title= content_for?(:title) ? yield(:title) : 'Untitled'
|
15
15
|
%meta{ name: 'keywords', content: '' }
|
16
16
|
%meta{ name: 'description', content: '' }
|
@@ -27,13 +27,23 @@
|
|
27
27
|
= render 'layouts/typekit'
|
28
28
|
|
29
29
|
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
|
30
|
+
<!--[if (lt IE 9) & (!IEMobile)]>
|
31
|
+
= stylesheet_link_tag 'ie', media: 'all', 'data-turbolinks-track' => true
|
32
|
+
<![endif]-->
|
33
|
+
|
30
34
|
= javascript_include_tag 'modernizr', 'data-turbolinks-track' => true
|
31
35
|
= csrf_meta_tags
|
32
36
|
|
33
37
|
%body{ class: body_class }
|
34
|
-
|
38
|
+
%header{role: "banner"}
|
39
|
+
= render 'partials/header'
|
40
|
+
|
41
|
+
%main#maincontent{role: "content"}
|
42
|
+
.row
|
43
|
+
= yield
|
35
44
|
|
36
|
-
|
45
|
+
%footer{role: "contentinfo"}
|
46
|
+
= render 'partials/footer'
|
37
47
|
|
38
48
|
-# Application JavaScripts
|
39
49
|
= javascript_include_tag 'application', 'data-turbolinks-track' => true
|
@@ -45,7 +55,16 @@
|
|
45
55
|
|
46
56
|
-# Google Analytics
|
47
57
|
:javascript
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
58
|
+
((b, o, i, l, e, r) ->
|
59
|
+
b.GoogleAnalyticsObject = l
|
60
|
+
b[l] or (b[l] = ->
|
61
|
+
(b[l].q = b[l].q or []).push arguments_
|
62
|
+
)
|
63
|
+
b[l].l = +new Date
|
64
|
+
e = o.createElement(i)
|
65
|
+
r = o.getElementsByTagName(i)[0]
|
66
|
+
e.src = "//www.google-analytics.com/analytics.js"
|
67
|
+
r.parentNode.insertBefore e, r
|
68
|
+
) window, document, "script", "ga"
|
69
|
+
ga "create", "UA-XXXXX-X"
|
70
|
+
ga "send", "pageview"
|
@@ -46,6 +46,8 @@ gem 'simple-navigation'
|
|
46
46
|
gem 'mail'
|
47
47
|
gem 'fabrication'
|
48
48
|
gem 'inherited_resources'
|
49
|
+
gem 'rails-i18n'
|
50
|
+
gem 'i18n-missing_translations'
|
49
51
|
|
50
52
|
if ENV['SHOESTRAP_PATH']
|
51
53
|
gem 'shoestrap', path: ENV['SHOESTRAP_PATH']
|
@@ -58,12 +60,15 @@ gem 'modernizr-rails'
|
|
58
60
|
gem 'bourbon'
|
59
61
|
|
60
62
|
gem_group :development, :test do
|
61
|
-
gem 'pry'
|
63
|
+
gem 'pry-rails'
|
62
64
|
gem 'terminal-notifier-guard'
|
63
65
|
gem 'rspec-rails'
|
64
66
|
gem 'guard-rspec'
|
65
67
|
gem 'guard-spring'
|
66
68
|
gem 'mailcatcher'
|
69
|
+
gem 'capybara'
|
70
|
+
gem 'capybara-webkit'
|
71
|
+
gem 'launchy'
|
67
72
|
end
|
68
73
|
|
69
74
|
gem_group :test do
|
@@ -0,0 +1,812 @@
|
|
1
|
+
/* Modernizr 2.6.2 (Custom Build) | MIT & BSD
|
2
|
+
* Build: http://modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-canvas-canvastext-draganddrop-hashchange-history-audio-video-indexeddb-input-inputtypes-localstorage-postmessage-sessionstorage-websockets-websqldatabase-webworkers-geolocation-inlinesvg-smil-svg-svgclippaths-touch-webgl-shiv-cssclasses-addtest-prefixed-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-load
|
3
|
+
*/
|
4
|
+
;
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
window.Modernizr = (function( window, document, undefined ) {
|
9
|
+
|
10
|
+
var version = '2.6.2',
|
11
|
+
|
12
|
+
Modernizr = {},
|
13
|
+
|
14
|
+
enableClasses = true,
|
15
|
+
|
16
|
+
docElement = document.documentElement,
|
17
|
+
|
18
|
+
mod = 'modernizr',
|
19
|
+
modElem = document.createElement(mod),
|
20
|
+
mStyle = modElem.style,
|
21
|
+
|
22
|
+
inputElem = document.createElement('input') ,
|
23
|
+
|
24
|
+
smile = ':)',
|
25
|
+
|
26
|
+
toString = {}.toString,
|
27
|
+
|
28
|
+
prefixes = ' -webkit- -moz- -o- -ms- '.split(' '),
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
omPrefixes = 'Webkit Moz O ms',
|
33
|
+
|
34
|
+
cssomPrefixes = omPrefixes.split(' '),
|
35
|
+
|
36
|
+
domPrefixes = omPrefixes.toLowerCase().split(' '),
|
37
|
+
|
38
|
+
ns = {'svg': 'http://www.w3.org/2000/svg'},
|
39
|
+
|
40
|
+
tests = {},
|
41
|
+
inputs = {},
|
42
|
+
attrs = {},
|
43
|
+
|
44
|
+
classes = [],
|
45
|
+
|
46
|
+
slice = classes.slice,
|
47
|
+
|
48
|
+
featureName,
|
49
|
+
|
50
|
+
|
51
|
+
injectElementWithStyles = function( rule, callback, nodes, testnames ) {
|
52
|
+
|
53
|
+
var style, ret, node, docOverflow,
|
54
|
+
div = document.createElement('div'),
|
55
|
+
body = document.body,
|
56
|
+
fakeBody = body || document.createElement('body');
|
57
|
+
|
58
|
+
if ( parseInt(nodes, 10) ) {
|
59
|
+
while ( nodes-- ) {
|
60
|
+
node = document.createElement('div');
|
61
|
+
node.id = testnames ? testnames[nodes] : mod + (nodes + 1);
|
62
|
+
div.appendChild(node);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
style = ['­','<style id="s', mod, '">', rule, '</style>'].join('');
|
67
|
+
div.id = mod;
|
68
|
+
(body ? div : fakeBody).innerHTML += style;
|
69
|
+
fakeBody.appendChild(div);
|
70
|
+
if ( !body ) {
|
71
|
+
fakeBody.style.background = '';
|
72
|
+
fakeBody.style.overflow = 'hidden';
|
73
|
+
docOverflow = docElement.style.overflow;
|
74
|
+
docElement.style.overflow = 'hidden';
|
75
|
+
docElement.appendChild(fakeBody);
|
76
|
+
}
|
77
|
+
|
78
|
+
ret = callback(div, rule);
|
79
|
+
if ( !body ) {
|
80
|
+
fakeBody.parentNode.removeChild(fakeBody);
|
81
|
+
docElement.style.overflow = docOverflow;
|
82
|
+
} else {
|
83
|
+
div.parentNode.removeChild(div);
|
84
|
+
}
|
85
|
+
|
86
|
+
return !!ret;
|
87
|
+
|
88
|
+
},
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
isEventSupported = (function() {
|
93
|
+
|
94
|
+
var TAGNAMES = {
|
95
|
+
'select': 'input', 'change': 'input',
|
96
|
+
'submit': 'form', 'reset': 'form',
|
97
|
+
'error': 'img', 'load': 'img', 'abort': 'img'
|
98
|
+
};
|
99
|
+
|
100
|
+
function isEventSupported( eventName, element ) {
|
101
|
+
|
102
|
+
element = element || document.createElement(TAGNAMES[eventName] || 'div');
|
103
|
+
eventName = 'on' + eventName;
|
104
|
+
|
105
|
+
var isSupported = eventName in element;
|
106
|
+
|
107
|
+
if ( !isSupported ) {
|
108
|
+
if ( !element.setAttribute ) {
|
109
|
+
element = document.createElement('div');
|
110
|
+
}
|
111
|
+
if ( element.setAttribute && element.removeAttribute ) {
|
112
|
+
element.setAttribute(eventName, '');
|
113
|
+
isSupported = is(element[eventName], 'function');
|
114
|
+
|
115
|
+
if ( !is(element[eventName], 'undefined') ) {
|
116
|
+
element[eventName] = undefined;
|
117
|
+
}
|
118
|
+
element.removeAttribute(eventName);
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
element = null;
|
123
|
+
return isSupported;
|
124
|
+
}
|
125
|
+
return isEventSupported;
|
126
|
+
})(),
|
127
|
+
|
128
|
+
|
129
|
+
_hasOwnProperty = ({}).hasOwnProperty, hasOwnProp;
|
130
|
+
|
131
|
+
if ( !is(_hasOwnProperty, 'undefined') && !is(_hasOwnProperty.call, 'undefined') ) {
|
132
|
+
hasOwnProp = function (object, property) {
|
133
|
+
return _hasOwnProperty.call(object, property);
|
134
|
+
};
|
135
|
+
}
|
136
|
+
else {
|
137
|
+
hasOwnProp = function (object, property) {
|
138
|
+
return ((property in object) && is(object.constructor.prototype[property], 'undefined'));
|
139
|
+
};
|
140
|
+
}
|
141
|
+
|
142
|
+
|
143
|
+
if (!Function.prototype.bind) {
|
144
|
+
Function.prototype.bind = function bind(that) {
|
145
|
+
|
146
|
+
var target = this;
|
147
|
+
|
148
|
+
if (typeof target != "function") {
|
149
|
+
throw new TypeError();
|
150
|
+
}
|
151
|
+
|
152
|
+
var args = slice.call(arguments, 1),
|
153
|
+
bound = function () {
|
154
|
+
|
155
|
+
if (this instanceof bound) {
|
156
|
+
|
157
|
+
var F = function(){};
|
158
|
+
F.prototype = target.prototype;
|
159
|
+
var self = new F();
|
160
|
+
|
161
|
+
var result = target.apply(
|
162
|
+
self,
|
163
|
+
args.concat(slice.call(arguments))
|
164
|
+
);
|
165
|
+
if (Object(result) === result) {
|
166
|
+
return result;
|
167
|
+
}
|
168
|
+
return self;
|
169
|
+
|
170
|
+
} else {
|
171
|
+
|
172
|
+
return target.apply(
|
173
|
+
that,
|
174
|
+
args.concat(slice.call(arguments))
|
175
|
+
);
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
};
|
180
|
+
|
181
|
+
return bound;
|
182
|
+
};
|
183
|
+
}
|
184
|
+
|
185
|
+
function setCss( str ) {
|
186
|
+
mStyle.cssText = str;
|
187
|
+
}
|
188
|
+
|
189
|
+
function setCssAll( str1, str2 ) {
|
190
|
+
return setCss(prefixes.join(str1 + ';') + ( str2 || '' ));
|
191
|
+
}
|
192
|
+
|
193
|
+
function is( obj, type ) {
|
194
|
+
return typeof obj === type;
|
195
|
+
}
|
196
|
+
|
197
|
+
function contains( str, substr ) {
|
198
|
+
return !!~('' + str).indexOf(substr);
|
199
|
+
}
|
200
|
+
|
201
|
+
function testProps( props, prefixed ) {
|
202
|
+
for ( var i in props ) {
|
203
|
+
var prop = props[i];
|
204
|
+
if ( !contains(prop, "-") && mStyle[prop] !== undefined ) {
|
205
|
+
return prefixed == 'pfx' ? prop : true;
|
206
|
+
}
|
207
|
+
}
|
208
|
+
return false;
|
209
|
+
}
|
210
|
+
|
211
|
+
function testDOMProps( props, obj, elem ) {
|
212
|
+
for ( var i in props ) {
|
213
|
+
var item = obj[props[i]];
|
214
|
+
if ( item !== undefined) {
|
215
|
+
|
216
|
+
if (elem === false) return props[i];
|
217
|
+
|
218
|
+
if (is(item, 'function')){
|
219
|
+
return item.bind(elem || obj);
|
220
|
+
}
|
221
|
+
|
222
|
+
return item;
|
223
|
+
}
|
224
|
+
}
|
225
|
+
return false;
|
226
|
+
}
|
227
|
+
|
228
|
+
function testPropsAll( prop, prefixed, elem ) {
|
229
|
+
|
230
|
+
var ucProp = prop.charAt(0).toUpperCase() + prop.slice(1),
|
231
|
+
props = (prop + ' ' + cssomPrefixes.join(ucProp + ' ') + ucProp).split(' ');
|
232
|
+
|
233
|
+
if(is(prefixed, "string") || is(prefixed, "undefined")) {
|
234
|
+
return testProps(props, prefixed);
|
235
|
+
|
236
|
+
} else {
|
237
|
+
props = (prop + ' ' + (domPrefixes).join(ucProp + ' ') + ucProp).split(' ');
|
238
|
+
return testDOMProps(props, prefixed, elem);
|
239
|
+
}
|
240
|
+
} tests['flexbox'] = function() {
|
241
|
+
return testPropsAll('flexWrap');
|
242
|
+
}; tests['canvas'] = function() {
|
243
|
+
var elem = document.createElement('canvas');
|
244
|
+
return !!(elem.getContext && elem.getContext('2d'));
|
245
|
+
};
|
246
|
+
|
247
|
+
tests['canvastext'] = function() {
|
248
|
+
return !!(Modernizr['canvas'] && is(document.createElement('canvas').getContext('2d').fillText, 'function'));
|
249
|
+
};
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
tests['webgl'] = function() {
|
254
|
+
return !!window.WebGLRenderingContext;
|
255
|
+
};
|
256
|
+
|
257
|
+
|
258
|
+
tests['touch'] = function() {
|
259
|
+
var bool;
|
260
|
+
|
261
|
+
if(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
|
262
|
+
bool = true;
|
263
|
+
} else {
|
264
|
+
injectElementWithStyles(['@media (',prefixes.join('touch-enabled),('),mod,')','{#modernizr{top:9px;position:absolute}}'].join(''), function( node ) {
|
265
|
+
bool = node.offsetTop === 9;
|
266
|
+
});
|
267
|
+
}
|
268
|
+
|
269
|
+
return bool;
|
270
|
+
};
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
tests['geolocation'] = function() {
|
275
|
+
return 'geolocation' in navigator;
|
276
|
+
};
|
277
|
+
|
278
|
+
|
279
|
+
tests['postmessage'] = function() {
|
280
|
+
return !!window.postMessage;
|
281
|
+
};
|
282
|
+
|
283
|
+
|
284
|
+
tests['websqldatabase'] = function() {
|
285
|
+
return !!window.openDatabase;
|
286
|
+
};
|
287
|
+
|
288
|
+
tests['indexedDB'] = function() {
|
289
|
+
return !!testPropsAll("indexedDB", window);
|
290
|
+
};
|
291
|
+
|
292
|
+
tests['hashchange'] = function() {
|
293
|
+
return isEventSupported('hashchange', window) && (document.documentMode === undefined || document.documentMode > 7);
|
294
|
+
};
|
295
|
+
|
296
|
+
tests['history'] = function() {
|
297
|
+
return !!(window.history && history.pushState);
|
298
|
+
};
|
299
|
+
|
300
|
+
tests['draganddrop'] = function() {
|
301
|
+
var div = document.createElement('div');
|
302
|
+
return ('draggable' in div) || ('ondragstart' in div && 'ondrop' in div);
|
303
|
+
};
|
304
|
+
|
305
|
+
tests['websockets'] = function() {
|
306
|
+
return 'WebSocket' in window || 'MozWebSocket' in window;
|
307
|
+
};
|
308
|
+
|
309
|
+
|
310
|
+
tests['rgba'] = function() {
|
311
|
+
setCss('background-color:rgba(150,255,150,.5)');
|
312
|
+
|
313
|
+
return contains(mStyle.backgroundColor, 'rgba');
|
314
|
+
};
|
315
|
+
|
316
|
+
tests['hsla'] = function() {
|
317
|
+
setCss('background-color:hsla(120,40%,100%,.5)');
|
318
|
+
|
319
|
+
return contains(mStyle.backgroundColor, 'rgba') || contains(mStyle.backgroundColor, 'hsla');
|
320
|
+
};
|
321
|
+
|
322
|
+
tests['multiplebgs'] = function() {
|
323
|
+
setCss('background:url(https://),url(https://),red url(https://)');
|
324
|
+
|
325
|
+
return (/(url\s*\(.*?){3}/).test(mStyle.background);
|
326
|
+
}; tests['backgroundsize'] = function() {
|
327
|
+
return testPropsAll('backgroundSize');
|
328
|
+
};
|
329
|
+
|
330
|
+
tests['borderimage'] = function() {
|
331
|
+
return testPropsAll('borderImage');
|
332
|
+
};
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
tests['borderradius'] = function() {
|
337
|
+
return testPropsAll('borderRadius');
|
338
|
+
};
|
339
|
+
|
340
|
+
tests['boxshadow'] = function() {
|
341
|
+
return testPropsAll('boxShadow');
|
342
|
+
};
|
343
|
+
|
344
|
+
tests['textshadow'] = function() {
|
345
|
+
return document.createElement('div').style.textShadow === '';
|
346
|
+
};
|
347
|
+
|
348
|
+
|
349
|
+
tests['opacity'] = function() {
|
350
|
+
setCssAll('opacity:.55');
|
351
|
+
|
352
|
+
return (/^0.55$/).test(mStyle.opacity);
|
353
|
+
};
|
354
|
+
|
355
|
+
|
356
|
+
tests['cssanimations'] = function() {
|
357
|
+
return testPropsAll('animationName');
|
358
|
+
};
|
359
|
+
|
360
|
+
|
361
|
+
tests['csscolumns'] = function() {
|
362
|
+
return testPropsAll('columnCount');
|
363
|
+
};
|
364
|
+
|
365
|
+
|
366
|
+
tests['cssgradients'] = function() {
|
367
|
+
var str1 = 'background-image:',
|
368
|
+
str2 = 'gradient(linear,left top,right bottom,from(#9f9),to(white));',
|
369
|
+
str3 = 'linear-gradient(left top,#9f9, white);';
|
370
|
+
|
371
|
+
setCss(
|
372
|
+
(str1 + '-webkit- '.split(' ').join(str2 + str1) +
|
373
|
+
prefixes.join(str3 + str1)).slice(0, -str1.length)
|
374
|
+
);
|
375
|
+
|
376
|
+
return contains(mStyle.backgroundImage, 'gradient');
|
377
|
+
};
|
378
|
+
|
379
|
+
|
380
|
+
tests['cssreflections'] = function() {
|
381
|
+
return testPropsAll('boxReflect');
|
382
|
+
};
|
383
|
+
|
384
|
+
|
385
|
+
tests['csstransforms'] = function() {
|
386
|
+
return !!testPropsAll('transform');
|
387
|
+
};
|
388
|
+
|
389
|
+
|
390
|
+
tests['csstransforms3d'] = function() {
|
391
|
+
|
392
|
+
var ret = !!testPropsAll('perspective');
|
393
|
+
|
394
|
+
if ( ret && 'webkitPerspective' in docElement.style ) {
|
395
|
+
|
396
|
+
injectElementWithStyles('@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}', function( node, rule ) {
|
397
|
+
ret = node.offsetLeft === 9 && node.offsetHeight === 3;
|
398
|
+
});
|
399
|
+
}
|
400
|
+
return ret;
|
401
|
+
};
|
402
|
+
|
403
|
+
|
404
|
+
tests['csstransitions'] = function() {
|
405
|
+
return testPropsAll('transition');
|
406
|
+
};
|
407
|
+
|
408
|
+
|
409
|
+
|
410
|
+
tests['fontface'] = function() {
|
411
|
+
var bool;
|
412
|
+
|
413
|
+
injectElementWithStyles('@font-face {font-family:"font";src:url("https://")}', function( node, rule ) {
|
414
|
+
var style = document.getElementById('smodernizr'),
|
415
|
+
sheet = style.sheet || style.styleSheet,
|
416
|
+
cssText = sheet ? (sheet.cssRules && sheet.cssRules[0] ? sheet.cssRules[0].cssText : sheet.cssText || '') : '';
|
417
|
+
|
418
|
+
bool = /src/i.test(cssText) && cssText.indexOf(rule.split(' ')[0]) === 0;
|
419
|
+
});
|
420
|
+
|
421
|
+
return bool;
|
422
|
+
};
|
423
|
+
|
424
|
+
tests['generatedcontent'] = function() {
|
425
|
+
var bool;
|
426
|
+
|
427
|
+
injectElementWithStyles(['#',mod,'{font:0/0 a}#',mod,':after{content:"',smile,'";visibility:hidden;font:3px/1 a}'].join(''), function( node ) {
|
428
|
+
bool = node.offsetHeight >= 3;
|
429
|
+
});
|
430
|
+
|
431
|
+
return bool;
|
432
|
+
};
|
433
|
+
tests['video'] = function() {
|
434
|
+
var elem = document.createElement('video'),
|
435
|
+
bool = false;
|
436
|
+
|
437
|
+
try {
|
438
|
+
if ( bool = !!elem.canPlayType ) {
|
439
|
+
bool = new Boolean(bool);
|
440
|
+
bool.ogg = elem.canPlayType('video/ogg; codecs="theora"') .replace(/^no$/,'');
|
441
|
+
|
442
|
+
bool.h264 = elem.canPlayType('video/mp4; codecs="avc1.42E01E"') .replace(/^no$/,'');
|
443
|
+
|
444
|
+
bool.webm = elem.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,'');
|
445
|
+
}
|
446
|
+
|
447
|
+
} catch(e) { }
|
448
|
+
|
449
|
+
return bool;
|
450
|
+
};
|
451
|
+
|
452
|
+
tests['audio'] = function() {
|
453
|
+
var elem = document.createElement('audio'),
|
454
|
+
bool = false;
|
455
|
+
|
456
|
+
try {
|
457
|
+
if ( bool = !!elem.canPlayType ) {
|
458
|
+
bool = new Boolean(bool);
|
459
|
+
bool.ogg = elem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,'');
|
460
|
+
bool.mp3 = elem.canPlayType('audio/mpeg;') .replace(/^no$/,'');
|
461
|
+
|
462
|
+
bool.wav = elem.canPlayType('audio/wav; codecs="1"') .replace(/^no$/,'');
|
463
|
+
bool.m4a = ( elem.canPlayType('audio/x-m4a;') ||
|
464
|
+
elem.canPlayType('audio/aac;')) .replace(/^no$/,'');
|
465
|
+
}
|
466
|
+
} catch(e) { }
|
467
|
+
|
468
|
+
return bool;
|
469
|
+
};
|
470
|
+
|
471
|
+
|
472
|
+
tests['localstorage'] = function() {
|
473
|
+
try {
|
474
|
+
localStorage.setItem(mod, mod);
|
475
|
+
localStorage.removeItem(mod);
|
476
|
+
return true;
|
477
|
+
} catch(e) {
|
478
|
+
return false;
|
479
|
+
}
|
480
|
+
};
|
481
|
+
|
482
|
+
tests['sessionstorage'] = function() {
|
483
|
+
try {
|
484
|
+
sessionStorage.setItem(mod, mod);
|
485
|
+
sessionStorage.removeItem(mod);
|
486
|
+
return true;
|
487
|
+
} catch(e) {
|
488
|
+
return false;
|
489
|
+
}
|
490
|
+
};
|
491
|
+
|
492
|
+
|
493
|
+
tests['webworkers'] = function() {
|
494
|
+
return !!window.Worker;
|
495
|
+
};
|
496
|
+
|
497
|
+
|
498
|
+
tests['applicationcache'] = function() {
|
499
|
+
return !!window.applicationCache;
|
500
|
+
};
|
501
|
+
|
502
|
+
|
503
|
+
tests['svg'] = function() {
|
504
|
+
return !!document.createElementNS && !!document.createElementNS(ns.svg, 'svg').createSVGRect;
|
505
|
+
};
|
506
|
+
|
507
|
+
tests['inlinesvg'] = function() {
|
508
|
+
var div = document.createElement('div');
|
509
|
+
div.innerHTML = '<svg/>';
|
510
|
+
return (div.firstChild && div.firstChild.namespaceURI) == ns.svg;
|
511
|
+
};
|
512
|
+
|
513
|
+
tests['smil'] = function() {
|
514
|
+
return !!document.createElementNS && /SVGAnimate/.test(toString.call(document.createElementNS(ns.svg, 'animate')));
|
515
|
+
};
|
516
|
+
|
517
|
+
|
518
|
+
tests['svgclippaths'] = function() {
|
519
|
+
return !!document.createElementNS && /SVGClipPath/.test(toString.call(document.createElementNS(ns.svg, 'clipPath')));
|
520
|
+
};
|
521
|
+
|
522
|
+
function webforms() {
|
523
|
+
Modernizr['input'] = (function( props ) {
|
524
|
+
for ( var i = 0, len = props.length; i < len; i++ ) {
|
525
|
+
attrs[ props[i] ] = !!(props[i] in inputElem);
|
526
|
+
}
|
527
|
+
if (attrs.list){
|
528
|
+
attrs.list = !!(document.createElement('datalist') && window.HTMLDataListElement);
|
529
|
+
}
|
530
|
+
return attrs;
|
531
|
+
})('autocomplete autofocus list placeholder max min multiple pattern required step'.split(' '));
|
532
|
+
Modernizr['inputtypes'] = (function(props) {
|
533
|
+
|
534
|
+
for ( var i = 0, bool, inputElemType, defaultView, len = props.length; i < len; i++ ) {
|
535
|
+
|
536
|
+
inputElem.setAttribute('type', inputElemType = props[i]);
|
537
|
+
bool = inputElem.type !== 'text';
|
538
|
+
|
539
|
+
if ( bool ) {
|
540
|
+
|
541
|
+
inputElem.value = smile;
|
542
|
+
inputElem.style.cssText = 'position:absolute;visibility:hidden;';
|
543
|
+
|
544
|
+
if ( /^range$/.test(inputElemType) && inputElem.style.WebkitAppearance !== undefined ) {
|
545
|
+
|
546
|
+
docElement.appendChild(inputElem);
|
547
|
+
defaultView = document.defaultView;
|
548
|
+
|
549
|
+
bool = defaultView.getComputedStyle &&
|
550
|
+
defaultView.getComputedStyle(inputElem, null).WebkitAppearance !== 'textfield' &&
|
551
|
+
(inputElem.offsetHeight !== 0);
|
552
|
+
|
553
|
+
docElement.removeChild(inputElem);
|
554
|
+
|
555
|
+
} else if ( /^(search|tel)$/.test(inputElemType) ){
|
556
|
+
} else if ( /^(url|email)$/.test(inputElemType) ) {
|
557
|
+
bool = inputElem.checkValidity && inputElem.checkValidity() === false;
|
558
|
+
|
559
|
+
} else {
|
560
|
+
bool = inputElem.value != smile;
|
561
|
+
}
|
562
|
+
}
|
563
|
+
|
564
|
+
inputs[ props[i] ] = !!bool;
|
565
|
+
}
|
566
|
+
return inputs;
|
567
|
+
})('search tel url email datetime date month week time datetime-local number range color'.split(' '));
|
568
|
+
}
|
569
|
+
for ( var feature in tests ) {
|
570
|
+
if ( hasOwnProp(tests, feature) ) {
|
571
|
+
featureName = feature.toLowerCase();
|
572
|
+
Modernizr[featureName] = tests[feature]();
|
573
|
+
|
574
|
+
classes.push((Modernizr[featureName] ? '' : 'no-') + featureName);
|
575
|
+
}
|
576
|
+
}
|
577
|
+
|
578
|
+
Modernizr.input || webforms();
|
579
|
+
|
580
|
+
|
581
|
+
Modernizr.addTest = function ( feature, test ) {
|
582
|
+
if ( typeof feature == 'object' ) {
|
583
|
+
for ( var key in feature ) {
|
584
|
+
if ( hasOwnProp( feature, key ) ) {
|
585
|
+
Modernizr.addTest( key, feature[ key ] );
|
586
|
+
}
|
587
|
+
}
|
588
|
+
} else {
|
589
|
+
|
590
|
+
feature = feature.toLowerCase();
|
591
|
+
|
592
|
+
if ( Modernizr[feature] !== undefined ) {
|
593
|
+
return Modernizr;
|
594
|
+
}
|
595
|
+
|
596
|
+
test = typeof test == 'function' ? test() : test;
|
597
|
+
|
598
|
+
if (typeof enableClasses !== "undefined" && enableClasses) {
|
599
|
+
docElement.className += ' ' + (test ? '' : 'no-') + feature;
|
600
|
+
}
|
601
|
+
Modernizr[feature] = test;
|
602
|
+
|
603
|
+
}
|
604
|
+
|
605
|
+
return Modernizr;
|
606
|
+
};
|
607
|
+
|
608
|
+
|
609
|
+
setCss('');
|
610
|
+
modElem = inputElem = null;
|
611
|
+
|
612
|
+
;(function(window, document) {
|
613
|
+
var options = window.html5 || {};
|
614
|
+
|
615
|
+
var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i;
|
616
|
+
|
617
|
+
var saveClones = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i;
|
618
|
+
|
619
|
+
var supportsHtml5Styles;
|
620
|
+
|
621
|
+
var expando = '_html5shiv';
|
622
|
+
|
623
|
+
var expanID = 0;
|
624
|
+
|
625
|
+
var expandoData = {};
|
626
|
+
|
627
|
+
var supportsUnknownElements;
|
628
|
+
|
629
|
+
(function() {
|
630
|
+
try {
|
631
|
+
var a = document.createElement('a');
|
632
|
+
a.innerHTML = '<xyz></xyz>';
|
633
|
+
supportsHtml5Styles = ('hidden' in a);
|
634
|
+
|
635
|
+
supportsUnknownElements = a.childNodes.length == 1 || (function() {
|
636
|
+
(document.createElement)('a');
|
637
|
+
var frag = document.createDocumentFragment();
|
638
|
+
return (
|
639
|
+
typeof frag.cloneNode == 'undefined' ||
|
640
|
+
typeof frag.createDocumentFragment == 'undefined' ||
|
641
|
+
typeof frag.createElement == 'undefined'
|
642
|
+
);
|
643
|
+
}());
|
644
|
+
} catch(e) {
|
645
|
+
supportsHtml5Styles = true;
|
646
|
+
supportsUnknownElements = true;
|
647
|
+
}
|
648
|
+
|
649
|
+
}()); function addStyleSheet(ownerDocument, cssText) {
|
650
|
+
var p = ownerDocument.createElement('p'),
|
651
|
+
parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement;
|
652
|
+
|
653
|
+
p.innerHTML = 'x<style>' + cssText + '</style>';
|
654
|
+
return parent.insertBefore(p.lastChild, parent.firstChild);
|
655
|
+
}
|
656
|
+
|
657
|
+
function getElements() {
|
658
|
+
var elements = html5.elements;
|
659
|
+
return typeof elements == 'string' ? elements.split(' ') : elements;
|
660
|
+
}
|
661
|
+
|
662
|
+
function getExpandoData(ownerDocument) {
|
663
|
+
var data = expandoData[ownerDocument[expando]];
|
664
|
+
if (!data) {
|
665
|
+
data = {};
|
666
|
+
expanID++;
|
667
|
+
ownerDocument[expando] = expanID;
|
668
|
+
expandoData[expanID] = data;
|
669
|
+
}
|
670
|
+
return data;
|
671
|
+
}
|
672
|
+
|
673
|
+
function createElement(nodeName, ownerDocument, data){
|
674
|
+
if (!ownerDocument) {
|
675
|
+
ownerDocument = document;
|
676
|
+
}
|
677
|
+
if(supportsUnknownElements){
|
678
|
+
return ownerDocument.createElement(nodeName);
|
679
|
+
}
|
680
|
+
if (!data) {
|
681
|
+
data = getExpandoData(ownerDocument);
|
682
|
+
}
|
683
|
+
var node;
|
684
|
+
|
685
|
+
if (data.cache[nodeName]) {
|
686
|
+
node = data.cache[nodeName].cloneNode();
|
687
|
+
} else if (saveClones.test(nodeName)) {
|
688
|
+
node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode();
|
689
|
+
} else {
|
690
|
+
node = data.createElem(nodeName);
|
691
|
+
}
|
692
|
+
|
693
|
+
return node.canHaveChildren && !reSkip.test(nodeName) ? data.frag.appendChild(node) : node;
|
694
|
+
}
|
695
|
+
|
696
|
+
function createDocumentFragment(ownerDocument, data){
|
697
|
+
if (!ownerDocument) {
|
698
|
+
ownerDocument = document;
|
699
|
+
}
|
700
|
+
if(supportsUnknownElements){
|
701
|
+
return ownerDocument.createDocumentFragment();
|
702
|
+
}
|
703
|
+
data = data || getExpandoData(ownerDocument);
|
704
|
+
var clone = data.frag.cloneNode(),
|
705
|
+
i = 0,
|
706
|
+
elems = getElements(),
|
707
|
+
l = elems.length;
|
708
|
+
for(;i<l;i++){
|
709
|
+
clone.createElement(elems[i]);
|
710
|
+
}
|
711
|
+
return clone;
|
712
|
+
}
|
713
|
+
|
714
|
+
function shivMethods(ownerDocument, data) {
|
715
|
+
if (!data.cache) {
|
716
|
+
data.cache = {};
|
717
|
+
data.createElem = ownerDocument.createElement;
|
718
|
+
data.createFrag = ownerDocument.createDocumentFragment;
|
719
|
+
data.frag = data.createFrag();
|
720
|
+
}
|
721
|
+
|
722
|
+
|
723
|
+
ownerDocument.createElement = function(nodeName) {
|
724
|
+
if (!html5.shivMethods) {
|
725
|
+
return data.createElem(nodeName);
|
726
|
+
}
|
727
|
+
return createElement(nodeName, ownerDocument, data);
|
728
|
+
};
|
729
|
+
|
730
|
+
ownerDocument.createDocumentFragment = Function('h,f', 'return function(){' +
|
731
|
+
'var n=f.cloneNode(),c=n.createElement;' +
|
732
|
+
'h.shivMethods&&(' +
|
733
|
+
getElements().join().replace(/\w+/g, function(nodeName) {
|
734
|
+
data.createElem(nodeName);
|
735
|
+
data.frag.createElement(nodeName);
|
736
|
+
return 'c("' + nodeName + '")';
|
737
|
+
}) +
|
738
|
+
');return n}'
|
739
|
+
)(html5, data.frag);
|
740
|
+
} function shivDocument(ownerDocument) {
|
741
|
+
if (!ownerDocument) {
|
742
|
+
ownerDocument = document;
|
743
|
+
}
|
744
|
+
var data = getExpandoData(ownerDocument);
|
745
|
+
|
746
|
+
if (html5.shivCSS && !supportsHtml5Styles && !data.hasCSS) {
|
747
|
+
data.hasCSS = !!addStyleSheet(ownerDocument,
|
748
|
+
'article,aside,figcaption,figure,footer,header,hgroup,nav,section{display:block}' +
|
749
|
+
'mark{background:#FF0;color:#000}'
|
750
|
+
);
|
751
|
+
}
|
752
|
+
if (!supportsUnknownElements) {
|
753
|
+
shivMethods(ownerDocument, data);
|
754
|
+
}
|
755
|
+
return ownerDocument;
|
756
|
+
} var html5 = {
|
757
|
+
|
758
|
+
'elements': options.elements || 'abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video',
|
759
|
+
|
760
|
+
'shivCSS': (options.shivCSS !== false),
|
761
|
+
|
762
|
+
'supportsUnknownElements': supportsUnknownElements,
|
763
|
+
|
764
|
+
'shivMethods': (options.shivMethods !== false),
|
765
|
+
|
766
|
+
'type': 'default',
|
767
|
+
|
768
|
+
'shivDocument': shivDocument,
|
769
|
+
|
770
|
+
createElement: createElement,
|
771
|
+
|
772
|
+
createDocumentFragment: createDocumentFragment
|
773
|
+
}; window.html5 = html5;
|
774
|
+
|
775
|
+
shivDocument(document);
|
776
|
+
|
777
|
+
}(this, document));
|
778
|
+
|
779
|
+
Modernizr._version = version;
|
780
|
+
|
781
|
+
Modernizr._prefixes = prefixes;
|
782
|
+
Modernizr._domPrefixes = domPrefixes;
|
783
|
+
Modernizr._cssomPrefixes = cssomPrefixes;
|
784
|
+
|
785
|
+
|
786
|
+
Modernizr.hasEvent = isEventSupported;
|
787
|
+
|
788
|
+
Modernizr.testProp = function(prop){
|
789
|
+
return testProps([prop]);
|
790
|
+
};
|
791
|
+
|
792
|
+
Modernizr.testAllProps = testPropsAll;
|
793
|
+
|
794
|
+
|
795
|
+
Modernizr.testStyles = injectElementWithStyles;
|
796
|
+
Modernizr.prefixed = function(prop, obj, elem){
|
797
|
+
if(!obj) {
|
798
|
+
return testPropsAll(prop, 'pfx');
|
799
|
+
} else {
|
800
|
+
return testPropsAll(prop, obj, elem);
|
801
|
+
}
|
802
|
+
};
|
803
|
+
|
804
|
+
|
805
|
+
docElement.className = docElement.className.replace(/(^|\s)no-js(\s|$)/, '$1$2') +
|
806
|
+
|
807
|
+
(enableClasses ? ' js ' + classes.join(' ') : '');
|
808
|
+
|
809
|
+
return Modernizr;
|
810
|
+
|
811
|
+
})(this, this.document);
|
812
|
+
/*yepnope1.5.4|WTFPL*/
|