1
YUI.add('features', function (Y, NAME) {
3
var feature_tests = {};
6
Contains the core of YUI's feature test architecture.
16
Y.mix(Y.namespace('Features'), {
19
* Object hash of all registered feature tests
26
* Add a test to the system
29
* Y.Features.add("load", "1", {});
33
* @param {String} cat The category, right now only 'load' is supported
34
* @param {String} name The number sequence of the test, how it's reported in the URL or config: 1, 2, 3
35
* @param {Object} o Object containing test properties
36
* @param {String} o.name The name of the test
37
* @param {Function} o.test The test function to execute, the only argument to the function is the `Y` instance
38
* @param {String} o.trigger The module that triggers this test.
40
add: function(cat, name, o) {
41
feature_tests[cat] = feature_tests[cat] || {};
42
feature_tests[cat][name] = o;
45
* Execute all tests of a given category and return the serialized results
51
* @param {String} cat The category to execute
52
* @param {Array} args The arguments to pass to the test function
53
* @return {String} A semi-colon separated string of tests and their success/failure: 1:1;2:1;3:0
55
all: function(cat, args) {
56
var cat_o = feature_tests[cat],
60
Y.Object.each(cat_o, function(v, k) {
61
result.push(k + ':' + (Y.Features.test(cat, k, args) ? 1 : 0));
65
return (result.length) ? result.join(';') : '';
68
* Run a sepecific test and return a Boolean response.
71
* Y.Features.test("load", "1");
75
* @param {String} cat The category of the test to run
76
* @param {String} name The name of the test to run
77
* @param {Array} args The arguments to pass to the test function
78
* @return {Boolean} True or false if the test passed/failed.
80
test: function(cat, name, args) {
83
cat_o = feature_tests[cat],
84
feature = cat_o && cat_o[name];
89
result = feature.result;
91
if (Y.Lang.isUndefined(result)) {
99
if (test && ((!ua) || result)) {
100
result = test.apply(Y, args);
103
feature.result = result;
111
// Y.Features.add("load", "1", {});
112
// Y.Features.test("load", "1");
115
/* This file is auto-generated by (yogi loader --yes --mix --start ../) */
116
/*jshint maxlen:900, eqeqeq: false */
117
var add = Y.Features.add;
118
// app-transitions-native
120
"name": "app-transitions-native",
121
"test": function (Y) {
122
var doc = Y.config.doc,
123
node = doc ? doc.documentElement : null;
125
if (node && node.style) {
126
return ('MozTransition' in node.style || 'WebkitTransition' in node.style || 'transition' in node.style);
131
"trigger": "app-transitions"
133
// autocomplete-list-keys
135
"name": "autocomplete-list-keys",
136
"test": function (Y) {
137
// Only add keyboard support to autocomplete-list if this doesn't appear to
138
// be an iOS or Android-based mobile device.
140
// There's currently no feasible way to actually detect whether a device has
141
// a hardware keyboard, so this sniff will have to do. It can easily be
142
// overridden by manually loading the autocomplete-list-keys module.
144
// Worth noting: even though iOS supports bluetooth keyboards, Mobile Safari
145
// doesn't fire the keyboard events used by AutoCompleteList, so there's
146
// no point loading the -keys module even when a bluetooth keyboard may be
148
return !(Y.UA.ios || Y.UA.android);
150
"trigger": "autocomplete-list"
154
"name": "dd-gestures",
155
"trigger": "dd-drag",
160
"name": "dom-style-ie",
161
"test": function (Y) {
163
var testFeature = Y.Features.test,
164
addFeature = Y.Features.add,
165
WINDOW = Y.config.win,
166
DOCUMENT = Y.config.doc,
167
DOCUMENT_ELEMENT = 'documentElement',
170
addFeature('style', 'computedStyle', {
172
return WINDOW && 'getComputedStyle' in WINDOW;
176
addFeature('style', 'opacity', {
178
return DOCUMENT && 'opacity' in DOCUMENT[DOCUMENT_ELEMENT].style;
182
ret = (!testFeature('style', 'opacity') &&
183
!testFeature('style', 'computedStyle'));
187
"trigger": "dom-style"
191
"name": "editor-para-ie",
192
"trigger": "editor-para",
198
"name": "event-base-ie",
199
"test": function(Y) {
200
var imp = Y.config.doc && Y.config.doc.implementation;
201
return (imp && (!imp.hasFeature('Events', '2.0')));
203
"trigger": "node-base"
207
"name": "graphics-canvas",
208
"test": function(Y) {
209
var DOCUMENT = Y.config.doc,
210
useCanvas = Y.config.defaultGraphicEngine && Y.config.defaultGraphicEngine == "canvas",
211
canvas = DOCUMENT && DOCUMENT.createElement("canvas"),
212
svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"));
213
return (!svg || useCanvas) && (canvas && canvas.getContext && canvas.getContext("2d"));
215
"trigger": "graphics"
217
// graphics-canvas-default
219
"name": "graphics-canvas-default",
220
"test": function(Y) {
221
var DOCUMENT = Y.config.doc,
222
useCanvas = Y.config.defaultGraphicEngine && Y.config.defaultGraphicEngine == "canvas",
223
canvas = DOCUMENT && DOCUMENT.createElement("canvas"),
224
svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"));
225
return (!svg || useCanvas) && (canvas && canvas.getContext && canvas.getContext("2d"));
227
"trigger": "graphics"
231
"name": "graphics-svg",
232
"test": function(Y) {
233
var DOCUMENT = Y.config.doc,
234
useSVG = !Y.config.defaultGraphicEngine || Y.config.defaultGraphicEngine != "canvas",
235
canvas = DOCUMENT && DOCUMENT.createElement("canvas"),
236
svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"));
238
return svg && (useSVG || !canvas);
240
"trigger": "graphics"
242
// graphics-svg-default
244
"name": "graphics-svg-default",
245
"test": function(Y) {
246
var DOCUMENT = Y.config.doc,
247
useSVG = !Y.config.defaultGraphicEngine || Y.config.defaultGraphicEngine != "canvas",
248
canvas = DOCUMENT && DOCUMENT.createElement("canvas"),
249
svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"));
251
return svg && (useSVG || !canvas);
253
"trigger": "graphics"
257
"name": "graphics-vml",
258
"test": function(Y) {
259
var DOCUMENT = Y.config.doc,
260
canvas = DOCUMENT && DOCUMENT.createElement("canvas");
261
return (DOCUMENT && !DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") && (!canvas || !canvas.getContext || !canvas.getContext("2d")));
263
"trigger": "graphics"
265
// graphics-vml-default
267
"name": "graphics-vml-default",
268
"test": function(Y) {
269
var DOCUMENT = Y.config.doc,
270
canvas = DOCUMENT && DOCUMENT.createElement("canvas");
271
return (DOCUMENT && !DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") && (!canvas || !canvas.getContext || !canvas.getContext("2d")));
273
"trigger": "graphics"
277
"name": "history-hash-ie",
278
"test": function (Y) {
279
var docMode = Y.config.doc && Y.config.doc.documentMode;
281
return Y.UA.ie && (!('onhashchange' in Y.config.win) ||
282
!docMode || docMode < 8);
284
"trigger": "history-hash"
289
"trigger": "io-base",
294
"name": "json-parse-shim",
295
"test": function (Y) {
296
var _JSON = Y.config.global.JSON,
297
Native = Object.prototype.toString.call(_JSON) === '[object JSON]' && _JSON,
298
nativeSupport = Y.config.useNativeJSONParse !== false && !!Native;
300
function workingNative( k, v ) {
301
return k === "ok" ? true : v;
304
// Double check basic functionality. This is mainly to catch early broken
305
// implementations of the JSON API in Firefox 3.1 beta1 and beta2
306
if ( nativeSupport ) {
308
nativeSupport = ( Native.parse( '{"ok":false}', workingNative ) ).ok;
311
nativeSupport = false;
315
return !nativeSupport;
317
"trigger": "json-parse"
319
// json-stringify-shim
321
"name": "json-stringify-shim",
322
"test": function (Y) {
323
var _JSON = Y.config.global.JSON,
324
Native = Object.prototype.toString.call(_JSON) === '[object JSON]' && _JSON,
325
nativeSupport = Y.config.useNativeJSONStringify !== false && !!Native;
327
// Double check basic native functionality. This is primarily to catch broken
328
// early JSON API implementations in Firefox 3.1 beta1 and beta2.
329
if ( nativeSupport ) {
331
nativeSupport = ( '0' === Native.stringify(0) );
333
nativeSupport = false;
338
return !nativeSupport;
340
"trigger": "json-stringify"
342
// scrollview-base-ie
344
"name": "scrollview-base-ie",
345
"trigger": "scrollview-base",
350
"name": "selector-css2",
351
"test": function (Y) {
352
var DOCUMENT = Y.config.doc,
353
ret = DOCUMENT && !('querySelectorAll' in DOCUMENT);
357
"trigger": "selector"
361
"name": "transition-timer",
362
"test": function (Y) {
363
var DOCUMENT = Y.config.doc,
364
node = (DOCUMENT) ? DOCUMENT.documentElement: null,
367
if (node && node.style) {
368
ret = !('MozTransition' in node.style || 'WebkitTransition' in node.style || 'transition' in node.style);
373
"trigger": "transition"
377
"name": "widget-base-ie",
378
"trigger": "widget-base",
384
"test": function (Y) {
385
/* Only load the JSONP module when not in nodejs or winjs
386
TODO Make the winjs module a CORS module
388
return (!Y.UA.nodejs && !Y.UA.winjs);
395
"name": "yql-nodejs",
408
}, '@VERSION@', {"requires": ["yui-base"]});