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 |
---|---|---|---|---|---|---|---|
async isOpen() {
return (
(await $(timePickerModalId).isDisplayed()) &&
(await (await $(timePickerModalId).$(
'button[id="time-picker_cancel-button"]',
)).isDisplayed()) &&
(await (await $(timePickerModalId).$(
'button[id="time-picker_ok-button"]',
)).isDisplayed()) &&
(await (await $(timePickerModalId).$(
'button[id="time-picker_up-button"]',
)).isDisplayed()) &&
(await (await $(timePickerModalId).$(
'button[id="time-picker_down-button"]',
)).isDisplayed()) &&
(await (await $(timePickerModalId).$('input[data-id="minutes"]')).isDisplayed()) &&
(await (await $(timePickerModalId).$('input[data-id="hour"]')).isDisplayed()) &&
(await (await $(timePickerModalId).$(
'input[aria-label="am-pm selector"]',
)).isDisplayed())
);
} | Returns true when the TimePicker is open.
@method
@returns {bool} | isOpen | javascript | nexxtway/react-rainbow | src/components/TimePicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/pageObject/index.js | MIT |
async getTimeValue() {
return $(this.rootElement)
.$(timeInputId)
.$('input')
.getValue();
} | Get the TimePicker value.
@method
@returns {string} | getTimeValue | javascript | nexxtway/react-rainbow | src/components/TimePicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/pageObject/index.js | MIT |
async hasFocusTimeInput() {
return $(this.rootElement)
.$(timeInputId)
.$('input')
.isFocused();
} | Returns true when the TimePicker has focus.
@method
@returns {bool} | hasFocusTimeInput | javascript | nexxtway/react-rainbow | src/components/TimePicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/pageObject/index.js | MIT |
async hasFocusHourInput() {
return $(timePickerModalId)
.$('input[data-id="hour"]')
.isFocused();
} | Returns true when the hour input has focus.
@method
@returns {bool} | hasFocusHourInput | javascript | nexxtway/react-rainbow | src/components/TimePicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/pageObject/index.js | MIT |
async getHourValue() {
return $(timePickerModalId)
.$('input[data-id="hour"]')
.getValue();
} | Get the hour input value.
@method
@returns {string} | getHourValue | javascript | nexxtway/react-rainbow | src/components/TimePicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/pageObject/index.js | MIT |
async hasFocusMinutesInput() {
return $(timePickerModalId)
.$('input[data-id="minutes"]')
.isFocused();
} | Returns true when the minutes input has focus.
@method
@returns {bool} | hasFocusMinutesInput | javascript | nexxtway/react-rainbow | src/components/TimePicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/pageObject/index.js | MIT |
async getMinutesValue() {
return $(timePickerModalId)
.$('input[data-id="minutes"]')
.getValue();
} | Get the minutes input value.
@method
@returns {string} | getMinutesValue | javascript | nexxtway/react-rainbow | src/components/TimePicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/pageObject/index.js | MIT |
async hasFocusAmPmSelect() {
return $(timePickerModalId)
.$('fieldset[role="presentation"]')
.isFocused();
} | Returns true when the am-pm selector has focus.
@method
@returns {bool} | hasFocusAmPmSelect | javascript | nexxtway/react-rainbow | src/components/TimePicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/pageObject/index.js | MIT |
async isAmSelected() {
await browser.waitUntil(async () =>
$(timePickerModalId)
.$('fieldset[role="presentation"]')
.isFocused(),
);
return $(timePickerModalId)
.$('input[value="AM"]')
.isSelected();
} | Returns true when the am input is selected.
@method
@returns {bool} | isAmSelected | javascript | nexxtway/react-rainbow | src/components/TimePicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/pageObject/index.js | MIT |
async isPmSelected() {
await browser.waitUntil(async () =>
$(timePickerModalId)
.$('fieldset[role="presentation"]')
.isFocused(),
);
return $(timePickerModalId)
.$('input[value="PM"]')
.isSelected();
} | Returns true when the pm input is selected.
@method
@returns {bool} | isPmSelected | javascript | nexxtway/react-rainbow | src/components/TimePicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/pageObject/index.js | MIT |
async setHourValue(value) {
await $(timePickerModalId)
.$('input[data-id="hour"]')
.setValue(value);
} | Type in the hour input element.
@method
@param {string} value - The value to type in the hour input element. | setHourValue | javascript | nexxtway/react-rainbow | src/components/TimePicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/pageObject/index.js | MIT |
async setMinutesValue(value) {
await $(timePickerModalId)
.$('input[data-id="minutes"]')
.setValue(value);
} | Type in the minutes input element.
@method
@param {string} value - The value to type in the minutes input element. | setMinutesValue | javascript | nexxtway/react-rainbow | src/components/TimePicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/pageObject/index.js | MIT |
async waitUntilOpen() {
await browser.waitUntil(async () => this.isOpen());
} | Wait until the TimePicker is open.
@method | waitUntilOpen | javascript | nexxtway/react-rainbow | src/components/TimePicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/pageObject/index.js | MIT |
async waitUntilClose() {
await browser.waitUntil(async () => !(await this.isOpen()));
} | Wait until the TimePicker is close.
@method | waitUntilClose | javascript | nexxtway/react-rainbow | src/components/TimePicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/pageObject/index.js | MIT |
function Tree(props) {
const {
data,
onNodeExpand,
onNodeCheck,
onNodeSelect,
selectedNode,
className,
style,
id,
ariaLabel,
ariaLabelledBy,
} = props;
const visibleNodes = useTreeNodesAsPlainList(data);
const {
autoFocus,
focusedNode,
setFocusedNode,
clearFocusedNode,
keyDownHandler,
} = useKeyNavigation({
visibleNodes,
selectedNode,
onNodeSelect,
onNodeExpand,
});
const treeData = Array.isArray(data) ? data : [];
return (
<Provider
value={{
autoFocus,
focusedNode,
onPrivateFocusNode: setFocusedNode,
onPrivateBlurNode: clearFocusedNode,
onPrivateKeyDown: keyDownHandler,
}}
>
<TreeContainerUl
className={className}
style={style}
id={id}
role="tree"
aria-labelledby={ariaLabelledBy}
aria-label={ariaLabel}
>
<TreeChildren
data={treeData}
onNodeExpand={onNodeExpand}
onNodeCheck={onNodeCheck}
nodePath={[]}
selectedNode={selectedNode}
onNodeSelect={onNodeSelect}
/>
</TreeContainerUl>
</Provider>
);
} | A Tree is visualization of a structure hierarchy with nested elements. A branch can be expanded or collapsed or selected. This is a BETA version.
@category Layout | Tree | javascript | nexxtway/react-rainbow | src/components/Tree/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tree/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new Tree page object.
@constructor
@param {string} rootElement - The selector of the Tree root element. | constructor | javascript | nexxtway/react-rainbow | src/components/Tree/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tree/pageObject/index.js | MIT |
async getNode(path) {
const nodePath = path.join('.');
const node = await $(this.rootElement).$(`[data-path="${nodePath}"]`);
if (node) {
return new PageNodeItem(`${this.rootElement} [data-path="${nodePath}"]`);
}
return null;
} | Returns a new Node page object of the element at specified path.
@method
@param {array} path - Array with 0 base indexes that defines the node path in tree. | getNode | javascript | nexxtway/react-rainbow | src/components/Tree/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tree/pageObject/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new Node page object.
@constructor
@param {string} rootElement - The selector of the Node root element. | constructor | javascript | nexxtway/react-rainbow | src/components/Tree/pageObject/node.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tree/pageObject/node.js | MIT |
async hasFocus() {
const nodeEl = $(this.rootElement);
return (await nodeEl.isExisting()) && nodeEl.isFocused();
} | Returns true when the li has focus.
@method
@returns {bool} | hasFocus | javascript | nexxtway/react-rainbow | src/components/Tree/pageObject/node.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tree/pageObject/node.js | MIT |
async clickExpandButton() {
await $(this.rootElement)
.$('[data-id="node-element"] button')
.click();
} | Clicks the button icon element.
@method | clickExpandButton | javascript | nexxtway/react-rainbow | src/components/Tree/pageObject/node.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tree/pageObject/node.js | MIT |
async isExpanded() {
const childEl = await $(this.rootElement).$('[data-id="node-element-li"]');
return (await childEl.isExisting()) && childEl.isDisplayed();
} | Returns true when the node is expanded, false otherwise.
@method
@returns {bool} | isExpanded | javascript | nexxtway/react-rainbow | src/components/Tree/pageObject/node.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tree/pageObject/node.js | MIT |
async isSelected() {
return (await $(this.rootElement).getAttribute('aria-selected')) === 'true';
} | Returns true when the node is selected, false otherwise.
@method
@returns {bool} | isSelected | javascript | nexxtway/react-rainbow | src/components/Tree/pageObject/node.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tree/pageObject/node.js | MIT |
function VerticalItem(props) {
return (
<NavigationConsumer>
{context => (
<SectionConsumer>
{entityHeaderId => (
<SectionOverflowConsumer>
{isExpanded => (
<Item
{...props}
{...context}
entityHeaderId={entityHeaderId}
isExpanded={isExpanded}
/>
)}
</SectionOverflowConsumer>
)}
</SectionConsumer>
)}
</NavigationConsumer>
);
} | A text-only link within VerticalNavigationSection or VerticalNavigationOverflow.
@category Layout | VerticalItem | javascript | nexxtway/react-rainbow | src/components/VerticalItem/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalItem/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new VerticalItem page object.
@constructor
@param {string} rootElement - The selector of the VerticalItem root element. | constructor | javascript | nexxtway/react-rainbow | src/components/VerticalItem/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalItem/pageObject/index.js | MIT |
async hasFocus() {
return $(this.rootElement)
.$('[data-id="vertical-item-clickable-element"]')
.isFocused();
} | Returns true when the vertical item has focus.
@method
@returns {bool} | hasFocus | javascript | nexxtway/react-rainbow | src/components/VerticalItem/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalItem/pageObject/index.js | MIT |
async isSelected() {
return !!(await $(this.rootElement).getAttribute('data-active'));
} | Returns true when the vertical item is selected.
@method
@returns {bool} | isSelected | javascript | nexxtway/react-rainbow | src/components/VerticalItem/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalItem/pageObject/index.js | MIT |
function VerticalNavigation(props) {
const {
id,
ariaLabel,
style,
selectedItem,
onSelect,
compact,
shaded,
className,
children,
} = props;
const context = {
selectedItem,
onSelect,
};
return (
<StyledNav
id={id}
className={className}
style={style}
aria-label={ariaLabel}
compact={compact}
shaded={shaded}
>
<Provider value={context}>{children}</Provider>
</StyledNav>
);
} | Navigation represents a list of links that either take the user to another page
or parts of the page the user is in.
@category Layout | VerticalNavigation | javascript | nexxtway/react-rainbow | src/components/VerticalNavigation/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalNavigation/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new VerticalNavigation page object.
@constructor
@param {string} rootElement - The selector of the VerticalNavigation root element. | constructor | javascript | nexxtway/react-rainbow | src/components/VerticalNavigation/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalNavigation/pageObject/index.js | MIT |
async getItem(itemPosition) {
const items = await $(this.rootElement).$$('[data-id="vertical-item"]');
if (items[itemPosition]) {
return new PageVerticalItem(
`${this.rootElement} [data-id="vertical-item"]:nth-child(${itemPosition + 1})`,
);
}
return null;
} | Returns a new VerticalItem page object of the element in item position.
@method
@param {number} itemPosition - The base 0 index of the vertical item. | getItem | javascript | nexxtway/react-rainbow | src/components/VerticalNavigation/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalNavigation/pageObject/index.js | MIT |
async getSectionOverflow(itemPosition) {
const items = await $(this.rootElement).$$('[data-id="vertical-overflow-container"]');
if (items[itemPosition]) {
return new PageVerticalSectionOverflow(
`${
this.rootElement
} [data-id="vertical-overflow-container"]:nth-child(${itemPosition + 1})`,
);
}
return null;
} | Returns a new VerticalSectionOverflow page object of the element in item position.
@method
@param {number} itemPosition - The base 0 index of the vertical section overflow. | getSectionOverflow | javascript | nexxtway/react-rainbow | src/components/VerticalNavigation/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalNavigation/pageObject/index.js | MIT |
constructor(props) {
super(props);
this.entityHeaderId = uniqueId('entity-header');
} | Represents a section within a VerticalNavigation.
@category Layout | constructor | javascript | nexxtway/react-rainbow | src/components/VerticalSection/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalSection/index.js | MIT |
render() {
const { label, style, children, className } = this.props;
return (
<StyledContainer className={className} style={style}>
<RenderIf isTrue={label}>
<StyledTitle id={this.entityHeaderId}>{label}</StyledTitle>
</RenderIf>
<Provider value={this.entityHeaderId}>
<StyledUl>{children}</StyledUl>
</Provider>
</StyledContainer>
);
} | Represents a section within a VerticalNavigation.
@category Layout | render | javascript | nexxtway/react-rainbow | src/components/VerticalSection/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalSection/index.js | MIT |
constructor(props) {
super(props);
this.searchResultsId = uniqueId('search-results');
this.state = {
isExpanded: props.expanded,
};
this.toggleOverflow = this.toggleOverflow.bind(this);
} | Represents an overflow of items from a preceding VerticalNavigationSection,
with the ability to toggle visibility.
@category Layout | constructor | javascript | nexxtway/react-rainbow | src/components/VerticalSectionOverflow/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalSectionOverflow/index.js | MIT |
static getDerivedStateFromProps(nextProps, state) {
const { expanded, onToggleSection } = nextProps;
if (expanded !== state.isExpanded && typeof onToggleSection === 'function') {
return {
isExpanded: expanded,
};
}
return null;
} | Represents an overflow of items from a preceding VerticalNavigationSection,
with the ability to toggle visibility.
@category Layout | getDerivedStateFromProps | javascript | nexxtway/react-rainbow | src/components/VerticalSectionOverflow/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalSectionOverflow/index.js | MIT |
toggleOverflow(event) {
const { isExpanded } = this.state;
const { onToggleSection } = this.props;
if (typeof onToggleSection === 'function') {
return onToggleSection(event);
}
return this.setState({ isExpanded: !isExpanded });
} | Represents an overflow of items from a preceding VerticalNavigationSection,
with the ability to toggle visibility.
@category Layout | toggleOverflow | javascript | nexxtway/react-rainbow | src/components/VerticalSectionOverflow/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalSectionOverflow/index.js | MIT |
render() {
const { label, description, style, assistiveText, children, className } = this.props;
const { isExpanded } = this.state;
const sectionMaxHeight = {
maxHeight: getMaxHeight(children, isExpanded),
};
return (
<StyledContainer
data-id="vertical-overflow-container"
className={className}
style={style}
isExpanded={isExpanded}
>
<StyledButton
data-id="vertical-overflow-button"
aria-controls={this.searchResultsId}
aria-expanded={isExpanded}
onClick={this.toggleOverflow}
isExpanded={isExpanded}
description={description}
>
<StyledActionContainer as="div">
<StyledActionLabel>{label}</StyledActionLabel>
<Description isExpanded={isExpanded} description={description} />
<AssistiveText text={assistiveText} />
</StyledActionContainer>
<RightArrow isExpanded={isExpanded} />
</StyledButton>
<StyledOverflow
data-id="vertical-overflow"
id={this.searchResultsId}
style={sectionMaxHeight}
isExpanded={isExpanded}
>
<Provider value={isExpanded}>
<StyledUl>{children}</StyledUl>
</Provider>
</StyledOverflow>
</StyledContainer>
);
} | Represents an overflow of items from a preceding VerticalNavigationSection,
with the ability to toggle visibility.
@category Layout | render | javascript | nexxtway/react-rainbow | src/components/VerticalSectionOverflow/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalSectionOverflow/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new VerticalSectionOverflow page object.
@constructor
@param {string} rootElement - The selector of the VerticalSectionOverflow root element. | constructor | javascript | nexxtway/react-rainbow | src/components/VerticalSectionOverflow/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalSectionOverflow/pageObject/index.js | MIT |
async click() {
await $(this.rootElement)
.$('[data-id="vertical-overflow-button"]')
.click();
} | Clicks the vertical section overflow button.
@method | click | javascript | nexxtway/react-rainbow | src/components/VerticalSectionOverflow/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalSectionOverflow/pageObject/index.js | MIT |
async isExpanded() {
return $(this.rootElement)
.$('[data-id="vertical-overflow"]')
.isDisplayed();
} | Returns true when the overflow section is visible, false otherwise.
@method
@returns {bool} | isExpanded | javascript | nexxtway/react-rainbow | src/components/VerticalSectionOverflow/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalSectionOverflow/pageObject/index.js | MIT |
async waitUntilExpand() {
await browser.waitUntil(async () => this.isExpanded());
} | Wait until the expand transition has finished.
@method | waitUntilExpand | javascript | nexxtway/react-rainbow | src/components/VerticalSectionOverflow/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalSectionOverflow/pageObject/index.js | MIT |
async waitUntilCollapse() {
await browser.waitUntil(async () => !(await this.isExpanded()));
} | Wait until the contract transition has finished.
@method | waitUntilCollapse | javascript | nexxtway/react-rainbow | src/components/VerticalSectionOverflow/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalSectionOverflow/pageObject/index.js | MIT |
async hasFocusButton() {
return $(this.rootElement)
.$('[data-id="vertical-overflow-button"]')
.isFocused();
} | Returns true when the vertical section overflow button has focus.
@method
@returns {bool} | hasFocusButton | javascript | nexxtway/react-rainbow | src/components/VerticalSectionOverflow/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VerticalSectionOverflow/pageObject/index.js | MIT |
constructor(props) {
super(props);
this.errorId = uniqueId('error-message');
this.groupNameId = props.name || uniqueId('visual-picker');
this.handleChange = this.handleChange.bind(this);
} | A VisualPicker can be either radio buttons, checkboxes, or links that are visually enhanced.
@category Form | constructor | javascript | nexxtway/react-rainbow | src/components/VisualPicker/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VisualPicker/index.js | MIT |
getErrorMessageId() {
const { error } = this.props;
if (error) {
return this.errorId;
}
return undefined;
} | A VisualPicker can be either radio buttons, checkboxes, or links that are visually enhanced.
@category Form | getErrorMessageId | javascript | nexxtway/react-rainbow | src/components/VisualPicker/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VisualPicker/index.js | MIT |
handleChange(optionName, isChecked) {
const { onChange, multiple, value } = this.props;
let currentValue = optionName;
if (multiple) {
if (!Array.isArray(value)) {
currentValue = isChecked ? [optionName] : [];
} else {
currentValue = isChecked
? [...value, optionName]
: value.filter(item => item !== optionName);
}
}
onChange(currentValue);
} | A VisualPicker can be either radio buttons, checkboxes, or links that are visually enhanced.
@category Form | handleChange | javascript | nexxtway/react-rainbow | src/components/VisualPicker/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VisualPicker/index.js | MIT |
render() {
const {
style,
label,
labelAlignment,
hideLabel,
required,
error,
id,
children,
value,
multiple,
className,
size,
} = this.props;
const context = {
ariaDescribedby: this.getErrorMessageId(),
groupName: this.groupNameId,
privateOnChange: this.handleChange,
value,
multiple,
size,
};
return (
<StyledContainer id={id} className={className} style={style}>
<RenderIf isTrue={label}>
<Label
label={label}
labelAlignment={labelAlignment}
hideLabel={hideLabel}
required={required}
as="legend"
/>
</RenderIf>
<StyledOptionsContainer>
<Provider value={context}>{children}</Provider>
</StyledOptionsContainer>
<RenderIf isTrue={error}>
<StyledError id={this.getErrorMessageId()}>{error}</StyledError>
</RenderIf>
</StyledContainer>
);
} | A VisualPicker can be either radio buttons, checkboxes, or links that are visually enhanced.
@category Form | render | javascript | nexxtway/react-rainbow | src/components/VisualPicker/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VisualPicker/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new VisualPicker page object.
@constructor
@param {string} rootElement - The selector of the VisualPicker root element. | constructor | javascript | nexxtway/react-rainbow | src/components/VisualPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VisualPicker/pageObject/index.js | MIT |
async getItem(itemPosition) {
const items = await $(this.rootElement).$$(
'span[data-id="visual-picker_option-container"]',
);
if (items[itemPosition]) {
return new PageVisualPickerOption(
`${
this.rootElement
} span[data-id="visual-picker_option-container"]:nth-child(${itemPosition + 1})`,
);
}
return null;
} | Returns a new VisualPickerOption page object of the element in item position.
@method
@param {number} itemPosition - The base 0 index of the VisualPickerOption. | getItem | javascript | nexxtway/react-rainbow | src/components/VisualPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VisualPicker/pageObject/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new VisualPickerOption page object.
@constructor
@param {string} rootElement - The selector of the VisualPickerOption root element. | constructor | javascript | nexxtway/react-rainbow | src/components/VisualPickerOption/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VisualPickerOption/pageObject/index.js | MIT |
async hasFocus() {
return $(this.rootElement)
.$('input')
.isFocused();
} | Returns true when the input has the focus.
@method
@returns {bool} | hasFocus | javascript | nexxtway/react-rainbow | src/components/VisualPickerOption/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VisualPickerOption/pageObject/index.js | MIT |
async isChecked() {
return $(this.rootElement)
.$('input')
.isSelected();
} | Returns true when the input is checked.
@method
@returns {bool} | isChecked | javascript | nexxtway/react-rainbow | src/components/VisualPickerOption/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/VisualPickerOption/pageObject/index.js | MIT |
handleOnChange = event => {
const weekDayValue = event.target.value;
const isChecked = event.target.checked;
if (!disabled && !readOnly) {
onChange(getNormalizedValue(weekDayValue, isChecked, multiple, value));
}
} | A WeekDayPicker allows to select the days of the week
@category Form | handleOnChange | javascript | nexxtway/react-rainbow | src/components/WeekDayPicker/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/WeekDayPicker/index.js | MIT |
handleOnChange = event => {
const weekDayValue = event.target.value;
const isChecked = event.target.checked;
if (!disabled && !readOnly) {
onChange(getNormalizedValue(weekDayValue, isChecked, multiple, value));
}
} | A WeekDayPicker allows to select the days of the week
@category Form | handleOnChange | javascript | nexxtway/react-rainbow | src/components/WeekDayPicker/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/WeekDayPicker/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new PageWeekDayPicker page object.
@constructor
@param {string} rootElement - The selector of the PageWeekDayPicker root element. | constructor | javascript | nexxtway/react-rainbow | src/components/WeekDayPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/WeekDayPicker/pageObject/index.js | MIT |
async clickOn(weekDay) {
const inputRef = await this.getInputRef(weekDay);
await inputRef.click();
} | Triggers a click over the checkbox/radio input by clicking his label reference.
@method
@param {string} weekDay - The value of the day we want the make click. | clickOn | javascript | nexxtway/react-rainbow | src/components/WeekDayPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/WeekDayPicker/pageObject/index.js | MIT |
async getSelectedDays() {
const selected = (await Promise.all(
weekDays.map(async weekDay => {
const input = await this.getInput(weekDay);
return (await input.isSelected()) ? weekDay : undefined;
}),
)).filter(value => value);
return selected;
} | Returns an array with the selected days
@method | getSelectedDays | javascript | nexxtway/react-rainbow | src/components/WeekDayPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/WeekDayPicker/pageObject/index.js | MIT |
async getFocusedDay() {
const focusedDay = (await Promise.all(
weekDays.map(async weekDay => {
const input = await this.getInput(weekDay);
return (await input.isFocused()) ? weekDay : undefined;
}),
)).filter(value => value);
return focusedDay.length ? focusedDay[0] : undefined;
} | Returns the day that has the current focus or empty
@method | getFocusedDay | javascript | nexxtway/react-rainbow | src/components/WeekDayPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/WeekDayPicker/pageObject/index.js | MIT |
async getInput(weekDay) {
const index = weekDays.findIndex(value => value === weekDay);
const elem = await $(this.rootElement).$$('input');
return elem[index];
} | Returns the day that has the current focus or empty
@method | getInput | javascript | nexxtway/react-rainbow | src/components/WeekDayPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/WeekDayPicker/pageObject/index.js | MIT |
async getInputRef(weekDay) {
const index = weekDays.findIndex(value => value === weekDay);
const elem = await $(this.rootElement).$$('span');
return elem[index].$('label');
} | Returns the day that has the current focus or empty
@method | getInputRef | javascript | nexxtway/react-rainbow | src/components/WeekDayPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/WeekDayPicker/pageObject/index.js | MIT |
ZoomableImage = ({ className, style, src, alt, width, height }) => {
const ref = useRef();
const imageRect = useRef({});
const [isOpen, setIsOpen] = useState(false);
const open = () => {
imageRect.current = ref.current.getBoundingClientRect();
setIsOpen(true);
};
const close = () => {
setIsOpen(false);
};
return (
<>
<StyledImage
className={className}
style={style}
src={src}
alt={alt}
width={width}
height={height}
ref={ref}
isOpen={isOpen}
onClick={open}
/>
<RenderIf isTrue={isOpen}>
<ZoomedImage src={src} alt={alt} close={close} originalRect={imageRect.current} />
</RenderIf>
</>
);
} | ZoomableImage renders an image that is zoomed in when clicked | ZoomableImage | javascript | nexxtway/react-rainbow | src/components/ZoomableImage/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ZoomableImage/index.js | MIT |
ZoomableImage = ({ className, style, src, alt, width, height }) => {
const ref = useRef();
const imageRect = useRef({});
const [isOpen, setIsOpen] = useState(false);
const open = () => {
imageRect.current = ref.current.getBoundingClientRect();
setIsOpen(true);
};
const close = () => {
setIsOpen(false);
};
return (
<>
<StyledImage
className={className}
style={style}
src={src}
alt={alt}
width={width}
height={height}
ref={ref}
isOpen={isOpen}
onClick={open}
/>
<RenderIf isTrue={isOpen}>
<ZoomedImage src={src} alt={alt} close={close} originalRect={imageRect.current} />
</RenderIf>
</>
);
} | ZoomableImage renders an image that is zoomed in when clicked | ZoomableImage | javascript | nexxtway/react-rainbow | src/components/ZoomableImage/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ZoomableImage/index.js | MIT |
open = () => {
imageRect.current = ref.current.getBoundingClientRect();
setIsOpen(true);
} | ZoomableImage renders an image that is zoomed in when clicked | open | javascript | nexxtway/react-rainbow | src/components/ZoomableImage/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ZoomableImage/index.js | MIT |
open = () => {
imageRect.current = ref.current.getBoundingClientRect();
setIsOpen(true);
} | ZoomableImage renders an image that is zoomed in when clicked | open | javascript | nexxtway/react-rainbow | src/components/ZoomableImage/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ZoomableImage/index.js | MIT |
function getElementSize(element) {
const rect = element.getBoundingClientRect();
return {
width: Math.round(rect.width),
height: Math.round(rect.height),
};
} | Get element size
@param {HTMLElement} element - element to return the size.
@returns {Object} {width, height} | getElementSize | javascript | nexxtway/react-rainbow | src/libs/ResizeSensor/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/libs/ResizeSensor/index.js | MIT |
function createResizeSensor() {
const resizeSensor = document.createElement('div');
resizeSensor.dir = 'ltr';
resizeSensor.className = 'resize-sensor';
const style =
'position: absolute; left: -10px; top: -10px; right: 0; bottom: 0; overflow: hidden; z-index: -1; visibility: hidden;';
const styleChild = 'position: absolute; left: 0; top: 0; transition: 0s;';
resizeSensor.style.cssText = style;
resizeSensor.innerHTML =
`<div class="resize-sensor-expand" style="${style}">` +
`<div style="${styleChild}"></div>` +
'</div>' +
`<div class="resize-sensor-shrink" style="${style}">` +
`<div style="${styleChild} width: 200%; height: 200%"></div>` +
'</div>';
return resizeSensor;
} | Get element size
@param {HTMLElement} element - element to return the size.
@returns {Object} {width, height} | createResizeSensor | javascript | nexxtway/react-rainbow | src/libs/ResizeSensor/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/libs/ResizeSensor/index.js | MIT |
function attachResizeEvent(element, resizeListener) {
if (!element) {
return;
}
if (element.resizedAttached) {
element.resizedAttached.add(() => resizeListener());
return;
}
element.resizedAttached = new EventQueue();
element.resizedAttached.add(() => resizeListener());
const resizeSensor = createResizeSensor();
element.resizeSensor = resizeSensor;
element.appendChild(resizeSensor);
const position = (window.getComputedStyle(element) || element.style).getPropertyValue(
'position',
);
if (position !== 'absolute' && position !== 'relative' && position !== 'fixed') {
element.style.position = 'relative';
}
const expand = resizeSensor.childNodes[0];
const expandChild = expand.childNodes[0];
const shrink = resizeSensor.childNodes[1];
let dirty;
let rafId;
let size = getElementSize(element);
let lastWidth = size.width;
let lastHeight = size.height;
let initialHiddenCheck = true;
let resetRafId;
const resetExpandShrink = () => {
expandChild.style.width = '100000px';
expandChild.style.height = '100000px';
expand.scrollLeft = 100000;
expand.scrollTop = 100000;
shrink.scrollLeft = 100000;
shrink.scrollTop = 100000;
};
const reset = () => {
// Check if element is hidden
if (initialHiddenCheck) {
if (!expand.scrollTop && !expand.scrollLeft) {
// reset
resetExpandShrink();
// Check in next frame
if (!resetRafId) {
resetRafId = requestAnimationFrame(() => {
resetRafId = 0;
reset();
});
}
return;
}
initialHiddenCheck = false;
}
resetExpandShrink();
};
resizeSensor.resetSensor = reset;
const onResized = () => {
rafId = 0;
if (!dirty) {
return;
}
lastWidth = size.width;
lastHeight = size.height;
if (element.resizedAttached) {
element.resizedAttached.call(size);
}
};
const onScroll = () => {
size = getElementSize(element);
dirty = size.width !== lastWidth || size.height !== lastHeight;
if (dirty && !rafId) {
rafId = requestAnimationFrame(onResized);
}
reset();
};
const addEvent = (elem, name, callback) => {
elem.addEventListener(name, callback);
};
addEvent(expand, 'scroll', onScroll);
addEvent(shrink, 'scroll', onScroll);
// Fix for custom Elements
requestAnimationFrame(reset);
} | @param {HTMLElement} element - element to listen resize.
@param {Function} resizeListener - resize event listener. | attachResizeEvent | javascript | nexxtway/react-rainbow | src/libs/ResizeSensor/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/libs/ResizeSensor/index.js | MIT |
resetExpandShrink = () => {
expandChild.style.width = '100000px';
expandChild.style.height = '100000px';
expand.scrollLeft = 100000;
expand.scrollTop = 100000;
shrink.scrollLeft = 100000;
shrink.scrollTop = 100000;
} | @param {HTMLElement} element - element to listen resize.
@param {Function} resizeListener - resize event listener. | resetExpandShrink | javascript | nexxtway/react-rainbow | src/libs/ResizeSensor/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/libs/ResizeSensor/index.js | MIT |
resetExpandShrink = () => {
expandChild.style.width = '100000px';
expandChild.style.height = '100000px';
expand.scrollLeft = 100000;
expand.scrollTop = 100000;
shrink.scrollLeft = 100000;
shrink.scrollTop = 100000;
} | @param {HTMLElement} element - element to listen resize.
@param {Function} resizeListener - resize event listener. | resetExpandShrink | javascript | nexxtway/react-rainbow | src/libs/ResizeSensor/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/libs/ResizeSensor/index.js | MIT |
reset = () => {
// Check if element is hidden
if (initialHiddenCheck) {
if (!expand.scrollTop && !expand.scrollLeft) {
// reset
resetExpandShrink();
// Check in next frame
if (!resetRafId) {
resetRafId = requestAnimationFrame(() => {
resetRafId = 0;
reset();
});
}
return;
}
initialHiddenCheck = false;
}
resetExpandShrink();
} | @param {HTMLElement} element - element to listen resize.
@param {Function} resizeListener - resize event listener. | reset | javascript | nexxtway/react-rainbow | src/libs/ResizeSensor/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/libs/ResizeSensor/index.js | MIT |
reset = () => {
// Check if element is hidden
if (initialHiddenCheck) {
if (!expand.scrollTop && !expand.scrollLeft) {
// reset
resetExpandShrink();
// Check in next frame
if (!resetRafId) {
resetRafId = requestAnimationFrame(() => {
resetRafId = 0;
reset();
});
}
return;
}
initialHiddenCheck = false;
}
resetExpandShrink();
} | @param {HTMLElement} element - element to listen resize.
@param {Function} resizeListener - resize event listener. | reset | javascript | nexxtway/react-rainbow | src/libs/ResizeSensor/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/libs/ResizeSensor/index.js | MIT |
onResized = () => {
rafId = 0;
if (!dirty) {
return;
}
lastWidth = size.width;
lastHeight = size.height;
if (element.resizedAttached) {
element.resizedAttached.call(size);
}
} | @param {HTMLElement} element - element to listen resize.
@param {Function} resizeListener - resize event listener. | onResized | javascript | nexxtway/react-rainbow | src/libs/ResizeSensor/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/libs/ResizeSensor/index.js | MIT |
onResized = () => {
rafId = 0;
if (!dirty) {
return;
}
lastWidth = size.width;
lastHeight = size.height;
if (element.resizedAttached) {
element.resizedAttached.call(size);
}
} | @param {HTMLElement} element - element to listen resize.
@param {Function} resizeListener - resize event listener. | onResized | javascript | nexxtway/react-rainbow | src/libs/ResizeSensor/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/libs/ResizeSensor/index.js | MIT |
onScroll = () => {
size = getElementSize(element);
dirty = size.width !== lastWidth || size.height !== lastHeight;
if (dirty && !rafId) {
rafId = requestAnimationFrame(onResized);
}
reset();
} | @param {HTMLElement} element - element to listen resize.
@param {Function} resizeListener - resize event listener. | onScroll | javascript | nexxtway/react-rainbow | src/libs/ResizeSensor/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/libs/ResizeSensor/index.js | MIT |
onScroll = () => {
size = getElementSize(element);
dirty = size.width !== lastWidth || size.height !== lastHeight;
if (dirty && !rafId) {
rafId = requestAnimationFrame(onResized);
}
reset();
} | @param {HTMLElement} element - element to listen resize.
@param {Function} resizeListener - resize event listener. | onScroll | javascript | nexxtway/react-rainbow | src/libs/ResizeSensor/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/libs/ResizeSensor/index.js | MIT |
addEvent = (elem, name, callback) => {
elem.addEventListener(name, callback);
} | @param {HTMLElement} element - element to listen resize.
@param {Function} resizeListener - resize event listener. | addEvent | javascript | nexxtway/react-rainbow | src/libs/ResizeSensor/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/libs/ResizeSensor/index.js | MIT |
addEvent = (elem, name, callback) => {
elem.addEventListener(name, callback);
} | @param {HTMLElement} element - element to listen resize.
@param {Function} resizeListener - resize event listener. | addEvent | javascript | nexxtway/react-rainbow | src/libs/ResizeSensor/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/libs/ResizeSensor/index.js | MIT |
function detach(elem, listener) {
if (!elem) {
return;
}
if (elem.resizedAttached && typeof listener === 'function') {
elem.resizedAttached.remove(listener);
if (elem.resizedAttached.length()) {
return;
}
}
if (elem.resizeSensor) {
if (elem.contains(elem.resizeSensor)) {
elem.removeChild(elem.resizeSensor);
}
delete elem.resizeSensor;
delete elem.resizedAttached;
}
} | @param {HTMLElement} element - element to listen resize.
@param {Function} resizeListener - resize event listener. | detach | javascript | nexxtway/react-rainbow | src/libs/ResizeSensor/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/libs/ResizeSensor/index.js | MIT |
constructor(element, resizeListener) {
this.targetElement = element;
this.resizeListener = resizeListener;
attachResizeEvent(this.targetElement, this.resizeListener);
} | @param {HTMLElement} element - element to listen resize.
@param {Function} resizeListener - resize event listener. | constructor | javascript | nexxtway/react-rainbow | src/libs/ResizeSensor/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/libs/ResizeSensor/index.js | MIT |
detach() {
detach(this.targetElement, this.resizeListener);
} | @param {HTMLElement} element - element to listen resize.
@param {Function} resizeListener - resize event listener. | detach | javascript | nexxtway/react-rainbow | src/libs/ResizeSensor/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/libs/ResizeSensor/index.js | MIT |
constructor(regexp, m) {
this._setDefaults(regexp);
if (regexp instanceof RegExp) {
this.ignoreCase = regexp.ignoreCase;
this.multiline = regexp.multiline;
regexp = regexp.source;
} else if (typeof regexp === 'string') {
this.ignoreCase = m && m.indexOf('i') !== -1;
this.multiline = m && m.indexOf('m') !== -1;
} else {
throw Error('Expected a regexp or string');
}
this.tokens = ret(regexp);
} | @constructor
@param {RegExp|string} regexp
@param {string} m | constructor | javascript | fent/randexp.js | lib/randexp.js | https://github.com/fent/randexp.js/blob/master/lib/randexp.js | MIT |
_setDefaults(regexp) {
// When a repetitional token has its max set to Infinite,
// randexp won't actually generate a random amount between min and Infinite
// instead it will see Infinite as min + 100.
this.max = regexp.max != null ? regexp.max :
RandExp.prototype.max != null ? RandExp.prototype.max : 100;
// This allows expanding to include additional characters
// for instance: RandExp.defaultRange.add(0, 65535);
this.defaultRange = regexp.defaultRange ?
regexp.defaultRange : this.defaultRange.clone();
if (regexp.randInt) {
this.randInt = regexp.randInt;
}
} | Checks if some custom properties have been set for this regexp.
@param {RandExp} randexp
@param {RegExp} regexp | _setDefaults | javascript | fent/randexp.js | lib/randexp.js | https://github.com/fent/randexp.js/blob/master/lib/randexp.js | MIT |
gen() {
return this._gen(this.tokens, []);
} | Generates the random string.
@return {string} | gen | javascript | fent/randexp.js | lib/randexp.js | https://github.com/fent/randexp.js/blob/master/lib/randexp.js | MIT |
_gen(token, groups) {
let stack, str, n, i, l, code, expandedSet;
switch (token.type) {
case types.ROOT:
case types.GROUP:
// Ignore lookaheads for now.
if (token.followedBy || token.notFollowedBy) { return ''; }
// Insert placeholder until group string is generated.
if (token.remember && token.groupNumber === undefined) {
token.groupNumber = groups.push(null) - 1;
}
stack = token.options ?
this._randSelect(token.options) : token.stack;
str = '';
for (i = 0, l = stack.length; i < l; i++) {
str += this._gen(stack[i], groups);
}
if (token.remember) {
groups[token.groupNumber] = str;
}
return str;
case types.POSITION:
// Do nothing for now.
return '';
case types.SET:
expandedSet = this._expand(token);
if (!expandedSet.length) { return ''; }
return String.fromCharCode(this._randSelect(expandedSet));
case types.REPETITION:
// Randomly generate number between min and max.
n = this.randInt(token.min,
token.max === Infinity ? token.min + this.max : token.max);
str = '';
for (i = 0; i < n; i++) {
str += this._gen(token.value, groups);
}
return str;
case types.REFERENCE:
return groups[token.value - 1] || '';
case types.CHAR:
code = this.ignoreCase && this._randBool() ?
this._toOtherCase(token.value) : token.value;
return String.fromCharCode(code);
}
} | Generate random string modeled after given tokens.
@param {Object} token
@param {Array.<string>} groups
@return {string} | _gen | javascript | fent/randexp.js | lib/randexp.js | https://github.com/fent/randexp.js/blob/master/lib/randexp.js | MIT |
_toOtherCase(code) {
return code + (97 <= code && code <= 122 ? -32 :
65 <= code && code <= 90 ? 32 : 0);
} | If code is alphabetic, converts to other case.
If not alphabetic, returns back code.
@param {number} code
@return {number} | _toOtherCase | javascript | fent/randexp.js | lib/randexp.js | https://github.com/fent/randexp.js/blob/master/lib/randexp.js | MIT |
_randBool() {
return !this.randInt(0, 1);
} | Randomly returns a true or false value.
@return {boolean} | _randBool | javascript | fent/randexp.js | lib/randexp.js | https://github.com/fent/randexp.js/blob/master/lib/randexp.js | MIT |
_randSelect(arr) {
if (arr instanceof DRange) {
return arr.index(this.randInt(0, arr.length - 1));
}
return arr[this.randInt(0, arr.length - 1)];
} | Randomly selects and returns a value from the array.
@param {Array.<Object>} arr
@return {Object} | _randSelect | javascript | fent/randexp.js | lib/randexp.js | https://github.com/fent/randexp.js/blob/master/lib/randexp.js | MIT |
_expand(token) {
if (token.type === ret.types.CHAR) {
return new DRange(token.value);
} else if (token.type === ret.types.RANGE) {
return new DRange(token.from, token.to);
} else {
let drange = new DRange();
for (let i = 0; i < token.set.length; i++) {
let subrange = this._expand(token.set[i]);
drange.add(subrange);
if (this.ignoreCase) {
for (let j = 0; j < subrange.length; j++) {
let code = subrange.index(j);
let otherCaseCode = this._toOtherCase(code);
if (code !== otherCaseCode) {
drange.add(otherCaseCode);
}
}
}
}
if (token.not) {
return this.defaultRange.clone().subtract(drange);
} else {
return this.defaultRange.clone().intersect(drange);
}
}
} | Expands a token to a DiscontinuousRange of characters which has a
length and an index function (for random selecting).
@param {Object} token
@return {DiscontinuousRange} | _expand | javascript | fent/randexp.js | lib/randexp.js | https://github.com/fent/randexp.js/blob/master/lib/randexp.js | MIT |
randInt(a, b) {
return a + Math.floor(Math.random() * (1 + b - a));
} | Randomly generates and returns a number between a and b (inclusive).
@param {number} a
@param {number} b
@return {number} | randInt | javascript | fent/randexp.js | lib/randexp.js | https://github.com/fent/randexp.js/blob/master/lib/randexp.js | MIT |
get defaultRange() {
return this._range = this._range || new DRange(32, 126);
} | Default range of characters to generate from. | defaultRange | javascript | fent/randexp.js | lib/randexp.js | https://github.com/fent/randexp.js/blob/master/lib/randexp.js | MIT |
set defaultRange(range) {
this._range = range;
} | Default range of characters to generate from. | defaultRange | javascript | fent/randexp.js | lib/randexp.js | https://github.com/fent/randexp.js/blob/master/lib/randexp.js | MIT |
static randexp(regexp, m) {
let randexp;
if(typeof regexp === 'string') {
regexp = new RegExp(regexp, m);
}
if (regexp._randexp === undefined) {
randexp = new RandExp(regexp, m);
regexp._randexp = randexp;
} else {
randexp = regexp._randexp;
randexp._setDefaults(regexp);
}
return randexp.gen();
} | Enables use of randexp with a shorter call.
@param {RegExp|string| regexp}
@param {string} m
@return {string} | randexp | javascript | fent/randexp.js | lib/randexp.js | https://github.com/fent/randexp.js/blob/master/lib/randexp.js | MIT |
setWindowOptions = function () {
for (const key in options) {
if (typeof window !== 'undefined' &&
typeof window.texme !== 'undefined' &&
typeof window.texme[key] !== 'undefined') {
options[key] = window.texme[key]
}
}
} | Read configuration options specified in `window.texme` and
configure TeXMe.
@memberof inner | setWindowOptions | javascript | susam/texme | texme.js | https://github.com/susam/texme/blob/master/texme.js | MIT |
setWindowOptions = function () {
for (const key in options) {
if (typeof window !== 'undefined' &&
typeof window.texme !== 'undefined' &&
typeof window.texme[key] !== 'undefined') {
options[key] = window.texme[key]
}
}
} | Read configuration options specified in `window.texme` and
configure TeXMe.
@memberof inner | setWindowOptions | javascript | susam/texme | texme.js | https://github.com/susam/texme/blob/master/texme.js | MIT |
loadjs = function (url, callback) {
const script = window.document.createElement('script')
script.src = url
script.onload = callback
window.document.head.appendChild(script)
} | Load JS in browser environment.
@param {string} url - URL of JavaScript file.
@param {function} callback - Callback to invoke after script loads.
@memberof inner | loadjs | javascript | susam/texme | texme.js | https://github.com/susam/texme/blob/master/texme.js | MIT |
loadjs = function (url, callback) {
const script = window.document.createElement('script')
script.src = url
script.onload = callback
window.document.head.appendChild(script)
} | Load JS in browser environment.
@param {string} url - URL of JavaScript file.
@param {function} callback - Callback to invoke after script loads.
@memberof inner | loadjs | javascript | susam/texme | texme.js | https://github.com/susam/texme/blob/master/texme.js | MIT |
function highlight(node) {
if (node.nodeType == 3) {
var val = node.nodeValue;
var pos = val.toLowerCase().indexOf(text);
if (pos >= 0 && !jQuery(node.parentNode).hasClass(className)) {
var span = document.createElement("span");
span.className = className;
span.appendChild(document.createTextNode(val.substr(pos, text.length)));
node.parentNode.insertBefore(span, node.parentNode.insertBefore(
document.createTextNode(val.substr(pos + text.length)),
node.nextSibling));
node.nodeValue = val.substr(0, pos);
}
}
else if (!jQuery(node).is("button, select, textarea")) {
jQuery.each(node.childNodes, function() {
highlight(this);
});
}
} | highlight a given string on a jquery object by wrapping it in
span elements with the given class name. | highlight | javascript | stitchfix/pyxley | docs/_build/html/_static/doctools.js | https://github.com/stitchfix/pyxley/blob/master/docs/_build/html/_static/doctools.js | MIT |
function markFunction( fn ) {
fn[ expando ] = true;
return fn;
} | Mark a function for special use by Sizzle
@param {Function} fn The function to mark | markFunction | javascript | stitchfix/pyxley | docs/_build/html/_static/jquery-1.11.1.js | https://github.com/stitchfix/pyxley/blob/master/docs/_build/html/_static/jquery-1.11.1.js | MIT |
function assert( fn ) {
var div = document.createElement("div");
try {
return !!fn( div );
} catch (e) {
return false;
} finally {
// Remove from its parent by default
if ( div.parentNode ) {
div.parentNode.removeChild( div );
}
// release memory in IE
div = null;
}
} | Support testing using an element
@param {Function} fn Passed the created div and expects a boolean result | assert | javascript | stitchfix/pyxley | docs/_build/html/_static/jquery-1.11.1.js | https://github.com/stitchfix/pyxley/blob/master/docs/_build/html/_static/jquery-1.11.1.js | MIT |
function addHandle( attrs, handler ) {
var arr = attrs.split("|"),
i = attrs.length;
while ( i-- ) {
Expr.attrHandle[ arr[i] ] = handler;
}
} | Adds the same handler for all of the specified attrs
@param {String} attrs Pipe-separated list of attributes
@param {Function} handler The method that will be applied | addHandle | javascript | stitchfix/pyxley | docs/_build/html/_static/jquery-1.11.1.js | https://github.com/stitchfix/pyxley/blob/master/docs/_build/html/_static/jquery-1.11.1.js | MIT |
function siblingCheck( a, b ) {
var cur = b && a,
diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
( ~b.sourceIndex || MAX_NEGATIVE ) -
( ~a.sourceIndex || MAX_NEGATIVE );
// Use IE sourceIndex if available on both nodes
if ( diff ) {
return diff;
}
// Check if b follows a
if ( cur ) {
while ( (cur = cur.nextSibling) ) {
if ( cur === b ) {
return -1;
}
}
}
return a ? 1 : -1;
} | Checks document order of two siblings
@param {Element} a
@param {Element} b
@returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b | siblingCheck | javascript | stitchfix/pyxley | docs/_build/html/_static/jquery-1.11.1.js | https://github.com/stitchfix/pyxley/blob/master/docs/_build/html/_static/jquery-1.11.1.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.