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
setRef = ref => { this.setRef(ref, _props.key) element.ref && element.ref(ref) }
Normalize a transition hook's argument length. The hook may be: - a merged hook (invoker) with the original in .fns - a wrapped component method (check ._length) - a plain function (.length)
setRef
javascript
GeekyAnts/vue-native-core
src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
MIT
setRef = ref => { this.setRef(ref, _props.key) element.ref && element.ref(ref) }
Normalize a transition hook's argument length. The hook may be: - a merged hook (invoker) with the original in .fns - a wrapped component method (check ._length) - a plain function (.length)
setRef
javascript
GeekyAnts/vue-native-core
src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
MIT
triggerTransitionExp() { const tagKey = this.state.tagKey const transition = this.state.transObj[tagKey] // someone want to hide and his prev state is show if (transition) { const transObj = {} transObj[tagKey] = Object.assign({}, transition, { exp: !transition.exp, }) return { animated: true, transObj: transObj, tagKey: tagKey, } } }
Normalize a transition hook's argument length. The hook may be: - a merged hook (invoker) with the original in .fns - a wrapped component method (check ._length) - a plain function (.length)
triggerTransitionExp
javascript
GeekyAnts/vue-native-core
src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
MIT
UNSAFE_componentWillMount() { this.transitionResolved = resolveTransition(this.props) this.isAppear = true const state = this.resolveData(this.props) state && this.setState(state) }
Normalize a transition hook's argument length. The hook may be: - a merged hook (invoker) with the original in .fns - a wrapped component method (check ._length) - a plain function (.length)
UNSAFE_componentWillMount
javascript
GeekyAnts/vue-native-core
src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
MIT
componentDidMount() { this.resolveEnterTransition({ el: this._refs[this.state.tagKey], }) }
Normalize a transition hook's argument length. The hook may be: - a merged hook (invoker) with the original in .fns - a wrapped component method (check ._length) - a plain function (.length)
componentDidMount
javascript
GeekyAnts/vue-native-core
src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
MIT
UNSAFE_componentWillReceiveProps(nextProps) { this.transitionResolved = resolveTransition(nextProps) this.isAppear = false const nextState = this.resolveData(nextProps, 'update') this._shouldComponentUpdateTransitionResult = nextState ? this._shouldComponentUpdateTransition(nextProps, nextState) : true Object.keys(this._refs).forEach(k => { const el = this._refs[k] if (isDef(el._leaveCb)) { el._leaveCb.cancelled = true el._leaveCb() } if (isDef(el._enterCb)) { el._enterCb.cancelled = true el._enterCb() } }) nextState && this.setState(nextState) }
Normalize a transition hook's argument length. The hook may be: - a merged hook (invoker) with the original in .fns - a wrapped component method (check ._length) - a plain function (.length)
UNSAFE_componentWillReceiveProps
javascript
GeekyAnts/vue-native-core
src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
MIT
_shouldComponentUpdateTransition(nextProps, nextState) { if ( Object.keys(nextState.transObj).length !== Object.keys(this.state.transObj).length ) { return true } if (nextState.tagKey === this.state.tagKey) { const nextTransition = nextState.transObj[nextState.tagKey] const transition = this.state.transObj[this.state.tagKey] if (nextTransition && transition) { return transition.exp !== nextTransition.exp } } return true }
Normalize a transition hook's argument length. The hook may be: - a merged hook (invoker) with the original in .fns - a wrapped component method (check ._length) - a plain function (.length)
_shouldComponentUpdateTransition
javascript
GeekyAnts/vue-native-core
src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
MIT
resolveEnterTransition(option) { enter.call(this, option) }
Normalize a transition hook's argument length. The hook may be: - a merged hook (invoker) with the original in .fns - a wrapped component method (check ._length) - a plain function (.length)
resolveEnterTransition
javascript
GeekyAnts/vue-native-core
src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
MIT
resolveLeaveTransition(option) { leave.call(this, option) }
Normalize a transition hook's argument length. The hook may be: - a merged hook (invoker) with the original in .fns - a wrapped component method (check ._length) - a plain function (.length)
resolveLeaveTransition
javascript
GeekyAnts/vue-native-core
src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
MIT
componentDidUpdate(prevProps, prevState) { if ( this.state.animated === false || this._shouldComponentUpdateTransition === false ) { return } if (this.state.tagKey === prevState.tagKey) { // same element const ref = this._refs[this.state.tagKey] const transition = this.state.transObj[this.state.tagKey] if (ref && transition) { if (transition.type === 'show') { if (transition.exp === false) { this.resolveLeaveTransition({ el: ref, cb: () => { ref.style.display = 'none' }, }) } else if (transition.exp === true) { ref.style.display = '' this.resolveEnterTransition({ el: ref, }) } } else if (transition.type === 'if') { if (transition.exp === false) { const transObj = Object.assign({}, this.state.transObj) delete transObj[prevState.tagKey] this.resolveLeaveTransition({ el: ref, cb: () => { this.setState({ transObj: transObj, animated: false, }) }, }) } else if (transition.exp === true) { this.resolveEnterTransition({ el: ref, }) } } } } else { const enterRef = this._refs[this.state.tagKey] const leaveRef = this._refs[prevState.tagKey] const transObj = Object.assign({}, this.state.transObj) delete transObj[prevState.tagKey] this.resolveEnterTransition({ el: enterRef, }) this.resolveLeaveTransition({ el: leaveRef, cb: () => { this.setState({ transObj: transObj, animated: false, }) }, }) } }
Normalize a transition hook's argument length. The hook may be: - a merged hook (invoker) with the original in .fns - a wrapped component method (check ._length) - a plain function (.length)
componentDidUpdate
javascript
GeekyAnts/vue-native-core
src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
MIT
render() { const transObj = this.state.transObj const tag = this.props.tag || 'null' return createElement( tag, null, Object.keys(transObj).map(k => { const type = transObj[k].element.type const props = transObj[k].props const children = props.children return createElement(type, props, children) }), ) }
Normalize a transition hook's argument length. The hook may be: - a merged hook (invoker) with the original in .fns - a wrapped component method (check ._length) - a plain function (.length)
render
javascript
GeekyAnts/vue-native-core
src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/vue-native/runtime/render-helpers/transitionWeb.js
MIT
function addClass(el: HTMLElement, cls: ?string) { /* istanbul ignore if */ if (!cls || !(cls = cls.trim())) { return } /* istanbul ignore else */ if (el.classList) { if (cls.indexOf(' ') > -1) { cls.split(/\s+/).forEach(c => el.classList.add(c)) } else { el.classList.add(cls) } } else { const cur = ` ${el.getAttribute('class') || ''} ` if (cur.indexOf(' ' + cls + ' ') < 0) { el.setAttribute('class', (cur + cls).trim()) } } }
Add class with compatibility for SVG since classList is not supported on SVG elements in IE
addClass
javascript
GeekyAnts/vue-native-core
src/platforms/web/runtime/class-util.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/web/runtime/class-util.js
MIT
function removeClass(el: HTMLElement, cls: ?string) { /* istanbul ignore if */ if (!cls || !(cls = cls.trim())) { return } /* istanbul ignore else */ if (el.classList) { if (cls.indexOf(' ') > -1) { cls.split(/\s+/).forEach(c => el.classList.remove(c)) } else { el.classList.remove(cls) } } else { let cur = ` ${el.getAttribute('class') || ''} ` const tar = ' ' + cls + ' ' while (cur.indexOf(tar) >= 0) { cur = cur.replace(tar, ' ') } el.setAttribute('class', cur.trim()) } }
Remove class with compatibility for SVG since classList is not supported on SVG elements in IE
removeClass
javascript
GeekyAnts/vue-native-core
src/platforms/web/runtime/class-util.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/web/runtime/class-util.js
MIT
inserted(el, binding, vnode) { if (vnode.tag === 'select') { const cb = () => { setSelected(el, binding, vnode.context) } cb() /* istanbul ignore if */ if (isIE || isEdge) { setTimeout(cb, 0) } } else if ( vnode.tag === 'textarea' || el.type === 'text' || el.type === 'password' ) { el._vModifiers = binding.modifiers if (!binding.modifiers.lazy) { // Safari < 10.2 & UIWebView doesn't fire compositionend when // switching focus before confirming composition choice // this also fixes the issue where some browsers e.g. iOS Chrome // fires "change" instead of "input" on autocomplete. el.addEventListener('change', onCompositionEnd) if (!isAndroid) { el.addEventListener('compositionstart', onCompositionStart) el.addEventListener('compositionend', onCompositionEnd) } /* istanbul ignore if */ if (isIE9) { el.vmodel = true } } } }
Not type checking this file because flow doesn't like attaching properties to Elements.
inserted
javascript
GeekyAnts/vue-native-core
src/platforms/web/runtime/directives/model.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/web/runtime/directives/model.js
MIT
cb = () => { setSelected(el, binding, vnode.context) }
Not type checking this file because flow doesn't like attaching properties to Elements.
cb
javascript
GeekyAnts/vue-native-core
src/platforms/web/runtime/directives/model.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/web/runtime/directives/model.js
MIT
cb = () => { setSelected(el, binding, vnode.context) }
Not type checking this file because flow doesn't like attaching properties to Elements.
cb
javascript
GeekyAnts/vue-native-core
src/platforms/web/runtime/directives/model.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/web/runtime/directives/model.js
MIT
componentUpdated(el, binding, vnode) { if (vnode.tag === 'select') { setSelected(el, binding, vnode.context) // in case the options rendered by v-for have changed, // it's possible that the value is out-of-sync with the rendered options. // detect such cases and filter out values that no longer has a matching // option in the DOM. const needReset = el.multiple ? binding.value.some(v => hasNoMatchingOption(v, el.options)) : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, el.options) if (needReset) { trigger(el, 'change') } } }
Not type checking this file because flow doesn't like attaching properties to Elements.
componentUpdated
javascript
GeekyAnts/vue-native-core
src/platforms/web/runtime/directives/model.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/web/runtime/directives/model.js
MIT
function setSelected(el, binding, vm) { const value = binding.value const isMultiple = el.multiple if (isMultiple && !Array.isArray(value)) { process.env.NODE_ENV !== 'production' && warn( `<select multiple v-model="${binding.expression}"> ` + `expects an Array value for its binding, but got ${Object.prototype.toString .call(value) .slice(8, -1)}`, vm, ) return } let selected, option for (let i = 0, l = el.options.length; i < l; i++) { option = el.options[i] if (isMultiple) { selected = looseIndexOf(value, getValue(option)) > -1 if (option.selected !== selected) { option.selected = selected } } else { if (looseEqual(getValue(option), value)) { if (el.selectedIndex !== i) { el.selectedIndex = i } return } } } if (!isMultiple) { el.selectedIndex = -1 } }
Not type checking this file because flow doesn't like attaching properties to Elements.
setSelected
javascript
GeekyAnts/vue-native-core
src/platforms/web/runtime/directives/model.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/web/runtime/directives/model.js
MIT
function hasNoMatchingOption(value, options) { for (let i = 0, l = options.length; i < l; i++) { if (looseEqual(getValue(options[i]), value)) { return false } } return true }
Not type checking this file because flow doesn't like attaching properties to Elements.
hasNoMatchingOption
javascript
GeekyAnts/vue-native-core
src/platforms/web/runtime/directives/model.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/web/runtime/directives/model.js
MIT
function getValue(option) { return '_value' in option ? option._value : option.value }
Not type checking this file because flow doesn't like attaching properties to Elements.
getValue
javascript
GeekyAnts/vue-native-core
src/platforms/web/runtime/directives/model.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/web/runtime/directives/model.js
MIT
function onCompositionStart(e) { e.target.composing = true }
Not type checking this file because flow doesn't like attaching properties to Elements.
onCompositionStart
javascript
GeekyAnts/vue-native-core
src/platforms/web/runtime/directives/model.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/web/runtime/directives/model.js
MIT
function onCompositionEnd(e) { e.target.composing = false trigger(e.target, 'input') }
Not type checking this file because flow doesn't like attaching properties to Elements.
onCompositionEnd
javascript
GeekyAnts/vue-native-core
src/platforms/web/runtime/directives/model.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/web/runtime/directives/model.js
MIT
function trigger(el, type) { const e = document.createEvent('HTMLEvents') e.initEvent(type, true, true) el.dispatchEvent(e) }
Not type checking this file because flow doesn't like attaching properties to Elements.
trigger
javascript
GeekyAnts/vue-native-core
src/platforms/web/runtime/directives/model.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/web/runtime/directives/model.js
MIT
function getHookArgumentsLength(fn: Function): boolean { if (isUndef(fn)) { return false } const invokerFns = fn.fns if (isDef(invokerFns)) { // invoker return getHookArgumentsLength( Array.isArray(invokerFns) ? invokerFns[0] : invokerFns, ) } else { return (fn._length || fn.length) > 1 } }
Normalize a transition hook's argument length. The hook may be: - a merged hook (invoker) with the original in .fns - a wrapped component method (check ._length) - a plain function (.length)
getHookArgumentsLength
javascript
GeekyAnts/vue-native-core
src/platforms/web/runtime/modules/transition.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/web/runtime/modules/transition.js
MIT
function _enter(_: any, vnode: VNodeWithData) { if (vnode.data.show !== true) { enter(vnode) } }
Normalize a transition hook's argument length. The hook may be: - a merged hook (invoker) with the original in .fns - a wrapped component method (check ._length) - a plain function (.length)
_enter
javascript
GeekyAnts/vue-native-core
src/platforms/web/runtime/modules/transition.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/web/runtime/modules/transition.js
MIT
if (vnode.data.show !== true) { leave(vnode, rm) }
Normalize a transition hook's argument length. The hook may be: - a merged hook (invoker) with the original in .fns - a wrapped component method (check ._length) - a plain function (.length)
if
javascript
GeekyAnts/vue-native-core
src/platforms/web/runtime/modules/transition.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/web/runtime/modules/transition.js
MIT
if (typeof el === 'string') { const selected = document.querySelector(el) if (!selected) { process.env.NODE_ENV !== 'production' && warn('Cannot find element: ' + el) return document.createElement('div') } return selected }
Query an element selector if it's not an element already.
if
javascript
GeekyAnts/vue-native-core
src/platforms/web/util/index.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/web/util/index.js
MIT
function getStyle(vnode: VNode, checkChild: boolean): Object { const res = {} let styleData if (checkChild) { let childNode = vnode while (childNode.componentInstance) { childNode = childNode.componentInstance._vnode if (childNode.data && (styleData = normalizeStyleData(childNode.data))) { extend(res, styleData) } } } if ((styleData = normalizeStyleData(vnode.data))) { extend(res, styleData) } let parentNode = vnode while ((parentNode = parentNode.parent)) { if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) { extend(res, styleData) } } return res }
parent component style should be after child's so that parent component's style could override it
getStyle
javascript
GeekyAnts/vue-native-core
src/platforms/web/util/style.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/platforms/web/util/style.js
MIT
function parseComponent( content: string, options?: Object = {}, ): SFCDescriptor { const sfc: SFCDescriptor = { template: null, script: null, styles: [], customBlocks: [], } let depth = 0 let currentBlock: ?(SFCBlock | SFCCustomBlock) = null function start( tag: string, attrs: Array<Attribute>, unary: boolean, start: number, end: number, ) { if (depth === 0) { currentBlock = { type: tag, content: '', start: end, attrs: attrs.reduce((cumulated, { name, value }) => { cumulated[name] = value || true return cumulated }, Object.create(null)), } if (isSpecialTag(tag)) { checkAttrs(currentBlock, attrs) if (tag === 'style') { sfc.styles.push(currentBlock) } else { sfc[tag] = currentBlock } } else { // custom blocks sfc.customBlocks.push(currentBlock) } } if (!unary) { depth++ } } function checkAttrs(block: SFCBlock, attrs: Array<Attribute>) { for (let i = 0; i < attrs.length; i++) { const attr = attrs[i] if (attr.name === 'lang') { block.lang = attr.value } if (attr.name === 'scoped') { block.scoped = true } if (attr.name === 'module') { block.module = attr.value || true } if (attr.name === 'src') { block.src = attr.value } } } // eslint-disable-next-line no-unused-vars function end(tag: string, start: number, end: number) { if (depth === 1 && currentBlock) { currentBlock.end = start let text = deindent(content.slice(currentBlock.start, currentBlock.end)) // pad content so that linters and pre-processors can output correct // line numbers in errors and warnings if (currentBlock.type !== 'template' && options.pad) { text = padContent(currentBlock, options.pad) + text } currentBlock.content = text currentBlock = null } depth-- } function padContent( block: SFCBlock | SFCCustomBlock, pad: true | 'line' | 'space', ) { if (pad === 'space') { return content.slice(0, block.start).replace(replaceRE, ' ') } else { const offset = content.slice(0, block.start).split(splitRE).length const padChar = block.type === 'script' && !block.lang ? '//\n' : '\n' return Array(offset).join(padChar) } } parseHTML(content, { start, end, }) return sfc }
Parse a single-file component (*.vue) file into an SFC Descriptor Object.
parseComponent
javascript
GeekyAnts/vue-native-core
src/sfc/parser.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/sfc/parser.js
MIT
function start( tag: string, attrs: Array<Attribute>, unary: boolean, start: number, end: number, ) { if (depth === 0) { currentBlock = { type: tag, content: '', start: end, attrs: attrs.reduce((cumulated, { name, value }) => { cumulated[name] = value || true return cumulated }, Object.create(null)), } if (isSpecialTag(tag)) { checkAttrs(currentBlock, attrs) if (tag === 'style') { sfc.styles.push(currentBlock) } else { sfc[tag] = currentBlock } } else { // custom blocks sfc.customBlocks.push(currentBlock) } } if (!unary) { depth++ } }
Parse a single-file component (*.vue) file into an SFC Descriptor Object.
start
javascript
GeekyAnts/vue-native-core
src/sfc/parser.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/sfc/parser.js
MIT
function checkAttrs(block: SFCBlock, attrs: Array<Attribute>) { for (let i = 0; i < attrs.length; i++) { const attr = attrs[i] if (attr.name === 'lang') { block.lang = attr.value } if (attr.name === 'scoped') { block.scoped = true } if (attr.name === 'module') { block.module = attr.value || true } if (attr.name === 'src') { block.src = attr.value } } }
Parse a single-file component (*.vue) file into an SFC Descriptor Object.
checkAttrs
javascript
GeekyAnts/vue-native-core
src/sfc/parser.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/sfc/parser.js
MIT
function end(tag: string, start: number, end: number) { if (depth === 1 && currentBlock) { currentBlock.end = start let text = deindent(content.slice(currentBlock.start, currentBlock.end)) // pad content so that linters and pre-processors can output correct // line numbers in errors and warnings if (currentBlock.type !== 'template' && options.pad) { text = padContent(currentBlock, options.pad) + text } currentBlock.content = text currentBlock = null } depth-- }
Parse a single-file component (*.vue) file into an SFC Descriptor Object.
end
javascript
GeekyAnts/vue-native-core
src/sfc/parser.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/sfc/parser.js
MIT
function padContent( block: SFCBlock | SFCCustomBlock, pad: true | 'line' | 'space', ) { if (pad === 'space') { return content.slice(0, block.start).replace(replaceRE, ' ') } else { const offset = content.slice(0, block.start).split(splitRE).length const padChar = block.type === 'script' && !block.lang ? '//\n' : '\n' return Array(offset).join(padChar) } }
Parse a single-file component (*.vue) file into an SFC Descriptor Object.
padContent
javascript
GeekyAnts/vue-native-core
src/sfc/parser.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/sfc/parser.js
MIT
function isPlainObject(obj: any): boolean { return toString.call(obj) === OBJECT_STRING }
Strict object type check. Only returns true for plain JavaScript objects.
isPlainObject
javascript
GeekyAnts/vue-native-core
src/shared/util.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/shared/util.js
MIT
function _toString(val: any): string { return val == null ? '' : typeof val === 'object' ? JSON.stringify(val, null, 2) : String(val) }
Convert a value to a string that is actually rendered.
_toString
javascript
GeekyAnts/vue-native-core
src/shared/util.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/shared/util.js
MIT
if (arr.length) { const index = arr.indexOf(item) if (index > -1) { return arr.splice(index, 1) } }
Remove an item from an array
if
javascript
GeekyAnts/vue-native-core
src/shared/util.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/shared/util.js
MIT
if (arr[i]) { extend(res, arr[i]) }
Merge an Array of Objects into a single Object.
if
javascript
GeekyAnts/vue-native-core
src/shared/util.js
https://github.com/GeekyAnts/vue-native-core/blob/master/src/shared/util.js
MIT
newQuery = function newQuery() { return { checks: [] }; }
Make a new query object @prop type {Type} The type enum (int) of the query @prop checks List of checks to make against an ele to test for a match
newQuery
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
stateSelectorMatches = function stateSelectorMatches(sel, ele) { return lookup[sel](ele); }
Always matches, useful placeholder for subject in `COMPOUND_SPLIT`
stateSelectorMatches
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
cleanMetaChars = function cleanMetaChars(str) { return str.replace(new RegExp('\\\\(' + tokens.metaChar + ')', 'g'), function (match, $1) { return $1; }); }
Always matches, useful placeholder for subject in `COMPOUND_SPLIT`
cleanMetaChars
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
replaceLastQuery = function replaceLastQuery(selector, examiningQuery, replacementQuery) { selector[selector.length - 1] = replacementQuery; }
Always matches, useful placeholder for subject in `COMPOUND_SPLIT`
replaceLastQuery
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
consumeExpr = function consumeExpr(remaining) { var expr; var match; var name; for (var j = 0; j < exprs.length; j++) { var e = exprs[j]; var n = e.name; var m = remaining.match(e.regexObj); if (m != null) { match = m; expr = e; name = n; var consumed = m[0]; remaining = remaining.substring(consumed.length); break; // we've consumed one expr, so we can return now } } return { expr: expr, match: match, name: name, remaining: remaining }; }
Of all the expressions, find the first match in the remaining text. @param {string} remaining The remaining text to parse @returns The matched expression and the newly remaining text `{ expr, match, name, remaining }`
consumeExpr
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
consumeWhitespace = function consumeWhitespace(remaining) { var match = remaining.match(/^\s+/); if (match) { var consumed = match[0]; remaining = remaining.substring(consumed.length); } return remaining; }
Consume all the leading whitespace @param {string} remaining The text to consume @returns The text with the leading whitespace removed
consumeWhitespace
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
parse = function parse(selector) { var self = this; var remaining = self.inputText = selector; var currentQuery = self[0] = newQuery(); self.length = 1; remaining = consumeWhitespace(remaining); // get rid of leading whitespace for (;;) { var exprInfo = consumeExpr(remaining); if (exprInfo.expr == null) { warn('The selector `' + selector + '`is invalid'); return false; } else { var args = exprInfo.match.slice(1); // let the token populate the selector object in currentQuery var ret = exprInfo.expr.populate(self, currentQuery, args); if (ret === false) { return false; // exit if population failed } else if (ret != null) { currentQuery = ret; // change the current query to be filled if the expr specifies } } remaining = exprInfo.remaining; // we're done when there's nothing left to parse if (remaining.match(/^\s*$/)) { break; } } var lastQ = self[self.length - 1]; if (self.currentSubject != null) { lastQ.subject = self.currentSubject; } lastQ.edgeCount = self.edgeCount; lastQ.compoundCount = self.compoundCount; for (var i = 0; i < self.length; i++) { var q = self[i]; // in future, this could potentially be allowed if there were operator precedence and detection of invalid combinations if (q.compoundCount > 0 && q.edgeCount > 0) { warn('The selector `' + selector + '` is invalid because it uses both a compound selector and an edge selector'); return false; } if (q.edgeCount > 1) { warn('The selector `' + selector + '` is invalid because it uses multiple edge selectors'); return false; } else if (q.edgeCount === 1) { warn('The selector `' + selector + '` is deprecated. Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons. Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.'); } } return true; // success }
Parse the string and store the parsed representation in the Selector. @param {string} selector The selector string @returns `true` if the selector was successfully parsed, `false` otherwise
parse
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
toString = function toString() { if (this.toStringCache != null) { return this.toStringCache; } var clean = function clean(obj) { if (obj == null) { return ''; } else { return obj; } }; var cleanVal = function cleanVal(val) { if (string(val)) { return '"' + val + '"'; } else { return clean(val); } }; var space = function space(val) { return ' ' + val + ' '; }; var checkToString = function checkToString(check, subject) { var type = check.type, value = check.value; switch (type) { case Type.GROUP: { var group = clean(value); return group.substring(0, group.length - 1); } case Type.DATA_COMPARE: { var field = check.field, operator = check.operator; return '[' + field + space(clean(operator)) + cleanVal(value) + ']'; } case Type.DATA_BOOL: { var _operator = check.operator, _field = check.field; return '[' + clean(_operator) + _field + ']'; } case Type.DATA_EXIST: { var _field2 = check.field; return '[' + _field2 + ']'; } case Type.META_COMPARE: { var _operator2 = check.operator, _field3 = check.field; return '[[' + _field3 + space(clean(_operator2)) + cleanVal(value) + ']]'; } case Type.STATE: { return value; } case Type.ID: { return '#' + value; } case Type.CLASS: { return '.' + value; } case Type.PARENT: case Type.CHILD: { return queryToString(check.parent, subject) + space('>') + queryToString(check.child, subject); } case Type.ANCESTOR: case Type.DESCENDANT: { return queryToString(check.ancestor, subject) + ' ' + queryToString(check.descendant, subject); } case Type.COMPOUND_SPLIT: { var lhs = queryToString(check.left, subject); var sub = queryToString(check.subject, subject); var rhs = queryToString(check.right, subject); return lhs + (lhs.length > 0 ? ' ' : '') + sub + rhs; } case Type.TRUE: { return ''; } } }; var queryToString = function queryToString(query, subject) { return query.checks.reduce(function (str, chk, i) { return str + (subject === query && i === 0 ? '$' : '') + checkToString(chk, subject); }, ''); }; var str = ''; for (var i = 0; i < this.length; i++) { var query = this[i]; str += queryToString(query, query.subject); if (this.length > 1 && i < this.length - 1) { str += ', '; } } this.toStringCache = str; return str; }
Get the selector represented as a string. This value uses default formatting, so things like spacing may differ from the input text passed to the constructor. @returns {string} The selector string
toString
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
clean = function clean(obj) { if (obj == null) { return ''; } else { return obj; } }
Get the selector represented as a string. This value uses default formatting, so things like spacing may differ from the input text passed to the constructor. @returns {string} The selector string
clean
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
cleanVal = function cleanVal(val) { if (string(val)) { return '"' + val + '"'; } else { return clean(val); } }
Get the selector represented as a string. This value uses default formatting, so things like spacing may differ from the input text passed to the constructor. @returns {string} The selector string
cleanVal
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
space = function space(val) { return ' ' + val + ' '; }
Get the selector represented as a string. This value uses default formatting, so things like spacing may differ from the input text passed to the constructor. @returns {string} The selector string
space
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
checkToString = function checkToString(check, subject) { var type = check.type, value = check.value; switch (type) { case Type.GROUP: { var group = clean(value); return group.substring(0, group.length - 1); } case Type.DATA_COMPARE: { var field = check.field, operator = check.operator; return '[' + field + space(clean(operator)) + cleanVal(value) + ']'; } case Type.DATA_BOOL: { var _operator = check.operator, _field = check.field; return '[' + clean(_operator) + _field + ']'; } case Type.DATA_EXIST: { var _field2 = check.field; return '[' + _field2 + ']'; } case Type.META_COMPARE: { var _operator2 = check.operator, _field3 = check.field; return '[[' + _field3 + space(clean(_operator2)) + cleanVal(value) + ']]'; } case Type.STATE: { return value; } case Type.ID: { return '#' + value; } case Type.CLASS: { return '.' + value; } case Type.PARENT: case Type.CHILD: { return queryToString(check.parent, subject) + space('>') + queryToString(check.child, subject); } case Type.ANCESTOR: case Type.DESCENDANT: { return queryToString(check.ancestor, subject) + ' ' + queryToString(check.descendant, subject); } case Type.COMPOUND_SPLIT: { var lhs = queryToString(check.left, subject); var sub = queryToString(check.subject, subject); var rhs = queryToString(check.right, subject); return lhs + (lhs.length > 0 ? ' ' : '') + sub + rhs; } case Type.TRUE: { return ''; } } }
Get the selector represented as a string. This value uses default formatting, so things like spacing may differ from the input text passed to the constructor. @returns {string} The selector string
checkToString
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
queryToString = function queryToString(query, subject) { return query.checks.reduce(function (str, chk, i) { return str + (subject === query && i === 0 ? '$' : '') + checkToString(chk, subject); }, ''); }
Get the selector represented as a string. This value uses default formatting, so things like spacing may differ from the input text passed to the constructor. @returns {string} The selector string
queryToString
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
valCmp = function valCmp(fieldVal, operator, value) { var matches; var isFieldStr = string(fieldVal); var isFieldNum = number(fieldVal); var isValStr = string(value); var fieldStr, valStr; var caseInsensitive = false; var notExpr = false; var isIneqCmp = false; if (operator.indexOf('!') >= 0) { operator = operator.replace('!', ''); notExpr = true; } if (operator.indexOf('@') >= 0) { operator = operator.replace('@', ''); caseInsensitive = true; } if (isFieldStr || isValStr || caseInsensitive) { fieldStr = !isFieldStr && !isFieldNum ? '' : '' + fieldVal; valStr = '' + value; } // if we're doing a case insensitive comparison, then we're using a STRING comparison // even if we're comparing numbers if (caseInsensitive) { fieldVal = fieldStr = fieldStr.toLowerCase(); value = valStr = valStr.toLowerCase(); } switch (operator) { case '*=': matches = fieldStr.indexOf(valStr) >= 0; break; case '$=': matches = fieldStr.indexOf(valStr, fieldStr.length - valStr.length) >= 0; break; case '^=': matches = fieldStr.indexOf(valStr) === 0; break; case '=': matches = fieldVal === value; break; case '>': isIneqCmp = true; matches = fieldVal > value; break; case '>=': isIneqCmp = true; matches = fieldVal >= value; break; case '<': isIneqCmp = true; matches = fieldVal < value; break; case '<=': isIneqCmp = true; matches = fieldVal <= value; break; default: matches = false; break; } // apply the not op, but null vals for inequalities should always stay non-matching if (notExpr && (fieldVal != null || !isIneqCmp)) { matches = !matches; } return matches; }
Get the selector represented as a string. This value uses default formatting, so things like spacing may differ from the input text passed to the constructor. @returns {string} The selector string
valCmp
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
boolCmp = function boolCmp(fieldVal, operator) { switch (operator) { case '?': return fieldVal ? true : false; case '!': return fieldVal ? false : true; case '^': return fieldVal === undefined; } }
Get the selector represented as a string. This value uses default formatting, so things like spacing may differ from the input text passed to the constructor. @returns {string} The selector string
boolCmp
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
existCmp = function existCmp(fieldVal) { return fieldVal !== undefined; }
Get the selector represented as a string. This value uses default formatting, so things like spacing may differ from the input text passed to the constructor. @returns {string} The selector string
existCmp
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
data = function data(ele, field) { return ele.data(field); }
Get the selector represented as a string. This value uses default formatting, so things like spacing may differ from the input text passed to the constructor. @returns {string} The selector string
data
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
meta = function meta(ele, field) { return ele[field](); }
Get the selector represented as a string. This value uses default formatting, so things like spacing may differ from the input text passed to the constructor. @returns {string} The selector string
meta
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
matches = function matches(query, ele) { return query.checks.every(function (chk) { return match[chk.type](chk, ele); }); }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
matches
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
filter = function filter(collection) { var self = this; // for 1 id #foo queries, just get the element if (self.length === 1 && self[0].checks.length === 1 && self[0].checks[0].type === Type.ID) { return collection.getElementById(self[0].checks[0].value).collection(); } var selectorFunction = function selectorFunction(element) { for (var j = 0; j < self.length; j++) { var query = self[j]; if (matches(query, element)) { return true; } } return false; }; if (self.text() == null) { selectorFunction = function selectorFunction() { return true; }; } return collection.filter(selectorFunction); }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
filter
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
selectorFunction = function selectorFunction(element) { for (var j = 0; j < self.length; j++) { var query = self[j]; if (matches(query, element)) { return true; } } return false; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
selectorFunction
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
matches$1 = function matches$1(ele) { var self = this; for (var j = 0; j < self.length; j++) { var query = self[j]; if (matches(query, ele)) { return true; } } return false; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
matches$1
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
Selector = function Selector(selector) { this.inputText = selector; this.currentSubject = null; this.compoundCount = 0; this.edgeCount = 0; this.length = 0; if (selector == null || string(selector) && selector.match(/^\s*$/)) ; else if (elementOrCollection(selector)) { this.addQuery({ checks: [{ type: Type.COLLECTION, value: selector.collection() }] }); } else if (fn(selector)) { this.addQuery({ checks: [{ type: Type.FILTER, value: selector }] }); } else if (string(selector)) { if (!this.parse(selector)) { this.invalid = true; } } else { error('A selector must be created from a string; found '); } }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
Selector
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
cache = function cache(fn, name) { return function traversalCache(arg1, arg2, arg3, arg4) { var selectorOrEles = arg1; var eles = this; var key; if (selectorOrEles == null) { key = ''; } else if (elementOrCollection(selectorOrEles) && selectorOrEles.length === 1) { key = selectorOrEles.id(); } if (eles.length === 1 && key) { var _p = eles[0]._private; var tch = _p.traversalCache = _p.traversalCache || {}; var ch = tch[name] = tch[name] || []; var hash = hashString(key); var cacheHit = ch[hash]; if (cacheHit) { return cacheHit; } else { return ch[hash] = fn.call(eles, arg1, arg2, arg3, arg4); } } else { return fn.call(eles, arg1, arg2, arg3, arg4); } }; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
cache
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
function add(eles) { for (var i = 0; i < eles.length; i++) { var ele = eles[i]; elements.push(ele); if (ele.children().nonempty()) { add(ele.children()); } } }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
add
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
function forEachCompound(eles, fn, includeSelf, recursiveStep) { var q = []; var did = new Set$1(); var cy = eles.cy(); var hasCompounds = cy.hasCompoundNodes(); for (var i = 0; i < eles.length; i++) { var ele = eles[i]; if (includeSelf) { q.push(ele); } else if (hasCompounds) { recursiveStep(q, did, ele); } } while (q.length > 0) { var _ele = q.shift(); fn(_ele); did.add(_ele.id()); if (hasCompounds) { recursiveStep(q, did, _ele); } } return eles; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
forEachCompound
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
function addChildren(q, did, ele) { if (ele.isParent()) { var children = ele._private.children; for (var i = 0; i < children.length; i++) { var child = children[i]; if (!did.has(child.id())) { q.push(child); } } } } // very efficient version of eles.add( eles.descendants() ).forEach()
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
addChildren
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
function addParent(q, did, ele) { if (ele.isChild()) { var parent = ele._private.parent; if (!did.has(parent.id())) { q.push(parent); } } }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
addParent
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
function addParentAndChildren(q, did, ele) { addParent(q, did, ele); addChildren(q, did, ele); }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
addParentAndChildren
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
function defineDegreeFunction(callback) { return function (includeLoops) { var self = this; if (includeLoops === undefined) { includeLoops = true; } if (self.length === 0) { return; } if (self.isNode() && !self.removed()) { var degree = 0; var node = self[0]; var connectedEdges = node._private.edges; for (var i = 0; i < connectedEdges.length; i++) { var edge = connectedEdges[i]; if (!includeLoops && edge.isLoop()) { continue; } degree += callback(node, edge); } return degree; } else { return; } }; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
defineDegreeFunction
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
function defineDegreeBoundsFunction(degreeFn, callback) { return function (includeLoops) { var ret; var nodes = this.nodes(); for (var i = 0; i < nodes.length; i++) { var ele = nodes[i]; var degree = ele[degreeFn](includeLoops); if (degree !== undefined && (ret === undefined || callback(degree, ret))) { ret = degree; } } return ret; }; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
defineDegreeBoundsFunction
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
beforePositionSet = function beforePositionSet(eles, newPos, silent) { for (var i = 0; i < eles.length; i++) { var ele = eles[i]; if (!ele.locked()) { var oldPos = ele._private.position; var delta = { x: newPos.x != null ? newPos.x - oldPos.x : 0, y: newPos.y != null ? newPos.y - oldPos.y : 0 }; if (ele.isParent() && !(delta.x === 0 && delta.y === 0)) { ele.children().shift(delta, silent); } ele.dirtyBoundingBoxCache(); } } }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
beforePositionSet
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
function update(parent) { if (!parent.isParent()) { return; } var _p = parent._private; var children = parent.children(); var includeLabels = parent.pstyle('compound-sizing-wrt-labels').value === 'include'; var min = { width: { val: parent.pstyle('min-width').pfValue, left: parent.pstyle('min-width-bias-left'), right: parent.pstyle('min-width-bias-right') }, height: { val: parent.pstyle('min-height').pfValue, top: parent.pstyle('min-height-bias-top'), bottom: parent.pstyle('min-height-bias-bottom') } }; var bb = children.boundingBox({ includeLabels: includeLabels, includeOverlays: false, // updating the compound bounds happens outside of the regular // cache cycle (i.e. before fired events) useCache: false }); var pos = _p.position; // if children take up zero area then keep position and fall back on stylesheet w/h if (bb.w === 0 || bb.h === 0) { bb = { w: parent.pstyle('width').pfValue, h: parent.pstyle('height').pfValue }; bb.x1 = pos.x - bb.w / 2; bb.x2 = pos.x + bb.w / 2; bb.y1 = pos.y - bb.h / 2; bb.y2 = pos.y + bb.h / 2; } function computeBiasValues(propDiff, propBias, propBiasComplement) { var biasDiff = 0; var biasComplementDiff = 0; var biasTotal = propBias + propBiasComplement; if (propDiff > 0 && biasTotal > 0) { biasDiff = propBias / biasTotal * propDiff; biasComplementDiff = propBiasComplement / biasTotal * propDiff; } return { biasDiff: biasDiff, biasComplementDiff: biasComplementDiff }; } function computePaddingValues(width, height, paddingObject, relativeTo) { // Assuming percentage is number from 0 to 1 if (paddingObject.units === '%') { switch (relativeTo) { case 'width': return width > 0 ? paddingObject.pfValue * width : 0; case 'height': return height > 0 ? paddingObject.pfValue * height : 0; case 'average': return width > 0 && height > 0 ? paddingObject.pfValue * (width + height) / 2 : 0; case 'min': return width > 0 && height > 0 ? width > height ? paddingObject.pfValue * height : paddingObject.pfValue * width : 0; case 'max': return width > 0 && height > 0 ? width > height ? paddingObject.pfValue * width : paddingObject.pfValue * height : 0; default: return 0; } } else if (paddingObject.units === 'px') { return paddingObject.pfValue; } else { return 0; } } var leftVal = min.width.left.value; if (min.width.left.units === 'px' && min.width.val > 0) { leftVal = leftVal * 100 / min.width.val; } var rightVal = min.width.right.value; if (min.width.right.units === 'px' && min.width.val > 0) { rightVal = rightVal * 100 / min.width.val; } var topVal = min.height.top.value; if (min.height.top.units === 'px' && min.height.val > 0) { topVal = topVal * 100 / min.height.val; } var bottomVal = min.height.bottom.value; if (min.height.bottom.units === 'px' && min.height.val > 0) { bottomVal = bottomVal * 100 / min.height.val; } var widthBiasDiffs = computeBiasValues(min.width.val - bb.w, leftVal, rightVal); var diffLeft = widthBiasDiffs.biasDiff; var diffRight = widthBiasDiffs.biasComplementDiff; var heightBiasDiffs = computeBiasValues(min.height.val - bb.h, topVal, bottomVal); var diffTop = heightBiasDiffs.biasDiff; var diffBottom = heightBiasDiffs.biasComplementDiff; _p.autoPadding = computePaddingValues(bb.w, bb.h, parent.pstyle('padding'), parent.pstyle('padding-relative-to').value); _p.autoWidth = Math.max(bb.w, min.width.val); pos.x = (-diffLeft + bb.x1 + bb.x2 + diffRight) / 2; _p.autoHeight = Math.max(bb.h, min.height.val); pos.y = (-diffTop + bb.y1 + bb.y2 + diffBottom) / 2; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
update
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
function computeBiasValues(propDiff, propBias, propBiasComplement) { var biasDiff = 0; var biasComplementDiff = 0; var biasTotal = propBias + propBiasComplement; if (propDiff > 0 && biasTotal > 0) { biasDiff = propBias / biasTotal * propDiff; biasComplementDiff = propBiasComplement / biasTotal * propDiff; } return { biasDiff: biasDiff, biasComplementDiff: biasComplementDiff }; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
computeBiasValues
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
function computePaddingValues(width, height, paddingObject, relativeTo) { // Assuming percentage is number from 0 to 1 if (paddingObject.units === '%') { switch (relativeTo) { case 'width': return width > 0 ? paddingObject.pfValue * width : 0; case 'height': return height > 0 ? paddingObject.pfValue * height : 0; case 'average': return width > 0 && height > 0 ? paddingObject.pfValue * (width + height) / 2 : 0; case 'min': return width > 0 && height > 0 ? width > height ? paddingObject.pfValue * height : paddingObject.pfValue * width : 0; case 'max': return width > 0 && height > 0 ? width > height ? paddingObject.pfValue * width : paddingObject.pfValue * height : 0; default: return 0; } } else if (paddingObject.units === 'px') { return paddingObject.pfValue; } else { return 0; } }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
computePaddingValues
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
noninf = function noninf(x) { if (x === Infinity || x === -Infinity) { return 0; } return x; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
noninf
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
updateBounds = function updateBounds(b, x1, y1, x2, y2) { // don't update with zero area boxes if (x2 - x1 === 0 || y2 - y1 === 0) { return; } // don't update with null dim if (x1 == null || y1 == null || x2 == null || y2 == null) { return; } b.x1 = x1 < b.x1 ? x1 : b.x1; b.x2 = x2 > b.x2 ? x2 : b.x2; b.y1 = y1 < b.y1 ? y1 : b.y1; b.y2 = y2 > b.y2 ? y2 : b.y2; b.w = b.x2 - b.x1; b.h = b.y2 - b.y1; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
updateBounds
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
updateBoundsFromBox = function updateBoundsFromBox(b, b2) { if (b2 == null) { return b; } return updateBounds(b, b2.x1, b2.y1, b2.x2, b2.y2); }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
updateBoundsFromBox
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
prefixedProperty = function prefixedProperty(obj, field, prefix) { return getPrefixedProperty(obj, field, prefix); }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
prefixedProperty
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
updateBoundsFromArrow = function updateBoundsFromArrow(bounds, ele, prefix) { if (ele.cy().headless()) { return; } var _p = ele._private; var rstyle = _p.rstyle; var halfArW = rstyle.arrowWidth / 2; var arrowType = ele.pstyle(prefix + '-arrow-shape').value; var x; var y; if (arrowType !== 'none') { if (prefix === 'source') { x = rstyle.srcX; y = rstyle.srcY; } else if (prefix === 'target') { x = rstyle.tgtX; y = rstyle.tgtY; } else { x = rstyle.midX; y = rstyle.midY; } // always store the individual arrow bounds var bbs = _p.arrowBounds = _p.arrowBounds || {}; var bb = bbs[prefix] = bbs[prefix] || {}; bb.x1 = x - halfArW; bb.y1 = y - halfArW; bb.x2 = x + halfArW; bb.y2 = y + halfArW; bb.w = bb.x2 - bb.x1; bb.h = bb.y2 - bb.y1; expandBoundingBox(bb, 1); updateBounds(bounds, bb.x1, bb.y1, bb.x2, bb.y2); } }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
updateBoundsFromArrow
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
updateBoundsFromLabel = function updateBoundsFromLabel(bounds, ele, prefix) { if (ele.cy().headless()) { return; } var prefixDash; if (prefix) { prefixDash = prefix + '-'; } else { prefixDash = ''; } var _p = ele._private; var rstyle = _p.rstyle; var label = ele.pstyle(prefixDash + 'label').strValue; if (label) { var halign = ele.pstyle('text-halign'); var valign = ele.pstyle('text-valign'); var labelWidth = prefixedProperty(rstyle, 'labelWidth', prefix); var labelHeight = prefixedProperty(rstyle, 'labelHeight', prefix); var labelX = prefixedProperty(rstyle, 'labelX', prefix); var labelY = prefixedProperty(rstyle, 'labelY', prefix); var marginX = ele.pstyle(prefixDash + 'text-margin-x').pfValue; var marginY = ele.pstyle(prefixDash + 'text-margin-y').pfValue; var isEdge = ele.isEdge(); var rotation = ele.pstyle(prefixDash + 'text-rotation'); var outlineWidth = ele.pstyle('text-outline-width').pfValue; var borderWidth = ele.pstyle('text-border-width').pfValue; var halfBorderWidth = borderWidth / 2; var padding = ele.pstyle('text-background-padding').pfValue; var marginOfError = 2; // expand to work around browser dimension inaccuracies var lh = labelHeight; var lw = labelWidth; var lw_2 = lw / 2; var lh_2 = lh / 2; var lx1, lx2, ly1, ly2; if (isEdge) { lx1 = labelX - lw_2; lx2 = labelX + lw_2; ly1 = labelY - lh_2; ly2 = labelY + lh_2; } else { switch (halign.value) { case 'left': lx1 = labelX - lw; lx2 = labelX; break; case 'center': lx1 = labelX - lw_2; lx2 = labelX + lw_2; break; case 'right': lx1 = labelX; lx2 = labelX + lw; break; } switch (valign.value) { case 'top': ly1 = labelY - lh; ly2 = labelY; break; case 'center': ly1 = labelY - lh_2; ly2 = labelY + lh_2; break; case 'bottom': ly1 = labelY; ly2 = labelY + lh; break; } } // shift by margin and expand by outline and border lx1 += marginX - Math.max(outlineWidth, halfBorderWidth) - padding - marginOfError; lx2 += marginX + Math.max(outlineWidth, halfBorderWidth) + padding + marginOfError; ly1 += marginY - Math.max(outlineWidth, halfBorderWidth) - padding - marginOfError; ly2 += marginY + Math.max(outlineWidth, halfBorderWidth) + padding + marginOfError; // always store the unrotated label bounds separately var bbPrefix = prefix || 'main'; var bbs = _p.labelBounds; var bb = bbs[bbPrefix] = bbs[bbPrefix] || {}; bb.x1 = lx1; bb.y1 = ly1; bb.x2 = lx2; bb.y2 = ly2; bb.w = lx2 - lx1; bb.h = ly2 - ly1; var isAutorotate = isEdge && rotation.strValue === 'autorotate'; var isPfValue = rotation.pfValue != null && rotation.pfValue !== 0; if (isAutorotate || isPfValue) { var theta = isAutorotate ? prefixedProperty(_p.rstyle, 'labelAngle', prefix) : rotation.pfValue; var cos = Math.cos(theta); var sin = Math.sin(theta); // rotation point (default value for center-center) var xo = (lx1 + lx2) / 2; var yo = (ly1 + ly2) / 2; if (!isEdge) { switch (halign.value) { case 'left': xo = lx2; break; case 'right': xo = lx1; break; } switch (valign.value) { case 'top': yo = ly2; break; case 'bottom': yo = ly1; break; } } var rotate = function rotate(x, y) { x = x - xo; y = y - yo; return { x: x * cos - y * sin + xo, y: x * sin + y * cos + yo }; }; var px1y1 = rotate(lx1, ly1); var px1y2 = rotate(lx1, ly2); var px2y1 = rotate(lx2, ly1); var px2y2 = rotate(lx2, ly2); lx1 = Math.min(px1y1.x, px1y2.x, px2y1.x, px2y2.x); lx2 = Math.max(px1y1.x, px1y2.x, px2y1.x, px2y2.x); ly1 = Math.min(px1y1.y, px1y2.y, px2y1.y, px2y2.y); ly2 = Math.max(px1y1.y, px1y2.y, px2y1.y, px2y2.y); } var bbPrefixRot = bbPrefix + 'Rot'; var bbRot = bbs[bbPrefixRot] = bbs[bbPrefixRot] || {}; bbRot.x1 = lx1; bbRot.y1 = ly1; bbRot.x2 = lx2; bbRot.y2 = ly2; bbRot.w = lx2 - lx1; bbRot.h = ly2 - ly1; updateBounds(bounds, lx1, ly1, lx2, ly2); updateBounds(_p.labelBounds.all, lx1, ly1, lx2, ly2); } return bounds; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
updateBoundsFromLabel
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
rotate = function rotate(x, y) { x = x - xo; y = y - yo; return { x: x * cos - y * sin + xo, y: x * sin + y * cos + yo }; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
rotate
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
boundingBoxImpl = function boundingBoxImpl(ele, options) { var cy = ele._private.cy; var styleEnabled = cy.styleEnabled(); var headless = cy.headless(); var bounds = makeBoundingBox(); var _p = ele._private; var isNode = ele.isNode(); var isEdge = ele.isEdge(); var ex1, ex2, ey1, ey2; // extrema of body / lines var x, y; // node pos var rstyle = _p.rstyle; var manualExpansion = isNode && styleEnabled ? ele.pstyle('bounds-expansion').pfValue : [0]; // must use `display` prop only, as reading `compound.width()` causes recursion // (other factors like width values will be considered later in this function anyway) var isDisplayed = function isDisplayed(ele) { return ele.pstyle('display').value !== 'none'; }; var displayed = !styleEnabled || isDisplayed(ele) // must take into account connected nodes b/c of implicit edge hiding on display:none node && (!isEdge || isDisplayed(ele.source()) && isDisplayed(ele.target())); if (displayed) { // displayed suffices, since we will find zero area eles anyway var overlayOpacity = 0; var overlayPadding = 0; if (styleEnabled && options.includeOverlays) { overlayOpacity = ele.pstyle('overlay-opacity').value; if (overlayOpacity !== 0) { overlayPadding = ele.pstyle('overlay-padding').value; } } var w = 0; var wHalf = 0; if (styleEnabled) { w = ele.pstyle('width').pfValue; wHalf = w / 2; } if (isNode && options.includeNodes) { var pos = ele.position(); x = pos.x; y = pos.y; var _w = ele.outerWidth(); var halfW = _w / 2; var h = ele.outerHeight(); var halfH = h / 2; // handle node dimensions ///////////////////////// ex1 = x - halfW; ex2 = x + halfW; ey1 = y - halfH; ey2 = y + halfH; updateBounds(bounds, ex1, ey1, ex2, ey2); } else if (isEdge && options.includeEdges) { if (styleEnabled && !headless) { var curveStyle = ele.pstyle('curve-style').strValue; // handle edge dimensions (rough box estimate) ////////////////////////////////////////////// ex1 = Math.min(rstyle.srcX, rstyle.midX, rstyle.tgtX); ex2 = Math.max(rstyle.srcX, rstyle.midX, rstyle.tgtX); ey1 = Math.min(rstyle.srcY, rstyle.midY, rstyle.tgtY); ey2 = Math.max(rstyle.srcY, rstyle.midY, rstyle.tgtY); // take into account edge width ex1 -= wHalf; ex2 += wHalf; ey1 -= wHalf; ey2 += wHalf; updateBounds(bounds, ex1, ey1, ex2, ey2); // precise edges //////////////// if (curveStyle === 'haystack') { var hpts = rstyle.haystackPts; if (hpts && hpts.length === 2) { ex1 = hpts[0].x; ey1 = hpts[0].y; ex2 = hpts[1].x; ey2 = hpts[1].y; if (ex1 > ex2) { var temp = ex1; ex1 = ex2; ex2 = temp; } if (ey1 > ey2) { var _temp = ey1; ey1 = ey2; ey2 = _temp; } updateBounds(bounds, ex1 - wHalf, ey1 - wHalf, ex2 + wHalf, ey2 + wHalf); } } else if (curveStyle === 'bezier' || curveStyle === 'unbundled-bezier' || curveStyle === 'segments' || curveStyle === 'taxi') { var pts; switch (curveStyle) { case 'bezier': case 'unbundled-bezier': pts = rstyle.bezierPts; break; case 'segments': case 'taxi': pts = rstyle.linePts; break; } if (pts != null) { for (var j = 0; j < pts.length; j++) { var pt = pts[j]; ex1 = pt.x - wHalf; ex2 = pt.x + wHalf; ey1 = pt.y - wHalf; ey2 = pt.y + wHalf; updateBounds(bounds, ex1, ey1, ex2, ey2); } } } // bezier-like or segment-like edge } else { // headless or style disabled // fallback on source and target positions ////////////////////////////////////////// var n1 = ele.source(); var n1pos = n1.position(); var n2 = ele.target(); var n2pos = n2.position(); ex1 = n1pos.x; ex2 = n2pos.x; ey1 = n1pos.y; ey2 = n2pos.y; if (ex1 > ex2) { var _temp2 = ex1; ex1 = ex2; ex2 = _temp2; } if (ey1 > ey2) { var _temp3 = ey1; ey1 = ey2; ey2 = _temp3; } // take into account edge width ex1 -= wHalf; ex2 += wHalf; ey1 -= wHalf; ey2 += wHalf; updateBounds(bounds, ex1, ey1, ex2, ey2); } // headless or style disabled } // edges // handle edge arrow size ///////////////////////// if (styleEnabled && options.includeEdges && isEdge) { updateBoundsFromArrow(bounds, ele, 'mid-source'); updateBoundsFromArrow(bounds, ele, 'mid-target'); updateBoundsFromArrow(bounds, ele, 'source'); updateBoundsFromArrow(bounds, ele, 'target'); } // ghost //////// if (styleEnabled) { var ghost = ele.pstyle('ghost').value === 'yes'; if (ghost) { var gx = ele.pstyle('ghost-offset-x').pfValue; var gy = ele.pstyle('ghost-offset-y').pfValue; updateBounds(bounds, bounds.x1 + gx, bounds.y1 + gy, bounds.x2 + gx, bounds.y2 + gy); } } // always store the body bounds separately from the labels var bbBody = _p.bodyBounds = _p.bodyBounds || {}; assignBoundingBox(bbBody, bounds); expandBoundingBoxSides(bbBody, manualExpansion); expandBoundingBox(bbBody, 1); // expand to work around browser dimension inaccuracies // overlay ////////// if (styleEnabled) { ex1 = bounds.x1; ex2 = bounds.x2; ey1 = bounds.y1; ey2 = bounds.y2; updateBounds(bounds, ex1 - overlayPadding, ey1 - overlayPadding, ex2 + overlayPadding, ey2 + overlayPadding); } // always store the body bounds separately from the labels var bbOverlay = _p.overlayBounds = _p.overlayBounds || {}; assignBoundingBox(bbOverlay, bounds); expandBoundingBoxSides(bbOverlay, manualExpansion); expandBoundingBox(bbOverlay, 1); // expand to work around browser dimension inaccuracies // handle label dimensions ////////////////////////// var bbLabels = _p.labelBounds = _p.labelBounds || {}; if (bbLabels.all != null) { clearBoundingBox(bbLabels.all); } else { bbLabels.all = makeBoundingBox(); } if (styleEnabled && options.includeLabels) { if (options.includeMainLabels) { updateBoundsFromLabel(bounds, ele, null); } if (isEdge) { if (options.includeSourceLabels) { updateBoundsFromLabel(bounds, ele, 'source'); } if (options.includeTargetLabels) { updateBoundsFromLabel(bounds, ele, 'target'); } } } // style enabled for labels } // if displayed bounds.x1 = noninf(bounds.x1); bounds.y1 = noninf(bounds.y1); bounds.x2 = noninf(bounds.x2); bounds.y2 = noninf(bounds.y2); bounds.w = noninf(bounds.x2 - bounds.x1); bounds.h = noninf(bounds.y2 - bounds.y1); if (bounds.w > 0 && bounds.h > 0 && displayed) { expandBoundingBoxSides(bounds, manualExpansion); // expand bounds by 1 because antialiasing can increase the visual/effective size by 1 on all sides expandBoundingBox(bounds, 1); } return bounds; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
boundingBoxImpl
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
isDisplayed = function isDisplayed(ele) { return ele.pstyle('display').value !== 'none'; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
isDisplayed
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
getKey = function getKey(opts) { var i = 0; var tf = function tf(val) { return (val ? 1 : 0) << i++; }; var key = 0; key += tf(opts.incudeNodes); key += tf(opts.includeEdges); key += tf(opts.includeLabels); key += tf(opts.includeMainLabels); key += tf(opts.includeSourceLabels); key += tf(opts.includeTargetLabels); key += tf(opts.includeOverlays); return key; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
getKey
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
tf = function tf(val) { return (val ? 1 : 0) << i++; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
tf
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
getBoundingBoxPosKey = function getBoundingBoxPosKey(ele) { if (ele.isEdge()) { var p1 = ele.source().position(); var p2 = ele.target().position(); var r = function r(x) { return Math.round(x); }; return hashIntsArray([r(p1.x), r(p1.y), r(p2.x), r(p2.y)]); } else { return 0; } }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
getBoundingBoxPosKey
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
r = function r(x) { return Math.round(x); }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
r
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
cachedBoundingBoxImpl = function cachedBoundingBoxImpl(ele, opts) { var _p = ele._private; var bb; var isEdge = ele.isEdge(); var key = opts == null ? defBbOptsKey : getKey(opts); var usingDefOpts = key === defBbOptsKey; var currPosKey = getBoundingBoxPosKey(ele); var isPosKeySame = _p.bbCachePosKey === currPosKey; var useCache = opts.useCache && isPosKeySame; var isDirty = function isDirty(ele) { return ele._private.bbCache == null || ele._private.styleDirty; }; var needRecalc = !useCache || isDirty(ele) || isEdge && isDirty(ele.source()) || isDirty(ele.target()); if (needRecalc) { if (!isPosKeySame) { ele.recalculateRenderedStyle(useCache); } bb = boundingBoxImpl(ele, defBbOpts); _p.bbCache = bb; _p.bbCachePosKey = currPosKey; } else { bb = _p.bbCache; } // not using def opts => need to build up bb from combination of sub bbs if (!usingDefOpts) { var isNode = ele.isNode(); bb = makeBoundingBox(); if (opts.includeNodes && isNode || opts.includeEdges && !isNode) { if (opts.includeOverlays) { updateBoundsFromBox(bb, _p.overlayBounds); } else { updateBoundsFromBox(bb, _p.bodyBounds); } } if (opts.includeLabels) { if (opts.includeMainLabels && (!isEdge || opts.includeSourceLabels && opts.includeTargetLabels)) { updateBoundsFromBox(bb, _p.labelBounds.all); } else { if (opts.includeMainLabels) { updateBoundsFromBox(bb, _p.labelBounds.mainRot); } if (opts.includeSourceLabels) { updateBoundsFromBox(bb, _p.labelBounds.sourceRot); } if (opts.includeTargetLabels) { updateBoundsFromBox(bb, _p.labelBounds.targetRot); } } } bb.w = bb.x2 - bb.x1; bb.h = bb.y2 - bb.y1; } return bb; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
cachedBoundingBoxImpl
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
isDirty = function isDirty(ele) { return ele._private.bbCache == null || ele._private.styleDirty; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
isDirty
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
storeOldPos = function storeOldPos(node, i) { return node._private.bbAtOldPos = fn(node, i); }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
storeOldPos
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
getOldPos = function getOldPos(node) { return node._private.bbAtOldPos; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
getOldPos
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
defineDimFns = function defineDimFns(opts) { opts.uppercaseName = capitalize(opts.name); opts.autoName = 'auto' + opts.uppercaseName; opts.labelName = 'label' + opts.uppercaseName; opts.outerName = 'outer' + opts.uppercaseName; opts.uppercaseOuterName = capitalize(opts.outerName); fn$4[opts.name] = function dimImpl() { var ele = this[0]; var _p = ele._private; var cy = _p.cy; var styleEnabled = cy._private.styleEnabled; if (ele) { if (styleEnabled) { if (ele.isParent()) { ele.updateCompoundBounds(); return _p[opts.autoName] || 0; } var d = ele.pstyle(opts.name); switch (d.strValue) { case 'label': ele.recalculateRenderedStyle(); return _p.rstyle[opts.labelName] || 0; default: return d.pfValue; } } else { return 1; } } }; fn$4['outer' + opts.uppercaseName] = function outerDimImpl() { var ele = this[0]; var _p = ele._private; var cy = _p.cy; var styleEnabled = cy._private.styleEnabled; if (ele) { if (styleEnabled) { var dim = ele[opts.name](); var border = ele.pstyle('border-width').pfValue; // n.b. 1/2 each side var padding = 2 * ele.padding(); return dim + border + padding; } else { return 1; } } }; fn$4['rendered' + opts.uppercaseName] = function renderedDimImpl() { var ele = this[0]; if (ele) { var d = ele[opts.name](); return d * this.cy().zoom(); } }; fn$4['rendered' + opts.uppercaseOuterName] = function renderedOuterDimImpl() { var ele = this[0]; if (ele) { var od = ele[opts.outerName](); return od * this.cy().zoom(); } }; }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
defineDimFns
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
ifEdge = function ifEdge(ele, getValue) { if (ele.isEdge()) { return getValue(ele); } }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
ifEdge
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
ifEdgeRenderedPosition = function ifEdgeRenderedPosition(ele, getPoint) { if (ele.isEdge()) { var cy = ele.cy(); return modelToRenderedPosition(getPoint(ele), cy.zoom(), cy.pan()); } }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
ifEdgeRenderedPosition
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
ifEdgeRenderedPositions = function ifEdgeRenderedPositions(ele, getPoints) { if (ele.isEdge()) { var cy = ele.cy(); var pan = cy.pan(); var zoom = cy.zoom(); return getPoints(ele).map(function (p) { return modelToRenderedPosition(p, zoom, pan); }); } }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
ifEdgeRenderedPositions
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
controlPoints = function controlPoints(ele) { return ele.renderer().getControlPoints(ele); }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
controlPoints
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
segmentPoints = function segmentPoints(ele) { return ele.renderer().getSegmentPoints(ele); }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
segmentPoints
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
sourceEndpoint = function sourceEndpoint(ele) { return ele.renderer().getSourceEndpoint(ele); }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
sourceEndpoint
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
targetEndpoint = function targetEndpoint(ele) { return ele.renderer().getTargetEndpoint(ele); }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
targetEndpoint
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
midpoint = function midpoint(ele) { return ele.renderer().getEdgeMidpoint(ele); }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
midpoint
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
renderedName = function renderedName(name) { return 'rendered' + name[0].toUpperCase() + name.substr(1); }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
renderedName
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT
Event = function Event(src, props) { this.recycle(src, props); }
Returns whether the query matches for the element @param query The `{ type, value, ... }` query object @param ele The element to compare against
Event
javascript
pistazie/cdk-dia
src/render/cytoscape/base/js/app.8e9fe77f.js
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
MIT