id int32 0 58k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
5,800 | loadimpact/k6 | samples/pantheon.js | doCategory | function doCategory(category) {
check(http.get(category.url), {
"title is correct": (res) => res.html("title").text() == category.title,
});
for (prodName in category.products) {
if (Math.random() <= category.products[prodName].chance) {
group(prodName, function() { doProductPage(category.products[prodName])... | javascript | function doCategory(category) {
check(http.get(category.url), {
"title is correct": (res) => res.html("title").text() == category.title,
});
for (prodName in category.products) {
if (Math.random() <= category.products[prodName].chance) {
group(prodName, function() { doProductPage(category.products[prodName])... | [
"function",
"doCategory",
"(",
"category",
")",
"{",
"check",
"(",
"http",
".",
"get",
"(",
"category",
".",
"url",
")",
",",
"{",
"\"title is correct\"",
":",
"(",
"res",
")",
"=>",
"res",
".",
"html",
"(",
"\"title\"",
")",
".",
"text",
"(",
")",
... | Load a product category page, then potentially load some product pages | [
"Load",
"a",
"product",
"category",
"page",
"then",
"potentially",
"load",
"some",
"product",
"pages"
] | 03645ba7059a4ca9eb22035f5adb52f1a91e7534 | https://github.com/loadimpact/k6/blob/03645ba7059a4ca9eb22035f5adb52f1a91e7534/samples/pantheon.js#L164-L174 |
5,801 | loadimpact/k6 | samples/pantheon.js | doProductPage | function doProductPage(product) {
let res = http.get(product.url);
check(res, {
"title is correct": (res) => res.html("title").text() == product.title,
});
if (Math.random() <= product.chance) {
let formBuildID = res.body.match('name="form_build_id" value="(.*)"')[1];
let formID = res.body.match('name="form_i... | javascript | function doProductPage(product) {
let res = http.get(product.url);
check(res, {
"title is correct": (res) => res.html("title").text() == product.title,
});
if (Math.random() <= product.chance) {
let formBuildID = res.body.match('name="form_build_id" value="(.*)"')[1];
let formID = res.body.match('name="form_i... | [
"function",
"doProductPage",
"(",
"product",
")",
"{",
"let",
"res",
"=",
"http",
".",
"get",
"(",
"product",
".",
"url",
")",
";",
"check",
"(",
"res",
",",
"{",
"\"title is correct\"",
":",
"(",
"res",
")",
"=>",
"res",
".",
"html",
"(",
"\"title\"... | Load product page and potentially add product to cart | [
"Load",
"product",
"page",
"and",
"potentially",
"add",
"product",
"to",
"cart"
] | 03645ba7059a4ca9eb22035f5adb52f1a91e7534 | https://github.com/loadimpact/k6/blob/03645ba7059a4ca9eb22035f5adb52f1a91e7534/samples/pantheon.js#L177-L191 |
5,802 | loadimpact/k6 | samples/pantheon.js | addProductToCart | function addProductToCart(url, productID, formID, formBuildID, formToken) {
let formdata = {
product_id: productID,
form_id: formID,
form_build_id: formBuildID,
form_token: formToken,
quantity: 1,
op: "Add to cart",
};
let headers = { "Content-Type": "application/x-www-form-urlencoded" };
let res = http... | javascript | function addProductToCart(url, productID, formID, formBuildID, formToken) {
let formdata = {
product_id: productID,
form_id: formID,
form_build_id: formBuildID,
form_token: formToken,
quantity: 1,
op: "Add to cart",
};
let headers = { "Content-Type": "application/x-www-form-urlencoded" };
let res = http... | [
"function",
"addProductToCart",
"(",
"url",
",",
"productID",
",",
"formID",
",",
"formBuildID",
",",
"formToken",
")",
"{",
"let",
"formdata",
"=",
"{",
"product_id",
":",
"productID",
",",
"form_id",
":",
"formID",
",",
"form_build_id",
":",
"formBuildID",
... | Add a product to our shopping cart | [
"Add",
"a",
"product",
"to",
"our",
"shopping",
"cart"
] | 03645ba7059a4ca9eb22035f5adb52f1a91e7534 | https://github.com/loadimpact/k6/blob/03645ba7059a4ca9eb22035f5adb52f1a91e7534/samples/pantheon.js#L194-L209 |
5,803 | loadimpact/k6 | samples/pantheon.js | doLogout | function doLogout() {
check(http.get(baseURL + "/user/logout"), {
"logout succeeded": (res) => res.body.includes('<a href="/user/login">Log in')
}) || fail("logout failed");
} | javascript | function doLogout() {
check(http.get(baseURL + "/user/logout"), {
"logout succeeded": (res) => res.body.includes('<a href="/user/login">Log in')
}) || fail("logout failed");
} | [
"function",
"doLogout",
"(",
")",
"{",
"check",
"(",
"http",
".",
"get",
"(",
"baseURL",
"+",
"\"/user/logout\"",
")",
",",
"{",
"\"logout succeeded\"",
":",
"(",
"res",
")",
"=>",
"res",
".",
"body",
".",
"includes",
"(",
"'<a href=\"/user/login\">Log in'",... | Log out the user | [
"Log",
"out",
"the",
"user"
] | 03645ba7059a4ca9eb22035f5adb52f1a91e7534 | https://github.com/loadimpact/k6/blob/03645ba7059a4ca9eb22035f5adb52f1a91e7534/samples/pantheon.js#L321-L325 |
5,804 | immutable-js/immutable-js | src/Hash.js | hashNumber | function hashNumber(n) {
if (n !== n || n === Infinity) {
return 0;
}
let hash = n | 0;
if (hash !== n) {
hash ^= n * 0xffffffff;
}
while (n > 0xffffffff) {
n /= 0xffffffff;
hash ^= n;
}
return smi(hash);
} | javascript | function hashNumber(n) {
if (n !== n || n === Infinity) {
return 0;
}
let hash = n | 0;
if (hash !== n) {
hash ^= n * 0xffffffff;
}
while (n > 0xffffffff) {
n /= 0xffffffff;
hash ^= n;
}
return smi(hash);
} | [
"function",
"hashNumber",
"(",
"n",
")",
"{",
"if",
"(",
"n",
"!==",
"n",
"||",
"n",
"===",
"Infinity",
")",
"{",
"return",
"0",
";",
"}",
"let",
"hash",
"=",
"n",
"|",
"0",
";",
"if",
"(",
"hash",
"!==",
"n",
")",
"{",
"hash",
"^=",
"n",
"... | Compress arbitrarily large numbers into smi hashes. | [
"Compress",
"arbitrarily",
"large",
"numbers",
"into",
"smi",
"hashes",
"."
] | 751082fd0d392f14f7fa567d5fad6edd8f94bd79 | https://github.com/immutable-js/immutable-js/blob/751082fd0d392f14f7fa567d5fad6edd8f94bd79/src/Hash.js#L49-L62 |
5,805 | immutable-js/immutable-js | src/Hash.js | getIENodeHash | function getIENodeHash(node) {
if (node && node.nodeType > 0) {
switch (node.nodeType) {
case 1: // Element
return node.uniqueID;
case 9: // Document
return node.documentElement && node.documentElement.uniqueID;
}
}
} | javascript | function getIENodeHash(node) {
if (node && node.nodeType > 0) {
switch (node.nodeType) {
case 1: // Element
return node.uniqueID;
case 9: // Document
return node.documentElement && node.documentElement.uniqueID;
}
}
} | [
"function",
"getIENodeHash",
"(",
"node",
")",
"{",
"if",
"(",
"node",
"&&",
"node",
".",
"nodeType",
">",
"0",
")",
"{",
"switch",
"(",
"node",
".",
"nodeType",
")",
"{",
"case",
"1",
":",
"// Element",
"return",
"node",
".",
"uniqueID",
";",
"case"... | IE has a `uniqueID` property on DOM nodes. We can construct the hash from it and avoid memory leaks from the IE cloneNode bug. | [
"IE",
"has",
"a",
"uniqueID",
"property",
"on",
"DOM",
"nodes",
".",
"We",
"can",
"construct",
"the",
"hash",
"from",
"it",
"and",
"avoid",
"memory",
"leaks",
"from",
"the",
"IE",
"cloneNode",
"bug",
"."
] | 751082fd0d392f14f7fa567d5fad6edd8f94bd79 | https://github.com/immutable-js/immutable-js/blob/751082fd0d392f14f7fa567d5fad6edd8f94bd79/src/Hash.js#L178-L187 |
5,806 | immutable-js/immutable-js | pages/src/docs/src/TypeDocumentation.js | getTypePropMap | function getTypePropMap(def) {
var map = {};
def &&
def.extends &&
def.extends.forEach(e => {
var superModule = defs.Immutable;
e.name.split('.').forEach(part => {
superModule =
superModule && superModule.module && superModule.module[part];
});
var superInterface = ... | javascript | function getTypePropMap(def) {
var map = {};
def &&
def.extends &&
def.extends.forEach(e => {
var superModule = defs.Immutable;
e.name.split('.').forEach(part => {
superModule =
superModule && superModule.module && superModule.module[part];
});
var superInterface = ... | [
"function",
"getTypePropMap",
"(",
"def",
")",
"{",
"var",
"map",
"=",
"{",
"}",
";",
"def",
"&&",
"def",
".",
"extends",
"&&",
"def",
".",
"extends",
".",
"forEach",
"(",
"e",
"=>",
"{",
"var",
"superModule",
"=",
"defs",
".",
"Immutable",
";",
"e... | Get a map from super type parameter to concrete type definition. This is
used when rendering inherited type definitions to ensure contextually
relevant information.
Example:
type A<T> implements B<number, T>
type B<K, V> implements C<K, V, V>
type C<X, Y, Z>
parse C:
{}
parse B:
{ C<X: K
C<Y: V
C<Z: V }
parse A:
{... | [
"Get",
"a",
"map",
"from",
"super",
"type",
"parameter",
"to",
"concrete",
"type",
"definition",
".",
"This",
"is",
"used",
"when",
"rendering",
"inherited",
"type",
"definitions",
"to",
"ensure",
"contextually",
"relevant",
"information",
"."
] | 751082fd0d392f14f7fa567d5fad6edd8f94bd79 | https://github.com/immutable-js/immutable-js/blob/751082fd0d392f14f7fa567d5fad6edd8f94bd79/pages/src/docs/src/TypeDocumentation.js#L303-L330 |
5,807 | szimek/signature_pad | docs/js/app.js | resizeCanvas | function resizeCanvas() {
// When zoomed out to less than 100%, for some very strange reason,
// some browsers report devicePixelRatio as less than 1
// and only part of the canvas is cleared then.
var ratio = Math.max(window.devicePixelRatio || 1, 1);
// This part causes the canvas to be cleared
canvas.w... | javascript | function resizeCanvas() {
// When zoomed out to less than 100%, for some very strange reason,
// some browsers report devicePixelRatio as less than 1
// and only part of the canvas is cleared then.
var ratio = Math.max(window.devicePixelRatio || 1, 1);
// This part causes the canvas to be cleared
canvas.w... | [
"function",
"resizeCanvas",
"(",
")",
"{",
"// When zoomed out to less than 100%, for some very strange reason,",
"// some browsers report devicePixelRatio as less than 1",
"// and only part of the canvas is cleared then.",
"var",
"ratio",
"=",
"Math",
".",
"max",
"(",
"window",
".",... | Adjust canvas coordinate space taking into account pixel ratio, to make it look crisp on mobile devices. This also causes canvas to be cleared. | [
"Adjust",
"canvas",
"coordinate",
"space",
"taking",
"into",
"account",
"pixel",
"ratio",
"to",
"make",
"it",
"look",
"crisp",
"on",
"mobile",
"devices",
".",
"This",
"also",
"causes",
"canvas",
"to",
"be",
"cleared",
"."
] | 028b538179ac1a56b190fb40b39821b8c39145b7 | https://github.com/szimek/signature_pad/blob/028b538179ac1a56b190fb40b39821b8c39145b7/docs/js/app.js#L18-L35 |
5,808 | react-native-community/cli | packages/platform-ios/src/commands/logIOS/index.js | logIOS | async function logIOS() {
const rawDevices = execFileSync(
'xcrun',
['simctl', 'list', 'devices', '--json'],
{encoding: 'utf8'},
);
const {devices} = JSON.parse(rawDevices);
const device = findAvailableDevice(devices);
if (device === undefined) {
logger.error('No active iOS device found');
... | javascript | async function logIOS() {
const rawDevices = execFileSync(
'xcrun',
['simctl', 'list', 'devices', '--json'],
{encoding: 'utf8'},
);
const {devices} = JSON.parse(rawDevices);
const device = findAvailableDevice(devices);
if (device === undefined) {
logger.error('No active iOS device found');
... | [
"async",
"function",
"logIOS",
"(",
")",
"{",
"const",
"rawDevices",
"=",
"execFileSync",
"(",
"'xcrun'",
",",
"[",
"'simctl'",
",",
"'list'",
",",
"'devices'",
",",
"'--json'",
"]",
",",
"{",
"encoding",
":",
"'utf8'",
"}",
",",
")",
";",
"const",
"{"... | Starts iOS device syslog tail | [
"Starts",
"iOS",
"device",
"syslog",
"tail"
] | c3ed10c0e2d5c7bfe68312093347fbf7e61aa7a7 | https://github.com/react-native-community/cli/blob/c3ed10c0e2d5c7bfe68312093347fbf7e61aa7a7/packages/platform-ios/src/commands/logIOS/index.js#L29-L45 |
5,809 | react-native-community/cli | packages/cli/src/cliEntry.js | printHelpInformation | function printHelpInformation(examples, pkg) {
let cmdName = this._name;
if (this._alias) {
cmdName = `${cmdName}|${this._alias}`;
}
const sourceInformation = pkg
? [`${chalk.bold('Source:')} ${pkg.name}@${pkg.version}`, '']
: [];
let output = [
chalk.bold(`react-native ${cmdName}`),
thi... | javascript | function printHelpInformation(examples, pkg) {
let cmdName = this._name;
if (this._alias) {
cmdName = `${cmdName}|${this._alias}`;
}
const sourceInformation = pkg
? [`${chalk.bold('Source:')} ${pkg.name}@${pkg.version}`, '']
: [];
let output = [
chalk.bold(`react-native ${cmdName}`),
thi... | [
"function",
"printHelpInformation",
"(",
"examples",
",",
"pkg",
")",
"{",
"let",
"cmdName",
"=",
"this",
".",
"_name",
";",
"if",
"(",
"this",
".",
"_alias",
")",
"{",
"cmdName",
"=",
"`",
"${",
"cmdName",
"}",
"${",
"this",
".",
"_alias",
"}",
"`",... | Custom printHelpInformation command inspired by internal Commander.js one modified to suit our needs | [
"Custom",
"printHelpInformation",
"command",
"inspired",
"by",
"internal",
"Commander",
".",
"js",
"one",
"modified",
"to",
"suit",
"our",
"needs"
] | c3ed10c0e2d5c7bfe68312093347fbf7e61aa7a7 | https://github.com/react-native-community/cli/blob/c3ed10c0e2d5c7bfe68312093347fbf7e61aa7a7/packages/cli/src/cliEntry.js#L56-L83 |
5,810 | react-native-community/cli | packages/cli/src/tools/copyFiles.js | copyBinaryFile | function copyBinaryFile(srcPath, destPath, cb) {
let cbCalled = false;
// const {mode} = fs.statSync(srcPath);
const readStream = fs.createReadStream(srcPath);
const writeStream = fs.createWriteStream(destPath);
readStream.on('error', err => {
done(err);
});
writeStream.on('error', err => {
done(e... | javascript | function copyBinaryFile(srcPath, destPath, cb) {
let cbCalled = false;
// const {mode} = fs.statSync(srcPath);
const readStream = fs.createReadStream(srcPath);
const writeStream = fs.createWriteStream(destPath);
readStream.on('error', err => {
done(err);
});
writeStream.on('error', err => {
done(e... | [
"function",
"copyBinaryFile",
"(",
"srcPath",
",",
"destPath",
",",
"cb",
")",
"{",
"let",
"cbCalled",
"=",
"false",
";",
"// const {mode} = fs.statSync(srcPath);",
"const",
"readStream",
"=",
"fs",
".",
"createReadStream",
"(",
"srcPath",
")",
";",
"const",
"wr... | Same as 'cp' on Unix. Don't do any replacements. | [
"Same",
"as",
"cp",
"on",
"Unix",
".",
"Don",
"t",
"do",
"any",
"replacements",
"."
] | c3ed10c0e2d5c7bfe68312093347fbf7e61aa7a7 | https://github.com/react-native-community/cli/blob/c3ed10c0e2d5c7bfe68312093347fbf7e61aa7a7/packages/cli/src/tools/copyFiles.js#L54-L79 |
5,811 | react-native-community/cli | packages/cli/src/commands/server/copyToClipBoard.js | copyToClipBoard | function copyToClipBoard(content) {
switch (process.platform) {
case 'darwin': {
const child = spawn('pbcopy', []);
child.stdin.end(Buffer.from(content, 'utf8'));
return true;
}
case 'win32': {
const child = spawn('clip', []);
child.stdin.end(Buffer.from(content, 'utf8'));
... | javascript | function copyToClipBoard(content) {
switch (process.platform) {
case 'darwin': {
const child = spawn('pbcopy', []);
child.stdin.end(Buffer.from(content, 'utf8'));
return true;
}
case 'win32': {
const child = spawn('clip', []);
child.stdin.end(Buffer.from(content, 'utf8'));
... | [
"function",
"copyToClipBoard",
"(",
"content",
")",
"{",
"switch",
"(",
"process",
".",
"platform",
")",
"{",
"case",
"'darwin'",
":",
"{",
"const",
"child",
"=",
"spawn",
"(",
"'pbcopy'",
",",
"[",
"]",
")",
";",
"child",
".",
"stdin",
".",
"end",
"... | Copy the content to host system clipboard. | [
"Copy",
"the",
"content",
"to",
"host",
"system",
"clipboard",
"."
] | c3ed10c0e2d5c7bfe68312093347fbf7e61aa7a7 | https://github.com/react-native-community/cli/blob/c3ed10c0e2d5c7bfe68312093347fbf7e61aa7a7/packages/cli/src/commands/server/copyToClipBoard.js#L21-L41 |
5,812 | react-native-community/cli | packages/cli/src/commands/upgrade/legacyUpgrade.js | upgradeProjectFiles | function upgradeProjectFiles(projectDir, projectName) {
// Just overwrite
copyProjectTemplateAndReplace(
path.dirname(require.resolve('react-native/template')),
projectDir,
projectName,
{upgrade: true},
);
} | javascript | function upgradeProjectFiles(projectDir, projectName) {
// Just overwrite
copyProjectTemplateAndReplace(
path.dirname(require.resolve('react-native/template')),
projectDir,
projectName,
{upgrade: true},
);
} | [
"function",
"upgradeProjectFiles",
"(",
"projectDir",
",",
"projectName",
")",
"{",
"// Just overwrite",
"copyProjectTemplateAndReplace",
"(",
"path",
".",
"dirname",
"(",
"require",
".",
"resolve",
"(",
"'react-native/template'",
")",
")",
",",
"projectDir",
",",
"... | Once all checks passed, upgrade the project files. | [
"Once",
"all",
"checks",
"passed",
"upgrade",
"the",
"project",
"files",
"."
] | c3ed10c0e2d5c7bfe68312093347fbf7e61aa7a7 | https://github.com/react-native-community/cli/blob/c3ed10c0e2d5c7bfe68312093347fbf7e61aa7a7/packages/cli/src/commands/upgrade/legacyUpgrade.js#L132-L140 |
5,813 | gnab/remark | src/remark/components/styler/styler.js | styleDocument | function styleDocument () {
var headElement, styleElement, style;
// Bail out if document has already been styled
if (getRemarkStylesheet()) {
return;
}
headElement = document.getElementsByTagName('head')[0];
styleElement = document.createElement('style');
styleElement.type = 'text/css';
// Set t... | javascript | function styleDocument () {
var headElement, styleElement, style;
// Bail out if document has already been styled
if (getRemarkStylesheet()) {
return;
}
headElement = document.getElementsByTagName('head')[0];
styleElement = document.createElement('style');
styleElement.type = 'text/css';
// Set t... | [
"function",
"styleDocument",
"(",
")",
"{",
"var",
"headElement",
",",
"styleElement",
",",
"style",
";",
"// Bail out if document has already been styled",
"if",
"(",
"getRemarkStylesheet",
"(",
")",
")",
"{",
"return",
";",
"}",
"headElement",
"=",
"document",
"... | Applies bundled styles to document | [
"Applies",
"bundled",
"styles",
"to",
"document"
] | 4432b423e38ca7537bf834880b3fa1cdaea5f8a7 | https://github.com/gnab/remark/blob/4432b423e38ca7537bf834880b3fa1cdaea5f8a7/src/remark/components/styler/styler.js#L11-L39 |
5,814 | gnab/remark | src/remark/components/styler/styler.js | getRemarkStylesheet | function getRemarkStylesheet () {
var i, l = document.styleSheets.length;
for (i = 0; i < l; ++i) {
if (document.styleSheets[i].title === 'remark') {
return document.styleSheets[i];
}
}
} | javascript | function getRemarkStylesheet () {
var i, l = document.styleSheets.length;
for (i = 0; i < l; ++i) {
if (document.styleSheets[i].title === 'remark') {
return document.styleSheets[i];
}
}
} | [
"function",
"getRemarkStylesheet",
"(",
")",
"{",
"var",
"i",
",",
"l",
"=",
"document",
".",
"styleSheets",
".",
"length",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"l",
";",
"++",
"i",
")",
"{",
"if",
"(",
"document",
".",
"styleSheets",
"... | Locates the embedded remark stylesheet | [
"Locates",
"the",
"embedded",
"remark",
"stylesheet"
] | 4432b423e38ca7537bf834880b3fa1cdaea5f8a7 | https://github.com/gnab/remark/blob/4432b423e38ca7537bf834880b3fa1cdaea5f8a7/src/remark/components/styler/styler.js#L50-L58 |
5,815 | gnab/remark | src/remark/components/styler/styler.js | getPageRule | function getPageRule (stylesheet) {
var i, l = stylesheet.cssRules.length;
for (i = 0; i < l; ++i) {
if (stylesheet.cssRules[i] instanceof window.CSSPageRule) {
return stylesheet.cssRules[i];
}
}
} | javascript | function getPageRule (stylesheet) {
var i, l = stylesheet.cssRules.length;
for (i = 0; i < l; ++i) {
if (stylesheet.cssRules[i] instanceof window.CSSPageRule) {
return stylesheet.cssRules[i];
}
}
} | [
"function",
"getPageRule",
"(",
"stylesheet",
")",
"{",
"var",
"i",
",",
"l",
"=",
"stylesheet",
".",
"cssRules",
".",
"length",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"l",
";",
"++",
"i",
")",
"{",
"if",
"(",
"stylesheet",
".",
"cssRules... | Locates the CSS @page rule | [
"Locates",
"the",
"CSS"
] | 4432b423e38ca7537bf834880b3fa1cdaea5f8a7 | https://github.com/gnab/remark/blob/4432b423e38ca7537bf834880b3fa1cdaea5f8a7/src/remark/components/styler/styler.js#L61-L69 |
5,816 | dabeng/OrgChart | dist/js/jquery.orgchart.js | function ($node, relation) {
if (!$node || !($node instanceof $) || !$node.is('.node')) {
return $();
}
if (relation === 'parent') {
return $node.closest('.nodes').parent().children(':first').find('.node');
} else if (relation === 'children') {
return $node.closest('tr').... | javascript | function ($node, relation) {
if (!$node || !($node instanceof $) || !$node.is('.node')) {
return $();
}
if (relation === 'parent') {
return $node.closest('.nodes').parent().children(':first').find('.node');
} else if (relation === 'children') {
return $node.closest('tr').... | [
"function",
"(",
"$node",
",",
"relation",
")",
"{",
"if",
"(",
"!",
"$node",
"||",
"!",
"(",
"$node",
"instanceof",
"$",
")",
"||",
"!",
"$node",
".",
"is",
"(",
"'.node'",
")",
")",
"{",
"return",
"$",
"(",
")",
";",
"}",
"if",
"(",
"relation... | find the related nodes | [
"find",
"the",
"related",
"nodes"
] | 188a8e4ba6dd0979588474765edb01891d85a38d | https://github.com/dabeng/OrgChart/blob/188a8e4ba6dd0979588474765edb01891d85a38d/dist/js/jquery.orgchart.js#L443-L456 | |
5,817 | dabeng/OrgChart | dist/js/jquery.orgchart.js | function ($node) {
var $upperLevel = $node.closest('.nodes').siblings();
if ($upperLevel.eq(0).find('.spinner').length) {
$node.closest('.orgchart').data('inAjax', false);
}
// hide the sibling nodes
if (this.getNodeState($node, 'siblings').visible) {
this.hideSiblings($nod... | javascript | function ($node) {
var $upperLevel = $node.closest('.nodes').siblings();
if ($upperLevel.eq(0).find('.spinner').length) {
$node.closest('.orgchart').data('inAjax', false);
}
// hide the sibling nodes
if (this.getNodeState($node, 'siblings').visible) {
this.hideSiblings($nod... | [
"function",
"(",
"$node",
")",
"{",
"var",
"$upperLevel",
"=",
"$node",
".",
"closest",
"(",
"'.nodes'",
")",
".",
"siblings",
"(",
")",
";",
"if",
"(",
"$upperLevel",
".",
"eq",
"(",
"0",
")",
".",
"find",
"(",
"'.spinner'",
")",
".",
"length",
")... | recursively hide the ancestor node and sibling nodes of the specified node | [
"recursively",
"hide",
"the",
"ancestor",
"node",
"and",
"sibling",
"nodes",
"of",
"the",
"specified",
"node"
] | 188a8e4ba6dd0979588474765edb01891d85a38d | https://github.com/dabeng/OrgChart/blob/188a8e4ba6dd0979588474765edb01891d85a38d/dist/js/jquery.orgchart.js#L462-L483 | |
5,818 | dabeng/OrgChart | dist/js/jquery.orgchart.js | function ($node) {
// just show only one superior level
var $upperLevel = $node.closest('.nodes').siblings().removeClass('hidden');
// just show only one line
$upperLevel.eq(2).children().slice(1, -1).addClass('hidden');
// show parent node with animation
var $parent = $upperLevel.eq... | javascript | function ($node) {
// just show only one superior level
var $upperLevel = $node.closest('.nodes').siblings().removeClass('hidden');
// just show only one line
$upperLevel.eq(2).children().slice(1, -1).addClass('hidden');
// show parent node with animation
var $parent = $upperLevel.eq... | [
"function",
"(",
"$node",
")",
"{",
"// just show only one superior level",
"var",
"$upperLevel",
"=",
"$node",
".",
"closest",
"(",
"'.nodes'",
")",
".",
"siblings",
"(",
")",
".",
"removeClass",
"(",
"'hidden'",
")",
";",
"// just show only one line",
"$upperLev... | show the parent node of the specified node | [
"show",
"the",
"parent",
"node",
"of",
"the",
"specified",
"node"
] | 188a8e4ba6dd0979588474765edb01891d85a38d | https://github.com/dabeng/OrgChart/blob/188a8e4ba6dd0979588474765edb01891d85a38d/dist/js/jquery.orgchart.js#L492-L501 | |
5,819 | 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 | |
5,820 | 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 | |
5,821 | 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 | |
5,822 | 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 | |
5,823 | 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 | |
5,824 | 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 | |
5,825 | 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 | |
5,826 | 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 | |
5,827 | 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 | |
5,828 | 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 | |
5,829 | 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 | |
5,830 | 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 | |
5,831 | 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 |
5,832 | 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 |
5,833 | 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 |
5,834 | 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 |
5,835 | 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 |
5,836 | 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 |
5,837 | 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 |
5,838 | 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 |
5,839 | 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 |
5,840 | 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 |
5,841 | 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 |
5,842 | 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 |
5,843 | 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 | |
5,844 | 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 |
5,845 | 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 |
5,846 | 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 |
5,847 | 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 |
5,848 | 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 | |
5,849 | 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 | |
5,850 | 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 | |
5,851 | 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 | |
5,852 | 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 | |
5,853 | 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 | |
5,854 | 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 | |
5,855 | 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 | |
5,856 | 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 |
5,857 | 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 |
5,858 | 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 |
5,859 | 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 |
5,860 | 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 |
5,861 | 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 |
5,862 | 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 | |
5,863 | 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 | |
5,864 | 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 | |
5,865 | 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 | |
5,866 | 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 | |
5,867 | 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 | |
5,868 | 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 | |
5,869 | 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 | |
5,870 | 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 | |
5,871 | 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 |
5,872 | 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 |
5,873 | 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 |
5,874 | 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 |
5,875 | 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 |
5,876 | 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 |
5,877 | 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 |
5,878 | 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 |
5,879 | 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 |
5,880 | 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 |
5,881 | 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 |
5,882 | 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 |
5,883 | 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 |
5,884 | 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 |
5,885 | 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 |
5,886 | 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 |
5,887 | 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 |
5,888 | 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 | |
5,889 | 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 | |
5,890 | 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 | |
5,891 | 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 | |
5,892 | 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 | |
5,893 | 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 | |
5,894 | 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 | |
5,895 | 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 | |
5,896 | 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 | |
5,897 | 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 | |
5,898 | 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 | |
5,899 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.