Return-Path: X-Original-To: apmail-roller-commits-archive@www.apache.org Delivered-To: apmail-roller-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 262D111985 for ; Fri, 11 Jul 2014 16:24:42 +0000 (UTC) Received: (qmail 43292 invoked by uid 500); 11 Jul 2014 16:24:42 -0000 Delivered-To: apmail-roller-commits-archive@roller.apache.org Received: (qmail 43261 invoked by uid 500); 11 Jul 2014 16:24:42 -0000 Mailing-List: contact commits-help@roller.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@roller.apache.org Delivered-To: mailing list commits@roller.apache.org Received: (qmail 43252 invoked by uid 99); 11 Jul 2014 16:24:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Jul 2014 16:24:42 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Jul 2014 16:24:35 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 661CC2388C28; Fri, 11 Jul 2014 16:23:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1609737 [12/18] - in /roller/trunk/app/src/main/webapp: WEB-INF/jsps/editor/ WEB-INF/jsps/tiles/ roller-ui/yui3/arraylist/ roller-ui/yui3/assets/ roller-ui/yui3/assets/skins/ roller-ui/yui3/assets/skins/sam/ roller-ui/yui3/async-queue/ rol... Date: Fri, 11 Jul 2014 16:23:29 -0000 To: commits@roller.apache.org From: gmazza@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140711162336.661CC2388C28@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: roller/trunk/app/src/main/webapp/roller-ui/yui3/node-core/node-core.js URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/webapp/roller-ui/yui3/node-core/node-core.js?rev=1609737&view=auto ============================================================================== --- roller/trunk/app/src/main/webapp/roller-ui/yui3/node-core/node-core.js (added) +++ roller/trunk/app/src/main/webapp/roller-ui/yui3/node-core/node-core.js Fri Jul 11 16:23:25 2014 @@ -0,0 +1,1619 @@ +/* +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"]}); Added: roller/trunk/app/src/main/webapp/roller-ui/yui3/node-event-delegate/node-event-delegate-min.js URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/webapp/roller-ui/yui3/node-event-delegate/node-event-delegate-min.js?rev=1609737&view=auto ============================================================================== --- roller/trunk/app/src/main/webapp/roller-ui/yui3/node-event-delegate/node-event-delegate-min.js (added) +++ roller/trunk/app/src/main/webapp/roller-ui/yui3/node-event-delegate/node-event-delegate-min.js Fri Jul 11 16:23:25 2014 @@ -0,0 +1,8 @@ +/* +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(e,t){e.Node.prototype.delegate=function(t){var n=e.Array(arguments,0,!0),r=e.Lang.isObject(t)&&!e.Lang.isArray(t)?1:2;return n.splice(r,0,this._node),e.delegate.apply(e,n)}},"3.17.2",{requires:["node-base","event-delegate"]}); Added: roller/trunk/app/src/main/webapp/roller-ui/yui3/node-event-delegate/node-event-delegate.js URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/webapp/roller-ui/yui3/node-event-delegate/node-event-delegate.js?rev=1609737&view=auto ============================================================================== --- roller/trunk/app/src/main/webapp/roller-ui/yui3/node-event-delegate/node-event-delegate.js (added) +++ roller/trunk/app/src/main/webapp/roller-ui/yui3/node-event-delegate/node-event-delegate.js Fri Jul 11 16:23:25 2014 @@ -0,0 +1,61 @@ +/* +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"]}); Added: roller/trunk/app/src/main/webapp/roller-ui/yui3/node-event-simulate/node-event-simulate-min.js URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/webapp/roller-ui/yui3/node-event-simulate/node-event-simulate-min.js?rev=1609737&view=auto ============================================================================== --- roller/trunk/app/src/main/webapp/roller-ui/yui3/node-event-simulate/node-event-simulate-min.js (added) +++ roller/trunk/app/src/main/webapp/roller-ui/yui3/node-event-simulate/node-event-simulate-min.js Fri Jul 11 16:23:25 2014 @@ -0,0 +1,8 @@ +/* +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-simulate",function(e,t){e.Node.prototype.simulate=function(t,n){e.Event.simulate(e.Node.getDOMNode(this),t,n)},e.Node.prototype.simulateGesture=function(t,n,r){e.Event.simulateGesture(this,t,n,r)}},"3.17.2",{requires:["node-base","event-simulate","gesture-simulate"]}); Added: roller/trunk/app/src/main/webapp/roller-ui/yui3/node-event-simulate/node-event-simulate.js URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/webapp/roller-ui/yui3/node-event-simulate/node-event-simulate.js?rev=1609737&view=auto ============================================================================== --- roller/trunk/app/src/main/webapp/roller-ui/yui3/node-event-simulate/node-event-simulate.js (added) +++ roller/trunk/app/src/main/webapp/roller-ui/yui3/node-event-simulate/node-event-simulate.js Fri Jul 11 16:23:25 2014 @@ -0,0 +1,194 @@ +/* +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-simulate', function (Y, NAME) { + +/** + * Adds functionality to simulate events. + * @module node + * @submodule node-event-simulate + */ + +/** + * Simulates an event on the node. + * @param {String} type The type of event (i.e., "click"). + * @param {Object} options (Optional) Extra options to copy onto the event object. + * @for Node + * @method simulate + */ +Y.Node.prototype.simulate = function (type, options) { + + Y.Event.simulate(Y.Node.getDOMNode(this), type, options); +}; + +/** + * Simulates the higher user level gesture of the given name on this node. + * This method generates a set of low level touch events(Apple specific gesture + * events as well for the iOS platforms) asynchronously. Note that gesture + * simulation is relying on `Y.Event.simulate()` method to generate + * the touch events under the hood. The `Y.Event.simulate()` method + * itself is a synchronous method. + * + * Supported gestures are `tap`, `doubletap`, `press`, `move`, `flick`, `pinch` + * and `rotate`. + * + * The `pinch` gesture is used to simulate the pinching and spreading of two + * fingers. During a pinch simulation, rotation is also possible. Essentially + * `pinch` and `rotate` simulations share the same base implementation to allow + * both pinching and rotation at the same time. The only difference is `pinch` + * requires `start` and `end` option properties while `rotate` requires `rotation` + * option property. + * + * The `pinch` and `rotate` gestures can be described as placing 2 fingers along a + * circle. Pinching and spreading can be described by start and end circles while + * rotation occurs on a single circle. If the radius of the start circle is greater + * than the end circle, the gesture becomes a pinch, otherwise it is a spread spread. + * + * @example + * + * var node = Y.one("#target"); + * + * // double tap example + * node.simulateGesture("doubletap", function() { + * // my callback function + * }); + * + * // flick example from the center of the node, move 50 pixels down for 50ms) + * node.simulateGesture("flick", { + * axis: y, + * distance: -100 + * duration: 50 + * }, function() { + * // my callback function + * }); + * + * // simulate rotating a node 75 degrees counter-clockwise + * node.simulateGesture("rotate", { + * rotation: -75 + * }); + * + * // simulate a pinch and a rotation at the same time. + * // fingers start on a circle of radius 100 px, placed at top/bottom + * // fingers end on a circle of radius 50px, placed at right/left + * node.simulateGesture("pinch", { + * r1: 100, + * r2: 50, + * start: 0 + * rotation: 90 + * }); + * + * @method simulateGesture + * @param {String} name The name of the supported gesture to simulate. The + * supported gesture name is one of "tap", "doubletap", "press", "move", + * "flick", "pinch" and "rotate". + * @param {Object} [options] Extra options used to define the gesture behavior: + * + * Valid options properties for the `tap` gesture: + * + * @param {Array} [options.point] (Optional) Indicates the [x,y] coordinates + * where the tap should be simulated. Default is the center of the node + * element. + * @param {Number} [options.hold=10] (Optional) The hold time in milliseconds. + * This is the time between `touchstart` and `touchend` event generation. + * @param {Number} [options.times=1] (Optional) Indicates the number of taps. + * @param {Number} [options.delay=10] (Optional) The number of milliseconds + * before the next tap simulation happens. This is valid only when `times` + * is more than 1. + * + * Valid options properties for the `doubletap` gesture: + * + * @param {Array} [options.point] (Optional) Indicates the [x,y] coordinates + * where the doubletap should be simulated. Default is the center of the + * node element. + * + * Valid options properties for the `press` gesture: + * + * @param {Array} [options.point] (Optional) Indicates the [x,y] coordinates + * where the press should be simulated. Default is the center of the node + * element. + * @param {Number} [options.hold=3000] (Optional) The hold time in milliseconds. + * This is the time between `touchstart` and `touchend` event generation. + * Default is 3000ms (3 seconds). + * + * Valid options properties for the `move` gesture: + * + * @param {Object} [options.path] (Optional) Indicates the path of the finger + * movement. It's an object with three optional properties: `point`, + * `xdist` and `ydist`. + * @param {Array} [options.path.point] A starting point of the gesture. + * Default is the center of the node element. + * @param {Number} [options.path.xdist=200] A distance to move in pixels + * along the X axis. A negative distance value indicates moving left. + * @param {Number} [options.path.ydist=0] A distance to move in pixels + * along the Y axis. A negative distance value indicates moving up. + * @param {Number} [options.duration=1000] (Optional) The duration of the + * gesture in milliseconds. + * + * Valid options properties for the `flick` gesture: + * + * @param {Array} [options.point] (Optional) Indicates the [x, y] coordinates + * where the flick should be simulated. Default is the center of the + * node element. + * @param {String} [options.axis='x'] (Optional) Valid values are either + * "x" or "y". Indicates axis to move along. The flick can move to one of + * 4 directions(left, right, up and down). + * @param {Number} [options.distance=200] (Optional) Distance to move in pixels + * @param {Number} [options.duration=1000] (Optional) The duration of the + * gesture in milliseconds. User given value could be automatically + * adjusted by the framework if it is below the minimum velocity to be + * a flick gesture. + * + * Valid options properties for the `pinch` gesture: + * + * @param {Array} [options.center] (Optional) The center of the circle where + * two fingers are placed. Default is the center of the node element. + * @param {Number} [options.r1] (Required) Pixel radius of the start circle + * where 2 fingers will be on when the gesture starts. The circles are + * centered at the center of the element. + * @param {Number} [options.r2] (Required) Pixel radius of the end circle + * when this gesture ends. + * @param {Number} [options.duration=1000] (Optional) The duration of the + * gesture in milliseconds. + * @param {Number} [options.start=0] (Optional) Starting degree of the first + * finger. The value is relative to the path of the north. Default is 0 + * (i.e., 12:00 on a clock). + * @param {Number} [options.rotation=0] (Optional) Degrees to rotate from + * the starting degree. A negative value means rotation to the + * counter-clockwise direction. + * + * Valid options properties for the `rotate` gesture: + * + * @param {Array} [options.center] (Optional) The center of the circle where + * two fingers are placed. Default is the center of the node element. + * @param {Number} [options.r1] (Optional) Pixel radius of the start circle + * where 2 fingers will be on when the gesture starts. The circles are + * centered at the center of the element. Default is a fourth of the node + * element width or height, whichever is smaller. + * @param {Number} [options.r2] (Optional) Pixel radius of the end circle + * when this gesture ends. Default is a fourth of the node element width or + * height, whichever is smaller. + * @param {Number} [options.duration=1000] (Optional) The duration of the + * gesture in milliseconds. + * @param {Number} [options.start=0] (Optional) Starting degree of the first + * finger. The value is relative to the path of the north. Default is 0 + * (i.e., 12:00 on a clock). + * @param {Number} [options.rotation] (Required) Degrees to rotate from + * the starting degree. A negative value means rotation to the + * counter-clockwise direction. + * + * @param {Function} [cb] The callback to execute when the asynchronouse gesture + * simulation is completed. + * @param {Error} cb.err An error object if the simulation is failed. + * @for Node + */ +Y.Node.prototype.simulateGesture = function (name, options, cb) { + + Y.Event.simulateGesture(this, name, options, cb); +}; + + +}, '3.17.2', {"requires": ["node-base", "event-simulate", "gesture-simulate"]}); Added: roller/trunk/app/src/main/webapp/roller-ui/yui3/node-focusmanager/node-focusmanager-min.js URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/webapp/roller-ui/yui3/node-focusmanager/node-focusmanager-min.js?rev=1609737&view=auto ============================================================================== --- roller/trunk/app/src/main/webapp/roller-ui/yui3/node-focusmanager/node-focusmanager-min.js (added) +++ roller/trunk/app/src/main/webapp/roller-ui/yui3/node-focusmanager/node-focusmanager-min.js Fri Jul 11 16:23:25 2014 @@ -0,0 +1,8 @@ +/* +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-focusmanager",function(e,t){var n="activeDescendant",r="id",i="disabled",s="tabIndex",o="focused",u="focusClass",a="circular",f="UI",l="key",c=n+"Change",h="host",p={37:!0,38:!0,39:!0,40:!0},d={a:!0,button:!0,input:!0,object:!0},v=e.Lang,m=e.UA,g=function(){g.superclass.constructor.apply(this,arguments)};g.ATTRS={focused:{value:!1,readOnly:!0},descendants:{getter:function(e){return this.get(h).all(e)}},activeDescendant:{setter:function(t){var n=v.isNumber,i=e.Attribute.INVALID_VALUE,s=this._descendantsMap,o=this._descendants,u,a,f;return n(t)?(u=t,a=u):t instanceof e.Node&&s?(u=s[t.get(r)],n(u)?a=u:a=i):a=i,o&&(f=o.item(u),f&&f.get("disabled")&&(a=i)),a}},keys:{value:{next:null,previous:null}},focusClass:{},circular:{value:!0}},e.extend(g,e.Plugin.Base,{_stopped:!0,_descendants:null,_descendantsMap:null,_focusedNode:null,_lastNodeIndex:0,_eventHandlers:null,_initDescendants:function(){var t=this.get("descendants"),o={},u=-1,a,f=this.get(n),l,c,h=0;v.isUndefined(f)&&(f= -1);if(t){a=t.size();for(h=0;h=0&&(r-=1,r===-1&&this.get(a)&&(r=this._lastNodeIndex),i=this._descendants.item(r),i&&(i.get("disabled")?this._focusPrevious(e,r):this.focus(r))),this._preventScroll(e)},_afterActiveDescendantChange:function(e){var t=this._descendants.item(e.prevVal);t&&t.set(s,-1),t=this._descendants.item(e.newVal),t&&t.set(s,0)},initializer:function(e){this.start()},destructor:function(){this.stop(),this.get(h).focusManager=null},focus:function(e){v.isUndefined(e)&&(e=this.get(n)),this.set(n,e,{src:f});var t=this._descendants.item(this.get(n));t&&(t.focus(),m.opera&&t.get("nodeName").toLowerCase()==="button"&&(this._focusTarget=t))},blur:function(){var e;this.get(o)&&(e=this._descendants.item(this.get(n)),e&&(e.blur(),this._removeFocusClass()),this._set(o,!1,{src:f}))},start:function(){this._stopped&&(this._initDescendants(),this._attachEventHandlers(),this._ stopped=!1)},stop:function(){this._stopped||(this._detachEventHandlers(),this._descendants=null,this._focusedNode=null,this._lastNodeIndex=0,this._stopped=!0)},refresh:function(){this._initDescendants(),this._eventHandlers||this._attachEventHandlers()}}),g.NAME="nodeFocusManager",g.NS="focusManager",e.namespace("Plugin"),e.Plugin.NodeFocusManager=g},"3.17.2",{requires:["attribute","node","plugin","node-event-simulate","event-key","event-focus"]});