code
stringlengths 24
2.07M
| docstring
stringlengths 25
85.3k
| func_name
stringlengths 1
92
| language
stringclasses 1
value | repo
stringlengths 5
64
| path
stringlengths 4
172
| url
stringlengths 44
218
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
function returnFalse() {
return false;
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | returnFalse | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function safeActiveElement() {
try {
return document.activeElement;
} catch ( err ) { }
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | safeActiveElement | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function on( elem, types, selector, data, fn, one ) {
var origFn, type;
// Types can be a map of types/handlers
if ( typeof types === "object" ) {
// ( types-Object, selector, data )
if ( typeof selector !== "string" ) {
// ( types-Object, data )
data = data || selector;
selector = undefined;
}
for ( type in types ) {
on( elem, type, selector, data, types[ type ], one );
}
return elem;
}
if ( data == null && fn == null ) {
// ( types, fn )
fn = selector;
data = selector = undefined;
} else if ( fn == null ) {
if ( typeof selector === "string" ) {
// ( types, selector, fn )
fn = data;
data = undefined;
} else {
// ( types, data, fn )
fn = data;
data = selector;
selector = undefined;
}
}
if ( fn === false ) {
fn = returnFalse;
} else if ( !fn ) {
return elem;
}
if ( one === 1 ) {
origFn = fn;
fn = function( event ) {
// Can use an empty set, since event contains the info
jQuery().off( event );
return origFn.apply( this, arguments );
};
// Use same guid so caller can remove using origFn
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
}
return elem.each( function() {
jQuery.event.add( this, types, fn, data, selector );
} );
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | on | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function manipulationTarget( elem, content ) {
if ( jQuery.nodeName( elem, "table" ) &&
jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
return elem.getElementsByTagName( "tbody" )[ 0 ] || elem;
}
return elem;
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | manipulationTarget | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function disableScript( elem ) {
elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
return elem;
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | disableScript | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function restoreScript( elem ) {
var match = rscriptTypeMasked.exec( elem.type );
if ( match ) {
elem.type = match[ 1 ];
} else {
elem.removeAttribute( "type" );
}
return elem;
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | restoreScript | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function cloneCopyEvent( src, dest ) {
var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
if ( dest.nodeType !== 1 ) {
return;
}
// 1. Copy private data: events, handlers, etc.
if ( dataPriv.hasData( src ) ) {
pdataOld = dataPriv.access( src );
pdataCur = dataPriv.set( dest, pdataOld );
events = pdataOld.events;
if ( events ) {
delete pdataCur.handle;
pdataCur.events = {};
for ( type in events ) {
for ( i = 0, l = events[ type ].length; i < l; i++ ) {
jQuery.event.add( dest, type, events[ type ][ i ] );
}
}
}
}
// 2. Copy user data
if ( dataUser.hasData( src ) ) {
udataOld = dataUser.access( src );
udataCur = jQuery.extend( {}, udataOld );
dataUser.set( dest, udataCur );
}
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | cloneCopyEvent | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function fixInput( src, dest ) {
var nodeName = dest.nodeName.toLowerCase();
// Fails to persist the checked state of a cloned checkbox or radio button.
if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
dest.checked = src.checked;
// Fails to return the selected option to the default selected state when cloning options
} else if ( nodeName === "input" || nodeName === "textarea" ) {
dest.defaultValue = src.defaultValue;
}
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | fixInput | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function domManip( collection, args, callback, ignored ) {
// Flatten any nested arrays
args = concat.apply( [], args );
var fragment, first, scripts, hasScripts, node, doc,
i = 0,
l = collection.length,
iNoClone = l - 1,
value = args[ 0 ],
isFunction = jQuery.isFunction( value );
// We can't cloneNode fragments that contain checked, in WebKit
if ( isFunction ||
( l > 1 && typeof value === "string" &&
!support.checkClone && rchecked.test( value ) ) ) {
return collection.each( function( index ) {
var self = collection.eq( index );
if ( isFunction ) {
args[ 0 ] = value.call( this, index, self.html() );
}
domManip( self, args, callback, ignored );
} );
}
if ( l ) {
fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
first = fragment.firstChild;
if ( fragment.childNodes.length === 1 ) {
fragment = first;
}
// Require either new content or an interest in ignored elements to invoke the callback
if ( first || ignored ) {
scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
hasScripts = scripts.length;
// Use the original fragment for the last item
// instead of the first because it can end up
// being emptied incorrectly in certain situations (#8070).
for ( ; i < l; i++ ) {
node = fragment;
if ( i !== iNoClone ) {
node = jQuery.clone( node, true, true );
// Keep references to cloned scripts for later restoration
if ( hasScripts ) {
// Support: Android <=4.0 only, PhantomJS 1 only
// push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( scripts, getAll( node, "script" ) );
}
}
callback.call( collection[ i ], node, i );
}
if ( hasScripts ) {
doc = scripts[ scripts.length - 1 ].ownerDocument;
// Reenable scripts
jQuery.map( scripts, restoreScript );
// Evaluate executable scripts on first document insertion
for ( i = 0; i < hasScripts; i++ ) {
node = scripts[ i ];
if ( rscriptType.test( node.type || "" ) &&
!dataPriv.access( node, "globalEval" ) &&
jQuery.contains( doc, node ) ) {
if ( node.src ) {
// Optional AJAX dependency, but won't run scripts if not present
if ( jQuery._evalUrl ) {
jQuery._evalUrl( node.src );
}
} else {
DOMEval( node.textContent.replace( rcleanScript, "" ), doc );
}
}
}
}
}
}
return collection;
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | domManip | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function remove( elem, selector, keepData ) {
var node,
nodes = selector ? jQuery.filter( selector, elem ) : elem,
i = 0;
for ( ; ( node = nodes[ i ] ) != null; i++ ) {
if ( !keepData && node.nodeType === 1 ) {
jQuery.cleanData( getAll( node ) );
}
if ( node.parentNode ) {
if ( keepData && jQuery.contains( node.ownerDocument, node ) ) {
setGlobalEval( getAll( node, "script" ) );
}
node.parentNode.removeChild( node );
}
}
return elem;
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | remove | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
getStyles = 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 );
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | getStyles | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
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;
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | computeStyleTests | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function curCSS( elem, name, computed ) {
var width, minWidth, maxWidth, ret,
style = elem.style;
computed = computed || getStyles( elem );
// Support: IE <=9 only
// getPropertyValue is only needed for .css('filter') (#12537)
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;
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | curCSS | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
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 );
}
};
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | addGetHookIf | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function vendorPropName( name ) {
// Shortcut for names that are not vendor prefixed
if ( name in emptyStyle ) {
return name;
}
// Check for vendor prefixed names
var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
i = cssPrefixes.length;
while ( i-- ) {
name = cssPrefixes[ i ] + capName;
if ( name in emptyStyle ) {
return name;
}
}
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | vendorPropName | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function setPositiveNumber( elem, value, subtract ) {
// Any relative (+/-) values have already been
// normalized at this point
var matches = rcssNum.exec( value );
return matches ?
// Guard against undefined "subtract", e.g., when used as in cssHooks
Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
value;
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | setPositiveNumber | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
var i,
val = 0;
// If we already have the right measurement, avoid augmentation
if ( extra === ( isBorderBox ? "border" : "content" ) ) {
i = 4;
// Otherwise initialize for horizontal or vertical properties
} else {
i = name === "width" ? 1 : 0;
}
for ( ; i < 4; i += 2 ) {
// Both box models exclude margin, so add it if we want it
if ( extra === "margin" ) {
val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
}
if ( isBorderBox ) {
// border-box includes padding, so remove it if we want content
if ( extra === "content" ) {
val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
}
// At this point, extra isn't border nor margin, so remove border
if ( extra !== "margin" ) {
val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
}
} else {
// At this point, extra isn't content, so add padding
val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
// At this point, extra isn't content nor padding, so add border
if ( extra !== "padding" ) {
val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
}
}
}
return val;
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | augmentWidthOrHeight | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function getWidthOrHeight( elem, name, extra ) {
// Start with offset property, which is equivalent to the border-box value
var val,
valueIsBorderBox = true,
styles = getStyles( elem ),
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
// Support: IE <=11 only
// Running getBoundingClientRect on a disconnected node
// in IE throws an error.
if ( elem.getClientRects().length ) {
val = elem.getBoundingClientRect()[ name ];
}
// Some non-html elements return undefined for offsetWidth, so check for null/undefined
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
if ( val <= 0 || val == null ) {
// Fall back to computed then uncomputed css if necessary
val = curCSS( elem, name, styles );
if ( val < 0 || val == null ) {
val = elem.style[ name ];
}
// Computed unit is not pixels. Stop here and return.
if ( rnumnonpx.test( val ) ) {
return val;
}
// Check for style in case a browser which returns unreliable values
// for getComputedStyle silently falls back to the reliable elem.style
valueIsBorderBox = isBorderBox &&
( support.boxSizingReliable() || val === elem.style[ name ] );
// Normalize "", auto, and prepare for extra
val = parseFloat( val ) || 0;
}
// Use the active box-sizing model to add/subtract irrelevant styles
return ( val +
augmentWidthOrHeight(
elem,
name,
extra || ( isBorderBox ? "border" : "content" ),
valueIsBorderBox,
styles
)
) + "px";
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | getWidthOrHeight | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function Tween( elem, options, prop, end, easing ) {
return new Tween.prototype.init( elem, options, prop, end, easing );
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | Tween | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function raf() {
if ( timerId ) {
window.requestAnimationFrame( raf );
jQuery.fx.tick();
}
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | raf | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function createFxNow() {
window.setTimeout( function() {
fxNow = undefined;
} );
return ( fxNow = jQuery.now() );
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | createFxNow | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function genFx( type, includeWidth ) {
var which,
i = 0,
attrs = { height: type };
// If we include width, step value is 1 to do all cssExpand values,
// otherwise step value is 2 to skip over Left and Right
includeWidth = includeWidth ? 1 : 0;
for ( ; i < 4; i += 2 - includeWidth ) {
which = cssExpand[ i ];
attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
}
if ( includeWidth ) {
attrs.opacity = attrs.width = type;
}
return attrs;
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | genFx | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function createTween( value, prop, animation ) {
var tween,
collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
index = 0,
length = collection.length;
for ( ; index < length; index++ ) {
if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
// We're done with this property
return tween;
}
}
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | createTween | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function defaultPrefilter( elem, props, opts ) {
var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
isBox = "width" in props || "height" in props,
anim = this,
orig = {},
style = elem.style,
hidden = elem.nodeType && isHiddenWithinTree( elem ),
dataShow = dataPriv.get( elem, "fxshow" );
// Queue-skipping animations hijack the fx hooks
if ( !opts.queue ) {
hooks = jQuery._queueHooks( elem, "fx" );
if ( hooks.unqueued == null ) {
hooks.unqueued = 0;
oldfire = hooks.empty.fire;
hooks.empty.fire = function() {
if ( !hooks.unqueued ) {
oldfire();
}
};
}
hooks.unqueued++;
anim.always( function() {
// Ensure the complete handler is called before this completes
anim.always( function() {
hooks.unqueued--;
if ( !jQuery.queue( elem, "fx" ).length ) {
hooks.empty.fire();
}
} );
} );
}
// Detect show/hide animations
for ( prop in props ) {
value = props[ prop ];
if ( rfxtypes.test( value ) ) {
delete props[ prop ];
toggle = toggle || value === "toggle";
if ( value === ( hidden ? "hide" : "show" ) ) {
// Pretend to be hidden if this is a "show" and
// there is still data from a stopped show/hide
if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
hidden = true;
// Ignore all other no-op show/hide data
} else {
continue;
}
}
orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
}
}
// Bail out if this is a no-op like .hide().hide()
propTween = !jQuery.isEmptyObject( props );
if ( !propTween && jQuery.isEmptyObject( orig ) ) {
return;
}
// Restrict "overflow" and "display" styles during box animations
if ( isBox && elem.nodeType === 1 ) {
// Support: IE <=9 - 11, Edge 12 - 13
// Record all 3 overflow attributes because IE does not infer the shorthand
// from identically-valued overflowX and overflowY
opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
// Identify a display type, preferring old show/hide data over the CSS cascade
restoreDisplay = dataShow && dataShow.display;
if ( restoreDisplay == null ) {
restoreDisplay = dataPriv.get( elem, "display" );
}
display = jQuery.css( elem, "display" );
if ( display === "none" ) {
if ( restoreDisplay ) {
display = restoreDisplay;
} else {
// Get nonempty value(s) by temporarily forcing visibility
showHide( [ elem ], true );
restoreDisplay = elem.style.display || restoreDisplay;
display = jQuery.css( elem, "display" );
showHide( [ elem ] );
}
}
// Animate inline elements as inline-block
if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
if ( jQuery.css( elem, "float" ) === "none" ) {
// Restore the original display value at the end of pure show/hide animations
if ( !propTween ) {
anim.done( function() {
style.display = restoreDisplay;
} );
if ( restoreDisplay == null ) {
display = style.display;
restoreDisplay = display === "none" ? "" : display;
}
}
style.display = "inline-block";
}
}
}
if ( opts.overflow ) {
style.overflow = "hidden";
anim.always( function() {
style.overflow = opts.overflow[ 0 ];
style.overflowX = opts.overflow[ 1 ];
style.overflowY = opts.overflow[ 2 ];
} );
}
// Implement show/hide animations
propTween = false;
for ( prop in orig ) {
// General show/hide setup for this element animation
if ( !propTween ) {
if ( dataShow ) {
if ( "hidden" in dataShow ) {
hidden = dataShow.hidden;
}
} else {
dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
}
// Store hidden/visible for toggle so `.stop().toggle()` "reverses"
if ( toggle ) {
dataShow.hidden = !hidden;
}
// Show elements before animating them
if ( hidden ) {
showHide( [ elem ], true );
}
/* eslint-disable no-loop-func */
anim.done( function() {
/* eslint-enable no-loop-func */
// The final step of a "hide" animation is actually hiding the element
if ( !hidden ) {
showHide( [ elem ] );
}
dataPriv.remove( elem, "fxshow" );
for ( prop in orig ) {
jQuery.style( elem, prop, orig[ prop ] );
}
} );
}
// Per-property setup
propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
if ( !( prop in dataShow ) ) {
dataShow[ prop ] = propTween.start;
if ( hidden ) {
propTween.end = propTween.start;
propTween.start = 0;
}
}
}
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | defaultPrefilter | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function propFilter( props, specialEasing ) {
var index, name, easing, value, hooks;
// camelCase, specialEasing and expand cssHook pass
for ( index in props ) {
name = jQuery.camelCase( index );
easing = specialEasing[ name ];
value = props[ index ];
if ( jQuery.isArray( value ) ) {
easing = value[ 1 ];
value = props[ index ] = value[ 0 ];
}
if ( index !== name ) {
props[ name ] = value;
delete props[ index ];
}
hooks = jQuery.cssHooks[ name ];
if ( hooks && "expand" in hooks ) {
value = hooks.expand( value );
delete props[ name ];
// Not quite $.extend, this won't overwrite existing keys.
// Reusing 'index' because we have the correct "name"
for ( index in value ) {
if ( !( index in props ) ) {
props[ index ] = value[ index ];
specialEasing[ index ] = easing;
}
}
} else {
specialEasing[ name ] = easing;
}
}
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | propFilter | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function Animation( elem, properties, options ) {
var result,
stopped,
index = 0,
length = Animation.prefilters.length,
deferred = jQuery.Deferred().always( function() {
// Don't match elem in the :animated selector
delete tick.elem;
} ),
tick = function() {
if ( stopped ) {
return false;
}
var currentTime = fxNow || createFxNow(),
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
// Support: Android 2.3 only
// Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
temp = remaining / animation.duration || 0,
percent = 1 - temp,
index = 0,
length = animation.tweens.length;
for ( ; index < length; index++ ) {
animation.tweens[ index ].run( percent );
}
deferred.notifyWith( elem, [ animation, percent, remaining ] );
if ( percent < 1 && length ) {
return remaining;
} else {
deferred.resolveWith( elem, [ animation ] );
return false;
}
},
animation = deferred.promise( {
elem: elem,
props: jQuery.extend( {}, properties ),
opts: jQuery.extend( true, {
specialEasing: {},
easing: jQuery.easing._default
}, options ),
originalProperties: properties,
originalOptions: options,
startTime: fxNow || createFxNow(),
duration: options.duration,
tweens: [],
createTween: function( prop, end ) {
var tween = jQuery.Tween( elem, animation.opts, prop, end,
animation.opts.specialEasing[ prop ] || animation.opts.easing );
animation.tweens.push( tween );
return tween;
},
stop: function( gotoEnd ) {
var index = 0,
// If we are going to the end, we want to run all the tweens
// otherwise we skip this part
length = gotoEnd ? animation.tweens.length : 0;
if ( stopped ) {
return this;
}
stopped = true;
for ( ; index < length; index++ ) {
animation.tweens[ index ].run( 1 );
}
// Resolve when we played the last frame; otherwise, reject
if ( gotoEnd ) {
deferred.notifyWith( elem, [ animation, 1, 0 ] );
deferred.resolveWith( elem, [ animation, gotoEnd ] );
} else {
deferred.rejectWith( elem, [ animation, gotoEnd ] );
}
return this;
}
} ),
props = animation.props;
propFilter( props, animation.opts.specialEasing );
for ( ; index < length; index++ ) {
result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
if ( result ) {
if ( jQuery.isFunction( result.stop ) ) {
jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
jQuery.proxy( result.stop, result );
}
return result;
}
}
jQuery.map( props, createTween, animation );
if ( jQuery.isFunction( animation.opts.start ) ) {
animation.opts.start.call( elem, animation );
}
jQuery.fx.timer(
jQuery.extend( tick, {
elem: elem,
anim: animation,
queue: animation.opts.queue
} )
);
// attach callbacks from options
return animation.progress( animation.opts.progress )
.done( animation.opts.done, animation.opts.complete )
.fail( animation.opts.fail )
.always( animation.opts.always );
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | Animation | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
tick = function() {
if ( stopped ) {
return false;
}
var currentTime = fxNow || createFxNow(),
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
// Support: Android 2.3 only
// Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
temp = remaining / animation.duration || 0,
percent = 1 - temp,
index = 0,
length = animation.tweens.length;
for ( ; index < length; index++ ) {
animation.tweens[ index ].run( percent );
}
deferred.notifyWith( elem, [ animation, percent, remaining ] );
if ( percent < 1 && length ) {
return remaining;
} else {
deferred.resolveWith( elem, [ animation ] );
return false;
}
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | tick | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
doAnimation = function() {
// Operate on a copy of prop so per-property easing won't be lost
var anim = Animation( this, jQuery.extend( {}, prop ), optall );
// Empty animations, or finishing resolves immediately
if ( empty || dataPriv.get( this, "finish" ) ) {
anim.stop( true );
}
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | doAnimation | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
stopQueue = function( hooks ) {
var stop = hooks.stop;
delete hooks.stop;
stop( gotoEnd );
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | stopQueue | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function stripAndCollapse( value ) {
var tokens = value.match( rnothtmlwhite ) || [];
return tokens.join( " " );
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | stripAndCollapse | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function getClass( elem ) {
return elem.getAttribute && elem.getAttribute( "class" ) || "";
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | getClass | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
handler = function( event ) {
jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | handler | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function buildParams( prefix, obj, traditional, add ) {
var name;
if ( jQuery.isArray( obj ) ) {
// Serialize array item.
jQuery.each( obj, function( i, v ) {
if ( traditional || rbracket.test( prefix ) ) {
// Treat each array item as a scalar.
add( prefix, v );
} else {
// Item is non-scalar (array or object), encode its numeric index.
buildParams(
prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
v,
traditional,
add
);
}
} );
} else if ( !traditional && jQuery.type( obj ) === "object" ) {
// Serialize object item.
for ( name in obj ) {
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
}
} else {
// Serialize scalar item.
add( prefix, obj );
}
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | buildParams | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
add = function( key, valueOrFunction ) {
// If value is a function, invoke it and use its return value
var value = jQuery.isFunction( valueOrFunction ) ?
valueOrFunction() :
valueOrFunction;
s[ s.length ] = encodeURIComponent( key ) + "=" +
encodeURIComponent( value == null ? "" : value );
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | add | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function addToPrefiltersOrTransports( structure ) {
// dataTypeExpression is optional and defaults to "*"
return function( dataTypeExpression, func ) {
if ( typeof dataTypeExpression !== "string" ) {
func = dataTypeExpression;
dataTypeExpression = "*";
}
var dataType,
i = 0,
dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
if ( jQuery.isFunction( func ) ) {
// For each dataType in the dataTypeExpression
while ( ( dataType = dataTypes[ i++ ] ) ) {
// Prepend if requested
if ( dataType[ 0 ] === "+" ) {
dataType = dataType.slice( 1 ) || "*";
( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
// Otherwise append
} else {
( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
}
}
}
};
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | addToPrefiltersOrTransports | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
var inspected = {},
seekingTransport = ( structure === transports );
function inspect( dataType ) {
var selected;
inspected[ dataType ] = true;
jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
if ( typeof dataTypeOrTransport === "string" &&
!seekingTransport && !inspected[ dataTypeOrTransport ] ) {
options.dataTypes.unshift( dataTypeOrTransport );
inspect( dataTypeOrTransport );
return false;
} else if ( seekingTransport ) {
return !( selected = dataTypeOrTransport );
}
} );
return selected;
}
return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | inspectPrefiltersOrTransports | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function inspect( dataType ) {
var selected;
inspected[ dataType ] = true;
jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
if ( typeof dataTypeOrTransport === "string" &&
!seekingTransport && !inspected[ dataTypeOrTransport ] ) {
options.dataTypes.unshift( dataTypeOrTransport );
inspect( dataTypeOrTransport );
return false;
} else if ( seekingTransport ) {
return !( selected = dataTypeOrTransport );
}
} );
return selected;
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | inspect | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function ajaxExtend( target, src ) {
var key, deep,
flatOptions = jQuery.ajaxSettings.flatOptions || {};
for ( key in src ) {
if ( src[ key ] !== undefined ) {
( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
}
}
if ( deep ) {
jQuery.extend( true, target, deep );
}
return target;
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | ajaxExtend | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function ajaxHandleResponses( s, jqXHR, responses ) {
var ct, type, finalDataType, firstDataType,
contents = s.contents,
dataTypes = s.dataTypes;
// Remove auto dataType and get content-type in the process
while ( dataTypes[ 0 ] === "*" ) {
dataTypes.shift();
if ( ct === undefined ) {
ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
}
}
// Check if we're dealing with a known content-type
if ( ct ) {
for ( type in contents ) {
if ( contents[ type ] && contents[ type ].test( ct ) ) {
dataTypes.unshift( type );
break;
}
}
}
// Check to see if we have a response for the expected dataType
if ( dataTypes[ 0 ] in responses ) {
finalDataType = dataTypes[ 0 ];
} else {
// Try convertible dataTypes
for ( type in responses ) {
if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
finalDataType = type;
break;
}
if ( !firstDataType ) {
firstDataType = type;
}
}
// Or just use first one
finalDataType = finalDataType || firstDataType;
}
// If we found a dataType
// We add the dataType to the list if needed
// and return the corresponding response
if ( finalDataType ) {
if ( finalDataType !== dataTypes[ 0 ] ) {
dataTypes.unshift( finalDataType );
}
return responses[ finalDataType ];
}
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | ajaxHandleResponses | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function ajaxConvert( s, response, jqXHR, isSuccess ) {
var conv2, current, conv, tmp, prev,
converters = {},
// Work with a copy of dataTypes in case we need to modify it for conversion
dataTypes = s.dataTypes.slice();
// Create converters map with lowercased keys
if ( dataTypes[ 1 ] ) {
for ( conv in s.converters ) {
converters[ conv.toLowerCase() ] = s.converters[ conv ];
}
}
current = dataTypes.shift();
// Convert to each sequential dataType
while ( current ) {
if ( s.responseFields[ current ] ) {
jqXHR[ s.responseFields[ current ] ] = response;
}
// Apply the dataFilter if provided
if ( !prev && isSuccess && s.dataFilter ) {
response = s.dataFilter( response, s.dataType );
}
prev = current;
current = dataTypes.shift();
if ( current ) {
// There's only work to do if current dataType is non-auto
if ( current === "*" ) {
current = prev;
// Convert response if prev dataType is non-auto and differs from current
} else if ( prev !== "*" && prev !== current ) {
// Seek a direct converter
conv = converters[ prev + " " + current ] || converters[ "* " + current ];
// If none found, seek a pair
if ( !conv ) {
for ( conv2 in converters ) {
// If conv2 outputs current
tmp = conv2.split( " " );
if ( tmp[ 1 ] === current ) {
// If prev can be converted to accepted input
conv = converters[ prev + " " + tmp[ 0 ] ] ||
converters[ "* " + tmp[ 0 ] ];
if ( conv ) {
// Condense equivalence converters
if ( conv === true ) {
conv = converters[ conv2 ];
// Otherwise, insert the intermediate dataType
} else if ( converters[ conv2 ] !== true ) {
current = tmp[ 0 ];
dataTypes.unshift( tmp[ 1 ] );
}
break;
}
}
}
}
// Apply converter (if not an equivalence)
if ( conv !== true ) {
// Unless errors are allowed to bubble, catch and return them
if ( conv && s.throws ) {
response = conv( response );
} else {
try {
response = conv( response );
} catch ( e ) {
return {
state: "parsererror",
error: conv ? e : "No conversion from " + prev + " to " + current
};
}
}
}
}
}
}
return { state: "success", data: response };
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | ajaxConvert | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function done( status, nativeStatusText, responses, headers ) {
var isSuccess, success, error, response, modified,
statusText = nativeStatusText;
// Ignore repeat invocations
if ( completed ) {
return;
}
completed = true;
// Clear timeout if it exists
if ( timeoutTimer ) {
window.clearTimeout( timeoutTimer );
}
// Dereference transport for early garbage collection
// (no matter how long the jqXHR object will be used)
transport = undefined;
// Cache response headers
responseHeadersString = headers || "";
// Set readyState
jqXHR.readyState = status > 0 ? 4 : 0;
// Determine if successful
isSuccess = status >= 200 && status < 300 || status === 304;
// Get response data
if ( responses ) {
response = ajaxHandleResponses( s, jqXHR, responses );
}
// Convert no matter what (that way responseXXX fields are always set)
response = ajaxConvert( s, response, jqXHR, isSuccess );
// If successful, handle type chaining
if ( isSuccess ) {
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
if ( s.ifModified ) {
modified = jqXHR.getResponseHeader( "Last-Modified" );
if ( modified ) {
jQuery.lastModified[ cacheURL ] = modified;
}
modified = jqXHR.getResponseHeader( "etag" );
if ( modified ) {
jQuery.etag[ cacheURL ] = modified;
}
}
// if no content
if ( status === 204 || s.type === "HEAD" ) {
statusText = "nocontent";
// if not modified
} else if ( status === 304 ) {
statusText = "notmodified";
// If we have data, let's convert it
} else {
statusText = response.state;
success = response.data;
error = response.error;
isSuccess = !error;
}
} else {
// Extract error from statusText and normalize for non-aborts
error = statusText;
if ( status || !statusText ) {
statusText = "error";
if ( status < 0 ) {
status = 0;
}
}
}
// Set data for the fake xhr object
jqXHR.status = status;
jqXHR.statusText = ( nativeStatusText || statusText ) + "";
// Success/Error
if ( isSuccess ) {
deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
} else {
deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
}
// Status-dependent callbacks
jqXHR.statusCode( statusCode );
statusCode = undefined;
if ( fireGlobals ) {
globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
[ jqXHR, s, isSuccess ? success : error ] );
}
// Complete
completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
if ( fireGlobals ) {
globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
// Handle the global AJAX counter
if ( !( --jQuery.active ) ) {
jQuery.event.trigger( "ajaxStop" );
}
}
} | A low-level selection function that works with Sizzle's compiled
selector functions
@param {String|Function} selector A selector or a pre-compiled
selector function built with Sizzle.compile
@param {Element} context
@param {Array} [results]
@param {Array} [seed] A set of elements to match against | done | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function arr_diff(a, b) {
var seen = [],
diff = [],
i;
for (i = 0; i < b.length; i++)
seen[b[i]] = true;
for (i = 0; i < a.length; i++)
if (!seen[a[i]])
diff.push(a[i]);
return diff;
} | Truncate a string to fit within an SVG text node
CSS text-overlow doesn't apply to SVG <= 1.2
@author Dan de Havilland (github.com/dandehavilland)
@date 2014-12-02 | arr_diff | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function warn_deprecation(message, untilVersion) {
console.warn('Deprecation: ' + message + (untilVersion ? '. This feature will be removed in ' + untilVersion + '.' : ' the near future.'));
console.trace();
} | Wrap the contents of a text node to a specific width
Adapted from bl.ocks.org/mbostock/7555321
@author Mike Bostock
@author Dan de Havilland
@date 2015-01-14 | warn_deprecation | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function truncate_text(textObj, textString, width) {
var bbox,
position = 0;
textObj.textContent = textString;
bbox = textObj.getBBox();
while (bbox.width > width) {
textObj.textContent = textString.slice(0, --position) + '...';
bbox = textObj.getBBox();
if (textObj.textContent === '...') {
break;
}
}
} | Wrap the contents of a text node to a specific width
Adapted from bl.ocks.org/mbostock/7555321
@author Mike Bostock
@author Dan de Havilland
@date 2015-01-14 | truncate_text | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function wrap_text(text, width, token, tspanAttrs) {
text.each(function() {
var text = d3.select(this),
words = text.text().split(token || /\s+/).reverse(),
word,
line = [],
lineNumber = 0,
lineHeight = 1.1, // ems
y = text.attr("y"),
dy = 0,
tspan = text.text(null)
.append("tspan")
.attr("x", 0)
.attr("y", dy + "em")
.attr(tspanAttrs || {});
while (!!(word = words.pop())) {
line.push(word);
tspan.text(line.join(" "));
if (width === null || tspan.node().getComputedTextLength() > width) {
line.pop();
tspan.text(line.join(" "));
line = [word];
tspan = text
.append("tspan")
.attr("x", 0)
.attr("y", ++lineNumber * lineHeight + dy + "em")
.attr(tspanAttrs || {})
.text(word);
}
}
});
} | Wrap the contents of a text node to a specific width
Adapted from bl.ocks.org/mbostock/7555321
@author Mike Bostock
@author Dan de Havilland
@date 2015-01-14 | wrap_text | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function chart(selection) {
renderWatch.reset();
renderWatch.models(scatter);
selection.each(function(data) {
var availableWidth = width - margin.left - margin.right,
availableHeight = height - margin.top - margin.bottom;
container = d3.select(this);
nv.utils.initSVG(container);
// Setup Scales
x = scatter.xScale();
y = scatter.yScale();
var dataRaw = data;
// Injecting point index into each point because d3.layout.stack().out does not give index
data.forEach(function(aseries, i) {
aseries.seriesIndex = i;
aseries.values = aseries.values.map(function(d, j) {
d.index = j;
d.seriesIndex = i;
return d;
});
});
var dataFiltered = data.filter(function(series) {
return !series.disabled;
});
data = d3.layout.stack()
.order(order)
.offset(offset)
.values(function(d) { return d.values }) //TODO: make values customizeable in EVERY model in this fashion
.x(getX)
.y(getY)
.out(function(d, y0, y) {
d.display = {
y: y,
y0: y0
};
})
(dataFiltered);
// Setup containers and skeleton of chart
var wrap = container.selectAll('g.nv-wrap.nv-stackedarea').data([data]);
var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-stackedarea');
var defsEnter = wrapEnter.append('defs');
var gEnter = wrapEnter.append('g');
var g = wrap.select('g');
gEnter.append('g').attr('class', 'nv-areaWrap');
gEnter.append('g').attr('class', 'nv-scatterWrap');
wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
// If the user has not specified forceY, make sure 0 is included in the domain
// Otherwise, use user-specified values for forceY
if (scatter.forceY().length == 0) {
scatter.forceY().push(0);
}
scatter
.width(availableWidth)
.height(availableHeight)
.x(getX)
.y(function(d) {
if (d.display !== undefined) { return d.display.y + d.display.y0; }
})
.color(data.map(function(d,i) {
d.color = d.color || color(d, d.seriesIndex);
return d.color;
}));
var scatterWrap = g.select('.nv-scatterWrap')
.datum(data);
scatterWrap.call(scatter);
defsEnter.append('clipPath')
.attr('id', 'nv-edge-clip-' + id)
.append('rect');
wrap.select('#nv-edge-clip-' + id + ' rect')
.attr('width', availableWidth)
.attr('height', availableHeight);
g.attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : '');
var area = d3.svg.area()
.defined(defined)
.x(function(d,i) { return x(getX(d,i)) })
.y0(function(d) {
return y(d.display.y0)
})
.y1(function(d) {
return y(d.display.y + d.display.y0)
})
.interpolate(interpolate);
var zeroArea = d3.svg.area()
.defined(defined)
.x(function(d,i) { return x(getX(d,i)) })
.y0(function(d) { return y(d.display.y0) })
.y1(function(d) { return y(d.display.y0) });
var path = g.select('.nv-areaWrap').selectAll('path.nv-area')
.data(function(d) { return d });
path.enter().append('path').attr('class', function(d,i) { return 'nv-area nv-area-' + i })
.attr('d', function(d,i){
return zeroArea(d.values, d.seriesIndex);
})
.on('mouseover', function(d,i) {
d3.select(this).classed('hover', true);
dispatch.areaMouseover({
point: d,
series: d.key,
pos: [d3.event.pageX, d3.event.pageY],
seriesIndex: d.seriesIndex
});
})
.on('mouseout', function(d,i) {
d3.select(this).classed('hover', false);
dispatch.areaMouseout({
point: d,
series: d.key,
pos: [d3.event.pageX, d3.event.pageY],
seriesIndex: d.seriesIndex
});
})
.on('click', function(d,i) {
d3.select(this).classed('hover', false);
dispatch.areaClick({
point: d,
series: d.key,
pos: [d3.event.pageX, d3.event.pageY],
seriesIndex: d.seriesIndex
});
});
path.exit().remove();
path.style('fill', function(d,i){
return d.color || color(d, d.seriesIndex)
})
.style('stroke', function(d,i){ return d.color || color(d, d.seriesIndex) });
path.watchTransition(renderWatch,'stackedArea path')
.attr('d', function(d,i) {
return area(d.values,i)
});
//============================================================
// Event Handling/Dispatching (in chart's scope)
//------------------------------------------------------------
scatter.dispatch.on('elementMouseover.area', function(e) {
g.select('.nv-chart-' + id + ' .nv-area-' + e.seriesIndex).classed('hover', true);
});
scatter.dispatch.on('elementMouseout.area', function(e) {
g.select('.nv-chart-' + id + ' .nv-area-' + e.seriesIndex).classed('hover', false);
});
//Special offset functions
chart.d3_stackedOffset_stackPercent = function(stackData) {
var n = stackData.length, //How many series
m = stackData[0].length, //how many points per series
i,
j,
o,
y0 = [];
for (j = 0; j < m; ++j) { //Looping through all points
for (i = 0, o = 0; i < dataRaw.length; i++) { //looping through all series
o += getY(dataRaw[i].values[j]); //total y value of all series at a certian point in time.
}
if (o) for (i = 0; i < n; i++) { //(total y value of all series at point in time i) != 0
stackData[i][j][1] /= o;
} else { //(total y value of all series at point in time i) == 0
for (i = 0; i < n; i++) {
stackData[i][j][1] = 0;
}
}
}
for (j = 0; j < m; ++j) y0[j] = 0;
return y0;
};
});
renderWatch.renderEnd('stackedArea immediate');
return chart;
} | *********************************
offset:
'wiggle' (stream)
'zero' (stacked)
'expand' (normalize to 100%)
'silhouette' (simple centered)
order:
'inside-out' (stream)
'default' (input order)
********************************** | chart | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
stateGetter = function(data) {
return function(){
return {
active: data.map(function(d) { return !d.disabled }),
style: stacked.style()
};
}
} | *********************************
offset:
'wiggle' (stream)
'zero' (stacked)
'expand' (normalize to 100%)
'silhouette' (simple centered)
order:
'inside-out' (stream)
'default' (input order)
********************************** | stateGetter | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
stateSetter = function(data) {
return function(state) {
if (state.style !== undefined)
style = state.style;
if (state.active !== undefined)
data.forEach(function(series,i) {
series.disabled = !state.active[i];
});
}
} | *********************************
offset:
'wiggle' (stream)
'zero' (stacked)
'expand' (normalize to 100%)
'silhouette' (simple centered)
order:
'inside-out' (stream)
'default' (input order)
********************************** | stateSetter | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function chart(selection) {
renderWatch.reset();
renderWatch.models(stacked);
if (showXAxis) renderWatch.models(xAxis);
if (showYAxis) renderWatch.models(yAxis);
selection.each(function(data) {
var container = d3.select(this),
that = this;
nv.utils.initSVG(container);
var availableWidth = nv.utils.availableWidth(width, container, margin),
availableHeight = nv.utils.availableHeight(height, container, margin) - (focusEnable ? focus.height() : 0);
chart.update = function() { container.transition().duration(duration).call(chart); };
chart.container = this;
state
.setter(stateSetter(data), chart.update)
.getter(stateGetter(data))
.update();
// DEPRECATED set state.disabled
state.disabled = data.map(function(d) { return !!d.disabled });
if (!defaultState) {
var key;
defaultState = {};
for (key in state) {
if (state[key] instanceof Array)
defaultState[key] = state[key].slice(0);
else
defaultState[key] = state[key];
}
}
// Display No Data message if there's nothing to show.
if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
nv.utils.noData(chart, container)
return chart;
} else {
container.selectAll('.nv-noData').remove();
}
// Setup Scales
x = stacked.xScale();
y = stacked.yScale();
// Setup containers and skeleton of chart
var wrap = container.selectAll('g.nv-wrap.nv-stackedAreaChart').data([data]);
var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-stackedAreaChart').append('g');
var g = wrap.select('g');
gEnter.append('g').attr('class', 'nv-legendWrap');
gEnter.append('g').attr('class', 'nv-controlsWrap');
var focusEnter = gEnter.append('g').attr('class', 'nv-focus');
focusEnter.append('g').attr('class', 'nv-background').append('rect');
focusEnter.append('g').attr('class', 'nv-x nv-axis');
focusEnter.append('g').attr('class', 'nv-y nv-axis');
focusEnter.append('g').attr('class', 'nv-stackedWrap');
focusEnter.append('g').attr('class', 'nv-interactive');
// g.select("rect").attr("width",availableWidth).attr("height",availableHeight);
var contextEnter = gEnter.append('g').attr('class', 'nv-focusWrap');
// Legend
if (!showLegend) {
g.select('.nv-legendWrap').selectAll('*').remove();
} else {
var legendWidth = (showControls && legendPosition === 'top') ? availableWidth - controlWidth : availableWidth;
legend.width(legendWidth);
g.select('.nv-legendWrap').datum(data).call(legend);
if (legendPosition === 'bottom') {
// constant from axis.js, plus some margin for better layout
var xAxisHeight = (showXAxis ? 12 : 0) + 10;
margin.bottom = Math.max(legend.height() + xAxisHeight, margin.bottom);
availableHeight = nv.utils.availableHeight(height, container, margin) - (focusEnable ? focus.height() : 0);
var legendTop = availableHeight + xAxisHeight;
g.select('.nv-legendWrap')
.attr('transform', 'translate(0,' + legendTop +')');
} else if (legendPosition === 'top') {
if (!marginTop && margin.top != legend.height()) {
margin.top = legend.height();
availableHeight = nv.utils.availableHeight(height, container, margin) - (focusEnable ? focus.height() : 0);
}
g.select('.nv-legendWrap')
.attr('transform', 'translate(' + (availableWidth-legendWidth) + ',' + (-margin.top) +')');
}
}
// Controls
if (!showControls) {
g.select('.nv-controlsWrap').selectAll('*').remove();
} else {
var controlsData = [
{
key: controlLabels.stacked || 'Stacked',
metaKey: 'Stacked',
disabled: stacked.style() != 'stack',
style: 'stack'
},
{
key: controlLabels.stream || 'Stream',
metaKey: 'Stream',
disabled: stacked.style() != 'stream',
style: 'stream'
},
{
key: controlLabels.expanded || 'Expanded',
metaKey: 'Expanded',
disabled: stacked.style() != 'expand',
style: 'expand'
},
{
key: controlLabels.stack_percent || 'Stack %',
metaKey: 'Stack_Percent',
disabled: stacked.style() != 'stack_percent',
style: 'stack_percent'
}
];
controlWidth = (controlOptions.length/3) * 260;
controlsData = controlsData.filter(function(d) {
return controlOptions.indexOf(d.metaKey) !== -1;
});
controls
.width( controlWidth )
.color(['#444', '#444', '#444']);
g.select('.nv-controlsWrap')
.datum(controlsData)
.call(controls);
var requiredTop = Math.max(controls.height(), showLegend && (legendPosition === 'top') ? legend.height() : 0);
if ( margin.top != requiredTop ) {
margin.top = requiredTop;
availableHeight = nv.utils.availableHeight(height, container, margin) - (focusEnable ? focus.height() : 0);
}
g.select('.nv-controlsWrap')
.attr('transform', 'translate(0,' + (-margin.top) +')');
}
wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
if (rightAlignYAxis) {
g.select(".nv-y.nv-axis")
.attr("transform", "translate(" + availableWidth + ",0)");
}
//Set up interactive layer
if (useInteractiveGuideline) {
interactiveLayer
.width(availableWidth)
.height(availableHeight)
.margin({left: margin.left, top: margin.top})
.svgContainer(container)
.xScale(x);
wrap.select(".nv-interactive").call(interactiveLayer);
}
g.select('.nv-focus .nv-background rect')
.attr('width', availableWidth)
.attr('height', availableHeight);
stacked
.width(availableWidth)
.height(availableHeight)
.color(data.map(function(d,i) {
return d.color || color(d, i);
}).filter(function(d,i) { return !data[i].disabled; }));
var stackedWrap = g.select('.nv-focus .nv-stackedWrap')
.datum(data.filter(function(d) { return !d.disabled; }));
// Setup Axes
if (showXAxis) {
xAxis.scale(x)
._ticks( nv.utils.calcTicksX(availableWidth/100, data) )
.tickSize( -availableHeight, 0);
}
if (showYAxis) {
var ticks;
if (stacked.offset() === 'wiggle') {
ticks = 0;
}
else {
ticks = nv.utils.calcTicksY(availableHeight/36, data);
}
yAxis.scale(y)
._ticks(ticks)
.tickSize(-availableWidth, 0);
}
//============================================================
// Update Axes
//============================================================
function updateXAxis() {
if(showXAxis) {
g.select('.nv-focus .nv-x.nv-axis')
.attr('transform', 'translate(0,' + availableHeight + ')')
.transition()
.duration(duration)
.call(xAxis)
;
}
}
function updateYAxis() {
if(showYAxis) {
if (stacked.style() === 'expand' || stacked.style() === 'stack_percent') {
var currentFormat = yAxis.tickFormat();
if ( !oldYTickFormat || currentFormat !== percentFormatter )
oldYTickFormat = currentFormat;
//Forces the yAxis to use percentage in 'expand' mode.
yAxis.tickFormat(percentFormatter);
}
else {
if (oldYTickFormat) {
yAxis.tickFormat(oldYTickFormat);
oldYTickFormat = null;
}
}
g.select('.nv-focus .nv-y.nv-axis')
.transition().duration(0)
.call(yAxis);
}
}
//============================================================
// Update Focus
//============================================================
if(!focusEnable) {
stackedWrap.transition().call(stacked);
updateXAxis();
updateYAxis();
} else {
focus.width(availableWidth);
g.select('.nv-focusWrap')
.attr('transform', 'translate(0,' + ( availableHeight + margin.bottom + focus.margin().top) + ')')
.datum(data.filter(function(d) { return !d.disabled; }))
.call(focus);
var extent = focus.brush.empty() ? focus.xDomain() : focus.brush.extent();
if(extent !== null){
onBrush(extent);
}
}
//============================================================
// Event Handling/Dispatching (in chart's scope)
//------------------------------------------------------------
stacked.dispatch.on('areaClick.toggle', function(e) {
if (data.filter(function(d) { return !d.disabled }).length === 1)
data.forEach(function(d) {
d.disabled = false;
});
else
data.forEach(function(d,i) {
d.disabled = (i != e.seriesIndex);
});
state.disabled = data.map(function(d) { return !!d.disabled });
dispatch.stateChange(state);
chart.update();
});
legend.dispatch.on('stateChange', function(newState) {
for (var key in newState)
state[key] = newState[key];
dispatch.stateChange(state);
chart.update();
});
controls.dispatch.on('legendClick', function(d,i) {
if (!d.disabled) return;
controlsData = controlsData.map(function(s) {
s.disabled = true;
return s;
});
d.disabled = false;
stacked.style(d.style);
state.style = stacked.style();
dispatch.stateChange(state);
chart.update();
});
interactiveLayer.dispatch.on('elementMousemove', function(e) {
stacked.clearHighlights();
var singlePoint, pointIndex, pointXLocation, allData = [], valueSum = 0, allNullValues = true;
data
.filter(function(series, i) {
series.seriesIndex = i;
return !series.disabled;
})
.forEach(function(series,i) {
pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x());
var point = series.values[pointIndex];
var pointYValue = chart.y()(point, pointIndex);
if (pointYValue != null) {
stacked.highlightPoint(i, pointIndex, true);
}
if (typeof point === 'undefined') return;
if (typeof singlePoint === 'undefined') singlePoint = point;
if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex));
//If we are in 'expand' mode, use the stacked percent value instead of raw value.
var tooltipValue = (stacked.style() == 'expand') ? point.display.y : chart.y()(point,pointIndex);
allData.push({
key: series.key,
value: tooltipValue,
color: color(series,series.seriesIndex),
point: point
});
if (showTotalInTooltip && stacked.style() != 'expand' && tooltipValue != null) {
valueSum += tooltipValue;
allNullValues = false;
};
});
allData.reverse();
//Highlight the tooltip entry based on which stack the mouse is closest to.
if (allData.length > 2) {
var yValue = chart.yScale().invert(e.mouseY);
var yDistMax = Infinity, indexToHighlight = null;
allData.forEach(function(series,i) {
//To handle situation where the stacked area chart is negative, we need to use absolute values
//when checking if the mouse Y value is within the stack area.
yValue = Math.abs(yValue);
var stackedY0 = Math.abs(series.point.display.y0);
var stackedY = Math.abs(series.point.display.y);
if ( yValue >= stackedY0 && yValue <= (stackedY + stackedY0))
{
indexToHighlight = i;
return;
}
});
if (indexToHighlight != null)
allData[indexToHighlight].highlight = true;
}
//If we are not in 'expand' mode, add a 'Total' row to the tooltip.
if (showTotalInTooltip && stacked.style() != 'expand' && allData.length >= 2 && !allNullValues) {
allData.push({
key: totalLabel,
value: valueSum,
total: true
});
}
var xValue = chart.x()(singlePoint,pointIndex);
var valueFormatter = interactiveLayer.tooltip.valueFormatter();
// Keeps track of the tooltip valueFormatter if the chart changes to expanded view
if (stacked.style() === 'expand' || stacked.style() === 'stack_percent') {
if ( !oldValueFormatter ) {
oldValueFormatter = valueFormatter;
}
//Forces the tooltip to use percentage in 'expand' mode.
valueFormatter = d3.format(".1%");
}
else {
if (oldValueFormatter) {
valueFormatter = oldValueFormatter;
oldValueFormatter = null;
}
}
interactiveLayer.tooltip
.valueFormatter(valueFormatter)
.data(
{
value: xValue,
series: allData
}
)();
interactiveLayer.renderGuideLine(pointXLocation);
});
interactiveLayer.dispatch.on("elementMouseout",function(e) {
stacked.clearHighlights();
});
/* Update `main' graph on brush update. */
focus.dispatch.on("onBrush", function(extent) {
onBrush(extent);
});
// Update chart from a state object passed to event handler
dispatch.on('changeState', function(e) {
if (typeof e.disabled !== 'undefined' && data.length === e.disabled.length) {
data.forEach(function(series,i) {
series.disabled = e.disabled[i];
});
state.disabled = e.disabled;
}
if (typeof e.style !== 'undefined') {
stacked.style(e.style);
style = e.style;
}
chart.update();
});
//============================================================
// Functions
//------------------------------------------------------------
function onBrush(extent) {
// Update Main (Focus)
var stackedWrap = g.select('.nv-focus .nv-stackedWrap')
.datum(
data.filter(function(d) { return !d.disabled; })
.map(function(d,i) {
return {
key: d.key,
area: d.area,
classed: d.classed,
values: d.values.filter(function(d,i) {
return stacked.x()(d,i) >= extent[0] && stacked.x()(d,i) <= extent[1];
}),
disableTooltip: d.disableTooltip
};
})
);
stackedWrap.transition().duration(duration).call(stacked);
// Update Main (Focus) Axes
updateXAxis();
updateYAxis();
}
});
renderWatch.renderEnd('stacked Area chart immediate');
return chart;
} | *********************************
offset:
'wiggle' (stream)
'zero' (stacked)
'expand' (normalize to 100%)
'silhouette' (simple centered)
order:
'inside-out' (stream)
'default' (input order)
********************************** | chart | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function updateXAxis() {
if(showXAxis) {
g.select('.nv-focus .nv-x.nv-axis')
.attr('transform', 'translate(0,' + availableHeight + ')')
.transition()
.duration(duration)
.call(xAxis)
;
}
} | *********************************
offset:
'wiggle' (stream)
'zero' (stacked)
'expand' (normalize to 100%)
'silhouette' (simple centered)
order:
'inside-out' (stream)
'default' (input order)
********************************** | updateXAxis | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function updateYAxis() {
if(showYAxis) {
if (stacked.style() === 'expand' || stacked.style() === 'stack_percent') {
var currentFormat = yAxis.tickFormat();
if ( !oldYTickFormat || currentFormat !== percentFormatter )
oldYTickFormat = currentFormat;
//Forces the yAxis to use percentage in 'expand' mode.
yAxis.tickFormat(percentFormatter);
}
else {
if (oldYTickFormat) {
yAxis.tickFormat(oldYTickFormat);
oldYTickFormat = null;
}
}
g.select('.nv-focus .nv-y.nv-axis')
.transition().duration(0)
.call(yAxis);
}
} | *********************************
offset:
'wiggle' (stream)
'zero' (stacked)
'expand' (normalize to 100%)
'silhouette' (simple centered)
order:
'inside-out' (stream)
'default' (input order)
********************************** | updateYAxis | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function onBrush(extent) {
// Update Main (Focus)
var stackedWrap = g.select('.nv-focus .nv-stackedWrap')
.datum(
data.filter(function(d) { return !d.disabled; })
.map(function(d,i) {
return {
key: d.key,
area: d.area,
classed: d.classed,
values: d.values.filter(function(d,i) {
return stacked.x()(d,i) >= extent[0] && stacked.x()(d,i) <= extent[1];
}),
disableTooltip: d.disableTooltip
};
})
);
stackedWrap.transition().duration(duration).call(stacked);
// Update Main (Focus) Axes
updateXAxis();
updateYAxis();
} | *********************************
offset:
'wiggle' (stream)
'zero' (stacked)
'expand' (normalize to 100%)
'silhouette' (simple centered)
order:
'inside-out' (stream)
'default' (input order)
********************************** | onBrush | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function rotationToAvoidUpsideDown(d) {
var centerAngle = computeCenterAngle(d);
if(centerAngle > 90){
return 180;
}
else {
return 0;
}
} | *********************************
offset:
'wiggle' (stream)
'zero' (stacked)
'expand' (normalize to 100%)
'silhouette' (simple centered)
order:
'inside-out' (stream)
'default' (input order)
********************************** | rotationToAvoidUpsideDown | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function computeCenterAngle(d) {
var startAngle = Math.max(0, Math.min(2 * Math.PI, x(d.x)));
var endAngle = Math.max(0, Math.min(2 * Math.PI, x(d.x + d.dx)));
var centerAngle = (((startAngle + endAngle) / 2) * (180 / Math.PI)) - 90;
return centerAngle;
} | *********************************
offset:
'wiggle' (stream)
'zero' (stacked)
'expand' (normalize to 100%)
'silhouette' (simple centered)
order:
'inside-out' (stream)
'default' (input order)
********************************** | computeCenterAngle | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function computeNodePercentage(d) {
var startAngle = Math.max(0, Math.min(2 * Math.PI, x(d.x)));
var endAngle = Math.max(0, Math.min(2 * Math.PI, x(d.x + d.dx)));
return (endAngle - startAngle) / (2 * Math.PI);
} | *********************************
offset:
'wiggle' (stream)
'zero' (stacked)
'expand' (normalize to 100%)
'silhouette' (simple centered)
order:
'inside-out' (stream)
'default' (input order)
********************************** | computeNodePercentage | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function labelThresholdMatched(d) {
var startAngle = Math.max(0, Math.min(2 * Math.PI, x(d.x)));
var endAngle = Math.max(0, Math.min(2 * Math.PI, x(d.x + d.dx)));
var size = endAngle - startAngle;
return size > labelThreshold;
} | *********************************
offset:
'wiggle' (stream)
'zero' (stacked)
'expand' (normalize to 100%)
'silhouette' (simple centered)
order:
'inside-out' (stream)
'default' (input order)
********************************** | labelThresholdMatched | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function arcTweenZoom(e,i) {
var xd = d3.interpolate(x.domain(), [node.x, node.x + node.dx]),
yd = d3.interpolate(y.domain(), [node.y, 1]),
yr = d3.interpolate(y.range(), [node.y ? 20 : 0, radius]);
if (i === 0) {
return function() {return arc(e);}
}
else {
return function (t) {
x.domain(xd(t));
y.domain(yd(t)).range(yr(t));
return arc(e);
}
};
} | *********************************
offset:
'wiggle' (stream)
'zero' (stacked)
'expand' (normalize to 100%)
'silhouette' (simple centered)
order:
'inside-out' (stream)
'default' (input order)
********************************** | arcTweenZoom | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function arcTweenUpdate(d) {
var ipo = d3.interpolate({x: d.x0, dx: d.dx0, y: d.y0, dy: d.dy0}, d);
return function (t) {
var b = ipo(t);
d.x0 = b.x;
d.dx0 = b.dx;
d.y0 = b.y;
d.dy0 = b.dy;
return arc(b);
};
} | *********************************
offset:
'wiggle' (stream)
'zero' (stacked)
'expand' (normalize to 100%)
'silhouette' (simple centered)
order:
'inside-out' (stream)
'default' (input order)
********************************** | arcTweenUpdate | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function updatePrevPosition(node) {
var k = key(node);
if(! prevPositions[k]) prevPositions[k] = {};
var pP = prevPositions[k];
pP.dx = node.dx;
pP.x = node.x;
pP.dy = node.dy;
pP.y = node.y;
} | *********************************
offset:
'wiggle' (stream)
'zero' (stacked)
'expand' (normalize to 100%)
'silhouette' (simple centered)
order:
'inside-out' (stream)
'default' (input order)
********************************** | updatePrevPosition | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function storeRetrievePrevPositions(nodes) {
nodes.forEach(function(n){
var k = key(n);
var pP = prevPositions[k];
//console.log(k,n,pP);
if( pP ){
n.dx0 = pP.dx;
n.x0 = pP.x;
n.dy0 = pP.dy;
n.y0 = pP.y;
}
else {
n.dx0 = n.dx;
n.x0 = n.x;
n.dy0 = n.dy;
n.y0 = n.y;
}
updatePrevPosition(n);
});
} | *********************************
offset:
'wiggle' (stream)
'zero' (stacked)
'expand' (normalize to 100%)
'silhouette' (simple centered)
order:
'inside-out' (stream)
'default' (input order)
********************************** | storeRetrievePrevPositions | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function zoomClick(d) {
var labels = container.selectAll('text')
var path = container.selectAll('path')
// fade out all text elements
labels.transition().attr("opacity",0);
// to allow reference to the new center node
node = d;
path.transition()
.duration(duration)
.attrTween("d", arcTweenZoom)
.each('end', function(e) {
// partially taken from here: http://bl.ocks.org/metmajer/5480307
// check if the animated element's data e lies within the visible angle span given in d
if(e.x >= d.x && e.x < (d.x + d.dx) ){
if(e.depth >= d.depth){
// get a selection of the associated text element
var parentNode = d3.select(this.parentNode);
var arcText = parentNode.select('text');
// fade in the text element and recalculate positions
arcText.transition().duration(duration)
.text( function(e){return labelFormat(e) })
.attr("opacity", function(d){
if(labelThresholdMatched(d)) {
return 1;
}
else {
return 0;
}
})
.attr("transform", function() {
var width = this.getBBox().width;
if(e.depth === 0)
return "translate(" + (width / 2 * - 1) + ",0)";
else if(e.depth === d.depth){
return "translate(" + (y(e.y) + 5) + ",0)";
}
else {
var centerAngle = computeCenterAngle(e);
var rotation = rotationToAvoidUpsideDown(e);
if (rotation === 0) {
return 'rotate('+ centerAngle +')translate(' + (y(e.y) + 5) + ',0)';
}
else {
return 'rotate('+ centerAngle +')translate(' + (y(e.y) + width + 5) + ',0)rotate(' + rotation + ')';
}
}
});
}
}
})
} | *********************************
offset:
'wiggle' (stream)
'zero' (stacked)
'expand' (normalize to 100%)
'silhouette' (simple centered)
order:
'inside-out' (stream)
'default' (input order)
********************************** | zoomClick | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function chart(selection) {
renderWatch.reset();
selection.each(function(data) {
container = d3.select(this);
availableWidth = nv.utils.availableWidth(width, container, margin);
availableHeight = nv.utils.availableHeight(height, container, margin);
radius = Math.min(availableWidth, availableHeight) / 2;
y.range([0, radius]);
// Setup containers and skeleton of chart
var wrap = container.select('g.nvd3.nv-wrap.nv-sunburst');
if( !wrap[0][0] ) {
wrap = container.append('g')
.attr('class', 'nvd3 nv-wrap nv-sunburst nv-chart-' + id)
.attr('transform', 'translate(' + ((availableWidth / 2) + margin.left + margin.right) + ',' + ((availableHeight / 2) + margin.top + margin.bottom) + ')');
} else {
wrap.attr('transform', 'translate(' + ((availableWidth / 2) + margin.left + margin.right) + ',' + ((availableHeight / 2) + margin.top + margin.bottom) + ')');
}
container.on('click', function (d, i) {
dispatch.chartClick({
data: d,
index: i,
pos: d3.event,
id: id
});
});
partition.value(modes[mode] || modes["count"]);
//reverse the drawing order so that the labels of inner
//arcs are drawn on top of the outer arcs.
var nodes = partition.nodes(data[0]).reverse()
storeRetrievePrevPositions(nodes);
var cG = wrap.selectAll('.arc-container').data(nodes, key)
//handle new datapoints
var cGE = cG.enter()
.append("g")
.attr("class",'arc-container')
cGE.append("path")
.attr("d", arc)
.style("fill", function (d) {
if (d.color) {
return d.color;
}
else if (groupColorByParent) {
return color((d.children ? d : d.parent).name);
}
else {
return color(d.name);
}
})
.style("stroke", "#FFF")
.on("click", function(d,i){
zoomClick(d);
dispatch.elementClick({
data: d,
index: i
})
})
.on('mouseover', function(d,i){
d3.select(this).classed('hover', true).style('opacity', 0.8);
dispatch.elementMouseover({
data: d,
color: d3.select(this).style("fill"),
percent: computeNodePercentage(d)
});
})
.on('mouseout', function(d,i){
d3.select(this).classed('hover', false).style('opacity', 1);
dispatch.elementMouseout({
data: d
});
})
.on('mousemove', function(d,i){
dispatch.elementMousemove({
data: d
});
});
///Iterating via each and selecting based on the this
///makes it work ... a cG.selectAll('path') doesn't.
///Without iteration the data (in the element) didn't update.
cG.each(function(d){
d3.select(this).select('path')
.transition()
.duration(duration)
.attrTween('d', arcTweenUpdate);
});
if(showLabels){
//remove labels first and add them back
cG.selectAll('text').remove();
//this way labels are on top of newly added arcs
cG.append('text')
.text( function(e){ return labelFormat(e)})
.transition()
.duration(duration)
.attr("opacity", function(d){
if(labelThresholdMatched(d)) {
return 1;
}
else {
return 0;
}
})
.attr("transform", function(d) {
var width = this.getBBox().width;
if(d.depth === 0){
return "rotate(0)translate(" + (width / 2 * -1) + ",0)";
}
else {
var centerAngle = computeCenterAngle(d);
var rotation = rotationToAvoidUpsideDown(d);
if (rotation === 0) {
return 'rotate('+ centerAngle +')translate(' + (y(d.y) + 5) + ',0)';
}
else {
return 'rotate('+ centerAngle +')translate(' + (y(d.y) + width + 5) + ',0)rotate(' + rotation + ')';
}
}
});
}
//zoom out to the center when the data is updated.
zoomClick(nodes[nodes.length - 1])
//remove unmatched elements ...
cG.exit()
.transition()
.duration(duration)
.attr('opacity',0)
.each('end',function(d){
var k = key(d);
prevPositions[k] = undefined;
})
.remove();
});
renderWatch.renderEnd('sunburst immediate');
return chart;
} | *********************************
offset:
'wiggle' (stream)
'zero' (stacked)
'expand' (normalize to 100%)
'silhouette' (simple centered)
order:
'inside-out' (stream)
'default' (input order)
********************************** | chart | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function chart(selection) {
renderWatch.reset();
renderWatch.models(sunburst);
selection.each(function(data) {
var container = d3.select(this);
nv.utils.initSVG(container);
var availableWidth = nv.utils.availableWidth(width, container, margin);
var availableHeight = nv.utils.availableHeight(height, container, margin);
chart.update = function() {
if (duration === 0) {
container.call(chart);
} else {
container.transition().duration(duration).call(chart);
}
};
chart.container = container;
// Display No Data message if there's nothing to show.
if (!data || !data.length) {
nv.utils.noData(chart, container);
return chart;
} else {
container.selectAll('.nv-noData').remove();
}
sunburst.width(availableWidth).height(availableHeight).margin(margin);
container.call(sunburst);
});
renderWatch.renderEnd('sunburstChart immediate');
return chart;
} | *********************************
offset:
'wiggle' (stream)
'zero' (stacked)
'expand' (normalize to 100%)
'silhouette' (simple centered)
order:
'inside-out' (stream)
'default' (input order)
********************************** | chart | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function shouldPrecacheNode(node, nodeID) {
return node.nodeType === 1 && node.getAttribute(ATTR_NAME) === String(nodeID) || node.nodeType === 8 && node.nodeValue === ' react-text: ' + nodeID + ' ' || node.nodeType === 8 && node.nodeValue === ' react-empty: ' + nodeID + ' ';
} | Populate `_hostNode` on the rendered host/text component with the given
DOM node. The passed `inst` can be a composite. | shouldPrecacheNode | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function getRenderedHostOrTextFromComponent(component) {
var rendered;
while (rendered = component._renderedComponent) {
component = rendered;
}
return component;
} | Populate `_hostNode` on the rendered host/text component with the given
DOM node. The passed `inst` can be a composite. | getRenderedHostOrTextFromComponent | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function precacheNode(inst, node) {
var hostInst = getRenderedHostOrTextFromComponent(inst);
hostInst._hostNode = node;
node[internalInstanceKey] = hostInst;
} | Populate `_hostNode` on each child of `inst`, assuming that the children
match up with the DOM (element) children of `node`.
We cache entire levels at once to avoid an n^2 problem where we access the
children of a node sequentially and have to walk from the start to our target
node every time.
Since we update `_renderedChildren` and the actual DOM at (slightly)
different times, we could race here and see a newer `_renderedChildren` than
the DOM nodes we see. To avoid this, ReactMultiChild calls
`prepareToManageChildren` before we change `_renderedChildren`, at which
time the container's child nodes are always cached (until it unmounts). | precacheNode | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function uncacheNode(inst) {
var node = inst._hostNode;
if (node) {
delete node[internalInstanceKey];
inst._hostNode = null;
}
} | Populate `_hostNode` on each child of `inst`, assuming that the children
match up with the DOM (element) children of `node`.
We cache entire levels at once to avoid an n^2 problem where we access the
children of a node sequentially and have to walk from the start to our target
node every time.
Since we update `_renderedChildren` and the actual DOM at (slightly)
different times, we could race here and see a newer `_renderedChildren` than
the DOM nodes we see. To avoid this, ReactMultiChild calls
`prepareToManageChildren` before we change `_renderedChildren`, at which
time the container's child nodes are always cached (until it unmounts). | uncacheNode | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function precacheChildNodes(inst, node) {
if (inst._flags & Flags.hasCachedChildNodes) {
return;
}
var children = inst._renderedChildren;
var childNode = node.firstChild;
outer: for (var name in children) {
if (!children.hasOwnProperty(name)) {
continue;
}
var childInst = children[name];
var childID = getRenderedHostOrTextFromComponent(childInst)._domID;
if (childID === 0) {
// We're currently unmounting this child in ReactMultiChild; skip it.
continue;
}
// We assume the child nodes are in the same order as the child instances.
for (; childNode !== null; childNode = childNode.nextSibling) {
if (shouldPrecacheNode(childNode, childID)) {
precacheNode(childInst, childNode);
continue outer;
}
}
// We reached the end of the DOM children without finding an ID match.
true ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Unable to find element with ID %s.', childID) : _prodInvariant('32', childID) : void 0;
}
inst._flags |= Flags.hasCachedChildNodes;
} | Given a DOM node, return the closest ReactDOMComponent or
ReactDOMTextComponent instance ancestor. | precacheChildNodes | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function getClosestInstanceFromNode(node) {
if (node[internalInstanceKey]) {
return node[internalInstanceKey];
}
// Walk up the tree until we find an ancestor whose instance we have cached.
var parents = [];
while (!node[internalInstanceKey]) {
parents.push(node);
if (node.parentNode) {
node = node.parentNode;
} else {
// Top of the tree. This node must not be part of a React tree (or is
// unmounted, potentially).
return null;
}
}
var closest;
var inst;
for (; node && (inst = node[internalInstanceKey]); node = parents.pop()) {
closest = inst;
if (parents.length) {
precacheChildNodes(inst, node);
}
}
return closest;
} | Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding
DOM node. | getClosestInstanceFromNode | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function getInstanceFromNode(node) {
var inst = getClosestInstanceFromNode(node);
if (inst != null && inst._hostNode === node) {
return inst;
} else {
return null;
}
} | Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding
DOM node. | getInstanceFromNode | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function getNodeFromInstance(inst) {
// Without this first invariant, passing a non-DOM-component triggers the next
// invariant for a missing parent, which is super confusing.
!(inst._hostNode !== undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNodeFromInstance: Invalid argument.') : _prodInvariant('33') : void 0;
if (inst._hostNode) {
return inst._hostNode;
}
// Walk up the tree until we find an ancestor whose DOM node we have cached.
var parents = [];
while (!inst._hostNode) {
parents.push(inst);
!inst._hostParent ? process.env.NODE_ENV !== 'production' ? invariant(false, 'React DOM tree root should always have a node reference.') : _prodInvariant('34') : void 0;
inst = inst._hostParent;
}
// Now parents contains each ancestor that does *not* have a cached native
// node, and `inst` is the deepest ancestor that does.
for (; parents.length; inst = parents.pop()) {
precacheChildNodes(inst, inst._hostNode);
}
return inst._hostNode;
} | Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding
DOM node. | getNodeFromInstance | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function checkMask(value, bitmask) {
return (value & bitmask) === bitmask;
} | Mapping from normalized, camelcased property names to a configuration that
specifies how the associated DOM property should be accessed or rendered. | checkMask | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function inject() {
if (alreadyInjected) {
// TODO: This is currently true because these injections are shared between
// the client and the server package. They should be built independently
// and not share any injection state. Then this problem will be solved.
return;
}
alreadyInjected = true;
ReactInjection.EventEmitter.injectReactEventListener(ReactEventListener);
/**
* Inject modules for resolving DOM hierarchy and plugin ordering.
*/
ReactInjection.EventPluginHub.injectEventPluginOrder(DefaultEventPluginOrder);
ReactInjection.EventPluginUtils.injectComponentTree(ReactDOMComponentTree);
ReactInjection.EventPluginUtils.injectTreeTraversal(ReactDOMTreeTraversal);
/**
* Some important event plugins included by default (without having to require
* them).
*/
ReactInjection.EventPluginHub.injectEventPluginsByName({
SimpleEventPlugin: SimpleEventPlugin,
EnterLeaveEventPlugin: EnterLeaveEventPlugin,
ChangeEventPlugin: ChangeEventPlugin,
SelectEventPlugin: SelectEventPlugin,
BeforeInputEventPlugin: BeforeInputEventPlugin
});
ReactInjection.HostComponent.injectGenericComponentClass(ReactDOMComponent);
ReactInjection.HostComponent.injectTextComponentClass(ReactDOMTextComponent);
ReactInjection.DOMProperty.injectDOMPropertyConfig(ARIADOMPropertyConfig);
ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
ReactInjection.EmptyComponent.injectEmptyComponentFactory(function (instantiate) {
return new ReactDOMEmptyComponent(instantiate);
});
ReactInjection.Updates.injectReconcileTransaction(ReactReconcileTransaction);
ReactInjection.Updates.injectBatchingStrategy(ReactDefaultBatchingStrategy);
ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
} | Some important event plugins included by default (without having to require
them). | inject | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function isPresto() {
var opera = window.opera;
return typeof opera === 'object' && typeof opera.version === 'function' && parseInt(opera.version(), 10) <= 12;
} | Opera <= 12 includes TextEvent in window, but does not fire
text input events. Rely on keypress instead. | isPresto | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function isKeypressCommand(nativeEvent) {
return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) &&
// ctrlKey && altKey is equivalent to AltGr, and is not a command.
!(nativeEvent.ctrlKey && nativeEvent.altKey);
} | Does our fallback mode think that this event is the end of composition?
@param {string} topLevelType
@param {object} nativeEvent
@return {boolean} | isKeypressCommand | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function getCompositionEventType(topLevelType) {
switch (topLevelType) {
case 'topCompositionStart':
return eventTypes.compositionStart;
case 'topCompositionEnd':
return eventTypes.compositionEnd;
case 'topCompositionUpdate':
return eventTypes.compositionUpdate;
}
} | Does our fallback mode think that this event is the end of composition?
@param {string} topLevelType
@param {object} nativeEvent
@return {boolean} | getCompositionEventType | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function isFallbackCompositionStart(topLevelType, nativeEvent) {
return topLevelType === 'topKeyDown' && nativeEvent.keyCode === START_KEYCODE;
} | Does our fallback mode think that this event is the end of composition?
@param {string} topLevelType
@param {object} nativeEvent
@return {boolean} | isFallbackCompositionStart | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function isFallbackCompositionEnd(topLevelType, nativeEvent) {
switch (topLevelType) {
case 'topKeyUp':
// Command keys insert or clear IME input.
return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1;
case 'topKeyDown':
// Expect IME keyCode on each keydown. If we get any other
// code we must have exited earlier.
return nativeEvent.keyCode !== START_KEYCODE;
case 'topKeyPress':
case 'topMouseDown':
case 'topBlur':
// Events are not possible without cancelling IME.
return true;
default:
return false;
}
} | Google Input Tools provides composition data via a CustomEvent,
with the `data` property populated in the `detail` object. If this
is available on the event object, use it. If not, this is a plain
composition event and we have nothing special to extract.
@param {object} nativeEvent
@return {?string} | isFallbackCompositionEnd | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function getNativeBeforeInputChars(topLevelType, nativeEvent) {
switch (topLevelType) {
case 'topCompositionEnd':
return getDataFromCustomEvent(nativeEvent);
case 'topKeyPress':
/**
* If native `textInput` events are available, our goal is to make
* use of them. However, there is a special case: the spacebar key.
* In Webkit, preventing default on a spacebar `textInput` event
* cancels character insertion, but it *also* causes the browser
* to fall back to its default spacebar behavior of scrolling the
* page.
*
* Tracking at:
* https://code.google.com/p/chromium/issues/detail?id=355103
*
* To avoid this issue, use the keypress event as if no `textInput`
* event is available.
*/
var which = nativeEvent.which;
if (which !== SPACEBAR_CODE) {
return null;
}
hasSpaceKeypress = true;
return SPACEBAR_CHAR;
case 'topTextInput':
// Record the characters to be added to the DOM.
var chars = nativeEvent.data;
// If it's a spacebar character, assume that we have already handled
// it at the keypress level and bail immediately. Android Chrome
// doesn't give us keycodes, so we need to blacklist it.
if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
return null;
}
return chars;
default:
// For other native event types, do nothing.
return null;
}
} | If native `textInput` events are available, our goal is to make
use of them. However, there is a special case: the spacebar key.
In Webkit, preventing default on a spacebar `textInput` event
cancels character insertion, but it *also* causes the browser
to fall back to its default spacebar behavior of scrolling the
page.
Tracking at:
https://code.google.com/p/chromium/issues/detail?id=355103
To avoid this issue, use the keypress event as if no `textInput`
event is available. | getNativeBeforeInputChars | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function getFallbackBeforeInputChars(topLevelType, nativeEvent) {
// If we are currently composing (IME) and using a fallback to do so,
// try to extract the composed characters from the fallback object.
// If composition event is available, we extract a string only at
// compositionevent, otherwise extract it at fallback events.
if (currentComposition) {
if (topLevelType === 'topCompositionEnd' || !canUseCompositionEvent && isFallbackCompositionEnd(topLevelType, nativeEvent)) {
var chars = currentComposition.getData();
FallbackCompositionState.release(currentComposition);
currentComposition = null;
return chars;
}
return null;
}
switch (topLevelType) {
case 'topPaste':
// If a paste event occurs after a keypress, throw out the input
// chars. Paste events should not lead to BeforeInput events.
return null;
case 'topKeyPress':
/**
* As of v27, Firefox may fire keypress events even when no character
* will be inserted. A few possibilities:
*
* - `which` is `0`. Arrow keys, Esc key, etc.
*
* - `which` is the pressed key code, but no char is available.
* Ex: 'AltGr + d` in Polish. There is no modified character for
* this key combination and no character is inserted into the
* document, but FF fires the keypress for char code `100` anyway.
* No `input` event will occur.
*
* - `which` is the pressed key code, but a command combination is
* being used. Ex: `Cmd+C`. No character is inserted, and no
* `input` event will occur.
*/
if (nativeEvent.which && !isKeypressCommand(nativeEvent)) {
return String.fromCharCode(nativeEvent.which);
}
return null;
case 'topCompositionEnd':
return useFallbackCompositionData ? null : nativeEvent.data;
default:
return null;
}
} | For browsers that do not provide the `textInput` event, extract the
appropriate string to use for SyntheticInputEvent.
@param {string} topLevelType Record from `EventConstants`.
@param {object} nativeEvent Native browser event.
@return {?string} The fallback string for this `beforeInput` event. | getFallbackBeforeInputChars | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
var chars;
if (canUseTextInputEvent) {
chars = getNativeBeforeInputChars(topLevelType, nativeEvent);
} else {
chars = getFallbackBeforeInputChars(topLevelType, nativeEvent);
}
// If no characters are being inserted, no BeforeInput event should
// be fired.
if (!chars) {
return null;
}
var event = SyntheticInputEvent.getPooled(eventTypes.beforeInput, targetInst, nativeEvent, nativeEventTarget);
event.data = chars;
EventPropagators.accumulateTwoPhaseDispatches(event);
return event;
} | Extract a SyntheticInputEvent for `beforeInput`, based on either native
`textInput` or fallback behavior.
@return {?object} A SyntheticInputEvent. | extractBeforeInputEvent | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function listenerAtPhase(inst, event, propagationPhase) {
var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase];
return getListener(inst, registrationName);
} | Tags a `SyntheticEvent` with dispatched listeners. Creating this function
here, allows us to not have to bind or create functions for each event.
Mutating the event's members allows us to not have to create a wrapping
"dispatch" object that pairs the event with the listener. | listenerAtPhase | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function accumulateDirectionalDispatches(inst, phase, event) {
if (process.env.NODE_ENV !== 'production') {
process.env.NODE_ENV !== 'production' ? warning(inst, 'Dispatching inst must not be null') : void 0;
}
var listener = listenerAtPhase(inst, event, phase);
if (listener) {
event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
}
} | Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID. | accumulateDirectionalDispatches | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function accumulateTwoPhaseDispatchesSingle(event) {
if (event && event.dispatchConfig.phasedRegistrationNames) {
EventPluginUtils.traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
}
} | Accumulates without regard to direction, does not look for phased
registration names. Same as `accumulateDirectDispatchesSingle` but without
requiring that the `dispatchMarker` be the same as the dispatched ID. | accumulateTwoPhaseDispatchesSingle | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
if (event && event.dispatchConfig.phasedRegistrationNames) {
var targetInst = event._targetInst;
var parentInst = targetInst ? EventPluginUtils.getParentInstance(targetInst) : null;
EventPluginUtils.traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event);
}
} | Accumulates dispatches on an `SyntheticEvent`, but only for the
`dispatchMarker`.
@param {SyntheticEvent} event | accumulateTwoPhaseDispatchesSingleSkipTarget | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function accumulateDispatches(inst, ignoredDirection, event) {
if (event && event.dispatchConfig.registrationName) {
var registrationName = event.dispatchConfig.registrationName;
var listener = getListener(inst, registrationName);
if (listener) {
event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
}
}
} | Accumulates dispatches on an `SyntheticEvent`, but only for the
`dispatchMarker`.
@param {SyntheticEvent} event | accumulateDispatches | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function accumulateDirectDispatchesSingle(event) {
if (event && event.dispatchConfig.registrationName) {
accumulateDispatches(event._targetInst, null, event);
}
} | A small set of propagation patterns, each of which will accept a small amount
of information, and generate a set of "dispatch ready event objects" - which
are sets of events that have already been annotated with a set of dispatched
listener functions/ids. The API is designed this way to discourage these
propagation strategies from actually executing the dispatches, since we
always want to collect the entire set of dispatches before executing event a
single one.
@constructor EventPropagators | accumulateDirectDispatchesSingle | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function accumulateTwoPhaseDispatches(events) {
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
} | A small set of propagation patterns, each of which will accept a small amount
of information, and generate a set of "dispatch ready event objects" - which
are sets of events that have already been annotated with a set of dispatched
listener functions/ids. The API is designed this way to discourage these
propagation strategies from actually executing the dispatches, since we
always want to collect the entire set of dispatches before executing event a
single one.
@constructor EventPropagators | accumulateTwoPhaseDispatches | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function accumulateTwoPhaseDispatchesSkipTarget(events) {
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
} | A small set of propagation patterns, each of which will accept a small amount
of information, and generate a set of "dispatch ready event objects" - which
are sets of events that have already been annotated with a set of dispatched
listener functions/ids. The API is designed this way to discourage these
propagation strategies from actually executing the dispatches, since we
always want to collect the entire set of dispatches before executing event a
single one.
@constructor EventPropagators | accumulateTwoPhaseDispatchesSkipTarget | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
executeDispatchesAndRelease = function (event, simulated) {
if (event) {
EventPluginUtils.executeDispatchesInOrder(event, simulated);
if (!event.isPersistent()) {
event.constructor.release(event);
}
}
} | Dispatches an event and releases it back into the pool, unless persistent.
@param {?object} event Synthetic event to be dispatched.
@param {boolean} simulated If the event is simulated (changes exn behavior)
@private | executeDispatchesAndRelease | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
executeDispatchesAndReleaseSimulated = function (e) {
return executeDispatchesAndRelease(e, true);
} | Dispatches an event and releases it back into the pool, unless persistent.
@param {?object} event Synthetic event to be dispatched.
@param {boolean} simulated If the event is simulated (changes exn behavior)
@private | executeDispatchesAndReleaseSimulated | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
executeDispatchesAndReleaseTopLevel = function (e) {
return executeDispatchesAndRelease(e, false);
} | Dispatches an event and releases it back into the pool, unless persistent.
@param {?object} event Synthetic event to be dispatched.
@param {boolean} simulated If the event is simulated (changes exn behavior)
@private | executeDispatchesAndReleaseTopLevel | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
getDictionaryKey = function (inst) {
// Prevents V8 performance issue:
// https://github.com/facebook/react/pull/7232
return '.' + inst._rootNodeID;
} | Dispatches an event and releases it back into the pool, unless persistent.
@param {?object} event Synthetic event to be dispatched.
@param {boolean} simulated If the event is simulated (changes exn behavior)
@private | getDictionaryKey | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function isInteractive(tag) {
return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea';
} | Dispatches an event and releases it back into the pool, unless persistent.
@param {?object} event Synthetic event to be dispatched.
@param {boolean} simulated If the event is simulated (changes exn behavior)
@private | isInteractive | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function shouldPreventMouseEvent(name, type, props) {
switch (name) {
case 'onClick':
case 'onClickCapture':
case 'onDoubleClick':
case 'onDoubleClickCapture':
case 'onMouseDown':
case 'onMouseDownCapture':
case 'onMouseMove':
case 'onMouseMoveCapture':
case 'onMouseUp':
case 'onMouseUpCapture':
return !!(props.disabled && isInteractive(type));
default:
return false;
}
} | Dispatches an event and releases it back into the pool, unless persistent.
@param {?object} event Synthetic event to be dispatched.
@param {boolean} simulated If the event is simulated (changes exn behavior)
@private | shouldPreventMouseEvent | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function recomputePluginOrdering() {
if (!eventPluginOrder) {
// Wait until an `eventPluginOrder` is injected.
return;
}
for (var pluginName in namesToPlugins) {
var pluginModule = namesToPlugins[pluginName];
var pluginIndex = eventPluginOrder.indexOf(pluginName);
!(pluginIndex > -1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.', pluginName) : _prodInvariant('96', pluginName) : void 0;
if (EventPluginRegistry.plugins[pluginIndex]) {
continue;
}
!pluginModule.extractEvents ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.', pluginName) : _prodInvariant('97', pluginName) : void 0;
EventPluginRegistry.plugins[pluginIndex] = pluginModule;
var publishedEvents = pluginModule.eventTypes;
for (var eventName in publishedEvents) {
!publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : _prodInvariant('98', eventName, pluginName) : void 0;
}
}
} | Recomputes the plugin list using the injected plugins and plugin ordering.
@private | recomputePluginOrdering | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function publishEventForPlugin(dispatchConfig, pluginModule, eventName) {
!!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same event name, `%s`.', eventName) : _prodInvariant('99', eventName) : void 0;
EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
if (phasedRegistrationNames) {
for (var phaseName in phasedRegistrationNames) {
if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
var phasedRegistrationName = phasedRegistrationNames[phaseName];
publishRegistrationName(phasedRegistrationName, pluginModule, eventName);
}
}
return true;
} else if (dispatchConfig.registrationName) {
publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName);
return true;
}
return false;
} | Publishes an event so that it can be dispatched by the supplied plugin.
@param {object} dispatchConfig Dispatch configuration for the event.
@param {object} PluginModule Plugin publishing the event.
@return {boolean} True if the event was successfully published.
@private | publishEventForPlugin | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function publishRegistrationName(registrationName, pluginModule, eventName) {
!!EventPluginRegistry.registrationNameModules[registrationName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same registration name, `%s`.', registrationName) : _prodInvariant('100', registrationName) : void 0;
EventPluginRegistry.registrationNameModules[registrationName] = pluginModule;
EventPluginRegistry.registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies;
if (process.env.NODE_ENV !== 'production') {
var lowerCasedName = registrationName.toLowerCase();
EventPluginRegistry.possibleRegistrationNames[lowerCasedName] = registrationName;
if (registrationName === 'onDoubleClick') {
EventPluginRegistry.possibleRegistrationNames.ondblclick = registrationName;
}
}
} | Mapping from event name to dispatch config | publishRegistrationName | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function isEndish(topLevelType) {
return topLevelType === 'topMouseUp' || topLevelType === 'topTouchEnd' || topLevelType === 'topTouchCancel';
} | - `ComponentTree`: [required] Module that can convert between React instances
and actual node references. | isEndish | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function isMoveish(topLevelType) {
return topLevelType === 'topMouseMove' || topLevelType === 'topTouchMove';
} | Dispatch the event to the listener.
@param {SyntheticEvent} event SyntheticEvent to handle
@param {boolean} simulated If the event is simulated (changes exn behavior)
@param {function} listener Application-level callback
@param {*} inst Internal component instance | isMoveish | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.