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/css/addGetHookIf.js | 26 +++++ .../assets/lib/jquery/src/css/adjustCSS.js | 71 ++++++++++++++ .../testapi-ui/assets/lib/jquery/src/css/curCSS.js | 65 +++++++++++++ .../lib/jquery/src/css/hiddenVisibleSelectors.js | 15 +++ .../assets/lib/jquery/src/css/showHide.js | 105 +++++++++++++++++++++ .../assets/lib/jquery/src/css/support.js | 89 +++++++++++++++++ .../assets/lib/jquery/src/css/var/cssExpand.js | 5 + .../assets/lib/jquery/src/css/var/getStyles.js | 17 ++++ .../lib/jquery/src/css/var/isHiddenWithinTree.js | 34 +++++++ .../assets/lib/jquery/src/css/var/rmargin.js | 5 + .../assets/lib/jquery/src/css/var/rnumnonpx.js | 7 ++ .../assets/lib/jquery/src/css/var/swap.js | 26 +++++ 12 files changed, 465 insertions(+) create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/addGetHookIf.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/adjustCSS.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/curCSS.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/hiddenVisibleSelectors.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/showHide.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/support.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/cssExpand.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/getStyles.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/isHiddenWithinTree.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/rmargin.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/rnumnonpx.js create mode 100644 cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/swap.js (limited to 'cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css') diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/addGetHookIf.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/addGetHookIf.js new file mode 100644 index 00000000..e4bb49a6 --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/addGetHookIf.js @@ -0,0 +1,26 @@ +define( function() { + +"use strict"; + +function addGetHookIf( conditionFn, hookFn ) { + + // Define the hook, we'll check on the first run if it's really needed. + return { + get: function() { + if ( conditionFn() ) { + + // Hook not needed (or it's not possible to use it due + // to missing dependency), remove it. + delete this.get; + return; + } + + // Hook needed; redefine it so that the support test is not executed again. + return ( this.get = hookFn ).apply( this, arguments ); + } + }; +} + +return addGetHookIf; + +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/adjustCSS.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/adjustCSS.js new file mode 100644 index 00000000..ded3a166 --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/adjustCSS.js @@ -0,0 +1,71 @@ +define( [ + "../core", + "../var/rcssNum" +], function( jQuery, rcssNum ) { + +"use strict"; + +function adjustCSS( elem, prop, valueParts, tween ) { + var adjusted, + scale = 1, + maxIterations = 20, + currentValue = tween ? + function() { + return tween.cur(); + } : + function() { + return jQuery.css( elem, prop, "" ); + }, + initial = currentValue(), + unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), + + // Starting value computation is required for potential unit mismatches + initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && + rcssNum.exec( jQuery.css( elem, prop ) ); + + if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { + + // Trust units reported by jQuery.css + unit = unit || initialInUnit[ 3 ]; + + // Make sure we update the tween properties later on + valueParts = valueParts || []; + + // Iteratively approximate from a nonzero starting point + initialInUnit = +initial || 1; + + do { + + // If previous iteration zeroed out, double until we get *something*. + // Use string for doubling so we don't accidentally see scale as unchanged below + scale = scale || ".5"; + + // Adjust and apply + initialInUnit = initialInUnit / scale; + jQuery.style( elem, prop, initialInUnit + unit ); + + // Update scale, tolerating zero or NaN from tween.cur() + // Break the loop if scale is unchanged or perfect, or if we've just had enough. + } while ( + scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations + ); + } + + if ( valueParts ) { + initialInUnit = +initialInUnit || +initial || 0; + + // Apply relative offset (+=/-=) if specified + adjusted = valueParts[ 1 ] ? + initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : + +valueParts[ 2 ]; + if ( tween ) { + tween.unit = unit; + tween.start = initialInUnit; + tween.end = adjusted; + } + } + return adjusted; +} + +return adjustCSS; +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/curCSS.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/curCSS.js new file mode 100644 index 00000000..01ccad3a --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/curCSS.js @@ -0,0 +1,65 @@ +define( [ + "../core", + "./var/rnumnonpx", + "./var/rmargin", + "./var/getStyles", + "./support", + "../selector" // Get jQuery.contains +], function( jQuery, rnumnonpx, rmargin, getStyles, support ) { + +"use strict"; + +function curCSS( elem, name, computed ) { + var width, minWidth, maxWidth, ret, + + // Support: Firefox 51+ + // Retrieving style before computed somehow + // fixes an issue with getting wrong values + // on detached elements + style = elem.style; + + computed = computed || getStyles( elem ); + + // getPropertyValue is needed for: + // .css('filter') (IE 9 only, #12537) + // .css('--customProperty) (#3144) + if ( computed ) { + ret = computed.getPropertyValue( name ) || computed[ name ]; + + if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { + ret = jQuery.style( elem, name ); + } + + // A tribute to the "awesome hack by Dean Edwards" + // Android Browser returns percentage for some values, + // but width seems to be reliably pixels. + // This is against the CSSOM draft spec: + // https://drafts.csswg.org/cssom/#resolved-values + if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) { + + // Remember the original values + width = style.width; + minWidth = style.minWidth; + maxWidth = style.maxWidth; + + // Put in the new values to get a computed value out + style.minWidth = style.maxWidth = style.width = ret; + ret = computed.width; + + // Revert the changed values + style.width = width; + style.minWidth = minWidth; + style.maxWidth = maxWidth; + } + } + + return ret !== undefined ? + + // Support: IE <=9 - 11 only + // IE returns zIndex value as an integer. + ret + "" : + ret; +} + +return curCSS; +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/hiddenVisibleSelectors.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/hiddenVisibleSelectors.js new file mode 100644 index 00000000..d7a9339d --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/hiddenVisibleSelectors.js @@ -0,0 +1,15 @@ +define( [ + "../core", + "../selector" +], function( jQuery ) { + +"use strict"; + +jQuery.expr.pseudos.hidden = function( elem ) { + return !jQuery.expr.pseudos.visible( elem ); +}; +jQuery.expr.pseudos.visible = function( elem ) { + return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ); +}; + +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/showHide.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/showHide.js new file mode 100644 index 00000000..3eeafef1 --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/showHide.js @@ -0,0 +1,105 @@ +define( [ + "../core", + "../data/var/dataPriv", + "../css/var/isHiddenWithinTree" +], function( jQuery, dataPriv, isHiddenWithinTree ) { + +"use strict"; + +var defaultDisplayMap = {}; + +function getDefaultDisplay( elem ) { + var temp, + doc = elem.ownerDocument, + nodeName = elem.nodeName, + display = defaultDisplayMap[ nodeName ]; + + if ( display ) { + return display; + } + + temp = doc.body.appendChild( doc.createElement( nodeName ) ); + display = jQuery.css( temp, "display" ); + + temp.parentNode.removeChild( temp ); + + if ( display === "none" ) { + display = "block"; + } + defaultDisplayMap[ nodeName ] = display; + + return display; +} + +function showHide( elements, show ) { + var display, elem, + values = [], + index = 0, + length = elements.length; + + // Determine new display value for elements that need to change + for ( ; index < length; index++ ) { + elem = elements[ index ]; + if ( !elem.style ) { + continue; + } + + display = elem.style.display; + if ( show ) { + + // Since we force visibility upon cascade-hidden elements, an immediate (and slow) + // check is required in this first loop unless we have a nonempty display value (either + // inline or about-to-be-restored) + if ( display === "none" ) { + values[ index ] = dataPriv.get( elem, "display" ) || null; + if ( !values[ index ] ) { + elem.style.display = ""; + } + } + if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) { + values[ index ] = getDefaultDisplay( elem ); + } + } else { + if ( display !== "none" ) { + values[ index ] = "none"; + + // Remember what we're overwriting + dataPriv.set( elem, "display", display ); + } + } + } + + // Set the display of the elements in a second loop to avoid constant reflow + for ( index = 0; index < length; index++ ) { + if ( values[ index ] != null ) { + elements[ index ].style.display = values[ index ]; + } + } + + return elements; +} + +jQuery.fn.extend( { + show: function() { + return showHide( this, true ); + }, + hide: function() { + return showHide( this ); + }, + toggle: function( state ) { + if ( typeof state === "boolean" ) { + return state ? this.show() : this.hide(); + } + + return this.each( function() { + if ( isHiddenWithinTree( this ) ) { + jQuery( this ).show(); + } else { + jQuery( this ).hide(); + } + } ); + } +} ); + +return showHide; +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/support.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/support.js new file mode 100644 index 00000000..883d0e53 --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/support.js @@ -0,0 +1,89 @@ +define( [ + "../core", + "../var/document", + "../var/documentElement", + "../var/support" +], function( jQuery, document, documentElement, support ) { + +"use strict"; + +( function() { + + // Executing both pixelPosition & boxSizingReliable tests require only one layout + // so they're executed at the same time to save the second computation. + function computeStyleTests() { + + // This is a singleton, we need to execute it only once + if ( !div ) { + return; + } + + div.style.cssText = + "box-sizing:border-box;" + + "position:relative;display:block;" + + "margin:auto;border:1px;padding:1px;" + + "top:1%;width:50%"; + div.innerHTML = ""; + documentElement.appendChild( container ); + + var divStyle = window.getComputedStyle( div ); + pixelPositionVal = divStyle.top !== "1%"; + + // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 + reliableMarginLeftVal = divStyle.marginLeft === "2px"; + boxSizingReliableVal = divStyle.width === "4px"; + + // Support: Android 4.0 - 4.3 only + // Some styles come back with percentage values, even though they shouldn't + div.style.marginRight = "50%"; + pixelMarginRightVal = divStyle.marginRight === "4px"; + + documentElement.removeChild( container ); + + // Nullify the div so it wouldn't be stored in the memory and + // it will also be a sign that checks already performed + div = null; + } + + var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal, + container = document.createElement( "div" ), + div = document.createElement( "div" ); + + // Finish early in limited (non-browser) environments + if ( !div.style ) { + return; + } + + // Support: IE <=9 - 11 only + // Style of cloned element affects source element cloned (#8908) + div.style.backgroundClip = "content-box"; + div.cloneNode( true ).style.backgroundClip = ""; + support.clearCloneStyle = div.style.backgroundClip === "content-box"; + + container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" + + "padding:0;margin-top:1px;position:absolute"; + container.appendChild( div ); + + jQuery.extend( support, { + pixelPosition: function() { + computeStyleTests(); + return pixelPositionVal; + }, + boxSizingReliable: function() { + computeStyleTests(); + return boxSizingReliableVal; + }, + pixelMarginRight: function() { + computeStyleTests(); + return pixelMarginRightVal; + }, + reliableMarginLeft: function() { + computeStyleTests(); + return reliableMarginLeftVal; + } + } ); +} )(); + +return support; + +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/cssExpand.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/cssExpand.js new file mode 100644 index 00000000..dd2007c3 --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/cssExpand.js @@ -0,0 +1,5 @@ +define( function() { + "use strict"; + + return [ "Top", "Right", "Bottom", "Left" ]; +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/getStyles.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/getStyles.js new file mode 100644 index 00000000..0b893acf --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/getStyles.js @@ -0,0 +1,17 @@ +define( function() { + "use strict"; + + return function( elem ) { + + // Support: IE <=11 only, Firefox <=30 (#15098, #14150) + // IE throws on elements created in popups + // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" + var view = elem.ownerDocument.defaultView; + + if ( !view || !view.opener ) { + view = window; + } + + return view.getComputedStyle( elem ); + }; +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/isHiddenWithinTree.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/isHiddenWithinTree.js new file mode 100644 index 00000000..3cfb93e1 --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/isHiddenWithinTree.js @@ -0,0 +1,34 @@ +define( [ + "../../core", + "../../selector" + + // css is assumed +], function( jQuery ) { + "use strict"; + + // isHiddenWithinTree reports if an element has a non-"none" display style (inline and/or + // through the CSS cascade), which is useful in deciding whether or not to make it visible. + // It differs from the :hidden selector (jQuery.expr.pseudos.hidden) in two important ways: + // * A hidden ancestor does not force an element to be classified as hidden. + // * Being disconnected from the document does not force an element to be classified as hidden. + // These differences improve the behavior of .toggle() et al. when applied to elements that are + // detached or contained within hidden ancestors (gh-2404, gh-2863). + return function( elem, el ) { + + // isHiddenWithinTree might be called from jQuery#filter function; + // in that case, element will be second argument + elem = el || elem; + + // Inline style trumps all + return elem.style.display === "none" || + elem.style.display === "" && + + // Otherwise, check computed style + // Support: Firefox <=43 - 45 + // Disconnected elements can have computed display: none, so first confirm that elem is + // in the document. + jQuery.contains( elem.ownerDocument, elem ) && + + jQuery.css( elem, "display" ) === "none"; + }; +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/rmargin.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/rmargin.js new file mode 100644 index 00000000..0fbfbd85 --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/rmargin.js @@ -0,0 +1,5 @@ +define( function() { + "use strict"; + + return ( /^margin/ ); +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/rnumnonpx.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/rnumnonpx.js new file mode 100644 index 00000000..056cda7a --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/rnumnonpx.js @@ -0,0 +1,7 @@ +define( [ + "../../var/pnum" +], function( pnum ) { + "use strict"; + + return new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); +} ); diff --git a/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/swap.js b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/swap.js new file mode 100644 index 00000000..1a9556ba --- /dev/null +++ b/cvp/3rd_party/static/testapi-ui/assets/lib/jquery/src/css/var/swap.js @@ -0,0 +1,26 @@ +define( function() { + +"use strict"; + +// A method for quickly swapping in/out CSS properties to get correct calculations. +return function( elem, options, callback, args ) { + var ret, name, + old = {}; + + // Remember the old values, and insert the new ones + for ( name in options ) { + old[ name ] = elem.style[ name ]; + elem.style[ name ] = options[ name ]; + } + + ret = callback.apply( elem, args || [] ); + + // Revert the old values + for ( name in options ) { + elem.style[ name ] = old[ name ]; + } + + return ret; +}; + +} ); -- cgit 1.2.3-korg