In order for the Modernizr API to be truly useful, other modules and themes need to integrate it. We've got a couple patched already but it will take a bigger effort to bring the level of automation I envision for this thing:
- Getting modules to implement
hook_modernizr_info()so they can declare their need for a specific Modernizr test. - Getting them to use
hook_modernizr_load()for supporting libs instead ofdrupal_add_js().
Example
The patch in #1935794-2: Move support for Modernizr into HTML5 submodule is a good example of what we need to tell them when requesting integration. It will be come easier as the list grows. Additionally, there's no need to include the 'source', 'type' or 'desc' parts in the hook anymore because I've moved all the metadata to a master list inside modernizr.args.inc, along with API changes for 3.1 that auto-detect which module or theme is supplying a test.
Official Docs for this process have been created
Here's the code from #1935794-2: Move support for Modernizr into HTML5 submodule
/**
* Implements hook_modernizr_info().
*/
function geolocation_html5_modernizr_info() {
$tests = array();
$tests[] = 'geolocation';
return $tests;
}
...or the shortest syntax possible (thanks @sreynen!)
/**
* Implements hook_modernizr_info().
*/
function geolocation_html5_modernizr_info() {
return array('geolocation');
}
Complete
Here is a list of modules and themes that already implement hook_modernizr_info().
Modules
- Geolocation HTML5 (dev) - #1935794: Move support for Modernizr into HTML5 submodule
- @font-your-face - #1946216: @font-your-face: Integration with Modernizr 7.x-3.x
- Dismiss (dev) - #1921760: Support Modernizr API 3.1
- Progressive Web App - 1.0 release will require
serviceworker
Themes
To-do
Let's work on implementing hook_modernizr_info() within these modules:
Modules
- Dynamic Background - Tests: backgroundsize, css_backgroundsizecover
- HTML5 tools - No issue yet - Tests:
inputtypes,shiv,printshiv - Respond.js - Tests: mq - Tests:
mq - Webform - No issue yet - Tests:
inputtypes - FlexSlider - No issue yet - Tests:
mq - Location - No issue yet - Tests:
geolocation - Geofield - No issue yet - Tests:
geolocation - Video - No issue yet - Tests:
video - VideoJS - No issue yet - Tests: none yet
- Breakpoints - No issue yet - Tests:
mq - MediaElement - No issue yet - Tests: none yet
- Superfish - #2331583: Add support for Modernizr Test API - Tests:
mq
Themes
Themes will declare tests within their info files. The syntax is very simple:
modernizr[tests][] = borderradius
This was blocked by #1923856: Extract Modernizr tests from themes, but if you download 7.x-3.x-dev (as of 2013-03-18) you can test theme integration just fine.
- AdaptiveTheme - No issue yet
- Mothership - No issue yet
- Omega 4.x - No issue yet
- Zen - No issue yet
- [insert your favorite theme here] - No issue yet
Comments
Comment #0.0
ruplUpdated issue summary.
Comment #0.1
ruplUpdated issue summary.
Comment #0.2
ruplUpdated issue summary based on issue #1923856 being opened
Comment #0.3
ruplUpdated issue summary.
Comment #0.4
iwuv commentedOpened feature request issue for @font-your-face and contributed patch. Edited this Modernizr meta issue with link to @font-your-face feature request issue.
Comment #0.5
ruplUpdated issue summary.
Comment #0.6
ruplUpdated issue summary to include example and reflect current state of issues in other queues.
Comment #0.7
ruplUpdated issue summary.
Comment #1
iwuv commentedWhich tests would be useful for HTML5 tools, Respond.js, and Webform?
I think Dynamic Background would benefit from a
background-sizetest. I'm assuming most people will want to usebackground-size: cover;and utilizing Modernizr will allow more in the way of presentation/fallback options.Comment #1.0
iwuv commentedUpdated issue summary.
Comment #1.1
ruplUpdated issue summary.
Comment #2
ruplHey Chad yes I think that module could benefit. Good thinking.
Just FYI the meat of the 3.1 API is in dev now. I have to clean some UI stuff up but it's stable and working with both the
fontyourfaceandgeolocation_html5modules.Comment #2.0
ruplUpdated issue summary.
Comment #2.1
ruplUpdated issue summary to include shortest syntax possible for hook. Updated supported/pending lists.
Comment #2.2
ruplUpdated issue summary to include Aurora
Comment #2.3
ruplUpdated issue summary adding dynamic background to module todos
Comment #3
ruplComment #4
ruplComment #5
ruplComment #6
rupl