[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 /* 2 YUI 3.17.2 (build 9c3c78e) 3 Copyright 2014 Yahoo! Inc. All rights reserved. 4 Licensed under the BSD License. 5 http://yuilibrary.com/license/ 6 */ 7 8 YUI.add('features', function (Y, NAME) { 9 10 var feature_tests = {}; 11 12 /** 13 Contains the core of YUI's feature test architecture. 14 @module features 15 */ 16 17 /** 18 * Feature detection 19 * @class Features 20 * @static 21 */ 22 23 Y.mix(Y.namespace('Features'), { 24 25 /** 26 * Object hash of all registered feature tests 27 * @property tests 28 * @type Object 29 */ 30 tests: feature_tests, 31 32 /** 33 * Add a test to the system 34 * 35 * ``` 36 * Y.Features.add("load", "1", {}); 37 * ``` 38 * 39 * @method add 40 * @param {String} cat The category, right now only 'load' is supported 41 * @param {String} name The number sequence of the test, how it's reported in the URL or config: 1, 2, 3 42 * @param {Object} o Object containing test properties 43 * @param {String} o.name The name of the test 44 * @param {Function} o.test The test function to execute, the only argument to the function is the `Y` instance 45 * @param {String} o.trigger The module that triggers this test. 46 */ 47 add: function(cat, name, o) { 48 feature_tests[cat] = feature_tests[cat] || {}; 49 feature_tests[cat][name] = o; 50 }, 51 /** 52 * Execute all tests of a given category and return the serialized results 53 * 54 * ``` 55 * caps=1:1;2:1;3:0 56 * ``` 57 * @method all 58 * @param {String} cat The category to execute 59 * @param {Array} args The arguments to pass to the test function 60 * @return {String} A semi-colon separated string of tests and their success/failure: 1:1;2:1;3:0 61 */ 62 all: function(cat, args) { 63 var cat_o = feature_tests[cat], 64 // results = {}; 65 result = []; 66 if (cat_o) { 67 Y.Object.each(cat_o, function(v, k) { 68 result.push(k + ':' + (Y.Features.test(cat, k, args) ? 1 : 0)); 69 }); 70 } 71 72 return (result.length) ? result.join(';') : ''; 73 }, 74 /** 75 * Run a specific test and return a Boolean response. 76 * 77 * ``` 78 * Y.Features.test("load", "1"); 79 * ``` 80 * 81 * @method test 82 * @param {String} cat The category of the test to run 83 * @param {String} name The name of the test to run 84 * @param {Array} args The arguments to pass to the test function 85 * @return {Boolean} True or false if the test passed/failed. 86 */ 87 test: function(cat, name, args) { 88 args = args || []; 89 var result, ua, test, 90 cat_o = feature_tests[cat], 91 feature = cat_o && cat_o[name]; 92 93 if (!feature) { 94 } else { 95 96 result = feature.result; 97 98 if (Y.Lang.isUndefined(result)) { 99 100 ua = feature.ua; 101 if (ua) { 102 result = (Y.UA[ua]); 103 } 104 105 test = feature.test; 106 if (test && ((!ua) || result)) { 107 result = test.apply(Y, args); 108 } 109 110 feature.result = result; 111 } 112 } 113 114 return result; 115 } 116 }); 117 118 // Y.Features.add("load", "1", {}); 119 // Y.Features.test("load", "1"); 120 // caps=1:1;2:0;3:1; 121 122 /* This file is auto-generated by (yogi.js loader --mix --yes) */ 123 /*jshint maxlen:900, eqeqeq: false */ 124 var add = Y.Features.add; 125 // app-transitions-native 126 add('load', '0', { 127 "name": "app-transitions-native", 128 "test": function (Y) { 129 var doc = Y.config.doc, 130 node = doc ? doc.documentElement : null; 131 132 if (node && node.style) { 133 return ('MozTransition' in node.style || 'WebkitTransition' in node.style || 'transition' in node.style); 134 } 135 136 return false; 137 }, 138 "trigger": "app-transitions" 139 }); 140 // autocomplete-list-keys 141 add('load', '1', { 142 "name": "autocomplete-list-keys", 143 "test": function (Y) { 144 // Only add keyboard support to autocomplete-list if this doesn't appear to 145 // be an iOS or Android-based mobile device. 146 // 147 // There's currently no feasible way to actually detect whether a device has 148 // a hardware keyboard, so this sniff will have to do. It can easily be 149 // overridden by manually loading the autocomplete-list-keys module. 150 // 151 // Worth noting: even though iOS supports bluetooth keyboards, Mobile Safari 152 // doesn't fire the keyboard events used by AutoCompleteList, so there's 153 // no point loading the -keys module even when a bluetooth keyboard may be 154 // available. 155 return !(Y.UA.ios || Y.UA.android); 156 }, 157 "trigger": "autocomplete-list" 158 }); 159 // dd-gestures 160 add('load', '2', { 161 "name": "dd-gestures", 162 "trigger": "dd-drag", 163 "ua": "touchEnabled" 164 }); 165 // dom-style-ie 166 add('load', '3', { 167 "name": "dom-style-ie", 168 "test": function (Y) { 169 170 var testFeature = Y.Features.test, 171 addFeature = Y.Features.add, 172 WINDOW = Y.config.win, 173 DOCUMENT = Y.config.doc, 174 DOCUMENT_ELEMENT = 'documentElement', 175 ret = false; 176 177 addFeature('style', 'computedStyle', { 178 test: function() { 179 return WINDOW && 'getComputedStyle' in WINDOW; 180 } 181 }); 182 183 addFeature('style', 'opacity', { 184 test: function() { 185 return DOCUMENT && 'opacity' in DOCUMENT[DOCUMENT_ELEMENT].style; 186 } 187 }); 188 189 ret = (!testFeature('style', 'opacity') && 190 !testFeature('style', 'computedStyle')); 191 192 return ret; 193 }, 194 "trigger": "dom-style" 195 }); 196 // editor-para-ie 197 add('load', '4', { 198 "name": "editor-para-ie", 199 "trigger": "editor-para", 200 "ua": "ie", 201 "when": "instead" 202 }); 203 // event-base-ie 204 add('load', '5', { 205 "name": "event-base-ie", 206 "test": function(Y) { 207 var imp = Y.config.doc && Y.config.doc.implementation; 208 return (imp && (!imp.hasFeature('Events', '2.0'))); 209 }, 210 "trigger": "node-base" 211 }); 212 // graphics-canvas 213 add('load', '6', { 214 "name": "graphics-canvas", 215 "test": function(Y) { 216 var DOCUMENT = Y.config.doc, 217 useCanvas = Y.config.defaultGraphicEngine && Y.config.defaultGraphicEngine == "canvas", 218 canvas = DOCUMENT && DOCUMENT.createElement("canvas"), 219 svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1")); 220 return (!svg || useCanvas) && (canvas && canvas.getContext && canvas.getContext("2d")); 221 }, 222 "trigger": "graphics" 223 }); 224 // graphics-canvas-default 225 add('load', '7', { 226 "name": "graphics-canvas-default", 227 "test": function(Y) { 228 var DOCUMENT = Y.config.doc, 229 useCanvas = Y.config.defaultGraphicEngine && Y.config.defaultGraphicEngine == "canvas", 230 canvas = DOCUMENT && DOCUMENT.createElement("canvas"), 231 svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1")); 232 return (!svg || useCanvas) && (canvas && canvas.getContext && canvas.getContext("2d")); 233 }, 234 "trigger": "graphics" 235 }); 236 // graphics-svg 237 add('load', '8', { 238 "name": "graphics-svg", 239 "test": function(Y) { 240 var DOCUMENT = Y.config.doc, 241 useSVG = !Y.config.defaultGraphicEngine || Y.config.defaultGraphicEngine != "canvas", 242 canvas = DOCUMENT && DOCUMENT.createElement("canvas"), 243 svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1")); 244 245 return svg && (useSVG || !canvas); 246 }, 247 "trigger": "graphics" 248 }); 249 // graphics-svg-default 250 add('load', '9', { 251 "name": "graphics-svg-default", 252 "test": function(Y) { 253 var DOCUMENT = Y.config.doc, 254 useSVG = !Y.config.defaultGraphicEngine || Y.config.defaultGraphicEngine != "canvas", 255 canvas = DOCUMENT && DOCUMENT.createElement("canvas"), 256 svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1")); 257 258 return svg && (useSVG || !canvas); 259 }, 260 "trigger": "graphics" 261 }); 262 // graphics-vml 263 add('load', '10', { 264 "name": "graphics-vml", 265 "test": function(Y) { 266 var DOCUMENT = Y.config.doc, 267 canvas = DOCUMENT && DOCUMENT.createElement("canvas"); 268 return (DOCUMENT && !DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") && (!canvas || !canvas.getContext || !canvas.getContext("2d"))); 269 }, 270 "trigger": "graphics" 271 }); 272 // graphics-vml-default 273 add('load', '11', { 274 "name": "graphics-vml-default", 275 "test": function(Y) { 276 var DOCUMENT = Y.config.doc, 277 canvas = DOCUMENT && DOCUMENT.createElement("canvas"); 278 return (DOCUMENT && !DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") && (!canvas || !canvas.getContext || !canvas.getContext("2d"))); 279 }, 280 "trigger": "graphics" 281 }); 282 // history-hash-ie 283 add('load', '12', { 284 "name": "history-hash-ie", 285 "test": function (Y) { 286 var docMode = Y.config.doc && Y.config.doc.documentMode; 287 288 return Y.UA.ie && (!('onhashchange' in Y.config.win) || 289 !docMode || docMode < 8); 290 }, 291 "trigger": "history-hash" 292 }); 293 // io-nodejs 294 add('load', '13', { 295 "name": "io-nodejs", 296 "trigger": "io-base", 297 "ua": "nodejs" 298 }); 299 // json-parse-shim 300 add('load', '14', { 301 "name": "json-parse-shim", 302 "test": function (Y) { 303 var _JSON = Y.config.global.JSON, 304 Native = Object.prototype.toString.call(_JSON) === '[object JSON]' && _JSON, 305 nativeSupport = Y.config.useNativeJSONParse !== false && !!Native; 306 307 function workingNative( k, v ) { 308 return k === "ok" ? true : v; 309 } 310 311 // Double check basic functionality. This is mainly to catch early broken 312 // implementations of the JSON API in Firefox 3.1 beta1 and beta2 313 if ( nativeSupport ) { 314 try { 315 nativeSupport = ( Native.parse( '{"ok":false}', workingNative ) ).ok; 316 } 317 catch ( e ) { 318 nativeSupport = false; 319 } 320 } 321 322 return !nativeSupport; 323 }, 324 "trigger": "json-parse" 325 }); 326 // json-stringify-shim 327 add('load', '15', { 328 "name": "json-stringify-shim", 329 "test": function (Y) { 330 var _JSON = Y.config.global.JSON, 331 Native = Object.prototype.toString.call(_JSON) === '[object JSON]' && _JSON, 332 nativeSupport = Y.config.useNativeJSONStringify !== false && !!Native; 333 334 // Double check basic native functionality. This is primarily to catch broken 335 // early JSON API implementations in Firefox 3.1 beta1 and beta2. 336 if ( nativeSupport ) { 337 try { 338 nativeSupport = ( '0' === Native.stringify(0) ); 339 } catch ( e ) { 340 nativeSupport = false; 341 } 342 } 343 344 345 return !nativeSupport; 346 }, 347 "trigger": "json-stringify" 348 }); 349 // scrollview-base-ie 350 add('load', '16', { 351 "name": "scrollview-base-ie", 352 "trigger": "scrollview-base", 353 "ua": "ie" 354 }); 355 // selector-css2 356 add('load', '17', { 357 "name": "selector-css2", 358 "test": function (Y) { 359 var DOCUMENT = Y.config.doc, 360 ret = DOCUMENT && !('querySelectorAll' in DOCUMENT); 361 362 return ret; 363 }, 364 "trigger": "selector" 365 }); 366 // transition-timer 367 add('load', '18', { 368 "name": "transition-timer", 369 "test": function (Y) { 370 var DOCUMENT = Y.config.doc, 371 node = (DOCUMENT) ? DOCUMENT.documentElement: null, 372 ret = true; 373 374 if (node && node.style) { 375 ret = !('MozTransition' in node.style || 'WebkitTransition' in node.style || 'transition' in node.style); 376 } 377 378 return ret; 379 }, 380 "trigger": "transition" 381 }); 382 // widget-base-ie 383 add('load', '19', { 384 "name": "widget-base-ie", 385 "trigger": "widget-base", 386 "ua": "ie" 387 }); 388 // yql-jsonp 389 add('load', '20', { 390 "name": "yql-jsonp", 391 "test": function (Y) { 392 /* Only load the JSONP module when not in nodejs or winjs 393 TODO Make the winjs module a CORS module 394 */ 395 return (!Y.UA.nodejs && !Y.UA.winjs); 396 }, 397 "trigger": "yql" 398 }); 399 // yql-nodejs 400 add('load', '21', { 401 "name": "yql-nodejs", 402 "trigger": "yql", 403 "ua": "nodejs" 404 }); 405 // yql-winjs 406 add('load', '22', { 407 "name": "yql-winjs", 408 "trigger": "yql", 409 "ua": "winjs" 410 }); 411 412 }, '3.17.2', {"requires": ["yui-base"]});
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |