/* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ /** The YUI module contains the components required for building the YUI seed file. This includes the script loading mechanism, a simple queue, and the core utilities for the library. @module yui @main yui @submodule yui-base **/ /*jshint eqeqeq: false*/ if (typeof YUI != 'undefined') { YUI._YUI = YUI; } /** The YUI global namespace object. This is the constructor for all YUI instances. This is a self-instantiable factory function, meaning you don't need to precede it with the `new` operator. You can invoke it directly like this: YUI().use('*', function (Y) { // Y is a new YUI instance. }); But it also works like this: var Y = YUI(); The `YUI` constructor accepts an optional config object, like this: YUI({ debug: true, combine: false }).use('node', function (Y) { // Y.Node is ready to use. }); See the API docs for the Config class for the complete list of supported configuration properties accepted by the YUI constuctor. If a global `YUI` object is already defined, the existing YUI object will not be overwritten, to ensure that defined namespaces are preserved. Each YUI instance has full custom event support, but only if the event system is available. @class YUI @uses EventTarget @constructor @global @param {Object} [config]* Zero or more optional configuration objects. Config values are stored in the `Y.config` property. See the Config docs for the list of supported properties. **/ /*global YUI*/ /*global YUI_config*/ var YUI = function() { var i = 0, Y = this, args = arguments, l = args.length, instanceOf = function(o, type) { return (o && o.hasOwnProperty && (o instanceof type)); }, gconf = (typeof YUI_config !== 'undefined') && YUI_config; if (!(instanceOf(Y, YUI))) { Y = new YUI(); } else { // set up the core environment Y._init(); /** Master configuration that might span multiple contexts in a non- browser environment. It is applied first to all instances in all contexts. @example YUI.GlobalConfig = { filter: 'debug' }; YUI().use('node', function (Y) { // debug files used here }); YUI({ filter: 'min' }).use('node', function (Y) { // min files used here }); @property {Object} GlobalConfig @global @static **/ if (YUI.GlobalConfig) { Y.applyConfig(YUI.GlobalConfig); } /** Page-level config applied to all YUI instances created on the current page. This is applied after `YUI.GlobalConfig` and before any instance-level configuration. @example // Single global var to include before YUI seed file YUI_config = { filter: 'debug' }; YUI().use('node', function (Y) { // debug files used here }); YUI({ filter: 'min' }).use('node', function (Y) { // min files used here }); @property {Object} YUI_config @global **/ if (gconf) { Y.applyConfig(gconf); } // bind the specified additional modules for this instance if (!l) { Y._setup(); } } if (l) { // Each instance can accept one or more configuration objects. // These are applied after YUI.GlobalConfig and YUI_Config, // overriding values set in those config files if there is a // matching property. for (; i < l; i++) { Y.applyConfig(args[i]); } Y._setup(); } Y.instanceOf = instanceOf; return Y; }; (function() { var proto, prop, VERSION = '3.17.2', PERIOD = '.', BASE = 'http://yui.yahooapis.com/', /* These CSS class names can't be generated by getClassName since it is not available at the time they are being used. */ DOC_LABEL = 'yui3-js-enabled', CSS_STAMP_EL = 'yui3-css-stamp', NOOP = function() {}, SLICE = Array.prototype.slice, APPLY_TO_AUTH = { 'io.xdrReady': 1, // the functions applyTo 'io.xdrResponse': 1, // can call. this should 'SWF.eventHandler': 1 }, // be done at build time hasWin = (typeof window != 'undefined'), win = (hasWin) ? window : null, doc = (hasWin) ? win.document : null, docEl = doc && doc.documentElement, docClass = docEl && docEl.className, instances = {}, time = new Date().getTime(), add = function(el, type, fn, capture) { if (el && el.addEventListener) { el.addEventListener(type, fn, capture); } else if (el && el.attachEvent) { el.attachEvent('on' + type, fn); } }, remove = function(el, type, fn, capture) { if (el && el.removeEventListener) { // this can throw an uncaught exception in FF try { el.removeEventListener(type, fn, capture); } catch (ex) {} } else if (el && el.detachEvent) { el.detachEvent('on' + type, fn); } }, handleReady = function() { YUI.Env.DOMReady = true; if (hasWin) { remove(doc, 'DOMContentLoaded', handleReady); } }, handleLoad = function() { YUI.Env.windowLoaded = true; YUI.Env.DOMReady = true; if (hasWin) { remove(window, 'load', handleLoad); } }, getLoader = function(Y, o) { var loader = Y.Env._loader, lCore = [ 'loader-base' ], G_ENV = YUI.Env, mods = G_ENV.mods; if (loader) { //loader._config(Y.config); loader.ignoreRegistered = false; loader.onEnd = null; loader.data = null; loader.required = []; loader.loadType = null; } else { loader = new Y.Loader(Y.config); Y.Env._loader = loader; } if (mods && mods.loader) { lCore = [].concat(lCore, YUI.Env.loaderExtras); } YUI.Env.core = Y.Array.dedupe([].concat(YUI.Env.core, lCore)); return loader; }, clobber = function(r, s) { for (var i in s) { if (s.hasOwnProperty(i)) { r[i] = s[i]; } } }, ALREADY_DONE = { success: true }; // Stamp the documentElement (HTML) with a class of "yui-loaded" to // enable styles that need to key off of JS being enabled. if (docEl && docClass.indexOf(DOC_LABEL) == -1) { if (docClass) { docClass += ' '; } docClass += DOC_LABEL; docEl.className = docClass; } if (VERSION.indexOf('@') > -1) { VERSION = '3.5.0'; // dev time hack for cdn test } proto = { /** Applies a new configuration object to the config of this YUI instance. This will merge new group/module definitions, and will also update the loader cache if necessary. Updating `Y.config` directly will not update the cache. @method applyConfig @param {Object} o the configuration object. @since 3.2.0 **/ applyConfig: function(o) { o = o || NOOP; var attr, name, // detail, config = this.config, mods = config.modules, groups = config.groups, aliases = config.aliases, loader = this.Env._loader; for (name in o) { if (o.hasOwnProperty(name)) { attr = o[name]; if (mods && name == 'modules') { clobber(mods, attr); } else if (aliases && name == 'aliases') { clobber(aliases, attr); } else if (groups && name == 'groups') { clobber(groups, attr); } else if (name == 'win') { config[name] = (attr && attr.contentWindow) || attr; config.doc = config[name] ? config[name].document : null; } else if (name == '_yuid') { // preserve the guid } else { config[name] = attr; } } } if (loader) { loader._config(o); } }, /** Old way to apply a config to this instance (calls `applyConfig` under the hood). @private @method _config @param {Object} o The config to apply **/ _config: function(o) { this.applyConfig(o); }, /** Initializes this YUI instance. @private @method _init **/ _init: function() { var filter, el, Y = this, G_ENV = YUI.Env, Env = Y.Env, prop; /** The version number of this YUI instance. This value is typically updated by a script when a YUI release is built, so it may not reflect the correct version number when YUI is run from the development source tree. @property {String} version **/ Y.version = VERSION; if (!Env) { Y.Env = { core: ['get', 'features', 'intl-base', 'yui-log', 'yui-later', 'loader-base', 'loader-rollup', 'loader-yui3'], loaderExtras: ['loader-rollup', 'loader-yui3'], mods: {}, // flat module map versions: {}, // version module map base: BASE, cdn: BASE + VERSION + '/build/', // bootstrapped: false, _idx: 0, _used: {}, _attached: {}, _exported: {}, _missed: [], _yidx: 0, _uidx: 0, _guidp: 'y', _loaded: {}, // serviced: {}, // Regex in English: // I'll start at the \b(yui). // 1. Look in the test string for "yui" or // "yui-base" or "yui-davglass" or "yui-foobar" that comes after a word break. That is, it // can't match "foyui" or "i_heart_yui". This can be anywhere in the string. // 2. After #1 must come a forward slash followed by the string matched in #1, so // "yui-base/yui-base" or "yui-pants/yui-pants". // 3. The second occurence of the #1 token can optionally be followed by "-debug" or "-min", // so "yui/yui-min", "yui/yui-debug", "yui-base/yui-base-debug". NOT "yui/yui-tshirt". // 4. This is followed by ".js", so "yui/yui.js". // 0. Going back to the beginning, now. If all that stuff in 1-4 comes after a "?" in the string, // then capture the junk between the LAST "&" and the string in 1-4. So // "blah?foo/yui/yui.js" will capture "foo/" and "blah?some/thing.js&3.3.0/build/yui-davglass/yui-davglass.js" // will capture "3.3.0/build/" // // Regex Exploded: // (?:\? Find a ? // (?:[^&]*&) followed by 0..n characters followed by an & // * in fact, find as many sets of characters followed by a & as you can // ([^&]*) capture the stuff after the last & in \1 // )? but it's ok if all this ?junk&more_junk stuff isn't even there // \b( after a word break find either the string // yui(?:-\w+)? "yui" optionally followed by a -, then more characters // ) and store the yui-* string in \2 // \/\2 then comes a / followed by the yui-* string in \2 // (?:-(min|debug))? optionally followed by "-min" or "-debug" // .js and ending in ".js" _BASE_RE: /(?:\?(?:[^&]*&)*([^&]*))?\b(yui(?:-\w+)?)\/\2(?:-(min|debug))?\.js/, parseBasePath: function(src, pattern) { var match = src.match(pattern), path, filter; if (match) { path = RegExp.leftContext || src.slice(0, src.indexOf(match[0])); // this is to set up the path to the loader. The file // filter for loader should match the yui include. filter = match[3]; // extract correct path for mixed combo urls // http://yuilibrary.com/projects/yui3/ticket/2528423 if (match[1]) { path += '?' + match[1]; } path = { filter: filter, path: path }; } return path; }, getBase: G_ENV && G_ENV.getBase || function(pattern) { var nodes = (doc && doc.getElementsByTagName('script')) || [], path = Env.cdn, parsed, i, len, src; for (i = 0, len = nodes.length; i < len; ++i) { src = nodes[i].src; if (src) { parsed = Y.Env.parseBasePath(src, pattern); if (parsed) { filter = parsed.filter; path = parsed.path; break; } } } // use CDN default return path; } }; Env = Y.Env; Env._loaded[VERSION] = {}; if (G_ENV && Y !== YUI) { Env._yidx = ++G_ENV._yidx; Env._guidp = ('yui_' + VERSION + '_' + Env._yidx + '_' + time).replace(/[^a-z0-9_]+/g, '_'); } else if (YUI._YUI) { G_ENV = YUI._YUI.Env; Env._yidx += G_ENV._yidx; Env._uidx += G_ENV._uidx; for (prop in G_ENV) { if (!(prop in Env)) { Env[prop] = G_ENV[prop]; } } delete YUI._YUI; } Y.id = Y.stamp(Y); instances[Y.id] = Y; } Y.constructor = YUI; // configuration defaults Y.config = Y.config || { bootstrap: true, cacheUse: true, debug: true, doc: doc, fetchCSS: true, throwFail: true, useBrowserConsole: true, useNativeES5: true, win: win, global: Function('return this')() }; //Register the CSS stamp element if (doc && !doc.getElementById(CSS_STAMP_EL)) { el = doc.createElement('div'); el.innerHTML = '
'; YUI.Env.cssStampEl = el.firstChild; if (doc.body) { doc.body.appendChild(YUI.Env.cssStampEl); } else { docEl.insertBefore(YUI.Env.cssStampEl, docEl.firstChild); } } else if (doc && doc.getElementById(CSS_STAMP_EL) && !YUI.Env.cssStampEl) { YUI.Env.cssStampEl = doc.getElementById(CSS_STAMP_EL); } Y.config.lang = Y.config.lang || 'en-US'; Y.config.base = YUI.config.base || Y.Env.getBase(Y.Env._BASE_RE); if (!filter || (!('mindebug').indexOf(filter))) { filter = 'min'; } filter = (filter) ? '-' + filter : filter; Y.config.loaderPath = YUI.config.loaderPath || 'loader/loader' + filter + '.js'; }, /** Finishes the instance setup. Attaches whatever YUI modules were defined at the time that this instance was created. @method _setup @private **/ _setup: function() { var i, Y = this, core = [], mods = YUI.Env.mods, extras = Y.config.core || [].concat(YUI.Env.core); //Clone it.. for (i = 0; i < extras.length; i++) { if (mods[extras[i]]) { core.push(extras[i]); } } Y._attach(['yui-base']); Y._attach(core); if (Y.Loader) { getLoader(Y); } }, /** Executes the named method on the specified YUI instance if that method is whitelisted. @method applyTo @param {String} id YUI instance id. @param {String} method Name of the method to execute. For example: 'Object.keys'. @param {Array} args Arguments to apply to the method. @return {Mixed} Return value from the applied method, or `null` if the specified instance was not found or the method was not whitelisted. **/ applyTo: function(id, method, args) { if (!(method in APPLY_TO_AUTH)) { this.log(method + ': applyTo not allowed', 'warn', 'yui'); return null; } var instance = instances[id], nest, m, i; if (instance) { nest = method.split('.'); m = instance; for (i = 0; i < nest.length; i = i + 1) { m = m[nest[i]]; if (!m) { this.log('applyTo not found: ' + method, 'warn', 'yui'); } } return m && m.apply(instance, args); } return null; }, /** Registers a YUI module and makes it available for use in a `YUI().use()` call or as a dependency for other modules. The easiest way to create a first-class YUI module is to use Shifter, the YUI component build tool. Shifter will automatically wrap your module code in a `YUI.add()` call along with any configuration info required for the module. @example YUI.add('davglass', function (Y) { Y.davglass = function () { }; }, '3.4.0', { requires: ['harley-davidson', 'mt-dew'] }); @method add @param {String} name Module name. @param {Function} fn Function containing module code. This function will be executed whenever the module is attached to a specific YUI instance. @param {YUI} fn.Y The YUI instance to which this module is attached. @param {String} fn.name Name of the module @param {String} version Module version number. This is currently used only for informational purposes, and is not used internally by YUI. @param {Object} [details] Module config. @param {Array} [details.requires] Array of other module names that must be attached before this module can be attached. @param {Array} [details.optional] Array of optional module names that should be attached before this module is attached if they've already been loaded. If the `loadOptional` YUI option is `true`, optional modules that have not yet been loaded will be loaded just as if they were hard requirements. @param {Array} [details.use] Array of module names that are included within or otherwise provided by this module, and which should be attached automatically when this module is attached. This makes it possible to create "virtual rollup" modules that simply attach a collection of other modules or submodules. @return {YUI} This YUI instance. **/ add: function(name, fn, version, details) { details = details || {}; var env = YUI.Env, mod = { name: name, fn: fn, version: version, details: details }, //Instance hash so we don't apply it to the same instance twice applied = {}, loader, inst, modInfo, i, versions = env.versions; env.mods[name] = mod; versions[version] = versions[version] || {}; versions[version][name] = mod; for (i in instances) { if (instances.hasOwnProperty(i)) { inst = instances[i]; if (!applied[inst.id]) { applied[inst.id] = true; loader = inst.Env._loader; if (loader) { modInfo = loader.getModuleInfo(name); if (!modInfo || modInfo.temp) { loader.addModule(details, name); } } } } } return this; }, /** Executes the callback function associated with each required module, attaching the module to this YUI instance. @method _attach @param {Array} r The array of modules to attach @param {Boolean} [moot=false] If `true`, don't throw a warning if the module is not attached. @private **/ _attach: function(r, moot) { var i, name, mod, details, req, use, after, mods = YUI.Env.mods, aliases = YUI.Env.aliases, Y = this, j, cache = YUI.Env._renderedMods, loader = Y.Env._loader, done = Y.Env._attached, exported = Y.Env._exported, len = r.length, loader, def, go, c = [], modArgs, esCompat, reqlen, modInfo, condition, __exports__, __imports__; //Check for conditional modules (in a second+ instance) and add their requirements //TODO I hate this entire method, it needs to be fixed ASAP (3.5.0) ^davglass for (i = 0; i < len; i++) { name = r[i]; mod = mods[name]; c.push(name); if (loader && loader.conditions[name]) { for (j in loader.conditions[name]) { if (loader.conditions[name].hasOwnProperty(j)) { def = loader.conditions[name][j]; go = def && ((def.ua && Y.UA[def.ua]) || (def.test && def.test(Y))); if (go) { c.push(def.name); } } } } } r = c; len = r.length; for (i = 0; i < len; i++) { if (!done[r[i]]) { name = r[i]; mod = mods[name]; if (aliases && aliases[name] && !mod) { Y._attach(aliases[name]); continue; } if (!mod) { modInfo = loader && loader.getModuleInfo(name); if (modInfo) { mod = modInfo; moot = true; } //if (!loader || !loader.moduleInfo[name]) { //if ((!loader || !loader.moduleInfo[name]) && !moot) { if (!moot && name) { if ((name.indexOf('skin-') === -1) && (name.indexOf('css') === -1)) { Y.Env._missed.push(name); Y.Env._missed = Y.Array.dedupe(Y.Env._missed); Y.message('NOT loaded: ' + name, 'warn', 'yui'); } } } else { done[name] = true; //Don't like this, but in case a mod was asked for once, then we fetch it //We need to remove it from the missed list ^davglass for (j = 0; j < Y.Env._missed.length; j++) { if (Y.Env._missed[j] === name) { Y.message('Found: ' + name + ' (was reported as missing earlier)', 'warn', 'yui'); Y.Env._missed.splice(j, 1); } } // Optional dependencies normally work by modifying the // dependency list of a module. If the dependency's test // passes it is added to the list. If not, it's not loaded. // This following check ensures that optional dependencies // are not attached when they were already loaded into the // page (when bundling for example) if (loader && !loader._canBeAttached(name)) { return true; } /* If it's a temp module, we need to redo it's requirements if it's already loaded since it may have been loaded by another instance and it's dependencies might have been redefined inside the fetched file. */ if (loader && cache && cache[name] && cache[name].temp) { loader.getRequires(cache[name]); req = []; modInfo = loader.getModuleInfo(name); for (j in modInfo.expanded_map) { if (modInfo.expanded_map.hasOwnProperty(j)) { req.push(j); } } Y._attach(req); } details = mod.details; req = details.requires; esCompat = details.es; use = details.use; after = details.after; //Force Intl load if there is a language (Loader logic) @todo fix this shit if (details.lang) { req = req || []; req.unshift('intl'); } if (req) { reqlen = req.length; for (j = 0; j < reqlen; j++) { if (!done[req[j]]) { if (!Y._attach(req)) { return false; } break; } } } if (after) { for (j = 0; j < after.length; j++) { if (!done[after[j]]) { if (!Y._attach(after, true)) { return false; } break; } } } if (mod.fn) { modArgs = [Y, name]; if (esCompat) { __imports__ = {}; __exports__ = {}; // passing `exports` and `imports` onto the module function modArgs.push(__imports__, __exports__); if (req) { reqlen = req.length; for (j = 0; j < reqlen; j++) { __imports__[req[j]] = exported.hasOwnProperty(req[j]) ? exported[req[j]] : Y; } } } if (Y.config.throwFail) { __exports__ = mod.fn.apply(esCompat ? undefined : mod, modArgs); } else { try { __exports__ = mod.fn.apply(esCompat ? undefined : mod, modArgs); } catch (e) { Y.error('Attach error: ' + name, e, name); return false; } } if (esCompat) { // store the `exports` in case others `es` modules requires it exported[name] = __exports__; // If an ES module is conditionally loaded and set // to be used "instead" another module, replace the // trigger module's content with the conditionally // loaded one so the values returned by require() // still makes sense condition = mod.details.condition; if (condition && condition.when === 'instead') { exported[condition.trigger] = __exports__; } } } if (use) { for (j = 0; j < use.length; j++) { if (!done[use[j]]) { if (!Y._attach(use)) { return false; } break; } } } } } } return true; }, /** Delays the `use` callback until another event has taken place such as `window.onload`, `domready`, `contentready`, or `available`. @private @method _delayCallback @param {Function} cb The original `use` callback. @param {String|Object} until Either an event name ('load', 'domready', etc.) or an object containing event/args keys for contentready/available. @return {Function} **/ _delayCallback: function(cb, until) { var Y = this, mod = ['event-base']; until = (Y.Lang.isObject(until) ? until : { event: until }); if (until.event === 'load') { mod.push('event-synthetic'); } return function() { var args = arguments; Y._use(mod, function() { Y.on(until.event, function() { args[1].delayUntil = until.event; cb.apply(Y, args); }, until.args); }); }; }, /** Attaches one or more modules to this YUI instance. When this is executed, the requirements of the desired modules are analyzed, and one of several things can happen: * All required modules have already been loaded, and just need to be attached to this YUI instance. In this case, the `use()` callback will be executed synchronously after the modules are attached. * One or more modules have not yet been loaded, or the Get utility is not available, or the `bootstrap` config option is `false`. In this case, a warning is issued indicating that modules are missing, but all available modules will still be attached and the `use()` callback will be executed synchronously. * One or more modules are missing and the Loader is not available but the Get utility is, and `bootstrap` is not `false`. In this case, the Get utility will be used to load the Loader, and we will then proceed to the following state: * One or more modules are missing and the Loader is available. In this case, the Loader will be used to resolve the dependency tree for the missing modules and load them and their dependencies. When the Loader is finished loading modules, the `use()` callback will be executed asynchronously. @example // Loads and attaches dd and its dependencies. YUI().use('dd', function (Y) { // ... }); // Loads and attaches dd and node as well as all of their dependencies. YUI().use(['dd', 'node'], function (Y) { // ... }); // Attaches all modules that have already been loaded. YUI().use('*', function (Y) { // ... }); // Attaches a gallery module. YUI().use('gallery-yql', function (Y) { // ... }); // Attaches a YUI 2in3 module. YUI().use('yui2-datatable', function (Y) { // ... }); @method use @param {String|Array} modules* One or more module names to attach. @param {Function} [callback] Callback function to be executed once all specified modules and their dependencies have been attached. @param {YUI} callback.Y The YUI instance created for this sandbox. @param {Object} callback.status Object containing `success`, `msg` and `data` properties. @chainable **/ use: function() { var args = SLICE.call(arguments, 0), callback = args[args.length - 1], Y = this, i = 0, name, Env = Y.Env, provisioned = true; // The last argument supplied to use can be a load complete callback if (Y.Lang.isFunction(callback)) { args.pop(); if (Y.config.delayUntil) { callback = Y._delayCallback(callback, Y.config.delayUntil); } } else { callback = null; } if (Y.Lang.isArray(args[0])) { args = args[0]; } if (Y.config.cacheUse) { while ((name = args[i++])) { if (!Env._attached[name]) { provisioned = false; break; } } if (provisioned) { if (args.length) { } Y._notify(callback, ALREADY_DONE, args); return Y; } } if (Y._loading) { Y._useQueue = Y._useQueue || new Y.Queue(); Y._useQueue.add([args, callback]); } else { Y._use(args, function(Y, response) { Y._notify(callback, response, args); }); } return Y; }, /** Sugar for loading both legacy and ES6-based YUI modules. @method require @param {String} [modules*] List of module names to import or a single module name. @param {Function} callback Callback that gets called once all the modules were loaded. Each parameter of the callback is the export value of the corresponding module in the list. If the module is a legacy YUI module, the YUI instance is used instead of the module exports. @example ``` YUI().require(['es6-set'], function (Y, imports) { var Set = imports.Set, set = new Set(); }); ``` **/ require: function () { var args = SLICE.call(arguments), callback; if (typeof args[args.length - 1] === 'function') { callback = args.pop(); // only add the callback if one was provided // YUI().require('foo'); is valid args.push(function (Y) { var i, length = args.length, exported = Y.Env._exported, __imports__ = {}; // Get only the imports requested as arguments for (i = 0; i < length; i++) { if (exported.hasOwnProperty(args[i])) { __imports__[args[i]] = exported[args[i]]; } } // Using `undefined` because: // - Using `Y.config.global` would force the value of `this` to be // the global object even in strict mode // - Using `Y` goes against the goal of moving away from a shared // object and start thinking in terms of imported and exported // objects callback.call(undefined, Y, __imports__); }); } // Do not return the Y object. This makes it hard to follow this // traditional pattern: // var Y = YUI().use(...); // This is a good idea in the light of ES6 modules, to avoid working // in the global scope. // This also leaves the door open for returning a promise, once the // YUI loader is based on the ES6 loader which uses // loader.import(...).then(...) this.use.apply(this, args); }, /** Handles Loader notifications about attachment/load errors. @method _notify @param {Function} callback Callback to pass to `Y.config.loadErrorFn`. @param {Object} response Response returned from Loader. @param {Array} args Arguments passed from Loader. @private **/ _notify: function(callback, response, args) { if (!response.success && this.config.loadErrorFn) { this.config.loadErrorFn.call(this, this, callback, response, args); } else if (callback) { if (this.Env._missed && this.Env._missed.length) { response.msg = 'Missing modules: ' + this.Env._missed.join(); response.success = false; } if (this.config.throwFail) { callback(this, response); } else { try { callback(this, response); } catch (e) { this.error('use callback error', e, args); } } } }, /** Called from the `use` method queue to ensure that only one set of loading logic is performed at a time. @method _use @param {String} args* One or more modules to attach. @param {Function} [callback] Function to call once all required modules have been attached. @private **/ _use: function(args, callback) { if (!this.Array) { this._attach(['yui-base']); } var len, loader, handleBoot, Y = this, G_ENV = YUI.Env, mods = G_ENV.mods, Env = Y.Env, used = Env._used, aliases = G_ENV.aliases, queue = G_ENV._loaderQueue, firstArg = args[0], YArray = Y.Array, config = Y.config, boot = config.bootstrap, missing = [], i, r = [], ret = true, fetchCSS = config.fetchCSS, process = function(names, skip) { var i = 0, a = [], name, len, m, req, use; if (!names.length) { return; } if (aliases) { len = names.length; for (i = 0; i < len; i++) { if (aliases[names[i]] && !mods[names[i]]) { a = [].concat(a, aliases[names[i]]); } else { a.push(names[i]); } } names = a; } len = names.length; for (i = 0; i < len; i++) { name = names[i]; if (!skip) { r.push(name); } // only attach a module once if (used[name]) { continue; } m = mods[name]; req = null; use = null; if (m) { used[name] = true; req = m.details.requires; use = m.details.use; } else { // CSS files don't register themselves, see if it has // been loaded if (!G_ENV._loaded[VERSION][name]) { missing.push(name); } else { used[name] = true; // probably css } } // make sure requirements are attached if (req && req.length) { process(req); } // make sure we grab the submodule dependencies too if (use && use.length) { process(use, 1); } } }, handleLoader = function(fromLoader) { var response = fromLoader || { success: true, msg: 'not dynamic' }, redo, origMissing, ret = true, data = response.data; Y._loading = false; if (data) { origMissing = missing; missing = []; r = []; process(data); redo = missing.length; if (redo) { if ([].concat(missing).sort().join() == origMissing.sort().join()) { redo = false; } } } if (redo && data) { Y._loading = true; Y._use(missing, function() { if (Y._attach(data)) { Y._notify(callback, response, data); } }); } else { if (data) { ret = Y._attach(data); } if (ret) { Y._notify(callback, response, args); } } if (Y._useQueue && Y._useQueue.size() && !Y._loading) { Y._use.apply(Y, Y._useQueue.next()); } }; // YUI().use('*'); // bind everything available if (firstArg === '*') { args = []; for (i in mods) { if (mods.hasOwnProperty(i)) { args.push(i); } } ret = Y._attach(args); if (ret) { handleLoader(); } return Y; } if ((mods.loader || mods['loader-base']) && !Y.Loader) { Y._attach(['loader' + ((!mods.loader) ? '-base' : '')]); } // use loader to expand dependencies and sort the // requirements if it is available. if (boot && Y.Loader && args.length) { loader = getLoader(Y); loader.require(args); loader.ignoreRegistered = true; loader._boot = true; loader.calculate(null, (fetchCSS) ? null : 'js'); args = loader.sorted; loader._boot = false; } process(args); len = missing.length; if (len) { missing = YArray.dedupe(missing); len = missing.length; } // dynamic load if (boot && len && Y.Loader) { Y._loading = true; loader = getLoader(Y); loader.onEnd = handleLoader; loader.context = Y; loader.data = args; loader.ignoreRegistered = false; loader.require(missing); loader.insert(null, (fetchCSS) ? null : 'js'); } else if (boot && len && Y.Get && !Env.bootstrapped) { Y._loading = true; handleBoot = function() { Y._loading = false; queue.running = false; Env.bootstrapped = true; G_ENV._bootstrapping = false; if (Y._attach(['loader'])) { Y._use(args, callback); } }; if (G_ENV._bootstrapping) { queue.add(handleBoot); } else { G_ENV._bootstrapping = true; Y.Get.script(config.base + config.loaderPath, { onEnd: handleBoot }); } } else { ret = Y._attach(args); if (ret) { handleLoader(); } } return Y; }, /** Utility method for safely creating namespaces if they don't already exist. May be called statically on the YUI global object or as a method on a YUI instance. When called statically, a namespace will be created on the YUI global object: // Create `YUI.your.namespace.here` as nested objects, preserving any // objects that already exist instead of overwriting them. YUI.namespace('your.namespace.here'); When called as a method on a YUI instance, a namespace will be created on that instance: // Creates `Y.property.package`. Y.namespace('property.package'); Dots in the input string cause `namespace` to create nested objects for each token. If any part of the requested namespace already exists, the current object will be left in place and will not be overwritten. This allows multiple calls to `namespace` to preserve existing namespaced properties. If the first token in the namespace string is "YAHOO", that token is discarded. This is legacy behavior for backwards compatibility with YUI 2. Be careful with namespace tokens. Reserved words may work in some browsers and not others. For instance, the following will fail in some browsers because the supported version of JavaScript reserves the word "long": Y.namespace('really.long.nested.namespace'); Note: If you pass multiple arguments to create multiple namespaces, only the last one created is returned from this function. @method namespace @param {String} namespace* One or more namespaces to create. @return {Object} Reference to the last namespace object created. **/ namespace: function() { var a = arguments, o, i = 0, j, d, arg; for (; i < a.length; i++) { o = this; //Reset base object per argument or it will get reused from the last arg = a[i]; if (arg.indexOf(PERIOD) > -1) { //Skip this if no "." is present d = arg.split(PERIOD); for (j = (d[0] == 'YAHOO') ? 1 : 0; j < d.length; j++) { o[d[j]] = o[d[j]] || {}; o = o[d[j]]; } } else { o[arg] = o[arg] || {}; o = o[arg]; //Reset base object to the new object so it's returned } } return o; }, // this is replaced if the log module is included log: NOOP, message: NOOP, // this is replaced if the dump module is included dump: function (o) { return ''+o; }, /** Reports an error. The reporting mechanism is controlled by the `throwFail` configuration attribute. If `throwFail` is falsy, the message is logged. If `throwFail` is truthy, a JS exception is thrown. If an `errorFn` is specified in the config it must return `true` to indicate that the exception was handled and keep it from being thrown. @method error @param {String} msg Error message. @param {Error|String} [e] JavaScript error object or an error string. @param {String} [src] Source of the error (such as the name of the module in which the error occurred). @chainable **/ error: function(msg, e, src) { //TODO Add check for window.onerror here var Y = this, ret; if (Y.config.errorFn) { ret = Y.config.errorFn.apply(Y, arguments); } if (!ret) { throw (e || new Error(msg)); } else { Y.message(msg, 'error', ''+src); // don't scrub this one } return Y; }, /** Generates an id string that is unique among all YUI instances in this execution context. @method guid @param {String} [pre] Prefix. @return {String} Unique id. **/ guid: function(pre) { var id = this.Env._guidp + '_' + (++this.Env._uidx); return (pre) ? (pre + id) : id; }, /** Returns a unique id associated with the given object and (if *readOnly* is falsy) stamps the object with that id so it can be identified in the future. Stamping an object involves adding a `_yuid` property to it that contains the object's id. One exception to this is that in Internet Explorer, DOM nodes have a `uniqueID` property that contains a browser-generated unique id, which will be used instead of a YUI-generated id when available. @method stamp @param {Object} o Object to stamp. @param {Boolean} readOnly If truthy and the given object has not already been stamped, the object will not be modified and `null` will be returned. @return {String} Object's unique id, or `null` if *readOnly* was truthy and the given object was not already stamped. **/ stamp: function(o, readOnly) { var uid; if (!o) { return o; } // IE generates its own unique ID for dom nodes // The uniqueID property of a document node returns a new ID if (o.uniqueID && o.nodeType && o.nodeType !== 9) { uid = o.uniqueID; } else { uid = (typeof o === 'string') ? o : o._yuid; } if (!uid) { uid = this.guid(); if (!readOnly) { try { o._yuid = uid; } catch (e) { uid = null; } } } return uid; }, /** Destroys this YUI instance. @method destroy @since 3.3.0 **/ destroy: function() { var Y = this; if (Y.Event) { Y.Event._unload(); } delete instances[Y.id]; delete Y.Env; delete Y.config; } /** Safe `instanceof` wrapper that works around a memory leak in IE when the object being tested is `window` or `document`. Unless you are testing objects that may be `window` or `document`, you should use the native `instanceof` operator instead of this method. @method instanceOf @param {Object} o Object to check. @param {Object} type Class to check against. @since 3.3.0 **/ }; YUI.prototype = proto; // inheritance utilities are not available yet for (prop in proto) { if (proto.hasOwnProperty(prop)) { YUI[prop] = proto[prop]; } } /** Applies a configuration to all YUI instances in this execution context. The main use case for this method is in "mashups" where several third-party scripts need to write to a global YUI config, but cannot share a single centrally-managed config object. This way they can all call `YUI.applyConfig({})` instead of overwriting the single global config. @example YUI.applyConfig({ modules: { davglass: { fullpath: './davglass.js' } } }); YUI.applyConfig({ modules: { foo: { fullpath: './foo.js' } } }); YUI().use('davglass', function (Y) { // Module davglass will be available here. }); @method applyConfig @param {Object} o Configuration object to apply. @static @since 3.5.0 **/ YUI.applyConfig = function(o) { if (!o) { return; } //If there is a GlobalConfig, apply it first to set the defaults if (YUI.GlobalConfig) { this.prototype.applyConfig.call(this, YUI.GlobalConfig); } //Apply this config to it this.prototype.applyConfig.call(this, o); //Reset GlobalConfig to the combined config YUI.GlobalConfig = this.config; }; // set up the environment YUI._init(); if (hasWin) { add(doc, 'DOMContentLoaded', handleReady); // add a window load event at load time so we can capture // the case where it fires before dynamic loading is // complete. add(window, 'load', handleLoad); } else { handleReady(); handleLoad(); } YUI.Env.add = add; YUI.Env.remove = remove; /*global exports*/ // Support the CommonJS method for exporting our single global if (typeof exports == 'object') { exports.YUI = YUI; /** * Set a method to be called when `Get.script` is called in Node.js * `Get` will open the file, then pass it's content and it's path * to this method before attaching it. Commonly used for code coverage * instrumentation. Calling this multiple times will only * attach the last hook method. This method is only * available in Node.js. * @method setLoadHook * @static * @param {Function} fn The function to set * @param {String} fn.data The content of the file * @param {String} fn.path The file path of the file */ YUI.setLoadHook = function(fn) { YUI._getLoadHook = fn; }; /** * Load hook for `Y.Get.script` in Node.js, see `YUI.setLoadHook` * @method _getLoadHook * @private * @param {String} data The content of the file * @param {String} path The file path of the file */ YUI._getLoadHook = null; } YUI.Env[VERSION] = {}; }()); /** Config object that contains all of the configuration options for this `YUI` instance. This object is supplied by the implementer when instantiating YUI. Some properties have default values if they are not supplied by the implementer. This object 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. @class config @static **/ /** If `true` (the default), YUI will "bootstrap" the YUI Loader and module metadata if they're needed to load additional dependencies and aren't already available. Setting this to `false` will prevent YUI from automatically loading the Loader and module metadata, so you will need to manually ensure that they're available or handle dependency resolution yourself. @property {Boolean} bootstrap @default true **/ /** @property {Object} filters **/ /** If `true`, YUI will use a combo handler to load multiple modules in as few requests as possible. The YUI CDN (which YUI uses by default) supports combo handling, but other servers may not. If the server from which you're loading YUI does not support combo handling, set this to `false`. Providing a value for the `base` config property will cause `combine` to default to `false` instead of `true`. @property {Boolean} combine @default true */ /** Array of module names that should never be dynamically loaded. @property {String[]} ignore **/ /** Array of module names that should always be loaded when required, even if already present on the page. @property {String[]} force **/ /** DOM element or id that should be used as the insertion point for dynamically added `', 'script'); } }); if (!testFeature('innerhtml', 'table')) { // TODO: thead/tfoot with nested tbody // IE adds TBODY when creating TABLE elements (which may share this impl) creators.tbody = function(html, doc) { var frag = Y_DOM.create(TABLE_OPEN + html + TABLE_CLOSE, doc), tb = Y.DOM._children(frag, 'tbody')[0]; if (frag.children.length > 1 && tb && !re_tbody.test(html)) { tb.parentNode.removeChild(tb); // strip extraneous tbody } return frag; }; } if (!testFeature('innerhtml-div', 'script')) { creators.script = function(html, doc) { var frag = doc.createElement('div'); frag.innerHTML = '-' + html; frag.removeChild(frag.firstChild); return frag; }; creators.link = creators.style = creators.script; } if (!testFeature('innerhtml-div', 'tr')) { Y.mix(creators, { option: function(html, doc) { return Y_DOM.create('', doc); }, tr: function(html, doc) { return Y_DOM.create('' + html + '', doc); }, td: function(html, doc) { return Y_DOM.create('' + html + '', doc); }, col: function(html, doc) { return Y_DOM.create('' + html + '', doc); }, tbody: 'table' }); Y.mix(creators, { legend: 'fieldset', th: creators.td, thead: creators.tbody, tfoot: creators.tbody, caption: creators.tbody, colgroup: creators.tbody, optgroup: creators.option }); } Y_DOM.creators = creators; Y.mix(Y.DOM, { /** * Sets the width of the element to the given size, regardless * of box model, border, padding, etc. * @method setWidth * @param {HTMLElement} element The DOM element. * @param {String|Number} size The pixel height to size to */ setWidth: function(node, size) { Y.DOM._setSize(node, 'width', size); }, /** * Sets the height of the element to the given size, regardless * of box model, border, padding, etc. * @method setHeight * @param {HTMLElement} element The DOM element. * @param {String|Number} size The pixel height to size to */ setHeight: function(node, size) { Y.DOM._setSize(node, 'height', size); }, _setSize: function(node, prop, val) { val = (val > 0) ? val : 0; var size = 0; node.style[prop] = val + 'px'; size = (prop === 'height') ? node.offsetHeight : node.offsetWidth; if (size > val) { val = val - (size - val); if (val < 0) { val = 0; } node.style[prop] = val + 'px'; } } }); }, '3.17.2', {"requires": ["dom-core"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('color-base', function (Y, NAME) { /** Color provides static methods for color conversion. Y.Color.toRGB('f00'); // rgb(255, 0, 0) Y.Color.toHex('rgb(255, 255, 0)'); // #ffff00 @module color @submodule color-base @class Color @since 3.8.0 **/ var REGEX_HEX = /^#?([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})(\ufffe)?/, REGEX_HEX3 = /^#?([\da-fA-F]{1})([\da-fA-F]{1})([\da-fA-F]{1})(\ufffe)?/, REGEX_RGB = /rgba?\(([\d]{1,3}), ?([\d]{1,3}), ?([\d]{1,3}),? ?([.\d]*)?\)/, TYPES = { 'HEX': 'hex', 'RGB': 'rgb', 'RGBA': 'rgba' }, CONVERTS = { 'hex': 'toHex', 'rgb': 'toRGB', 'rgba': 'toRGBA' }; Y.Color = { /** @static @property KEYWORDS @type Object @since 3.8.0 **/ KEYWORDS: { 'black': '000', 'silver': 'c0c0c0', 'gray': '808080', 'white': 'fff', 'maroon': '800000', 'red': 'f00', 'purple': '800080', 'fuchsia': 'f0f', 'green': '008000', 'lime': '0f0', 'olive': '808000', 'yellow': 'ff0', 'navy': '000080', 'blue': '00f', 'teal': '008080', 'aqua': '0ff' }, /** NOTE: `(\ufffe)?` is added to the Regular Expression to carve out a place for the alpha channel that is returned from toArray without compromising any usage of the Regular Expression @static @property REGEX_HEX @type RegExp @default /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})(\ufffe)?/ @since 3.8.0 **/ REGEX_HEX: REGEX_HEX, /** NOTE: `(\ufffe)?` is added to the Regular Expression to carve out a place for the alpha channel that is returned from toArray without compromising any usage of the Regular Expression @static @property REGEX_HEX3 @type RegExp @default /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})(\ufffe)?/ @since 3.8.0 **/ REGEX_HEX3: REGEX_HEX3, /** @static @property REGEX_RGB @type RegExp @default /rgba?\(([0-9]{1,3}), ?([0-9]{1,3}), ?([0-9]{1,3}),? ?([.0-9]{1,3})?\)/ @since 3.8.0 **/ REGEX_RGB: REGEX_RGB, re_RGB: REGEX_RGB, re_hex: REGEX_HEX, re_hex3: REGEX_HEX3, /** @static @property STR_HEX @type String @default #{*}{*}{*} @since 3.8.0 **/ STR_HEX: '#{*}{*}{*}', /** @static @property STR_RGB @type String @default rgb({*}, {*}, {*}) @since 3.8.0 **/ STR_RGB: 'rgb({*}, {*}, {*})', /** @static @property STR_RGBA @type String @default rgba({*}, {*}, {*}, {*}) @since 3.8.0 **/ STR_RGBA: 'rgba({*}, {*}, {*}, {*})', /** @static @property TYPES @type Object @default {'rgb':'rgb', 'rgba':'rgba'} @since 3.8.0 **/ TYPES: TYPES, /** @static @property CONVERTS @type Object @default {} @since 3.8.0 **/ CONVERTS: CONVERTS, /** Converts the provided string to the provided type. You can use the `Y.Color.TYPES` to get a valid `to` type. If the color cannot be converted, the original color will be returned. @public @method convert @param {String} str @param {String} to @return {String} @since 3.8.0 **/ convert: function (str, to) { var convert = Y.Color.CONVERTS[to.toLowerCase()], clr = str; if (convert && Y.Color[convert]) { clr = Y.Color[convert](str); } return clr; }, /** Converts provided color value to a hex value string @public @method toHex @param {String} str Hex or RGB value string @return {String} returns array of values or CSS string if options.css is true @since 3.8.0 **/ toHex: function (str) { var clr = Y.Color._convertTo(str, 'hex'), isTransparent = clr.toLowerCase() === 'transparent'; if (clr.charAt(0) !== '#' && !isTransparent) { clr = '#' + clr; } return isTransparent ? clr.toLowerCase() : clr.toUpperCase(); }, /** Converts provided color value to an RGB value string @public @method toRGB @param {String} str Hex or RGB value string @return {String} @since 3.8.0 **/ toRGB: function (str) { var clr = Y.Color._convertTo(str, 'rgb'); return clr.toLowerCase(); }, /** Converts provided color value to an RGB value string @public @method toRGBA @param {String} str Hex or RGB value string @return {String} @since 3.8.0 **/ toRGBA: function (str) { var clr = Y.Color._convertTo(str, 'rgba' ); return clr.toLowerCase(); }, /** Converts the provided color string to an array of values where the last value is the alpha value. Will return an empty array if the provided string is not able to be parsed. NOTE: `(\ufffe)?` is added to `HEX` and `HEX3` Regular Expressions to carve out a place for the alpha channel that is returned from toArray without compromising any usage of the Regular Expression Y.Color.toArray('fff'); // ['ff', 'ff', 'ff', 1] Y.Color.toArray('rgb(0, 0, 0)'); // ['0', '0', '0', 1] Y.Color.toArray('rgba(0, 0, 0, 0)'); // ['0', '0', '0', 1] @public @method toArray @param {String} str @return {Array} @since 3.8.0 **/ toArray: function(str) { // parse with regex and return "matches" array var type = Y.Color.findType(str).toUpperCase(), regex, arr, length, lastItem; if (type === 'HEX' && str.length < 5) { type = 'HEX3'; } if (type.charAt(type.length - 1) === 'A') { type = type.slice(0, -1); } regex = Y.Color['REGEX_' + type]; if (regex) { arr = regex.exec(str) || []; length = arr.length; if (length) { arr.shift(); length--; if (type === 'HEX3') { arr[0] += arr[0]; arr[1] += arr[1]; arr[2] += arr[2]; } lastItem = arr[length - 1]; if (!lastItem) { arr[length - 1] = 1; } } } return arr; }, /** Converts the array of values to a string based on the provided template. @public @method fromArray @param {Array} arr @param {String} template @return {String} @since 3.8.0 **/ fromArray: function(arr, template) { arr = arr.concat(); if (typeof template === 'undefined') { return arr.join(', '); } var replace = '{*}'; template = Y.Color['STR_' + template.toUpperCase()]; if (arr.length === 3 && template.match(/\{\*\}/g).length === 4) { arr.push(1); } while ( template.indexOf(replace) >= 0 && arr.length > 0) { template = template.replace(replace, arr.shift()); } return template; }, /** Finds the value type based on the str value provided. @public @method findType @param {String} str @return {String} @since 3.8.0 **/ findType: function (str) { if (Y.Color.KEYWORDS[str]) { return 'keyword'; } var index = str.indexOf('('), key; if (index > 0) { key = str.substr(0, index); } if (key && Y.Color.TYPES[key.toUpperCase()]) { return Y.Color.TYPES[key.toUpperCase()]; } return 'hex'; }, // return 'keyword', 'hex', 'rgb' /** Retrives the alpha channel from the provided string. If no alpha channel is present, `1` will be returned. @protected @method _getAlpha @param {String} clr @return {Number} @since 3.8.0 **/ _getAlpha: function (clr) { var alpha, arr = Y.Color.toArray(clr); if (arr.length > 3) { alpha = arr.pop(); } return +alpha || 1; }, /** Returns the hex value string if found in the KEYWORDS object @protected @method _keywordToHex @param {String} clr @return {String} @since 3.8.0 **/ _keywordToHex: function (clr) { var keyword = Y.Color.KEYWORDS[clr]; if (keyword) { return keyword; } }, /** Converts the provided color string to the value type provided as `to` @protected @method _convertTo @param {String} clr @param {String} to @return {String} @since 3.8.0 **/ _convertTo: function(clr, to) { if (clr === 'transparent') { return clr; } var from = Y.Color.findType(clr), originalTo = to, needsAlpha, alpha, method, ucTo; if (from === 'keyword') { clr = Y.Color._keywordToHex(clr); from = 'hex'; } if (from === 'hex' && clr.length < 5) { if (clr.charAt(0) === '#') { clr = clr.substr(1); } clr = '#' + clr.charAt(0) + clr.charAt(0) + clr.charAt(1) + clr.charAt(1) + clr.charAt(2) + clr.charAt(2); } if (from === to) { return clr; } if (from.charAt(from.length - 1) === 'a') { from = from.slice(0, -1); } needsAlpha = (to.charAt(to.length - 1) === 'a'); if (needsAlpha) { to = to.slice(0, -1); alpha = Y.Color._getAlpha(clr); } ucTo = to.charAt(0).toUpperCase() + to.substr(1).toLowerCase(); method = Y.Color['_' + from + 'To' + ucTo ]; // check to see if need conversion to rgb first // check to see if there is a direct conversion method // convertions are: hex <-> rgb <-> hsl if (!method) { if (from !== 'rgb' && to !== 'rgb') { clr = Y.Color['_' + from + 'ToRgb'](clr); from = 'rgb'; method = Y.Color['_' + from + 'To' + ucTo ]; } } if (method) { clr = ((method)(clr, needsAlpha)); } // process clr from arrays to strings after conversions if alpha is needed if (needsAlpha) { if (!Y.Lang.isArray(clr)) { clr = Y.Color.toArray(clr); } clr.push(alpha); clr = Y.Color.fromArray(clr, originalTo.toUpperCase()); } return clr; }, /** Processes the hex string into r, g, b values. Will return values as an array, or as an rgb string. @protected @method _hexToRgb @param {String} str @param {Boolean} [toArray] @return {String|Array} @since 3.8.0 **/ _hexToRgb: function (str, toArray) { var r, g, b; /*jshint bitwise:false*/ if (str.charAt(0) === '#') { str = str.substr(1); } str = parseInt(str, 16); r = str >> 16; g = str >> 8 & 0xFF; b = str & 0xFF; if (toArray) { return [r, g, b]; } return 'rgb(' + r + ', ' + g + ', ' + b + ')'; }, /** Processes the rgb string into r, g, b values. Will return values as an array, or as a hex string. @protected @method _rgbToHex @param {String} str @param {Boolean} [toArray] @return {String|Array} @since 3.8.0 **/ _rgbToHex: function (str) { /*jshint bitwise:false*/ var rgb = Y.Color.toArray(str), hex = rgb[2] | (rgb[1] << 8) | (rgb[0] << 16); hex = (+hex).toString(16); while (hex.length < 6) { hex = '0' + hex; } return '#' + hex; } }; }, '3.17.2', {"requires": ["yui-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('dom-style', function (Y, NAME) { /** * Add style management functionality to DOM. * @module dom * @submodule dom-style * @for DOM */ var DOCUMENT_ELEMENT = 'documentElement', DEFAULT_VIEW = 'defaultView', OWNER_DOCUMENT = 'ownerDocument', STYLE = 'style', FLOAT = 'float', CSS_FLOAT = 'cssFloat', STYLE_FLOAT = 'styleFloat', TRANSPARENT = 'transparent', GET_COMPUTED_STYLE = 'getComputedStyle', GET_BOUNDING_CLIENT_RECT = 'getBoundingClientRect', DOCUMENT = Y.config.doc, Y_DOM = Y.DOM, TRANSFORM, TRANSFORMORIGIN, VENDOR_TRANSFORM = [ 'WebkitTransform', 'MozTransform', 'OTransform', 'msTransform', 'transform' ], re_unit = /width|height|top|left|right|bottom|margin|padding/i; Y.Array.each(VENDOR_TRANSFORM, function(val) { if (val in DOCUMENT[DOCUMENT_ELEMENT].style) { TRANSFORM = val; TRANSFORMORIGIN = val + "Origin"; } }); Y.mix(Y_DOM, { DEFAULT_UNIT: 'px', CUSTOM_STYLES: { }, /** * Sets a style property for a given element. * @method setStyle * @param {HTMLElement} node The HTMLElement to apply the style to. * @param {String} att The style property to set. * @param {String|Number} val The value. * @param {Object} [style] The style node. Defaults to `node.style`. */ setStyle: function(node, att, val, style) { style = style || node.style; var CUSTOM_STYLES = Y_DOM.CUSTOM_STYLES; if (style) { if (val === null || val === '') { // normalize unsetting val = ''; } else if (!isNaN(Number(val)) && re_unit.test(att)) { // number values may need a unit val += Y_DOM.DEFAULT_UNIT; } if (att in CUSTOM_STYLES) { if (CUSTOM_STYLES[att].set) { CUSTOM_STYLES[att].set(node, val, style); return; // NOTE: return } else if (typeof CUSTOM_STYLES[att] === 'string') { att = CUSTOM_STYLES[att]; } } else if (att === '') { // unset inline styles att = 'cssText'; val = ''; } style[att] = val; } }, /** * Returns the current style value for the given property. * @method getStyle * @param {HTMLElement} node The HTMLElement to get the style from. * @param {String} att The style property to get. * @param {Object} [style] The style node. Defaults to `node.style`. */ getStyle: function(node, att, style) { style = style || node.style; var CUSTOM_STYLES = Y_DOM.CUSTOM_STYLES, val = ''; if (style) { if (att in CUSTOM_STYLES) { if (CUSTOM_STYLES[att].get) { return CUSTOM_STYLES[att].get(node, att, style); // NOTE: return } else if (typeof CUSTOM_STYLES[att] === 'string') { att = CUSTOM_STYLES[att]; } } val = style[att]; if (val === '') { // TODO: is empty string sufficient? val = Y_DOM[GET_COMPUTED_STYLE](node, att); } } return val; }, /** * Sets multiple style properties. * @method setStyles * @param {HTMLElement} node The HTMLElement to apply the styles to. * @param {Object} hash An object literal of property:value pairs. */ setStyles: function(node, hash) { var style = node.style; Y.each(hash, function(v, n) { Y_DOM.setStyle(node, n, v, style); }, Y_DOM); }, /** * Returns the computed style for the given node. * @method getComputedStyle * @param {HTMLElement} node The HTMLElement to get the style from. * @param {String} att The style property to get. * @return {String} The computed value of the style property. */ getComputedStyle: function(node, att) { var val = '', doc = node[OWNER_DOCUMENT], computed; if (node[STYLE] && doc[DEFAULT_VIEW] && doc[DEFAULT_VIEW][GET_COMPUTED_STYLE]) { computed = doc[DEFAULT_VIEW][GET_COMPUTED_STYLE](node, null); if (computed) { // FF may be null in some cases (ticket #2530548) val = computed[att]; } } return val; } }); // normalize reserved word float alternatives ("cssFloat" or "styleFloat") if (DOCUMENT[DOCUMENT_ELEMENT][STYLE][CSS_FLOAT] !== undefined) { Y_DOM.CUSTOM_STYLES[FLOAT] = CSS_FLOAT; } else if (DOCUMENT[DOCUMENT_ELEMENT][STYLE][STYLE_FLOAT] !== undefined) { Y_DOM.CUSTOM_STYLES[FLOAT] = STYLE_FLOAT; } // safari converts transparent to rgba(), others use "transparent" if (Y.UA.webkit) { Y_DOM[GET_COMPUTED_STYLE] = function(node, att) { var view = node[OWNER_DOCUMENT][DEFAULT_VIEW], val = view[GET_COMPUTED_STYLE](node, '')[att]; if (val === 'rgba(0, 0, 0, 0)') { val = TRANSPARENT; } return val; }; } Y.DOM._getAttrOffset = function(node, attr) { var val = Y.DOM[GET_COMPUTED_STYLE](node, attr), offsetParent = node.offsetParent, position, parentOffset, offset; if (val === 'auto') { position = Y.DOM.getStyle(node, 'position'); if (position === 'static' || position === 'relative') { val = 0; } else if (offsetParent && offsetParent[GET_BOUNDING_CLIENT_RECT]) { parentOffset = offsetParent[GET_BOUNDING_CLIENT_RECT]()[attr]; offset = node[GET_BOUNDING_CLIENT_RECT]()[attr]; if (attr === 'left' || attr === 'top') { val = offset - parentOffset; } else { val = parentOffset - node[GET_BOUNDING_CLIENT_RECT]()[attr]; } } } return val; }; Y.DOM._getOffset = function(node) { var pos, xy = null; if (node) { pos = Y_DOM.getStyle(node, 'position'); xy = [ parseInt(Y_DOM[GET_COMPUTED_STYLE](node, 'left'), 10), parseInt(Y_DOM[GET_COMPUTED_STYLE](node, 'top'), 10) ]; if ( isNaN(xy[0]) ) { // in case of 'auto' xy[0] = parseInt(Y_DOM.getStyle(node, 'left'), 10); // try inline if ( isNaN(xy[0]) ) { // default to offset value xy[0] = (pos === 'relative') ? 0 : node.offsetLeft || 0; } } if ( isNaN(xy[1]) ) { // in case of 'auto' xy[1] = parseInt(Y_DOM.getStyle(node, 'top'), 10); // try inline if ( isNaN(xy[1]) ) { // default to offset value xy[1] = (pos === 'relative') ? 0 : node.offsetTop || 0; } } } return xy; }; if (TRANSFORM) { Y_DOM.CUSTOM_STYLES.transform = { set: function(node, val, style) { style[TRANSFORM] = val; }, get: function(node) { return Y_DOM[GET_COMPUTED_STYLE](node, TRANSFORM); } }; Y_DOM.CUSTOM_STYLES.transformOrigin = { set: function(node, val, style) { style[TRANSFORMORIGIN] = val; }, get: function(node) { return Y_DOM[GET_COMPUTED_STYLE](node, TRANSFORMORIGIN); } }; } }, '3.17.2', {"requires": ["dom-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('selector-native', function (Y, NAME) { (function(Y) { /** * The selector-native module provides support for native querySelector * @module dom * @submodule selector-native * @for Selector */ /** * Provides support for using CSS selectors to query the DOM * @class Selector * @static * @for Selector */ Y.namespace('Selector'); // allow native module to standalone var COMPARE_DOCUMENT_POSITION = 'compareDocumentPosition', OWNER_DOCUMENT = 'ownerDocument'; var Selector = { _types: { esc: { token: '\uE000', re: /\\[:\[\]\(\)#\.\'\>+~"]/gi }, attr: { token: '\uE001', re: /(\[[^\]]*\])/g }, pseudo: { token: '\uE002', re: /(\([^\)]*\))/g } }, /** * Use the native version of `querySelectorAll`, if it exists. * * @property useNative * @default true * @static */ useNative: true, _escapeId: function(id) { if (id) { id = id.replace(/([:\[\]\(\)#\.'<>+~"])/g,'\\$1'); } return id; }, _compare: ('sourceIndex' in Y.config.doc.documentElement) ? function(nodeA, nodeB) { var a = nodeA.sourceIndex, b = nodeB.sourceIndex; if (a === b) { return 0; } else if (a > b) { return 1; } return -1; } : (Y.config.doc.documentElement[COMPARE_DOCUMENT_POSITION] ? function(nodeA, nodeB) { if (nodeA[COMPARE_DOCUMENT_POSITION](nodeB) & 4) { return -1; } else { return 1; } } : function(nodeA, nodeB) { var rangeA, rangeB, compare; if (nodeA && nodeB) { rangeA = nodeA[OWNER_DOCUMENT].createRange(); rangeA.setStart(nodeA, 0); rangeB = nodeB[OWNER_DOCUMENT].createRange(); rangeB.setStart(nodeB, 0); compare = rangeA.compareBoundaryPoints(1, rangeB); // 1 === Range.START_TO_END } return compare; }), _sort: function(nodes) { if (nodes) { nodes = Y.Array(nodes, 0, true); if (nodes.sort) { nodes.sort(Selector._compare); } } return nodes; }, _deDupe: function(nodes) { var ret = [], i, node; for (i = 0; (node = nodes[i++]);) { if (!node._found) { ret[ret.length] = node; node._found = true; } } for (i = 0; (node = ret[i++]);) { node._found = null; node.removeAttribute('_found'); } return ret; }, /** * Retrieves a set of nodes based on a given CSS selector. * @method query * * @param {String} selector A CSS selector. * @param {HTMLElement} root optional A node to start the query from. Defaults to `Y.config.doc`. * @param {Boolean} firstOnly optional Whether or not to return only the first match. * @return {HTMLElement[]} The array of nodes that matched the given selector. * @static */ query: function(selector, root, firstOnly, skipNative) { root = root || Y.config.doc; var ret = [], useNative = (Y.Selector.useNative && Y.config.doc.querySelector && !skipNative), queries = [[selector, root]], query, result, i, fn = (useNative) ? Y.Selector._nativeQuery : Y.Selector._bruteQuery; if (selector && fn) { // split group into seperate queries if (!skipNative && // already done if skipping (!useNative || root.tagName)) { // split native when element scoping is needed queries = Selector._splitQueries(selector, root); } for (i = 0; (query = queries[i++]);) { result = fn(query[0], query[1], firstOnly); if (!firstOnly) { // coerce DOM Collection to Array result = Y.Array(result, 0, true); } if (result) { ret = ret.concat(result); } } if (queries.length > 1) { // remove dupes and sort by doc order ret = Selector._sort(Selector._deDupe(ret)); } } return (firstOnly) ? (ret[0] || null) : ret; }, _replaceSelector: function(selector) { var esc = Y.Selector._parse('esc', selector), // pull escaped colon, brackets, etc. attrs, pseudos; // first replace escaped chars, which could be present in attrs or pseudos selector = Y.Selector._replace('esc', selector); // then replace pseudos before attrs to avoid replacing :not([foo]) pseudos = Y.Selector._parse('pseudo', selector); selector = Selector._replace('pseudo', selector); attrs = Y.Selector._parse('attr', selector); selector = Y.Selector._replace('attr', selector); return { esc: esc, attrs: attrs, pseudos: pseudos, selector: selector }; }, _restoreSelector: function(replaced) { var selector = replaced.selector; selector = Y.Selector._restore('attr', selector, replaced.attrs); selector = Y.Selector._restore('pseudo', selector, replaced.pseudos); selector = Y.Selector._restore('esc', selector, replaced.esc); return selector; }, _replaceCommas: function(selector) { var replaced = Y.Selector._replaceSelector(selector), selector = replaced.selector; if (selector) { selector = selector.replace(/,/g, '\uE007'); replaced.selector = selector; selector = Y.Selector._restoreSelector(replaced); } return selector; }, // allows element scoped queries to begin with combinator // e.g. query('> p', document.body) === query('body > p') _splitQueries: function(selector, node) { if (selector.indexOf(',') > -1) { selector = Y.Selector._replaceCommas(selector); } var groups = selector.split('\uE007'), // split on replaced comma token queries = [], prefix = '', id, i, len; if (node) { // enforce for element scoping if (node.nodeType === 1) { // Elements only id = Y.Selector._escapeId(Y.DOM.getId(node)); if (!id) { id = Y.guid(); Y.DOM.setId(node, id); } prefix = '[id="' + id + '"] '; } for (i = 0, len = groups.length; i < len; ++i) { selector = prefix + groups[i]; queries.push([selector, node]); } } return queries; }, _nativeQuery: function(selector, root, one) { if ( (Y.UA.webkit || Y.UA.opera) && // webkit (chrome, safari) and Opera selector.indexOf(':checked') > -1 && // fail to pick up "selected" with ":checked" (Y.Selector.pseudos && Y.Selector.pseudos.checked) ) { return Y.Selector.query(selector, root, one, true); // redo with skipNative true to try brute query } try { return root['querySelector' + (one ? '' : 'All')](selector); } catch(e) { // fallback to brute if available return Y.Selector.query(selector, root, one, true); // redo with skipNative true } }, /** * Filters out nodes that do not match the given CSS selector. * @method filter * * @param {HTMLElement[]} nodes An array of nodes. * @param {String} selector A CSS selector to test each node against. * @return {HTMLElement[]} The nodes that matched the given CSS selector. * @static */ filter: function(nodes, selector) { var ret = [], i, node; if (nodes && selector) { for (i = 0; (node = nodes[i++]);) { if (Y.Selector.test(node, selector)) { ret[ret.length] = node; } } } else { } return ret; }, /** * Determines whether or not the given node matches the given CSS selector. * @method test * * @param {HTMLElement} node A node to test. * @param {String} selector A CSS selector to test the node against. * @param {HTMLElement} root optional A node to start the query from. Defaults to the parent document of the node. * @return {Boolean} Whether or not the given node matched the given CSS selector. * @static */ test: function(node, selector, root) { var ret = false, useFrag = false, groups, parent, item, items, frag, id, i, j, group; if (node && node.tagName) { // only test HTMLElements if (typeof selector == 'function') { // test with function ret = selector.call(node, node); } else { // test with query // we need a root if off-doc groups = selector.split(','); if (!root && !Y.DOM.inDoc(node)) { parent = node.parentNode; if (parent) { root = parent; } else { // only use frag when no parent to query frag = node[OWNER_DOCUMENT].createDocumentFragment(); frag.appendChild(node); root = frag; useFrag = true; } } root = root || node[OWNER_DOCUMENT]; id = Y.Selector._escapeId(Y.DOM.getId(node)); if (!id) { id = Y.guid(); Y.DOM.setId(node, id); } for (i = 0; (group = groups[i++]);) { // TODO: off-dom test group += '[id="' + id + '"]'; items = Y.Selector.query(group, root); for (j = 0; item = items[j++];) { if (item === node) { ret = true; break; } } if (ret) { break; } } if (useFrag) { // cleanup frag.removeChild(node); } }; } return ret; }, /** * A convenience method to emulate Y.Node's aNode.ancestor(selector). * @method ancestor * * @param {HTMLElement} node A node to start the query from. * @param {String} selector A CSS selector to test the node against. * @param {Boolean} testSelf optional Whether or not to include the node in the scan. * @return {HTMLElement} The ancestor node matching the selector, or null. * @static */ ancestor: function (node, selector, testSelf) { return Y.DOM.ancestor(node, function(n) { return Y.Selector.test(n, selector); }, testSelf); }, _parse: function(name, selector) { return selector.match(Y.Selector._types[name].re); }, _replace: function(name, selector) { var o = Y.Selector._types[name]; return selector.replace(o.re, o.token); }, _restore: function(name, selector, items) { if (items) { var token = Y.Selector._types[name].token, i, len; for (i = 0, len = items.length; i < len; ++i) { selector = selector.replace(token, items[i]); } } return selector; } }; Y.mix(Y.Selector, Selector, true); })(Y); }, '3.17.2', {"requires": ["dom-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('selector', function (Y, NAME) { }, '3.17.2', {"requires": ["selector-native"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('node-core', function (Y, NAME) { /** * The Node Utility provides a DOM-like interface for interacting with DOM nodes. * @module node * @main node * @submodule node-core */ /** * The Node class provides a wrapper for manipulating DOM Nodes. * Node properties can be accessed via the set/get methods. * Use `Y.one()` to retrieve Node instances. * * NOTE: Node properties are accessed using * the set and get methods. * * @class Node * @constructor * @param {HTMLElement} node the DOM node to be mapped to the Node instance. * @uses EventTarget */ // "globals" var DOT = '.', NODE_NAME = 'nodeName', NODE_TYPE = 'nodeType', OWNER_DOCUMENT = 'ownerDocument', TAG_NAME = 'tagName', UID = '_yuid', EMPTY_OBJ = {}, _slice = Array.prototype.slice, Y_DOM = Y.DOM, Y_Node = function(node) { if (!this.getDOMNode) { // support optional "new" return new Y_Node(node); } if (typeof node == 'string') { node = Y_Node._fromString(node); if (!node) { return null; // NOTE: return } } var uid = (node.nodeType !== 9) ? node.uniqueID : node[UID]; if (uid && Y_Node._instances[uid] && Y_Node._instances[uid]._node !== node) { node[UID] = null; // unset existing uid to prevent collision (via clone or hack) } uid = uid || Y.stamp(node); if (!uid) { // stamp failed; likely IE non-HTMLElement uid = Y.guid(); } this[UID] = uid; /** * The underlying DOM node bound to the Y.Node instance * @property _node * @type HTMLElement * @private */ this._node = node; this._stateProxy = node; // when augmented with Attribute if (this._initPlugins) { // when augmented with Plugin.Host this._initPlugins(); } }, // used with previous/next/ancestor tests _wrapFn = function(fn) { var ret = null; if (fn) { ret = (typeof fn == 'string') ? function(n) { return Y.Selector.test(n, fn); } : function(n) { return fn(Y.one(n)); }; } return ret; }; // end "globals" Y_Node.ATTRS = {}; Y_Node.DOM_EVENTS = {}; Y_Node._fromString = function(node) { if (node) { if (node.indexOf('doc') === 0) { // doc OR document node = Y.config.doc; } else if (node.indexOf('win') === 0) { // win OR window node = Y.config.win; } else { node = Y.Selector.query(node, null, true); } } return node || null; }; /** * The name of the component * @static * @type String * @property NAME */ Y_Node.NAME = 'node'; /* * The pattern used to identify ARIA attributes */ Y_Node.re_aria = /^(?:role$|aria-)/; Y_Node.SHOW_TRANSITION = 'fadeIn'; Y_Node.HIDE_TRANSITION = 'fadeOut'; /** * A list of Node instances that have been created * @private * @type Object * @property _instances * @static * */ Y_Node._instances = {}; /** * Retrieves the DOM node bound to a Node instance * @method getDOMNode * @static * * @param {Node|HTMLElement} node The Node instance or an HTMLElement * @return {HTMLElement} The DOM node bound to the Node instance. If a DOM node is passed * as the node argument, it is simply returned. */ Y_Node.getDOMNode = function(node) { if (node) { return (node.nodeType) ? node : node._node || null; } return null; }; /** * Checks Node return values and wraps DOM Nodes as Y.Node instances * and DOM Collections / Arrays as Y.NodeList instances. * Other return values just pass thru. If undefined is returned (e.g. no return) * then the Node instance is returned for chainability. * @method scrubVal * @static * * @param {HTMLElement|HTMLElement[]|Node} node The Node instance or an HTMLElement * @return {Node | NodeList | Any} Depends on what is returned from the DOM node. */ Y_Node.scrubVal = function(val, node) { if (val) { // only truthy values are risky if (typeof val == 'object' || typeof val == 'function') { // safari nodeList === function if (NODE_TYPE in val || Y_DOM.isWindow(val)) {// node || window val = Y.one(val); } else if ((val.item && !val._nodes) || // dom collection or Node instance (val[0] && val[0][NODE_TYPE])) { // array of DOM Nodes val = Y.all(val); } } } else if (typeof val === 'undefined') { val = node; // for chaining } else if (val === null) { val = null; // IE: DOM null not the same as null } return val; }; /** * Adds methods to the Y.Node prototype, routing through scrubVal. * @method addMethod * @static * * @param {String} name The name of the method to add * @param {Function} fn The function that becomes the method * @param {Object} context An optional context to call the method with * (defaults to the Node instance) * @return {any} Depends on what is returned from the DOM node. */ Y_Node.addMethod = function(name, fn, context) { if (name && fn && typeof fn == 'function') { Y_Node.prototype[name] = function() { var args = _slice.call(arguments), node = this, ret; if (args[0] && args[0]._node) { args[0] = args[0]._node; } if (args[1] && args[1]._node) { args[1] = args[1]._node; } args.unshift(node._node); ret = fn.apply(context || node, args); if (ret) { // scrub truthy ret = Y_Node.scrubVal(ret, node); } (typeof ret != 'undefined') || (ret = node); return ret; }; } else { } }; /** * Imports utility methods to be added as Y.Node methods. * @method importMethod * @static * * @param {Object} host The object that contains the method to import. * @param {String} name The name of the method to import * @param {String} altName An optional name to use in place of the host name * @param {Object} context An optional context to call the method with */ Y_Node.importMethod = function(host, name, altName) { if (typeof name == 'string') { altName = altName || name; Y_Node.addMethod(altName, host[name], host); } else { Y.Array.each(name, function(n) { Y_Node.importMethod(host, n); }); } }; /** * Retrieves a NodeList based on the given CSS selector. * @method all * * @param {string} selector The CSS selector to test against. * @return {NodeList} A NodeList instance for the matching HTMLCollection/Array. * @for YUI */ /** * Returns a single Node instance bound to the node or the * first element matching the given selector. Returns null if no match found. * Note: For chaining purposes you may want to * use Y.all, which returns a NodeList when no match is found. * @method one * @param {String | HTMLElement} node a node or Selector * @return {Node | null} a Node instance or null if no match found. * @for YUI */ /** * Returns a single Node instance bound to the node or the * first element matching the given selector. Returns null if no match found. * Note: For chaining purposes you may want to * use Y.all, which returns a NodeList when no match is found. * @method one * @static * @param {String | HTMLElement} node a node or Selector * @return {Node | null} a Node instance or null if no match found. * @for Node */ Y_Node.one = function(node) { var instance = null, cachedNode, uid; if (node) { if (typeof node == 'string') { node = Y_Node._fromString(node); if (!node) { return null; // NOTE: return } } else if (node.getDOMNode) { return node; // NOTE: return } if (node.nodeType || Y.DOM.isWindow(node)) { // avoid bad input (numbers, boolean, etc) uid = (node.uniqueID && node.nodeType !== 9) ? node.uniqueID : node._yuid; instance = Y_Node._instances[uid]; // reuse exising instances cachedNode = instance ? instance._node : null; if (!instance || (cachedNode && node !== cachedNode)) { // new Node when nodes don't match instance = new Y_Node(node); if (node.nodeType != 11) { // dont cache document fragment Y_Node._instances[instance[UID]] = instance; // cache node } } } } return instance; }; /** * The default setter for DOM properties * Called with instance context (this === the Node instance) * @method DEFAULT_SETTER * @static * @param {String} name The attribute/property being set * @param {any} val The value to be set * @return {any} The value */ Y_Node.DEFAULT_SETTER = function(name, val) { var node = this._stateProxy, strPath; if (name.indexOf(DOT) > -1) { strPath = name; name = name.split(DOT); // only allow when defined on node Y.Object.setValue(node, name, val); } else if (typeof node[name] != 'undefined') { // pass thru DOM properties node[name] = val; } return val; }; /** * The default getter for DOM properties * Called with instance context (this === the Node instance) * @method DEFAULT_GETTER * @static * @param {String} name The attribute/property to look up * @return {any} The current value */ Y_Node.DEFAULT_GETTER = function(name) { var node = this._stateProxy, val; if (name.indexOf && name.indexOf(DOT) > -1) { val = Y.Object.getValue(node, name.split(DOT)); } else if (typeof node[name] != 'undefined') { // pass thru from DOM val = node[name]; } return val; }; Y.mix(Y_Node.prototype, { DATA_PREFIX: 'data-', /** * The method called when outputting Node instances as strings * @method toString * @return {String} A string representation of the Node instance */ toString: function() { var str = this[UID] + ': not bound to a node', node = this._node, attrs, id, className; if (node) { attrs = node.attributes; id = (attrs && attrs.id) ? node.getAttribute('id') : null; className = (attrs && attrs.className) ? node.getAttribute('className') : null; str = node[NODE_NAME]; if (id) { str += '#' + id; } if (className) { str += '.' + className.replace(' ', '.'); } // TODO: add yuid? str += ' ' + this[UID]; } return str; }, /** * Returns an attribute value on the Node instance. * Unless pre-configured (via `Node.ATTRS`), get hands * off to the underlying DOM node. Only valid * attributes/properties for the node will be queried. * @method get * @param {String} attr The attribute * @return {any} The current value of the attribute */ get: function(attr) { var val; if (this._getAttr) { // use Attribute imple val = this._getAttr(attr); } else { val = this._get(attr); } if (val) { val = Y_Node.scrubVal(val, this); } else if (val === null) { val = null; // IE: DOM null is not true null (even though they ===) } return val; }, /** * Helper method for get. * @method _get * @private * @param {String} attr The attribute * @return {any} The current value of the attribute */ _get: function(attr) { var attrConfig = Y_Node.ATTRS[attr], val; if (attrConfig && attrConfig.getter) { val = attrConfig.getter.call(this); } else if (Y_Node.re_aria.test(attr)) { val = this._node.getAttribute(attr, 2); } else { val = Y_Node.DEFAULT_GETTER.apply(this, arguments); } return val; }, /** * Sets an attribute on the Node instance. * Unless pre-configured (via Node.ATTRS), set hands * off to the underlying DOM node. Only valid * attributes/properties for the node will be set. * To set custom attributes use setAttribute. * @method set * @param {String} attr The attribute to be set. * @param {any} val The value to set the attribute to. * @chainable */ set: function(attr, val) { var attrConfig = Y_Node.ATTRS[attr]; if (this._setAttr) { // use Attribute imple this._setAttr.apply(this, arguments); } else { // use setters inline if (attrConfig && attrConfig.setter) { attrConfig.setter.call(this, val, attr); } else if (Y_Node.re_aria.test(attr)) { // special case Aria this._node.setAttribute(attr, val); } else { Y_Node.DEFAULT_SETTER.apply(this, arguments); } } return this; }, /** * Sets multiple attributes. * @method setAttrs * @param {Object} attrMap an object of name/value pairs to set * @chainable */ setAttrs: function(attrMap) { if (this._setAttrs) { // use Attribute imple this._setAttrs(attrMap); } else { // use setters inline Y.Object.each(attrMap, function(v, n) { this.set(n, v); }, this); } return this; }, /** * Returns an object containing the values for the requested attributes. * @method getAttrs * @param {Array} attrs an array of attributes to get values * @return {Object} An object with attribute name/value pairs. */ getAttrs: function(attrs) { var ret = {}; if (this._getAttrs) { // use Attribute imple this._getAttrs(attrs); } else { // use setters inline Y.Array.each(attrs, function(v, n) { ret[v] = this.get(v); }, this); } return ret; }, /** * Compares nodes to determine if they match. * Node instances can be compared to each other and/or HTMLElements. * @method compareTo * @param {HTMLElement | Node} refNode The reference node to compare to the node. * @return {Boolean} True if the nodes match, false if they do not. */ compareTo: function(refNode) { var node = this._node; if (refNode && refNode._node) { refNode = refNode._node; } return node === refNode; }, /** * Determines whether the node is appended to the document. * @method inDoc * @param {Node|HTMLElement} doc optional An optional document to check against. * Defaults to current document. * @return {Boolean} Whether or not this node is appended to the document. */ inDoc: function(doc) { var node = this._node; if (node) { doc = (doc) ? doc._node || doc : node[OWNER_DOCUMENT]; if (doc.documentElement) { return Y_DOM.contains(doc.documentElement, node); } } return false; }, getById: function(id) { var node = this._node, ret = Y_DOM.byId(id, node[OWNER_DOCUMENT]); if (ret && Y_DOM.contains(node, ret)) { ret = Y.one(ret); } else { ret = null; } return ret; }, /** * Returns the nearest ancestor that passes the test applied by supplied boolean method. * @method ancestor * @param {String | Function} fn A selector string or boolean method for testing elements. * If a function is used, it receives the current node being tested as the only argument. * If fn is not passed as an argument, the parent node will be returned. * @param {Boolean} testSelf optional Whether or not to include the element in the scan * @param {String | Function} stopFn optional A selector string or boolean * method to indicate when the search should stop. The search bails when the function * returns true or the selector matches. * If a function is used, it receives the current node being tested as the only argument. * @return {Node} The matching Node instance or null if not found */ ancestor: function(fn, testSelf, stopFn) { // testSelf is optional, check for stopFn as 2nd arg if (arguments.length === 2 && (typeof testSelf == 'string' || typeof testSelf == 'function')) { stopFn = testSelf; } return Y.one(Y_DOM.ancestor(this._node, _wrapFn(fn), testSelf, _wrapFn(stopFn))); }, /** * Returns the ancestors that pass the test applied by supplied boolean method. * @method ancestors * @param {String | Function} fn A selector string or boolean method for testing elements. * @param {Boolean} testSelf optional Whether or not to include the element in the scan * If a function is used, it receives the current node being tested as the only argument. * @return {NodeList} A NodeList instance containing the matching elements */ ancestors: function(fn, testSelf, stopFn) { if (arguments.length === 2 && (typeof testSelf == 'string' || typeof testSelf == 'function')) { stopFn = testSelf; } return Y.all(Y_DOM.ancestors(this._node, _wrapFn(fn), testSelf, _wrapFn(stopFn))); }, /** * Returns the previous matching sibling. * Returns the nearest element node sibling if no method provided. * @method previous * @param {String | Function} fn A selector or boolean method for testing elements. * If a function is used, it receives the current node being tested as the only argument. * @param {Boolean} [all] Whether text nodes as well as element nodes should be returned, or * just element nodes will be returned(default) * @return {Node} Node instance or null if not found */ previous: function(fn, all) { return Y.one(Y_DOM.elementByAxis(this._node, 'previousSibling', _wrapFn(fn), all)); }, /** * Returns the next matching sibling. * Returns the nearest element node sibling if no method provided. * @method next * @param {String | Function} fn A selector or boolean method for testing elements. * If a function is used, it receives the current node being tested as the only argument. * @param {Boolean} [all] Whether text nodes as well as element nodes should be returned, or * just element nodes will be returned(default) * @return {Node} Node instance or null if not found */ next: function(fn, all) { return Y.one(Y_DOM.elementByAxis(this._node, 'nextSibling', _wrapFn(fn), all)); }, /** * Returns all matching siblings. * Returns all siblings if no method provided. * @method siblings * @param {String | Function} fn A selector or boolean method for testing elements. * If a function is used, it receives the current node being tested as the only argument. * @return {NodeList} NodeList instance bound to found siblings */ siblings: function(fn) { return Y.all(Y_DOM.siblings(this._node, _wrapFn(fn))); }, /** * Retrieves a single Node instance, the first element matching the given * CSS selector. * Returns null if no match found. * @method one * * @param {string} selector The CSS selector to test against. * @return {Node | null} A Node instance for the matching HTMLElement or null * if no match found. */ one: function(selector) { return Y.one(Y.Selector.query(selector, this._node, true)); }, /** * Retrieves a NodeList based on the given CSS selector. * @method all * * @param {string} selector The CSS selector to test against. * @return {NodeList} A NodeList instance for the matching HTMLCollection/Array. */ all: function(selector) { var nodelist; if (this._node) { nodelist = Y.all(Y.Selector.query(selector, this._node)); nodelist._query = selector; nodelist._queryRoot = this._node; } return nodelist || Y.all([]); }, // TODO: allow fn test /** * Test if the supplied node matches the supplied selector. * @method test * * @param {string} selector The CSS selector to test against. * @return {boolean} Whether or not the node matches the selector. */ test: function(selector) { return Y.Selector.test(this._node, selector); }, /** * Removes the node from its parent. * Shortcut for myNode.get('parentNode').removeChild(myNode); * @method remove * @param {Boolean} destroy whether or not to call destroy() on the node * after removal. * @chainable * */ remove: function(destroy) { var node = this._node; if (node && node.parentNode) { node.parentNode.removeChild(node); } if (destroy) { this.destroy(); } return this; }, /** * Replace the node with the other node. This is a DOM update only * and does not change the node bound to the Node instance. * Shortcut for myNode.get('parentNode').replaceChild(newNode, myNode); * @method replace * @param {Node | HTMLElement} newNode Node to be inserted * @chainable * */ replace: function(newNode) { var node = this._node; if (typeof newNode == 'string') { newNode = Y_Node.create(newNode); } node.parentNode.replaceChild(Y_Node.getDOMNode(newNode), node); return this; }, /** * @method replaceChild * @for Node * @param {String | HTMLElement | Node} node Node to be inserted * @param {HTMLElement | Node} refNode Node to be replaced * @return {Node} The replaced node */ replaceChild: function(node, refNode) { if (typeof node == 'string') { node = Y_DOM.create(node); } return Y.one(this._node.replaceChild(Y_Node.getDOMNode(node), Y_Node.getDOMNode(refNode))); }, /** * Nulls internal node references, removes any plugins and event listeners. * Note that destroy() will not remove the node from its parent or from the DOM. For that * functionality, call remove(true). * @method destroy * @param {Boolean} recursivePurge (optional) Whether or not to remove listeners from the * node's subtree (default is false) * */ destroy: function(recursive) { var UID = Y.config.doc.uniqueID ? 'uniqueID' : '_yuid', instance; this.purge(); // TODO: only remove events add via this Node if (this.unplug) { // may not be a PluginHost this.unplug(); } this.clearData(); if (recursive) { Y.NodeList.each(this.all('*'), function(node) { instance = Y_Node._instances[node[UID]]; if (instance) { instance.destroy(); } else { // purge in case added by other means Y.Event.purgeElement(node); } }); } this._node = null; this._stateProxy = null; delete Y_Node._instances[this._yuid]; }, /** * Invokes a method on the Node instance * @method invoke * @param {String} method The name of the method to invoke * @param {any} [args*] Arguments to invoke the method with. * @return {any} Whatever the underly method returns. * DOM Nodes and Collections return values * are converted to Node/NodeList instances. * */ invoke: function(method, a, b, c, d, e) { var node = this._node, ret; if (a && a._node) { a = a._node; } if (b && b._node) { b = b._node; } ret = node[method](a, b, c, d, e); return Y_Node.scrubVal(ret, this); }, /** * @method swap * @description Swap DOM locations with the given node. * This does not change which DOM node each Node instance refers to. * @param {Node} otherNode The node to swap with * @chainable */ swap: Y.config.doc.documentElement.swapNode ? function(otherNode) { this._node.swapNode(Y_Node.getDOMNode(otherNode)); } : function(otherNode) { otherNode = Y_Node.getDOMNode(otherNode); var node = this._node, parent = otherNode.parentNode, nextSibling = otherNode.nextSibling; if (nextSibling === node) { parent.insertBefore(node, otherNode); } else if (otherNode === node.nextSibling) { parent.insertBefore(otherNode, node); } else { node.parentNode.replaceChild(otherNode, node); Y_DOM.addHTML(parent, node, nextSibling); } return this; }, hasMethod: function(method) { var node = this._node; return !!(node && method in node && typeof node[method] != 'unknown' && (typeof node[method] == 'function' || String(node[method]).indexOf('function') === 1)); // IE reports as object, prepends space }, isFragment: function() { return (this.get('nodeType') === 11); }, /** * Removes and destroys all of the nodes within the node. * @method empty * @chainable */ empty: function() { this.get('childNodes').remove().destroy(true); return this; }, /** * Returns the DOM node bound to the Node instance * @method getDOMNode * @return {HTMLElement} */ getDOMNode: function() { return this._node; } }, true); Y.Node = Y_Node; Y.one = Y_Node.one; /** * The NodeList module provides support for managing collections of Nodes. * @module node * @submodule node-core */ /** * The NodeList class provides a wrapper for manipulating DOM NodeLists. * NodeList properties can be accessed via the set/get methods. * Use Y.all() to retrieve NodeList instances. * * @class NodeList * @constructor * @param nodes {String|element|Node|Array} A selector, DOM element, Node, list of DOM elements, or list of Nodes with which to populate this NodeList. */ var NodeList = function(nodes) { var tmp = []; if (nodes) { if (typeof nodes === 'string') { // selector query this._query = nodes; nodes = Y.Selector.query(nodes); } else if (nodes.nodeType || Y_DOM.isWindow(nodes)) { // domNode || window nodes = [nodes]; } else if (nodes._node) { // Y.Node nodes = [nodes._node]; } else if (nodes[0] && nodes[0]._node) { // allow array of Y.Nodes Y.Array.each(nodes, function(node) { if (node._node) { tmp.push(node._node); } }); nodes = tmp; } else { // array of domNodes or domNodeList (no mixed array of Y.Node/domNodes) nodes = Y.Array(nodes, 0, true); } } /** * The underlying array of DOM nodes bound to the Y.NodeList instance * @property _nodes * @private */ this._nodes = nodes || []; }; NodeList.NAME = 'NodeList'; /** * Retrieves the DOM nodes bound to a NodeList instance * @method getDOMNodes * @static * * @param {NodeList} nodelist The NodeList instance * @return {Array} The array of DOM nodes bound to the NodeList */ NodeList.getDOMNodes = function(nodelist) { return (nodelist && nodelist._nodes) ? nodelist._nodes : nodelist; }; NodeList.each = function(instance, fn, context) { var nodes = instance._nodes; if (nodes && nodes.length) { Y.Array.each(nodes, fn, context || instance); } else { } }; NodeList.addMethod = function(name, fn, context) { if (name && fn) { NodeList.prototype[name] = function() { var ret = [], args = arguments; Y.Array.each(this._nodes, function(node) { var UID = (node.uniqueID && node.nodeType !== 9 ) ? 'uniqueID' : '_yuid', instance = Y.Node._instances[node[UID]], ctx, result; if (!instance) { instance = NodeList._getTempNode(node); } ctx = context || instance; result = fn.apply(ctx, args); if (result !== undefined && result !== instance) { ret[ret.length] = result; } }); // TODO: remove tmp pointer return ret.length ? ret : this; }; } else { } }; NodeList.importMethod = function(host, name, altName) { if (typeof name === 'string') { altName = altName || name; NodeList.addMethod(name, host[name]); } else { Y.Array.each(name, function(n) { NodeList.importMethod(host, n); }); } }; NodeList._getTempNode = function(node) { var tmp = NodeList._tempNode; if (!tmp) { tmp = Y.Node.create('
'); NodeList._tempNode = tmp; } tmp._node = node; tmp._stateProxy = node; return tmp; }; Y.mix(NodeList.prototype, { _invoke: function(method, args, getter) { var ret = (getter) ? [] : this; this.each(function(node) { var val = node[method].apply(node, args); if (getter) { ret.push(val); } }); return ret; }, /** * Retrieves the Node instance at the given index. * @method item * * @param {Number} index The index of the target Node. * @return {Node} The Node instance at the given index. */ item: function(index) { return Y.one((this._nodes || [])[index]); }, /** * Applies the given function to each Node in the NodeList. * @method each * @param {Function} fn The function to apply. It receives 3 arguments: * the current node instance, the node's index, and the NodeList instance * @param {Object} context optional An optional context to apply the function with * Default context is the current Node instance * @chainable */ each: function(fn, context) { var instance = this; Y.Array.each(this._nodes, function(node, index) { node = Y.one(node); return fn.call(context || node, node, index, instance); }); return instance; }, batch: function(fn, context) { var nodelist = this; Y.Array.each(this._nodes, function(node, index) { var instance = Y.Node._instances[node[UID]]; if (!instance) { instance = NodeList._getTempNode(node); } return fn.call(context || instance, instance, index, nodelist); }); return nodelist; }, /** * Executes the function once for each node until a true value is returned. * @method some * @param {Function} fn The function to apply. It receives 3 arguments: * the current node instance, the node's index, and the NodeList instance * @param {Object} context optional An optional context to execute the function from. * Default context is the current Node instance * @return {Boolean} Whether or not the function returned true for any node. */ some: function(fn, context) { var instance = this; return Y.Array.some(this._nodes, function(node, index) { node = Y.one(node); context = context || node; return fn.call(context, node, index, instance); }); }, /** * Creates a documenFragment from the nodes bound to the NodeList instance * @method toFrag * @return {Node} a Node instance bound to the documentFragment */ toFrag: function() { return Y.one(Y.DOM._nl2frag(this._nodes)); }, /** * Returns the index of the node in the NodeList instance * or -1 if the node isn't found. * @method indexOf * @param {Node | HTMLElement} node the node to search for * @return {Number} the index of the node value or -1 if not found */ indexOf: function(node) { return Y.Array.indexOf(this._nodes, Y.Node.getDOMNode(node)); }, /** * Filters the NodeList instance down to only nodes matching the given selector. * @method filter * @param {String} selector The selector to filter against * @return {NodeList} NodeList containing the updated collection * @see Selector */ filter: function(selector) { return Y.all(Y.Selector.filter(this._nodes, selector)); }, /** * Creates a new NodeList containing all nodes at every n indices, where * remainder n % index equals r. * (zero-based index). * @method modulus * @param {Number} n The offset to use (return every nth node) * @param {Number} r An optional remainder to use with the modulus operation (defaults to zero) * @return {NodeList} NodeList containing the updated collection */ modulus: function(n, r) { r = r || 0; var nodes = []; NodeList.each(this, function(node, i) { if (i % n === r) { nodes.push(node); } }); return Y.all(nodes); }, /** * Creates a new NodeList containing all nodes at odd indices * (zero-based index). * @method odd * @return {NodeList} NodeList containing the updated collection */ odd: function() { return this.modulus(2, 1); }, /** * Creates a new NodeList containing all nodes at even indices * (zero-based index), including zero. * @method even * @return {NodeList} NodeList containing the updated collection */ even: function() { return this.modulus(2); }, destructor: function() { }, /** * Reruns the initial query, when created using a selector query * @method refresh * @chainable */ refresh: function() { var doc, nodes = this._nodes, query = this._query, root = this._queryRoot; if (query) { if (!root) { if (nodes && nodes[0] && nodes[0].ownerDocument) { root = nodes[0].ownerDocument; } } this._nodes = Y.Selector.query(query, root); } return this; }, /** * Returns the current number of items in the NodeList. * @method size * @return {Number} The number of items in the NodeList. */ size: function() { return this._nodes.length; }, /** * Determines if the instance is bound to any nodes * @method isEmpty * @return {Boolean} Whether or not the NodeList is bound to any nodes */ isEmpty: function() { return this._nodes.length < 1; }, toString: function() { var str = '', errorMsg = this[UID] + ': not bound to any nodes', nodes = this._nodes, node; if (nodes && nodes[0]) { node = nodes[0]; str += node[NODE_NAME]; if (node.id) { str += '#' + node.id; } if (node.className) { str += '.' + node.className.replace(' ', '.'); } if (nodes.length > 1) { str += '...[' + nodes.length + ' items]'; } } return str || errorMsg; }, /** * Returns the DOM node bound to the Node instance * @method getDOMNodes * @return {Array} */ getDOMNodes: function() { return this._nodes; } }, true); NodeList.importMethod(Y.Node.prototype, [ /** * Called on each Node instance. Nulls internal node references, * removes any plugins and event listeners * @method destroy * @param {Boolean} recursivePurge (optional) Whether or not to * remove listeners from the node's subtree (default is false) * @see Node.destroy */ 'destroy', /** * Called on each Node instance. Removes and destroys all of the nodes * within the node * @method empty * @chainable * @see Node.empty */ 'empty', /** * Called on each Node instance. Removes the node from its parent. * Shortcut for myNode.get('parentNode').removeChild(myNode); * @method remove * @param {Boolean} destroy whether or not to call destroy() on the node * after removal. * @chainable * @see Node.remove */ 'remove', /** * Called on each Node instance. Sets an attribute on the Node instance. * Unless pre-configured (via Node.ATTRS), set hands * off to the underlying DOM node. Only valid * attributes/properties for the node will be set. * To set custom attributes use setAttribute. * @method set * @param {String} attr The attribute to be set. * @param {any} val The value to set the attribute to. * @chainable * @see Node.set */ 'set' ]); // one-off implementation to convert array of Nodes to NodeList // e.g. Y.all('input').get('parentNode'); /** Called on each Node instance * @method get * @see Node */ NodeList.prototype.get = function(attr) { var ret = [], nodes = this._nodes, isNodeList = false, getTemp = NodeList._getTempNode, instance, val; if (nodes[0]) { instance = Y.Node._instances[nodes[0]._yuid] || getTemp(nodes[0]); val = instance._get(attr); if (val && val.nodeType) { isNodeList = true; } } Y.Array.each(nodes, function(node) { instance = Y.Node._instances[node._yuid]; if (!instance) { instance = getTemp(node); } val = instance._get(attr); if (!isNodeList) { // convert array of Nodes to NodeList val = Y.Node.scrubVal(val, instance); } ret.push(val); }); return (isNodeList) ? Y.all(ret) : ret; }; Y.NodeList = NodeList; Y.all = function(nodes) { return new NodeList(nodes); }; Y.Node.all = Y.all; /** * @module node * @submodule node-core */ var Y_NodeList = Y.NodeList, ArrayProto = Array.prototype, ArrayMethods = { /** Returns a new NodeList combining the given NodeList(s) * @for NodeList * @method concat * @param {NodeList | Array} valueN Arrays/NodeLists and/or values to * concatenate to the resulting NodeList * @return {NodeList} A new NodeList comprised of this NodeList joined with the input. */ 'concat': 1, /** Removes the last from the NodeList and returns it. * @for NodeList * @method pop * @return {Node | null} The last item in the NodeList, or null if the list is empty. */ 'pop': 0, /** Adds the given Node(s) to the end of the NodeList. * @for NodeList * @method push * @param {Node | HTMLElement} nodes One or more nodes to add to the end of the NodeList. */ 'push': 0, /** Removes the first item from the NodeList and returns it. * @for NodeList * @method shift * @return {Node | null} The first item in the NodeList, or null if the NodeList is empty. */ 'shift': 0, /** Returns a new NodeList comprising the Nodes in the given range. * @for NodeList * @method slice * @param {Number} begin Zero-based index at which to begin extraction. As a negative index, start indicates an offset from the end of the sequence. slice(-2) extracts the second-to-last element and the last element in the sequence. * @param {Number} end Zero-based index at which to end extraction. slice extracts up to but not including end. slice(1,4) extracts the second element through the fourth element (elements indexed 1, 2, and 3). As a negative index, end indicates an offset from the end of the sequence. slice(2,-1) extracts the third element through the second-to-last element in the sequence. If end is omitted, slice extracts to the end of the sequence. * @return {NodeList} A new NodeList comprised of this NodeList joined with the input. */ 'slice': 1, /** Changes the content of the NodeList, adding new elements while removing old elements. * @for NodeList * @method splice * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end. * @param {Number} howMany An integer indicating the number of old array elements to remove. If howMany is 0, no elements are removed. In this case, you should specify at least one new element. If no howMany parameter is specified (second syntax above, which is a SpiderMonkey extension), all elements after index are removed. * {Node | HTMLElement| element1, ..., elementN The elements to add to the array. If you don't specify any elements, splice simply removes elements from the array. * @return {NodeList} The element(s) removed. */ 'splice': 1, /** Adds the given Node(s) to the beginning of the NodeList. * @for NodeList * @method unshift * @param {Node | HTMLElement} nodes One or more nodes to add to the NodeList. */ 'unshift': 0 }; Y.Object.each(ArrayMethods, function(returnNodeList, name) { Y_NodeList.prototype[name] = function() { var args = [], i = 0, arg, ret; while (typeof (arg = arguments[i++]) != 'undefined') { // use DOM nodes/nodeLists args.push(arg._node || arg._nodes || arg); } ret = ArrayProto[name].apply(this._nodes, args); if (returnNodeList) { ret = Y.all(ret); } else { ret = Y.Node.scrubVal(ret); } return ret; }; }); /** * @module node * @submodule node-core */ Y.Array.each([ /** * Passes through to DOM method. * @for Node * @method removeChild * @param {HTMLElement | Node} node Node to be removed * @return {Node} The removed node */ 'removeChild', /** * Passes through to DOM method. * @method hasChildNodes * @return {Boolean} Whether or not the node has any childNodes */ 'hasChildNodes', /** * Passes through to DOM method. * @method cloneNode * @param {Boolean} deep Whether or not to perform a deep clone, which includes * subtree and attributes * @return {Node} The clone */ 'cloneNode', /** * Passes through to DOM method. * @method hasAttribute * @param {String} attribute The attribute to test for * @return {Boolean} Whether or not the attribute is present */ 'hasAttribute', /** * Passes through to DOM method. * @method scrollIntoView * @chainable */ 'scrollIntoView', /** * Passes through to DOM method. * @method getElementsByTagName * @param {String} tagName The tagName to collect * @return {NodeList} A NodeList representing the HTMLCollection */ 'getElementsByTagName', /** * Passes through to DOM method. * @method focus * @chainable */ 'focus', /** * Passes through to DOM method. * @method blur * @chainable */ 'blur', /** * Passes through to DOM method. * Only valid on FORM elements * @method submit * @chainable */ 'submit', /** * Passes through to DOM method. * Only valid on FORM elements * @method reset * @chainable */ 'reset', /** * Passes through to DOM method. * @method select * @chainable */ 'select', /** * Passes through to DOM method. * Only valid on TABLE elements * @method createCaption * @chainable */ 'createCaption' ], function(method) { Y.Node.prototype[method] = function(arg1, arg2, arg3) { var ret = this.invoke(method, arg1, arg2, arg3); return ret; }; }); /** * Passes through to DOM method. * @method removeAttribute * @param {String} attribute The attribute to be removed * @chainable */ // one-off implementation due to IE returning boolean, breaking chaining Y.Node.prototype.removeAttribute = function(attr) { var node = this._node; if (node) { node.removeAttribute(attr, 0); // comma zero for IE < 8 to force case-insensitive } return this; }; Y.Node.importMethod(Y.DOM, [ /** * Determines whether the node is an ancestor of another HTML element in the DOM hierarchy. * @method contains * @param {Node | HTMLElement} needle The possible node or descendent * @return {Boolean} Whether or not this node is the needle its ancestor */ 'contains', /** * Allows setting attributes on DOM nodes, normalizing in some cases. * This passes through to the DOM node, allowing for custom attributes. * @method setAttribute * @for Node * @chainable * @param {string} name The attribute name * @param {string} value The value to set */ 'setAttribute', /** * Allows getting attributes on DOM nodes, normalizing in some cases. * This passes through to the DOM node, allowing for custom attributes. * @method getAttribute * @for Node * @param {string} name The attribute name * @return {string} The attribute value */ 'getAttribute', /** * Wraps the given HTML around the node. * @method wrap * @param {String} html The markup to wrap around the node. * @chainable * @for Node */ 'wrap', /** * Removes the node's parent node. * @method unwrap * @chainable */ 'unwrap', /** * Applies a unique ID to the node if none exists * @method generateID * @return {String} The existing or generated ID */ 'generateID' ]); Y.NodeList.importMethod(Y.Node.prototype, [ /** * Allows getting attributes on DOM nodes, normalizing in some cases. * This passes through to the DOM node, allowing for custom attributes. * @method getAttribute * @see Node * @for NodeList * @param {string} name The attribute name * @return {string} The attribute value */ 'getAttribute', /** * Allows setting attributes on DOM nodes, normalizing in some cases. * This passes through to the DOM node, allowing for custom attributes. * @method setAttribute * @see Node * @for NodeList * @chainable * @param {string} name The attribute name * @param {string} value The value to set */ 'setAttribute', /** * Allows for removing attributes on DOM nodes. * This passes through to the DOM node, allowing for custom attributes. * @method removeAttribute * @see Node * @for NodeList * @param {string} name The attribute to remove */ 'removeAttribute', /** * Removes the parent node from node in the list. * @method unwrap * @chainable */ 'unwrap', /** * Wraps the given HTML around each node. * @method wrap * @param {String} html The markup to wrap around the node. * @chainable */ 'wrap', /** * Applies a unique ID to each node if none exists * @method generateID * @return {String} The existing or generated ID */ 'generateID' ]); }, '3.17.2', {"requires": ["dom-core", "selector"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('node-base', function (Y, NAME) { /** * @module node * @submodule node-base */ var methods = [ /** * Determines whether the node has the given className. * @method hasClass * @for Node * @param {String} className the class name to search for * @return {Boolean} Whether or not the node has the specified class */ 'hasClass', /** * Adds a class name to the node. * @method addClass * @param {String} className the class name to add to the node's class attribute * @chainable */ 'addClass', /** * Removes a class name from the node. * @method removeClass * @param {String} className the class name to remove from the node's class attribute * @chainable */ 'removeClass', /** * Replace a class with another class on the node. * If no oldClassName is present, the newClassName is simply added. * @method replaceClass * @param {String} oldClassName the class name to be replaced * @param {String} newClassName the class name that will be replacing the old class name * @chainable */ 'replaceClass', /** * If the className exists on the node it is removed, if it doesn't exist it is added. * @method toggleClass * @param {String} className the class name to be toggled * @param {Boolean} force Option to force adding or removing the class. * @chainable */ 'toggleClass' ]; Y.Node.importMethod(Y.DOM, methods); /** * Determines whether each node has the given className. * @method hasClass * @see Node.hasClass * @for NodeList * @param {String} className the class name to search for * @return {Array} An array of booleans for each node bound to the NodeList. */ /** * Adds a class name to each node. * @method addClass * @see Node.addClass * @param {String} className the class name to add to each node's class attribute * @chainable */ /** * Removes a class name from each node. * @method removeClass * @see Node.removeClass * @param {String} className the class name to remove from each node's class attribute * @chainable */ /** * Replace a class with another class for each node. * If no oldClassName is present, the newClassName is simply added. * @method replaceClass * @see Node.replaceClass * @param {String} oldClassName the class name to be replaced * @param {String} newClassName the class name that will be replacing the old class name * @chainable */ /** * For each node, if the className exists on the node it is removed, if it doesn't exist it is added. * @method toggleClass * @see Node.toggleClass * @param {String} className the class name to be toggled * @chainable */ Y.NodeList.importMethod(Y.Node.prototype, methods); /** * @module node * @submodule node-base */ var Y_Node = Y.Node, Y_DOM = Y.DOM; /** * Returns a new dom node using the provided markup string. * @method create * @static * @param {String} html The markup used to create the element. * Use `Y.Escape.html()` * to escape html content. * @param {HTMLDocument} doc An optional document context * @return {Node} A Node instance bound to a DOM node or fragment * @for Node */ Y_Node.create = function(html, doc) { if (doc && doc._node) { doc = doc._node; } return Y.one(Y_DOM.create(html, doc)); }; Y.mix(Y_Node.prototype, { /** * Creates a new Node using the provided markup string. * @method create * @param {String} html The markup used to create the element. * Use `Y.Escape.html()` * to escape html content. * @param {HTMLDocument} doc An optional document context * @return {Node} A Node instance bound to a DOM node or fragment */ create: Y_Node.create, /** * Inserts the content before the reference node. * @method insert * @param {String | Node | HTMLElement | NodeList | HTMLCollection} content The content to insert. * Use `Y.Escape.html()` * to escape html content. * @param {Int | Node | HTMLElement | String} where The position to insert at. * Possible "where" arguments *
*
Y.Node
*
The Node to insert before
*
HTMLElement
*
The element to insert before
*
Int
*
The index of the child element to insert before
*
"replace"
*
Replaces the existing HTML
*
"before"
*
Inserts before the existing HTML
*
"before"
*
Inserts content before the node
*
"after"
*
Inserts content after the node
*
* @chainable */ insert: function(content, where) { this._insert(content, where); return this; }, _insert: function(content, where) { var node = this._node, ret = null; if (typeof where == 'number') { // allow index where = this._node.childNodes[where]; } else if (where && where._node) { // Node where = where._node; } if (content && typeof content != 'string') { // allow Node or NodeList/Array instances content = content._node || content._nodes || content; } ret = Y_DOM.addHTML(node, content, where); return ret; }, /** * Inserts the content as the firstChild of the node. * @method prepend * @param {String | Node | HTMLElement} content The content to insert. * Use `Y.Escape.html()` * to escape html content. * @chainable */ prepend: function(content) { return this.insert(content, 0); }, /** * Inserts the content as the lastChild of the node. * @method append * @param {String | Node | HTMLElement} content The content to insert. * Use `Y.Escape.html()` * to escape html content. * @chainable */ append: function(content) { return this.insert(content, null); }, /** * @method appendChild * @param {String | HTMLElement | Node} node Node to be appended. * Use `Y.Escape.html()` * to escape html content. * @return {Node} The appended node */ appendChild: function(node) { return Y_Node.scrubVal(this._insert(node)); }, /** * @method insertBefore * @param {String | HTMLElement | Node} newNode Node to be appended * @param {HTMLElement | Node} refNode Node to be inserted before. * Use `Y.Escape.html()` * to escape html content. * @return {Node} The inserted node */ insertBefore: function(newNode, refNode) { return Y.Node.scrubVal(this._insert(newNode, refNode)); }, /** * Appends the node to the given node. * @example * // appendTo returns the node that has been created beforehand * Y.Node.create('

').appendTo('body').set('text', 'hello world!'); * @method appendTo * @param {Node | HTMLElement | String} node The node to append to. * If `node` is a string it will be considered as a css selector and only the first matching node will be used. * @chainable */ appendTo: function(node) { Y.one(node).append(this); return this; }, // This method is deprecated, and is intentionally left undocumented. // Use `setHTML` instead. setContent: function(content) { this._insert(content, 'replace'); return this; }, // This method is deprecated, and is intentionally left undocumented. // Use `getHTML` instead. getContent: function() { var node = this; if (node._node.nodeType === 11) { // 11 === Node.DOCUMENT_FRAGMENT_NODE // "this", when it is a document fragment, must be cloned because // the nodes contained in the fragment actually disappear once // the fragment is appended anywhere node = node.create("
").append(node.cloneNode(true)); } return node.get("innerHTML"); } }); /** * Replaces the node's current html content with the content provided. * Note that this passes to innerHTML and is not escaped. * Use `Y.Escape.html()` * to escape html content or `set('text')` to add as text. * @method setHTML * @param {String | Node | HTMLElement | NodeList | HTMLCollection} content The content to insert * @chainable */ Y.Node.prototype.setHTML = Y.Node.prototype.setContent; /** * Returns the node's current html content (e.g. innerHTML) * @method getHTML * @return {String} The html content */ Y.Node.prototype.getHTML = Y.Node.prototype.getContent; Y.NodeList.importMethod(Y.Node.prototype, [ /** * Called on each Node instance * @for NodeList * @method append * @see Node.append */ 'append', /** * Called on each Node instance * @for NodeList * @method insert * @see Node.insert */ 'insert', /** * Called on each Node instance * @for NodeList * @method appendChild * @see Node.appendChild */ 'appendChild', /** * Called on each Node instance * @for NodeList * @method insertBefore * @see Node.insertBefore */ 'insertBefore', /** * Called on each Node instance * @for NodeList * @method prepend * @see Node.prepend */ 'prepend', 'setContent', 'getContent', /** * Called on each Node instance * Note that this passes to innerHTML and is not escaped. * Use `Y.Escape.html()` * to escape html content or `set('text')` to add as text. * @for NodeList * @method setHTML * @see Node.setHTML */ 'setHTML', /** * Called on each Node instance * @for NodeList * @method getHTML * @see Node.getHTML */ 'getHTML' ]); /** * @module node * @submodule node-base */ var Y_Node = Y.Node, Y_DOM = Y.DOM; /** * Static collection of configuration attributes for special handling * @property ATTRS * @static * @type object */ Y_Node.ATTRS = { /** * Allows for getting and setting the text of an element. * Formatting is preserved and special characters are treated literally. * @config text * @type String */ text: { getter: function() { return Y_DOM.getText(this._node); }, setter: function(content) { Y_DOM.setText(this._node, content); return content; } }, /** * Allows for getting and setting the text of an element. * Formatting is preserved and special characters are treated literally. * @config for * @type String */ 'for': { getter: function() { return Y_DOM.getAttribute(this._node, 'for'); }, setter: function(val) { Y_DOM.setAttribute(this._node, 'for', val); return val; } }, 'options': { getter: function() { return this._node.getElementsByTagName('option'); } }, /** * Returns a NodeList instance of all HTMLElement children. * @readOnly * @config children * @type NodeList */ 'children': { getter: function() { var node = this._node, children = node.children, childNodes, i, len; if (!children) { childNodes = node.childNodes; children = []; for (i = 0, len = childNodes.length; i < len; ++i) { if (childNodes[i].tagName) { children[children.length] = childNodes[i]; } } } return Y.all(children); } }, value: { getter: function() { return Y_DOM.getValue(this._node); }, setter: function(val) { Y_DOM.setValue(this._node, val); return val; } } }; Y.Node.importMethod(Y.DOM, [ /** * Allows setting attributes on DOM nodes, normalizing in some cases. * This passes through to the DOM node, allowing for custom attributes. * @method setAttribute * @for Node * @for NodeList * @chainable * @param {string} name The attribute name * @param {string} value The value to set */ 'setAttribute', /** * Allows getting attributes on DOM nodes, normalizing in some cases. * This passes through to the DOM node, allowing for custom attributes. * @method getAttribute * @for Node * @for NodeList * @param {string} name The attribute name * @return {string} The attribute value */ 'getAttribute' ]); /** * @module node * @submodule node-base */ var Y_Node = Y.Node; var Y_NodeList = Y.NodeList; /** * List of events that route to DOM events * @static * @property DOM_EVENTS * @for Node */ Y_Node.DOM_EVENTS = { abort: 1, beforeunload: 1, blur: 1, change: 1, click: 1, close: 1, command: 1, contextmenu: 1, copy: 1, cut: 1, dblclick: 1, DOMMouseScroll: 1, drag: 1, dragstart: 1, dragenter: 1, dragover: 1, dragleave: 1, dragend: 1, drop: 1, error: 1, focus: 1, key: 1, keydown: 1, keypress: 1, keyup: 1, load: 1, message: 1, mousedown: 1, mouseenter: 1, mouseleave: 1, mousemove: 1, mousemultiwheel: 1, mouseout: 1, mouseover: 1, mouseup: 1, mousewheel: 1, orientationchange: 1, paste: 1, reset: 1, resize: 1, select: 1, selectstart: 1, submit: 1, scroll: 1, textInput: 1, unload: 1, invalid: 1 }; // Add custom event adaptors to this list. This will make it so // that delegate, key, available, contentready, etc all will // be available through Node.on Y.mix(Y_Node.DOM_EVENTS, Y.Env.evt.plugins); Y.augment(Y_Node, Y.EventTarget); Y.mix(Y_Node.prototype, { /** * Removes event listeners from the node and (optionally) its subtree * @method purge * @param {Boolean} recurse (optional) Whether or not to remove listeners from the * node's subtree * @param {String} type (optional) Only remove listeners of the specified type * @chainable * */ purge: function(recurse, type) { Y.Event.purgeElement(this._node, recurse, type); return this; } }); Y.mix(Y.NodeList.prototype, { _prepEvtArgs: function(type, fn, context) { // map to Y.on/after signature (type, fn, nodes, context, arg1, arg2, etc) var args = Y.Array(arguments, 0, true); if (args.length < 2) { // type only (event hash) just add nodes args[2] = this._nodes; } else { args.splice(2, 0, this._nodes); } args[3] = context || this; // default to NodeList instance as context return args; }, /** Subscribe a callback function for each `Node` in the collection to execute in response to a DOM event. NOTE: Generally, the `on()` method should be avoided on `NodeLists`, in favor of using event delegation from a parent Node. See the Event user guide for details. Most DOM events are associated with a preventable default behavior, such as link clicks navigating to a new page. Callbacks are passed a `DOMEventFacade` object as their first argument (usually called `e`) that can be used to prevent this default behavior with `e.preventDefault()`. See the `DOMEventFacade` API for all available properties and methods on the object. By default, the `this` object will be the `NodeList` that the subscription came from, not the `Node` that received the event. Use `e.currentTarget` to refer to the `Node`. Returning `false` from a callback is supported as an alternative to calling `e.preventDefault(); e.stopPropagation();`. However, it is recommended to use the event methods. @example Y.all(".sku").on("keydown", function (e) { if (e.keyCode === 13) { e.preventDefault(); // Use e.currentTarget to refer to the individual Node var item = Y.MyApp.searchInventory( e.currentTarget.get('value') ); // etc ... } }); @method on @param {String} type The name of the event @param {Function} fn The callback to execute in response to the event @param {Object} [context] Override `this` object in callback @param {Any} [arg*] 0..n additional arguments to supply to the subscriber @return {EventHandle} A subscription handle capable of detaching that subscription @for NodeList **/ on: function(type, fn, context) { return Y.on.apply(Y, this._prepEvtArgs.apply(this, arguments)); }, /** * Applies an one-time event listener to each Node bound to the NodeList. * @method once * @param {String} type The event being listened for * @param {Function} fn The handler to call when the event fires * @param {Object} context The context to call the handler with. * Default is the NodeList instance. * @return {EventHandle} A subscription handle capable of detaching that * subscription * @for NodeList */ once: function(type, fn, context) { return Y.once.apply(Y, this._prepEvtArgs.apply(this, arguments)); }, /** * Applies an event listener to each Node bound to the NodeList. * The handler is called only after all on() handlers are called * and the event is not prevented. * @method after * @param {String} type The event being listened for * @param {Function} fn The handler to call when the event fires * @param {Object} context The context to call the handler with. * Default is the NodeList instance. * @return {EventHandle} A subscription handle capable of detaching that * subscription * @for NodeList */ after: function(type, fn, context) { return Y.after.apply(Y, this._prepEvtArgs.apply(this, arguments)); }, /** * Applies an one-time event listener to each Node bound to the NodeList * that will be called only after all on() handlers are called and the * event is not prevented. * * @method onceAfter * @param {String} type The event being listened for * @param {Function} fn The handler to call when the event fires * @param {Object} context The context to call the handler with. * Default is the NodeList instance. * @return {EventHandle} A subscription handle capable of detaching that * subscription * @for NodeList */ onceAfter: function(type, fn, context) { return Y.onceAfter.apply(Y, this._prepEvtArgs.apply(this, arguments)); } }); Y_NodeList.importMethod(Y.Node.prototype, [ /** * Called on each Node instance * @method detach * @see Node.detach * @for NodeList */ 'detach', /** Called on each Node instance * @method detachAll * @see Node.detachAll * @for NodeList */ 'detachAll' ]); /** Subscribe a callback function to execute in response to a DOM event or custom event. Most DOM events are associated with a preventable default behavior such as link clicks navigating to a new page. Callbacks are passed a `DOMEventFacade` object as their first argument (usually called `e`) that can be used to prevent this default behavior with `e.preventDefault()`. See the `DOMEventFacade` API for all available properties and methods on the object. If the event name passed as the first parameter is not a whitelisted DOM event, it will be treated as a custom event subscriptions, allowing `node.fire('customEventName')` later in the code. Refer to the Event user guide for the full DOM event whitelist. By default, the `this` object in the callback will refer to the subscribed `Node`. Returning `false` from a callback is supported as an alternative to calling `e.preventDefault(); e.stopPropagation();`. However, it is recommended to use the event methods. @example Y.one("#my-form").on("submit", function (e) { e.preventDefault(); // proceed with ajax form submission instead... }); @method on @param {String} type The name of the event @param {Function} fn The callback to execute in response to the event @param {Object} [context] Override `this` object in callback @param {Any} [arg*] 0..n additional arguments to supply to the subscriber @return {EventHandle} A subscription handle capable of detaching that subscription @for Node **/ Y.mix(Y.Node.ATTRS, { offsetHeight: { setter: function(h) { Y.DOM.setHeight(this._node, h); return h; }, getter: function() { return this._node.offsetHeight; } }, offsetWidth: { setter: function(w) { Y.DOM.setWidth(this._node, w); return w; }, getter: function() { return this._node.offsetWidth; } } }); Y.mix(Y.Node.prototype, { sizeTo: function(w, h) { var node; if (arguments.length < 2) { node = Y.one(w); w = node.get('offsetWidth'); h = node.get('offsetHeight'); } this.setAttrs({ offsetWidth: w, offsetHeight: h }); } }); if (!Y.config.doc.documentElement.hasAttribute) { // IE < 8 Y.Node.prototype.hasAttribute = function(attr) { if (attr === 'value') { if (this.get('value') !== "") { // IE < 8 fails to populate specified when set in HTML return true; } } return !!(this._node.attributes[attr] && this._node.attributes[attr].specified); }; } // IE throws an error when calling focus() on an element that's invisible, not // displayed, or disabled. Y.Node.prototype.focus = function () { try { this._node.focus(); } catch (e) { } return this; }; // IE throws error when setting input.type = 'hidden', // input.setAttribute('type', 'hidden') and input.attributes.type.value = 'hidden' Y.Node.ATTRS.type = { setter: function(val) { if (val === 'hidden') { try { this._node.type = 'hidden'; } catch(e) { this._node.style.display = 'none'; this._inputType = 'hidden'; } } else { try { // IE errors when changing the type from "hidden' this._node.type = val; } catch (e) { } } return val; }, getter: function() { return this._inputType || this._node.type; }, _bypassProxy: true // don't update DOM when using with Attribute }; if (Y.config.doc.createElement('form').elements.nodeType) { // IE: elements collection is also FORM node which trips up scrubVal. Y.Node.ATTRS.elements = { getter: function() { return this.all('input, textarea, button, select'); } }; } /** * Provides methods for managing custom Node data. * * @module node * @main node * @submodule node-data */ Y.mix(Y.Node.prototype, { _initData: function() { if (! ('_data' in this)) { this._data = {}; } }, /** * @method getData * @for Node * @description Retrieves arbitrary data stored on a Node instance. * If no data is associated with the Node, it will attempt to retrieve * a value from the corresponding HTML data attribute. (e.g. node.getData('foo') * will check node.getAttribute('data-foo')). * @param {string} name Optional name of the data field to retrieve. * If no name is given, all data is returned. * @return {any | Object} Whatever is stored at the given field, * or an object hash of all fields. */ getData: function(name) { this._initData(); var data = this._data, ret = data; if (arguments.length) { // single field if (name in data) { ret = data[name]; } else { // initialize from HTML attribute ret = this._getDataAttribute(name); } } else if (typeof data == 'object' && data !== null) { // all fields ret = {}; Y.Object.each(data, function(v, n) { ret[n] = v; }); ret = this._getDataAttributes(ret); } return ret; }, _getDataAttributes: function(ret) { ret = ret || {}; var i = 0, attrs = this._node.attributes, len = attrs.length, prefix = this.DATA_PREFIX, prefixLength = prefix.length, name; while (i < len) { name = attrs[i].name; if (name.indexOf(prefix) === 0) { name = name.substr(prefixLength); if (!(name in ret)) { // only merge if not already stored ret[name] = this._getDataAttribute(name); } } i += 1; } return ret; }, _getDataAttribute: function(name) { name = this.DATA_PREFIX + name; var node = this._node, attrs = node.attributes, data = attrs && attrs[name] && attrs[name].value; return data; }, /** * @method setData * @for Node * @description Stores arbitrary data on a Node instance. * This is not stored with the DOM node. * @param {string} name The name of the field to set. If no val * is given, name is treated as the data and overrides any existing data. * @param {any} val The value to be assigned to the field. * @chainable */ setData: function(name, val) { this._initData(); if (arguments.length > 1) { this._data[name] = val; } else { this._data = name; } return this; }, /** * @method clearData * @for Node * @description Clears internally stored data. * @param {string} name The name of the field to clear. If no name * is given, all data is cleared. * @chainable */ clearData: function(name) { if ('_data' in this) { if (typeof name != 'undefined') { delete this._data[name]; } else { delete this._data; } } return this; } }); Y.mix(Y.NodeList.prototype, { /** * @method getData * @for NodeList * @description Retrieves arbitrary data stored on each Node instance * bound to the NodeList. * @see Node * @param {string} name Optional name of the data field to retrieve. * If no name is given, all data is returned. * @return {Array} An array containing all of the data for each Node instance. * or an object hash of all fields. */ getData: function(name) { var args = (arguments.length) ? [name] : []; return this._invoke('getData', args, true); }, /** * @method setData * @for NodeList * @description Stores arbitrary data on each Node instance bound to the * NodeList. This is not stored with the DOM node. * @param {string} name The name of the field to set. If no name * is given, name is treated as the data and overrides any existing data. * @param {any} val The value to be assigned to the field. * @chainable */ setData: function(name, val) { var args = (arguments.length > 1) ? [name, val] : [name]; return this._invoke('setData', args); }, /** * @method clearData * @for NodeList * @description Clears data on all Node instances bound to the NodeList. * @param {string} name The name of the field to clear. If no name * is given, all data is cleared. * @chainable */ clearData: function(name) { var args = (arguments.length) ? [name] : []; return this._invoke('clearData', [name]); } }); }, '3.17.2', {"requires": ["event-base", "node-core", "dom-base", "dom-style"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('event-base', function (Y, NAME) { /* * DOM event listener abstraction layer * @module event * @submodule event-base */ /** * The domready event fires at the moment the browser's DOM is * usable. In most cases, this is before images are fully * downloaded, allowing you to provide a more responsive user * interface. * * In YUI 3, domready subscribers will be notified immediately if * that moment has already passed when the subscription is created. * * One exception is if the yui.js file is dynamically injected into * the page. If this is done, you must tell the YUI instance that * you did this in order for DOMReady (and window load events) to * fire normally. That configuration option is 'injected' -- set * it to true if the yui.js script is not included inline. * * This method is part of the 'event-ready' module, which is a * submodule of 'event'. * * @event domready * @for YUI */ Y.publish('domready', { fireOnce: true, async: true }); if (YUI.Env.DOMReady) { Y.fire('domready'); } else { Y.Do.before(function() { Y.fire('domready'); }, YUI.Env, '_ready'); } /** * Custom event engine, DOM event listener abstraction layer, synthetic DOM * events. * @module event * @submodule event-base */ /** * Wraps a DOM event, properties requiring browser abstraction are * fixed here. Provids a security layer when required. * @class DOMEventFacade * @param ev {Event} the DOM event * @param currentTarget {HTMLElement} the element the listener was attached to * @param wrapper {CustomEvent} the custom event wrapper for this DOM event */ var ua = Y.UA, EMPTY = {}, /** * webkit key remapping required for Safari < 3.1 * @property webkitKeymap * @private */ webkitKeymap = { 63232: 38, // up 63233: 40, // down 63234: 37, // left 63235: 39, // right 63276: 33, // page up 63277: 34, // page down 25: 9, // SHIFT-TAB (Safari provides a different key code in // this case, even though the shiftKey modifier is set) 63272: 46, // delete 63273: 36, // home 63275: 35 // end }, /** * Returns a wrapped node. Intended to be used on event targets, * so it will return the node's parent if the target is a text * node. * * If accessing a property of the node throws an error, this is * probably the anonymous div wrapper Gecko adds inside text * nodes. This likely will only occur when attempting to access * the relatedTarget. In this case, we now return null because * the anonymous div is completely useless and we do not know * what the related target was because we can't even get to * the element's parent node. * * @method resolve * @private */ resolve = function(n) { if (!n) { return n; } try { if (n && 3 == n.nodeType) { n = n.parentNode; } } catch(e) { return null; } return Y.one(n); }, DOMEventFacade = function(ev, currentTarget, wrapper) { this._event = ev; this._currentTarget = currentTarget; this._wrapper = wrapper || EMPTY; // if not lazy init this.init(); }; Y.extend(DOMEventFacade, Object, { init: function() { var e = this._event, overrides = this._wrapper.overrides, x = e.pageX, y = e.pageY, c, currentTarget = this._currentTarget; this.altKey = e.altKey; this.ctrlKey = e.ctrlKey; this.metaKey = e.metaKey; this.shiftKey = e.shiftKey; this.type = (overrides && overrides.type) || e.type; this.clientX = e.clientX; this.clientY = e.clientY; this.pageX = x; this.pageY = y; // charCode is unknown in keyup, keydown. keyCode is unknown in keypress. // FF 3.6 - 8+? pass 0 for keyCode in keypress events. // Webkit, FF 3.6-8+?, and IE9+? pass 0 for charCode in keydown, keyup. // Webkit and IE9+? duplicate charCode in keyCode. // Opera never sets charCode, always keyCode (though with the charCode). // IE6-8 don't set charCode or which. // All browsers other than IE6-8 set which=keyCode in keydown, keyup, and // which=charCode in keypress. // // Moral of the story: (e.which || e.keyCode) will always return the // known code for that key event phase. e.keyCode is often different in // keypress from keydown and keyup. c = e.keyCode || e.charCode; if (ua.webkit && (c in webkitKeymap)) { c = webkitKeymap[c]; } this.keyCode = c; this.charCode = c; // Fill in e.which for IE - implementers should always use this over // e.keyCode or e.charCode. this.which = e.which || e.charCode || c; // this.button = e.button; this.button = this.which; this.target = resolve(e.target); this.currentTarget = resolve(currentTarget); this.relatedTarget = resolve(e.relatedTarget); if (e.type == "mousewheel" || e.type == "DOMMouseScroll") { this.wheelDelta = (e.detail) ? (e.detail * -1) : Math.round(e.wheelDelta / 80) || ((e.wheelDelta < 0) ? -1 : 1); } if (this._touch) { this._touch(e, currentTarget, this._wrapper); } }, stopPropagation: function() { this._event.stopPropagation(); this._wrapper.stopped = 1; this.stopped = 1; }, stopImmediatePropagation: function() { var e = this._event; if (e.stopImmediatePropagation) { e.stopImmediatePropagation(); } else { this.stopPropagation(); } this._wrapper.stopped = 2; this.stopped = 2; }, preventDefault: function(returnValue) { var e = this._event; e.preventDefault(); if (returnValue) { e.returnValue = returnValue; } this._wrapper.prevented = 1; this.prevented = 1; }, halt: function(immediate) { if (immediate) { this.stopImmediatePropagation(); } else { this.stopPropagation(); } this.preventDefault(); } }); DOMEventFacade.resolve = resolve; Y.DOM2EventFacade = DOMEventFacade; Y.DOMEventFacade = DOMEventFacade; /** * The native event * @property _event * @type {DOMEvent} * @private */ /** The name of the event (e.g. "click") @property type @type {String} **/ /** `true` if the "alt" or "option" key is pressed. @property altKey @type {Boolean} **/ /** `true` if the shift key is pressed. @property shiftKey @type {Boolean} **/ /** `true` if the "Windows" key on a Windows keyboard, "command" key on an Apple keyboard, or "meta" key on other keyboards is pressed. @property metaKey @type {Boolean} **/ /** `true` if the "Ctrl" or "control" key is pressed. @property ctrlKey @type {Boolean} **/ /** * The X location of the event on the page (including scroll) * @property pageX * @type {Number} */ /** * The Y location of the event on the page (including scroll) * @property pageY * @type {Number} */ /** * The X location of the event in the viewport * @property clientX * @type {Number} */ /** * The Y location of the event in the viewport * @property clientY * @type {Number} */ /** * The keyCode for key events. Uses charCode if keyCode is not available * @property keyCode * @type {Number} */ /** * The charCode for key events. Same as keyCode * @property charCode * @type {Number} */ /** * The button that was pushed. 1 for left click, 2 for middle click, 3 for * right click. This is only reliably populated on `mouseup` events. * @property button * @type {Number} */ /** * The button that was pushed. Same as button. * @property which * @type {Number} */ /** * Node reference for the targeted element * @property target * @type {Node} */ /** * Node reference for the element that the listener was attached to. * @property currentTarget * @type {Node} */ /** * Node reference to the relatedTarget * @property relatedTarget * @type {Node} */ /** * Number representing the direction and velocity of the movement of the mousewheel. * Negative is down, the higher the number, the faster. Applies to the mousewheel event. * @property wheelDelta * @type {Number} */ /** * Stops the propagation to the next bubble target * @method stopPropagation */ /** * Stops the propagation to the next bubble target and * prevents any additional listeners from being exectued * on the current target. * @method stopImmediatePropagation */ /** * Prevents the event's default behavior * @method preventDefault * @param returnValue {string} sets the returnValue of the event to this value * (rather than the default false value). This can be used to add a customized * confirmation query to the beforeunload event). */ /** * Stops the event propagation and prevents the default * event behavior. * @method halt * @param immediate {boolean} if true additional listeners * on the current target will not be executed */ (function() { /** * The event utility provides functions to add and remove event listeners, * event cleansing. It also tries to automatically remove listeners it * registers during the unload event. * @module event * @main event * @submodule event-base */ /** * The event utility provides functions to add and remove event listeners, * event cleansing. It also tries to automatically remove listeners it * registers during the unload event. * * @class Event * @static */ Y.Env.evt.dom_wrappers = {}; Y.Env.evt.dom_map = {}; var _eventenv = Y.Env.evt, config = Y.config, win = config.win, add = YUI.Env.add, remove = YUI.Env.remove, onLoad = function() { YUI.Env.windowLoaded = true; Y.Event._load(); remove(win, "load", onLoad); }, onUnload = function() { Y.Event._unload(); }, EVENT_READY = 'domready', COMPAT_ARG = '~yui|2|compat~', shouldIterate = function(o) { try { // TODO: See if there's a more performant way to return true early on this, for the common case return (o && typeof o !== "string" && Y.Lang.isNumber(o.length) && !o.tagName && !Y.DOM.isWindow(o)); } catch(ex) { return false; } }, // aliases to support DOM event subscription clean up when the last // subscriber is detached. deleteAndClean overrides the DOM event's wrapper // CustomEvent _delete method. _ceProtoDelete = Y.CustomEvent.prototype._delete, _deleteAndClean = function(s) { var ret = _ceProtoDelete.apply(this, arguments); if (!this.hasSubs()) { Y.Event._clean(this); } return ret; }, Event = function() { /** * True after the onload event has fired * @property _loadComplete * @type boolean * @static * @private */ var _loadComplete = false, /** * The number of times to poll after window.onload. This number is * increased if additional late-bound handlers are requested after * the page load. * @property _retryCount * @static * @private */ _retryCount = 0, /** * onAvailable listeners * @property _avail * @static * @private */ _avail = [], /** * Custom event wrappers for DOM events. Key is * 'event:' + Element uid stamp + event type * @property _wrappers * @type CustomEvent * @static * @private */ _wrappers = _eventenv.dom_wrappers, _windowLoadKey = null, /** * Custom event wrapper map DOM events. Key is * Element uid stamp. Each item is a hash of custom event * wrappers as provided in the _wrappers collection. This * provides the infrastructure for getListeners. * @property _el_events * @static * @private */ _el_events = _eventenv.dom_map; return { /** * The number of times we should look for elements that are not * in the DOM at the time the event is requested after the document * has been loaded. The default is 1000@amp;40 ms, so it will poll * for 40 seconds or until all outstanding handlers are bound * (whichever comes first). * @property POLL_RETRYS * @type int * @static * @final */ POLL_RETRYS: 1000, /** * The poll interval in milliseconds * @property POLL_INTERVAL * @type int * @static * @final */ POLL_INTERVAL: 40, /** * addListener/removeListener can throw errors in unexpected scenarios. * These errors are suppressed, the method returns false, and this property * is set * @property lastError * @static * @type Error */ lastError: null, /** * poll handle * @property _interval * @static * @private */ _interval: null, /** * document readystate poll handle * @property _dri * @static * @private */ _dri: null, /** * True when the document is initially usable * @property DOMReady * @type boolean * @static */ DOMReady: false, /** * @method startInterval * @static * @private */ startInterval: function() { if (!Event._interval) { Event._interval = setInterval(Event._poll, Event.POLL_INTERVAL); } }, /** * Executes the supplied callback when the item with the supplied * id is found. This is meant to be used to execute behavior as * soon as possible as the page loads. If you use this after the * initial page load it will poll for a fixed time for the element. * The number of times it will poll and the frequency are * configurable. By default it will poll for 10 seconds. * *

The callback is executed with a single parameter: * the custom object parameter, if provided.

* * @method onAvailable * * @param {string||string[]} id the id of the element, or an array * of ids to look for. * @param {function} fn what to execute when the element is found. * @param {object} p_obj an optional object to be passed back as * a parameter to fn. * @param {boolean|object} p_override If set to true, fn will execute * in the context of p_obj, if set to an object it * will execute in the context of that object * @param checkContent {boolean} check child node readiness (onContentReady) * @static * @deprecated Use Y.on("available") */ // @TODO fix arguments onAvailable: function(id, fn, p_obj, p_override, checkContent, compat) { var a = Y.Array(id), i, availHandle; for (i=0; iThe callback is executed with a single parameter: * the custom object parameter, if provided.

* * @method onContentReady * * @param {string} id the id of the element to look for. * @param {function} fn what to execute when the element is ready. * @param {object} obj an optional object to be passed back as * a parameter to fn. * @param {boolean|object} override If set to true, fn will execute * in the context of p_obj. If an object, fn will * exectute in the context of that object * * @static * @deprecated Use Y.on("contentready") */ // @TODO fix arguments onContentReady: function(id, fn, obj, override, compat) { return Event.onAvailable(id, fn, obj, override, true, compat); }, /** * Adds an event listener * * @method attach * * @param {String} type The type of event to append * @param {Function} fn The method the event invokes * @param {String|HTMLElement|Array|NodeList} el An id, an element * reference, or a collection of ids and/or elements to assign the * listener to. * @param {Object} context optional context object * @param {Boolean|object} args 0..n arguments to pass to the callback * @return {EventHandle} an object to that can be used to detach the listener * * @static */ attach: function(type, fn, el, context) { return Event._attach(Y.Array(arguments, 0, true)); }, _createWrapper: function (el, type, capture, compat, facade) { var cewrapper, ek = Y.stamp(el), key = 'event:' + ek + type; if (false === facade) { key += 'native'; } if (capture) { key += 'capture'; } cewrapper = _wrappers[key]; if (!cewrapper) { // create CE wrapper cewrapper = Y.publish(key, { silent: true, bubbles: false, emitFacade:false, contextFn: function() { if (compat) { return cewrapper.el; } else { cewrapper.nodeRef = cewrapper.nodeRef || Y.one(cewrapper.el); return cewrapper.nodeRef; } } }); cewrapper.overrides = {}; // for later removeListener calls cewrapper.el = el; cewrapper.key = key; cewrapper.domkey = ek; cewrapper.type = type; cewrapper.fn = function(e) { cewrapper.fire(Event.getEvent(e, el, (compat || (false === facade)))); }; cewrapper.capture = capture; if (el == win && type == "load") { // window load happens once cewrapper.fireOnce = true; _windowLoadKey = key; } cewrapper._delete = _deleteAndClean; _wrappers[key] = cewrapper; _el_events[ek] = _el_events[ek] || {}; _el_events[ek][key] = cewrapper; add(el, type, cewrapper.fn, capture); } return cewrapper; }, _attach: function(args, conf) { var compat, handles, oEl, cewrapper, context, fireNow = false, ret, type = args[0], fn = args[1], el = args[2] || win, facade = conf && conf.facade, capture = conf && conf.capture, overrides = conf && conf.overrides; if (args[args.length-1] === COMPAT_ARG) { compat = true; } if (!fn || !fn.call) { return false; } // The el argument can be an array of elements or element ids. if (shouldIterate(el)) { handles=[]; Y.each(el, function(v, k) { args[2] = v; handles.push(Event._attach(args.slice(), conf)); }); // return (handles.length === 1) ? handles[0] : handles; return new Y.EventHandle(handles); // If the el argument is a string, we assume it is // actually the id of the element. If the page is loaded // we convert el to the actual element, otherwise we // defer attaching the event until the element is // ready } else if (Y.Lang.isString(el)) { // oEl = (compat) ? Y.DOM.byId(el) : Y.Selector.query(el); if (compat) { oEl = Y.DOM.byId(el); } else { oEl = Y.Selector.query(el); switch (oEl.length) { case 0: oEl = null; break; case 1: oEl = oEl[0]; break; default: args[2] = oEl; return Event._attach(args, conf); } } if (oEl) { el = oEl; // Not found = defer adding the event until the element is available } else { ret = Event.onAvailable(el, function() { ret.handle = Event._attach(args, conf); }, Event, true, false, compat); return ret; } } // Element should be an html element or node if (!el) { return false; } if (Y.Node && Y.instanceOf(el, Y.Node)) { el = Y.Node.getDOMNode(el); } cewrapper = Event._createWrapper(el, type, capture, compat, facade); if (overrides) { Y.mix(cewrapper.overrides, overrides); } if (el == win && type == "load") { // if the load is complete, fire immediately. // all subscribers, including the current one // will be notified. if (YUI.Env.windowLoaded) { fireNow = true; } } if (compat) { args.pop(); } context = args[3]; // set context to the Node if not specified // ret = cewrapper.on.apply(cewrapper, trimmedArgs); ret = cewrapper._on(fn, context, (args.length > 4) ? args.slice(4) : null); if (fireNow) { cewrapper.fire(); } return ret; }, /** * Removes an event listener. Supports the signature the event was bound * with, but the preferred way to remove listeners is using the handle * that is returned when using Y.on * * @method detach * * @param {String} type the type of event to remove. * @param {Function} fn the method the event invokes. If fn is * undefined, then all event handlers for the type of event are * removed. * @param {String|HTMLElement|Array|NodeList|EventHandle} el An * event handle, an id, an element reference, or a collection * of ids and/or elements to remove the listener from. * @return {boolean} true if the unbind was successful, false otherwise. * @static */ detach: function(type, fn, el, obj) { var args=Y.Array(arguments, 0, true), compat, l, ok, i, id, ce; if (args[args.length-1] === COMPAT_ARG) { compat = true; // args.pop(); } if (type && type.detach) { return type.detach(); } // The el argument can be a string if (typeof el == "string") { // el = (compat) ? Y.DOM.byId(el) : Y.all(el); if (compat) { el = Y.DOM.byId(el); } else { el = Y.Selector.query(el); l = el.length; if (l < 1) { el = null; } else if (l == 1) { el = el[0]; } } // return Event.detach.apply(Event, args); } if (!el) { return false; } if (el.detach) { args.splice(2, 1); return el.detach.apply(el, args); // The el argument can be an array of elements or element ids. } else if (shouldIterate(el)) { ok = true; for (i=0, l=el.length; i 0); } // onAvailable notAvail = []; executeItem = function (el, item) { var context, ov = item.override; try { if (item.compat) { if (item.override) { if (ov === true) { context = item.obj; } else { context = ov; } } else { context = el; } item.fn.call(context, item.obj); } else { context = item.obj || Y.one(el); item.fn.apply(context, (Y.Lang.isArray(ov)) ? ov : []); } } catch (e) { } }; // onAvailable for (i=0,len=_avail.length; i 4 ? Y.Array(arguments, 4, true) : null; return Y.Event.onAvailable.call(Y.Event, id, fn, o, a); } }; /** * Executes the callback as soon as the specified element * is detected in the DOM with a nextSibling property * (indicating that the element's children are available). * This function expects a selector * string for the element(s) to detect. If you already have * an element reference, you don't need this event. * @event contentready * @param type {string} 'contentready' * @param fn {function} the callback function to execute. * @param el {string} an selector for the element(s) to attach. * @param context optional argument that specifies what 'this' refers to. * @param args* 0..n additional arguments to pass on to the callback function. * These arguments will be added after the event object. * @return {EventHandle} the detach handle * @for YUI */ Y.Env.evt.plugins.contentready = { on: function(type, fn, id, o) { var a = arguments.length > 4 ? Y.Array(arguments, 4, true) : null; return Y.Event.onContentReady.call(Y.Event, id, fn, o, a); } }; }, '3.17.2', {"requires": ["event-custom-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ (function() { var stateChangeListener, GLOBAL_ENV = YUI.Env, config = YUI.config, doc = config.doc, docElement = doc && doc.documentElement, EVENT_NAME = 'onreadystatechange', pollInterval = config.pollInterval || 40; if (docElement.doScroll && !GLOBAL_ENV._ieready) { GLOBAL_ENV._ieready = function() { GLOBAL_ENV._ready(); }; /*! DOMReady: based on work by: Dean Edwards/John Resig/Matthias Miller/Diego Perini */ // Internet Explorer: use the doScroll() method on the root element. // This isolates what appears to be a safe moment to manipulate the // DOM prior to when the document's readyState suggests it is safe to do so. if (self !== self.top) { stateChangeListener = function() { if (doc.readyState == 'complete') { GLOBAL_ENV.remove(doc, EVENT_NAME, stateChangeListener); GLOBAL_ENV.ieready(); } }; GLOBAL_ENV.add(doc, EVENT_NAME, stateChangeListener); } else { GLOBAL_ENV._dri = setInterval(function() { try { docElement.doScroll('left'); clearInterval(GLOBAL_ENV._dri); GLOBAL_ENV._dri = null; GLOBAL_ENV._ieready(); } catch (domNotReady) { } }, pollInterval); } } })(); YUI.add('event-base-ie', function (Y, NAME) { /* * Custom event engine, DOM event listener abstraction layer, synthetic DOM * events. * @module event * @submodule event-base */ function IEEventFacade() { // IEEventFacade.superclass.constructor.apply(this, arguments); Y.DOM2EventFacade.apply(this, arguments); } /* * (intentially left out of API docs) * Alternate Facade implementation that is based on Object.defineProperty, which * is partially supported in IE8. Properties that involve setup work are * deferred to temporary getters using the static _define method. */ function IELazyFacade(e) { var proxy = Y.config.doc.createEventObject(e), proto = IELazyFacade.prototype; // TODO: necessary? proxy.hasOwnProperty = function () { return true; }; proxy.init = proto.init; proxy.halt = proto.halt; proxy.preventDefault = proto.preventDefault; proxy.stopPropagation = proto.stopPropagation; proxy.stopImmediatePropagation = proto.stopImmediatePropagation; Y.DOM2EventFacade.apply(proxy, arguments); return proxy; } var imp = Y.config.doc && Y.config.doc.implementation, useLazyFacade = Y.config.lazyEventFacade, buttonMap = { 0: 1, // left click 4: 2, // middle click 2: 3 // right click }, relatedTargetMap = { mouseout: 'toElement', mouseover: 'fromElement' }, resolve = Y.DOM2EventFacade.resolve, proto = { init: function() { IEEventFacade.superclass.init.apply(this, arguments); var e = this._event, x, y, d, b, de, t; this.target = resolve(e.srcElement); if (('clientX' in e) && (!x) && (0 !== x)) { x = e.clientX; y = e.clientY; d = Y.config.doc; b = d.body; de = d.documentElement; x += (de.scrollLeft || (b && b.scrollLeft) || 0); y += (de.scrollTop || (b && b.scrollTop) || 0); this.pageX = x; this.pageY = y; } if (e.type == "mouseout") { t = e.toElement; } else if (e.type == "mouseover") { t = e.fromElement; } // fallback to t.relatedTarget to support simulated events. // IE doesn't support setting toElement or fromElement on generic // events, so Y.Event.simulate sets relatedTarget instead. this.relatedTarget = resolve(t || e.relatedTarget); // which should contain the unicode key code if this is a key event. // For click events, which is normalized for which mouse button was // clicked. this.which = // chained assignment this.button = e.keyCode || buttonMap[e.button] || e.button; }, stopPropagation: function() { this._event.cancelBubble = true; this._wrapper.stopped = 1; this.stopped = 1; }, stopImmediatePropagation: function() { this.stopPropagation(); this._wrapper.stopped = 2; this.stopped = 2; }, preventDefault: function(returnValue) { this._event.returnValue = returnValue || false; this._wrapper.prevented = 1; this.prevented = 1; } }; Y.extend(IEEventFacade, Y.DOM2EventFacade, proto); Y.extend(IELazyFacade, Y.DOM2EventFacade, proto); IELazyFacade.prototype.init = function () { var e = this._event, overrides = this._wrapper.overrides, define = IELazyFacade._define, lazyProperties = IELazyFacade._lazyProperties, prop; this.altKey = e.altKey; this.ctrlKey = e.ctrlKey; this.metaKey = e.metaKey; this.shiftKey = e.shiftKey; this.type = (overrides && overrides.type) || e.type; this.clientX = e.clientX; this.clientY = e.clientY; this.keyCode = // chained assignment this.charCode = e.keyCode; this.which = // chained assignment this.button = e.keyCode || buttonMap[e.button] || e.button; for (prop in lazyProperties) { if (lazyProperties.hasOwnProperty(prop)) { define(this, prop, lazyProperties[prop]); } } if (this._touch) { this._touch(e, this._currentTarget, this._wrapper); } }; IELazyFacade._lazyProperties = { target: function () { return resolve(this._event.srcElement); }, relatedTarget: function () { var e = this._event, targetProp = relatedTargetMap[e.type] || 'relatedTarget'; // fallback to t.relatedTarget to support simulated events. // IE doesn't support setting toElement or fromElement on generic // events, so Y.Event.simulate sets relatedTarget instead. return resolve(e[targetProp] || e.relatedTarget); }, currentTarget: function () { return resolve(this._currentTarget); }, wheelDelta: function () { var e = this._event; if (e.type === "mousewheel" || e.type === "DOMMouseScroll") { return (e.detail) ? (e.detail * -1) : // wheelDelta between -80 and 80 result in -1 or 1 Math.round(e.wheelDelta / 80) || ((e.wheelDelta < 0) ? -1 : 1); } }, pageX: function () { var e = this._event, val = e.pageX, doc, bodyScroll, docScroll; if (val === undefined) { doc = Y.config.doc; bodyScroll = doc.body && doc.body.scrollLeft; docScroll = doc.documentElement.scrollLeft; val = e.clientX + (docScroll || bodyScroll || 0); } return val; }, pageY: function () { var e = this._event, val = e.pageY, doc, bodyScroll, docScroll; if (val === undefined) { doc = Y.config.doc; bodyScroll = doc.body && doc.body.scrollTop; docScroll = doc.documentElement.scrollTop; val = e.clientY + (docScroll || bodyScroll || 0); } return val; } }; /** * Wrapper function for Object.defineProperty that creates a property whose * value will be calulated only when asked for. After calculating the value, * the getter wll be removed, so it will behave as a normal property beyond that * point. A setter is also assigned so assigning to the property will clear * the getter, so foo.prop = 'a'; foo.prop; won't trigger the getter, * overwriting value 'a'. * * Used only by the DOMEventFacades used by IE8 when the YUI configuration * lazyEventFacade is set to true. * * @method _define * @param o {DOMObject} A DOM object to add the property to * @param prop {String} The name of the new property * @param valueFn {Function} The function that will return the initial, default * value for the property. * @static * @private */ IELazyFacade._define = function (o, prop, valueFn) { function val(v) { var ret = (arguments.length) ? v : valueFn.call(this); delete o[prop]; Object.defineProperty(o, prop, { value: ret, configurable: true, writable: true }); return ret; } Object.defineProperty(o, prop, { get: val, set: val, configurable: true }); }; if (imp && (!imp.hasFeature('Events', '2.0'))) { if (useLazyFacade) { // Make sure we can use the lazy facade logic try { Object.defineProperty(Y.config.doc.createEventObject(), 'z', {}); } catch (e) { useLazyFacade = false; } } Y.DOMEventFacade = (useLazyFacade) ? IELazyFacade : IEEventFacade; } }, '3.17.2', {"requires": ["node-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('pluginhost-base', function (Y, NAME) { /** * Provides the augmentable PluginHost interface, which can be added to any class. * @module pluginhost */ /** * Provides the augmentable PluginHost interface, which can be added to any class. * @module pluginhost-base */ /** *

* An augmentable class, which provides the augmented class with the ability to host plugins. * It adds plug and unplug methods to the augmented class, which can * be used to add or remove plugins from instances of the class. *

* *

Plugins can also be added through the constructor configuration object passed to the host class' constructor using * the "plugins" property. Supported values for the "plugins" property are those defined by the plug method. * * For example the following code would add the AnimPlugin and IOPlugin to Overlay (the plugin host): *

* var o = new Overlay({plugins: [ AnimPlugin, {fn:IOPlugin, cfg:{section:"header"}}]}); * *

*

* Plug.Host's protected _initPlugins and _destroyPlugins * methods should be invoked by the host class at the appropriate point in the host's lifecyle. *

* * @class Plugin.Host */ var L = Y.Lang; function PluginHost() { this._plugins = {}; } PluginHost.prototype = { /** * Adds a plugin to the host object. This will instantiate the * plugin and attach it to the configured namespace on the host object. * * @method plug * @chainable * @param P {Function | Object |Array} Accepts the plugin class, or an * object with a "fn" property specifying the plugin class and * a "cfg" property specifying the configuration for the Plugin. *

* Additionally an Array can also be passed in, with the above function or * object values, allowing the user to add multiple plugins in a single call. *

* @param config (Optional) If the first argument is the plugin class, the second argument * can be the configuration for the plugin. * @return {Base} A reference to the host object */ plug: function(Plugin, config) { var i, ln, ns; if (L.isArray(Plugin)) { for (i = 0, ln = Plugin.length; i < ln; i++) { this.plug(Plugin[i]); } } else { if (Plugin && !L.isFunction(Plugin)) { config = Plugin.cfg; Plugin = Plugin.fn; } // Plugin should be fn by now if (Plugin && Plugin.NS) { ns = Plugin.NS; config = config || {}; config.host = this; if (this.hasPlugin(ns)) { // Update config if (this[ns].setAttrs) { this[ns].setAttrs(config); } } else { // Create new instance this[ns] = new Plugin(config); this._plugins[ns] = Plugin; } } } return this; }, /** * Removes a plugin from the host object. This will destroy the * plugin instance and delete the namespace from the host object. * * @method unplug * @param {String | Function} plugin The namespace of the plugin, or the plugin class with the static NS namespace property defined. If not provided, * all registered plugins are unplugged. * @return {Base} A reference to the host object * @chainable */ unplug: function(plugin) { var ns = plugin, plugins = this._plugins; if (plugin) { if (L.isFunction(plugin)) { ns = plugin.NS; if (ns && (!plugins[ns] || plugins[ns] !== plugin)) { ns = null; } } if (ns) { if (this[ns]) { if (this[ns].destroy) { this[ns].destroy(); } delete this[ns]; } if (plugins[ns]) { delete plugins[ns]; } } } else { for (ns in this._plugins) { if (this._plugins.hasOwnProperty(ns)) { this.unplug(ns); } } } return this; }, /** * Determines if a plugin has plugged into this host. * * @method hasPlugin * @param {String} ns The plugin's namespace * @return {Plugin} Returns a truthy value (the plugin instance) if present, or undefined if not. */ hasPlugin : function(ns) { return (this._plugins[ns] && this[ns]); }, /** * Initializes static plugins registered on the host (using the * Base.plug static method) and any plugins passed to the * instance through the "plugins" configuration property. * * @method _initPlugins * @param {Object} config The configuration object with property name/value pairs. * @private */ _initPlugins: function(config) { this._plugins = this._plugins || {}; if (this._initConfigPlugins) { this._initConfigPlugins(config); } }, /** * Unplugs and destroys all plugins on the host * @method _destroyPlugins * @private */ _destroyPlugins: function() { this.unplug(); } }; Y.namespace("Plugin").Host = PluginHost; }, '3.17.2', {"requires": ["yui-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('pluginhost-config', function (Y, NAME) { /** * Adds pluginhost constructor configuration and static configuration support * @submodule pluginhost-config */ var PluginHost = Y.Plugin.Host, L = Y.Lang; /** * A protected initialization method, used by the host class to initialize * plugin configurations passed the constructor, through the config object. * * Host objects should invoke this method at the appropriate time in their * construction lifecycle. * * @method _initConfigPlugins * @param {Object} config The configuration object passed to the constructor * @protected * @for Plugin.Host */ PluginHost.prototype._initConfigPlugins = function(config) { // Class Configuration var classes = (this._getClasses) ? this._getClasses() : [this.constructor], plug = [], unplug = {}, constructor, i, classPlug, classUnplug, pluginClassName; // TODO: Room for optimization. Can we apply statically/unplug in same pass? for (i = classes.length - 1; i >= 0; i--) { constructor = classes[i]; classUnplug = constructor._UNPLUG; if (classUnplug) { // subclasses over-write Y.mix(unplug, classUnplug, true); } classPlug = constructor._PLUG; if (classPlug) { // subclasses over-write Y.mix(plug, classPlug, true); } } for (pluginClassName in plug) { if (plug.hasOwnProperty(pluginClassName)) { if (!unplug[pluginClassName]) { this.plug(plug[pluginClassName]); } } } // User Configuration if (config && config.plugins) { this.plug(config.plugins); } }; /** * Registers plugins to be instantiated at the class level (plugins * which should be plugged into every instance of the class by default). * * @method plug * @static * * @param {Function} hostClass The host class on which to register the plugins * @param {Function | Array} plugin Either the plugin class, an array of plugin classes or an array of objects (with fn and cfg properties defined) * @param {Object} config (Optional) If plugin is the plugin class, the configuration for the plugin * @for Plugin.Host */ PluginHost.plug = function(hostClass, plugin, config) { // Cannot plug into Base, since Plugins derive from Base [ will cause infinite recurrsion ] var p, i, l, name; if (hostClass !== Y.Base) { hostClass._PLUG = hostClass._PLUG || {}; if (!L.isArray(plugin)) { if (config) { plugin = {fn:plugin, cfg:config}; } plugin = [plugin]; } for (i = 0, l = plugin.length; i < l;i++) { p = plugin[i]; name = p.NAME || p.fn.NAME; hostClass._PLUG[name] = p; } } }; /** * Unregisters any class level plugins which have been registered by the host class, or any * other class in the hierarchy. * * @method unplug * @static * * @param {Function} hostClass The host class from which to unregister the plugins * @param {Function | Array} plugin The plugin class, or an array of plugin classes * @for Plugin.Host */ PluginHost.unplug = function(hostClass, plugin) { var p, i, l, name; if (hostClass !== Y.Base) { hostClass._UNPLUG = hostClass._UNPLUG || {}; if (!L.isArray(plugin)) { plugin = [plugin]; } for (i = 0, l = plugin.length; i < l; i++) { p = plugin[i]; name = p.NAME; if (!hostClass._PLUG[name]) { hostClass._UNPLUG[name] = p; } else { delete hostClass._PLUG[name]; } } } }; }, '3.17.2', {"requires": ["pluginhost-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('event-delegate', function (Y, NAME) { /** * Adds event delegation support to the library. * * @module event * @submodule event-delegate */ var toArray = Y.Array, YLang = Y.Lang, isString = YLang.isString, isObject = YLang.isObject, isArray = YLang.isArray, selectorTest = Y.Selector.test, detachCategories = Y.Env.evt.handles; /** *

Sets up event delegation on a container element. The delegated event * will use a supplied selector or filtering function to test if the event * references at least one node that should trigger the subscription * callback.

* *

Selector string filters will trigger the callback if the event originated * from a node that matches it or is contained in a node that matches it. * Function filters are called for each Node up the parent axis to the * subscribing container node, and receive at each level the Node and the event * object. The function should return true (or a truthy value) if that Node * should trigger the subscription callback. Note, it is possible for filters * to match multiple Nodes for a single event. In this case, the delegate * callback will be executed for each matching Node.

* *

For each matching Node, the callback will be executed with its 'this' * object set to the Node matched by the filter (unless a specific context was * provided during subscription), and the provided event's * currentTarget will also be set to the matching Node. The * containing Node from which the subscription was originally made can be * referenced as e.container. * * @method delegate * @param type {String} the event type to delegate * @param fn {Function} the callback function to execute. This function * will be provided the event object for the delegated event. * @param el {String|node} the element that is the delegation container * @param filter {string|Function} a selector that must match the target of the * event or a function to test target and its parents for a match * @param context optional argument that specifies what 'this' refers to. * @param args* 0..n additional arguments to pass on to the callback function. * These arguments will be added after the event object. * @return {EventHandle} the detach handle * @static * @for Event */ function delegate(type, fn, el, filter) { var args = toArray(arguments, 0, true), query = isString(el) ? el : null, typeBits, synth, container, categories, cat, i, len, handles, handle; // Support Y.delegate({ click: fnA, key: fnB }, el, filter, ...); // and Y.delegate(['click', 'key'], fn, el, filter, ...); if (isObject(type)) { handles = []; if (isArray(type)) { for (i = 0, len = type.length; i < len; ++i) { args[0] = type[i]; handles.push(Y.delegate.apply(Y, args)); } } else { // Y.delegate({'click', fn}, el, filter) => // Y.delegate('click', fn, el, filter) args.unshift(null); // one arg becomes two; need to make space for (i in type) { if (type.hasOwnProperty(i)) { args[0] = i; args[1] = type[i]; handles.push(Y.delegate.apply(Y, args)); } } } return new Y.EventHandle(handles); } typeBits = type.split(/\|/); if (typeBits.length > 1) { cat = typeBits.shift(); args[0] = type = typeBits.shift(); } synth = Y.Node.DOM_EVENTS[type]; if (isObject(synth) && synth.delegate) { handle = synth.delegate.apply(synth, arguments); } if (!handle) { if (!type || !fn || !el || !filter) { return; } container = (query) ? Y.Selector.query(query, null, true) : el; if (!container && isString(el)) { handle = Y.on('available', function () { Y.mix(handle, Y.delegate.apply(Y, args), true); }, el); } if (!handle && container) { args.splice(2, 2, container); // remove the filter handle = Y.Event._attach(args, { facade: false }); handle.sub.filter = filter; handle.sub._notify = delegate.notifySub; } } if (handle && cat) { categories = detachCategories[cat] || (detachCategories[cat] = {}); categories = categories[type] || (categories[type] = []); categories.push(handle); } return handle; } /** Overrides the _notify method on the normal DOM subscription to inject the filtering logic and only proceed in the case of a match. This method is hosted as a private property of the `delegate` method (e.g. `Y.delegate.notifySub`) @method notifySub @param thisObj {Object} default 'this' object for the callback @param args {Array} arguments passed to the event's fire() @param ce {CustomEvent} the custom event managing the DOM subscriptions for the subscribed event on the subscribing node. @return {Boolean} false if the event was stopped @private @static @since 3.2.0 **/ delegate.notifySub = function (thisObj, args, ce) { // Preserve args for other subscribers args = args.slice(); if (this.args) { args.push.apply(args, this.args); } // Only notify subs if the event occurred on a targeted element var currentTarget = delegate._applyFilter(this.filter, args, ce), //container = e.currentTarget, e, i, len, ret; if (currentTarget) { // Support multiple matches up the the container subtree currentTarget = toArray(currentTarget); // The second arg is the currentTarget, but we'll be reusing this // facade, replacing the currentTarget for each use, so it doesn't // matter what element we seed it with. e = args[0] = new Y.DOMEventFacade(args[0], ce.el, ce); e.container = Y.one(ce.el); for (i = 0, len = currentTarget.length; i < len && !e.stopped; ++i) { e.currentTarget = Y.one(currentTarget[i]); ret = this.fn.apply(this.context || e.currentTarget, args); if (ret === false) { // stop further notifications break; } } return ret; } }; /** Compiles a selector string into a filter function to identify whether Nodes along the parent axis of an event's target should trigger event notification. This function is memoized, so previously compiled filter functions are returned if the same selector string is provided. This function may be useful when defining synthetic events for delegate handling. Hosted as a property of the `delegate` method (e.g. `Y.delegate.compileFilter`). @method compileFilter @param selector {String} the selector string to base the filtration on @return {Function} @since 3.2.0 @static **/ delegate.compileFilter = Y.cached(function (selector) { return function (target, e) { return selectorTest(target._node, selector, (e.currentTarget === e.target) ? null : e.currentTarget._node); }; }); /** Regex to test for disabled elements during filtering. This is only relevant to IE to normalize behavior with other browsers, which swallow events that occur to disabled elements. IE fires the event from the parent element instead of the original target, though it does preserve `event.srcElement` as the disabled element. IE also supports disabled on ``, but the event still bubbles, so it acts more like `e.preventDefault()` plus styling. That issue is not handled here because other browsers fire the event on the ``, so delegate is supported in both cases. @property _disabledRE @type {RegExp} @protected @since 3.8.1 **/ delegate._disabledRE = /^(?:button|input|select|textarea)$/i; /** Walks up the parent axis of an event's target, and tests each element against a supplied filter function. If any Nodes, including the container, satisfy the filter, the delegated callback will be triggered for each. Hosted as a protected property of the `delegate` method (e.g. `Y.delegate._applyFilter`). @method _applyFilter @param filter {Function} boolean function to test for inclusion in event notification @param args {Array} the arguments that would be passed to subscribers @param ce {CustomEvent} the DOM event wrapper @return {Node|Node[]|undefined} The Node or Nodes that satisfy the filter @protected **/ delegate._applyFilter = function (filter, args, ce) { var e = args[0], container = ce.el, // facadeless events in IE, have no e.currentTarget target = e.target || e.srcElement, match = [], isContainer = false; // Resolve text nodes to their containing element if (target.nodeType === 3) { target = target.parentNode; } // For IE. IE propagates events from the parent element of disabled // elements, where other browsers swallow the event entirely. To normalize // this in IE, filtering for matching elements should abort if the target // is a disabled form control. if (target.disabled && delegate._disabledRE.test(target.nodeName)) { return match; } // passing target as the first arg rather than leaving well enough alone // making 'this' in the filter function refer to the target. This is to // support bound filter functions. args.unshift(target); if (isString(filter)) { while (target) { isContainer = (target === container); if (selectorTest(target, filter, (isContainer ? null: container))) { match.push(target); } if (isContainer) { break; } target = target.parentNode; } } else { // filter functions are implementer code and should receive wrappers args[0] = Y.one(target); args[1] = new Y.DOMEventFacade(e, container, ce); while (target) { // filter(target, e, extra args...) - this === target if (filter.apply(args[0], args)) { match.push(target); } if (target === container) { break; } target = target.parentNode; args[0] = Y.one(target); } args[1] = e; // restore the raw DOM event } if (match.length <= 1) { match = match[0]; // single match or undefined } // remove the target args.shift(); return match; }; /** * Sets up event delegation on a container element. The delegated event * will use a supplied filter to test if the callback should be executed. * This filter can be either a selector string or a function that returns * a Node to use as the currentTarget for the event. * * The event object for the delegated event is supplied to the callback * function. It is modified slightly in order to support all properties * that may be needed for event delegation. 'currentTarget' is set to * the element that matched the selector string filter or the Node returned * from the filter function. 'container' is set to the element that the * listener is delegated from (this normally would be the 'currentTarget'). * * Filter functions will be called with the arguments that would be passed to * the callback function, including the event object as the first parameter. * The function should return false (or a falsey value) if the success criteria * aren't met, and the Node to use as the event's currentTarget and 'this' * object if they are. * * @method delegate * @param type {string} the event type to delegate * @param fn {function} the callback function to execute. This function * will be provided the event object for the delegated event. * @param el {string|node} the element that is the delegation container * @param filter {string|function} a selector that must match the target of the * event or a function that returns a Node or false. * @param context optional argument that specifies what 'this' refers to. * @param args* 0..n additional arguments to pass on to the callback function. * These arguments will be added after the event object. * @return {EventHandle} the detach handle * @for YUI */ Y.delegate = Y.Event.delegate = delegate; }, '3.17.2', {"requires": ["node-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('node-event-delegate', function (Y, NAME) { /** * Functionality to make the node a delegated event container * @module node * @submodule node-event-delegate */ /** *

Sets up a delegation listener for an event occurring inside the Node. * The delegated event will be verified against a supplied selector or * filtering function to test if the event references at least one node that * should trigger the subscription callback.

* *

Selector string filters will trigger the callback if the event originated * from a node that matches it or is contained in a node that matches it. * Function filters are called for each Node up the parent axis to the * subscribing container node, and receive at each level the Node and the event * object. The function should return true (or a truthy value) if that Node * should trigger the subscription callback. Note, it is possible for filters * to match multiple Nodes for a single event. In this case, the delegate * callback will be executed for each matching Node.

* *

For each matching Node, the callback will be executed with its 'this' * object set to the Node matched by the filter (unless a specific context was * provided during subscription), and the provided event's * currentTarget will also be set to the matching Node. The * containing Node from which the subscription was originally made can be * referenced as e.container. * * @method delegate * @param type {String} the event type to delegate * @param fn {Function} the callback function to execute. This function * will be provided the event object for the delegated event. * @param spec {String|Function} a selector that must match the target of the * event or a function to test target and its parents for a match * @param context {Object} optional argument that specifies what 'this' refers to. * @param args* {any} 0..n additional arguments to pass on to the callback function. * These arguments will be added after the event object. * @return {EventHandle} the detach handle * @for Node */ Y.Node.prototype.delegate = function(type) { var args = Y.Array(arguments, 0, true), index = (Y.Lang.isObject(type) && !Y.Lang.isArray(type)) ? 1 : 2; args.splice(index, 0, this._node); return Y.delegate.apply(Y, args); }; }, '3.17.2', {"requires": ["node-base", "event-delegate"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('node-pluginhost', function (Y, NAME) { /** * @module node * @submodule node-pluginhost */ /** * Registers plugins to be instantiated at the class level (plugins * which should be plugged into every instance of Node by default). * * @method plug * @static * @for Node * @param {Function | Array} plugin Either the plugin class, an array of plugin classes or an array of objects (with fn and cfg properties defined) * @param {Object} config (Optional) If plugin is the plugin class, the configuration for the plugin */ Y.Node.plug = function() { var args = Y.Array(arguments); args.unshift(Y.Node); Y.Plugin.Host.plug.apply(Y.Base, args); return Y.Node; }; /** * Unregisters any class level plugins which have been registered by the Node * * @method unplug * @static * * @param {Function | Array} plugin The plugin class, or an array of plugin classes */ Y.Node.unplug = function() { var args = Y.Array(arguments); args.unshift(Y.Node); Y.Plugin.Host.unplug.apply(Y.Base, args); return Y.Node; }; Y.mix(Y.Node, Y.Plugin.Host, false, null, 1); // run PluginHost constructor on cached Node instances Y.Object.each(Y.Node._instances, function (node) { Y.Plugin.Host.apply(node); }); // allow batching of plug/unplug via NodeList // doesn't use NodeList.importMethod because we need real Nodes (not tmpNode) /** * Adds a plugin to each node in the NodeList. * This will instantiate the plugin and attach it to the configured namespace on each node * @method plug * @for NodeList * @param P {Function | Object |Array} Accepts the plugin class, or an * object with a "fn" property specifying the plugin class and * a "cfg" property specifying the configuration for the Plugin. *

* Additionally an Array can also be passed in, with the above function or * object values, allowing the user to add multiple plugins in a single call. *

* @param config (Optional) If the first argument is the plugin class, the second argument * can be the configuration for the plugin. * @chainable */ Y.NodeList.prototype.plug = function() { var args = arguments; Y.NodeList.each(this, function(node) { Y.Node.prototype.plug.apply(Y.one(node), args); }); return this; }; /** * Removes a plugin from all nodes in the NodeList. This will destroy the * plugin instance and delete the namespace each node. * @method unplug * @for NodeList * @param {String | Function} plugin The namespace of the plugin, or the plugin class with the static NS namespace property defined. If not provided, * all registered plugins are unplugged. * @chainable */ Y.NodeList.prototype.unplug = function() { var args = arguments; Y.NodeList.each(this, function(node) { Y.Node.prototype.unplug.apply(Y.one(node), args); }); return this; }; }, '3.17.2', {"requires": ["node-base", "pluginhost"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('dom-screen', function (Y, NAME) { (function(Y) { /** * Adds position and region management functionality to DOM. * @module dom * @submodule dom-screen * @for DOM */ var DOCUMENT_ELEMENT = 'documentElement', COMPAT_MODE = 'compatMode', POSITION = 'position', FIXED = 'fixed', RELATIVE = 'relative', LEFT = 'left', TOP = 'top', _BACK_COMPAT = 'BackCompat', MEDIUM = 'medium', BORDER_LEFT_WIDTH = 'borderLeftWidth', BORDER_TOP_WIDTH = 'borderTopWidth', GET_BOUNDING_CLIENT_RECT = 'getBoundingClientRect', GET_COMPUTED_STYLE = 'getComputedStyle', Y_DOM = Y.DOM, // TODO: how about thead/tbody/tfoot/tr? // TODO: does caption matter? RE_TABLE = /^t(?:able|d|h)$/i, SCROLL_NODE; if (Y.UA.ie) { if (Y.config.doc[COMPAT_MODE] !== 'BackCompat') { SCROLL_NODE = DOCUMENT_ELEMENT; } else { SCROLL_NODE = 'body'; } } Y.mix(Y_DOM, { /** * Returns the inner height of the viewport (exludes scrollbar). * @method winHeight * @return {Number} The current height of the viewport. */ winHeight: function(node) { var h = Y_DOM._getWinSize(node).height; return h; }, /** * Returns the inner width of the viewport (exludes scrollbar). * @method winWidth * @return {Number} The current width of the viewport. */ winWidth: function(node) { var w = Y_DOM._getWinSize(node).width; return w; }, /** * Document height * @method docHeight * @return {Number} The current height of the document. */ docHeight: function(node) { var h = Y_DOM._getDocSize(node).height; return Math.max(h, Y_DOM._getWinSize(node).height); }, /** * Document width * @method docWidth * @return {Number} The current width of the document. */ docWidth: function(node) { var w = Y_DOM._getDocSize(node).width; return Math.max(w, Y_DOM._getWinSize(node).width); }, /** * Amount page has been scroll horizontally * @method docScrollX * @return {Number} The current amount the screen is scrolled horizontally. */ docScrollX: function(node, doc) { doc = doc || (node) ? Y_DOM._getDoc(node) : Y.config.doc; // perf optimization var dv = doc.defaultView, pageOffset = (dv) ? dv.pageXOffset : 0; return Math.max(doc[DOCUMENT_ELEMENT].scrollLeft, doc.body.scrollLeft, pageOffset); }, /** * Amount page has been scroll vertically * @method docScrollY * @return {Number} The current amount the screen is scrolled vertically. */ docScrollY: function(node, doc) { doc = doc || (node) ? Y_DOM._getDoc(node) : Y.config.doc; // perf optimization var dv = doc.defaultView, pageOffset = (dv) ? dv.pageYOffset : 0; return Math.max(doc[DOCUMENT_ELEMENT].scrollTop, doc.body.scrollTop, pageOffset); }, /** * Gets the current position of an element based on page coordinates. * Element must be part of the DOM tree to have page coordinates * (display:none or elements not appended return false). * @method getXY * @param element The target element * @return {Array} The XY position of the element TODO: test inDocument/display? */ getXY: function() { if (Y.config.doc[DOCUMENT_ELEMENT][GET_BOUNDING_CLIENT_RECT]) { return function(node) { var xy = null, scrollLeft, scrollTop, mode, box, offX, offY, doc, win, inDoc, rootNode; if (node && node.tagName) { doc = node.ownerDocument; mode = doc[COMPAT_MODE]; if (mode !== _BACK_COMPAT) { rootNode = doc[DOCUMENT_ELEMENT]; } else { rootNode = doc.body; } // inline inDoc check for perf if (rootNode.contains) { inDoc = rootNode.contains(node); } else { inDoc = Y.DOM.contains(rootNode, node); } if (inDoc) { win = doc.defaultView; // inline scroll calc for perf if (win && 'pageXOffset' in win) { scrollLeft = win.pageXOffset; scrollTop = win.pageYOffset; } else { scrollLeft = (SCROLL_NODE) ? doc[SCROLL_NODE].scrollLeft : Y_DOM.docScrollX(node, doc); scrollTop = (SCROLL_NODE) ? doc[SCROLL_NODE].scrollTop : Y_DOM.docScrollY(node, doc); } if (Y.UA.ie) { // IE < 8, quirks, or compatMode if (!doc.documentMode || doc.documentMode < 8 || mode === _BACK_COMPAT) { offX = rootNode.clientLeft; offY = rootNode.clientTop; } } box = node[GET_BOUNDING_CLIENT_RECT](); xy = [box.left, box.top]; if (offX || offY) { xy[0] -= offX; xy[1] -= offY; } if ((scrollTop || scrollLeft)) { if (!Y.UA.ios || (Y.UA.ios >= 4.2)) { xy[0] += scrollLeft; xy[1] += scrollTop; } } } else { xy = Y_DOM._getOffset(node); } } return xy; }; } else { return function(node) { // manually calculate by crawling up offsetParents //Calculate the Top and Left border sizes (assumes pixels) var xy = null, doc, parentNode, bCheck, scrollTop, scrollLeft; if (node) { if (Y_DOM.inDoc(node)) { xy = [node.offsetLeft, node.offsetTop]; doc = node.ownerDocument; parentNode = node; // TODO: refactor with !! or just falsey bCheck = ((Y.UA.gecko || Y.UA.webkit > 519) ? true : false); // TODO: worth refactoring for TOP/LEFT only? while ((parentNode = parentNode.offsetParent)) { xy[0] += parentNode.offsetLeft; xy[1] += parentNode.offsetTop; if (bCheck) { xy = Y_DOM._calcBorders(parentNode, xy); } } // account for any scrolled ancestors if (Y_DOM.getStyle(node, POSITION) != FIXED) { parentNode = node; while ((parentNode = parentNode.parentNode)) { scrollTop = parentNode.scrollTop; scrollLeft = parentNode.scrollLeft; //Firefox does something funky with borders when overflow is not visible. if (Y.UA.gecko && (Y_DOM.getStyle(parentNode, 'overflow') !== 'visible')) { xy = Y_DOM._calcBorders(parentNode, xy); } if (scrollTop || scrollLeft) { xy[0] -= scrollLeft; xy[1] -= scrollTop; } } xy[0] += Y_DOM.docScrollX(node, doc); xy[1] += Y_DOM.docScrollY(node, doc); } else { //Fix FIXED position -- add scrollbars xy[0] += Y_DOM.docScrollX(node, doc); xy[1] += Y_DOM.docScrollY(node, doc); } } else { xy = Y_DOM._getOffset(node); } } return xy; }; } }(),// NOTE: Executing for loadtime branching /** Gets the width of vertical scrollbars on overflowed containers in the body content. @method getScrollbarWidth @return {Number} Pixel width of a scrollbar in the current browser **/ getScrollbarWidth: Y.cached(function () { var doc = Y.config.doc, testNode = doc.createElement('div'), body = doc.getElementsByTagName('body')[0], // 0.1 because cached doesn't support falsy refetch values width = 0.1; if (body) { testNode.style.cssText = "position:absolute;visibility:hidden;overflow:scroll;width:20px;"; testNode.appendChild(doc.createElement('p')).style.height = '1px'; body.insertBefore(testNode, body.firstChild); width = testNode.offsetWidth - testNode.clientWidth; body.removeChild(testNode); } return width; }, null, 0.1), /** * Gets the current X position of an element based on page coordinates. * Element must be part of the DOM tree to have page coordinates * (display:none or elements not appended return false). * @method getX * @param element The target element * @return {Number} The X position of the element */ getX: function(node) { return Y_DOM.getXY(node)[0]; }, /** * Gets the current Y position of an element based on page coordinates. * Element must be part of the DOM tree to have page coordinates * (display:none or elements not appended return false). * @method getY * @param element The target element * @return {Number} The Y position of the element */ getY: function(node) { return Y_DOM.getXY(node)[1]; }, /** * Set the position of an html element in page coordinates. * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). * @method setXY * @param element The target element * @param {Array} xy Contains X & Y values for new position (coordinates are page-based) * @param {Boolean} noRetry By default we try and set the position a second time if the first fails */ setXY: function(node, xy, noRetry) { var setStyle = Y_DOM.setStyle, pos, delta, newXY, currentXY; if (node && xy) { pos = Y_DOM.getStyle(node, POSITION); delta = Y_DOM._getOffset(node); if (pos == 'static') { // default to relative pos = RELATIVE; setStyle(node, POSITION, pos); } currentXY = Y_DOM.getXY(node); if (xy[0] !== null) { setStyle(node, LEFT, xy[0] - currentXY[0] + delta[0] + 'px'); } if (xy[1] !== null) { setStyle(node, TOP, xy[1] - currentXY[1] + delta[1] + 'px'); } if (!noRetry) { newXY = Y_DOM.getXY(node); if (newXY[0] !== xy[0] || newXY[1] !== xy[1]) { Y_DOM.setXY(node, xy, true); } } } else { } }, /** * Set the X position of an html element in page coordinates, regardless of how the element is positioned. * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). * @method setX * @param element The target element * @param {Number} x The X values for new position (coordinates are page-based) */ setX: function(node, x) { return Y_DOM.setXY(node, [x, null]); }, /** * Set the Y position of an html element in page coordinates, regardless of how the element is positioned. * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). * @method setY * @param element The target element * @param {Number} y The Y values for new position (coordinates are page-based) */ setY: function(node, y) { return Y_DOM.setXY(node, [null, y]); }, /** * @method swapXY * @description Swap the xy position with another node * @param {Node} node The node to swap with * @param {Node} otherNode The other node to swap with * @return {Node} */ swapXY: function(node, otherNode) { var xy = Y_DOM.getXY(node); Y_DOM.setXY(node, Y_DOM.getXY(otherNode)); Y_DOM.setXY(otherNode, xy); }, _calcBorders: function(node, xy2) { var t = parseInt(Y_DOM[GET_COMPUTED_STYLE](node, BORDER_TOP_WIDTH), 10) || 0, l = parseInt(Y_DOM[GET_COMPUTED_STYLE](node, BORDER_LEFT_WIDTH), 10) || 0; if (Y.UA.gecko) { if (RE_TABLE.test(node.tagName)) { t = 0; l = 0; } } xy2[0] += l; xy2[1] += t; return xy2; }, _getWinSize: function(node, doc) { doc = doc || (node) ? Y_DOM._getDoc(node) : Y.config.doc; var win = doc.defaultView || doc.parentWindow, mode = doc[COMPAT_MODE], h = win.innerHeight, w = win.innerWidth, root = doc[DOCUMENT_ELEMENT]; if ( mode && !Y.UA.opera ) { // IE, Gecko if (mode != 'CSS1Compat') { // Quirks root = doc.body; } h = root.clientHeight; w = root.clientWidth; } return { height: h, width: w }; }, _getDocSize: function(node) { var doc = (node) ? Y_DOM._getDoc(node) : Y.config.doc, root = doc[DOCUMENT_ELEMENT]; if (doc[COMPAT_MODE] != 'CSS1Compat') { root = doc.body; } return { height: root.scrollHeight, width: root.scrollWidth }; } }); })(Y); (function(Y) { var TOP = 'top', RIGHT = 'right', BOTTOM = 'bottom', LEFT = 'left', getOffsets = function(r1, r2) { var t = Math.max(r1[TOP], r2[TOP]), r = Math.min(r1[RIGHT], r2[RIGHT]), b = Math.min(r1[BOTTOM], r2[BOTTOM]), l = Math.max(r1[LEFT], r2[LEFT]), ret = {}; ret[TOP] = t; ret[RIGHT] = r; ret[BOTTOM] = b; ret[LEFT] = l; return ret; }, DOM = Y.DOM; Y.mix(DOM, { /** * Returns an Object literal containing the following about this element: (top, right, bottom, left) * @for DOM * @method region * @param {HTMLElement} element The DOM element. * @return {Object} Object literal containing the following about this element: (top, right, bottom, left) */ region: function(node) { var xy = DOM.getXY(node), ret = false; if (node && xy) { ret = DOM._getRegion( xy[1], // top xy[0] + node.offsetWidth, // right xy[1] + node.offsetHeight, // bottom xy[0] // left ); } return ret; }, /** * Find the intersect information for the passed nodes. * @method intersect * @for DOM * @param {HTMLElement} element The first element * @param {HTMLElement | Object} element2 The element or region to check the interect with * @param {Object} altRegion An object literal containing the region for the first element if we already have the data (for performance e.g. DragDrop) * @return {Object} Object literal containing the following intersection data: (top, right, bottom, left, area, yoff, xoff, inRegion) */ intersect: function(node, node2, altRegion) { var r = altRegion || DOM.region(node), region = {}, n = node2, off; if (n.tagName) { region = DOM.region(n); } else if (Y.Lang.isObject(node2)) { region = node2; } else { return false; } off = getOffsets(region, r); return { top: off[TOP], right: off[RIGHT], bottom: off[BOTTOM], left: off[LEFT], area: ((off[BOTTOM] - off[TOP]) * (off[RIGHT] - off[LEFT])), yoff: ((off[BOTTOM] - off[TOP])), xoff: (off[RIGHT] - off[LEFT]), inRegion: DOM.inRegion(node, node2, false, altRegion) }; }, /** * Check if any part of this node is in the passed region * @method inRegion * @for DOM * @param {Object} node The node to get the region from * @param {Object} node2 The second node to get the region from or an Object literal of the region * @param {Boolean} all Should all of the node be inside the region * @param {Object} altRegion An object literal containing the region for this node if we already have the data (for performance e.g. DragDrop) * @return {Boolean} True if in region, false if not. */ inRegion: function(node, node2, all, altRegion) { var region = {}, r = altRegion || DOM.region(node), n = node2, off; if (n.tagName) { region = DOM.region(n); } else if (Y.Lang.isObject(node2)) { region = node2; } else { return false; } if (all) { return ( r[LEFT] >= region[LEFT] && r[RIGHT] <= region[RIGHT] && r[TOP] >= region[TOP] && r[BOTTOM] <= region[BOTTOM] ); } else { off = getOffsets(region, r); if (off[BOTTOM] >= off[TOP] && off[RIGHT] >= off[LEFT]) { return true; } else { return false; } } }, /** * Check if any part of this element is in the viewport * @method inViewportRegion * @for DOM * @param {HTMLElement} element The DOM element. * @param {Boolean} all Should all of the node be inside the region * @param {Object} altRegion An object literal containing the region for this node if we already have the data (for performance e.g. DragDrop) * @return {Boolean} True if in region, false if not. */ inViewportRegion: function(node, all, altRegion) { return DOM.inRegion(node, DOM.viewportRegion(node), all, altRegion); }, _getRegion: function(t, r, b, l) { var region = {}; region[TOP] = region[1] = t; region[LEFT] = region[0] = l; region[BOTTOM] = b; region[RIGHT] = r; region.width = region[RIGHT] - region[LEFT]; region.height = region[BOTTOM] - region[TOP]; return region; }, /** * Returns an Object literal containing the following about the visible region of viewport: (top, right, bottom, left) * @method viewportRegion * @for DOM * @return {Object} Object literal containing the following about the visible region of the viewport: (top, right, bottom, left) */ viewportRegion: function(node) { node = node || Y.config.doc.documentElement; var ret = false, scrollX, scrollY; if (node) { scrollX = DOM.docScrollX(node); scrollY = DOM.docScrollY(node); ret = DOM._getRegion(scrollY, // top DOM.winWidth(node) + scrollX, // right scrollY + DOM.winHeight(node), // bottom scrollX); // left } return ret; } }); })(Y); }, '3.17.2', {"requires": ["dom-base", "dom-style"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('node-screen', function (Y, NAME) { /** * Extended Node interface for managing regions and screen positioning. * Adds support for positioning elements and normalizes window size and scroll detection. * @module node * @submodule node-screen */ // these are all "safe" returns, no wrapping required Y.each([ /** * Returns the inner width of the viewport (exludes scrollbar). * @config winWidth * @for Node * @type {Number} */ 'winWidth', /** * Returns the inner height of the viewport (exludes scrollbar). * @config winHeight * @type {Number} */ 'winHeight', /** * Document width * @config docWidth * @type {Number} */ 'docWidth', /** * Document height * @config docHeight * @type {Number} */ 'docHeight', /** * Pixel distance the page has been scrolled horizontally * @config docScrollX * @type {Number} */ 'docScrollX', /** * Pixel distance the page has been scrolled vertically * @config docScrollY * @type {Number} */ 'docScrollY' ], function(name) { Y.Node.ATTRS[name] = { getter: function() { var args = Array.prototype.slice.call(arguments); args.unshift(Y.Node.getDOMNode(this)); return Y.DOM[name].apply(this, args); } }; } ); Y.Node.ATTRS.scrollLeft = { getter: function() { var node = Y.Node.getDOMNode(this); return ('scrollLeft' in node) ? node.scrollLeft : Y.DOM.docScrollX(node); }, setter: function(val) { var node = Y.Node.getDOMNode(this); if (node) { if ('scrollLeft' in node) { node.scrollLeft = val; } else if (node.document || node.nodeType === 9) { Y.DOM._getWin(node).scrollTo(val, Y.DOM.docScrollY(node)); // scroll window if win or doc } } else { } } }; Y.Node.ATTRS.scrollTop = { getter: function() { var node = Y.Node.getDOMNode(this); return ('scrollTop' in node) ? node.scrollTop : Y.DOM.docScrollY(node); }, setter: function(val) { var node = Y.Node.getDOMNode(this); if (node) { if ('scrollTop' in node) { node.scrollTop = val; } else if (node.document || node.nodeType === 9) { Y.DOM._getWin(node).scrollTo(Y.DOM.docScrollX(node), val); // scroll window if win or doc } } else { } } }; Y.Node.importMethod(Y.DOM, [ /** * Gets the current position of the node in page coordinates. * @method getXY * @for Node * @return {Array} The XY position of the node */ 'getXY', /** * Set the position of the node in page coordinates, regardless of how the node is positioned. * @method setXY * @param {Array} xy Contains X & Y values for new position (coordinates are page-based) * @chainable */ 'setXY', /** * Gets the current position of the node in page coordinates. * @method getX * @return {Number} The X position of the node */ 'getX', /** * Set the position of the node in page coordinates, regardless of how the node is positioned. * @method setX * @param {Number} x X value for new position (coordinates are page-based) * @chainable */ 'setX', /** * Gets the current position of the node in page coordinates. * @method getY * @return {Number} The Y position of the node */ 'getY', /** * Set the position of the node in page coordinates, regardless of how the node is positioned. * @method setY * @param {Number} y Y value for new position (coordinates are page-based) * @chainable */ 'setY', /** * Swaps the XY position of this node with another node. * @method swapXY * @param {Node | HTMLElement} otherNode The node to swap with. * @chainable */ 'swapXY' ]); /** * @module node * @submodule node-screen */ /** * Returns a region object for the node * @config region * @for Node * @type Node */ Y.Node.ATTRS.region = { getter: function() { var node = this.getDOMNode(), region; if (node && !node.tagName) { if (node.nodeType === 9) { // document node = node.documentElement; } } if (Y.DOM.isWindow(node)) { region = Y.DOM.viewportRegion(node); } else { region = Y.DOM.region(node); } return region; } }; /** * Returns a region object for the node's viewport * @config viewportRegion * @type Node */ Y.Node.ATTRS.viewportRegion = { getter: function() { return Y.DOM.viewportRegion(Y.Node.getDOMNode(this)); } }; Y.Node.importMethod(Y.DOM, 'inViewportRegion'); // these need special treatment to extract 2nd node arg /** * Compares the intersection of the node with another node or region * @method intersect * @for Node * @param {Node|Object} node2 The node or region to compare with. * @param {Object} altRegion An alternate region to use (rather than this node's). * @return {Object} An object representing the intersection of the regions. */ Y.Node.prototype.intersect = function(node2, altRegion) { var node1 = Y.Node.getDOMNode(this); if (Y.instanceOf(node2, Y.Node)) { // might be a region object node2 = Y.Node.getDOMNode(node2); } return Y.DOM.intersect(node1, node2, altRegion); }; /** * Determines whether or not the node is within the given region. * @method inRegion * @param {Node|Object} node2 The node or region to compare with. * @param {Boolean} all Whether or not all of the node must be in the region. * @param {Object} altRegion An alternate region to use (rather than this node's). * @return {Boolean} True if in region, false if not. */ Y.Node.prototype.inRegion = function(node2, all, altRegion) { var node1 = Y.Node.getDOMNode(this); if (Y.instanceOf(node2, Y.Node)) { // might be a region object node2 = Y.Node.getDOMNode(node2); } return Y.DOM.inRegion(node1, node2, all, altRegion); }; }, '3.17.2', {"requires": ["dom-screen", "node-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('node-style', function (Y, NAME) { (function(Y) { /** * Extended Node interface for managing node styles. * @module node * @submodule node-style */ Y.mix(Y.Node.prototype, { /** * Sets a style property of the node. * Use camelCase (e.g. 'backgroundColor') for multi-word properties. * @method setStyle * @param {String} attr The style attribute to set. * @param {String|Number} val The value. * @chainable */ setStyle: function(attr, val) { Y.DOM.setStyle(this._node, attr, val); return this; }, /** * Sets multiple style properties on the node. * Use camelCase (e.g. 'backgroundColor') for multi-word properties. * @method setStyles * @param {Object} hash An object literal of property:value pairs. * @chainable */ setStyles: function(hash) { Y.DOM.setStyles(this._node, hash); return this; }, /** * Returns the style's current value. * Use camelCase (e.g. 'backgroundColor') for multi-word properties. * @method getStyle * @for Node * @param {String} attr The style attribute to retrieve. * @return {String} The current value of the style property for the element. */ getStyle: function(attr) { return Y.DOM.getStyle(this._node, attr); }, /** * Returns the computed value for the given style property. * Use camelCase (e.g. 'backgroundColor') for multi-word properties. * @method getComputedStyle * @param {String} attr The style attribute to retrieve. * @return {String} The computed value of the style property for the element. */ getComputedStyle: function(attr) { return Y.DOM.getComputedStyle(this._node, attr); } }); /** * Returns an array of values for each node. * Use camelCase (e.g. 'backgroundColor') for multi-word properties. * @method getStyle * @for NodeList * @see Node.getStyle * @param {String} attr The style attribute to retrieve. * @return {Array} The current values of the style property for the element. */ /** * Returns an array of the computed value for each node. * Use camelCase (e.g. 'backgroundColor') for multi-word properties. * @method getComputedStyle * @see Node.getComputedStyle * @param {String} attr The style attribute to retrieve. * @return {Array} The computed values for each node. */ /** * Sets a style property on each node. * Use camelCase (e.g. 'backgroundColor') for multi-word properties. * @method setStyle * @see Node.setStyle * @param {String} attr The style attribute to set. * @param {String|Number} val The value. * @chainable */ /** * Sets multiple style properties on each node. * Use camelCase (e.g. 'backgroundColor') for multi-word properties. * @method setStyles * @see Node.setStyles * @param {Object} hash An object literal of property:value pairs. * @chainable */ // These are broken out to handle undefined return (avoid false positive for // chainable) Y.NodeList.importMethod(Y.Node.prototype, ['getStyle', 'getComputedStyle', 'setStyle', 'setStyles']); })(Y); /** * @module node * @submodule node-base */ var Y_Node = Y.Node; Y.mix(Y_Node.prototype, { /** * Makes the node visible. * If the "transition" module is loaded, show optionally * animates the showing of the node using either the default * transition effect ('fadeIn'), or the given named effect. * @method show * @for Node * @param {String} name A named Transition effect to use as the show effect. * @param {Object} config Options to use with the transition. * @param {Function} callback An optional function to run after the transition completes. * @chainable */ show: function(callback) { callback = arguments[arguments.length - 1]; this.toggleView(true, callback); return this; }, /** * The implementation for showing nodes. * Default is to remove the hidden attribute and reset the CSS style.display property. * @method _show * @protected * @chainable */ _show: function() { this.removeAttribute('hidden'); // For back-compat we need to leave this in for browsers that // do not visually hide a node via the hidden attribute // and for users that check visibility based on style display. this.setStyle('display', ''); }, /** Returns whether the node is hidden by YUI or not. The hidden status is determined by the 'hidden' attribute and the value of the 'display' CSS property. @method _isHidden @return {Boolean} `true` if the node is hidden. @private **/ _isHidden: function() { return this.hasAttribute('hidden') || Y.DOM.getComputedStyle(this._node, 'display') === 'none'; }, /** * Displays or hides the node. * If the "transition" module is loaded, toggleView optionally * animates the toggling of the node using given named effect. * @method toggleView * @for Node * @param {Boolean} [on] An optional boolean value to force the node to be shown or hidden * @param {Function} [callback] An optional function to run after the transition completes. * @chainable */ toggleView: function(on, callback) { this._toggleView.apply(this, arguments); return this; }, _toggleView: function(on, callback) { callback = arguments[arguments.length - 1]; // base on current state if not forcing if (typeof on != 'boolean') { on = (this._isHidden()) ? 1 : 0; } if (on) { this._show(); } else { this._hide(); } if (typeof callback == 'function') { callback.call(this); } return this; }, /** * Hides the node. * If the "transition" module is loaded, hide optionally * animates the hiding of the node using either the default * transition effect ('fadeOut'), or the given named effect. * @method hide * @param {String} name A named Transition effect to use as the show effect. * @param {Object} config Options to use with the transition. * @param {Function} callback An optional function to run after the transition completes. * @chainable */ hide: function(callback) { callback = arguments[arguments.length - 1]; this.toggleView(false, callback); return this; }, /** * The implementation for hiding nodes. * Default is to set the hidden attribute to true and set the CSS style.display to 'none'. * @method _hide * @protected * @chainable */ _hide: function() { this.setAttribute('hidden', 'hidden'); // For back-compat we need to leave this in for browsers that // do not visually hide a node via the hidden attribute // and for users that check visibility based on style display. this.setStyle('display', 'none'); } }); Y.NodeList.importMethod(Y.Node.prototype, [ /** * Makes each node visible. * If the "transition" module is loaded, show optionally * animates the showing of the node using either the default * transition effect ('fadeIn'), or the given named effect. * @method show * @param {String} name A named Transition effect to use as the show effect. * @param {Object} config Options to use with the transition. * @param {Function} callback An optional function to run after the transition completes. * @for NodeList * @chainable */ 'show', /** * Hides each node. * If the "transition" module is loaded, hide optionally * animates the hiding of the node using either the default * transition effect ('fadeOut'), or the given named effect. * @method hide * @param {String} name A named Transition effect to use as the show effect. * @param {Object} config Options to use with the transition. * @param {Function} callback An optional function to run after the transition completes. * @chainable */ 'hide', /** * Displays or hides each node. * If the "transition" module is loaded, toggleView optionally * animates the toggling of the nodes using given named effect. * @method toggleView * @param {Boolean} [on] An optional boolean value to force the nodes to be shown or hidden * @param {Function} [callback] An optional function to run after the transition completes. * @chainable */ 'toggleView' ]); }, '3.17.2', {"requires": ["dom-style", "node-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('querystring-stringify-simple', function (Y, NAME) { /*global Y */ /** *

Provides Y.QueryString.stringify method for converting objects to Query Strings. * This is a subset implementation of the full querystring-stringify.

*

This module provides the bare minimum functionality (encoding a hash of simple values), * without the additional support for nested data structures. Every key-value pair is * encoded by encodeURIComponent.

*

This module provides a minimalistic way for io to handle single-level objects * as transaction data.

* * @module querystring * @submodule querystring-stringify-simple */ var QueryString = Y.namespace("QueryString"), EUC = encodeURIComponent; QueryString.stringify = function (obj, c) { var qs = [], // Default behavior is false; standard key notation. s = c && c.arrayKey ? true : false, key, i, l; for (key in obj) { if (obj.hasOwnProperty(key)) { if (Y.Lang.isArray(obj[key])) { for (i = 0, l = obj[key].length; i < l; i++) { qs.push(EUC(s ? key + '[]' : key) + '=' + EUC(obj[key][i])); } } else { qs.push(EUC(key) + '=' + EUC(obj[key])); } } } return qs.join('&'); }; }, '3.17.2', {"requires": ["yui-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('io-base', function (Y, NAME) { /** Base IO functionality. Provides basic XHR transport support. @module io @submodule io-base @for IO **/ var // List of events that comprise the IO event lifecycle. EVENTS = ['start', 'complete', 'end', 'success', 'failure', 'progress'], // Whitelist of used XHR response object properties. XHR_PROPS = ['status', 'statusText', 'responseText', 'responseXML'], win = Y.config.win, uid = 0; /** The IO class is a utility that brokers HTTP requests through a simplified interface. Specifically, it allows JavaScript to make HTTP requests to a resource without a page reload. The underlying transport for making same-domain requests is the XMLHttpRequest object. IO can also use Flash, if specified as a transport, for cross-domain requests. @class IO @constructor @param {Object} config Object of EventTarget's publish method configurations used to configure IO's events. **/ function IO (config) { var io = this; io._uid = 'io:' + uid++; io._init(config); Y.io._map[io._uid] = io; } IO.prototype = { //-------------------------------------- // Properties //-------------------------------------- /** * A counter that increments for each transaction. * * @property _id * @private * @type {Number} */ _id: 0, /** * Object of IO HTTP headers sent with each transaction. * * @property _headers * @private * @type {Object} */ _headers: { 'X-Requested-With' : 'XMLHttpRequest' }, /** * Object that stores timeout values for any transaction with a defined * "timeout" configuration property. * * @property _timeout * @private * @type {Object} */ _timeout: {}, //-------------------------------------- // Methods //-------------------------------------- _init: function(config) { var io = this, i, len; io.cfg = config || {}; Y.augment(io, Y.EventTarget); for (i = 0, len = EVENTS.length; i < len; ++i) { // Publish IO global events with configurations, if any. // IO global events are set to broadcast by default. // These events use the "io:" namespace. io.publish('io:' + EVENTS[i], Y.merge({ broadcast: 1 }, config)); // Publish IO transaction events with configurations, if // any. These events use the "io-trn:" namespace. io.publish('io-trn:' + EVENTS[i], config); } }, /** * Method that creates a unique transaction object for each request. * * @method _create * @private * @param {Object} cfg Configuration object subset to determine if * the transaction is an XDR or file upload, * requiring an alternate transport. * @param {Number} id Transaction id * @return {Object} The transaction object */ _create: function(config, id) { var io = this, transaction = { id : Y.Lang.isNumber(id) ? id : io._id++, uid: io._uid }, alt = config.xdr ? config.xdr.use : null, form = config.form && config.form.upload ? 'iframe' : null, use; if (alt === 'native') { // Non-IE and IE >= 10 can use XHR level 2 and not rely on an // external transport. alt = Y.UA.ie && !SUPPORTS_CORS ? 'xdr' : null; // Prevent "pre-flight" OPTIONS request by removing the // `X-Requested-With` HTTP header from CORS requests. This header // can be added back on a per-request basis, if desired. io.setHeader('X-Requested-With'); } use = alt || form; transaction = use ? Y.merge(Y.IO.customTransport(use), transaction) : Y.merge(Y.IO.defaultTransport(), transaction); if (transaction.notify) { config.notify = function (e, t, c) { io.notify(e, t, c); }; } if (!use) { if (win && win.FormData && config.data instanceof win.FormData) { transaction.c.upload.onprogress = function (e) { io.progress(transaction, e, config); }; transaction.c.onload = function (e) { io.load(transaction, e, config); }; transaction.c.onerror = function (e) { io.error(transaction, e, config); }; transaction.upload = true; } } return transaction; }, _destroy: function(transaction) { if (win && !transaction.notify && !transaction.xdr) { if (XHR && !transaction.upload) { transaction.c.onreadystatechange = null; } else if (transaction.upload) { transaction.c.upload.onprogress = null; transaction.c.onload = null; transaction.c.onerror = null; } else if (Y.UA.ie && !transaction.e) { // IE, when using XMLHttpRequest as an ActiveX Object, will throw // a "Type Mismatch" error if the event handler is set to "null". transaction.c.abort(); } } transaction = transaction.c = null; }, /** * Method for creating and firing events. * * @method _evt * @private * @param {String} eventName Event to be published. * @param {Object} transaction Transaction object. * @param {Object} config Configuration data subset for event subscription. */ _evt: function(eventName, transaction, config) { var io = this, params, args = config['arguments'], emitFacade = io.cfg.emitFacade, globalEvent = "io:" + eventName, trnEvent = "io-trn:" + eventName; // Workaround for #2532107 this.detach(trnEvent); if (transaction.e) { transaction.c = { status: 0, statusText: transaction.e }; } // Fire event with parameters or an Event Facade. params = [ emitFacade ? { id: transaction.id, data: transaction.c, cfg: config, 'arguments': args } : transaction.id ]; if (!emitFacade) { if (eventName === EVENTS[0] || eventName === EVENTS[2]) { if (args) { params.push(args); } } else { if (transaction.evt) { params.push(transaction.evt); } else { params.push(transaction.c); } if (args) { params.push(args); } } } params.unshift(globalEvent); // Fire global events. io.fire.apply(io, params); // Fire transaction events, if receivers are defined. if (config.on) { params[0] = trnEvent; io.once(trnEvent, config.on[eventName], config.context || Y); io.fire.apply(io, params); } }, /** * Fires event "io:start" and creates, fires a transaction-specific * start event, if `config.on.start` is defined. * * @method start * @param {Object} transaction Transaction object. * @param {Object} config Configuration object for the transaction. */ start: function(transaction, config) { /** * Signals the start of an IO request. * @event io:start */ this._evt(EVENTS[0], transaction, config); }, /** * Fires event "io:complete" and creates, fires a * transaction-specific "complete" event, if config.on.complete is * defined. * * @method complete * @param {Object} transaction Transaction object. * @param {Object} config Configuration object for the transaction. */ complete: function(transaction, config) { /** * Signals the completion of the request-response phase of a * transaction. Response status and data are accessible, if * available, in this event. * @event io:complete */ this._evt(EVENTS[1], transaction, config); }, /** * Fires event "io:end" and creates, fires a transaction-specific "end" * event, if config.on.end is defined. * * @method end * @param {Object} transaction Transaction object. * @param {Object} config Configuration object for the transaction. */ end: function(transaction, config) { /** * Signals the end of the transaction lifecycle. * @event io:end */ this._evt(EVENTS[2], transaction, config); this._destroy(transaction); }, /** * Fires event "io:success" and creates, fires a transaction-specific * "success" event, if config.on.success is defined. * * @method success * @param {Object} transaction Transaction object. * @param {Object} config Configuration object for the transaction. */ success: function(transaction, config) { /** * Signals an HTTP response with status in the 2xx range. * Fires after io:complete. * @event io:success */ this._evt(EVENTS[3], transaction, config); this.end(transaction, config); }, /** * Fires event "io:failure" and creates, fires a transaction-specific * "failure" event, if config.on.failure is defined. * * @method failure * @param {Object} transaction Transaction object. * @param {Object} config Configuration object for the transaction. */ failure: function(transaction, config) { /** * Signals an HTTP response with status outside of the 2xx range. * Fires after io:complete. * @event io:failure */ this._evt(EVENTS[4], transaction, config); this.end(transaction, config); }, /** * Fires event "io:progress" and creates, fires a transaction-specific * "progress" event -- for XMLHttpRequest file upload -- if * config.on.progress is defined. * * @method progress * @param {Object} transaction Transaction object. * @param {Object} progress event. * @param {Object} config Configuration object for the transaction. */ progress: function(transaction, e, config) { /** * Signals the interactive state during a file upload transaction. * This event fires after io:start and before io:complete. * @event io:progress */ transaction.evt = e; this._evt(EVENTS[5], transaction, config); }, /** * Fires event "io:complete" and creates, fires a transaction-specific * "complete" event -- for XMLHttpRequest file upload -- if * config.on.complete is defined. * * @method load * @param {Object} transaction Transaction object. * @param {Object} load event. * @param {Object} config Configuration object for the transaction. */ load: function (transaction, e, config) { transaction.evt = e.target; this._evt(EVENTS[1], transaction, config); }, /** * Fires event "io:failure" and creates, fires a transaction-specific * "failure" event -- for XMLHttpRequest file upload -- if * config.on.failure is defined. * * @method error * @param {Object} transaction Transaction object. * @param {Object} error event. * @param {Object} config Configuration object for the transaction. */ error: function (transaction, e, config) { transaction.evt = e; this._evt(EVENTS[4], transaction, config); }, /** * Retry an XDR transaction, using the Flash tranport, if the native * transport fails. * * @method _retry * @private * @param {Object} transaction Transaction object. * @param {String} uri Qualified path to transaction resource. * @param {Object} config Configuration object for the transaction. */ _retry: function(transaction, uri, config) { this._destroy(transaction); config.xdr.use = 'flash'; return this.send(uri, config, transaction.id); }, /** * Method that concatenates string data for HTTP GET transactions. * * @method _concat * @private * @param {String} uri URI or root data. * @param {String} data Data to be concatenated onto URI. * @return {String} */ _concat: function(uri, data) { uri += (uri.indexOf('?') === -1 ? '?' : '&') + data; return uri; }, /** * Stores default client headers for all transactions. If a label is * passed with no value argument, the header will be deleted. * * @method setHeader * @param {String} name HTTP header * @param {String} value HTTP header value */ setHeader: function(name, value) { if (value) { this._headers[name] = value; } else { delete this._headers[name]; } }, /** * Method that sets all HTTP headers to be sent in a transaction. * * @method _setHeaders * @private * @param {Object} transaction - XHR instance for the specific transaction. * @param {Object} headers - HTTP headers for the specific transaction, as * defined in the configuration object passed to YUI.io(). */ _setHeaders: function(transaction, headers) { headers = Y.merge(this._headers, headers); Y.Object.each(headers, function(value, name) { if (value !== 'disable') { transaction.setRequestHeader(name, headers[name]); } }); }, /** * Starts timeout count if the configuration object has a defined * timeout property. * * @method _startTimeout * @private * @param {Object} transaction Transaction object generated by _create(). * @param {Object} timeout Timeout in milliseconds. */ _startTimeout: function(transaction, timeout) { var io = this; io._timeout[transaction.id] = setTimeout(function() { io._abort(transaction, 'timeout'); }, timeout); }, /** * Clears the timeout interval started by _startTimeout(). * * @method _clearTimeout * @private * @param {Number} id - Transaction id. */ _clearTimeout: function(id) { clearTimeout(this._timeout[id]); delete this._timeout[id]; }, /** * Method that determines if a transaction response qualifies as success * or failure, based on the response HTTP status code, and fires the * appropriate success or failure events. * * @method _result * @private * @static * @param {Object} transaction Transaction object generated by _create(). * @param {Object} config Configuration object passed to io(). */ _result: function(transaction, config) { var status; // Firefox will throw an exception if attempting to access // an XHR object's status property, after a request is aborted. try { status = transaction.c.status; } catch(e) { status = 0; } // IE reports HTTP 204 as HTTP 1223. if (status >= 200 && status < 300 || status === 304 || status === 1223) { this.success(transaction, config); } else { this.failure(transaction, config); } }, /** * Event handler bound to onreadystatechange. * * @method _rS * @private * @param {Object} transaction Transaction object generated by _create(). * @param {Object} config Configuration object passed to YUI.io(). */ _rS: function(transaction, config) { var io = this; if (transaction.c.readyState === 4) { if (config.timeout) { io._clearTimeout(transaction.id); } // Yield in the event of request timeout or abort. setTimeout(function() { io.complete(transaction, config); io._result(transaction, config); }, 0); } }, /** * Terminates a transaction due to an explicit abort or timeout. * * @method _abort * @private * @param {Object} transaction Transaction object generated by _create(). * @param {String} type Identifies timed out or aborted transaction. */ _abort: function(transaction, type) { if (transaction && transaction.c) { transaction.e = type; transaction.c.abort(); } }, /** * Requests a transaction. `send()` is implemented as `Y.io()`. Each * transaction may include a configuration object. Its properties are: * *
*
method
*
HTTP method verb (e.g., GET or POST). If this property is not * not defined, the default value will be GET.
* *
data
*
This is the name-value string that will be sent as the * transaction data. If the request is HTTP GET, the data become * part of querystring. If HTTP POST, the data are sent in the * message body.
* *
xdr
*
Defines the transport to be used for cross-domain requests. * By setting this property, the transaction will use the specified * transport instead of XMLHttpRequest. The properties of the * transport object are: *
*
use
*
The transport to be used: 'flash' or 'native'
*
dataType
*
Set the value to 'XML' if that is the expected response * content type.
*
credentials
*
Set the value to 'true' to set XHR.withCredentials property to true.
*
* *
form
*
Form serialization configuration object. Its properties are: *
*
id
*
Node object or id of HTML form
*
useDisabled
*
`true` to also serialize disabled form field values * (defaults to `false`)
*
* *
on
*
Assigns transaction event subscriptions. Available events are: *
*
start
*
Fires when a request is sent to a resource.
*
complete
*
Fires when the transaction is complete.
*
success
*
Fires when the HTTP response status is within the 2xx * range.
*
failure
*
Fires when the HTTP response status is outside the 2xx * range, if an exception occurs, if the transation is aborted, * or if the transaction exceeds a configured `timeout`.
*
end
*
Fires at the conclusion of the transaction * lifecycle, after `success` or `failure`.
*
* *

Callback functions for `start` and `end` receive the id of the * transaction as a first argument. For `complete`, `success`, and * `failure`, callbacks receive the id and the response object * (usually the XMLHttpRequest instance). If the `arguments` * property was included in the configuration object passed to * `Y.io()`, the configured data will be passed to all callbacks as * the last argument.

*
* *
sync
*
Pass `true` to make a same-domain transaction synchronous. * CAVEAT: This will negatively impact the user * experience. Have a very good reason if you intend to use * this.
* *
context
*
The "`this'" object for all configured event handlers. If a * specific context is needed for individual callbacks, bind the * callback to a context using `Y.bind()`.
* *
headers
*
Object map of transaction headers to send to the server. The * object keys are the header names and the values are the header * values.
* *
username
*
Username to use in a HTTP authentication.
* *
password
*
Password to use in a HTTP authentication.
* *
timeout
*
Millisecond threshold for the transaction before being * automatically aborted.
* *
arguments
*
User-defined data passed to all registered event handlers. * This value is available as the second argument in the "start" and * "end" event handlers. It is the third argument in the "complete", * "success", and "failure" event handlers. Be sure to quote * this property name in the transaction configuration as * "arguments" is a reserved word in JavaScript (e.g. * `Y.io({ ..., "arguments": stuff })`).
*
* * @method send * @public * @param {String} uri Qualified path to transaction resource. * @param {Object} config Configuration object for the transaction. * @param {Number} id Transaction id, if already set. * @return {Object} */ send: function(uri, config, id) { var transaction, method, i, len, sync, data, io = this, u = uri, response = {}; config = config ? Y.Object(config) : {}; transaction = io._create(config, id); method = config.method ? config.method.toUpperCase() : 'GET'; sync = config.sync; data = config.data; // Serialize a map object into a key-value string using // querystring-stringify-simple. if ((Y.Lang.isObject(data) && !data.nodeType) && !transaction.upload) { if (Y.QueryString && Y.QueryString.stringify) { config.data = data = Y.QueryString.stringify(data); } else { } } if (config.form) { if (config.form.upload) { // This is a file upload transaction, calling // upload() in io-upload-iframe. return io.upload(transaction, uri, config); } else { // Serialize HTML form data into a key-value string. data = io._serialize(config.form, data); } } // Convert falsy values to an empty string. This way IE can't be // rediculous and translate `undefined` to "undefined". data || (data = ''); if (data) { switch (method) { case 'GET': case 'HEAD': case 'DELETE': u = io._concat(u, data); data = ''; break; case 'POST': case 'PUT': // If Content-Type is defined in the configuration object, or // or as a default header, it will be used instead of // 'application/x-www-form-urlencoded; charset=UTF-8' config.headers = Y.merge({ 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, config.headers); break; } } if (transaction.xdr) { // Route data to io-xdr module for flash and XDomainRequest. return io.xdr(u, transaction, config); } else if (transaction.notify) { // Route data to custom transport return transaction.c.send(transaction, uri, config); } if (!sync && !transaction.upload) { transaction.c.onreadystatechange = function() { io._rS(transaction, config); }; } try { // Determine if request is to be set as // synchronous or asynchronous. transaction.c.open(method, u, !sync, config.username || null, config.password || null); io._setHeaders(transaction.c, config.headers || {}); io.start(transaction, config); // Will work only in browsers that implement the // Cross-Origin Resource Sharing draft. if (config.xdr && config.xdr.credentials && SUPPORTS_CORS) { transaction.c.withCredentials = true; } // Using "null" with HTTP POST will result in a request // with no Content-Length header defined. transaction.c.send(data); if (sync) { // Create a response object for synchronous transactions, // mixing id and arguments properties with the xhr // properties whitelist. for (i = 0, len = XHR_PROPS.length; i < len; ++i) { response[XHR_PROPS[i]] = transaction.c[XHR_PROPS[i]]; } response.getAllResponseHeaders = function() { return transaction.c.getAllResponseHeaders(); }; response.getResponseHeader = function(name) { return transaction.c.getResponseHeader(name); }; io.complete(transaction, config); io._result(transaction, config); return response; } } catch(e) { if (transaction.xdr) { // This exception is usually thrown by browsers // that do not support XMLHttpRequest Level 2. // Retry the request with the XDR transport set // to 'flash'. If the Flash transport is not // initialized or available, the transaction // will resolve to a transport error. return io._retry(transaction, uri, config); } else { io.complete(transaction, config); io._result(transaction, config); } } // If config.timeout is defined, and the request is standard XHR, // initialize timeout polling. if (config.timeout) { io._startTimeout(transaction, config.timeout); } return { id: transaction.id, abort: function() { return transaction.c ? io._abort(transaction, 'abort') : false; }, isInProgress: function() { return transaction.c ? (transaction.c.readyState % 4) : false; }, io: io }; } }; /** Method for initiating an ajax call. The first argument is the url end point for the call. The second argument is an object to configure the transaction and attach event subscriptions. The configuration object supports the following properties:
method
HTTP method verb (e.g., GET or POST). If this property is not not defined, the default value will be GET.
data
This is the name-value string that will be sent as the transaction data. If the request is HTTP GET, the data become part of querystring. If HTTP POST, the data are sent in the message body.
xdr
Defines the transport to be used for cross-domain requests. By setting this property, the transaction will use the specified transport instead of XMLHttpRequest. The properties of the transport object are:
use
The transport to be used: 'flash' or 'native'
dataType
Set the value to 'XML' if that is the expected response content type.
form
Form serialization configuration object. Its properties are:
id
Node object or id of HTML form
useDisabled
`true` to also serialize disabled form field values (defaults to `false`)
on
Assigns transaction event subscriptions. Available events are:
start
Fires when a request is sent to a resource.
complete
Fires when the transaction is complete.
success
Fires when the HTTP response status is within the 2xx range.
failure
Fires when the HTTP response status is outside the 2xx range, if an exception occurs, if the transation is aborted, or if the transaction exceeds a configured `timeout`.
end
Fires at the conclusion of the transaction lifecycle, after `success` or `failure`.

Callback functions for `start` and `end` receive the id of the transaction as a first argument. For `complete`, `success`, and `failure`, callbacks receive the id and the response object (usually the XMLHttpRequest instance). If the `arguments` property was included in the configuration object passed to `Y.io()`, the configured data will be passed to all callbacks as the last argument.

sync
Pass `true` to make a same-domain transaction synchronous. CAVEAT: This will negatively impact the user experience. Have a very good reason if you intend to use this.
context
The "`this'" object for all configured event handlers. If a specific context is needed for individual callbacks, bind the callback to a context using `Y.bind()`.
headers
Object map of transaction headers to send to the server. The object keys are the header names and the values are the header values.
timeout
Millisecond threshold for the transaction before being automatically aborted.
arguments
User-defined data passed to all registered event handlers. This value is available as the second argument in the "start" and "end" event handlers. It is the third argument in the "complete", "success", and "failure" event handlers. Be sure to quote this property name in the transaction configuration as "arguments" is a reserved word in JavaScript (e.g. `Y.io({ ..., "arguments": stuff })`).
@method io @static @param {String} url qualified path to transaction resource. @param {Object} config configuration object for the transaction. @return {Object} @for YUI **/ Y.io = function(url, config) { // Calling IO through the static interface will use and reuse // an instance of IO. var transaction = Y.io._map['io:0'] || new IO(); return transaction.send.apply(transaction, [url, config]); }; /** Method for setting and deleting IO HTTP headers to be sent with every request. Hosted as a property on the `io` function (e.g. `Y.io.header`). @method header @param {String} name HTTP header @param {String} value HTTP header value @static **/ Y.io.header = function(name, value) { // Calling IO through the static interface will use and reuse // an instance of IO. var transaction = Y.io._map['io:0'] || new IO(); transaction.setHeader(name, value); }; Y.IO = IO; // Map of all IO instances created. Y.io._map = {}; var XHR = win && win.XMLHttpRequest, XDR = win && win.XDomainRequest, AX = win && win.ActiveXObject, // Checks for the presence of the `withCredentials` in an XHR instance // object, which will be present if the environment supports CORS. SUPPORTS_CORS = XHR && 'withCredentials' in (new XMLHttpRequest()); Y.mix(Y.IO, { /** * The ID of the default IO transport, defaults to `xhr` * @property _default * @type {String} * @static */ _default: 'xhr', /** * * @method defaultTransport * @static * @param {String} [id] The transport to set as the default, if empty a new transport is created. * @return {Object} The transport object with a `send` method */ defaultTransport: function(id) { if (id) { Y.IO._default = id; } else { var o = { c: Y.IO.transports[Y.IO._default](), notify: Y.IO._default === 'xhr' ? false : true }; return o; } }, /** * An object hash of custom transports available to IO * @property transports * @type {Object} * @static */ transports: { xhr: function () { return XHR ? new XMLHttpRequest() : AX ? new ActiveXObject('Microsoft.XMLHTTP') : null; }, xdr: function () { return XDR ? new XDomainRequest() : null; }, iframe: function () { return {}; }, flash: null, nodejs: null }, /** * Create a custom transport of type and return it's object * @method customTransport * @param {String} id The id of the transport to create. * @static */ customTransport: function(id) { var o = { c: Y.IO.transports[id]() }; o[(id === 'xdr' || id === 'flash') ? 'xdr' : 'notify'] = true; return o; } }); Y.mix(Y.IO.prototype, { /** * Fired from the notify method of the transport which in turn fires * the event on the IO object. * @method notify * @param {String} event The name of the event * @param {Object} transaction The transaction object * @param {Object} config The configuration object for this transaction */ notify: function(event, transaction, config) { var io = this; switch (event) { case 'timeout': case 'abort': case 'transport error': transaction.c = { status: 0, statusText: event }; event = 'failure'; default: io[event].apply(io, [transaction, config]); } } }); }, '3.17.2', {"requires": ["event-custom-base", "querystring-stringify-simple"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('json-parse', function (Y, NAME) { var _JSON = Y.config.global.JSON; Y.namespace('JSON').parse = function (obj, reviver, space) { return _JSON.parse((typeof obj === 'string' ? obj : obj + ''), reviver, space); }; }, '3.17.2', {"requires": ["yui-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('transition', function (Y, NAME) { /** * Provides the transition method for Node. * Transition has no API of its own, but adds the transition method to Node. * * @module transition * @requires node-style */ var CAMEL_VENDOR_PREFIX = '', VENDOR_PREFIX = '', DOCUMENT = Y.config.doc, DOCUMENT_ELEMENT = 'documentElement', DOCUMENT_STYLE = DOCUMENT[DOCUMENT_ELEMENT].style, TRANSITION_CAMEL = 'transition', TRANSITION_PROPERTY_CAMEL = 'transitionProperty', TRANSITION_PROPERTY, TRANSITION_DURATION, TRANSITION_TIMING_FUNCTION, TRANSITION_DELAY, TRANSITION_END, ON_TRANSITION_END, EMPTY_OBJ = {}, VENDORS = [ 'Webkit', 'Moz' ], VENDOR_TRANSITION_END = { Webkit: 'webkitTransitionEnd' }, /** * A class for constructing transition instances. * Adds the "transition" method to Node. * @class Transition * @constructor */ Transition = function() { this.init.apply(this, arguments); }; // One off handling of transform-prefixing. Transition._TRANSFORM = 'transform'; Transition._toCamel = function(property) { property = property.replace(/-([a-z])/gi, function(m0, m1) { return m1.toUpperCase(); }); return property; }; Transition._toHyphen = function(property) { property = property.replace(/([A-Z]?)([a-z]+)([A-Z]?)/g, function(m0, m1, m2, m3) { var str = ((m1) ? '-' + m1.toLowerCase() : '') + m2; if (m3) { str += '-' + m3.toLowerCase(); } return str; }); return property; }; Transition.SHOW_TRANSITION = 'fadeIn'; Transition.HIDE_TRANSITION = 'fadeOut'; Transition.useNative = false; // Map transition properties to vendor-specific versions. if ('transition' in DOCUMENT_STYLE && 'transitionProperty' in DOCUMENT_STYLE && 'transitionDuration' in DOCUMENT_STYLE && 'transitionTimingFunction' in DOCUMENT_STYLE && 'transitionDelay' in DOCUMENT_STYLE) { Transition.useNative = true; Transition.supported = true; // TODO: remove } else { Y.Array.each(VENDORS, function(val) { // then vendor specific var property = val + 'Transition'; if (property in DOCUMENT[DOCUMENT_ELEMENT].style) { CAMEL_VENDOR_PREFIX = val; VENDOR_PREFIX = Transition._toHyphen(val) + '-'; Transition.useNative = true; Transition.supported = true; // TODO: remove Transition._VENDOR_PREFIX = val; } }); } // Map transform property to vendor-specific versions. // One-off required for cssText injection. if (typeof DOCUMENT_STYLE.transform === 'undefined') { Y.Array.each(VENDORS, function(val) { // then vendor specific var property = val + 'Transform'; if (typeof DOCUMENT_STYLE[property] !== 'undefined') { Transition._TRANSFORM = property; } }); } if (CAMEL_VENDOR_PREFIX) { TRANSITION_CAMEL = CAMEL_VENDOR_PREFIX + 'Transition'; TRANSITION_PROPERTY_CAMEL = CAMEL_VENDOR_PREFIX + 'TransitionProperty'; } TRANSITION_PROPERTY = VENDOR_PREFIX + 'transition-property'; TRANSITION_DURATION = VENDOR_PREFIX + 'transition-duration'; TRANSITION_TIMING_FUNCTION = VENDOR_PREFIX + 'transition-timing-function'; TRANSITION_DELAY = VENDOR_PREFIX + 'transition-delay'; TRANSITION_END = 'transitionend'; ON_TRANSITION_END = 'on' + CAMEL_VENDOR_PREFIX.toLowerCase() + 'transitionend'; TRANSITION_END = VENDOR_TRANSITION_END[CAMEL_VENDOR_PREFIX] || TRANSITION_END; Transition.fx = {}; Transition.toggles = {}; Transition._hasEnd = {}; Transition._reKeywords = /^(?:node|duration|iterations|easing|delay|on|onstart|onend)$/i; Y.Node.DOM_EVENTS[TRANSITION_END] = 1; Transition.NAME = 'transition'; Transition.DEFAULT_EASING = 'ease'; Transition.DEFAULT_DURATION = 0.5; Transition.DEFAULT_DELAY = 0; Transition._nodeAttrs = {}; Transition.prototype = { constructor: Transition, init: function(node, config) { var anim = this; anim._node = node; if (!anim._running && config) { anim._config = config; node._transition = anim; // cache for reuse anim._duration = ('duration' in config) ? config.duration: anim.constructor.DEFAULT_DURATION; anim._delay = ('delay' in config) ? config.delay: anim.constructor.DEFAULT_DELAY; anim._easing = config.easing || anim.constructor.DEFAULT_EASING; anim._count = 0; // track number of animated properties anim._running = false; } return anim; }, addProperty: function(prop, config) { var anim = this, node = this._node, uid = Y.stamp(node), nodeInstance = Y.one(node), attrs = Transition._nodeAttrs[uid], computed, compareVal, dur, attr, val; if (!attrs) { attrs = Transition._nodeAttrs[uid] = {}; } attr = attrs[prop]; // might just be a value if (config && config.value !== undefined) { val = config.value; } else if (config !== undefined) { val = config; config = EMPTY_OBJ; } if (typeof val === 'function') { val = val.call(nodeInstance, nodeInstance); } if (attr && attr.transition) { // take control if another transition owns this property if (attr.transition !== anim) { attr.transition._count--; // remapping attr to this transition } } anim._count++; // properties per transition // make 0 async and fire events dur = ((typeof config.duration !== 'undefined') ? config.duration : anim._duration) || 0.0001; attrs[prop] = { value: val, duration: dur, delay: (typeof config.delay !== 'undefined') ? config.delay : anim._delay, easing: config.easing || anim._easing, transition: anim }; // native end event doesnt fire when setting to same value // supplementing with timer // val may be a string or number (height: 0, etc), but computedStyle is always string computed = Y.DOM.getComputedStyle(node, prop); compareVal = (typeof val === 'string') ? computed : parseFloat(computed); if (Transition.useNative && compareVal === val) { setTimeout(function() { anim._onNativeEnd.call(node, { propertyName: prop, elapsedTime: dur }); }, dur * 1000); } }, removeProperty: function(prop) { var anim = this, attrs = Transition._nodeAttrs[Y.stamp(anim._node)]; if (attrs && attrs[prop]) { delete attrs[prop]; anim._count--; } }, initAttrs: function(config) { var attr, node = this._node; if (config.transform && !config[Transition._TRANSFORM]) { config[Transition._TRANSFORM] = config.transform; delete config.transform; // TODO: copy } for (attr in config) { if (config.hasOwnProperty(attr) && !Transition._reKeywords.test(attr)) { this.addProperty(attr, config[attr]); // when size is auto or % webkit starts from zero instead of computed // (https://bugs.webkit.org/show_bug.cgi?id=16020) // TODO: selective set if (node.style[attr] === '') { Y.DOM.setStyle(node, attr, Y.DOM.getComputedStyle(node, attr)); } } } }, /** * Starts or an animation. * @method run * @chainable * @private */ run: function(callback) { var anim = this, node = anim._node, config = anim._config, data = { type: 'transition:start', config: config }; if (!anim._running) { anim._running = true; if (config.on && config.on.start) { config.on.start.call(Y.one(node), data); } anim.initAttrs(anim._config); anim._callback = callback; anim._start(); } return anim; }, _start: function() { this._runNative(); }, _prepDur: function(dur) { dur = parseFloat(dur) * 1000; return dur + 'ms'; }, _runNative: function() { var anim = this, node = anim._node, uid = Y.stamp(node), style = node.style, computed = node.ownerDocument.defaultView.getComputedStyle(node), attrs = Transition._nodeAttrs[uid], cssText = '', cssTransition = computed[Transition._toCamel(TRANSITION_PROPERTY)], transitionText = TRANSITION_PROPERTY + ': ', duration = TRANSITION_DURATION + ': ', easing = TRANSITION_TIMING_FUNCTION + ': ', delay = TRANSITION_DELAY + ': ', hyphy, attr, name; // preserve existing transitions if (cssTransition !== 'all') { transitionText += cssTransition + ','; duration += computed[Transition._toCamel(TRANSITION_DURATION)] + ','; easing += computed[Transition._toCamel(TRANSITION_TIMING_FUNCTION)] + ','; delay += computed[Transition._toCamel(TRANSITION_DELAY)] + ','; } // run transitions mapped to this instance for (name in attrs) { hyphy = Transition._toHyphen(name); attr = attrs[name]; if ((attr = attrs[name]) && attr.transition === anim) { if (name in node.style) { // only native styles allowed duration += anim._prepDur(attr.duration) + ','; delay += anim._prepDur(attr.delay) + ','; easing += (attr.easing) + ','; transitionText += hyphy + ','; cssText += hyphy + ': ' + attr.value + '; '; } else { this.removeProperty(name); } } } transitionText = transitionText.replace(/,$/, ';'); duration = duration.replace(/,$/, ';'); easing = easing.replace(/,$/, ';'); delay = delay.replace(/,$/, ';'); // only one native end event per node if (!Transition._hasEnd[uid]) { node.addEventListener(TRANSITION_END, anim._onNativeEnd, ''); Transition._hasEnd[uid] = true; } style.cssText += transitionText + duration + easing + delay + cssText; }, _end: function(elapsed) { var anim = this, node = anim._node, callback = anim._callback, config = anim._config, data = { type: 'transition:end', config: config, elapsedTime: elapsed }, nodeInstance = Y.one(node); anim._running = false; anim._callback = null; if (node) { if (config.on && config.on.end) { setTimeout(function() { // IE: allow previous update to finish config.on.end.call(nodeInstance, data); // nested to ensure proper fire order if (callback) { callback.call(nodeInstance, data); } }, 1); } else if (callback) { setTimeout(function() { // IE: allow previous update to finish callback.call(nodeInstance, data); }, 1); } } }, _endNative: function(name) { var node = this._node, value = node.ownerDocument.defaultView.getComputedStyle(node, '')[Transition._toCamel(TRANSITION_PROPERTY)]; name = Transition._toHyphen(name); if (typeof value === 'string') { value = value.replace(new RegExp('(?:^|,\\s)' + name + ',?'), ','); value = value.replace(/^,|,$/, ''); node.style[TRANSITION_CAMEL] = value; } }, _onNativeEnd: function(e) { var node = this, uid = Y.stamp(node), event = e,//e._event, name = Transition._toCamel(event.propertyName), elapsed = event.elapsedTime, attrs = Transition._nodeAttrs[uid], attr = attrs[name], anim = (attr) ? attr.transition : null, data, config; if (anim) { anim.removeProperty(name); anim._endNative(name); config = anim._config[name]; data = { type: 'propertyEnd', propertyName: name, elapsedTime: elapsed, config: config }; if (config && config.on && config.on.end) { config.on.end.call(Y.one(node), data); } if (anim._count <= 0) { // after propertyEnd fires anim._end(elapsed); node.style[TRANSITION_PROPERTY_CAMEL] = ''; // clean up style } } }, destroy: function() { var anim = this, node = anim._node; if (node) { node.removeEventListener(TRANSITION_END, anim._onNativeEnd, false); anim._node = null; } } }; Y.Transition = Transition; Y.TransitionNative = Transition; // TODO: remove /** * Animate one or more css properties to a given value. Requires the "transition" module. *
example usage:
 *       Y.one('#demo').transition({
 *           duration: 1, // in seconds, default is 0.5
 *           easing: 'ease-out', // default is 'ease'
 *           delay: '1', // delay start for 1 second, default is 0
 *
 *           height: '10px',
 *           width: '10px',
 *
 *           opacity: { // per property
 *               value: 0,
 *               duration: 2,
 *               delay: 2,
 *               easing: 'ease-in'
 *           }
 *       });
 *   
* @for Node * @method transition * @param {Object} config An object containing one or more style properties, a duration and an easing. * @param {Function} callback A function to run after the transition has completed. * @chainable */ Y.Node.prototype.transition = function(name, config, callback) { var transitionAttrs = Transition._nodeAttrs[Y.stamp(this._node)], anim = (transitionAttrs) ? transitionAttrs.transition || null : null, fxConfig, prop; if (typeof name === 'string') { // named effect, pull config from registry if (typeof config === 'function') { callback = config; config = null; } fxConfig = Transition.fx[name]; if (config && typeof config === 'object') { config = Y.clone(config); for (prop in fxConfig) { if (fxConfig.hasOwnProperty(prop)) { if (! (prop in config)) { config[prop] = fxConfig[prop]; } } } } else { config = fxConfig; } } else { // name is a config, config is a callback or undefined callback = config; config = name; } if (anim && !anim._running) { anim.init(this, config); } else { anim = new Transition(this._node, config); } anim.run(callback); return this; }; Y.Node.prototype.show = function(name, config, callback) { this._show(); // show prior to transition if (name && Y.Transition) { if (typeof name !== 'string' && !name.push) { // named effect or array of effects supercedes default if (typeof config === 'function') { callback = config; config = name; } name = Transition.SHOW_TRANSITION; } this.transition(name, config, callback); } return this; }; Y.NodeList.prototype.show = function(name, config, callback) { var nodes = this._nodes, i = 0, node; while ((node = nodes[i++])) { Y.one(node).show(name, config, callback); } return this; }; var _wrapCallBack = function(anim, fn, callback) { return function() { if (fn) { fn.call(anim); } if (callback && typeof callback === 'function') { callback.apply(anim._node, arguments); } }; }; Y.Node.prototype.hide = function(name, config, callback) { if (name && Y.Transition) { if (typeof config === 'function') { callback = config; config = null; } callback = _wrapCallBack(this, this._hide, callback); // wrap with existing callback if (typeof name !== 'string' && !name.push) { // named effect or array of effects supercedes default if (typeof config === 'function') { callback = config; config = name; } name = Transition.HIDE_TRANSITION; } this.transition(name, config, callback); } else { this._hide(); } return this; }; Y.NodeList.prototype.hide = function(name, config, callback) { var nodes = this._nodes, i = 0, node; while ((node = nodes[i++])) { Y.one(node).hide(name, config, callback); } return this; }; /** * Animate one or more css properties to a given value. Requires the "transition" module. *
example usage:
 *       Y.all('.demo').transition({
 *           duration: 1, // in seconds, default is 0.5
 *           easing: 'ease-out', // default is 'ease'
 *           delay: '1', // delay start for 1 second, default is 0
 *
 *           height: '10px',
 *           width: '10px',
 *
 *           opacity: { // per property
 *               value: 0,
 *               duration: 2,
 *               delay: 2,
 *               easing: 'ease-in'
 *           }
 *       });
 *   
* @for NodeList * @method transition * @param {Object} config An object containing one or more style properties, a duration and an easing. * @param {Function} callback A function to run after the transition has completed. The callback fires * once per item in the NodeList. * @param {Boolean} callbackOnce If true, the callback will be called only after the * last transition has completed * @chainable */ Y.NodeList.prototype.transition = function(config, callback, callbackOnce) { var nodes = this._nodes, size = this.size(), i = 0, callbackOnce = callbackOnce === true, node; while ((node = nodes[i++])) { if (i < size && callbackOnce){ Y.one(node).transition(config); } else { Y.one(node).transition(config, callback); } } return this; }; Y.Node.prototype.toggleView = function(name, on, callback) { this._toggles = this._toggles || []; callback = arguments[arguments.length - 1]; if (typeof name !== 'string') { // no transition, just toggle on = name; this._toggleView(on, callback); // call original _toggleView in Y.Node return; } if (typeof on === 'function') { // Ignore "on" if used for callback argument. on = undefined; } if (typeof on === 'undefined' && name in this._toggles) { // reverse current toggle on = ! this._toggles[name]; } on = (on) ? 1 : 0; if (on) { this._show(); } else { callback = _wrapCallBack(this, this._hide, callback); } this._toggles[name] = on; this.transition(Y.Transition.toggles[name][on], callback); return this; }; Y.NodeList.prototype.toggleView = function(name, on, callback) { var nodes = this._nodes, i = 0, node; while ((node = nodes[i++])) { node = Y.one(node); node.toggleView.apply(node, arguments); } return this; }; Y.mix(Transition.fx, { fadeOut: { opacity: 0, duration: 0.5, easing: 'ease-out' }, fadeIn: { opacity: 1, duration: 0.5, easing: 'ease-in' }, sizeOut: { height: 0, width: 0, duration: 0.75, easing: 'ease-out' }, sizeIn: { height: function(node) { return node.get('scrollHeight') + 'px'; }, width: function(node) { return node.get('scrollWidth') + 'px'; }, duration: 0.5, easing: 'ease-in', on: { start: function() { var overflow = this.getStyle('overflow'); if (overflow !== 'hidden') { // enable scrollHeight/Width this.setStyle('overflow', 'hidden'); this._transitionOverflow = overflow; } }, end: function() { if (this._transitionOverflow) { // revert overridden value this.setStyle('overflow', this._transitionOverflow); delete this._transitionOverflow; } } } } }); Y.mix(Transition.toggles, { size: ['sizeOut', 'sizeIn'], fade: ['fadeOut', 'fadeIn'] }); }, '3.17.2', {"requires": ["node-style"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('selector-css2', function (Y, NAME) { /** * The selector module provides helper methods allowing CSS2 Selectors to be used with DOM elements. * @module dom * @submodule selector-css2 * @for Selector */ /* * Provides helper methods for collecting and filtering DOM elements. */ var PARENT_NODE = 'parentNode', TAG_NAME = 'tagName', ATTRIBUTES = 'attributes', COMBINATOR = 'combinator', PSEUDOS = 'pseudos', Selector = Y.Selector, SelectorCSS2 = { _reRegExpTokens: /([\^\$\?\[\]\*\+\-\.\(\)\|\\])/, SORT_RESULTS: true, // TODO: better detection, document specific _isXML: (function() { var isXML = (Y.config.doc.createElement('div').tagName !== 'DIV'); return isXML; }()), /** * Mapping of shorthand tokens to corresponding attribute selector * @property shorthand * @type object */ shorthand: { '\\#(-?[_a-z0-9]+[-\\w\\uE000]*)': '[id=$1]', '\\.(-?[_a-z]+[-\\w\\uE000]*)': '[className~=$1]' }, /** * List of operators and corresponding boolean functions. * These functions are passed the attribute and the current node's value of the attribute. * @property operators * @type object */ operators: { '': function(node, attr) { return Y.DOM.getAttribute(node, attr) !== ''; }, // Just test for existence of attribute '~=': '(?:^|\\s+){val}(?:\\s+|$)', // space-delimited '|=': '^{val}-?' // optional hyphen-delimited }, pseudos: { 'first-child': function(node) { return Y.DOM._children(node[PARENT_NODE])[0] === node; } }, _bruteQuery: function(selector, root, firstOnly) { var ret = [], nodes = [], visited, tokens = Selector._tokenize(selector), token = tokens[tokens.length - 1], rootDoc = Y.DOM._getDoc(root), child, id, className, tagName, isUniversal; if (token) { // prefilter nodes id = token.id; className = token.className; tagName = token.tagName || '*'; if (root.getElementsByTagName) { // non-IE lacks DOM api on doc frags // try ID first, unless no root.all && root not in document // (root.all works off document, but not getElementById) if (id && (root.all || (root.nodeType === 9 || Y.DOM.inDoc(root)))) { nodes = Y.DOM.allById(id, root); // try className } else if (className) { nodes = root.getElementsByClassName(className); } else { // default to tagName nodes = root.getElementsByTagName(tagName); } } else { // brute getElementsByTagName() visited = []; child = root.firstChild; isUniversal = tagName === "*"; while (child) { while (child) { // IE 6-7 considers comment nodes as element nodes, and gives them the tagName "!". // We can filter them out by checking if its tagName is > "@". // This also avoids a superflous nodeType === 1 check. if (child.tagName > "@" && (isUniversal || child.tagName === tagName)) { nodes.push(child); } // We may need to traverse back up the tree to find more unvisited subtrees. visited.push(child); child = child.firstChild; } // Find the most recently visited node who has a next sibling. while (visited.length > 0 && !child) { child = visited.pop().nextSibling; } } } if (nodes.length) { ret = Selector._filterNodes(nodes, tokens, firstOnly); } } return ret; }, _filterNodes: function(nodes, tokens, firstOnly) { var i = 0, j, len = tokens.length, n = len - 1, result = [], node = nodes[0], tmpNode = node, getters = Y.Selector.getters, operator, combinator, token, path, pass, value, tests, test; for (i = 0; (tmpNode = node = nodes[i++]);) { n = len - 1; path = null; testLoop: while (tmpNode && tmpNode.tagName) { token = tokens[n]; tests = token.tests; j = tests.length; if (j && !pass) { while ((test = tests[--j])) { operator = test[1]; if (getters[test[0]]) { value = getters[test[0]](tmpNode, test[0]); } else { value = tmpNode[test[0]]; if (test[0] === 'tagName' && !Selector._isXML) { value = value.toUpperCase(); } if (typeof value != 'string' && value !== undefined && value.toString) { value = value.toString(); // coerce for comparison } else if (value === undefined && tmpNode.getAttribute) { // use getAttribute for non-standard attributes value = tmpNode.getAttribute(test[0], 2); // 2 === force string for IE } } if ((operator === '=' && value !== test[2]) || // fast path for equality (typeof operator !== 'string' && // protect against String.test monkey-patch (Moo) operator.test && !operator.test(value)) || // regex test (!operator.test && // protect against RegExp as function (webkit) typeof operator === 'function' && !operator(tmpNode, test[0], test[2]))) { // function test // skip non element nodes or non-matching tags if ((tmpNode = tmpNode[path])) { while (tmpNode && (!tmpNode.tagName || (token.tagName && token.tagName !== tmpNode.tagName)) ) { tmpNode = tmpNode[path]; } } continue testLoop; } } } n--; // move to next token // now that we've passed the test, move up the tree by combinator if (!pass && (combinator = token.combinator)) { path = combinator.axis; tmpNode = tmpNode[path]; // skip non element nodes while (tmpNode && !tmpNode.tagName) { tmpNode = tmpNode[path]; } if (combinator.direct) { // one pass only path = null; } } else { // success if we made it this far result.push(node); if (firstOnly) { return result; } break; } } } node = tmpNode = null; return result; }, combinators: { ' ': { axis: 'parentNode' }, '>': { axis: 'parentNode', direct: true }, '+': { axis: 'previousSibling', direct: true } }, _parsers: [ { name: ATTRIBUTES, re: /^\uE003(-?[a-z]+[\w\-]*)+([~\|\^\$\*!=]=?)?['"]?([^\uE004'"]*)['"]?\uE004/i, fn: function(match, token) { var operator = match[2] || '', operators = Selector.operators, escVal = (match[3]) ? match[3].replace(/\\/g, '') : '', test; // add prefiltering for ID and CLASS if ((match[1] === 'id' && operator === '=') || (match[1] === 'className' && Y.config.doc.documentElement.getElementsByClassName && (operator === '~=' || operator === '='))) { token.prefilter = match[1]; match[3] = escVal; // escape all but ID for prefilter, which may run through QSA (via Dom.allById) token[match[1]] = (match[1] === 'id') ? match[3] : escVal; } // add tests if (operator in operators) { test = operators[operator]; if (typeof test === 'string') { match[3] = escVal.replace(Selector._reRegExpTokens, '\\$1'); test = new RegExp(test.replace('{val}', match[3])); } match[2] = test; } if (!token.last || token.prefilter !== match[1]) { return match.slice(1); } } }, { name: TAG_NAME, re: /^((?:-?[_a-z]+[\w-]*)|\*)/i, fn: function(match, token) { var tag = match[1]; if (!Selector._isXML) { tag = tag.toUpperCase(); } token.tagName = tag; if (tag !== '*' && (!token.last || token.prefilter)) { return [TAG_NAME, '=', tag]; } if (!token.prefilter) { token.prefilter = 'tagName'; } } }, { name: COMBINATOR, re: /^\s*([>+~]|\s)\s*/, fn: function(match, token) { } }, { name: PSEUDOS, re: /^:([\-\w]+)(?:\uE005['"]?([^\uE005]*)['"]?\uE006)*/i, fn: function(match, token) { var test = Selector[PSEUDOS][match[1]]; if (test) { // reorder match array and unescape special chars for tests if (match[2]) { match[2] = match[2].replace(/\\/g, ''); } return [match[2], test]; } else { // selector token not supported (possibly missing CSS3 module) return false; } } } ], _getToken: function(token) { return { tagName: null, id: null, className: null, attributes: {}, combinator: null, tests: [] }; }, /* Break selector into token units per simple selector. Combinator is attached to the previous token. */ _tokenize: function(selector) { selector = selector || ''; selector = Selector._parseSelector(Y.Lang.trim(selector)); var token = Selector._getToken(), // one token per simple selector (left selector holds combinator) query = selector, // original query for debug report tokens = [], // array of tokens found = false, // whether or not any matches were found this pass match, // the regex match test, i, parser; /* Search for selector patterns, store, and strip them from the selector string until no patterns match (invalid selector) or we run out of chars. Multiple attributes and pseudos are allowed, in any order. for example: 'form:first-child[type=button]:not(button)[lang|=en]' */ outer: do { found = false; // reset after full pass for (i = 0; (parser = Selector._parsers[i++]);) { if ( (match = parser.re.exec(selector)) ) { // note assignment if (parser.name !== COMBINATOR ) { token.selector = selector; } selector = selector.replace(match[0], ''); // strip current match from selector if (!selector.length) { token.last = true; } if (Selector._attrFilters[match[1]]) { // convert class to className, etc. match[1] = Selector._attrFilters[match[1]]; } test = parser.fn(match, token); if (test === false) { // selector not supported found = false; break outer; } else if (test) { token.tests.push(test); } if (!selector.length || parser.name === COMBINATOR) { tokens.push(token); token = Selector._getToken(token); if (parser.name === COMBINATOR) { token.combinator = Y.Selector.combinators[match[1]]; } } found = true; } } } while (found && selector.length); if (!found || selector.length) { // not fully parsed tokens = []; } return tokens; }, _replaceMarkers: function(selector) { selector = selector.replace(/\[/g, '\uE003'); selector = selector.replace(/\]/g, '\uE004'); selector = selector.replace(/\(/g, '\uE005'); selector = selector.replace(/\)/g, '\uE006'); return selector; }, _replaceShorthand: function(selector) { var shorthand = Y.Selector.shorthand, re; for (re in shorthand) { if (shorthand.hasOwnProperty(re)) { selector = selector.replace(new RegExp(re, 'gi'), shorthand[re]); } } return selector; }, _parseSelector: function(selector) { var replaced = Y.Selector._replaceSelector(selector), selector = replaced.selector; // replace shorthand (".foo, #bar") after pseudos and attrs // to avoid replacing unescaped chars selector = Y.Selector._replaceShorthand(selector); selector = Y.Selector._restore('attr', selector, replaced.attrs); selector = Y.Selector._restore('pseudo', selector, replaced.pseudos); // replace braces and parens before restoring escaped chars // to avoid replacing ecaped markers selector = Y.Selector._replaceMarkers(selector); selector = Y.Selector._restore('esc', selector, replaced.esc); return selector; }, _attrFilters: { 'class': 'className', 'for': 'htmlFor' }, getters: { href: function(node, attr) { return Y.DOM.getAttribute(node, attr); }, id: function(node, attr) { return Y.DOM.getId(node); } } }; Y.mix(Y.Selector, SelectorCSS2, true); Y.Selector.getters.src = Y.Selector.getters.rel = Y.Selector.getters.href; // IE wants class with native queries if (Y.Selector.useNative && Y.config.doc.querySelector) { Y.Selector.shorthand['\\.(-?[_a-z]+[-\\w]*)'] = '[class~=$1]'; } }, '3.17.2', {"requires": ["selector-native"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('selector-css3', function (Y, NAME) { /** * The selector css3 module provides support for css3 selectors. * @module dom * @submodule selector-css3 * @for Selector */ /* an+b = get every _a_th node starting at the _b_th 0n+b = no repeat ("0" and "n" may both be omitted (together) , e.g. "0n+1" or "1", not "0+1"), return only the _b_th element 1n+b = get every element starting from b ("1" may may be omitted, e.g. "1n+0" or "n+0" or "n") an+0 = get every _a_th element, "0" may be omitted */ Y.Selector._reNth = /^(?:([\-]?\d*)(n){1}|(odd|even)$)*([\-+]?\d*)$/; Y.Selector._getNth = function(node, expr, tag, reverse) { Y.Selector._reNth.test(expr); var a = parseInt(RegExp.$1, 10), // include every _a_ elements (zero means no repeat, just first _a_) n = RegExp.$2, // "n" oddeven = RegExp.$3, // "odd" or "even" b = parseInt(RegExp.$4, 10) || 0, // start scan from element _b_ result = [], siblings = Y.DOM._children(node.parentNode, tag), op; if (oddeven) { a = 2; // always every other op = '+'; n = 'n'; b = (oddeven === 'odd') ? 1 : 0; } else if ( isNaN(a) ) { a = (n) ? 1 : 0; // start from the first or no repeat } if (a === 0) { // just the first if (reverse) { b = siblings.length - b + 1; } if (siblings[b - 1] === node) { return true; } else { return false; } } else if (a < 0) { reverse = !!reverse; a = Math.abs(a); } if (!reverse) { for (var i = b - 1, len = siblings.length; i < len; i += a) { if ( i >= 0 && siblings[i] === node ) { return true; } } } else { for (var i = siblings.length - b, len = siblings.length; i >= 0; i -= a) { if ( i < len && siblings[i] === node ) { return true; } } } return false; }; Y.mix(Y.Selector.pseudos, { 'root': function(node) { return node === node.ownerDocument.documentElement; }, 'nth-child': function(node, expr) { return Y.Selector._getNth(node, expr); }, 'nth-last-child': function(node, expr) { return Y.Selector._getNth(node, expr, null, true); }, 'nth-of-type': function(node, expr) { return Y.Selector._getNth(node, expr, node.tagName); }, 'nth-last-of-type': function(node, expr) { return Y.Selector._getNth(node, expr, node.tagName, true); }, 'last-child': function(node) { var children = Y.DOM._children(node.parentNode); return children[children.length - 1] === node; }, 'first-of-type': function(node) { return Y.DOM._children(node.parentNode, node.tagName)[0] === node; }, 'last-of-type': function(node) { var children = Y.DOM._children(node.parentNode, node.tagName); return children[children.length - 1] === node; }, 'only-child': function(node) { var children = Y.DOM._children(node.parentNode); return children.length === 1 && children[0] === node; }, 'only-of-type': function(node) { var children = Y.DOM._children(node.parentNode, node.tagName); return children.length === 1 && children[0] === node; }, 'empty': function(node) { return node.childNodes.length === 0; }, 'not': function(node, expr) { return !Y.Selector.test(node, expr); }, 'contains': function(node, expr) { var text = node.innerText || node.textContent || ''; return text.indexOf(expr) > -1; }, 'checked': function(node) { return (node.checked === true || node.selected === true); }, enabled: function(node) { return (node.disabled !== undefined && !node.disabled); }, disabled: function(node) { return (node.disabled); } }); Y.mix(Y.Selector.operators, { '^=': '^{val}', // Match starts with value '$=': '{val}$', // Match ends with value '*=': '{val}' // Match contains value as substring }); Y.Selector.combinators['~'] = { axis: 'previousSibling' }; }, '3.17.2', {"requires": ["selector-native", "selector-css2"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('dom-style-ie', function (Y, NAME) { var HAS_LAYOUT = 'hasLayout', PX = 'px', FILTER = 'filter', FILTERS = 'filters', OPACITY = 'opacity', AUTO = 'auto', BORDER_WIDTH = 'borderWidth', BORDER_TOP_WIDTH = 'borderTopWidth', BORDER_RIGHT_WIDTH = 'borderRightWidth', BORDER_BOTTOM_WIDTH = 'borderBottomWidth', BORDER_LEFT_WIDTH = 'borderLeftWidth', WIDTH = 'width', HEIGHT = 'height', TRANSPARENT = 'transparent', VISIBLE = 'visible', GET_COMPUTED_STYLE = 'getComputedStyle', documentElement = Y.config.doc.documentElement, testFeature = Y.Features.test, addFeature = Y.Features.add, // TODO: unit-less lineHeight (e.g. 1.22) re_unit = /^(\d[.\d]*)+(em|ex|px|gd|rem|vw|vh|vm|ch|mm|cm|in|pt|pc|deg|rad|ms|s|hz|khz|%){1}?/i, isIE8 = (Y.UA.ie >= 8), _getStyleObj = function(node) { return node.currentStyle || node.style; }, ComputedStyle = { CUSTOM_STYLES: {}, get: function(el, property) { var value = '', current; if (el) { current = _getStyleObj(el)[property]; if (property === OPACITY && Y.DOM.CUSTOM_STYLES[OPACITY]) { value = Y.DOM.CUSTOM_STYLES[OPACITY].get(el); } else if (!current || (current.indexOf && current.indexOf(PX) > -1)) { // no need to convert value = current; } else if (Y.DOM.IE.COMPUTED[property]) { // use compute function value = Y.DOM.IE.COMPUTED[property](el, property); } else if (re_unit.test(current)) { // convert to pixel value = ComputedStyle.getPixel(el, property) + PX; } else { value = current; } } return value; }, sizeOffsets: { width: ['Left', 'Right'], height: ['Top', 'Bottom'], top: ['Top'], bottom: ['Bottom'] }, getOffset: function(el, prop) { var current = _getStyleObj(el)[prop], // value of "width", "top", etc. capped = prop.charAt(0).toUpperCase() + prop.substr(1), // "Width", "Top", etc. pixel = 'pixel' + capped, // "pixelWidth", "pixelTop", etc. sizeOffsets = ComputedStyle.sizeOffsets[prop], mode = el.ownerDocument.compatMode, value = ''; // IE pixelWidth incorrect for percent // manually compute by subtracting padding and border from offset size // NOTE: clientWidth/Height (size minus border) is 0 when current === AUTO so offsetHeight is used // reverting to auto from auto causes position stacking issues (old impl) if (current === AUTO || current.indexOf('%') > -1) { value = el['offset' + capped]; if (mode !== 'BackCompat') { if (sizeOffsets[0]) { value -= ComputedStyle.getPixel(el, 'padding' + sizeOffsets[0]); value -= ComputedStyle.getBorderWidth(el, 'border' + sizeOffsets[0] + 'Width', 1); } if (sizeOffsets[1]) { value -= ComputedStyle.getPixel(el, 'padding' + sizeOffsets[1]); value -= ComputedStyle.getBorderWidth(el, 'border' + sizeOffsets[1] + 'Width', 1); } } } else { // use style.pixelWidth, etc. to convert to pixels // need to map style.width to currentStyle (no currentStyle.pixelWidth) if (!el.style[pixel] && !el.style[prop]) { el.style[prop] = current; } value = el.style[pixel]; } return value + PX; }, borderMap: { thin: (isIE8) ? '1px' : '2px', medium: (isIE8) ? '3px': '4px', thick: (isIE8) ? '5px' : '6px' }, getBorderWidth: function(el, property, omitUnit) { var current = el.currentStyle[property]; if (current.indexOf(PX) < 0) { // look up keywords if a border exists if (ComputedStyle.borderMap[current] && el.currentStyle.borderStyle !== 'none') { current = ComputedStyle.borderMap[current]; } else { // otherwise no border (default is "medium") current = 0; } } return (omitUnit) ? parseFloat(current) : current; }, getPixel: function(node, att) { // use pixelRight to convert to px var val = null, style = _getStyleObj(node), styleRight = style.right, current = style[att]; node.style.right = current; val = node.style.pixelRight; node.style.right = styleRight; // revert return val; }, getMargin: function(node, att) { var val, style = _getStyleObj(node); if (style[att] === AUTO) { val = 0; } else { val = ComputedStyle.getPixel(node, att); } return val + PX; }, getVisibility: function(node, att) { var current; while ( (current = node.currentStyle) && current[att] === 'inherit') { // NOTE: assignment in test node = node.parentNode; } return (current) ? current[att] : VISIBLE; }, getColor: function(node, att) { var current = _getStyleObj(node)[att]; if (!current || current === TRANSPARENT) { Y.DOM.elementByAxis(node, 'parentNode', null, function(parent) { current = _getStyleObj(parent)[att]; if (current && current !== TRANSPARENT) { node = parent; return true; } }); } return Y.Color.toRGB(current); }, getBorderColor: function(node, att) { var current = _getStyleObj(node), val = current[att] || current.color; return Y.Color.toRGB(Y.Color.toHex(val)); } }, //fontSize: getPixelFont, IEComputed = {}; addFeature('style', 'computedStyle', { test: function() { return 'getComputedStyle' in Y.config.win; } }); addFeature('style', 'opacity', { test: function() { return 'opacity' in documentElement.style; } }); addFeature('style', 'filter', { test: function() { return 'filters' in documentElement; } }); // use alpha filter for IE opacity if (!testFeature('style', 'opacity') && testFeature('style', 'filter')) { Y.DOM.CUSTOM_STYLES[OPACITY] = { get: function(node) { var val = 100; try { // will error if no DXImageTransform val = node[FILTERS]['DXImageTransform.Microsoft.Alpha'][OPACITY]; } catch(e) { try { // make sure its in the document val = node[FILTERS]('alpha')[OPACITY]; } catch(err) { } } return val / 100; }, set: function(node, val, style) { var current, styleObj = _getStyleObj(node), currentFilter = styleObj[FILTER]; style = style || node.style; if (val === '') { // normalize inline style behavior current = (OPACITY in styleObj) ? styleObj[OPACITY] : 1; // revert to original opacity val = current; } if (typeof currentFilter === 'string') { // in case not appended style[FILTER] = currentFilter.replace(/alpha([^)]*\))/gi, '') + ((val <= 1) ? 'alpha(' + OPACITY + '=' + val * 100 + ')' : ''); if (!style[FILTER]) { style.removeAttribute(FILTER); } if (!styleObj[HAS_LAYOUT]) { style.zoom = 1; // needs layout } } } }; } try { Y.config.doc.createElement('div').style.height = '-1px'; } catch(e) { // IE throws error on invalid style set; trap common cases Y.DOM.CUSTOM_STYLES.height = { set: function(node, val, style) { var floatVal = parseFloat(val); if (floatVal >= 0 || val === 'auto' || val === '') { style.height = val; } else { } } }; Y.DOM.CUSTOM_STYLES.width = { set: function(node, val, style) { var floatVal = parseFloat(val); if (floatVal >= 0 || val === 'auto' || val === '') { style.width = val; } else { } } }; } if (!testFeature('style', 'computedStyle')) { // TODO: top, right, bottom, left IEComputed[WIDTH] = IEComputed[HEIGHT] = ComputedStyle.getOffset; IEComputed.color = IEComputed.backgroundColor = ComputedStyle.getColor; IEComputed[BORDER_WIDTH] = IEComputed[BORDER_TOP_WIDTH] = IEComputed[BORDER_RIGHT_WIDTH] = IEComputed[BORDER_BOTTOM_WIDTH] = IEComputed[BORDER_LEFT_WIDTH] = ComputedStyle.getBorderWidth; IEComputed.marginTop = IEComputed.marginRight = IEComputed.marginBottom = IEComputed.marginLeft = ComputedStyle.getMargin; IEComputed.visibility = ComputedStyle.getVisibility; IEComputed.borderColor = IEComputed.borderTopColor = IEComputed.borderRightColor = IEComputed.borderBottomColor = IEComputed.borderLeftColor = ComputedStyle.getBorderColor; Y.DOM[GET_COMPUTED_STYLE] = ComputedStyle.get; Y.namespace('DOM.IE'); Y.DOM.IE.COMPUTED = IEComputed; Y.DOM.IE.ComputedStyle = ComputedStyle; } }, '3.17.2', {"requires": ["dom-style", "color-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('escape', function (Y, NAME) { /** Provides utility methods for escaping strings. @module escape @class Escape @static @since 3.3.0 **/ var HTML_CHARS = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''', '/': '/', '`': '`' }, Escape = { // -- Public Static Methods ------------------------------------------------ /** Returns a copy of the specified string with special HTML characters escaped. The following characters will be converted to their corresponding character entities: & < > " ' / ` This implementation is based on the [OWASP HTML escaping recommendations][1]. In addition to the characters in the OWASP recommendations, we also escape the ` character, since IE interprets it as an attribute delimiter. If _string_ is not already a string, it will be coerced to a string. [1]: http://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet @method html @param {String} string String to escape. @return {String} Escaped string. @static **/ html: function (string) { return (string + '').replace(/[&<>"'\/`]/g, Escape._htmlReplacer); }, /** Returns a copy of the specified string with special regular expression characters escaped, allowing the string to be used safely inside a regex. The following characters, and all whitespace characters, are escaped: - $ ^ * ( ) + [ ] { } | \ , . ? If _string_ is not already a string, it will be coerced to a string. @method regex @param {String} string String to escape. @return {String} Escaped string. @static **/ regex: function (string) { // There's no need to escape !, =, and : since they only have meaning // when they follow a parenthesized ?, as in (?:...), and we already // escape parens and question marks. return (string + '').replace(/[\-$\^*()+\[\]{}|\\,.?\s]/g, '\\$&'); }, // -- Protected Static Methods --------------------------------------------- /** * Regex replacer for HTML escaping. * * @method _htmlReplacer * @param {String} match Matched character (must exist in HTML_CHARS). * @return {String} HTML entity. * @static * @protected */ _htmlReplacer: function (match) { return HTML_CHARS[match]; } }; Escape.regexp = Escape.regex; Y.Escape = Escape; }, '3.17.2', {"requires": ["yui-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('attribute-core', function (Y, NAME) { /** * The State class maintains state for a collection of named items, with * a varying number of properties defined. * * It avoids the need to create a separate class for the item, and separate instances * of these classes for each item, by storing the state in a 2 level hash table, * improving performance when the number of items is likely to be large. * * @constructor * @class State */ Y.State = function() { /** * Hash of attributes * @property data */ this.data = {}; }; Y.State.prototype = { /** * Adds a property to an item. * * @method add * @param name {String} The name of the item. * @param key {String} The name of the property. * @param val {Any} The value of the property. */ add: function(name, key, val) { var item = this.data[name]; if (!item) { item = this.data[name] = {}; } item[key] = val; }, /** * Adds multiple properties to an item. * * @method addAll * @param name {String} The name of the item. * @param obj {Object} A hash of property/value pairs. */ addAll: function(name, obj) { var item = this.data[name], key; if (!item) { item = this.data[name] = {}; } for (key in obj) { if (obj.hasOwnProperty(key)) { item[key] = obj[key]; } } }, /** * Removes a property from an item. * * @method remove * @param name {String} The name of the item. * @param key {String} The property to remove. */ remove: function(name, key) { var item = this.data[name]; if (item) { delete item[key]; } }, /** * Removes multiple properties from an item, or removes the item completely. * * @method removeAll * @param name {String} The name of the item. * @param obj {Object|Array} Collection of properties to delete. If not provided, the entire item is removed. */ removeAll: function(name, obj) { var data; if (!obj) { data = this.data; if (name in data) { delete data[name]; } } else { Y.each(obj, function(value, key) { this.remove(name, typeof key === 'string' ? key : value); }, this); } }, /** * For a given item, returns the value of the property requested, or undefined if not found. * * @method get * @param name {String} The name of the item * @param key {String} Optional. The property value to retrieve. * @return {Any} The value of the supplied property. */ get: function(name, key) { var item = this.data[name]; if (item) { return item[key]; } }, /** * For the given item, returns an object with all of the * item's property/value pairs. By default the object returned * is a shallow copy of the stored data, but passing in true * as the second parameter will return a reference to the stored * data. * * @method getAll * @param name {String} The name of the item * @param reference {boolean} true, if you want a reference to the stored * object * @return {Object} An object with property/value pairs for the item. */ getAll : function(name, reference) { var item = this.data[name], key, obj; if (reference) { obj = item; } else if (item) { obj = {}; for (key in item) { if (item.hasOwnProperty(key)) { obj[key] = item[key]; } } } return obj; } }; /*For log lines*/ /*jshint maxlen:200*/ /** * The attribute module provides an augmentable Attribute implementation, which * adds configurable attributes and attribute change events to the class being * augmented. It also provides a State class, which is used internally by Attribute, * but can also be used independently to provide a name/property/value data structure to * store state. * * @module attribute */ /** * The attribute-core submodule provides the lightest level of attribute handling support * without Attribute change events, or lesser used methods such as reset(), modifyAttrs(), * and removeAttr(). * * @module attribute * @submodule attribute-core */ var O = Y.Object, Lang = Y.Lang, DOT = ".", // Externally configurable props GETTER = "getter", SETTER = "setter", READ_ONLY = "readOnly", WRITE_ONCE = "writeOnce", INIT_ONLY = "initOnly", VALIDATOR = "validator", VALUE = "value", VALUE_FN = "valueFn", LAZY_ADD = "lazyAdd", // Used for internal state management ADDED = "added", BYPASS_PROXY = "_bypassProxy", INIT_VALUE = "initValue", LAZY = "lazy", INVALID_VALUE; /** *

* AttributeCore provides the lightest level of configurable attribute support. It is designed to be * augmented on to a host class, and provides the host with the ability to configure * attributes to store and retrieve state, but without support for attribute change events. *

*

For example, attributes added to the host can be configured:

*
* *

See the addAttr method, for the complete set of configuration * options available for attributes.

* *

Object/Classes based on AttributeCore can augment AttributeObservable * (with true for overwrite) and AttributeExtras to add attribute event and * additional, less commonly used attribute methods, such as `modifyAttr`, `removeAttr` and `reset`.

* * @class AttributeCore * @param attrs {Object} The attributes to add during construction (passed through to addAttrs). * These can also be defined on the constructor being augmented with Attribute by defining the ATTRS property on the constructor. * @param values {Object} The initial attribute values to apply (passed through to addAttrs). * These are not merged/cloned. The caller is responsible for isolating user provided values if required. * @param lazy {boolean} Whether or not to add attributes lazily (passed through to addAttrs). */ function AttributeCore(attrs, values, lazy) { // HACK: Fix #2531929 // Complete hack, to make sure the first clone of a node value in IE doesn't doesn't hurt state - maintains 3.4.1 behavior. // Too late in the release cycle to do anything about the core problem. // The root issue is that cloning a Y.Node instance results in an object which barfs in IE, when you access it's properties (since 3.3.0). this._yuievt = null; this._initAttrHost(attrs, values, lazy); } /** *

The value to return from an attribute setter in order to prevent the set from going through.

* *

You can return this value from your setter if you wish to combine validator and setter * functionality into a single setter function, which either returns the massaged value to be stored or * AttributeCore.INVALID_VALUE to prevent invalid values from being stored.

* * @property INVALID_VALUE * @type Object * @static * @final */ AttributeCore.INVALID_VALUE = {}; INVALID_VALUE = AttributeCore.INVALID_VALUE; /** * The list of properties which can be configured for * each attribute (e.g. setter, getter, writeOnce etc.). * * This property is used internally as a whitelist for faster * Y.mix operations. * * @property _ATTR_CFG * @type Array * @static * @protected */ AttributeCore._ATTR_CFG = [SETTER, GETTER, VALIDATOR, VALUE, VALUE_FN, WRITE_ONCE, READ_ONLY, LAZY_ADD, BYPASS_PROXY]; /** * Utility method to protect an attribute configuration hash, by merging the * entire object and the individual attr config objects. * * @method protectAttrs * @static * @param {Object} attrs A hash of attribute to configuration object pairs. * @return {Object} A protected version of the `attrs` argument. */ AttributeCore.protectAttrs = function (attrs) { if (attrs) { attrs = Y.merge(attrs); for (var attr in attrs) { if (attrs.hasOwnProperty(attr)) { attrs[attr] = Y.merge(attrs[attr]); } } } return attrs; }; AttributeCore.prototype = { /** * Constructor logic for attributes. Initializes the host state, and sets up the inital attributes passed to the * constructor. * * @method _initAttrHost * @param attrs {Object} The attributes to add during construction (passed through to addAttrs). * These can also be defined on the constructor being augmented with Attribute by defining the ATTRS property on the constructor. * @param values {Object} The initial attribute values to apply (passed through to addAttrs). * These are not merged/cloned. The caller is responsible for isolating user provided values if required. * @param lazy {boolean} Whether or not to add attributes lazily (passed through to addAttrs). * @private */ _initAttrHost : function(attrs, values, lazy) { this._state = new Y.State(); this._initAttrs(attrs, values, lazy); }, /** *

* Adds an attribute with the provided configuration to the host object. *

*

* The config argument object supports the following properties: *

* *
*
value <Any>
*
The initial value to set on the attribute
* *
valueFn <Function | String>
*
*

A function, which will return the initial value to set on the attribute. This is useful * for cases where the attribute configuration is defined statically, but needs to * reference the host instance ("this") to obtain an initial value. If both the value and valueFn properties are defined, * the value returned by the valueFn has precedence over the value property, unless it returns undefined, in which * case the value property is used.

* *

valueFn can also be set to a string, representing the name of the instance method to be used to retrieve the value.

*
* *
readOnly <boolean>
*
Whether or not the attribute is read only. Attributes having readOnly set to true * cannot be modified by invoking the set method.
* *
writeOnce <boolean> or <string>
*
* Whether or not the attribute is "write once". Attributes having writeOnce set to true, * can only have their values set once, be it through the default configuration, * constructor configuration arguments, or by invoking set. *

The writeOnce attribute can also be set to the string "initOnly", * in which case the attribute can only be set during initialization * (when used with Base, this means it can only be set during construction)

*
* *
setter <Function | String>
*
*

The setter function used to massage or normalize the value passed to the set method for the attribute. * The value returned by the setter will be the final stored value. Returning * Attribute.INVALID_VALUE, from the setter will prevent * the value from being stored. *

* *

setter can also be set to a string, representing the name of the instance method to be used as the setter function.

*
* *
getter <Function | String>
*
*

* The getter function used to massage or normalize the value returned by the get method for the attribute. * The value returned by the getter function is the value which will be returned to the user when they * invoke get. *

* *

getter can also be set to a string, representing the name of the instance method to be used as the getter function.

*
* *
validator <Function | String>
*
*

* The validator function invoked prior to setting the stored value. Returning * false from the validator function will prevent the value from being stored. *

* *

validator can also be set to a string, representing the name of the instance method to be used as the validator function.

*
* *
lazyAdd <boolean>
*
Whether or not to delay initialization of the attribute until the first call to get/set it. * This flag can be used to over-ride lazy initialization on a per attribute basis, when adding multiple attributes through * the addAttrs method.
* *
* *

The setter, getter and validator are invoked with the value and name passed in as the first and second arguments, and with * the context ("this") set to the host object.

* *

Configuration properties outside of the list mentioned above are considered private properties used internally by attribute, * and are not intended for public use.

* * @method addAttr * * @param {String} name The name of the attribute. * @param {Object} config An object with attribute configuration property/value pairs, specifying the configuration for the attribute. * *

* NOTE: The configuration object is modified when adding an attribute, so if you need * to protect the original values, you will need to merge the object. *

* * @param {boolean} lazy (optional) Whether or not to add this attribute lazily (on the first call to get/set). * * @return {Object} A reference to the host object. * * @chainable */ addAttr : function(name, config, lazy) { var host = this, // help compression state = host._state, data = state.data, value, added, hasValue; config = config || {}; if (LAZY_ADD in config) { lazy = config[LAZY_ADD]; } added = state.get(name, ADDED); if (lazy && !added) { state.data[name] = { lazy : config, added : true }; } else { if (!added || config.isLazyAdd) { hasValue = (VALUE in config); if (hasValue) { // We'll go through set, don't want to set value in config directly // PERF TODO: VALIDATE: See if setting this to undefined is sufficient. We use to delete before. // In certain code paths/use cases, undefined may not be the same as not present. // If not, we can set it to some known fixed value (like INVALID_VALUE, say INITIALIZING_VALUE) for performance, // to avoid a delete which seems to help a lot. value = config.value; config.value = undefined; } config.added = true; config.initializing = true; data[name] = config; if (hasValue) { // Go through set, so that raw values get normalized/validated host.set(name, value); } config.initializing = false; } } return host; }, /** * Checks if the given attribute has been added to the host * * @method attrAdded * @param {String} name The name of the attribute to check. * @return {boolean} true if an attribute with the given name has been added, false if it hasn't. * This method will return true for lazily added attributes. */ attrAdded: function(name) { return !!(this._state.get(name, ADDED)); }, /** * Returns the current value of the attribute. If the attribute * has been configured with a 'getter' function, this method will delegate * to the 'getter' to obtain the value of the attribute. * * @method get * * @param {String} name The name of the attribute. If the value of the attribute is an Object, * dot notation can be used to obtain the value of a property of the object (e.g. get("x.y.z")) * * @return {Any} The value of the attribute */ get : function(name) { return this._getAttr(name); }, /** * Checks whether or not the attribute is one which has been * added lazily and still requires initialization. * * @method _isLazyAttr * @private * @param {String} name The name of the attribute * @return {boolean} true if it's a lazily added attribute, false otherwise. */ _isLazyAttr: function(name) { return this._state.get(name, LAZY); }, /** * Finishes initializing an attribute which has been lazily added. * * @method _addLazyAttr * @private * @param {Object} name The name of the attribute * @param {Object} [lazyCfg] Optional config hash for the attribute. This is added for performance * along the critical path, where the calling method has already obtained lazy config from state. */ _addLazyAttr: function(name, lazyCfg) { var state = this._state; lazyCfg = lazyCfg || state.get(name, LAZY); if (lazyCfg) { // PERF TODO: For App's id override, otherwise wouldn't be // needed. It expects to find it in the cfg for it's // addAttr override. Would like to remove, once App override is // removed. state.data[name].lazy = undefined; lazyCfg.isLazyAdd = true; this.addAttr(name, lazyCfg); } }, /** * Sets the value of an attribute. * * @method set * @chainable * * @param {String} name The name of the attribute. If the * current value of the attribute is an Object, dot notation can be used * to set the value of a property within the object (e.g. set("x.y.z", 5)). * @param {Any} value The value to set the attribute to. * @param {Object} [opts] Optional data providing the circumstances for the change. * @return {Object} A reference to the host object. */ set : function(name, val, opts) { return this._setAttr(name, val, opts); }, /** * Allows setting of readOnly/writeOnce attributes. See set for argument details. * * @method _set * @protected * @chainable * * @param {String} name The name of the attribute. * @param {Any} val The value to set the attribute to. * @param {Object} [opts] Optional data providing the circumstances for the change. * @return {Object} A reference to the host object. */ _set : function(name, val, opts) { return this._setAttr(name, val, opts, true); }, /** * Provides the common implementation for the public set and protected _set methods. * * See set for argument details. * * @method _setAttr * @protected * @chainable * * @param {String} name The name of the attribute. * @param {Any} value The value to set the attribute to. * @param {Object} [opts] Optional data providing the circumstances for the change. * @param {boolean} force If true, allows the caller to set values for * readOnly or writeOnce attributes which have already been set. * * @return {Object} A reference to the host object. */ _setAttr : function(name, val, opts, force) { var allowSet = true, state = this._state, stateProxy = this._stateProxy, tCfgs = this._tCfgs, cfg, initialSet, strPath, path, currVal, writeOnce, initializing; if (name.indexOf(DOT) !== -1) { strPath = name; path = name.split(DOT); name = path.shift(); } // On Demand - Should be rare - handles out of order valueFn, setter, getter references if (tCfgs && tCfgs[name]) { this._addOutOfOrder(name, tCfgs[name]); } cfg = state.data[name] || {}; if (cfg.lazy) { cfg = cfg.lazy; this._addLazyAttr(name, cfg); } initialSet = (cfg.value === undefined); if (stateProxy && name in stateProxy && !cfg._bypassProxy) { // TODO: Value is always set for proxy. Can we do any better? Maybe take a snapshot as the initial value for the first call to set? initialSet = false; } writeOnce = cfg.writeOnce; initializing = cfg.initializing; if (!initialSet && !force) { if (writeOnce) { allowSet = false; } if (cfg.readOnly) { allowSet = false; } } if (!initializing && !force && writeOnce === INIT_ONLY) { allowSet = false; } if (allowSet) { // Don't need currVal if initialSet (might fail in custom getter if it always expects a non-undefined/non-null value) if (!initialSet) { currVal = this.get(name); } if (path) { val = O.setValue(Y.clone(currVal), path, val); if (val === undefined) { allowSet = false; } } if (allowSet) { if (!this._fireAttrChange || initializing) { this._setAttrVal(name, strPath, currVal, val, opts, cfg); } else { // HACK - no real reason core needs to know about _fireAttrChange, but // it adds fn hops if we want to break it out. Not sure it's worth it for this critical path this._fireAttrChange(name, strPath, currVal, val, opts, cfg); } } } return this; }, /** * Utility method used by get/set to add attributes * encountered out of order when calling addAttrs(). * * For example, if: * * this.addAttrs({ * foo: { * setter: function() { * // make sure this bar is available when foo is added * this.get("bar"); * } * }, * bar: { * value: ... * } * }); * * @method _addOutOfOrder * @private * @param name {String} attribute name * @param cfg {Object} attribute configuration */ _addOutOfOrder : function(name, cfg) { var attrs = {}; attrs[name] = cfg; delete this._tCfgs[name]; // TODO: The original code went through addAttrs, so // sticking with it for this pass. Seems like we could // just jump straight to _addAttr() and get some perf // improvement. this._addAttrs(attrs, this._tVals); }, /** * Provides the common implementation for the public get method, * allowing Attribute hosts to over-ride either method. * * See get for argument details. * * @method _getAttr * @protected * @chainable * * @param {String} name The name of the attribute. * @return {Any} The value of the attribute. */ _getAttr : function(name) { var fullName = name, tCfgs = this._tCfgs, path, getter, val, attrCfg; if (name.indexOf(DOT) !== -1) { path = name.split(DOT); name = path.shift(); } // On Demand - Should be rare - handles out of // order valueFn, setter, getter references if (tCfgs && tCfgs[name]) { this._addOutOfOrder(name, tCfgs[name]); } attrCfg = this._state.data[name] || {}; // Lazy Init if (attrCfg.lazy) { attrCfg = attrCfg.lazy; this._addLazyAttr(name, attrCfg); } val = this._getStateVal(name, attrCfg); getter = attrCfg.getter; if (getter && !getter.call) { getter = this[getter]; } val = (getter) ? getter.call(this, val, fullName) : val; val = (path) ? O.getValue(val, path) : val; return val; }, /** * Gets the stored value for the attribute, from either the * internal state object, or the state proxy if it exits * * @method _getStateVal * @private * @param {String} name The name of the attribute * @param {Object} [cfg] Optional config hash for the attribute. This is added for performance along the critical path, * where the calling method has already obtained the config from state. * * @return {Any} The stored value of the attribute */ _getStateVal : function(name, cfg) { var stateProxy = this._stateProxy; if (!cfg) { cfg = this._state.getAll(name) || {}; } return (stateProxy && (name in stateProxy) && !(cfg._bypassProxy)) ? stateProxy[name] : cfg.value; }, /** * Sets the stored value for the attribute, in either the * internal state object, or the state proxy if it exits * * @method _setStateVal * @private * @param {String} name The name of the attribute * @param {Any} value The value of the attribute */ _setStateVal : function(name, value) { var stateProxy = this._stateProxy; if (stateProxy && (name in stateProxy) && !this._state.get(name, BYPASS_PROXY)) { stateProxy[name] = value; } else { this._state.add(name, VALUE, value); } }, /** * Updates the stored value of the attribute in the privately held State object, * if validation and setter passes. * * @method _setAttrVal * @private * @param {String} attrName The attribute name. * @param {String} subAttrName The sub-attribute name, if setting a sub-attribute property ("x.y.z"). * @param {Any} prevVal The currently stored value of the attribute. * @param {Any} newVal The value which is going to be stored. * @param {Object} [opts] Optional data providing the circumstances for the change. * @param {Object} [attrCfg] Optional config hash for the attribute. This is added for performance along the critical path, * where the calling method has already obtained the config from state. * * @return {Boolean} true if the new attribute value was stored, false if not. */ _setAttrVal : function(attrName, subAttrName, prevVal, newVal, opts, attrCfg) { var host = this, allowSet = true, cfg = attrCfg || this._state.data[attrName] || {}, validator = cfg.validator, setter = cfg.setter, initializing = cfg.initializing, prevRawVal = this._getStateVal(attrName, cfg), name = subAttrName || attrName, retVal, valid; if (validator) { if (!validator.call) { // Assume string - trying to keep critical path tight, so avoiding Lang check validator = this[validator]; } if (validator) { valid = validator.call(host, newVal, name, opts); if (!valid && initializing) { newVal = cfg.defaultValue; valid = true; // Assume it's valid, for perf. } } } if (!validator || valid) { if (setter) { if (!setter.call) { // Assume string - trying to keep critical path tight, so avoiding Lang check setter = this[setter]; } if (setter) { retVal = setter.call(host, newVal, name, opts); if (retVal === INVALID_VALUE) { if (initializing) { newVal = cfg.defaultValue; } else { allowSet = false; } } else if (retVal !== undefined){ newVal = retVal; } } } if (allowSet) { if(!subAttrName && (newVal === prevRawVal) && !Lang.isObject(newVal)) { allowSet = false; } else { // Store value if (!(INIT_VALUE in cfg)) { cfg.initValue = newVal; } host._setStateVal(attrName, newVal); } } } else { allowSet = false; } return allowSet; }, /** * Sets multiple attribute values. * * @method setAttrs * @param {Object} attrs An object with attributes name/value pairs. * @param {Object} [opts] Optional data providing the circumstances for the change. * @return {Object} A reference to the host object. * @chainable */ setAttrs : function(attrs, opts) { return this._setAttrs(attrs, opts); }, /** * Implementation behind the public setAttrs method, to set multiple attribute values. * * @method _setAttrs * @protected * @param {Object} attrs An object with attributes name/value pairs. * @param {Object} [opts] Optional data providing the circumstances for the change * @return {Object} A reference to the host object. * @chainable */ _setAttrs : function(attrs, opts) { var attr; for (attr in attrs) { if ( attrs.hasOwnProperty(attr) ) { this.set(attr, attrs[attr], opts); } } return this; }, /** * Gets multiple attribute values. * * @method getAttrs * @param {String[]|Boolean} attrs Optional. An array of attribute names. If omitted, all attribute values are * returned. If set to true, all attributes modified from their initial values are returned. * @return {Object} An object with attribute name/value pairs. */ getAttrs : function(attrs) { return this._getAttrs(attrs); }, /** * Implementation behind the public getAttrs method, to get multiple attribute values. * * @method _getAttrs * @protected * @param {String[]|Boolean} attrs Optional. An array of attribute names. If omitted, all attribute values are * returned. If set to true, all attributes modified from their initial values are returned. * @return {Object} An object with attribute name/value pairs. */ _getAttrs : function(attrs) { var obj = {}, attr, i, len, modifiedOnly = (attrs === true); // TODO - figure out how to get all "added" if (!attrs || modifiedOnly) { attrs = O.keys(this._state.data); } for (i = 0, len = attrs.length; i < len; i++) { attr = attrs[i]; if (!modifiedOnly || this._getStateVal(attr) != this._state.get(attr, INIT_VALUE)) { // Go through get, to honor cloning/normalization obj[attr] = this.get(attr); } } return obj; }, /** * Configures a group of attributes, and sets initial values. * *

* NOTE: This method does not isolate the configuration object by merging/cloning. * The caller is responsible for merging/cloning the configuration object if required. *

* * @method addAttrs * @chainable * * @param {Object} cfgs An object with attribute name/configuration pairs. * @param {Object} values An object with attribute name/value pairs, defining the initial values to apply. * Values defined in the cfgs argument will be over-written by values in this argument unless defined as read only. * @param {boolean} lazy Whether or not to delay the intialization of these attributes until the first call to get/set. * Individual attributes can over-ride this behavior by defining a lazyAdd configuration property in their configuration. * See addAttr. * * @return {Object} A reference to the host object. */ addAttrs : function(cfgs, values, lazy) { if (cfgs) { this._tCfgs = cfgs; this._tVals = (values) ? this._normAttrVals(values) : null; this._addAttrs(cfgs, this._tVals, lazy); this._tCfgs = this._tVals = null; } return this; }, /** * Implementation behind the public addAttrs method. * * This method is invoked directly by get if it encounters a scenario * in which an attribute's valueFn attempts to obtain the * value an attribute in the same group of attributes, which has not yet * been added (on demand initialization). * * @method _addAttrs * @private * @param {Object} cfgs An object with attribute name/configuration pairs. * @param {Object} values An object with attribute name/value pairs, defining the initial values to apply. * Values defined in the cfgs argument will be over-written by values in this argument unless defined as read only. * @param {boolean} lazy Whether or not to delay the intialization of these attributes until the first call to get/set. * Individual attributes can over-ride this behavior by defining a lazyAdd configuration property in their configuration. * See addAttr. */ _addAttrs : function(cfgs, values, lazy) { var tCfgs = this._tCfgs, tVals = this._tVals, attr, attrCfg, value; for (attr in cfgs) { if (cfgs.hasOwnProperty(attr)) { // Not Merging. Caller is responsible for isolating configs attrCfg = cfgs[attr]; attrCfg.defaultValue = attrCfg.value; // Handle simple, complex and user values, accounting for read-only value = this._getAttrInitVal(attr, attrCfg, tVals); if (value !== undefined) { attrCfg.value = value; } if (tCfgs[attr]) { tCfgs[attr] = undefined; } this.addAttr(attr, attrCfg, lazy); } } }, /** * Utility method to protect an attribute configuration * hash, by merging the entire object and the individual * attr config objects. * * @method _protectAttrs * @protected * @param {Object} attrs A hash of attribute to configuration object pairs. * @return {Object} A protected version of the attrs argument. * @deprecated Use `AttributeCore.protectAttrs()` or * `Attribute.protectAttrs()` which are the same static utility method. */ _protectAttrs : AttributeCore.protectAttrs, /** * Utility method to normalize attribute values. The base implementation * simply merges the hash to protect the original. * * @method _normAttrVals * @param {Object} valueHash An object with attribute name/value pairs * * @return {Object} An object literal with 2 properties - "simple" and "complex", * containing simple and complex attribute values respectively keyed * by the top level attribute name, or null, if valueHash is falsey. * * @private */ _normAttrVals : function(valueHash) { var vals, subvals, path, attr, v, k; if (!valueHash) { return null; } vals = {}; for (k in valueHash) { if (valueHash.hasOwnProperty(k)) { if (k.indexOf(DOT) !== -1) { path = k.split(DOT); attr = path.shift(); subvals = subvals || {}; v = subvals[attr] = subvals[attr] || []; v[v.length] = { path : path, value: valueHash[k] }; } else { vals[k] = valueHash[k]; } } } return { simple:vals, complex:subvals }; }, /** * Returns the initial value of the given attribute from * either the default configuration provided, or the * over-ridden value if it exists in the set of initValues * provided and the attribute is not read-only. * * @param {String} attr The name of the attribute * @param {Object} cfg The attribute configuration object * @param {Object} initValues The object with simple and complex attribute name/value pairs returned from _normAttrVals * * @return {Any} The initial value of the attribute. * * @method _getAttrInitVal * @private */ _getAttrInitVal : function(attr, cfg, initValues) { var val = cfg.value, valFn = cfg.valueFn, tmpVal, initValSet = false, readOnly = cfg.readOnly, simple, complex, i, l, path, subval, subvals; if (!readOnly && initValues) { // Simple Attributes simple = initValues.simple; if (simple && simple.hasOwnProperty(attr)) { val = simple[attr]; initValSet = true; } } if (valFn && !initValSet) { if (!valFn.call) { valFn = this[valFn]; } if (valFn) { tmpVal = valFn.call(this, attr); val = tmpVal; } } if (!readOnly && initValues) { // Complex Attributes (complex values applied, after simple, in case both are set) complex = initValues.complex; if (complex && complex.hasOwnProperty(attr) && (val !== undefined) && (val !== null)) { subvals = complex[attr]; for (i = 0, l = subvals.length; i < l; ++i) { path = subvals[i].path; subval = subvals[i].value; O.setValue(val, path, subval); } } } return val; }, /** * Utility method to set up initial attributes defined during construction, * either through the constructor.ATTRS property, or explicitly passed in. * * @method _initAttrs * @protected * @param attrs {Object} The attributes to add during construction (passed through to addAttrs). * These can also be defined on the constructor being augmented with Attribute by defining the ATTRS property on the constructor. * @param values {Object} The initial attribute values to apply (passed through to addAttrs). * These are not merged/cloned. The caller is responsible for isolating user provided values if required. * @param lazy {boolean} Whether or not to add attributes lazily (passed through to addAttrs). */ _initAttrs : function(attrs, values, lazy) { // ATTRS support for Node, which is not Base based attrs = attrs || this.constructor.ATTRS; var Base = Y.Base, BaseCore = Y.BaseCore, baseInst = (Base && Y.instanceOf(this, Base)), baseCoreInst = (!baseInst && BaseCore && Y.instanceOf(this, BaseCore)); if (attrs && !baseInst && !baseCoreInst) { this.addAttrs(Y.AttributeCore.protectAttrs(attrs), values, lazy); } } }; Y.AttributeCore = AttributeCore; }, '3.17.2', {"requires": ["oop"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('event-custom-complex', function (Y, NAME) { /** * Adds event facades, preventable default behavior, and bubbling. * events. * @module event-custom * @submodule event-custom-complex */ var FACADE, FACADE_KEYS, YObject = Y.Object, key, EMPTY = {}, CEProto = Y.CustomEvent.prototype, ETProto = Y.EventTarget.prototype, mixFacadeProps = function(facade, payload) { var p; for (p in payload) { if (!(FACADE_KEYS.hasOwnProperty(p))) { facade[p] = payload[p]; } } }; /** * Wraps and protects a custom event for use when emitFacade is set to true. * Requires the event-custom-complex module * @class EventFacade * @param e {Event} the custom event * @param currentTarget {HTMLElement} the element the listener was attached to */ Y.EventFacade = function(e, currentTarget) { if (!e) { e = EMPTY; } this._event = e; /** * The arguments passed to fire * @property details * @type Array */ this.details = e.details; /** * The event type, this can be overridden by the fire() payload * @property type * @type string */ this.type = e.type; /** * The real event type * @property _type * @type string * @private */ this._type = e.type; ////////////////////////////////////////////////////// /** * Node reference for the targeted eventtarget * @property target * @type Node */ this.target = e.target; /** * Node reference for the element that the listener was attached to. * @property currentTarget * @type Node */ this.currentTarget = currentTarget; /** * Node reference to the relatedTarget * @property relatedTarget * @type Node */ this.relatedTarget = e.relatedTarget; }; Y.mix(Y.EventFacade.prototype, { /** * Stops the propagation to the next bubble target * @method stopPropagation */ stopPropagation: function() { this._event.stopPropagation(); this.stopped = 1; }, /** * Stops the propagation to the next bubble target and * prevents any additional listeners from being exectued * on the current target. * @method stopImmediatePropagation */ stopImmediatePropagation: function() { this._event.stopImmediatePropagation(); this.stopped = 2; }, /** * Prevents the event's default behavior * @method preventDefault */ preventDefault: function() { this._event.preventDefault(); this.prevented = 1; }, /** * Stops the event propagation and prevents the default * event behavior. * @method halt * @param immediate {boolean} if true additional listeners * on the current target will not be executed */ halt: function(immediate) { this._event.halt(immediate); this.prevented = 1; this.stopped = (immediate) ? 2 : 1; } }); CEProto.fireComplex = function(args) { var es, ef, q, queue, ce, ret = true, events, subs, ons, afters, afterQueue, postponed, prevented, preventedFn, defaultFn, self = this, host = self.host || self, next, oldbubble, stack = self.stack, yuievt = host._yuievt, hasPotentialSubscribers; if (stack) { // queue this event if the current item in the queue bubbles if (self.queuable && self.type !== stack.next.type) { if (!stack.queue) { stack.queue = []; } stack.queue.push([self, args]); return true; } } hasPotentialSubscribers = self.hasSubs() || yuievt.hasTargets || self.broadcast; self.target = self.target || host; self.currentTarget = host; self.details = args.concat(); if (hasPotentialSubscribers) { es = stack || { id: self.id, // id of the first event in the stack next: self, silent: self.silent, stopped: 0, prevented: 0, bubbling: null, type: self.type, // defaultFnQueue: new Y.Queue(), defaultTargetOnly: self.defaultTargetOnly }; subs = self.getSubs(); ons = subs[0]; afters = subs[1]; self.stopped = (self.type !== es.type) ? 0 : es.stopped; self.prevented = (self.type !== es.type) ? 0 : es.prevented; if (self.stoppedFn) { // PERF TODO: Can we replace with callback, like preventedFn. Look into history events = new Y.EventTarget({ fireOnce: true, context: host }); self.events = events; events.on('stopped', self.stoppedFn); } self._facade = null; // kill facade to eliminate stale properties ef = self._createFacade(args); if (ons) { self._procSubs(ons, args, ef); } // bubble if this is hosted in an event target and propagation has not been stopped if (self.bubbles && host.bubble && !self.stopped) { oldbubble = es.bubbling; es.bubbling = self.type; if (es.type !== self.type) { es.stopped = 0; es.prevented = 0; } ret = host.bubble(self, args, null, es); self.stopped = Math.max(self.stopped, es.stopped); self.prevented = Math.max(self.prevented, es.prevented); es.bubbling = oldbubble; } prevented = self.prevented; if (prevented) { preventedFn = self.preventedFn; if (preventedFn) { preventedFn.apply(host, args); } } else { defaultFn = self.defaultFn; if (defaultFn && ((!self.defaultTargetOnly && !es.defaultTargetOnly) || host === ef.target)) { defaultFn.apply(host, args); } } // broadcast listeners are fired as discreet events on the // YUI instance and potentially the YUI global. if (self.broadcast) { self._broadcast(args); } if (afters && !self.prevented && self.stopped < 2) { // Queue the after afterQueue = es.afterQueue; if (es.id === self.id || self.type !== yuievt.bubbling) { self._procSubs(afters, args, ef); if (afterQueue) { while ((next = afterQueue.last())) { next(); } } } else { postponed = afters; if (es.execDefaultCnt) { postponed = Y.merge(postponed); Y.each(postponed, function(s) { s.postponed = true; }); } if (!afterQueue) { es.afterQueue = new Y.Queue(); } es.afterQueue.add(function() { self._procSubs(postponed, args, ef); }); } } self.target = null; if (es.id === self.id) { queue = es.queue; if (queue) { while (queue.length) { q = queue.pop(); ce = q[0]; // set up stack to allow the next item to be processed es.next = ce; ce._fire(q[1]); } } self.stack = null; } ret = !(self.stopped); if (self.type !== yuievt.bubbling) { es.stopped = 0; es.prevented = 0; self.stopped = 0; self.prevented = 0; } } else { defaultFn = self.defaultFn; if(defaultFn) { ef = self._createFacade(args); if ((!self.defaultTargetOnly) || (host === ef.target)) { defaultFn.apply(host, args); } } } // Kill the cached facade to free up memory. // Otherwise we have the facade from the last fire, sitting around forever. self._facade = null; return ret; }; /** * @method _hasPotentialSubscribers * @for CustomEvent * @private * @return {boolean} Whether the event has potential subscribers or not */ CEProto._hasPotentialSubscribers = function() { return this.hasSubs() || this.host._yuievt.hasTargets || this.broadcast; }; /** * Internal utility method to create a new facade instance and * insert it into the fire argument list, accounting for any payload * merging which needs to happen. * * This used to be called `_getFacade`, but the name seemed inappropriate * when it was used without a need for the return value. * * @method _createFacade * @private * @param fireArgs {Array} The arguments passed to "fire", which need to be * shifted (and potentially merged) when the facade is added. * @return {EventFacade} The event facade created. */ // TODO: Remove (private) _getFacade alias, once synthetic.js is updated. CEProto._createFacade = CEProto._getFacade = function(fireArgs) { var userArgs = this.details, firstArg = userArgs && userArgs[0], firstArgIsObj = (firstArg && (typeof firstArg === "object")), ef = this._facade; if (!ef) { ef = new Y.EventFacade(this, this.currentTarget); } if (firstArgIsObj) { // protect the event facade properties mixFacadeProps(ef, firstArg); // Allow the event type to be faked http://yuilibrary.com/projects/yui3/ticket/2528376 if (firstArg.type) { ef.type = firstArg.type; } if (fireArgs) { fireArgs[0] = ef; } } else { if (fireArgs) { fireArgs.unshift(ef); } } // update the details field with the arguments ef.details = this.details; // use the original target when the event bubbled to this target ef.target = this.originalTarget || this.target; ef.currentTarget = this.currentTarget; ef.stopped = 0; ef.prevented = 0; this._facade = ef; return this._facade; }; /** * Utility method to manipulate the args array passed in, to add the event facade, * if it's not already the first arg. * * @method _addFacadeToArgs * @private * @param {Array} The arguments to manipulate */ CEProto._addFacadeToArgs = function(args) { var e = args[0]; // Trying not to use instanceof, just to avoid potential cross Y edge case issues. if (!(e && e.halt && e.stopImmediatePropagation && e.stopPropagation && e._event)) { this._createFacade(args); } }; /** * Stop propagation to bubble targets * @for CustomEvent * @method stopPropagation */ CEProto.stopPropagation = function() { this.stopped = 1; if (this.stack) { this.stack.stopped = 1; } if (this.events) { this.events.fire('stopped', this); } }; /** * Stops propagation to bubble targets, and prevents any remaining * subscribers on the current target from executing. * @method stopImmediatePropagation */ CEProto.stopImmediatePropagation = function() { this.stopped = 2; if (this.stack) { this.stack.stopped = 2; } if (this.events) { this.events.fire('stopped', this); } }; /** * Prevents the execution of this event's defaultFn * @method preventDefault */ CEProto.preventDefault = function() { if (this.preventable) { this.prevented = 1; if (this.stack) { this.stack.prevented = 1; } } }; /** * Stops the event propagation and prevents the default * event behavior. * @method halt * @param immediate {boolean} if true additional listeners * on the current target will not be executed */ CEProto.halt = function(immediate) { if (immediate) { this.stopImmediatePropagation(); } else { this.stopPropagation(); } this.preventDefault(); }; /** * Registers another EventTarget as a bubble target. Bubble order * is determined by the order registered. Multiple targets can * be specified. * * Events can only bubble if emitFacade is true. * * Included in the event-custom-complex submodule. * * @method addTarget * @chainable * @param o {EventTarget} the target to add * @for EventTarget */ ETProto.addTarget = function(o) { var etState = this._yuievt; if (!etState.targets) { etState.targets = {}; } etState.targets[Y.stamp(o)] = o; etState.hasTargets = true; return this; }; /** * Returns an array of bubble targets for this object. * @method getTargets * @return EventTarget[] */ ETProto.getTargets = function() { var targets = this._yuievt.targets; return targets ? YObject.values(targets) : []; }; /** * Removes a bubble target * @method removeTarget * @chainable * @param o {EventTarget} the target to remove * @for EventTarget */ ETProto.removeTarget = function(o) { var targets = this._yuievt.targets; if (targets) { delete targets[Y.stamp(o, true)]; if (YObject.size(targets) === 0) { this._yuievt.hasTargets = false; } } return this; }; /** * Propagate an event. Requires the event-custom-complex module. * @method bubble * @param evt {CustomEvent} the custom event to propagate * @return {boolean} the aggregated return value from Event.Custom.fire * @for EventTarget */ ETProto.bubble = function(evt, args, target, es) { var targs = this._yuievt.targets, ret = true, t, ce, i, bc, ce2, type = evt && evt.type, originalTarget = target || (evt && evt.target) || this, oldbubble; if (!evt || ((!evt.stopped) && targs)) { for (i in targs) { if (targs.hasOwnProperty(i)) { t = targs[i]; ce = t._yuievt.events[type]; if (t._hasSiblings) { ce2 = t.getSibling(type, ce); } if (ce2 && !ce) { ce = t.publish(type); } oldbubble = t._yuievt.bubbling; t._yuievt.bubbling = type; // if this event was not published on the bubble target, // continue propagating the event. if (!ce) { if (t._yuievt.hasTargets) { t.bubble(evt, args, originalTarget, es); } } else { if (ce2) { ce.sibling = ce2; } // set the original target to that the target payload on the facade is correct. ce.target = originalTarget; ce.originalTarget = originalTarget; ce.currentTarget = t; bc = ce.broadcast; ce.broadcast = false; // default publish may not have emitFacade true -- that // shouldn't be what the implementer meant to do ce.emitFacade = true; ce.stack = es; // TODO: See what's getting in the way of changing this to use // the more performant ce._fire(args || evt.details || []). // Something in Widget Parent/Child tests is not happy if we // change it - maybe evt.details related? ret = ret && ce.fire.apply(ce, args || evt.details || []); ce.broadcast = bc; ce.originalTarget = null; // stopPropagation() was called if (ce.stopped) { break; } } t._yuievt.bubbling = oldbubble; } } } return ret; }; /** * @method _hasPotentialSubscribers * @for EventTarget * @private * @param {String} fullType The fully prefixed type name * @return {boolean} Whether the event has potential subscribers or not */ ETProto._hasPotentialSubscribers = function(fullType) { var etState = this._yuievt, e = etState.events[fullType]; if (e) { return e.hasSubs() || etState.hasTargets || e.broadcast; } else { return false; } }; FACADE = new Y.EventFacade(); FACADE_KEYS = {}; // Flatten whitelist for (key in FACADE) { FACADE_KEYS[key] = true; } }, '3.17.2', {"requires": ["event-custom-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('base-core', function (Y, NAME) { /** * The base module provides the Base class, which objects requiring attribute and custom event support can extend. * The module also provides two ways to reuse code - It augments Base with the Plugin.Host interface which provides * plugin support and also provides the BaseCore.build method which provides a way to build custom classes using extensions. * * @module base */ /** *

The base-core module provides the BaseCore class, the lightest version of Base, * which provides Base's basic lifecycle management and ATTRS construction support, * but doesn't fire init/destroy or attribute change events.

* *

It mixes in AttributeCore, which is the lightest version of Attribute

* * @module base * @submodule base-core */ var O = Y.Object, L = Y.Lang, DOT = ".", INITIALIZED = "initialized", DESTROYED = "destroyed", INITIALIZER = "initializer", VALUE = "value", OBJECT_CONSTRUCTOR = Object.prototype.constructor, DEEP = "deep", SHALLOW = "shallow", DESTRUCTOR = "destructor", AttributeCore = Y.AttributeCore, _wlmix = function(r, s, wlhash) { var p; for (p in s) { if(wlhash[p]) { r[p] = s[p]; } } return r; }; /** * The BaseCore class, is the lightest version of Base, and provides Base's * basic lifecycle management and ATTRS construction support, but doesn't * fire init/destroy or attribute change events. * * BaseCore also handles the chaining of initializer and destructor methods across * the hierarchy as part of object construction and destruction. Additionally, attributes * configured through the static ATTRS * property for each class in the hierarchy will be initialized by BaseCore. * * Classes which require attribute support, but don't intend to use/expose attribute * change events can extend BaseCore instead of Base for optimal kweight and * runtime performance. * * **3.11.0 BACK COMPAT NOTE FOR COMPONENT DEVELOPERS** * * Prior to version 3.11.0, ATTRS would get added a class at a time. That is: * *
     *    for each (class in the hierarchy) {
     *       Call the class Extension constructors.
     *
     *       Add the class ATTRS.
     *
     *       Call the class initializer
     *       Call the class Extension initializers.
     *    }
     * 
* * As of 3.11.0, ATTRS from all classes in the hierarchy are added in one `addAttrs` call * before **any** initializers are called. That is, the flow becomes: * *
     *    for each (class in the hierarchy) {
     *       Call the class Extension constructors.
     *    }
     *
     *    Add ATTRS for all classes
     *
     *    for each (class in the hierarchy) {
     *       Call the class initializer.
     *       Call the class Extension initializers.
     *    }
     * 
* * Adding all ATTRS at once fixes subtle edge-case issues with subclass ATTRS overriding * superclass `setter`, `getter` or `valueFn` definitions and being unable to get/set attributes * defined by the subclass. It also leaves us with a cleaner order of operation flow moving * forward. * * However, it may require component developers to upgrade their components, for the following * scenarios: * * 1. It impacts components which may have `setter`, `getter` or `valueFn` code which * expects a superclass' initializer to have run. * * This is expected to be rare, but to support it, Base now supports a `_preAddAttrs()`, method * hook (same signature as `addAttrs`). Components can implement this method on their prototype * for edge cases which do require finer control over the order in which attributes are added * (see widget-htmlparser for example). * * 2. Extension developers may need to move code from Extension constructors to `initializer`s * * Older extensions, which were written before `initializer` support was added, had a lot of * initialization code in their constructors. For example, code which acccessed superclass * attributes. With the new flow this code would not be able to see attributes. The recommendation * is to move this initialization code to an `initializer` on the Extension, which was the * recommendation for anything created after `initializer` support for Extensions was added. * * @class BaseCore * @constructor * @uses AttributeCore * @param {Object} cfg Object with configuration property name/value pairs. * The object can be used to provide initial values for the objects published * attributes. */ function BaseCore(cfg) { if (!this._BaseInvoked) { this._BaseInvoked = true; this._initBase(cfg); } } /** * The list of properties which can be configured for each attribute * (e.g. setter, getter, writeOnce, readOnly etc.) * * @property _ATTR_CFG * @type Array * @static * @private */ BaseCore._ATTR_CFG = AttributeCore._ATTR_CFG.concat("cloneDefaultValue"); /** * The array of non-attribute configuration properties supported by this class. * * For example `BaseCore` defines a "plugins" configuration property which * should not be set up as an attribute. This property is primarily required so * that when `_allowAdHocAttrs` is enabled by a class, * non-attribute configuration properties don't get added as ad-hoc attributes. * * @property _NON_ATTRS_CFG * @type Array * @static * @private */ BaseCore._NON_ATTRS_CFG = ["plugins"]; /** * This property controls whether or not instances of this class should * allow users to add ad-hoc attributes through the constructor configuration * hash. * * AdHoc attributes are attributes which are not defined by the class, and are * not handled by the MyClass._NON_ATTRS_CFG * * @property _allowAdHocAttrs * @type boolean * @default undefined (false) * @protected */ /** * The string to be used to identify instances of this class. * * Classes extending BaseCore, should define their own * static NAME property, which should be camelCase by * convention (e.g. MyClass.NAME = "myClass";). * * @property NAME * @type String * @static */ BaseCore.NAME = "baseCore"; /** * The default set of attributes which will be available for instances of this class, and * their configuration. In addition to the configuration properties listed by * AttributeCore's addAttr method, * the attribute can also be configured with a "cloneDefaultValue" property, which * defines how the statically defined value field should be protected * ("shallow", "deep" and false are supported values). * * By default if the value is an object literal or an array it will be "shallow" * cloned, to protect the default value. * * @property ATTRS * @type Object * @static */ BaseCore.ATTRS = { /** * Flag indicating whether or not this object * has been through the init lifecycle phase. * * @attribute initialized * @readonly * @default false * @type boolean */ initialized: { readOnly:true, value:false }, /** * Flag indicating whether or not this object * has been through the destroy lifecycle phase. * * @attribute destroyed * @readonly * @default false * @type boolean */ destroyed: { readOnly:true, value:false } }; /** Provides a way to safely modify a `Y.BaseCore` subclass' static `ATTRS` after the class has been defined or created. BaseCore-based classes cache information about the class hierarchy in order to efficiently create instances. This cache includes includes the aggregated `ATTRS` configs. If the static `ATTRS` configs need to be modified after the class has been defined or create, then use this method which will make sure to clear any cached data before making any modifications. @method modifyAttrs @param {Function} [ctor] The constructor function whose `ATTRS` should be modified. If a `ctor` function is not specified, then `this` is assumed to be the constructor which hosts the `ATTRS`. @param {Object} configs The collection of `ATTRS` configs to mix with the existing attribute configurations. @static @since 3.10.0 **/ BaseCore.modifyAttrs = function (ctor, configs) { // When called without a constructor, assume `this` is the constructor. if (typeof ctor !== 'function') { configs = ctor; ctor = this; } var attrs, attr, name; // Eagerly create the `ATTRS` object if it doesn't already exist. attrs = ctor.ATTRS || (ctor.ATTRS = {}); if (configs) { // Clear cache because it has ATTRS aggregation data which is about // to be modified. ctor._CACHED_CLASS_DATA = null; for (name in configs) { if (configs.hasOwnProperty(name)) { attr = attrs[name] || (attrs[name] = {}); Y.mix(attr, configs[name], true); } } } }; BaseCore.prototype = { /** * Internal construction logic for BaseCore. * * @method _initBase * @param {Object} config The constructor configuration object * @private */ _initBase : function(config) { Y.stamp(this); this._initAttribute(config); // If Plugin.Host has been augmented [ through base-pluginhost ], setup it's // initial state, but don't initialize Plugins yet. That's done after initialization. var PluginHost = Y.Plugin && Y.Plugin.Host; if (this._initPlugins && PluginHost) { PluginHost.call(this); } if (this._lazyAddAttrs !== false) { this._lazyAddAttrs = true; } /** * The string used to identify the class of this object. * * @deprecated Use this.constructor.NAME * @property name * @type String */ this.name = this.constructor.NAME; this.init.apply(this, arguments); }, /** * Initializes AttributeCore * * @method _initAttribute * @private */ _initAttribute: function() { AttributeCore.call(this); }, /** * Init lifecycle method, invoked during construction. Sets up attributes * and invokes initializers for the class hierarchy. * * @method init * @chainable * @param {Object} cfg Object with configuration property name/value pairs * @return {BaseCore} A reference to this object */ init: function(cfg) { this._baseInit(cfg); return this; }, /** * Internal initialization implementation for BaseCore * * @method _baseInit * @private */ _baseInit: function(cfg) { this._initHierarchy(cfg); if (this._initPlugins) { // Need to initPlugins manually, to handle constructor parsing, static Plug parsing this._initPlugins(cfg); } this._set(INITIALIZED, true); }, /** * Destroy lifecycle method. Invokes destructors for the class hierarchy. * * @method destroy * @return {BaseCore} A reference to this object * @chainable */ destroy: function() { this._baseDestroy(); return this; }, /** * Internal destroy implementation for BaseCore * * @method _baseDestroy * @private */ _baseDestroy : function() { if (this._destroyPlugins) { this._destroyPlugins(); } this._destroyHierarchy(); this._set(DESTROYED, true); }, /** * Returns the class hierarchy for this object, with BaseCore being the last class in the array. * * @method _getClasses * @protected * @return {Function[]} An array of classes (constructor functions), making up the class hierarchy for this object. * This value is cached the first time the method, or _getAttrCfgs, is invoked. Subsequent invocations return the * cached value. */ _getClasses : function() { if (!this._classes) { this._initHierarchyData(); } return this._classes; }, /** * Returns an aggregated set of attribute configurations, by traversing * the class hierarchy. * * @method _getAttrCfgs * @protected * @return {Object} The hash of attribute configurations, aggregated across classes in the hierarchy * This value is cached the first time the method, or _getClasses, is invoked. Subsequent invocations return * the cached value. */ _getAttrCfgs : function() { if (!this._attrs) { this._initHierarchyData(); } return this._attrs; }, /** * A helper method used to isolate the attrs config for this instance to pass to `addAttrs`, * from the static cached ATTRS for the class. * * @method _getInstanceAttrCfgs * @private * * @param {Object} allCfgs The set of all attribute configurations for this instance. * Attributes will be removed from this set, if they belong to the filtered class, so * that by the time all classes are processed, allCfgs will be empty. * * @return {Object} The set of attributes to be added for this instance, suitable * for passing through to `addAttrs`. */ _getInstanceAttrCfgs : function(allCfgs) { var cfgs = {}, cfg, val, subAttr, subAttrs, subAttrPath, attr, attrCfg, allSubAttrs = allCfgs._subAttrs, attrCfgProperties = this._attrCfgHash(); for (attr in allCfgs) { if (allCfgs.hasOwnProperty(attr) && attr !== "_subAttrs") { attrCfg = allCfgs[attr]; // Need to isolate from allCfgs, because we're going to set values etc. cfg = cfgs[attr] = _wlmix({}, attrCfg, attrCfgProperties); val = cfg.value; if (val && (typeof val === "object")) { this._cloneDefaultValue(attr, cfg); } if (allSubAttrs && allSubAttrs.hasOwnProperty(attr)) { subAttrs = allCfgs._subAttrs[attr]; for (subAttrPath in subAttrs) { subAttr = subAttrs[subAttrPath]; if (subAttr.path) { O.setValue(cfg.value, subAttr.path, subAttr.value); } } } } } return cfgs; }, /** * @method _filterAdHocAttrs * @private * * @param {Object} allAttrs The set of all attribute configurations for this instance. * Attributes will be removed from this set, if they belong to the filtered class, so * that by the time all classes are processed, allCfgs will be empty. * @param {Object} userVals The config object passed in by the user, from which adhoc attrs are to be filtered. * @return {Object} The set of adhoc attributes passed in, in the form * of an object with attribute name/configuration pairs. */ _filterAdHocAttrs : function(allAttrs, userVals) { var adHocs, nonAttrs = this._nonAttrs, attr; if (userVals) { adHocs = {}; for (attr in userVals) { if (!allAttrs[attr] && !nonAttrs[attr] && userVals.hasOwnProperty(attr)) { adHocs[attr] = { value:userVals[attr] }; } } } return adHocs; }, /** * A helper method used by _getClasses and _getAttrCfgs, which determines both * the array of classes and aggregate set of attribute configurations * across the class hierarchy for the instance. * * @method _initHierarchyData * @private */ _initHierarchyData : function() { var ctor = this.constructor, cachedClassData = ctor._CACHED_CLASS_DATA, c, i, l, attrCfg, attrCfgHash, needsAttrCfgHash = !ctor._ATTR_CFG_HASH, nonAttrsCfg, nonAttrs = {}, classes = [], attrs = []; // Start with `this` instance's constructor. c = ctor; if (!cachedClassData) { while (c) { // Add to classes classes[classes.length] = c; // Add to attributes if (c.ATTRS) { attrs[attrs.length] = c.ATTRS; } // Aggregate ATTR cfg whitelist. if (needsAttrCfgHash) { attrCfg = c._ATTR_CFG; attrCfgHash = attrCfgHash || {}; if (attrCfg) { for (i = 0, l = attrCfg.length; i < l; i += 1) { attrCfgHash[attrCfg[i]] = true; } } } // Commenting out the if. We always aggregate, since we don't // know if we'll be needing this on the instance or not. // if (this._allowAdHocAttrs) { nonAttrsCfg = c._NON_ATTRS_CFG; if (nonAttrsCfg) { for (i = 0, l = nonAttrsCfg.length; i < l; i++) { nonAttrs[nonAttrsCfg[i]] = true; } } //} c = c.superclass ? c.superclass.constructor : null; } // Cache computed `_ATTR_CFG_HASH` on the constructor. if (needsAttrCfgHash) { ctor._ATTR_CFG_HASH = attrCfgHash; } cachedClassData = ctor._CACHED_CLASS_DATA = { classes : classes, nonAttrs : nonAttrs, attrs : this._aggregateAttrs(attrs) }; } this._classes = cachedClassData.classes; this._attrs = cachedClassData.attrs; this._nonAttrs = cachedClassData.nonAttrs; }, /** * Utility method to define the attribute hash used to filter/whitelist property mixes for * this class for iteration performance reasons. * * @method _attrCfgHash * @private */ _attrCfgHash: function() { return this.constructor._ATTR_CFG_HASH; }, /** * This method assumes that the value has already been checked to be an object. * Since it's on a critical path, we don't want to re-do the check. * * @method _cloneDefaultValue * @param {Object} cfg * @private */ _cloneDefaultValue : function(attr, cfg) { var val = cfg.value, clone = cfg.cloneDefaultValue; if (clone === DEEP || clone === true) { cfg.value = Y.clone(val); } else if (clone === SHALLOW) { cfg.value = Y.merge(val); } else if ((clone === undefined && (OBJECT_CONSTRUCTOR === val.constructor || L.isArray(val)))) { cfg.value = Y.clone(val); } // else if (clone === false), don't clone the static default value. // It's intended to be used by reference. }, /** * A helper method, used by _initHierarchyData to aggregate * attribute configuration across the instances class hierarchy. * * The method will protect the attribute configuration value to protect the statically defined * default value in ATTRS if required (if the value is an object literal, array or the * attribute configuration has cloneDefaultValue set to shallow or deep). * * @method _aggregateAttrs * @private * @param {Array} allAttrs An array of ATTRS definitions across classes in the hierarchy * (subclass first, Base last) * @return {Object} The aggregate set of ATTRS definitions for the instance */ _aggregateAttrs : function(allAttrs) { var attr, attrs, subAttrsHash, cfg, path, i, cfgPropsHash = this._attrCfgHash(), aggAttr, aggAttrs = {}; if (allAttrs) { for (i = allAttrs.length-1; i >= 0; --i) { attrs = allAttrs[i]; for (attr in attrs) { if (attrs.hasOwnProperty(attr)) { // PERF TODO: Do we need to merge here, since we're merging later in getInstanceAttrCfgs // Should we move this down to only merge if we hit the path or valueFn ifs below? cfg = _wlmix({}, attrs[attr], cfgPropsHash); path = null; if (attr.indexOf(DOT) !== -1) { path = attr.split(DOT); attr = path.shift(); } aggAttr = aggAttrs[attr]; if (path && aggAttr && aggAttr.value) { subAttrsHash = aggAttrs._subAttrs; if (!subAttrsHash) { subAttrsHash = aggAttrs._subAttrs = {}; } if (!subAttrsHash[attr]) { subAttrsHash[attr] = {}; } subAttrsHash[attr][path.join(DOT)] = { value: cfg.value, path : path }; } else if (!path) { if (!aggAttr) { aggAttrs[attr] = cfg; } else { if (aggAttr.valueFn && VALUE in cfg) { aggAttr.valueFn = null; } // Mix into existing config. _wlmix(aggAttr, cfg, cfgPropsHash); } } } } } } return aggAttrs; }, /** * Initializes the class hierarchy for the instance, which includes * initializing attributes for each class defined in the class's * static ATTRS property and * invoking the initializer method on the prototype of each class in the hierarchy. * * @method _initHierarchy * @param {Object} userVals Object with configuration property name/value pairs * @private */ _initHierarchy : function(userVals) { var lazy = this._lazyAddAttrs, constr, constrProto, i, l, ci, ei, el, ext, extProto, exts, instanceAttrs, initializers = [], classes = this._getClasses(), attrCfgs = this._getAttrCfgs(), cl = classes.length - 1; // Constructors for (ci = cl; ci >= 0; ci--) { constr = classes[ci]; constrProto = constr.prototype; exts = constr._yuibuild && constr._yuibuild.exts; // Using INITIALIZER in hasOwnProperty check, for performance reasons (helps IE6 avoid GC thresholds when // referencing string literals). Not using it in apply, again, for performance "." is faster. if (constrProto.hasOwnProperty(INITIALIZER)) { // Store initializer while we're here and looping initializers[initializers.length] = constrProto.initializer; } if (exts) { for (ei = 0, el = exts.length; ei < el; ei++) { ext = exts[ei]; // Ext Constructor ext.apply(this, arguments); extProto = ext.prototype; if (extProto.hasOwnProperty(INITIALIZER)) { // Store initializer while we're here and looping initializers[initializers.length] = extProto.initializer; } } } } // ATTRS instanceAttrs = this._getInstanceAttrCfgs(attrCfgs); if (this._preAddAttrs) { this._preAddAttrs(instanceAttrs, userVals, lazy); } if (this._allowAdHocAttrs) { this.addAttrs(this._filterAdHocAttrs(attrCfgs, userVals), userVals, lazy); } this.addAttrs(instanceAttrs, userVals, lazy); // Initializers for (i = 0, l = initializers.length; i < l; i++) { initializers[i].apply(this, arguments); } }, /** * Destroys the class hierarchy for this instance by invoking * the destructor method on the prototype of each class in the hierarchy. * * @method _destroyHierarchy * @private */ _destroyHierarchy : function() { var constr, constrProto, ci, cl, ei, el, exts, extProto, classes = this._getClasses(); for (ci = 0, cl = classes.length; ci < cl; ci++) { constr = classes[ci]; constrProto = constr.prototype; exts = constr._yuibuild && constr._yuibuild.exts; if (exts) { for (ei = 0, el = exts.length; ei < el; ei++) { extProto = exts[ei].prototype; if (extProto.hasOwnProperty(DESTRUCTOR)) { extProto.destructor.apply(this, arguments); } } } if (constrProto.hasOwnProperty(DESTRUCTOR)) { constrProto.destructor.apply(this, arguments); } } }, /** * Default toString implementation. Provides the constructor NAME * and the instance guid, if set. * * @method toString * @return {String} String representation for this object */ toString: function() { return this.name + "[" + Y.stamp(this, true) + "]"; } }; // Straightup augment, no wrapper functions Y.mix(BaseCore, AttributeCore, false, null, 1); // Fix constructor BaseCore.prototype.constructor = BaseCore; Y.BaseCore = BaseCore; }, '3.17.2', {"requires": ["attribute-core"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('attribute-base', function (Y, NAME) { /** * The attribute module provides an augmentable Attribute implementation, which * adds configurable attributes and attribute change events to the class being * augmented. It also provides a State class, which is used internally by Attribute, * but can also be used independently to provide a name/property/value data structure to * store state. * * @module attribute */ /** * The attribute-base submodule provides core attribute handling support, with everything * aside from complex attribute handling in the provider's constructor. * * @module attribute * @submodule attribute-base */ /** *

* Attribute provides configurable attribute support along with attribute change events. It is designed to be * augmented on to a host class, and provides the host with the ability to configure attributes to store and retrieve state, * along with attribute change events. *

*

For example, attributes added to the host can be configured:

*
    *
  • As read only.
  • *
  • As write once.
  • *
  • With a setter function, which can be used to manipulate * values passed to Attribute's set method, before they are stored.
  • *
  • With a getter function, which can be used to manipulate stored values, * before they are returned by Attribute's get method.
  • *
  • With a validator function, to validate values before they are stored.
  • *
* *

See the addAttr method, for the complete set of configuration * options available for attributes.

* *

NOTE: Most implementations will be better off extending the Base class, * instead of augmenting Attribute directly. Base augments Attribute and will handle the initial configuration * of attributes for derived classes, accounting for values passed into the constructor.

* * @class Attribute * @param attrs {Object} The attributes to add during construction (passed through to addAttrs). * These can also be defined on the constructor being augmented with Attribute by defining the ATTRS property on the constructor. * @param values {Object} The initial attribute values to apply (passed through to addAttrs). * These are not merged/cloned. The caller is responsible for isolating user provided values if required. * @param lazy {boolean} Whether or not to add attributes lazily (passed through to addAttrs). * @uses AttributeCore * @uses AttributeObservable * @uses EventTarget * @uses AttributeExtras */ function Attribute() { Y.AttributeCore.apply(this, arguments); Y.AttributeObservable.apply(this, arguments); Y.AttributeExtras.apply(this, arguments); } Y.mix(Attribute, Y.AttributeCore, false, null, 1); Y.mix(Attribute, Y.AttributeExtras, false, null, 1); // Needs to be `true`, to overwrite methods from AttributeCore Y.mix(Attribute, Y.AttributeObservable, true, null, 1); /** *

The value to return from an attribute setter in order to prevent the set from going through.

* *

You can return this value from your setter if you wish to combine validator and setter * functionality into a single setter function, which either returns the massaged value to be stored or * AttributeCore.INVALID_VALUE to prevent invalid values from being stored.

* * @property INVALID_VALUE * @type Object * @static * @final */ Attribute.INVALID_VALUE = Y.AttributeCore.INVALID_VALUE; /** * The list of properties which can be configured for * each attribute (e.g. setter, getter, writeOnce etc.). * * This property is used internally as a whitelist for faster * Y.mix operations. * * @property _ATTR_CFG * @type Array * @static * @protected */ Attribute._ATTR_CFG = Y.AttributeCore._ATTR_CFG.concat(Y.AttributeObservable._ATTR_CFG); /** * Utility method to protect an attribute configuration hash, by merging the * entire object and the individual attr config objects. * * @method protectAttrs * @static * @param {Object} attrs A hash of attribute to configuration object pairs. * @return {Object} A protected version of the `attrs` argument. */ Attribute.protectAttrs = Y.AttributeCore.protectAttrs; Y.Attribute = Attribute; }, '3.17.2', {"requires": ["attribute-core", "attribute-observable", "attribute-extras"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('attribute-extras', function (Y, NAME) { /** * The attribute module provides an augmentable Attribute implementation, which * adds configurable attributes and attribute change events to the class being * augmented. It also provides a State class, which is used internally by Attribute, * but can also be used independently to provide a name/property/value data structure to * store state. * * @module attribute */ /** * The attribute-extras submodule provides less commonly used attribute methods, and can * be augmented/mixed into an implemention which used attribute-core. * * @module attribute * @submodule attribute-extras */ var BROADCAST = "broadcast", PUBLISHED = "published", INIT_VALUE = "initValue", MODIFIABLE = { readOnly:1, writeOnce:1, getter:1, broadcast:1 }; /** * A augmentable implementation for AttributeCore, providing less frequently used * methods for Attribute management such as modifyAttrs(), removeAttr and reset() * * @class AttributeExtras * @extensionfor AttributeCore */ function AttributeExtras() {} AttributeExtras.prototype = { /** * Updates the configuration of an attribute which has already been added. *

* The properties which can be modified through this interface are limited * to the following subset of attributes, which can be safely modified * after a value has already been set on the attribute: *

*
*
readOnly;
*
writeOnce;
*
broadcast; and
*
getter.
*
*

* Note: New attributes cannot be added using this interface. New attributes must be * added using {{#crossLink "AttributeCore/addAttr:method"}}addAttr{{/crossLink}}, or an * appropriate manner for a class which utilises Attributes (e.g. the * {{#crossLink "Base/ATTRS:property"}}ATTRS{{/crossLink}} property in * {{#crossLink "Base"}}Base{{/crossLink}}). *

* @method modifyAttr * @param {String} name The name of the attribute whose configuration is to be updated. * @param {Object} config An object with configuration property/value pairs, specifying the configuration properties to modify. */ modifyAttr: function(name, config) { var host = this, // help compression prop, state; if (host.attrAdded(name)) { if (host._isLazyAttr(name)) { host._addLazyAttr(name); } state = host._state; for (prop in config) { if (MODIFIABLE[prop] && config.hasOwnProperty(prop)) { state.add(name, prop, config[prop]); // If we reconfigured broadcast, need to republish if (prop === BROADCAST) { state.remove(name, PUBLISHED); } } } } else { } }, /** * Removes an attribute from the host object * * @method removeAttr * @param {String} name The name of the attribute to be removed. */ removeAttr: function(name) { this._state.removeAll(name); }, /** * Resets the attribute (or all attributes) to its initial value, as long as * the attribute is not readOnly, or writeOnce. * * @method reset * @param {String} name Optional. The name of the attribute to reset. If omitted, all attributes are reset. * @return {Object} A reference to the host object. * @chainable */ reset : function(name) { var host = this; // help compression if (name) { if (host._isLazyAttr(name)) { host._addLazyAttr(name); } host.set(name, host._state.get(name, INIT_VALUE)); } else { Y.Object.each(host._state.data, function(v, n) { host.reset(n); }); } return host; }, /** * Returns an object with the configuration properties (and value) * for the given attribute. If attrName is not provided, returns the * configuration properties for all attributes. * * @method _getAttrCfg * @protected * @param {String} name Optional. The attribute name. If not provided, the method will return the configuration for all attributes. * @return {Object} The configuration properties for the given attribute, or all attributes. */ _getAttrCfg : function(name) { var o, state = this._state; if (name) { o = state.getAll(name) || {}; } else { o = {}; Y.each(state.data, function(v, n) { o[n] = state.getAll(n); }); } return o; } }; Y.AttributeExtras = AttributeExtras; }, '3.17.2', {"requires": ["oop"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('attribute-observable', function (Y, NAME) { /*For log lines*/ /*jshint maxlen:200*/ /** * The attribute module provides an augmentable Attribute implementation, which * adds configurable attributes and attribute change events to the class being * augmented. It also provides a State class, which is used internally by Attribute, * but can also be used independently to provide a name/property/value data structure to * store state. * * @module attribute */ /** * The `attribute-observable` submodule provides augmentable attribute change event support * for AttributeCore based implementations. * * @module attribute * @submodule attribute-observable */ var EventTarget = Y.EventTarget, CHANGE = "Change", BROADCAST = "broadcast"; /** * Provides an augmentable implementation of attribute change events for * AttributeCore. * * @class AttributeObservable * @extensionfor AttributeCore * @uses EventTarget */ function AttributeObservable() { // Perf tweak - avoid creating event literals if not required. this._ATTR_E_FACADE = {}; EventTarget.call(this, {emitFacade:true}); } AttributeObservable._ATTR_CFG = [BROADCAST]; AttributeObservable.prototype = { /** * Sets the value of an attribute. * * @method set * @chainable * * @param {String} name The name of the attribute. If the * current value of the attribute is an Object, dot notation can be used * to set the value of a property within the object (e.g. set("x.y.z", 5)). * * @param {Any} value The value to set the attribute to. * * @param {Object} opts (Optional) Optional event data to be mixed into * the event facade passed to subscribers of the attribute's change event. This * can be used as a flexible way to identify the source of a call to set, allowing * the developer to distinguish between set called internally by the host, vs. * set called externally by the application developer. * * @return {Object} A reference to the host object. */ set : function(name, val, opts) { return this._setAttr(name, val, opts); }, /** * Allows setting of readOnly/writeOnce attributes. See set for argument details. * * @method _set * @protected * @chainable * * @param {String} name The name of the attribute. * @param {Any} val The value to set the attribute to. * @param {Object} opts (Optional) Optional event data to be mixed into * the event facade passed to subscribers of the attribute's change event. * @return {Object} A reference to the host object. */ _set : function(name, val, opts) { return this._setAttr(name, val, opts, true); }, /** * Sets multiple attribute values. * * @method setAttrs * @param {Object} attrs An object with attributes name/value pairs. * @param {Object} opts Properties to mix into the event payload. These are shared and mixed into each set * @return {Object} A reference to the host object. * @chainable */ setAttrs : function(attrs, opts) { return this._setAttrs(attrs, opts); }, /** * Implementation behind the public setAttrs method, to set multiple attribute values. * * @method _setAttrs * @protected * @param {Object} attrs An object with attributes name/value pairs. * @param {Object} opts Properties to mix into the event payload. These are shared and mixed into each set * @return {Object} A reference to the host object. * @chainable */ _setAttrs : function(attrs, opts) { var attr; for (attr in attrs) { if ( attrs.hasOwnProperty(attr) ) { this.set(attr, attrs[attr], opts); } } return this; }, /** * Utility method to help setup the event payload and fire the attribute change event. * * @method _fireAttrChange * @private * @param {String} attrName The name of the attribute * @param {String} subAttrName The full path of the property being changed, * if this is a sub-attribute value being change. Otherwise null. * @param {Any} currVal The current value of the attribute * @param {Any} newVal The new value of the attribute * @param {Object} opts Any additional event data to mix into the attribute change event's event facade. * @param {Object} [cfg] The attribute config stored in State, if already available. */ _fireAttrChange : function(attrName, subAttrName, currVal, newVal, opts, cfg) { var host = this, eventName = this._getFullType(attrName + CHANGE), state = host._state, facade, broadcast, e; if (!cfg) { cfg = state.data[attrName] || {}; } if (!cfg.published) { // PERF: Using lower level _publish() for // critical path performance e = host._publish(eventName); e.emitFacade = true; e.defaultTargetOnly = true; e.defaultFn = host._defAttrChangeFn; broadcast = cfg.broadcast; if (broadcast !== undefined) { e.broadcast = broadcast; } cfg.published = true; } if (opts) { facade = Y.merge(opts); facade._attrOpts = opts; } else { facade = host._ATTR_E_FACADE; } // Not using the single object signature for fire({type:..., newVal:...}), since // we don't want to override type. Changed to the fire(type, {newVal:...}) signature. facade.attrName = attrName; facade.subAttrName = subAttrName; facade.prevVal = currVal; facade.newVal = newVal; if (host._hasPotentialSubscribers(eventName)) { host.fire(eventName, facade); } else { this._setAttrVal(attrName, subAttrName, currVal, newVal, opts, cfg); } }, /** * Default function for attribute change events. * * @private * @method _defAttrChangeFn * @param {EventFacade} e The event object for attribute change events. * @param {boolean} eventFastPath Whether or not we're using this as a fast path in the case of no listeners or not */ _defAttrChangeFn : function(e, eventFastPath) { var opts = e._attrOpts; if (opts) { delete e._attrOpts; } if (!this._setAttrVal(e.attrName, e.subAttrName, e.prevVal, e.newVal, opts)) { if (!eventFastPath) { // Prevent "after" listeners from being invoked since nothing changed. e.stopImmediatePropagation(); } } else { if (!eventFastPath) { e.newVal = this.get(e.attrName); } } } }; // Basic prototype augment - no lazy constructor invocation. Y.mix(AttributeObservable, EventTarget, false, null, 1); Y.AttributeObservable = AttributeObservable; /** The `AttributeEvents` class extension was deprecated in YUI 3.8.0 and is now an alias for the `AttributeObservable` class extension. Use that class extnesion instead. This alias will be removed in a future version of YUI. @class AttributeEvents @uses EventTarget @deprecated Use `AttributeObservable` instead. @see AttributeObservable **/ Y.AttributeEvents = AttributeObservable; }, '3.17.2', {"requires": ["event-custom"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('base-observable', function (Y, NAME) { /** The `base-observable` submodule adds observability to Base's lifecycle and attributes, and also make it an `EventTarget`. @module base @submodule base-observable **/ var L = Y.Lang, DESTROY = "destroy", INIT = "init", BUBBLETARGETS = "bubbleTargets", _BUBBLETARGETS = "_bubbleTargets", AttributeObservable = Y.AttributeObservable, BaseCore = Y.BaseCore; /** Provides an augmentable implementation of lifecycle and attribute events for `BaseCore`. @class BaseObservable @extensionfor BaseCore @uses AttributeObservable @uses EventTarget @since 3.8.0 **/ function BaseObservable() {} BaseObservable._ATTR_CFG = AttributeObservable._ATTR_CFG.concat(); BaseObservable._NON_ATTRS_CFG = ["on", "after", "bubbleTargets"]; BaseObservable.prototype = { /** * Initializes Attribute * * @method _initAttribute * @private */ _initAttribute: function() { BaseCore.prototype._initAttribute.apply(this, arguments); AttributeObservable.call(this); this._eventPrefix = this.constructor.EVENT_PREFIX || this.constructor.NAME; this._yuievt.config.prefix = this._eventPrefix; }, /** * Init lifecycle method, invoked during construction. * Fires the init event prior to setting up attributes and * invoking initializers for the class hierarchy. * * @method init * @chainable * @param {Object} config Object with configuration property name/value pairs * @return {Base} A reference to this object */ init: function(config) { /** *

* Lifecycle event for the init phase, fired prior to initialization. * Invoking the preventDefault() method on the event object provided * to subscribers will prevent initialization from occuring. *

*

* Subscribers to the "after" momemt of this event, will be notified * after initialization of the object is complete (and therefore * cannot prevent initialization). *

* * @event init * @preventable _defInitFn * @param {EventFacade} e Event object, with a cfg property which * refers to the configuration object passed to the constructor. */ // PERF: Using lower level _publish() for // critical path performance var type = this._getFullType(INIT), e = this._publish(type); e.emitFacade = true; e.fireOnce = true; e.defaultTargetOnly = true; e.defaultFn = this._defInitFn; this._preInitEventCfg(config); if (e._hasPotentialSubscribers()) { this.fire(type, {cfg: config}); } else { this._baseInit(config); // HACK. Major hack actually. But really fast for no-listeners. // Since it's fireOnce, subscribers may come along later, so since we're // bypassing the event stack the first time, we need to tell the published // event that it's been "fired". Could extract it into a CE method? e.fired = true; e.firedWith = [{cfg:config}]; } return this; }, /** * Handles the special on, after and target properties which allow the user to * easily configure on and after listeners as well as bubble targets during * construction, prior to init. * * @private * @method _preInitEventCfg * @param {Object} config The user configuration object */ _preInitEventCfg : function(config) { if (config) { if (config.on) { this.on(config.on); } if (config.after) { this.after(config.after); } } var i, l, target, userTargets = (config && BUBBLETARGETS in config); if (userTargets || _BUBBLETARGETS in this) { target = userTargets ? (config && config.bubbleTargets) : this._bubbleTargets; if (L.isArray(target)) { for (i = 0, l = target.length; i < l; i++) { this.addTarget(target[i]); } } else if (target) { this.addTarget(target); } } }, /** *

* Destroy lifecycle method. Fires the destroy * event, prior to invoking destructors for the * class hierarchy. *

*

* Subscribers to the destroy * event can invoke preventDefault on the event object, to prevent destruction * from proceeding. *

* @method destroy * @return {Base} A reference to this object * @chainable */ destroy: function() { /** *

* Lifecycle event for the destroy phase, * fired prior to destruction. Invoking the preventDefault * method on the event object provided to subscribers will * prevent destruction from proceeding. *

*

* Subscribers to the "after" moment of this event, will be notified * after destruction is complete (and as a result cannot prevent * destruction). *

* @event destroy * @preventable _defDestroyFn * @param {EventFacade} e Event object */ this.publish(DESTROY, { fireOnce:true, defaultTargetOnly:true, defaultFn: this._defDestroyFn }); this.fire(DESTROY); this.detachAll(); return this; }, /** * Default init event handler * * @method _defInitFn * @param {EventFacade} e Event object, with a cfg property which * refers to the configuration object passed to the constructor. * @protected */ _defInitFn : function(e) { this._baseInit(e.cfg); }, /** * Default destroy event handler * * @method _defDestroyFn * @param {EventFacade} e Event object * @protected */ _defDestroyFn : function(e) { this._baseDestroy(e.cfg); } }; Y.mix(BaseObservable, AttributeObservable, false, null, 1); Y.BaseObservable = BaseObservable; }, '3.17.2', {"requires": ["attribute-observable", "base-core"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('base-base', function (Y, NAME) { /** * The base module provides the Base class, which objects requiring attribute and custom event support can extend. * The module also provides two ways to reuse code - It augments Base with the Plugin.Host interface which provides * plugin support and also provides the BaseCore.build method which provides a way to build custom classes using extensions. * * @module base */ /** * The base-base submodule provides the Base class without the Plugin support, provided by Plugin.Host, * and without the extension support provided by BaseCore.build. * * @module base * @submodule base-base */ var AttributeCore = Y.AttributeCore, AttributeExtras = Y.AttributeExtras, BaseCore = Y.BaseCore, BaseObservable = Y.BaseObservable; /** *

* A base class which objects requiring attributes and custom event support can * extend. Base also handles the chaining of initializer and destructor methods across * the hierarchy as part of object construction and destruction. Additionally, attributes configured * through the static ATTRS property for each class * in the hierarchy will be initialized by Base. *

* *

* **NOTE:** Prior to version 3.11.0, ATTRS would get added a class at a time. That is, * Base would loop through each class in the hierarchy, and add the class' ATTRS, and * then call it's initializer, and move on to the subclass' ATTRS and initializer. As of * 3.11.0, ATTRS from all classes in the hierarchy are added in one `addAttrs` call before * any initializers are called. This fixes subtle edge-case issues with subclass ATTRS overriding * superclass `setter`, `getter` or `valueFn` definitions and being unable to get/set attributes * defined by the subclass. This order of operation change may impact `setter`, `getter` or `valueFn` * code which expects a superclass' initializer to have run. This is expected to be rare, but to support * it, Base supports a `_preAddAttrs()`, method hook (same signature as `addAttrs`). Components can * implement this method on their prototype for edge cases which do require finer control over * the order in which attributes are added (see widget-htmlparser). *

* *

* The static NAME property of each class extending * from Base will be used as the identifier for the class, and is used by Base to prefix * all events fired by instances of that class. *

* * @class Base * @constructor * @uses BaseCore * @uses BaseObservable * @uses AttributeCore * @uses AttributeObservable * @uses AttributeExtras * @uses EventTarget * * @param {Object} config Object with configuration property name/value pairs. The object can be * used to provide default values for the objects published attributes. * *

* The config object can also contain the following non-attribute properties, providing a convenient * way to configure events listeners and plugins for the instance, as part of the constructor call: *

* *
*
on
*
An event name to listener function map, to register event listeners for the "on" moment of the event. * A constructor convenience property for the on method.
*
after
*
An event name to listener function map, to register event listeners for the "after" moment of the event. * A constructor convenience property for the after method.
*
bubbleTargets
*
An object, or array of objects, to register as bubble targets for bubbled events fired by this instance. * A constructor convenience property for the addTarget method.
*
plugins
*
A plugin, or array of plugins to be plugged into the instance (see PluginHost's plug method for signature details). * A constructor convenience property for the plug method.
*
*/ function Base() { BaseCore.apply(this, arguments); BaseObservable.apply(this, arguments); AttributeExtras.apply(this, arguments); } /** * The list of properties which can be configured for * each attribute (e.g. setter, getter, writeOnce, readOnly etc.) * * @property _ATTR_CFG * @type Array * @static * @private */ Base._ATTR_CFG = BaseCore._ATTR_CFG.concat(BaseObservable._ATTR_CFG); /** * The array of non-attribute configuration properties supported by this class. * * `Base` supports "on", "after", "plugins" and "bubbleTargets" properties, * which are not set up as attributes. * * This property is primarily required so that when * `_allowAdHocAttrs` is enabled by * a class, non-attribute configurations don't get added as ad-hoc attributes. * * @property _NON_ATTRS_CFG * @type Array * @static * @private */ Base._NON_ATTRS_CFG = BaseCore._NON_ATTRS_CFG.concat(BaseObservable._NON_ATTRS_CFG); /** *

* The string to be used to identify instances of * this class, for example in prefixing events. *

*

* Classes extending Base, should define their own * static NAME property, which should be camelCase by * convention (e.g. MyClass.NAME = "myClass";). *

* @property NAME * @type String * @static */ Base.NAME = 'base'; /** * The default set of attributes which will be available for instances of this class, and * their configuration. In addition to the configuration properties listed by * Attribute's addAttr method, the attribute * can also be configured with a "cloneDefaultValue" property, which defines how the statically * defined value field should be protected ("shallow", "deep" and false are supported values). * * By default if the value is an object literal or an array it will be "shallow" cloned, to * protect the default value. * * @property ATTRS * @type Object * @static */ Base.ATTRS = AttributeCore.protectAttrs(BaseCore.ATTRS); /** Provides a way to safely modify a `Y.Base` subclass' static `ATTRS` after the class has been defined or created. Base-based classes cache information about the class hierarchy in order to efficiently create instances. This cache includes includes the aggregated `ATTRS` configs. If the static `ATTRS` configs need to be modified after the class has been defined or create, then use this method which will make sure to clear any cached data before making any modifications. @method modifyAttrs @param {Function} [ctor] The constructor function whose `ATTRS` should be modified. If a `ctor` function is not specified, then `this` is assumed to be the constructor which hosts the `ATTRS`. @param {Object} configs The collection of `ATTRS` configs to mix with the existing attribute configurations. @static @since 3.10.0 **/ Base.modifyAttrs = BaseCore.modifyAttrs; Y.mix(Base, BaseCore, false, null, 1); Y.mix(Base, AttributeExtras, false, null, 1); // Needs to be `true`, to overwrite methods from `BaseCore`. Y.mix(Base, BaseObservable, true, null, 1); // Fix constructor Base.prototype.constructor = Base; Y.Base = Base; }, '3.17.2', {"requires": ["attribute-base", "base-core", "base-observable"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('base-pluginhost', function (Y, NAME) { /** * The base-pluginhost submodule adds Plugin support to Base, by augmenting Base with * Plugin.Host and setting up static (class level) Base.plug and Base.unplug methods. * * @module base * @submodule base-pluginhost * @for Base */ var Base = Y.Base, PluginHost = Y.Plugin.Host; Y.mix(Base, PluginHost, false, null, 1); /** * Alias for Plugin.Host.plug. See aliased * method for argument and return value details. * * @method plug * @static */ Base.plug = PluginHost.plug; /** * Alias for Plugin.Host.unplug. See the * aliased method for argument and return value details. * * @method unplug * @static */ Base.unplug = PluginHost.unplug; }, '3.17.2', {"requires": ["base-base", "pluginhost"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('base-build', function (Y, NAME) { /** * The base-build submodule provides Base.build functionality, which * can be used to create custom classes, by aggregating extensions onto * a main class. * * @module base * @submodule base-build * @for Base */ var BaseCore = Y.BaseCore, Base = Y.Base, L = Y.Lang, INITIALIZER = "initializer", DESTRUCTOR = "destructor", AGGREGATES = ["_PLUG", "_UNPLUG"], build; // Utility function used in `_buildCfg` to aggregate array values into a new // array from the sender constructor to the receiver constructor. function arrayAggregator(prop, r, s) { if (s[prop]) { r[prop] = (r[prop] || []).concat(s[prop]); } } // Utility function used in `_buildCfg` to aggregate `_ATTR_CFG` array // values from the sender constructor into a new array on receiver's // constructor, and clear the cached hash. function attrCfgAggregator(prop, r, s) { if (s._ATTR_CFG) { // Clear cached hash. r._ATTR_CFG_HASH = null; arrayAggregator.apply(null, arguments); } } // Utility function used in `_buildCfg` to aggregate ATTRS configs from one // the sender constructor to the receiver constructor. function attrsAggregator(prop, r, s) { BaseCore.modifyAttrs(r, s.ATTRS); } Base._build = function(name, main, extensions, px, sx, cfg) { var build = Base._build, builtClass = build._ctor(main, cfg), buildCfg = build._cfg(main, cfg, extensions), _mixCust = build._mixCust, dynamic = builtClass._yuibuild.dynamic, i, l, extClass, extProto, initializer, destructor; // Augment/Aggregate for (i = 0, l = extensions.length; i < l; i++) { extClass = extensions[i]; extProto = extClass.prototype; initializer = extProto[INITIALIZER]; destructor = extProto[DESTRUCTOR]; delete extProto[INITIALIZER]; delete extProto[DESTRUCTOR]; // Prototype, old non-displacing augment Y.mix(builtClass, extClass, true, null, 1); // Custom Statics _mixCust(builtClass, extClass, buildCfg); if (initializer) { extProto[INITIALIZER] = initializer; } if (destructor) { extProto[DESTRUCTOR] = destructor; } builtClass._yuibuild.exts.push(extClass); } if (px) { Y.mix(builtClass.prototype, px, true); } if (sx) { Y.mix(builtClass, build._clean(sx, buildCfg), true); _mixCust(builtClass, sx, buildCfg); } builtClass.prototype.hasImpl = build._impl; if (dynamic) { builtClass.NAME = name; builtClass.prototype.constructor = builtClass; // Carry along the reference to `modifyAttrs()` from `main`. builtClass.modifyAttrs = main.modifyAttrs; } return builtClass; }; build = Base._build; Y.mix(build, { _mixCust: function(r, s, cfg) { var aggregates, custom, statics, aggr, l, i; if (cfg) { aggregates = cfg.aggregates; custom = cfg.custom; statics = cfg.statics; } if (statics) { Y.mix(r, s, true, statics); } if (aggregates) { for (i = 0, l = aggregates.length; i < l; i++) { aggr = aggregates[i]; if (!r.hasOwnProperty(aggr) && s.hasOwnProperty(aggr)) { r[aggr] = L.isArray(s[aggr]) ? [] : {}; } Y.aggregate(r, s, true, [aggr]); } } if (custom) { for (i in custom) { if (custom.hasOwnProperty(i)) { custom[i](i, r, s); } } } }, _tmpl: function(main) { function BuiltClass() { BuiltClass.superclass.constructor.apply(this, arguments); } Y.extend(BuiltClass, main); return BuiltClass; }, _impl : function(extClass) { var classes = this._getClasses(), i, l, cls, exts, ll, j; for (i = 0, l = classes.length; i < l; i++) { cls = classes[i]; if (cls._yuibuild) { exts = cls._yuibuild.exts; ll = exts.length; for (j = 0; j < ll; j++) { if (exts[j] === extClass) { return true; } } } } return false; }, _ctor : function(main, cfg) { var dynamic = (cfg && false === cfg.dynamic) ? false : true, builtClass = (dynamic) ? build._tmpl(main) : main, buildCfg = builtClass._yuibuild; if (!buildCfg) { buildCfg = builtClass._yuibuild = {}; } buildCfg.id = buildCfg.id || null; buildCfg.exts = buildCfg.exts || []; buildCfg.dynamic = dynamic; return builtClass; }, _cfg : function(main, cfg, exts) { var aggr = [], cust = {}, statics = [], buildCfg, cfgAggr = (cfg && cfg.aggregates), cfgCustBuild = (cfg && cfg.custom), cfgStatics = (cfg && cfg.statics), c = main, i, l; // Prototype Chain while (c && c.prototype) { buildCfg = c._buildCfg; if (buildCfg) { if (buildCfg.aggregates) { aggr = aggr.concat(buildCfg.aggregates); } if (buildCfg.custom) { Y.mix(cust, buildCfg.custom, true); } if (buildCfg.statics) { statics = statics.concat(buildCfg.statics); } } c = c.superclass ? c.superclass.constructor : null; } // Exts if (exts) { for (i = 0, l = exts.length; i < l; i++) { c = exts[i]; buildCfg = c._buildCfg; if (buildCfg) { if (buildCfg.aggregates) { aggr = aggr.concat(buildCfg.aggregates); } if (buildCfg.custom) { Y.mix(cust, buildCfg.custom, true); } if (buildCfg.statics) { statics = statics.concat(buildCfg.statics); } } } } if (cfgAggr) { aggr = aggr.concat(cfgAggr); } if (cfgCustBuild) { Y.mix(cust, cfg.cfgBuild, true); } if (cfgStatics) { statics = statics.concat(cfgStatics); } return { aggregates: aggr, custom: cust, statics: statics }; }, _clean : function(sx, cfg) { var prop, i, l, sxclone = Y.merge(sx), aggregates = cfg.aggregates, custom = cfg.custom; for (prop in custom) { if (sxclone.hasOwnProperty(prop)) { delete sxclone[prop]; } } for (i = 0, l = aggregates.length; i < l; i++) { prop = aggregates[i]; if (sxclone.hasOwnProperty(prop)) { delete sxclone[prop]; } } return sxclone; } }); /** *

* Builds a custom constructor function (class) from the * main function, and array of extension functions (classes) * provided. The NAME field for the constructor function is * defined by the first argument passed in. *

*

* The cfg object supports the following properties *

*
*
dynamic <boolean>
*
*

If true (default), a completely new class * is created which extends the main class, and acts as the * host on which the extension classes are augmented.

*

If false, the extensions classes are augmented directly to * the main class, modifying the main class' prototype.

*
*
aggregates <String[]>
*
An array of static property names, which will get aggregated * on to the built class, in addition to the default properties build * will always aggregate as defined by the main class' static _buildCfg * property. *
*
* * @method build * @deprecated Use the more convenient Base.create and Base.mix methods instead * @static * @param {Function} name The name of the new class. Used to define the NAME property for the new class. * @param {Function} main The main class on which to base the built class * @param {Function[]} extensions The set of extension classes which will be * augmented/aggregated to the built class. * @param {Object} cfg Optional. Build configuration for the class (see description). * @return {Function} A custom class, created from the provided main and extension classes */ Base.build = function(name, main, extensions, cfg) { return build(name, main, extensions, null, null, cfg); }; /** * Creates a new class (constructor function) which extends the base class passed in as the second argument, * and mixes in the array of extensions provided. * * Prototype properties or methods can be added to the new class, using the px argument (similar to Y.extend). * * Static properties or methods can be added to the new class, using the sx argument (similar to Y.extend). * * **NOTE FOR COMPONENT DEVELOPERS**: Both the `base` class, and `extensions` can define static a `_buildCfg` * property, which acts as class creation meta-data, and drives how special static properties from the base * class, or extensions should be copied, aggregated or (custom) mixed into the newly created class. * * The `_buildCfg` property is a hash with 3 supported properties: `statics`, `aggregates` and `custom`, e.g: * * // If the Base/Main class is the thing introducing the property: * * MyBaseClass._buildCfg = { * * // Static properties/methods to copy (Alias) to the built class. * statics: ["CopyThisMethod", "CopyThisProperty"], * * // Static props to aggregate onto the built class. * aggregates: ["AggregateThisProperty"], * * // Static properties which need custom handling (e.g. deep merge etc.) * custom: { * "CustomProperty" : function(property, Receiver, Supplier) { * ... * var triggers = Receiver.CustomProperty.triggers; * Receiver.CustomProperty.triggers = triggers.concat(Supplier.CustomProperty.triggers); * ... * } * } * }; * * MyBaseClass.CopyThisMethod = function() {...}; * MyBaseClass.CopyThisProperty = "foo"; * MyBaseClass.AggregateThisProperty = {...}; * MyBaseClass.CustomProperty = { * triggers: [...] * } * * // Or, if the Extension is the thing introducing the property: * * MyExtension._buildCfg = { * statics : ... * aggregates : ... * custom : ... * } * * This way, when users pass your base or extension class to `Y.Base.create` or `Y.Base.mix`, they don't need to * know which properties need special handling. `Y.Base` has a buildCfg which defines `ATTRS` for custom mix handling * (to protect the static config objects), and `Y.Widget` has a buildCfg which specifies `HTML_PARSER` for * straight up aggregation. * * @method create * @static * @param {String} name The name of the newly created class. Used to define the NAME property for the new class. * @param {Function} main The base class which the new class should extend. * This class needs to be Base or a class derived from base (e.g. Widget). * @param {Function[]} extensions The list of extensions which will be mixed into the built class. * @param {Object} px The set of prototype properties/methods to add to the built class. * @param {Object} sx The set of static properties/methods to add to the built class. * @return {Function} The newly created class. */ Base.create = function(name, base, extensions, px, sx) { return build(name, base, extensions, px, sx); }; /** *

Mixes in a list of extensions to an existing class.

* @method mix * @static * @param {Function} main The existing class into which the extensions should be mixed. * The class needs to be Base or a class derived from Base (e.g. Widget) * @param {Function[]} extensions The set of extension classes which will mixed into the existing main class. * @return {Function} The modified main class, with extensions mixed in. */ Base.mix = function(main, extensions) { if (main._CACHED_CLASS_DATA) { main._CACHED_CLASS_DATA = null; } return build(null, main, extensions, null, null, {dynamic:false}); }; /** * The build configuration for the Base class. * * Defines the static fields which need to be aggregated when the Base class * is used as the main class passed to the * Base.build method. * * @property _buildCfg * @type Object * @static * @final * @private */ BaseCore._buildCfg = { aggregates: AGGREGATES.concat(), custom: { ATTRS : attrsAggregator, _ATTR_CFG : attrCfgAggregator, _NON_ATTRS_CFG: arrayAggregator } }; // Makes sure Base and BaseCore use separate `_buildCfg` objects. Base._buildCfg = { aggregates: AGGREGATES.concat(), custom: { ATTRS : attrsAggregator, _ATTR_CFG : attrCfgAggregator, _NON_ATTRS_CFG: arrayAggregator } }; }, '3.17.2', {"requires": ["base-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('event-synthetic', function (Y, NAME) { /** * Define new DOM events that can be subscribed to from Nodes. * * @module event * @submodule event-synthetic */ var CustomEvent = Y.CustomEvent, DOMMap = Y.Env.evt.dom_map, toArray = Y.Array, YLang = Y.Lang, isObject = YLang.isObject, isString = YLang.isString, isArray = YLang.isArray, query = Y.Selector.query, noop = function () {}; /** *

The triggering mechanism used by SyntheticEvents.

* *

Implementers should not instantiate these directly. Use the Notifier * provided to the event's implemented on(node, sub, notifier) or * delegate(node, sub, notifier, filter) methods.

* * @class SyntheticEvent.Notifier * @constructor * @param handle {EventHandle} the detach handle for the subscription to an * internal custom event used to execute the callback passed to * on(..) or delegate(..) * @param emitFacade {Boolean} take steps to ensure the first arg received by * the subscription callback is an event facade * @private * @since 3.2.0 */ function Notifier(handle, emitFacade) { this.handle = handle; this.emitFacade = emitFacade; } /** *

Executes the subscription callback, passing the firing arguments as the * first parameters to that callback. For events that are configured with * emitFacade=true, it is common practice to pass the triggering DOMEventFacade * as the first parameter. Barring a proper DOMEventFacade or EventFacade * (from a CustomEvent), a new EventFacade will be generated. In that case, if * fire() is called with a simple object, it will be mixed into the facade. * Otherwise, the facade will be prepended to the callback parameters.

* *

For notifiers provided to delegate logic, the first argument should be an * object with a "currentTarget" property to identify what object to * default as 'this' in the callback. Typically this is gleaned from the * DOMEventFacade or EventFacade, but if configured with emitFacade=false, an * object must be provided. In that case, the object will be removed from the * callback parameters.

* *

Additional arguments passed during event subscription will be * automatically added after those passed to fire().

* * @method fire * @param {EventFacade|DOMEventFacade|any} e (see description) * @param {any[]} [arg*] additional arguments received by all subscriptions * @private */ Notifier.prototype.fire = function (e) { // first arg to delegate notifier should be an object with currentTarget var args = toArray(arguments, 0, true), handle = this.handle, ce = handle.evt, sub = handle.sub, thisObj = sub.context, delegate = sub.filter, event = e || {}, ret; if (this.emitFacade) { if (!e || !e.preventDefault) { event = ce._getFacade(); if (isObject(e) && !e.preventDefault) { Y.mix(event, e, true); args[0] = event; } else { args.unshift(event); } } event.type = ce.type; event.details = args.slice(); if (delegate) { event.container = ce.host; } } else if (delegate && isObject(e) && e.currentTarget) { args.shift(); } sub.context = thisObj || event.currentTarget || ce.host; ret = ce.fire.apply(ce, args); // have to handle preventedFn and stoppedFn manually because // Notifier CustomEvents are forced to emitFacade=false if (e.prevented && ce.preventedFn) { ce.preventedFn.apply(ce, args); } if (e.stopped && ce.stoppedFn) { ce.stoppedFn.apply(ce, args); } sub.context = thisObj; // reset for future firing // to capture callbacks that return false to stopPropagation. // Useful for delegate implementations return ret; }; /** * Manager object for synthetic event subscriptions to aggregate multiple synths on the * same node without colliding with actual DOM subscription entries in the global map of * DOM subscriptions. Also facilitates proper cleanup on page unload. * * @class SynthRegistry * @constructor * @param el {HTMLElement} the DOM element * @param yuid {String} the yuid stamp for the element * @param key {String} the generated id token used to identify an event type + * element in the global DOM subscription map. * @private */ function SynthRegistry(el, yuid, key) { this.handles = []; this.el = el; this.key = key; this.domkey = yuid; } SynthRegistry.prototype = { constructor: SynthRegistry, // A few object properties to fake the CustomEvent interface for page // unload cleanup. DON'T TOUCH! type : '_synth', fn : noop, capture : false, /** * Adds a subscription from the Notifier registry. * * @method register * @param handle {EventHandle} the subscription * @since 3.4.0 */ register: function (handle) { handle.evt.registry = this; this.handles.push(handle); }, /** * Removes the subscription from the Notifier registry. * * @method _unregisterSub * @param sub {Subscription} the subscription * @since 3.4.0 */ unregister: function (sub) { var handles = this.handles, events = DOMMap[this.domkey], i; for (i = handles.length - 1; i >= 0; --i) { if (handles[i].sub === sub) { handles.splice(i, 1); break; } } // Clean up left over objects when there are no more subscribers. if (!handles.length) { delete events[this.key]; if (!Y.Object.size(events)) { delete DOMMap[this.domkey]; } } }, /** * Used by the event system's unload cleanup process. When navigating * away from the page, the event system iterates the global map of element * subscriptions and detaches everything using detachAll(). Normally, * the map is populated with custom events, so this object needs to * at least support the detachAll method to duck type its way to * cleanliness. * * @method detachAll * @private * @since 3.4.0 */ detachAll : function () { var handles = this.handles, i = handles.length; while (--i >= 0) { handles[i].detach(); } } }; /** *

Wrapper class for the integration of new events into the YUI event * infrastructure. Don't instantiate this object directly, use * Y.Event.define(type, config). See that method for details.

* *

Properties that MAY or SHOULD be specified in the configuration are noted * below and in the description of Y.Event.define.

* * @class SyntheticEvent * @constructor * @param cfg {Object} Implementation pieces and configuration * @since 3.1.0 * @in event-synthetic */ function SyntheticEvent() { this._init.apply(this, arguments); } Y.mix(SyntheticEvent, { Notifier: Notifier, SynthRegistry: SynthRegistry, /** * Returns the array of subscription handles for a node for the given event * type. Passing true as the third argument will create a registry entry * in the event system's DOM map to host the array if one doesn't yet exist. * * @method getRegistry * @param node {Node} the node * @param type {String} the event * @param create {Boolean} create a registration entry to host a new array * if one doesn't exist. * @return {Array} * @static * @protected * @since 3.2.0 */ getRegistry: function (node, type, create) { var el = node._node, yuid = Y.stamp(el), key = 'event:' + yuid + type + '_synth', events = DOMMap[yuid]; if (create) { if (!events) { events = DOMMap[yuid] = {}; } if (!events[key]) { events[key] = new SynthRegistry(el, yuid, key); } } return (events && events[key]) || null; }, /** * Alternate _delete() method for the CustomEvent object * created to manage SyntheticEvent subscriptions. * * @method _deleteSub * @param sub {Subscription} the subscription to clean up * @private * @since 3.2.0 */ _deleteSub: function (sub) { if (sub && sub.fn) { var synth = this.eventDef, method = (sub.filter) ? 'detachDelegate' : 'detach'; this._subscribers = []; if (CustomEvent.keepDeprecatedSubs) { this.subscribers = {}; } synth[method](sub.node, sub, this.notifier, sub.filter); this.registry.unregister(sub); delete sub.fn; delete sub.node; delete sub.context; } }, prototype: { constructor: SyntheticEvent, /** * Construction logic for the event. * * @method _init * @protected */ _init: function () { var config = this.publishConfig || (this.publishConfig = {}); // The notification mechanism handles facade creation this.emitFacade = ('emitFacade' in config) ? config.emitFacade : true; config.emitFacade = false; }, /** *

Implementers MAY provide this method definition.

* *

Implement this function if the event supports a different * subscription signature. This function is used by both * on() and delegate(). The second parameter * indicates that the event is being subscribed via * delegate().

* *

Implementations must remove extra arguments from the args list * before returning. The required args for on() * subscriptions are

*
[type, callback, target, context, argN...]
* *

The required args for delegate() * subscriptions are

* *
[type, callback, target, filter, context, argN...]
* *

The return value from this function will be stored on the * subscription in the '_extra' property for reference elsewhere.

* * @method processArgs * @param args {Array} parmeters passed to Y.on(..) or Y.delegate(..) * @param delegate {Boolean} true if the subscription is from Y.delegate * @return {any} */ processArgs: noop, /** *

Implementers MAY override this property.

* *

Whether to prevent multiple subscriptions to this event that are * classified as being the same. By default, this means the subscribed * callback is the same function. See the subMatch * method. Setting this to true will impact performance for high volume * events.

* * @property preventDups * @type {Boolean} * @default false */ //preventDups : false, /** *

Implementers SHOULD provide this method definition.

* * Implementation logic for subscriptions done via node.on(type, * fn) or Y.on(type, fn, target). This * function should set up the monitor(s) that will eventually fire the * event. Typically this involves subscribing to at least one DOM * event. It is recommended to store detach handles from any DOM * subscriptions to make for easy cleanup in the detach * method. Typically these handles are added to the sub * object. Also for SyntheticEvents that leverage a single DOM * subscription under the hood, it is recommended to pass the DOM event * object to notifier.fire(e). (The event name on the * object will be updated). * * @method on * @param node {Node} the node the subscription is being applied to * @param sub {Subscription} the object to track this subscription * @param notifier {SyntheticEvent.Notifier} call notifier.fire(..) to * trigger the execution of the subscribers */ on: noop, /** *

Implementers SHOULD provide this method definition.

* *

Implementation logic for detaching subscriptions done via * node.on(type, fn). This function should clean up any * subscriptions made in the on() phase.

* * @method detach * @param node {Node} the node the subscription was applied to * @param sub {Subscription} the object tracking this subscription * @param notifier {SyntheticEvent.Notifier} the Notifier used to * trigger the execution of the subscribers */ detach: noop, /** *

Implementers SHOULD provide this method definition.

* *

Implementation logic for subscriptions done via * node.delegate(type, fn, filter) or * Y.delegate(type, fn, container, filter). Like with * on() above, this function should monitor the environment * for the event being fired, and trigger subscription execution by * calling notifier.fire(e).

* *

This function receives a fourth argument, which is the filter * used to identify which Node's are of interest to the subscription. * The filter will be either a boolean function that accepts a target * Node for each hierarchy level as the event bubbles, or a selector * string. To translate selector strings into filter functions, use * Y.delegate.compileFilter(filter).

* * @method delegate * @param node {Node} the node the subscription is being applied to * @param sub {Subscription} the object to track this subscription * @param notifier {SyntheticEvent.Notifier} call notifier.fire(..) to * trigger the execution of the subscribers * @param filter {String|Function} Selector string or function that * accepts an event object and returns null, a Node, or an * array of Nodes matching the criteria for processing. * @since 3.2.0 */ delegate : noop, /** *

Implementers SHOULD provide this method definition.

* *

Implementation logic for detaching subscriptions done via * node.delegate(type, fn, filter) or * Y.delegate(type, fn, container, filter). This function * should clean up any subscriptions made in the * delegate() phase.

* * @method detachDelegate * @param node {Node} the node the subscription was applied to * @param sub {Subscription} the object tracking this subscription * @param notifier {SyntheticEvent.Notifier} the Notifier used to * trigger the execution of the subscribers * @param filter {String|Function} Selector string or function that * accepts an event object and returns null, a Node, or an * array of Nodes matching the criteria for processing. * @since 3.2.0 */ detachDelegate : noop, /** * Sets up the boilerplate for detaching the event and facilitating the * execution of subscriber callbacks. * * @method _on * @param args {Array} array of arguments passed to * Y.on(...) or Y.delegate(...) * @param delegate {Boolean} true if called from * Y.delegate(...) * @return {EventHandle} the detach handle for this subscription * @private * since 3.2.0 */ _on: function (args, delegate) { var handles = [], originalArgs = args.slice(), extra = this.processArgs(args, delegate), selector = args[2], method = delegate ? 'delegate' : 'on', nodes, handle; // Can't just use Y.all because it doesn't support window (yet?) nodes = (isString(selector)) ? query(selector) : toArray(selector || Y.one(Y.config.win)); if (!nodes.length && isString(selector)) { handle = Y.on('available', function () { Y.mix(handle, Y[method].apply(Y, originalArgs), true); }, selector); return handle; } Y.Array.each(nodes, function (node) { var subArgs = args.slice(), filter; node = Y.one(node); if (node) { if (delegate) { filter = subArgs.splice(3, 1)[0]; } // (type, fn, el, thisObj, ...) => (fn, thisObj, ...) subArgs.splice(0, 4, subArgs[1], subArgs[3]); if (!this.preventDups || !this.getSubs(node, args, null, true)) { handles.push(this._subscribe(node, method, subArgs, extra, filter)); } } }, this); return (handles.length === 1) ? handles[0] : new Y.EventHandle(handles); }, /** * Creates a new Notifier object for use by this event's * on(...) or delegate(...) implementation * and register the custom event proxy in the DOM system for cleanup. * * @method _subscribe * @param node {Node} the Node hosting the event * @param method {String} "on" or "delegate" * @param args {Array} the subscription arguments passed to either * Y.on(...) or Y.delegate(...) * after running through processArgs(args) to * normalize the argument signature * @param extra {any} Extra data parsed from * processArgs(args) * @param filter {String|Function} the selector string or function * filter passed to Y.delegate(...) (not * present when called from Y.on(...)) * @return {EventHandle} * @private * @since 3.2.0 */ _subscribe: function (node, method, args, extra, filter) { var dispatcher = new Y.CustomEvent(this.type, this.publishConfig), handle = dispatcher.on.apply(dispatcher, args), notifier = new Notifier(handle, this.emitFacade), registry = SyntheticEvent.getRegistry(node, this.type, true), sub = handle.sub; sub.node = node; sub.filter = filter; if (extra) { this.applyArgExtras(extra, sub); } Y.mix(dispatcher, { eventDef : this, notifier : notifier, host : node, // I forget what this is for currentTarget: node, // for generating facades target : node, // for generating facades el : node._node, // For category detach _delete : SyntheticEvent._deleteSub }, true); handle.notifier = notifier; registry.register(handle); // Call the implementation's "on" or "delegate" method this[method](node, sub, notifier, filter); return handle; }, /** *

Implementers MAY provide this method definition.

* *

Implement this function if you want extra data extracted during * processArgs to be propagated to subscriptions on a per-node basis. * That is to say, if you call Y.on('xyz', fn, xtra, 'div') * the data returned from processArgs will be shared * across the subscription objects for all the divs. If you want each * subscription to receive unique information, do that processing * here.

* *

The default implementation adds the data extracted by processArgs * to the subscription object as sub._extra.

* * @method applyArgExtras * @param extra {any} Any extra data extracted from processArgs * @param sub {Subscription} the individual subscription */ applyArgExtras: function (extra, sub) { sub._extra = extra; }, /** * Removes the subscription(s) from the internal subscription dispatch * mechanism. See SyntheticEvent._deleteSub. * * @method _detach * @param args {Array} The arguments passed to * node.detach(...) * @private * @since 3.2.0 */ _detach: function (args) { // Can't use Y.all because it doesn't support window (yet?) // TODO: Does Y.all support window now? var target = args[2], els = (isString(target)) ? query(target) : toArray(target), node, i, len, handles, j; // (type, fn, el, context, filter?) => (type, fn, context, filter?) args.splice(2, 1); for (i = 0, len = els.length; i < len; ++i) { node = Y.one(els[i]); if (node) { handles = this.getSubs(node, args); if (handles) { for (j = handles.length - 1; j >= 0; --j) { handles[j].detach(); } } } } }, /** * Returns the detach handles of subscriptions on a node that satisfy a * search/filter function. By default, the filter used is the * subMatch method. * * @method getSubs * @param node {Node} the node hosting the event * @param args {Array} the array of original subscription args passed * to Y.on(...) (before * processArgs * @param filter {Function} function used to identify a subscription * for inclusion in the returned array * @param first {Boolean} stop after the first match (used to check for * duplicate subscriptions) * @return {EventHandle[]} detach handles for the matching subscriptions */ getSubs: function (node, args, filter, first) { var registry = SyntheticEvent.getRegistry(node, this.type), handles = [], allHandles, i, len, handle; if (registry) { allHandles = registry.handles; if (!filter) { filter = this.subMatch; } for (i = 0, len = allHandles.length; i < len; ++i) { handle = allHandles[i]; if (filter.call(this, handle.sub, args)) { if (first) { return handle; } else { handles.push(allHandles[i]); } } } } return handles.length && handles; }, /** *

Implementers MAY override this to define what constitutes a * "same" subscription. Override implementations should * consider the lack of a comparator as a match, so calling * getSubs() with no arguments will return all subs.

* *

Compares a set of subscription arguments against a Subscription * object to determine if they match. The default implementation * compares the callback function against the second argument passed to * Y.on(...) or node.detach(...) etc.

* * @method subMatch * @param sub {Subscription} the existing subscription * @param args {Array} the calling arguments passed to * Y.on(...) etc. * @return {Boolean} true if the sub can be described by the args * present * @since 3.2.0 */ subMatch: function (sub, args) { // Default detach cares only about the callback matching return !args[1] || sub.fn === args[1]; } } }, true); Y.SyntheticEvent = SyntheticEvent; /** *

Defines a new event in the DOM event system. Implementers are * responsible for monitoring for a scenario whereby the event is fired. A * notifier object is provided to the functions identified below. When the * criteria defining the event are met, call notifier.fire( [args] ); to * execute event subscribers.

* *

The first parameter is the name of the event. The second parameter is a * configuration object which define the behavior of the event system when the * new event is subscribed to or detached from. The methods that should be * defined in this configuration object are on, * detach, delegate, and detachDelegate. * You are free to define any other methods or properties needed to define your * event. Be aware, however, that since the object is used to subclass * SyntheticEvent, you should avoid method names used by SyntheticEvent unless * your intention is to override the default behavior.

* *

This is a list of properties and methods that you can or should specify * in the configuration object:

* *
*
on
*
function (node, subscription, notifier) The * implementation logic for subscription. Any special setup you need to * do to create the environment for the event being fired--E.g. native * DOM event subscriptions. Store subscription related objects and * state on the subscription object. When the * criteria have been met to fire the synthetic event, call * notifier.fire(e). See Notifier's fire() * method for details about what to pass as parameters.
* *
detach
*
function (node, subscription, notifier) The * implementation logic for cleaning up a detached subscription. E.g. * detach any DOM subscriptions added in on.
* *
delegate
*
function (node, subscription, notifier, filter) The * implementation logic for subscription via Y.delegate or * node.delegate. The filter is typically either a selector * string or a function. You can use * Y.delegate.compileFilter(selectorString) to create a * filter function from a selector string if needed. The filter function * expects an event object as input and should output either null, a * matching Node, or an array of matching Nodes. Otherwise, this acts * like on DOM event subscriptions. Store subscription * related objects and information on the subscription * object. When the criteria have been met to fire the synthetic event, * call notifier.fire(e) as noted above.
* *
detachDelegate
*
function (node, subscription, notifier) The * implementation logic for cleaning up a detached delegate subscription. * E.g. detach any DOM delegate subscriptions added in * delegate.
* *
publishConfig
*
(Object) The configuration object that will be used to instantiate * the underlying CustomEvent. See Notifier's fire method * for details.
* *
processArgs
*

function (argArray, fromDelegate) Optional method * to extract any additional arguments from the subscription * signature. Using this allows on or * delegate signatures like * node.on("hover", overCallback, * outCallback).

*

When processing an atypical argument signature, make sure the * args array is returned to the normal signature before returning * from the function. For example, in the "hover" example * above, the outCallback needs to be spliced * out of the array. The expected signature of the args array for * on() subscriptions is:

*
 *              [type, callback, target, contextOverride, argN...]
 *          
*

And for delegate():

*
 *              [type, callback, target, filter, contextOverride, argN...]
 *          
*

where target is the node the event is being * subscribed for. You can see these signatures documented for * Y.on() and Y.delegate() respectively.

*

Whatever gets returned from the function will be stored on the * subscription object under * subscription._extra.

*
subMatch
*
*

function (sub, args) Compares a set of * subscription arguments against a Subscription object to determine * if they match. The default implementation compares the callback * function against the second argument passed to * Y.on(...) or node.detach(...) etc.

*
*
* * @method define * @param type {String} the name of the event * @param config {Object} the prototype definition for the new event (see above) * @param force {Boolean} override an existing event (use with caution) * @return {SyntheticEvent} the subclass implementation instance created to * handle event subscriptions of this type * @static * @for Event * @since 3.1.0 * @in event-synthetic */ Y.Event.define = function (type, config, force) { var eventDef, Impl, synth; if (type && type.type) { eventDef = type; force = config; } else if (config) { eventDef = Y.merge({ type: type }, config); } if (eventDef) { if (force || !Y.Node.DOM_EVENTS[eventDef.type]) { Impl = function () { SyntheticEvent.apply(this, arguments); }; Y.extend(Impl, SyntheticEvent, eventDef); synth = new Impl(); type = synth.type; Y.Node.DOM_EVENTS[type] = Y.Env.evt.plugins[type] = { eventDef: synth, on: function () { return synth._on(toArray(arguments)); }, delegate: function () { return synth._on(toArray(arguments), true); }, detach: function () { return synth._detach(toArray(arguments)); } }; } } else if (isString(type) || isArray(type)) { Y.Array.each(toArray(type), function (t) { Y.Node.DOM_EVENTS[t] = 1; }); } return synth; }; }, '3.17.2', {"requires": ["node-base", "event-custom-complex"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('attribute-complex', function (Y, NAME) { /** * Adds support for attribute providers to handle complex attributes in the constructor * * @module attribute * @submodule attribute-complex * @for Attribute * @deprecated AttributeComplex's overrides are now part of AttributeCore. */ var Attribute = Y.Attribute; Attribute.Complex = function() {}; Attribute.Complex.prototype = { /** * Utility method to split out simple attribute name/value pairs ("x") * from complex attribute name/value pairs ("x.y.z"), so that complex * attributes can be keyed by the top level attribute name. * * @method _normAttrVals * @param {Object} valueHash An object with attribute name/value pairs * * @return {Object} An object literal with 2 properties - "simple" and "complex", * containing simple and complex attribute values respectively keyed * by the top level attribute name, or null, if valueHash is falsey. * * @private */ _normAttrVals : Attribute.prototype._normAttrVals, /** * Returns the initial value of the given attribute from * either the default configuration provided, or the * over-ridden value if it exists in the set of initValues * provided and the attribute is not read-only. * * @param {String} attr The name of the attribute * @param {Object} cfg The attribute configuration object * @param {Object} initValues The object with simple and complex attribute name/value pairs returned from _normAttrVals * * @return {Any} The initial value of the attribute. * * @method _getAttrInitVal * @private */ _getAttrInitVal : Attribute.prototype._getAttrInitVal }; // Consistency with the rest of the Attribute addons for now. Y.AttributeComplex = Attribute.Complex; }, '3.17.2', {"requires": ["attribute-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('event-mouseenter', function (Y, NAME) { /** *

Adds subscription and delegation support for mouseenter and mouseleave * events. Unlike mouseover and mouseout, these events aren't fired from child * elements of a subscribed node.

* *

This avoids receiving three mouseover notifications from a setup like

* *
div#container > p > a[href]
* *

where

* *
Y.one('#container').on('mouseover', callback)
* *

When the mouse moves over the link, one mouseover event is fired from * #container, then when the mouse moves over the p, another mouseover event is * fired and bubbles to #container, causing a second notification, and finally * when the mouse moves over the link, a third mouseover event is fired and * bubbles to #container for a third notification.

* *

By contrast, using mouseenter instead of mouseover, the callback would be * executed only once when the mouse moves over #container.

* * @module event * @submodule event-mouseenter */ var domEventProxies = Y.Env.evt.dom_wrappers, contains = Y.DOM.contains, toArray = Y.Array, noop = function () {}, config = { proxyType: "mouseover", relProperty: "fromElement", _notify: function (e, property, notifier) { var el = this._node, related = e.relatedTarget || e[property]; if (el !== related && !contains(el, related)) { notifier.fire(new Y.DOMEventFacade(e, el, domEventProxies['event:' + Y.stamp(el) + e.type])); } }, on: function (node, sub, notifier) { var el = Y.Node.getDOMNode(node), args = [ this.proxyType, this._notify, el, null, this.relProperty, notifier]; sub.handle = Y.Event._attach(args, { facade: false }); // node.on(this.proxyType, notify, null, notifier); }, detach: function (node, sub) { sub.handle.detach(); }, delegate: function (node, sub, notifier, filter) { var el = Y.Node.getDOMNode(node), args = [ this.proxyType, noop, el, null, notifier ]; sub.handle = Y.Event._attach(args, { facade: false }); sub.handle.sub.filter = filter; sub.handle.sub.relProperty = this.relProperty; sub.handle.sub._notify = this._filterNotify; }, _filterNotify: function (thisObj, args, ce) { args = args.slice(); if (this.args) { args.push.apply(args, this.args); } var currentTarget = Y.delegate._applyFilter(this.filter, args, ce), related = args[0].relatedTarget || args[0][this.relProperty], e, i, len, ret, ct; if (currentTarget) { currentTarget = toArray(currentTarget); for (i = 0, len = currentTarget.length && (!e || !e.stopped); i < len; ++i) { ct = currentTarget[0]; if (!contains(ct, related)) { if (!e) { e = new Y.DOMEventFacade(args[0], ct, ce); e.container = Y.one(ce.el); } e.currentTarget = Y.one(ct); // TODO: where is notifier? args? this.notifier? ret = args[1].fire(e); if (ret === false) { break; } } } } return ret; }, detachDelegate: function (node, sub) { sub.handle.detach(); } }; Y.Event.define("mouseenter", config, true); Y.Event.define("mouseleave", Y.merge(config, { proxyType: "mouseout", relProperty: "toElement" }), true); }, '3.17.2', {"requires": ["event-synthetic"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('event-key', function (Y, NAME) { /** * Functionality to listen for one or more specific key combinations. * @module event * @submodule event-key */ var ALT = "+alt", CTRL = "+ctrl", META = "+meta", SHIFT = "+shift", trim = Y.Lang.trim, eventDef = { KEY_MAP: { enter : 13, space : 32, esc : 27, backspace: 8, tab : 9, pageup : 33, pagedown : 34 }, _typeRE: /^(up|down|press):/, _keysRE: /^(?:up|down|press):|\+(alt|ctrl|meta|shift)/g, processArgs: function (args) { var spec = args.splice(3,1)[0], mods = Y.Array.hash(spec.match(/\+(?:alt|ctrl|meta|shift)\b/g) || []), config = { type: this._typeRE.test(spec) ? RegExp.$1 : null, mods: mods, keys: null }, // strip type and modifiers from spec, leaving only keyCodes bits = spec.replace(this._keysRE, ''), chr, uc, lc, i; if (bits) { bits = bits.split(','); config.keys = {}; // FIXME: need to support '65,esc' => keypress, keydown for (i = bits.length - 1; i >= 0; --i) { chr = trim(bits[i]); // catch sloppy filters, trailing commas, etc 'a,,' if (!chr) { continue; } // non-numerics are single characters or key names if (+chr == chr) { config.keys[chr] = mods; } else { lc = chr.toLowerCase(); if (this.KEY_MAP[lc]) { config.keys[this.KEY_MAP[lc]] = mods; // FIXME: '65,enter' defaults keydown for both if (!config.type) { config.type = "down"; // safest } } else { // FIXME: Character mapping only works for keypress // events. Otherwise, it uses String.fromCharCode() // from the keyCode, which is wrong. chr = chr.charAt(0); uc = chr.toUpperCase(); if (mods["+shift"]) { chr = uc; } // FIXME: stupid assumption that // the keycode of the lower case == the // charCode of the upper case // a (key:65,char:97), A (key:65,char:65) config.keys[chr.charCodeAt(0)] = (chr === uc) ? // upper case chars get +shift free Y.merge(mods, { "+shift": true }) : mods; } } } } if (!config.type) { config.type = "press"; } return config; }, on: function (node, sub, notifier, filter) { var spec = sub._extra, type = "key" + spec.type, keys = spec.keys, method = (filter) ? "delegate" : "on"; // Note: without specifying any keyCodes, this becomes a // horribly inefficient alias for 'keydown' (et al), but I // can't abort this subscription for a simple // Y.on('keypress', ...); // Please use keyCodes or just subscribe directly to keydown, // keyup, or keypress sub._detach = node[method](type, function (e) { var key = keys ? keys[e.which] : spec.mods; if (key && (!key[ALT] || (key[ALT] && e.altKey)) && (!key[CTRL] || (key[CTRL] && e.ctrlKey)) && (!key[META] || (key[META] && e.metaKey)) && (!key[SHIFT] || (key[SHIFT] && e.shiftKey))) { notifier.fire(e); } }, filter); }, detach: function (node, sub, notifier) { sub._detach.detach(); } }; eventDef.delegate = eventDef.on; eventDef.detachDelegate = eventDef.detach; /** *

Add a key listener. The listener will only be notified if the * keystroke detected meets the supplied specification. The * specification is a string that is defined as:

* *
*
spec
*
[{type}:]{code}[,{code}]*
*
type
*
"down", "up", or "press"
*
code
*
{keyCode|character|keyName}[+{modifier}]*
*
modifier
*
"shift", "ctrl", "alt", or "meta"
*
keyName
*
"enter", "space", "backspace", "esc", "tab", "pageup", or "pagedown"
*
* *

Examples:

*
    *
  • Y.on("key", callback, "press:12,65+shift+ctrl", "#my-input");
  • *
  • Y.delegate("key", preventSubmit, "#forms", "enter", "input[type=text]");
  • *
  • Y.one("doc").on("key", viNav, "j,k,l,;");
  • *
* * @event key * @for YUI * @param type {string} 'key' * @param fn {function} the function to execute * @param id {string|HTMLElement|collection} the element(s) to bind * @param spec {string} the keyCode and modifier specification * @param o optional context object * @param args 0..n additional arguments to provide to the listener. * @return {Event.Handle} the detach handle */ Y.Event.define('key', eventDef, true); }, '3.17.2', {"requires": ["event-synthetic"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('event-outside', function (Y, NAME) { /** * Outside events are synthetic DOM events that fire when a corresponding native * or synthetic DOM event occurs outside a bound element. * * The following outside events are pre-defined by this module: *
    *
  • blur
  • *
  • change
  • *
  • click
  • *
  • dblclick
  • *
  • focus
  • *
  • keydown
  • *
  • keypress
  • *
  • keyup
  • *
  • mousedown
  • *
  • mousemove
  • *
  • mouseout
  • *
  • mouseover
  • *
  • mouseup
  • *
  • select
  • *
  • submit
  • *
* * Define new outside events with * Y.Event.defineOutside(eventType);. * By default, the created synthetic event name will be the name of the event * with "outside" appended (e.g. "click" becomes "clickoutside"). If you want * a different name for the created Event, pass it as a second argument like so: * Y.Event.defineOutside(eventType, "yonderclick"). * * This module was contributed by Brett Stimmerman, promoted from his * gallery-outside-events module at * http://yuilibrary.com/gallery/show/outside-events * * @module event * @submodule event-outside * @author brettstimmerman * @since 3.4.0 */ // Outside events are pre-defined for each of these native DOM events var nativeEvents = [ 'blur', 'change', 'click', 'dblclick', 'focus', 'keydown', 'keypress', 'keyup', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'select', 'submit' ]; /** * Defines a new outside event to correspond with the given DOM event. * * By default, the created synthetic event name will be the name of the event * with "outside" appended (e.g. "click" becomes "clickoutside"). If you want * a different name for the created Event, pass it as a second argument like so: * Y.Event.defineOutside(eventType, "yonderclick"). * * @method defineOutside * @param {String} event DOM event * @param {String} name (optional) custom outside event name * @static * @for Event */ Y.Event.defineOutside = function (event, name) { name = name || (event + 'outside'); var config = { on: function (node, sub, notifier) { sub.handle = Y.one('doc').on(event, function(e) { if (this.isOutside(node, e.target)) { e.currentTarget = node; notifier.fire(e); } }, this); }, detach: function (node, sub, notifier) { sub.handle.detach(); }, delegate: function (node, sub, notifier, filter) { sub.handle = Y.one('doc').delegate(event, function (e) { if (this.isOutside(node, e.target)) { notifier.fire(e); } }, filter, this); }, isOutside: function (node, target) { return target !== node && !target.ancestor(function (p) { return p === node; }); } }; config.detachDelegate = config.detach; Y.Event.define(name, config); }; // Define outside events for some common native DOM events Y.Array.each(nativeEvents, function (event) { Y.Event.defineOutside(event); }); }, '3.17.2', {"requires": ["event-synthetic"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('event-focus', function (Y, NAME) { /** * Adds bubbling and delegation support to DOM events focus and blur. * * @module event * @submodule event-focus */ var Event = Y.Event, YLang = Y.Lang, isString = YLang.isString, arrayIndex = Y.Array.indexOf, useActivate = (function() { // Changing the structure of this test, so that it doesn't use inline JS in HTML, // which throws an exception in Win8 packaged apps, due to additional security restrictions: // http://msdn.microsoft.com/en-us/library/windows/apps/hh465380.aspx#differences var supported = false, doc = Y.config.doc, p; if (doc) { p = doc.createElement("p"); p.setAttribute("onbeforeactivate", ";"); // onbeforeactivate is a function in IE8+. // onbeforeactivate is a string in IE6,7 (unfortunate, otherwise we could have just checked for function below). // onbeforeactivate is a function in IE10, in a Win8 App environment (no exception running the test). // onbeforeactivate is undefined in Webkit/Gecko. // onbeforeactivate is a function in Webkit/Gecko if it's a supported event (e.g. onclick). supported = (p.onbeforeactivate !== undefined); } return supported; }()); function define(type, proxy, directEvent) { var nodeDataKey = '_' + type + 'Notifiers'; Y.Event.define(type, { _useActivate : useActivate, _attach: function (el, notifier, delegate) { if (Y.DOM.isWindow(el)) { return Event._attach([type, function (e) { notifier.fire(e); }, el]); } else { return Event._attach( [proxy, this._proxy, el, this, notifier, delegate], { capture: true }); } }, _proxy: function (e, notifier, delegate) { var target = e.target, currentTarget = e.currentTarget, notifiers = target.getData(nodeDataKey), yuid = Y.stamp(currentTarget._node), defer = (useActivate || target !== currentTarget), directSub; notifier.currentTarget = (delegate) ? target : currentTarget; notifier.container = (delegate) ? currentTarget : null; // Maintain a list to handle subscriptions from nested // containers div#a>div#b>input #a.on(focus..) #b.on(focus..), // use one focus or blur subscription that fires notifiers from // #b then #a to emulate bubble sequence. if (!notifiers) { notifiers = {}; target.setData(nodeDataKey, notifiers); // only subscribe to the element's focus if the target is // not the current target ( if (defer) { directSub = Event._attach( [directEvent, this._notify, target._node]).sub; directSub.once = true; } } else { // In old IE, defer is always true. In capture-phase browsers, // The delegate subscriptions will be encountered first, which // will establish the notifiers data and direct subscription // on the node. If there is also a direct subscription to the // node's focus/blur, it should not call _notify because the // direct subscription from the delegate sub(s) exists, which // will call _notify. So this avoids _notify being called // twice, unnecessarily. defer = true; } if (!notifiers[yuid]) { notifiers[yuid] = []; } notifiers[yuid].push(notifier); if (!defer) { this._notify(e); } }, _notify: function (e, container) { var currentTarget = e.currentTarget, notifierData = currentTarget.getData(nodeDataKey), axisNodes = currentTarget.ancestors(), doc = currentTarget.get('ownerDocument'), delegates = [], // Used to escape loops when there are no more // notifiers to consider count = notifierData ? Y.Object.keys(notifierData).length : 0, target, notifiers, notifier, yuid, match, tmp, i, len, sub, ret; // clear the notifications list (mainly for delegation) currentTarget.clearData(nodeDataKey); // Order the delegate subs by their placement in the parent axis axisNodes.push(currentTarget); // document.get('ownerDocument') returns null // which we'll use to prevent having duplicate Nodes in the list if (doc) { axisNodes.unshift(doc); } // ancestors() returns the Nodes from top to bottom axisNodes._nodes.reverse(); if (count) { // Store the count for step 2 tmp = count; axisNodes.some(function (node) { var yuid = Y.stamp(node), notifiers = notifierData[yuid], i, len; if (notifiers) { count--; for (i = 0, len = notifiers.length; i < len; ++i) { if (notifiers[i].handle.sub.filter) { delegates.push(notifiers[i]); } } } return !count; }); count = tmp; } // Walk up the parent axis, notifying direct subscriptions and // testing delegate filters. while (count && (target = axisNodes.shift())) { yuid = Y.stamp(target); notifiers = notifierData[yuid]; if (notifiers) { for (i = 0, len = notifiers.length; i < len; ++i) { notifier = notifiers[i]; sub = notifier.handle.sub; match = true; e.currentTarget = target; if (sub.filter) { match = sub.filter.apply(target, [target, e].concat(sub.args || [])); // No longer necessary to test against this // delegate subscription for the nodes along // the parent axis. delegates.splice( arrayIndex(delegates, notifier), 1); } if (match) { // undefined for direct subs e.container = notifier.container; ret = notifier.fire(e); } if (ret === false || e.stopped === 2) { break; } } delete notifiers[yuid]; count--; } if (e.stopped !== 2) { // delegates come after subs targeting this specific node // because they would not normally report until they'd // bubbled to the container node. for (i = 0, len = delegates.length; i < len; ++i) { notifier = delegates[i]; sub = notifier.handle.sub; if (sub.filter.apply(target, [target, e].concat(sub.args || []))) { e.container = notifier.container; e.currentTarget = target; ret = notifier.fire(e); } if (ret === false || e.stopped === 2 || // If e.stopPropagation() is called, notify any // delegate subs from the same container, but break // once the container changes. This emulates // delegate() behavior for events like 'click' which // won't notify delegates higher up the parent axis. (e.stopped && delegates[i+1] && delegates[i+1].container !== notifier.container)) { break; } } } if (e.stopped) { break; } } }, on: function (node, sub, notifier) { sub.handle = this._attach(node._node, notifier); }, detach: function (node, sub) { sub.handle.detach(); }, delegate: function (node, sub, notifier, filter) { if (isString(filter)) { sub.filter = function (target) { return Y.Selector.test(target._node, filter, node === target ? null : node._node); }; } sub.handle = this._attach(node._node, notifier, true); }, detachDelegate: function (node, sub) { sub.handle.detach(); } }, true); } // For IE, we need to defer to focusin rather than focus because // `el.focus(); doSomething();` executes el.onbeforeactivate, el.onactivate, // el.onfocusin, doSomething, then el.onfocus. All others support capture // phase focus, which executes before doSomething. To guarantee consistent // behavior for this use case, IE's direct subscriptions are made against // focusin so subscribers will be notified before js following el.focus() is // executed. if (useActivate) { // name capture phase direct subscription define("focus", "beforeactivate", "focusin"); define("blur", "beforedeactivate", "focusout"); } else { define("focus", "focus", "focus"); define("blur", "blur", "blur"); } }, '3.17.2', {"requires": ["event-synthetic"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('classnamemanager', function (Y, NAME) { /** * Contains a singleton (ClassNameManager) that enables easy creation and caching of * prefixed class names. * @module classnamemanager */ /** * A singleton class providing: * *
    *
  • Easy creation of prefixed class names
  • *
  • Caching of previously created class names for improved performance.
  • *
* * @class ClassNameManager * @static */ // String constants var CLASS_NAME_PREFIX = 'classNamePrefix', CLASS_NAME_DELIMITER = 'classNameDelimiter', CONFIG = Y.config; // Global config /** * Configuration property indicating the prefix for all CSS class names in this YUI instance. * * @property classNamePrefix * @type {String} * @default "yui" * @static */ CONFIG[CLASS_NAME_PREFIX] = CONFIG[CLASS_NAME_PREFIX] || 'yui3'; /** * Configuration property indicating the delimiter used to compose all CSS class names in * this YUI instance. * * @property classNameDelimiter * @type {String} * @default "-" * @static */ CONFIG[CLASS_NAME_DELIMITER] = CONFIG[CLASS_NAME_DELIMITER] || '-'; Y.ClassNameManager = function () { var sPrefix = CONFIG[CLASS_NAME_PREFIX], sDelimiter = CONFIG[CLASS_NAME_DELIMITER]; return { /** * Returns a class name prefixed with the value of the * Y.config.classNamePrefix attribute + the provided strings. * Uses the Y.config.classNameDelimiter attribute to delimit the * provided strings. E.g. Y.ClassNameManager.getClassName('foo','bar'); // yui-foo-bar * * @method getClassName * @param {String} [classnameSection*] one or more classname sections to be joined * @param {Boolean} skipPrefix If set to true, the classname will not be prefixed with the default Y.config.classNameDelimiter value. */ getClassName: Y.cached(function () { var args = Y.Array(arguments); if (args[args.length-1] !== true) { args.unshift(sPrefix); } else { args.pop(); } return args.join(sDelimiter); }) }; }(); }, '3.17.2', {"requires": ["yui-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('widget-base', function (Y, NAME) { /** * Provides the base Widget class, with HTML Parser support * * @module widget * @main widget */ /** * Provides the base Widget class * * @module widget * @submodule widget-base */ var L = Y.Lang, Node = Y.Node, ClassNameManager = Y.ClassNameManager, _getClassName = ClassNameManager.getClassName, _getWidgetClassName, _toInitialCap = Y.cached(function(str) { return str.substring(0, 1).toUpperCase() + str.substring(1); }), // K-Weight, IE GC optimizations CONTENT = "content", VISIBLE = "visible", HIDDEN = "hidden", DISABLED = "disabled", FOCUSED = "focused", WIDTH = "width", HEIGHT = "height", BOUNDING_BOX = "boundingBox", CONTENT_BOX = "contentBox", PARENT_NODE = "parentNode", OWNER_DOCUMENT = "ownerDocument", AUTO = "auto", SRC_NODE = "srcNode", BODY = "body", TAB_INDEX = "tabIndex", ID = "id", RENDER = "render", RENDERED = "rendered", DESTROYED = "destroyed", STRINGS = "strings", DIV = "
", CHANGE = "Change", LOADING = "loading", _UISET = "_uiSet", EMPTY_STR = "", EMPTY_FN = function() {}, TRUE = true, FALSE = false, UI, ATTRS = {}, UI_ATTRS = [VISIBLE, DISABLED, HEIGHT, WIDTH, FOCUSED, TAB_INDEX], WEBKIT = Y.UA.webkit, // Widget nodeid-to-instance map. _instances = {}; /** * A base class for widgets, providing: *
    *
  • The render lifecycle method, in addition to the init and destroy * lifecycle methods provide by Base
  • *
  • Abstract methods to support consistent MVC structure across * widgets: renderer, renderUI, bindUI, syncUI
  • *
  • Support for common widget attributes, such as boundingBox, contentBox, visible, * disabled, focused, strings
  • *
* * @param config {Object} Object literal specifying widget configuration properties. * * @class Widget * @constructor * @extends Base */ function Widget(config) { // kweight var widget = this, parentNode, render, constructor = widget.constructor; widget._strs = {}; widget._cssPrefix = constructor.CSS_PREFIX || _getClassName(constructor.NAME.toLowerCase()); // We need a config for HTML_PARSER to work. config = config || {}; Widget.superclass.constructor.call(widget, config); render = widget.get(RENDER); if (render) { // Render could be a node or boolean if (render !== TRUE) { parentNode = render; } widget.render(parentNode); } } /** * Static property provides a string to identify the class. *

* Currently used to apply class identifiers to the bounding box * and to classify events fired by the widget. *

* * @property NAME * @type String * @static */ Widget.NAME = "widget"; /** * Constant used to identify state changes originating from * the DOM (as opposed to the JavaScript model). * * @property UI_SRC * @type String * @static * @final */ UI = Widget.UI_SRC = "ui"; /** * Static property used to define the default attribute * configuration for the Widget. * * @property ATTRS * @type Object * @static */ Widget.ATTRS = ATTRS; // Trying to optimize kweight by setting up attrs this way saves about 0.4K min'd /** * @attribute id * @writeOnce * @default Generated using guid() * @type String */ ATTRS[ID] = { valueFn: "_guid", writeOnce: TRUE }; /** * Flag indicating whether or not this Widget * has been through the render lifecycle phase. * * @attribute rendered * @readOnly * @default false * @type boolean */ ATTRS[RENDERED] = { value:FALSE, readOnly: TRUE }; /** * @attribute boundingBox * @description The outermost DOM node for the Widget, used for sizing and positioning * of a Widget as well as a containing element for any decorator elements used * for skinning. * @type String | Node * @writeOnce */ ATTRS[BOUNDING_BOX] = { valueFn:"_defaultBB", setter: "_setBB", writeOnce: TRUE }; /** * @attribute contentBox * @description A DOM node that is a direct descendant of a Widget's bounding box that * houses its content. * @type String | Node * @writeOnce */ ATTRS[CONTENT_BOX] = { valueFn:"_defaultCB", setter: "_setCB", writeOnce: TRUE }; /** * @attribute tabIndex * @description Number (between -32767 to 32767) indicating the widget's * position in the default tab flow. The value is used to set the * "tabIndex" attribute on the widget's bounding box. Negative values allow * the widget to receive DOM focus programmatically (by calling the focus * method), while being removed from the default tab flow. A value of * null removes the "tabIndex" attribute from the widget's bounding box. * @type Number * @default null */ ATTRS[TAB_INDEX] = { value: null, validator: "_validTabIndex" }; /** * @attribute focused * @description Boolean indicating if the Widget, or one of its descendants, * has focus. * @readOnly * @default false * @type boolean */ ATTRS[FOCUSED] = { value: FALSE, readOnly:TRUE }; /** * @attribute disabled * @description Boolean indicating if the Widget should be disabled. The disabled implementation * is left to the specific classes extending widget. * @default false * @type boolean */ ATTRS[DISABLED] = { value: FALSE }; /** * @attribute visible * @description Boolean indicating whether or not the Widget is visible. * @default TRUE * @type boolean */ ATTRS[VISIBLE] = { value: TRUE }; /** * @attribute height * @description String with units, or number, representing the height of the Widget. If a number is provided, * the default unit, defined by the Widgets DEF_UNIT, property is used. * @default EMPTY_STR * @type {String | Number} */ ATTRS[HEIGHT] = { value: EMPTY_STR }; /** * @attribute width * @description String with units, or number, representing the width of the Widget. If a number is provided, * the default unit, defined by the Widgets DEF_UNIT, property is used. * @default EMPTY_STR * @type {String | Number} */ ATTRS[WIDTH] = { value: EMPTY_STR }; /** * @attribute strings * @description Collection of strings used to label elements of the Widget's UI. * @default null * @type Object */ ATTRS[STRINGS] = { value: {}, setter: "_strSetter", getter: "_strGetter" }; /** * Whether or not to render the widget automatically after init, and optionally, to which parent node. * * @attribute render * @type boolean | Node * @writeOnce */ ATTRS[RENDER] = { value:FALSE, writeOnce:TRUE }; /** * The css prefix which the static Widget.getClassName method should use when constructing class names * * @property CSS_PREFIX * @type String * @default Widget.NAME.toLowerCase() * @private * @static */ Widget.CSS_PREFIX = _getClassName(Widget.NAME.toLowerCase()); /** * Generate a standard prefixed classname for the Widget, prefixed by the default prefix defined * by the Y.config.classNamePrefix attribute used by ClassNameManager and * Widget.NAME.toLowerCase() (e.g. "yui-widget-xxxxx-yyyyy", based on default values for * the prefix and widget class name). *

* The instance based version of this method can be used to generate standard prefixed classnames, * based on the instances NAME, as opposed to Widget.NAME. This method should be used when you * need to use a constant class name across different types instances. *

* @method getClassName * @param {String*} args* 0..n strings which should be concatenated, using the default separator defined by ClassNameManager, to create the class name */ Widget.getClassName = function() { // arguments needs to be array'fied to concat return _getClassName.apply(ClassNameManager, [Widget.CSS_PREFIX].concat(Y.Array(arguments), true)); }; _getWidgetClassName = Widget.getClassName; /** * Returns the widget instance whose bounding box contains, or is, the given node. *

* In the case of nested widgets, the nearest bounding box ancestor is used to * return the widget instance. *

* @method getByNode * @static * @param node {Node | String} The node for which to return a Widget instance. If a selector * string is passed in, which selects more than one node, the first node found is used. * @return {Widget} Widget instance, or null if not found. */ Widget.getByNode = function(node) { var widget, widgetMarker = _getWidgetClassName(); node = Node.one(node); if (node) { node = node.ancestor("." + widgetMarker, true); if (node) { widget = _instances[Y.stamp(node, true)]; } } return widget || null; }; Y.extend(Widget, Y.Base, { /** * Returns a class name prefixed with the the value of the * YUI.config.classNamePrefix attribute + the instances NAME property. * Uses YUI.config.classNameDelimiter attribute to delimit the provided strings. * e.g. * *
     *    // returns "yui-slider-foo-bar", for a slider instance
     *    var scn = slider.getClassName('foo','bar');
     *
     *    // returns "yui-overlay-foo-bar", for an overlay instance
     *    var ocn = overlay.getClassName('foo','bar');
     * 
*
* * @method getClassName * @param {String} [classnames*] One or more classname bits to be joined and prefixed */ getClassName: function () { return _getClassName.apply(ClassNameManager, [this._cssPrefix].concat(Y.Array(arguments), true)); }, /** * Initializer lifecycle implementation for the Widget class. Registers the * widget instance, and runs through the Widget's HTML_PARSER definition. * * @method initializer * @protected * @param config {Object} Configuration object literal for the widget */ initializer: function(config) { var bb = this.get(BOUNDING_BOX); if (bb instanceof Node) { this._mapInstance(Y.stamp(bb)); } /** * Notification event, which widget implementations can fire, when * they change the content of the widget. This event has no default * behavior and cannot be prevented, so the "on" or "after" * moments are effectively equivalent (with on listeners being invoked before * after listeners). * * @event widget:contentUpdate * @preventable false * @param {EventFacade} e The Event Facade */ }, /** * Utility method used to add an entry to the boundingBox id to instance map. * * This method can be used to populate the instance with lazily created boundingBox Node references. * * @method _mapInstance * @param {String} The boundingBox id * @protected */ _mapInstance : function(id) { _instances[id] = this; }, /** * Destructor lifecycle implementation for the Widget class. Purges events attached * to the bounding box and content box, removes them from the DOM and removes * the Widget from the list of registered widgets. * * @method destructor * @protected */ destructor: function() { var boundingBox = this.get(BOUNDING_BOX), bbGuid; if (boundingBox instanceof Node) { bbGuid = Y.stamp(boundingBox,true); if (bbGuid in _instances) { delete _instances[bbGuid]; } this._destroyBox(); } }, /** *

* Destroy lifecycle method. Fires the destroy * event, prior to invoking destructors for the * class hierarchy. * * Overrides Base's implementation, to support arguments to destroy *

*

* Subscribers to the destroy * event can invoke preventDefault on the event object, to prevent destruction * from proceeding. *

* @method destroy * @param destroyAllNodes {Boolean} If true, all nodes contained within the Widget are * removed and destroyed. Defaults to false due to potentially high run-time cost. * @return {Widget} A reference to this object * @chainable */ destroy: function(destroyAllNodes) { this._destroyAllNodes = destroyAllNodes; return Widget.superclass.destroy.apply(this); }, /** * Removes and destroys the widgets rendered boundingBox, contentBox, * and detaches bound UI events. * * @method _destroyBox * @protected */ _destroyBox : function() { var boundingBox = this.get(BOUNDING_BOX), contentBox = this.get(CONTENT_BOX), deep = this._destroyAllNodes, same; same = boundingBox && boundingBox.compareTo(contentBox); if (this.UI_EVENTS) { this._destroyUIEvents(); } this._unbindUI(boundingBox); if (contentBox) { if (deep) { contentBox.empty(); } contentBox.remove(TRUE); } if (!same) { if (deep) { boundingBox.empty(); } boundingBox.remove(TRUE); } }, /** * Establishes the initial DOM for the widget. Invoking this * method will lead to the creating of all DOM elements for * the widget (or the manipulation of existing DOM elements * for the progressive enhancement use case). *

* This method should only be invoked once for an initialized * widget. *

*

* It delegates to the widget specific renderer method to do * the actual work. *

* * @method render * @chainable * @final * @param parentNode {Object | String} Optional. The Node under which the * Widget is to be rendered. This can be a Node instance or a CSS selector string. *

* If the selector string returns more than one Node, the first node will be used * as the parentNode. NOTE: This argument is required if both the boundingBox and contentBox * are not currently in the document. If it's not provided, the Widget will be rendered * to the body of the current document in this case. *

*/ render: function(parentNode) { if (!this.get(DESTROYED) && !this.get(RENDERED)) { /** * Lifecycle event for the render phase, fired prior to rendering the UI * for the widget (prior to invoking the widget's renderer method). *

* Subscribers to the "on" moment of this event, will be notified * before the widget is rendered. *

*

* Subscribers to the "after" moment of this event, will be notified * after rendering is complete. *

* * @event render * @preventable _defRenderFn * @param {EventFacade} e The Event Facade */ this.publish(RENDER, { queuable:FALSE, fireOnce:TRUE, defaultTargetOnly:TRUE, defaultFn: this._defRenderFn }); this.fire(RENDER, {parentNode: (parentNode) ? Node.one(parentNode) : null}); } return this; }, /** * Default render handler * * @method _defRenderFn * @protected * @param {EventFacade} e The Event object * @param {Node} parentNode The parent node to render to, if passed in to the render method */ _defRenderFn : function(e) { this._parentNode = e.parentNode; this.renderer(); this._set(RENDERED, TRUE); this._removeLoadingClassNames(); }, /** * Creates DOM (or manipulates DOM for progressive enhancement) * This method is invoked by render() and is not chained * automatically for the class hierarchy (unlike initializer, destructor) * so it should be chained manually for subclasses if required. * * @method renderer * @protected */ renderer: function() { // kweight var widget = this; widget._renderUI(); widget.renderUI(); widget._bindUI(); widget.bindUI(); widget._syncUI(); widget.syncUI(); }, /** * Configures/Sets up listeners to bind Widget State to UI/DOM * * This method is not called by framework and is not chained * automatically for the class hierarchy. * * @method bindUI * @protected */ bindUI: EMPTY_FN, /** * Adds nodes to the DOM * * This method is not called by framework and is not chained * automatically for the class hierarchy. * * @method renderUI * @protected */ renderUI: EMPTY_FN, /** * Refreshes the rendered UI, based on Widget State * * This method is not called by framework and is not chained * automatically for the class hierarchy. * * @method syncUI * @protected * */ syncUI: EMPTY_FN, /** * @method hide * @description Hides the Widget by setting the "visible" attribute to "false". * @chainable */ hide: function() { return this.set(VISIBLE, FALSE); }, /** * @method show * @description Shows the Widget by setting the "visible" attribute to "true". * @chainable */ show: function() { return this.set(VISIBLE, TRUE); }, /** * @method focus * @description Causes the Widget to receive the focus by setting the "focused" * attribute to "true". * @chainable */ focus: function () { return this._set(FOCUSED, TRUE); }, /** * @method blur * @description Causes the Widget to lose focus by setting the "focused" attribute * to "false" * @chainable */ blur: function () { return this._set(FOCUSED, FALSE); }, /** * @method enable * @description Set the Widget's "disabled" attribute to "false". * @chainable */ enable: function() { return this.set(DISABLED, FALSE); }, /** * @method disable * @description Set the Widget's "disabled" attribute to "true". * @chainable */ disable: function() { return this.set(DISABLED, TRUE); }, /** * @method _uiSizeCB * @protected * @param {boolean} expand */ _uiSizeCB : function(expand) { this.get(CONTENT_BOX).toggleClass(_getWidgetClassName(CONTENT, "expanded"), expand); }, /** * Helper method to collect the boundingBox and contentBox and append to the provided parentNode, if not * already a child. The owner document of the boundingBox, or the owner document of the contentBox will be used * as the document into which the Widget is rendered if a parentNode is node is not provided. If both the boundingBox and * the contentBox are not currently in the document, and no parentNode is provided, the widget will be rendered * to the current document's body. * * @method _renderBox * @private * @param {Node} parentNode The parentNode to render the widget to. If not provided, and both the boundingBox and * the contentBox are not currently in the document, the widget will be rendered to the current document's body. */ _renderBox: function(parentNode) { // TODO: Performance Optimization [ More effective algo to reduce Node refs, compares, replaces? ] var widget = this, // kweight contentBox = widget.get(CONTENT_BOX), boundingBox = widget.get(BOUNDING_BOX), srcNode = widget.get(SRC_NODE), defParentNode = widget.DEF_PARENT_NODE, doc = (srcNode && srcNode.get(OWNER_DOCUMENT)) || boundingBox.get(OWNER_DOCUMENT) || contentBox.get(OWNER_DOCUMENT); // If srcNode (assume it's always in doc), have contentBox take its place (widget render responsible for re-use of srcNode contents) if (srcNode && !srcNode.compareTo(contentBox) && !contentBox.inDoc(doc)) { srcNode.replace(contentBox); } if (!boundingBox.compareTo(contentBox.get(PARENT_NODE)) && !boundingBox.compareTo(contentBox)) { // If contentBox box is already in the document, have boundingBox box take it's place if (contentBox.inDoc(doc)) { contentBox.replace(boundingBox); } boundingBox.appendChild(contentBox); } parentNode = parentNode || (defParentNode && Node.one(defParentNode)); if (parentNode) { parentNode.appendChild(boundingBox); } else if (!boundingBox.inDoc(doc)) { Node.one(BODY).insert(boundingBox, 0); } }, /** * Setter for the boundingBox attribute * * @method _setBB * @private * @param {Node|String} node * @return Node */ _setBB: function(node) { return this._setBox(this.get(ID), node, this.BOUNDING_TEMPLATE, true); }, /** * Setter for the contentBox attribute * * @method _setCB * @private * @param {Node|String} node * @return Node */ _setCB: function(node) { return (this.CONTENT_TEMPLATE === null) ? this.get(BOUNDING_BOX) : this._setBox(null, node, this.CONTENT_TEMPLATE, false); }, /** * Returns the default value for the boundingBox attribute. * * For the Widget class, this will most commonly be null (resulting in a new * boundingBox node instance being created), unless a srcNode was provided * and CONTENT_TEMPLATE is null, in which case it will be srcNode. * This behavior was introduced in 3.17.2 to accomodate single-box widgets * whose BB & CB both point to srcNode (e.g. Y.Button). * * @method _defaultBB * @protected */ _defaultBB : function() { var node = this.get(SRC_NODE), nullCT = (this.CONTENT_TEMPLATE === null); return ((node && nullCT) ? node : null); }, /** * Returns the default value for the contentBox attribute. * * For the Widget class, this will be the srcNode if provided, otherwise null (resulting in * a new contentBox node instance being created) * * @method _defaultCB * @protected */ _defaultCB : function(node) { return this.get(SRC_NODE) || null; }, /** * Helper method to set the bounding/content box, or create it from * the provided template if not found. * * @method _setBox * @private * * @param {String} id The node's id attribute * @param {Node|String} node The node reference * @param {String} template HTML string template for the node * @param {boolean} isBounding true if this is the boundingBox, false if it's the contentBox * @return {Node} The node */ _setBox : function(id, node, template, isBounding) { node = Node.one(node); if (!node) { node = Node.create(template); if (isBounding) { this._bbFromTemplate = true; } else { this._cbFromTemplate = true; } } if (!node.get(ID)) { node.set(ID, id || Y.guid()); } return node; }, /** * Initializes the UI state for the Widget's bounding/content boxes. * * @method _renderUI * @protected */ _renderUI: function() { this._renderBoxClassNames(); this._renderBox(this._parentNode); }, /** * Applies standard class names to the boundingBox and contentBox * * @method _renderBoxClassNames * @protected */ _renderBoxClassNames : function() { var classes = this._getClasses(), cl, boundingBox = this.get(BOUNDING_BOX), i; boundingBox.addClass(_getWidgetClassName()); // Start from Widget Sub Class for (i = classes.length-3; i >= 0; i--) { cl = classes[i]; boundingBox.addClass(cl.CSS_PREFIX || _getClassName(cl.NAME.toLowerCase())); } // Use instance based name for content box this.get(CONTENT_BOX).addClass(this.getClassName(CONTENT)); }, /** * Removes class names representative of the widget's loading state from * the boundingBox. * * @method _removeLoadingClassNames * @protected */ _removeLoadingClassNames: function () { var boundingBox = this.get(BOUNDING_BOX), contentBox = this.get(CONTENT_BOX), instClass = this.getClassName(LOADING), widgetClass = _getWidgetClassName(LOADING); boundingBox.removeClass(widgetClass) .removeClass(instClass); contentBox.removeClass(widgetClass) .removeClass(instClass); }, /** * Sets up DOM and CustomEvent listeners for the widget. * * @method _bindUI * @protected */ _bindUI: function() { this._bindAttrUI(this._UI_ATTRS.BIND); this._bindDOM(); }, /** * @method _unbindUI * @protected */ _unbindUI : function(boundingBox) { this._unbindDOM(boundingBox); }, /** * Sets up DOM listeners, on elements rendered by the widget. * * @method _bindDOM * @protected */ _bindDOM : function() { var oDocument = this.get(BOUNDING_BOX).get(OWNER_DOCUMENT), focusHandle = Widget._hDocFocus; // Shared listener across all Widgets. if (!focusHandle) { focusHandle = Widget._hDocFocus = oDocument.on("focus", this._onDocFocus, this); focusHandle.listeners = { count: 0 }; } focusHandle.listeners[Y.stamp(this, true)] = true; focusHandle.listeners.count++; // Fix for Webkit: // Document doesn't receive focus in Webkit when the user mouses // down on it, so the "focused" attribute won't get set to the // correct value. Keeping this instance based for now, potential better performance. // Otherwise we'll end up looking up widgets from the DOM on every mousedown. if (WEBKIT){ this._hDocMouseDown = oDocument.on("mousedown", this._onDocMouseDown, this); } }, /** * @method _unbindDOM * @protected */ _unbindDOM : function(boundingBox) { var focusHandle = Widget._hDocFocus, yuid = Y.stamp(this, true), focusListeners, mouseHandle = this._hDocMouseDown; if (focusHandle) { focusListeners = focusHandle.listeners; if (focusListeners[yuid]) { delete focusListeners[yuid]; focusListeners.count--; } if (focusListeners.count === 0) { focusHandle.detach(); Widget._hDocFocus = null; } } if (WEBKIT && mouseHandle) { mouseHandle.detach(); } }, /** * Updates the widget UI to reflect the attribute state. * * @method _syncUI * @protected */ _syncUI: function() { this._syncAttrUI(this._UI_ATTRS.SYNC); }, /** * Sets the height on the widget's bounding box element * * @method _uiSetHeight * @protected * @param {String | Number} val */ _uiSetHeight: function(val) { this._uiSetDim(HEIGHT, val); this._uiSizeCB((val !== EMPTY_STR && val !== AUTO)); }, /** * Sets the width on the widget's bounding box element * * @method _uiSetWidth * @protected * @param {String | Number} val */ _uiSetWidth: function(val) { this._uiSetDim(WIDTH, val); }, /** * @method _uiSetDim * @private * @param {String} dim The dimension - "width" or "height" * @param {Number | String} val The value to set */ _uiSetDim: function(dimension, val) { this.get(BOUNDING_BOX).setStyle(dimension, L.isNumber(val) ? val + this.DEF_UNIT : val); }, /** * Sets the visible state for the UI * * @method _uiSetVisible * @protected * @param {boolean} val */ _uiSetVisible: function(val) { this.get(BOUNDING_BOX).toggleClass(this.getClassName(HIDDEN), !val); }, /** * Sets the disabled state for the UI * * @method _uiSetDisabled * @protected * @param {boolean} val */ _uiSetDisabled: function(val) { this.get(BOUNDING_BOX).toggleClass(this.getClassName(DISABLED), val); }, /** * Sets the focused state for the UI * * @method _uiSetFocused * @protected * @param {boolean} val * @param {string} src String representing the source that triggered an update to * the UI. */ _uiSetFocused: function(val, src) { var boundingBox = this.get(BOUNDING_BOX); boundingBox.toggleClass(this.getClassName(FOCUSED), val); if (src !== UI) { if (val) { boundingBox.focus(); } else { boundingBox.blur(); } } }, /** * Set the tabIndex on the widget's rendered UI * * @method _uiSetTabIndex * @protected * @param Number */ _uiSetTabIndex: function(index) { var boundingBox = this.get(BOUNDING_BOX); if (L.isNumber(index)) { boundingBox.set(TAB_INDEX, index); } else { boundingBox.removeAttribute(TAB_INDEX); } }, /** * @method _onDocMouseDown * @description "mousedown" event handler for the owner document of the * widget's bounding box. * @protected * @param {EventFacade} evt The event facade for the DOM focus event */ _onDocMouseDown: function (evt) { if (this._domFocus) { this._onDocFocus(evt); } }, /** * DOM focus event handler, used to sync the state of the Widget with the DOM * * @method _onDocFocus * @protected * @param {EventFacade} evt The event facade for the DOM focus event */ _onDocFocus: function (evt) { var widget = Widget.getByNode(evt.target), activeWidget = Widget._active; if (activeWidget && (activeWidget !== widget)) { activeWidget._domFocus = false; activeWidget._set(FOCUSED, false, {src:UI}); Widget._active = null; } if (widget) { widget._domFocus = true; widget._set(FOCUSED, true, {src:UI}); Widget._active = widget; } }, /** * Generic toString implementation for all widgets. * * @method toString * @return {String} The default string value for the widget [ displays the NAME of the instance, and the unique id ] */ toString: function() { // Using deprecated name prop for kweight squeeze. return this.name + "[" + this.get(ID) + "]"; }, /** * Default unit to use for dimension values * * @property DEF_UNIT * @type String */ DEF_UNIT : "px", /** * Default node to render the bounding box to. If not set, * will default to the current document body. * * @property DEF_PARENT_NODE * @type String | Node */ DEF_PARENT_NODE : null, /** * Property defining the markup template for content box. If your Widget doesn't * need the dual boundingBox/contentBox structure, set CONTENT_TEMPLATE to null, * and contentBox and boundingBox will both point to the same Node. * * @property CONTENT_TEMPLATE * @type String */ CONTENT_TEMPLATE : DIV, /** * Property defining the markup template for bounding box. * * @property BOUNDING_TEMPLATE * @type String */ BOUNDING_TEMPLATE : DIV, /** * @method _guid * @protected */ _guid : function() { return Y.guid(); }, /** * @method _validTabIndex * @protected * @param {Number} tabIndex */ _validTabIndex : function (tabIndex) { return (L.isNumber(tabIndex) || L.isNull(tabIndex)); }, /** * Binds after listeners for the list of attributes provided * * @method _bindAttrUI * @private * @param {Array} attrs */ _bindAttrUI : function(attrs) { var i, l = attrs.length; for (i = 0; i < l; i++) { this.after(attrs[i] + CHANGE, this._setAttrUI); } }, /** * Invokes the _uiSet=ATTR NAME> method for the list of attributes provided * * @method _syncAttrUI * @private * @param {Array} attrs */ _syncAttrUI : function(attrs) { var i, l = attrs.length, attr; for (i = 0; i < l; i++) { attr = attrs[i]; this[_UISET + _toInitialCap(attr)](this.get(attr)); } }, /** * @method _setAttrUI * @private * @param {EventFacade} e */ _setAttrUI : function(e) { if (e.target === this) { this[_UISET + _toInitialCap(e.attrName)](e.newVal, e.src); } }, /** * The default setter for the strings attribute. Merges partial sets * into the full string set, to allow users to partial sets of strings * * @method _strSetter * @protected * @param {Object} strings * @return {String} The full set of strings to set */ _strSetter : function(strings) { return Y.merge(this.get(STRINGS), strings); }, /** * Helper method to get a specific string value * * @deprecated Used by deprecated WidgetLocale implementations. * @method getString * @param {String} key * @return {String} The string */ getString : function(key) { return this.get(STRINGS)[key]; }, /** * Helper method to get the complete set of strings for the widget * * @deprecated Used by deprecated WidgetLocale implementations. * @method getStrings * @param {String} key * @return {String} The strings */ getStrings : function() { return this.get(STRINGS); }, /** * The lists of UI attributes to bind and sync for widget's _bindUI and _syncUI implementations * * @property _UI_ATTRS * @type Object * @private */ _UI_ATTRS : { BIND: UI_ATTRS, SYNC: UI_ATTRS } }); Y.Widget = Widget; }, '3.17.2', { "requires": [ "attribute", "base-base", "base-pluginhost", "classnamemanager", "event-focus", "node-base", "node-style" ], "skinnable": true }); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('widget-htmlparser', function (Y, NAME) { /** * Adds HTML Parser support to the base Widget class * * @module widget * @submodule widget-htmlparser * @for Widget */ var Widget = Y.Widget, Node = Y.Node, Lang = Y.Lang, SRC_NODE = "srcNode", CONTENT_BOX = "contentBox"; /** * Object hash, defining how attribute values are to be parsed from * markup contained in the widget's content box. e.g.: *
 *   {
 *       // Set single Node references using selector syntax
 *       // (selector is run through node.one)
 *       titleNode: "span.yui-title",
 *       // Set NodeList references using selector syntax
 *       // (array indicates selector is to be run through node.all)
 *       listNodes: ["li.yui-item"],
 *       // Set other attribute types, using a parse function.
 *       // Context is set to the widget instance.
 *       label: function(contentBox) {
 *           return contentBox.one("span.title").get("innerHTML");
 *       }
 *   }
 * 
* * @property HTML_PARSER * @type Object * @static */ Widget.HTML_PARSER = {}; /** * The build configuration for the Widget class. *

* Defines the static fields which need to be aggregated, * when this class is used as the main class passed to * the Base.build method. *

* @property _buildCfg * @type Object * @static * @final * @private */ Widget._buildCfg = { aggregates : ["HTML_PARSER"] }; /** * The DOM node to parse for configuration values, passed to the Widget's HTML_PARSER definition * * @attribute srcNode * @type String | Node * @writeOnce */ Widget.ATTRS[SRC_NODE] = { value: null, setter: Node.one, getter: "_getSrcNode", writeOnce: true }; Y.mix(Widget.prototype, { /** * @method _getSrcNode * @protected * @return {Node} The Node to apply HTML_PARSER to */ _getSrcNode : function(val) { return val || this.get(CONTENT_BOX); }, /** * Implement the BaseCore _preAddAttrs method hook, to add * the srcNode and related attributes, so that HTML_PARSER * (which relies on `this.get("srcNode")`) can merge in it's * results before the rest of the attributes are added. * * @method _preAddAttrs * @protected * * @param attrs {Object} The full hash of statically defined ATTRS * attributes being added for this instance * * @param userVals {Object} The hash of user values passed to * the constructor * * @param lazy {boolean} Whether or not to add the attributes lazily */ _preAddAttrs : function(attrs, userVals, lazy) { var preAttrs = { id : attrs.id, boundingBox : attrs.boundingBox, contentBox : attrs.contentBox, srcNode : attrs.srcNode }; this.addAttrs(preAttrs, userVals, lazy); delete attrs.boundingBox; delete attrs.contentBox; delete attrs.srcNode; delete attrs.id; if (this._applyParser) { this._applyParser(userVals); } }, /** * @method _applyParsedConfig * @protected * @return {Object} The merged configuration literal */ _applyParsedConfig : function(node, cfg, parsedCfg) { return (parsedCfg) ? Y.mix(cfg, parsedCfg, false) : cfg; }, /** * Utility method used to apply the HTML_PARSER configuration for the * instance, to retrieve config data values. * * @method _applyParser * @protected * @param config {Object} User configuration object (will be populated with values from Node) */ _applyParser : function(config) { var widget = this, srcNode = this._getNodeToParse(), schema = widget._getHtmlParser(), parsedConfig, val; if (schema && srcNode) { Y.Object.each(schema, function(v, k, o) { val = null; if (Lang.isFunction(v)) { val = v.call(widget, srcNode); } else { if (Lang.isArray(v)) { val = srcNode.all(v[0]); if (val.isEmpty()) { val = null; } } else { val = srcNode.one(v); } } if (val !== null && val !== undefined) { parsedConfig = parsedConfig || {}; parsedConfig[k] = val; } }); } config = widget._applyParsedConfig(srcNode, config, parsedConfig); }, /** * Determines whether we have a node reference which we should try and parse. * * The current implementation does not parse nodes generated from CONTENT_TEMPLATE, * only explicitly set srcNode, or contentBox attributes. * * @method _getNodeToParse * @return {Node} The node reference to apply HTML_PARSER to. * @private */ _getNodeToParse : function() { var srcNode = this.get("srcNode"); return (!this._cbFromTemplate) ? srcNode : null; }, /** * Gets the HTML_PARSER definition for this instance, by merging HTML_PARSER * definitions across the class hierarchy. * * @private * @method _getHtmlParser * @return {Object} HTML_PARSER definition for this instance */ _getHtmlParser : function() { // Removed caching for kweight. This is a private method // and only called once so don't need to cache HTML_PARSER var classes = this._getClasses(), parser = {}, i, p; for (i = classes.length - 1; i >= 0; i--) { p = classes[i].HTML_PARSER; if (p) { Y.mix(parser, p, true); } } return parser; } }); }, '3.17.2', {"requires": ["widget-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('widget-skin', function (Y, NAME) { /** * Provides skin related utlility methods. * * @module widget * @submodule widget-skin */ var BOUNDING_BOX = "boundingBox", CONTENT_BOX = "contentBox", SKIN = "skin", _getClassName = Y.ClassNameManager.getClassName; /** * Returns the name of the skin that's currently applied to the widget. * * Searches up the Widget's ancestor axis for, by default, a class * yui3-skin-(name), and returns the (name) portion. Otherwise, returns null. * * This is only really useful after the widget's DOM structure is in the * document, either by render or by progressive enhancement. * * @method getSkinName * @for Widget * @param {String} [skinPrefix] The prefix which the implementation uses for the skin * ("yui3-skin-" is the default). * * NOTE: skinPrefix will be used as part of a regular expression: * * new RegExp('\\b' + skinPrefix + '(\\S+)') * * Although an unlikely use case, literal characters which may result in an invalid * regular expression should be escaped. * * @return {String} The name of the skin, or null, if a matching skin class is not found. */ Y.Widget.prototype.getSkinName = function (skinPrefix) { var root = this.get( CONTENT_BOX ) || this.get( BOUNDING_BOX ), match, search; skinPrefix = skinPrefix || _getClassName(SKIN, ""); search = new RegExp( '\\b' + skinPrefix + '(\\S+)' ); if ( root ) { root.ancestor( function ( node ) { match = node.get( 'className' ).match( search ); return match; } ); } return ( match ) ? match[1] : null; }; }, '3.17.2', {"requires": ["widget-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('widget-uievents', function (Y, NAME) { /** * Support for Widget UI Events (Custom Events fired by the widget, which wrap the underlying DOM events - e.g. widget:click, widget:mousedown) * * @module widget * @submodule widget-uievents */ var BOUNDING_BOX = "boundingBox", Widget = Y.Widget, RENDER = "render", L = Y.Lang, EVENT_PREFIX_DELIMITER = ":", // Map of Node instances serving as a delegation containers for a specific // event type to Widget instances using that delegation container. _uievts = Y.Widget._uievts = Y.Widget._uievts || {}; Y.mix(Widget.prototype, { /** * Destructor logic for UI event infrastructure, * invoked during Widget destruction. * * @method _destroyUIEvents * @for Widget * @private */ _destroyUIEvents: function() { var widgetGuid = Y.stamp(this, true); Y.each(_uievts, function (info, key) { if (info.instances[widgetGuid]) { // Unregister this Widget instance as needing this delegated // event listener. delete info.instances[widgetGuid]; // There are no more Widget instances using this delegated // event listener, so detach it. if (Y.Object.isEmpty(info.instances)) { info.handle.detach(); if (_uievts[key]) { delete _uievts[key]; } } } }); }, /** * Map of DOM events that should be fired as Custom Events by the * Widget instance. * * @property UI_EVENTS * @for Widget * @type Object */ UI_EVENTS: Y.Node.DOM_EVENTS, /** * Returns the node on which to bind delegate listeners. * * @method _getUIEventNode * @for Widget * @protected */ _getUIEventNode: function () { return this.get(BOUNDING_BOX); }, /** * Binds a delegated DOM event listener of the specified type to the * Widget's outtermost DOM element to facilitate the firing of a Custom * Event of the same type for the Widget instance. * * @method _createUIEvent * @for Widget * @param type {String} String representing the name of the event * @private */ _createUIEvent: function (type) { var uiEvtNode = this._getUIEventNode(), key = (Y.stamp(uiEvtNode) + type), info = _uievts[key], handle; // For each Node instance: Ensure that there is only one delegated // event listener used to fire Widget UI events. if (!info) { handle = uiEvtNode.delegate(type, function (evt) { var widget = Widget.getByNode(this); // Widget could be null if node instance belongs to // another Y instance. if (widget) { if (widget._filterUIEvent(evt)) { widget.fire(evt.type, { domEvent: evt }); } } }, "." + Y.Widget.getClassName()); _uievts[key] = info = { instances: {}, handle: handle }; } // Register this Widget as using this Node as a delegation container. info.instances[Y.stamp(this)] = 1; }, /** * This method is used to determine if we should fire * the UI Event or not. The default implementation makes sure * that for nested delegates (nested unrelated widgets), we don't * fire the UI event listener more than once at each level. * *

For example, without the additional filter, if you have nested * widgets, each widget will have a delegate listener. If you * click on the inner widget, the inner delegate listener's * filter will match once, but the outer will match twice * (based on delegate's design) - once for the inner widget, * and once for the outer.

* * @method _filterUIEvent * @for Widget * @param {DOMEventFacade} evt * @return {boolean} true if it's OK to fire the custom UI event, false if not. * @private * */ _filterUIEvent: function(evt) { // Either it's hitting this widget's delegate container (and not some other widget's), // or the container it's hitting is handling this widget's ui events. return (evt.currentTarget.compareTo(evt.container) || evt.container.compareTo(this._getUIEventNode())); }, /** * Determines if the specified event is a UI event. * * @private * @method _isUIEvent * @for Widget * @param type {String} String representing the name of the event * @return {String} Event Returns the name of the UI Event, otherwise * undefined. */ _getUIEvent: function (type) { if (L.isString(type)) { var sType = this.parseType(type)[1], iDelim, returnVal; if (sType) { // TODO: Get delimiter from ET, or have ET support this. iDelim = sType.indexOf(EVENT_PREFIX_DELIMITER); if (iDelim > -1) { sType = sType.substring(iDelim + EVENT_PREFIX_DELIMITER.length); } if (this.UI_EVENTS[sType]) { returnVal = sType; } } return returnVal; } }, /** * Sets up infrastructure required to fire a UI event. * * @private * @method _initUIEvent * @for Widget * @param type {String} String representing the name of the event * @return {String} */ _initUIEvent: function (type) { var sType = this._getUIEvent(type), queue = this._uiEvtsInitQueue || {}; if (sType && !queue[sType]) { this._uiEvtsInitQueue = queue[sType] = 1; this.after(RENDER, function() { this._createUIEvent(sType); delete this._uiEvtsInitQueue[sType]; }); } }, // Override of "on" from Base to facilitate the firing of Widget events // based on DOM events of the same name/type (e.g. "click", "mouseover"). // Temporary solution until we have the ability to listen to when // someone adds an event listener (bug 2528230) on: function (type) { this._initUIEvent(type); return Widget.superclass.on.apply(this, arguments); }, // Override of "publish" from Base to facilitate the firing of Widget events // based on DOM events of the same name/type (e.g. "click", "mouseover"). // Temporary solution until we have the ability to listen to when // someone publishes an event (bug 2528230) publish: function (type, config) { var sType = this._getUIEvent(type); if (sType && config && config.defaultFn) { this._initUIEvent(sType); } return Widget.superclass.publish.apply(this, arguments); } }, true); // overwrite existing EventTarget methods }, '3.17.2', {"requires": ["node-event-delegate", "widget-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('widget-stdmod', function (Y, NAME) { /** * Provides standard module support for Widgets through an extension. * * @module widget-stdmod */ var L = Y.Lang, Node = Y.Node, UA = Y.UA, Widget = Y.Widget, EMPTY = "", HD = "hd", BD = "bd", FT = "ft", HEADER = "header", BODY = "body", FOOTER = "footer", FILL_HEIGHT = "fillHeight", STDMOD = "stdmod", NODE_SUFFIX = "Node", CONTENT_SUFFIX = "Content", FIRST_CHILD = "firstChild", CHILD_NODES = "childNodes", OWNER_DOCUMENT = "ownerDocument", CONTENT_BOX = "contentBox", HEIGHT = "height", OFFSET_HEIGHT = "offsetHeight", AUTO = "auto", HeaderChange = "headerContentChange", BodyChange = "bodyContentChange", FooterChange = "footerContentChange", FillHeightChange = "fillHeightChange", HeightChange = "heightChange", ContentUpdate = "contentUpdate", RENDERUI = "renderUI", BINDUI = "bindUI", SYNCUI = "syncUI", APPLY_PARSED_CONFIG = "_applyParsedConfig", UI = Y.Widget.UI_SRC; /** * Widget extension, which can be used to add Standard Module support to the * base Widget class, through the Base.build * method. *

* The extension adds header, body and footer sections to the Widget's content box and * provides the corresponding methods and attributes to modify the contents of these sections. *

* @class WidgetStdMod * @param {Object} The user configuration object */ function StdMod(config) {} /** * Constant used to refer the the standard module header, in methods which expect a section specifier * * @property HEADER * @static * @type String */ StdMod.HEADER = HEADER; /** * Constant used to refer the the standard module body, in methods which expect a section specifier * * @property BODY * @static * @type String */ StdMod.BODY = BODY; /** * Constant used to refer the the standard module footer, in methods which expect a section specifier * * @property FOOTER * @static * @type String */ StdMod.FOOTER = FOOTER; /** * Constant used to specify insertion position, when adding content to sections of the standard module in * methods which expect a "where" argument. *

* Inserts new content before the sections existing content. *

* @property AFTER * @static * @type String */ StdMod.AFTER = "after"; /** * Constant used to specify insertion position, when adding content to sections of the standard module in * methods which expect a "where" argument. *

* Inserts new content before the sections existing content. *

* @property BEFORE * @static * @type String */ StdMod.BEFORE = "before"; /** * Constant used to specify insertion position, when adding content to sections of the standard module in * methods which expect a "where" argument. *

* Replaces the sections existing content, with new content. *

* @property REPLACE * @static * @type String */ StdMod.REPLACE = "replace"; var STD_HEADER = StdMod.HEADER, STD_BODY = StdMod.BODY, STD_FOOTER = StdMod.FOOTER, HEADER_CONTENT = STD_HEADER + CONTENT_SUFFIX, FOOTER_CONTENT = STD_FOOTER + CONTENT_SUFFIX, BODY_CONTENT = STD_BODY + CONTENT_SUFFIX; /** * Static property used to define the default attribute * configuration introduced by WidgetStdMod. * * @property ATTRS * @type Object * @static */ StdMod.ATTRS = { /** * @attribute headerContent * @type HTML * @default undefined * @description The content to be added to the header section. This will replace any existing content * in the header. If you want to append, or insert new content, use the setStdModContent method. */ headerContent: { value:null }, /** * @attribute footerContent * @type HTML * @default undefined * @description The content to be added to the footer section. This will replace any existing content * in the footer. If you want to append, or insert new content, use the setStdModContent method. */ footerContent: { value:null }, /** * @attribute bodyContent * @type HTML * @default undefined * @description The content to be added to the body section. This will replace any existing content * in the body. If you want to append, or insert new content, use the setStdModContent method. */ bodyContent: { value:null }, /** * @attribute fillHeight * @type {String} * @default WidgetStdMod.BODY * @description The section (WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER) which should be resized to fill the height of the standard module, when a * height is set on the Widget. If a height is not set on the widget, then all sections are sized based on * their content. */ fillHeight: { value: StdMod.BODY, validator: function(val) { return this._validateFillHeight(val); } } }; /** * The HTML parsing rules for the WidgetStdMod class. * * @property HTML_PARSER * @static * @type Object */ StdMod.HTML_PARSER = { headerContent: function(contentBox) { return this._parseStdModHTML(STD_HEADER); }, bodyContent: function(contentBox) { return this._parseStdModHTML(STD_BODY); }, footerContent : function(contentBox) { return this._parseStdModHTML(STD_FOOTER); } }; /** * Static hash of default class names used for the header, * body and footer sections of the standard module, keyed by * the section identifier (WidgetStdMod.STD_HEADER, WidgetStdMod.STD_BODY, WidgetStdMod.STD_FOOTER) * * @property SECTION_CLASS_NAMES * @static * @type Object */ StdMod.SECTION_CLASS_NAMES = { header: Widget.getClassName(HD), body: Widget.getClassName(BD), footer: Widget.getClassName(FT) }; /** * The template HTML strings for each of the standard module sections. Section entries are keyed by the section constants, * WidgetStdMod.HEADER, WidgetStdMod.BODY, WidgetStdMod.FOOTER, and contain the HTML to be added for each section. * e.g. *
     *    {
     *       header : '<div class="yui-widget-hd"></div>',
     *       body : '<div class="yui-widget-bd"></div>',
     *       footer : '<div class="yui-widget-ft"></div>'
     *    }
     * 
* @property TEMPLATES * @type Object * @static */ StdMod.TEMPLATES = { header : '
', body : '
', footer : '
' }; StdMod.prototype = { initializer : function() { this._stdModNode = this.get(CONTENT_BOX); Y.before(this._renderUIStdMod, this, RENDERUI); Y.before(this._bindUIStdMod, this, BINDUI); Y.before(this._syncUIStdMod, this, SYNCUI); }, /** * Synchronizes the UI to match the Widgets standard module state. *

* This method is invoked after syncUI is invoked for the Widget class * using YUI's aop infrastructure. *

* @method _syncUIStdMod * @protected */ _syncUIStdMod : function() { var stdModParsed = this._stdModParsed; if (!stdModParsed || !stdModParsed[HEADER_CONTENT]) { this._uiSetStdMod(STD_HEADER, this.get(HEADER_CONTENT)); } if (!stdModParsed || !stdModParsed[BODY_CONTENT]) { this._uiSetStdMod(STD_BODY, this.get(BODY_CONTENT)); } if (!stdModParsed || !stdModParsed[FOOTER_CONTENT]) { this._uiSetStdMod(STD_FOOTER, this.get(FOOTER_CONTENT)); } this._uiSetFillHeight(this.get(FILL_HEIGHT)); }, /** * Creates/Initializes the DOM for standard module support. *

* This method is invoked after renderUI is invoked for the Widget class * using YUI's aop infrastructure. *

* @method _renderUIStdMod * @protected */ _renderUIStdMod : function() { this._stdModNode.addClass(Widget.getClassName(STDMOD)); this._renderStdModSections(); //This normally goes in bindUI but in order to allow setStdModContent() to work before renderUI //stage, these listeners should be set up at the earliest possible time. this.after(HeaderChange, this._afterHeaderChange); this.after(BodyChange, this._afterBodyChange); this.after(FooterChange, this._afterFooterChange); }, _renderStdModSections : function() { if (L.isValue(this.get(HEADER_CONTENT))) { this._renderStdMod(STD_HEADER); } if (L.isValue(this.get(BODY_CONTENT))) { this._renderStdMod(STD_BODY); } if (L.isValue(this.get(FOOTER_CONTENT))) { this._renderStdMod(STD_FOOTER); } }, /** * Binds event listeners responsible for updating the UI state in response to * Widget standard module related state changes. *

* This method is invoked after bindUI is invoked for the Widget class * using YUI's aop infrastructure. *

* @method _bindUIStdMod * @protected */ _bindUIStdMod : function() { // this.after(HeaderChange, this._afterHeaderChange); // this.after(BodyChange, this._afterBodyChange); // this.after(FooterChange, this._afterFooterChange); this.after(FillHeightChange, this._afterFillHeightChange); this.after(HeightChange, this._fillHeight); this.after(ContentUpdate, this._fillHeight); }, /** * Default attribute change listener for the headerContent attribute, responsible * for updating the UI, in response to attribute changes. * * @method _afterHeaderChange * @protected * @param {EventFacade} e The event facade for the attribute change */ _afterHeaderChange : function(e) { if (e.src !== UI) { this._uiSetStdMod(STD_HEADER, e.newVal, e.stdModPosition); } }, /** * Default attribute change listener for the bodyContent attribute, responsible * for updating the UI, in response to attribute changes. * * @method _afterBodyChange * @protected * @param {EventFacade} e The event facade for the attribute change */ _afterBodyChange : function(e) { if (e.src !== UI) { this._uiSetStdMod(STD_BODY, e.newVal, e.stdModPosition); } }, /** * Default attribute change listener for the footerContent attribute, responsible * for updating the UI, in response to attribute changes. * * @method _afterFooterChange * @protected * @param {EventFacade} e The event facade for the attribute change */ _afterFooterChange : function(e) { if (e.src !== UI) { this._uiSetStdMod(STD_FOOTER, e.newVal, e.stdModPosition); } }, /** * Default attribute change listener for the fillHeight attribute, responsible * for updating the UI, in response to attribute changes. * * @method _afterFillHeightChange * @protected * @param {EventFacade} e The event facade for the attribute change */ _afterFillHeightChange: function (e) { this._uiSetFillHeight(e.newVal); }, /** * Default validator for the fillHeight attribute. Verifies that the * value set is a valid section specifier - one of WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER, * or a falsey value if fillHeight is to be disabled. * * @method _validateFillHeight * @protected * @param {String} val The section which should be setup to fill height, or false/null to disable fillHeight * @return true if valid, false if not */ _validateFillHeight : function(val) { return !val || val == StdMod.BODY || val == StdMod.HEADER || val == StdMod.FOOTER; }, /** * Updates the rendered UI, to resize the provided section so that the standard module fills out * the specified widget height. Note: This method does not check whether or not a height is set * on the Widget. * * @method _uiSetFillHeight * @protected * @param {String} fillSection A valid section specifier - one of WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER */ _uiSetFillHeight : function(fillSection) { var fillNode = this.getStdModNode(fillSection); var currNode = this._currFillNode; if (currNode && fillNode !== currNode){ currNode.setStyle(HEIGHT, EMPTY); } if (fillNode) { this._currFillNode = fillNode; } this._fillHeight(); }, /** * Updates the rendered UI, to resize the current section specified by the fillHeight attribute, so * that the standard module fills out the Widget height. If a height has not been set on Widget, * the section is not resized (height is set to "auto"). * * @method _fillHeight * @private */ _fillHeight : function() { if (this.get(FILL_HEIGHT)) { var height = this.get(HEIGHT); if (height != EMPTY && height != AUTO) { this.fillHeight(this.getStdModNode(this.get(FILL_HEIGHT))); } } }, /** * Updates the rendered UI, adding the provided content (either an HTML string, or node reference), * to the specified section. The content is either added before, after or replaces existing content * in the section, based on the value of the where argument. * * @method _uiSetStdMod * @protected * * @param {String} section The section to be updated. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER. * @param {String | Node} content The new content (either as an HTML string, or Node reference) to add to the section * @param {String} where Optional. Either WidgetStdMod.AFTER, WidgetStdMod.BEFORE or WidgetStdMod.REPLACE. * If not provided, the content will replace existing content in the section. */ _uiSetStdMod : function(section, content, where) { // Using isValue, so that "" is valid content if (L.isValue(content)) { var node = this.getStdModNode(section, true); this._addStdModContent(node, content, where); this.set(section + CONTENT_SUFFIX, this._getStdModContent(section), {src:UI}); } else { this._eraseStdMod(section); } this.fire(ContentUpdate); }, /** * Creates the DOM node for the given section, and inserts it into the correct location in the contentBox. * * @method _renderStdMod * @protected * @param {String} section The section to create/render. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER. * @return {Node} A reference to the added section node */ _renderStdMod : function(section) { var contentBox = this.get(CONTENT_BOX), sectionNode = this._findStdModSection(section); if (!sectionNode) { sectionNode = this._getStdModTemplate(section); } this._insertStdModSection(contentBox, section, sectionNode); this[section + NODE_SUFFIX] = sectionNode; return this[section + NODE_SUFFIX]; }, /** * Removes the DOM node for the given section. * * @method _eraseStdMod * @protected * @param {String} section The section to remove. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER. */ _eraseStdMod : function(section) { var sectionNode = this.getStdModNode(section); if (sectionNode) { sectionNode.remove(true); delete this[section + NODE_SUFFIX]; } }, /** * Helper method to insert the Node for the given section into the correct location in the contentBox. * * @method _insertStdModSection * @private * @param {Node} contentBox A reference to the Widgets content box. * @param {String} section The section to create/render. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER. * @param {Node} sectionNode The Node for the section. */ _insertStdModSection : function(contentBox, section, sectionNode) { var fc = contentBox.get(FIRST_CHILD); if (section === STD_FOOTER || !fc) { contentBox.appendChild(sectionNode); } else { if (section === STD_HEADER) { contentBox.insertBefore(sectionNode, fc); } else { var footer = this[STD_FOOTER + NODE_SUFFIX]; if (footer) { contentBox.insertBefore(sectionNode, footer); } else { contentBox.appendChild(sectionNode); } } } }, /** * Gets a new Node reference for the given standard module section, by cloning * the stored template node. * * @method _getStdModTemplate * @protected * @param {String} section The section to create a new node for. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER. * @return {Node} The new Node instance for the section */ _getStdModTemplate : function(section) { return Node.create(StdMod.TEMPLATES[section], this._stdModNode.get(OWNER_DOCUMENT)); }, /** * Helper method to add content to a StdMod section node. * The content is added either before, after or replaces the existing node content * based on the value of the where argument. * * @method _addStdModContent * @private * * @param {Node} node The section Node to be updated. * @param {Node|NodeList|String} children The new content Node, NodeList or String to be added to section Node provided. * @param {String} where Optional. Either WidgetStdMod.AFTER, WidgetStdMod.BEFORE or WidgetStdMod.REPLACE. * If not provided, the content will replace existing content in the Node. */ _addStdModContent : function(node, children, where) { // StdMod where to Node where switch (where) { case StdMod.BEFORE: // 0 is before fistChild where = 0; break; case StdMod.AFTER: // undefined is appendChild where = undefined; break; default: // replace is replace, not specified is replace where = StdMod.REPLACE; } node.insert(children, where); }, /** * Helper method to obtain the precise height of the node provided, including padding and border. * The height could be a sub-pixel value for certain browsers, such as Firefox 3. * * @method _getPreciseHeight * @private * @param {Node} node The node for which the precise height is required. * @return {Number} The height of the Node including borders and padding, possibly a float. */ _getPreciseHeight : function(node) { var height = (node) ? node.get(OFFSET_HEIGHT) : 0, getBCR = "getBoundingClientRect"; if (node && node.hasMethod(getBCR)) { var preciseRegion = node.invoke(getBCR); if (preciseRegion) { height = preciseRegion.bottom - preciseRegion.top; } } return height; }, /** * Helper method to to find the rendered node for the given section, * if it exists. * * @method _findStdModSection * @private * @param {String} section The section for which the render Node is to be found. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER. * @return {Node} The rendered node for the given section, or null if not found. */ _findStdModSection: function(section) { return this.get(CONTENT_BOX).one("> ." + StdMod.SECTION_CLASS_NAMES[section]); }, /** * Utility method, used by WidgetStdMods HTML_PARSER implementation * to extract data for each section from markup. * * @method _parseStdModHTML * @private * @param {String} section * @return {String} Inner HTML string with the contents of the section */ _parseStdModHTML : function(section) { var node = this._findStdModSection(section); if (node) { if (!this._stdModParsed) { this._stdModParsed = {}; Y.before(this._applyStdModParsedConfig, this, APPLY_PARSED_CONFIG); } this._stdModParsed[section + CONTENT_SUFFIX] = 1; return node.get("innerHTML"); } return null; }, /** * This method is injected before the _applyParsedConfig step in * the application of HTML_PARSER, and sets up the state to * identify whether or not we should remove the current DOM content * or not, based on whether or not the current content attribute value * was extracted from the DOM, or provided by the user configuration * * @method _applyStdModParsedConfig * @private */ _applyStdModParsedConfig : function(node, cfg, parsedCfg) { var parsed = this._stdModParsed; if (parsed) { parsed[HEADER_CONTENT] = !(HEADER_CONTENT in cfg) && (HEADER_CONTENT in parsed); parsed[BODY_CONTENT] = !(BODY_CONTENT in cfg) && (BODY_CONTENT in parsed); parsed[FOOTER_CONTENT] = !(FOOTER_CONTENT in cfg) && (FOOTER_CONTENT in parsed); } }, /** * Retrieves the child nodes (content) of a standard module section * * @method _getStdModContent * @private * @param {String} section The standard module section whose child nodes are to be retrieved. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER. * @return {Node} The child node collection of the standard module section. */ _getStdModContent : function(section) { return (this[section + NODE_SUFFIX]) ? this[section + NODE_SUFFIX].get(CHILD_NODES) : null; }, /** * Updates the body section of the standard module with the content provided (either an HTML string, or node reference). *

* This method can be used instead of the corresponding section content attribute if you'd like to retain the current content of the section, * and insert content before or after it, by specifying the where argument. *

* @method setStdModContent * @param {String} section The standard module section whose content is to be updated. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER. * @param {String | Node} content The content to be added, either an HTML string or a Node reference. * @param {String} where Optional. Either WidgetStdMod.AFTER, WidgetStdMod.BEFORE or WidgetStdMod.REPLACE. * If not provided, the content will replace existing content in the section. */ setStdModContent : function(section, content, where) { //var node = this.getStdModNode(section) || this._renderStdMod(section); this.set(section + CONTENT_SUFFIX, content, {stdModPosition:where}); //this._addStdModContent(node, content, where); }, /** Returns the node reference for the specified `section`. **Note:** The DOM is not queried for the node reference. The reference stored by the widget instance is returned if it was set. Passing a truthy for `forceCreate` will create the section node if it does not already exist. @method getStdModNode @param {String} section The section whose node reference is required. Either `WidgetStdMod.HEADER`, `WidgetStdMod.BODY`, or `WidgetStdMod.FOOTER`. @param {Boolean} forceCreate Whether the section node should be created if it does not already exist. @return {Node} The node reference for the `section`, or null if not set. **/ getStdModNode : function(section, forceCreate) { var node = this[section + NODE_SUFFIX] || null; if (!node && forceCreate) { node = this._renderStdMod(section); } return node; }, /** * Sets the height on the provided header, body or footer element to * fill out the height of the Widget. It determines the height of the * widgets bounding box, based on it's configured height value, and * sets the height of the provided section to fill out any * space remaining after the other standard module section heights * have been accounted for. * *

NOTE: This method is not designed to work if an explicit * height has not been set on the Widget, since for an "auto" height Widget, * the heights of the header/body/footer will drive the height of the Widget.

* * @method fillHeight * @param {Node} node The node which should be resized to fill out the height * of the Widget bounding box. Should be a standard module section node which belongs * to the widget. */ fillHeight : function(node) { if (node) { var contentBox = this.get(CONTENT_BOX), stdModNodes = [this.headerNode, this.bodyNode, this.footerNode], stdModNode, cbContentHeight, filled = 0, remaining = 0, validNode = false; for (var i = 0, l = stdModNodes.length; i < l; i++) { stdModNode = stdModNodes[i]; if (stdModNode) { if (stdModNode !== node) { filled += this._getPreciseHeight(stdModNode); } else { validNode = true; } } } if (validNode) { if (UA.ie || UA.opera) { // Need to set height to 0, to allow height to be reduced node.set(OFFSET_HEIGHT, 0); } cbContentHeight = contentBox.get(OFFSET_HEIGHT) - parseInt(contentBox.getComputedStyle("paddingTop"), 10) - parseInt(contentBox.getComputedStyle("paddingBottom"), 10) - parseInt(contentBox.getComputedStyle("borderBottomWidth"), 10) - parseInt(contentBox.getComputedStyle("borderTopWidth"), 10); if (L.isNumber(cbContentHeight)) { remaining = cbContentHeight - filled; if (remaining >= 0) { node.set(OFFSET_HEIGHT, remaining); } } } } } }; Y.WidgetStdMod = StdMod; }, '3.17.2', {"requires": ["base-build", "widget"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('widget-position', function (Y, NAME) { /** * Provides basic XY positioning support for Widgets, though an extension * * @module widget-position */ var Lang = Y.Lang, Widget = Y.Widget, XY_COORD = "xy", POSITION = "position", POSITIONED = "positioned", BOUNDING_BOX = "boundingBox", RELATIVE = "relative", RENDERUI = "renderUI", BINDUI = "bindUI", SYNCUI = "syncUI", UI = Widget.UI_SRC, XYChange = "xyChange"; /** * Widget extension, which can be used to add positioning support to the base Widget class, * through the Base.build method. * * @class WidgetPosition * @param {Object} config User configuration object */ function Position(config) { } /** * Static property used to define the default attribute * configuration introduced by WidgetPosition. * * @property ATTRS * @static * @type Object */ Position.ATTRS = { /** * @attribute x * @type number * @default 0 * * @description Page X co-ordinate for the widget. This attribute acts as a facade for the * xy attribute. Changes in position can be monitored by listening for xyChange events. */ x: { setter: function(val) { this._setX(val); }, getter: function() { return this._getX(); }, lazyAdd:false }, /** * @attribute y * @type number * @default 0 * * @description Page Y co-ordinate for the widget. This attribute acts as a facade for the * xy attribute. Changes in position can be monitored by listening for xyChange events. */ y: { setter: function(val) { this._setY(val); }, getter: function() { return this._getY(); }, lazyAdd: false }, /** * @attribute xy * @type Array * @default [0,0] * * @description Page XY co-ordinate pair for the widget. */ xy: { value:[0,0], validator: function(val) { return this._validateXY(val); } } }; /** * Default class used to mark the boundingBox of a positioned widget. * * @property POSITIONED_CLASS_NAME * @type String * @default "yui-widget-positioned" * @static */ Position.POSITIONED_CLASS_NAME = Widget.getClassName(POSITIONED); Position.prototype = { initializer : function() { this._posNode = this.get(BOUNDING_BOX); // WIDGET METHOD OVERLAP Y.after(this._renderUIPosition, this, RENDERUI); Y.after(this._syncUIPosition, this, SYNCUI); Y.after(this._bindUIPosition, this, BINDUI); }, /** * Creates/Initializes the DOM to support xy page positioning. *

* This method in invoked after renderUI is invoked for the Widget class * using YUI's aop infrastructure. *

* @method _renderUIPosition * @protected */ _renderUIPosition : function() { this._posNode.addClass(Position.POSITIONED_CLASS_NAME); }, /** * Synchronizes the UI to match the Widgets xy page position state. *

* This method in invoked after syncUI is invoked for the Widget class * using YUI's aop infrastructure. *

* @method _syncUIPosition * @protected */ _syncUIPosition : function() { var posNode = this._posNode; if (posNode.getStyle(POSITION) === RELATIVE) { this.syncXY(); } this._uiSetXY(this.get(XY_COORD)); }, /** * Binds event listeners responsible for updating the UI state in response to * Widget position related state changes. *

* This method in invoked after bindUI is invoked for the Widget class * using YUI's aop infrastructure. *

* @method _bindUIPosition * @protected */ _bindUIPosition :function() { this.after(XYChange, this._afterXYChange); }, /** * Moves the Widget to the specified page xy co-ordinate position. * * @method move * * @param {Number|Number[]} x The new x position or [x, y] values passed * as an array to support simple pass through of Node.getXY results * @param {Number} [y] The new y position */ move: function () { var args = arguments, coord = (Lang.isArray(args[0])) ? args[0] : [args[0], args[1]]; this.set(XY_COORD, coord); }, /** * Synchronizes the Panel's "xy", "x", and "y" properties with the * Widget's position in the DOM. * * @method syncXY */ syncXY : function () { this.set(XY_COORD, this._posNode.getXY(), {src: UI}); }, /** * Default validator for the XY attribute * * @method _validateXY * @protected * @param {Array} val The XY page co-ordinate value which is being set. * @return {boolean} true if valid, false if not. */ _validateXY : function(val) { return (Lang.isArray(val) && Lang.isNumber(val[0]) && Lang.isNumber(val[1])); }, /** * Default setter for the X attribute. The setter passes the X value through * to the XY attribute, which is the sole store for the XY state. * * @method _setX * @protected * @param {Number} val The X page co-ordinate value */ _setX : function(val) { this.set(XY_COORD, [val, this.get(XY_COORD)[1]]); }, /** * Default setter for the Y attribute. The setter passes the Y value through * to the XY attribute, which is the sole store for the XY state. * * @method _setY * @protected * @param {Number} val The Y page co-ordinate value */ _setY : function(val) { this.set(XY_COORD, [this.get(XY_COORD)[0], val]); }, /** * Default getter for the X attribute. The value is retrieved from * the XY attribute, which is the sole store for the XY state. * * @method _getX * @protected * @return {Number} The X page co-ordinate value */ _getX : function() { return this.get(XY_COORD)[0]; }, /** * Default getter for the Y attribute. The value is retrieved from * the XY attribute, which is the sole store for the XY state. * * @method _getY * @protected * @return {Number} The Y page co-ordinate value */ _getY : function() { return this.get(XY_COORD)[1]; }, /** * Default attribute change listener for the xy attribute, responsible * for updating the UI, in response to attribute changes. * * @method _afterXYChange * @protected * @param {EventFacade} e The event facade for the attribute change */ _afterXYChange : function(e) { if (e.src != UI) { this._uiSetXY(e.newVal); } }, /** * Updates the UI to reflect the XY page co-ordinates passed in. * * @method _uiSetXY * @protected * @param {String} val The XY page co-ordinates value to be reflected in the UI */ _uiSetXY : function(val) { this._posNode.setXY(val); } }; Y.WidgetPosition = Position; }, '3.17.2', {"requires": ["base-build", "node-screen", "widget"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('widget-position-align', function (Y, NAME) { /** Provides extended/advanced XY positioning support for Widgets, through an extension. It builds on top of the `widget-position` module, to provide alignment and centering support. Future releases aim to add constrained and fixed positioning support. @module widget-position-align **/ var Lang = Y.Lang, ALIGN = 'align', ALIGN_ON = 'alignOn', VISIBLE = 'visible', BOUNDING_BOX = 'boundingBox', OFFSET_WIDTH = 'offsetWidth', OFFSET_HEIGHT = 'offsetHeight', REGION = 'region', VIEWPORT_REGION = 'viewportRegion'; /** Widget extension, which can be used to add extended XY positioning support to the base Widget class, through the `Base.create` method. **Note:** This extension requires that the `WidgetPosition` extension be added to the Widget (before `WidgetPositionAlign`, if part of the same extension list passed to `Base.build`). @class WidgetPositionAlign @param {Object} config User configuration object. @constructor **/ function PositionAlign (config) {} PositionAlign.ATTRS = { /** The alignment configuration for this widget. The `align` attribute is used to align a reference point on the widget, with the reference point on another `Node`, or the viewport. The object which `align` expects has the following properties: * __`node`__: The `Node` to which the widget is to be aligned. If set to `null`, or not provided, the widget is aligned to the viewport. * __`points`__: A two element Array, defining the two points on the widget and `Node`/viewport which are to be aligned. The first element is the point on the widget, and the second element is the point on the `Node`/viewport. Supported alignment points are defined as static properties on `WidgetPositionAlign`. @example Aligns the top-right corner of the widget with the top-left corner of the viewport: myWidget.set('align', { points: [Y.WidgetPositionAlign.TR, Y.WidgetPositionAlign.TL] }); @attribute align @type Object @default null **/ align: { value: null }, /** A convenience Attribute, which can be used as a shortcut for the `align` Attribute. If set to `true`, the widget is centered in the viewport. If set to a `Node` reference or valid selector String, the widget will be centered within the `Node`. If set to `false`, no center positioning is applied. @attribute centered @type Boolean|Node @default false **/ centered: { setter : '_setAlignCenter', lazyAdd:false, value :false }, /** An Array of Objects corresponding to the `Node`s and events that will cause the alignment of this widget to be synced to the DOM. The `alignOn` Attribute is expected to be an Array of Objects with the following properties: * __`eventName`__: The String event name to listen for. * __`node`__: The optional `Node` that will fire the event, it can be a `Node` reference or a selector String. This will default to the widget's `boundingBox`. @example Sync this widget's alignment on window resize: myWidget.set('alignOn', [ { node : Y.one('win'), eventName: 'resize' } ]); @attribute alignOn @type Array @default [] **/ alignOn: { value : [], validator: Y.Lang.isArray } }; /** Constant used to specify the top-left corner for alignment @property TL @type String @value 'tl' @static **/ PositionAlign.TL = 'tl'; /** Constant used to specify the top-right corner for alignment @property TR @type String @value 'tr' @static **/ PositionAlign.TR = 'tr'; /** Constant used to specify the bottom-left corner for alignment @property BL @type String @value 'bl' @static **/ PositionAlign.BL = 'bl'; /** Constant used to specify the bottom-right corner for alignment @property BR @type String @value 'br' @static **/ PositionAlign.BR = 'br'; /** Constant used to specify the top edge-center point for alignment @property TC @type String @value 'tc' @static **/ PositionAlign.TC = 'tc'; /** Constant used to specify the right edge, center point for alignment @property RC @type String @value 'rc' @static **/ PositionAlign.RC = 'rc'; /** Constant used to specify the bottom edge, center point for alignment @property BC @type String @value 'bc' @static **/ PositionAlign.BC = 'bc'; /** Constant used to specify the left edge, center point for alignment @property LC @type String @value 'lc' @static **/ PositionAlign.LC = 'lc'; /** Constant used to specify the center of widget/node/viewport for alignment @property CC @type String @value 'cc' @static */ PositionAlign.CC = 'cc'; PositionAlign.prototype = { // -- Protected Properties ------------------------------------------------- initializer : function() { if (!this._posNode) { Y.error('WidgetPosition needs to be added to the Widget, ' + 'before WidgetPositionAlign is added'); } Y.after(this._bindUIPosAlign, this, 'bindUI'); Y.after(this._syncUIPosAlign, this, 'syncUI'); }, /** Holds the alignment-syncing event handles. @property _posAlignUIHandles @type Array @default null @protected **/ _posAlignUIHandles: null, // -- Lifecycle Methods ---------------------------------------------------- destructor: function () { this._detachPosAlignUIHandles(); }, /** Bind event listeners responsible for updating the UI state in response to the widget's position-align related state changes. This method is invoked after `bindUI` has been invoked for the `Widget` class using the AOP infrastructure. @method _bindUIPosAlign @protected **/ _bindUIPosAlign: function () { this.after('alignChange', this._afterAlignChange); this.after('alignOnChange', this._afterAlignOnChange); this.after('visibleChange', this._syncUIPosAlign); }, /** Synchronizes the current `align` Attribute value to the DOM. This method is invoked after `syncUI` has been invoked for the `Widget` class using the AOP infrastructure. @method _syncUIPosAlign @protected **/ _syncUIPosAlign: function () { var align = this.get(ALIGN); this._uiSetVisiblePosAlign(this.get(VISIBLE)); if (align) { this._uiSetAlign(align.node, align.points); } }, // -- Public Methods ------------------------------------------------------- /** Aligns this widget to the provided `Node` (or viewport) using the provided points. This method can be invoked with no arguments which will cause the widget's current `align` Attribute value to be synced to the DOM. @example Aligning to the top-left corner of the ``: myWidget.align('body', [Y.WidgetPositionAlign.TL, Y.WidgetPositionAlign.TR]); @method align @param {Node|String|null} [node] A reference (or selector String) for the `Node` which with the widget is to be aligned. If null is passed in, the widget will be aligned with the viewport. @param {Array[2]} [points] A two item array specifying the points on the widget and `Node`/viewport which will to be aligned. The first entry is the point on the widget, and the second entry is the point on the `Node`/viewport. Valid point references are defined as static constants on the `WidgetPositionAlign` extension. @chainable **/ align: function (node, points) { if (arguments.length) { // Set the `align` Attribute. this.set(ALIGN, { node : node, points: points }); } else { // Sync the current `align` Attribute value to the DOM. this._syncUIPosAlign(); } return this; }, /** Centers the widget in the viewport, or if a `Node` is passed in, it will be centered to that `Node`. @method centered @param {Node|String} [node] A `Node` reference or selector String defining the `Node` which the widget should be centered. If a `Node` is not passed in, then the widget will be centered to the viewport. @chainable **/ centered: function (node) { return this.align(node, [PositionAlign.CC, PositionAlign.CC]); }, // -- Protected Methods ---------------------------------------------------- /** Default setter for `center` Attribute changes. Sets up the appropriate value, and passes it through the to the align attribute. @method _setAlignCenter @param {Boolean|Node} val The Attribute value being set. @return {Boolean|Node} the value passed in. @protected **/ _setAlignCenter: function (val) { if (val) { this.set(ALIGN, { node : val === true ? null : val, points: [PositionAlign.CC, PositionAlign.CC] }); } return val; }, /** Updates the UI to reflect the `align` value passed in. **Note:** See the `align` Attribute documentation, for the Object structure expected. @method _uiSetAlign @param {Node|String|null} [node] The node to align to, or null to indicate the viewport. @param {Array} points The alignment points. @protected **/ _uiSetAlign: function (node, points) { if ( ! Lang.isArray(points) || points.length !== 2) { Y.error('align: Invalid Points Arguments'); return; } var nodeRegion = this._getRegion(node), widgetPoint, nodePoint, xy; if ( ! nodeRegion) { // No-op, nothing to align to. return; } widgetPoint = points[0]; nodePoint = points[1]; // TODO: Optimize KWeight - Would lookup table help? switch (nodePoint) { case PositionAlign.TL: xy = [nodeRegion.left, nodeRegion.top]; break; case PositionAlign.TR: xy = [nodeRegion.right, nodeRegion.top]; break; case PositionAlign.BL: xy = [nodeRegion.left, nodeRegion.bottom]; break; case PositionAlign.BR: xy = [nodeRegion.right, nodeRegion.bottom]; break; case PositionAlign.TC: xy = [ nodeRegion.left + Math.floor(nodeRegion.width / 2), nodeRegion.top ]; break; case PositionAlign.BC: xy = [ nodeRegion.left + Math.floor(nodeRegion.width / 2), nodeRegion.bottom ]; break; case PositionAlign.LC: xy = [ nodeRegion.left, nodeRegion.top + Math.floor(nodeRegion.height / 2) ]; break; case PositionAlign.RC: xy = [ nodeRegion.right, nodeRegion.top + Math.floor(nodeRegion.height / 2) ]; break; case PositionAlign.CC: xy = [ nodeRegion.left + Math.floor(nodeRegion.width / 2), nodeRegion.top + Math.floor(nodeRegion.height / 2) ]; break; default: break; } if (xy) { this._doAlign(widgetPoint, xy[0], xy[1]); } }, /** Attaches or detaches alignment-syncing event handlers based on the widget's `visible` Attribute state. @method _uiSetVisiblePosAlign @param {Boolean} visible The current value of the widget's `visible` Attribute. @protected **/ _uiSetVisiblePosAlign: function (visible) { if (visible) { this._attachPosAlignUIHandles(); } else { this._detachPosAlignUIHandles(); } }, /** Attaches the alignment-syncing event handlers. @method _attachPosAlignUIHandles @protected **/ _attachPosAlignUIHandles: function () { if (this._posAlignUIHandles) { // No-op if we have already setup the event handlers. return; } var bb = this.get(BOUNDING_BOX), syncAlign = Y.bind(this._syncUIPosAlign, this), handles = []; Y.Array.each(this.get(ALIGN_ON), function (o) { var event = o.eventName, node = Y.one(o.node) || bb; if (event) { handles.push(node.on(event, syncAlign)); } }); this._posAlignUIHandles = handles; }, /** Detaches the alignment-syncing event handlers. @method _detachPosAlignUIHandles @protected **/ _detachPosAlignUIHandles: function () { var handles = this._posAlignUIHandles; if (handles) { new Y.EventHandle(handles).detach(); this._posAlignUIHandles = null; } }, // -- Private Methods ------------------------------------------------------ /** Helper method, used to align the given point on the widget, with the XY page coordinates provided. @method _doAlign @param {String} widgetPoint Supported point constant (e.g. WidgetPositionAlign.TL) @param {Number} x X page coordinate to align to. @param {Number} y Y page coordinate to align to. @private **/ _doAlign: function (widgetPoint, x, y) { var widgetNode = this._posNode, xy; switch (widgetPoint) { case PositionAlign.TL: xy = [x, y]; break; case PositionAlign.TR: xy = [ x - widgetNode.get(OFFSET_WIDTH), y ]; break; case PositionAlign.BL: xy = [ x, y - widgetNode.get(OFFSET_HEIGHT) ]; break; case PositionAlign.BR: xy = [ x - widgetNode.get(OFFSET_WIDTH), y - widgetNode.get(OFFSET_HEIGHT) ]; break; case PositionAlign.TC: xy = [ x - (widgetNode.get(OFFSET_WIDTH) / 2), y ]; break; case PositionAlign.BC: xy = [ x - (widgetNode.get(OFFSET_WIDTH) / 2), y - widgetNode.get(OFFSET_HEIGHT) ]; break; case PositionAlign.LC: xy = [ x, y - (widgetNode.get(OFFSET_HEIGHT) / 2) ]; break; case PositionAlign.RC: xy = [ x - widgetNode.get(OFFSET_WIDTH), y - (widgetNode.get(OFFSET_HEIGHT) / 2) ]; break; case PositionAlign.CC: xy = [ x - (widgetNode.get(OFFSET_WIDTH) / 2), y - (widgetNode.get(OFFSET_HEIGHT) / 2) ]; break; default: break; } if (xy) { this.move(xy); } }, /** Returns the region of the passed-in `Node`, or the viewport region if calling with passing in a `Node`. @method _getRegion @param {Node} [node] The node to get the region of. @return {Object} The node's region. @private **/ _getRegion: function (node) { var nodeRegion; if ( ! node) { nodeRegion = this._posNode.get(VIEWPORT_REGION); } else { node = Y.Node.one(node); if (node) { nodeRegion = node.get(REGION); } } return nodeRegion; }, // -- Protected Event Handlers --------------------------------------------- /** Handles `alignChange` events by updating the UI in response to `align` Attribute changes. @method _afterAlignChange @param {EventFacade} e @protected **/ _afterAlignChange: function (e) { var align = e.newVal; if (align) { this._uiSetAlign(align.node, align.points); } }, /** Handles `alignOnChange` events by updating the alignment-syncing event handlers. @method _afterAlignOnChange @param {EventFacade} e @protected **/ _afterAlignOnChange: function(e) { this._detachPosAlignUIHandles(); if (this.get(VISIBLE)) { this._attachPosAlignUIHandles(); } } }; Y.WidgetPositionAlign = PositionAlign; }, '3.17.2', {"requires": ["widget-position"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('widget-stack', function (Y, NAME) { /** * Provides stackable (z-index) support for Widgets through an extension. * * @module widget-stack */ var L = Y.Lang, UA = Y.UA, Node = Y.Node, Widget = Y.Widget, ZINDEX = "zIndex", SHIM = "shim", VISIBLE = "visible", BOUNDING_BOX = "boundingBox", RENDER_UI = "renderUI", BIND_UI = "bindUI", SYNC_UI = "syncUI", OFFSET_WIDTH = "offsetWidth", OFFSET_HEIGHT = "offsetHeight", PARENT_NODE = "parentNode", FIRST_CHILD = "firstChild", OWNER_DOCUMENT = "ownerDocument", WIDTH = "width", HEIGHT = "height", PX = "px", // HANDLE KEYS SHIM_DEFERRED = "shimdeferred", SHIM_RESIZE = "shimresize", // Events VisibleChange = "visibleChange", WidthChange = "widthChange", HeightChange = "heightChange", ShimChange = "shimChange", ZIndexChange = "zIndexChange", ContentUpdate = "contentUpdate", // CSS STACKED = "stacked"; /** * Widget extension, which can be used to add stackable (z-index) support to the * base Widget class along with a shimming solution, through the * Base.build method. * * @class WidgetStack * @param {Object} User configuration object */ function Stack(config) {} // Static Properties /** * Static property used to define the default attribute * configuration introduced by WidgetStack. * * @property ATTRS * @type Object * @static */ Stack.ATTRS = { /** * @attribute shim * @type boolean * @default false, for all browsers other than IE6, for which a shim is enabled by default. * * @description Boolean flag to indicate whether or not a shim should be added to the Widgets * boundingBox, to protect it from select box bleedthrough. */ shim: { value: (UA.ie == 6) }, /** * @attribute zIndex * @type number * @default 0 * @description The z-index to apply to the Widgets boundingBox. Non-numerical values for * zIndex will be converted to 0 */ zIndex: { value : 0, setter: '_setZIndex' } }; /** * The HTML parsing rules for the WidgetStack class. * * @property HTML_PARSER * @static * @type Object */ Stack.HTML_PARSER = { zIndex: function (srcNode) { return this._parseZIndex(srcNode); } }; /** * Default class used to mark the shim element * * @property SHIM_CLASS_NAME * @type String * @static * @default "yui3-widget-shim" */ Stack.SHIM_CLASS_NAME = Widget.getClassName(SHIM); /** * Default class used to mark the boundingBox of a stacked widget. * * @property STACKED_CLASS_NAME * @type String * @static * @default "yui3-widget-stacked" */ Stack.STACKED_CLASS_NAME = Widget.getClassName(STACKED); /** * Default markup template used to generate the shim element. * * @property SHIM_TEMPLATE * @type String * @static */ Stack.SHIM_TEMPLATE = ''; Stack.prototype = { initializer : function() { this._stackNode = this.get(BOUNDING_BOX); this._stackHandles = {}; // WIDGET METHOD OVERLAP Y.after(this._renderUIStack, this, RENDER_UI); Y.after(this._syncUIStack, this, SYNC_UI); Y.after(this._bindUIStack, this, BIND_UI); }, /** * Synchronizes the UI to match the Widgets stack state. This method in * invoked after syncUI is invoked for the Widget class using YUI's aop infrastructure. * * @method _syncUIStack * @protected */ _syncUIStack: function() { this._uiSetShim(this.get(SHIM)); this._uiSetZIndex(this.get(ZINDEX)); }, /** * Binds event listeners responsible for updating the UI state in response to * Widget stack related state changes. *

* This method is invoked after bindUI is invoked for the Widget class * using YUI's aop infrastructure. *

* @method _bindUIStack * @protected */ _bindUIStack: function() { this.after(ShimChange, this._afterShimChange); this.after(ZIndexChange, this._afterZIndexChange); }, /** * Creates/Initializes the DOM to support stackability. *

* This method in invoked after renderUI is invoked for the Widget class * using YUI's aop infrastructure. *

* @method _renderUIStack * @protected */ _renderUIStack: function() { this._stackNode.addClass(Stack.STACKED_CLASS_NAME); }, /** Parses a `zIndex` attribute value from this widget's `srcNode`. @method _parseZIndex @param {Node} srcNode The node to parse a `zIndex` value from. @return {Mixed} The parsed `zIndex` value. @protected **/ _parseZIndex: function (srcNode) { var zIndex; // Prefers how WebKit handles `z-index` which better matches the // spec: // // * http://www.w3.org/TR/CSS2/visuren.html#z-index // * https://bugs.webkit.org/show_bug.cgi?id=15562 // // When a node isn't rendered in the document, and/or when a // node is not positioned, then it doesn't have a context to derive // a valid `z-index` value from. if (!srcNode.inDoc() || srcNode.getStyle('position') === 'static') { zIndex = 'auto'; } else { // Uses `getComputedStyle()` because it has greater accuracy in // more browsers than `getStyle()` does for `z-index`. zIndex = srcNode.getComputedStyle('zIndex'); } // This extension adds a stacking context to widgets, therefore a // `srcNode` witout a stacking context (i.e. "auto") will return // `null` from this DOM parser. This way the widget's default or // user provided value for `zIndex` will be used. return zIndex === 'auto' ? null : zIndex; }, /** * Default setter for zIndex attribute changes. Normalizes zIndex values to * numbers, converting non-numerical values to 0. * * @method _setZIndex * @protected * @param {String | Number} zIndex * @return {Number} Normalized zIndex */ _setZIndex: function(zIndex) { if (L.isString(zIndex)) { zIndex = parseInt(zIndex, 10); } if (!L.isNumber(zIndex)) { zIndex = 0; } return zIndex; }, /** * Default attribute change listener for the shim attribute, responsible * for updating the UI, in response to attribute changes. * * @method _afterShimChange * @protected * @param {EventFacade} e The event facade for the attribute change */ _afterShimChange : function(e) { this._uiSetShim(e.newVal); }, /** * Default attribute change listener for the zIndex attribute, responsible * for updating the UI, in response to attribute changes. * * @method _afterZIndexChange * @protected * @param {EventFacade} e The event facade for the attribute change */ _afterZIndexChange : function(e) { this._uiSetZIndex(e.newVal); }, /** * Updates the UI to reflect the zIndex value passed in. * * @method _uiSetZIndex * @protected * @param {number} zIndex The zindex to be reflected in the UI */ _uiSetZIndex: function (zIndex) { this._stackNode.setStyle(ZINDEX, zIndex); }, /** * Updates the UI to enable/disable the shim. If the widget is not currently visible, * creation of the shim is deferred until it is made visible, for performance reasons. * * @method _uiSetShim * @protected * @param {boolean} enable If true, creates/renders the shim, if false, removes it. */ _uiSetShim: function (enable) { if (enable) { // Lazy creation if (this.get(VISIBLE)) { this._renderShim(); } else { this._renderShimDeferred(); } // Eagerly attach resize handlers // // Required because of Event stack behavior, commit ref: cd8dddc // Should be revisted after Ticket #2531067 is resolved. if (UA.ie == 6) { this._addShimResizeHandlers(); } } else { this._destroyShim(); } }, /** * Sets up change handlers for the visible attribute, to defer shim creation/rendering * until the Widget is made visible. * * @method _renderShimDeferred * @private */ _renderShimDeferred : function() { this._stackHandles[SHIM_DEFERRED] = this._stackHandles[SHIM_DEFERRED] || []; var handles = this._stackHandles[SHIM_DEFERRED], createBeforeVisible = function(e) { if (e.newVal) { this._renderShim(); } }; handles.push(this.on(VisibleChange, createBeforeVisible)); // Depending how how Ticket #2531067 is resolved, a reversal of // commit ref: cd8dddc could lead to a more elagent solution, with // the addition of this line here: // // handles.push(this.after(VisibleChange, this.sizeShim)); }, /** * Sets up event listeners to resize the shim when the size of the Widget changes. *

* NOTE: This method is only used for IE6 currently, since IE6 doesn't support a way to * resize the shim purely through CSS, when the Widget does not have an explicit width/height * set. *

* @method _addShimResizeHandlers * @private */ _addShimResizeHandlers : function() { this._stackHandles[SHIM_RESIZE] = this._stackHandles[SHIM_RESIZE] || []; var sizeShim = this.sizeShim, handles = this._stackHandles[SHIM_RESIZE]; handles.push(this.after(VisibleChange, sizeShim)); handles.push(this.after(WidthChange, sizeShim)); handles.push(this.after(HeightChange, sizeShim)); handles.push(this.after(ContentUpdate, sizeShim)); }, /** * Detaches any handles stored for the provided key * * @method _detachStackHandles * @param String handleKey The key defining the group of handles which should be detached * @private */ _detachStackHandles : function(handleKey) { var handles = this._stackHandles[handleKey], handle; if (handles && handles.length > 0) { while((handle = handles.pop())) { handle.detach(); } } }, /** * Creates the shim element and adds it to the DOM * * @method _renderShim * @private */ _renderShim : function() { var shimEl = this._shimNode, stackEl = this._stackNode; if (!shimEl) { shimEl = this._shimNode = this._getShimTemplate(); stackEl.insertBefore(shimEl, stackEl.get(FIRST_CHILD)); this._detachStackHandles(SHIM_DEFERRED); this.sizeShim(); } }, /** * Removes the shim from the DOM, and detaches any related event * listeners. * * @method _destroyShim * @private */ _destroyShim : function() { if (this._shimNode) { this._shimNode.get(PARENT_NODE).removeChild(this._shimNode); this._shimNode = null; this._detachStackHandles(SHIM_DEFERRED); this._detachStackHandles(SHIM_RESIZE); } }, /** * For IE6, synchronizes the size and position of iframe shim to that of * Widget bounding box which it is protecting. For all other browsers, * this method does not do anything. * * @method sizeShim */ sizeShim: function () { var shim = this._shimNode, node = this._stackNode; if (shim && UA.ie === 6 && this.get(VISIBLE)) { shim.setStyle(WIDTH, node.get(OFFSET_WIDTH) + PX); shim.setStyle(HEIGHT, node.get(OFFSET_HEIGHT) + PX); } }, /** * Creates a cloned shim node, using the SHIM_TEMPLATE html template, for use on a new instance. * * @method _getShimTemplate * @private * @return {Node} node A new shim Node instance. */ _getShimTemplate : function() { return Node.create(Stack.SHIM_TEMPLATE, this._stackNode.get(OWNER_DOCUMENT)); } }; Y.WidgetStack = Stack; }, '3.17.2', {"requires": ["base-build", "widget"], "skinnable": true}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('widget-position-constrain', function (Y, NAME) { /** * Provides constrained xy positioning support for Widgets, through an extension. * * It builds on top of the widget-position module, to provide constrained positioning support. * * @module widget-position-constrain */ var CONSTRAIN = "constrain", CONSTRAIN_XYCHANGE = "constrain|xyChange", CONSTRAIN_CHANGE = "constrainChange", PREVENT_OVERLAP = "preventOverlap", ALIGN = "align", EMPTY_STR = "", BINDUI = "bindUI", XY = "xy", X_COORD = "x", Y_COORD = "y", Node = Y.Node, VIEWPORT_REGION = "viewportRegion", REGION = "region", PREVENT_OVERLAP_MAP; /** * A widget extension, which can be used to add constrained xy positioning support to the base Widget class, * through the Base.build method. This extension requires that * the WidgetPosition extension be added to the Widget (before WidgetPositionConstrain, if part of the same * extension list passed to Base.build). * * @class WidgetPositionConstrain * @param {Object} User configuration object */ function PositionConstrain(config) {} /** * Static property used to define the default attribute * configuration introduced by WidgetPositionConstrain. * * @property ATTRS * @type Object * @static */ PositionConstrain.ATTRS = { /** * @attribute constrain * @type boolean | Node * @default null * @description The node to constrain the widget's bounding box to, when setting xy. Can also be * set to true, to constrain to the viewport. */ constrain : { value: null, setter: "_setConstrain" }, /** * @attribute preventOverlap * @type boolean * @description If set to true, and WidgetPositionAlign is also added to the Widget, * constrained positioning will attempt to prevent the widget's bounding box from overlapping * the element to which it has been aligned, by flipping the orientation of the alignment * for corner based alignments */ preventOverlap : { value:false } }; /** * @property _PREVENT_OVERLAP * @static * @protected * @type Object * @description The set of positions for which to prevent * overlap. */ PREVENT_OVERLAP_MAP = PositionConstrain._PREVENT_OVERLAP = { x: { "tltr": 1, "blbr": 1, "brbl": 1, "trtl": 1 }, y : { "trbr": 1, "tlbl": 1, "bltl": 1, "brtr": 1 } }; PositionConstrain.prototype = { initializer : function() { if (!this._posNode) { Y.error("WidgetPosition needs to be added to the Widget, before WidgetPositionConstrain is added"); } Y.after(this._bindUIPosConstrained, this, BINDUI); }, /** * Calculates the constrained positions for the XY positions provided, using * the provided node argument is passed in. If no node value is passed in, the value of * the "constrain" attribute is used. * * @method getConstrainedXY * @param {Array} xy The xy values to constrain * @param {Node | boolean} node Optional. The node to constrain to, or true for the viewport * @return {Array} The constrained xy values */ getConstrainedXY : function(xy, node) { node = node || this.get(CONSTRAIN); var constrainingRegion = this._getRegion((node === true) ? null : node), nodeRegion = this._posNode.get(REGION); return [ this._constrain(xy[0], X_COORD, nodeRegion, constrainingRegion), this._constrain(xy[1], Y_COORD, nodeRegion, constrainingRegion) ]; }, /** * Constrains the widget's bounding box to a node (or the viewport). If xy or node are not * passed in, the current position and the value of "constrain" will be used respectively. * * The widget's position will be changed to the constrained position. * * @method constrain * @param {Array} xy Optional. The xy values to constrain * @param {Node | boolean} node Optional. The node to constrain to, or true for the viewport */ constrain : function(xy, node) { var currentXY, constrainedXY, constraint = node || this.get(CONSTRAIN); if (constraint) { currentXY = xy || this.get(XY); constrainedXY = this.getConstrainedXY(currentXY, constraint); if (constrainedXY[0] !== currentXY[0] || constrainedXY[1] !== currentXY[1]) { this.set(XY, constrainedXY, { constrained:true }); } } }, /** * The setter implementation for the "constrain" attribute. * * @method _setConstrain * @protected * @param {Node | boolean} val The attribute value */ _setConstrain : function(val) { return (val === true) ? val : Node.one(val); }, /** * The method which performs the actual constrain calculations for a given axis ("x" or "y") based * on the regions provided. * * @method _constrain * @protected * * @param {Number} val The value to constrain * @param {String} axis The axis to use for constrainment * @param {Region} nodeRegion The region of the node to constrain * @param {Region} constrainingRegion The region of the node (or viewport) to constrain to * * @return {Number} The constrained value */ _constrain: function(val, axis, nodeRegion, constrainingRegion) { if (constrainingRegion) { if (this.get(PREVENT_OVERLAP)) { val = this._preventOverlap(val, axis, nodeRegion, constrainingRegion); } var x = (axis == X_COORD), regionSize = (x) ? constrainingRegion.width : constrainingRegion.height, nodeSize = (x) ? nodeRegion.width : nodeRegion.height, minConstraint = (x) ? constrainingRegion.left : constrainingRegion.top, maxConstraint = (x) ? constrainingRegion.right - nodeSize : constrainingRegion.bottom - nodeSize; if (val < minConstraint || val > maxConstraint) { if (nodeSize < regionSize) { if (val < minConstraint) { val = minConstraint; } else if (val > maxConstraint) { val = maxConstraint; } } else { val = minConstraint; } } } return val; }, /** * The method which performs the preventOverlap calculations for a given axis ("x" or "y") based * on the value and regions provided. * * @method _preventOverlap * @protected * * @param {Number} val The value being constrain * @param {String} axis The axis to being constrained * @param {Region} nodeRegion The region of the node being constrained * @param {Region} constrainingRegion The region of the node (or viewport) we need to constrain to * * @return {Number} The constrained value */ _preventOverlap : function(val, axis, nodeRegion, constrainingRegion) { var align = this.get(ALIGN), x = (axis === X_COORD), nodeSize, alignRegion, nearEdge, farEdge, spaceOnNearSide, spaceOnFarSide; if (align && align.points && PREVENT_OVERLAP_MAP[axis][align.points.join(EMPTY_STR)]) { alignRegion = this._getRegion(align.node); if (alignRegion) { nodeSize = (x) ? nodeRegion.width : nodeRegion.height; nearEdge = (x) ? alignRegion.left : alignRegion.top; farEdge = (x) ? alignRegion.right : alignRegion.bottom; spaceOnNearSide = (x) ? alignRegion.left - constrainingRegion.left : alignRegion.top - constrainingRegion.top; spaceOnFarSide = (x) ? constrainingRegion.right - alignRegion.right : constrainingRegion.bottom - alignRegion.bottom; } if (val > nearEdge) { if (spaceOnFarSide < nodeSize && spaceOnNearSide > nodeSize) { val = nearEdge - nodeSize; } } else { if (spaceOnNearSide < nodeSize && spaceOnFarSide > nodeSize) { val = farEdge; } } } return val; }, /** * Binds event listeners responsible for updating the UI state in response to * Widget constrained positioning related state changes. *

* This method is invoked after bindUI is invoked for the Widget class * using YUI's aop infrastructure. *

* * @method _bindUIPosConstrained * @protected */ _bindUIPosConstrained : function() { this.after(CONSTRAIN_CHANGE, this._afterConstrainChange); this._enableConstraints(this.get(CONSTRAIN)); }, /** * After change listener for the "constrain" attribute, responsible * for updating the UI, in response to attribute changes. * * @method _afterConstrainChange * @protected * @param {EventFacade} e The event facade */ _afterConstrainChange : function(e) { this._enableConstraints(e.newVal); }, /** * Updates the UI if enabling constraints, and sets up the xyChange event listeners * to constrain whenever the widget is moved. Disabling constraints removes the listeners. * * @method _enableConstraints * @private * @param {boolean} enable Enable or disable constraints */ _enableConstraints : function(enable) { if (enable) { this.constrain(); this._cxyHandle = this._cxyHandle || this.on(CONSTRAIN_XYCHANGE, this._constrainOnXYChange); } else if (this._cxyHandle) { this._cxyHandle.detach(); this._cxyHandle = null; } }, /** * The on change listener for the "xy" attribute. Modifies the event facade's * newVal property with the constrained XY value. * * @method _constrainOnXYChange * @protected * @param {EventFacade} e The event facade for the attribute change */ _constrainOnXYChange : function(e) { if (!e.constrained) { e.newVal = this.getConstrainedXY(e.newVal); } }, /** * Utility method to normalize region retrieval from a node instance, * or the viewport, if no node is provided. * * @method _getRegion * @private * @param {Node} node Optional. */ _getRegion : function(node) { var region; if (!node) { region = this._posNode.get(VIEWPORT_REGION); } else { node = Node.one(node); if (node) { region = node.get(REGION); } } return region; } }; Y.WidgetPositionConstrain = PositionConstrain; }, '3.17.2', {"requires": ["widget-position"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('overlay', function (Y, NAME) { /** * Provides a basic Overlay widget, with Standard Module content support. The Overlay widget * provides Page XY positioning support, alignment and centering support along with basic * stackable support (z-index and shimming). * * @module overlay */ /** * A basic Overlay Widget, which can be positioned based on Page XY co-ordinates and is stackable (z-index support). * It also provides alignment and centering support and uses a standard module format for it's content, with header, * body and footer section support. * * @class Overlay * @constructor * @extends Widget * @uses WidgetStdMod * @uses WidgetPosition * @uses WidgetStack * @uses WidgetPositionAlign * @uses WidgetPositionConstrain * @param {Object} object The user configuration for the instance. */ Y.Overlay = Y.Base.create("overlay", Y.Widget, [Y.WidgetStdMod, Y.WidgetPosition, Y.WidgetStack, Y.WidgetPositionAlign, Y.WidgetPositionConstrain]); }, '3.17.2', { "requires": [ "widget", "widget-stdmod", "widget-position", "widget-position-align", "widget-stack", "widget-position-constrain" ], "skinnable": true }); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('widget-autohide', function (Y, NAME) { /** * A widget-level extension that provides ability to hide widget when * certain events occur. * * @module widget-autohide * @author eferraiuolo, tilomitra * @since 3.4.0 */ var WIDGET_AUTOHIDE = 'widgetAutohide', AUTOHIDE = 'autohide', CLICK_OUTSIDE = 'clickoutside', FOCUS_OUTSIDE = 'focusoutside', DOCUMENT = 'document', KEY = 'key', PRESS_ESCAPE = 'esc', BIND_UI = 'bindUI', SYNC_UI = "syncUI", RENDERED = "rendered", BOUNDING_BOX = "boundingBox", VISIBLE = "visible", CHANGE = 'Change', getCN = Y.ClassNameManager.getClassName; /** * The WidgetAutohide class provides the hideOn attribute which can * be used to hide the widget when certain events occur. * * @class WidgetAutohide * @param {Object} config User configuration object */ function WidgetAutohide(config) { Y.after(this._bindUIAutohide, this, BIND_UI); Y.after(this._syncUIAutohide, this, SYNC_UI); if (this.get(RENDERED)) { this._bindUIAutohide(); this._syncUIAutohide(); } } /** * Static property used to define the default attribute * configuration introduced by WidgetAutohide. * * @property ATTRS * @static * @type Object */ WidgetAutohide.ATTRS = { /** * @attribute hideOn * @type array * * @description An array of objects corresponding to the nodes, events, and keycodes to hide the widget on. * The implementer can supply an array of objects, with each object having the following properties: *

eventName: (string, required): The eventName to listen to.

*

node: (Y.Node, optional): The Y.Node that will fire the event (defaults to the boundingBox of the widget)

*

keyCode: (string, optional): If listening for key events, specify the keyCode

*

By default, this attribute consists of one object which will cause the widget to hide if the * escape key is pressed.

*/ hideOn: { validator: Y.Lang.isArray, valueFn : function() { return [ { node: Y.one(DOCUMENT), eventName: KEY, keyCode: PRESS_ESCAPE } ]; } } }; WidgetAutohide.prototype = { // *** Instance Members *** // _uiHandlesAutohide : null, // *** Lifecycle Methods *** // destructor : function () { this._detachUIHandlesAutohide(); }, /** * Binds event listeners to the widget. *

* This method in invoked after bindUI is invoked for the Widget class * using YUI's aop infrastructure. *

* @method _bindUIAutohide * @protected */ _bindUIAutohide : function () { this.after(VISIBLE+CHANGE, this._afterHostVisibleChangeAutohide); this.after("hideOnChange", this._afterHideOnChange); }, /** * Syncs up the widget based on its current state. In particular, removes event listeners if * widget is not visible, and attaches them otherwise. *

* This method in invoked after syncUI is invoked for the Widget class * using YUI's aop infrastructure. *

* @method _syncUIAutohide * @protected */ _syncUIAutohide : function () { this._uiSetHostVisibleAutohide(this.get(VISIBLE)); }, // *** Private Methods *** // /** * Removes event listeners if widget is not visible, and attaches them otherwise. * * @method _uiSetHostVisibleAutohide * @protected */ _uiSetHostVisibleAutohide : function (visible) { if (visible) { //this._attachUIHandlesAutohide(); Y.later(1, this, '_attachUIHandlesAutohide'); } else { this._detachUIHandlesAutohide(); } }, /** * Iterates through all objects in the hideOn attribute and creates event listeners. * * @method _attachUIHandlesAutohide * @protected */ _attachUIHandlesAutohide : function () { if (this._uiHandlesAutohide) { return; } var bb = this.get(BOUNDING_BOX), hide = Y.bind(this.hide,this), uiHandles = [], self = this, hideOn = this.get('hideOn'), i = 0, o = {node: undefined, ev: undefined, keyCode: undefined}; //push all events on which the widget should be hidden for (; i < hideOn.length; i++) { o.node = hideOn[i].node; o.ev = hideOn[i].eventName; o.keyCode = hideOn[i].keyCode; //no keycode or node defined if (!o.node && !o.keyCode && o.ev) { uiHandles.push(bb.on(o.ev, hide)); } //node defined, no keycode (not a keypress) else if (o.node && !o.keyCode && o.ev) { uiHandles.push(o.node.on(o.ev, hide)); } //node defined, keycode defined, event defined (its a key press) else if (o.node && o.keyCode && o.ev) { uiHandles.push(o.node.on(o.ev, hide, o.keyCode)); } else { } } this._uiHandlesAutohide = uiHandles; }, /** * Detaches all event listeners created by this extension * * @method _detachUIHandlesAutohide * @protected */ _detachUIHandlesAutohide : function () { Y.each(this._uiHandlesAutohide, function(h){ h.detach(); }); this._uiHandlesAutohide = null; }, /** * Default function called when the visibility of the widget changes. Determines * whether to attach or detach event listeners based on the visibility of the widget. * * @method _afterHostVisibleChangeAutohide * @protected */ _afterHostVisibleChangeAutohide : function (e) { this._uiSetHostVisibleAutohide(e.newVal); }, /** * Default function called when hideOn Attribute is changed. Remove existing listeners and create new listeners. * * @method _afterHideOnChange * @protected */ _afterHideOnChange : function(e) { this._detachUIHandlesAutohide(); if (this.get(VISIBLE)) { this._attachUIHandlesAutohide(); } } }; Y.WidgetAutohide = WidgetAutohide; }, '3.17.2', {"requires": ["base-build", "event-key", "event-outside", "widget"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('button-core', function (Y, NAME) { /** * Provides an interface for working with button-like DOM nodes * * @module button-core * @since 3.5.0 */ var getClassName = Y.ClassNameManager.getClassName, AttributeCore = Y.AttributeCore; /** * Creates a button * * @class ButtonCore * @uses AttributeCore * @param config {Object} Configuration object * @constructor */ function ButtonCore(config) { this.initializer(config); } ButtonCore.prototype = { /** * * @property TEMPLATE * @type {String} * @default `. This attribute is **read-only**; anytime there are changes to this widget's `buttons`, the `defaultButton` will be updated if needed. **Note:** If two or more buttons are configured to be the default button, the last one wins. @attribute defaultButton @type Node @default null @readOnly @since 3.5.0 **/ defaultButton: { readOnly: true, value : null } }; /** CSS classes used by `WidgetButtons`. @property CLASS_NAMES @type Object @static @since 3.5.0 **/ WidgetButtons.CLASS_NAMES = { button : getClassName('button'), buttons: Widget.getClassName('buttons'), primary: getClassName('button', 'primary') }; WidgetButtons.HTML_PARSER = { buttons: function (srcNode) { return this._parseButtons(srcNode); } }; /** The list of button configuration properties which are specific to `WidgetButtons` and should not be passed to `Y.Plugin.Button.createNode()`. @property NON_BUTTON_NODE_CFG @type Array @static @since 3.5.0 **/ WidgetButtons.NON_BUTTON_NODE_CFG = [ 'action', 'classNames', 'context', 'events', 'isDefault', 'section' ]; WidgetButtons.prototype = { // -- Public Properties ---------------------------------------------------- /** Collection of predefined buttons mapped by name -> config. These button configurations will serve as defaults for any button added to a widget's buttons which have the same `name`. See `addButton()` for a list of possible configuration values. @property BUTTONS @type Object @default {} @see addButton() @since 3.5.0 **/ BUTTONS: {}, /** The HTML template to use when creating the node which wraps all buttons of a section. By default it will have the CSS class: "yui3-widget-buttons". @property BUTTONS_TEMPLATE @type String @default "" @since 3.5.0 **/ BUTTONS_TEMPLATE: '', /** The default section to render buttons in when no section is specified. @property DEFAULT_BUTTONS_SECTION @type String @default Y.WidgetStdMod.FOOTER @since 3.5.0 **/ DEFAULT_BUTTONS_SECTION: WidgetStdMod.FOOTER, // -- Protected Properties ------------------------------------------------- /** A map of button node `_yuid` -> event-handle for all button nodes which were created by this widget. @property _buttonsHandles @type Object @protected @since 3.5.0 **/ /** A map of this widget's `buttons`, both name -> button and section:name -> button. @property _buttonsMap @type Object @protected @since 3.5.0 **/ /** Internal reference to this widget's default button. @property _defaultButton @type Node @protected @since 3.5.0 **/ // -- Lifecycle Methods ---------------------------------------------------- initializer: function () { // Require `Y.WidgetStdMod`. if (!this._stdModNode) { Y.error('WidgetStdMod must be added to a Widget before WidgetButtons.'); } // Creates button mappings and sets the `defaultButton`. this._mapButtons(this.get('buttons')); this._updateDefaultButton(); // Bound with `Y.bind()` to make more extensible. this.after({ buttonsChange : Y.bind('_afterButtonsChange', this), defaultButtonChange: Y.bind('_afterDefaultButtonChange', this) }); Y.after(this._bindUIButtons, this, 'bindUI'); Y.after(this._syncUIButtons, this, 'syncUI'); }, destructor: function () { // Detach all event subscriptions this widget added to its `buttons`. YObject.each(this._buttonsHandles, function (handle) { handle.detach(); }); delete this._buttonsHandles; delete this._buttonsMap; delete this._defaultButton; }, // -- Public Methods ------------------------------------------------------- /** Adds a button to this widget. The new button node will have the `Y.Plugin.Button` plugin applied, be added to this widget's `buttons`, and rendered in the specified `section` at the specified `index` (or end of the section when no `index` is provided). If the section does not exist, it will be created. This fires the `buttonsChange` event and adds the following properties to the event facade: * `button`: The button node or config object to add. * `section`: The `WidgetStdMod` section (header/body/footer) where the button will be added. * `index`: The index at which the button will be in the section. * `src`: "add" **Note:** The `index` argument will be passed to the Array `splice()` method, therefore a negative value will insert the `button` that many items from the end. The `index` property on the `buttonsChange` event facade is the index at which the `button` was added. @method addButton @param {Node|Object|String} button The button to add. This can be a `Y.Node` instance, config Object, or String name for a predefined button on the `BUTTONS` prototype property. When a config Object is provided, it will be merged with any defaults provided by any `srcNode` and/or a button with the same `name` defined on the `BUTTONS` property. The following are the possible configuration properties beyond what Node plugins accept by default: @param {Function|String} [button.action] The default handler that should be called when the button is clicked. A String name of a Function that exists on the `context` object can also be provided. **Note:** Specifying a set of `events` will override this setting. @param {String|String[]} [button.classNames] Additional CSS classes to add to the button node. @param {Object} [button.context=this] Context which any `events` or `action` should be called with. Defaults to `this`, the widget. **Note:** `e.target` will access the button node in the event handlers. @param {Boolean} [button.disabled=false] Whether the button should be disabled. @param {String|Object} [button.events="click"] Event name, or set of events and handlers to bind to the button node. **See:** `Y.Node.on()`, this value is passed as the first argument to `on()`. @param {Boolean} [button.isDefault=false] Whether the button is the default button. @param {String} [button.label] The visible text/value displayed in the button. @param {String} [button.name] A name which can later be used to reference this button. If a button is defined on the `BUTTONS` property with this same name, its configuration properties will be merged in as defaults. @param {String} [button.section] The `WidgetStdMod` section (header, body, footer) where the button should be added. @param {Node} [button.srcNode] An existing Node to use for the button, default values will be seeded from this node, but are overriden by any values specified in the config object. By default a new <button> node will be created. @param {String} [button.template] A specific template to use when creating a new button node (e.g. "<a />"). **Note:** Specifying a `srcNode` will overide this. @param {String} [section="footer"] The `WidgetStdMod` section (header/body/footer) where the button should be added. This takes precedence over the `button.section` configuration property. @param {Number} [index] The index at which the button should be inserted. If not specified, the button will be added to the end of the section. This value is passed to the Array `splice()` method, therefore a negative value will insert the `button` that many items from the end. @chainable @see Plugin.Button.createNode() @since 3.4.0 **/ addButton: function (button, section, index) { var buttons = this.get('buttons'), sectionButtons, atIndex; // Makes sure we have the full config object. if (!isNode(button)) { button = this._mergeButtonConfig(button); section || (section = button.section); } section || (section = this.DEFAULT_BUTTONS_SECTION); sectionButtons = buttons[section] || (buttons[section] = []); isNumber(index) || (index = sectionButtons.length); // Insert new button at the correct position. sectionButtons.splice(index, 0, button); // Determine the index at which the `button` now exists in the array. atIndex = YArray.indexOf(sectionButtons, button); this.set('buttons', buttons, { button : button, section: section, index : atIndex, src : 'add' }); return this; }, /** Returns a button node from this widget's `buttons`. @method getButton @param {Number|String} name The string name or index of the button. @param {String} [section="footer"] The `WidgetStdMod` section (header/body/footer) where the button exists. Only applicable when looking for a button by numerical index, or by name but scoped to a particular section. @return {Node} The button node. @since 3.5.0 **/ getButton: function (name, section) { if (!isValue(name)) { return; } var map = this._buttonsMap, buttons; section || (section = this.DEFAULT_BUTTONS_SECTION); // Supports `getButton(1, 'header')` signature. if (isNumber(name)) { buttons = this.get('buttons'); return buttons[section] && buttons[section][name]; } // Looks up button by name or section:name. return arguments.length > 1 ? map[section + ':' + name] : map[name]; }, /** Removes a button from this widget. The button will be removed from this widget's `buttons` and its DOM. Any event subscriptions on the button which were created by this widget will be detached. If the content section becomes empty after removing the button node, then the section will also be removed. This fires the `buttonsChange` event and adds the following properties to the event facade: * `button`: The button node to remove. * `section`: The `WidgetStdMod` section (header/body/footer) where the button should be removed from. * `index`: The index at which the button exists in the section. * `src`: "remove" @method removeButton @param {Node|Number|String} button The button to remove. This can be a `Y.Node` instance, index, or String name of a button. @param {String} [section="footer"] The `WidgetStdMod` section (header/body/footer) where the button exists. Only applicable when removing a button by numerical index, or by name but scoped to a particular section. @chainable @since 3.5.0 **/ removeButton: function (button, section) { if (!isValue(button)) { return this; } var buttons = this.get('buttons'), index; // Shortcut if `button` is already an index which is needed for slicing. if (isNumber(button)) { section || (section = this.DEFAULT_BUTTONS_SECTION); index = button; button = buttons[section][index]; } else { // Supports `button` being the string name. if (isString(button)) { // `getButton()` is called this way because its behavior is // different based on the number of arguments. button = this.getButton.apply(this, arguments); } // Determines the `section` and `index` at which the button exists. YObject.some(buttons, function (sectionButtons, currentSection) { index = YArray.indexOf(sectionButtons, button); if (index > -1) { section = currentSection; return true; } }); } // Button was found at an appropriate index. if (button && index > -1) { // Remove button from `section` array. buttons[section].splice(index, 1); this.set('buttons', buttons, { button : button, section: section, index : index, src : 'remove' }); } return this; }, // -- Protected Methods ---------------------------------------------------- /** Binds UI event listeners. This method is inserted via AOP, and will execute after `bindUI()`. @method _bindUIButtons @protected @since 3.4.0 **/ _bindUIButtons: function () { // Event handlers are bound with `bind()` to make them more extensible. var afterContentChange = Y.bind('_afterContentChangeButtons', this); this.after({ visibleChange : Y.bind('_afterVisibleChangeButtons', this), headerContentChange: afterContentChange, bodyContentChange : afterContentChange, footerContentChange: afterContentChange }); }, /** Returns a button node based on the specified `button` node or configuration. The button node will either be created via `Y.Plugin.Button.createNode()`, or when `button` is specified as a node already, it will by `plug()`ed with `Y.Plugin.Button`. @method _createButton @param {Node|Object} button Button node or configuration object. @return {Node} The button node. @protected @since 3.5.0 **/ _createButton: function (button) { var config, buttonConfig, nonButtonNodeCfg, i, len, action, context, handle; // Makes sure the exiting `Y.Node` instance is from this YUI sandbox and // is plugged with `Y.Plugin.Button`. if (isNode(button)) { return Y.one(button.getDOMNode()).plug(ButtonPlugin); } // Merge `button` config with defaults and back-compat. config = Y.merge({ context: this, events : 'click', label : button.value }, button); buttonConfig = Y.merge(config); nonButtonNodeCfg = WidgetButtons.NON_BUTTON_NODE_CFG; // Remove all non-button Node config props. for (i = 0, len = nonButtonNodeCfg.length; i < len; i += 1) { delete buttonConfig[nonButtonNodeCfg[i]]; } // Create the button node using the button Node-only config. button = ButtonPlugin.createNode(buttonConfig); context = config.context; action = config.action; // Supports `action` as a String name of a Function on the `context` // object. if (isString(action)) { action = Y.bind(action, context); } // Supports all types of crazy configs for event subscriptions and // stores a reference to the returned `EventHandle`. handle = button.on(config.events, action, context); this._buttonsHandles[Y.stamp(button, true)] = handle; // Tags the button with the configured `name` and `isDefault` settings. button.setData('name', this._getButtonName(config)); button.setData('default', this._getButtonDefault(config)); // Add any CSS classnames to the button node. YArray.each(YArray(config.classNames), button.addClass, button); return button; }, /** Returns the buttons container for the specified `section`, passing a truthy value for `create` will create the node if it does not already exist. **Note:** It is up to the caller to properly insert the returned container node into the content section. @method _getButtonContainer @param {String} section The `WidgetStdMod` section (header/body/footer). @param {Boolean} create Whether the buttons container should be created if it does not already exist. @return {Node} The buttons container node for the specified `section`. @protected @see BUTTONS_TEMPLATE @since 3.5.0 **/ _getButtonContainer: function (section, create) { var sectionClassName = WidgetStdMod.SECTION_CLASS_NAMES[section], buttonsClassName = WidgetButtons.CLASS_NAMES.buttons, contentBox = this.get('contentBox'), containerSelector, container; // Search for an existing buttons container within the section. containerSelector = '.' + sectionClassName + ' .' + buttonsClassName; container = contentBox.one(containerSelector); // Create the `container` if it doesn't already exist. if (!container && create) { container = Y.Node.create(this.BUTTONS_TEMPLATE); container.addClass(buttonsClassName); } return container; }, /** Returns whether or not the specified `button` is configured to be the default button. When a button node is specified, the button's `getData()` method will be used to determine if the button is configured to be the default. When a button config object is specified, the `isDefault` prop will determine whether the button is the default. **Note:** `` is supported via the `button.getData('default')` API call. @method _getButtonDefault @param {Node|Object} button The button node or configuration object. @return {Boolean} Whether the button is configured to be the default button. @protected @since 3.5.0 **/ _getButtonDefault: function (button) { var isDefault = isNode(button) ? button.getData('default') : button.isDefault; if (isString(isDefault)) { return isDefault.toLowerCase() === 'true'; } return !!isDefault; }, /** Returns the name of the specified `button`. When a button node is specified, the button's `getData('name')` method is preferred, but will fallback to `get('name')`, and the result will determine the button's name. When a button config object is specified, the `name` prop will determine the button's name. **Note:** `` is supported via the `button.getData('name')` API call. @method _getButtonName @param {Node|Object} button The button node or configuration object. @return {String} The name of the button. @protected @since 3.5.0 **/ _getButtonName: function (button) { var name; if (isNode(button)) { name = button.getData('name') || button.get('name'); } else { name = button && (button.name || button.type); } return name; }, /** Getter for the `buttons` attribute. A copy of the `buttons` object is returned so the stored state cannot be modified by the callers of `get('buttons')`. This will recreate a copy of the `buttons` object, and each section array (the button nodes are *not* copied/cloned.) @method _getButtons @param {Object} buttons The widget's current `buttons` state. @return {Object} A copy of the widget's current `buttons` state. @protected @since 3.5.0 **/ _getButtons: function (buttons) { var buttonsCopy = {}; // Creates a new copy of the `buttons` object. YObject.each(buttons, function (sectionButtons, section) { // Creates of copy of the array of button nodes. buttonsCopy[section] = sectionButtons.concat(); }); return buttonsCopy; }, /** Adds the specified `button` to the buttons map (both name -> button and section:name -> button), and sets the button as the default if it is configured as the default button. **Note:** If two or more buttons are configured with the same `name` and/or configured to be the default button, the last one wins. @method _mapButton @param {Node} button The button node to map. @param {String} section The `WidgetStdMod` section (header/body/footer). @protected @since 3.5.0 **/ _mapButton: function (button, section) { var map = this._buttonsMap, name = this._getButtonName(button), isDefault = this._getButtonDefault(button); if (name) { // name -> button map[name] = button; // section:name -> button map[section + ':' + name] = button; } isDefault && (this._defaultButton = button); }, /** Adds the specified `buttons` to the buttons map (both name -> button and section:name -> button), and set the a button as the default if one is configured as the default button. **Note:** This will clear all previous button mappings and null-out any previous default button! If two or more buttons are configured with the same `name` and/or configured to be the default button, the last one wins. @method _mapButtons @param {Node[]} buttons The button nodes to map. @protected @since 3.5.0 **/ _mapButtons: function (buttons) { this._buttonsMap = {}; this._defaultButton = null; YObject.each(buttons, function (sectionButtons, section) { var i, len; for (i = 0, len = sectionButtons.length; i < len; i += 1) { this._mapButton(sectionButtons[i], section); } }, this); }, /** Returns a copy of the specified `config` object merged with any defaults provided by a `srcNode` and/or a predefined configuration for a button with the same `name` on the `BUTTONS` property. @method _mergeButtonConfig @param {Object|String} config Button configuration object, or string name. @return {Object} A copy of the button configuration object merged with any defaults. @protected @since 3.5.0 **/ _mergeButtonConfig: function (config) { var buttonConfig, defConfig, name, button, tagName, label; // Makes sure `config` is an Object and a copy of the specified value. config = isString(config) ? {name: config} : Y.merge(config); // Seeds default values from the button node, if there is one. if (config.srcNode) { button = config.srcNode; tagName = button.get('tagName').toLowerCase(); label = button.get(tagName === 'input' ? 'value' : 'text'); // Makes sure the button's current values override any defaults. buttonConfig = { disabled : !!button.get('disabled'), isDefault: this._getButtonDefault(button), name : this._getButtonName(button) }; // Label should only be considered when not an empty string. label && (buttonConfig.label = label); // Merge `config` with `buttonConfig` values. Y.mix(config, buttonConfig, false, null, 0, true); } name = this._getButtonName(config); defConfig = this.BUTTONS && this.BUTTONS[name]; // Merge `config` with predefined default values. if (defConfig) { Y.mix(config, defConfig, false, null, 0, true); } return config; }, /** `HTML_PARSER` implementation for the `buttons` attribute. **Note:** To determine a button node's name its `data-name` and `name` attributes are examined. Whether the button should be the default is determined by its `data-default` attribute. @method _parseButtons @param {Node} srcNode This widget's srcNode to search for buttons. @return {null|Object} `buttons` Config object parsed from this widget's DOM. @protected @since 3.5.0 **/ _parseButtons: function (srcNode) { var buttonSelector = '.' + WidgetButtons.CLASS_NAMES.button, sections = ['header', 'body', 'footer'], buttonsConfig = null; YArray.each(sections, function (section) { var container = this._getButtonContainer(section), buttons = container && container.all(buttonSelector), sectionButtons; if (!buttons || buttons.isEmpty()) { return; } sectionButtons = []; // Creates a button config object for every button node found and // adds it to the section. This way each button configuration can be // merged with any defaults provided by predefined `BUTTONS`. buttons.each(function (button) { sectionButtons.push({srcNode: button}); }); buttonsConfig || (buttonsConfig = {}); buttonsConfig[section] = sectionButtons; }, this); return buttonsConfig; }, /** Setter for the `buttons` attribute. This processes the specified `config` and returns a new `buttons` object which is stored as the new state; leaving the original, specified `config` unmodified. The button nodes will either be created via `Y.Plugin.Button.createNode()`, or when a button is already a Node already, it will by `plug()`ed with `Y.Plugin.Button`. @method _setButtons @param {Array|Object} config The `buttons` configuration to process. @return {Object} The processed `buttons` object which represents the new state. @protected @since 3.5.0 **/ _setButtons: function (config) { var defSection = this.DEFAULT_BUTTONS_SECTION, buttons = {}; function processButtons(buttonConfigs, currentSection) { if (!isArray(buttonConfigs)) { return; } var i, len, button, section; for (i = 0, len = buttonConfigs.length; i < len; i += 1) { button = buttonConfigs[i]; section = currentSection; if (!isNode(button)) { button = this._mergeButtonConfig(button); section || (section = button.section); } // Always passes through `_createButton()` to make sure the node // is decorated as a button. button = this._createButton(button); // Use provided `section` or fallback to the default section. section || (section = defSection); // Add button to the array of buttons for the specified section. (buttons[section] || (buttons[section] = [])).push(button); } } // Handle `config` being either an Array or Object of Arrays. if (isArray(config)) { processButtons.call(this, config); } else { YObject.each(config, processButtons, this); } return buttons; }, /** Syncs this widget's current button-related state to its DOM. This method is inserted via AOP, and will execute after `syncUI()`. @method _syncUIButtons @protected @since 3.4.0 **/ _syncUIButtons: function () { this._uiSetButtons(this.get('buttons')); this._uiSetDefaultButton(this.get('defaultButton')); this._uiSetVisibleButtons(this.get('visible')); }, /** Inserts the specified `button` node into this widget's DOM at the specified `section` and `index` and updates the section content. The section and button container nodes will be created if they do not already exist. @method _uiInsertButton @param {Node} button The button node to insert into this widget's DOM. @param {String} section The `WidgetStdMod` section (header/body/footer). @param {Number} index Index at which the `button` should be positioned. @protected @since 3.5.0 **/ _uiInsertButton: function (button, section, index) { var buttonsClassName = WidgetButtons.CLASS_NAMES.button, buttonContainer = this._getButtonContainer(section, true), sectionButtons = buttonContainer.all('.' + buttonsClassName); // Inserts the button node at the correct index. buttonContainer.insertBefore(button, sectionButtons.item(index)); // Adds the button container to the section content. this.setStdModContent(section, buttonContainer, 'after'); }, /** Removes the button node from this widget's DOM and detaches any event subscriptions on the button that were created by this widget. The section content will be updated unless `{preserveContent: true}` is passed in the `options`. By default the button container node will be removed when this removes the last button of the specified `section`; and if no other content remains in the section node, it will also be removed. @method _uiRemoveButton @param {Node} button The button to remove and destroy. @param {String} section The `WidgetStdMod` section (header/body/footer). @param {Object} [options] Additional options. @param {Boolean} [options.preserveContent=false] Whether the section content should be updated. @protected @since 3.5.0 **/ _uiRemoveButton: function (button, section, options) { var yuid = Y.stamp(button, this), handles = this._buttonsHandles, handle = handles[yuid], buttonContainer, buttonClassName; if (handle) { handle.detach(); } delete handles[yuid]; button.remove(); options || (options = {}); // Remove the button container and section nodes if needed. if (!options.preserveContent) { buttonContainer = this._getButtonContainer(section); buttonClassName = WidgetButtons.CLASS_NAMES.button; // Only matters if we have a button container which is empty. if (buttonContainer && buttonContainer.all('.' + buttonClassName).isEmpty()) { buttonContainer.remove(); this._updateContentButtons(section); } } }, /** Sets the current `buttons` state to this widget's DOM by rendering the specified collection of `buttons` and updates the contents of each section as needed. Button nodes which already exist in the DOM will remain intact, or will be moved if they should be in a new position. Old button nodes which are no longer represented in the specified `buttons` collection will be removed, and any event subscriptions on the button which were created by this widget will be detached. If the button nodes in this widget's DOM actually change, then each content section will be updated (or removed) appropriately. @method _uiSetButtons @param {Object} buttons The current `buttons` state to visually represent. @protected @since 3.5.0 **/ _uiSetButtons: function (buttons) { var buttonClassName = WidgetButtons.CLASS_NAMES.button, sections = ['header', 'body', 'footer']; YArray.each(sections, function (section) { var sectionButtons = buttons[section] || [], numButtons = sectionButtons.length, buttonContainer = this._getButtonContainer(section, numButtons), buttonsUpdated = false, oldNodes, i, button, buttonIndex; // When there's no button container, there are no new buttons or old // buttons that we have to deal with for this section. if (!buttonContainer) { return; } oldNodes = buttonContainer.all('.' + buttonClassName); for (i = 0; i < numButtons; i += 1) { button = sectionButtons[i]; buttonIndex = oldNodes.indexOf(button); // Buttons already rendered in the Widget should remain there or // moved to their new index. New buttons will be added to the // current `buttonContainer`. if (buttonIndex > -1) { // Remove button from existing buttons nodeList since its in // the DOM already. oldNodes.splice(buttonIndex, 1); // Check that the button is at the right position, if not, // move it to its new position. if (buttonIndex !== i) { // Using `i + 1` because the button should be at index // `i`; it's inserted before the node which comes after. buttonContainer.insertBefore(button, i + 1); buttonsUpdated = true; } } else { buttonContainer.appendChild(button); buttonsUpdated = true; } } // Safely removes the old button nodes which are no longer part of // this widget's `buttons`. oldNodes.each(function (button) { this._uiRemoveButton(button, section, {preserveContent: true}); buttonsUpdated = true; }, this); // Remove leftover empty button containers and updated the StdMod // content area. if (numButtons === 0) { buttonContainer.remove(); this._updateContentButtons(section); return; } // Adds the button container to the section content. if (buttonsUpdated) { this.setStdModContent(section, buttonContainer, 'after'); } }, this); }, /** Adds the "yui3-button-primary" CSS class to the new `defaultButton` and removes it from the old default button. @method _uiSetDefaultButton @param {Node} newButton The new `defaultButton`. @param {Node} oldButton The old `defaultButton`. @protected @since 3.5.0 **/ _uiSetDefaultButton: function (newButton, oldButton) { var primaryClassName = WidgetButtons.CLASS_NAMES.primary; if (newButton) { newButton.addClass(primaryClassName); } if (oldButton) { oldButton.removeClass(primaryClassName); } }, /** Focuses this widget's `defaultButton` if there is one and this widget is visible. @method _uiSetVisibleButtons @param {Boolean} visible Whether this widget is visible. @protected @since 3.5.0 **/ _uiSetVisibleButtons: function (visible) { if (!visible) { return; } var defaultButton = this.get('defaultButton'); if (defaultButton) { defaultButton.focus(); } }, /** Removes the specified `button` from the buttons map (both name -> button and section:name -> button), and nulls-out the `defaultButton` if it is currently the default button. @method _unMapButton @param {Node} button The button node to remove from the buttons map. @param {String} section The `WidgetStdMod` section (header/body/footer). @protected @since 3.5.0 **/ _unMapButton: function (button, section) { var map = this._buttonsMap, name = this._getButtonName(button), sectionName; // Only delete the map entry if the specified `button` is mapped to it. if (name) { // name -> button if (map[name] === button) { delete map[name]; } // section:name -> button sectionName = section + ':' + name; if (map[sectionName] === button) { delete map[sectionName]; } } // Clear the default button if its the specified `button`. if (this._defaultButton === button) { this._defaultButton = null; } }, /** Updates the `defaultButton` attribute if it needs to be updated by comparing its current value with the protected `_defaultButton` property. @method _updateDefaultButton @protected @since 3.5.0 **/ _updateDefaultButton: function () { var defaultButton = this._defaultButton; if (this.get('defaultButton') !== defaultButton) { this._set('defaultButton', defaultButton); } }, /** Updates the content attribute which corresponds to the specified `section`. The method updates the section's content to its current `childNodes` (text and/or HTMLElement), or will null-out its contents if the section is empty. It also specifies a `src` of `buttons` on the change event facade. @method _updateContentButtons @param {String} section The `WidgetStdMod` section (header/body/footer) to update. @protected @since 3.5.0 **/ _updateContentButtons: function (section) { // `childNodes` return text nodes and HTMLElements. var sectionContent = this.getStdModNode(section).get('childNodes'); // Updates the section to its current contents, or null if it is empty. this.set(section + 'Content', sectionContent.isEmpty() ? null : sectionContent, {src: 'buttons'}); }, // -- Protected Event Handlers --------------------------------------------- /** Handles this widget's `buttonsChange` event which fires anytime the `buttons` attribute is modified. **Note:** This method special-cases the `buttons` modifications caused by `addButton()` and `removeButton()`, both of which set the `src` property on the event facade to "add" and "remove" respectively. @method _afterButtonsChange @param {EventFacade} e @protected @since 3.4.0 **/ _afterButtonsChange: function (e) { var buttons = e.newVal, section = e.section, index = e.index, src = e.src, button; // Special cases `addButton()` to only set and insert the new button. if (src === 'add') { // Make sure we have the button node. button = buttons[section][index]; this._mapButton(button, section); this._updateDefaultButton(); this._uiInsertButton(button, section, index); return; } // Special cases `removeButton()` to only remove the specified button. if (src === 'remove') { // Button node already exists on the event facade. button = e.button; this._unMapButton(button, section); this._updateDefaultButton(); this._uiRemoveButton(button, section); return; } this._mapButtons(buttons); this._updateDefaultButton(); this._uiSetButtons(buttons); }, /** Handles this widget's `headerContentChange`, `bodyContentChange`, `footerContentChange` events by making sure the `buttons` remain rendered after changes to the content areas. These events are very chatty, so extra caution is taken to avoid doing extra work or getting into an infinite loop. @method _afterContentChangeButtons @param {EventFacade} e @protected @since 3.5.0 **/ _afterContentChangeButtons: function (e) { var src = e.src, pos = e.stdModPosition, replace = !pos || pos === WidgetStdMod.REPLACE; // Only do work when absolutely necessary. if (replace && src !== 'buttons' && src !== Widget.UI_SRC) { this._uiSetButtons(this.get('buttons')); } }, /** Handles this widget's `defaultButtonChange` event by adding the "yui3-button-primary" CSS class to the new `defaultButton` and removing it from the old default button. @method _afterDefaultButtonChange @param {EventFacade} e @protected @since 3.5.0 **/ _afterDefaultButtonChange: function (e) { this._uiSetDefaultButton(e.newVal, e.prevVal); }, /** Handles this widget's `visibleChange` event by focusing the `defaultButton` if there is one. @method _afterVisibleChangeButtons @param {EventFacade} e @protected @since 3.5.0 **/ _afterVisibleChangeButtons: function (e) { this._uiSetVisibleButtons(e.newVal); } }; Y.WidgetButtons = WidgetButtons; }, '3.17.2', {"requires": ["button-plugin", "cssbutton", "widget-stdmod"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('widget-modality', function (Y, NAME) { /** * Provides modality support for Widgets, though an extension * * @module widget-modality */ var WIDGET = 'widget', RENDER_UI = 'renderUI', BIND_UI = 'bindUI', SYNC_UI = 'syncUI', BOUNDING_BOX = 'boundingBox', VISIBLE = 'visible', Z_INDEX = 'zIndex', CHANGE = 'Change', isBoolean = Y.Lang.isBoolean, getCN = Y.ClassNameManager.getClassName, MaskShow = "maskShow", MaskHide = "maskHide", ClickOutside = "clickoutside", FocusOutside = "focusoutside", supportsPosFixed = (function(){ /*! IS_POSITION_FIXED_SUPPORTED - Juriy Zaytsev (kangax) - http://yura.thinkweb2.com/cft/ */ var doc = Y.config.doc, isSupported = null, el, root; if (doc.createElement) { el = doc.createElement('div'); if (el && el.style) { el.style.position = 'fixed'; el.style.top = '10px'; root = doc.body; if (root && root.appendChild && root.removeChild) { root.appendChild(el); isSupported = (el.offsetTop === 10); root.removeChild(el); } } } return isSupported; }()); /** * Widget extension, which can be used to add modality support to the base Widget class, * through the Base.create method. * * @class WidgetModality * @param {Object} config User configuration object */ function WidgetModal(config) {} var MODAL = 'modal', MASK = 'mask', MODAL_CLASSES = { modal : getCN(WIDGET, MODAL), mask : getCN(WIDGET, MASK) }; /** * Static property used to define the default attribute * configuration introduced by WidgetModality. * * @property ATTRS * @static * @type Object */ WidgetModal.ATTRS = { /** * @attribute maskNode * @type Y.Node * * @description Returns a Y.Node instance of the node being used as the mask. */ maskNode : { getter : '_getMaskNode', readOnly : true }, /** * @attribute modal * @type boolean * * @description Whether the widget should be modal or not. */ modal: { value:false, validator: isBoolean }, /** * @attribute focusOn * @type array * * @description An array of objects corresponding to the nodes and events that will trigger a re-focus back on the widget. * The implementer can supply an array of objects, with each object having the following properties: *

eventName: (string, required): The eventName to listen to.

*

node: (Y.Node, optional): The Y.Node that will fire the event (defaults to the boundingBox of the widget)

*

By default, this attribute consists of two objects which will cause the widget to re-focus if anything * outside the widget is clicked on or focussed upon.

*/ focusOn: { valueFn: function() { return [ { // node: this.get(BOUNDING_BOX), eventName: ClickOutside }, { //node: this.get(BOUNDING_BOX), eventName: FocusOutside } ]; }, validator: Y.Lang.isArray } }; WidgetModal.CLASSES = MODAL_CLASSES; WidgetModal._MASK = null; /** * Returns the mask if it exists on the page - otherwise creates a mask. There's only * one mask on a page at a given time. *

* This method in invoked internally by the getter of the maskNode ATTR. *

* @method _GET_MASK * @static */ WidgetModal._GET_MASK = function() { var mask = WidgetModal._MASK, win = Y.one('win'); if (mask && (mask.getDOMNode() !== null) && mask.inDoc()) { return mask; } mask = Y.Node.create('
').addClass(MODAL_CLASSES.mask); WidgetModal._MASK = mask; if (supportsPosFixed) { mask.setStyles({ position: 'fixed', width : '100%', height : '100%', top : '0', left : '0', display : 'block' }); } else { mask.setStyles({ position: 'absolute', width : win.get('winWidth') +'px', height : win.get('winHeight') + 'px', top : '0', left : '0', display : 'block' }); } return mask; }; /** * A stack of Y.Widget objects representing the current hierarchy of modal widgets presently displayed on the screen * @property STACK */ WidgetModal.STACK = []; WidgetModal.prototype = { initializer: function () { Y.after(this._renderUIModal, this, RENDER_UI); Y.after(this._syncUIModal, this, SYNC_UI); Y.after(this._bindUIModal, this, BIND_UI); }, destructor: function () { // Hack to remove this thing from the STACK. this._uiSetHostVisibleModal(false); }, // *** Instance Members *** // _uiHandlesModal: null, /** * Adds modal class to the bounding box of the widget *

* This method in invoked after renderUI is invoked for the Widget class * using YUI's aop infrastructure. *

* @method _renderUIModal * @protected */ _renderUIModal : function () { var bb = this.get(BOUNDING_BOX); //cb = this.get(CONTENT_BOX); //this makes the content box content appear over the mask // cb.setStyles({ // position: "" // }); this._repositionMask(this); bb.addClass(MODAL_CLASSES.modal); }, /** * Hooks up methods to be executed when the widget's visibility or z-index changes *

* This method in invoked after bindUI is invoked for the Widget class * using YUI's aop infrastructure. *

* @method _bindUIModal * @protected */ _bindUIModal : function () { this.after(VISIBLE+CHANGE, this._afterHostVisibleChangeModal); this.after(Z_INDEX+CHANGE, this._afterHostZIndexChangeModal); this.after("focusOnChange", this._afterFocusOnChange); // Re-align the mask in the viewport if `position: fixed;` is not // supported. iOS < 5 and Android < 3 don't actually support it even // though they both pass the feature test; the UA sniff is here to // account for that. Ideally this should be replaced with a better // feature test. if (!supportsPosFixed || (Y.UA.ios && Y.UA.ios < 5) || (Y.UA.android && Y.UA.android < 3)) { Y.one('win').on('scroll', this._resyncMask, this); } }, /** * Syncs the mask with the widget's current state, namely the visibility and z-index of the widget *

* This method in invoked after syncUI is invoked for the Widget class * using YUI's aop infrastructure. *

* @method _syncUIModal * @protected */ _syncUIModal : function () { //var host = this.get(HOST); this._uiSetHostVisibleModal(this.get(VISIBLE)); }, /** * Provides mouse and tab focus to the widget's bounding box. * * @method _focus */ _focus : function () { var bb = this.get(BOUNDING_BOX), oldTI = bb.get('tabIndex'); bb.set('tabIndex', oldTI >= 0 ? oldTI : 0); this.focus(); }, /** * Blurs the widget. * * @method _blur */ _blur : function () { this.blur(); }, /** * Returns the Y.Node instance of the maskNode * * @method _getMaskNode * @return {Node} The Y.Node instance of the mask, as returned from WidgetModal._GET_MASK */ _getMaskNode : function () { return WidgetModal._GET_MASK(); }, /** * Performs events attaching/detaching, stack shifting and mask repositioning based on the visibility of the widget * * @method _uiSetHostVisibleModal * @param {boolean} Whether the widget is visible or not */ _uiSetHostVisibleModal : function (visible) { var stack = WidgetModal.STACK, maskNode = this.get('maskNode'), isModal = this.get('modal'), topModal, index; if (visible) { Y.Array.each(stack, function(modal){ modal._detachUIHandlesModal(); modal._blur(); }); // push on top of stack stack.unshift(this); this._repositionMask(this); this._uiSetHostZIndexModal(this.get(Z_INDEX)); if (isModal) { maskNode.show(); Y.later(1, this, '_attachUIHandlesModal'); this._focus(); } } else { index = Y.Array.indexOf(stack, this); if (index >= 0) { // Remove modal widget from global stack. stack.splice(index, 1); } this._detachUIHandlesModal(); this._blur(); if (stack.length) { topModal = stack[0]; this._repositionMask(topModal); //topModal._attachUIHandlesModal(); topModal._uiSetHostZIndexModal(topModal.get(Z_INDEX)); if (topModal.get('modal')) { //topModal._attachUIHandlesModal(); Y.later(1, topModal, '_attachUIHandlesModal'); topModal._focus(); } } else { if (maskNode.getStyle('display') === 'block') { maskNode.hide(); } } } }, /** * Sets the z-index of the mask node. * * @method _uiSetHostZIndexModal * @param {Number} Z-Index of the widget */ _uiSetHostZIndexModal : function (zIndex) { if (this.get('modal')) { this.get('maskNode').setStyle(Z_INDEX, zIndex || 0); } }, /** * Attaches UI Listeners for "clickoutside" and "focusoutside" on the * widget. When these events occur, and the widget is modal, focus is * shifted back onto the widget. * * @method _attachUIHandlesModal */ _attachUIHandlesModal : function () { if (this._uiHandlesModal || WidgetModal.STACK[0] !== this) { // Quit early if we have ui handles, or if we not at the top // of the global stack. return; } var bb = this.get(BOUNDING_BOX), maskNode = this.get('maskNode'), focusOn = this.get('focusOn'), focus = Y.bind(this._focus, this), uiHandles = [], i, len, o; for (i = 0, len = focusOn.length; i < len; i++) { o = {}; o.node = focusOn[i].node; o.ev = focusOn[i].eventName; o.keyCode = focusOn[i].keyCode; //no keycode or node defined if (!o.node && !o.keyCode && o.ev) { uiHandles.push(bb.on(o.ev, focus)); } //node defined, no keycode (not a keypress) else if (o.node && !o.keyCode && o.ev) { uiHandles.push(o.node.on(o.ev, focus)); } //node defined, keycode defined, event defined (its a key press) else if (o.node && o.keyCode && o.ev) { uiHandles.push(o.node.on(o.ev, focus, o.keyCode)); } else { Y.Log('focusOn ATTR Error: The event with name "'+o.ev+'" could not be attached.'); } } if ( ! supportsPosFixed) { uiHandles.push(Y.one('win').on('scroll', Y.bind(function(){ maskNode.setStyle('top', maskNode.get('docScrollY')); }, this))); } this._uiHandlesModal = uiHandles; }, /** * Detaches all UI Listeners that were set in _attachUIHandlesModal from the widget. * * @method _detachUIHandlesModal */ _detachUIHandlesModal : function () { Y.each(this._uiHandlesModal, function(h){ h.detach(); }); this._uiHandlesModal = null; }, /** * Default function that is called when visibility is changed on the widget. * * @method _afterHostVisibleChangeModal * @param {EventFacade} e The event facade of the change */ _afterHostVisibleChangeModal : function (e) { this._uiSetHostVisibleModal(e.newVal); }, /** * Default function that is called when z-index is changed on the widget. * * @method _afterHostZIndexChangeModal * @param {EventFacade} e The event facade of the change */ _afterHostZIndexChangeModal : function (e) { this._uiSetHostZIndexModal(e.newVal); }, /** * Returns a boolean representing whether the current widget is in a "nested modality" state. * This is done by checking the number of widgets currently on the stack. * * @method isNested * @public */ isNested: function() { var length = WidgetModal.STACK.length, retval = (length > 1) ? true : false; return retval; }, /** * Repositions the mask in the DOM for nested modality cases. * * @method _repositionMask * @param {Widget} nextElem The Y.Widget instance that will be visible in the stack once the current widget is closed. */ _repositionMask: function(nextElem) { var currentModal = this.get('modal'), nextModal = nextElem.get('modal'), maskNode = this.get('maskNode'), bb, bbParent; //if this is modal and host is not modal if (currentModal && !nextModal) { //leave the mask where it is, since the host is not modal. maskNode.remove(); this.fire(MaskHide); } //if the main widget is not modal but the host is modal, or both of them are modal else if ((!currentModal && nextModal) || (currentModal && nextModal)) { //then remove the mask off DOM, reposition it, and reinsert it into the DOM maskNode.remove(); this.fire(MaskHide); bb = nextElem.get(BOUNDING_BOX); bbParent = bb.get('parentNode') || Y.one('body'); bbParent.insert(maskNode, bbParent.get('firstChild')); this.fire(MaskShow); } }, /** * Resyncs the mask in the viewport for browsers that don't support fixed positioning * * @method _resyncMask * @param {Y.Widget} nextElem The Y.Widget instance that will be visible in the stack once the current widget is closed. * @private */ _resyncMask: function (e) { var o = e.currentTarget, offsetX = o.get('docScrollX'), offsetY = o.get('docScrollY'), w = o.get('innerWidth') || o.get('winWidth'), h = o.get('innerHeight') || o.get('winHeight'), mask = this.get('maskNode'); mask.setStyles({ "top": offsetY + "px", "left": offsetX + "px", "width": w + 'px', "height": h + 'px' }); }, /** * Default function called when focusOn Attribute is changed. Remove existing listeners and create new listeners. * * @method _afterFocusOnChange */ _afterFocusOnChange : function() { this._detachUIHandlesModal(); if (this.get(VISIBLE)) { this._attachUIHandlesModal(); } } }; Y.WidgetModality = WidgetModal; }, '3.17.2', {"requires": ["base-build", "event-outside", "widget"], "skinnable": true}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('panel', function (Y, NAME) { // TODO: Change this description! /** Provides a Panel widget, a widget that mimics the functionality of a regular OS window. Comes with Standard Module support, XY Positioning, Alignment Support, Stack (z-index) support, modality, auto-focus and auto-hide functionality, and header/footer button support. @module panel **/ var getClassName = Y.ClassNameManager.getClassName; // TODO: Change this description! /** A basic Panel Widget, which can be positioned based on Page XY co-ordinates and is stackable (z-index support). It also provides alignment and centering support and uses a standard module format for it's content, with header, body and footer section support. It can be made modal, and has functionality to hide and focus on different events. The header and footer sections can be modified to allow for button support. @class Panel @constructor @extends Widget @uses WidgetAutohide @uses WidgetButtons @uses WidgetModality @uses WidgetPosition @uses WidgetPositionAlign @uses WidgetPositionConstrain @uses WidgetStack @uses WidgetStdMod @since 3.4.0 */ Y.Panel = Y.Base.create('panel', Y.Widget, [ // Other Widget extensions depend on these two. Y.WidgetPosition, Y.WidgetStdMod, Y.WidgetAutohide, Y.WidgetButtons, Y.WidgetModality, Y.WidgetPositionAlign, Y.WidgetPositionConstrain, Y.WidgetStack ], { // -- Public Properties ---------------------------------------------------- /** Collection of predefined buttons mapped from name => config. Panel includes a "close" button which can be use by name. When the close button is in the header (which is the default), it will look like: [x]. See `addButton()` for a list of possible configuration values. @example // Panel with close button in header. var panel = new Y.Panel({ buttons: ['close'] }); // Panel with close button in footer. var otherPanel = new Y.Panel({ buttons: { footer: ['close'] } }); @property BUTTONS @type Object @default {close: {}} @since 3.5.0 **/ BUTTONS: { close: { label : 'Close', action : 'hide', section: 'header', // Uses `type="button"` so the button's default action can still // occur but it won't cause things like a form to submit. template : '