2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
8 YUI.add('features', function(Y) {
10 var feature_tests = {};
12 Y.mix(Y.namespace('Features'), {
16 add: function(cat, name, o) {
17 feature_tests[cat] = feature_tests[cat] || {};
18 feature_tests[cat][name] = o;
21 all: function(cat, args) {
22 var cat_o = feature_tests[cat],
26 Y.Object.each(cat_o, function(v, k) {
27 // results[k] = Y.Features.test(cat, k, args);
29 (Y.Features.test(cat, k, args) ? 1 : 0) + ';';
36 test: function(cat, name, args) {
39 cat_o = feature_tests[cat],
40 feature = cat_o && cat_o[name];
45 result = feature.result;
47 if (Y.Lang.isUndefined(result)) {
55 if (test && ((!ua) || result)) {
56 result = test.apply(Y, args);
59 feature.result = result;
67 // Y.Features.add("load", "1", {});
68 // Y.Features.test("load", "1");
71 /* This file is auto-generated by src/loader/meta_join.py */
72 var add = Y.Features.add;
73 // autocomplete-list-keys-sniff.js
75 "test": function (Y) {
76 // Only add keyboard support to autocomplete-list if this doesn't appear to
77 // be an iOS or Android-based mobile device.
79 // There's currently no feasible way to actually detect whether a device has
80 // a hardware keyboard, so this sniff will have to do. It can easily be
81 // overridden by manually loading the autocomplete-list-keys module.
83 // Worth noting: even though iOS supports bluetooth keyboards, Mobile Safari
84 // doesn't fire the keyboard events used by AutoCompleteList, so there's
85 // no point loading the -keys module even when a bluetooth keyboard may be
87 return !(Y.UA.ios || Y.UA.android);
89 "trigger": "autocomplete-list"
93 "test": function (Y) {
95 var testFeature = Y.Features.test,
96 addFeature = Y.Features.add,
97 WINDOW = Y.config.win,
98 DOCUMENT = Y.config.doc,
99 DOCUMENT_ELEMENT = 'documentElement',
102 addFeature('style', 'computedStyle', {
104 return WINDOW && 'getComputedStyle' in WINDOW;
108 addFeature('style', 'opacity', {
110 return DOCUMENT && 'opacity' in DOCUMENT[DOCUMENT_ELEMENT].style;
114 ret = (!testFeature('style', 'opacity') &&
115 !testFeature('style', 'computedStyle'));
119 "trigger": "dom-style"
123 "trigger": "widget-base",
128 "test": function(Y) {
129 var imp = Y.config.doc && Y.config.doc.implementation;
130 return (imp && (!imp.hasFeature('Events', '2.0')));
132 "trigger": "node-base"
134 // dd-gestures-test.js
136 "test": function(Y) {
137 return (Y.config.win && ('ontouchstart' in Y.config.win && !Y.UA.chrome));
141 // history-hash-ie-test.js
143 "test": function (Y) {
144 var docMode = Y.config.doc.documentMode;
146 return Y.UA.ie && (!('onhashchange' in Y.config.win) ||
147 !docMode || docMode < 8);
149 "trigger": "history-hash"
153 }, '3.3.0' ,{requires:['yui-base']});