_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q22700
LocalIndexedDBStoreBackend
train
function LocalIndexedDBStoreBackend( indexedDBInterface, dbName, ) { this.indexedDB = indexedDBInterface; this._dbName = "matrix-js-sdk:" + (dbName || "default"); this.db = null; this._disconnected = true; this._syncAccumulator = new SyncAccumulator(); this._isNewlyCreated = false; }
javascript
{ "resource": "" }
q22701
train
function() { if (!this._disconnected) { console.log( `LocalIndexedDBStoreBackend.connect: already connected or connecting`, ); return Promise.resolve(); } this._disconnected = false; console.log( `LocalIndexedDBStoreBacken...
javascript
{ "resource": "" }
q22702
train
function() { return Promise.all([ this._loadAccountData(), this._loadSyncData(), ]).then(([accountData, syncData]) => { console.log( `LocalIndexedDBStoreBackend: loaded initial data`, ); this._syncAccumulator.accumulate({ ...
javascript
{ "resource": "" }
q22703
train
function(roomId) { return new Promise((resolve, reject) =>{ const tx = this.db.transaction(["oob_membership_events"], "readonly"); const store = tx.objectStore("oob_membership_events"); const roomIndex = store.index("room"); const range = IDBKeyRange.only(roomId);...
javascript
{ "resource": "" }
q22704
train
async function(roomId, membershipEvents) { console.log(`LL: backend about to store ${membershipEvents.length}` + ` members for ${roomId}`); const tx = this.db.transaction(["oob_membership_events"], "readwrite"); const store = tx.objectStore("oob_membership_events"); membershi...
javascript
{ "resource": "" }
q22705
train
function() { return new Promise((resolve, reject) => { console.log(`Removing indexeddb instance: ${this._dbName}`); const req = this.indexedDB.deleteDatabase(this._dbName); req.onblocked = () => { console.log( `can't yet delete indexeddb $...
javascript
{ "resource": "" }
q22706
train
function(accountData) { return Promise.try(() => { const txn = this.db.transaction(["accountData"], "readwrite"); const store = txn.objectStore("accountData"); for (let i = 0; i < accountData.length; i++) { store.put(accountData[i]); // put == UPSERT ...
javascript
{ "resource": "" }
q22707
train
function() { console.log( `LocalIndexedDBStoreBackend: loading account data...`, ); return Promise.try(() => { const txn = this.db.transaction(["accountData"], "readonly"); const store = txn.objectStore("accountData"); return selectQuery(store, und...
javascript
{ "resource": "" }
q22708
train
function() { console.log( `LocalIndexedDBStoreBackend: loading sync data...`, ); return Promise.try(() => { const txn = this.db.transaction(["sync"], "readonly"); const store = txn.objectStore("sync"); return selectQuery(store, undefined, (cursor) ...
javascript
{ "resource": "" }
q22709
_walkObject
train
function _walkObject(object, callback, path, config) { const {walkArrays, walkArraysMatchingKeys} = config; Object.keys(object).forEach(key => { // Callback can force traversal to stop by returning `true`. if (callback(key, object, path.get(object, key))) { return; } const value = object[key]...
javascript
{ "resource": "" }
q22710
handleEscaping
train
function handleEscaping(tokens, token, index) { if (index === 0) { return [token]; } const previousToken = tokens[index - 1]; if (!previousToken.endsWith('\\')) { return [...tokens, token]; } return [...tokens.slice(0, index - 1), `${previousToken.slice(0, -1)} ${token}`]; }
javascript
{ "resource": "" }
q22711
isEnv
train
function isEnv(envAlias) { // Check for default case if (envAlias === ENV_ALIAS.DEV && Object.keys(env).length === 0) { return true; } return envAlias.some(alias => env[alias]); }
javascript
{ "resource": "" }
q22712
cors
train
function cors(req, res, next) { const port = process.env.NODE_ENV === 'production' ? null : new url.URL(req.query.__amp_source_origin).port; const host = process.env.NODE_ENV === 'production' ? `https://${req.hostname}` : `http://${req.hostname}:${port}`; res.header('amp-access-control-allow-sou...
javascript
{ "resource": "" }
q22713
filter
train
function filter(data, query) { var results = []; var push = true; // omit every result that doesn't pass _every_ filter data.forEach((val) => { var push = true; // if we fail a filter condition, then don't push // check if we're over the max price if (query.maxPrice > 0) { if (val.price....
javascript
{ "resource": "" }
q22714
selectedCities
train
function selectedCities(travelData, cities) { var selected = []; travelData.activities.forEach((data) => { const isSelected = cities.includes(data.location.city); // check if the city already exists in our cities array var existsIdx = -1; selected.forEach((city, idx) => { if (city.name === da...
javascript
{ "resource": "" }
q22715
sortResults
train
function sortResults(val, results) { const sortPopularity = (a, b) => { if (a.reviews.count < b.reviews.count) { return 1; } else if (a.reviews.count > b.reviews.count) { return -1; } return 0; }; const sortRating = (a, b) => { if (a.reviews.averageRating.value < b.reviews.average...
javascript
{ "resource": "" }
q22716
getSVGGraphPathData
train
function getSVGGraphPathData(data, width, height) { var max = Math.max.apply(null, data); var width = 800; var height = 100; var scaleH = width / (data.length - 1) var scaleV = height / max; var factor = 0.25; var commands = [`m0,${applyScaleV(data[0])}`]; function round(val) { return Math.round...
javascript
{ "resource": "" }
q22717
handleHashChange_
train
function handleHashChange_() { cssTranspiler.getCssWithVars(getUrlCssVars()).then(updatedStyles => { iframeManager.setStyle(updatedStyles); }).catch(error => { // Don't set the styles, log the error console.error(error); }); }
javascript
{ "resource": "" }
q22718
argPoint
train
function argPoint(bbox, args) { var x = args.x; if (util.isString(x)) { x = parseFloat(x) / 100 * bbox.width; } var y = args.y; if (util.isString(y)) { y = parseFloat(y) / 100 * bbox.height; } return g.point(x || 0, y || 0); }
javascript
{ "resource": "" }
q22719
findLineIntersections
train
function findLineIntersections(line, crossCheckLines) { return util.toArray(crossCheckLines).reduce(function(res, crossCheckLine) { var intersection = line.intersection(crossCheckLine); if (intersection) { res.push(intersection); } return res; ...
javascript
{ "resource": "" }
q22720
createJumps
train
function createJumps(line, intersections, jumpSize) { return intersections.reduce(function(resultLines, point, idx) { // skipping points that were merged with the previous line // to make bigger arc over multiple lines that are close to each other if (point.skip === true) { ...
javascript
{ "resource": "" }
q22721
train
function() { var step = this.step; return { x: -step, y: -step, width: 2 * step, height: 2 * step }; }
javascript
{ "resource": "" }
q22722
getTargetBBox
train
function getTargetBBox(linkView, opt) { // expand by padding box if (opt && opt.paddingBox) return linkView.targetBBox.clone().moveAndExpand(opt.paddingBox); return linkView.targetBBox.clone(); }
javascript
{ "resource": "" }
q22723
getSourceAnchor
train
function getSourceAnchor(linkView, opt) { if (linkView.sourceAnchor) return linkView.sourceAnchor; // fallback: center of bbox var sourceBBox = getSourceBBox(linkView, opt); return sourceBBox.center(); }
javascript
{ "resource": "" }
q22724
getTargetAnchor
train
function getTargetAnchor(linkView, opt) { if (linkView.targetAnchor) return linkView.targetAnchor; // fallback: center of bbox var targetBBox = getTargetBBox(linkView, opt); return targetBBox.center(); // default }
javascript
{ "resource": "" }
q22725
getDirectionAngle
train
function getDirectionAngle(start, end, numDirections, grid, opt) { var quadrant = 360 / numDirections; var angleTheta = start.theta(fixAngleEnd(start, end, grid, opt)); var normalizedAngle = g.normalizeAngle(angleTheta + (quadrant / 2)); return quadrant * Math.floor(normalizedAngle / qu...
javascript
{ "resource": "" }
q22726
getDirectionChange
train
function getDirectionChange(angle1, angle2) { var directionChange = Math.abs(angle1 - angle2); return (directionChange > 180) ? (360 - directionChange) : directionChange; }
javascript
{ "resource": "" }
q22727
getGridOffsets
train
function getGridOffsets(directions, grid, opt) { var step = opt.step; util.toArray(opt.directions).forEach(function(direction) { direction.gridOffsetX = (direction.offsetX / step) * grid.x; direction.gridOffsetY = (direction.offsetY / step) * grid.y; }); }
javascript
{ "resource": "" }
q22728
getGrid
train
function getGrid(step, source, target) { return { source: source.clone(), x: getGridDimension(target.x - source.x, step), y: getGridDimension(target.y - source.y, step) }; }
javascript
{ "resource": "" }
q22729
snapToGrid
train
function snapToGrid(point, grid) { var source = grid.source; var snappedX = g.snapToGrid(point.x - source.x, grid.x) + source.x; var snappedY = g.snapToGrid(point.y - source.y, grid.y) + source.y; return new g.Point(snappedX, snappedY); }
javascript
{ "resource": "" }
q22730
align
train
function align(point, grid, precision) { return round(snapToGrid(point.clone(), grid), precision); }
javascript
{ "resource": "" }
q22731
normalizePoint
train
function normalizePoint(point) { return new g.Point( point.x === 0 ? 0 : Math.abs(point.x) / point.x, point.y === 0 ? 0 : Math.abs(point.y) / point.y ); }
javascript
{ "resource": "" }
q22732
estimateCost
train
function estimateCost(from, endPoints) { var min = Infinity; for (var i = 0, len = endPoints.length; i < len; i++) { var cost = from.manhattanDistance(endPoints[i]); if (cost < min) min = cost; } return min; }
javascript
{ "resource": "" }
q22733
resolveOptions
train
function resolveOptions(opt) { opt.directions = util.result(opt, 'directions'); opt.penalties = util.result(opt, 'penalties'); opt.paddingBox = util.result(opt, 'paddingBox'); opt.padding = util.result(opt, 'padding'); if (opt.padding) { // if both provided, opt.pad...
javascript
{ "resource": "" }
q22734
router
train
function router(vertices, opt, linkView) { resolveOptions(opt); // enable/disable linkView perpendicular option linkView.options.perpendicular = !!opt.perpendicular; var sourceBBox = getSourceBBox(linkView, opt); var targetBBox = getTargetBBox(linkView, opt); var sour...
javascript
{ "resource": "" }
q22735
TypedArray
train
function TypedArray(arg1) { var result; if (typeof arg1 === 'number') { result = new Array(arg1); for (var i = 0; i < arg1; ++i) { result[i] = 0; } } else { result = arg1.slice(0); } result.subarray = subarray; ...
javascript
{ "resource": "" }
q22736
train
function(knots) { console.warn('deprecated'); var firstControlPoints = []; var secondControlPoints = []; var n = knots.length - 1; var i; // Special case: Bezier curve should be a straight line. if (n == 1) { // 3P1 =...
javascript
{ "resource": "" }
q22737
train
function(c) { return !!c && this.start.x === c.start.x && this.start.y === c.start.y && this.controlPoint1.x === c.controlPoint1.x && this.controlPoint1.y === c.controlPoint1.y && this.controlPoint2.x === c....
javascript
{ "resource": "" }
q22738
train
function(t) { var start = this.start; var control1 = this.controlPoint1; var control2 = this.controlPoint2; var end = this.end; // shortcuts for `t` values that are out of range if (t <= 0) { return { startCont...
javascript
{ "resource": "" }
q22739
train
function(opt) { opt = opt || {}; var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision; // opt.precision only used in getSubdivisions() call var subdivisions = (opt.subdivisions === undefined) ? this.getSubdivisions({ precision: precision }) : opt.subdivisio...
javascript
{ "resource": "" }
q22740
train
function(ratio, opt) { if (!this.isDifferentiable()) return null; if (ratio < 0) ratio = 0; else if (ratio > 1) ratio = 1; var t = this.tAt(ratio, opt); return this.tangentAtT(t); }
javascript
{ "resource": "" }
q22741
train
function(length, opt) { if (!this.isDifferentiable()) return null; var t = this.tAtLength(length, opt); return this.tangentAtT(t); }
javascript
{ "resource": "" }
q22742
train
function(t) { if (!this.isDifferentiable()) return null; if (t < 0) t = 0; else if (t > 1) t = 1; var skeletonPoints = this.getSkeletonPoints(t); var p1 = skeletonPoints.startControlPoint2; var p2 = skeletonPoints.dividerControlPoint1; ...
javascript
{ "resource": "" }
q22743
train
function(ratio, opt) { if (ratio <= 0) return 0; if (ratio >= 1) return 1; opt = opt || {}; var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision; var subdivisions = (opt.subdivisions === undefined) ? this.getSubdivisions({ precision...
javascript
{ "resource": "" }
q22744
train
function(dx, dy) { if (dx === undefined) { dx = 0; } if (dy === undefined) { dy = dx; } this.a += 2 * dx; this.b += 2 * dy; return this; }
javascript
{ "resource": "" }
q22745
train
function(p) { var refPointDelta = 30; var x0 = p.x; var y0 = p.y; var a = this.a; var b = this.b; var center = this.bbox().center(); var m = center.x; var n = center.y; var q1 = x0 > center.x + a / 2; ...
javascript
{ "resource": "" }
q22746
train
function(arg) { var segments = this.segments; var numSegments = segments.length; // works even if path has no segments var currentSegment; var previousSegment = ((numSegments !== 0) ? segments[numSegments - 1] : null); // if we are appending to an empty pat...
javascript
{ "resource": "" }
q22747
train
function() { var segments = this.segments; var numSegments = segments.length; if (numSegments === 0) return null; // if segments is an empty array var bbox; for (var i = 0; i < numSegments; i++) { var segment = segments[i]; i...
javascript
{ "resource": "" }
q22748
train
function() { var segments = this.segments; var numSegments = segments.length; // works even if path has no segments var path = new Path(); for (var i = 0; i < numSegments; i++) { var segment = segments[i].clone(); path.append...
javascript
{ "resource": "" }
q22749
train
function(p) { if (!p) return false; var segments = this.segments; var otherSegments = p.segments; var numSegments = segments.length; if (otherSegments.length !== numSegments) return false; // if the two paths have different number of segments, they cannot b...
javascript
{ "resource": "" }
q22750
train
function(index) { var segments = this.segments; var numSegments = segments.length; if (numSegments === 0) throw new Error('Path has no segments.'); if (index < 0) index = numSegments + index; // convert negative indices to positive if (index >= numSegments |...
javascript
{ "resource": "" }
q22751
train
function(opt) { var segments = this.segments; var numSegments = segments.length; // works even if path has no segments opt = opt || {}; var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision; // not using opt.segmentSubdiv...
javascript
{ "resource": "" }
q22752
train
function(opt) { var segments = this.segments; var numSegments = segments.length; if (numSegments === 0) return 0; // if segments is an empty array opt = opt || {}; var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision; // opt.precisi...
javascript
{ "resource": "" }
q22753
train
function(ratio, opt) { var segments = this.segments; var numSegments = segments.length; if (numSegments === 0) return null; // if segments is an empty array if (ratio <= 0) return this.start.clone(); if (ratio >= 1) return this.end.clone(); opt ...
javascript
{ "resource": "" }
q22754
train
function(length, opt) { var segments = this.segments; var numSegments = segments.length; if (numSegments === 0) return null; // if segments is an empty array if (length === 0) return this.start.clone(); var fromStart = true; if (length < 0) { ...
javascript
{ "resource": "" }
q22755
train
function(segment, previousSegment, nextSegment) { // insert after previous segment and before previous segment's next segment segment.previousSegment = previousSegment; segment.nextSegment = nextSegment; if (previousSegment) previousSegment.nextSegment = segment; ...
javascript
{ "resource": "" }
q22756
train
function(index) { var segments = this.segments; var numSegments = segments.length; if (numSegments === 0) throw new Error('Path has no segments.'); if (index < 0) index = numSegments + index; // convert negative indices to positive if (index >= numSegments |...
javascript
{ "resource": "" }
q22757
train
function(length, opt) { var segments = this.segments; var numSegments = segments.length; if (numSegments === 0) return null; // if segments is an empty array var fromStart = true; if (length < 0) { fromStart = false; // negative lengths mean ...
javascript
{ "resource": "" }
q22758
train
function(segment) { var previousSegment = segment.previousSegment; // may be null while (segment && !segment.isSubpathStart) { // assign previous segment's subpath start segment to this segment if (previousSegment) segment.subpathStartSegment = previousSegment.s...
javascript
{ "resource": "" }
q22759
train
function(ref, distance) { var theta = toRad((new Point(ref)).theta(this)); var offset = this.offset(cos(theta) * distance, -sin(theta) * distance); return offset; }
javascript
{ "resource": "" }
q22760
train
function(sx, sy, origin) { origin = (origin && new Point(origin)) || new Point(0, 0); this.x = origin.x + sx * (this.x - origin.x); this.y = origin.y + sy * (this.y - origin.y); return this; }
javascript
{ "resource": "" }
q22761
train
function(o) { o = (o && new Point(o)) || new Point(0, 0); var x = this.x; var y = this.y; this.x = sqrt((x - o.x) * (x - o.x) + (y - o.y) * (y - o.y)); // r this.y = toRad(o.theta(new Point(x, y))); return this; }
javascript
{ "resource": "" }
q22762
train
function(p) { if (!p) return false; var points = this.points; var otherPoints = p.points; var numPoints = points.length; if (otherPoints.length !== numPoints) return false; // if the two polylines have different number of points, they cannot be equal ...
javascript
{ "resource": "" }
q22763
train
function() { var points = this.points; var numPoints = points.length; if (numPoints === 0) return ''; // if points array is empty var output = ''; for (var i = 0; i < numPoints; i++) { var point = points[i]; output += point.x...
javascript
{ "resource": "" }
q22764
train
function(angle) { if (!angle) return this.clone(); var theta = toRad(angle); var st = abs(sin(theta)); var ct = abs(cos(theta)); var w = this.width * ct + this.height * st; var h = this.width * st + this.height * ct; return new Rect(t...
javascript
{ "resource": "" }
q22765
train
function(p, angle) { p = new Point(p); var center = new Point(this.x + this.width / 2, this.y + this.height / 2); var result; if (angle) p.rotate(center, angle); // (clockwise, starting from the top side) var sides = [ this.topLi...
javascript
{ "resource": "" }
q22766
train
function(sx, sy, origin) { origin = this.origin().scale(sx, sy, origin); this.x = origin.x; this.y = origin.y; this.width *= sx; this.height *= sy; return this; }
javascript
{ "resource": "" }
q22767
train
function(domain, range, value) { var domainSpan = domain[1] - domain[0]; var rangeSpan = range[1] - range[0]; return (((value - domain[0]) / domainSpan) * rangeSpan + range[0]) || 0; }
javascript
{ "resource": "" }
q22768
train
function() { var args = []; var n = arguments.length; for (var i = 0; i < n; i++) { args.push(arguments[i]); } if (!(this instanceof Closepath)) { // switching context of `this` to Closepath when called without `new` return applyToNew(Closepath, args); ...
javascript
{ "resource": "" }
q22769
train
function(obj) { this.guid.id = this.guid.id || 1; obj.id = (obj.id === undefined ? 'j_' + this.guid.id++ : obj.id); return obj.id; }
javascript
{ "resource": "" }
q22770
train
function(blob, fileName) { if (window.navigator.msSaveBlob) { // requires IE 10+ // pulls up a save dialog window.navigator.msSaveBlob(blob, fileName); } else { // other browsers // downloads directly in Chrome and Safari // pres...
javascript
{ "resource": "" }
q22771
train
function(dataUri, fileName) { var blob = joint.util.dataUriToBlob(dataUri); joint.util.downloadBlob(blob, fileName); }
javascript
{ "resource": "" }
q22772
train
function(url, callback) { if (!url || url.substr(0, 'data:'.length) === 'data:') { // No need to convert to data uri if it is already in data uri. // This not only convenient but desired. For example, // IE throws a security error if data:image/svg+xml is us...
javascript
{ "resource": "" }
q22773
train
function(xhr, callback) { if (xhr.status === 200) { var reader = new FileReader(); reader.onload = function(evt) { var dataUri = evt.target.result; callback(null, dataUri); }; ...
javascript
{ "resource": "" }
q22774
train
function(el) { this.$el = el instanceof Backbone.$ ? el : Backbone.$(el); this.el = this.$el[0]; if (this.svgElement) this.vel = V(this.el); }
javascript
{ "resource": "" }
q22775
train
function(cells, opt) { var preparedCells = joint.util.toArray(cells).map(function(cell) { return this._prepareCell(cell, opt); }, this); this.get('cells').reset(preparedCells, opt); return this; }
javascript
{ "resource": "" }
q22776
train
function(elementA, elementB) { var isSuccessor = false; this.search(elementA, function(element) { if (element === elementB && element !== elementA) { isSuccessor = true; return false; } }, { outbound: true }); return isSuccessor; ...
javascript
{ "resource": "" }
q22777
train
function(elementA, elementB) { var isPredecessor = false; this.search(elementA, function(element) { if (element === elementB && element !== elementA) { isPredecessor = true; return false; } }, { inbound: true }); return isPredecess...
javascript
{ "resource": "" }
q22778
train
function(model, opt) { this.getConnectedLinks(model).forEach(function(link) { link.set((link.source().id === model.id ? 'source' : 'target'), { x: 0, y: 0 }, opt); }); }
javascript
{ "resource": "" }
q22779
train
function(rect, opt) { rect = g.rect(rect); opt = joint.util.defaults(opt || {}, { strict: false }); var method = opt.strict ? 'containsRect' : 'intersect'; return this.getElements().filter(function(el) { return rect[method](el.getBBox()); }); }
javascript
{ "resource": "" }
q22780
train
function(element, opt) { opt = joint.util.defaults(opt || {}, { searchBy: 'bbox' }); var bbox = element.getBBox(); var elements = (opt.searchBy === 'bbox') ? this.findModelsInArea(bbox) : this.findModelsFromPoint(bbox[opt.searchBy]()); // don't account element ...
javascript
{ "resource": "" }
q22781
train
function(cells, opt) { return joint.util.toArray(cells).reduce(function(memo, cell) { if (cell.isLink()) return memo; var rect = cell.getBBox(opt); var angle = cell.angle(); if (angle) rect = rect.bbox(angle); if (memo) { return memo.u...
javascript
{ "resource": "" }
q22782
dWrapper
train
function dWrapper(opt) { function pathConstructor(value) { return new g.Path(V.normalizePathData(value)); } var shape = shapeWrapper(pathConstructor, opt); return function(value, refBBox, node) { var path = shape(value, refBBox, node); return { ...
javascript
{ "resource": "" }
q22783
pointsWrapper
train
function pointsWrapper(opt) { var shape = shapeWrapper(g.Polyline, opt); return function(value, refBBox, node) { var polyline = shape(value, refBBox, node); return { points: polyline.serialize() }; }; }
javascript
{ "resource": "" }
q22784
train
function() { var ancestors = []; if (!this.graph) { return ancestors; } var parentCell = this.getParentCell(); while (parentCell) { ancestors.push(parentCell); parentCell = parentCell.getParentCell(); } return ancestors; ...
javascript
{ "resource": "" }
q22785
train
function(path, opt) { // Once a property is removed from the `attrs` attribute // the cellView will recognize a `dirty` flag and rerender itself // in order to remove the attribute from SVG element. opt = opt || {}; opt.dirty = true; var pathArray = Array.isArray(path) ...
javascript
{ "resource": "" }
q22786
train
function(attrs, value, opt) { var args = Array.from(arguments); if (args.length === 0) { return this.get('attrs'); } if (Array.isArray(attrs)) { args[0] = ['attrs'].concat(attrs); } else if (joint.util.isString(attrs)) { // Get/set an attribu...
javascript
{ "resource": "" }
q22787
train
function(path, opt) { if (Array.isArray(path)) { return this.removeProp(['attrs'].concat(path)); } return this.removeProp('attrs/' + path, opt); }
javascript
{ "resource": "" }
q22788
train
function(el) { var $el = this.$(el); var $rootEl = this.$el; if ($el.length === 0) { $el = $rootEl; } do { var magnet = $el.attr('magnet'); if ((magnet || $el.is($rootEl)) && magnet !== 'false') { return $el[0]; ...
javascript
{ "resource": "" }
q22789
train
function(el, prevSelector) { var selector; if (el === this.el) { if (typeof prevSelector === 'string') selector = '> ' + prevSelector; return selector; } if (el) { var nthChild = V(el).index() + 1; selector = el.tagName + ':nth-child(' ...
javascript
{ "resource": "" }
q22790
train
function(angle, absolute, origin, opt) { if (origin) { var center = this.getBBox().center(); var size = this.get('size'); var position = this.get('position'); center.rotate(origin, this.get('angle') - angle); var dx = center.x - size.width / 2 - posi...
javascript
{ "resource": "" }
q22791
train
function() { var element = this.model; var markup = element.get('markup') || element.markup; if (!markup) throw new Error('dia.ElementView: markup required'); if (Array.isArray(markup)) return this.renderJSONMarkup(markup); if (typeof markup === 'string') return this.renderStrin...
javascript
{ "resource": "" }
q22792
train
function(evt, x, y) { var data = this.eventData(evt); if (data.embedding) this.finalizeEmbedding(data); }
javascript
{ "resource": "" }
q22793
train
function(idx, label, opt) { var labels = this.labels(); idx = (isFinite(idx) && idx !== null) ? (idx | 0) : 0; if (idx < 0) idx = labels.length + idx; // getter if (arguments.length <= 1) return this.prop(['labels', idx]); // setter return this.prop(['labels', ...
javascript
{ "resource": "" }
q22794
train
function() { var connectionAncestor; if (this.graph) { var cells = [ this, this.getSourceElement(), // null if source is a point this.getTargetElement() // null if target is a point ].filter(function(item) { retur...
javascript
{ "resource": "" }
q22795
train
function(cell) { var cellId = (joint.util.isString(cell) || joint.util.isNumber(cell)) ? cell : cell.id; var ancestor = this.getRelationshipAncestor(); return !!ancestor && (ancestor.id === cellId || ancestor.isEmbeddedIn(cellId)); }
javascript
{ "resource": "" }
q22796
train
function() { var defaultLabel = this.get('defaultLabel') || this.defaultLabel || {}; var label = {}; label.markup = defaultLabel.markup || this.get('labelMarkup') || this.labelMarkup; label.position = defaultLabel.position; label.attrs = defaultLabel.attrs; label.size =...
javascript
{ "resource": "" }
q22797
train
function(endType) { // create handler for specific end type (source|target). var onModelChange = function(endModel, opt) { this.onEndModelChange(endType, endModel, opt); }; function watchEndModel(link, end) { end = end || {}; var endModel = null; ...
javascript
{ "resource": "" }
q22798
train
function(x, y, opt) { // accept input in form `{ x, y }, opt` or `x, y, opt` var isPointProvided = (typeof x !== 'number'); var localX = isPointProvided ? x.x : x; var localY = isPointProvided ? x.y : y; var localOpt = isPointProvided ? y : opt; var vertex = { x: localX...
javascript
{ "resource": "" }
q22799
train
function(angle, cx, cy) { // getter if (angle === undefined) { return V.matrixToRotate(this.matrix()); } // setter // If the origin is not set explicitely, rotate around the center. Note that // we must use the plain bounding box (`this.el.getBBox()` instea...
javascript
{ "resource": "" }