repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
MrSwitch/hello.js | demos/Collage/fabric.js | function () {
var activeObject = this.getActiveGroup() || this.getActiveObject();
if (activeObject) {
this.fire('before:selection:cleared', { target: activeObject });
}
this.deactivateAll();
if (activeObject) {
this.fire('selection:cleared');
}
return this;
... | javascript | function () {
var activeObject = this.getActiveGroup() || this.getActiveObject();
if (activeObject) {
this.fire('before:selection:cleared', { target: activeObject });
}
this.deactivateAll();
if (activeObject) {
this.fire('selection:cleared');
}
return this;
... | [
"function",
"(",
")",
"{",
"var",
"activeObject",
"=",
"this",
".",
"getActiveGroup",
"(",
")",
"||",
"this",
".",
"getActiveObject",
"(",
")",
";",
"if",
"(",
"activeObject",
")",
"{",
"this",
".",
"fire",
"(",
"'before:selection:cleared'",
",",
"{",
"t... | Deactivates all objects and dispatches appropriate events
@method deactivateAllWithDispatch
@return {fabric.Canvas} thisArg | [
"Deactivates",
"all",
"objects",
"and",
"dispatches",
"appropriate",
"events"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L7171-L7181 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function (object, callbacks) {
callbacks = callbacks || { };
var empty = function() { },
onComplete = callbacks.onComplete || empty,
onChange = callbacks.onChange || empty,
_this = this;
fabric.util.animate({
startValue: object.get('left'),
endValue: this.getCenter().le... | javascript | function (object, callbacks) {
callbacks = callbacks || { };
var empty = function() { },
onComplete = callbacks.onComplete || empty,
onChange = callbacks.onChange || empty,
_this = this;
fabric.util.animate({
startValue: object.get('left'),
endValue: this.getCenter().le... | [
"function",
"(",
"object",
",",
"callbacks",
")",
"{",
"callbacks",
"=",
"callbacks",
"||",
"{",
"}",
";",
"var",
"empty",
"=",
"function",
"(",
")",
"{",
"}",
",",
"onComplete",
"=",
"callbacks",
".",
"onComplete",
"||",
"empty",
",",
"onChange",
"=",... | Centers object horizontally with animation.
@method fxCenterObjectH
@param {fabric.Object} object Object to center
@param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties
@return {fabric.Canvas} thisArg
@chainable | [
"Centers",
"object",
"horizontally",
"with",
"animation",
"."
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L7219-L7243 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function (callback) {
var data = JSON.stringify(this);
this.cloneWithoutData(function(clone) {
clone.loadFromJSON(data, function() {
callback && callback(clone);
});
});
} | javascript | function (callback) {
var data = JSON.stringify(this);
this.cloneWithoutData(function(clone) {
clone.loadFromJSON(data, function() {
callback && callback(clone);
});
});
} | [
"function",
"(",
"callback",
")",
"{",
"var",
"data",
"=",
"JSON",
".",
"stringify",
"(",
"this",
")",
";",
"this",
".",
"cloneWithoutData",
"(",
"function",
"(",
"clone",
")",
"{",
"clone",
".",
"loadFromJSON",
"(",
"data",
",",
"function",
"(",
")",
... | Clones canvas instance
@method clone
@param {Object} [callback] Receives cloned instance as a first argument | [
"Clones",
"canvas",
"instance"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L7546-L7553 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function() {
var NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS;
var object = {
type: this.type,
left: toFixed(this.left, NUM_FRACTION_DIGITS),
top: toFixed(this.top, NUM_FRACTION_DIGITS),
width: toFixed(this.width, N... | javascript | function() {
var NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS;
var object = {
type: this.type,
left: toFixed(this.left, NUM_FRACTION_DIGITS),
top: toFixed(this.top, NUM_FRACTION_DIGITS),
width: toFixed(this.width, N... | [
"function",
"(",
")",
"{",
"var",
"NUM_FRACTION_DIGITS",
"=",
"fabric",
".",
"Object",
".",
"NUM_FRACTION_DIGITS",
";",
"var",
"object",
"=",
"{",
"type",
":",
"this",
".",
"type",
",",
"left",
":",
"toFixed",
"(",
"this",
".",
"left",
",",
"NUM_FRACTION... | Returns an object representation of an instance
@method toObject
@return {Object} | [
"Returns",
"an",
"object",
"representation",
"of",
"an",
"instance"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L7882-L7916 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function() {
return [
"stroke: ", (this.stroke ? this.stroke : 'none'), "; ",
"stroke-width: ", (this.strokeWidth ? this.strokeWidth : '0'), "; ",
"stroke-dasharray: ", (this.strokeDashArray ? this.strokeDashArray.join(' ') : "; "),
"fill: ", (this.fill ? this.fill : 'none'), "; ",... | javascript | function() {
return [
"stroke: ", (this.stroke ? this.stroke : 'none'), "; ",
"stroke-width: ", (this.strokeWidth ? this.strokeWidth : '0'), "; ",
"stroke-dasharray: ", (this.strokeDashArray ? this.strokeDashArray.join(' ') : "; "),
"fill: ", (this.fill ? this.fill : 'none'), "; ",... | [
"function",
"(",
")",
"{",
"return",
"[",
"\"stroke: \"",
",",
"(",
"this",
".",
"stroke",
"?",
"this",
".",
"stroke",
":",
"'none'",
")",
",",
"\"; \"",
",",
"\"stroke-width: \"",
",",
"(",
"this",
".",
"strokeWidth",
"?",
"this",
".",
"strokeWidth",
... | Returns styles-string for svg-export
@method getSvgStyles
@return {string} | [
"Returns",
"styles",
"-",
"string",
"for",
"svg",
"-",
"export"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L7932-L7940 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function() {
var angle = this.getAngle();
return [
"translate(", toFixed(this.left, 2), " ", toFixed(this.top, 2), ")",
angle !== 0 ? (" rotate(" + toFixed(angle, 2) + ")") : '',
(this.scaleX === 1 && this.scaleY === 1) ? '' : (" scale(" + toFixed(this.scaleX, 2) + " " + toFixed(this... | javascript | function() {
var angle = this.getAngle();
return [
"translate(", toFixed(this.left, 2), " ", toFixed(this.top, 2), ")",
angle !== 0 ? (" rotate(" + toFixed(angle, 2) + ")") : '',
(this.scaleX === 1 && this.scaleY === 1) ? '' : (" scale(" + toFixed(this.scaleX, 2) + " " + toFixed(this... | [
"function",
"(",
")",
"{",
"var",
"angle",
"=",
"this",
".",
"getAngle",
"(",
")",
";",
"return",
"[",
"\"translate(\"",
",",
"toFixed",
"(",
"this",
".",
"left",
",",
"2",
")",
",",
"\" \"",
",",
"toFixed",
"(",
"this",
".",
"top",
",",
"2",
")"... | Returns transform-string for svg-export
@method getSvgTransform
@return {string} | [
"Returns",
"transform",
"-",
"string",
"for",
"svg",
"-",
"export"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L7947-L7954 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(key, value) {
if (typeof key === 'object') {
for (var prop in key) {
this._set(prop, key[prop]);
}
}
else {
if (typeof value === 'function') {
this._set(key, value(this.get(key)));
}
else {
this._set(key, value);
}
... | javascript | function(key, value) {
if (typeof key === 'object') {
for (var prop in key) {
this._set(prop, key[prop]);
}
}
else {
if (typeof value === 'function') {
this._set(key, value(this.get(key)));
}
else {
this._set(key, value);
}
... | [
"function",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"key",
"===",
"'object'",
")",
"{",
"for",
"(",
"var",
"prop",
"in",
"key",
")",
"{",
"this",
".",
"_set",
"(",
"prop",
",",
"key",
"[",
"prop",
"]",
")",
";",
"}",
"}",
"el... | Sets property to a given value
@method set
@param {String} name
@param {Object|Function} value
@return {fabric.Group} thisArg
@chainable | [
"Sets",
"property",
"to",
"a",
"given",
"value"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L8007-L8022 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function() {
this.oCoords || this.setCoords();
var xCoords = [this.oCoords.tl.x, this.oCoords.tr.x, this.oCoords.br.x, this.oCoords.bl.x];
var minX = fabric.util.array.min(xCoords);
var maxX = fabric.util.array.max(xCoords);
return Math.abs(minX - maxX);
} | javascript | function() {
this.oCoords || this.setCoords();
var xCoords = [this.oCoords.tl.x, this.oCoords.tr.x, this.oCoords.br.x, this.oCoords.bl.x];
var minX = fabric.util.array.min(xCoords);
var maxX = fabric.util.array.max(xCoords);
return Math.abs(minX - maxX);
} | [
"function",
"(",
")",
"{",
"this",
".",
"oCoords",
"||",
"this",
".",
"setCoords",
"(",
")",
";",
"var",
"xCoords",
"=",
"[",
"this",
".",
"oCoords",
".",
"tl",
".",
"x",
",",
"this",
".",
"oCoords",
".",
"tr",
".",
"x",
",",
"this",
".",
"oCoo... | Returns width of an object's bounding rectangle
@method getBoundingRectWidth
@return {Number} width value | [
"Returns",
"width",
"of",
"an",
"object",
"s",
"bounding",
"rectangle"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L8309-L8315 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function() {
this.oCoords || this.setCoords();
var yCoords = [this.oCoords.tl.y, this.oCoords.tr.y, this.oCoords.br.y, this.oCoords.bl.y];
var minY = fabric.util.array.min(yCoords);
var maxY = fabric.util.array.max(yCoords);
return Math.abs(minY - maxY);
} | javascript | function() {
this.oCoords || this.setCoords();
var yCoords = [this.oCoords.tl.y, this.oCoords.tr.y, this.oCoords.br.y, this.oCoords.bl.y];
var minY = fabric.util.array.min(yCoords);
var maxY = fabric.util.array.max(yCoords);
return Math.abs(minY - maxY);
} | [
"function",
"(",
")",
"{",
"this",
".",
"oCoords",
"||",
"this",
".",
"setCoords",
"(",
")",
";",
"var",
"yCoords",
"=",
"[",
"this",
".",
"oCoords",
".",
"tl",
".",
"y",
",",
"this",
".",
"oCoords",
".",
"tr",
".",
"y",
",",
"this",
".",
"oCoo... | Returns height of an object's bounding rectangle
@method getBoundingRectHeight
@return {Number} height value | [
"Returns",
"height",
"of",
"an",
"object",
"s",
"bounding",
"rectangle"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L8322-L8328 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(options) {
if (this.constructor.fromObject) {
return this.constructor.fromObject(this.toObject(), options);
}
return new fabric.Object(this.toObject());
} | javascript | function(options) {
if (this.constructor.fromObject) {
return this.constructor.fromObject(this.toObject(), options);
}
return new fabric.Object(this.toObject());
} | [
"function",
"(",
"options",
")",
"{",
"if",
"(",
"this",
".",
"constructor",
".",
"fromObject",
")",
"{",
"return",
"this",
".",
"constructor",
".",
"fromObject",
"(",
"this",
".",
"toObject",
"(",
")",
",",
"options",
")",
";",
"}",
"return",
"new",
... | Clones an instance
@method clone
@param {Object} options object
@return {fabric.Object} clone of an instance | [
"Clones",
"an",
"instance"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L8567-L8572 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(callback) {
if (fabric.Image) {
var i = new Image();
/** @ignore */
i.onload = function() {
if (callback) {
callback(new fabric.Image(i), orig);
}
i = i.onload = null;
};
var orig = {
angle: this.get('angle'),
... | javascript | function(callback) {
if (fabric.Image) {
var i = new Image();
/** @ignore */
i.onload = function() {
if (callback) {
callback(new fabric.Image(i), orig);
}
i = i.onload = null;
};
var orig = {
angle: this.get('angle'),
... | [
"function",
"(",
"callback",
")",
"{",
"if",
"(",
"fabric",
".",
"Image",
")",
"{",
"var",
"i",
"=",
"new",
"Image",
"(",
")",
";",
"/** @ignore */",
"i",
".",
"onload",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"callback",
")",
"{",
"callback",
... | Creates an instance of fabric.Image out of an object
@method cloneAsImage
@param callback {Function} callback, invoked with an instance as a first argument
@return {fabric.Object} thisArg
@chainable | [
"Creates",
"an",
"instance",
"of",
"fabric",
".",
"Image",
"out",
"of",
"an",
"object"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L8581-L8606 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(callback) {
var el = fabric.document.createElement('canvas');
if (!el.getContext && typeof G_vmlCanvasManager != 'undefined') {
G_vmlCanvasManager.initElement(el);
}
el.width = this.getBoundingRectWidth();
el.height = this.getBoundingRectHeight();
fabric.util.wrapE... | javascript | function(callback) {
var el = fabric.document.createElement('canvas');
if (!el.getContext && typeof G_vmlCanvasManager != 'undefined') {
G_vmlCanvasManager.initElement(el);
}
el.width = this.getBoundingRectWidth();
el.height = this.getBoundingRectHeight();
fabric.util.wrapE... | [
"function",
"(",
"callback",
")",
"{",
"var",
"el",
"=",
"fabric",
".",
"document",
".",
"createElement",
"(",
"'canvas'",
")",
";",
"if",
"(",
"!",
"el",
".",
"getContext",
"&&",
"typeof",
"G_vmlCanvasManager",
"!=",
"'undefined'",
")",
"{",
"G_vmlCanvasM... | Converts an object into a data-url-like string
@method toDataURL
@return {String} string of data | [
"Converts",
"an",
"object",
"into",
"a",
"data",
"-",
"url",
"-",
"like",
"string"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L8613-L8649 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(selectionTL, selectionBR) {
var oCoords = this.oCoords,
tl = new fabric.Point(oCoords.tl.x, oCoords.tl.y),
tr = new fabric.Point(oCoords.tr.x, oCoords.tr.y),
bl = new fabric.Point(oCoords.bl.x, oCoords.bl.y),
br = new fabric.Point(oCoords.br.x, oCoords.br.y);
... | javascript | function(selectionTL, selectionBR) {
var oCoords = this.oCoords,
tl = new fabric.Point(oCoords.tl.x, oCoords.tl.y),
tr = new fabric.Point(oCoords.tr.x, oCoords.tr.y),
bl = new fabric.Point(oCoords.bl.x, oCoords.bl.y),
br = new fabric.Point(oCoords.br.x, oCoords.br.y);
... | [
"function",
"(",
"selectionTL",
",",
"selectionBR",
")",
"{",
"var",
"oCoords",
"=",
"this",
".",
"oCoords",
",",
"tl",
"=",
"new",
"fabric",
".",
"Point",
"(",
"oCoords",
".",
"tl",
".",
"x",
",",
"oCoords",
".",
"tl",
".",
"y",
")",
",",
"tr",
... | Returns true if object intersects with an area formed by 2 points
@method intersectsWithRect
@param {Object} selectionTL
@param {Object} selectionBR
@return {Boolean} | [
"Returns",
"true",
"if",
"object",
"intersects",
"with",
"an",
"area",
"formed",
"by",
"2",
"points"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L8688-L8701 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(other) {
// extracts coords
function getCoords(oCoords) {
return {
tl: new fabric.Point(oCoords.tl.x, oCoords.tl.y),
tr: new fabric.Point(oCoords.tr.x, oCoords.tr.y),
bl: new fabric.Point(oCoords.bl.x, oCoords.bl.y),
br: new fabric.Point(oCoords.br.x,... | javascript | function(other) {
// extracts coords
function getCoords(oCoords) {
return {
tl: new fabric.Point(oCoords.tl.x, oCoords.tl.y),
tr: new fabric.Point(oCoords.tr.x, oCoords.tr.y),
bl: new fabric.Point(oCoords.bl.x, oCoords.bl.y),
br: new fabric.Point(oCoords.br.x,... | [
"function",
"(",
"other",
")",
"{",
"// extracts coords",
"function",
"getCoords",
"(",
"oCoords",
")",
"{",
"return",
"{",
"tl",
":",
"new",
"fabric",
".",
"Point",
"(",
"oCoords",
".",
"tl",
".",
"x",
",",
"oCoords",
".",
"tl",
".",
"y",
")",
",",
... | Returns true if object intersects with another object
@method intersectsWithObject
@param {Object} other Object to test
@return {Boolean} | [
"Returns",
"true",
"if",
"object",
"intersects",
"with",
"another",
"object"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L8709-L8728 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(selectionTL, selectionBR) {
var oCoords = this.oCoords,
tl = new fabric.Point(oCoords.tl.x, oCoords.tl.y),
tr = new fabric.Point(oCoords.tr.x, oCoords.tr.y),
bl = new fabric.Point(oCoords.bl.x, oCoords.bl.y),
br = new fabric.Point(oCoords.br.x, oCoords.br.y);
... | javascript | function(selectionTL, selectionBR) {
var oCoords = this.oCoords,
tl = new fabric.Point(oCoords.tl.x, oCoords.tl.y),
tr = new fabric.Point(oCoords.tr.x, oCoords.tr.y),
bl = new fabric.Point(oCoords.bl.x, oCoords.bl.y),
br = new fabric.Point(oCoords.br.x, oCoords.br.y);
... | [
"function",
"(",
"selectionTL",
",",
"selectionBR",
")",
"{",
"var",
"oCoords",
"=",
"this",
".",
"oCoords",
",",
"tl",
"=",
"new",
"fabric",
".",
"Point",
"(",
"oCoords",
".",
"tl",
".",
"x",
",",
"oCoords",
".",
"tl",
".",
"y",
")",
",",
"tr",
... | Returns true if object is fully contained within area formed by 2 points
@method isContainedWithinRect
@param {Object} selectionTL
@param {Object} selectionBR
@return {Boolean} | [
"Returns",
"true",
"if",
"object",
"is",
"fully",
"contained",
"within",
"area",
"formed",
"by",
"2",
"points"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L8747-L8758 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(e, offset) {
if (!this.hasControls || !this.active) return false;
var pointer = getPointer(e),
ex = pointer.x - offset.left,
ey = pointer.y - offset.top,
xpoints,
lines;
for (var i in this.oCoords) {
if (i === 'mtr' && !this.hasRotatingPoint)... | javascript | function(e, offset) {
if (!this.hasControls || !this.active) return false;
var pointer = getPointer(e),
ex = pointer.x - offset.left,
ey = pointer.y - offset.top,
xpoints,
lines;
for (var i in this.oCoords) {
if (i === 'mtr' && !this.hasRotatingPoint)... | [
"function",
"(",
"e",
",",
"offset",
")",
"{",
"if",
"(",
"!",
"this",
".",
"hasControls",
"||",
"!",
"this",
".",
"active",
")",
"return",
"false",
";",
"var",
"pointer",
"=",
"getPointer",
"(",
"e",
")",
",",
"ex",
"=",
"pointer",
".",
"x",
"-"... | Determines which one of the four corners has been clicked
@method _findTargetCorner
@private
@param e {Event} event object
@param offset {Object} canvas offset
@return {String|Boolean} corner code (tl, tr, bl, br, etc.), or false if nothing is found | [
"Determines",
"which",
"one",
"of",
"the",
"four",
"corners",
"has",
"been",
"clicked"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L8777-L8819 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(ex, ey, oCoords) {
var b1, b2, a1, a2, xi, yi,
xcount = 0,
iLine;
for (var lineKey in oCoords) {
iLine = oCoords[lineKey];
// optimisation 1: line below dot. no cross
if ((iLine.o.y < ey) && (iLine.d.y < ey)) {
continue;
}
// op... | javascript | function(ex, ey, oCoords) {
var b1, b2, a1, a2, xi, yi,
xcount = 0,
iLine;
for (var lineKey in oCoords) {
iLine = oCoords[lineKey];
// optimisation 1: line below dot. no cross
if ((iLine.o.y < ey) && (iLine.d.y < ey)) {
continue;
}
// op... | [
"function",
"(",
"ex",
",",
"ey",
",",
"oCoords",
")",
"{",
"var",
"b1",
",",
"b2",
",",
"a1",
",",
"a2",
",",
"xi",
",",
"yi",
",",
"xcount",
"=",
"0",
",",
"iLine",
";",
"for",
"(",
"var",
"lineKey",
"in",
"oCoords",
")",
"{",
"iLine",
"=",... | Helper method to determine how many cross points are between the 4 image edges
and the horizontal line determined by the position of our mouse when clicked on canvas
@method _findCrossPoints
@private
@param ex {Number} x coordinate of the mouse
@param ey {Number} y coordinate of the mouse
@param oCoords {Object} Coordi... | [
"Helper",
"method",
"to",
"determine",
"how",
"many",
"cross",
"points",
"are",
"between",
"the",
"4",
"image",
"edges",
"and",
"the",
"horizontal",
"line",
"determined",
"by",
"the",
"position",
"of",
"our",
"mouse",
"when",
"clicked",
"on",
"canvas"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L8830-L8870 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(oCoords, i) {
return {
topline: {
o: oCoords.tl,
d: oCoords.tr
},
rightline: {
o: oCoords.tr,
d: oCoords.br
},
bottomline: {
o: oCoords.br,
d: oCoords.bl
},
leftline: {
o: oCoords... | javascript | function(oCoords, i) {
return {
topline: {
o: oCoords.tl,
d: oCoords.tr
},
rightline: {
o: oCoords.tr,
d: oCoords.br
},
bottomline: {
o: oCoords.br,
d: oCoords.bl
},
leftline: {
o: oCoords... | [
"function",
"(",
"oCoords",
",",
"i",
")",
"{",
"return",
"{",
"topline",
":",
"{",
"o",
":",
"oCoords",
".",
"tl",
",",
"d",
":",
"oCoords",
".",
"tr",
"}",
",",
"rightline",
":",
"{",
"o",
":",
"oCoords",
".",
"tr",
",",
"d",
":",
"oCoords",
... | Method that returns an object with the image lines in it given the coordinates of the corners
@method _getImageLines
@private
@param oCoords {Object} coordinates of the image corners | [
"Method",
"that",
"returns",
"an",
"object",
"with",
"the",
"image",
"lines",
"in",
"it",
"given",
"the",
"coordinates",
"of",
"the",
"corners"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L8878-L8897 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(parsedAttributes) {
if (parsedAttributes.left) {
this.set('left', parsedAttributes.left + this.getWidth() / 2);
}
this.set('x', parsedAttributes.left || 0);
if (parsedAttributes.top) {
this.set('top', parsedAttributes.top + this.getHeight() / 2);
}
this.set('... | javascript | function(parsedAttributes) {
if (parsedAttributes.left) {
this.set('left', parsedAttributes.left + this.getWidth() / 2);
}
this.set('x', parsedAttributes.left || 0);
if (parsedAttributes.top) {
this.set('top', parsedAttributes.top + this.getHeight() / 2);
}
this.set('... | [
"function",
"(",
"parsedAttributes",
")",
"{",
"if",
"(",
"parsedAttributes",
".",
"left",
")",
"{",
"this",
".",
"set",
"(",
"'left'",
",",
"parsedAttributes",
".",
"left",
"+",
"this",
".",
"getWidth",
"(",
")",
"/",
"2",
")",
";",
"}",
"this",
"."... | since our coordinate system differs from that of SVG | [
"since",
"our",
"coordinate",
"system",
"differs",
"from",
"that",
"of",
"SVG"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L10067-L10077 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(ctx, noTransform) {
ctx.save();
var m = this.transformMatrix;
if (m) {
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
}
if (!noTransform) {
this.transform(ctx);
}
// ctx.globalCompositeOperation = this.fillRule;
if (this.overlayFill) {
... | javascript | function(ctx, noTransform) {
ctx.save();
var m = this.transformMatrix;
if (m) {
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
}
if (!noTransform) {
this.transform(ctx);
}
// ctx.globalCompositeOperation = this.fillRule;
if (this.overlayFill) {
... | [
"function",
"(",
"ctx",
",",
"noTransform",
")",
"{",
"ctx",
".",
"save",
"(",
")",
";",
"var",
"m",
"=",
"this",
".",
"transformMatrix",
";",
"if",
"(",
"m",
")",
"{",
"ctx",
".",
"transform",
"(",
"m",
"[",
"0",
"]",
",",
"m",
"[",
"1",
"]"... | Renders path on a specified context
@method render
@param {CanvasRenderingContext2D} ctx context to render path on
@param {Boolean} noTransform When true, context is not transformed | [
"Renders",
"path",
"on",
"a",
"specified",
"context"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L10995-L11036 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(ctx) {
ctx.save();
var m = this.transformMatrix;
if (m) {
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
}
this.transform(ctx);
for (var i = 0, l = this.paths.length; i < l; ++i) {
this.paths[i].render(ctx, true);
}
if (this.active) {
... | javascript | function(ctx) {
ctx.save();
var m = this.transformMatrix;
if (m) {
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
}
this.transform(ctx);
for (var i = 0, l = this.paths.length; i < l; ++i) {
this.paths[i].render(ctx, true);
}
if (this.active) {
... | [
"function",
"(",
"ctx",
")",
"{",
"ctx",
".",
"save",
"(",
")",
";",
"var",
"m",
"=",
"this",
".",
"transformMatrix",
";",
"if",
"(",
"m",
")",
"{",
"ctx",
".",
"transform",
"(",
"m",
"[",
"0",
"]",
",",
"m",
"[",
"1",
"]",
",",
"m",
"[",
... | Renders this group on a specified context
@method render
@param {CanvasRenderingContext2D} ctx Context to render this instance on | [
"Renders",
"this",
"group",
"on",
"a",
"specified",
"context"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L11321-L11338 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(prop, value) {
if ((prop === 'fill' || prop === 'overlayFill') && value && this.isSameColor()) {
var i = this.paths.length;
while (i--) {
this.paths[i]._set(prop, value);
}
}
return this.callSuper('_set', prop, value);
} | javascript | function(prop, value) {
if ((prop === 'fill' || prop === 'overlayFill') && value && this.isSameColor()) {
var i = this.paths.length;
while (i--) {
this.paths[i]._set(prop, value);
}
}
return this.callSuper('_set', prop, value);
} | [
"function",
"(",
"prop",
",",
"value",
")",
"{",
"if",
"(",
"(",
"prop",
"===",
"'fill'",
"||",
"prop",
"===",
"'overlayFill'",
")",
"&&",
"value",
"&&",
"this",
".",
"isSameColor",
"(",
")",
")",
"{",
"var",
"i",
"=",
"this",
".",
"paths",
".",
... | Sets certain property to a certain value
@method _set
@param {String} prop
@param {Any} value
@return {fabric.PathGroup} thisArg | [
"Sets",
"certain",
"property",
"to",
"a",
"certain",
"value"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L11347-L11357 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function() {
return this.paths.reduce(function(total, path) {
return total + ((path && path.complexity) ? path.complexity() : 0);
}, 0);
} | javascript | function() {
return this.paths.reduce(function(total, path) {
return total + ((path && path.complexity) ? path.complexity() : 0);
}, 0);
} | [
"function",
"(",
")",
"{",
"return",
"this",
".",
"paths",
".",
"reduce",
"(",
"function",
"(",
"total",
",",
"path",
")",
"{",
"return",
"total",
"+",
"(",
"(",
"path",
"&&",
"path",
".",
"complexity",
")",
"?",
"path",
".",
"complexity",
"(",
")"... | Returns number representation of object's complexity
@method complexity
@return {Number} complexity | [
"Returns",
"number",
"representation",
"of",
"object",
"s",
"complexity"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L11435-L11439 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(object) {
this._restoreObjectsState();
removeFromArray(this.objects, object);
object.setActive(false);
this._calcBounds();
this._updateObjectsCoords();
return this;
} | javascript | function(object) {
this._restoreObjectsState();
removeFromArray(this.objects, object);
object.setActive(false);
this._calcBounds();
this._updateObjectsCoords();
return this;
} | [
"function",
"(",
"object",
")",
"{",
"this",
".",
"_restoreObjectsState",
"(",
")",
";",
"removeFromArray",
"(",
"this",
".",
"objects",
",",
"object",
")",
";",
"object",
".",
"setActive",
"(",
"false",
")",
";",
"this",
".",
"_calcBounds",
"(",
")",
... | Removes an object from a group; Then recalculates group's dimension, position.
@method removeWithUpdate
@param {Object} object
@return {fabric.Group} thisArg
@chainable | [
"Removes",
"an",
"object",
"from",
"a",
"group",
";",
"Then",
"recalculates",
"group",
"s",
"dimension",
"position",
"."
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L11612-L11619 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(ctx, noTransform) {
ctx.save();
this.transform(ctx);
var groupScaleFactor = Math.max(this.scaleX, this.scaleY);
for (var i = 0, len = this.objects.length, object; object = this.objects[i]; i++) {
var originalScaleFactor = object.borderScaleFactor;
object.borderScaleFac... | javascript | function(ctx, noTransform) {
ctx.save();
this.transform(ctx);
var groupScaleFactor = Math.max(this.scaleX, this.scaleY);
for (var i = 0, len = this.objects.length, object; object = this.objects[i]; i++) {
var originalScaleFactor = object.borderScaleFactor;
object.borderScaleFac... | [
"function",
"(",
"ctx",
",",
"noTransform",
")",
"{",
"ctx",
".",
"save",
"(",
")",
";",
"this",
".",
"transform",
"(",
"ctx",
")",
";",
"var",
"groupScaleFactor",
"=",
"Math",
".",
"max",
"(",
"this",
".",
"scaleX",
",",
"this",
".",
"scaleY",
")"... | Renders instance on a given context
@method render
@param {CanvasRenderingContext2D} ctx context to render instance on | [
"Renders",
"instance",
"on",
"a",
"given",
"context"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L11695-L11713 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function() {
return this.getObjects().reduce(function(total, object) {
total += (typeof object.complexity == 'function') ? object.complexity() : 0;
return total;
}, 0);
} | javascript | function() {
return this.getObjects().reduce(function(total, object) {
total += (typeof object.complexity == 'function') ? object.complexity() : 0;
return total;
}, 0);
} | [
"function",
"(",
")",
"{",
"return",
"this",
".",
"getObjects",
"(",
")",
".",
"reduce",
"(",
"function",
"(",
"total",
",",
"object",
")",
"{",
"total",
"+=",
"(",
"typeof",
"object",
".",
"complexity",
"==",
"'function'",
")",
"?",
"object",
".",
"... | Returns complexity of an instance
@method complexity
@return {Number} complexity | [
"Returns",
"complexity",
"of",
"an",
"instance"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L11730-L11735 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(object) {
var groupLeft = this.get('left'),
groupTop = this.get('top'),
groupAngle = this.getAngle() * (Math.PI / 180),
objectLeft = object.get('originalLeft'),
objectTop = object.get('originalTop'),
rotatedTop = Math.cos(groupAngle) * object.get('top') ... | javascript | function(object) {
var groupLeft = this.get('left'),
groupTop = this.get('top'),
groupAngle = this.getAngle() * (Math.PI / 180),
objectLeft = object.get('originalLeft'),
objectTop = object.get('originalTop'),
rotatedTop = Math.cos(groupAngle) * object.get('top') ... | [
"function",
"(",
"object",
")",
"{",
"var",
"groupLeft",
"=",
"this",
".",
"get",
"(",
"'left'",
")",
",",
"groupTop",
"=",
"this",
".",
"get",
"(",
"'top'",
")",
",",
"groupAngle",
"=",
"this",
".",
"getAngle",
"(",
")",
"*",
"(",
"Math",
".",
"... | Restores original state of a specified object in group
@private
@method _restoreObjectState
@param {fabric.Object} object
@return {fabric.Group} thisArg | [
"Restores",
"original",
"state",
"of",
"a",
"specified",
"object",
"in",
"group"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L11756-L11780 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(point) {
var halfWidth = this.get('width') / 2,
halfHeight = this.get('height') / 2,
centerX = this.get('left'),
centerY = this.get('top');
return centerX - halfWidth < point.x &&
centerX + halfWidth > point.x &&
centerY - halfHeight < po... | javascript | function(point) {
var halfWidth = this.get('width') / 2,
halfHeight = this.get('height') / 2,
centerX = this.get('left'),
centerY = this.get('top');
return centerX - halfWidth < point.x &&
centerX + halfWidth > point.x &&
centerY - halfHeight < po... | [
"function",
"(",
"point",
")",
"{",
"var",
"halfWidth",
"=",
"this",
".",
"get",
"(",
"'width'",
")",
"/",
"2",
",",
"halfHeight",
"=",
"this",
".",
"get",
"(",
"'height'",
")",
"/",
"2",
",",
"centerX",
"=",
"this",
".",
"get",
"(",
"'left'",
")... | Checks if point is contained within the group
@method containsPoint
@param {fabric.Point} point point with `x` and `y` properties
@return {Boolean} true if point is contained within group | [
"Checks",
"if",
"point",
"is",
"contained",
"within",
"the",
"group"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L11915-L11926 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(ctx, noTransform) {
ctx.save();
var m = this.transformMatrix;
this._resetWidthHeight();
if (this.group) {
ctx.translate(-this.group.width/2 + this.width/2, -this.group.height/2 + this.height/2);
}
if (m) {
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
... | javascript | function(ctx, noTransform) {
ctx.save();
var m = this.transformMatrix;
this._resetWidthHeight();
if (this.group) {
ctx.translate(-this.group.width/2 + this.width/2, -this.group.height/2 + this.height/2);
}
if (m) {
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
... | [
"function",
"(",
"ctx",
",",
"noTransform",
")",
"{",
"ctx",
".",
"save",
"(",
")",
";",
"var",
"m",
"=",
"this",
".",
"transformMatrix",
";",
"this",
".",
"_resetWidthHeight",
"(",
")",
";",
"if",
"(",
"this",
".",
"group",
")",
"{",
"ctx",
".",
... | Renders image on a specified context
@method render
@param {CanvasRenderingContext2D} ctx Context to render on | [
"Renders",
"image",
"on",
"a",
"specified",
"context"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L12106-L12125 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(element) {
this.setElement(fabric.util.getById(element));
fabric.util.addClass(this.getElement(), fabric.Image.CSS_CANVAS);
} | javascript | function(element) {
this.setElement(fabric.util.getById(element));
fabric.util.addClass(this.getElement(), fabric.Image.CSS_CANVAS);
} | [
"function",
"(",
"element",
")",
"{",
"this",
".",
"setElement",
"(",
"fabric",
".",
"util",
".",
"getById",
"(",
"element",
")",
")",
";",
"fabric",
".",
"util",
".",
"addClass",
"(",
"this",
".",
"getElement",
"(",
")",
",",
"fabric",
".",
"Image",... | The Image class's initialization method. This method is automatically
called by the constructor.
@method _initElement
@param {HTMLImageElement|String} el The element representing the image | [
"The",
"Image",
"class",
"s",
"initialization",
"method",
".",
"This",
"method",
"is",
"automatically",
"called",
"by",
"the",
"constructor",
"."
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L12283-L12286 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function() {
var canvasEl = fabric.document.createElement('canvas');
if (!canvasEl.getContext && typeof G_vmlCanvasManager != 'undefined') {
G_vmlCanvasManager.initElement(canvasEl);
}
this._render(canvasEl.getContext('2d'));
} | javascript | function() {
var canvasEl = fabric.document.createElement('canvas');
if (!canvasEl.getContext && typeof G_vmlCanvasManager != 'undefined') {
G_vmlCanvasManager.initElement(canvasEl);
}
this._render(canvasEl.getContext('2d'));
} | [
"function",
"(",
")",
"{",
"var",
"canvasEl",
"=",
"fabric",
".",
"document",
".",
"createElement",
"(",
"'canvas'",
")",
";",
"if",
"(",
"!",
"canvasEl",
".",
"getContext",
"&&",
"typeof",
"G_vmlCanvasManager",
"!=",
"'undefined'",
")",
"{",
"G_vmlCanvasMan... | Renders text object on offscreen canvas, so that it would get dimensions
@private
@method _initDimensions | [
"Renders",
"text",
"object",
"on",
"offscreen",
"canvas",
"so",
"that",
"it",
"would",
"get",
"dimensions"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L13168-L13176 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(ctx, noTransform) {
ctx.save();
this._render(ctx);
if (!noTransform && this.active) {
this.drawBorders(ctx);
this.hideCorners || this.drawCorners(ctx);
}
ctx.restore();
} | javascript | function(ctx, noTransform) {
ctx.save();
this._render(ctx);
if (!noTransform && this.active) {
this.drawBorders(ctx);
this.hideCorners || this.drawCorners(ctx);
}
ctx.restore();
} | [
"function",
"(",
"ctx",
",",
"noTransform",
")",
"{",
"ctx",
".",
"save",
"(",
")",
";",
"this",
".",
"_render",
"(",
"ctx",
")",
";",
"if",
"(",
"!",
"noTransform",
"&&",
"this",
".",
"active",
")",
"{",
"this",
".",
"drawBorders",
"(",
"ctx",
"... | Renders text instance on a specified context
@method render
@param ctx {CanvasRenderingContext2D} context to render on | [
"Renders",
"text",
"instance",
"on",
"a",
"specified",
"context"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L13554-L13562 | train | |
MrSwitch/hello.js | demos/Collage/fabric.js | function(name, value) {
if (name === 'fontFamily' && this.path) {
this.path = this.path.replace(/(.*?)([^\/]*)(\.font\.js)/, '$1' + value + '$3');
}
this.callSuper('_set', name, value);
} | javascript | function(name, value) {
if (name === 'fontFamily' && this.path) {
this.path = this.path.replace(/(.*?)([^\/]*)(\.font\.js)/, '$1' + value + '$3');
}
this.callSuper('_set', name, value);
} | [
"function",
"(",
"name",
",",
"value",
")",
"{",
"if",
"(",
"name",
"===",
"'fontFamily'",
"&&",
"this",
".",
"path",
")",
"{",
"this",
".",
"path",
"=",
"this",
".",
"path",
".",
"replace",
"(",
"/",
"(.*?)([^\\/]*)(\\.font\\.js)",
"/",
",",
"'$1'",
... | Sets specified property to a specified value
@method set
@param {String} name
@param {Any} value
@return {fabric.Text} thisArg
@chainable | [
"Sets",
"specified",
"property",
"to",
"a",
"specified",
"value"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/Collage/fabric.js#L13776-L13781 | train | |
MrSwitch/hello.js | assets/knockout/src/subscribables/subscribable.js | limitNotifySubscribers | function limitNotifySubscribers(value, event) {
if (!event || event === defaultEvent) {
this._limitChange(value);
} else if (event === 'beforeChange') {
this._limitBeforeChange(value);
} else {
this._origNotifySubscribers(value, event);
}
} | javascript | function limitNotifySubscribers(value, event) {
if (!event || event === defaultEvent) {
this._limitChange(value);
} else if (event === 'beforeChange') {
this._limitBeforeChange(value);
} else {
this._origNotifySubscribers(value, event);
}
} | [
"function",
"limitNotifySubscribers",
"(",
"value",
",",
"event",
")",
"{",
"if",
"(",
"!",
"event",
"||",
"event",
"===",
"defaultEvent",
")",
"{",
"this",
".",
"_limitChange",
"(",
"value",
")",
";",
"}",
"else",
"if",
"(",
"event",
"===",
"'beforeChan... | Moved out of "limit" to avoid the extra closure | [
"Moved",
"out",
"of",
"limit",
"to",
"avoid",
"the",
"extra",
"closure"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/assets/knockout/src/subscribables/subscribable.js#L22-L30 | train |
MrSwitch/hello.js | assets/knockout/src/binding/bindingAttributeSyntax.js | makeAccessorsFromFunction | function makeAccessorsFromFunction(callback) {
return ko.utils.objectMap(ko.dependencyDetection.ignore(callback), function(value, key) {
return function() {
return callback()[key];
};
});
} | javascript | function makeAccessorsFromFunction(callback) {
return ko.utils.objectMap(ko.dependencyDetection.ignore(callback), function(value, key) {
return function() {
return callback()[key];
};
});
} | [
"function",
"makeAccessorsFromFunction",
"(",
"callback",
")",
"{",
"return",
"ko",
".",
"utils",
".",
"objectMap",
"(",
"ko",
".",
"dependencyDetection",
".",
"ignore",
"(",
"callback",
")",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"return",
"... | Given a function that returns bindings, create and return a new object that contains binding value-accessors functions. Each accessor function calls the original function so that it always gets the latest value and all dependencies are captured. This is used by ko.applyBindingsToNode and getBindingsAndMakeAccessors. | [
"Given",
"a",
"function",
"that",
"returns",
"bindings",
"create",
"and",
"return",
"a",
"new",
"object",
"that",
"contains",
"binding",
"value",
"-",
"accessors",
"functions",
".",
"Each",
"accessor",
"function",
"calls",
"the",
"original",
"function",
"so",
... | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/assets/knockout/src/binding/bindingAttributeSyntax.js#L158-L164 | train |
MrSwitch/hello.js | assets/css-social-buttons/site/html5slider.js | update | function update() {
min = isAttrNum(slider.min) ? +slider.min : 0;
max = isAttrNum(slider.max) ? +slider.max : 100;
if (max < min)
max = min > 100 ? min : 100;
step = isAttrNum(slider.step) && slider.step > 0 ? +slider.step : 1;
range = max - min;
draw(true);
} | javascript | function update() {
min = isAttrNum(slider.min) ? +slider.min : 0;
max = isAttrNum(slider.max) ? +slider.max : 100;
if (max < min)
max = min > 100 ? min : 100;
step = isAttrNum(slider.step) && slider.step > 0 ? +slider.step : 1;
range = max - min;
draw(true);
} | [
"function",
"update",
"(",
")",
"{",
"min",
"=",
"isAttrNum",
"(",
"slider",
".",
"min",
")",
"?",
"+",
"slider",
".",
"min",
":",
"0",
";",
"max",
"=",
"isAttrNum",
"(",
"slider",
".",
"max",
")",
"?",
"+",
"slider",
".",
"max",
":",
"100",
";... | validates min, max, and step attributes and redraws | [
"validates",
"min",
"max",
"and",
"step",
"attributes",
"and",
"redraws"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/assets/css-social-buttons/site/html5slider.js#L220-L228 | train |
MrSwitch/hello.js | assets/css-social-buttons/site/html5slider.js | calc | function calc() {
if (!isValueSet && !areAttrsSet)
value = slider.getAttribute('value');
if (!isAttrNum(value))
value = (min + max) / 2;;
// snap to step intervals (WebKit sometimes does not - bug?)
value = Math.round((value - min) / step) * step + min;
if (value < min)
value = min... | javascript | function calc() {
if (!isValueSet && !areAttrsSet)
value = slider.getAttribute('value');
if (!isAttrNum(value))
value = (min + max) / 2;;
// snap to step intervals (WebKit sometimes does not - bug?)
value = Math.round((value - min) / step) * step + min;
if (value < min)
value = min... | [
"function",
"calc",
"(",
")",
"{",
"if",
"(",
"!",
"isValueSet",
"&&",
"!",
"areAttrsSet",
")",
"value",
"=",
"slider",
".",
"getAttribute",
"(",
"'value'",
")",
";",
"if",
"(",
"!",
"isAttrNum",
"(",
"value",
")",
")",
"value",
"=",
"(",
"min",
"+... | recalculates value property | [
"recalculates",
"value",
"property"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/assets/css-social-buttons/site/html5slider.js#L231-L242 | train |
MrSwitch/hello.js | assets/css-social-buttons/site/html5slider.js | draw | function draw(attrsModified) {
calc();
if (isChanged && value != prevValue)
slider.dispatchEvent(onChange);
isChanged = false;
if (!attrsModified && value == prevValue)
return;
prevValue = value;
var position = range ? (value - min) / range * 100 : 0;
var bg = '-moz-element(#__sl... | javascript | function draw(attrsModified) {
calc();
if (isChanged && value != prevValue)
slider.dispatchEvent(onChange);
isChanged = false;
if (!attrsModified && value == prevValue)
return;
prevValue = value;
var position = range ? (value - min) / range * 100 : 0;
var bg = '-moz-element(#__sl... | [
"function",
"draw",
"(",
"attrsModified",
")",
"{",
"calc",
"(",
")",
";",
"if",
"(",
"isChanged",
"&&",
"value",
"!=",
"prevValue",
")",
"slider",
".",
"dispatchEvent",
"(",
"onChange",
")",
";",
"isChanged",
"=",
"false",
";",
"if",
"(",
"!",
"attrsM... | renders slider using CSS background ;) | [
"renders",
"slider",
"using",
"CSS",
"background",
";",
")"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/assets/css-social-buttons/site/html5slider.js#L245-L256 | train |
MrSwitch/hello.js | assets/index.js | before_photo_post | function before_photo_post(test, callback){
hello(test.network)
.api("me/albums")
.then(function(r){
for(var i=0;i<r.data.length;i++){
if(r.data[i].name === "TestAlbum"){
var id = r.data[i].id;
test.data.id = id;
return callback();
}
}
callback("Failed to setup: Could not find the album 'Test... | javascript | function before_photo_post(test, callback){
hello(test.network)
.api("me/albums")
.then(function(r){
for(var i=0;i<r.data.length;i++){
if(r.data[i].name === "TestAlbum"){
var id = r.data[i].id;
test.data.id = id;
return callback();
}
}
callback("Failed to setup: Could not find the album 'Test... | [
"function",
"before_photo_post",
"(",
"test",
",",
"callback",
")",
"{",
"hello",
"(",
"test",
".",
"network",
")",
".",
"api",
"(",
"\"me/albums\"",
")",
".",
"then",
"(",
"function",
"(",
"r",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",... | Get the ID of the test album | [
"Get",
"the",
"ID",
"of",
"the",
"test",
"album"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/assets/index.js#L772-L787 | train |
MrSwitch/hello.js | assets/index.js | DictionaryItem | function DictionaryItem(key, value) {
this.key = ko.observable(key);
this.options = [];
if(value instanceof Array){
this.options = value;
value = value[0];
}
this.value = (typeof(value)==='function')? value : ko.observable(value);
} | javascript | function DictionaryItem(key, value) {
this.key = ko.observable(key);
this.options = [];
if(value instanceof Array){
this.options = value;
value = value[0];
}
this.value = (typeof(value)==='function')? value : ko.observable(value);
} | [
"function",
"DictionaryItem",
"(",
"key",
",",
"value",
")",
"{",
"this",
".",
"key",
"=",
"ko",
".",
"observable",
"(",
"key",
")",
";",
"this",
".",
"options",
"=",
"[",
"]",
";",
"if",
"(",
"value",
"instanceof",
"Array",
")",
"{",
"this",
".",
... | Turn an object of Key => Value into mutable stores | [
"Turn",
"an",
"object",
"of",
"Key",
"=",
">",
"Value",
"into",
"mutable",
"stores"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/assets/index.js#L1185-L1193 | train |
MrSwitch/hello.js | assets/index.js | Dictionary | function Dictionary(data) {
this.items = ko.observableArray([]);
for (var field in data) {
if (data.hasOwnProperty(field)) {
this.items.push(new DictionaryItem(field, data[field]));
}
}
this.addItem = function() {
this.items.push(new DictionaryItem());
}.bind(thi... | javascript | function Dictionary(data) {
this.items = ko.observableArray([]);
for (var field in data) {
if (data.hasOwnProperty(field)) {
this.items.push(new DictionaryItem(field, data[field]));
}
}
this.addItem = function() {
this.items.push(new DictionaryItem());
}.bind(thi... | [
"function",
"Dictionary",
"(",
"data",
")",
"{",
"this",
".",
"items",
"=",
"ko",
".",
"observableArray",
"(",
"[",
"]",
")",
";",
"for",
"(",
"var",
"field",
"in",
"data",
")",
"{",
"if",
"(",
"data",
".",
"hasOwnProperty",
"(",
"field",
")",
")",... | Custom Dictionary observable in Knockout represent the dictionary object | [
"Custom",
"Dictionary",
"observable",
"in",
"Knockout",
"represent",
"the",
"dictionary",
"object"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/assets/index.js#L1200-L1224 | train |
MrSwitch/hello.js | assets/index.js | _indexOf | function _indexOf(a,s){
// Do we need the hack?
if(a.indexOf){
return a.indexOf(s);
}
for(var j=0;j<a.length;j++){
if(a[j]===s){
return j;
}
}
return -1;
} | javascript | function _indexOf(a,s){
// Do we need the hack?
if(a.indexOf){
return a.indexOf(s);
}
for(var j=0;j<a.length;j++){
if(a[j]===s){
return j;
}
}
return -1;
} | [
"function",
"_indexOf",
"(",
"a",
",",
"s",
")",
"{",
"// Do we need the hack?",
"if",
"(",
"a",
".",
"indexOf",
")",
"{",
"return",
"a",
".",
"indexOf",
"(",
"s",
")",
";",
"}",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"a",
".",
"lengt... | indexOf IE hack Array.indexOf doesn't exist prior to IE9 | [
"indexOf",
"IE",
"hack",
"Array",
".",
"indexOf",
"doesn",
"t",
"exist",
"prior",
"to",
"IE9"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/assets/index.js#L1258-L1270 | train |
MrSwitch/hello.js | assets/expect/index.js | every | function every (arr, fn, thisObj) {
var scope = thisObj || global;
for (var i = 0, j = arr.length; i < j; ++i) {
if (!fn.call(scope, arr[i], i, arr)) {
return false;
}
}
return true;
} | javascript | function every (arr, fn, thisObj) {
var scope = thisObj || global;
for (var i = 0, j = arr.length; i < j; ++i) {
if (!fn.call(scope, arr[i], i, arr)) {
return false;
}
}
return true;
} | [
"function",
"every",
"(",
"arr",
",",
"fn",
",",
"thisObj",
")",
"{",
"var",
"scope",
"=",
"thisObj",
"||",
"global",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"j",
"=",
"arr",
".",
"length",
";",
"i",
"<",
"j",
";",
"++",
"i",
")",
"{",
... | Array every compatibility
@see bit.ly/5Fq1N2
@api public | [
"Array",
"every",
"compatibility"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/assets/expect/index.js#L510-L518 | train |
MrSwitch/hello.js | demos/helper/uiProfile.js | img_xhr | function img_xhr(img, url) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'blob';
xhr.onload = function(e) {
img.src = window.URL.createObjectURL(this.response);
};
xhr.send();
} | javascript | function img_xhr(img, url) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'blob';
xhr.onload = function(e) {
img.src = window.URL.createObjectURL(this.response);
};
xhr.send();
} | [
"function",
"img_xhr",
"(",
"img",
",",
"url",
")",
"{",
"var",
"xhr",
"=",
"new",
"XMLHttpRequest",
"(",
")",
";",
"xhr",
".",
"open",
"(",
"'GET'",
",",
"url",
",",
"true",
")",
";",
"xhr",
".",
"responseType",
"=",
"'blob'",
";",
"xhr",
".",
"... | Utility for loading the thumbnail in chromeapp | [
"Utility",
"for",
"loading",
"the",
"thumbnail",
"in",
"chromeapp"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/helper/uiProfile.js#L42-L50 | train |
MrSwitch/hello.js | demos/FilePicker/filePicker.js | fileRef | function fileRef(item, network, bucket, selected){
this.els = [];
this.selected = false;
this.item = {};
// Item contents change
this.update = function(item){
if(!item){
return this.item;
}
else {
// Merge the two together
this.item = hello.utils.merge(this.item, item);
}
// Loo... | javascript | function fileRef(item, network, bucket, selected){
this.els = [];
this.selected = false;
this.item = {};
// Item contents change
this.update = function(item){
if(!item){
return this.item;
}
else {
// Merge the two together
this.item = hello.utils.merge(this.item, item);
}
// Loo... | [
"function",
"fileRef",
"(",
"item",
",",
"network",
",",
"bucket",
",",
"selected",
")",
"{",
"this",
".",
"els",
"=",
"[",
"]",
";",
"this",
".",
"selected",
"=",
"false",
";",
"this",
".",
"item",
"=",
"{",
"}",
";",
"// Item contents change",
"thi... | Each item is stored as a fileRef instance in the ref array This function controls the element which it is applied upon. Controlling when the elements update for generated content | [
"Each",
"item",
"is",
"stored",
"as",
"a",
"fileRef",
"instance",
"in",
"the",
"ref",
"array",
"This",
"function",
"controls",
"the",
"element",
"which",
"it",
"is",
"applied",
"upon",
".",
"Controlling",
"when",
"the",
"elements",
"update",
"for",
"generate... | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/FilePicker/filePicker.js#L387-L486 | train |
MrSwitch/hello.js | demos/FilePicker/filePicker.js | uploadFileList | function uploadFileList(files){
// FileList
if(!("FileList" in window) || (files instanceof File) || (files instanceof Blob)){
// Make an Array
files = [files];
}
var max = 20, len = files.length;
if(len>max){
var bool = confirm("You man only upload "+max+" files at a time");
if(!bool){
ret... | javascript | function uploadFileList(files){
// FileList
if(!("FileList" in window) || (files instanceof File) || (files instanceof Blob)){
// Make an Array
files = [files];
}
var max = 20, len = files.length;
if(len>max){
var bool = confirm("You man only upload "+max+" files at a time");
if(!bool){
ret... | [
"function",
"uploadFileList",
"(",
"files",
")",
"{",
"// FileList",
"if",
"(",
"!",
"(",
"\"FileList\"",
"in",
"window",
")",
"||",
"(",
"files",
"instanceof",
"File",
")",
"||",
"(",
"files",
"instanceof",
"Blob",
")",
")",
"{",
"// Make an Array",
"file... | Upload file list Take all the photos in the FileList and create items with them | [
"Upload",
"file",
"list",
"Take",
"all",
"the",
"photos",
"in",
"the",
"FileList",
"and",
"create",
"items",
"with",
"them"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/FilePicker/filePicker.js#L491-L513 | train |
MrSwitch/hello.js | demos/FilePicker/filePicker.js | createRef | function createRef(file){
// Create a new fileRef
var pointer = new fileRef({
name : file.name,
type : file.type,
file : file
}, current_network, current_bucket, true);
ref.push( pointer );
if(current_folder==="local"){
readFile(file, function(dataURL){
// Update list
pointer.update({
... | javascript | function createRef(file){
// Create a new fileRef
var pointer = new fileRef({
name : file.name,
type : file.type,
file : file
}, current_network, current_bucket, true);
ref.push( pointer );
if(current_folder==="local"){
readFile(file, function(dataURL){
// Update list
pointer.update({
... | [
"function",
"createRef",
"(",
"file",
")",
"{",
"// Create a new fileRef",
"var",
"pointer",
"=",
"new",
"fileRef",
"(",
"{",
"name",
":",
"file",
".",
"name",
",",
"type",
":",
"file",
".",
"type",
",",
"file",
":",
"file",
"}",
",",
"current_network",
... | Do we upload them to the endpoint? Or load them into the page? | [
"Do",
"we",
"upload",
"them",
"to",
"the",
"endpoint?",
"Or",
"load",
"them",
"into",
"the",
"page?"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/FilePicker/filePicker.js#L516-L548 | train |
MrSwitch/hello.js | demos/FilePicker/filePicker.js | readFile | function readFile(file, callback){
// Run this sequentially
sync(function(){
// Create a new FileReader Object
var reader = new FileReader();
// Set an onload handler because we load files into it Asynchronously
reader.onload = function(e){
// Print onto Canvas
callback( this.result );
/... | javascript | function readFile(file, callback){
// Run this sequentially
sync(function(){
// Create a new FileReader Object
var reader = new FileReader();
// Set an onload handler because we load files into it Asynchronously
reader.onload = function(e){
// Print onto Canvas
callback( this.result );
/... | [
"function",
"readFile",
"(",
"file",
",",
"callback",
")",
"{",
"// Run this sequentially",
"sync",
"(",
"function",
"(",
")",
"{",
"// Create a new FileReader Object",
"var",
"reader",
"=",
"new",
"FileReader",
"(",
")",
";",
"// Set an onload handler because we load... | readFile Perform one operation at a time, to get a nice gradule load | [
"readFile",
"Perform",
"one",
"operation",
"at",
"a",
"time",
"to",
"get",
"a",
"nice",
"gradule",
"load"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/demos/FilePicker/filePicker.js#L552-L571 | train |
MrSwitch/hello.js | src/modules/tumblr.js | query | function query(p, callback) {
if (p.data) {
extend(p.query, p.data);
p.data = null;
}
callback(p.path);
} | javascript | function query(p, callback) {
if (p.data) {
extend(p.query, p.data);
p.data = null;
}
callback(p.path);
} | [
"function",
"query",
"(",
"p",
",",
"callback",
")",
"{",
"if",
"(",
"p",
".",
"data",
")",
"{",
"extend",
"(",
"p",
".",
"query",
",",
"p",
".",
"data",
")",
";",
"p",
".",
"data",
"=",
"null",
";",
"}",
"callback",
"(",
"p",
".",
"path",
... | Converts post parameters to query | [
"Converts",
"post",
"parameters",
"to",
"query"
] | 50b2b792d758774fc08e8da911fd4415ea3831ba | https://github.com/MrSwitch/hello.js/blob/50b2b792d758774fc08e8da911fd4415ea3831ba/src/modules/tumblr.js#L93-L100 | train |
rtfeldman/seamless-immutable | seamless-immutable.development.js | without | function without(remove) {
// Calling .without() with no arguments is a no-op. Don't bother cloning.
if (typeof remove === "undefined" && arguments.length === 0) {
return this;
}
if (typeof remove !== "function") {
// If we weren't given an array, use the arguments list.
var keysToRem... | javascript | function without(remove) {
// Calling .without() with no arguments is a no-op. Don't bother cloning.
if (typeof remove === "undefined" && arguments.length === 0) {
return this;
}
if (typeof remove !== "function") {
// If we weren't given an array, use the arguments list.
var keysToRem... | [
"function",
"without",
"(",
"remove",
")",
"{",
"// Calling .without() with no arguments is a no-op. Don't bother cloning.",
"if",
"(",
"typeof",
"remove",
"===",
"\"undefined\"",
"&&",
"arguments",
".",
"length",
"===",
"0",
")",
"{",
"return",
"this",
";",
"}",
"i... | Returns an Immutable copy of the object without the given keys included.
@param {array} keysToRemove - A list of strings representing the keys to exclude in the return value. Instead of providing a single array, this method can also be called by passing multiple strings as separate arguments. | [
"Returns",
"an",
"Immutable",
"copy",
"of",
"the",
"object",
"without",
"the",
"given",
"keys",
"included",
"."
] | 2d870b14a01e222493c686a7644181185f859558 | https://github.com/rtfeldman/seamless-immutable/blob/2d870b14a01e222493c686a7644181185f859558/seamless-immutable.development.js#L265-L298 | train |
rtfeldman/seamless-immutable | seamless-immutable.development.js | merge | function merge(other, config) {
// Calling .merge() with no arguments is a no-op. Don't bother cloning.
if (arguments.length === 0) {
return this;
}
if (other === null || (typeof other !== "object")) {
throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not " + ... | javascript | function merge(other, config) {
// Calling .merge() with no arguments is a no-op. Don't bother cloning.
if (arguments.length === 0) {
return this;
}
if (other === null || (typeof other !== "object")) {
throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not " + ... | [
"function",
"merge",
"(",
"other",
",",
"config",
")",
"{",
"// Calling .merge() with no arguments is a no-op. Don't bother cloning.",
"if",
"(",
"arguments",
".",
"length",
"===",
"0",
")",
"{",
"return",
"this",
";",
"}",
"if",
"(",
"other",
"===",
"null",
"||... | Returns an Immutable Object containing the properties and values of both
this object and the provided object, prioritizing the provided object's
values whenever the same key is present in both objects.
@param {object} other - The other object to merge. Multiple objects can be passed as an array. In such a case, the la... | [
"Returns",
"an",
"Immutable",
"Object",
"containing",
"the",
"properties",
"and",
"values",
"of",
"both",
"this",
"object",
"and",
"the",
"provided",
"object",
"prioritizing",
"the",
"provided",
"object",
"s",
"values",
"whenever",
"the",
"same",
"key",
"is",
... | 2d870b14a01e222493c686a7644181185f859558 | https://github.com/rtfeldman/seamless-immutable/blob/2d870b14a01e222493c686a7644181185f859558/seamless-immutable.development.js#L374-L467 | train |
rtfeldman/seamless-immutable | seamless-immutable.development.js | addToResult | function addToResult(currentObj, otherObj, key) {
var immutableValue = Immutable(otherObj[key]);
var mergerResult = merger && merger(currentObj[key], immutableValue, config);
var currentValue = currentObj[key];
if ((result !== undefined) ||
(mergerResult !== undefined) ||
(!curr... | javascript | function addToResult(currentObj, otherObj, key) {
var immutableValue = Immutable(otherObj[key]);
var mergerResult = merger && merger(currentObj[key], immutableValue, config);
var currentValue = currentObj[key];
if ((result !== undefined) ||
(mergerResult !== undefined) ||
(!curr... | [
"function",
"addToResult",
"(",
"currentObj",
",",
"otherObj",
",",
"key",
")",
"{",
"var",
"immutableValue",
"=",
"Immutable",
"(",
"otherObj",
"[",
"key",
"]",
")",
";",
"var",
"mergerResult",
"=",
"merger",
"&&",
"merger",
"(",
"currentObj",
"[",
"key",... | Use the given key to extract a value from the given object, then place that value in the result object under the same key. If that resulted in a change from this object's value at that key, set anyChanges = true. | [
"Use",
"the",
"given",
"key",
"to",
"extract",
"a",
"value",
"from",
"the",
"given",
"object",
"then",
"place",
"that",
"value",
"in",
"the",
"result",
"object",
"under",
"the",
"same",
"key",
".",
"If",
"that",
"resulted",
"in",
"a",
"change",
"from",
... | 2d870b14a01e222493c686a7644181185f859558 | https://github.com/rtfeldman/seamless-immutable/blob/2d870b14a01e222493c686a7644181185f859558/seamless-immutable.development.js#L393-L422 | train |
rtfeldman/seamless-immutable | seamless-immutable.development.js | makeImmutableObject | function makeImmutableObject(obj) {
if (!globalConfig.use_static) {
addPropertyTo(obj, "merge", merge);
addPropertyTo(obj, "replace", objectReplace);
addPropertyTo(obj, "without", without);
addPropertyTo(obj, "asMutable", asMutableObject);
addPropertyTo(obj, "set", objectSet);
ad... | javascript | function makeImmutableObject(obj) {
if (!globalConfig.use_static) {
addPropertyTo(obj, "merge", merge);
addPropertyTo(obj, "replace", objectReplace);
addPropertyTo(obj, "without", without);
addPropertyTo(obj, "asMutable", asMutableObject);
addPropertyTo(obj, "set", objectSet);
ad... | [
"function",
"makeImmutableObject",
"(",
"obj",
")",
"{",
"if",
"(",
"!",
"globalConfig",
".",
"use_static",
")",
"{",
"addPropertyTo",
"(",
"obj",
",",
"\"merge\"",
",",
"merge",
")",
";",
"addPropertyTo",
"(",
"obj",
",",
"\"replace\"",
",",
"objectReplace"... | Finalizes an object with immutable methods, freezes it, and returns it. | [
"Finalizes",
"an",
"object",
"with",
"immutable",
"methods",
"freezes",
"it",
"and",
"returns",
"it",
"."
] | 2d870b14a01e222493c686a7644181185f859558 | https://github.com/rtfeldman/seamless-immutable/blob/2d870b14a01e222493c686a7644181185f859558/seamless-immutable.development.js#L586-L600 | train |
rtfeldman/seamless-immutable | seamless-immutable.development.js | toStatic | function toStatic(fn) {
function staticWrapper() {
var args = [].slice.call(arguments);
var self = args.shift();
return fn.apply(self, args);
}
return staticWrapper;
} | javascript | function toStatic(fn) {
function staticWrapper() {
var args = [].slice.call(arguments);
var self = args.shift();
return fn.apply(self, args);
}
return staticWrapper;
} | [
"function",
"toStatic",
"(",
"fn",
")",
"{",
"function",
"staticWrapper",
"(",
")",
"{",
"var",
"args",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"var",
"self",
"=",
"args",
".",
"shift",
"(",
")",
";",
"return",
"fn",
... | Wrapper to allow the use of object methods as static methods of Immutable. | [
"Wrapper",
"to",
"allow",
"the",
"use",
"of",
"object",
"methods",
"as",
"static",
"methods",
"of",
"Immutable",
"."
] | 2d870b14a01e222493c686a7644181185f859558 | https://github.com/rtfeldman/seamless-immutable/blob/2d870b14a01e222493c686a7644181185f859558/seamless-immutable.development.js#L670-L678 | train |
rtfeldman/seamless-immutable | seamless-immutable.development.js | toStaticObjectOrArray | function toStaticObjectOrArray(fnObject, fnArray) {
function staticWrapper() {
var args = [].slice.call(arguments);
var self = args.shift();
if (Array.isArray(self)) {
return fnArray.apply(self, args);
} else {
return fnObject.apply(self, args);
}
}
return ... | javascript | function toStaticObjectOrArray(fnObject, fnArray) {
function staticWrapper() {
var args = [].slice.call(arguments);
var self = args.shift();
if (Array.isArray(self)) {
return fnArray.apply(self, args);
} else {
return fnObject.apply(self, args);
}
}
return ... | [
"function",
"toStaticObjectOrArray",
"(",
"fnObject",
",",
"fnArray",
")",
"{",
"function",
"staticWrapper",
"(",
")",
"{",
"var",
"args",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"var",
"self",
"=",
"args",
".",
"shift",
"... | Wrapper to allow the use of object methods as static methods of Immutable. with the additional condition of choosing which function to call depending if argument is an array or an object. | [
"Wrapper",
"to",
"allow",
"the",
"use",
"of",
"object",
"methods",
"as",
"static",
"methods",
"of",
"Immutable",
".",
"with",
"the",
"additional",
"condition",
"of",
"choosing",
"which",
"function",
"to",
"call",
"depending",
"if",
"argument",
"is",
"an",
"a... | 2d870b14a01e222493c686a7644181185f859558 | https://github.com/rtfeldman/seamless-immutable/blob/2d870b14a01e222493c686a7644181185f859558/seamless-immutable.development.js#L683-L695 | train |
angular-ui/ui-select | src/uiSelectController.js | function(){
var origSrc = originalSource($scope);
$scope.$uisSource = Object.keys(origSrc).map(function(v){
var result = {};
result[ctrl.parserResult.keyName] = v;
result.value = origSrc[v];
return result;
});
} | javascript | function(){
var origSrc = originalSource($scope);
$scope.$uisSource = Object.keys(origSrc).map(function(v){
var result = {};
result[ctrl.parserResult.keyName] = v;
result.value = origSrc[v];
return result;
});
} | [
"function",
"(",
")",
"{",
"var",
"origSrc",
"=",
"originalSource",
"(",
"$scope",
")",
";",
"$scope",
".",
"$uisSource",
"=",
"Object",
".",
"keys",
"(",
"origSrc",
")",
".",
"map",
"(",
"function",
"(",
"v",
")",
"{",
"var",
"result",
"=",
"{",
"... | When an object is used as source, we better create an array and use it as 'source' | [
"When",
"an",
"object",
"is",
"used",
"as",
"source",
"we",
"better",
"create",
"an",
"array",
"and",
"use",
"it",
"as",
"source"
] | d8fed304ab7f7f8dfde1e8424ee2a572e31c7488 | https://github.com/angular-ui/ui-select/blob/d8fed304ab7f7f8dfde1e8424ee2a572e31c7488/src/uiSelectController.js#L231-L239 | train | |
angular-ui/ui-select | src/uiSelectMultipleDirective.js | _handleMatchSelection | function _handleMatchSelection(key){
var caretPosition = _getCaretPosition($select.searchInput[0]),
length = $select.selected.length,
// none = -1,
first = 0,
last = length-1,
curr = $selectMultiple.activeMatchIndex,
next = $selectMulti... | javascript | function _handleMatchSelection(key){
var caretPosition = _getCaretPosition($select.searchInput[0]),
length = $select.selected.length,
// none = -1,
first = 0,
last = length-1,
curr = $selectMultiple.activeMatchIndex,
next = $selectMulti... | [
"function",
"_handleMatchSelection",
"(",
"key",
")",
"{",
"var",
"caretPosition",
"=",
"_getCaretPosition",
"(",
"$select",
".",
"searchInput",
"[",
"0",
"]",
")",
",",
"length",
"=",
"$select",
".",
"selected",
".",
"length",
",",
"// none = -1,",
"first",
... | Handles selected options in "multiple" mode | [
"Handles",
"selected",
"options",
"in",
"multiple",
"mode"
] | d8fed304ab7f7f8dfde1e8424ee2a572e31c7488 | https://github.com/angular-ui/ui-select/blob/d8fed304ab7f7f8dfde1e8424ee2a572e31c7488/src/uiSelectMultipleDirective.js#L218-L280 | train |
jedfoster/Readmore.js | jquery.mockjax.js | parseXML | function parseXML(xml) {
if ( window.DOMParser == undefined && window.ActiveXObject ) {
DOMParser = function() { };
DOMParser.prototype.parseFromString = function( xmlString ) {
var doc = new ActiveXObject('Microsoft.XMLDOM');
doc.async = 'false';
doc.loadXML( xmlString );
return doc;
};
}
... | javascript | function parseXML(xml) {
if ( window.DOMParser == undefined && window.ActiveXObject ) {
DOMParser = function() { };
DOMParser.prototype.parseFromString = function( xmlString ) {
var doc = new ActiveXObject('Microsoft.XMLDOM');
doc.async = 'false';
doc.loadXML( xmlString );
return doc;
};
}
... | [
"function",
"parseXML",
"(",
"xml",
")",
"{",
"if",
"(",
"window",
".",
"DOMParser",
"==",
"undefined",
"&&",
"window",
".",
"ActiveXObject",
")",
"{",
"DOMParser",
"=",
"function",
"(",
")",
"{",
"}",
";",
"DOMParser",
".",
"prototype",
".",
"parseFromS... | Parse the given XML string. | [
"Parse",
"the",
"given",
"XML",
"string",
"."
] | d7fe38b8214fc5804219736008c8470953b082c0 | https://github.com/jedfoster/Readmore.js/blob/d7fe38b8214fc5804219736008c8470953b082c0/jquery.mockjax.js#L26-L53 | train |
jedfoster/Readmore.js | jquery.mockjax.js | isMockDataEqual | function isMockDataEqual( mock, live ) {
var identical = true;
// Test for situations where the data is a querystring (not an object)
if (typeof live === 'string') {
// Querystring may be a regex
return $.isFunction( mock.test ) ? mock.test(live) : mock == live;
}
$.each(mock, function(k) {
if ( live... | javascript | function isMockDataEqual( mock, live ) {
var identical = true;
// Test for situations where the data is a querystring (not an object)
if (typeof live === 'string') {
// Querystring may be a regex
return $.isFunction( mock.test ) ? mock.test(live) : mock == live;
}
$.each(mock, function(k) {
if ( live... | [
"function",
"isMockDataEqual",
"(",
"mock",
",",
"live",
")",
"{",
"var",
"identical",
"=",
"true",
";",
"// Test for situations where the data is a querystring (not an object)",
"if",
"(",
"typeof",
"live",
"===",
"'string'",
")",
"{",
"// Querystring may be a regex",
... | Check if the data field on the mock handler and the request match. This can be used to restrict a mock handler to being used only when a certain set of data is passed to it. | [
"Check",
"if",
"the",
"data",
"field",
"on",
"the",
"mock",
"handler",
"and",
"the",
"request",
"match",
".",
"This",
"can",
"be",
"used",
"to",
"restrict",
"a",
"mock",
"handler",
"to",
"being",
"used",
"only",
"when",
"a",
"certain",
"set",
"of",
"da... | d7fe38b8214fc5804219736008c8470953b082c0 | https://github.com/jedfoster/Readmore.js/blob/d7fe38b8214fc5804219736008c8470953b082c0/jquery.mockjax.js#L58-L86 | train |
jedfoster/Readmore.js | jquery.mockjax.js | getMockForRequest | function getMockForRequest( handler, requestSettings ) {
// If the mock was registered with a function, let the function decide if we
// want to mock this request
if ( $.isFunction(handler) ) {
return handler( requestSettings );
}
// Inspect the URL of the request and check if the mock handler's url
// ... | javascript | function getMockForRequest( handler, requestSettings ) {
// If the mock was registered with a function, let the function decide if we
// want to mock this request
if ( $.isFunction(handler) ) {
return handler( requestSettings );
}
// Inspect the URL of the request and check if the mock handler's url
// ... | [
"function",
"getMockForRequest",
"(",
"handler",
",",
"requestSettings",
")",
"{",
"// If the mock was registered with a function, let the function decide if we",
"// want to mock this request",
"if",
"(",
"$",
".",
"isFunction",
"(",
"handler",
")",
")",
"{",
"return",
"ha... | Check the given handler should mock the given request | [
"Check",
"the",
"given",
"handler",
"should",
"mock",
"the",
"given",
"request"
] | d7fe38b8214fc5804219736008c8470953b082c0 | https://github.com/jedfoster/Readmore.js/blob/d7fe38b8214fc5804219736008c8470953b082c0/jquery.mockjax.js#L94-L132 | train |
jedfoster/Readmore.js | jquery.mockjax.js | xhr | function xhr(mockHandler, requestSettings, origSettings, origHandler) {
// Extend with our default mockjax settings
mockHandler = $.extend(true, {}, $.mockjaxSettings, mockHandler);
if (typeof mockHandler.headers === 'undefined') {
mockHandler.headers = {};
}
if (typeof requestSettings.headers === 'undefi... | javascript | function xhr(mockHandler, requestSettings, origSettings, origHandler) {
// Extend with our default mockjax settings
mockHandler = $.extend(true, {}, $.mockjaxSettings, mockHandler);
if (typeof mockHandler.headers === 'undefined') {
mockHandler.headers = {};
}
if (typeof requestSettings.headers === 'undefi... | [
"function",
"xhr",
"(",
"mockHandler",
",",
"requestSettings",
",",
"origSettings",
",",
"origHandler",
")",
"{",
"// Extend with our default mockjax settings",
"mockHandler",
"=",
"$",
".",
"extend",
"(",
"true",
",",
"{",
"}",
",",
"$",
".",
"mockjaxSettings",
... | Construct a mocked XHR Object | [
"Construct",
"a",
"mocked",
"XHR",
"Object"
] | d7fe38b8214fc5804219736008c8470953b082c0 | https://github.com/jedfoster/Readmore.js/blob/d7fe38b8214fc5804219736008c8470953b082c0/jquery.mockjax.js#L252-L306 | train |
jedfoster/Readmore.js | jquery.mockjax.js | processJsonpMock | function processJsonpMock( requestSettings, mockHandler, origSettings ) {
// Handle JSONP Parameter Callbacks, we need to replicate some of the jQuery core here
// because there isn't an easy hook for the cross domain script tag of jsonp
processJsonpUrl( requestSettings );
requestSettings.dataType = "json";
... | javascript | function processJsonpMock( requestSettings, mockHandler, origSettings ) {
// Handle JSONP Parameter Callbacks, we need to replicate some of the jQuery core here
// because there isn't an easy hook for the cross domain script tag of jsonp
processJsonpUrl( requestSettings );
requestSettings.dataType = "json";
... | [
"function",
"processJsonpMock",
"(",
"requestSettings",
",",
"mockHandler",
",",
"origSettings",
")",
"{",
"// Handle JSONP Parameter Callbacks, we need to replicate some of the jQuery core here",
"// because there isn't an easy hook for the cross domain script tag of jsonp",
"processJsonpUr... | Process a JSONP mock request. | [
"Process",
"a",
"JSONP",
"mock",
"request",
"."
] | d7fe38b8214fc5804219736008c8470953b082c0 | https://github.com/jedfoster/Readmore.js/blob/d7fe38b8214fc5804219736008c8470953b082c0/jquery.mockjax.js#L309-L340 | train |
jedfoster/Readmore.js | jquery.mockjax.js | processJsonpUrl | function processJsonpUrl( requestSettings ) {
if ( requestSettings.type.toUpperCase() === "GET" ) {
if ( !CALLBACK_REGEX.test( requestSettings.url ) ) {
requestSettings.url += (/\?/.test( requestSettings.url ) ? "&" : "?") +
(requestSettings.jsonp || "callback") + "=?";
}
} else if ( !requestSettings... | javascript | function processJsonpUrl( requestSettings ) {
if ( requestSettings.type.toUpperCase() === "GET" ) {
if ( !CALLBACK_REGEX.test( requestSettings.url ) ) {
requestSettings.url += (/\?/.test( requestSettings.url ) ? "&" : "?") +
(requestSettings.jsonp || "callback") + "=?";
}
} else if ( !requestSettings... | [
"function",
"processJsonpUrl",
"(",
"requestSettings",
")",
"{",
"if",
"(",
"requestSettings",
".",
"type",
".",
"toUpperCase",
"(",
")",
"===",
"\"GET\"",
")",
"{",
"if",
"(",
"!",
"CALLBACK_REGEX",
".",
"test",
"(",
"requestSettings",
".",
"url",
")",
")... | Append the required callback parameter to the end of the request URL, for a JSONP request | [
"Append",
"the",
"required",
"callback",
"parameter",
"to",
"the",
"end",
"of",
"the",
"request",
"URL",
"for",
"a",
"JSONP",
"request"
] | d7fe38b8214fc5804219736008c8470953b082c0 | https://github.com/jedfoster/Readmore.js/blob/d7fe38b8214fc5804219736008c8470953b082c0/jquery.mockjax.js#L343-L352 | train |
jedfoster/Readmore.js | jquery.mockjax.js | processJsonpRequest | function processJsonpRequest( requestSettings, mockHandler, origSettings ) {
// Synthesize the mock request for adding a script tag
var callbackContext = origSettings && origSettings.context || requestSettings,
newMock = null;
// If the response handler on the moock is a function, call it
if ( mockHandler.... | javascript | function processJsonpRequest( requestSettings, mockHandler, origSettings ) {
// Synthesize the mock request for adding a script tag
var callbackContext = origSettings && origSettings.context || requestSettings,
newMock = null;
// If the response handler on the moock is a function, call it
if ( mockHandler.... | [
"function",
"processJsonpRequest",
"(",
"requestSettings",
",",
"mockHandler",
",",
"origSettings",
")",
"{",
"// Synthesize the mock request for adding a script tag",
"var",
"callbackContext",
"=",
"origSettings",
"&&",
"origSettings",
".",
"context",
"||",
"requestSettings"... | Process a JSONP request by evaluating the mocked response text | [
"Process",
"a",
"JSONP",
"request",
"by",
"evaluating",
"the",
"mocked",
"response",
"text"
] | d7fe38b8214fc5804219736008c8470953b082c0 | https://github.com/jedfoster/Readmore.js/blob/d7fe38b8214fc5804219736008c8470953b082c0/jquery.mockjax.js#L355-L391 | train |
jedfoster/Readmore.js | jquery.mockjax.js | createJsonpCallback | function createJsonpCallback( requestSettings, mockHandler, origSettings ) {
var callbackContext = origSettings && origSettings.context || requestSettings;
var jsonp = requestSettings.jsonpCallback || ("jsonp" + jsc++);
// Replace the =? sequence both in the query string and the data
if ( requestSettings.data ... | javascript | function createJsonpCallback( requestSettings, mockHandler, origSettings ) {
var callbackContext = origSettings && origSettings.context || requestSettings;
var jsonp = requestSettings.jsonpCallback || ("jsonp" + jsc++);
// Replace the =? sequence both in the query string and the data
if ( requestSettings.data ... | [
"function",
"createJsonpCallback",
"(",
"requestSettings",
",",
"mockHandler",
",",
"origSettings",
")",
"{",
"var",
"callbackContext",
"=",
"origSettings",
"&&",
"origSettings",
".",
"context",
"||",
"requestSettings",
";",
"var",
"jsonp",
"=",
"requestSettings",
"... | Create the required JSONP callback function for the request | [
"Create",
"the",
"required",
"JSONP",
"callback",
"function",
"for",
"the",
"request"
] | d7fe38b8214fc5804219736008c8470953b082c0 | https://github.com/jedfoster/Readmore.js/blob/d7fe38b8214fc5804219736008c8470953b082c0/jquery.mockjax.js#L395-L423 | train |
jedfoster/Readmore.js | jquery.mockjax.js | jsonpSuccess | function jsonpSuccess(requestSettings, callbackContext, mockHandler) {
// If a local callback was specified, fire it and pass it the data
if ( requestSettings.success ) {
requestSettings.success.call( callbackContext, mockHandler.responseText || "", status, {} );
}
// Fire the global callback
if ( request... | javascript | function jsonpSuccess(requestSettings, callbackContext, mockHandler) {
// If a local callback was specified, fire it and pass it the data
if ( requestSettings.success ) {
requestSettings.success.call( callbackContext, mockHandler.responseText || "", status, {} );
}
// Fire the global callback
if ( request... | [
"function",
"jsonpSuccess",
"(",
"requestSettings",
",",
"callbackContext",
",",
"mockHandler",
")",
"{",
"// If a local callback was specified, fire it and pass it the data",
"if",
"(",
"requestSettings",
".",
"success",
")",
"{",
"requestSettings",
".",
"success",
".",
... | The JSONP request was successful | [
"The",
"JSONP",
"request",
"was",
"successful"
] | d7fe38b8214fc5804219736008c8470953b082c0 | https://github.com/jedfoster/Readmore.js/blob/d7fe38b8214fc5804219736008c8470953b082c0/jquery.mockjax.js#L426-L436 | train |
jedfoster/Readmore.js | jquery.mockjax.js | jsonpComplete | function jsonpComplete(requestSettings, callbackContext) {
// Process result
if ( requestSettings.complete ) {
requestSettings.complete.call( callbackContext, {} , status );
}
// The request was completed
if ( requestSettings.global ) {
(requestSettings.context ? $(requestSettings.context) : $.event).t... | javascript | function jsonpComplete(requestSettings, callbackContext) {
// Process result
if ( requestSettings.complete ) {
requestSettings.complete.call( callbackContext, {} , status );
}
// The request was completed
if ( requestSettings.global ) {
(requestSettings.context ? $(requestSettings.context) : $.event).t... | [
"function",
"jsonpComplete",
"(",
"requestSettings",
",",
"callbackContext",
")",
"{",
"// Process result",
"if",
"(",
"requestSettings",
".",
"complete",
")",
"{",
"requestSettings",
".",
"complete",
".",
"call",
"(",
"callbackContext",
",",
"{",
"}",
",",
"sta... | The JSONP request was completed | [
"The",
"JSONP",
"request",
"was",
"completed"
] | d7fe38b8214fc5804219736008c8470953b082c0 | https://github.com/jedfoster/Readmore.js/blob/d7fe38b8214fc5804219736008c8470953b082c0/jquery.mockjax.js#L439-L454 | train |
jedfoster/Readmore.js | jquery.mockjax.js | copyUrlParameters | function copyUrlParameters(mockHandler, origSettings) {
//parameters aren't captured if the URL isn't a RegExp
if (!(mockHandler.url instanceof RegExp)) {
return;
}
//if no URL params were defined on the handler, don't attempt a capture
if (!mockHandler.hasOwnProperty('urlParams')) {
return;
}
var c... | javascript | function copyUrlParameters(mockHandler, origSettings) {
//parameters aren't captured if the URL isn't a RegExp
if (!(mockHandler.url instanceof RegExp)) {
return;
}
//if no URL params were defined on the handler, don't attempt a capture
if (!mockHandler.hasOwnProperty('urlParams')) {
return;
}
var c... | [
"function",
"copyUrlParameters",
"(",
"mockHandler",
",",
"origSettings",
")",
"{",
"//parameters aren't captured if the URL isn't a RegExp",
"if",
"(",
"!",
"(",
"mockHandler",
".",
"url",
"instanceof",
"RegExp",
")",
")",
"{",
"return",
";",
"}",
"//if no URL params... | Copies URL parameter values if they were captured by a regular expression
@param {Object} mockHandler
@param {Object} origSettings | [
"Copies",
"URL",
"parameter",
"values",
"if",
"they",
"were",
"captured",
"by",
"a",
"regular",
"expression"
] | d7fe38b8214fc5804219736008c8470953b082c0 | https://github.com/jedfoster/Readmore.js/blob/d7fe38b8214fc5804219736008c8470953b082c0/jquery.mockjax.js#L572-L599 | train |
marceljuenemann/angular-drag-and-drop-lists | angular-drag-and-drop-lists.js | getMimeType | function getMimeType(types) {
if (!types) return MSIE_MIME_TYPE; // IE 9 workaround.
for (var i = 0; i < types.length; i++) {
if (types[i] == MSIE_MIME_TYPE || types[i] == EDGE_MIME_TYPE ||
types[i].substr(0, MIME_TYPE.length) == MIME_TYPE) {
return types[i];
... | javascript | function getMimeType(types) {
if (!types) return MSIE_MIME_TYPE; // IE 9 workaround.
for (var i = 0; i < types.length; i++) {
if (types[i] == MSIE_MIME_TYPE || types[i] == EDGE_MIME_TYPE ||
types[i].substr(0, MIME_TYPE.length) == MIME_TYPE) {
return types[i];
... | [
"function",
"getMimeType",
"(",
"types",
")",
"{",
"if",
"(",
"!",
"types",
")",
"return",
"MSIE_MIME_TYPE",
";",
"// IE 9 workaround.",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"types",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"... | Given the types array from the DataTransfer object, returns the first valid mime type.
A type is valid if it starts with MIME_TYPE, or it equals MSIE_MIME_TYPE or EDGE_MIME_TYPE. | [
"Given",
"the",
"types",
"array",
"from",
"the",
"DataTransfer",
"object",
"returns",
"the",
"first",
"valid",
"mime",
"type",
".",
"A",
"type",
"is",
"valid",
"if",
"it",
"starts",
"with",
"MIME_TYPE",
"or",
"it",
"equals",
"MSIE_MIME_TYPE",
"or",
"EDGE_MIM... | 7e98e194a8d66fa735bf6dc7c3e39886287b914e | https://github.com/marceljuenemann/angular-drag-and-drop-lists/blob/7e98e194a8d66fa735bf6dc7c3e39886287b914e/angular-drag-and-drop-lists.js#L454-L463 | train |
marceljuenemann/angular-drag-and-drop-lists | angular-drag-and-drop-lists.js | getItemType | function getItemType(mimeType) {
if (dndState.isDragging) return dndState.itemType || undefined;
if (mimeType == MSIE_MIME_TYPE || mimeType == EDGE_MIME_TYPE) return null;
return (mimeType && mimeType.substr(MIME_TYPE.length + 1)) || undefined;
} | javascript | function getItemType(mimeType) {
if (dndState.isDragging) return dndState.itemType || undefined;
if (mimeType == MSIE_MIME_TYPE || mimeType == EDGE_MIME_TYPE) return null;
return (mimeType && mimeType.substr(MIME_TYPE.length + 1)) || undefined;
} | [
"function",
"getItemType",
"(",
"mimeType",
")",
"{",
"if",
"(",
"dndState",
".",
"isDragging",
")",
"return",
"dndState",
".",
"itemType",
"||",
"undefined",
";",
"if",
"(",
"mimeType",
"==",
"MSIE_MIME_TYPE",
"||",
"mimeType",
"==",
"EDGE_MIME_TYPE",
")",
... | Determines the type of the item from the dndState, or from the mime type for items from
external sources. Returns undefined if no item type was set and null if the item type could
not be determined. | [
"Determines",
"the",
"type",
"of",
"the",
"item",
"from",
"the",
"dndState",
"or",
"from",
"the",
"mime",
"type",
"for",
"items",
"from",
"external",
"sources",
".",
"Returns",
"undefined",
"if",
"no",
"item",
"type",
"was",
"set",
"and",
"null",
"if",
"... | 7e98e194a8d66fa735bf6dc7c3e39886287b914e | https://github.com/marceljuenemann/angular-drag-and-drop-lists/blob/7e98e194a8d66fa735bf6dc7c3e39886287b914e/angular-drag-and-drop-lists.js#L470-L474 | train |
marceljuenemann/angular-drag-and-drop-lists | angular-drag-and-drop-lists.js | getPlaceholderElement | function getPlaceholderElement() {
var placeholder;
angular.forEach(element.children(), function(childNode) {
var child = angular.element(childNode);
if (child.hasClass('dndPlaceholder')) {
placeholder = child;
}
});
return placeholder || angular... | javascript | function getPlaceholderElement() {
var placeholder;
angular.forEach(element.children(), function(childNode) {
var child = angular.element(childNode);
if (child.hasClass('dndPlaceholder')) {
placeholder = child;
}
});
return placeholder || angular... | [
"function",
"getPlaceholderElement",
"(",
")",
"{",
"var",
"placeholder",
";",
"angular",
".",
"forEach",
"(",
"element",
".",
"children",
"(",
")",
",",
"function",
"(",
"childNode",
")",
"{",
"var",
"child",
"=",
"angular",
".",
"element",
"(",
"childNod... | Tries to find a child element that has the dndPlaceholder class set. If none was found, a
new li element is created. | [
"Tries",
"to",
"find",
"a",
"child",
"element",
"that",
"has",
"the",
"dndPlaceholder",
"class",
"set",
".",
"If",
"none",
"was",
"found",
"a",
"new",
"li",
"element",
"is",
"created",
"."
] | 7e98e194a8d66fa735bf6dc7c3e39886287b914e | https://github.com/marceljuenemann/angular-drag-and-drop-lists/blob/7e98e194a8d66fa735bf6dc7c3e39886287b914e/angular-drag-and-drop-lists.js#L553-L562 | train |
marceljuenemann/angular-drag-and-drop-lists | angular-drag-and-drop-lists.js | filterEffects | function filterEffects(effects, effectAllowed) {
if (effectAllowed == 'all') return effects;
return effects.filter(function(effect) {
return effectAllowed.toLowerCase().indexOf(effect) != -1;
});
} | javascript | function filterEffects(effects, effectAllowed) {
if (effectAllowed == 'all') return effects;
return effects.filter(function(effect) {
return effectAllowed.toLowerCase().indexOf(effect) != -1;
});
} | [
"function",
"filterEffects",
"(",
"effects",
",",
"effectAllowed",
")",
"{",
"if",
"(",
"effectAllowed",
"==",
"'all'",
")",
"return",
"effects",
";",
"return",
"effects",
".",
"filter",
"(",
"function",
"(",
"effect",
")",
"{",
"return",
"effectAllowed",
".... | Filters an array of drop effects using a HTML5 effectAllowed string. | [
"Filters",
"an",
"array",
"of",
"drop",
"effects",
"using",
"a",
"HTML5",
"effectAllowed",
"string",
"."
] | 7e98e194a8d66fa735bf6dc7c3e39886287b914e | https://github.com/marceljuenemann/angular-drag-and-drop-lists/blob/7e98e194a8d66fa735bf6dc7c3e39886287b914e/angular-drag-and-drop-lists.js#L629-L634 | train |
wilix-team/iohook | install.js | install | function install(runtime, abi, platform, arch, cb) {
const essential = runtime + '-v' + abi + '-' + platform + '-' + arch;
const pkgVersion = pkg.version;
const currentPlatform = pkg.name + '-v' + pkgVersion + '-' + essential;
console.log('Downloading prebuild for platform:', currentPlatform);
let downloadUr... | javascript | function install(runtime, abi, platform, arch, cb) {
const essential = runtime + '-v' + abi + '-' + platform + '-' + arch;
const pkgVersion = pkg.version;
const currentPlatform = pkg.name + '-v' + pkgVersion + '-' + essential;
console.log('Downloading prebuild for platform:', currentPlatform);
let downloadUr... | [
"function",
"install",
"(",
"runtime",
",",
"abi",
",",
"platform",
",",
"arch",
",",
"cb",
")",
"{",
"const",
"essential",
"=",
"runtime",
"+",
"'-v'",
"+",
"abi",
"+",
"'-'",
"+",
"platform",
"+",
"'-'",
"+",
"arch",
";",
"const",
"pkgVersion",
"="... | Download and Install prebuild
@param runtime
@param abi
@param platform
@param arch
@param cb Callback | [
"Download",
"and",
"Install",
"prebuild"
] | 7a298ab49afb5bfd75f74ab94b1fce220150d396 | https://github.com/wilix-team/iohook/blob/7a298ab49afb5bfd75f74ab94b1fce220150d396/install.js#L25-L78 | train |
wilix-team/iohook | install.js | optionsFromPackage | function optionsFromPackage(attempts) {
attempts = attempts || 2;
if (attempts > 5) {
console.log('Can\'t resolve main package.json file');
return {
targets: [],
platforms: [process.platform],
arches: [process.arch]
}
}
let mainPath = Array(attempts).join("../");
try {
const ... | javascript | function optionsFromPackage(attempts) {
attempts = attempts || 2;
if (attempts > 5) {
console.log('Can\'t resolve main package.json file');
return {
targets: [],
platforms: [process.platform],
arches: [process.arch]
}
}
let mainPath = Array(attempts).join("../");
try {
const ... | [
"function",
"optionsFromPackage",
"(",
"attempts",
")",
"{",
"attempts",
"=",
"attempts",
"||",
"2",
";",
"if",
"(",
"attempts",
">",
"5",
")",
"{",
"console",
".",
"log",
"(",
"'Can\\'t resolve main package.json file'",
")",
";",
"return",
"{",
"targets",
"... | Return options for iohook from package.json
@return {Object} | [
"Return",
"options",
"for",
"iohook",
"from",
"package",
".",
"json"
] | 7a298ab49afb5bfd75f74ab94b1fce220150d396 | https://github.com/wilix-team/iohook/blob/7a298ab49afb5bfd75f74ab94b1fce220150d396/install.js#L84-L108 | train |
govau/design-system-components | packages/main-nav/src/js/module.js | listenHandler | function listenHandler( event ) {
var handler = rawHandler.apply( this, arguments );
if ( handler === false) {
event.stopPropagation();
event.preventDefault();
}
return( handler );
} | javascript | function listenHandler( event ) {
var handler = rawHandler.apply( this, arguments );
if ( handler === false) {
event.stopPropagation();
event.preventDefault();
}
return( handler );
} | [
"function",
"listenHandler",
"(",
"event",
")",
"{",
"var",
"handler",
"=",
"rawHandler",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"if",
"(",
"handler",
"===",
"false",
")",
"{",
"event",
".",
"stopPropagation",
"(",
")",
";",
"event",
".... | Using local functions instead of anonymous for event handler | [
"Using",
"local",
"functions",
"instead",
"of",
"anonymous",
"for",
"event",
"handler"
] | 38aa8c127e1469a7835dea5513f1d6e2aff05186 | https://github.com/govau/design-system-components/blob/38aa8c127e1469a7835dea5513f1d6e2aff05186/packages/main-nav/src/js/module.js#L96-L103 | train |
govau/design-system-components | packages/main-nav/src/js/module.js | attachHandler | function attachHandler() {
var handler = rawHandler.call( element, window.event );
if ( handler === false ) {
window.event.returnValue = false;
window.event.cancelBubble = true;
}
return( handler );
} | javascript | function attachHandler() {
var handler = rawHandler.call( element, window.event );
if ( handler === false ) {
window.event.returnValue = false;
window.event.cancelBubble = true;
}
return( handler );
} | [
"function",
"attachHandler",
"(",
")",
"{",
"var",
"handler",
"=",
"rawHandler",
".",
"call",
"(",
"element",
",",
"window",
".",
"event",
")",
";",
"if",
"(",
"handler",
"===",
"false",
")",
"{",
"window",
".",
"event",
".",
"returnValue",
"=",
"false... | Make sure attachHandler is also going to work | [
"Make",
"sure",
"attachHandler",
"is",
"also",
"going",
"to",
"work"
] | 38aa8c127e1469a7835dea5513f1d6e2aff05186 | https://github.com/govau/design-system-components/blob/38aa8c127e1469a7835dea5513f1d6e2aff05186/packages/main-nav/src/js/module.js#L106-L113 | train |
govau/design-system-components | packages/main-nav/src/js/module.js | removeEvent | function removeEvent( token ) {
if ( token.element.removeEventListener ) {
token.element.removeEventListener( token.event, token.handler );
} else {
token.element.detachEvent( 'on' + token.event, token.handler );
}
} | javascript | function removeEvent( token ) {
if ( token.element.removeEventListener ) {
token.element.removeEventListener( token.event, token.handler );
} else {
token.element.detachEvent( 'on' + token.event, token.handler );
}
} | [
"function",
"removeEvent",
"(",
"token",
")",
"{",
"if",
"(",
"token",
".",
"element",
".",
"removeEventListener",
")",
"{",
"token",
".",
"element",
".",
"removeEventListener",
"(",
"token",
".",
"event",
",",
"token",
".",
"handler",
")",
";",
"}",
"el... | PRIVATE
IE8 compatible function for removing an event
@param {object} token - The token from the add listener function | [
"PRIVATE",
"IE8",
"compatible",
"function",
"for",
"removing",
"an",
"event"
] | 38aa8c127e1469a7835dea5513f1d6e2aff05186 | https://github.com/govau/design-system-components/blob/38aa8c127e1469a7835dea5513f1d6e2aff05186/packages/main-nav/src/js/module.js#L140-L146 | train |
govau/design-system-components | packages/main-nav/src/js/module.js | getStyle | function getStyle( element, property ) {
return (
typeof getComputedStyle !== 'undefined'
? getComputedStyle( element, null)
: element.currentStyle
)[ property ]; // avoid getPropertyValue altogether
} | javascript | function getStyle( element, property ) {
return (
typeof getComputedStyle !== 'undefined'
? getComputedStyle( element, null)
: element.currentStyle
)[ property ]; // avoid getPropertyValue altogether
} | [
"function",
"getStyle",
"(",
"element",
",",
"property",
")",
"{",
"return",
"(",
"typeof",
"getComputedStyle",
"!==",
"'undefined'",
"?",
"getComputedStyle",
"(",
"element",
",",
"null",
")",
":",
"element",
".",
"currentStyle",
")",
"[",
"property",
"]",
"... | PRIVATE
IE8 compatible function for getting elements style
@param {object} element - element to check style
@param {object} property - property to return value | [
"PRIVATE",
"IE8",
"compatible",
"function",
"for",
"getting",
"elements",
"style"
] | 38aa8c127e1469a7835dea5513f1d6e2aff05186 | https://github.com/govau/design-system-components/blob/38aa8c127e1469a7835dea5513f1d6e2aff05186/packages/main-nav/src/js/module.js#L156-L162 | train |
govau/design-system-components | packages/accordion/src/js/module.js | toggleClasses | function toggleClasses( element, state, openingClass, closingClass ) {
if( state === 'opening' || state === 'open' ) {
var oldClass = openingClass || 'au-accordion--closed';
var newClass = closingClass || 'au-accordion--open';
}
else {
var oldClass = closingClass || 'au-accordion--open';
var newClass... | javascript | function toggleClasses( element, state, openingClass, closingClass ) {
if( state === 'opening' || state === 'open' ) {
var oldClass = openingClass || 'au-accordion--closed';
var newClass = closingClass || 'au-accordion--open';
}
else {
var oldClass = closingClass || 'au-accordion--open';
var newClass... | [
"function",
"toggleClasses",
"(",
"element",
",",
"state",
",",
"openingClass",
",",
"closingClass",
")",
"{",
"if",
"(",
"state",
"===",
"'opening'",
"||",
"state",
"===",
"'open'",
")",
"{",
"var",
"oldClass",
"=",
"openingClass",
"||",
"'au-accordion--close... | PRIVATE
IE8 compatible function for replacing classes on a DOM node
@param {object} element - The DOM element we want to toggle classes on
@param {object} target - The DOM element we want to toggle classes on
@param {object} state - The current state of the animation on the element
@param {string... | [
"PRIVATE",
"IE8",
"compatible",
"function",
"for",
"replacing",
"classes",
"on",
"a",
"DOM",
"node"
] | 38aa8c127e1469a7835dea5513f1d6e2aff05186 | https://github.com/govau/design-system-components/blob/38aa8c127e1469a7835dea5513f1d6e2aff05186/packages/accordion/src/js/module.js#L52-L65 | train |
govau/design-system-components | scripts/helper.js | ExitHandler | function ExitHandler( exiting, error ) {
if( error ) {
if( error.stack ) {
console.error( error.stack );
}
process.exit( 1 );
}
if( exiting.now ) {
process.exit( 0 ); // exit now
}
console.log('\n');
process.exit( 0 ); // now exit with a smile :)
} | javascript | function ExitHandler( exiting, error ) {
if( error ) {
if( error.stack ) {
console.error( error.stack );
}
process.exit( 1 );
}
if( exiting.now ) {
process.exit( 0 ); // exit now
}
console.log('\n');
process.exit( 0 ); // now exit with a smile :)
} | [
"function",
"ExitHandler",
"(",
"exiting",
",",
"error",
")",
"{",
"if",
"(",
"error",
")",
"{",
"if",
"(",
"error",
".",
"stack",
")",
"{",
"console",
".",
"error",
"(",
"error",
".",
"stack",
")",
";",
"}",
"process",
".",
"exit",
"(",
"1",
")"... | Handle exiting of program
@param {null} exiting - null for bind
@param {object} error - Object to distinguish between closing events | [
"Handle",
"exiting",
"of",
"program"
] | 38aa8c127e1469a7835dea5513f1d6e2aff05186 | https://github.com/govau/design-system-components/blob/38aa8c127e1469a7835dea5513f1d6e2aff05186/scripts/helper.js#L1266-L1282 | train |
nordnet/cordova-hot-code-push | scripts/beforePluginInstallHook.js | checkCliDependency | function checkCliDependency(ctx) {
var result = spawnSync('cordova-hcp', [], { cwd: './plugins/' + ctx.opts.plugin.id });
if (!result.error) {
return;
}
suggestCliInstallation();
} | javascript | function checkCliDependency(ctx) {
var result = spawnSync('cordova-hcp', [], { cwd: './plugins/' + ctx.opts.plugin.id });
if (!result.error) {
return;
}
suggestCliInstallation();
} | [
"function",
"checkCliDependency",
"(",
"ctx",
")",
"{",
"var",
"result",
"=",
"spawnSync",
"(",
"'cordova-hcp'",
",",
"[",
"]",
",",
"{",
"cwd",
":",
"'./plugins/'",
"+",
"ctx",
".",
"opts",
".",
"plugin",
".",
"id",
"}",
")",
";",
"if",
"(",
"!",
... | region CLI specific
Check if cordova-hcp utility is installed. If not - suggest user to install it. | [
"region",
"CLI",
"specific",
"Check",
"if",
"cordova",
"-",
"hcp",
"utility",
"is",
"installed",
".",
"If",
"not",
"-",
"suggest",
"user",
"to",
"install",
"it",
"."
] | 0163767206f4cf97f49257e2ad599bf0ba61f43d | https://github.com/nordnet/cordova-hot-code-push/blob/0163767206f4cf97f49257e2ad599bf0ba61f43d/scripts/beforePluginInstallHook.js#L19-L26 | train |
nordnet/cordova-hot-code-push | scripts/beforePluginInstallHook.js | suggestCliInstallation | function suggestCliInstallation() {
console.log('---------CHCP-------------');
console.log('To make the development process easier for you - we developed a CLI client for our plugin.');
console.log('To install it, please, use command:');
console.log('npm install -g cordova-hot-code-push-cli');
console.log('Fo... | javascript | function suggestCliInstallation() {
console.log('---------CHCP-------------');
console.log('To make the development process easier for you - we developed a CLI client for our plugin.');
console.log('To install it, please, use command:');
console.log('npm install -g cordova-hot-code-push-cli');
console.log('Fo... | [
"function",
"suggestCliInstallation",
"(",
")",
"{",
"console",
".",
"log",
"(",
"'---------CHCP-------------'",
")",
";",
"console",
".",
"log",
"(",
"'To make the development process easier for you - we developed a CLI client for our plugin.'",
")",
";",
"console",
".",
"... | Show message, that developer should install CLI client for the plugin, so it would be easier to use. | [
"Show",
"message",
"that",
"developer",
"should",
"install",
"CLI",
"client",
"for",
"the",
"plugin",
"so",
"it",
"would",
"be",
"easier",
"to",
"use",
"."
] | 0163767206f4cf97f49257e2ad599bf0ba61f43d | https://github.com/nordnet/cordova-hot-code-push/blob/0163767206f4cf97f49257e2ad599bf0ba61f43d/scripts/beforePluginInstallHook.js#L31-L38 | train |
nordnet/cordova-hot-code-push | scripts/beforePluginInstallHook.js | isInstallationAlreadyPerformed | function isInstallationAlreadyPerformed(ctx) {
var pathToInstallFlag = path.join(ctx.opts.projectRoot, 'plugins', ctx.opts.plugin.id, INSTALLATION_FLAG_FILE_NAME);
try {
fs.accessSync(pathToInstallFlag, fs.F_OK);
return true;
} catch (err) {
return false;
}
} | javascript | function isInstallationAlreadyPerformed(ctx) {
var pathToInstallFlag = path.join(ctx.opts.projectRoot, 'plugins', ctx.opts.plugin.id, INSTALLATION_FLAG_FILE_NAME);
try {
fs.accessSync(pathToInstallFlag, fs.F_OK);
return true;
} catch (err) {
return false;
}
} | [
"function",
"isInstallationAlreadyPerformed",
"(",
"ctx",
")",
"{",
"var",
"pathToInstallFlag",
"=",
"path",
".",
"join",
"(",
"ctx",
".",
"opts",
".",
"projectRoot",
",",
"'plugins'",
",",
"ctx",
".",
"opts",
".",
"plugin",
".",
"id",
",",
"INSTALLATION_FLA... | region mark that we installed npm packages
Check if we already executed this hook.
@param {Object} ctx - cordova context
@return {Boolean} true if already executed; otherwise - false | [
"region",
"mark",
"that",
"we",
"installed",
"npm",
"packages",
"Check",
"if",
"we",
"already",
"executed",
"this",
"hook",
"."
] | 0163767206f4cf97f49257e2ad599bf0ba61f43d | https://github.com/nordnet/cordova-hot-code-push/blob/0163767206f4cf97f49257e2ad599bf0ba61f43d/scripts/beforePluginInstallHook.js#L49-L57 | train |
nordnet/cordova-hot-code-push | scripts/beforePluginInstallHook.js | createPluginInstalledFlag | function createPluginInstalledFlag(ctx) {
var pathToInstallFlag = path.join(ctx.opts.projectRoot, 'plugins', ctx.opts.plugin.id, INSTALLATION_FLAG_FILE_NAME);
fs.closeSync(fs.openSync(pathToInstallFlag, 'w'));
} | javascript | function createPluginInstalledFlag(ctx) {
var pathToInstallFlag = path.join(ctx.opts.projectRoot, 'plugins', ctx.opts.plugin.id, INSTALLATION_FLAG_FILE_NAME);
fs.closeSync(fs.openSync(pathToInstallFlag, 'w'));
} | [
"function",
"createPluginInstalledFlag",
"(",
"ctx",
")",
"{",
"var",
"pathToInstallFlag",
"=",
"path",
".",
"join",
"(",
"ctx",
".",
"opts",
".",
"projectRoot",
",",
"'plugins'",
",",
"ctx",
".",
"opts",
".",
"plugin",
".",
"id",
",",
"INSTALLATION_FLAG_FIL... | Create empty file - indicator, that we tried to install dependency modules after installation.
We have to do that, or this hook is gonna be called on any plugin installation. | [
"Create",
"empty",
"file",
"-",
"indicator",
"that",
"we",
"tried",
"to",
"install",
"dependency",
"modules",
"after",
"installation",
".",
"We",
"have",
"to",
"do",
"that",
"or",
"this",
"hook",
"is",
"gonna",
"be",
"called",
"on",
"any",
"plugin",
"insta... | 0163767206f4cf97f49257e2ad599bf0ba61f43d | https://github.com/nordnet/cordova-hot-code-push/blob/0163767206f4cf97f49257e2ad599bf0ba61f43d/scripts/beforePluginInstallHook.js#L63-L67 | train |
nordnet/cordova-hot-code-push | scripts/lib/chcpConfigXmlReader.js | readOptions | function readOptions(ctx) {
var configFilePath = path.join(ctx.opts.projectRoot, 'config.xml');
var configXmlContent = xmlHelper.readXmlAsJson(configFilePath, true);
return parseConfig(configXmlContent);
} | javascript | function readOptions(ctx) {
var configFilePath = path.join(ctx.opts.projectRoot, 'config.xml');
var configXmlContent = xmlHelper.readXmlAsJson(configFilePath, true);
return parseConfig(configXmlContent);
} | [
"function",
"readOptions",
"(",
"ctx",
")",
"{",
"var",
"configFilePath",
"=",
"path",
".",
"join",
"(",
"ctx",
".",
"opts",
".",
"projectRoot",
",",
"'config.xml'",
")",
";",
"var",
"configXmlContent",
"=",
"xmlHelper",
".",
"readXmlAsJson",
"(",
"configFil... | region Public API
Read plugin options from config.xml.
If none is specified - default options are returned.
@param {Object} ctx - cordova context object
@return {Object} plugin prefereces | [
"region",
"Public",
"API",
"Read",
"plugin",
"options",
"from",
"config",
".",
"xml",
".",
"If",
"none",
"is",
"specified",
"-",
"default",
"options",
"are",
"returned",
"."
] | 0163767206f4cf97f49257e2ad599bf0ba61f43d | https://github.com/nordnet/cordova-hot-code-push/blob/0163767206f4cf97f49257e2ad599bf0ba61f43d/scripts/lib/chcpConfigXmlReader.js#L24-L29 | train |
nordnet/cordova-hot-code-push | www/chcp.js | broadcastEventFromNative | function broadcastEventFromNative(nativeMessage) {
var params = {};
if (nativeMessage.error != null) {
params.error = nativeMessage.error;
}
var chcpEvent = new CustomEvent(nativeMessage.action, {
'detail': params
});
document.dispatchEvent(chcpEvent);
} | javascript | function broadcastEventFromNative(nativeMessage) {
var params = {};
if (nativeMessage.error != null) {
params.error = nativeMessage.error;
}
var chcpEvent = new CustomEvent(nativeMessage.action, {
'detail': params
});
document.dispatchEvent(chcpEvent);
} | [
"function",
"broadcastEventFromNative",
"(",
"nativeMessage",
")",
"{",
"var",
"params",
"=",
"{",
"}",
";",
"if",
"(",
"nativeMessage",
".",
"error",
"!=",
"null",
")",
"{",
"params",
".",
"error",
"=",
"nativeMessage",
".",
"error",
";",
"}",
"var",
"c... | Broadcast event that was received from the native side.
@param {Object} arguments, received from the native side | [
"Broadcast",
"event",
"that",
"was",
"received",
"from",
"the",
"native",
"side",
"."
] | 0163767206f4cf97f49257e2ad599bf0ba61f43d | https://github.com/nordnet/cordova-hot-code-push/blob/0163767206f4cf97f49257e2ad599bf0ba61f43d/www/chcp.js#L126-L136 | train |
nordnet/cordova-hot-code-push | www/chcp.js | function(options, callback) {
if (options === undefined || options == null) {
return;
}
callNativeMethod(pluginNativeMethod.CONFIGURE, options, callback);
} | javascript | function(options, callback) {
if (options === undefined || options == null) {
return;
}
callNativeMethod(pluginNativeMethod.CONFIGURE, options, callback);
} | [
"function",
"(",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"options",
"===",
"undefined",
"||",
"options",
"==",
"null",
")",
"{",
"return",
";",
"}",
"callNativeMethod",
"(",
"pluginNativeMethod",
".",
"CONFIGURE",
",",
"options",
",",
"callback",
... | DEPRECATED! WILL BE REMOVED EVENTUALLY!
If you want to set config-url - use chcp.fetchUpdate(callback, options).
If you want to set auto-download/auto-install preference - do it in config.xml instead of this method.
Set plugin options.
Options are send to the native side.
As soon as they are processed - callback is c... | [
"DEPRECATED!",
"WILL",
"BE",
"REMOVED",
"EVENTUALLY!"
] | 0163767206f4cf97f49257e2ad599bf0ba61f43d | https://github.com/nordnet/cordova-hot-code-push/blob/0163767206f4cf97f49257e2ad599bf0ba61f43d/www/chcp.js#L201-L207 | train | |
nordnet/cordova-hot-code-push | scripts/lib/chcpConfigXmlWriter.js | setup | function setup(context) {
cordovaContext = context;
platforms = context.opts.platforms;
projectRoot = context.opts.projectRoot;
} | javascript | function setup(context) {
cordovaContext = context;
platforms = context.opts.platforms;
projectRoot = context.opts.projectRoot;
} | [
"function",
"setup",
"(",
"context",
")",
"{",
"cordovaContext",
"=",
"context",
";",
"platforms",
"=",
"context",
".",
"opts",
".",
"platforms",
";",
"projectRoot",
"=",
"context",
".",
"opts",
".",
"projectRoot",
";",
"}"
] | region Private API
Initialize module.
@param {Object} cordovaContext - cordova context instance | [
"region",
"Private",
"API",
"Initialize",
"module",
"."
] | 0163767206f4cf97f49257e2ad599bf0ba61f43d | https://github.com/nordnet/cordova-hot-code-push/blob/0163767206f4cf97f49257e2ad599bf0ba61f43d/scripts/lib/chcpConfigXmlWriter.js#L38-L42 | train |
nordnet/cordova-hot-code-push | scripts/lib/chcpConfigXmlWriter.js | getProjectName | function getProjectName(ctx, projectRoot) {
var cordova_util = ctx.requireCordovaModule('cordova-lib/src/cordova/util');
var xml = cordova_util.projectConfig(projectRoot);
var ConfigParser;
// If we are running Cordova 5.4 or abova - use parser from cordova-common.
// Otherwise - from cordova-lib.
try {
... | javascript | function getProjectName(ctx, projectRoot) {
var cordova_util = ctx.requireCordovaModule('cordova-lib/src/cordova/util');
var xml = cordova_util.projectConfig(projectRoot);
var ConfigParser;
// If we are running Cordova 5.4 or abova - use parser from cordova-common.
// Otherwise - from cordova-lib.
try {
... | [
"function",
"getProjectName",
"(",
"ctx",
",",
"projectRoot",
")",
"{",
"var",
"cordova_util",
"=",
"ctx",
".",
"requireCordovaModule",
"(",
"'cordova-lib/src/cordova/util'",
")",
";",
"var",
"xml",
"=",
"cordova_util",
".",
"projectConfig",
"(",
"projectRoot",
")... | Get name of the current project.
@param {Object} ctx - cordova context instance
@param {String} projectRoot - current root of the project
@return {String} name of the project | [
"Get",
"name",
"of",
"the",
"current",
"project",
"."
] | 0163767206f4cf97f49257e2ad599bf0ba61f43d | https://github.com/nordnet/cordova-hot-code-push/blob/0163767206f4cf97f49257e2ad599bf0ba61f43d/scripts/lib/chcpConfigXmlWriter.js#L52-L66 | train |
nordnet/cordova-hot-code-push | scripts/lib/chcpConfigXmlWriter.js | getPlatformSpecificConfigXml | function getPlatformSpecificConfigXml(platform) {
var configFilePath = null;
switch (platform) {
case 'ios':
{
configFilePath = pathToIosConfigXml();
break;
}
case 'android':
{
configFilePath = pathToAndroidConfigXml();
break;
}
}
return configFil... | javascript | function getPlatformSpecificConfigXml(platform) {
var configFilePath = null;
switch (platform) {
case 'ios':
{
configFilePath = pathToIosConfigXml();
break;
}
case 'android':
{
configFilePath = pathToAndroidConfigXml();
break;
}
}
return configFil... | [
"function",
"getPlatformSpecificConfigXml",
"(",
"platform",
")",
"{",
"var",
"configFilePath",
"=",
"null",
";",
"switch",
"(",
"platform",
")",
"{",
"case",
"'ios'",
":",
"{",
"configFilePath",
"=",
"pathToIosConfigXml",
"(",
")",
";",
"break",
";",
"}",
"... | Get path to platform-specific config.xml file.
@param {String} platform - for what platform we need config.xml
@return {String} absolute path to config.xml | [
"Get",
"path",
"to",
"platform",
"-",
"specific",
"config",
".",
"xml",
"file",
"."
] | 0163767206f4cf97f49257e2ad599bf0ba61f43d | https://github.com/nordnet/cordova-hot-code-push/blob/0163767206f4cf97f49257e2ad599bf0ba61f43d/scripts/lib/chcpConfigXmlWriter.js#L94-L110 | train |
nordnet/cordova-hot-code-push | scripts/lib/chcpConfigXmlWriter.js | injectOptions | function injectOptions(options) {
platforms.forEach(function(platform) {
var configXmlFilePath = getPlatformSpecificConfigXml(platform);
if (configXmlFilePath == null) {
return;
}
// read data from config.xml
var configData = xmlHelper.readXmlAsJson(configXmlFilePath);
if (configData ==... | javascript | function injectOptions(options) {
platforms.forEach(function(platform) {
var configXmlFilePath = getPlatformSpecificConfigXml(platform);
if (configXmlFilePath == null) {
return;
}
// read data from config.xml
var configData = xmlHelper.readXmlAsJson(configXmlFilePath);
if (configData ==... | [
"function",
"injectOptions",
"(",
"options",
")",
"{",
"platforms",
".",
"forEach",
"(",
"function",
"(",
"platform",
")",
"{",
"var",
"configXmlFilePath",
"=",
"getPlatformSpecificConfigXml",
"(",
"platform",
")",
";",
"if",
"(",
"configXmlFilePath",
"==",
"nul... | Write provided options into config.xml file for each platform.
@param {Object} options - plugin options | [
"Write",
"provided",
"options",
"into",
"config",
".",
"xml",
"file",
"for",
"each",
"platform",
"."
] | 0163767206f4cf97f49257e2ad599bf0ba61f43d | https://github.com/nordnet/cordova-hot-code-push/blob/0163767206f4cf97f49257e2ad599bf0ba61f43d/scripts/lib/chcpConfigXmlWriter.js#L117-L142 | train |
nordnet/cordova-hot-code-push | scripts/afterPrepareHook.js | processConsoleOptions | function processConsoleOptions(ctx) {
var consoleOptions = ctx.opts.options;
// If we are using Cordova 5.3.3 or lower - arguments are array of strings.
// Will be removed after some time.
if (consoleOptions instanceof Array) {
return processConsoleOptions_cordova_53(consoleOptions);
}
// for newer ve... | javascript | function processConsoleOptions(ctx) {
var consoleOptions = ctx.opts.options;
// If we are using Cordova 5.3.3 or lower - arguments are array of strings.
// Will be removed after some time.
if (consoleOptions instanceof Array) {
return processConsoleOptions_cordova_53(consoleOptions);
}
// for newer ve... | [
"function",
"processConsoleOptions",
"(",
"ctx",
")",
"{",
"var",
"consoleOptions",
"=",
"ctx",
".",
"opts",
".",
"options",
";",
"// If we are using Cordova 5.3.3 or lower - arguments are array of strings.",
"// Will be removed after some time.",
"if",
"(",
"consoleOptions",
... | Read arguments from console.
We are reading only plugin-related preferences.
@param {Object} ctx - cordova context object
@return {Object} parsed arguments; if none were provided - default options are returned | [
"Read",
"arguments",
"from",
"console",
".",
"We",
"are",
"reading",
"only",
"plugin",
"-",
"related",
"preferences",
"."
] | 0163767206f4cf97f49257e2ad599bf0ba61f43d | https://github.com/nordnet/cordova-hot-code-push/blob/0163767206f4cf97f49257e2ad599bf0ba61f43d/scripts/afterPrepareHook.js#L48-L59 | train |
nordnet/cordova-hot-code-push | scripts/afterPrepareHook.js | prepareWithCustomBuildOption | function prepareWithCustomBuildOption(ctx, optionName, chcpXmlOptions) {
if (optionName.length == 0) {
return false;
}
var buildConfig = chcpBuildOptions.getBuildConfigurationByName(ctx, optionName);
if (buildConfig == null) {
console.warn('Build configuration for "' + optionName + '" not found in chcp... | javascript | function prepareWithCustomBuildOption(ctx, optionName, chcpXmlOptions) {
if (optionName.length == 0) {
return false;
}
var buildConfig = chcpBuildOptions.getBuildConfigurationByName(ctx, optionName);
if (buildConfig == null) {
console.warn('Build configuration for "' + optionName + '" not found in chcp... | [
"function",
"prepareWithCustomBuildOption",
"(",
"ctx",
",",
"optionName",
",",
"chcpXmlOptions",
")",
"{",
"if",
"(",
"optionName",
".",
"length",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"var",
"buildConfig",
"=",
"chcpBuildOptions",
".",
"getBuildC... | Try to inject build options according to the arguments from the console.
@param {Object} ctx - cordova context object
@param {String} optionName - build option name from console; will be mapped to configuration from chcpbuild.options file
@return {boolean} true - if build option is found and we successfully injected i... | [
"Try",
"to",
"inject",
"build",
"options",
"according",
"to",
"the",
"arguments",
"from",
"the",
"console",
"."
] | 0163767206f4cf97f49257e2ad599bf0ba61f43d | https://github.com/nordnet/cordova-hot-code-push/blob/0163767206f4cf97f49257e2ad599bf0ba61f43d/scripts/afterPrepareHook.js#L127-L149 | train |
nordnet/cordova-hot-code-push | scripts/lib/iosWKWebViewEngineSupport.js | setWKWebViewEngineMacro | function setWKWebViewEngineMacro(cordovaContext) {
init(cordovaContext);
// injecting options in project file
var projectFile = loadProjectFile();
setMacro(projectFile.xcode);
projectFile.write();
} | javascript | function setWKWebViewEngineMacro(cordovaContext) {
init(cordovaContext);
// injecting options in project file
var projectFile = loadProjectFile();
setMacro(projectFile.xcode);
projectFile.write();
} | [
"function",
"setWKWebViewEngineMacro",
"(",
"cordovaContext",
")",
"{",
"init",
"(",
"cordovaContext",
")",
";",
"// injecting options in project file",
"var",
"projectFile",
"=",
"loadProjectFile",
"(",
")",
";",
"setMacro",
"(",
"projectFile",
".",
"xcode",
")",
"... | Define preprocessor macro for WKWebViewEngine.
@param {Object} cordovaContext - cordova context | [
"Define",
"preprocessor",
"macro",
"for",
"WKWebViewEngine",
"."
] | 0163767206f4cf97f49257e2ad599bf0ba61f43d | https://github.com/nordnet/cordova-hot-code-push/blob/0163767206f4cf97f49257e2ad599bf0ba61f43d/scripts/lib/iosWKWebViewEngineSupport.js#L27-L34 | train |
nordnet/cordova-hot-code-push | scripts/lib/iosWKWebViewEngineSupport.js | init | function init(ctx) {
context = ctx;
projectRoot = ctx.opts.projectRoot;
projectName = getProjectName(ctx, projectRoot);
iosPlatformPath = path.join(projectRoot, 'platforms', 'ios');
var wkWebViewPluginPath = path.join(projectRoot, 'plugins', WKWEBVIEW_PLUGIN_NAME);
isWkWebViewEngineUsed = isDirectoryExists... | javascript | function init(ctx) {
context = ctx;
projectRoot = ctx.opts.projectRoot;
projectName = getProjectName(ctx, projectRoot);
iosPlatformPath = path.join(projectRoot, 'platforms', 'ios');
var wkWebViewPluginPath = path.join(projectRoot, 'plugins', WKWEBVIEW_PLUGIN_NAME);
isWkWebViewEngineUsed = isDirectoryExists... | [
"function",
"init",
"(",
"ctx",
")",
"{",
"context",
"=",
"ctx",
";",
"projectRoot",
"=",
"ctx",
".",
"opts",
".",
"projectRoot",
";",
"projectName",
"=",
"getProjectName",
"(",
"ctx",
",",
"projectRoot",
")",
";",
"iosPlatformPath",
"=",
"path",
".",
"j... | region General private methods
Initialize before execution.
@param {Object} ctx - cordova context instance | [
"region",
"General",
"private",
"methods",
"Initialize",
"before",
"execution",
"."
] | 0163767206f4cf97f49257e2ad599bf0ba61f43d | https://github.com/nordnet/cordova-hot-code-push/blob/0163767206f4cf97f49257e2ad599bf0ba61f43d/scripts/lib/iosWKWebViewEngineSupport.js#L43-L51 | train |
nordnet/cordova-hot-code-push | scripts/lib/iosWKWebViewEngineSupport.js | setMacro | function setMacro(xcodeProject) {
var configurations = nonComments(xcodeProject.pbxXCBuildConfigurationSection());
var config;
var buildSettings;
for (config in configurations) {
buildSettings = configurations[config].buildSettings;
var preprocessorDefs = buildSettings['GCC_PREPROCESSOR_DEFINITIONS'] ?... | javascript | function setMacro(xcodeProject) {
var configurations = nonComments(xcodeProject.pbxXCBuildConfigurationSection());
var config;
var buildSettings;
for (config in configurations) {
buildSettings = configurations[config].buildSettings;
var preprocessorDefs = buildSettings['GCC_PREPROCESSOR_DEFINITIONS'] ?... | [
"function",
"setMacro",
"(",
"xcodeProject",
")",
"{",
"var",
"configurations",
"=",
"nonComments",
"(",
"xcodeProject",
".",
"pbxXCBuildConfigurationSection",
"(",
")",
")",
";",
"var",
"config",
";",
"var",
"buildSettings",
";",
"for",
"(",
"config",
"in",
"... | region Macros injection
Inject WKWebView macro into project configuration file.
@param {Object} xcodeProject - xcode project file instance | [
"region",
"Macros",
"injection",
"Inject",
"WKWebView",
"macro",
"into",
"project",
"configuration",
"file",
"."
] | 0163767206f4cf97f49257e2ad599bf0ba61f43d | https://github.com/nordnet/cordova-hot-code-push/blob/0163767206f4cf97f49257e2ad599bf0ba61f43d/scripts/lib/iosWKWebViewEngineSupport.js#L167-L202 | train |
nordnet/cordova-hot-code-push | scripts/lib/chcpBuildOptions.js | getBuildConfigurationByName | function getBuildConfigurationByName(ctx, buildName) {
// load options from the chcpbuild.options file
var chcpBuildOptions = getBuildOptionsFromConfig(ctx);
if (chcpBuildOptions == null) {
return null;
}
var resultConfig = chcpBuildOptions[buildName];
if (!resultConfig) {
return null;
}
// ba... | javascript | function getBuildConfigurationByName(ctx, buildName) {
// load options from the chcpbuild.options file
var chcpBuildOptions = getBuildOptionsFromConfig(ctx);
if (chcpBuildOptions == null) {
return null;
}
var resultConfig = chcpBuildOptions[buildName];
if (!resultConfig) {
return null;
}
// ba... | [
"function",
"getBuildConfigurationByName",
"(",
"ctx",
",",
"buildName",
")",
"{",
"// load options from the chcpbuild.options file",
"var",
"chcpBuildOptions",
"=",
"getBuildOptionsFromConfig",
"(",
"ctx",
")",
";",
"if",
"(",
"chcpBuildOptions",
"==",
"null",
")",
"{"... | region Public API
Generate build options depending on the options, provided in console.
@param {String} buildName - build identifier
@return {Object} build options; null - if none are found | [
"region",
"Public",
"API",
"Generate",
"build",
"options",
"depending",
"on",
"the",
"options",
"provided",
"in",
"console",
"."
] | 0163767206f4cf97f49257e2ad599bf0ba61f43d | https://github.com/nordnet/cordova-hot-code-push/blob/0163767206f4cf97f49257e2ad599bf0ba61f43d/scripts/lib/chcpBuildOptions.js#L22-L44 | train |
nordnet/cordova-hot-code-push | scripts/lib/chcpBuildOptions.js | getBuildOptionsFromConfig | function getBuildOptionsFromConfig(ctx) {
var chcpBuildOptionsFilePath = path.join(ctx.opts.projectRoot, OPTIONS_FILE_NAME);
return readObjectFromFile(chcpBuildOptionsFilePath);
} | javascript | function getBuildOptionsFromConfig(ctx) {
var chcpBuildOptionsFilePath = path.join(ctx.opts.projectRoot, OPTIONS_FILE_NAME);
return readObjectFromFile(chcpBuildOptionsFilePath);
} | [
"function",
"getBuildOptionsFromConfig",
"(",
"ctx",
")",
"{",
"var",
"chcpBuildOptionsFilePath",
"=",
"path",
".",
"join",
"(",
"ctx",
".",
"opts",
".",
"projectRoot",
",",
"OPTIONS_FILE_NAME",
")",
";",
"return",
"readObjectFromFile",
"(",
"chcpBuildOptionsFilePat... | region Private API
Read options, listed in chcpbuild.options file.
@return {Object} options from chcpbuild.options file | [
"region",
"Private",
"API",
"Read",
"options",
"listed",
"in",
"chcpbuild",
".",
"options",
"file",
"."
] | 0163767206f4cf97f49257e2ad599bf0ba61f43d | https://github.com/nordnet/cordova-hot-code-push/blob/0163767206f4cf97f49257e2ad599bf0ba61f43d/scripts/lib/chcpBuildOptions.js#L55-L59 | train |
nordnet/cordova-hot-code-push | scripts/lib/xmlHelper.js | writeJsonAsXml | function writeJsonAsXml(jsData, filePath, options) {
var xmlBuilder = new xml2js.Builder(options);
var changedXmlData = xmlBuilder.buildObject(jsData);
var isSaved = true;
try {
fs.writeFileSync(filePath, changedXmlData);
} catch (err) {
console.log(err);
isSaved = false;
}
return isSaved;
} | javascript | function writeJsonAsXml(jsData, filePath, options) {
var xmlBuilder = new xml2js.Builder(options);
var changedXmlData = xmlBuilder.buildObject(jsData);
var isSaved = true;
try {
fs.writeFileSync(filePath, changedXmlData);
} catch (err) {
console.log(err);
isSaved = false;
}
return isSaved;
} | [
"function",
"writeJsonAsXml",
"(",
"jsData",
",",
"filePath",
",",
"options",
")",
"{",
"var",
"xmlBuilder",
"=",
"new",
"xml2js",
".",
"Builder",
"(",
"options",
")",
";",
"var",
"changedXmlData",
"=",
"xmlBuilder",
".",
"buildObject",
"(",
"jsData",
")",
... | Write JSON object as xml into the specified file.
@param {Object} jsData - JSON object to write
@param {String} filePath - path to the xml file where data should be saved
@param {Object} options - xml options
@return {boolean} true - if data saved to file; false - otherwise | [
"Write",
"JSON",
"object",
"as",
"xml",
"into",
"the",
"specified",
"file",
"."
] | 0163767206f4cf97f49257e2ad599bf0ba61f43d | https://github.com/nordnet/cordova-hot-code-push/blob/0163767206f4cf97f49257e2ad599bf0ba61f43d/scripts/lib/xmlHelper.js#L57-L70 | train |
distillpub/template | src/transforms/typeset.js | acceptNode | function acceptNode(node) {
var parent = node.parentElement;
var isMath = (parent && parent.getAttribute && parent.getAttribute('class')) ? parent.getAttribute('class').includes('katex') || parent.getAttribute('class').includes('MathJax') : false;
return parent &&
parent.nodeName !== 'SCRIPT' &&
... | javascript | function acceptNode(node) {
var parent = node.parentElement;
var isMath = (parent && parent.getAttribute && parent.getAttribute('class')) ? parent.getAttribute('class').includes('katex') || parent.getAttribute('class').includes('MathJax') : false;
return parent &&
parent.nodeName !== 'SCRIPT' &&
... | [
"function",
"acceptNode",
"(",
"node",
")",
"{",
"var",
"parent",
"=",
"node",
".",
"parentElement",
";",
"var",
"isMath",
"=",
"(",
"parent",
"&&",
"parent",
".",
"getAttribute",
"&&",
"parent",
".",
"getAttribute",
"(",
"'class'",
")",
")",
"?",
"paren... | 2018-07-11 shancarter@ and ludwigschubert@ no longer know what this was meant to accomplish if it was trying to not replace text in any child nodes of those listed here, then it does not accomplish that. | [
"2018",
"-",
"07",
"-",
"11",
"shancarter"
] | 042da68b9ab9cbbe42fcce3f38b58f1a305dd415 | https://github.com/distillpub/template/blob/042da68b9ab9cbbe42fcce3f38b58f1a305dd415/src/transforms/typeset.js#L38-L58 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.