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
renderForm () { if (!this.props.isOpen) return; var form = []; var list = this.props.list; var nameField = this.props.list.nameField; var focusWasSet; // If the name field is an initial one, we need to render a proper // input for it if (list.nameIsInitial) { var nameFieldProps = this.getFieldProps(nameField); nameFieldProps.autoFocus = focusWasSet = true; if (nameField.type === 'text') { nameFieldProps.className = 'item-name-field'; nameFieldProps.placeholder = nameField.label; nameFieldProps.label = ''; } form.push(React.createElement(Fields[nameField.type], nameFieldProps)); } // Render inputs for all initial fields Object.keys(list.initialFields).forEach(key => { var field = list.fields[list.initialFields[key]]; // If there's something weird passed in as field type, render the // invalid field type component if (typeof Fields[field.type] !== 'function') { form.push(React.createElement(InvalidFieldType, { type: field.type, path: field.path, key: field.path })); return; } // Get the props for the input field var fieldProps = this.getFieldProps(field); // If there was no focusRef set previously, set the current field to // be the one to be focussed. Generally the first input field, if // there's an initial name field that takes precedence. if (!focusWasSet) { fieldProps.autoFocus = focusWasSet = true; } form.push(React.createElement(Fields[field.type], fieldProps)); }); return ( <Form layout="horizontal" onSubmit={this.submitForm}> <Modal.Header text={'Create a new ' + list.singular} showCloseButton /> <Modal.Body> <AlertMessages alerts={this.state.alerts} /> {form} </Modal.Body> <Modal.Footer> <Button color="success" type="submit" data-button-type="submit"> Create </Button> <Button variant="link" color="cancel" data-button-type="cancel" onClick={this.props.onCancel} > Cancel </Button> </Modal.Footer> </Form> ); }
The form that's visible when "Create <ItemName>" is clicked on either the List screen or the Item screen
renderForm
javascript
keystonejs/keystone-classic
admin/client/App/shared/CreateForm.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/CreateForm.js
MIT
render () { return ( <Modal.Dialog isOpen={this.props.isOpen} onClose={this.props.onCancel} backdropClosesModal > {this.renderForm()} </Modal.Dialog> ); }
The form that's visible when "Create <ItemName>" is clicked on either the List screen or the Item screen
render
javascript
keystonejs/keystone-classic
admin/client/App/shared/CreateForm.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/CreateForm.js
MIT
renderMessage (message) { // If the message is only a string, render the string if (typeof message === 'string') { return ( <span> {message} </span> ); } // Get the title and the detail of the message const title = message.title ? <h4>{message.title}</h4> : null; const detail = message.detail ? <p>{message.detail}</p> : null; // If the message has a list attached, render a <ul> const list = message.list ? ( <ul style={{ marginBottom: 0 }}> {message.list.map((item, i) => <li key={`i${i}`}>{item}</li>)} </ul> ) : null; return ( <span> {title} {detail} {list} </span> ); }
A single flash message component. Used by FlashMessages.js
renderMessage
javascript
keystonejs/keystone-classic
admin/client/App/shared/FlashMessage.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/FlashMessage.js
MIT
render () { const { message, type } = this.props; return ( <Alert color={type}> {this.renderMessage(message)} </Alert> ); }
A single flash message component. Used by FlashMessages.js
render
javascript
keystonejs/keystone-classic
admin/client/App/shared/FlashMessage.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/FlashMessage.js
MIT
renderMessages (messages, type) { if (!messages || !messages.length) return null; return messages.map((message, i) => { return <FlashMessage message={message} type={type} key={`i${i}`} />; }); }
Render a few flash messages, e.g. errors, success messages, warnings,... Use like this: <FlashMessages messages={{ error: [{ title: 'There is a network problem', detail: 'Please try again later...', }], }} /> Instead of error, it can also be hilight, info, success or warning
renderMessages
javascript
keystonejs/keystone-classic
admin/client/App/shared/FlashMessages.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/FlashMessages.js
MIT
renderTypes (types) { return Object.keys(types).map(type => this.renderMessages(types[type], type)); }
Render a few flash messages, e.g. errors, success messages, warnings,... Use like this: <FlashMessages messages={{ error: [{ title: 'There is a network problem', detail: 'Please try again later...', }], }} /> Instead of error, it can also be hilight, info, success or warning
renderTypes
javascript
keystonejs/keystone-classic
admin/client/App/shared/FlashMessages.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/FlashMessages.js
MIT
render () { if (!this.props.messages) return null; return ( <div className="flash-messages"> {_.isPlainObject(this.props.messages) && this.renderTypes(this.props.messages)} </div> ); }
Render a few flash messages, e.g. errors, success messages, warnings,... Use like this: <FlashMessages messages={{ error: [{ title: 'There is a network problem', detail: 'Please try again later...', }], }} /> Instead of error, it can also be hilight, info, success or warning
render
javascript
keystonejs/keystone-classic
admin/client/App/shared/FlashMessages.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/FlashMessages.js
MIT
InvalidFieldType = function (props) { return ( <div className="alert alert-danger"> Invalid field type <strong>{props.type}</strong> at path <strong>{props.path}</strong> </div> ); }
Renders an "Invalid Field Type" error
InvalidFieldType
javascript
keystonejs/keystone-classic
admin/client/App/shared/InvalidFieldType.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/InvalidFieldType.js
MIT
InvalidFieldType = function (props) { return ( <div className="alert alert-danger"> Invalid field type <strong>{props.type}</strong> at path <strong>{props.path}</strong> </div> ); }
Renders an "Invalid Field Type" error
InvalidFieldType
javascript
keystonejs/keystone-classic
admin/client/App/shared/InvalidFieldType.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/InvalidFieldType.js
MIT
componentDidMount () { const el = document.createElement('div'); document.body.appendChild(el); this.portalElement = el; this.componentDidUpdate(); }
Used by the Popout component and the Lightbox component of the fields for popouts. Renders a non-react DOM node.
componentDidMount
javascript
keystonejs/keystone-classic
admin/client/App/shared/Portal.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/Portal.js
MIT
componentDidUpdate () { ReactDOM.render(<div {...this.props} />, this.portalElement); }
Used by the Popout component and the Lightbox component of the fields for popouts. Renders a non-react DOM node.
componentDidUpdate
javascript
keystonejs/keystone-classic
admin/client/App/shared/Portal.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/Portal.js
MIT
getPortalDOMNode () { return this.portalElement; }
Used by the Popout component and the Lightbox component of the fields for popouts. Renders a non-react DOM node.
getPortalDOMNode
javascript
keystonejs/keystone-classic
admin/client/App/shared/Portal.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/Portal.js
MIT
render () { return null; }
Used by the Popout component and the Lightbox component of the fields for popouts. Renders a non-react DOM node.
render
javascript
keystonejs/keystone-classic
admin/client/App/shared/Portal.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/Portal.js
MIT
getDefaultProps () { return { width: 320, }; }
A Popout component. One can also add a Header (Popout/Header), a Footer (Popout/Footer), a Body (Popout/Body) and a Pan (Popout/Pane).
getDefaultProps
javascript
keystonejs/keystone-classic
admin/client/App/shared/Popout/index.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/Popout/index.js
MIT
getInitialState () { return {}; }
A Popout component. One can also add a Header (Popout/Header), a Footer (Popout/Footer), a Body (Popout/Body) and a Pan (Popout/Pane).
getInitialState
javascript
keystonejs/keystone-classic
admin/client/App/shared/Popout/index.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/Popout/index.js
MIT
componentWillReceiveProps (nextProps) { if (!this.props.isOpen && nextProps.isOpen) { window.addEventListener('resize', this.calculatePosition); this.calculatePosition(nextProps.isOpen); } else if (this.props.isOpen && !nextProps.isOpen) { window.removeEventListener('resize', this.calculatePosition); } }
A Popout component. One can also add a Header (Popout/Header), a Footer (Popout/Footer), a Body (Popout/Body) and a Pan (Popout/Pane).
componentWillReceiveProps
javascript
keystonejs/keystone-classic
admin/client/App/shared/Popout/index.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/Popout/index.js
MIT
getPortalDOMNode () { return this.refs.portal.getPortalDOMNode(); }
A Popout component. One can also add a Header (Popout/Header), a Footer (Popout/Footer), a Body (Popout/Body) and a Pan (Popout/Pane).
getPortalDOMNode
javascript
keystonejs/keystone-classic
admin/client/App/shared/Popout/index.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/Popout/index.js
MIT
calculatePosition (isOpen) { if (!isOpen) return; let posNode = document.getElementById(this.props.relativeToID); const pos = { top: 0, left: 0, width: posNode.offsetWidth, height: posNode.offsetHeight, }; while (posNode.offsetParent) { pos.top += posNode.offsetTop; pos.left += posNode.offsetLeft; posNode = posNode.offsetParent; } let leftOffset = Math.max(pos.left + (pos.width / 2) - (this.props.width / 2), SIZES.horizontalMargin); let topOffset = pos.top + pos.height + SIZES.arrowHeight; var spaceOnRight = window.innerWidth - (leftOffset + this.props.width + SIZES.horizontalMargin); if (spaceOnRight < 0) { leftOffset = leftOffset + spaceOnRight; } const arrowLeftOffset = leftOffset === SIZES.horizontalMargin ? pos.left + (pos.width / 2) - (SIZES.arrowWidth / 2) - SIZES.horizontalMargin : null; const newStateAvaliable = this.state.leftOffset !== leftOffset || this.state.topOffset !== topOffset || this.state.arrowLeftOffset !== arrowLeftOffset; if (newStateAvaliable) { this.setState({ leftOffset: leftOffset, topOffset: topOffset, arrowLeftOffset: arrowLeftOffset, }); } }
A Popout component. One can also add a Header (Popout/Header), a Footer (Popout/Footer), a Body (Popout/Body) and a Pan (Popout/Pane).
calculatePosition
javascript
keystonejs/keystone-classic
admin/client/App/shared/Popout/index.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/Popout/index.js
MIT
renderPopout () { if (!this.props.isOpen) return null; const { width } = this.props; const { arrowLeftOffset, leftOffset: left, topOffset: top } = this.state; const arrowStyles = arrowLeftOffset ? { left: 0, marginLeft: arrowLeftOffset } : null; return ( <div className="Popout" style={{ left, top, width }}> <span className="Popout__arrow" style={arrowStyles} /> <div className="Popout__inner"> {this.props.children} </div> </div> ); }
A Popout component. One can also add a Header (Popout/Header), a Footer (Popout/Footer), a Body (Popout/Body) and a Pan (Popout/Pane).
renderPopout
javascript
keystonejs/keystone-classic
admin/client/App/shared/Popout/index.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/Popout/index.js
MIT
renderBlockout () { if (!this.props.isOpen) return; return <div className="blockout" onClick={this.props.onCancel} />; }
A Popout component. One can also add a Header (Popout/Header), a Footer (Popout/Footer), a Body (Popout/Body) and a Pan (Popout/Pane).
renderBlockout
javascript
keystonejs/keystone-classic
admin/client/App/shared/Popout/index.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/Popout/index.js
MIT
render () { return ( <Portal className="Popout-wrapper" ref="portal"> <Transition transitionEnterTimeout={200} transitionLeaveTimeout={200} transitionName="Popout" > {this.renderPopout()} </Transition> {this.renderBlockout()} </Portal> ); }
A Popout component. One can also add a Header (Popout/Header), a Footer (Popout/Footer), a Body (Popout/Body) and a Pan (Popout/Pane).
render
javascript
keystonejs/keystone-classic
admin/client/App/shared/Popout/index.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/Popout/index.js
MIT
render () { const className = classnames('PopoutList', this.props.className); const props = blacklist(this.props, 'className'); return ( <div className={className} {...props} /> ); }
Render a popout list. Can also use PopoutListItem and PopoutListHeading
render
javascript
keystonejs/keystone-classic
admin/client/App/shared/Popout/PopoutList.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/Popout/PopoutList.js
MIT
getDefaultProps () { return { onLayout: () => {}, }; }
Render a popout pane, calls props.onLayout when the component mounts
getDefaultProps
javascript
keystonejs/keystone-classic
admin/client/App/shared/Popout/PopoutPane.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/Popout/PopoutPane.js
MIT
render () { const className = classnames('Popout__pane', this.props.className); const props = blacklist(this.props, 'className', 'onLayout'); return ( <div ref="el" className={className} {...props} /> ); }
Render a popout pane, calls props.onLayout when the component mounts
render
javascript
keystonejs/keystone-classic
admin/client/App/shared/Popout/PopoutPane.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/App/shared/Popout/PopoutPane.js
MIT
getInitialState() { return { email: "", password: "", isAnimating: false, isInvalid: false, invalidMessage: "", signedOut: window.location.search === "?signedout" }; }
The actual Sign In view, with the login form
getInitialState
javascript
keystonejs/keystone-classic
admin/client/Signin/Signin.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/Signin/Signin.js
MIT
componentDidMount() { // Focus the email field when we're mounted if (this.refs.email) { this.refs.email.select(); } this.__isMounted = true; }
The actual Sign In view, with the login form
componentDidMount
javascript
keystonejs/keystone-classic
admin/client/Signin/Signin.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/Signin/Signin.js
MIT
componentWillUnmount() { this.__isMounted = false; }
The actual Sign In view, with the login form
componentWillUnmount
javascript
keystonejs/keystone-classic
admin/client/Signin/Signin.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/Signin/Signin.js
MIT
handleInputChange(e) { // Set the new state when the input changes const newState = {}; newState[e.target.name] = e.target.value; this.setState(newState); }
The actual Sign In view, with the login form
handleInputChange
javascript
keystonejs/keystone-classic
admin/client/Signin/Signin.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/Signin/Signin.js
MIT
handleSubmit(e) { e.preventDefault(); // If either password or mail are missing, show an error if (!this.state.email || !this.state.password) { return this.displayError( "Please enter an email address and password to sign in." ); } xhr( { url: `${Keystone.adminPath}/api/session/signin`, method: "post", json: { email: this.state.email, password: this.state.password }, headers: assign({}, Keystone.csrf.header) }, (err, resp, body) => { if (err || (body && body.error)) { return body.error === "invalid csrf" ? this.displayError( "Something went wrong; please refresh your browser and try again." ) : this.displayError( "The email and password you entered are not valid." ); } else { // Redirect to where we came from or to the default admin path if (Keystone.redirect) { top.location.href = Keystone.redirect; } else { top.location.href = this.props.from ? this.props.from : Keystone.adminPath; } } } ); }
The actual Sign In view, with the login form
handleSubmit
javascript
keystonejs/keystone-classic
admin/client/Signin/Signin.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/Signin/Signin.js
MIT
displayError(message) { this.setState({ isAnimating: true, isInvalid: true, invalidMessage: message }); setTimeout(this.finishAnimation, 750); }
Display an error message @param {String} message The message you want to show
displayError
javascript
keystonejs/keystone-classic
admin/client/Signin/Signin.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/Signin/Signin.js
MIT
finishAnimation() { if (!this.__isMounted) return; if (this.refs.email) { this.refs.email.select(); } this.setState({ isAnimating: false }); }
Display an error message @param {String} message The message you want to show
finishAnimation
javascript
keystonejs/keystone-classic
admin/client/Signin/Signin.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/Signin/Signin.js
MIT
render() { const boxClassname = classnames("auth-box", { "auth-box--has-errors": this.state.isAnimating }); return ( <div className="auth-wrapper"> <Alert isInvalid={this.state.isInvalid} signedOut={this.state.signedOut} invalidMessage={this.state.invalidMessage} /> <div className={boxClassname}> <h1 className="u-hidden-visually"> {this.props.brand ? this.props.brand : "Keystone"} Sign In{" "} </h1> <div className="auth-box__inner"> <Brand logo={this.props.logo} brand={this.props.brand} /> {this.props.user ? ( <UserInfo adminPath={ this.props.from ? this.props.from : Keystone.adminPath } signoutPath={`${Keystone.adminPath}/signout`} userCanAccessKeystone={this.props.userCanAccessKeystone} userName={this.props.user.name} /> ) : ( <LoginForm email={this.state.email} handleInputChange={this.handleInputChange} handleSubmit={this.handleSubmit} isAnimating={this.state.isAnimating} password={this.state.password} /> )} </div> </div> <div className="auth-footer"> <span>Powered by </span> <a href="http://v4.keystonejs.com" target="_blank" title="The Node.js CMS and web application platform (new window)" > KeystoneJS </a> </div> </div> ); }
Display an error message @param {String} message The message you want to show
render
javascript
keystonejs/keystone-classic
admin/client/Signin/Signin.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/Signin/Signin.js
MIT
AlertView = function (props) { if (props.isInvalid) { return <Alert key="error" color="danger" style={{ textAlign: 'center' }}>{props.invalidMessage}</Alert>; } else if (props.signedOut) { return <Alert key="signed-out" color="info" style={{ textAlign: 'center' }}>You have been signed out.</Alert>; } else { // Can't return "null" from stateless components return <span />; } }
Renders an Alert. Pass either an isInvalid and invalidMessage prop, or set the signedOut prop to true to show the standard signed out message
AlertView
javascript
keystonejs/keystone-classic
admin/client/Signin/components/Alert.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/Signin/components/Alert.js
MIT
AlertView = function (props) { if (props.isInvalid) { return <Alert key="error" color="danger" style={{ textAlign: 'center' }}>{props.invalidMessage}</Alert>; } else if (props.signedOut) { return <Alert key="signed-out" color="info" style={{ textAlign: 'center' }}>You have been signed out.</Alert>; } else { // Can't return "null" from stateless components return <span />; } }
Renders an Alert. Pass either an isInvalid and invalidMessage prop, or set the signedOut prop to true to show the standard signed out message
AlertView
javascript
keystonejs/keystone-classic
admin/client/Signin/components/Alert.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/Signin/components/Alert.js
MIT
Brand = function (props) { // Default to the KeystoneJS logo let logo = { src: `${Keystone.adminPath}/images/logo.png`, width: 205, height: 68 }; if (props.logo) { // If the logo is set to a string, it's a direct link logo = typeof props.logo === 'string' ? { src: props.logo } : props.logo; // Optionally one can specify the logo as an array, also stating the // wanted width and height of the logo // TODO: Deprecate this if (Array.isArray(logo)) { logo = { src: logo[0], width: logo[1], height: logo[2] }; } } return ( <div className="auth-box__col"> <div className="auth-box__brand"> <a href="/" className="auth-box__brand__logo"> <img src={logo.src} width={logo.width ? logo.width : null} height={logo.height ? logo.height : null} alt={props.brand} /> </a> </div> </div> ); }
Renders a logo, defaulting to the Keystone logo if no brand is specified in the configuration
Brand
javascript
keystonejs/keystone-classic
admin/client/Signin/components/Brand.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/Signin/components/Brand.js
MIT
Brand = function (props) { // Default to the KeystoneJS logo let logo = { src: `${Keystone.adminPath}/images/logo.png`, width: 205, height: 68 }; if (props.logo) { // If the logo is set to a string, it's a direct link logo = typeof props.logo === 'string' ? { src: props.logo } : props.logo; // Optionally one can specify the logo as an array, also stating the // wanted width and height of the logo // TODO: Deprecate this if (Array.isArray(logo)) { logo = { src: logo[0], width: logo[1], height: logo[2] }; } } return ( <div className="auth-box__col"> <div className="auth-box__brand"> <a href="/" className="auth-box__brand__logo"> <img src={logo.src} width={logo.width ? logo.width : null} height={logo.height ? logo.height : null} alt={props.brand} /> </a> </div> </div> ); }
Renders a logo, defaulting to the Keystone logo if no brand is specified in the configuration
Brand
javascript
keystonejs/keystone-classic
admin/client/Signin/components/Brand.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/Signin/components/Brand.js
MIT
LoginForm = ({ email, handleInputChange, handleSubmit, isAnimating, password, }) => { return ( <div className="auth-box__col"> <Form onSubmit={handleSubmit} noValidate> <FormField label="Email" htmlFor="email"> <FormInput autoFocus type="email" name="email" onChange={handleInputChange} value={email} /> </FormField> <FormField label="Password" htmlFor="password"> <FormInput type="password" name="password" onChange={handleInputChange} value={password} /> </FormField> <Button disabled={isAnimating} color="primary" type="submit"> Sign In </Button> </Form> </div> ); }
The login form of the signin screen
LoginForm
javascript
keystonejs/keystone-classic
admin/client/Signin/components/LoginForm.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/Signin/components/LoginForm.js
MIT
LoginForm = ({ email, handleInputChange, handleSubmit, isAnimating, password, }) => { return ( <div className="auth-box__col"> <Form onSubmit={handleSubmit} noValidate> <FormField label="Email" htmlFor="email"> <FormInput autoFocus type="email" name="email" onChange={handleInputChange} value={email} /> </FormField> <FormField label="Password" htmlFor="password"> <FormInput type="password" name="password" onChange={handleInputChange} value={password} /> </FormField> <Button disabled={isAnimating} color="primary" type="submit"> Sign In </Button> </Form> </div> ); }
The login form of the signin screen
LoginForm
javascript
keystonejs/keystone-classic
admin/client/Signin/components/LoginForm.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/Signin/components/LoginForm.js
MIT
function validateHex (color) { const hex = color.replace('#', ''); if (hex.length === 3) { return hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; } if (hex.length !== 6) { throw new Error(`Invalid color value provided: "${color}"`); } return hex; }
Validate Hex ============================== @param {String} hex 1. remove hash if present 2. convert from 3 to 6 digit color code & ensure valid hex
validateHex
javascript
keystonejs/keystone-classic
admin/client/utils/color.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/color.js
MIT
function fade (color, opacity = 100) { const decimalFraction = opacity / 100; const hex = validateHex(color); // 1. const r = parseInt(hex.substring(0, 2), 16); const g = parseInt(hex.substring(2, 4), 16); const b = parseInt(hex.substring(4, 6), 16); // 2. const result = 'rgba(' + r + ',' + g + ',' + b + ',' + decimalFraction + ')'; return result; }
Fade Color ============================== Takes a hexidecimal color, converts it to RGB and applies an alpha value. @param {String} color @param {Number} opacity (0-100) 1. convert hex to RGB 2. combine and add alpha channel
fade
javascript
keystonejs/keystone-classic
admin/client/utils/color.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/color.js
MIT
function shade (color, percent) { const decimalFraction = percent / 100; const hex = validateHex(color); // 1. let f = parseInt(hex, 16); let t = decimalFraction < 0 ? 0 : 255; let p = decimalFraction < 0 ? decimalFraction * -1 : decimalFraction; const R = f >> 16; const G = f >> 8 & 0x00FF; const B = f & 0x0000FF; // 2. return '#' + (0x1000000 + (Math.round((t - R) * p) + R) * 0x10000 + (Math.round((t - G) * p) + G) * 0x100 + (Math.round((t - B) * p) + B)).toString(16).slice(1); }
Shade Color ============================== Takes a hexidecimal color, converts it to RGB and lightens or darkens @param {String} color @param {Number} opacity (0-100) 1. do fancy RGB bitwise operations 2. combine back into a hex value
shade
javascript
keystonejs/keystone-classic
admin/client/utils/color.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/color.js
MIT
function darken (color, percent) { return shade(color, percent * -1); }
Shade Color ============================== Takes a hexidecimal color, converts it to RGB and lightens or darkens @param {String} color @param {Number} opacity (0-100) 1. do fancy RGB bitwise operations 2. combine back into a hex value
darken
javascript
keystonejs/keystone-classic
admin/client/utils/color.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/color.js
MIT
function blend (color1, color2, percent) { const decimalFraction = percent / 100; const hex1 = validateHex(color1); const hex2 = validateHex(color2); // 1. const f = parseInt(hex1, 16); const t = parseInt(hex2, 16); const R1 = f >> 16; const G1 = f >> 8 & 0x00FF; const B1 = f & 0x0000FF; const R2 = t >> 16; const G2 = t >> 8 & 0x00FF; const B2 = t & 0x0000FF; // 2. return '#' + (0x1000000 + (Math.round((R2 - R1) * decimalFraction) + R1) * 0x10000 + (Math.round((G2 - G1) * decimalFraction) + G1) * 0x100 + (Math.round((B2 - B1) * decimalFraction) + B1)).toString(16).slice(1); }
Blend Color ============================== Takes two hexidecimal colors and blend them together @param {String} color1 @param {String} color2 @param {Number} percent (0-100) 1. do fancy RGB bitwise operations 2. combine back into a hex value
blend
javascript
keystonejs/keystone-classic
admin/client/utils/color.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/color.js
MIT
function linearGradient (direction, top, bottom, base = '') { return { background: `linear-gradient(${direction}, ${top} 0%, ${bottom} 100%) ${base}`, }; }
Linear Gradient ============================== Short-hand helper for adding a linear gradient to your component. - @param {String} sideOrCorner - @param {String} top - @param {String} bottom - @param {String} base (optional) - @returns {Object} css linear gradient declaration Spread the declaration into your component class: ------------------------------ myComponentClass: { ...linearGradient(red, blue), }
linearGradient
javascript
keystonejs/keystone-classic
admin/client/utils/css.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/css.js
MIT
function gradientVertical (top, bottom, base) { return linearGradient('to bottom', top, bottom, base); }
Linear Gradient ============================== Short-hand helper for adding a linear gradient to your component. - @param {String} sideOrCorner - @param {String} top - @param {String} bottom - @param {String} base (optional) - @returns {Object} css linear gradient declaration Spread the declaration into your component class: ------------------------------ myComponentClass: { ...linearGradient(red, blue), }
gradientVertical
javascript
keystonejs/keystone-classic
admin/client/utils/css.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/css.js
MIT
function gradientHorizontal (top, bottom, base) { return linearGradient('to right', top, bottom, base); }
Linear Gradient ============================== Short-hand helper for adding a linear gradient to your component. - @param {String} sideOrCorner - @param {String} top - @param {String} bottom - @param {String} base (optional) - @returns {Object} css linear gradient declaration Spread the declaration into your component class: ------------------------------ myComponentClass: { ...linearGradient(red, blue), }
gradientHorizontal
javascript
keystonejs/keystone-classic
admin/client/utils/css.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/css.js
MIT
function borderTopRadius (radius) { return { borderTopLeftRadius: radius, borderTopRightRadius: radius, }; }
Border Radius ============================== Short-hand helper for border radii
borderTopRadius
javascript
keystonejs/keystone-classic
admin/client/utils/css.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/css.js
MIT
function borderRightRadius (radius) { return { borderBottomRightRadius: radius, borderTopRightRadius: radius, }; }
Border Radius ============================== Short-hand helper for border radii
borderRightRadius
javascript
keystonejs/keystone-classic
admin/client/utils/css.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/css.js
MIT
function borderBottomRadius (radius) { return { borderBottomLeftRadius: radius, borderBottomRightRadius: radius, }; }
Border Radius ============================== Short-hand helper for border radii
borderBottomRadius
javascript
keystonejs/keystone-classic
admin/client/utils/css.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/css.js
MIT
function borderLeftRadius (radius) { return { borderBottomLeftRadius: radius, borderTopLeftRadius: radius, }; }
Border Radius ============================== Short-hand helper for border radii
borderLeftRadius
javascript
keystonejs/keystone-classic
admin/client/utils/css.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/css.js
MIT
function getColumns (list) { return list.uiElements.map((col) => { if (col.type === 'heading') { return { type: 'heading', content: col.content }; } else { var field = list.fields[col.field]; return field ? { type: 'field', field: field, title: field.label, path: field.path } : null; } }).filter(truthy); }
Get the columns of a list, structured by fields and headings @param {Object} list The list we want the columns of @return {Array} The columns
getColumns
javascript
keystonejs/keystone-classic
admin/client/utils/List.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/List.js
MIT
function getFilters (filterArray) { var filters = {}; filterArray.forEach((filter) => { filters[filter.field.path] = filter.value; }); return filters; }
Make an array of filters an object keyed by the filtering path @param {Array} filterArray The array of filters @return {Object} The corrected filters, keyed by path
getFilters
javascript
keystonejs/keystone-classic
admin/client/utils/List.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/List.js
MIT
function getSortString (sort) { return sort.paths.map(i => { // If we want to sort inverted, we prefix a "-" before the sort path return i.invert ? '-' + i.path : i.path; }).filter(truthy).join(','); }
Get the sorting string for the URI @param {Array} sort.paths The paths we want to sort @return {String} All the sorting queries we want as a string
getSortString
javascript
keystonejs/keystone-classic
admin/client/utils/List.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/List.js
MIT
function buildQueryString (options) { const query = {}; if (options.search) query.search = options.search; if (options.filters.length) query.filters = JSON.stringify(getFilters(options.filters)); if (options.columns) query.fields = options.columns.map(i => i.path).join(','); if (options.page && options.page.size) query.limit = options.page.size; if (options.page && options.page.index > 1) query.skip = (options.page.index - 1) * options.page.size; if (options.sort) query.sort = getSortString(options.sort); query.expandRelationshipFields = true; return '?' + qs.stringify(query); }
Build a query string from a bunch of options
buildQueryString
javascript
keystonejs/keystone-classic
admin/client/utils/List.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/List.js
MIT
List = function (options) { // TODO these options are possibly unused assign(this, options); this.columns = getColumns(this); this.expandedDefaultColumns = this.expandColumns(this.defaultColumns); this.defaultColumnPaths = this.expandedDefaultColumns.map(i => i.path).join(','); }
The main list helper class @param {Object} options
List
javascript
keystonejs/keystone-classic
admin/client/utils/List.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/List.js
MIT
List = function (options) { // TODO these options are possibly unused assign(this, options); this.columns = getColumns(this); this.expandedDefaultColumns = this.expandColumns(this.defaultColumns); this.defaultColumnPaths = this.expandedDefaultColumns.map(i => i.path).join(','); }
The main list helper class @param {Object} options
List
javascript
keystonejs/keystone-classic
admin/client/utils/List.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/List.js
MIT
function updateQueryParams (params, location) { if (!location) return; const newParams = assign({}, location.query); // Stringify nested objects inside the parameters Object.keys(params).forEach(i => { if (params[i]) { newParams[i] = params[i]; if (typeof newParams[i] === 'object') { newParams[i] = JSON.stringify(newParams[i]); } } else { delete newParams[i]; } }); return newParams; }
Updates the query parameters with the ones passed as the first argument @param {Object} params The new parameters to be added @param {Object} location The current location object
updateQueryParams
javascript
keystonejs/keystone-classic
admin/client/utils/queryParams.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/queryParams.js
MIT
function stringifyColumns (columns, defaultColumnPaths) { if (!columns) { return; } // Turns [{ path: 'someColumn' }, { path: 'someOtherColumn' }] // into ['someColumn', 'someOtherColumn'] let columnString = columns.map((column) => column.path); // Turns that array into 'someColumn,someOtherColumn' if (Array.isArray(columnString)) columnString = columnString.join(','); // If that is the same as the default columns, don't set the query param if (columnString === defaultColumnPaths) columnString = undefined; return columnString; }
Stringify the columns array from the state @param {Array} columns The columns from the active state @param {String} defaultColumnPaths The default column paths of the current list @return {String} The column array, stringified
stringifyColumns
javascript
keystonejs/keystone-classic
admin/client/utils/queryParams.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/queryParams.js
MIT
function parametizeFilters (filterArray) { if (!filterArray || filterArray.length === 0) { return; } return filterArray.map((filter) => { return Object.assign({ path: filter.field.path, }, filter.value); }); }
Flattens filters from state into the minimum needed object to be used as a url param @param {Object} filterArray The array of filters from state
parametizeFilters
javascript
keystonejs/keystone-classic
admin/client/utils/queryParams.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/client/utils/queryParams.js
MIT
function inspect(obj, opts) { // default options var ctx = { seen: [], stylize: stylizeNoColor }; // legacy... if (arguments.length >= 3) ctx.depth = arguments[2]; if (arguments.length >= 4) ctx.colors = arguments[3]; if (isBoolean(opts)) { // legacy... ctx.showHidden = opts; } else if (opts) { // got an "options" object exports._extend(ctx, opts); } // set default options if (isUndefined(ctx.showHidden)) ctx.showHidden = false; if (isUndefined(ctx.depth)) ctx.depth = 2; if (isUndefined(ctx.colors)) ctx.colors = false; if (isUndefined(ctx.customInspect)) ctx.customInspect = true; if (ctx.colors) ctx.stylize = stylizeWithColor; return formatValue(ctx, obj, ctx.depth); }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
inspect
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function stylizeWithColor(str, styleType) { var style = inspect.styles[styleType]; if (style) { return '\u001b[' + inspect.colors[style][0] + 'm' + str + '\u001b[' + inspect.colors[style][1] + 'm'; } else { return str; } }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
stylizeWithColor
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function stylizeNoColor(str, styleType) { return str; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
stylizeNoColor
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function arrayToHash(array) { var hash = {}; array.forEach(function(val, idx) { hash[val] = true; }); return hash; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
arrayToHash
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function formatValue(ctx, value, recurseTimes) { // Provide a hook for user-specified inspect functions. // Check that value is an object with an inspect function on it if (ctx.customInspect && value && isFunction(value.inspect) && // Filter out the util module, it's inspect function is special value.inspect !== exports.inspect && // Also filter out any prototype objects using the circular check. !(value.constructor && value.constructor.prototype === value)) { var ret = value.inspect(recurseTimes, ctx); if (!isString(ret)) { ret = formatValue(ctx, ret, recurseTimes); } return ret; } // Primitive types cannot have properties var primitive = formatPrimitive(ctx, value); if (primitive) { return primitive; } // Look up the keys of the object. var keys = Object.keys(value); var visibleKeys = arrayToHash(keys); if (ctx.showHidden) { keys = Object.getOwnPropertyNames(value); } // IE doesn't make error fields non-enumerable // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx if (isError(value) && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { return formatError(value); } // Some type of object without properties can be shortcutted. if (keys.length === 0) { if (isFunction(value)) { var name = value.name ? ': ' + value.name : ''; return ctx.stylize('[Function' + name + ']', 'special'); } if (isRegExp(value)) { return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); } if (isDate(value)) { return ctx.stylize(Date.prototype.toString.call(value), 'date'); } if (isError(value)) { return formatError(value); } } var base = '', array = false, braces = ['{', '}']; // Make Array say that they are Array if (isArray(value)) { array = true; braces = ['[', ']']; } // Make functions say that they are functions if (isFunction(value)) { var n = value.name ? ': ' + value.name : ''; base = ' [Function' + n + ']'; } // Make RegExps say that they are RegExps if (isRegExp(value)) { base = ' ' + RegExp.prototype.toString.call(value); } // Make dates with properties first say the date if (isDate(value)) { base = ' ' + Date.prototype.toUTCString.call(value); } // Make error with message first say the error if (isError(value)) { base = ' ' + formatError(value); } if (keys.length === 0 && (!array || value.length == 0)) { return braces[0] + base + braces[1]; } if (recurseTimes < 0) { if (isRegExp(value)) { return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); } else { return ctx.stylize('[Object]', 'special'); } } ctx.seen.push(value); var output; if (array) { output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); } else { output = keys.map(function(key) { return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); }); } ctx.seen.pop(); return reduceToSingleString(output, base, braces); }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
formatValue
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function formatPrimitive(ctx, value) { if (isUndefined(value)) return ctx.stylize('undefined', 'undefined'); if (isString(value)) { var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') .replace(/'/g, "\\'") .replace(/\\"/g, '"') + '\''; return ctx.stylize(simple, 'string'); } if (isNumber(value)) return ctx.stylize('' + value, 'number'); if (isBoolean(value)) return ctx.stylize('' + value, 'boolean'); // For some reason typeof null is "object", so special case here. if (isNull(value)) return ctx.stylize('null', 'null'); }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
formatPrimitive
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function formatError(value) { return '[' + Error.prototype.toString.call(value) + ']'; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
formatError
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { var output = []; for (var i = 0, l = value.length; i < l; ++i) { if (hasOwnProperty(value, String(i))) { output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true)); } else { output.push(''); } } keys.forEach(function(key) { if (!key.match(/^\d+$/)) { output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true)); } }); return output; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
formatArray
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { var name, str, desc; desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; if (desc.get) { if (desc.set) { str = ctx.stylize('[Getter/Setter]', 'special'); } else { str = ctx.stylize('[Getter]', 'special'); } } else { if (desc.set) { str = ctx.stylize('[Setter]', 'special'); } } if (!hasOwnProperty(visibleKeys, key)) { name = '[' + key + ']'; } if (!str) { if (ctx.seen.indexOf(desc.value) < 0) { if (isNull(recurseTimes)) { str = formatValue(ctx, desc.value, null); } else { str = formatValue(ctx, desc.value, recurseTimes - 1); } if (str.indexOf('\n') > -1) { if (array) { str = str.split('\n').map(function(line) { return ' ' + line; }).join('\n').substr(2); } else { str = '\n' + str.split('\n').map(function(line) { return ' ' + line; }).join('\n'); } } } else { str = ctx.stylize('[Circular]', 'special'); } } if (isUndefined(name)) { if (array && key.match(/^\d+$/)) { return str; } name = JSON.stringify('' + key); if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { name = name.substr(1, name.length - 2); name = ctx.stylize(name, 'name'); } else { name = name.replace(/'/g, "\\'") .replace(/\\"/g, '"') .replace(/(^"|"$)/g, "'"); name = ctx.stylize(name, 'string'); } } return name + ': ' + str; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
formatProperty
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function reduceToSingleString(output, base, braces) { var numLinesEst = 0; var length = output.reduce(function(prev, cur) { numLinesEst++; if (cur.indexOf('\n') >= 0) numLinesEst++; return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; }, 0); if (length > 60) { return braces[0] + (base === '' ? '' : base + '\n ') + ' ' + output.join(',\n ') + ' ' + braces[1]; } return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
reduceToSingleString
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function isArray(ar) { return Array.isArray(ar); }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isArray
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function isBoolean(arg) { return typeof arg === 'boolean'; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isBoolean
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function isNull(arg) { return arg === null; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isNull
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function isNullOrUndefined(arg) { return arg == null; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isNullOrUndefined
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function isNumber(arg) { return typeof arg === 'number'; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isNumber
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function isString(arg) { return typeof arg === 'string'; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isString
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function isSymbol(arg) { return typeof arg === 'symbol'; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isSymbol
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function isUndefined(arg) { return arg === void 0; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isUndefined
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function isRegExp(re) { return isObject(re) && objectToString(re) === '[object RegExp]'; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isRegExp
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function isObject(arg) { return typeof arg === 'object' && arg !== null; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isObject
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function isDate(d) { return isObject(d) && objectToString(d) === '[object Date]'; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isDate
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function isError(e) { return isObject(e) && (objectToString(e) === '[object Error]' || e instanceof Error); }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isError
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function isFunction(arg) { return typeof arg === 'function'; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isFunction
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function isPrimitive(arg) { return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || typeof arg === 'symbol' || // ES6 symbol typeof arg === 'undefined'; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isPrimitive
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function objectToString(o) { return Object.prototype.toString.call(o); }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
objectToString
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function pad(n) { return n < 10 ? '0' + n.toString(10) : n.toString(10); }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
pad
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function timestamp() { var d = new Date(); var time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(':'); return [d.getDate(), months[d.getMonth()], time].join(' '); }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
timestamp
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function hasOwnProperty(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
Inherit the prototype methods from one constructor into another. The Function.prototype.inherits from lang.js rewritten as a standalone function (not on Function.prototype). NOTE: If this file is to be loaded during bootstrapping this function needs to be rewritten using some native functions as prototype setup using normal JavaScript does not work as expected during bootstrapping (see mirror.js in r114903). @param {function} ctor Constructor function which needs to inherit the prototype. @param {function} superCtor Constructor function to inherit prototype from.
hasOwnProperty
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function info() { console.log.apply(console, arguments) }
Inherit the prototype methods from one constructor into another. The Function.prototype.inherits from lang.js rewritten as a standalone function (not on Function.prototype). NOTE: If this file is to be loaded during bootstrapping this function needs to be rewritten using some native functions as prototype setup using normal JavaScript does not work as expected during bootstrapping (see mirror.js in r114903). @param {function} ctor Constructor function which needs to inherit the prototype. @param {function} superCtor Constructor function to inherit prototype from.
info
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function warn() { console.log.apply(console, arguments) }
Inherit the prototype methods from one constructor into another. The Function.prototype.inherits from lang.js rewritten as a standalone function (not on Function.prototype). NOTE: If this file is to be loaded during bootstrapping this function needs to be rewritten using some native functions as prototype setup using normal JavaScript does not work as expected during bootstrapping (see mirror.js in r114903). @param {function} ctor Constructor function which needs to inherit the prototype. @param {function} superCtor Constructor function to inherit prototype from.
warn
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function error() { console.warn.apply(console, arguments) }
Inherit the prototype methods from one constructor into another. The Function.prototype.inherits from lang.js rewritten as a standalone function (not on Function.prototype). NOTE: If this file is to be loaded during bootstrapping this function needs to be rewritten using some native functions as prototype setup using normal JavaScript does not work as expected during bootstrapping (see mirror.js in r114903). @param {function} ctor Constructor function which needs to inherit the prototype. @param {function} superCtor Constructor function to inherit prototype from.
error
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function time(label) { times[label] = Date.now() }
Inherit the prototype methods from one constructor into another. The Function.prototype.inherits from lang.js rewritten as a standalone function (not on Function.prototype). NOTE: If this file is to be loaded during bootstrapping this function needs to be rewritten using some native functions as prototype setup using normal JavaScript does not work as expected during bootstrapping (see mirror.js in r114903). @param {function} ctor Constructor function which needs to inherit the prototype. @param {function} superCtor Constructor function to inherit prototype from.
time
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function timeEnd(label) { var time = times[label] if (!time) { throw new Error("No such label: " + label) } var duration = Date.now() - time console.log(label + ": " + duration + "ms") }
Inherit the prototype methods from one constructor into another. The Function.prototype.inherits from lang.js rewritten as a standalone function (not on Function.prototype). NOTE: If this file is to be loaded during bootstrapping this function needs to be rewritten using some native functions as prototype setup using normal JavaScript does not work as expected during bootstrapping (see mirror.js in r114903). @param {function} ctor Constructor function which needs to inherit the prototype. @param {function} superCtor Constructor function to inherit prototype from.
timeEnd
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function trace() { var err = new Error() err.name = "Trace" err.message = util.format.apply(null, arguments) console.error(err.stack) }
Inherit the prototype methods from one constructor into another. The Function.prototype.inherits from lang.js rewritten as a standalone function (not on Function.prototype). NOTE: If this file is to be loaded during bootstrapping this function needs to be rewritten using some native functions as prototype setup using normal JavaScript does not work as expected during bootstrapping (see mirror.js in r114903). @param {function} ctor Constructor function which needs to inherit the prototype. @param {function} superCtor Constructor function to inherit prototype from.
trace
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function dir(object) { console.log(util.inspect(object) + "\n") }
Inherit the prototype methods from one constructor into another. The Function.prototype.inherits from lang.js rewritten as a standalone function (not on Function.prototype). NOTE: If this file is to be loaded during bootstrapping this function needs to be rewritten using some native functions as prototype setup using normal JavaScript does not work as expected during bootstrapping (see mirror.js in r114903). @param {function} ctor Constructor function which needs to inherit the prototype. @param {function} superCtor Constructor function to inherit prototype from.
dir
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
function assert(expression) { if (!expression) { var arr = slice.call(arguments, 1) assert.ok(false, util.format.apply(null, arr)) } }
Inherit the prototype methods from one constructor into another. The Function.prototype.inherits from lang.js rewritten as a standalone function (not on Function.prototype). NOTE: If this file is to be loaded during bootstrapping this function needs to be rewritten using some native functions as prototype setup using normal JavaScript does not work as expected during bootstrapping (see mirror.js in r114903). @param {function} ctor Constructor function which needs to inherit the prototype. @param {function} superCtor Constructor function to inherit prototype from.
assert
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
_ = function(obj) { if (obj instanceof _) return obj; if (!(this instanceof _)) return new _(obj); this._wrapped = obj; }
Inherit the prototype methods from one constructor into another. The Function.prototype.inherits from lang.js rewritten as a standalone function (not on Function.prototype). NOTE: If this file is to be loaded during bootstrapping this function needs to be rewritten using some native functions as prototype setup using normal JavaScript does not work as expected during bootstrapping (see mirror.js in r114903). @param {function} ctor Constructor function which needs to inherit the prototype. @param {function} superCtor Constructor function to inherit prototype from.
_
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
lookupIterator = function(value) { return _.isFunction(value) ? value : function(obj){ return obj[value]; }; }
Inherit the prototype methods from one constructor into another. The Function.prototype.inherits from lang.js rewritten as a standalone function (not on Function.prototype). NOTE: If this file is to be loaded during bootstrapping this function needs to be rewritten using some native functions as prototype setup using normal JavaScript does not work as expected during bootstrapping (see mirror.js in r114903). @param {function} ctor Constructor function which needs to inherit the prototype. @param {function} superCtor Constructor function to inherit prototype from.
lookupIterator
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
group = function(obj, value, context, behavior) { var result = {}; var iterator = lookupIterator(value || _.identity); each(obj, function(value, index) { var key = iterator.call(context, value, index, obj); behavior(result, key, value); }); return result; }
Inherit the prototype methods from one constructor into another. The Function.prototype.inherits from lang.js rewritten as a standalone function (not on Function.prototype). NOTE: If this file is to be loaded during bootstrapping this function needs to be rewritten using some native functions as prototype setup using normal JavaScript does not work as expected during bootstrapping (see mirror.js in r114903). @param {function} ctor Constructor function which needs to inherit the prototype. @param {function} superCtor Constructor function to inherit prototype from.
group
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
flatten = function(input, shallow, output) { each(input, function(value) { if (_.isArray(value)) { shallow ? push.apply(output, value) : flatten(value, shallow, output); } else { output.push(value); } }); return output; }
Inherit the prototype methods from one constructor into another. The Function.prototype.inherits from lang.js rewritten as a standalone function (not on Function.prototype). NOTE: If this file is to be loaded during bootstrapping this function needs to be rewritten using some native functions as prototype setup using normal JavaScript does not work as expected during bootstrapping (see mirror.js in r114903). @param {function} ctor Constructor function which needs to inherit the prototype. @param {function} superCtor Constructor function to inherit prototype from.
flatten
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT
later = function() { previous = new Date; timeout = null; result = func.apply(context, args); }
Inherit the prototype methods from one constructor into another. The Function.prototype.inherits from lang.js rewritten as a standalone function (not on Function.prototype). NOTE: If this file is to be loaded during bootstrapping this function needs to be rewritten using some native functions as prototype setup using normal JavaScript does not work as expected during bootstrapping (see mirror.js in r114903). @param {function} ctor Constructor function which needs to inherit the prototype. @param {function} superCtor Constructor function to inherit prototype from.
later
javascript
keystonejs/keystone-classic
admin/public/js/lib/codemirror/codemirror-compressed.js
https://github.com/keystonejs/keystone-classic/blob/master/admin/public/js/lib/codemirror/codemirror-compressed.js
MIT