From 0cf6b232ac9cf128ee9183a27c08f4f74ab2e2e6 Mon Sep 17 00:00:00 2001 From: grakiss Date: Thu, 28 Sep 2017 03:47:54 -0400 Subject: add api&web services for cvp JIRA: DOVETAIL-512 add api&web services for cvp Change-Id: I9ef9525e980fe61dc3108035ef9a3ff8783b2697 Signed-off-by: grakiss --- .../assets/lib/jquery/src/core/DOMEval.js | 16 +++ .../assets/lib/jquery/src/core/access.js | 70 +++++++++++ .../testapi-ui/assets/lib/jquery/src/core/init.js | 128 +++++++++++++++++++++ .../assets/lib/jquery/src/core/nodeName.js | 13 +++ .../assets/lib/jquery/src/core/parseHTML.js | 65 +++++++++++ .../lib/jquery/src/core/ready-no-deferred.js | 96 ++++++++++++++++ .../testapi-ui/assets/lib/jquery/src/core/ready.js | 86 ++++++++++++++ .../assets/lib/jquery/src/core/readyException.js | 13 +++ .../assets/lib/jquery/src/core/stripAndCollapse.js | 14 +++ .../assets/lib/jquery/src/core/support.js | 20 ++++ .../assets/lib/jquery/src/core/var/rsingleTag.js | 6 + 11 files changed, 527 insertions(+) create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/DOMEval.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/access.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/init.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/nodeName.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/parseHTML.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/ready-no-deferred.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/ready.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/readyException.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/stripAndCollapse.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/support.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/var/rsingleTag.js (limited to 'cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core') diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/DOMEval.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/DOMEval.js new file mode 100644 index 00000000..c49c12e5 --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/DOMEval.js @@ -0,0 +1,16 @@ +define( [ + "../var/document" +], function( document ) { + "use strict"; + + function DOMEval( code, doc ) { + doc = doc || document; + + var script = doc.createElement( "script" ); + + script.text = code; + doc.head.appendChild( script ).parentNode.removeChild( script ); + } + + return DOMEval; +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/access.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/access.js new file mode 100644 index 00000000..86cdbc7e --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/access.js @@ -0,0 +1,70 @@ +define( [ + "../core" +], function( jQuery ) { + +"use strict"; + +// Multifunctional method to get and set values of a collection +// The value/s can optionally be executed if it's a function +var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { + var i = 0, + len = elems.length, + bulk = key == null; + + // Sets many values + if ( jQuery.type( key ) === "object" ) { + chainable = true; + for ( i in key ) { + access( elems, fn, i, key[ i ], true, emptyGet, raw ); + } + + // Sets one value + } else if ( value !== undefined ) { + chainable = true; + + if ( !jQuery.isFunction( value ) ) { + raw = true; + } + + if ( bulk ) { + + // Bulk operations run against the entire set + if ( raw ) { + fn.call( elems, value ); + fn = null; + + // ...except when executing function values + } else { + bulk = fn; + fn = function( elem, key, value ) { + return bulk.call( jQuery( elem ), value ); + }; + } + } + + if ( fn ) { + for ( ; i < len; i++ ) { + fn( + elems[ i ], key, raw ? + value : + value.call( elems[ i ], i, fn( elems[ i ], key ) ) + ); + } + } + } + + if ( chainable ) { + return elems; + } + + // Gets + if ( bulk ) { + return fn.call( elems ); + } + + return len ? fn( elems[ 0 ], key ) : emptyGet; +}; + +return access; + +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/init.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/init.js new file mode 100644 index 00000000..8841264d --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/init.js @@ -0,0 +1,128 @@ +// Initialize a jQuery object +define( [ + "../core", + "../var/document", + "./var/rsingleTag", + + "../traversing/findFilter" +], function( jQuery, document, rsingleTag ) { + +"use strict"; + +// A central reference to the root jQuery(document) +var rootjQuery, + + // A simple way to check for HTML strings + // Prioritize #id over to avoid XSS via location.hash (#9521) + // Strict HTML recognition (#11290: must start with <) + // Shortcut simple #id case for speed + rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, + + init = jQuery.fn.init = function( selector, context, root ) { + var match, elem; + + // HANDLE: $(""), $(null), $(undefined), $(false) + if ( !selector ) { + return this; + } + + // Method init() accepts an alternate rootjQuery + // so migrate can support jQuery.sub (gh-2101) + root = root || rootjQuery; + + // Handle HTML strings + if ( typeof selector === "string" ) { + if ( selector[ 0 ] === "<" && + selector[ selector.length - 1 ] === ">" && + selector.length >= 3 ) { + + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; + + } else { + match = rquickExpr.exec( selector ); + } + + // Match html or make sure no context is specified for #id + if ( match && ( match[ 1 ] || !context ) ) { + + // HANDLE: $(html) -> $(array) + if ( match[ 1 ] ) { + context = context instanceof jQuery ? context[ 0 ] : context; + + // Option to run scripts is true for back-compat + // Intentionally let the error be thrown if parseHTML is not present + jQuery.merge( this, jQuery.parseHTML( + match[ 1 ], + context && context.nodeType ? context.ownerDocument || context : document, + true + ) ); + + // HANDLE: $(html, props) + if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { + for ( match in context ) { + + // Properties of context are called as methods if possible + if ( jQuery.isFunction( this[ match ] ) ) { + this[ match ]( context[ match ] ); + + // ...and otherwise set as attributes + } else { + this.attr( match, context[ match ] ); + } + } + } + + return this; + + // HANDLE: $(#id) + } else { + elem = document.getElementById( match[ 2 ] ); + + if ( elem ) { + + // Inject the element directly into the jQuery object + this[ 0 ] = elem; + this.length = 1; + } + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return ( context || root ).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(DOMElement) + } else if ( selector.nodeType ) { + this[ 0 ] = selector; + this.length = 1; + return this; + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) { + return root.ready !== undefined ? + root.ready( selector ) : + + // Execute immediately if ready is not present + selector( jQuery ); + } + + return jQuery.makeArray( selector, this ); + }; + +// Give the init function the jQuery prototype for later instantiation +init.prototype = jQuery.fn; + +// Initialize central reference +rootjQuery = jQuery( document ); + +return init; + +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/nodeName.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/nodeName.js new file mode 100644 index 00000000..8a5f5f03 --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/nodeName.js @@ -0,0 +1,13 @@ +define( function() { + +"use strict"; + +function nodeName( elem, name ) { + + return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); + +}; + +return nodeName; + +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/parseHTML.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/parseHTML.js new file mode 100644 index 00000000..21ff6bfa --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/parseHTML.js @@ -0,0 +1,65 @@ +define( [ + "../core", + "../var/document", + "./var/rsingleTag", + "../manipulation/buildFragment", + + // This is the only module that needs core/support + "./support" +], function( jQuery, document, rsingleTag, buildFragment, support ) { + +"use strict"; + +// Argument "data" should be string of html +// context (optional): If specified, the fragment will be created in this context, +// defaults to document +// keepScripts (optional): If true, will include scripts passed in the html string +jQuery.parseHTML = function( data, context, keepScripts ) { + if ( typeof data !== "string" ) { + return []; + } + if ( typeof context === "boolean" ) { + keepScripts = context; + context = false; + } + + var base, parsed, scripts; + + if ( !context ) { + + // Stop scripts or inline event handlers from being executed immediately + // by using document.implementation + if ( support.createHTMLDocument ) { + context = document.implementation.createHTMLDocument( "" ); + + // Set the base href for the created document + // so any parsed elements with URLs + // are based on the document's URL (gh-2965) + base = context.createElement( "base" ); + base.href = document.location.href; + context.head.appendChild( base ); + } else { + context = document; + } + } + + parsed = rsingleTag.exec( data ); + scripts = !keepScripts && []; + + // Single tag + if ( parsed ) { + return [ context.createElement( parsed[ 1 ] ) ]; + } + + parsed = buildFragment( [ data ], context, scripts ); + + if ( scripts && scripts.length ) { + jQuery( scripts ).remove(); + } + + return jQuery.merge( [], parsed.childNodes ); +}; + +return jQuery.parseHTML; + +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/ready-no-deferred.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/ready-no-deferred.js new file mode 100644 index 00000000..a7722ae9 --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/ready-no-deferred.js @@ -0,0 +1,96 @@ +define( [ + "../core", + "../var/document" +], function( jQuery, document ) { + +"use strict"; + +var readyCallbacks = [], + whenReady = function( fn ) { + readyCallbacks.push( fn ); + }, + executeReady = function( fn ) { + + // Prevent errors from freezing future callback execution (gh-1823) + // Not backwards-compatible as this does not execute sync + window.setTimeout( function() { + fn.call( document, jQuery ); + } ); + }; + +jQuery.fn.ready = function( fn ) { + whenReady( fn ); + return this; +}; + +jQuery.extend( { + + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + ready: function( wait ) { + + // Abort if there are pending holds or we're already ready + if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { + return; + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + whenReady = function( fn ) { + readyCallbacks.push( fn ); + + while ( readyCallbacks.length ) { + fn = readyCallbacks.shift(); + if ( jQuery.isFunction( fn ) ) { + executeReady( fn ); + } + } + }; + + whenReady(); + } +} ); + +// Make jQuery.ready Promise consumable (gh-1778) +jQuery.ready.then = jQuery.fn.ready; + +/** + * The ready event handler and self cleanup method + */ +function completed() { + document.removeEventListener( "DOMContentLoaded", completed ); + window.removeEventListener( "load", completed ); + jQuery.ready(); +} + +// Catch cases where $(document).ready() is called +// after the browser event has already occurred. +// Support: IE9-10 only +// Older IE sometimes signals "interactive" too soon +if ( document.readyState === "complete" || + ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { + + // Handle it asynchronously to allow scripts the opportunity to delay ready + window.setTimeout( jQuery.ready ); + +} else { + + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", completed ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", completed ); +} + +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/ready.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/ready.js new file mode 100644 index 00000000..794feeec --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/ready.js @@ -0,0 +1,86 @@ +define( [ + "../core", + "../var/document", + "../core/readyException", + "../deferred" +], function( jQuery, document ) { + +"use strict"; + +// The deferred used on DOM ready +var readyList = jQuery.Deferred(); + +jQuery.fn.ready = function( fn ) { + + readyList + .then( fn ) + + // Wrap jQuery.readyException in a function so that the lookup + // happens at the time of error handling instead of callback + // registration. + .catch( function( error ) { + jQuery.readyException( error ); + } ); + + return this; +}; + +jQuery.extend( { + + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + // Handle when the DOM is ready + ready: function( wait ) { + + // Abort if there are pending holds or we're already ready + if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { + return; + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.resolveWith( document, [ jQuery ] ); + } +} ); + +jQuery.ready.then = readyList.then; + +// The ready event handler and self cleanup method +function completed() { + document.removeEventListener( "DOMContentLoaded", completed ); + window.removeEventListener( "load", completed ); + jQuery.ready(); +} + +// Catch cases where $(document).ready() is called +// after the browser event has already occurred. +// Support: IE <=9 - 10 only +// Older IE sometimes signals "interactive" too soon +if ( document.readyState === "complete" || + ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { + + // Handle it asynchronously to allow scripts the opportunity to delay ready + window.setTimeout( jQuery.ready ); + +} else { + + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", completed ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", completed ); +} + +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/readyException.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/readyException.js new file mode 100644 index 00000000..72bdd90b --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/readyException.js @@ -0,0 +1,13 @@ +define( [ + "../core" +], function( jQuery ) { + +"use strict"; + +jQuery.readyException = function( error ) { + window.setTimeout( function() { + throw error; + } ); +}; + +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/stripAndCollapse.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/stripAndCollapse.js new file mode 100644 index 00000000..ccad6602 --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/stripAndCollapse.js @@ -0,0 +1,14 @@ +define( [ + "../var/rnothtmlwhite" +], function( rnothtmlwhite ) { + "use strict"; + + // Strip and collapse whitespace according to HTML spec + // https://html.spec.whatwg.org/multipage/infrastructure.html#strip-and-collapse-whitespace + function stripAndCollapse( value ) { + var tokens = value.match( rnothtmlwhite ) || []; + return tokens.join( " " ); + } + + return stripAndCollapse; +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/support.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/support.js new file mode 100644 index 00000000..13ae02f0 --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/support.js @@ -0,0 +1,20 @@ +define( [ + "../var/document", + "../var/support" +], function( document, support ) { + +"use strict"; + +// Support: Safari 8 only +// In Safari 8 documents created via document.implementation.createHTMLDocument +// collapse sibling forms: the second one becomes a child of the first one. +// Because of that, this security measure has to be disabled in Safari 8. +// https://bugs.webkit.org/show_bug.cgi?id=137337 +support.createHTMLDocument = ( function() { + var body = document.implementation.createHTMLDocument( "" ).body; + body.innerHTML = "
"; + return body.childNodes.length === 2; +} )(); + +return support; +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/var/rsingleTag.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/var/rsingleTag.js new file mode 100644 index 00000000..4d6e8a0a --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/core/var/rsingleTag.js @@ -0,0 +1,6 @@ +define( function() { + "use strict"; + + // Match a standalone tag + return ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i ); +} ); -- cgit 1.2.3-korg