modernizr

Different methods based on Modernizr: click vs hover

家住魔仙堡 提交于 2019-12-11 13:06:41
问题 I want to be able to choose between .mouseover and .click events based on Modernizr's touch/no-touch output. if (Modernizr.touch) { $(el).click(stuff); $(el).click(stuff); } else { $(el).mouseover(stuff); $(el).mouseover(stuff); } But I don't want to write out all that stuff twice. Is it possible to define something so that I can just call: if (Modernizr.touch) {correctEvent = click} else {correctEvent = mouseover} $(el).correctEvent(stuff); $(el).correctEvent(stuff); 回答1: Yes, this is easy

Full list of possible classnames added by Modernizr?

丶灬走出姿态 提交于 2019-12-11 12:39:20
问题 Where can I find such a full list? I can tell there are .js and .no-js , .touch and .no-touch. But .opacity -- is there .no-opacity or just missing .opacity means no support? This is just an example. A full list helps me a lot in writing code for those devices that I don't have. 回答1: All Modernizr detects will add .<feature> if supported and .no-<feature> if not. The set of detects depends on the custom build settings you chose in the downloader. In the source of every Modernizr build, there

Modernizr load [A, B] seems to execute B before A, how is this possible?

此生再无相见时 提交于 2019-12-11 02:16:03
问题 Modernizr.load({ both: [a, b] }) seems to executes b before a but that's not how Modernizr is supposed to work? "yepnope.js [used by Modernizr] always executes things in the order they are listed" Modernizr versions 2.5.3 and 2.6.2. I'm loading angular.js and angular-sanitize.js like so: Modernizr.load({ both: [ cdnDir + 'angular.js', cdnDir + 'angular-sanitize.js', d.i.assetsUrlPathStart + 'debiki-dashbar.js'], complete: bootstrapAngular }) However, infrequently, angular-sanitize.js dies

modernizr check for grayscale filters IE 10

蹲街弑〆低调 提交于 2019-12-11 00:28:16
问题 IE 10 does not support DX filters (yeaaaay) I'm currently using $.browser to detect IE 10 and implement the svg solution. However the $.browser is deprecated and will be removed or is already removed (Yeaaaay again!!!!). So, what is modernizr's alternative for $.browser in this case? filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0

Loading Scripts Using Modernizr… Not Working

╄→гoц情女王★ 提交于 2019-12-10 18:15:08
问题 I'm having problems trying to load scripts using the Modernizr version of yepnope and can't get my head around why they are different. If I load the scripts using yep nope it works fine: <script type="text/javascript" src="/js/yepnope.1.0.2-min.js"></script> <script type="text/javascript"> yepnope([ '/js/fancy-box-2.0.4/jquery.fancybox.css', '/js/jquery-1.7.min.js', '/js/jquery.form-defaults.js', '/js/jquery.cycle.all.js', '/js/jquery.easing.1.3.js', '/js/fancy-box-2.0.4/jquery.fancybox.js',

Is there a way to set up a fallback for the <input> formAction attribute in HTML5?

只谈情不闲聊 提交于 2019-12-10 15:22:50
问题 I have a form that is supposed to dynamically change where it is submitted to. I am doing this by bringing in a submit button using ajax that has the formAction attribute set to where I want the form to submit to (I'm bringing in a number of other things as well that are dependent on the user input, but as far as I can tell have no bearing on this question). Here's an example of my submit button: <input type="submit" value="Edit" name="save" id="save" formAction="http://example.com" /> The

Is Modernizr.load (Yepnope) meant to be used in the <head>

别说谁变了你拦得住时间么 提交于 2019-12-10 09:34:59
问题 Since Modernizr.load and Yepnope are asynchronous loaders, is it better performance-wise to use them in the <head> or at the end of the page? 回答1: It depends on the resources being loaded. See this thread where Yepnope developer Alex Sexton says to combine all the resources into one call to the loader. In practice, if any of the resources you want to load with Modernizr.load or Yepnope affect what the user sees or needs when the page first loads, then IMO in most cases you want to call the

Can modernizr load scripts asynchronously but execute them in order?

时光总嘲笑我的痴心妄想 提交于 2019-12-10 04:19:00
问题 I'm experimenting with Modernizer.load. I have this: Modernizr.load([ { load : ['/js/jquery-1.6.1.js', '/js/jquery.tools.min.js', '/js/myscript.js'] } ]); If I understand correctly, I can use code like this to load scripts asynchronously. However, can I then execute them in order? What if myscript.js requires the jquery object to be loaded first? In the example in the modernizr documentation, load([]) can take a 'complete' property, the parameter of which can be a function that can load

Remove all hover effects through css

徘徊边缘 提交于 2019-12-10 02:30:54
问题 When I come down on touch devices I don't want the hover behavior. Is it possible to disable all hover effects at once for a whole website? Given that you use Modernizr to detect touch and set the class. This is what I came up with but it gives a lot of inconsistency: html.touch *:hover { color: inherit !important; background: inherit !important; } Is there a way to do this with pure CSS? If not, how can it be done with javascript? 回答1: This is good but not supported very well: html.touch *

RequireJS: Conditionally Load Polyfill Using Modernizr

久未见 提交于 2019-12-10 00:16:26
问题 How do you wrap a polyfill script as an AMD module and conditionally load it using Modernizr and RequireJS? (Figured it out while I was drafting my question - posting answer for anyone else trying to do the same thing.) 回答1: The polyfill I needed to load was jquery-placeholder for browsers that don't support input placeholders. It does not provide AMD support out of the box. First I wrapped it as an AMD module like this: define(['jquery'], function ($) { (function(window, document, $) { ...