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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
dabeng/OrgChart | dist/js/jquery.orgchart.js | function ($node) {
var $lowerLevel = $node.closest('tr').siblings();
this.stopAjax($lowerLevel.last());
var $animatedNodes = $lowerLevel.last().find('.node').filter(this.isVisibleNode.bind(this));
var isVerticalDesc = $lowerLevel.last().is('.verticalNodes') ? true : false;
if (!isVerticalD... | javascript | function ($node) {
var $lowerLevel = $node.closest('tr').siblings();
this.stopAjax($lowerLevel.last());
var $animatedNodes = $lowerLevel.last().find('.node').filter(this.isVisibleNode.bind(this));
var isVerticalDesc = $lowerLevel.last().is('.verticalNodes') ? true : false;
if (!isVerticalD... | [
"function",
"(",
"$node",
")",
"{",
"var",
"$lowerLevel",
"=",
"$node",
".",
"closest",
"(",
"'tr'",
")",
".",
"siblings",
"(",
")",
";",
"this",
".",
"stopAjax",
"(",
"$lowerLevel",
".",
"last",
"(",
")",
")",
";",
"var",
"$animatedNodes",
"=",
"$lo... | recursively hide the descendant nodes of the specified node | [
"recursively",
"hide",
"the",
"descendant",
"nodes",
"of",
"the",
"specified",
"node"
] | 188a8e4ba6dd0979588474765edb01891d85a38d | https://github.com/dabeng/OrgChart/blob/188a8e4ba6dd0979588474765edb01891d85a38d/dist/js/jquery.orgchart.js#L525-L535 | train | |
dabeng/OrgChart | dist/js/jquery.orgchart.js | function ($node) {
var that = this;
var $levels = $node.closest('tr').siblings();
var isVerticalDesc = $levels.is('.verticalNodes') ? true : false;
var $animatedNodes = isVerticalDesc
? $levels.removeClass('hidden').find('.node').filter(this.isVisibleNode.bind(this))
: $levels.re... | javascript | function ($node) {
var that = this;
var $levels = $node.closest('tr').siblings();
var isVerticalDesc = $levels.is('.verticalNodes') ? true : false;
var $animatedNodes = isVerticalDesc
? $levels.removeClass('hidden').find('.node').filter(this.isVisibleNode.bind(this))
: $levels.re... | [
"function",
"(",
"$node",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"$levels",
"=",
"$node",
".",
"closest",
"(",
"'tr'",
")",
".",
"siblings",
"(",
")",
";",
"var",
"isVerticalDesc",
"=",
"$levels",
".",
"is",
"(",
"'.verticalNodes'",
")",
"... | show the children nodes of the specified node | [
"show",
"the",
"children",
"nodes",
"of",
"the",
"specified",
"node"
] | 188a8e4ba6dd0979588474765edb01891d85a38d | https://github.com/dabeng/OrgChart/blob/188a8e4ba6dd0979588474765edb01891d85a38d/dist/js/jquery.orgchart.js#L545-L555 | train | |
dabeng/OrgChart | dist/js/jquery.orgchart.js | function ($node, direction) {
var that = this;
var $nodeContainer = $node.closest('table').parent();
if ($nodeContainer.siblings().find('.spinner').length) {
$node.closest('.orgchart').data('inAjax', false);
}
if (direction) {
if (direction === 'left') {
$nodeCont... | javascript | function ($node, direction) {
var that = this;
var $nodeContainer = $node.closest('table').parent();
if ($nodeContainer.siblings().find('.spinner').length) {
$node.closest('.orgchart').data('inAjax', false);
}
if (direction) {
if (direction === 'left') {
$nodeCont... | [
"function",
"(",
"$node",
",",
"direction",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"$nodeContainer",
"=",
"$node",
".",
"closest",
"(",
"'table'",
")",
".",
"parent",
"(",
")",
";",
"if",
"(",
"$nodeContainer",
".",
"siblings",
"(",
")",
"... | hide the sibling nodes of the specified node | [
"hide",
"the",
"sibling",
"nodes",
"of",
"the",
"specified",
"node"
] | 188a8e4ba6dd0979588474765edb01891d85a38d | https://github.com/dabeng/OrgChart/blob/188a8e4ba6dd0979588474765edb01891d85a38d/dist/js/jquery.orgchart.js#L576-L595 | train | |
dabeng/OrgChart | dist/js/jquery.orgchart.js | function ($node, direction) {
var that = this;
// firstly, show the sibling td tags
var $siblings = $();
if (direction) {
if (direction === 'left') {
$siblings = $node.closest('table').parent().prevAll().removeClass('hidden');
} else {
$siblings = $node.closes... | javascript | function ($node, direction) {
var that = this;
// firstly, show the sibling td tags
var $siblings = $();
if (direction) {
if (direction === 'left') {
$siblings = $node.closest('table').parent().prevAll().removeClass('hidden');
} else {
$siblings = $node.closes... | [
"function",
"(",
"$node",
",",
"direction",
")",
"{",
"var",
"that",
"=",
"this",
";",
"// firstly, show the sibling td tags",
"var",
"$siblings",
"=",
"$",
"(",
")",
";",
"if",
"(",
"direction",
")",
"{",
"if",
"(",
"direction",
"===",
"'left'",
")",
"{... | show the sibling nodes of the specified node | [
"show",
"the",
"sibling",
"nodes",
"of",
"the",
"specified",
"node"
] | 188a8e4ba6dd0979588474765edb01891d85a38d | https://github.com/dabeng/OrgChart/blob/188a8e4ba6dd0979588474765edb01891d85a38d/dist/js/jquery.orgchart.js#L610-L642 | train | |
dabeng/OrgChart | dist/js/jquery.orgchart.js | function ($edge) {
var $chart = this.$chart;
if (typeof $chart.data('inAjax') !== 'undefined' && $chart.data('inAjax') === true) {
return false;
}
$edge.addClass('hidden');
$edge.parent().append('<i class="fa fa-circle-o-notch fa-spin spinner"></i>')
.children().not('.spin... | javascript | function ($edge) {
var $chart = this.$chart;
if (typeof $chart.data('inAjax') !== 'undefined' && $chart.data('inAjax') === true) {
return false;
}
$edge.addClass('hidden');
$edge.parent().append('<i class="fa fa-circle-o-notch fa-spin spinner"></i>')
.children().not('.spin... | [
"function",
"(",
"$edge",
")",
"{",
"var",
"$chart",
"=",
"this",
".",
"$chart",
";",
"if",
"(",
"typeof",
"$chart",
".",
"data",
"(",
"'inAjax'",
")",
"!==",
"'undefined'",
"&&",
"$chart",
".",
"data",
"(",
"'inAjax'",
")",
"===",
"true",
")",
"{",
... | start up loading status for requesting new nodes | [
"start",
"up",
"loading",
"status",
"for",
"requesting",
"new",
"nodes"
] | 188a8e4ba6dd0979588474765edb01891d85a38d | https://github.com/dabeng/OrgChart/blob/188a8e4ba6dd0979588474765edb01891d85a38d/dist/js/jquery.orgchart.js#L644-L656 | train | |
dabeng/OrgChart | dist/js/jquery.orgchart.js | function ($edge) {
var $node = $edge.parent();
$edge.removeClass('hidden');
$node.find('.spinner').remove();
$node.children().removeAttr('style');
this.$chart.data('inAjax', false);
$('.oc-export-btn' + (this.options.chartClass !== '' ? '.' + this.options.chartClass : '')).prop('disa... | javascript | function ($edge) {
var $node = $edge.parent();
$edge.removeClass('hidden');
$node.find('.spinner').remove();
$node.children().removeAttr('style');
this.$chart.data('inAjax', false);
$('.oc-export-btn' + (this.options.chartClass !== '' ? '.' + this.options.chartClass : '')).prop('disa... | [
"function",
"(",
"$edge",
")",
"{",
"var",
"$node",
"=",
"$edge",
".",
"parent",
"(",
")",
";",
"$edge",
".",
"removeClass",
"(",
"'hidden'",
")",
";",
"$node",
".",
"find",
"(",
"'.spinner'",
")",
".",
"remove",
"(",
")",
";",
"$node",
".",
"child... | terminate loading status for requesting new nodes | [
"terminate",
"loading",
"status",
"for",
"requesting",
"new",
"nodes"
] | 188a8e4ba6dd0979588474765edb01891d85a38d | https://github.com/dabeng/OrgChart/blob/188a8e4ba6dd0979588474765edb01891d85a38d/dist/js/jquery.orgchart.js#L658-L665 | train | |
dabeng/OrgChart | dist/js/jquery.orgchart.js | function (rel, url, $edge) {
var that = this;
var opts = this.options;
$.ajax({ 'url': url, 'dataType': 'json' })
.done(function (data) {
if (that.$chart.data('inAjax')) {
if (rel === 'parent') {
if (!$.isEmptyObject(data)) {
that.addParent($edge.paren... | javascript | function (rel, url, $edge) {
var that = this;
var opts = this.options;
$.ajax({ 'url': url, 'dataType': 'json' })
.done(function (data) {
if (that.$chart.data('inAjax')) {
if (rel === 'parent') {
if (!$.isEmptyObject(data)) {
that.addParent($edge.paren... | [
"function",
"(",
"rel",
",",
"url",
",",
"$edge",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"opts",
"=",
"this",
".",
"options",
";",
"$",
".",
"ajax",
"(",
"{",
"'url'",
":",
"url",
",",
"'dataType'",
":",
"'json'",
"}",
")",
".",
"don... | load new nodes by ajax | [
"load",
"new",
"nodes",
"by",
"ajax"
] | 188a8e4ba6dd0979588474765edb01891d85a38d | https://github.com/dabeng/OrgChart/blob/188a8e4ba6dd0979588474765edb01891d85a38d/dist/js/jquery.orgchart.js#L736-L761 | train | |
dabeng/OrgChart | dist/js/jquery.orgchart.js | function ($appendTo, data) {
var that = this;
var opts = this.options;
var level = 0;
if (data.level) {
level = data.level;
} else {
level = data.level = $appendTo.parentsUntil('.orgchart', '.nodes').length + 1;
}
// Construct the node
var childrenData = d... | javascript | function ($appendTo, data) {
var that = this;
var opts = this.options;
var level = 0;
if (data.level) {
level = data.level;
} else {
level = data.level = $appendTo.parentsUntil('.orgchart', '.nodes').length + 1;
}
// Construct the node
var childrenData = d... | [
"function",
"(",
"$appendTo",
",",
"data",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"opts",
"=",
"this",
".",
"options",
";",
"var",
"level",
"=",
"0",
";",
"if",
"(",
"data",
".",
"level",
")",
"{",
"level",
"=",
"data",
".",
"level",
... | recursively build the tree | [
"recursively",
"build",
"the",
"tree"
] | 188a8e4ba6dd0979588474765edb01891d85a38d | https://github.com/dabeng/OrgChart/blob/188a8e4ba6dd0979588474765edb01891d85a38d/dist/js/jquery.orgchart.js#L1193-L1253 | train | |
dabeng/OrgChart | dist/js/jquery.orgchart.js | function ($currentRoot, data) {
data.relationship = data.relationship || '001';
var $table = $('<table>')
.append($('<tr>').append($('<td colspan="2">').append(this.createNode(data))))
.append('<tr class="lines"><td colspan="2"><div class="downLine"></div></td></tr>')
.append('<tr cl... | javascript | function ($currentRoot, data) {
data.relationship = data.relationship || '001';
var $table = $('<table>')
.append($('<tr>').append($('<td colspan="2">').append(this.createNode(data))))
.append('<tr class="lines"><td colspan="2"><div class="downLine"></div></td></tr>')
.append('<tr cl... | [
"function",
"(",
"$currentRoot",
",",
"data",
")",
"{",
"data",
".",
"relationship",
"=",
"data",
".",
"relationship",
"||",
"'001'",
";",
"var",
"$table",
"=",
"$",
"(",
"'<table>'",
")",
".",
"append",
"(",
"$",
"(",
"'<tr>'",
")",
".",
"append",
"... | build the parent node of specific node | [
"build",
"the",
"parent",
"node",
"of",
"specific",
"node"
] | 188a8e4ba6dd0979588474765edb01891d85a38d | https://github.com/dabeng/OrgChart/blob/188a8e4ba6dd0979588474765edb01891d85a38d/dist/js/jquery.orgchart.js#L1273-L1282 | train | |
dabeng/OrgChart | dist/js/jquery.orgchart.js | function ($oneSibling, siblingCount, existingSibligCount) {
var lines = '';
for (var i = 0; i < existingSibligCount; i++) {
lines += '<td class="leftLine topLine"></td><td class="rightLine topLine"></td>';
}
$oneSibling.parent().prevAll('tr:gt(0)').children().attr('colspan', siblingCount... | javascript | function ($oneSibling, siblingCount, existingSibligCount) {
var lines = '';
for (var i = 0; i < existingSibligCount; i++) {
lines += '<td class="leftLine topLine"></td><td class="rightLine topLine"></td>';
}
$oneSibling.parent().prevAll('tr:gt(0)').children().attr('colspan', siblingCount... | [
"function",
"(",
"$oneSibling",
",",
"siblingCount",
",",
"existingSibligCount",
")",
"{",
"var",
"lines",
"=",
"''",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"existingSibligCount",
";",
"i",
"++",
")",
"{",
"lines",
"+=",
"'<td class=\"left... | subsequent processing of build sibling nodes | [
"subsequent",
"processing",
"of",
"build",
"sibling",
"nodes"
] | 188a8e4ba6dd0979588474765edb01891d85a38d | https://github.com/dabeng/OrgChart/blob/188a8e4ba6dd0979588474765edb01891d85a38d/dist/js/jquery.orgchart.js#L1294-L1301 | train | |
dabeng/OrgChart | dist/js/jquery.orgchart.js | function ($nodeChart, data) {
var newSiblingCount = $.isArray(data) ? data.length : data.children.length;
var existingSibligCount = $nodeChart.parent().is('td') ? $nodeChart.closest('tr').children().length : 1;
var siblingCount = existingSibligCount + newSiblingCount;
var insertPostion = (siblin... | javascript | function ($nodeChart, data) {
var newSiblingCount = $.isArray(data) ? data.length : data.children.length;
var existingSibligCount = $nodeChart.parent().is('td') ? $nodeChart.closest('tr').children().length : 1;
var siblingCount = existingSibligCount + newSiblingCount;
var insertPostion = (siblin... | [
"function",
"(",
"$nodeChart",
",",
"data",
")",
"{",
"var",
"newSiblingCount",
"=",
"$",
".",
"isArray",
"(",
"data",
")",
"?",
"data",
".",
"length",
":",
"data",
".",
"children",
".",
"length",
";",
"var",
"existingSibligCount",
"=",
"$nodeChart",
"."... | build the sibling nodes of specific node | [
"build",
"the",
"sibling",
"nodes",
"of",
"specific",
"node"
] | 188a8e4ba6dd0979588474765edb01891d85a38d | https://github.com/dabeng/OrgChart/blob/188a8e4ba6dd0979588474765edb01891d85a38d/dist/js/jquery.orgchart.js#L1303-L1324 | train | |
OnsenUI/OnsenUI | core/src/ons/styler.js | function(element, style) {
Object.keys(style).forEach(function(key) {
if (key in element.style) {
element.style[key] = style[key];
} else if (prefix(key) in element.style) {
element.style[prefix(key)] = style[key];
} else {
util.warn('No such style property: ' + key);
}
});
retur... | javascript | function(element, style) {
Object.keys(style).forEach(function(key) {
if (key in element.style) {
element.style[key] = style[key];
} else if (prefix(key) in element.style) {
element.style[prefix(key)] = style[key];
} else {
util.warn('No such style property: ' + key);
}
});
retur... | [
"function",
"(",
"element",
",",
"style",
")",
"{",
"Object",
".",
"keys",
"(",
"style",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"if",
"(",
"key",
"in",
"element",
".",
"style",
")",
"{",
"element",
".",
"style",
"[",
"key",
"... | Minimal utility library for manipulating element's style.
Set element's style.
@param {Element} element
@param {Object} styles
@return {Element} | [
"Minimal",
"utility",
"library",
"for",
"manipulating",
"element",
"s",
"style",
".",
"Set",
"element",
"s",
"style",
"."
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/styler.js#L48-L59 | train | |
OnsenUI/OnsenUI | core/src/ons/gesture-detector.js | setup | function setup(opts) {
if (GestureDetector.READY) {
return;
}
// find what eventtypes we add listeners to
Event.determineEventTypes();
// Register all gestures inside GestureDetector.gestures
Utils.each(GestureDetector.gestures, function(gesture) {
Detection.register(gesture);
});
// Add touc... | javascript | function setup(opts) {
if (GestureDetector.READY) {
return;
}
// find what eventtypes we add listeners to
Event.determineEventTypes();
// Register all gestures inside GestureDetector.gestures
Utils.each(GestureDetector.gestures, function(gesture) {
Detection.register(gesture);
});
// Add touc... | [
"function",
"setup",
"(",
"opts",
")",
"{",
"if",
"(",
"GestureDetector",
".",
"READY",
")",
"{",
"return",
";",
"}",
"// find what eventtypes we add listeners to",
"Event",
".",
"determineEventTypes",
"(",
")",
";",
"// Register all gestures inside GestureDetector.gest... | setup events to detect gestures on the document
this function is called when creating an new instance
@private | [
"setup",
"events",
"to",
"detect",
"gestures",
"on",
"the",
"document",
"this",
"function",
"is",
"called",
"when",
"creating",
"an",
"new",
"instance"
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/gesture-detector.js#L182-L201 | train |
OnsenUI/OnsenUI | core/src/ons/gesture-detector.js | on | function on(element, type, handler, opt) {
util.addEventListener(element, type, handler, opt, true);
} | javascript | function on(element, type, handler, opt) {
util.addEventListener(element, type, handler, opt, true);
} | [
"function",
"on",
"(",
"element",
",",
"type",
",",
"handler",
",",
"opt",
")",
"{",
"util",
".",
"addEventListener",
"(",
"element",
",",
"type",
",",
"handler",
",",
"opt",
",",
"true",
")",
";",
"}"
] | simple addEventListener wrapper
@param {HTMLElement} element
@param {String} type
@param {Function} handler | [
"simple",
"addEventListener",
"wrapper"
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/gesture-detector.js#L233-L235 | train |
OnsenUI/OnsenUI | core/src/ons/gesture-detector.js | off | function off(element, type, handler, opt) {
util.removeEventListener(element, type, handler, opt, true);
} | javascript | function off(element, type, handler, opt) {
util.removeEventListener(element, type, handler, opt, true);
} | [
"function",
"off",
"(",
"element",
",",
"type",
",",
"handler",
",",
"opt",
")",
"{",
"util",
".",
"removeEventListener",
"(",
"element",
",",
"type",
",",
"handler",
",",
"opt",
",",
"true",
")",
";",
"}"
] | simple removeEventListener wrapper
@param {HTMLElement} element
@param {String} type
@param {Function} handler | [
"simple",
"removeEventListener",
"wrapper"
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/gesture-detector.js#L243-L245 | train |
OnsenUI/OnsenUI | core/src/ons/gesture-detector.js | inArray | function inArray(src, find, deep) {
if (deep) {
for (var i = 0, len = src.length; i < len; i++) { // Array.findIndex
if (Object.keys(find).every(function(key) { return src[i][key] === find[key]; })) {
return i;
}
}
return -1;
}
if (src.indexOf) {
return src... | javascript | function inArray(src, find, deep) {
if (deep) {
for (var i = 0, len = src.length; i < len; i++) { // Array.findIndex
if (Object.keys(find).every(function(key) { return src[i][key] === find[key]; })) {
return i;
}
}
return -1;
}
if (src.indexOf) {
return src... | [
"function",
"inArray",
"(",
"src",
",",
"find",
",",
"deep",
")",
"{",
"if",
"(",
"deep",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"src",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"// Array.findIndex",
... | find if a array contains the object using indexOf or a simple polyfill
@param {String} src
@param {String} find
@return {Boolean|Number} false when not found, or the index | [
"find",
"if",
"a",
"array",
"contains",
"the",
"object",
"using",
"indexOf",
"or",
"a",
"simple",
"polyfill"
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/gesture-detector.js#L296-L316 | train |
OnsenUI/OnsenUI | core/src/ons/gesture-detector.js | getDirection | function getDirection(touch1, touch2) {
var x = Math.abs(touch1.clientX - touch2.clientX),
y = Math.abs(touch1.clientY - touch2.clientY);
if (x >= y) {
return touch1.clientX - touch2.clientX > 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
}
return touch1.clientY - touch2.clientY > 0 ? DIRECTION_U... | javascript | function getDirection(touch1, touch2) {
var x = Math.abs(touch1.clientX - touch2.clientX),
y = Math.abs(touch1.clientY - touch2.clientY);
if (x >= y) {
return touch1.clientX - touch2.clientX > 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
}
return touch1.clientY - touch2.clientY > 0 ? DIRECTION_U... | [
"function",
"getDirection",
"(",
"touch1",
",",
"touch2",
")",
"{",
"var",
"x",
"=",
"Math",
".",
"abs",
"(",
"touch1",
".",
"clientX",
"-",
"touch2",
".",
"clientX",
")",
",",
"y",
"=",
"Math",
".",
"abs",
"(",
"touch1",
".",
"clientY",
"-",
"touc... | do a small comparison to get the direction between two touches.
@param {Touch} touch1
@param {Touch} touch2
@return {String} direction matches `DIRECTION_LEFT|RIGHT|UP|DOWN` | [
"do",
"a",
"small",
"comparison",
"to",
"get",
"the",
"direction",
"between",
"two",
"touches",
"."
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/gesture-detector.js#L414-L422 | train |
OnsenUI/OnsenUI | core/src/ons/gesture-detector.js | getScale | function getScale(start, end) {
// need two fingers...
if (start.length >= 2 && end.length >= 2) {
return this.getDistance(end[0], end[1]) / this.getDistance(start[0], start[1]);
}
return 1;
} | javascript | function getScale(start, end) {
// need two fingers...
if (start.length >= 2 && end.length >= 2) {
return this.getDistance(end[0], end[1]) / this.getDistance(start[0], start[1]);
}
return 1;
} | [
"function",
"getScale",
"(",
"start",
",",
"end",
")",
"{",
"// need two fingers...",
"if",
"(",
"start",
".",
"length",
">=",
"2",
"&&",
"end",
".",
"length",
">=",
"2",
")",
"{",
"return",
"this",
".",
"getDistance",
"(",
"end",
"[",
"0",
"]",
",",... | calculate the scale factor between two touchLists
no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
@param {Array} start array of touches
@param {Array} end array of touches
@return {Number} scale | [
"calculate",
"the",
"scale",
"factor",
"between",
"two",
"touchLists",
"no",
"scale",
"is",
"1",
"and",
"goes",
"down",
"to",
"0",
"when",
"pinched",
"together",
"and",
"bigger",
"when",
"pinched",
"out"
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/gesture-detector.js#L444-L450 | train |
OnsenUI/OnsenUI | core/src/ons/gesture-detector.js | getRotation | function getRotation(start, end) {
// need two fingers
if (start.length >= 2 && end.length >= 2) {
return this.getAngle(end[1], end[0]) - this.getAngle(start[1], start[0]);
}
return 0;
} | javascript | function getRotation(start, end) {
// need two fingers
if (start.length >= 2 && end.length >= 2) {
return this.getAngle(end[1], end[0]) - this.getAngle(start[1], start[0]);
}
return 0;
} | [
"function",
"getRotation",
"(",
"start",
",",
"end",
")",
"{",
"// need two fingers",
"if",
"(",
"start",
".",
"length",
">=",
"2",
"&&",
"end",
".",
"length",
">=",
"2",
")",
"{",
"return",
"this",
".",
"getAngle",
"(",
"end",
"[",
"1",
"]",
",",
... | calculate the rotation degrees between two touchLists
@param {Array} start array of touches
@param {Array} end array of touches
@return {Number} rotation | [
"calculate",
"the",
"rotation",
"degrees",
"between",
"two",
"touchLists"
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/gesture-detector.js#L458-L464 | train |
OnsenUI/OnsenUI | core/src/ons/gesture-detector.js | setPrefixedCss | function setPrefixedCss(element, prop, value, toggle) {
var prefixes = ['', 'Webkit', 'Moz', 'O', 'ms'];
prop = Utils.toCamelCase(prop);
for (var i = 0; i < prefixes.length; i++) {
var p = prop;
// prefixes
if (prefixes[i]) {
p = prefixes[i] + p.slice(0, 1).toUpperCase() + p.slice... | javascript | function setPrefixedCss(element, prop, value, toggle) {
var prefixes = ['', 'Webkit', 'Moz', 'O', 'ms'];
prop = Utils.toCamelCase(prop);
for (var i = 0; i < prefixes.length; i++) {
var p = prop;
// prefixes
if (prefixes[i]) {
p = prefixes[i] + p.slice(0, 1).toUpperCase() + p.slice... | [
"function",
"setPrefixedCss",
"(",
"element",
",",
"prop",
",",
"value",
",",
"toggle",
")",
"{",
"var",
"prefixes",
"=",
"[",
"''",
",",
"'Webkit'",
",",
"'Moz'",
",",
"'O'",
",",
"'ms'",
"]",
";",
"prop",
"=",
"Utils",
".",
"toCamelCase",
"(",
"pro... | set css properties with their prefixes
@param {HTMLElement} element
@param {String} prop
@param {String} value
@param {Boolean} [toggle=true]
@return {Boolean} | [
"set",
"css",
"properties",
"with",
"their",
"prefixes"
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/gesture-detector.js#L483-L500 | train |
OnsenUI/OnsenUI | core/src/ons/gesture-detector.js | toggleBehavior | function toggleBehavior(element, props, toggle) {
if (!props || !element || !element.style) {
return;
}
// set the css properties
Utils.each(props, function(value, prop) {
Utils.setPrefixedCss(element, prop, value, toggle);
});
var falseFn = toggle && function() {
return fals... | javascript | function toggleBehavior(element, props, toggle) {
if (!props || !element || !element.style) {
return;
}
// set the css properties
Utils.each(props, function(value, prop) {
Utils.setPrefixedCss(element, prop, value, toggle);
});
var falseFn = toggle && function() {
return fals... | [
"function",
"toggleBehavior",
"(",
"element",
",",
"props",
",",
"toggle",
")",
"{",
"if",
"(",
"!",
"props",
"||",
"!",
"element",
"||",
"!",
"element",
".",
"style",
")",
"{",
"return",
";",
"}",
"// set the css properties",
"Utils",
".",
"each",
"(",
... | toggle browser default behavior by setting css properties.
`userSelect='none'` also sets `element.onselectstart` to false
`userDrag='none'` also sets `element.ondragstart` to false
@param {HtmlElement} element
@param {Object} props
@param {Boolean} [toggle=true] | [
"toggle",
"browser",
"default",
"behavior",
"by",
"setting",
"css",
"properties",
".",
"userSelect",
"=",
"none",
"also",
"sets",
"element",
".",
"onselectstart",
"to",
"false",
"userDrag",
"=",
"none",
"also",
"sets",
"element",
".",
"ondragstart",
"to",
"fal... | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/gesture-detector.js#L511-L533 | train |
OnsenUI/OnsenUI | core/src/ons/gesture-detector.js | on | function on(element, type, handler, opt, hook) {
var types = type.split(' ');
Utils.each(types, function(type) {
Utils.on(element, type, handler, opt);
hook && hook(type);
});
} | javascript | function on(element, type, handler, opt, hook) {
var types = type.split(' ');
Utils.each(types, function(type) {
Utils.on(element, type, handler, opt);
hook && hook(type);
});
} | [
"function",
"on",
"(",
"element",
",",
"type",
",",
"handler",
",",
"opt",
",",
"hook",
")",
"{",
"var",
"types",
"=",
"type",
".",
"split",
"(",
"' '",
")",
";",
"Utils",
".",
"each",
"(",
"types",
",",
"function",
"(",
"type",
")",
"{",
"Utils"... | simple event binder with a hook and support for multiple types
@param {HTMLElement} element
@param {String} type
@param {Function} handler
@param {Object} [opt]
@param {Function} [hook]
@param {Object} hook.type | [
"simple",
"event",
"binder",
"with",
"a",
"hook",
"and",
"support",
"for",
"multiple",
"types"
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/gesture-detector.js#L591-L597 | train |
OnsenUI/OnsenUI | core/src/ons/gesture-detector.js | doDetect | function doDetect(ev, eventType, element, handler) {
var touchList = this.getTouchList(ev, eventType);
var touchListLength = touchList.length;
var triggerType = eventType;
var triggerChange = touchList.trigger; // used by fakeMultitouch plugin
var changedLength = touchListLength;
// at each tou... | javascript | function doDetect(ev, eventType, element, handler) {
var touchList = this.getTouchList(ev, eventType);
var touchListLength = touchList.length;
var triggerType = eventType;
var triggerChange = touchList.trigger; // used by fakeMultitouch plugin
var changedLength = touchListLength;
// at each tou... | [
"function",
"doDetect",
"(",
"ev",
",",
"eventType",
",",
"element",
",",
"handler",
")",
"{",
"var",
"touchList",
"=",
"this",
".",
"getTouchList",
"(",
"ev",
",",
"eventType",
")",
";",
"var",
"touchListLength",
"=",
"touchList",
".",
"length",
";",
"v... | the core detection method
this finds out what GestureDetector-touch-events to trigger
@param {Object} ev
@param {String} eventType matches `EVENT_START|MOVE|END`
@param {HTMLElement} element
@param {Function} handler
@return {String} triggerType matches `EVENT_START|MOVE|END` | [
"the",
"core",
"detection",
"method",
"this",
"finds",
"out",
"what",
"GestureDetector",
"-",
"touch",
"-",
"events",
"to",
"trigger"
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/gesture-detector.js#L687-L745 | train |
OnsenUI/OnsenUI | core/src/ons/gesture-detector.js | getTouchList | function getTouchList(ev, eventType) {
// get the fake pointerEvent touchlist
if (GestureDetector.HAS_POINTEREVENTS) {
return PointerEvent.getTouchList();
}
// get the touchlist
if (ev.touches) {
if (eventType == EVENT_MOVE) {
return ev.touches;
}
var identifiers = ... | javascript | function getTouchList(ev, eventType) {
// get the fake pointerEvent touchlist
if (GestureDetector.HAS_POINTEREVENTS) {
return PointerEvent.getTouchList();
}
// get the touchlist
if (ev.touches) {
if (eventType == EVENT_MOVE) {
return ev.touches;
}
var identifiers = ... | [
"function",
"getTouchList",
"(",
"ev",
",",
"eventType",
")",
"{",
"// get the fake pointerEvent touchlist",
"if",
"(",
"GestureDetector",
".",
"HAS_POINTEREVENTS",
")",
"{",
"return",
"PointerEvent",
".",
"getTouchList",
"(",
")",
";",
"}",
"// get the touchlist",
... | create touchList depending on the event
@param {Object} ev
@param {String} eventType
@return {Array} touches | [
"create",
"touchList",
"depending",
"on",
"the",
"event"
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/gesture-detector.js#L795-L824 | train |
OnsenUI/OnsenUI | core/src/ons/gesture-detector.js | function() {
var srcEvent = this.srcEvent;
srcEvent.preventManipulation && srcEvent.preventManipulation();
srcEvent.preventDefault && srcEvent.preventDefault();
} | javascript | function() {
var srcEvent = this.srcEvent;
srcEvent.preventManipulation && srcEvent.preventManipulation();
srcEvent.preventDefault && srcEvent.preventDefault();
} | [
"function",
"(",
")",
"{",
"var",
"srcEvent",
"=",
"this",
".",
"srcEvent",
";",
"srcEvent",
".",
"preventManipulation",
"&&",
"srcEvent",
".",
"preventManipulation",
"(",
")",
";",
"srcEvent",
".",
"preventDefault",
"&&",
"srcEvent",
".",
"preventDefault",
"(... | prevent the browser default actions
mostly used to disable scrolling of the browser | [
"prevent",
"the",
"browser",
"default",
"actions",
"mostly",
"used",
"to",
"disable",
"scrolling",
"of",
"the",
"browser"
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/gesture-detector.js#L856-L860 | train | |
OnsenUI/OnsenUI | core/src/ons/gesture-detector.js | getTouchList | function getTouchList() {
var touchlist = [];
// we can use forEach since pointerEvents only is in IE10
Utils.each(this.pointers, function(pointer) {
touchlist.push(pointer);
});
return touchlist;
} | javascript | function getTouchList() {
var touchlist = [];
// we can use forEach since pointerEvents only is in IE10
Utils.each(this.pointers, function(pointer) {
touchlist.push(pointer);
});
return touchlist;
} | [
"function",
"getTouchList",
"(",
")",
"{",
"var",
"touchlist",
"=",
"[",
"]",
";",
"// we can use forEach since pointerEvents only is in IE10",
"Utils",
".",
"each",
"(",
"this",
".",
"pointers",
",",
"function",
"(",
"pointer",
")",
"{",
"touchlist",
".",
"push... | get the pointers as an array
@return {Array} touchlist | [
"get",
"the",
"pointers",
"as",
"an",
"array"
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/gesture-detector.js#L900-L907 | train |
OnsenUI/OnsenUI | core/src/ons/gesture-detector.js | startDetect | function startDetect(inst, eventData) {
// already busy with a GestureDetector.gesture detection on an element
if (this.current) {
return;
}
this.stopped = false;
// holds current session
this.current = {
inst: inst, // reference to GestureDetectorInstance we're working for
s... | javascript | function startDetect(inst, eventData) {
// already busy with a GestureDetector.gesture detection on an element
if (this.current) {
return;
}
this.stopped = false;
// holds current session
this.current = {
inst: inst, // reference to GestureDetectorInstance we're working for
s... | [
"function",
"startDetect",
"(",
"inst",
",",
"eventData",
")",
"{",
"// already busy with a GestureDetector.gesture detection on an element",
"if",
"(",
"this",
".",
"current",
")",
"{",
"return",
";",
"}",
"this",
".",
"stopped",
"=",
"false",
";",
"// holds curren... | start GestureDetector.gesture detection
@param {GestureDetector.Instance} inst
@param {Object} eventData | [
"start",
"GestureDetector",
".",
"gesture",
"detection"
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/gesture-detector.js#L976-L996 | train |
OnsenUI/OnsenUI | core/src/ons/gesture-detector.js | getCalculatedData | function getCalculatedData(ev, center, deltaTime, deltaX, deltaY) {
var cur = this.current,
recalc = false,
calcEv = cur.lastCalcEvent,
calcData = cur.lastCalcData;
if (calcEv && ev.timeStamp - calcEv.timeStamp > GestureDetector.CALCULATE_INTERVAL) {
center = calcEv.center;
... | javascript | function getCalculatedData(ev, center, deltaTime, deltaX, deltaY) {
var cur = this.current,
recalc = false,
calcEv = cur.lastCalcEvent,
calcData = cur.lastCalcData;
if (calcEv && ev.timeStamp - calcEv.timeStamp > GestureDetector.CALCULATE_INTERVAL) {
center = calcEv.center;
... | [
"function",
"getCalculatedData",
"(",
"ev",
",",
"center",
",",
"deltaTime",
",",
"deltaX",
",",
"deltaY",
")",
"{",
"var",
"cur",
"=",
"this",
".",
"current",
",",
"recalc",
"=",
"false",
",",
"calcEv",
"=",
"cur",
".",
"lastCalcEvent",
",",
"calcData",... | calculate velocity, angle and direction
@param {Object} ev
@param {Object} center
@param {Number} deltaTime
@param {Number} deltaX
@param {Number} deltaY | [
"calculate",
"velocity",
"angle",
"and",
"direction"
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/gesture-detector.js#L1058-L1089 | train |
OnsenUI/OnsenUI | core/src/ons/gesture-detector.js | extendEventData | function extendEventData(ev) {
var cur = this.current,
startEv = cur.startEvent,
lastEv = cur.lastEvent || startEv;
// update the start touchlist to calculate the scale/rotation
if (ev.eventType == EVENT_TOUCH || ev.eventType == EVENT_RELEASE) {
startEv.touches = [];
Utils.each(... | javascript | function extendEventData(ev) {
var cur = this.current,
startEv = cur.startEvent,
lastEv = cur.lastEvent || startEv;
// update the start touchlist to calculate the scale/rotation
if (ev.eventType == EVENT_TOUCH || ev.eventType == EVENT_RELEASE) {
startEv.touches = [];
Utils.each(... | [
"function",
"extendEventData",
"(",
"ev",
")",
"{",
"var",
"cur",
"=",
"this",
".",
"current",
",",
"startEv",
"=",
"cur",
".",
"startEvent",
",",
"lastEv",
"=",
"cur",
".",
"lastEvent",
"||",
"startEv",
";",
"// update the start touchlist to calculate the scale... | extend eventData for GestureDetector.gestures
@param {Object} ev
@return {Object} ev | [
"extend",
"eventData",
"for",
"GestureDetector",
".",
"gestures"
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/gesture-detector.js#L1096-L1133 | train |
OnsenUI/OnsenUI | core/src/ons/animit.js | function(from, to, delay) {
function step(params, duration, timing) {
if (params.duration !== undefined) {
duration = params.duration;
}
if (params.timing !== undefined) {
timing = params.timing;
}
return {
css: params.css || params,
duration: duration,... | javascript | function(from, to, delay) {
function step(params, duration, timing) {
if (params.duration !== undefined) {
duration = params.duration;
}
if (params.timing !== undefined) {
timing = params.timing;
}
return {
css: params.css || params,
duration: duration,... | [
"function",
"(",
"from",
",",
"to",
",",
"delay",
")",
"{",
"function",
"step",
"(",
"params",
",",
"duration",
",",
"timing",
")",
"{",
"if",
"(",
"params",
".",
"duration",
"!==",
"undefined",
")",
"{",
"duration",
"=",
"params",
".",
"duration",
"... | Most of the animations follow this default process.
@param {from} css or options object containing css
@param {to} css or options object containing css
@param {delay} delay to wait | [
"Most",
"of",
"the",
"animations",
"follow",
"this",
"default",
"process",
"."
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/animit.js#L275-L296 | train | |
OnsenUI/OnsenUI | core/src/ons/animit.js | function(transition, options) {
var queue = this.transitionQueue;
if (transition && options) {
options.css = transition;
transition = new Animit.Transition(options);
}
if (!(transition instanceof Function || transition instanceof Animit.Transition)) {
if (transition.css) {
tr... | javascript | function(transition, options) {
var queue = this.transitionQueue;
if (transition && options) {
options.css = transition;
transition = new Animit.Transition(options);
}
if (!(transition instanceof Function || transition instanceof Animit.Transition)) {
if (transition.css) {
tr... | [
"function",
"(",
"transition",
",",
"options",
")",
"{",
"var",
"queue",
"=",
"this",
".",
"transitionQueue",
";",
"if",
"(",
"transition",
"&&",
"options",
")",
"{",
"options",
".",
"css",
"=",
"transition",
";",
"transition",
"=",
"new",
"Animit",
".",... | Queue transition animations or other function.
e.g. animit(elt).queue({color: 'red'})
e.g. animit(elt).queue({color: 'red'}, {duration: 0.4})
e.g. animit(elt).queue({css: {color: 'red'}, duration: 0.2})
@param {Object|Animit.Transition|Function} transition
@param {Object} [options] | [
"Queue",
"transition",
"animations",
"or",
"other",
"function",
"."
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/animit.js#L308-L335 | train | |
OnsenUI/OnsenUI | bindings/angular1/services/onsen.js | function(attrs, modifiers) {
var attrModifiers = attrs && typeof attrs.modifier === 'string' ? attrs.modifier.trim().split(/ +/) : [];
modifiers = angular.isArray(modifiers) ? attrModifiers.concat(modifiers) : attrModifiers;
/**
* @return {String} template eg. 'ons-button--*', ... | javascript | function(attrs, modifiers) {
var attrModifiers = attrs && typeof attrs.modifier === 'string' ? attrs.modifier.trim().split(/ +/) : [];
modifiers = angular.isArray(modifiers) ? attrModifiers.concat(modifiers) : attrModifiers;
/**
* @return {String} template eg. 'ons-button--*', ... | [
"function",
"(",
"attrs",
",",
"modifiers",
")",
"{",
"var",
"attrModifiers",
"=",
"attrs",
"&&",
"typeof",
"attrs",
".",
"modifier",
"===",
"'string'",
"?",
"attrs",
".",
"modifier",
".",
"trim",
"(",
")",
".",
"split",
"(",
"/",
" +",
"/",
")",
":"... | Create modifier templater function. The modifier templater generate css classes bound modifier name.
@param {Object} attrs
@param {Array} [modifiers] an array of appendix modifier
@return {Function} | [
"Create",
"modifier",
"templater",
"function",
".",
"The",
"modifier",
"templater",
"generate",
"css",
"classes",
"bound",
"modifier",
"name",
"."
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/bindings/angular1/services/onsen.js#L264-L277 | train | |
OnsenUI/OnsenUI | bindings/angular1/services/onsen.js | function(view, element) {
var methods = {
hasModifier: function(needle) {
var tokens = ModifierUtil.split(element.attr('modifier'));
needle = typeof needle === 'string' ? needle.trim() : '';
return ModifierUtil.split(needle).some(function(needle) {
... | javascript | function(view, element) {
var methods = {
hasModifier: function(needle) {
var tokens = ModifierUtil.split(element.attr('modifier'));
needle = typeof needle === 'string' ? needle.trim() : '';
return ModifierUtil.split(needle).some(function(needle) {
... | [
"function",
"(",
"view",
",",
"element",
")",
"{",
"var",
"methods",
"=",
"{",
"hasModifier",
":",
"function",
"(",
"needle",
")",
"{",
"var",
"tokens",
"=",
"ModifierUtil",
".",
"split",
"(",
"element",
".",
"attr",
"(",
"'modifier'",
")",
")",
";",
... | Add modifier methods to view object for custom elements.
@param {Object} view object
@param {jqLite} element | [
"Add",
"modifier",
"methods",
"to",
"view",
"object",
"for",
"custom",
"elements",
"."
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/bindings/angular1/services/onsen.js#L285-L328 | train | |
OnsenUI/OnsenUI | bindings/angular1/services/onsen.js | function(view, template, element) {
var _tr = function(modifier) {
return template.replace('*', modifier);
};
var fns = {
hasModifier: function(modifier) {
return element.hasClass(_tr(modifier));
},
removeModifier: function(mo... | javascript | function(view, template, element) {
var _tr = function(modifier) {
return template.replace('*', modifier);
};
var fns = {
hasModifier: function(modifier) {
return element.hasClass(_tr(modifier));
},
removeModifier: function(mo... | [
"function",
"(",
"view",
",",
"template",
",",
"element",
")",
"{",
"var",
"_tr",
"=",
"function",
"(",
"modifier",
")",
"{",
"return",
"template",
".",
"replace",
"(",
"'*'",
",",
"modifier",
")",
";",
"}",
";",
"var",
"fns",
"=",
"{",
"hasModifier"... | Add modifier methods to view object.
@param {Object} view object
@param {String} template
@param {jqLite} element | [
"Add",
"modifier",
"methods",
"to",
"view",
"object",
"."
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/bindings/angular1/services/onsen.js#L337-L395 | train | |
OnsenUI/OnsenUI | bindings/angular1/services/onsen.js | function(view) {
view.hasModifier = view.removeModifier =
view.addModifier = view.setModifier =
view.toggleModifier = undefined;
} | javascript | function(view) {
view.hasModifier = view.removeModifier =
view.addModifier = view.setModifier =
view.toggleModifier = undefined;
} | [
"function",
"(",
"view",
")",
"{",
"view",
".",
"hasModifier",
"=",
"view",
".",
"removeModifier",
"=",
"view",
".",
"addModifier",
"=",
"view",
".",
"setModifier",
"=",
"view",
".",
"toggleModifier",
"=",
"undefined",
";",
"}"
] | Remove modifier methods.
@param {Object} view object | [
"Remove",
"modifier",
"methods",
"."
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/bindings/angular1/services/onsen.js#L402-L406 | train | |
OnsenUI/OnsenUI | bindings/angular1/services/onsen.js | function(component, eventNames) {
eventNames = eventNames.trim().split(/\s+/);
for (var i = 0, l = eventNames.length; i < l; i++) {
var eventName = eventNames[i];
this._registerEventHandler(component, eventName);
}
} | javascript | function(component, eventNames) {
eventNames = eventNames.trim().split(/\s+/);
for (var i = 0, l = eventNames.length; i < l; i++) {
var eventName = eventNames[i];
this._registerEventHandler(component, eventName);
}
} | [
"function",
"(",
"component",
",",
"eventNames",
")",
"{",
"eventNames",
"=",
"eventNames",
".",
"trim",
"(",
")",
".",
"split",
"(",
"/",
"\\s+",
"/",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"eventNames",
".",
"length",
";",
"... | Register event handlers for attributes.
@param {Object} component
@param {String} eventNames | [
"Register",
"event",
"handlers",
"for",
"attributes",
"."
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/bindings/angular1/services/onsen.js#L441-L448 | train | |
OnsenUI/OnsenUI | bindings/angular1/services/onsen.js | function(name, object) {
var names = name.split(/\./);
function set(container, names, object) {
var name;
for (var i = 0; i < names.length - 1; i++) {
name = names[i];
if (container[name] === undefined || container[name] === null) {
... | javascript | function(name, object) {
var names = name.split(/\./);
function set(container, names, object) {
var name;
for (var i = 0; i < names.length - 1; i++) {
name = names[i];
if (container[name] === undefined || container[name] === null) {
... | [
"function",
"(",
"name",
",",
"object",
")",
"{",
"var",
"names",
"=",
"name",
".",
"split",
"(",
"/",
"\\.",
"/",
")",
";",
"function",
"set",
"(",
"container",
",",
"names",
",",
"object",
")",
"{",
"var",
"name",
";",
"for",
"(",
"var",
"i",
... | Define a variable to JavaScript global scope and AngularJS scope.
Util.defineVar('foo', 'foo-value');
// => window.foo and $scope.foo is now 'foo-value'
Util.defineVar('foo.bar', 'foo-bar-value');
// => window.foo.bar and $scope.foo.bar is now 'foo-bar-value'
@param {String} name
@param object | [
"Define",
"a",
"variable",
"to",
"JavaScript",
"global",
"scope",
"and",
"AngularJS",
"scope",
"."
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/bindings/angular1/services/onsen.js#L521-L572 | train | |
OnsenUI/OnsenUI | core/src/ons/page-loader.js | loadPage | function loadPage({page, parent, params = {}}, done) {
internal.getPageHTMLAsync(page).then(html => {
const pageElement = util.createElement(html);
parent.appendChild(pageElement);
done(pageElement);
});
} | javascript | function loadPage({page, parent, params = {}}, done) {
internal.getPageHTMLAsync(page).then(html => {
const pageElement = util.createElement(html);
parent.appendChild(pageElement);
done(pageElement);
});
} | [
"function",
"loadPage",
"(",
"{",
"page",
",",
"parent",
",",
"params",
"=",
"{",
"}",
"}",
",",
"done",
")",
"{",
"internal",
".",
"getPageHTMLAsync",
"(",
"page",
")",
".",
"then",
"(",
"html",
"=>",
"{",
"const",
"pageElement",
"=",
"util",
".",
... | Default implementation for global PageLoader. | [
"Default",
"implementation",
"for",
"global",
"PageLoader",
"."
] | dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5 | https://github.com/OnsenUI/OnsenUI/blob/dafaaa13bc2cf0e16e1f1995788a0d77419d5cf5/core/src/ons/page-loader.js#L21-L28 | train |
stylus/stylus | lib/functions/rgba.js | rgba | function rgba(red, green, blue, alpha){
switch (arguments.length) {
case 1:
utils.assertColor(red);
return red.rgba;
case 2:
utils.assertColor(red);
var color = red.rgba;
utils.assertType(green, 'unit', 'alpha');
alpha = green.clone();
if ('%' == alpha.type) alpha.val... | javascript | function rgba(red, green, blue, alpha){
switch (arguments.length) {
case 1:
utils.assertColor(red);
return red.rgba;
case 2:
utils.assertColor(red);
var color = red.rgba;
utils.assertType(green, 'unit', 'alpha');
alpha = green.clone();
if ('%' == alpha.type) alpha.val... | [
"function",
"rgba",
"(",
"red",
",",
"green",
",",
"blue",
",",
"alpha",
")",
"{",
"switch",
"(",
"arguments",
".",
"length",
")",
"{",
"case",
"1",
":",
"utils",
".",
"assertColor",
"(",
"red",
")",
";",
"return",
"red",
".",
"rgba",
";",
"case",
... | Return a `RGBA` from the r,g,b,a channels.
Examples:
rgba(255,0,0,0.5)
// => rgba(255,0,0,0.5)
rgba(255,0,0,1)
// => #ff0000
rgba(#ffcc00, 50%)
// rgba(255,204,0,0.5)
@param {Unit|RGBA|HSLA} red
@param {Unit} green
@param {Unit} blue
@param {Unit} alpha
@return {RGBA}
@api public | [
"Return",
"a",
"RGBA",
"from",
"the",
"r",
"g",
"b",
"a",
"channels",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/rgba.js#L26-L59 | train |
stylus/stylus | lib/functions/basename.js | basename | function basename(p, ext){
utils.assertString(p, 'path');
return path.basename(p.val, ext && ext.val);
} | javascript | function basename(p, ext){
utils.assertString(p, 'path');
return path.basename(p.val, ext && ext.val);
} | [
"function",
"basename",
"(",
"p",
",",
"ext",
")",
"{",
"utils",
".",
"assertString",
"(",
"p",
",",
"'path'",
")",
";",
"return",
"path",
".",
"basename",
"(",
"p",
".",
"val",
",",
"ext",
"&&",
"ext",
".",
"val",
")",
";",
"}"
] | Return the basename of `path`.
@param {String} path
@return {String}
@api public | [
"Return",
"the",
"basename",
"of",
"path",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/basename.js#L12-L15 | train |
stylus/stylus | lib/functions/operate.js | operate | function operate(op, left, right){
utils.assertType(op, 'string', 'op');
utils.assertPresent(left, 'left');
utils.assertPresent(right, 'right');
return left.operate(op.val, right);
} | javascript | function operate(op, left, right){
utils.assertType(op, 'string', 'op');
utils.assertPresent(left, 'left');
utils.assertPresent(right, 'right');
return left.operate(op.val, right);
} | [
"function",
"operate",
"(",
"op",
",",
"left",
",",
"right",
")",
"{",
"utils",
".",
"assertType",
"(",
"op",
",",
"'string'",
",",
"'op'",
")",
";",
"utils",
".",
"assertPresent",
"(",
"left",
",",
"'left'",
")",
";",
"utils",
".",
"assertPresent",
... | Perform `op` on the `left` and `right` operands.
@param {String} op
@param {Node} left
@param {Node} right
@return {Node}
@api public | [
"Perform",
"op",
"on",
"the",
"left",
"and",
"right",
"operands",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/operate.js#L13-L18 | train |
stylus/stylus | lib/functions/math.js | math | function math(n, fn){
utils.assertType(n, 'unit', 'n');
utils.assertString(fn, 'fn');
return new nodes.Unit(Math[fn.string](n.val), n.type);
} | javascript | function math(n, fn){
utils.assertType(n, 'unit', 'n');
utils.assertString(fn, 'fn');
return new nodes.Unit(Math[fn.string](n.val), n.type);
} | [
"function",
"math",
"(",
"n",
",",
"fn",
")",
"{",
"utils",
".",
"assertType",
"(",
"n",
",",
"'unit'",
",",
"'n'",
")",
";",
"utils",
".",
"assertString",
"(",
"fn",
",",
"'fn'",
")",
";",
"return",
"new",
"nodes",
".",
"Unit",
"(",
"Math",
"[",... | Apply Math `fn` to `n`.
@param {Unit} n
@param {String} fn
@return {Unit}
@api private | [
"Apply",
"Math",
"fn",
"to",
"n",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/math.js#L13-L17 | train |
stylus/stylus | lib/lexer.js | Lexer | function Lexer(str, options) {
options = options || {};
this.stash = [];
this.indentStack = [];
this.indentRe = null;
this.lineno = 1;
this.column = 1;
// HACK!
function comment(str, val, offset, s) {
var inComment = s.lastIndexOf('/*', offset) > s.lastIndexOf('*/', offset)
, commentIdx = s.l... | javascript | function Lexer(str, options) {
options = options || {};
this.stash = [];
this.indentStack = [];
this.indentRe = null;
this.lineno = 1;
this.column = 1;
// HACK!
function comment(str, val, offset, s) {
var inComment = s.lastIndexOf('/*', offset) > s.lastIndexOf('*/', offset)
, commentIdx = s.l... | [
"function",
"Lexer",
"(",
"str",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"stash",
"=",
"[",
"]",
";",
"this",
".",
"indentStack",
"=",
"[",
"]",
";",
"this",
".",
"indentRe",
"=",
"null",
";",
"this"... | Initialize a new `Lexer` with the given `str` and `options`.
@param {String} str
@param {Object} options
@api private | [
"Initialize",
"a",
"new",
"Lexer",
"with",
"the",
"given",
"str",
"and",
"options",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/lexer.js#L43-L86 | train |
stylus/stylus | lib/lexer.js | function(){
var tok
, tmp = this.str
, buf = [];
while ('eos' != (tok = this.next()).type) {
buf.push(tok.inspect());
}
this.str = tmp;
return buf.concat(tok.inspect()).join('\n');
} | javascript | function(){
var tok
, tmp = this.str
, buf = [];
while ('eos' != (tok = this.next()).type) {
buf.push(tok.inspect());
}
this.str = tmp;
return buf.concat(tok.inspect()).join('\n');
} | [
"function",
"(",
")",
"{",
"var",
"tok",
",",
"tmp",
"=",
"this",
".",
"str",
",",
"buf",
"=",
"[",
"]",
";",
"while",
"(",
"'eos'",
"!=",
"(",
"tok",
"=",
"this",
".",
"next",
"(",
")",
")",
".",
"type",
")",
"{",
"buf",
".",
"push",
"(",
... | Custom inspect. | [
"Custom",
"inspect",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/lexer.js#L98-L107 | train | |
stylus/stylus | lib/lexer.js | function(n){
var fetch = n - this.stash.length;
while (fetch-- > 0) this.stash.push(this.advance());
return this.stash[--n];
} | javascript | function(n){
var fetch = n - this.stash.length;
while (fetch-- > 0) this.stash.push(this.advance());
return this.stash[--n];
} | [
"function",
"(",
"n",
")",
"{",
"var",
"fetch",
"=",
"n",
"-",
"this",
".",
"stash",
".",
"length",
";",
"while",
"(",
"fetch",
"--",
">",
"0",
")",
"this",
".",
"stash",
".",
"push",
"(",
"this",
".",
"advance",
"(",
")",
")",
";",
"return",
... | Lookahead `n` tokens.
@param {Number} n
@return {Object}
@api private | [
"Lookahead",
"n",
"tokens",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/lexer.js#L117-L121 | train | |
stylus/stylus | lib/lexer.js | function(len){
var chunk = len[0];
len = chunk ? chunk.length : len;
this.str = this.str.substr(len);
if (chunk) {
this.move(chunk);
} else {
this.column += len;
}
} | javascript | function(len){
var chunk = len[0];
len = chunk ? chunk.length : len;
this.str = this.str.substr(len);
if (chunk) {
this.move(chunk);
} else {
this.column += len;
}
} | [
"function",
"(",
"len",
")",
"{",
"var",
"chunk",
"=",
"len",
"[",
"0",
"]",
";",
"len",
"=",
"chunk",
"?",
"chunk",
".",
"length",
":",
"len",
";",
"this",
".",
"str",
"=",
"this",
".",
"str",
".",
"substr",
"(",
"len",
")",
";",
"if",
"(",
... | Consume the given `len`.
@param {Number|Array} len
@api private | [
"Consume",
"the",
"given",
"len",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/lexer.js#L130-L139 | train | |
stylus/stylus | lib/lexer.js | function(str){
var lines = str.match(/\n/g)
, idx = str.lastIndexOf('\n');
if (lines) this.lineno += lines.length;
this.column = ~idx
? str.length - idx
: this.column + str.length;
} | javascript | function(str){
var lines = str.match(/\n/g)
, idx = str.lastIndexOf('\n');
if (lines) this.lineno += lines.length;
this.column = ~idx
? str.length - idx
: this.column + str.length;
} | [
"function",
"(",
"str",
")",
"{",
"var",
"lines",
"=",
"str",
".",
"match",
"(",
"/",
"\\n",
"/",
"g",
")",
",",
"idx",
"=",
"str",
".",
"lastIndexOf",
"(",
"'\\n'",
")",
";",
"if",
"(",
"lines",
")",
"this",
".",
"lineno",
"+=",
"lines",
".",
... | Move current line and column position.
@param {String} str
@api private | [
"Move",
"current",
"line",
"and",
"column",
"position",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/lexer.js#L148-L156 | train | |
stylus/stylus | lib/lexer.js | function() {
var tok = this.stash[this.stash.length - 1] || this.prev;
switch (tok && tok.type) {
// #for
case 'color':
return 2 == tok.val.raw.length;
// .or
case '.':
// [is]
case '[':
return true;
}
return false;
} | javascript | function() {
var tok = this.stash[this.stash.length - 1] || this.prev;
switch (tok && tok.type) {
// #for
case 'color':
return 2 == tok.val.raw.length;
// .or
case '.':
// [is]
case '[':
return true;
}
return false;
} | [
"function",
"(",
")",
"{",
"var",
"tok",
"=",
"this",
".",
"stash",
"[",
"this",
".",
"stash",
".",
"length",
"-",
"1",
"]",
"||",
"this",
".",
"prev",
";",
"switch",
"(",
"tok",
"&&",
"tok",
".",
"type",
")",
"{",
"// #for",
"case",
"'color'",
... | Check if the current token is a part of selector.
@return {Boolean}
@api private | [
"Check",
"if",
"the",
"current",
"token",
"is",
"a",
"part",
"of",
"selector",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/lexer.js#L178-L191 | train | |
stylus/stylus | lib/lexer.js | function() {
var column = this.column
, line = this.lineno
, tok = this.eos()
|| this.null()
|| this.sep()
|| this.keyword()
|| this.urlchars()
|| this.comment()
|| this.newline()
|| this.escaped()
|| this.important()
|| this.literal()
|| this.... | javascript | function() {
var column = this.column
, line = this.lineno
, tok = this.eos()
|| this.null()
|| this.sep()
|| this.keyword()
|| this.urlchars()
|| this.comment()
|| this.newline()
|| this.escaped()
|| this.important()
|| this.literal()
|| this.... | [
"function",
"(",
")",
"{",
"var",
"column",
"=",
"this",
".",
"column",
",",
"line",
"=",
"this",
".",
"lineno",
",",
"tok",
"=",
"this",
".",
"eos",
"(",
")",
"||",
"this",
".",
"null",
"(",
")",
"||",
"this",
".",
"sep",
"(",
")",
"||",
"th... | Fetch next token.
@return {Token}
@api private | [
"Fetch",
"next",
"token",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/lexer.js#L200-L243 | train | |
stylus/stylus | lib/lexer.js | function() {
var captures
, tok;
if (captures = /^(not|and|or|is a|is defined|isnt|is not|is)(?!-)\b([ \t]*)/.exec(this.str)) {
var op = captures[1];
this.skip(captures);
if (this.isPartOfSelector()) {
tok = new Token('ident', new nodes.Ident(captures[0]));
} else {
... | javascript | function() {
var captures
, tok;
if (captures = /^(not|and|or|is a|is defined|isnt|is not|is)(?!-)\b([ \t]*)/.exec(this.str)) {
var op = captures[1];
this.skip(captures);
if (this.isPartOfSelector()) {
tok = new Token('ident', new nodes.Ident(captures[0]));
} else {
... | [
"function",
"(",
")",
"{",
"var",
"captures",
",",
"tok",
";",
"if",
"(",
"captures",
"=",
"/",
"^(not|and|or|is a|is defined|isnt|is not|is)(?!-)\\b([ \\t]*)",
"/",
".",
"exec",
"(",
"this",
".",
"str",
")",
")",
"{",
"var",
"op",
"=",
"captures",
"[",
"1... | 'not'
| 'and'
| 'or'
| 'is'
| 'is not'
| 'isnt'
| 'is a'
| 'is defined' | [
"not",
"|",
"and",
"|",
"or",
"|",
"is",
"|",
"is",
"not",
"|",
"isnt",
"|",
"is",
"a",
"|",
"is",
"defined"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/lexer.js#L474-L489 | train | |
stylus/stylus | lib/lexer.js | function() {
var captures;
if (captures = /^(true|false)\b([ \t]*)/.exec(this.str)) {
var val = nodes.Boolean('true' == captures[1]);
this.skip(captures);
var tok = new Token('boolean', val);
tok.space = captures[2];
return tok;
}
} | javascript | function() {
var captures;
if (captures = /^(true|false)\b([ \t]*)/.exec(this.str)) {
var val = nodes.Boolean('true' == captures[1]);
this.skip(captures);
var tok = new Token('boolean', val);
tok.space = captures[2];
return tok;
}
} | [
"function",
"(",
")",
"{",
"var",
"captures",
";",
"if",
"(",
"captures",
"=",
"/",
"^(true|false)\\b([ \\t]*)",
"/",
".",
"exec",
"(",
"this",
".",
"str",
")",
")",
"{",
"var",
"val",
"=",
"nodes",
".",
"Boolean",
"(",
"'true'",
"==",
"captures",
"[... | 'true' | 'false' | [
"true",
"|",
"false"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/lexer.js#L627-L636 | train | |
stylus/stylus | lib/lexer.js | function() {
var captures, re;
// we have established the indentation regexp
if (this.indentRe){
captures = this.indentRe.exec(this.str);
// figure out if we are using tabs or spaces
} else {
// try tabs
re = /^\n([\t]*)[ \t]*/;
captures = re.exec(this.str);
// nope, ... | javascript | function() {
var captures, re;
// we have established the indentation regexp
if (this.indentRe){
captures = this.indentRe.exec(this.str);
// figure out if we are using tabs or spaces
} else {
// try tabs
re = /^\n([\t]*)[ \t]*/;
captures = re.exec(this.str);
// nope, ... | [
"function",
"(",
")",
"{",
"var",
"captures",
",",
"re",
";",
"// we have established the indentation regexp",
"if",
"(",
"this",
".",
"indentRe",
")",
"{",
"captures",
"=",
"this",
".",
"indentRe",
".",
"exec",
"(",
"this",
".",
"str",
")",
";",
"// figur... | '\n' ' '+ | [
"\\",
"n",
"+"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/lexer.js#L682-L735 | train | |
stylus/stylus | lib/functions/lightness.js | lightness | function lightness(color, value){
if (value) {
var hslaColor = color.hsla;
return hsla(
new nodes.Unit(hslaColor.h),
new nodes.Unit(hslaColor.s),
value,
new nodes.Unit(hslaColor.a)
)
}
return component(color, new nodes.String('lightness'));
} | javascript | function lightness(color, value){
if (value) {
var hslaColor = color.hsla;
return hsla(
new nodes.Unit(hslaColor.h),
new nodes.Unit(hslaColor.s),
value,
new nodes.Unit(hslaColor.a)
)
}
return component(color, new nodes.String('lightness'));
} | [
"function",
"lightness",
"(",
"color",
",",
"value",
")",
"{",
"if",
"(",
"value",
")",
"{",
"var",
"hslaColor",
"=",
"color",
".",
"hsla",
";",
"return",
"hsla",
"(",
"new",
"nodes",
".",
"Unit",
"(",
"hslaColor",
".",
"h",
")",
",",
"new",
"nodes... | Return the lightness component of the given `color`,
or set the lightness component to the optional second `value` argument.
Examples:
lightness(#00c)
// => 100%
lightness(#00c, 80%)
// => #99f
@param {RGBA|HSLA} color
@param {Unit} [value]
@return {Unit|RGBA}
@api public | [
"Return",
"the",
"lightness",
"component",
"of",
"the",
"given",
"color",
"or",
"set",
"the",
"lightness",
"component",
"to",
"the",
"optional",
"second",
"value",
"argument",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/lightness.js#L23-L34 | train |
stylus/stylus | lib/errors.js | ParseError | function ParseError(msg) {
this.name = 'ParseError';
this.message = msg;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, ParseError);
}
} | javascript | function ParseError(msg) {
this.name = 'ParseError';
this.message = msg;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, ParseError);
}
} | [
"function",
"ParseError",
"(",
"msg",
")",
"{",
"this",
".",
"name",
"=",
"'ParseError'",
";",
"this",
".",
"message",
"=",
"msg",
";",
"if",
"(",
"Error",
".",
"captureStackTrace",
")",
"{",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"ParseErr... | Initialize a new `ParseError` with the given `msg`.
@param {String} msg
@api private | [
"Initialize",
"a",
"new",
"ParseError",
"with",
"the",
"given",
"msg",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/errors.js#L22-L28 | train |
stylus/stylus | lib/functions/blend.js | blend | function blend(top, bottom){
// TODO: different blend modes like overlay etc.
utils.assertColor(top);
top = top.rgba;
bottom = bottom || new nodes.RGBA(255, 255, 255, 1);
utils.assertColor(bottom);
bottom = bottom.rgba;
return new nodes.RGBA(
top.r * top.a + bottom.r * (1 - top.a),
top.g * top.a ... | javascript | function blend(top, bottom){
// TODO: different blend modes like overlay etc.
utils.assertColor(top);
top = top.rgba;
bottom = bottom || new nodes.RGBA(255, 255, 255, 1);
utils.assertColor(bottom);
bottom = bottom.rgba;
return new nodes.RGBA(
top.r * top.a + bottom.r * (1 - top.a),
top.g * top.a ... | [
"function",
"blend",
"(",
"top",
",",
"bottom",
")",
"{",
"// TODO: different blend modes like overlay etc.",
"utils",
".",
"assertColor",
"(",
"top",
")",
";",
"top",
"=",
"top",
".",
"rgba",
";",
"bottom",
"=",
"bottom",
"||",
"new",
"nodes",
".",
"RGBA",
... | Blend the `top` color over the `bottom`
Examples:
blend(rgba(#FFF, 0.5), #000)
// => #808080
blend(rgba(#FFDE00,.42), #19C261)
// => #7ace38
blend(rgba(lime, 0.5), rgba(red, 0.25))
// => rgba(128,128,0,0.625)
@param {RGBA|HSLA} top
@param {RGBA|HSLA} [bottom=#fff]
@return {RGBA}
@api public | [
"Blend",
"the",
"top",
"color",
"over",
"the",
"bottom"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/blend.js#L24-L37 | train |
stylus/stylus | lib/functions/hue.js | hue | function hue(color, value){
if (value) {
var hslaColor = color.hsla;
return hsla(
value,
new nodes.Unit(hslaColor.s),
new nodes.Unit(hslaColor.l),
new nodes.Unit(hslaColor.a)
)
}
return component(color, new nodes.String('hue'));
} | javascript | function hue(color, value){
if (value) {
var hslaColor = color.hsla;
return hsla(
value,
new nodes.Unit(hslaColor.s),
new nodes.Unit(hslaColor.l),
new nodes.Unit(hslaColor.a)
)
}
return component(color, new nodes.String('hue'));
} | [
"function",
"hue",
"(",
"color",
",",
"value",
")",
"{",
"if",
"(",
"value",
")",
"{",
"var",
"hslaColor",
"=",
"color",
".",
"hsla",
";",
"return",
"hsla",
"(",
"value",
",",
"new",
"nodes",
".",
"Unit",
"(",
"hslaColor",
".",
"s",
")",
",",
"ne... | Return the hue component of the given `color`,
or set the hue component to the optional second `value` argument.
Examples:
hue(#00c)
// => 240deg
hue(#00c, 90deg)
// => #6c0
@param {RGBA|HSLA} color
@param {Unit} [value]
@return {Unit|RGBA}
@api public | [
"Return",
"the",
"hue",
"component",
"of",
"the",
"given",
"color",
"or",
"set",
"the",
"hue",
"component",
"to",
"the",
"optional",
"second",
"value",
"argument",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/hue.js#L23-L34 | train |
stylus/stylus | lib/functions/split.js | split | function split(delim, val){
utils.assertString(delim, 'delimiter');
utils.assertString(val, 'val');
var splitted = val.string.split(delim.string);
var expr = new nodes.Expression();
var ItemNode = val instanceof nodes.Ident
? nodes.Ident
: nodes.String;
for (var i = 0, len = splitted.length; i < len... | javascript | function split(delim, val){
utils.assertString(delim, 'delimiter');
utils.assertString(val, 'val');
var splitted = val.string.split(delim.string);
var expr = new nodes.Expression();
var ItemNode = val instanceof nodes.Ident
? nodes.Ident
: nodes.String;
for (var i = 0, len = splitted.length; i < len... | [
"function",
"split",
"(",
"delim",
",",
"val",
")",
"{",
"utils",
".",
"assertString",
"(",
"delim",
",",
"'delimiter'",
")",
";",
"utils",
".",
"assertString",
"(",
"val",
",",
"'val'",
")",
";",
"var",
"splitted",
"=",
"val",
".",
"string",
".",
"s... | Splits the given `val` by `delim`
@param {String} delim
@param {String|Ident} val
@return {Expression}
@api public | [
"Splits",
"the",
"given",
"val",
"by",
"delim"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/split.js#L13-L25 | train |
stylus/stylus | lib/functions/replace.js | replace | function replace(pattern, replacement, val){
utils.assertString(pattern, 'pattern');
utils.assertString(replacement, 'replacement');
utils.assertString(val, 'val');
pattern = new RegExp(pattern.string, 'g');
var res = val.string.replace(pattern, replacement.string);
return val instanceof nodes.Ident
? n... | javascript | function replace(pattern, replacement, val){
utils.assertString(pattern, 'pattern');
utils.assertString(replacement, 'replacement');
utils.assertString(val, 'val');
pattern = new RegExp(pattern.string, 'g');
var res = val.string.replace(pattern, replacement.string);
return val instanceof nodes.Ident
? n... | [
"function",
"replace",
"(",
"pattern",
",",
"replacement",
",",
"val",
")",
"{",
"utils",
".",
"assertString",
"(",
"pattern",
",",
"'pattern'",
")",
";",
"utils",
".",
"assertString",
"(",
"replacement",
",",
"'replacement'",
")",
";",
"utils",
".",
"asse... | Returns string with all matches of `pattern` replaced by `replacement` in given `val`
@param {String} pattern
@param {String} replacement
@param {String|Ident} val
@return {String|Ident}
@api public | [
"Returns",
"string",
"with",
"all",
"matches",
"of",
"pattern",
"replaced",
"by",
"replacement",
"in",
"given",
"val"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/replace.js#L14-L23 | train |
stylus/stylus | lib/middleware.js | compile | function compile() {
debug('read %s', cssPath);
fs.readFile(stylusPath, 'utf8', function(err, str){
if (err) return error(err);
var style = options.compile(str, stylusPath);
var paths = style.options._imports = [];
imports[stylusPath] = null;
style.rende... | javascript | function compile() {
debug('read %s', cssPath);
fs.readFile(stylusPath, 'utf8', function(err, str){
if (err) return error(err);
var style = options.compile(str, stylusPath);
var paths = style.options._imports = [];
imports[stylusPath] = null;
style.rende... | [
"function",
"compile",
"(",
")",
"{",
"debug",
"(",
"'read %s'",
",",
"cssPath",
")",
";",
"fs",
".",
"readFile",
"(",
"stylusPath",
",",
"'utf8'",
",",
"function",
"(",
"err",
",",
"str",
")",
"{",
"if",
"(",
"err",
")",
"return",
"error",
"(",
"e... | Compile to cssPath | [
"Compile",
"to",
"cssPath"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/middleware.js#L149-L166 | train |
stylus/stylus | lib/middleware.js | compare | function compare(pathA, pathB) {
pathA = pathA.split(sep);
pathB = pathB.split('/');
if (!pathA[pathA.length - 1]) pathA.pop();
if (!pathB[0]) pathB.shift();
var overlap = [];
while (pathA[pathA.length - 1] == pathB[0]) {
overlap.push(pathA.pop());
pathB.shift();
}
return overlap.join('/');
} | javascript | function compare(pathA, pathB) {
pathA = pathA.split(sep);
pathB = pathB.split('/');
if (!pathA[pathA.length - 1]) pathA.pop();
if (!pathB[0]) pathB.shift();
var overlap = [];
while (pathA[pathA.length - 1] == pathB[0]) {
overlap.push(pathA.pop());
pathB.shift();
}
return overlap.join('/');
} | [
"function",
"compare",
"(",
"pathA",
",",
"pathB",
")",
"{",
"pathA",
"=",
"pathA",
".",
"split",
"(",
"sep",
")",
";",
"pathB",
"=",
"pathB",
".",
"split",
"(",
"'/'",
")",
";",
"if",
"(",
"!",
"pathA",
"[",
"pathA",
".",
"length",
"-",
"1",
"... | get the overlaping path from the end of path A, and the begining of path B.
@param {String} pathA
@param {String} pathB
@return {String}
@api private | [
"get",
"the",
"overlaping",
"path",
"from",
"the",
"end",
"of",
"path",
"A",
"and",
"the",
"begining",
"of",
"path",
"B",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/middleware.js#L245-L257 | train |
stylus/stylus | lib/functions/prefix-classes.js | prefixClasses | function prefixClasses(prefix, block){
utils.assertString(prefix, 'prefix');
utils.assertType(block, 'block', 'block');
var _prefix = this.prefix;
this.options.prefix = this.prefix = prefix.string;
block = this.visit(block);
this.options.prefix = this.prefix = _prefix;
return block;
} | javascript | function prefixClasses(prefix, block){
utils.assertString(prefix, 'prefix');
utils.assertType(block, 'block', 'block');
var _prefix = this.prefix;
this.options.prefix = this.prefix = prefix.string;
block = this.visit(block);
this.options.prefix = this.prefix = _prefix;
return block;
} | [
"function",
"prefixClasses",
"(",
"prefix",
",",
"block",
")",
"{",
"utils",
".",
"assertString",
"(",
"prefix",
",",
"'prefix'",
")",
";",
"utils",
".",
"assertType",
"(",
"block",
",",
"'block'",
",",
"'block'",
")",
";",
"var",
"_prefix",
"=",
"this",... | Prefix css classes in a block
@param {String} prefix
@param {Block} block
@return {Block}
@api private | [
"Prefix",
"css",
"classes",
"in",
"a",
"block"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/prefix-classes.js#L12-L22 | train |
stylus/stylus | lib/functions/use.js | use | function use(plugin, options){
utils.assertString(plugin, 'plugin');
if (options) {
utils.assertType(options, 'object', 'options');
options = parseObject(options);
}
// lookup
plugin = plugin.string;
var found = utils.lookup(plugin, this.options.paths, this.options.filename);
if (!found) throw n... | javascript | function use(plugin, options){
utils.assertString(plugin, 'plugin');
if (options) {
utils.assertType(options, 'object', 'options');
options = parseObject(options);
}
// lookup
plugin = plugin.string;
var found = utils.lookup(plugin, this.options.paths, this.options.filename);
if (!found) throw n... | [
"function",
"use",
"(",
"plugin",
",",
"options",
")",
"{",
"utils",
".",
"assertString",
"(",
"plugin",
",",
"'plugin'",
")",
";",
"if",
"(",
"options",
")",
"{",
"utils",
".",
"assertType",
"(",
"options",
",",
"'object'",
",",
"'options'",
")",
";",... | Use the given `plugin`
Examples:
use("plugins/add.js")
width add(10, 100)
// => width: 110 | [
"Use",
"the",
"given",
"plugin"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/use.js#L15-L34 | train |
stylus/stylus | lib/functions/use.js | parseObject | function parseObject(obj){
obj = obj.vals;
for (var key in obj) {
var nodes = obj[key].nodes[0].nodes;
if (nodes && nodes.length) {
obj[key] = [];
for (var i = 0, len = nodes.length; i < len; ++i) {
obj[key].push(convert(nodes[i]));
}
} else {
obj[key] = convert(obj[key].... | javascript | function parseObject(obj){
obj = obj.vals;
for (var key in obj) {
var nodes = obj[key].nodes[0].nodes;
if (nodes && nodes.length) {
obj[key] = [];
for (var i = 0, len = nodes.length; i < len; ++i) {
obj[key].push(convert(nodes[i]));
}
} else {
obj[key] = convert(obj[key].... | [
"function",
"parseObject",
"(",
"obj",
")",
"{",
"obj",
"=",
"obj",
".",
"vals",
";",
"for",
"(",
"var",
"key",
"in",
"obj",
")",
"{",
"var",
"nodes",
"=",
"obj",
"[",
"key",
"]",
".",
"nodes",
"[",
"0",
"]",
".",
"nodes",
";",
"if",
"(",
"no... | Attempt to parse object node to the javascript object.
@param {Object} obj
@return {Object}
@api private | [
"Attempt",
"to",
"parse",
"object",
"node",
"to",
"the",
"javascript",
"object",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/use.js#L46-L76 | train |
stylus/stylus | lib/renderer.js | Renderer | function Renderer(str, options) {
options = options || {};
options.globals = options.globals || {};
options.functions = options.functions || {};
options.use = options.use || [];
options.use = Array.isArray(options.use) ? options.use : [options.use];
options.imports = [join(__dirname, 'functions')].concat(op... | javascript | function Renderer(str, options) {
options = options || {};
options.globals = options.globals || {};
options.functions = options.functions || {};
options.use = options.use || [];
options.use = Array.isArray(options.use) ? options.use : [options.use];
options.imports = [join(__dirname, 'functions')].concat(op... | [
"function",
"Renderer",
"(",
"str",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"options",
".",
"globals",
"=",
"options",
".",
"globals",
"||",
"{",
"}",
";",
"options",
".",
"functions",
"=",
"options",
".",
"functions",... | Initialize a new `Renderer` with the given `str` and `options`.
@param {String} str
@param {Object} options
@api public | [
"Initialize",
"a",
"new",
"Renderer",
"with",
"the",
"given",
"str",
"and",
"options",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/renderer.js#L35-L48 | train |
stylus/stylus | lib/functions/tan.js | tan | function tan(angle) {
utils.assertType(angle, 'unit', 'angle');
var radians = angle.val;
if (angle.type === 'deg') {
radians *= Math.PI / 180;
}
var m = Math.pow(10, 9);
var sin = Math.round(Math.sin(radians) * m) / m
, cos = Math.round(Math.cos(radians) * m) / m
, tan = Math.round(m * sin /... | javascript | function tan(angle) {
utils.assertType(angle, 'unit', 'angle');
var radians = angle.val;
if (angle.type === 'deg') {
radians *= Math.PI / 180;
}
var m = Math.pow(10, 9);
var sin = Math.round(Math.sin(radians) * m) / m
, cos = Math.round(Math.cos(radians) * m) / m
, tan = Math.round(m * sin /... | [
"function",
"tan",
"(",
"angle",
")",
"{",
"utils",
".",
"assertType",
"(",
"angle",
",",
"'unit'",
",",
"'angle'",
")",
";",
"var",
"radians",
"=",
"angle",
".",
"val",
";",
"if",
"(",
"angle",
".",
"type",
"===",
"'deg'",
")",
"{",
"radians",
"*=... | Return the tangent of the given `angle`.
@param {Unit} angle
@return {Unit}
@api public | [
"Return",
"the",
"tangent",
"of",
"the",
"given",
"angle",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/tan.js#L12-L28 | train |
stylus/stylus | lib/functions/dirname.js | dirname | function dirname(p){
utils.assertString(p, 'path');
return path.dirname(p.val).replace(/\\/g, '/');
} | javascript | function dirname(p){
utils.assertString(p, 'path');
return path.dirname(p.val).replace(/\\/g, '/');
} | [
"function",
"dirname",
"(",
"p",
")",
"{",
"utils",
".",
"assertString",
"(",
"p",
",",
"'path'",
")",
";",
"return",
"path",
".",
"dirname",
"(",
"p",
".",
"val",
")",
".",
"replace",
"(",
"/",
"\\\\",
"/",
"g",
",",
"'/'",
")",
";",
"}"
] | Return the dirname of `path`.
@param {String} path
@return {String}
@api public | [
"Return",
"the",
"dirname",
"of",
"path",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/dirname.js#L12-L15 | train |
stylus/stylus | lib/functions/range.js | range | function range(start, stop, step){
utils.assertType(start, 'unit', 'start');
utils.assertType(stop, 'unit', 'stop');
if (step) {
utils.assertType(step, 'unit', 'step');
if (0 == step.val) {
throw new Error('ArgumentError: "step" argument must not be zero');
}
} else {
step = new nodes.Unit... | javascript | function range(start, stop, step){
utils.assertType(start, 'unit', 'start');
utils.assertType(stop, 'unit', 'stop');
if (step) {
utils.assertType(step, 'unit', 'step');
if (0 == step.val) {
throw new Error('ArgumentError: "step" argument must not be zero');
}
} else {
step = new nodes.Unit... | [
"function",
"range",
"(",
"start",
",",
"stop",
",",
"step",
")",
"{",
"utils",
".",
"assertType",
"(",
"start",
",",
"'unit'",
",",
"'start'",
")",
";",
"utils",
".",
"assertType",
"(",
"stop",
",",
"'unit'",
",",
"'stop'",
")",
";",
"if",
"(",
"s... | Returns a list of units from `start` to `stop`
by `step`. If `step` argument is omitted,
it defaults to 1.
@param {Unit} start
@param {Unit} stop
@param {Unit} [step]
@return {Expression}
@api public | [
"Returns",
"a",
"list",
"of",
"units",
"from",
"start",
"to",
"stop",
"by",
"step",
".",
"If",
"step",
"argument",
"is",
"omitted",
"it",
"defaults",
"to",
"1",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/range.js#L16-L32 | train |
stylus/stylus | lib/functions/json.js | oldJson | function oldJson(json, local, namePrefix){
if (namePrefix) {
utils.assertString(namePrefix, 'namePrefix');
namePrefix = namePrefix.val;
} else {
namePrefix = '';
}
local = local ? local.toBoolean() : new nodes.Boolean(local);
var scope = local.isTrue ? this.currentScope : this.global.scope;
con... | javascript | function oldJson(json, local, namePrefix){
if (namePrefix) {
utils.assertString(namePrefix, 'namePrefix');
namePrefix = namePrefix.val;
} else {
namePrefix = '';
}
local = local ? local.toBoolean() : new nodes.Boolean(local);
var scope = local.isTrue ? this.currentScope : this.global.scope;
con... | [
"function",
"oldJson",
"(",
"json",
",",
"local",
",",
"namePrefix",
")",
"{",
"if",
"(",
"namePrefix",
")",
"{",
"utils",
".",
"assertString",
"(",
"namePrefix",
",",
"'namePrefix'",
")",
";",
"namePrefix",
"=",
"namePrefix",
".",
"val",
";",
"}",
"else... | Old `json` BIF.
@api private | [
"Old",
"json",
"BIF",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/json.js#L91-L118 | train |
stylus/stylus | lib/functions/component.js | component | function component(color, name) {
utils.assertColor(color, 'color');
utils.assertString(name, 'name');
var name = name.string
, unit = unitMap[name]
, type = typeMap[name]
, name = componentMap[name];
if (!name) throw new Error('invalid color component "' + name + '"');
return new nodes.Unit(color... | javascript | function component(color, name) {
utils.assertColor(color, 'color');
utils.assertString(name, 'name');
var name = name.string
, unit = unitMap[name]
, type = typeMap[name]
, name = componentMap[name];
if (!name) throw new Error('invalid color component "' + name + '"');
return new nodes.Unit(color... | [
"function",
"component",
"(",
"color",
",",
"name",
")",
"{",
"utils",
".",
"assertColor",
"(",
"color",
",",
"'color'",
")",
";",
"utils",
".",
"assertString",
"(",
"name",
",",
"'name'",
")",
";",
"var",
"name",
"=",
"name",
".",
"string",
",",
"un... | Return component `name` for the given `color`.
@param {RGBA|HSLA} color
@param {String} name
@return {Unit}
@api public | [
"Return",
"component",
"name",
"for",
"the",
"given",
"color",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/component.js#L51-L60 | train |
stylus/stylus | lib/parser.js | function(){
var block = this.parent = this.root;
if (Parser.cache.has(this.hash)) {
block = Parser.cache.get(this.hash);
// normalize cached imports
if ('block' == block.nodeName) block.constructor = nodes.Root;
} else {
while ('eos' != this.peek().type) {
this.skipWhitespace... | javascript | function(){
var block = this.parent = this.root;
if (Parser.cache.has(this.hash)) {
block = Parser.cache.get(this.hash);
// normalize cached imports
if ('block' == block.nodeName) block.constructor = nodes.Root;
} else {
while ('eos' != this.peek().type) {
this.skipWhitespace... | [
"function",
"(",
")",
"{",
"var",
"block",
"=",
"this",
".",
"parent",
"=",
"this",
".",
"root",
";",
"if",
"(",
"Parser",
".",
"cache",
".",
"has",
"(",
"this",
".",
"hash",
")",
")",
"{",
"block",
"=",
"Parser",
".",
"cache",
".",
"get",
"(",... | Parse the input, then return the root node.
@return {Node}
@api private | [
"Parse",
"the",
"input",
"then",
"return",
"the",
"root",
"node",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L226-L244 | train | |
stylus/stylus | lib/parser.js | function(msg){
var type = this.peek().type
, val = undefined == this.peek().val
? ''
: ' ' + this.peek().toString();
if (val.trim() == type.trim()) val = '';
throw new errors.ParseError(msg.replace('{peek}', '"' + type + val + '"'));
} | javascript | function(msg){
var type = this.peek().type
, val = undefined == this.peek().val
? ''
: ' ' + this.peek().toString();
if (val.trim() == type.trim()) val = '';
throw new errors.ParseError(msg.replace('{peek}', '"' + type + val + '"'));
} | [
"function",
"(",
"msg",
")",
"{",
"var",
"type",
"=",
"this",
".",
"peek",
"(",
")",
".",
"type",
",",
"val",
"=",
"undefined",
"==",
"this",
".",
"peek",
"(",
")",
".",
"val",
"?",
"''",
":",
"' '",
"+",
"this",
".",
"peek",
"(",
")",
".",
... | Throw an `Error` with the given `msg`.
@param {String} msg
@api private | [
"Throw",
"an",
"Error",
"with",
"the",
"given",
"msg",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L253-L260 | train | |
stylus/stylus | lib/parser.js | function() {
var tok = this.stash.length
? this.stash.pop()
: this.lexer.next()
, line = tok.lineno
, column = tok.column || 1;
if (tok.val && tok.val.nodeName) {
tok.val.lineno = line;
tok.val.column = column;
}
nodes.lineno = line;
nodes.column = column;
de... | javascript | function() {
var tok = this.stash.length
? this.stash.pop()
: this.lexer.next()
, line = tok.lineno
, column = tok.column || 1;
if (tok.val && tok.val.nodeName) {
tok.val.lineno = line;
tok.val.column = column;
}
nodes.lineno = line;
nodes.column = column;
de... | [
"function",
"(",
")",
"{",
"var",
"tok",
"=",
"this",
".",
"stash",
".",
"length",
"?",
"this",
".",
"stash",
".",
"pop",
"(",
")",
":",
"this",
".",
"lexer",
".",
"next",
"(",
")",
",",
"line",
"=",
"tok",
".",
"lineno",
",",
"column",
"=",
... | Get the next token.
@return {Token}
@api private | [
"Get",
"the",
"next",
"token",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L299-L314 | train | |
stylus/stylus | lib/parser.js | function(n) {
var la = this.lookahead(n).type;
switch (la) {
case 'for':
return this.bracketed;
case '[':
this.bracketed = true;
return true;
case ']':
this.bracketed = false;
return true;
default:
return ~selectorTokens.indexOf(la);
}
... | javascript | function(n) {
var la = this.lookahead(n).type;
switch (la) {
case 'for':
return this.bracketed;
case '[':
this.bracketed = true;
return true;
case ']':
this.bracketed = false;
return true;
default:
return ~selectorTokens.indexOf(la);
}
... | [
"function",
"(",
"n",
")",
"{",
"var",
"la",
"=",
"this",
".",
"lookahead",
"(",
"n",
")",
".",
"type",
";",
"switch",
"(",
"la",
")",
"{",
"case",
"'for'",
":",
"return",
"this",
".",
"bracketed",
";",
"case",
"'['",
":",
"this",
".",
"bracketed... | Check if the token at `n` is a valid selector token.
@param {Number} n
@return {Boolean}
@api private | [
"Check",
"if",
"the",
"token",
"at",
"n",
"is",
"a",
"valid",
"selector",
"token",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L347-L361 | train | |
stylus/stylus | lib/parser.js | function(n){
var val = this.lookahead(n).val;
return val && ~pseudoSelectors.indexOf(val.name);
} | javascript | function(n){
var val = this.lookahead(n).val;
return val && ~pseudoSelectors.indexOf(val.name);
} | [
"function",
"(",
"n",
")",
"{",
"var",
"val",
"=",
"this",
".",
"lookahead",
"(",
"n",
")",
".",
"val",
";",
"return",
"val",
"&&",
"~",
"pseudoSelectors",
".",
"indexOf",
"(",
"val",
".",
"name",
")",
";",
"}"
] | Check if the token at `n` is a pseudo selector.
@param {Number} n
@return {Boolean}
@api private | [
"Check",
"if",
"the",
"token",
"at",
"n",
"is",
"a",
"pseudo",
"selector",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L371-L374 | train | |
stylus/stylus | lib/parser.js | function(type){
var i = 1
, la;
while (la = this.lookahead(i++)) {
if (~['indent', 'outdent', 'newline', 'eos'].indexOf(la.type)) return;
if (type == la.type) return true;
}
} | javascript | function(type){
var i = 1
, la;
while (la = this.lookahead(i++)) {
if (~['indent', 'outdent', 'newline', 'eos'].indexOf(la.type)) return;
if (type == la.type) return true;
}
} | [
"function",
"(",
"type",
")",
"{",
"var",
"i",
"=",
"1",
",",
"la",
";",
"while",
"(",
"la",
"=",
"this",
".",
"lookahead",
"(",
"i",
"++",
")",
")",
"{",
"if",
"(",
"~",
"[",
"'indent'",
",",
"'outdent'",
",",
"'newline'",
",",
"'eos'",
"]",
... | Check if the current line contains `type`.
@param {String} type
@return {Boolean}
@api private | [
"Check",
"if",
"the",
"current",
"line",
"contains",
"type",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L384-L392 | train | |
stylus/stylus | lib/parser.js | function() {
if (this.isSelectorToken(1)) {
if ('{' == this.peek().type) {
// unclosed, must be a block
if (!this.lineContains('}')) return;
// check if ':' is within the braces.
// though not required by Stylus, chances
// are if someone is using {} they will
/... | javascript | function() {
if (this.isSelectorToken(1)) {
if ('{' == this.peek().type) {
// unclosed, must be a block
if (!this.lineContains('}')) return;
// check if ':' is within the braces.
// though not required by Stylus, chances
// are if someone is using {} they will
/... | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"isSelectorToken",
"(",
"1",
")",
")",
"{",
"if",
"(",
"'{'",
"==",
"this",
".",
"peek",
"(",
")",
".",
"type",
")",
"{",
"// unclosed, must be a block",
"if",
"(",
"!",
"this",
".",
"lineContains",
... | Valid selector tokens. | [
"Valid",
"selector",
"tokens",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L398-L422 | train | |
stylus/stylus | lib/parser.js | function(n) {
var type = this.lookahead(n).type;
if ('=' == type && this.bracketed) return true;
return ('ident' == type || 'string' == type)
&& ']' == this.lookahead(n + 1).type
&& ('newline' == this.lookahead(n + 2).type || this.isSelectorToken(n + 2))
&& !this.lineContains(':')
&&... | javascript | function(n) {
var type = this.lookahead(n).type;
if ('=' == type && this.bracketed) return true;
return ('ident' == type || 'string' == type)
&& ']' == this.lookahead(n + 1).type
&& ('newline' == this.lookahead(n + 2).type || this.isSelectorToken(n + 2))
&& !this.lineContains(':')
&&... | [
"function",
"(",
"n",
")",
"{",
"var",
"type",
"=",
"this",
".",
"lookahead",
"(",
"n",
")",
".",
"type",
";",
"if",
"(",
"'='",
"==",
"type",
"&&",
"this",
".",
"bracketed",
")",
"return",
"true",
";",
"return",
"(",
"'ident'",
"==",
"type",
"||... | Check if the following sequence of tokens
forms an attribute selector. | [
"Check",
"if",
"the",
"following",
"sequence",
"of",
"tokens",
"forms",
"an",
"attribute",
"selector",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L660-L668 | train | |
stylus/stylus | lib/parser.js | function() {
var i = 2
, type;
switch (this.lookahead(i).type) {
case '{':
case 'indent':
case ',':
return true;
case 'newline':
while ('unit' == this.lookahead(++i).type
|| 'newline' == this.lookahead(i).type) ;
type = this.lookahead(i).type;
... | javascript | function() {
var i = 2
, type;
switch (this.lookahead(i).type) {
case '{':
case 'indent':
case ',':
return true;
case 'newline':
while ('unit' == this.lookahead(++i).type
|| 'newline' == this.lookahead(i).type) ;
type = this.lookahead(i).type;
... | [
"function",
"(",
")",
"{",
"var",
"i",
"=",
"2",
",",
"type",
";",
"switch",
"(",
"this",
".",
"lookahead",
"(",
"i",
")",
".",
"type",
")",
"{",
"case",
"'{'",
":",
"case",
"'indent'",
":",
"case",
"','",
":",
"return",
"true",
";",
"case",
"'... | Check if the following sequence of tokens
forms a keyframe block. | [
"Check",
"if",
"the",
"following",
"sequence",
"of",
"tokens",
"forms",
"a",
"keyframe",
"block",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L675-L689 | train | |
stylus/stylus | lib/parser.js | function() {
var stmt = this.stmt()
, state = this.prevState
, block
, op;
// special-case statements since it
// is not an expression. We could
// implement postfix conditionals at
// the expression level, however they
// would then fail to enclose properties
if (this.all... | javascript | function() {
var stmt = this.stmt()
, state = this.prevState
, block
, op;
// special-case statements since it
// is not an expression. We could
// implement postfix conditionals at
// the expression level, however they
// would then fail to enclose properties
if (this.all... | [
"function",
"(",
")",
"{",
"var",
"stmt",
"=",
"this",
".",
"stmt",
"(",
")",
",",
"state",
"=",
"this",
".",
"prevState",
",",
"block",
",",
"op",
";",
"// special-case statements since it",
"// is not an expression. We could",
"// implement postfix conditionals at... | statement
| statement 'if' expression
| statement 'unless' expression | [
"statement",
"|",
"statement",
"if",
"expression",
"|",
"statement",
"unless",
"expression"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L729-L776 | train | |
stylus/stylus | lib/parser.js | function() {
var tok = this.peek(), selector;
switch (tok.type) {
case 'keyframes':
return this.keyframes();
case '-moz-document':
return this.mozdocument();
case 'comment':
case 'selector':
case 'literal':
case 'charset':
case 'namespace':
case 'i... | javascript | function() {
var tok = this.peek(), selector;
switch (tok.type) {
case 'keyframes':
return this.keyframes();
case '-moz-document':
return this.mozdocument();
case 'comment':
case 'selector':
case 'literal':
case 'charset':
case 'namespace':
case 'i... | [
"function",
"(",
")",
"{",
"var",
"tok",
"=",
"this",
".",
"peek",
"(",
")",
",",
"selector",
";",
"switch",
"(",
"tok",
".",
"type",
")",
"{",
"case",
"'keyframes'",
":",
"return",
"this",
".",
"keyframes",
"(",
")",
";",
"case",
"'-moz-document'",
... | ident
| selector
| literal
| charset
| namespace
| import
| require
| media
| atrule
| scope
| keyframes
| mozdocument
| for
| if
| unless
| comment
| expression
| 'return' expression | [
"ident",
"|",
"selector",
"|",
"literal",
"|",
"charset",
"|",
"namespace",
"|",
"import",
"|",
"require",
"|",
"media",
"|",
"atrule",
"|",
"scope",
"|",
"keyframes",
"|",
"mozdocument",
"|",
"for",
"|",
"if",
"|",
"unless",
"|",
"comment",
"|",
"expr... | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L799-L875 | train | |
stylus/stylus | lib/parser.js | function() {
this.expect('unless');
this.state.push('conditional');
this.cond = true;
var node = new nodes.If(this.expression(), true);
this.cond = false;
node.block = this.block(node, false);
this.state.pop();
return node;
} | javascript | function() {
this.expect('unless');
this.state.push('conditional');
this.cond = true;
var node = new nodes.If(this.expression(), true);
this.cond = false;
node.block = this.block(node, false);
this.state.pop();
return node;
} | [
"function",
"(",
")",
"{",
"this",
".",
"expect",
"(",
"'unless'",
")",
";",
"this",
".",
"state",
".",
"push",
"(",
"'conditional'",
")",
";",
"this",
".",
"cond",
"=",
"true",
";",
"var",
"node",
"=",
"new",
"nodes",
".",
"If",
"(",
"this",
"."... | unless expression block | [
"unless",
"expression",
"block"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L984-L993 | train | |
stylus/stylus | lib/parser.js | function(){
var type = this.expect('atrule').val
, node = new nodes.Atrule(type)
, tok;
this.skipSpacesAndComments();
node.segments = this.selectorParts();
this.skipSpacesAndComments();
tok = this.peek().type;
if ('indent' == tok || '{' == tok || ('newline' == tok
&& '{' == thi... | javascript | function(){
var type = this.expect('atrule').val
, node = new nodes.Atrule(type)
, tok;
this.skipSpacesAndComments();
node.segments = this.selectorParts();
this.skipSpacesAndComments();
tok = this.peek().type;
if ('indent' == tok || '{' == tok || ('newline' == tok
&& '{' == thi... | [
"function",
"(",
")",
"{",
"var",
"type",
"=",
"this",
".",
"expect",
"(",
"'atrule'",
")",
".",
"val",
",",
"node",
"=",
"new",
"nodes",
".",
"Atrule",
"(",
"type",
")",
",",
"tok",
";",
"this",
".",
"skipSpacesAndComments",
"(",
")",
";",
"node",... | atrule selector? block? | [
"atrule",
"selector?",
"block?"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L1055-L1070 | train | |
stylus/stylus | lib/parser.js | function(){
var node = this.supportsNegation()
|| this.supportsOp();
if (!node) {
this.cond = true;
node = this.expression();
this.cond = false;
}
return node;
} | javascript | function(){
var node = this.supportsNegation()
|| this.supportsOp();
if (!node) {
this.cond = true;
node = this.expression();
this.cond = false;
}
return node;
} | [
"function",
"(",
")",
"{",
"var",
"node",
"=",
"this",
".",
"supportsNegation",
"(",
")",
"||",
"this",
".",
"supportsOp",
"(",
")",
";",
"if",
"(",
"!",
"node",
")",
"{",
"this",
".",
"cond",
"=",
"true",
";",
"node",
"=",
"this",
".",
"expressi... | supports negation
| supports op
| expression | [
"supports",
"negation",
"|",
"supports",
"op",
"|",
"expression"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L1104-L1113 | train | |
stylus/stylus | lib/parser.js | function(){
if (this.accept('not')) {
var node = new nodes.Expression;
node.push(new nodes.Literal('not'));
node.push(this.supportsFeature());
return node;
}
} | javascript | function(){
if (this.accept('not')) {
var node = new nodes.Expression;
node.push(new nodes.Literal('not'));
node.push(this.supportsFeature());
return node;
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"accept",
"(",
"'not'",
")",
")",
"{",
"var",
"node",
"=",
"new",
"nodes",
".",
"Expression",
";",
"node",
".",
"push",
"(",
"new",
"nodes",
".",
"Literal",
"(",
"'not'",
")",
")",
";",
"node",
... | 'not' supports feature | [
"not",
"supports",
"feature"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L1119-L1126 | train | |
stylus/stylus | lib/parser.js | function() {
var tok = this.expect('keyframes')
, keyframes;
this.skipSpacesAndComments();
keyframes = new nodes.Keyframes(this.selectorParts(), tok.val);
keyframes.column = tok.column;
this.skipSpacesAndComments();
// block
this.state.push('atrule');
keyframes.block = this.bloc... | javascript | function() {
var tok = this.expect('keyframes')
, keyframes;
this.skipSpacesAndComments();
keyframes = new nodes.Keyframes(this.selectorParts(), tok.val);
keyframes.column = tok.column;
this.skipSpacesAndComments();
// block
this.state.push('atrule');
keyframes.block = this.bloc... | [
"function",
"(",
")",
"{",
"var",
"tok",
"=",
"this",
".",
"expect",
"(",
"'keyframes'",
")",
",",
"keyframes",
";",
"this",
".",
"skipSpacesAndComments",
"(",
")",
";",
"keyframes",
"=",
"new",
"nodes",
".",
"Keyframes",
"(",
"this",
".",
"selectorParts... | keyframes name block | [
"keyframes",
"name",
"block"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L1376-L1392 | train | |
stylus/stylus | lib/parser.js | function() {
var arr
, group = new nodes.Group
, scope = this.selectorScope
, isRoot = 'root' == this.currentState()
, selector;
do {
// Clobber newline after ,
this.accept('newline');
arr = this.selectorParts();
// Push the selector
if (isRoot && scope) ... | javascript | function() {
var arr
, group = new nodes.Group
, scope = this.selectorScope
, isRoot = 'root' == this.currentState()
, selector;
do {
// Clobber newline after ,
this.accept('newline');
arr = this.selectorParts();
// Push the selector
if (isRoot && scope) ... | [
"function",
"(",
")",
"{",
"var",
"arr",
",",
"group",
"=",
"new",
"nodes",
".",
"Group",
",",
"scope",
"=",
"this",
".",
"selectorScope",
",",
"isRoot",
"=",
"'root'",
"==",
"this",
".",
"currentState",
"(",
")",
",",
"selector",
";",
"do",
"{",
"... | selector ',' selector
| selector newline selector
| selector block | [
"selector",
"selector",
"|",
"selector",
"newline",
"selector",
"|",
"selector",
"block"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L1594-L1624 | train | |
stylus/stylus | lib/parser.js | function() {
var parens = 1
, i = 2
, tok;
// Lookahead and determine if we are dealing
// with a function call or definition. Here
// we pair parens to prevent false negatives
out:
while (tok = this.lookahead(i++)) {
switch (tok.type) {
case 'function':
case '... | javascript | function() {
var parens = 1
, i = 2
, tok;
// Lookahead and determine if we are dealing
// with a function call or definition. Here
// we pair parens to prevent false negatives
out:
while (tok = this.lookahead(i++)) {
switch (tok.type) {
case 'function':
case '... | [
"function",
"(",
")",
"{",
"var",
"parens",
"=",
"1",
",",
"i",
"=",
"2",
",",
"tok",
";",
"// Lookahead and determine if we are dealing",
"// with a function call or definition. Here",
"// we pair parens to prevent false negatives",
"out",
":",
"while",
"(",
"tok",
"="... | definition
| call | [
"definition",
"|",
"call"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L1729-L1761 | train | |
stylus/stylus | lib/parser.js | function() {
var tok
, node
, params = new nodes.Params;
while (tok = this.accept('ident')) {
this.accept('space');
params.push(node = tok.val);
if (this.accept('...')) {
node.rest = true;
} else if (this.accept('=')) {
node.val = this.expression();
}
... | javascript | function() {
var tok
, node
, params = new nodes.Params;
while (tok = this.accept('ident')) {
this.accept('space');
params.push(node = tok.val);
if (this.accept('...')) {
node.rest = true;
} else if (this.accept('=')) {
node.val = this.expression();
}
... | [
"function",
"(",
")",
"{",
"var",
"tok",
",",
"node",
",",
"params",
"=",
"new",
"nodes",
".",
"Params",
";",
"while",
"(",
"tok",
"=",
"this",
".",
"accept",
"(",
"'ident'",
")",
")",
"{",
"this",
".",
"accept",
"(",
"'space'",
")",
";",
"params... | ident
| ident '...'
| ident '=' expression
| ident ',' ident | [
"ident",
"|",
"ident",
"...",
"|",
"ident",
"=",
"expression",
"|",
"ident",
"ident"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L1835-L1852 | train | |
stylus/stylus | lib/parser.js | function() {
var node = this.unary();
if (this.accept('is defined')) {
if (!node) this.error('illegal unary "is defined", missing left-hand operand');
node = new nodes.BinOp('is defined', node);
}
return node;
} | javascript | function() {
var node = this.unary();
if (this.accept('is defined')) {
if (!node) this.error('illegal unary "is defined", missing left-hand operand');
node = new nodes.BinOp('is defined', node);
}
return node;
} | [
"function",
"(",
")",
"{",
"var",
"node",
"=",
"this",
".",
"unary",
"(",
")",
";",
"if",
"(",
"this",
".",
"accept",
"(",
"'is defined'",
")",
")",
"{",
"if",
"(",
"!",
"node",
")",
"this",
".",
"error",
"(",
"'illegal unary \"is defined\", missing le... | unary 'is defined'
| unary | [
"unary",
"is",
"defined",
"|",
"unary"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/parser.js#L2087-L2094 | train | |
stylus/stylus | lib/functions/adjust.js | adjust | function adjust(color, prop, amount){
utils.assertColor(color, 'color');
utils.assertString(prop, 'prop');
utils.assertType(amount, 'unit', 'amount');
var hsl = color.hsla.clone();
prop = { hue: 'h', saturation: 's', lightness: 'l' }[prop.string];
if (!prop) throw new Error('invalid adjustment property');
... | javascript | function adjust(color, prop, amount){
utils.assertColor(color, 'color');
utils.assertString(prop, 'prop');
utils.assertType(amount, 'unit', 'amount');
var hsl = color.hsla.clone();
prop = { hue: 'h', saturation: 's', lightness: 'l' }[prop.string];
if (!prop) throw new Error('invalid adjustment property');
... | [
"function",
"adjust",
"(",
"color",
",",
"prop",
",",
"amount",
")",
"{",
"utils",
".",
"assertColor",
"(",
"color",
",",
"'color'",
")",
";",
"utils",
".",
"assertString",
"(",
"prop",
",",
"'prop'",
")",
";",
"utils",
".",
"assertType",
"(",
"amount"... | Adjust HSL `color` `prop` by `amount`.
@param {RGBA|HSLA} color
@param {String} prop
@param {Unit} amount
@return {RGBA}
@api private | [
"Adjust",
"HSL",
"color",
"prop",
"by",
"amount",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/adjust.js#L13-L28 | train |
stylus/stylus | lib/functions/green.js | green | function green(color, value){
color = color.rgba;
if (value) {
return rgba(
new nodes.Unit(color.r),
value,
new nodes.Unit(color.b),
new nodes.Unit(color.a)
);
}
return new nodes.Unit(color.g, '');
} | javascript | function green(color, value){
color = color.rgba;
if (value) {
return rgba(
new nodes.Unit(color.r),
value,
new nodes.Unit(color.b),
new nodes.Unit(color.a)
);
}
return new nodes.Unit(color.g, '');
} | [
"function",
"green",
"(",
"color",
",",
"value",
")",
"{",
"color",
"=",
"color",
".",
"rgba",
";",
"if",
"(",
"value",
")",
"{",
"return",
"rgba",
"(",
"new",
"nodes",
".",
"Unit",
"(",
"color",
".",
"r",
")",
",",
"value",
",",
"new",
"nodes",
... | Return the green component of the given `color`,
or set the green component to the optional second `value` argument.
Examples:
green(#0c0)
// => 204
green(#000, 255)
// => #0f0
@param {RGBA|HSLA} color
@param {Unit} [value]
@return {Unit|RGBA}
@api public | [
"Return",
"the",
"green",
"component",
"of",
"the",
"given",
"color",
"or",
"set",
"the",
"green",
"component",
"to",
"the",
"optional",
"second",
"value",
"argument",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/green.js#L22-L33 | train |
stylus/stylus | lib/functions/transparentify.js | transparentify | function transparentify(top, bottom, alpha){
utils.assertColor(top);
top = top.rgba;
// Handle default arguments
bottom = bottom || new nodes.RGBA(255, 255, 255, 1);
if (!alpha && bottom && !bottom.rgba) {
alpha = bottom;
bottom = new nodes.RGBA(255, 255, 255, 1);
}
utils.assertColor(bottom);
bo... | javascript | function transparentify(top, bottom, alpha){
utils.assertColor(top);
top = top.rgba;
// Handle default arguments
bottom = bottom || new nodes.RGBA(255, 255, 255, 1);
if (!alpha && bottom && !bottom.rgba) {
alpha = bottom;
bottom = new nodes.RGBA(255, 255, 255, 1);
}
utils.assertColor(bottom);
bo... | [
"function",
"transparentify",
"(",
"top",
",",
"bottom",
",",
"alpha",
")",
"{",
"utils",
".",
"assertColor",
"(",
"top",
")",
";",
"top",
"=",
"top",
".",
"rgba",
";",
"// Handle default arguments",
"bottom",
"=",
"bottom",
"||",
"new",
"nodes",
".",
"R... | Returns the transparent version of the given `top` color,
as if it was blend over the given `bottom` color.
Examples:
transparentify(#808080)
=> rgba(0,0,0,0.5)
transparentify(#414141, #000)
=> rgba(255,255,255,0.25)
transparentify(#91974C, #F34949, 0.5)
=> rgba(47,229,79,0.5)
@param {RGBA|HSLA} top
@param {RGBA|H... | [
"Returns",
"the",
"transparent",
"version",
"of",
"the",
"given",
"top",
"color",
"as",
"if",
"it",
"was",
"blend",
"over",
"the",
"given",
"bottom",
"color",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/transparentify.js#L26-L63 | train |
stylus/stylus | lib/functions/transparentify.js | processChannel | function processChannel(channel) {
if (0 == bestAlpha) {
return bottom[channel]
} else {
return bottom[channel] + (top[channel] - bottom[channel]) / bestAlpha
}
} | javascript | function processChannel(channel) {
if (0 == bestAlpha) {
return bottom[channel]
} else {
return bottom[channel] + (top[channel] - bottom[channel]) / bestAlpha
}
} | [
"function",
"processChannel",
"(",
"channel",
")",
"{",
"if",
"(",
"0",
"==",
"bestAlpha",
")",
"{",
"return",
"bottom",
"[",
"channel",
"]",
"}",
"else",
"{",
"return",
"bottom",
"[",
"channel",
"]",
"+",
"(",
"top",
"[",
"channel",
"]",
"-",
"botto... | Calculate the resulting color | [
"Calculate",
"the",
"resulting",
"color"
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/transparentify.js#L50-L56 | train |
stylus/stylus | lib/functions/selector-exists.js | selectorExists | function selectorExists(sel) {
utils.assertString(sel, 'selector');
if (!this.__selectorsMap__) {
var Normalizer = require('../visitor/normalizer')
, visitor = new Normalizer(this.root.clone());
visitor.visit(visitor.root);
this.__selectorsMap__ = visitor.map;
}
return sel.string in this.__... | javascript | function selectorExists(sel) {
utils.assertString(sel, 'selector');
if (!this.__selectorsMap__) {
var Normalizer = require('../visitor/normalizer')
, visitor = new Normalizer(this.root.clone());
visitor.visit(visitor.root);
this.__selectorsMap__ = visitor.map;
}
return sel.string in this.__... | [
"function",
"selectorExists",
"(",
"sel",
")",
"{",
"utils",
".",
"assertString",
"(",
"sel",
",",
"'selector'",
")",
";",
"if",
"(",
"!",
"this",
".",
"__selectorsMap__",
")",
"{",
"var",
"Normalizer",
"=",
"require",
"(",
"'../visitor/normalizer'",
")",
... | Returns true if the given selector exists.
@param {String} sel
@return {Boolean}
@api public | [
"Returns",
"true",
"if",
"the",
"given",
"selector",
"exists",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/selector-exists.js#L11-L23 | train |
stylus/stylus | lib/functions/remove.js | remove | function remove(object, key){
utils.assertType(object, 'object', 'object');
utils.assertString(key, 'key');
delete object.vals[key.string];
return object;
} | javascript | function remove(object, key){
utils.assertType(object, 'object', 'object');
utils.assertString(key, 'key');
delete object.vals[key.string];
return object;
} | [
"function",
"remove",
"(",
"object",
",",
"key",
")",
"{",
"utils",
".",
"assertType",
"(",
"object",
",",
"'object'",
",",
"'object'",
")",
";",
"utils",
".",
"assertString",
"(",
"key",
",",
"'key'",
")",
";",
"delete",
"object",
".",
"vals",
"[",
... | Remove the given `key` from the `object`.
@param {Object} object
@param {String} key
@return {Object}
@api public | [
"Remove",
"the",
"given",
"key",
"from",
"the",
"object",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/remove.js#L12-L17 | train |
stylus/stylus | lib/nodes/node.js | CoercionError | function CoercionError(msg) {
this.name = 'CoercionError'
this.message = msg
if (Error.captureStackTrace) {
Error.captureStackTrace(this, CoercionError);
}
} | javascript | function CoercionError(msg) {
this.name = 'CoercionError'
this.message = msg
if (Error.captureStackTrace) {
Error.captureStackTrace(this, CoercionError);
}
} | [
"function",
"CoercionError",
"(",
"msg",
")",
"{",
"this",
".",
"name",
"=",
"'CoercionError'",
"this",
".",
"message",
"=",
"msg",
"if",
"(",
"Error",
".",
"captureStackTrace",
")",
"{",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"CoercionError",
... | Initialize a new `CoercionError` with the given `msg`.
@param {String} msg
@api private | [
"Initialize",
"a",
"new",
"CoercionError",
"with",
"the",
"given",
"msg",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/nodes/node.js#L23-L29 | train |
stylus/stylus | lib/nodes/node.js | function(op, right){
switch (op) {
case 'is a':
if ('string' == right.first.nodeName) {
return nodes.Boolean(this.nodeName == right.val);
} else {
throw new Error('"is a" expects a string, got ' + right.toString());
}
case '==':
return nodes.Boolean(th... | javascript | function(op, right){
switch (op) {
case 'is a':
if ('string' == right.first.nodeName) {
return nodes.Boolean(this.nodeName == right.val);
} else {
throw new Error('"is a" expects a string, got ' + right.toString());
}
case '==':
return nodes.Boolean(th... | [
"function",
"(",
"op",
",",
"right",
")",
"{",
"switch",
"(",
"op",
")",
"{",
"case",
"'is a'",
":",
"if",
"(",
"'string'",
"==",
"right",
".",
"first",
".",
"nodeName",
")",
"{",
"return",
"nodes",
".",
"Boolean",
"(",
"this",
".",
"nodeName",
"==... | Operate on `right` with the given `op`.
@param {String} op
@param {Node} right
@return {Node}
@api public | [
"Operate",
"on",
"right",
"with",
"the",
"given",
"op",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/nodes/node.js#L176-L238 | train | |
stylus/stylus | lib/convert/css.js | Converter | function Converter(css) {
var parse = require('css-parse');
this.css = css;
this.root = parse(css, { position: false });
this.indents = 0;
} | javascript | function Converter(css) {
var parse = require('css-parse');
this.css = css;
this.root = parse(css, { position: false });
this.indents = 0;
} | [
"function",
"Converter",
"(",
"css",
")",
"{",
"var",
"parse",
"=",
"require",
"(",
"'css-parse'",
")",
";",
"this",
".",
"css",
"=",
"css",
";",
"this",
".",
"root",
"=",
"parse",
"(",
"css",
",",
"{",
"position",
":",
"false",
"}",
")",
";",
"t... | Initialize a new `Converter` with the given `css`.
@param {String} css
@api private | [
"Initialize",
"a",
"new",
"Converter",
"with",
"the",
"given",
"css",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/convert/css.js#L26-L31 | train |
stylus/stylus | lib/functions/hsla.js | hsla | function hsla(hue, saturation, lightness, alpha){
switch (arguments.length) {
case 1:
utils.assertColor(hue);
return hue.hsla;
case 2:
utils.assertColor(hue);
var color = hue.hsla;
utils.assertType(saturation, 'unit', 'alpha');
var alpha = saturation.clone();
if ('%' ... | javascript | function hsla(hue, saturation, lightness, alpha){
switch (arguments.length) {
case 1:
utils.assertColor(hue);
return hue.hsla;
case 2:
utils.assertColor(hue);
var color = hue.hsla;
utils.assertType(saturation, 'unit', 'alpha');
var alpha = saturation.clone();
if ('%' ... | [
"function",
"hsla",
"(",
"hue",
",",
"saturation",
",",
"lightness",
",",
"alpha",
")",
"{",
"switch",
"(",
"arguments",
".",
"length",
")",
"{",
"case",
"1",
":",
"utils",
".",
"assertColor",
"(",
"hue",
")",
";",
"return",
"hue",
".",
"hsla",
";",
... | Convert the given `color` to an `HSLA` node,
or h,s,l,a component values.
Examples:
hsla(10deg, 50%, 30%, 0.5)
// => HSLA
hsla(#ffcc00)
// => HSLA
@param {RGBA|HSLA|Unit} hue
@param {Unit} saturation
@param {Unit} lightness
@param {Unit} alpha
@return {HSLA}
@api public | [
"Convert",
"the",
"given",
"color",
"to",
"an",
"HSLA",
"node",
"or",
"h",
"s",
"l",
"a",
"component",
"values",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/hsla.js#L24-L53 | train |
stylus/stylus | lib/functions/rgb.js | rgb | function rgb(red, green, blue){
switch (arguments.length) {
case 1:
utils.assertColor(red);
var color = red.rgba;
return new nodes.RGBA(
color.r
, color.g
, color.b
, 1);
default:
return rgba(
red
, green
, blue
, new ... | javascript | function rgb(red, green, blue){
switch (arguments.length) {
case 1:
utils.assertColor(red);
var color = red.rgba;
return new nodes.RGBA(
color.r
, color.g
, color.b
, 1);
default:
return rgba(
red
, green
, blue
, new ... | [
"function",
"rgb",
"(",
"red",
",",
"green",
",",
"blue",
")",
"{",
"switch",
"(",
"arguments",
".",
"length",
")",
"{",
"case",
"1",
":",
"utils",
".",
"assertColor",
"(",
"red",
")",
";",
"var",
"color",
"=",
"red",
".",
"rgba",
";",
"return",
... | Return a `RGBA` from the r,g,b channels.
Examples:
rgb(255,204,0)
// => #ffcc00
rgb(#fff)
// => #fff
@param {Unit|RGBA|HSLA} red
@param {Unit} green
@param {Unit} blue
@return {RGBA}
@api public | [
"Return",
"a",
"RGBA",
"from",
"the",
"r",
"g",
"b",
"channels",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/rgb.js#L23-L40 | 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.