config Class
The config object contains all of the configuration options for
the YUI
instance. This object is supplied by the implementer
when instantiating a YUI
instance. Some properties have default
values if they are not supplied by the implementer. This should
not be updated directly because some values are cached. Use
applyConfig()
to update the config object on a YUI instance that
has already been configured.
Item Index
Methods
Properties
- 2in3
- aliases
- base
- bootstrap
- cacheUse
- combine
- comboBase
- core
- cssAttributes
- dateFormat
- debug
- doc
- errorFn
- fetchCSS
- filter
- filters
- force
- gallery
- groups
- ignore
- injected
- insertBefore
- jsAttributes
- lang
- loaderPath
- loadErrorFn
- locale
- logExclude
- logFn
- logInclude
- modules
- onCSS
- pollInterval
- purgethreshold
- requireRegistration
- root
- skin
- throwFail
- timeout
- useBrowserConsole
- useHistoryHTML5
- win
- windowResizeDelay
- yui2
Methods
useNativeES5
()
Whether or not YUI should use native ES5 functionality when available for
features like Y.Array.each()
, Y.Object()
, etc. When false
, YUI will
always use its own fallback implementations instead of relying on ES5
functionality, even when it's available.
Properties
2in3
String
The 2in3 project is a deployment of the various versions of YUI 2 deployed as first-class YUI 3 modules. Eventually, the wrapper for the modules will change (but the underlying YUI 2 code will be the same), and you can select a particular version of the wrapper modules via this config.
Default: 4
aliases
Object
Aliases are dynamic groups of modules that can be used as shortcuts.
YUI({
aliases: {
davglass: [ 'node', 'yql', 'dd' ],
mine: [ 'davglass', 'autocomplete']
}
}).use('mine', function(Y) {
//Node, YQL, DD & AutoComplete available here..
});
bootstrap
Boolean
Allows the YUI seed file to fetch the loader component and library metadata to dynamically load additional dependencies.
Default: true
combine
Boolean
Use the YUI combo service to reduce the number of http connections required to load your dependencies. Turning this off will disable combo handling for YUI and all module groups configured with a combo service.
For dynamic loading.
Default: true if 'base' is not supplied, false if it is.
comboBase
String
The YUI combo service base dir. Ex: http://yui.yahooapis.com/combo?
For dynamic loading.
core
Array
A list of modules that defines the YUI core (overrides the default list).
Default: [ get,features,intl-base,yui-log,yui-later,loader-base, loader-rollup, loader-yui3 ]
doc
Document
The document associated with the 'win' configuration.
Default: the document hosting YUI
errorFn
Function
A callback to execute when Y.error is called. It receives the
error message and an javascript error object if Y.error was
executed because a javascript error was caught. The function
is executed in the YUI instance context. Returning true
from this
function will stop the Error from being thrown.
fetchCSS
Boolean | String
Specifies whether or not YUI().use(...) will attempt to load CSS resources at all. Any truthy value will cause CSS dependencies to load when fetching script. The special value 'force' will cause CSS dependencies to be loaded even if no script is needed.
Default: true
filter
String | Object
A filter to apply to result urls. This filter will modify the default path for all modules. The default path for the YUI library is the minified version of the files (e.g., event-min.js). The filter property can be a predefined filter or a custom filter. The valid predefined filters are:
- DEBUG
- Selects the debug versions of the library (e.g., event-debug.js). This option will automatically include the Logger widget
- RAW
- Selects the non-minified version of the library (e.g., event.js).
You can also define a custom filter, which must be an object literal containing a search expression and a replace string:
myFilter: {
'searchExp': "-min\\.js",
'replaceStr': "-debug.js"
}
For dynamic loading.
filters
Unknown
Hash of per-component filter specification. If specified for a given component, this overrides the filter config.
For dynamic loading.
force
String[]
A list of modules that should always be loaded when required, even if already present on the page.
groups
Object
A hash of module group definitions. It for each group you can specify a list of modules and the base path and combo spec to use when dynamically loading the modules.
groups: {
yui2: {
// specify whether or not this group has a combo service
combine: true,
// The comboSeperator to use with this group's combo handler
comboSep: ';',
// The maxURLLength for this server
maxURLLength: 500,
// the base path for non-combo paths
base: 'http://yui.yahooapis.com/2.8.0r4/build/',
// the path to the combo service
comboBase: 'http://yui.yahooapis.com/combo?',
// a fragment to prepend to the path attribute when
// when building combo urls
root: '2.8.0r4/build/',
// the module definitions
modules: {
yui2_yde: {
path: "yahoo-dom-event/yahoo-dom-event.js"
},
yui2_anim: {
path: "animation/animation.js",
requires: ['yui2_yde']
}
}
}
}
injected
Boolean
Set to true if the yui seed file was dynamically loaded in
order to bootstrap components relying on the window load event
and the domready
custom event.
Default: false
insertBefore
String
Node or id for a node that should be used as the insertion point for new nodes. For dynamic loading.
lang
String | String[]
A list of languages in order of preference. This list is matched against the list of available languages in modules that the YUI instance uses to determine the best possible localization of language sensitive modules. Languages are represented using BCP 47 language tags, such as "en-GB" for English as used in the United Kingdom, or "zh-Hans-CN" for simplified Chinese as used in China. The list can be provided as a comma-separated list or as an array.
loaderPath
String
The loader 'path' attribute to the loader itself. This is combined with the 'base' attribute to dynamically load the loader component when boostrapping with the get utility alone.
Default: loader/loader-min.js
loadErrorFn
Function
A callback to execute when the loader fails to load one or more resource. This could be because of a script load failure. It can also fail if a javascript module fails to register itself, but only when the 'requireRegistration' is true. If this function is defined, the use() callback will only be called when the loader succeeds, otherwise it always executes unless there was a javascript error when attaching a module.
logExclude
Object
A hash of log sources that should be not be logged. If specified, all sources are logged if not on this list.
logFn
Function
Alternative console log function for use in environments without a supported native console. The function is executed in the YUI instance context.
logInclude
Object
A hash of log sources that should be logged. If specified, only log messages from these sources will be logged.
modules
Object
A hash of module definitions to add to the list of YUI components.
These components can then be dynamically loaded side by side with
YUI via the use()
method. This is a hash, the key is the module
name, and the value is an object literal specifying the metdata
for the module. See Loader.addModule
for the supported module
metadata fields. Also see groups, which provides a way to
configure the base and combo spec for a set of modules.
modules: {
mymod1: {
requires: ['node'],
fullpath: '/mymod1/mymod1.js'
},
mymod2: {
requires: ['mymod1'],
fullpath: '/mymod2/mymod2.js'
},
mymod3: '/js/mymod3.js',
mycssmod: '/css/mycssmod.css'
}
onCSS
Function
Callback for the 'CSSComplete' event. When dynamically loading YUI components with CSS, this property fires when the CSS is finished loading but script loading is still ongoing. This provides an opportunity to enhance the presentation of a loading page a little bit before the entire loading process is done.
pollInterval
Int
The default interval when polling in milliseconds.
Default: 20
purgethreshold
Int
The number of dynamic nodes to insert by default before automatically removing them. This applies to script nodes because removing the node will not make the evaluated script unavailable. Dynamic CSS is not auto purged, because removing a linked style sheet will also remove the style definitions.
Default: 20
requireRegistration
Boolean
When set to true, the YUI loader will expect that all modules it is responsible for loading will be first-class YUI modules that register themselves with the YUI global. If this is set to true, loader will fail if the module registration fails to happen after the script is loaded.
Default: false
root
String
The root path to prepend to module path for the combo service. Ex: 3.0.0b1/build/ For dynamic loading.
skin
Unknown
The skin
config let's you configure application level skin
customizations. It contains the following attributes which
can be specified to override the defaults:
// The default skin, which is automatically applied if not
// overriden by a component-specific skin definition.
// Change this in to apply a different skin globally
defaultSkin: 'sam',
// This is combined with the loader base property to get
// the default root directory for a skin.
base: 'assets/skins/',
// Any component-specific overrides can be specified here,
// making it possible to load different skins for different
// components. It is possible to load more than one skin
// for a given component as well.
overrides: {
slider: ['capsule', 'round']
}
For dynamic loading.
throwFail
Boolean
If throwFail
is set, Y.error
will generate or re-throw a JS Error.
Otherwise the failure is logged.
Default: true
timeout
Int
Number of milliseconds before a timeout occurs when dynamically loading nodes. If not set, there is no timeout.
useBrowserConsole
Boolean
Log to the browser console if debug is on and the browser has a supported console.
Default: true
useHistoryHTML5
Boolean
If true
, the Y.History
alias will always point to
Y.HistoryHTML5
when the history-html5 module is loaded, even if
the current browser doesn't support HTML5 history.
If false
, the Y.History
alias will always point to
Y.HistoryHash
when the history-hash module is loaded, even if
the current browser supports HTML5 history.
If neither true
nor false
, the
Y.History
alias will point to the best available history adapter
that the browser supports. This is the default behavior.
win
Window
The window/frame that this instance should operate in.
Default: the window hosting YUI
windowResizeDelay
Int
The default interval when polling in milliseconds.
Default: 40
yui2
String
The default YUI 2 version to build yui2 module urls. This is for intrinsic YUI 2 support via the 2in3 project. Also see the '2in3' config for pulling different revisions of the wrapped YUI 2 modules.
Default: 2.9.0