repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
list | docstring
stringlengths 4
11.8k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 86
226
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
burnnat/grunt-debug | tasks/debug.js | function(name, brk, debugChildren) {
var deferred = Q.defer();
var args = process.argv;
grunt.task.clearQueue();
var tasks = args.slice(args.indexOf(name) + 1);
if (debugChildren) {
tasks.unshift('debug:hook' + (brk ? '-break' : ''));
}
var child = child_process.fork(
args[1],
tasks,
{
execArgv: [
brk
? '--debug-brk'
: '--debug'
]
}
);
child.on('exit', function(code) {
if (code == 0) {
deferred.resolve();
}
else {
deferred.reject(code);
}
});
return deferred.promise;
} | javascript | function(name, brk, debugChildren) {
var deferred = Q.defer();
var args = process.argv;
grunt.task.clearQueue();
var tasks = args.slice(args.indexOf(name) + 1);
if (debugChildren) {
tasks.unshift('debug:hook' + (brk ? '-break' : ''));
}
var child = child_process.fork(
args[1],
tasks,
{
execArgv: [
brk
? '--debug-brk'
: '--debug'
]
}
);
child.on('exit', function(code) {
if (code == 0) {
deferred.resolve();
}
else {
deferred.reject(code);
}
});
return deferred.promise;
} | [
"function",
"(",
"name",
",",
"brk",
",",
"debugChildren",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"var",
"args",
"=",
"process",
".",
"argv",
";",
"grunt",
".",
"task",
".",
"clearQueue",
"(",
")",
";",
"var",
"tasks",
"=",
"args",
".",
"slice",
"(",
"args",
".",
"indexOf",
"(",
"name",
")",
"+",
"1",
")",
";",
"if",
"(",
"debugChildren",
")",
"{",
"tasks",
".",
"unshift",
"(",
"'debug:hook'",
"+",
"(",
"brk",
"?",
"'-break'",
":",
"''",
")",
")",
";",
"}",
"var",
"child",
"=",
"child_process",
".",
"fork",
"(",
"args",
"[",
"1",
"]",
",",
"tasks",
",",
"{",
"execArgv",
":",
"[",
"brk",
"?",
"'--debug-brk'",
":",
"'--debug'",
"]",
"}",
")",
";",
"child",
".",
"on",
"(",
"'exit'",
",",
"function",
"(",
"code",
")",
"{",
"if",
"(",
"code",
"==",
"0",
")",
"{",
"deferred",
".",
"resolve",
"(",
")",
";",
"}",
"else",
"{",
"deferred",
".",
"reject",
"(",
"code",
")",
";",
"}",
"}",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}"
]
| Manually forks the Grunt process for debugging | [
"Manually",
"forks",
"the",
"Grunt",
"process",
"for",
"debugging"
]
| 968fefb5c99621752bc8b81d0fe865c1f90b8eb0 | https://github.com/burnnat/grunt-debug/blob/968fefb5c99621752bc8b81d0fe865c1f90b8eb0/tasks/debug.js#L17-L51 | train |
|
burnnat/grunt-debug | tasks/debug.js | function() {
var pid = process.pid;
return Q.fcall(function() {
if (process.platform === 'win32') {
process._debugProcess(pid);
}
else {
process.kill(pid, 'SIGUSR1');
}
});
} | javascript | function() {
var pid = process.pid;
return Q.fcall(function() {
if (process.platform === 'win32') {
process._debugProcess(pid);
}
else {
process.kill(pid, 'SIGUSR1');
}
});
} | [
"function",
"(",
")",
"{",
"var",
"pid",
"=",
"process",
".",
"pid",
";",
"return",
"Q",
".",
"fcall",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"process",
".",
"platform",
"===",
"'win32'",
")",
"{",
"process",
".",
"_debugProcess",
"(",
"pid",
")",
";",
"}",
"else",
"{",
"process",
".",
"kill",
"(",
"pid",
",",
"'SIGUSR1'",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Sets up existing Grunt process for debugging | [
"Sets",
"up",
"existing",
"Grunt",
"process",
"for",
"debugging"
]
| 968fefb5c99621752bc8b81d0fe865c1f90b8eb0 | https://github.com/burnnat/grunt-debug/blob/968fefb5c99621752bc8b81d0fe865c1f90b8eb0/tasks/debug.js#L56-L67 | train |
|
burnnat/grunt-debug | tasks/debug.js | function(brk) {
hooks.enableHooks(
brk,
function(module, port) {
grunt.log.ok('Debugging forked process %s on port %d', module, port);
}
);
} | javascript | function(brk) {
hooks.enableHooks(
brk,
function(module, port) {
grunt.log.ok('Debugging forked process %s on port %d', module, port);
}
);
} | [
"function",
"(",
"brk",
")",
"{",
"hooks",
".",
"enableHooks",
"(",
"brk",
",",
"function",
"(",
"module",
",",
"port",
")",
"{",
"grunt",
".",
"log",
".",
"ok",
"(",
"'Debugging forked process %s on port %d'",
",",
"module",
",",
"port",
")",
";",
"}",
")",
";",
"}"
]
| Enabled debugging hooks for child processes | [
"Enabled",
"debugging",
"hooks",
"for",
"child",
"processes"
]
| 968fefb5c99621752bc8b81d0fe865c1f90b8eb0 | https://github.com/burnnat/grunt-debug/blob/968fefb5c99621752bc8b81d0fe865c1f90b8eb0/tasks/debug.js#L72-L79 | train |
|
wearefractal/warlock | warlock.js | Transport | function Transport (opts) {
this.path = opts.path;
this.host = opts.host;
this.port = opts.port;
this.secure = opts.secure;
this.query = opts.query;
this.timestampParam = opts.timestampParam;
this.timestampRequests = opts.timestampRequests;
this.readyState = '';
} | javascript | function Transport (opts) {
this.path = opts.path;
this.host = opts.host;
this.port = opts.port;
this.secure = opts.secure;
this.query = opts.query;
this.timestampParam = opts.timestampParam;
this.timestampRequests = opts.timestampRequests;
this.readyState = '';
} | [
"function",
"Transport",
"(",
"opts",
")",
"{",
"this",
".",
"path",
"=",
"opts",
".",
"path",
";",
"this",
".",
"host",
"=",
"opts",
".",
"host",
";",
"this",
".",
"port",
"=",
"opts",
".",
"port",
";",
"this",
".",
"secure",
"=",
"opts",
".",
"secure",
";",
"this",
".",
"query",
"=",
"opts",
".",
"query",
";",
"this",
".",
"timestampParam",
"=",
"opts",
".",
"timestampParam",
";",
"this",
".",
"timestampRequests",
"=",
"opts",
".",
"timestampRequests",
";",
"this",
".",
"readyState",
"=",
"''",
";",
"}"
]
| Transport abstract constructor.
@param {Object} options.
@api private | [
"Transport",
"abstract",
"constructor",
"."
]
| de4a9ad1d030f3cdf1dc5c4560c7653c50ce3cde | https://github.com/wearefractal/warlock/blob/de4a9ad1d030f3cdf1dc5c4560c7653c50ce3cde/warlock.js#L906-L915 | train |
wearefractal/warlock | warlock.js | create | function create (path, fn) {
if (scripts[path]) return fn();
var el = document.createElement('script');
var loaded = false;
// debug: loading "%s", path
el.onload = el.onreadystatechange = function () {
if (loaded || scripts[path]) return;
var rs = el.readyState;
if (!rs || 'loaded' == rs || 'complete' == rs) {
// debug: loaded "%s", path
el.onload = el.onreadystatechange = null;
loaded = true;
scripts[path] = true;
fn();
}
};
el.async = 1;
el.src = path;
var head = document.getElementsByTagName('head')[0];
head.insertBefore(el, head.firstChild);
} | javascript | function create (path, fn) {
if (scripts[path]) return fn();
var el = document.createElement('script');
var loaded = false;
// debug: loading "%s", path
el.onload = el.onreadystatechange = function () {
if (loaded || scripts[path]) return;
var rs = el.readyState;
if (!rs || 'loaded' == rs || 'complete' == rs) {
// debug: loaded "%s", path
el.onload = el.onreadystatechange = null;
loaded = true;
scripts[path] = true;
fn();
}
};
el.async = 1;
el.src = path;
var head = document.getElementsByTagName('head')[0];
head.insertBefore(el, head.firstChild);
} | [
"function",
"create",
"(",
"path",
",",
"fn",
")",
"{",
"if",
"(",
"scripts",
"[",
"path",
"]",
")",
"return",
"fn",
"(",
")",
";",
"var",
"el",
"=",
"document",
".",
"createElement",
"(",
"'script'",
")",
";",
"var",
"loaded",
"=",
"false",
";",
"el",
".",
"onload",
"=",
"el",
".",
"onreadystatechange",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"loaded",
"||",
"scripts",
"[",
"path",
"]",
")",
"return",
";",
"var",
"rs",
"=",
"el",
".",
"readyState",
";",
"if",
"(",
"!",
"rs",
"||",
"'loaded'",
"==",
"rs",
"||",
"'complete'",
"==",
"rs",
")",
"{",
"el",
".",
"onload",
"=",
"el",
".",
"onreadystatechange",
"=",
"null",
";",
"loaded",
"=",
"true",
";",
"scripts",
"[",
"path",
"]",
"=",
"true",
";",
"fn",
"(",
")",
";",
"}",
"}",
";",
"el",
".",
"async",
"=",
"1",
";",
"el",
".",
"src",
"=",
"path",
";",
"var",
"head",
"=",
"document",
".",
"getElementsByTagName",
"(",
"'head'",
")",
"[",
"0",
"]",
";",
"head",
".",
"insertBefore",
"(",
"el",
",",
"head",
".",
"firstChild",
")",
";",
"}"
]
| Injects a script. Keeps tracked of injected ones.
@param {String} path
@param {Function} callback
@api private | [
"Injects",
"a",
"script",
".",
"Keeps",
"tracked",
"of",
"injected",
"ones",
"."
]
| de4a9ad1d030f3cdf1dc5c4560c7653c50ce3cde | https://github.com/wearefractal/warlock/blob/de4a9ad1d030f3cdf1dc5c4560c7653c50ce3cde/warlock.js#L1237-L1261 | train |
express-bem/express-bem | lib/index.js | initVar | function initVar (key, envKey, def) {
var negate = !def;
switch (true) {
case cacheObj.hasOwnProperty(key):
return cacheObj[key];
case process.env.hasOwnProperty(envGlobalCacheKey):
return process.env[envGlobalCacheKey] !== '';
case process.env.hasOwnProperty(envKey):
return negate ? process.env[envKey] === 'YES' : process.env[envKey] !== 'NO';
default:
return def;
}
} | javascript | function initVar (key, envKey, def) {
var negate = !def;
switch (true) {
case cacheObj.hasOwnProperty(key):
return cacheObj[key];
case process.env.hasOwnProperty(envGlobalCacheKey):
return process.env[envGlobalCacheKey] !== '';
case process.env.hasOwnProperty(envKey):
return negate ? process.env[envKey] === 'YES' : process.env[envKey] !== 'NO';
default:
return def;
}
} | [
"function",
"initVar",
"(",
"key",
",",
"envKey",
",",
"def",
")",
"{",
"var",
"negate",
"=",
"!",
"def",
";",
"switch",
"(",
"true",
")",
"{",
"case",
"cacheObj",
".",
"hasOwnProperty",
"(",
"key",
")",
":",
"return",
"cacheObj",
"[",
"key",
"]",
";",
"case",
"process",
".",
"env",
".",
"hasOwnProperty",
"(",
"envGlobalCacheKey",
")",
":",
"return",
"process",
".",
"env",
"[",
"envGlobalCacheKey",
"]",
"!==",
"''",
";",
"case",
"process",
".",
"env",
".",
"hasOwnProperty",
"(",
"envKey",
")",
":",
"return",
"negate",
"?",
"process",
".",
"env",
"[",
"envKey",
"]",
"===",
"'YES'",
":",
"process",
".",
"env",
"[",
"envKey",
"]",
"!==",
"'NO'",
";",
"default",
":",
"return",
"def",
";",
"}",
"}"
]
| cache variable initializer
@param {String} key
@param {String} envKey
@param {Boolean} def
@returns {Boolean} | [
"cache",
"variable",
"initializer"
]
| 6ea49e5ecdd8e949dd5051ecc5762e40cbcead9c | https://github.com/express-bem/express-bem/blob/6ea49e5ecdd8e949dd5051ecc5762e40cbcead9c/lib/index.js#L213-L225 | train |
CodingKoopa/eslint-plugin-more-naming-conventions | Source/Rules/UpperCamelCase.js | function(node)
{
// declarations is an array of the comma-separated variable declarations like "var foo, zerp;"
node.declarations.forEach(declaration =>
{
// id contains info about the variable being declare.
var variable_name = declaration.id.name;
// Skip if the variable is already whitelisted.
if (variable_whitelist.indexOf(variable_name) > -1)
return;
// init contains info about the value being initialized to. It is null when the variable is
// being declared without being initialized.
// If initialization type is "CallExpression", that means that the variable is being
// initialized to a function.
// init.callee contains info about the function that the value is being initialized to,
// undefined if it's not being initialized to a function, or at all.
// So, this filters down into variables being initialized to the "require" function.
if (declaration.init && declaration.init.type === `CallExpression` &&
declaration.init.callee.name === `require`)
{
var module_name;
// init.arguments is an array of the arguments being passed to the callee, undefinied if
// the variable isn't being initialized to a function, or at all. Unlike the declarations,
// we won't iterate over this because we only care about the first argument.
if (declaration.init.arguments[0].type === `TemplateLiteral`)
// The quasis array is a bit weird. Parsed template literals have them, and the number
// of elements is equal to the number of placeholders, plus one for the non-placeholder
// section. However, the values of the placeholder sections are always empty, so I'm
// not sure what purpose they serve.
// This takes the cooked non-placeholder portion as-is.
module_name = declaration.init.arguments[0].quasis[0].value.cooked;
else if (declaration.init.arguments[0].type === `Literal`)
// Literals are easy. The value is right there.
module_name = declaration.init.arguments[0].value;
else
// Something other than `, ', or "? ¯\_(ツ)_/¯
return;
// Detect if the module is being included via a path. This means that it is a part of the
// project, and not from an external dependency. This means that it's alright to correct
// the case in it.
if (module_name.includes(`/`))
variable_whitelist.push(variable_name);
}
});
} | javascript | function(node)
{
// declarations is an array of the comma-separated variable declarations like "var foo, zerp;"
node.declarations.forEach(declaration =>
{
// id contains info about the variable being declare.
var variable_name = declaration.id.name;
// Skip if the variable is already whitelisted.
if (variable_whitelist.indexOf(variable_name) > -1)
return;
// init contains info about the value being initialized to. It is null when the variable is
// being declared without being initialized.
// If initialization type is "CallExpression", that means that the variable is being
// initialized to a function.
// init.callee contains info about the function that the value is being initialized to,
// undefined if it's not being initialized to a function, or at all.
// So, this filters down into variables being initialized to the "require" function.
if (declaration.init && declaration.init.type === `CallExpression` &&
declaration.init.callee.name === `require`)
{
var module_name;
// init.arguments is an array of the arguments being passed to the callee, undefinied if
// the variable isn't being initialized to a function, or at all. Unlike the declarations,
// we won't iterate over this because we only care about the first argument.
if (declaration.init.arguments[0].type === `TemplateLiteral`)
// The quasis array is a bit weird. Parsed template literals have them, and the number
// of elements is equal to the number of placeholders, plus one for the non-placeholder
// section. However, the values of the placeholder sections are always empty, so I'm
// not sure what purpose they serve.
// This takes the cooked non-placeholder portion as-is.
module_name = declaration.init.arguments[0].quasis[0].value.cooked;
else if (declaration.init.arguments[0].type === `Literal`)
// Literals are easy. The value is right there.
module_name = declaration.init.arguments[0].value;
else
// Something other than `, ', or "? ¯\_(ツ)_/¯
return;
// Detect if the module is being included via a path. This means that it is a part of the
// project, and not from an external dependency. This means that it's alright to correct
// the case in it.
if (module_name.includes(`/`))
variable_whitelist.push(variable_name);
}
});
} | [
"function",
"(",
"node",
")",
"{",
"node",
".",
"declarations",
".",
"forEach",
"(",
"declaration",
"=>",
"{",
"var",
"variable_name",
"=",
"declaration",
".",
"id",
".",
"name",
";",
"if",
"(",
"variable_whitelist",
".",
"indexOf",
"(",
"variable_name",
")",
">",
"-",
"1",
")",
"return",
";",
"if",
"(",
"declaration",
".",
"init",
"&&",
"declaration",
".",
"init",
".",
"type",
"===",
"`",
"`",
"&&",
"declaration",
".",
"init",
".",
"callee",
".",
"name",
"===",
"`",
"`",
")",
"{",
"var",
"module_name",
";",
"if",
"(",
"declaration",
".",
"init",
".",
"arguments",
"[",
"0",
"]",
".",
"type",
"===",
"`",
"`",
")",
"module_name",
"=",
"declaration",
".",
"init",
".",
"arguments",
"[",
"0",
"]",
".",
"quasis",
"[",
"0",
"]",
".",
"value",
".",
"cooked",
";",
"else",
"if",
"(",
"declaration",
".",
"init",
".",
"arguments",
"[",
"0",
"]",
".",
"type",
"===",
"`",
"`",
")",
"module_name",
"=",
"declaration",
".",
"init",
".",
"arguments",
"[",
"0",
"]",
".",
"value",
";",
"else",
"return",
";",
"if",
"(",
"module_name",
".",
"includes",
"(",
"`",
"`",
")",
")",
"variable_whitelist",
".",
"push",
"(",
"variable_name",
")",
";",
"}",
"}",
")",
";",
"}"
]
| When a new variable is declared. This is where we whitelist nodes to check function calls of. | [
"When",
"a",
"new",
"variable",
"is",
"declared",
".",
"This",
"is",
"where",
"we",
"whitelist",
"nodes",
"to",
"check",
"function",
"calls",
"of",
"."
]
| 98ad46204e7d50b0886fd11d90b1571eb6991de7 | https://github.com/CodingKoopa/eslint-plugin-more-naming-conventions/blob/98ad46204e7d50b0886fd11d90b1571eb6991de7/Source/Rules/UpperCamelCase.js#L38-L83 | train |
|
XadillaX/illyria2 | lib/server_zookeeper.js | function(connectString, options, root, prefix) {
EventEmitter.call(this);
if(util.isArray(connectString)) {
connectString = connectString.join(",");
}
this.connectString = connectString;
this.options = options;
this.root = root || "/illyria";
this.prefix = prefix || "/HB_";
this.path = null;
this.root = this.root.trim();
this.prefix = this.prefix.trim();
if(!this.root.length) this.root = "/illyria";
if(!this.prefix.length) this.prefix = "/HB_";
if(this.root[0] !== "/") this.root = "/" + this.root;
if(this.prefix[0] !== "/") this.prefix = "/" + this.prefix;
this.client = zookeeper.createClient(this.connectString, options);
this.server = {
host: "127.0.0.1",
port: 3721,
clients: 0
};
this.clientStatus = ZK_STATUS.NOT_CONNECTED;
this._setup();
} | javascript | function(connectString, options, root, prefix) {
EventEmitter.call(this);
if(util.isArray(connectString)) {
connectString = connectString.join(",");
}
this.connectString = connectString;
this.options = options;
this.root = root || "/illyria";
this.prefix = prefix || "/HB_";
this.path = null;
this.root = this.root.trim();
this.prefix = this.prefix.trim();
if(!this.root.length) this.root = "/illyria";
if(!this.prefix.length) this.prefix = "/HB_";
if(this.root[0] !== "/") this.root = "/" + this.root;
if(this.prefix[0] !== "/") this.prefix = "/" + this.prefix;
this.client = zookeeper.createClient(this.connectString, options);
this.server = {
host: "127.0.0.1",
port: 3721,
clients: 0
};
this.clientStatus = ZK_STATUS.NOT_CONNECTED;
this._setup();
} | [
"function",
"(",
"connectString",
",",
"options",
",",
"root",
",",
"prefix",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"if",
"(",
"util",
".",
"isArray",
"(",
"connectString",
")",
")",
"{",
"connectString",
"=",
"connectString",
".",
"join",
"(",
"\",\"",
")",
";",
"}",
"this",
".",
"connectString",
"=",
"connectString",
";",
"this",
".",
"options",
"=",
"options",
";",
"this",
".",
"root",
"=",
"root",
"||",
"\"/illyria\"",
";",
"this",
".",
"prefix",
"=",
"prefix",
"||",
"\"/HB_\"",
";",
"this",
".",
"path",
"=",
"null",
";",
"this",
".",
"root",
"=",
"this",
".",
"root",
".",
"trim",
"(",
")",
";",
"this",
".",
"prefix",
"=",
"this",
".",
"prefix",
".",
"trim",
"(",
")",
";",
"if",
"(",
"!",
"this",
".",
"root",
".",
"length",
")",
"this",
".",
"root",
"=",
"\"/illyria\"",
";",
"if",
"(",
"!",
"this",
".",
"prefix",
".",
"length",
")",
"this",
".",
"prefix",
"=",
"\"/HB_\"",
";",
"if",
"(",
"this",
".",
"root",
"[",
"0",
"]",
"!==",
"\"/\"",
")",
"this",
".",
"root",
"=",
"\"/\"",
"+",
"this",
".",
"root",
";",
"if",
"(",
"this",
".",
"prefix",
"[",
"0",
"]",
"!==",
"\"/\"",
")",
"this",
".",
"prefix",
"=",
"\"/\"",
"+",
"this",
".",
"prefix",
";",
"this",
".",
"client",
"=",
"zookeeper",
".",
"createClient",
"(",
"this",
".",
"connectString",
",",
"options",
")",
";",
"this",
".",
"server",
"=",
"{",
"host",
":",
"\"127.0.0.1\"",
",",
"port",
":",
"3721",
",",
"clients",
":",
"0",
"}",
";",
"this",
".",
"clientStatus",
"=",
"ZK_STATUS",
".",
"NOT_CONNECTED",
";",
"this",
".",
"_setup",
"(",
")",
";",
"}"
]
| illyria zookeeper wrapper
@param {String|Array} connectString the connect string(s)
@param {Object} options the connect options, refer to
https://github.com/alexguan/node-zookeeper-client
#client-createclientconnectionstring-options
@param {String} [root] the root path
@param {String} [prefix] the path's prefix
@constructor | [
"illyria",
"zookeeper",
"wrapper"
]
| ced0cc71cdcda11afcbab33f13739cbe547a2a17 | https://github.com/XadillaX/illyria2/blob/ced0cc71cdcda11afcbab33f13739cbe547a2a17/lib/server_zookeeper.js#L32-L64 | train |
|
patsissons/hubot-giphy | src/giphy.js | extend | function extend(object, properties) {
object = object || { };
const anotherObject = properties || { };
for (const key in anotherObject) {
const val = anotherObject[key];
if (val || (val === '')) {
object[key] = val;
}
}
return object;
} | javascript | function extend(object, properties) {
object = object || { };
const anotherObject = properties || { };
for (const key in anotherObject) {
const val = anotherObject[key];
if (val || (val === '')) {
object[key] = val;
}
}
return object;
} | [
"function",
"extend",
"(",
"object",
",",
"properties",
")",
"{",
"object",
"=",
"object",
"||",
"{",
"}",
";",
"const",
"anotherObject",
"=",
"properties",
"||",
"{",
"}",
";",
"for",
"(",
"const",
"key",
"in",
"anotherObject",
")",
"{",
"const",
"val",
"=",
"anotherObject",
"[",
"key",
"]",
";",
"if",
"(",
"val",
"||",
"(",
"val",
"===",
"''",
")",
")",
"{",
"object",
"[",
"key",
"]",
"=",
"val",
";",
"}",
"}",
"return",
"object",
";",
"}"
]
| utility method for extending an object definition | [
"utility",
"method",
"for",
"extending",
"an",
"object",
"definition"
]
| 59d8904a66206ba2147b5016a4a20bb1bea6f34b | https://github.com/patsissons/hubot-giphy/blob/59d8904a66206ba2147b5016a4a20bb1bea6f34b/src/giphy.js#L35-L47 | train |
divio/browserslist-saucelabs | getdata.js | eliminateDuplicates | function eliminateDuplicates(browsers) {
var set = {};
browsers.forEach(function (browser) {
var osgroup = browser.os;
var subgroup = browser.long_name;
var version = browser.short_version;
var device;
var browserName;
if (browser.api_name === "iphone") {
osgroup = device = "iPhone Simulator";
} else if (browser.api_name === "ipad") {
osgroup = device = "iPad Simulator";
} else if (browser.long_name === "Google Chrome") {
browserName = 'Chrome';
} else if (browser.long_name === "Microsoft Edge") {
browserName = 'MicrosoftEdge';
version = browser.long_version.substr(0, 8);
} else if (browser.api_name === "android") {
browserName = 'Android';
osgroup = "Android " + browser.short_version;
device = browser.long_name;
if (subgroup === "Android") {
subgroup += " " + version + " Emulator";
device = "Android Emulator";
}
} else if (osgroup in OS_ID_TO_GROUPNAME) {
osgroup = OS_ID_TO_GROUPNAME[osgroup];
}
set[JSON.stringify([osgroup, subgroup, version])] = {
browserName: browserName || browser.long_name,
platform: OS_ID_TO_GROUPNAME[browser.os] || browser.os,
version: version,
deviceName: device || browser.device
};
});
var uniques = Object.keys(set).sort().map(function (id) {
return set[id];
});
return uniques;
} | javascript | function eliminateDuplicates(browsers) {
var set = {};
browsers.forEach(function (browser) {
var osgroup = browser.os;
var subgroup = browser.long_name;
var version = browser.short_version;
var device;
var browserName;
if (browser.api_name === "iphone") {
osgroup = device = "iPhone Simulator";
} else if (browser.api_name === "ipad") {
osgroup = device = "iPad Simulator";
} else if (browser.long_name === "Google Chrome") {
browserName = 'Chrome';
} else if (browser.long_name === "Microsoft Edge") {
browserName = 'MicrosoftEdge';
version = browser.long_version.substr(0, 8);
} else if (browser.api_name === "android") {
browserName = 'Android';
osgroup = "Android " + browser.short_version;
device = browser.long_name;
if (subgroup === "Android") {
subgroup += " " + version + " Emulator";
device = "Android Emulator";
}
} else if (osgroup in OS_ID_TO_GROUPNAME) {
osgroup = OS_ID_TO_GROUPNAME[osgroup];
}
set[JSON.stringify([osgroup, subgroup, version])] = {
browserName: browserName || browser.long_name,
platform: OS_ID_TO_GROUPNAME[browser.os] || browser.os,
version: version,
deviceName: device || browser.device
};
});
var uniques = Object.keys(set).sort().map(function (id) {
return set[id];
});
return uniques;
} | [
"function",
"eliminateDuplicates",
"(",
"browsers",
")",
"{",
"var",
"set",
"=",
"{",
"}",
";",
"browsers",
".",
"forEach",
"(",
"function",
"(",
"browser",
")",
"{",
"var",
"osgroup",
"=",
"browser",
".",
"os",
";",
"var",
"subgroup",
"=",
"browser",
".",
"long_name",
";",
"var",
"version",
"=",
"browser",
".",
"short_version",
";",
"var",
"device",
";",
"var",
"browserName",
";",
"if",
"(",
"browser",
".",
"api_name",
"===",
"\"iphone\"",
")",
"{",
"osgroup",
"=",
"device",
"=",
"\"iPhone Simulator\"",
";",
"}",
"else",
"if",
"(",
"browser",
".",
"api_name",
"===",
"\"ipad\"",
")",
"{",
"osgroup",
"=",
"device",
"=",
"\"iPad Simulator\"",
";",
"}",
"else",
"if",
"(",
"browser",
".",
"long_name",
"===",
"\"Google Chrome\"",
")",
"{",
"browserName",
"=",
"'Chrome'",
";",
"}",
"else",
"if",
"(",
"browser",
".",
"long_name",
"===",
"\"Microsoft Edge\"",
")",
"{",
"browserName",
"=",
"'MicrosoftEdge'",
";",
"version",
"=",
"browser",
".",
"long_version",
".",
"substr",
"(",
"0",
",",
"8",
")",
";",
"}",
"else",
"if",
"(",
"browser",
".",
"api_name",
"===",
"\"android\"",
")",
"{",
"browserName",
"=",
"'Android'",
";",
"osgroup",
"=",
"\"Android \"",
"+",
"browser",
".",
"short_version",
";",
"device",
"=",
"browser",
".",
"long_name",
";",
"if",
"(",
"subgroup",
"===",
"\"Android\"",
")",
"{",
"subgroup",
"+=",
"\" \"",
"+",
"version",
"+",
"\" Emulator\"",
";",
"device",
"=",
"\"Android Emulator\"",
";",
"}",
"}",
"else",
"if",
"(",
"osgroup",
"in",
"OS_ID_TO_GROUPNAME",
")",
"{",
"osgroup",
"=",
"OS_ID_TO_GROUPNAME",
"[",
"osgroup",
"]",
";",
"}",
"set",
"[",
"JSON",
".",
"stringify",
"(",
"[",
"osgroup",
",",
"subgroup",
",",
"version",
"]",
")",
"]",
"=",
"{",
"browserName",
":",
"browserName",
"||",
"browser",
".",
"long_name",
",",
"platform",
":",
"OS_ID_TO_GROUPNAME",
"[",
"browser",
".",
"os",
"]",
"||",
"browser",
".",
"os",
",",
"version",
":",
"version",
",",
"deviceName",
":",
"device",
"||",
"browser",
".",
"device",
"}",
";",
"}",
")",
";",
"var",
"uniques",
"=",
"Object",
".",
"keys",
"(",
"set",
")",
".",
"sort",
"(",
")",
".",
"map",
"(",
"function",
"(",
"id",
")",
"{",
"return",
"set",
"[",
"id",
"]",
";",
"}",
")",
";",
"return",
"uniques",
";",
"}"
]
| The platforms API lists multiple versions of platforms with different properties. Pull out just the essentials, and eliminate duplicates. | [
"The",
"platforms",
"API",
"lists",
"multiple",
"versions",
"of",
"platforms",
"with",
"different",
"properties",
".",
"Pull",
"out",
"just",
"the",
"essentials",
"and",
"eliminate",
"duplicates",
"."
]
| e28f1a163cde9c48b0d6e0f9861ffd5dea523106 | https://github.com/divio/browserslist-saucelabs/blob/e28f1a163cde9c48b0d6e0f9861ffd5dea523106/getdata.js#L21-L62 | train |
alexcjohnson/world-calendars | jquery-src/jquery.calendars.validation.js | function(elem, target) {
this.selectDateOrig(elem, target);
var inst = $.calendarsPicker._getInst(elem);
if (!inst.inline && $.fn.validate) {
var validation = $(elem).parents('form').validate();
if (validation) {
validation.element('#' + elem.id);
}
}
} | javascript | function(elem, target) {
this.selectDateOrig(elem, target);
var inst = $.calendarsPicker._getInst(elem);
if (!inst.inline && $.fn.validate) {
var validation = $(elem).parents('form').validate();
if (validation) {
validation.element('#' + elem.id);
}
}
} | [
"function",
"(",
"elem",
",",
"target",
")",
"{",
"this",
".",
"selectDateOrig",
"(",
"elem",
",",
"target",
")",
";",
"var",
"inst",
"=",
"$",
".",
"calendarsPicker",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"!",
"inst",
".",
"inline",
"&&",
"$",
".",
"fn",
".",
"validate",
")",
"{",
"var",
"validation",
"=",
"$",
"(",
"elem",
")",
".",
"parents",
"(",
"'form'",
")",
".",
"validate",
"(",
")",
";",
"if",
"(",
"validation",
")",
"{",
"validation",
".",
"element",
"(",
"'#'",
"+",
"elem",
".",
"id",
")",
";",
"}",
"}",
"}"
]
| Trigger a validation after updating the input field with the selected date.
@param elem {Element} The control to examine.
@param target {Element} The selected datepicker element. | [
"Trigger",
"a",
"validation",
"after",
"updating",
"the",
"input",
"field",
"with",
"the",
"selected",
"date",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.validation.js#L38-L47 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.validation.js | function(error, elem) {
var inst = $.calendarsPicker._getInst(elem);
if (inst) {
error[inst.options.isRTL ? 'insertBefore' : 'insertAfter'](
inst.trigger.length > 0 ? inst.trigger : elem);
}
else {
error.insertAfter(elem);
}
} | javascript | function(error, elem) {
var inst = $.calendarsPicker._getInst(elem);
if (inst) {
error[inst.options.isRTL ? 'insertBefore' : 'insertAfter'](
inst.trigger.length > 0 ? inst.trigger : elem);
}
else {
error.insertAfter(elem);
}
} | [
"function",
"(",
"error",
",",
"elem",
")",
"{",
"var",
"inst",
"=",
"$",
".",
"calendarsPicker",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"inst",
")",
"{",
"error",
"[",
"inst",
".",
"options",
".",
"isRTL",
"?",
"'insertBefore'",
":",
"'insertAfter'",
"]",
"(",
"inst",
".",
"trigger",
".",
"length",
">",
"0",
"?",
"inst",
".",
"trigger",
":",
"elem",
")",
";",
"}",
"else",
"{",
"error",
".",
"insertAfter",
"(",
"elem",
")",
";",
"}",
"}"
]
| Correct error placement for validation errors - after any trigger.
@param error {jQuery} The error message.
@param elem {jQuery} The field in error. | [
"Correct",
"error",
"placement",
"for",
"validation",
"errors",
"-",
"after",
"any",
"trigger",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.validation.js#L52-L61 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.validation.js | function(source, params) {
var format = ($.calendarsPicker.curInst ?
$.calendarsPicker.curInst.get('dateFormat') :
$.calendarsPicker.defaultOptions.dateFormat);
$.each(params, function(index, value) {
source = source.replace(new RegExp('\\{' + index + '\\}', 'g'),
value.formatDate(format) || 'nothing');
});
return source;
} | javascript | function(source, params) {
var format = ($.calendarsPicker.curInst ?
$.calendarsPicker.curInst.get('dateFormat') :
$.calendarsPicker.defaultOptions.dateFormat);
$.each(params, function(index, value) {
source = source.replace(new RegExp('\\{' + index + '\\}', 'g'),
value.formatDate(format) || 'nothing');
});
return source;
} | [
"function",
"(",
"source",
",",
"params",
")",
"{",
"var",
"format",
"=",
"(",
"$",
".",
"calendarsPicker",
".",
"curInst",
"?",
"$",
".",
"calendarsPicker",
".",
"curInst",
".",
"get",
"(",
"'dateFormat'",
")",
":",
"$",
".",
"calendarsPicker",
".",
"defaultOptions",
".",
"dateFormat",
")",
";",
"$",
".",
"each",
"(",
"params",
",",
"function",
"(",
"index",
",",
"value",
")",
"{",
"source",
"=",
"source",
".",
"replace",
"(",
"new",
"RegExp",
"(",
"'\\\\{'",
"+",
"\\\\",
"+",
"index",
",",
"'\\\\}'",
")",
",",
"\\\\",
")",
";",
"}",
")",
";",
"'g'",
"}"
]
| Format a validation error message involving dates.
@param source {string} The error message.
@param params {Date[]} The dates.
@return {string} The formatted message. | [
"Format",
"a",
"validation",
"error",
"message",
"involving",
"dates",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.validation.js#L67-L76 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.validation.js | validateEach | function validateEach(value, elem) {
var inst = $.calendarsPicker._getInst(elem);
var dates = (inst.options.multiSelect ? value.split(inst.options.multiSeparator) :
(inst.options.rangeSelect ? value.split(inst.options.rangeSeparator) : [value]));
var ok = (inst.options.multiSelect && dates.length <= inst.options.multiSelect) ||
(!inst.options.multiSelect && inst.options.rangeSelect && dates.length === 2) ||
(!inst.options.multiSelect && !inst.options.rangeSelect && dates.length === 1);
if (ok) {
try {
var dateFormat = inst.get('dateFormat');
var minDate = inst.get('minDate');
var maxDate = inst.get('maxDate');
var cp = $(elem);
$.each(dates, function(i, v) {
dates[i] = inst.options.calendar.parseDate(dateFormat, v);
ok = ok && (!dates[i] || (cp.calendarsPicker('isSelectable', dates[i]) &&
(!minDate || dates[i].compareTo(minDate) !== -1) &&
(!maxDate || dates[i].compareTo(maxDate) !== +1)));
});
}
catch (e) {
ok = false;
}
}
if (ok && inst.options.rangeSelect) {
ok = (dates[0].compareTo(dates[1]) !== +1);
}
return ok;
} | javascript | function validateEach(value, elem) {
var inst = $.calendarsPicker._getInst(elem);
var dates = (inst.options.multiSelect ? value.split(inst.options.multiSeparator) :
(inst.options.rangeSelect ? value.split(inst.options.rangeSeparator) : [value]));
var ok = (inst.options.multiSelect && dates.length <= inst.options.multiSelect) ||
(!inst.options.multiSelect && inst.options.rangeSelect && dates.length === 2) ||
(!inst.options.multiSelect && !inst.options.rangeSelect && dates.length === 1);
if (ok) {
try {
var dateFormat = inst.get('dateFormat');
var minDate = inst.get('minDate');
var maxDate = inst.get('maxDate');
var cp = $(elem);
$.each(dates, function(i, v) {
dates[i] = inst.options.calendar.parseDate(dateFormat, v);
ok = ok && (!dates[i] || (cp.calendarsPicker('isSelectable', dates[i]) &&
(!minDate || dates[i].compareTo(minDate) !== -1) &&
(!maxDate || dates[i].compareTo(maxDate) !== +1)));
});
}
catch (e) {
ok = false;
}
}
if (ok && inst.options.rangeSelect) {
ok = (dates[0].compareTo(dates[1]) !== +1);
}
return ok;
} | [
"function",
"validateEach",
"(",
"value",
",",
"elem",
")",
"{",
"var",
"inst",
"=",
"$",
".",
"calendarsPicker",
".",
"_getInst",
"(",
"elem",
")",
";",
"var",
"dates",
"=",
"(",
"inst",
".",
"options",
".",
"multiSelect",
"?",
"value",
".",
"split",
"(",
"inst",
".",
"options",
".",
"multiSeparator",
")",
":",
"(",
"inst",
".",
"options",
".",
"rangeSelect",
"?",
"value",
".",
"split",
"(",
"inst",
".",
"options",
".",
"rangeSeparator",
")",
":",
"[",
"value",
"]",
")",
")",
";",
"var",
"ok",
"=",
"(",
"inst",
".",
"options",
".",
"multiSelect",
"&&",
"dates",
".",
"length",
"<=",
"inst",
".",
"options",
".",
"multiSelect",
")",
"||",
"(",
"!",
"inst",
".",
"options",
".",
"multiSelect",
"&&",
"inst",
".",
"options",
".",
"rangeSelect",
"&&",
"dates",
".",
"length",
"===",
"2",
")",
"||",
"(",
"!",
"inst",
".",
"options",
".",
"multiSelect",
"&&",
"!",
"inst",
".",
"options",
".",
"rangeSelect",
"&&",
"dates",
".",
"length",
"===",
"1",
")",
";",
"if",
"(",
"ok",
")",
"{",
"try",
"{",
"var",
"dateFormat",
"=",
"inst",
".",
"get",
"(",
"'dateFormat'",
")",
";",
"var",
"minDate",
"=",
"inst",
".",
"get",
"(",
"'minDate'",
")",
";",
"var",
"maxDate",
"=",
"inst",
".",
"get",
"(",
"'maxDate'",
")",
";",
"var",
"cp",
"=",
"$",
"(",
"elem",
")",
";",
"$",
".",
"each",
"(",
"dates",
",",
"function",
"(",
"i",
",",
"v",
")",
"{",
"dates",
"[",
"i",
"]",
"=",
"inst",
".",
"options",
".",
"calendar",
".",
"parseDate",
"(",
"dateFormat",
",",
"v",
")",
";",
"ok",
"=",
"ok",
"&&",
"(",
"!",
"dates",
"[",
"i",
"]",
"||",
"(",
"cp",
".",
"calendarsPicker",
"(",
"'isSelectable'",
",",
"dates",
"[",
"i",
"]",
")",
"&&",
"(",
"!",
"minDate",
"||",
"dates",
"[",
"i",
"]",
".",
"compareTo",
"(",
"minDate",
")",
"!==",
"-",
"1",
")",
"&&",
"(",
"!",
"maxDate",
"||",
"dates",
"[",
"i",
"]",
".",
"compareTo",
"(",
"maxDate",
")",
"!==",
"+",
"1",
")",
")",
")",
";",
"}",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"ok",
"=",
"false",
";",
"}",
"}",
"if",
"(",
"ok",
"&&",
"inst",
".",
"options",
".",
"rangeSelect",
")",
"{",
"ok",
"=",
"(",
"dates",
"[",
"0",
"]",
".",
"compareTo",
"(",
"dates",
"[",
"1",
"]",
")",
"!==",
"+",
"1",
")",
";",
"}",
"return",
"ok",
";",
"}"
]
| Apply a validation test to each date provided.
@private
@param value {string} The current field value.
@param elem {Element} The field control.
@return {boolean} <code>true</code> if OK, <code>false</code> if failed validation. | [
"Apply",
"a",
"validation",
"test",
"to",
"each",
"date",
"provided",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.validation.js#L103-L131 | train |
alexcjohnson/world-calendars | jquery-src/jquery.calendars.validation.js | normaliseParams | function normaliseParams(params) {
if (typeof params === 'string') {
params = params.split(' ');
}
else if (!$.isArray(params)) {
var opts = [];
for (var name in params) {
opts[0] = name;
opts[1] = params[name];
}
params = opts;
}
return params;
} | javascript | function normaliseParams(params) {
if (typeof params === 'string') {
params = params.split(' ');
}
else if (!$.isArray(params)) {
var opts = [];
for (var name in params) {
opts[0] = name;
opts[1] = params[name];
}
params = opts;
}
return params;
} | [
"function",
"normaliseParams",
"(",
"params",
")",
"{",
"if",
"(",
"typeof",
"params",
"===",
"'string'",
")",
"{",
"params",
"=",
"params",
".",
"split",
"(",
"' '",
")",
";",
"}",
"else",
"if",
"(",
"!",
"$",
".",
"isArray",
"(",
"params",
")",
")",
"{",
"var",
"opts",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"name",
"in",
"params",
")",
"{",
"opts",
"[",
"0",
"]",
"=",
"name",
";",
"opts",
"[",
"1",
"]",
"=",
"params",
"[",
"name",
"]",
";",
"}",
"params",
"=",
"opts",
";",
"}",
"return",
"params",
";",
"}"
]
| Normalise the comparison parameters to an array.
@param params {Array|object|string} The original parameters.
@return {Array} The normalised parameters. | [
"Normalise",
"the",
"comparison",
"parameters",
"to",
"an",
"array",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.validation.js#L189-L202 | train |
alexcjohnson/world-calendars | jquery-src/jquery.calendars.validation.js | extractOtherDate | function extractOtherDate(elem, source, noOther) {
if (source.newDate && source.extraInfo) { // Already a CDate
return [source];
}
var inst = $.calendarsPicker._getInst(elem);
var thatDate = null;
try {
if (typeof source === 'string' && source !== 'today') {
thatDate = inst.options.calendar.parseDate(inst.get('dateFormat'), source);
}
}
catch (e) {
// Ignore
}
thatDate = (thatDate ? [thatDate] : (source === 'today' ?
[inst.options.calendar.today()] : (noOther ? [] : $(source).calendarsPicker('getDate'))));
return thatDate;
} | javascript | function extractOtherDate(elem, source, noOther) {
if (source.newDate && source.extraInfo) { // Already a CDate
return [source];
}
var inst = $.calendarsPicker._getInst(elem);
var thatDate = null;
try {
if (typeof source === 'string' && source !== 'today') {
thatDate = inst.options.calendar.parseDate(inst.get('dateFormat'), source);
}
}
catch (e) {
// Ignore
}
thatDate = (thatDate ? [thatDate] : (source === 'today' ?
[inst.options.calendar.today()] : (noOther ? [] : $(source).calendarsPicker('getDate'))));
return thatDate;
} | [
"function",
"extractOtherDate",
"(",
"elem",
",",
"source",
",",
"noOther",
")",
"{",
"if",
"(",
"source",
".",
"newDate",
"&&",
"source",
".",
"extraInfo",
")",
"{",
"return",
"[",
"source",
"]",
";",
"}",
"var",
"inst",
"=",
"$",
".",
"calendarsPicker",
".",
"_getInst",
"(",
"elem",
")",
";",
"var",
"thatDate",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"typeof",
"source",
"===",
"'string'",
"&&",
"source",
"!==",
"'today'",
")",
"{",
"thatDate",
"=",
"inst",
".",
"options",
".",
"calendar",
".",
"parseDate",
"(",
"inst",
".",
"get",
"(",
"'dateFormat'",
")",
",",
"source",
")",
";",
"}",
"}",
"catch",
"(",
"e",
")",
"{",
"}",
"thatDate",
"=",
"(",
"thatDate",
"?",
"[",
"thatDate",
"]",
":",
"(",
"source",
"===",
"'today'",
"?",
"[",
"inst",
".",
"options",
".",
"calendar",
".",
"today",
"(",
")",
"]",
":",
"(",
"noOther",
"?",
"[",
"]",
":",
"$",
"(",
"source",
")",
".",
"calendarsPicker",
"(",
"'getDate'",
")",
")",
")",
")",
";",
"return",
"thatDate",
";",
"}"
]
| Determine the comparison date.
@param elem {Element} The current datepicker element.
@param source {string|CDate|jQueryElement} The source of the other date.
@param noOther {boolean} <code>true</code> to not get the date from another field.
@return {CDate[]} The date for comparison. | [
"Determine",
"the",
"comparison",
"date",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.validation.js#L209-L226 | train |
Neil-G/redux-mastermind | lib/helpers.js | objectToArray | function objectToArray(object) {
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'id';
var convertedArray = [];
Object.keys(object).forEach(function (_key) {
var item = object[_key];
item[key] = _key;
convertedArray.push(item);
});
return convertedArray;
} | javascript | function objectToArray(object) {
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'id';
var convertedArray = [];
Object.keys(object).forEach(function (_key) {
var item = object[_key];
item[key] = _key;
convertedArray.push(item);
});
return convertedArray;
} | [
"function",
"objectToArray",
"(",
"object",
")",
"{",
"var",
"key",
"=",
"arguments",
".",
"length",
">",
"1",
"&&",
"arguments",
"[",
"1",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"1",
"]",
":",
"'id'",
";",
"var",
"convertedArray",
"=",
"[",
"]",
";",
"Object",
".",
"keys",
"(",
"object",
")",
".",
"forEach",
"(",
"function",
"(",
"_key",
")",
"{",
"var",
"item",
"=",
"object",
"[",
"_key",
"]",
";",
"item",
"[",
"key",
"]",
"=",
"_key",
";",
"convertedArray",
".",
"push",
"(",
"item",
")",
";",
"}",
")",
";",
"return",
"convertedArray",
";",
"}"
]
| converts an object to an array | [
"converts",
"an",
"object",
"to",
"an",
"array"
]
| 669e2978b4a7cdd48fbd33d4fd6dbe47e92d3cef | https://github.com/Neil-G/redux-mastermind/blob/669e2978b4a7cdd48fbd33d4fd6dbe47e92d3cef/lib/helpers.js#L22-L34 | train |
HasakiUI/hsk-jinx | src/component/intro/intro.js | _nextStep | function _nextStep() {
this._direction = 'forward';
if (typeof this._currentStepNumber !== 'undefined') {
for (var i = 0, len = this._introItems.length; i < len; i++) {
var item = this._introItems[i];
if (item.step === this._currentStepNumber) {
this._currentStep = i - 1;
this._currentStepNumber = undefined;
}
}
}
if (typeof this._currentStep === 'undefined') {
this._currentStep = 0;
} else {
++this._currentStep;
}
if (typeof this._introBeforeChangeCallback !== 'undefined') {
var continueStep = this._introBeforeChangeCallback.call(this);
}
// if `onbeforechange` returned `false`, stop displaying the element
if (continueStep === false) {
--this._currentStep;
return false;
}
if (this._introItems.length <= this._currentStep) {
//end of the intro
//check if any callback is defined
if (typeof this._introCompleteCallback === 'function') {
this._introCompleteCallback.call(this);
}
_exitIntro.call(this, this._targetElement);
return;
}
var nextStep = this._introItems[this._currentStep];
_showElement.call(this, nextStep);
} | javascript | function _nextStep() {
this._direction = 'forward';
if (typeof this._currentStepNumber !== 'undefined') {
for (var i = 0, len = this._introItems.length; i < len; i++) {
var item = this._introItems[i];
if (item.step === this._currentStepNumber) {
this._currentStep = i - 1;
this._currentStepNumber = undefined;
}
}
}
if (typeof this._currentStep === 'undefined') {
this._currentStep = 0;
} else {
++this._currentStep;
}
if (typeof this._introBeforeChangeCallback !== 'undefined') {
var continueStep = this._introBeforeChangeCallback.call(this);
}
// if `onbeforechange` returned `false`, stop displaying the element
if (continueStep === false) {
--this._currentStep;
return false;
}
if (this._introItems.length <= this._currentStep) {
//end of the intro
//check if any callback is defined
if (typeof this._introCompleteCallback === 'function') {
this._introCompleteCallback.call(this);
}
_exitIntro.call(this, this._targetElement);
return;
}
var nextStep = this._introItems[this._currentStep];
_showElement.call(this, nextStep);
} | [
"function",
"_nextStep",
"(",
")",
"{",
"this",
".",
"_direction",
"=",
"'forward'",
";",
"if",
"(",
"typeof",
"this",
".",
"_currentStepNumber",
"!==",
"'undefined'",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"this",
".",
"_introItems",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"item",
"=",
"this",
".",
"_introItems",
"[",
"i",
"]",
";",
"if",
"(",
"item",
".",
"step",
"===",
"this",
".",
"_currentStepNumber",
")",
"{",
"this",
".",
"_currentStep",
"=",
"i",
"-",
"1",
";",
"this",
".",
"_currentStepNumber",
"=",
"undefined",
";",
"}",
"}",
"}",
"if",
"(",
"typeof",
"this",
".",
"_currentStep",
"===",
"'undefined'",
")",
"{",
"this",
".",
"_currentStep",
"=",
"0",
";",
"}",
"else",
"{",
"++",
"this",
".",
"_currentStep",
";",
"}",
"if",
"(",
"typeof",
"this",
".",
"_introBeforeChangeCallback",
"!==",
"'undefined'",
")",
"{",
"var",
"continueStep",
"=",
"this",
".",
"_introBeforeChangeCallback",
".",
"call",
"(",
"this",
")",
";",
"}",
"if",
"(",
"continueStep",
"===",
"false",
")",
"{",
"--",
"this",
".",
"_currentStep",
";",
"return",
"false",
";",
"}",
"if",
"(",
"this",
".",
"_introItems",
".",
"length",
"<=",
"this",
".",
"_currentStep",
")",
"{",
"if",
"(",
"typeof",
"this",
".",
"_introCompleteCallback",
"===",
"'function'",
")",
"{",
"this",
".",
"_introCompleteCallback",
".",
"call",
"(",
"this",
")",
";",
"}",
"_exitIntro",
".",
"call",
"(",
"this",
",",
"this",
".",
"_targetElement",
")",
";",
"return",
";",
"}",
"var",
"nextStep",
"=",
"this",
".",
"_introItems",
"[",
"this",
".",
"_currentStep",
"]",
";",
"_showElement",
".",
"call",
"(",
"this",
",",
"nextStep",
")",
";",
"}"
]
| Go to next step on intro
@api private
@method _nextStep | [
"Go",
"to",
"next",
"step",
"on",
"intro"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L357-L398 | train |
HasakiUI/hsk-jinx | src/component/intro/intro.js | _exitIntro | function _exitIntro(targetElement, force) {
var continueExit = true;
// calling onbeforeexit callback
//
// If this callback return `false`, it would halt the process
if (this._introBeforeExitCallback != undefined) {
continueExit = this._introBeforeExitCallback.call(self);
}
// skip this check if `force` parameter is `true`
// otherwise, if `onbeforeexit` returned `false`, don't exit the intro
if (!force && continueExit === false) return;
//remove overlay layers from the page
var overlayLayers = targetElement.querySelectorAll('.introjs-overlay');
if (overlayLayers && overlayLayers.length > 0) {
for (var i = overlayLayers.length - 1; i >= 0; i--) {
//for fade-out animation
var overlayLayer = overlayLayers[i];
overlayLayer.style.opacity = 0;
setTimeout(
function() {
if (this.parentNode) {
this.parentNode.removeChild(this);
}
}.bind(overlayLayer),
500
);
}
}
//remove all helper layers
var helperLayer = targetElement.querySelector('.introjs-helperLayer');
if (helperLayer) {
helperLayer.parentNode.removeChild(helperLayer);
}
var referenceLayer = targetElement.querySelector('.introjs-tooltipReferenceLayer');
if (referenceLayer) {
referenceLayer.parentNode.removeChild(referenceLayer);
}
//remove disableInteractionLayer
var disableInteractionLayer = targetElement.querySelector('.introjs-disableInteraction');
if (disableInteractionLayer) {
disableInteractionLayer.parentNode.removeChild(disableInteractionLayer);
}
//remove intro floating element
var floatingElement = document.querySelector('.introjsFloatingElement');
if (floatingElement) {
floatingElement.parentNode.removeChild(floatingElement);
}
_removeShowElement();
//remove `introjs-fixParent` class from the elements
var fixParents = document.querySelectorAll('.introjs-fixParent');
if (fixParents && fixParents.length > 0) {
for (var i = fixParents.length - 1; i >= 0; i--) {
fixParents[i].className = fixParents[i].className
.replace(/introjs-fixParent/g, '')
.replace(/^\s+|\s+$/g, '');
}
}
//clean listeners
if (window.removeEventListener) {
window.removeEventListener('keydown', this._onKeyDown, true);
} else if (document.detachEvent) {
//IE
document.detachEvent('onkeydown', this._onKeyDown);
}
//check if any callback is defined
if (this._introExitCallback != undefined) {
this._introExitCallback.call(self);
}
//set the step to zero
this._currentStep = undefined;
} | javascript | function _exitIntro(targetElement, force) {
var continueExit = true;
// calling onbeforeexit callback
//
// If this callback return `false`, it would halt the process
if (this._introBeforeExitCallback != undefined) {
continueExit = this._introBeforeExitCallback.call(self);
}
// skip this check if `force` parameter is `true`
// otherwise, if `onbeforeexit` returned `false`, don't exit the intro
if (!force && continueExit === false) return;
//remove overlay layers from the page
var overlayLayers = targetElement.querySelectorAll('.introjs-overlay');
if (overlayLayers && overlayLayers.length > 0) {
for (var i = overlayLayers.length - 1; i >= 0; i--) {
//for fade-out animation
var overlayLayer = overlayLayers[i];
overlayLayer.style.opacity = 0;
setTimeout(
function() {
if (this.parentNode) {
this.parentNode.removeChild(this);
}
}.bind(overlayLayer),
500
);
}
}
//remove all helper layers
var helperLayer = targetElement.querySelector('.introjs-helperLayer');
if (helperLayer) {
helperLayer.parentNode.removeChild(helperLayer);
}
var referenceLayer = targetElement.querySelector('.introjs-tooltipReferenceLayer');
if (referenceLayer) {
referenceLayer.parentNode.removeChild(referenceLayer);
}
//remove disableInteractionLayer
var disableInteractionLayer = targetElement.querySelector('.introjs-disableInteraction');
if (disableInteractionLayer) {
disableInteractionLayer.parentNode.removeChild(disableInteractionLayer);
}
//remove intro floating element
var floatingElement = document.querySelector('.introjsFloatingElement');
if (floatingElement) {
floatingElement.parentNode.removeChild(floatingElement);
}
_removeShowElement();
//remove `introjs-fixParent` class from the elements
var fixParents = document.querySelectorAll('.introjs-fixParent');
if (fixParents && fixParents.length > 0) {
for (var i = fixParents.length - 1; i >= 0; i--) {
fixParents[i].className = fixParents[i].className
.replace(/introjs-fixParent/g, '')
.replace(/^\s+|\s+$/g, '');
}
}
//clean listeners
if (window.removeEventListener) {
window.removeEventListener('keydown', this._onKeyDown, true);
} else if (document.detachEvent) {
//IE
document.detachEvent('onkeydown', this._onKeyDown);
}
//check if any callback is defined
if (this._introExitCallback != undefined) {
this._introExitCallback.call(self);
}
//set the step to zero
this._currentStep = undefined;
} | [
"function",
"_exitIntro",
"(",
"targetElement",
",",
"force",
")",
"{",
"var",
"continueExit",
"=",
"true",
";",
"if",
"(",
"this",
".",
"_introBeforeExitCallback",
"!=",
"undefined",
")",
"{",
"continueExit",
"=",
"this",
".",
"_introBeforeExitCallback",
".",
"call",
"(",
"self",
")",
";",
"}",
"if",
"(",
"!",
"force",
"&&",
"continueExit",
"===",
"false",
")",
"return",
";",
"var",
"overlayLayers",
"=",
"targetElement",
".",
"querySelectorAll",
"(",
"'.introjs-overlay'",
")",
";",
"if",
"(",
"overlayLayers",
"&&",
"overlayLayers",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"overlayLayers",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"var",
"overlayLayer",
"=",
"overlayLayers",
"[",
"i",
"]",
";",
"overlayLayer",
".",
"style",
".",
"opacity",
"=",
"0",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"parentNode",
")",
"{",
"this",
".",
"parentNode",
".",
"removeChild",
"(",
"this",
")",
";",
"}",
"}",
".",
"bind",
"(",
"overlayLayer",
")",
",",
"500",
")",
";",
"}",
"}",
"var",
"helperLayer",
"=",
"targetElement",
".",
"querySelector",
"(",
"'.introjs-helperLayer'",
")",
";",
"if",
"(",
"helperLayer",
")",
"{",
"helperLayer",
".",
"parentNode",
".",
"removeChild",
"(",
"helperLayer",
")",
";",
"}",
"var",
"referenceLayer",
"=",
"targetElement",
".",
"querySelector",
"(",
"'.introjs-tooltipReferenceLayer'",
")",
";",
"if",
"(",
"referenceLayer",
")",
"{",
"referenceLayer",
".",
"parentNode",
".",
"removeChild",
"(",
"referenceLayer",
")",
";",
"}",
"var",
"disableInteractionLayer",
"=",
"targetElement",
".",
"querySelector",
"(",
"'.introjs-disableInteraction'",
")",
";",
"if",
"(",
"disableInteractionLayer",
")",
"{",
"disableInteractionLayer",
".",
"parentNode",
".",
"removeChild",
"(",
"disableInteractionLayer",
")",
";",
"}",
"var",
"floatingElement",
"=",
"document",
".",
"querySelector",
"(",
"'.introjsFloatingElement'",
")",
";",
"if",
"(",
"floatingElement",
")",
"{",
"floatingElement",
".",
"parentNode",
".",
"removeChild",
"(",
"floatingElement",
")",
";",
"}",
"_removeShowElement",
"(",
")",
";",
"var",
"fixParents",
"=",
"document",
".",
"querySelectorAll",
"(",
"'.introjs-fixParent'",
")",
";",
"if",
"(",
"fixParents",
"&&",
"fixParents",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"fixParents",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"fixParents",
"[",
"i",
"]",
".",
"className",
"=",
"fixParents",
"[",
"i",
"]",
".",
"className",
".",
"replace",
"(",
"/",
"introjs-fixParent",
"/",
"g",
",",
"''",
")",
".",
"replace",
"(",
"/",
"^\\s+|\\s+$",
"/",
"g",
",",
"''",
")",
";",
"}",
"}",
"if",
"(",
"window",
".",
"removeEventListener",
")",
"{",
"window",
".",
"removeEventListener",
"(",
"'keydown'",
",",
"this",
".",
"_onKeyDown",
",",
"true",
")",
";",
"}",
"else",
"if",
"(",
"document",
".",
"detachEvent",
")",
"{",
"document",
".",
"detachEvent",
"(",
"'onkeydown'",
",",
"this",
".",
"_onKeyDown",
")",
";",
"}",
"if",
"(",
"this",
".",
"_introExitCallback",
"!=",
"undefined",
")",
"{",
"this",
".",
"_introExitCallback",
".",
"call",
"(",
"self",
")",
";",
"}",
"this",
".",
"_currentStep",
"=",
"undefined",
";",
"}"
]
| Exit from intro
@api private
@method _exitIntro
@param {Object} targetElement
@param {Boolean} force - Setting to `true` will skip the result of beforeExit callback | [
"Exit",
"from",
"intro"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L466-L549 | train |
HasakiUI/hsk-jinx | src/component/intro/intro.js | _checkRight | function _checkRight(targetOffset, tooltipLayerStyleLeft, tooltipOffset, windowSize, tooltipLayer) {
if (targetOffset.left + tooltipLayerStyleLeft + tooltipOffset.width > windowSize.width) {
// off the right side of the window
tooltipLayer.style.left = windowSize.width - tooltipOffset.width - targetOffset.left + 'px';
return false;
}
tooltipLayer.style.left = tooltipLayerStyleLeft + 'px';
return true;
} | javascript | function _checkRight(targetOffset, tooltipLayerStyleLeft, tooltipOffset, windowSize, tooltipLayer) {
if (targetOffset.left + tooltipLayerStyleLeft + tooltipOffset.width > windowSize.width) {
// off the right side of the window
tooltipLayer.style.left = windowSize.width - tooltipOffset.width - targetOffset.left + 'px';
return false;
}
tooltipLayer.style.left = tooltipLayerStyleLeft + 'px';
return true;
} | [
"function",
"_checkRight",
"(",
"targetOffset",
",",
"tooltipLayerStyleLeft",
",",
"tooltipOffset",
",",
"windowSize",
",",
"tooltipLayer",
")",
"{",
"if",
"(",
"targetOffset",
".",
"left",
"+",
"tooltipLayerStyleLeft",
"+",
"tooltipOffset",
".",
"width",
">",
"windowSize",
".",
"width",
")",
"{",
"tooltipLayer",
".",
"style",
".",
"left",
"=",
"windowSize",
".",
"width",
"-",
"tooltipOffset",
".",
"width",
"-",
"targetOffset",
".",
"left",
"+",
"'px'",
";",
"return",
"false",
";",
"}",
"tooltipLayer",
".",
"style",
".",
"left",
"=",
"tooltipLayerStyleLeft",
"+",
"'px'",
";",
"return",
"true",
";",
"}"
]
| Set tooltip left so it doesn't go off the right side of the window
@return boolean true, if tooltipLayerStyleLeft is ok. false, otherwise. | [
"Set",
"tooltip",
"left",
"so",
"it",
"doesn",
"t",
"go",
"off",
"the",
"right",
"side",
"of",
"the",
"window"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L739-L747 | train |
HasakiUI/hsk-jinx | src/component/intro/intro.js | _determineAutoPosition | function _determineAutoPosition(targetElement, tooltipLayer, desiredTooltipPosition) {
// Take a clone of position precedence. These will be the available
var possiblePositions = this._options.positionPrecedence.slice();
var windowSize = _getWinSize();
var tooltipHeight = _getOffset(tooltipLayer).height + 10;
var tooltipWidth = _getOffset(tooltipLayer).width + 20;
var targetOffset = _getOffset(targetElement);
// If we check all the possible areas, and there are no valid places for the tooltip, the element
// must take up most of the screen real estate. Show the tooltip floating in the middle of the screen.
var calculatedPosition = 'floating';
// TODO Update by joyer
// Check if the width of the tooltip + the starting point would spill off the right side of the screen
// If no, neither bottom or top are valid
// if (targetOffset.left + tooltipWidth > windowSize.width || ((targetOffset.left + (targetOffset.width / 2)) - tooltipWidth) < 0) {
// _removeEntry(possiblePositions, "bottom");
// _removeEntry(possiblePositions, "top");
// } else {
// Check for space below
if (targetOffset.height + targetOffset.top + tooltipHeight > windowSize.height) {
_removeEntry(possiblePositions, 'bottom');
}
// Check for space above
if (targetOffset.top - tooltipHeight < 0) {
_removeEntry(possiblePositions, 'top');
}
// }
// Check for space to the right
if (targetOffset.width + targetOffset.left + tooltipWidth > windowSize.width) {
_removeEntry(possiblePositions, 'right');
}
// Check for space to the left
if (targetOffset.left - tooltipWidth < 0) {
_removeEntry(possiblePositions, 'left');
}
// At this point, our array only has positions that are valid. Pick the first one, as it remains in order
if (possiblePositions.length > 0) {
calculatedPosition = possiblePositions[0];
}
// If the requested position is in the list, replace our calculated choice with that
if (desiredTooltipPosition && desiredTooltipPosition != 'auto') {
if (possiblePositions.indexOf(desiredTooltipPosition) > -1) {
calculatedPosition = desiredTooltipPosition;
}
}
return calculatedPosition;
} | javascript | function _determineAutoPosition(targetElement, tooltipLayer, desiredTooltipPosition) {
// Take a clone of position precedence. These will be the available
var possiblePositions = this._options.positionPrecedence.slice();
var windowSize = _getWinSize();
var tooltipHeight = _getOffset(tooltipLayer).height + 10;
var tooltipWidth = _getOffset(tooltipLayer).width + 20;
var targetOffset = _getOffset(targetElement);
// If we check all the possible areas, and there are no valid places for the tooltip, the element
// must take up most of the screen real estate. Show the tooltip floating in the middle of the screen.
var calculatedPosition = 'floating';
// TODO Update by joyer
// Check if the width of the tooltip + the starting point would spill off the right side of the screen
// If no, neither bottom or top are valid
// if (targetOffset.left + tooltipWidth > windowSize.width || ((targetOffset.left + (targetOffset.width / 2)) - tooltipWidth) < 0) {
// _removeEntry(possiblePositions, "bottom");
// _removeEntry(possiblePositions, "top");
// } else {
// Check for space below
if (targetOffset.height + targetOffset.top + tooltipHeight > windowSize.height) {
_removeEntry(possiblePositions, 'bottom');
}
// Check for space above
if (targetOffset.top - tooltipHeight < 0) {
_removeEntry(possiblePositions, 'top');
}
// }
// Check for space to the right
if (targetOffset.width + targetOffset.left + tooltipWidth > windowSize.width) {
_removeEntry(possiblePositions, 'right');
}
// Check for space to the left
if (targetOffset.left - tooltipWidth < 0) {
_removeEntry(possiblePositions, 'left');
}
// At this point, our array only has positions that are valid. Pick the first one, as it remains in order
if (possiblePositions.length > 0) {
calculatedPosition = possiblePositions[0];
}
// If the requested position is in the list, replace our calculated choice with that
if (desiredTooltipPosition && desiredTooltipPosition != 'auto') {
if (possiblePositions.indexOf(desiredTooltipPosition) > -1) {
calculatedPosition = desiredTooltipPosition;
}
}
return calculatedPosition;
} | [
"function",
"_determineAutoPosition",
"(",
"targetElement",
",",
"tooltipLayer",
",",
"desiredTooltipPosition",
")",
"{",
"var",
"possiblePositions",
"=",
"this",
".",
"_options",
".",
"positionPrecedence",
".",
"slice",
"(",
")",
";",
"var",
"windowSize",
"=",
"_getWinSize",
"(",
")",
";",
"var",
"tooltipHeight",
"=",
"_getOffset",
"(",
"tooltipLayer",
")",
".",
"height",
"+",
"10",
";",
"var",
"tooltipWidth",
"=",
"_getOffset",
"(",
"tooltipLayer",
")",
".",
"width",
"+",
"20",
";",
"var",
"targetOffset",
"=",
"_getOffset",
"(",
"targetElement",
")",
";",
"var",
"calculatedPosition",
"=",
"'floating'",
";",
"if",
"(",
"targetOffset",
".",
"height",
"+",
"targetOffset",
".",
"top",
"+",
"tooltipHeight",
">",
"windowSize",
".",
"height",
")",
"{",
"_removeEntry",
"(",
"possiblePositions",
",",
"'bottom'",
")",
";",
"}",
"if",
"(",
"targetOffset",
".",
"top",
"-",
"tooltipHeight",
"<",
"0",
")",
"{",
"_removeEntry",
"(",
"possiblePositions",
",",
"'top'",
")",
";",
"}",
"if",
"(",
"targetOffset",
".",
"width",
"+",
"targetOffset",
".",
"left",
"+",
"tooltipWidth",
">",
"windowSize",
".",
"width",
")",
"{",
"_removeEntry",
"(",
"possiblePositions",
",",
"'right'",
")",
";",
"}",
"if",
"(",
"targetOffset",
".",
"left",
"-",
"tooltipWidth",
"<",
"0",
")",
"{",
"_removeEntry",
"(",
"possiblePositions",
",",
"'left'",
")",
";",
"}",
"if",
"(",
"possiblePositions",
".",
"length",
">",
"0",
")",
"{",
"calculatedPosition",
"=",
"possiblePositions",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"desiredTooltipPosition",
"&&",
"desiredTooltipPosition",
"!=",
"'auto'",
")",
"{",
"if",
"(",
"possiblePositions",
".",
"indexOf",
"(",
"desiredTooltipPosition",
")",
">",
"-",
"1",
")",
"{",
"calculatedPosition",
"=",
"desiredTooltipPosition",
";",
"}",
"}",
"return",
"calculatedPosition",
";",
"}"
]
| Determines the position of the tooltip based on the position precedence and availability
of screen space.
@param {Object} targetElement
@param {Object} tooltipLayer
@param {Object} desiredTooltipPosition | [
"Determines",
"the",
"position",
"of",
"the",
"tooltip",
"based",
"on",
"the",
"position",
"precedence",
"and",
"availability",
"of",
"screen",
"space",
"."
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L773-L827 | train |
HasakiUI/hsk-jinx | src/component/intro/intro.js | _removeEntry | function _removeEntry(stringArray, stringToRemove) {
if (stringArray.indexOf(stringToRemove) > -1) {
stringArray.splice(stringArray.indexOf(stringToRemove), 1);
}
} | javascript | function _removeEntry(stringArray, stringToRemove) {
if (stringArray.indexOf(stringToRemove) > -1) {
stringArray.splice(stringArray.indexOf(stringToRemove), 1);
}
} | [
"function",
"_removeEntry",
"(",
"stringArray",
",",
"stringToRemove",
")",
"{",
"if",
"(",
"stringArray",
".",
"indexOf",
"(",
"stringToRemove",
")",
">",
"-",
"1",
")",
"{",
"stringArray",
".",
"splice",
"(",
"stringArray",
".",
"indexOf",
"(",
"stringToRemove",
")",
",",
"1",
")",
";",
"}",
"}"
]
| Remove an entry from a string array if it's there, does nothing if it isn't there.
@param {Array} stringArray
@param {String} stringToRemove | [
"Remove",
"an",
"entry",
"from",
"a",
"string",
"array",
"if",
"it",
"s",
"there",
"does",
"nothing",
"if",
"it",
"isn",
"t",
"there",
"."
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L835-L839 | train |
HasakiUI/hsk-jinx | src/component/intro/intro.js | _setHelperLayerPosition | function _setHelperLayerPosition(helperLayer) {
if (helperLayer) {
//prevent error when `this._currentStep` in undefined
if (!this._introItems[this._currentStep]) return;
var currentElement = this._introItems[this._currentStep],
elementPosition = _getOffset(currentElement.element),
widthHeightPadding = 10;
// If the target element is fixed, the tooltip should be fixed as well.
// Otherwise, remove a fixed class that may be left over from the previous
// step.
if (_isFixed(currentElement.element)) {
helperLayer.className += ' introjs-fixedTooltip';
} else {
helperLayer.className = helperLayer.className.replace(' introjs-fixedTooltip', '');
}
if (currentElement.position == 'floating') {
widthHeightPadding = 0;
}
//set new position to helper layer
helperLayer.setAttribute(
'style',
'width: ' +
(elementPosition.width + widthHeightPadding) +
'px; ' +
'height:' +
(elementPosition.height + widthHeightPadding) +
'px; ' +
'top:' +
(elementPosition.top - 5) +
'px;' +
'left: ' +
(elementPosition.left - 5) +
'px;'
);
}
} | javascript | function _setHelperLayerPosition(helperLayer) {
if (helperLayer) {
//prevent error when `this._currentStep` in undefined
if (!this._introItems[this._currentStep]) return;
var currentElement = this._introItems[this._currentStep],
elementPosition = _getOffset(currentElement.element),
widthHeightPadding = 10;
// If the target element is fixed, the tooltip should be fixed as well.
// Otherwise, remove a fixed class that may be left over from the previous
// step.
if (_isFixed(currentElement.element)) {
helperLayer.className += ' introjs-fixedTooltip';
} else {
helperLayer.className = helperLayer.className.replace(' introjs-fixedTooltip', '');
}
if (currentElement.position == 'floating') {
widthHeightPadding = 0;
}
//set new position to helper layer
helperLayer.setAttribute(
'style',
'width: ' +
(elementPosition.width + widthHeightPadding) +
'px; ' +
'height:' +
(elementPosition.height + widthHeightPadding) +
'px; ' +
'top:' +
(elementPosition.top - 5) +
'px;' +
'left: ' +
(elementPosition.left - 5) +
'px;'
);
}
} | [
"function",
"_setHelperLayerPosition",
"(",
"helperLayer",
")",
"{",
"if",
"(",
"helperLayer",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_introItems",
"[",
"this",
".",
"_currentStep",
"]",
")",
"return",
";",
"var",
"currentElement",
"=",
"this",
".",
"_introItems",
"[",
"this",
".",
"_currentStep",
"]",
",",
"elementPosition",
"=",
"_getOffset",
"(",
"currentElement",
".",
"element",
")",
",",
"widthHeightPadding",
"=",
"10",
";",
"if",
"(",
"_isFixed",
"(",
"currentElement",
".",
"element",
")",
")",
"{",
"helperLayer",
".",
"className",
"+=",
"' introjs-fixedTooltip'",
";",
"}",
"else",
"{",
"helperLayer",
".",
"className",
"=",
"helperLayer",
".",
"className",
".",
"replace",
"(",
"' introjs-fixedTooltip'",
",",
"''",
")",
";",
"}",
"if",
"(",
"currentElement",
".",
"position",
"==",
"'floating'",
")",
"{",
"widthHeightPadding",
"=",
"0",
";",
"}",
"helperLayer",
".",
"setAttribute",
"(",
"'style'",
",",
"'width: '",
"+",
"(",
"elementPosition",
".",
"width",
"+",
"widthHeightPadding",
")",
"+",
"'px; '",
"+",
"'height:'",
"+",
"(",
"elementPosition",
".",
"height",
"+",
"widthHeightPadding",
")",
"+",
"'px; '",
"+",
"'top:'",
"+",
"(",
"elementPosition",
".",
"top",
"-",
"5",
")",
"+",
"'px;'",
"+",
"'left: '",
"+",
"(",
"elementPosition",
".",
"left",
"-",
"5",
")",
"+",
"'px;'",
")",
";",
"}",
"}"
]
| Update the position of the helper layer on the screen
@api private
@method _setHelperLayerPosition
@param {Object} helperLayer | [
"Update",
"the",
"position",
"of",
"the",
"helper",
"layer",
"on",
"the",
"screen"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L848-L887 | train |
HasakiUI/hsk-jinx | src/component/intro/intro.js | _disableInteraction | function _disableInteraction() {
var disableInteractionLayer = document.querySelector('.introjs-disableInteraction');
if (disableInteractionLayer === null) {
disableInteractionLayer = document.createElement('div');
disableInteractionLayer.className = 'introjs-disableInteraction';
this._targetElement.appendChild(disableInteractionLayer);
}
_setHelperLayerPosition.call(this, disableInteractionLayer);
} | javascript | function _disableInteraction() {
var disableInteractionLayer = document.querySelector('.introjs-disableInteraction');
if (disableInteractionLayer === null) {
disableInteractionLayer = document.createElement('div');
disableInteractionLayer.className = 'introjs-disableInteraction';
this._targetElement.appendChild(disableInteractionLayer);
}
_setHelperLayerPosition.call(this, disableInteractionLayer);
} | [
"function",
"_disableInteraction",
"(",
")",
"{",
"var",
"disableInteractionLayer",
"=",
"document",
".",
"querySelector",
"(",
"'.introjs-disableInteraction'",
")",
";",
"if",
"(",
"disableInteractionLayer",
"===",
"null",
")",
"{",
"disableInteractionLayer",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"disableInteractionLayer",
".",
"className",
"=",
"'introjs-disableInteraction'",
";",
"this",
".",
"_targetElement",
".",
"appendChild",
"(",
"disableInteractionLayer",
")",
";",
"}",
"_setHelperLayerPosition",
".",
"call",
"(",
"this",
",",
"disableInteractionLayer",
")",
";",
"}"
]
| Add disableinteraction layer and adjust the size and position of the layer
@api private
@method _disableInteraction | [
"Add",
"disableinteraction",
"layer",
"and",
"adjust",
"the",
"size",
"and",
"position",
"of",
"the",
"layer"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L895-L905 | train |
HasakiUI/hsk-jinx | src/component/intro/intro.js | _scrollTo | function _scrollTo(scrollTo, targetElement, tooltipLayer) {
if (!this._options.scrollToElement) return;
if (scrollTo === 'tooltip') {
var rect = tooltipLayer.getBoundingClientRect();
} else {
var rect = targetElement.element.getBoundingClientRect();
}
if (!_elementInViewport(targetElement.element)) {
var winHeight = _getWinSize().height;
var top = rect.bottom - (rect.bottom - rect.top);
var bottom = rect.bottom - winHeight;
// TODO (afshinm): do we need scroll padding now?
// I have changed the scroll option and now it scrolls the window to
// the center of the target element or tooltip.
if (top < 0 || targetElement.element.clientHeight > winHeight) {
window.scrollBy(
0,
rect.top - (winHeight / 2 - rect.height / 2) - this._options.scrollPadding
); // 30px padding from edge to look nice
//Scroll down
} else {
window.scrollBy(
0,
rect.top - (winHeight / 2 - rect.height / 2) + this._options.scrollPadding
); // 30px padding from edge to look nice
}
}
} | javascript | function _scrollTo(scrollTo, targetElement, tooltipLayer) {
if (!this._options.scrollToElement) return;
if (scrollTo === 'tooltip') {
var rect = tooltipLayer.getBoundingClientRect();
} else {
var rect = targetElement.element.getBoundingClientRect();
}
if (!_elementInViewport(targetElement.element)) {
var winHeight = _getWinSize().height;
var top = rect.bottom - (rect.bottom - rect.top);
var bottom = rect.bottom - winHeight;
// TODO (afshinm): do we need scroll padding now?
// I have changed the scroll option and now it scrolls the window to
// the center of the target element or tooltip.
if (top < 0 || targetElement.element.clientHeight > winHeight) {
window.scrollBy(
0,
rect.top - (winHeight / 2 - rect.height / 2) - this._options.scrollPadding
); // 30px padding from edge to look nice
//Scroll down
} else {
window.scrollBy(
0,
rect.top - (winHeight / 2 - rect.height / 2) + this._options.scrollPadding
); // 30px padding from edge to look nice
}
}
} | [
"function",
"_scrollTo",
"(",
"scrollTo",
",",
"targetElement",
",",
"tooltipLayer",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_options",
".",
"scrollToElement",
")",
"return",
";",
"if",
"(",
"scrollTo",
"===",
"'tooltip'",
")",
"{",
"var",
"rect",
"=",
"tooltipLayer",
".",
"getBoundingClientRect",
"(",
")",
";",
"}",
"else",
"{",
"var",
"rect",
"=",
"targetElement",
".",
"element",
".",
"getBoundingClientRect",
"(",
")",
";",
"}",
"if",
"(",
"!",
"_elementInViewport",
"(",
"targetElement",
".",
"element",
")",
")",
"{",
"var",
"winHeight",
"=",
"_getWinSize",
"(",
")",
".",
"height",
";",
"var",
"top",
"=",
"rect",
".",
"bottom",
"-",
"(",
"rect",
".",
"bottom",
"-",
"rect",
".",
"top",
")",
";",
"var",
"bottom",
"=",
"rect",
".",
"bottom",
"-",
"winHeight",
";",
"if",
"(",
"top",
"<",
"0",
"||",
"targetElement",
".",
"element",
".",
"clientHeight",
">",
"winHeight",
")",
"{",
"window",
".",
"scrollBy",
"(",
"0",
",",
"rect",
".",
"top",
"-",
"(",
"winHeight",
"/",
"2",
"-",
"rect",
".",
"height",
"/",
"2",
")",
"-",
"this",
".",
"_options",
".",
"scrollPadding",
")",
";",
"}",
"else",
"{",
"window",
".",
"scrollBy",
"(",
"0",
",",
"rect",
".",
"top",
"-",
"(",
"winHeight",
"/",
"2",
"-",
"rect",
".",
"height",
"/",
"2",
")",
"+",
"this",
".",
"_options",
".",
"scrollPadding",
")",
";",
"}",
"}",
"}"
]
| To change the scroll of `window` after highlighting an element
@api private
@method _scrollTo
@param {String} scrollTo
@param {Object} targetElement
@param {Object} tooltipLayer | [
"To",
"change",
"the",
"scroll",
"of",
"window",
"after",
"highlighting",
"an",
"element"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L1309-L1341 | train |
HasakiUI/hsk-jinx | src/component/intro/intro.js | _populateHints | function _populateHints(targetElm) {
var self = this;
this._introItems = [];
if (this._options.hints) {
for (var i = 0, l = this._options.hints.length; i < l; i++) {
var currentItem = _cloneObject(this._options.hints[i]);
if (typeof currentItem.element === 'string') {
//grab the element with given selector from the page
currentItem.element = document.querySelector(currentItem.element);
}
currentItem.hintPosition = currentItem.hintPosition || this._options.hintPosition;
currentItem.hintAnimation = currentItem.hintAnimation || this._options.hintAnimation;
if (currentItem.element != null) {
this._introItems.push(currentItem);
}
}
} else {
var hints = targetElm.querySelectorAll('*[data-hint]');
if (hints.length < 1) {
return false;
}
//first add intro items with data-step
for (var i = 0, l = hints.length; i < l; i++) {
var currentElement = hints[i];
// hint animation
var hintAnimation = currentElement.getAttribute('data-hintAnimation');
if (hintAnimation) {
hintAnimation = hintAnimation == 'true';
} else {
hintAnimation = this._options.hintAnimation;
}
this._introItems.push({
element: currentElement,
hint: currentElement.getAttribute('data-hint'),
hintPosition:
currentElement.getAttribute('data-hintPosition') || this._options.hintPosition,
hintAnimation: hintAnimation,
tooltipClass: currentElement.getAttribute('data-tooltipClass'),
position:
currentElement.getAttribute('data-position') || this._options.tooltipPosition
});
}
}
_addHints.call(this);
if (document.addEventListener) {
document.addEventListener('click', _removeHintTooltip.bind(this), false);
//for window resize
window.addEventListener('resize', _reAlignHints.bind(this), true);
} else if (document.attachEvent) {
//IE
//for window resize
document.attachEvent('onclick', _removeHintTooltip.bind(this));
document.attachEvent('onresize', _reAlignHints.bind(this));
}
} | javascript | function _populateHints(targetElm) {
var self = this;
this._introItems = [];
if (this._options.hints) {
for (var i = 0, l = this._options.hints.length; i < l; i++) {
var currentItem = _cloneObject(this._options.hints[i]);
if (typeof currentItem.element === 'string') {
//grab the element with given selector from the page
currentItem.element = document.querySelector(currentItem.element);
}
currentItem.hintPosition = currentItem.hintPosition || this._options.hintPosition;
currentItem.hintAnimation = currentItem.hintAnimation || this._options.hintAnimation;
if (currentItem.element != null) {
this._introItems.push(currentItem);
}
}
} else {
var hints = targetElm.querySelectorAll('*[data-hint]');
if (hints.length < 1) {
return false;
}
//first add intro items with data-step
for (var i = 0, l = hints.length; i < l; i++) {
var currentElement = hints[i];
// hint animation
var hintAnimation = currentElement.getAttribute('data-hintAnimation');
if (hintAnimation) {
hintAnimation = hintAnimation == 'true';
} else {
hintAnimation = this._options.hintAnimation;
}
this._introItems.push({
element: currentElement,
hint: currentElement.getAttribute('data-hint'),
hintPosition:
currentElement.getAttribute('data-hintPosition') || this._options.hintPosition,
hintAnimation: hintAnimation,
tooltipClass: currentElement.getAttribute('data-tooltipClass'),
position:
currentElement.getAttribute('data-position') || this._options.tooltipPosition
});
}
}
_addHints.call(this);
if (document.addEventListener) {
document.addEventListener('click', _removeHintTooltip.bind(this), false);
//for window resize
window.addEventListener('resize', _reAlignHints.bind(this), true);
} else if (document.attachEvent) {
//IE
//for window resize
document.attachEvent('onclick', _removeHintTooltip.bind(this));
document.attachEvent('onresize', _reAlignHints.bind(this));
}
} | [
"function",
"_populateHints",
"(",
"targetElm",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"_introItems",
"=",
"[",
"]",
";",
"if",
"(",
"this",
".",
"_options",
".",
"hints",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"this",
".",
"_options",
".",
"hints",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"currentItem",
"=",
"_cloneObject",
"(",
"this",
".",
"_options",
".",
"hints",
"[",
"i",
"]",
")",
";",
"if",
"(",
"typeof",
"currentItem",
".",
"element",
"===",
"'string'",
")",
"{",
"currentItem",
".",
"element",
"=",
"document",
".",
"querySelector",
"(",
"currentItem",
".",
"element",
")",
";",
"}",
"currentItem",
".",
"hintPosition",
"=",
"currentItem",
".",
"hintPosition",
"||",
"this",
".",
"_options",
".",
"hintPosition",
";",
"currentItem",
".",
"hintAnimation",
"=",
"currentItem",
".",
"hintAnimation",
"||",
"this",
".",
"_options",
".",
"hintAnimation",
";",
"if",
"(",
"currentItem",
".",
"element",
"!=",
"null",
")",
"{",
"this",
".",
"_introItems",
".",
"push",
"(",
"currentItem",
")",
";",
"}",
"}",
"}",
"else",
"{",
"var",
"hints",
"=",
"targetElm",
".",
"querySelectorAll",
"(",
"'*[data-hint]'",
")",
";",
"if",
"(",
"hints",
".",
"length",
"<",
"1",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"hints",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"currentElement",
"=",
"hints",
"[",
"i",
"]",
";",
"var",
"hintAnimation",
"=",
"currentElement",
".",
"getAttribute",
"(",
"'data-hintAnimation'",
")",
";",
"if",
"(",
"hintAnimation",
")",
"{",
"hintAnimation",
"=",
"hintAnimation",
"==",
"'true'",
";",
"}",
"else",
"{",
"hintAnimation",
"=",
"this",
".",
"_options",
".",
"hintAnimation",
";",
"}",
"this",
".",
"_introItems",
".",
"push",
"(",
"{",
"element",
":",
"currentElement",
",",
"hint",
":",
"currentElement",
".",
"getAttribute",
"(",
"'data-hint'",
")",
",",
"hintPosition",
":",
"currentElement",
".",
"getAttribute",
"(",
"'data-hintPosition'",
")",
"||",
"this",
".",
"_options",
".",
"hintPosition",
",",
"hintAnimation",
":",
"hintAnimation",
",",
"tooltipClass",
":",
"currentElement",
".",
"getAttribute",
"(",
"'data-tooltipClass'",
")",
",",
"position",
":",
"currentElement",
".",
"getAttribute",
"(",
"'data-position'",
")",
"||",
"this",
".",
"_options",
".",
"tooltipPosition",
"}",
")",
";",
"}",
"}",
"_addHints",
".",
"call",
"(",
"this",
")",
";",
"if",
"(",
"document",
".",
"addEventListener",
")",
"{",
"document",
".",
"addEventListener",
"(",
"'click'",
",",
"_removeHintTooltip",
".",
"bind",
"(",
"this",
")",
",",
"false",
")",
";",
"window",
".",
"addEventListener",
"(",
"'resize'",
",",
"_reAlignHints",
".",
"bind",
"(",
"this",
")",
",",
"true",
")",
";",
"}",
"else",
"if",
"(",
"document",
".",
"attachEvent",
")",
"{",
"document",
".",
"attachEvent",
"(",
"'onclick'",
",",
"_removeHintTooltip",
".",
"bind",
"(",
"this",
")",
")",
";",
"document",
".",
"attachEvent",
"(",
"'onresize'",
",",
"_reAlignHints",
".",
"bind",
"(",
"this",
")",
")",
";",
"}",
"}"
]
| Start parsing hint items
@api private
@param {Object} targetElm
@method _startHint | [
"Start",
"parsing",
"hint",
"items"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L1604-L1669 | train |
HasakiUI/hsk-jinx | src/component/intro/intro.js | _reAlignHints | function _reAlignHints() {
for (var i = 0, l = this._introItems.length; i < l; i++) {
var item = this._introItems[i];
if (typeof item.targetElement == 'undefined') continue;
_alignHintPosition.call(this, item.hintPosition, item.element, item.targetElement);
}
} | javascript | function _reAlignHints() {
for (var i = 0, l = this._introItems.length; i < l; i++) {
var item = this._introItems[i];
if (typeof item.targetElement == 'undefined') continue;
_alignHintPosition.call(this, item.hintPosition, item.element, item.targetElement);
}
} | [
"function",
"_reAlignHints",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"this",
".",
"_introItems",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"item",
"=",
"this",
".",
"_introItems",
"[",
"i",
"]",
";",
"if",
"(",
"typeof",
"item",
".",
"targetElement",
"==",
"'undefined'",
")",
"continue",
";",
"_alignHintPosition",
".",
"call",
"(",
"this",
",",
"item",
".",
"hintPosition",
",",
"item",
".",
"element",
",",
"item",
".",
"targetElement",
")",
";",
"}",
"}"
]
| Re-aligns all hint elements
@api private
@method _reAlignHints | [
"Re",
"-",
"aligns",
"all",
"hint",
"elements"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L1677-L1685 | train |
HasakiUI/hsk-jinx | src/component/intro/intro.js | _hideHint | function _hideHint(stepId) {
_removeHintTooltip.call(this);
var hint = this._targetElement.querySelector('.introjs-hint[data-step="' + stepId + '"]');
if (hint) {
hint.className += ' introjs-hidehint';
}
// call the callback function (if any)
if (typeof this._hintCloseCallback !== 'undefined') {
this._hintCloseCallback.call(this, stepId);
}
} | javascript | function _hideHint(stepId) {
_removeHintTooltip.call(this);
var hint = this._targetElement.querySelector('.introjs-hint[data-step="' + stepId + '"]');
if (hint) {
hint.className += ' introjs-hidehint';
}
// call the callback function (if any)
if (typeof this._hintCloseCallback !== 'undefined') {
this._hintCloseCallback.call(this, stepId);
}
} | [
"function",
"_hideHint",
"(",
"stepId",
")",
"{",
"_removeHintTooltip",
".",
"call",
"(",
"this",
")",
";",
"var",
"hint",
"=",
"this",
".",
"_targetElement",
".",
"querySelector",
"(",
"'.introjs-hint[data-step=\"'",
"+",
"stepId",
"+",
"'\"]'",
")",
";",
"if",
"(",
"hint",
")",
"{",
"hint",
".",
"className",
"+=",
"' introjs-hidehint'",
";",
"}",
"if",
"(",
"typeof",
"this",
".",
"_hintCloseCallback",
"!==",
"'undefined'",
")",
"{",
"this",
".",
"_hintCloseCallback",
".",
"call",
"(",
"this",
",",
"stepId",
")",
";",
"}",
"}"
]
| Hide a hint
@api private
@method _hideHint | [
"Hide",
"a",
"hint"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L1693-L1705 | train |
HasakiUI/hsk-jinx | src/component/intro/intro.js | _hideHints | function _hideHints() {
var hints = this._targetElement.querySelectorAll('.introjs-hint');
if (hints && hints.length > 0) {
for (var i = 0; i < hints.length; i++) {
_hideHint.call(this, hints[i].getAttribute('data-step'));
}
}
} | javascript | function _hideHints() {
var hints = this._targetElement.querySelectorAll('.introjs-hint');
if (hints && hints.length > 0) {
for (var i = 0; i < hints.length; i++) {
_hideHint.call(this, hints[i].getAttribute('data-step'));
}
}
} | [
"function",
"_hideHints",
"(",
")",
"{",
"var",
"hints",
"=",
"this",
".",
"_targetElement",
".",
"querySelectorAll",
"(",
"'.introjs-hint'",
")",
";",
"if",
"(",
"hints",
"&&",
"hints",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"hints",
".",
"length",
";",
"i",
"++",
")",
"{",
"_hideHint",
".",
"call",
"(",
"this",
",",
"hints",
"[",
"i",
"]",
".",
"getAttribute",
"(",
"'data-step'",
")",
")",
";",
"}",
"}",
"}"
]
| Hide all hints
@api private
@method _hideHints | [
"Hide",
"all",
"hints"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L1713-L1721 | train |
HasakiUI/hsk-jinx | src/component/intro/intro.js | _showHints | function _showHints() {
var hints = this._targetElement.querySelectorAll('.introjs-hint');
if (hints && hints.length > 0) {
for (var i = 0; i < hints.length; i++) {
_showHint.call(this, hints[i].getAttribute('data-step'));
}
} else {
_populateHints.call(this, this._targetElement);
}
} | javascript | function _showHints() {
var hints = this._targetElement.querySelectorAll('.introjs-hint');
if (hints && hints.length > 0) {
for (var i = 0; i < hints.length; i++) {
_showHint.call(this, hints[i].getAttribute('data-step'));
}
} else {
_populateHints.call(this, this._targetElement);
}
} | [
"function",
"_showHints",
"(",
")",
"{",
"var",
"hints",
"=",
"this",
".",
"_targetElement",
".",
"querySelectorAll",
"(",
"'.introjs-hint'",
")",
";",
"if",
"(",
"hints",
"&&",
"hints",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"hints",
".",
"length",
";",
"i",
"++",
")",
"{",
"_showHint",
".",
"call",
"(",
"this",
",",
"hints",
"[",
"i",
"]",
".",
"getAttribute",
"(",
"'data-step'",
")",
")",
";",
"}",
"}",
"else",
"{",
"_populateHints",
".",
"call",
"(",
"this",
",",
"this",
".",
"_targetElement",
")",
";",
"}",
"}"
]
| Show all hints
@api private
@method _showHints | [
"Show",
"all",
"hints"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L1729-L1739 | train |
HasakiUI/hsk-jinx | src/component/intro/intro.js | _showHint | function _showHint(stepId) {
var hint = this._targetElement.querySelector('.introjs-hint[data-step="' + stepId + '"]');
if (hint) {
hint.className = hint.className.replace(/introjs\-hidehint/g, '');
}
} | javascript | function _showHint(stepId) {
var hint = this._targetElement.querySelector('.introjs-hint[data-step="' + stepId + '"]');
if (hint) {
hint.className = hint.className.replace(/introjs\-hidehint/g, '');
}
} | [
"function",
"_showHint",
"(",
"stepId",
")",
"{",
"var",
"hint",
"=",
"this",
".",
"_targetElement",
".",
"querySelector",
"(",
"'.introjs-hint[data-step=\"'",
"+",
"stepId",
"+",
"'\"]'",
")",
";",
"if",
"(",
"hint",
")",
"{",
"hint",
".",
"className",
"=",
"hint",
".",
"className",
".",
"replace",
"(",
"/",
"introjs\\-hidehint",
"/",
"g",
",",
"''",
")",
";",
"}",
"}"
]
| Show a hint
@api private
@method _showHint | [
"Show",
"a",
"hint"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L1747-L1753 | train |
HasakiUI/hsk-jinx | src/component/intro/intro.js | _addHints | function _addHints() {
var self = this;
var oldHintsWrapper = document.querySelector('.introjs-hints');
if (oldHintsWrapper != null) {
hintsWrapper = oldHintsWrapper;
} else {
var hintsWrapper = document.createElement('div');
hintsWrapper.className = 'introjs-hints';
}
for (var i = 0, l = this._introItems.length; i < l; i++) {
var item = this._introItems[i];
// avoid append a hint twice
if (document.querySelector('.introjs-hint[data-step="' + i + '"]')) continue;
var hint = document.createElement('a');
_setAnchorAsButton(hint);
(function(hint, item, i) {
// when user clicks on the hint element
hint.onclick = function(e) {
var evt = e ? e : window.event;
if (evt.stopPropagation) evt.stopPropagation();
if (evt.cancelBubble != null) evt.cancelBubble = true;
_showHintDialog.call(self, i);
};
})(hint, item, i);
hint.className = 'introjs-hint';
if (!item.hintAnimation) {
hint.className += ' introjs-hint-no-anim';
}
// hint's position should be fixed if the target element's position is fixed
if (_isFixed(item.element)) {
hint.className += ' introjs-fixedhint';
}
var hintDot = document.createElement('div');
hintDot.className = 'introjs-hint-dot';
var hintPulse = document.createElement('div');
hintPulse.className = 'introjs-hint-pulse';
hint.appendChild(hintDot);
hint.appendChild(hintPulse);
hint.setAttribute('data-step', i);
// we swap the hint element with target element
// because _setHelperLayerPosition uses `element` property
item.targetElement = item.element;
item.element = hint;
// align the hint position
_alignHintPosition.call(this, item.hintPosition, hint, item.targetElement);
hintsWrapper.appendChild(hint);
}
// adding the hints wrapper
document.body.appendChild(hintsWrapper);
// call the callback function (if any)
if (typeof this._hintsAddedCallback !== 'undefined') {
this._hintsAddedCallback.call(this);
}
} | javascript | function _addHints() {
var self = this;
var oldHintsWrapper = document.querySelector('.introjs-hints');
if (oldHintsWrapper != null) {
hintsWrapper = oldHintsWrapper;
} else {
var hintsWrapper = document.createElement('div');
hintsWrapper.className = 'introjs-hints';
}
for (var i = 0, l = this._introItems.length; i < l; i++) {
var item = this._introItems[i];
// avoid append a hint twice
if (document.querySelector('.introjs-hint[data-step="' + i + '"]')) continue;
var hint = document.createElement('a');
_setAnchorAsButton(hint);
(function(hint, item, i) {
// when user clicks on the hint element
hint.onclick = function(e) {
var evt = e ? e : window.event;
if (evt.stopPropagation) evt.stopPropagation();
if (evt.cancelBubble != null) evt.cancelBubble = true;
_showHintDialog.call(self, i);
};
})(hint, item, i);
hint.className = 'introjs-hint';
if (!item.hintAnimation) {
hint.className += ' introjs-hint-no-anim';
}
// hint's position should be fixed if the target element's position is fixed
if (_isFixed(item.element)) {
hint.className += ' introjs-fixedhint';
}
var hintDot = document.createElement('div');
hintDot.className = 'introjs-hint-dot';
var hintPulse = document.createElement('div');
hintPulse.className = 'introjs-hint-pulse';
hint.appendChild(hintDot);
hint.appendChild(hintPulse);
hint.setAttribute('data-step', i);
// we swap the hint element with target element
// because _setHelperLayerPosition uses `element` property
item.targetElement = item.element;
item.element = hint;
// align the hint position
_alignHintPosition.call(this, item.hintPosition, hint, item.targetElement);
hintsWrapper.appendChild(hint);
}
// adding the hints wrapper
document.body.appendChild(hintsWrapper);
// call the callback function (if any)
if (typeof this._hintsAddedCallback !== 'undefined') {
this._hintsAddedCallback.call(this);
}
} | [
"function",
"_addHints",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"oldHintsWrapper",
"=",
"document",
".",
"querySelector",
"(",
"'.introjs-hints'",
")",
";",
"if",
"(",
"oldHintsWrapper",
"!=",
"null",
")",
"{",
"hintsWrapper",
"=",
"oldHintsWrapper",
";",
"}",
"else",
"{",
"var",
"hintsWrapper",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"hintsWrapper",
".",
"className",
"=",
"'introjs-hints'",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"this",
".",
"_introItems",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"item",
"=",
"this",
".",
"_introItems",
"[",
"i",
"]",
";",
"if",
"(",
"document",
".",
"querySelector",
"(",
"'.introjs-hint[data-step=\"'",
"+",
"i",
"+",
"'\"]'",
")",
")",
"continue",
";",
"var",
"hint",
"=",
"document",
".",
"createElement",
"(",
"'a'",
")",
";",
"_setAnchorAsButton",
"(",
"hint",
")",
";",
"(",
"function",
"(",
"hint",
",",
"item",
",",
"i",
")",
"{",
"hint",
".",
"onclick",
"=",
"function",
"(",
"e",
")",
"{",
"var",
"evt",
"=",
"e",
"?",
"e",
":",
"window",
".",
"event",
";",
"if",
"(",
"evt",
".",
"stopPropagation",
")",
"evt",
".",
"stopPropagation",
"(",
")",
";",
"if",
"(",
"evt",
".",
"cancelBubble",
"!=",
"null",
")",
"evt",
".",
"cancelBubble",
"=",
"true",
";",
"_showHintDialog",
".",
"call",
"(",
"self",
",",
"i",
")",
";",
"}",
";",
"}",
")",
"(",
"hint",
",",
"item",
",",
"i",
")",
";",
"hint",
".",
"className",
"=",
"'introjs-hint'",
";",
"if",
"(",
"!",
"item",
".",
"hintAnimation",
")",
"{",
"hint",
".",
"className",
"+=",
"' introjs-hint-no-anim'",
";",
"}",
"if",
"(",
"_isFixed",
"(",
"item",
".",
"element",
")",
")",
"{",
"hint",
".",
"className",
"+=",
"' introjs-fixedhint'",
";",
"}",
"var",
"hintDot",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"hintDot",
".",
"className",
"=",
"'introjs-hint-dot'",
";",
"var",
"hintPulse",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"hintPulse",
".",
"className",
"=",
"'introjs-hint-pulse'",
";",
"hint",
".",
"appendChild",
"(",
"hintDot",
")",
";",
"hint",
".",
"appendChild",
"(",
"hintPulse",
")",
";",
"hint",
".",
"setAttribute",
"(",
"'data-step'",
",",
"i",
")",
";",
"item",
".",
"targetElement",
"=",
"item",
".",
"element",
";",
"item",
".",
"element",
"=",
"hint",
";",
"_alignHintPosition",
".",
"call",
"(",
"this",
",",
"item",
".",
"hintPosition",
",",
"hint",
",",
"item",
".",
"targetElement",
")",
";",
"hintsWrapper",
".",
"appendChild",
"(",
"hint",
")",
";",
"}",
"document",
".",
"body",
".",
"appendChild",
"(",
"hintsWrapper",
")",
";",
"if",
"(",
"typeof",
"this",
".",
"_hintsAddedCallback",
"!==",
"'undefined'",
")",
"{",
"this",
".",
"_hintsAddedCallback",
".",
"call",
"(",
"this",
")",
";",
"}",
"}"
]
| Add all available hints to the page
@api private
@method _addHints | [
"Add",
"all",
"available",
"hints",
"to",
"the",
"page"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L1794-L1864 | train |
canjs/can-bind | can-bind.js | turnOffListeningAndUpdate | function turnOffListeningAndUpdate(listenToObservable, updateObservable, updateFunction, queue) {
var offValueOrOffEmitFn;
// Use either offValue or offEmit depending on which Symbols are on the `observable`
if (listenToObservable[onValueSymbol]) {
offValueOrOffEmitFn = canReflect.offValue;
} else if (listenToObservable[onEmitSymbol]) {
offValueOrOffEmitFn = offEmit;
}
if (offValueOrOffEmitFn) {
offValueOrOffEmitFn(listenToObservable, updateFunction, queue);
//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
// The updateObservable is no longer mutated by listenToObservable
canReflectDeps.deleteMutatedBy(updateObservable, listenToObservable);
// The updateFunction no longer mutates anything
updateFunction[getChangesSymbol] = function getChangesDependencyRecord() {
};
}
//!steal-remove-end
}
} | javascript | function turnOffListeningAndUpdate(listenToObservable, updateObservable, updateFunction, queue) {
var offValueOrOffEmitFn;
// Use either offValue or offEmit depending on which Symbols are on the `observable`
if (listenToObservable[onValueSymbol]) {
offValueOrOffEmitFn = canReflect.offValue;
} else if (listenToObservable[onEmitSymbol]) {
offValueOrOffEmitFn = offEmit;
}
if (offValueOrOffEmitFn) {
offValueOrOffEmitFn(listenToObservable, updateFunction, queue);
//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
// The updateObservable is no longer mutated by listenToObservable
canReflectDeps.deleteMutatedBy(updateObservable, listenToObservable);
// The updateFunction no longer mutates anything
updateFunction[getChangesSymbol] = function getChangesDependencyRecord() {
};
}
//!steal-remove-end
}
} | [
"function",
"turnOffListeningAndUpdate",
"(",
"listenToObservable",
",",
"updateObservable",
",",
"updateFunction",
",",
"queue",
")",
"{",
"var",
"offValueOrOffEmitFn",
";",
"if",
"(",
"listenToObservable",
"[",
"onValueSymbol",
"]",
")",
"{",
"offValueOrOffEmitFn",
"=",
"canReflect",
".",
"offValue",
";",
"}",
"else",
"if",
"(",
"listenToObservable",
"[",
"onEmitSymbol",
"]",
")",
"{",
"offValueOrOffEmitFn",
"=",
"offEmit",
";",
"}",
"if",
"(",
"offValueOrOffEmitFn",
")",
"{",
"offValueOrOffEmitFn",
"(",
"listenToObservable",
",",
"updateFunction",
",",
"queue",
")",
";",
"if",
"(",
"process",
".",
"env",
".",
"NODE_ENV",
"!==",
"'production'",
")",
"{",
"canReflectDeps",
".",
"deleteMutatedBy",
"(",
"updateObservable",
",",
"listenToObservable",
")",
";",
"updateFunction",
"[",
"getChangesSymbol",
"]",
"=",
"function",
"getChangesDependencyRecord",
"(",
")",
"{",
"}",
";",
"}",
"}",
"}"
]
| Given an observable, stop listening to it and tear down the mutation dependencies | [
"Given",
"an",
"observable",
"stop",
"listening",
"to",
"it",
"and",
"tear",
"down",
"the",
"mutation",
"dependencies"
]
| 22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761 | https://github.com/canjs/can-bind/blob/22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761/can-bind.js#L39-L65 | train |
canjs/can-bind | can-bind.js | turnOnListeningAndUpdate | function turnOnListeningAndUpdate(listenToObservable, updateObservable, updateFunction, queue) {
var onValueOrOnEmitFn;
// Use either onValue or onEmit depending on which Symbols are on the `observable`
if (listenToObservable[onValueSymbol]) {
onValueOrOnEmitFn = canReflect.onValue;
} else if (listenToObservable[onEmitSymbol]) {
onValueOrOnEmitFn = onEmit;
}
if (onValueOrOnEmitFn) {
onValueOrOnEmitFn(listenToObservable, updateFunction, queue);
//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
// The updateObservable is mutated by listenToObservable
canReflectDeps.addMutatedBy(updateObservable, listenToObservable);
// The updateFunction mutates updateObservable
updateFunction[getChangesSymbol] = function getChangesDependencyRecord() {
var s = new Set();
s.add(updateObservable);
return {
valueDependencies: s
};
};
}
//!steal-remove-end
}
} | javascript | function turnOnListeningAndUpdate(listenToObservable, updateObservable, updateFunction, queue) {
var onValueOrOnEmitFn;
// Use either onValue or onEmit depending on which Symbols are on the `observable`
if (listenToObservable[onValueSymbol]) {
onValueOrOnEmitFn = canReflect.onValue;
} else if (listenToObservable[onEmitSymbol]) {
onValueOrOnEmitFn = onEmit;
}
if (onValueOrOnEmitFn) {
onValueOrOnEmitFn(listenToObservable, updateFunction, queue);
//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
// The updateObservable is mutated by listenToObservable
canReflectDeps.addMutatedBy(updateObservable, listenToObservable);
// The updateFunction mutates updateObservable
updateFunction[getChangesSymbol] = function getChangesDependencyRecord() {
var s = new Set();
s.add(updateObservable);
return {
valueDependencies: s
};
};
}
//!steal-remove-end
}
} | [
"function",
"turnOnListeningAndUpdate",
"(",
"listenToObservable",
",",
"updateObservable",
",",
"updateFunction",
",",
"queue",
")",
"{",
"var",
"onValueOrOnEmitFn",
";",
"if",
"(",
"listenToObservable",
"[",
"onValueSymbol",
"]",
")",
"{",
"onValueOrOnEmitFn",
"=",
"canReflect",
".",
"onValue",
";",
"}",
"else",
"if",
"(",
"listenToObservable",
"[",
"onEmitSymbol",
"]",
")",
"{",
"onValueOrOnEmitFn",
"=",
"onEmit",
";",
"}",
"if",
"(",
"onValueOrOnEmitFn",
")",
"{",
"onValueOrOnEmitFn",
"(",
"listenToObservable",
",",
"updateFunction",
",",
"queue",
")",
";",
"if",
"(",
"process",
".",
"env",
".",
"NODE_ENV",
"!==",
"'production'",
")",
"{",
"canReflectDeps",
".",
"addMutatedBy",
"(",
"updateObservable",
",",
"listenToObservable",
")",
";",
"updateFunction",
"[",
"getChangesSymbol",
"]",
"=",
"function",
"getChangesDependencyRecord",
"(",
")",
"{",
"var",
"s",
"=",
"new",
"Set",
"(",
")",
";",
"s",
".",
"add",
"(",
"updateObservable",
")",
";",
"return",
"{",
"valueDependencies",
":",
"s",
"}",
";",
"}",
";",
"}",
"}",
"}"
]
| Given an observable, start listening to it and set up the mutation dependencies | [
"Given",
"an",
"observable",
"start",
"listening",
"to",
"it",
"and",
"set",
"up",
"the",
"mutation",
"dependencies"
]
| 22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761 | https://github.com/canjs/can-bind/blob/22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761/can-bind.js#L68-L100 | train |
canjs/can-bind | can-bind.js | function() {
if (this._bindingState.child === false && this._childToParent === true) {
var options = this._options;
this._bindingState.child = true;
turnOnListeningAndUpdate(options.child, options.parent, this._updateParent, options.queue);
}
} | javascript | function() {
if (this._bindingState.child === false && this._childToParent === true) {
var options = this._options;
this._bindingState.child = true;
turnOnListeningAndUpdate(options.child, options.parent, this._updateParent, options.queue);
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_bindingState",
".",
"child",
"===",
"false",
"&&",
"this",
".",
"_childToParent",
"===",
"true",
")",
"{",
"var",
"options",
"=",
"this",
".",
"_options",
";",
"this",
".",
"_bindingState",
".",
"child",
"=",
"true",
";",
"turnOnListeningAndUpdate",
"(",
"options",
".",
"child",
",",
"options",
".",
"parent",
",",
"this",
".",
"_updateParent",
",",
"options",
".",
"queue",
")",
";",
"}",
"}"
]
| Listen for changes to the child observable and update the parent | [
"Listen",
"for",
"changes",
"to",
"the",
"child",
"observable",
"and",
"update",
"the",
"parent"
]
| 22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761 | https://github.com/canjs/can-bind/blob/22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761/can-bind.js#L402-L408 | train |
|
canjs/can-bind | can-bind.js | function() {
if (this._bindingState.parent === false && this._parentToChild === true) {
var options = this._options;
this._bindingState.parent = true;
turnOnListeningAndUpdate(options.parent, options.child, this._updateChild, options.queue);
}
} | javascript | function() {
if (this._bindingState.parent === false && this._parentToChild === true) {
var options = this._options;
this._bindingState.parent = true;
turnOnListeningAndUpdate(options.parent, options.child, this._updateChild, options.queue);
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_bindingState",
".",
"parent",
"===",
"false",
"&&",
"this",
".",
"_parentToChild",
"===",
"true",
")",
"{",
"var",
"options",
"=",
"this",
".",
"_options",
";",
"this",
".",
"_bindingState",
".",
"parent",
"=",
"true",
";",
"turnOnListeningAndUpdate",
"(",
"options",
".",
"parent",
",",
"options",
".",
"child",
",",
"this",
".",
"_updateChild",
",",
"options",
".",
"queue",
")",
";",
"}",
"}"
]
| Listen for changes to the parent observable and update the child | [
"Listen",
"for",
"changes",
"to",
"the",
"parent",
"observable",
"and",
"update",
"the",
"child"
]
| 22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761 | https://github.com/canjs/can-bind/blob/22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761/can-bind.js#L411-L417 | train |
|
canjs/can-bind | can-bind.js | function() {
var bindingState = this._bindingState;
var options = this._options;
// Turn off the parent listener
if (bindingState.parent === true && this._parentToChild === true) {
bindingState.parent = false;
turnOffListeningAndUpdate(options.parent, options.child, this._updateChild, options.queue);
}
// Turn off the child listener
if (bindingState.child === true && this._childToParent === true) {
bindingState.child = false;
turnOffListeningAndUpdate(options.child, options.parent, this._updateParent, options.queue);
}
} | javascript | function() {
var bindingState = this._bindingState;
var options = this._options;
// Turn off the parent listener
if (bindingState.parent === true && this._parentToChild === true) {
bindingState.parent = false;
turnOffListeningAndUpdate(options.parent, options.child, this._updateChild, options.queue);
}
// Turn off the child listener
if (bindingState.child === true && this._childToParent === true) {
bindingState.child = false;
turnOffListeningAndUpdate(options.child, options.parent, this._updateParent, options.queue);
}
} | [
"function",
"(",
")",
"{",
"var",
"bindingState",
"=",
"this",
".",
"_bindingState",
";",
"var",
"options",
"=",
"this",
".",
"_options",
";",
"if",
"(",
"bindingState",
".",
"parent",
"===",
"true",
"&&",
"this",
".",
"_parentToChild",
"===",
"true",
")",
"{",
"bindingState",
".",
"parent",
"=",
"false",
";",
"turnOffListeningAndUpdate",
"(",
"options",
".",
"parent",
",",
"options",
".",
"child",
",",
"this",
".",
"_updateChild",
",",
"options",
".",
"queue",
")",
";",
"}",
"if",
"(",
"bindingState",
".",
"child",
"===",
"true",
"&&",
"this",
".",
"_childToParent",
"===",
"true",
")",
"{",
"bindingState",
".",
"child",
"=",
"false",
";",
"turnOffListeningAndUpdate",
"(",
"options",
".",
"child",
",",
"options",
".",
"parent",
",",
"this",
".",
"_updateParent",
",",
"options",
".",
"queue",
")",
";",
"}",
"}"
]
| Turn off all the bindings | [
"Turn",
"off",
"all",
"the",
"bindings"
]
| 22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761 | https://github.com/canjs/can-bind/blob/22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761/can-bind.js#L420-L435 | train |
|
verma/greyhound.js | lib/greyhound.js | function(mins, maxs) {
// make sure correct number of elements in both mins and maxs
if (mins.length != 3 ||
maxs.length != 3)
throw new Error("Mins and Maxs should have 3 elements each");
// make sure all maxes are greater than mins
mins.forEach(function(v, i) {
if (v >= maxs[i])
throw new Error("All elements of maxs should be greater than mins");
});
this.mins = mins;
this.maxs = maxs;
} | javascript | function(mins, maxs) {
// make sure correct number of elements in both mins and maxs
if (mins.length != 3 ||
maxs.length != 3)
throw new Error("Mins and Maxs should have 3 elements each");
// make sure all maxes are greater than mins
mins.forEach(function(v, i) {
if (v >= maxs[i])
throw new Error("All elements of maxs should be greater than mins");
});
this.mins = mins;
this.maxs = maxs;
} | [
"function",
"(",
"mins",
",",
"maxs",
")",
"{",
"if",
"(",
"mins",
".",
"length",
"!=",
"3",
"||",
"maxs",
".",
"length",
"!=",
"3",
")",
"throw",
"new",
"Error",
"(",
"\"Mins and Maxs should have 3 elements each\"",
")",
";",
"mins",
".",
"forEach",
"(",
"function",
"(",
"v",
",",
"i",
")",
"{",
"if",
"(",
"v",
">=",
"maxs",
"[",
"i",
"]",
")",
"throw",
"new",
"Error",
"(",
"\"All elements of maxs should be greater than mins\"",
")",
";",
"}",
")",
";",
"this",
".",
"mins",
"=",
"mins",
";",
"this",
".",
"maxs",
"=",
"maxs",
";",
"}"
]
| A bounding box abstraction class which can be passed to or returned by the reader. This bounding box is not a general
purpose bounding box, but is rather geared towards geo data. It is also, always axis aligned.
The ground is in the X,Y plane and Z represents the height, the Z coordinate is never touched when perfoming
splitting actions. Top refers to North, Left to West, Right to East and Bottom to South.
@class
@return {BBox} | [
"A",
"bounding",
"box",
"abstraction",
"class",
"which",
"can",
"be",
"passed",
"to",
"or",
"returned",
"by",
"the",
"reader",
".",
"This",
"bounding",
"box",
"is",
"not",
"a",
"general",
"purpose",
"bounding",
"box",
"but",
"is",
"rather",
"geared",
"towards",
"geo",
"data",
".",
"It",
"is",
"also",
"always",
"axis",
"aligned",
".",
"The",
"ground",
"is",
"in",
"the",
"X",
"Y",
"plane",
"and",
"Z",
"represents",
"the",
"height",
"the",
"Z",
"coordinate",
"is",
"never",
"touched",
"when",
"perfoming",
"splitting",
"actions",
".",
"Top",
"refers",
"to",
"North",
"Left",
"to",
"West",
"Right",
"to",
"East",
"and",
"Bottom",
"to",
"South",
"."
]
| d219b9eb9ec12af6a006f29d604543b61d2ae0a9 | https://github.com/verma/greyhound.js/blob/d219b9eb9ec12af6a006f29d604543b61d2ae0a9/lib/greyhound.js#L206-L220 | train |
|
verma/greyhound.js | lib/greyhound.js | function(host) {
if (!host)
throw new Error('Need hostname to initialize reader');
if (host.match(/^(\S+):\/\//))
throw new Error('Protocol specified, need bare hostname');
this.host = host;
var portParts = this.host.match(/:(\d+)$/);
if (portParts !== null)
this.port = parseInt(portParts[1]);
else
this.port = 80;
// make sure port stuff is taken out of the host
//
var hostParts = this.host.match(/^(\S+):/);
if (hostParts)
this.host = hostParts[1];
} | javascript | function(host) {
if (!host)
throw new Error('Need hostname to initialize reader');
if (host.match(/^(\S+):\/\//))
throw new Error('Protocol specified, need bare hostname');
this.host = host;
var portParts = this.host.match(/:(\d+)$/);
if (portParts !== null)
this.port = parseInt(portParts[1]);
else
this.port = 80;
// make sure port stuff is taken out of the host
//
var hostParts = this.host.match(/^(\S+):/);
if (hostParts)
this.host = hostParts[1];
} | [
"function",
"(",
"host",
")",
"{",
"if",
"(",
"!",
"host",
")",
"throw",
"new",
"Error",
"(",
"'Need hostname to initialize reader'",
")",
";",
"if",
"(",
"host",
".",
"match",
"(",
"/",
"^(\\S+):\\/\\/",
"/",
")",
")",
"throw",
"new",
"Error",
"(",
"'Protocol specified, need bare hostname'",
")",
";",
"this",
".",
"host",
"=",
"host",
";",
"var",
"portParts",
"=",
"this",
".",
"host",
".",
"match",
"(",
"/",
":(\\d+)$",
"/",
")",
";",
"if",
"(",
"portParts",
"!==",
"null",
")",
"this",
".",
"port",
"=",
"parseInt",
"(",
"portParts",
"[",
"1",
"]",
")",
";",
"else",
"this",
".",
"port",
"=",
"80",
";",
"var",
"hostParts",
"=",
"this",
".",
"host",
".",
"match",
"(",
"/",
"^(\\S+):",
"/",
")",
";",
"if",
"(",
"hostParts",
")",
"this",
".",
"host",
"=",
"hostParts",
"[",
"1",
"]",
";",
"}"
]
| A greyhound data reader implementation. This class abstracts the details of reading data
from greyhound servers.
@example
var gh = new GrehoundReader("myserver.com");
// create a session
//
gh.createSession("pipelineid", function(err, id) {
// read some stats just for kicks
gh.getStats(id, function(err, stats) {
// print some informations
console.log("Mins:", stats.mins(), "Maxs:", stats.maxs());
// Read EVERYTHING
gh.read(id, function(err, data) {
// Do fun stuff with data
console.log("Read all the data");
// Finally destroy the session
gh.destroy(id, function(err) {
console.log("Bye");
// always a good practice to close this stuff
gh.close();
});
});
});
});
@class
@param {string} host - Should be a bare hostname with no protocol specified, but may specify a port name .e.g myserver.com:8012
@return {GreyhoundReader} When initialized with new, returns a new reader instance | [
"A",
"greyhound",
"data",
"reader",
"implementation",
".",
"This",
"class",
"abstracts",
"the",
"details",
"of",
"reading",
"data",
"from",
"greyhound",
"servers",
"."
]
| d219b9eb9ec12af6a006f29d604543b61d2ae0a9 | https://github.com/verma/greyhound.js/blob/d219b9eb9ec12af6a006f29d604543b61d2ae0a9/lib/greyhound.js#L426-L446 | train |
|
owejs/owe | src/filter.js | filterGenerator | function filterGenerator(filter) {
if(typeof filter === "boolean")
return () => filter;
if(typeof filter === "function")
return filter;
if(filter instanceof RegExp)
return input => filter.test(input);
if(filter instanceof Set)
return input => filter.has(input);
if(filter instanceof Map)
return input => !!filter.get(input);
if(Array.isArray(filter))
return input => filter.indexOf(input) !== -1;
if(filter && typeof filter === "object")
return input => !!filter[input];
throw new TypeError("Invalid filter type.");
} | javascript | function filterGenerator(filter) {
if(typeof filter === "boolean")
return () => filter;
if(typeof filter === "function")
return filter;
if(filter instanceof RegExp)
return input => filter.test(input);
if(filter instanceof Set)
return input => filter.has(input);
if(filter instanceof Map)
return input => !!filter.get(input);
if(Array.isArray(filter))
return input => filter.indexOf(input) !== -1;
if(filter && typeof filter === "object")
return input => !!filter[input];
throw new TypeError("Invalid filter type.");
} | [
"function",
"filterGenerator",
"(",
"filter",
")",
"{",
"if",
"(",
"typeof",
"filter",
"===",
"\"boolean\"",
")",
"return",
"(",
")",
"=>",
"filter",
";",
"if",
"(",
"typeof",
"filter",
"===",
"\"function\"",
")",
"return",
"filter",
";",
"if",
"(",
"filter",
"instanceof",
"RegExp",
")",
"return",
"input",
"=>",
"filter",
".",
"test",
"(",
"input",
")",
";",
"if",
"(",
"filter",
"instanceof",
"Set",
")",
"return",
"input",
"=>",
"filter",
".",
"has",
"(",
"input",
")",
";",
"if",
"(",
"filter",
"instanceof",
"Map",
")",
"return",
"input",
"=>",
"!",
"!",
"filter",
".",
"get",
"(",
"input",
")",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"filter",
")",
")",
"return",
"input",
"=>",
"filter",
".",
"indexOf",
"(",
"input",
")",
"!==",
"-",
"1",
";",
"if",
"(",
"filter",
"&&",
"typeof",
"filter",
"===",
"\"object\"",
")",
"return",
"input",
"=>",
"!",
"!",
"filter",
"[",
"input",
"]",
";",
"throw",
"new",
"TypeError",
"(",
"\"Invalid filter type.\"",
")",
";",
"}"
]
| Generates a filter function out of the given filter.
@param {any} filter The filter.
@return {function} A filter function for `filter`. | [
"Generates",
"a",
"filter",
"function",
"out",
"of",
"the",
"given",
"filter",
"."
]
| 5e1ed342a9b2f20af4e633d706543da7f3a64b8a | https://github.com/owejs/owe/blob/5e1ed342a9b2f20af4e633d706543da7f3a64b8a/src/filter.js#L8-L31 | train |
nearform/nscale-docker-ssh-analyzer | dockerApi.js | preconnect | function preconnect(user, sshKeyPath, ipaddress, cb, pollCount) {
if (pollCount === undefined) {
pollCount = 0;
}
logger.info({
user: user,
identityFile: sshKeyPath,
ipAddress: ipaddress
}, 'waiting for connectivity');
portscanner.checkPortStatus(22, ipaddress, function(err, status) {
if (status === 'closed') {
if (pollCount > MAX_POLLS) {
pollCount = 0;
cb('timeout exceeded - unable to connect to: ' + ipaddress);
}
else {
pollCount = pollCount + 1;
setTimeout(function() { preconnect(user, sshKeyPath, ipaddress, cb, pollCount); }, POLL_INTERVAL);
}
}
else if (status === 'open') {
pollCount = 0;
sshCheck.check(ipaddress, user, sshKeyPath, null, function(err) {
cb(err);
});
}
});
} | javascript | function preconnect(user, sshKeyPath, ipaddress, cb, pollCount) {
if (pollCount === undefined) {
pollCount = 0;
}
logger.info({
user: user,
identityFile: sshKeyPath,
ipAddress: ipaddress
}, 'waiting for connectivity');
portscanner.checkPortStatus(22, ipaddress, function(err, status) {
if (status === 'closed') {
if (pollCount > MAX_POLLS) {
pollCount = 0;
cb('timeout exceeded - unable to connect to: ' + ipaddress);
}
else {
pollCount = pollCount + 1;
setTimeout(function() { preconnect(user, sshKeyPath, ipaddress, cb, pollCount); }, POLL_INTERVAL);
}
}
else if (status === 'open') {
pollCount = 0;
sshCheck.check(ipaddress, user, sshKeyPath, null, function(err) {
cb(err);
});
}
});
} | [
"function",
"preconnect",
"(",
"user",
",",
"sshKeyPath",
",",
"ipaddress",
",",
"cb",
",",
"pollCount",
")",
"{",
"if",
"(",
"pollCount",
"===",
"undefined",
")",
"{",
"pollCount",
"=",
"0",
";",
"}",
"logger",
".",
"info",
"(",
"{",
"user",
":",
"user",
",",
"identityFile",
":",
"sshKeyPath",
",",
"ipAddress",
":",
"ipaddress",
"}",
",",
"'waiting for connectivity'",
")",
";",
"portscanner",
".",
"checkPortStatus",
"(",
"22",
",",
"ipaddress",
",",
"function",
"(",
"err",
",",
"status",
")",
"{",
"if",
"(",
"status",
"===",
"'closed'",
")",
"{",
"if",
"(",
"pollCount",
">",
"MAX_POLLS",
")",
"{",
"pollCount",
"=",
"0",
";",
"cb",
"(",
"'timeout exceeded - unable to connect to: '",
"+",
"ipaddress",
")",
";",
"}",
"else",
"{",
"pollCount",
"=",
"pollCount",
"+",
"1",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"preconnect",
"(",
"user",
",",
"sshKeyPath",
",",
"ipaddress",
",",
"cb",
",",
"pollCount",
")",
";",
"}",
",",
"POLL_INTERVAL",
")",
";",
"}",
"}",
"else",
"if",
"(",
"status",
"===",
"'open'",
")",
"{",
"pollCount",
"=",
"0",
";",
"sshCheck",
".",
"check",
"(",
"ipaddress",
",",
"user",
",",
"sshKeyPath",
",",
"null",
",",
"function",
"(",
"err",
")",
"{",
"cb",
"(",
"err",
")",
";",
"}",
")",
";",
"}",
"}",
")",
";",
"}"
]
| preconnect in the case that ssh multiplexing is operative | [
"preconnect",
"in",
"the",
"case",
"that",
"ssh",
"multiplexing",
"is",
"operative"
]
| 2e983b2e58ce40aba5842d0d97aea86a90654b02 | https://github.com/nearform/nscale-docker-ssh-analyzer/blob/2e983b2e58ce40aba5842d0d97aea86a90654b02/dockerApi.js#L58-L87 | train |
seattleacademy/mcp9808 | examples/graph-webpage/js/main.js | UpdateChartData | function UpdateChartData()
{
while(Points > 10)
{
Points -= 1;
myLineChart.removeData();
}
myLineChart.addData([Data["Temperature"]], Math.floor((Date.now() - StartTime) / 1000.0));
myLineChart.update();
Points+=1;
} | javascript | function UpdateChartData()
{
while(Points > 10)
{
Points -= 1;
myLineChart.removeData();
}
myLineChart.addData([Data["Temperature"]], Math.floor((Date.now() - StartTime) / 1000.0));
myLineChart.update();
Points+=1;
} | [
"function",
"UpdateChartData",
"(",
")",
"{",
"while",
"(",
"Points",
">",
"10",
")",
"{",
"Points",
"-=",
"1",
";",
"myLineChart",
".",
"removeData",
"(",
")",
";",
"}",
"myLineChart",
".",
"addData",
"(",
"[",
"Data",
"[",
"\"Temperature\"",
"]",
"]",
",",
"Math",
".",
"floor",
"(",
"(",
"Date",
".",
"now",
"(",
")",
"-",
"StartTime",
")",
"/",
"1000.0",
")",
")",
";",
"myLineChart",
".",
"update",
"(",
")",
";",
"Points",
"+=",
"1",
";",
"}"
]
| update the chart function | [
"update",
"the",
"chart",
"function"
]
| 211c07158e0585dfc3c2149b1e5e93d105d89723 | https://github.com/seattleacademy/mcp9808/blob/211c07158e0585dfc3c2149b1e5e93d105d89723/examples/graph-webpage/js/main.js#L10-L22 | train |
redturn/jsonresponse | lib/jsonresponse.js | function(err, results) {
if(err) {
this.success = false;
this.error = err;
this.results = null;
// customize error for error types
if(util.isError(err)) {
this.error = {
message: err.message,
type: err.type,
arguments: err.arguments
};
if(NODE_ENV === 'development') {
this.error.stack = err.stack;
}
}
} else {
this.success = true;
this.error = null;
this.results = convertToClient(results);
}
} | javascript | function(err, results) {
if(err) {
this.success = false;
this.error = err;
this.results = null;
// customize error for error types
if(util.isError(err)) {
this.error = {
message: err.message,
type: err.type,
arguments: err.arguments
};
if(NODE_ENV === 'development') {
this.error.stack = err.stack;
}
}
} else {
this.success = true;
this.error = null;
this.results = convertToClient(results);
}
} | [
"function",
"(",
"err",
",",
"results",
")",
"{",
"if",
"(",
"err",
")",
"{",
"this",
".",
"success",
"=",
"false",
";",
"this",
".",
"error",
"=",
"err",
";",
"this",
".",
"results",
"=",
"null",
";",
"if",
"(",
"util",
".",
"isError",
"(",
"err",
")",
")",
"{",
"this",
".",
"error",
"=",
"{",
"message",
":",
"err",
".",
"message",
",",
"type",
":",
"err",
".",
"type",
",",
"arguments",
":",
"err",
".",
"arguments",
"}",
";",
"if",
"(",
"NODE_ENV",
"===",
"'development'",
")",
"{",
"this",
".",
"error",
".",
"stack",
"=",
"err",
".",
"stack",
";",
"}",
"}",
"}",
"else",
"{",
"this",
".",
"success",
"=",
"true",
";",
"this",
".",
"error",
"=",
"null",
";",
"this",
".",
"results",
"=",
"convertToClient",
"(",
"results",
")",
";",
"}",
"}"
]
| Creates a uniform Json response object
@param err the optional error
@param results the optional results
@constructor | [
"Creates",
"a",
"uniform",
"Json",
"response",
"object"
]
| 2b8ca09784a3596c758e14230b4c1bb6111fd991 | https://github.com/redturn/jsonresponse/blob/2b8ca09784a3596c758e14230b4c1bb6111fd991/lib/jsonresponse.js#L10-L33 | train |
|
iximiuz/js-itertools | lib/permutations.js | permutations | function permutations(iterable, r) {
// (ABCD, 2) -> AB AC AD BA BC BD CA CB CD DA DB DC
// (012, 3) -> 012 021 102 120 201 210
/*
0 1 2 3, 3
______
(0, 1, 2)
(0, 1, 3)
(0, 2, 1)
(0, 2, 3)
(0, 3, 1)
(0, 3, 2)
(1, 0, 2)
(1, 0, 3)
(1, 2, 0)
(1, 2, 3)
(1, 3, 0)
(1, 3, 2)
(2, 0, 1)
(2, 0, 3)
(2, 1, 0)
(2, 1, 3)
(2, 3, 0)
(2, 3, 1)
(3, 0, 1)
(3, 0, 2)
(3, 1, 0)
(3, 1, 2)
(3, 2, 0)
(3, 2, 1)
*/
var pool = tools.toArray(tools.ensureIter(iterable));
var n = pool.length;
r = r || n;
if (r > n) {
throw new Error(
'Parameter r cannot be greater than amount of elements in the iterable [' + n + ']'
);
}
var indices = tools.newArray(r, 0, 1);
function fromIndices() {
state.current = indices.map(function(idx) {
state.used[idx] = true;
return pool[idx];
});
}
function next() {
// 0. indices: 0, 1, 2
// 1. indices: 0, 1, 3
// 2. indices: 0, 1, 4 -> carry = t 0, 1, -1 -> 0, 1, 0 -> 0, 1, 1 -> 0, 1, 2
var backtrack = null;
var i = indices.length - 1;
for (; i >= 0; i--) {
indices[i]++;
if (indices[i] === n) {
// Time to reset current index and increase previous one.
if (i === 0) {
// There is no previous index, so it's the end of generation.
continue;
}
delete state.used[indices[i - 1]]; // Release previous index
backtrack = indices[i] - 1; // Pre-save current index to be able to release it in future.
indices[i] = -1; // Reset current index
i++;
continue;
}
if (state.used[indices[i]]) {
// Trying to increase current index until find the
// lowest free value or reach the end of the range.
i++;
continue;
}
// First free value found. Release previous one.
if (backtrack !== null) {
// If we need to backtrack, doing it!
delete state.used[backtrack];
backtrack = null;
continue;
}
// Otherwise exiting from the generation.
break;
}
if (i < 0) {
state.finished = true;
} else {
fromIndices();
}
}
var state = {current: null, finished: false, used: {}};
var permutIter = {
next: function() {
state.current
? next()
: fromIndices();
return {
done: state.finished,
value: state.finished
? undefined
: state.current
};
}
};
return tools.fuseIter(permutIter, function() { return permutIter; });
} | javascript | function permutations(iterable, r) {
// (ABCD, 2) -> AB AC AD BA BC BD CA CB CD DA DB DC
// (012, 3) -> 012 021 102 120 201 210
/*
0 1 2 3, 3
______
(0, 1, 2)
(0, 1, 3)
(0, 2, 1)
(0, 2, 3)
(0, 3, 1)
(0, 3, 2)
(1, 0, 2)
(1, 0, 3)
(1, 2, 0)
(1, 2, 3)
(1, 3, 0)
(1, 3, 2)
(2, 0, 1)
(2, 0, 3)
(2, 1, 0)
(2, 1, 3)
(2, 3, 0)
(2, 3, 1)
(3, 0, 1)
(3, 0, 2)
(3, 1, 0)
(3, 1, 2)
(3, 2, 0)
(3, 2, 1)
*/
var pool = tools.toArray(tools.ensureIter(iterable));
var n = pool.length;
r = r || n;
if (r > n) {
throw new Error(
'Parameter r cannot be greater than amount of elements in the iterable [' + n + ']'
);
}
var indices = tools.newArray(r, 0, 1);
function fromIndices() {
state.current = indices.map(function(idx) {
state.used[idx] = true;
return pool[idx];
});
}
function next() {
// 0. indices: 0, 1, 2
// 1. indices: 0, 1, 3
// 2. indices: 0, 1, 4 -> carry = t 0, 1, -1 -> 0, 1, 0 -> 0, 1, 1 -> 0, 1, 2
var backtrack = null;
var i = indices.length - 1;
for (; i >= 0; i--) {
indices[i]++;
if (indices[i] === n) {
// Time to reset current index and increase previous one.
if (i === 0) {
// There is no previous index, so it's the end of generation.
continue;
}
delete state.used[indices[i - 1]]; // Release previous index
backtrack = indices[i] - 1; // Pre-save current index to be able to release it in future.
indices[i] = -1; // Reset current index
i++;
continue;
}
if (state.used[indices[i]]) {
// Trying to increase current index until find the
// lowest free value or reach the end of the range.
i++;
continue;
}
// First free value found. Release previous one.
if (backtrack !== null) {
// If we need to backtrack, doing it!
delete state.used[backtrack];
backtrack = null;
continue;
}
// Otherwise exiting from the generation.
break;
}
if (i < 0) {
state.finished = true;
} else {
fromIndices();
}
}
var state = {current: null, finished: false, used: {}};
var permutIter = {
next: function() {
state.current
? next()
: fromIndices();
return {
done: state.finished,
value: state.finished
? undefined
: state.current
};
}
};
return tools.fuseIter(permutIter, function() { return permutIter; });
} | [
"function",
"permutations",
"(",
"iterable",
",",
"r",
")",
"{",
"var",
"pool",
"=",
"tools",
".",
"toArray",
"(",
"tools",
".",
"ensureIter",
"(",
"iterable",
")",
")",
";",
"var",
"n",
"=",
"pool",
".",
"length",
";",
"r",
"=",
"r",
"||",
"n",
";",
"if",
"(",
"r",
">",
"n",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Parameter r cannot be greater than amount of elements in the iterable ['",
"+",
"n",
"+",
"']'",
")",
";",
"}",
"var",
"indices",
"=",
"tools",
".",
"newArray",
"(",
"r",
",",
"0",
",",
"1",
")",
";",
"function",
"fromIndices",
"(",
")",
"{",
"state",
".",
"current",
"=",
"indices",
".",
"map",
"(",
"function",
"(",
"idx",
")",
"{",
"state",
".",
"used",
"[",
"idx",
"]",
"=",
"true",
";",
"return",
"pool",
"[",
"idx",
"]",
";",
"}",
")",
";",
"}",
"function",
"next",
"(",
")",
"{",
"var",
"backtrack",
"=",
"null",
";",
"var",
"i",
"=",
"indices",
".",
"length",
"-",
"1",
";",
"for",
"(",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"indices",
"[",
"i",
"]",
"++",
";",
"if",
"(",
"indices",
"[",
"i",
"]",
"===",
"n",
")",
"{",
"if",
"(",
"i",
"===",
"0",
")",
"{",
"continue",
";",
"}",
"delete",
"state",
".",
"used",
"[",
"indices",
"[",
"i",
"-",
"1",
"]",
"]",
";",
"backtrack",
"=",
"indices",
"[",
"i",
"]",
"-",
"1",
";",
"indices",
"[",
"i",
"]",
"=",
"-",
"1",
";",
"i",
"++",
";",
"continue",
";",
"}",
"if",
"(",
"state",
".",
"used",
"[",
"indices",
"[",
"i",
"]",
"]",
")",
"{",
"i",
"++",
";",
"continue",
";",
"}",
"if",
"(",
"backtrack",
"!==",
"null",
")",
"{",
"delete",
"state",
".",
"used",
"[",
"backtrack",
"]",
";",
"backtrack",
"=",
"null",
";",
"continue",
";",
"}",
"break",
";",
"}",
"if",
"(",
"i",
"<",
"0",
")",
"{",
"state",
".",
"finished",
"=",
"true",
";",
"}",
"else",
"{",
"fromIndices",
"(",
")",
";",
"}",
"}",
"var",
"state",
"=",
"{",
"current",
":",
"null",
",",
"finished",
":",
"false",
",",
"used",
":",
"{",
"}",
"}",
";",
"var",
"permutIter",
"=",
"{",
"next",
":",
"function",
"(",
")",
"{",
"state",
".",
"current",
"?",
"next",
"(",
")",
":",
"fromIndices",
"(",
")",
";",
"return",
"{",
"done",
":",
"state",
".",
"finished",
",",
"value",
":",
"state",
".",
"finished",
"?",
"undefined",
":",
"state",
".",
"current",
"}",
";",
"}",
"}",
";",
"return",
"tools",
".",
"fuseIter",
"(",
"permutIter",
",",
"function",
"(",
")",
"{",
"return",
"permutIter",
";",
"}",
")",
";",
"}"
]
| Return successive r length permutations of elements in the iterable.
@param {Iterator|Iterable|Array|String} iterable
@param {Number} r - length of permutations.
@returns {Iterator|Iterable} | [
"Return",
"successive",
"r",
"length",
"permutations",
"of",
"elements",
"in",
"the",
"iterable",
"."
]
| a228cc89c39e959f0461a04cabb4f625bea1fe33 | https://github.com/iximiuz/js-itertools/blob/a228cc89c39e959f0461a04cabb4f625bea1fe33/lib/permutations.js#L12-L125 | train |
lemonde/knex-schema | lib/drop.js | drop | function drop(schemas) {
var resolver = new Resolver(schemas);
var knex = this.knex;
return Promise.map(schemas || [], function(schema) {
return (schema.preDrop || _.noop)(knex);
})
.then(function () {
// Reduce force sequential execution.
return Promise.reduce(resolver.resolve().reverse(), dropSchema.bind(this), []);
}.bind(this));
} | javascript | function drop(schemas) {
var resolver = new Resolver(schemas);
var knex = this.knex;
return Promise.map(schemas || [], function(schema) {
return (schema.preDrop || _.noop)(knex);
})
.then(function () {
// Reduce force sequential execution.
return Promise.reduce(resolver.resolve().reverse(), dropSchema.bind(this), []);
}.bind(this));
} | [
"function",
"drop",
"(",
"schemas",
")",
"{",
"var",
"resolver",
"=",
"new",
"Resolver",
"(",
"schemas",
")",
";",
"var",
"knex",
"=",
"this",
".",
"knex",
";",
"return",
"Promise",
".",
"map",
"(",
"schemas",
"||",
"[",
"]",
",",
"function",
"(",
"schema",
")",
"{",
"return",
"(",
"schema",
".",
"preDrop",
"||",
"_",
".",
"noop",
")",
"(",
"knex",
")",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"Promise",
".",
"reduce",
"(",
"resolver",
".",
"resolve",
"(",
")",
".",
"reverse",
"(",
")",
",",
"dropSchema",
".",
"bind",
"(",
"this",
")",
",",
"[",
"]",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
]
| Drop schemas tables. If it exists, it calls `preDrop` beforehand
@param {[Schemas]} schemas
@return {Promise} | [
"Drop",
"schemas",
"tables",
".",
"If",
"it",
"exists",
"it",
"calls",
"preDrop",
"beforehand"
]
| 3e0f6cde374d240552eb08e50e123a513fda44ae | https://github.com/lemonde/knex-schema/blob/3e0f6cde374d240552eb08e50e123a513fda44ae/lib/drop.js#L20-L30 | train |
lemonde/knex-schema | lib/drop.js | dropSchema | function dropSchema(result, schema) {
return this.knex.schema.dropTableIfExists(schema.tableName)
.then(function () {
return result.concat([schema]);
});
} | javascript | function dropSchema(result, schema) {
return this.knex.schema.dropTableIfExists(schema.tableName)
.then(function () {
return result.concat([schema]);
});
} | [
"function",
"dropSchema",
"(",
"result",
",",
"schema",
")",
"{",
"return",
"this",
".",
"knex",
".",
"schema",
".",
"dropTableIfExists",
"(",
"schema",
".",
"tableName",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"result",
".",
"concat",
"(",
"[",
"schema",
"]",
")",
";",
"}",
")",
";",
"}"
]
| Drop schema table.
@param {[Schema]} result - reduce accumulator
@param {Schema} schema
@return {Promise} | [
"Drop",
"schema",
"table",
"."
]
| 3e0f6cde374d240552eb08e50e123a513fda44ae | https://github.com/lemonde/knex-schema/blob/3e0f6cde374d240552eb08e50e123a513fda44ae/lib/drop.js#L40-L45 | train |
IDfr-Corporation/format-number-french | index.js | formatNumber | function formatNumber(value, options) {
options = options || {};
value += ''; // must be String Type
// not a number !!
if (!__isNumber(value)) {
return false;
}
var valueArr = __splitValue(value),
integer = valueArr[0],
negative = integer < 0,
absInteger = Math.abs(integer) + '',
formattedValue;
if (options.reduce) {
if (absInteger >= 100000 && absInteger <= 999999) {
options.prefix = 'k' + options.prefix;
integer = integer.slice(0, -3);
} else if (absInteger > 999999 && absInteger <= 9999999) {
options.prefix = 'Mio ' + options.prefix;
integer = negative ? '-' + absInteger[0] + ',' + absInteger[1] : absInteger[0] + ',' + absInteger[1];
} else if (absInteger > 9999999 && absInteger <= 999999999) {
options.prefix = 'Mio ' + options.prefix;
integer = integer.slice(0, -6);
} else if (absInteger > 999999999 && absInteger <= 9999999999) {
options.prefix = 'Mrd ' + options.prefix;
integer = integer.slice(0, -8);
integer = negative ? '-' + absInteger[0] + ',' + absInteger[1] : absInteger[0] + ',' + absInteger[1];
} else if (absInteger > 9999999999) {
options.prefix = 'Mrd ' + options.prefix;
integer = integer.slice(0, -9);
}
// add spaces
formattedValue = __addSpacesSeparator(integer);
} else {
// add spaces
valueArr[0] = __addSpacesSeparator(integer);
formattedValue = valueArr.join(',');
}
if (options.prefix) {
formattedValue += ' ' + options.prefix;
}
return formattedValue;
} | javascript | function formatNumber(value, options) {
options = options || {};
value += ''; // must be String Type
// not a number !!
if (!__isNumber(value)) {
return false;
}
var valueArr = __splitValue(value),
integer = valueArr[0],
negative = integer < 0,
absInteger = Math.abs(integer) + '',
formattedValue;
if (options.reduce) {
if (absInteger >= 100000 && absInteger <= 999999) {
options.prefix = 'k' + options.prefix;
integer = integer.slice(0, -3);
} else if (absInteger > 999999 && absInteger <= 9999999) {
options.prefix = 'Mio ' + options.prefix;
integer = negative ? '-' + absInteger[0] + ',' + absInteger[1] : absInteger[0] + ',' + absInteger[1];
} else if (absInteger > 9999999 && absInteger <= 999999999) {
options.prefix = 'Mio ' + options.prefix;
integer = integer.slice(0, -6);
} else if (absInteger > 999999999 && absInteger <= 9999999999) {
options.prefix = 'Mrd ' + options.prefix;
integer = integer.slice(0, -8);
integer = negative ? '-' + absInteger[0] + ',' + absInteger[1] : absInteger[0] + ',' + absInteger[1];
} else if (absInteger > 9999999999) {
options.prefix = 'Mrd ' + options.prefix;
integer = integer.slice(0, -9);
}
// add spaces
formattedValue = __addSpacesSeparator(integer);
} else {
// add spaces
valueArr[0] = __addSpacesSeparator(integer);
formattedValue = valueArr.join(',');
}
if (options.prefix) {
formattedValue += ' ' + options.prefix;
}
return formattedValue;
} | [
"function",
"formatNumber",
"(",
"value",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"value",
"+=",
"''",
";",
"if",
"(",
"!",
"__isNumber",
"(",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"var",
"valueArr",
"=",
"__splitValue",
"(",
"value",
")",
",",
"integer",
"=",
"valueArr",
"[",
"0",
"]",
",",
"negative",
"=",
"integer",
"<",
"0",
",",
"absInteger",
"=",
"Math",
".",
"abs",
"(",
"integer",
")",
"+",
"''",
",",
"formattedValue",
";",
"if",
"(",
"options",
".",
"reduce",
")",
"{",
"if",
"(",
"absInteger",
">=",
"100000",
"&&",
"absInteger",
"<=",
"999999",
")",
"{",
"options",
".",
"prefix",
"=",
"'k'",
"+",
"options",
".",
"prefix",
";",
"integer",
"=",
"integer",
".",
"slice",
"(",
"0",
",",
"-",
"3",
")",
";",
"}",
"else",
"if",
"(",
"absInteger",
">",
"999999",
"&&",
"absInteger",
"<=",
"9999999",
")",
"{",
"options",
".",
"prefix",
"=",
"'Mio '",
"+",
"options",
".",
"prefix",
";",
"integer",
"=",
"negative",
"?",
"'-'",
"+",
"absInteger",
"[",
"0",
"]",
"+",
"','",
"+",
"absInteger",
"[",
"1",
"]",
":",
"absInteger",
"[",
"0",
"]",
"+",
"','",
"+",
"absInteger",
"[",
"1",
"]",
";",
"}",
"else",
"if",
"(",
"absInteger",
">",
"9999999",
"&&",
"absInteger",
"<=",
"999999999",
")",
"{",
"options",
".",
"prefix",
"=",
"'Mio '",
"+",
"options",
".",
"prefix",
";",
"integer",
"=",
"integer",
".",
"slice",
"(",
"0",
",",
"-",
"6",
")",
";",
"}",
"else",
"if",
"(",
"absInteger",
">",
"999999999",
"&&",
"absInteger",
"<=",
"9999999999",
")",
"{",
"options",
".",
"prefix",
"=",
"'Mrd '",
"+",
"options",
".",
"prefix",
";",
"integer",
"=",
"integer",
".",
"slice",
"(",
"0",
",",
"-",
"8",
")",
";",
"integer",
"=",
"negative",
"?",
"'-'",
"+",
"absInteger",
"[",
"0",
"]",
"+",
"','",
"+",
"absInteger",
"[",
"1",
"]",
":",
"absInteger",
"[",
"0",
"]",
"+",
"','",
"+",
"absInteger",
"[",
"1",
"]",
";",
"}",
"else",
"if",
"(",
"absInteger",
">",
"9999999999",
")",
"{",
"options",
".",
"prefix",
"=",
"'Mrd '",
"+",
"options",
".",
"prefix",
";",
"integer",
"=",
"integer",
".",
"slice",
"(",
"0",
",",
"-",
"9",
")",
";",
"}",
"formattedValue",
"=",
"__addSpacesSeparator",
"(",
"integer",
")",
";",
"}",
"else",
"{",
"valueArr",
"[",
"0",
"]",
"=",
"__addSpacesSeparator",
"(",
"integer",
")",
";",
"formattedValue",
"=",
"valueArr",
".",
"join",
"(",
"','",
")",
";",
"}",
"if",
"(",
"options",
".",
"prefix",
")",
"{",
"formattedValue",
"+=",
"' '",
"+",
"options",
".",
"prefix",
";",
"}",
"return",
"formattedValue",
";",
"}"
]
| Return a well formatted number according to french rules
@param value
@param options | [
"Return",
"a",
"well",
"formatted",
"number",
"according",
"to",
"french",
"rules"
]
| 55dd37f034cbbb8f82ad964c1ae75975e396f642 | https://github.com/IDfr-Corporation/format-number-french/blob/55dd37f034cbbb8f82ad964c1ae75975e396f642/index.js#L21-L68 | train |
IDfr-Corporation/format-number-french | index.js | __addSpacesSeparator | function __addSpacesSeparator(val) {
var reg = /(\d+)(\d{3})/,
sep = ' ';
// val must be a type String
val += '';
while (reg.test(val)) {
val = val.replace(reg, '$1' + sep + '$2');
}
return val;
} | javascript | function __addSpacesSeparator(val) {
var reg = /(\d+)(\d{3})/,
sep = ' ';
// val must be a type String
val += '';
while (reg.test(val)) {
val = val.replace(reg, '$1' + sep + '$2');
}
return val;
} | [
"function",
"__addSpacesSeparator",
"(",
"val",
")",
"{",
"var",
"reg",
"=",
"/",
"(\\d+)(\\d{3})",
"/",
",",
"sep",
"=",
"' '",
";",
"val",
"+=",
"''",
";",
"while",
"(",
"reg",
".",
"test",
"(",
"val",
")",
")",
"{",
"val",
"=",
"val",
".",
"replace",
"(",
"reg",
",",
"'$1'",
"+",
"sep",
"+",
"'$2'",
")",
";",
"}",
"return",
"val",
";",
"}"
]
| Add a space every three characters
@param val
@returns {string}
@private | [
"Add",
"a",
"space",
"every",
"three",
"characters"
]
| 55dd37f034cbbb8f82ad964c1ae75975e396f642 | https://github.com/IDfr-Corporation/format-number-french/blob/55dd37f034cbbb8f82ad964c1ae75975e396f642/index.js#L97-L107 | train |
alexcjohnson/world-calendars | jquery-src/jquery.plugin.js | function(name, otherArgs) {
if (name === 'option' && (otherArgs.length === 0 ||
(otherArgs.length === 1 && typeof otherArgs[0] === 'string'))) {
return true;
}
return $.inArray(name, this._getters) > -1;
} | javascript | function(name, otherArgs) {
if (name === 'option' && (otherArgs.length === 0 ||
(otherArgs.length === 1 && typeof otherArgs[0] === 'string'))) {
return true;
}
return $.inArray(name, this._getters) > -1;
} | [
"function",
"(",
"name",
",",
"otherArgs",
")",
"{",
"if",
"(",
"name",
"===",
"'option'",
"&&",
"(",
"otherArgs",
".",
"length",
"===",
"0",
"||",
"(",
"otherArgs",
".",
"length",
"===",
"1",
"&&",
"typeof",
"otherArgs",
"[",
"0",
"]",
"===",
"'string'",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"$",
".",
"inArray",
"(",
"name",
",",
"this",
".",
"_getters",
")",
">",
"-",
"1",
";",
"}"
]
| Determine whether a method is a getter and doesn't permit chaining.
@private
@param name {string} The method name.
@param otherArgs {any[]} Any other arguments for the method.
@return {boolean} True if this method is a getter, false otherwise. | [
"Determine",
"whether",
"a",
"method",
"is",
"a",
"getter",
"and",
"doesn",
"t",
"permit",
"chaining",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.plugin.js#L155-L161 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.plugin.js | function(elem, options) {
elem = $(elem);
if (elem.hasClass(this._getMarker())) {
return;
}
elem.addClass(this._getMarker());
options = $.extend({}, this.defaultOptions, this._getMetadata(elem), options || {});
var inst = $.extend({name: this.name, elem: elem, options: options},
this._instSettings(elem, options));
elem.data(this.name, inst); // Save instance against element
this._postAttach(elem, inst);
this.option(elem, options);
} | javascript | function(elem, options) {
elem = $(elem);
if (elem.hasClass(this._getMarker())) {
return;
}
elem.addClass(this._getMarker());
options = $.extend({}, this.defaultOptions, this._getMetadata(elem), options || {});
var inst = $.extend({name: this.name, elem: elem, options: options},
this._instSettings(elem, options));
elem.data(this.name, inst); // Save instance against element
this._postAttach(elem, inst);
this.option(elem, options);
} | [
"function",
"(",
"elem",
",",
"options",
")",
"{",
"elem",
"=",
"$",
"(",
"elem",
")",
";",
"if",
"(",
"elem",
".",
"hasClass",
"(",
"this",
".",
"_getMarker",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"elem",
".",
"addClass",
"(",
"this",
".",
"_getMarker",
"(",
")",
")",
";",
"options",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"this",
".",
"defaultOptions",
",",
"this",
".",
"_getMetadata",
"(",
"elem",
")",
",",
"options",
"||",
"{",
"}",
")",
";",
"var",
"inst",
"=",
"$",
".",
"extend",
"(",
"{",
"name",
":",
"this",
".",
"name",
",",
"elem",
":",
"elem",
",",
"options",
":",
"options",
"}",
",",
"this",
".",
"_instSettings",
"(",
"elem",
",",
"options",
")",
")",
";",
"elem",
".",
"data",
"(",
"this",
".",
"name",
",",
"inst",
")",
";",
"this",
".",
"_postAttach",
"(",
"elem",
",",
"inst",
")",
";",
"this",
".",
"option",
"(",
"elem",
",",
"options",
")",
";",
"}"
]
| Initialise an element. Called internally only.
Adds an instance object as data named for the plugin.
@param elem {Element} The element to enhance.
@param options {object} Overriding settings. | [
"Initialise",
"an",
"element",
".",
"Called",
"internally",
"only",
".",
"Adds",
"an",
"instance",
"object",
"as",
"data",
"named",
"for",
"the",
"plugin",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.plugin.js#L167-L179 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.plugin.js | function(elem, name, value) {
elem = $(elem);
var inst = elem.data(this.name);
if (!name || (typeof name === 'string' && value == null)) {
var options = (inst || {}).options;
return (options && name ? options[name] : options);
}
if (!elem.hasClass(this._getMarker())) {
return;
}
var options = name || {};
if (typeof name === 'string') {
options = {};
options[name] = value;
}
this._optionsChanged(elem, inst, options);
$.extend(inst.options, options);
} | javascript | function(elem, name, value) {
elem = $(elem);
var inst = elem.data(this.name);
if (!name || (typeof name === 'string' && value == null)) {
var options = (inst || {}).options;
return (options && name ? options[name] : options);
}
if (!elem.hasClass(this._getMarker())) {
return;
}
var options = name || {};
if (typeof name === 'string') {
options = {};
options[name] = value;
}
this._optionsChanged(elem, inst, options);
$.extend(inst.options, options);
} | [
"function",
"(",
"elem",
",",
"name",
",",
"value",
")",
"{",
"elem",
"=",
"$",
"(",
"elem",
")",
";",
"var",
"inst",
"=",
"elem",
".",
"data",
"(",
"this",
".",
"name",
")",
";",
"if",
"(",
"!",
"name",
"||",
"(",
"typeof",
"name",
"===",
"'string'",
"&&",
"value",
"==",
"null",
")",
")",
"{",
"var",
"options",
"=",
"(",
"inst",
"||",
"{",
"}",
")",
".",
"options",
";",
"return",
"(",
"options",
"&&",
"name",
"?",
"options",
"[",
"name",
"]",
":",
"options",
")",
";",
"}",
"if",
"(",
"!",
"elem",
".",
"hasClass",
"(",
"this",
".",
"_getMarker",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"var",
"options",
"=",
"name",
"||",
"{",
"}",
";",
"if",
"(",
"typeof",
"name",
"===",
"'string'",
")",
"{",
"options",
"=",
"{",
"}",
";",
"options",
"[",
"name",
"]",
"=",
"value",
";",
"}",
"this",
".",
"_optionsChanged",
"(",
"elem",
",",
"inst",
",",
"options",
")",
";",
"$",
".",
"extend",
"(",
"inst",
".",
"options",
",",
"options",
")",
";",
"}"
]
| Retrieve or reconfigure the settings for a plugin.
@param elem {Element} The source element.
@param name {object|string} The collection of new option values or the name of a single option.
@param [value] {any} The value for a single named option.
@return {any|object} If retrieving a single value or all options.
@example $(selector).plugin('option', 'name', value)
$(selector).plugin('option', {name: value, ...})
var value = $(selector).plugin('option', 'name')
var options = $(selector).plugin('option') | [
"Retrieve",
"or",
"reconfigure",
"the",
"settings",
"for",
"a",
"plugin",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.plugin.js#L250-L267 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.plugin.js | function(superClass, overrides) {
if (typeof superClass === 'object') {
overrides = superClass;
superClass = 'JQPlugin';
}
superClass = camelCase(superClass);
var className = camelCase(overrides.name);
JQClass.classes[className] = JQClass.classes[superClass].extend(overrides);
new JQClass.classes[className]();
} | javascript | function(superClass, overrides) {
if (typeof superClass === 'object') {
overrides = superClass;
superClass = 'JQPlugin';
}
superClass = camelCase(superClass);
var className = camelCase(overrides.name);
JQClass.classes[className] = JQClass.classes[superClass].extend(overrides);
new JQClass.classes[className]();
} | [
"function",
"(",
"superClass",
",",
"overrides",
")",
"{",
"if",
"(",
"typeof",
"superClass",
"===",
"'object'",
")",
"{",
"overrides",
"=",
"superClass",
";",
"superClass",
"=",
"'JQPlugin'",
";",
"}",
"superClass",
"=",
"camelCase",
"(",
"superClass",
")",
";",
"var",
"className",
"=",
"camelCase",
"(",
"overrides",
".",
"name",
")",
";",
"JQClass",
".",
"classes",
"[",
"className",
"]",
"=",
"JQClass",
".",
"classes",
"[",
"superClass",
"]",
".",
"extend",
"(",
"overrides",
")",
";",
"new",
"JQClass",
".",
"classes",
"[",
"className",
"]",
"(",
")",
";",
"}"
]
| Create a new collection plugin.
@memberof "$.JQPlugin"
@param [superClass='JQPlugin'] {string} The name of the parent class to inherit from.
@param overrides {object} The property/function overrides for the new class.
@example $.JQPlugin.createPlugin({
name: 'tabs',
defaultOptions: {selectedClass: 'selected'},
_initSettings: function(elem, options) { return {...}; },
_postAttach: function(elem, inst) { ... }
}); | [
"Create",
"a",
"new",
"collection",
"plugin",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.plugin.js#L332-L341 | train |
|
ssulleyymmann/ng-all-login | docs/vendor.bundle.js | fingerprint | function fingerprint(str) {
var /** @type {?} */ utf8 = utf8Encode(str);
var _a = [hash32(utf8, 0), hash32(utf8, 102072)], hi = _a[0], lo = _a[1];
if (hi == 0 && (lo == 0 || lo == 1)) {
hi = hi ^ 0x130f9bef;
lo = lo ^ -0x6b5f56d8;
}
return [hi, lo];
} | javascript | function fingerprint(str) {
var /** @type {?} */ utf8 = utf8Encode(str);
var _a = [hash32(utf8, 0), hash32(utf8, 102072)], hi = _a[0], lo = _a[1];
if (hi == 0 && (lo == 0 || lo == 1)) {
hi = hi ^ 0x130f9bef;
lo = lo ^ -0x6b5f56d8;
}
return [hi, lo];
} | [
"function",
"fingerprint",
"(",
"str",
")",
"{",
"var",
"utf8",
"=",
"utf8Encode",
"(",
"str",
")",
";",
"var",
"_a",
"=",
"[",
"hash32",
"(",
"utf8",
",",
"0",
")",
",",
"hash32",
"(",
"utf8",
",",
"102072",
")",
"]",
",",
"hi",
"=",
"_a",
"[",
"0",
"]",
",",
"lo",
"=",
"_a",
"[",
"1",
"]",
";",
"if",
"(",
"hi",
"==",
"0",
"&&",
"(",
"lo",
"==",
"0",
"||",
"lo",
"==",
"1",
")",
")",
"{",
"hi",
"=",
"hi",
"^",
"0x130f9bef",
";",
"lo",
"=",
"lo",
"^",
"-",
"0x6b5f56d8",
";",
"}",
"return",
"[",
"hi",
",",
"lo",
"]",
";",
"}"
]
| Compute the fingerprint of the given string
The output is 64 bit number encoded as a decimal string
based on:
https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java
@param {?} str
@return {?} | [
"Compute",
"the",
"fingerprint",
"of",
"the",
"given",
"string"
]
| 4aa73280c4858011894a416760bef34339ab11b1 | https://github.com/ssulleyymmann/ng-all-login/blob/4aa73280c4858011894a416760bef34339ab11b1/docs/vendor.bundle.js#L32838-L32846 | train |
ssulleyymmann/ng-all-login | docs/vendor.bundle.js | _removeDotSegments | function _removeDotSegments(path) {
if (path == '/')
return '/';
var /** @type {?} */ leadingSlash = path[0] == '/' ? '/' : '';
var /** @type {?} */ trailingSlash = path[path.length - 1] === '/' ? '/' : '';
var /** @type {?} */ segments = path.split('/');
var /** @type {?} */ out = [];
var /** @type {?} */ up = 0;
for (var /** @type {?} */ pos = 0; pos < segments.length; pos++) {
var /** @type {?} */ segment = segments[pos];
switch (segment) {
case '':
case '.':
break;
case '..':
if (out.length > 0) {
out.pop();
}
else {
up++;
}
break;
default:
out.push(segment);
}
}
if (leadingSlash == '') {
while (up-- > 0) {
out.unshift('..');
}
if (out.length === 0)
out.push('.');
}
return leadingSlash + out.join('/') + trailingSlash;
} | javascript | function _removeDotSegments(path) {
if (path == '/')
return '/';
var /** @type {?} */ leadingSlash = path[0] == '/' ? '/' : '';
var /** @type {?} */ trailingSlash = path[path.length - 1] === '/' ? '/' : '';
var /** @type {?} */ segments = path.split('/');
var /** @type {?} */ out = [];
var /** @type {?} */ up = 0;
for (var /** @type {?} */ pos = 0; pos < segments.length; pos++) {
var /** @type {?} */ segment = segments[pos];
switch (segment) {
case '':
case '.':
break;
case '..':
if (out.length > 0) {
out.pop();
}
else {
up++;
}
break;
default:
out.push(segment);
}
}
if (leadingSlash == '') {
while (up-- > 0) {
out.unshift('..');
}
if (out.length === 0)
out.push('.');
}
return leadingSlash + out.join('/') + trailingSlash;
} | [
"function",
"_removeDotSegments",
"(",
"path",
")",
"{",
"if",
"(",
"path",
"==",
"'/'",
")",
"return",
"'/'",
";",
"var",
"leadingSlash",
"=",
"path",
"[",
"0",
"]",
"==",
"'/'",
"?",
"'/'",
":",
"''",
";",
"var",
"trailingSlash",
"=",
"path",
"[",
"path",
".",
"length",
"-",
"1",
"]",
"===",
"'/'",
"?",
"'/'",
":",
"''",
";",
"var",
"segments",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
";",
"var",
"out",
"=",
"[",
"]",
";",
"var",
"up",
"=",
"0",
";",
"for",
"(",
"var",
"pos",
"=",
"0",
";",
"pos",
"<",
"segments",
".",
"length",
";",
"pos",
"++",
")",
"{",
"var",
"segment",
"=",
"segments",
"[",
"pos",
"]",
";",
"switch",
"(",
"segment",
")",
"{",
"case",
"''",
":",
"case",
"'.'",
":",
"break",
";",
"case",
"'..'",
":",
"if",
"(",
"out",
".",
"length",
">",
"0",
")",
"{",
"out",
".",
"pop",
"(",
")",
";",
"}",
"else",
"{",
"up",
"++",
";",
"}",
"break",
";",
"default",
":",
"out",
".",
"push",
"(",
"segment",
")",
";",
"}",
"}",
"if",
"(",
"leadingSlash",
"==",
"''",
")",
"{",
"while",
"(",
"up",
"--",
">",
"0",
")",
"{",
"out",
".",
"unshift",
"(",
"'..'",
")",
";",
"}",
"if",
"(",
"out",
".",
"length",
"===",
"0",
")",
"out",
".",
"push",
"(",
"'.'",
")",
";",
"}",
"return",
"leadingSlash",
"+",
"out",
".",
"join",
"(",
"'/'",
")",
"+",
"trailingSlash",
";",
"}"
]
| Removes dot segments in given path component, as described in
RFC 3986, section 5.2.4.
@param {?} path A non-empty path component.
@return {?} Path component with removed dot segments. | [
"Removes",
"dot",
"segments",
"in",
"given",
"path",
"component",
"as",
"described",
"in",
"RFC",
"3986",
"section",
"5",
".",
"2",
".",
"4",
"."
]
| 4aa73280c4858011894a416760bef34339ab11b1 | https://github.com/ssulleyymmann/ng-all-login/blob/4aa73280c4858011894a416760bef34339ab11b1/docs/vendor.bundle.js#L39097-L39131 | train |
ssulleyymmann/ng-all-login | docs/vendor.bundle.js | convertPropertyBinding | function convertPropertyBinding(localResolver, implicitReceiver, expressionWithoutBuiltins, bindingId) {
if (!localResolver) {
localResolver = new DefaultLocalResolver();
}
var /** @type {?} */ currValExpr = createCurrValueExpr(bindingId);
var /** @type {?} */ stmts = [];
var /** @type {?} */ visitor = new _AstToIrVisitor(localResolver, implicitReceiver, bindingId);
var /** @type {?} */ outputExpr = expressionWithoutBuiltins.visit(visitor, _Mode.Expression);
if (visitor.temporaryCount) {
for (var /** @type {?} */ i = 0; i < visitor.temporaryCount; i++) {
stmts.push(temporaryDeclaration(bindingId, i));
}
}
stmts.push(currValExpr.set(outputExpr).toDeclStmt(null, [StmtModifier.Final]));
return new ConvertPropertyBindingResult(stmts, currValExpr);
} | javascript | function convertPropertyBinding(localResolver, implicitReceiver, expressionWithoutBuiltins, bindingId) {
if (!localResolver) {
localResolver = new DefaultLocalResolver();
}
var /** @type {?} */ currValExpr = createCurrValueExpr(bindingId);
var /** @type {?} */ stmts = [];
var /** @type {?} */ visitor = new _AstToIrVisitor(localResolver, implicitReceiver, bindingId);
var /** @type {?} */ outputExpr = expressionWithoutBuiltins.visit(visitor, _Mode.Expression);
if (visitor.temporaryCount) {
for (var /** @type {?} */ i = 0; i < visitor.temporaryCount; i++) {
stmts.push(temporaryDeclaration(bindingId, i));
}
}
stmts.push(currValExpr.set(outputExpr).toDeclStmt(null, [StmtModifier.Final]));
return new ConvertPropertyBindingResult(stmts, currValExpr);
} | [
"function",
"convertPropertyBinding",
"(",
"localResolver",
",",
"implicitReceiver",
",",
"expressionWithoutBuiltins",
",",
"bindingId",
")",
"{",
"if",
"(",
"!",
"localResolver",
")",
"{",
"localResolver",
"=",
"new",
"DefaultLocalResolver",
"(",
")",
";",
"}",
"var",
"currValExpr",
"=",
"createCurrValueExpr",
"(",
"bindingId",
")",
";",
"var",
"stmts",
"=",
"[",
"]",
";",
"var",
"visitor",
"=",
"new",
"_AstToIrVisitor",
"(",
"localResolver",
",",
"implicitReceiver",
",",
"bindingId",
")",
";",
"var",
"outputExpr",
"=",
"expressionWithoutBuiltins",
".",
"visit",
"(",
"visitor",
",",
"_Mode",
".",
"Expression",
")",
";",
"if",
"(",
"visitor",
".",
"temporaryCount",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"visitor",
".",
"temporaryCount",
";",
"i",
"++",
")",
"{",
"stmts",
".",
"push",
"(",
"temporaryDeclaration",
"(",
"bindingId",
",",
"i",
")",
")",
";",
"}",
"}",
"stmts",
".",
"push",
"(",
"currValExpr",
".",
"set",
"(",
"outputExpr",
")",
".",
"toDeclStmt",
"(",
"null",
",",
"[",
"StmtModifier",
".",
"Final",
"]",
")",
")",
";",
"return",
"new",
"ConvertPropertyBindingResult",
"(",
"stmts",
",",
"currValExpr",
")",
";",
"}"
]
| Converts the given expression AST into an executable output AST, assuming the expression
is used in property binding. The expression has to be preprocessed via
`convertPropertyBindingBuiltins`.
@param {?} localResolver
@param {?} implicitReceiver
@param {?} expressionWithoutBuiltins
@param {?} bindingId
@return {?} | [
"Converts",
"the",
"given",
"expression",
"AST",
"into",
"an",
"executable",
"output",
"AST",
"assuming",
"the",
"expression",
"is",
"used",
"in",
"property",
"binding",
".",
"The",
"expression",
"has",
"to",
"be",
"preprocessed",
"via",
"convertPropertyBindingBuiltins",
"."
]
| 4aa73280c4858011894a416760bef34339ab11b1 | https://github.com/ssulleyymmann/ng-all-login/blob/4aa73280c4858011894a416760bef34339ab11b1/docs/vendor.bundle.js#L46432-L46447 | train |
ssulleyymmann/ng-all-login | docs/vendor.bundle.js | Class | function Class(clsDef) {
var /** @type {?} */ constructor = applyParams(clsDef.hasOwnProperty('constructor') ? clsDef.constructor : undefined, 'constructor');
var /** @type {?} */ proto = constructor.prototype;
if (clsDef.hasOwnProperty('extends')) {
if (typeof clsDef.extends === 'function') {
((constructor)).prototype = proto =
Object.create(((clsDef.extends)).prototype);
}
else {
throw new Error("Class definition 'extends' property must be a constructor function was: " + stringify(clsDef.extends));
}
}
for (var /** @type {?} */ key in clsDef) {
if (key !== 'extends' && key !== 'prototype' && clsDef.hasOwnProperty(key)) {
proto[key] = applyParams(clsDef[key], key);
}
}
if (this && this.annotations instanceof Array) {
Reflect.defineMetadata('annotations', this.annotations, constructor);
}
var /** @type {?} */ constructorName = constructor['name'];
if (!constructorName || constructorName === 'constructor') {
((constructor))['overriddenName'] = "class" + _nextClassId++;
}
return (constructor);
} | javascript | function Class(clsDef) {
var /** @type {?} */ constructor = applyParams(clsDef.hasOwnProperty('constructor') ? clsDef.constructor : undefined, 'constructor');
var /** @type {?} */ proto = constructor.prototype;
if (clsDef.hasOwnProperty('extends')) {
if (typeof clsDef.extends === 'function') {
((constructor)).prototype = proto =
Object.create(((clsDef.extends)).prototype);
}
else {
throw new Error("Class definition 'extends' property must be a constructor function was: " + stringify(clsDef.extends));
}
}
for (var /** @type {?} */ key in clsDef) {
if (key !== 'extends' && key !== 'prototype' && clsDef.hasOwnProperty(key)) {
proto[key] = applyParams(clsDef[key], key);
}
}
if (this && this.annotations instanceof Array) {
Reflect.defineMetadata('annotations', this.annotations, constructor);
}
var /** @type {?} */ constructorName = constructor['name'];
if (!constructorName || constructorName === 'constructor') {
((constructor))['overriddenName'] = "class" + _nextClassId++;
}
return (constructor);
} | [
"function",
"Class",
"(",
"clsDef",
")",
"{",
"var",
"constructor",
"=",
"applyParams",
"(",
"clsDef",
".",
"hasOwnProperty",
"(",
"'constructor'",
")",
"?",
"clsDef",
".",
"constructor",
":",
"undefined",
",",
"'constructor'",
")",
";",
"var",
"proto",
"=",
"constructor",
".",
"prototype",
";",
"if",
"(",
"clsDef",
".",
"hasOwnProperty",
"(",
"'extends'",
")",
")",
"{",
"if",
"(",
"typeof",
"clsDef",
".",
"extends",
"===",
"'function'",
")",
"{",
"(",
"(",
"constructor",
")",
")",
".",
"prototype",
"=",
"proto",
"=",
"Object",
".",
"create",
"(",
"(",
"(",
"clsDef",
".",
"extends",
")",
")",
".",
"prototype",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"\"Class definition 'extends' property must be a constructor function was: \"",
"+",
"stringify",
"(",
"clsDef",
".",
"extends",
")",
")",
";",
"}",
"}",
"for",
"(",
"var",
"key",
"in",
"clsDef",
")",
"{",
"if",
"(",
"key",
"!==",
"'extends'",
"&&",
"key",
"!==",
"'prototype'",
"&&",
"clsDef",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"proto",
"[",
"key",
"]",
"=",
"applyParams",
"(",
"clsDef",
"[",
"key",
"]",
",",
"key",
")",
";",
"}",
"}",
"if",
"(",
"this",
"&&",
"this",
".",
"annotations",
"instanceof",
"Array",
")",
"{",
"Reflect",
".",
"defineMetadata",
"(",
"'annotations'",
",",
"this",
".",
"annotations",
",",
"constructor",
")",
";",
"}",
"var",
"constructorName",
"=",
"constructor",
"[",
"'name'",
"]",
";",
"if",
"(",
"!",
"constructorName",
"||",
"constructorName",
"===",
"'constructor'",
")",
"{",
"(",
"(",
"constructor",
")",
")",
"[",
"'overriddenName'",
"]",
"=",
"\"class\"",
"+",
"_nextClassId",
"++",
";",
"}",
"return",
"(",
"constructor",
")",
";",
"}"
]
| Provides a way for expressing ES6 classes with parameter annotations in ES5.
## Basic Example
```
var Greeter = ng.Class({
constructor: function(name) {
this.name = name;
},
greet: function() {
alert('Hello ' + this.name + '!');
}
});
```
is equivalent to ES6:
```
class Greeter {
constructor(name) {
this.name = name;
}
greet() {
alert('Hello ' + this.name + '!');
}
}
```
or equivalent to ES5:
```
var Greeter = function (name) {
this.name = name;
}
Greeter.prototype.greet = function () {
alert('Hello ' + this.name + '!');
}
```
### Example with parameter annotations
```
var MyService = ng.Class({
constructor: [String, [new Optional(), Service], function(name, myService) {
...
}]
});
```
is equivalent to ES6:
```
class MyService {
constructor(name: string, \@Optional() myService: Service) {
...
}
}
```
### Example with inheritance
```
var Shape = ng.Class({
constructor: (color) {
this.color = color;
}
});
var Square = ng.Class({
extends: Shape,
constructor: function(color, size) {
Shape.call(this, color);
this.size = size;
}
});
```
@suppress {globalThis}
\@stable
@param {?} clsDef
@return {?} | [
"Provides",
"a",
"way",
"for",
"expressing",
"ES6",
"classes",
"with",
"parameter",
"annotations",
"in",
"ES5",
"."
]
| 4aa73280c4858011894a416760bef34339ab11b1 | https://github.com/ssulleyymmann/ng-all-login/blob/4aa73280c4858011894a416760bef34339ab11b1/docs/vendor.bundle.js#L53307-L53332 | train |
elmarburke/hoodie-plugin-angularjs | src/hoodieArray.js | mapFromArray | function mapFromArray(array, prop) {
var map = {};
for (var i = 0; i < array.length; i++) {
map[ array[i][prop] ] = array[i];
}
return map;
} | javascript | function mapFromArray(array, prop) {
var map = {};
for (var i = 0; i < array.length; i++) {
map[ array[i][prop] ] = array[i];
}
return map;
} | [
"function",
"mapFromArray",
"(",
"array",
",",
"prop",
")",
"{",
"var",
"map",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
";",
"i",
"++",
")",
"{",
"map",
"[",
"array",
"[",
"i",
"]",
"[",
"prop",
"]",
"]",
"=",
"array",
"[",
"i",
"]",
";",
"}",
"return",
"map",
";",
"}"
]
| Creates a map out of an array be choosing what property to key by
@param {object[]} array Array that will be converted into a map
@param {string} prop Name of property to key by
@return {object} The mapped array. Example:
mapFromArray([{a:1,b:2}, {a:3,b:4}], 'a')
returns {1: {a:1,b:2}, 3: {a:3,b:4}} | [
"Creates",
"a",
"map",
"out",
"of",
"an",
"array",
"be",
"choosing",
"what",
"property",
"to",
"key",
"by"
]
| 7f38248a0162ebea439e747d81a7423f43fd3cc8 | https://github.com/elmarburke/hoodie-plugin-angularjs/blob/7f38248a0162ebea439e747d81a7423f43fd3cc8/src/hoodieArray.js#L70-L76 | train |
solid/contacts-pane | toolsPane.js | saveCleanPeople | function saveCleanPeople () {
var cleanPeople
return Promise.resolve()
.then(() => {
cleanPeople = kb.sym(stats.book.dir().uri + 'clean-people.ttl')
var sts = []
for (let i = 0; i < stats.uniques.length; i++) {
sts = sts.concat(kb.connectedStatements(stats.uniques[i], stats.nameEmailIndex))
}
var sz = (new $rdf.Serializer(kb)).setBase(stats.nameEmailIndex.uri)
log('Serializing index of uniques...')
var data = sz.statementsToN3(sts)
return kb.fetcher.webOperation('PUT', cleanPeople, { data: data, contentType: 'text/turtle' })
})
.then(function () {
log('Done uniques log ' + cleanPeople)
return true
})
.catch(function (e) {
log('Error saving uniques: ' + e)
})
} | javascript | function saveCleanPeople () {
var cleanPeople
return Promise.resolve()
.then(() => {
cleanPeople = kb.sym(stats.book.dir().uri + 'clean-people.ttl')
var sts = []
for (let i = 0; i < stats.uniques.length; i++) {
sts = sts.concat(kb.connectedStatements(stats.uniques[i], stats.nameEmailIndex))
}
var sz = (new $rdf.Serializer(kb)).setBase(stats.nameEmailIndex.uri)
log('Serializing index of uniques...')
var data = sz.statementsToN3(sts)
return kb.fetcher.webOperation('PUT', cleanPeople, { data: data, contentType: 'text/turtle' })
})
.then(function () {
log('Done uniques log ' + cleanPeople)
return true
})
.catch(function (e) {
log('Error saving uniques: ' + e)
})
} | [
"function",
"saveCleanPeople",
"(",
")",
"{",
"var",
"cleanPeople",
"return",
"Promise",
".",
"resolve",
"(",
")",
".",
"then",
"(",
"(",
")",
"=>",
"{",
"cleanPeople",
"=",
"kb",
".",
"sym",
"(",
"stats",
".",
"book",
".",
"dir",
"(",
")",
".",
"uri",
"+",
"'clean-people.ttl'",
")",
"var",
"sts",
"=",
"[",
"]",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"stats",
".",
"uniques",
".",
"length",
";",
"i",
"++",
")",
"{",
"sts",
"=",
"sts",
".",
"concat",
"(",
"kb",
".",
"connectedStatements",
"(",
"stats",
".",
"uniques",
"[",
"i",
"]",
",",
"stats",
".",
"nameEmailIndex",
")",
")",
"}",
"var",
"sz",
"=",
"(",
"new",
"$rdf",
".",
"Serializer",
"(",
"kb",
")",
")",
".",
"setBase",
"(",
"stats",
".",
"nameEmailIndex",
".",
"uri",
")",
"log",
"(",
"'Serializing index of uniques...'",
")",
"var",
"data",
"=",
"sz",
".",
"statementsToN3",
"(",
"sts",
")",
"return",
"kb",
".",
"fetcher",
".",
"webOperation",
"(",
"'PUT'",
",",
"cleanPeople",
",",
"{",
"data",
":",
"data",
",",
"contentType",
":",
"'text/turtle'",
"}",
")",
"}",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"log",
"(",
"'Done uniques log '",
"+",
"cleanPeople",
")",
"return",
"true",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"e",
")",
"{",
"log",
"(",
"'Error saving uniques: '",
"+",
"e",
")",
"}",
")",
"}"
]
| Save a new clean version | [
"Save",
"a",
"new",
"clean",
"version"
]
| 373c55fc6e2c584603741ee972d036fcb1e2f4b8 | https://github.com/solid/contacts-pane/blob/373c55fc6e2c584603741ee972d036fcb1e2f4b8/toolsPane.js#L465-L488 | train |
alexcjohnson/world-calendars | dist/plus.js | function() {
if (value.charAt(iValue) !== format.charAt(iFormat)) {
throw (main.local.unexpectedLiteralAt ||
main.regionalOptions[''].unexpectedLiteralAt).replace(/\{0\}/, iValue);
}
iValue++;
} | javascript | function() {
if (value.charAt(iValue) !== format.charAt(iFormat)) {
throw (main.local.unexpectedLiteralAt ||
main.regionalOptions[''].unexpectedLiteralAt).replace(/\{0\}/, iValue);
}
iValue++;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"value",
".",
"charAt",
"(",
"iValue",
")",
"!==",
"format",
".",
"charAt",
"(",
"iFormat",
")",
")",
"{",
"throw",
"(",
"main",
".",
"local",
".",
"unexpectedLiteralAt",
"||",
"main",
".",
"regionalOptions",
"[",
"''",
"]",
".",
"unexpectedLiteralAt",
")",
".",
"replace",
"(",
"/",
"\\{0\\}",
"/",
",",
"iValue",
")",
";",
"}",
"iValue",
"++",
";",
"}"
]
| Confirm that a literal character matches the string value | [
"Confirm",
"that",
"a",
"literal",
"character",
"matches",
"the",
"string",
"value"
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/dist/plus.js#L369-L375 | train |
|
sat-utils/sat-api-lib | libs/api.js | function (intersects) {
if (_.isString(intersects)) {
try {
intersects = JSON.parse(intersects);
} catch (e) {
throw new Error('Invalid Geojson');
}
}
return intersects;
} | javascript | function (intersects) {
if (_.isString(intersects)) {
try {
intersects = JSON.parse(intersects);
} catch (e) {
throw new Error('Invalid Geojson');
}
}
return intersects;
} | [
"function",
"(",
"intersects",
")",
"{",
"if",
"(",
"_",
".",
"isString",
"(",
"intersects",
")",
")",
"{",
"try",
"{",
"intersects",
"=",
"JSON",
".",
"parse",
"(",
"intersects",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Invalid Geojson'",
")",
";",
"}",
"}",
"return",
"intersects",
";",
"}"
]
| converts string intersect to js object | [
"converts",
"string",
"intersect",
"to",
"js",
"object"
]
| 74ef1cb09789ecc9c18512781a95eada6fdc3813 | https://github.com/sat-utils/sat-api-lib/blob/74ef1cb09789ecc9c18512781a95eada6fdc3813/libs/api.js#L11-L21 | train |
|
XadillaX/illyria2 | benchmark/index.js | function(callback) {
server = illyria2.createServer();
server.expose("benchmark", {
echo: function(req, resp) {
resp.send(req.params());
}
});
server.listen(SERVER_PORT, function() {
callback();
});
} | javascript | function(callback) {
server = illyria2.createServer();
server.expose("benchmark", {
echo: function(req, resp) {
resp.send(req.params());
}
});
server.listen(SERVER_PORT, function() {
callback();
});
} | [
"function",
"(",
"callback",
")",
"{",
"server",
"=",
"illyria2",
".",
"createServer",
"(",
")",
";",
"server",
".",
"expose",
"(",
"\"benchmark\"",
",",
"{",
"echo",
":",
"function",
"(",
"req",
",",
"resp",
")",
"{",
"resp",
".",
"send",
"(",
"req",
".",
"params",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"server",
".",
"listen",
"(",
"SERVER_PORT",
",",
"function",
"(",
")",
"{",
"callback",
"(",
")",
";",
"}",
")",
";",
"}"
]
| step 1.
create server | [
"step",
"1",
".",
"create",
"server"
]
| ced0cc71cdcda11afcbab33f13739cbe547a2a17 | https://github.com/XadillaX/illyria2/blob/ced0cc71cdcda11afcbab33f13739cbe547a2a17/benchmark/index.js#L80-L90 | train |
|
XadillaX/illyria2 | benchmark/index.js | function(callback) {
var scarlet = new Scarlet(Math.min(opts.n, 100));
function connect(taskObject) {
var client = taskObject.task.client;
var i = taskObject.task.idx;
client.connect(function() {
scarlet.taskDone(taskObject);
});
client.on("error", function(err) {
console.log(err + ": Client " + i);
});
}
console.time("Connect");
// if mode is `clients`, we create (opts.complicating) clients,
// otherwise we create only one.
var max = opts["complicating-mode"] === "clients" ? opts.complicating : 1;
for(var i = 0; i < max; i++) {
var client = illyria2.createClient("127.0.0.1", SERVER_PORT, {
runTimeout: 10000,
retryInterval: 1000,
reconnect: true
});
scarlet.push({ idx: i, client: client }, connect);
clients.push(client);
}
scarlet.afterFinish(max, function() {
console.timeEnd("Connect");
callback();
}, false);
} | javascript | function(callback) {
var scarlet = new Scarlet(Math.min(opts.n, 100));
function connect(taskObject) {
var client = taskObject.task.client;
var i = taskObject.task.idx;
client.connect(function() {
scarlet.taskDone(taskObject);
});
client.on("error", function(err) {
console.log(err + ": Client " + i);
});
}
console.time("Connect");
// if mode is `clients`, we create (opts.complicating) clients,
// otherwise we create only one.
var max = opts["complicating-mode"] === "clients" ? opts.complicating : 1;
for(var i = 0; i < max; i++) {
var client = illyria2.createClient("127.0.0.1", SERVER_PORT, {
runTimeout: 10000,
retryInterval: 1000,
reconnect: true
});
scarlet.push({ idx: i, client: client }, connect);
clients.push(client);
}
scarlet.afterFinish(max, function() {
console.timeEnd("Connect");
callback();
}, false);
} | [
"function",
"(",
"callback",
")",
"{",
"var",
"scarlet",
"=",
"new",
"Scarlet",
"(",
"Math",
".",
"min",
"(",
"opts",
".",
"n",
",",
"100",
")",
")",
";",
"function",
"connect",
"(",
"taskObject",
")",
"{",
"var",
"client",
"=",
"taskObject",
".",
"task",
".",
"client",
";",
"var",
"i",
"=",
"taskObject",
".",
"task",
".",
"idx",
";",
"client",
".",
"connect",
"(",
"function",
"(",
")",
"{",
"scarlet",
".",
"taskDone",
"(",
"taskObject",
")",
";",
"}",
")",
";",
"client",
".",
"on",
"(",
"\"error\"",
",",
"function",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"err",
"+",
"\": Client \"",
"+",
"i",
")",
";",
"}",
")",
";",
"}",
"console",
".",
"time",
"(",
"\"Connect\"",
")",
";",
"var",
"max",
"=",
"opts",
"[",
"\"complicating-mode\"",
"]",
"===",
"\"clients\"",
"?",
"opts",
".",
"complicating",
":",
"1",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"max",
";",
"i",
"++",
")",
"{",
"var",
"client",
"=",
"illyria2",
".",
"createClient",
"(",
"\"127.0.0.1\"",
",",
"SERVER_PORT",
",",
"{",
"runTimeout",
":",
"10000",
",",
"retryInterval",
":",
"1000",
",",
"reconnect",
":",
"true",
"}",
")",
";",
"scarlet",
".",
"push",
"(",
"{",
"idx",
":",
"i",
",",
"client",
":",
"client",
"}",
",",
"connect",
")",
";",
"clients",
".",
"push",
"(",
"client",
")",
";",
"}",
"scarlet",
".",
"afterFinish",
"(",
"max",
",",
"function",
"(",
")",
"{",
"console",
".",
"timeEnd",
"(",
"\"Connect\"",
")",
";",
"callback",
"(",
")",
";",
"}",
",",
"false",
")",
";",
"}"
]
| step 2.
create clients and connect to server | [
"step",
"2",
".",
"create",
"clients",
"and",
"connect",
"to",
"server"
]
| ced0cc71cdcda11afcbab33f13739cbe547a2a17 | https://github.com/XadillaX/illyria2/blob/ced0cc71cdcda11afcbab33f13739cbe547a2a17/benchmark/index.js#L96-L133 | train |
|
XadillaX/illyria2 | benchmark/index.js | function(callback) {
block = "";
for(var i = 0; i < opts.size; i++) block + ".";
testAbility(callback);
} | javascript | function(callback) {
block = "";
for(var i = 0; i < opts.size; i++) block + ".";
testAbility(callback);
} | [
"function",
"(",
"callback",
")",
"{",
"block",
"=",
"\"\"",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"opts",
".",
"size",
";",
"i",
"++",
")",
"block",
"+",
"\".\"",
";",
"testAbility",
"(",
"callback",
")",
";",
"}"
]
| step 3.
start testing | [
"step",
"3",
".",
"start",
"testing"
]
| ced0cc71cdcda11afcbab33f13739cbe547a2a17 | https://github.com/XadillaX/illyria2/blob/ced0cc71cdcda11afcbab33f13739cbe547a2a17/benchmark/index.js#L139-L143 | train |
|
balderdashy/mast | dist/mast.dev.js | function (events, options) {
var eventKeys = _.keys(events || {}),
limitEvents,
parsedEvents = [];
// Optionally filter using set of acceptable event types
limitEvents = options.only;
eventKeys = _.filter(eventKeys, function checkEventName (eventKey) {
// Parse event string into semantic representation
var event = Events.parseDOMEvent(eventKey);
parsedEvents.push(event);
// Optional filter
if (limitEvents) {
return _.contains(limitEvents, event.name);
}
return true;
});
return parsedEvents;
} | javascript | function (events, options) {
var eventKeys = _.keys(events || {}),
limitEvents,
parsedEvents = [];
// Optionally filter using set of acceptable event types
limitEvents = options.only;
eventKeys = _.filter(eventKeys, function checkEventName (eventKey) {
// Parse event string into semantic representation
var event = Events.parseDOMEvent(eventKey);
parsedEvents.push(event);
// Optional filter
if (limitEvents) {
return _.contains(limitEvents, event.name);
}
return true;
});
return parsedEvents;
} | [
"function",
"(",
"events",
",",
"options",
")",
"{",
"var",
"eventKeys",
"=",
"_",
".",
"keys",
"(",
"events",
"||",
"{",
"}",
")",
",",
"limitEvents",
",",
"parsedEvents",
"=",
"[",
"]",
";",
"limitEvents",
"=",
"options",
".",
"only",
";",
"eventKeys",
"=",
"_",
".",
"filter",
"(",
"eventKeys",
",",
"function",
"checkEventName",
"(",
"eventKey",
")",
"{",
"var",
"event",
"=",
"Events",
".",
"parseDOMEvent",
"(",
"eventKey",
")",
";",
"parsedEvents",
".",
"push",
"(",
"event",
")",
";",
"if",
"(",
"limitEvents",
")",
"{",
"return",
"_",
".",
"contains",
"(",
"limitEvents",
",",
"event",
".",
"name",
")",
";",
"}",
"return",
"true",
";",
"}",
")",
";",
"return",
"parsedEvents",
";",
"}"
]
| Parses a dictionary of events and optionally filters by the event type. If the event
@param {Object} events [A Backbone.View events object]
@param {Object} options [Options object that allows us to filter parsing to certain event
names]
@return {Array} [Array containing parsedEvents that are matching event keys] | [
"Parses",
"a",
"dictionary",
"of",
"events",
"and",
"optionally",
"filters",
"by",
"the",
"event",
"type",
".",
"If",
"the",
"event"
]
| 6fc2b07849ec6a6fe15f66e456e556e5270ed37f | https://github.com/balderdashy/mast/blob/6fc2b07849ec6a6fe15f66e456e556e5270ed37f/dist/mast.dev.js#L2350-L2372 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(inst) {
var maxDate = inst.get('maxDate');
return (!maxDate || inst.drawDate.newDate().
add(inst.options.monthsToJump - inst.options.monthsOffset, 'm').
day(inst.options.calendar.minDay).compareTo(maxDate) !== +1); } | javascript | function(inst) {
var maxDate = inst.get('maxDate');
return (!maxDate || inst.drawDate.newDate().
add(inst.options.monthsToJump - inst.options.monthsOffset, 'm').
day(inst.options.calendar.minDay).compareTo(maxDate) !== +1); } | [
"function",
"(",
"inst",
")",
"{",
"var",
"maxDate",
"=",
"inst",
".",
"get",
"(",
"'maxDate'",
")",
";",
"return",
"(",
"!",
"maxDate",
"||",
"inst",
".",
"drawDate",
".",
"newDate",
"(",
")",
".",
"add",
"(",
"inst",
".",
"options",
".",
"monthsToJump",
"-",
"inst",
".",
"options",
".",
"monthsOffset",
",",
"'m'",
")",
".",
"day",
"(",
"inst",
".",
"options",
".",
"calendar",
".",
"minDay",
")",
".",
"compareTo",
"(",
"maxDate",
")",
"!==",
"+",
"1",
")",
";",
"}"
]
| Ctrl + Page down | [
"Ctrl",
"+",
"Page",
"down"
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L164-L168 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(inst) {
var minDate = inst.curMinDate();
var maxDate = inst.get('maxDate');
var curDate = inst.selectedDates[0] || inst.options.calendar.today();
return (!minDate || curDate.compareTo(minDate) !== -1) &&
(!maxDate || curDate.compareTo(maxDate) !== +1); } | javascript | function(inst) {
var minDate = inst.curMinDate();
var maxDate = inst.get('maxDate');
var curDate = inst.selectedDates[0] || inst.options.calendar.today();
return (!minDate || curDate.compareTo(minDate) !== -1) &&
(!maxDate || curDate.compareTo(maxDate) !== +1); } | [
"function",
"(",
"inst",
")",
"{",
"var",
"minDate",
"=",
"inst",
".",
"curMinDate",
"(",
")",
";",
"var",
"maxDate",
"=",
"inst",
".",
"get",
"(",
"'maxDate'",
")",
";",
"var",
"curDate",
"=",
"inst",
".",
"selectedDates",
"[",
"0",
"]",
"||",
"inst",
".",
"options",
".",
"calendar",
".",
"today",
"(",
")",
";",
"return",
"(",
"!",
"minDate",
"||",
"curDate",
".",
"compareTo",
"(",
"minDate",
")",
"!==",
"-",
"1",
")",
"&&",
"(",
"!",
"maxDate",
"||",
"curDate",
".",
"compareTo",
"(",
"maxDate",
")",
"!==",
"+",
"1",
")",
";",
"}"
]
| Ctrl + Home | [
"Ctrl",
"+",
"Home"
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L178-L183 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(inst) {
var minDate = inst.curMinDate();
return (!minDate || inst.drawDate.newDate().
add(-inst.options.calendar.daysInWeek(), 'd').compareTo(minDate) !== -1); } | javascript | function(inst) {
var minDate = inst.curMinDate();
return (!minDate || inst.drawDate.newDate().
add(-inst.options.calendar.daysInWeek(), 'd').compareTo(minDate) !== -1); } | [
"function",
"(",
"inst",
")",
"{",
"var",
"minDate",
"=",
"inst",
".",
"curMinDate",
"(",
")",
";",
"return",
"(",
"!",
"minDate",
"||",
"inst",
".",
"drawDate",
".",
"newDate",
"(",
")",
".",
"add",
"(",
"-",
"inst",
".",
"options",
".",
"calendar",
".",
"daysInWeek",
"(",
")",
",",
"'d'",
")",
".",
"compareTo",
"(",
"minDate",
")",
"!==",
"-",
"1",
")",
";",
"}"
]
| Ctrl + Up | [
"Ctrl",
"+",
"Up"
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L214-L217 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(inst) {
var minDate = inst.curMinDate();
return (!minDate || inst.drawDate.newDate().add(-1, 'd').
compareTo(minDate) !== -1); } | javascript | function(inst) {
var minDate = inst.curMinDate();
return (!minDate || inst.drawDate.newDate().add(-1, 'd').
compareTo(minDate) !== -1); } | [
"function",
"(",
"inst",
")",
"{",
"var",
"minDate",
"=",
"inst",
".",
"curMinDate",
"(",
")",
";",
"return",
"(",
"!",
"minDate",
"||",
"inst",
".",
"drawDate",
".",
"newDate",
"(",
")",
".",
"add",
"(",
"-",
"1",
",",
"'d'",
")",
".",
"compareTo",
"(",
"minDate",
")",
"!==",
"-",
"1",
")",
";",
"}"
]
| Ctrl + Left | [
"Ctrl",
"+",
"Left"
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L224-L227 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(inst) {
var maxDate = inst.get('maxDate');
return (!maxDate || inst.drawDate.newDate().add(1, 'd').
compareTo(maxDate) !== +1); } | javascript | function(inst) {
var maxDate = inst.get('maxDate');
return (!maxDate || inst.drawDate.newDate().add(1, 'd').
compareTo(maxDate) !== +1); } | [
"function",
"(",
"inst",
")",
"{",
"var",
"maxDate",
"=",
"inst",
".",
"get",
"(",
"'maxDate'",
")",
";",
"return",
"(",
"!",
"maxDate",
"||",
"inst",
".",
"drawDate",
".",
"newDate",
"(",
")",
".",
"add",
"(",
"1",
",",
"'d'",
")",
".",
"compareTo",
"(",
"maxDate",
")",
"!==",
"+",
"1",
")",
";",
"}"
]
| Ctrl + Right | [
"Ctrl",
"+",
"Right"
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L233-L236 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(inst) {
var maxDate = inst.get('maxDate');
return (!maxDate || inst.drawDate.newDate().
add(inst.options.calendar.daysInWeek(), 'd').compareTo(maxDate) !== +1); } | javascript | function(inst) {
var maxDate = inst.get('maxDate');
return (!maxDate || inst.drawDate.newDate().
add(inst.options.calendar.daysInWeek(), 'd').compareTo(maxDate) !== +1); } | [
"function",
"(",
"inst",
")",
"{",
"var",
"maxDate",
"=",
"inst",
".",
"get",
"(",
"'maxDate'",
")",
";",
"return",
"(",
"!",
"maxDate",
"||",
"inst",
".",
"drawDate",
".",
"newDate",
"(",
")",
".",
"add",
"(",
"inst",
".",
"options",
".",
"calendar",
".",
"daysInWeek",
"(",
")",
",",
"'d'",
")",
".",
"compareTo",
"(",
"maxDate",
")",
"!==",
"+",
"1",
")",
";",
"}"
]
| Ctrl + Down | [
"Ctrl",
"+",
"Down"
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L242-L245 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem, inst) {
elem.off('focus.' + inst.name);
if (inst.options.showOnFocus) {
elem.on('focus.' + inst.name, this.show);
}
if (inst.trigger) {
inst.trigger.remove();
}
var trigger = inst.options.showTrigger;
inst.trigger = (!trigger ? $([]) :
$(trigger).clone().removeAttr('id').addClass(this._triggerClass)
[inst.options.isRTL ? 'insertBefore' : 'insertAfter'](elem).
click(function() {
if (!plugin.isDisabled(elem[0])) {
plugin[plugin.curInst === inst ? 'hide' : 'show'](elem[0]);
}
}));
this._autoSize(elem, inst);
var dates = this._extractDates(inst, elem.val());
if (dates) {
this.setDate(elem[0], dates, null, true);
}
var defaultDate = inst.get('defaultDate');
if (inst.options.selectDefaultDate && defaultDate && inst.selectedDates.length === 0) {
this.setDate(elem[0], (defaultDate || inst.options.calendar.today()).newDate());
}
} | javascript | function(elem, inst) {
elem.off('focus.' + inst.name);
if (inst.options.showOnFocus) {
elem.on('focus.' + inst.name, this.show);
}
if (inst.trigger) {
inst.trigger.remove();
}
var trigger = inst.options.showTrigger;
inst.trigger = (!trigger ? $([]) :
$(trigger).clone().removeAttr('id').addClass(this._triggerClass)
[inst.options.isRTL ? 'insertBefore' : 'insertAfter'](elem).
click(function() {
if (!plugin.isDisabled(elem[0])) {
plugin[plugin.curInst === inst ? 'hide' : 'show'](elem[0]);
}
}));
this._autoSize(elem, inst);
var dates = this._extractDates(inst, elem.val());
if (dates) {
this.setDate(elem[0], dates, null, true);
}
var defaultDate = inst.get('defaultDate');
if (inst.options.selectDefaultDate && defaultDate && inst.selectedDates.length === 0) {
this.setDate(elem[0], (defaultDate || inst.options.calendar.today()).newDate());
}
} | [
"function",
"(",
"elem",
",",
"inst",
")",
"{",
"elem",
".",
"off",
"(",
"'focus.'",
"+",
"inst",
".",
"name",
")",
";",
"if",
"(",
"inst",
".",
"options",
".",
"showOnFocus",
")",
"{",
"elem",
".",
"on",
"(",
"'focus.'",
"+",
"inst",
".",
"name",
",",
"this",
".",
"show",
")",
";",
"}",
"if",
"(",
"inst",
".",
"trigger",
")",
"{",
"inst",
".",
"trigger",
".",
"remove",
"(",
")",
";",
"}",
"var",
"trigger",
"=",
"inst",
".",
"options",
".",
"showTrigger",
";",
"inst",
".",
"trigger",
"=",
"(",
"!",
"trigger",
"?",
"$",
"(",
"[",
"]",
")",
":",
"$",
"(",
"trigger",
")",
".",
"clone",
"(",
")",
".",
"removeAttr",
"(",
"'id'",
")",
".",
"addClass",
"(",
"this",
".",
"_triggerClass",
")",
"[",
"inst",
".",
"options",
".",
"isRTL",
"?",
"'insertBefore'",
":",
"'insertAfter'",
"]",
"(",
"elem",
")",
".",
"click",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"plugin",
".",
"isDisabled",
"(",
"elem",
"[",
"0",
"]",
")",
")",
"{",
"plugin",
"[",
"plugin",
".",
"curInst",
"===",
"inst",
"?",
"'hide'",
":",
"'show'",
"]",
"(",
"elem",
"[",
"0",
"]",
")",
";",
"}",
"}",
")",
")",
";",
"this",
".",
"_autoSize",
"(",
"elem",
",",
"inst",
")",
";",
"var",
"dates",
"=",
"this",
".",
"_extractDates",
"(",
"inst",
",",
"elem",
".",
"val",
"(",
")",
")",
";",
"if",
"(",
"dates",
")",
"{",
"this",
".",
"setDate",
"(",
"elem",
"[",
"0",
"]",
",",
"dates",
",",
"null",
",",
"true",
")",
";",
"}",
"var",
"defaultDate",
"=",
"inst",
".",
"get",
"(",
"'defaultDate'",
")",
";",
"if",
"(",
"inst",
".",
"options",
".",
"selectDefaultDate",
"&&",
"defaultDate",
"&&",
"inst",
".",
"selectedDates",
".",
"length",
"===",
"0",
")",
"{",
"this",
".",
"setDate",
"(",
"elem",
"[",
"0",
"]",
",",
"(",
"defaultDate",
"||",
"inst",
".",
"options",
".",
"calendar",
".",
"today",
"(",
")",
")",
".",
"newDate",
"(",
")",
")",
";",
"}",
"}"
]
| Attach events and trigger, if necessary.
@memberof CalendarsPicker
@private
@param elem {jQuery} The control to affect.
@param inst {object} The current instance settings. | [
"Attach",
"events",
"and",
"trigger",
"if",
"necessary",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L585-L611 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem, inst) {
if (inst.options.autoSize && !inst.inline) {
var calendar = inst.options.calendar;
var date = calendar.newDate(2009, 10, 20); // Ensure double digits
var dateFormat = inst.get('dateFormat');
if (dateFormat.match(/[DM]/)) {
var findMax = function(names) {
var max = 0;
var maxI = 0;
for (var i = 0; i < names.length; i++) {
if (names[i].length > max) {
max = names[i].length;
maxI = i;
}
}
return maxI;
};
date.month(findMax(calendar.local[dateFormat.match(/MM/) ? // Longest month
'monthNames' : 'monthNamesShort']) + 1);
date.day(findMax(calendar.local[dateFormat.match(/DD/) ? // Longest day
'dayNames' : 'dayNamesShort']) + 20 - date.dayOfWeek());
}
inst.elem.attr('size', date.formatDate(dateFormat,
{localNumbers: inst.options.localnumbers}).length);
}
} | javascript | function(elem, inst) {
if (inst.options.autoSize && !inst.inline) {
var calendar = inst.options.calendar;
var date = calendar.newDate(2009, 10, 20); // Ensure double digits
var dateFormat = inst.get('dateFormat');
if (dateFormat.match(/[DM]/)) {
var findMax = function(names) {
var max = 0;
var maxI = 0;
for (var i = 0; i < names.length; i++) {
if (names[i].length > max) {
max = names[i].length;
maxI = i;
}
}
return maxI;
};
date.month(findMax(calendar.local[dateFormat.match(/MM/) ? // Longest month
'monthNames' : 'monthNamesShort']) + 1);
date.day(findMax(calendar.local[dateFormat.match(/DD/) ? // Longest day
'dayNames' : 'dayNamesShort']) + 20 - date.dayOfWeek());
}
inst.elem.attr('size', date.formatDate(dateFormat,
{localNumbers: inst.options.localnumbers}).length);
}
} | [
"function",
"(",
"elem",
",",
"inst",
")",
"{",
"if",
"(",
"inst",
".",
"options",
".",
"autoSize",
"&&",
"!",
"inst",
".",
"inline",
")",
"{",
"var",
"calendar",
"=",
"inst",
".",
"options",
".",
"calendar",
";",
"var",
"date",
"=",
"calendar",
".",
"newDate",
"(",
"2009",
",",
"10",
",",
"20",
")",
";",
"var",
"dateFormat",
"=",
"inst",
".",
"get",
"(",
"'dateFormat'",
")",
";",
"if",
"(",
"dateFormat",
".",
"match",
"(",
"/",
"[DM]",
"/",
")",
")",
"{",
"var",
"findMax",
"=",
"function",
"(",
"names",
")",
"{",
"var",
"max",
"=",
"0",
";",
"var",
"maxI",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"names",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"names",
"[",
"i",
"]",
".",
"length",
">",
"max",
")",
"{",
"max",
"=",
"names",
"[",
"i",
"]",
".",
"length",
";",
"maxI",
"=",
"i",
";",
"}",
"}",
"return",
"maxI",
";",
"}",
";",
"date",
".",
"month",
"(",
"findMax",
"(",
"calendar",
".",
"local",
"[",
"dateFormat",
".",
"match",
"(",
"/",
"MM",
"/",
")",
"?",
"'monthNames'",
":",
"'monthNamesShort'",
"]",
")",
"+",
"1",
")",
";",
"date",
".",
"day",
"(",
"findMax",
"(",
"calendar",
".",
"local",
"[",
"dateFormat",
".",
"match",
"(",
"/",
"DD",
"/",
")",
"?",
"'dayNames'",
":",
"'dayNamesShort'",
"]",
")",
"+",
"20",
"-",
"date",
".",
"dayOfWeek",
"(",
")",
")",
";",
"}",
"inst",
".",
"elem",
".",
"attr",
"(",
"'size'",
",",
"date",
".",
"formatDate",
"(",
"dateFormat",
",",
"{",
"localNumbers",
":",
"inst",
".",
"options",
".",
"localnumbers",
"}",
")",
".",
"length",
")",
";",
"}",
"}"
]
| Apply the maximum length for the date format.
@memberof CalendarsPicker
@private
@param elem {jQuery} The control to affect.
@param inst {object} The current instance settings. | [
"Apply",
"the",
"maximum",
"length",
"for",
"the",
"date",
"format",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L618-L643 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(fns) {
var funcs = arguments;
return function(args) {
for (var i = 0; i < funcs.length; i++) {
funcs[i].apply(this, arguments);
}
};
} | javascript | function(fns) {
var funcs = arguments;
return function(args) {
for (var i = 0; i < funcs.length; i++) {
funcs[i].apply(this, arguments);
}
};
} | [
"function",
"(",
"fns",
")",
"{",
"var",
"funcs",
"=",
"arguments",
";",
"return",
"function",
"(",
"args",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"funcs",
".",
"length",
";",
"i",
"++",
")",
"{",
"funcs",
"[",
"i",
"]",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}",
"}",
";",
"}"
]
| Apply multiple event functions.
@memberof CalendarsPicker
@param fns {function} The functions to apply.
@example onShow: multipleEvents(fn1, fn2, ...) | [
"Apply",
"multiple",
"event",
"functions",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L662-L669 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem) {
elem = $(elem);
if (!elem.hasClass(this._getMarker())) {
return;
}
var inst = this._getInst(elem);
if (inst.inline) {
elem.children('.' + this._disableClass).remove().end().
find('button,select').prop('disabled', false).end().
find('a').attr('href', 'javascript:void(0)');
}
else {
elem.prop('disabled', false);
inst.trigger.filter('button.' + this._triggerClass).prop('disabled', false).end().
filter('img.' + this._triggerClass).css({opacity: '1.0', cursor: ''});
}
this._disabled = $.map(this._disabled,
function(value) { return (value === elem[0] ? null : value); }); // Delete entry
} | javascript | function(elem) {
elem = $(elem);
if (!elem.hasClass(this._getMarker())) {
return;
}
var inst = this._getInst(elem);
if (inst.inline) {
elem.children('.' + this._disableClass).remove().end().
find('button,select').prop('disabled', false).end().
find('a').attr('href', 'javascript:void(0)');
}
else {
elem.prop('disabled', false);
inst.trigger.filter('button.' + this._triggerClass).prop('disabled', false).end().
filter('img.' + this._triggerClass).css({opacity: '1.0', cursor: ''});
}
this._disabled = $.map(this._disabled,
function(value) { return (value === elem[0] ? null : value); }); // Delete entry
} | [
"function",
"(",
"elem",
")",
"{",
"elem",
"=",
"$",
"(",
"elem",
")",
";",
"if",
"(",
"!",
"elem",
".",
"hasClass",
"(",
"this",
".",
"_getMarker",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"var",
"inst",
"=",
"this",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"inst",
".",
"inline",
")",
"{",
"elem",
".",
"children",
"(",
"'.'",
"+",
"this",
".",
"_disableClass",
")",
".",
"remove",
"(",
")",
".",
"end",
"(",
")",
".",
"find",
"(",
"'button,select'",
")",
".",
"prop",
"(",
"'disabled'",
",",
"false",
")",
".",
"end",
"(",
")",
".",
"find",
"(",
"'a'",
")",
".",
"attr",
"(",
"'href'",
",",
"'javascript:void(0)'",
")",
";",
"}",
"else",
"{",
"elem",
".",
"prop",
"(",
"'disabled'",
",",
"false",
")",
";",
"inst",
".",
"trigger",
".",
"filter",
"(",
"'button.'",
"+",
"this",
".",
"_triggerClass",
")",
".",
"prop",
"(",
"'disabled'",
",",
"false",
")",
".",
"end",
"(",
")",
".",
"filter",
"(",
"'img.'",
"+",
"this",
".",
"_triggerClass",
")",
".",
"css",
"(",
"{",
"opacity",
":",
"'1.0'",
",",
"cursor",
":",
"''",
"}",
")",
";",
"}",
"this",
".",
"_disabled",
"=",
"$",
".",
"map",
"(",
"this",
".",
"_disabled",
",",
"function",
"(",
"value",
")",
"{",
"return",
"(",
"value",
"===",
"elem",
"[",
"0",
"]",
"?",
"null",
":",
"value",
")",
";",
"}",
")",
";",
"}"
]
| Enable the control.
@memberof CalendarsPicker
@param elem {Element} The control to affect.
@example $(selector).datepick('enable') | [
"Enable",
"the",
"control",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L675-L693 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem) {
elem = $(elem);
if (!elem.hasClass(this._getMarker())) {
return;
}
var inst = this._getInst(elem);
if (inst.inline) {
var inline = elem.children(':last');
var offset = inline.offset();
var relOffset = {left: 0, top: 0};
inline.parents().each(function() {
if ($(this).css('position') === 'relative') {
relOffset = $(this).offset();
return false;
}
});
var zIndex = elem.css('zIndex');
zIndex = (zIndex === 'auto' ? 0 : parseInt(zIndex, 10)) + 1;
elem.prepend('<div class="' + this._disableClass + '" style="' +
'width: ' + inline.outerWidth() + 'px; height: ' + inline.outerHeight() +
'px; left: ' + (offset.left - relOffset.left) + 'px; top: ' +
(offset.top - relOffset.top) + 'px; z-index: ' + zIndex + '"></div>').
find('button,select').prop('disabled', true).end().
find('a').removeAttr('href');
}
else {
elem.prop('disabled', true);
inst.trigger.filter('button.' + this._triggerClass).prop('disabled', true).end().
filter('img.' + this._triggerClass).css({opacity: '0.5', cursor: 'default'});
}
this._disabled = $.map(this._disabled,
function(value) { return (value === elem[0] ? null : value); }); // Delete entry
this._disabled.push(elem[0]);
} | javascript | function(elem) {
elem = $(elem);
if (!elem.hasClass(this._getMarker())) {
return;
}
var inst = this._getInst(elem);
if (inst.inline) {
var inline = elem.children(':last');
var offset = inline.offset();
var relOffset = {left: 0, top: 0};
inline.parents().each(function() {
if ($(this).css('position') === 'relative') {
relOffset = $(this).offset();
return false;
}
});
var zIndex = elem.css('zIndex');
zIndex = (zIndex === 'auto' ? 0 : parseInt(zIndex, 10)) + 1;
elem.prepend('<div class="' + this._disableClass + '" style="' +
'width: ' + inline.outerWidth() + 'px; height: ' + inline.outerHeight() +
'px; left: ' + (offset.left - relOffset.left) + 'px; top: ' +
(offset.top - relOffset.top) + 'px; z-index: ' + zIndex + '"></div>').
find('button,select').prop('disabled', true).end().
find('a').removeAttr('href');
}
else {
elem.prop('disabled', true);
inst.trigger.filter('button.' + this._triggerClass).prop('disabled', true).end().
filter('img.' + this._triggerClass).css({opacity: '0.5', cursor: 'default'});
}
this._disabled = $.map(this._disabled,
function(value) { return (value === elem[0] ? null : value); }); // Delete entry
this._disabled.push(elem[0]);
} | [
"function",
"(",
"elem",
")",
"{",
"elem",
"=",
"$",
"(",
"elem",
")",
";",
"if",
"(",
"!",
"elem",
".",
"hasClass",
"(",
"this",
".",
"_getMarker",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"var",
"inst",
"=",
"this",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"inst",
".",
"inline",
")",
"{",
"var",
"inline",
"=",
"elem",
".",
"children",
"(",
"':last'",
")",
";",
"var",
"offset",
"=",
"inline",
".",
"offset",
"(",
")",
";",
"var",
"relOffset",
"=",
"{",
"left",
":",
"0",
",",
"top",
":",
"0",
"}",
";",
"inline",
".",
"parents",
"(",
")",
".",
"each",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"$",
"(",
"this",
")",
".",
"css",
"(",
"'position'",
")",
"===",
"'relative'",
")",
"{",
"relOffset",
"=",
"$",
"(",
"this",
")",
".",
"offset",
"(",
")",
";",
"return",
"false",
";",
"}",
"}",
")",
";",
"var",
"zIndex",
"=",
"elem",
".",
"css",
"(",
"'zIndex'",
")",
";",
"zIndex",
"=",
"(",
"zIndex",
"===",
"'auto'",
"?",
"0",
":",
"parseInt",
"(",
"zIndex",
",",
"10",
")",
")",
"+",
"1",
";",
"elem",
".",
"prepend",
"(",
"'<div class=\"'",
"+",
"this",
".",
"_disableClass",
"+",
"'\" style=\"'",
"+",
"'width: '",
"+",
"inline",
".",
"outerWidth",
"(",
")",
"+",
"'px; height: '",
"+",
"inline",
".",
"outerHeight",
"(",
")",
"+",
"'px; left: '",
"+",
"(",
"offset",
".",
"left",
"-",
"relOffset",
".",
"left",
")",
"+",
"'px; top: '",
"+",
"(",
"offset",
".",
"top",
"-",
"relOffset",
".",
"top",
")",
"+",
"'px; z-index: '",
"+",
"zIndex",
"+",
"'\"></div>'",
")",
".",
"find",
"(",
"'button,select'",
")",
".",
"prop",
"(",
"'disabled'",
",",
"true",
")",
".",
"end",
"(",
")",
".",
"find",
"(",
"'a'",
")",
".",
"removeAttr",
"(",
"'href'",
")",
";",
"}",
"else",
"{",
"elem",
".",
"prop",
"(",
"'disabled'",
",",
"true",
")",
";",
"inst",
".",
"trigger",
".",
"filter",
"(",
"'button.'",
"+",
"this",
".",
"_triggerClass",
")",
".",
"prop",
"(",
"'disabled'",
",",
"true",
")",
".",
"end",
"(",
")",
".",
"filter",
"(",
"'img.'",
"+",
"this",
".",
"_triggerClass",
")",
".",
"css",
"(",
"{",
"opacity",
":",
"'0.5'",
",",
"cursor",
":",
"'default'",
"}",
")",
";",
"}",
"this",
".",
"_disabled",
"=",
"$",
".",
"map",
"(",
"this",
".",
"_disabled",
",",
"function",
"(",
"value",
")",
"{",
"return",
"(",
"value",
"===",
"elem",
"[",
"0",
"]",
"?",
"null",
":",
"value",
")",
";",
"}",
")",
";",
"this",
".",
"_disabled",
".",
"push",
"(",
"elem",
"[",
"0",
"]",
")",
";",
"}"
]
| Disable the control.
@memberof CalendarsPicker
@param elem {Element} The control to affect.
@example $(selector).datepick('disable') | [
"Disable",
"the",
"control",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L699-L732 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem) {
elem = $(elem.target || elem);
var inst = plugin._getInst(elem);
if (plugin.curInst === inst) {
return;
}
if (plugin.curInst) {
plugin.hide(plugin.curInst, true);
}
if (!$.isEmptyObject(inst)) {
// Retrieve existing date(s)
inst.lastVal = null;
inst.selectedDates = plugin._extractDates(inst, elem.val());
inst.pickingRange = false;
inst.drawDate = plugin._checkMinMax((inst.selectedDates[0] ||
inst.get('defaultDate') || inst.options.calendar.today()).newDate(), inst);
inst.prevDate = inst.drawDate.newDate();
plugin.curInst = inst;
// Generate content
plugin._update(elem[0], true);
// Adjust position before showing
var offset = plugin._checkOffset(inst);
inst.div.css({left: offset.left, top: offset.top});
// And display
var showAnim = inst.options.showAnim;
var showSpeed = inst.options.showSpeed;
showSpeed = (showSpeed === 'normal' && $.ui &&
parseInt($.ui.version.substring(2)) >= 8 ? '_default' : showSpeed);
if ($.effects && ($.effects[showAnim] || ($.effects.effect && $.effects.effect[showAnim]))) {
var data = inst.div.data(); // Update old effects data
for (var key in data) {
if (key.match(/^ec\.storage\./)) {
data[key] = inst._mainDiv.css(key.replace(/ec\.storage\./, ''));
}
}
inst.div.data(data).show(showAnim, inst.options.showOptions, showSpeed);
}
else {
inst.div[showAnim || 'show'](showAnim ? showSpeed : 0);
}
}
} | javascript | function(elem) {
elem = $(elem.target || elem);
var inst = plugin._getInst(elem);
if (plugin.curInst === inst) {
return;
}
if (plugin.curInst) {
plugin.hide(plugin.curInst, true);
}
if (!$.isEmptyObject(inst)) {
// Retrieve existing date(s)
inst.lastVal = null;
inst.selectedDates = plugin._extractDates(inst, elem.val());
inst.pickingRange = false;
inst.drawDate = plugin._checkMinMax((inst.selectedDates[0] ||
inst.get('defaultDate') || inst.options.calendar.today()).newDate(), inst);
inst.prevDate = inst.drawDate.newDate();
plugin.curInst = inst;
// Generate content
plugin._update(elem[0], true);
// Adjust position before showing
var offset = plugin._checkOffset(inst);
inst.div.css({left: offset.left, top: offset.top});
// And display
var showAnim = inst.options.showAnim;
var showSpeed = inst.options.showSpeed;
showSpeed = (showSpeed === 'normal' && $.ui &&
parseInt($.ui.version.substring(2)) >= 8 ? '_default' : showSpeed);
if ($.effects && ($.effects[showAnim] || ($.effects.effect && $.effects.effect[showAnim]))) {
var data = inst.div.data(); // Update old effects data
for (var key in data) {
if (key.match(/^ec\.storage\./)) {
data[key] = inst._mainDiv.css(key.replace(/ec\.storage\./, ''));
}
}
inst.div.data(data).show(showAnim, inst.options.showOptions, showSpeed);
}
else {
inst.div[showAnim || 'show'](showAnim ? showSpeed : 0);
}
}
} | [
"function",
"(",
"elem",
")",
"{",
"elem",
"=",
"$",
"(",
"elem",
".",
"target",
"||",
"elem",
")",
";",
"var",
"inst",
"=",
"plugin",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"plugin",
".",
"curInst",
"===",
"inst",
")",
"{",
"return",
";",
"}",
"if",
"(",
"plugin",
".",
"curInst",
")",
"{",
"plugin",
".",
"hide",
"(",
"plugin",
".",
"curInst",
",",
"true",
")",
";",
"}",
"if",
"(",
"!",
"$",
".",
"isEmptyObject",
"(",
"inst",
")",
")",
"{",
"inst",
".",
"lastVal",
"=",
"null",
";",
"inst",
".",
"selectedDates",
"=",
"plugin",
".",
"_extractDates",
"(",
"inst",
",",
"elem",
".",
"val",
"(",
")",
")",
";",
"inst",
".",
"pickingRange",
"=",
"false",
";",
"inst",
".",
"drawDate",
"=",
"plugin",
".",
"_checkMinMax",
"(",
"(",
"inst",
".",
"selectedDates",
"[",
"0",
"]",
"||",
"inst",
".",
"get",
"(",
"'defaultDate'",
")",
"||",
"inst",
".",
"options",
".",
"calendar",
".",
"today",
"(",
")",
")",
".",
"newDate",
"(",
")",
",",
"inst",
")",
";",
"inst",
".",
"prevDate",
"=",
"inst",
".",
"drawDate",
".",
"newDate",
"(",
")",
";",
"plugin",
".",
"curInst",
"=",
"inst",
";",
"plugin",
".",
"_update",
"(",
"elem",
"[",
"0",
"]",
",",
"true",
")",
";",
"var",
"offset",
"=",
"plugin",
".",
"_checkOffset",
"(",
"inst",
")",
";",
"inst",
".",
"div",
".",
"css",
"(",
"{",
"left",
":",
"offset",
".",
"left",
",",
"top",
":",
"offset",
".",
"top",
"}",
")",
";",
"var",
"showAnim",
"=",
"inst",
".",
"options",
".",
"showAnim",
";",
"var",
"showSpeed",
"=",
"inst",
".",
"options",
".",
"showSpeed",
";",
"showSpeed",
"=",
"(",
"showSpeed",
"===",
"'normal'",
"&&",
"$",
".",
"ui",
"&&",
"parseInt",
"(",
"$",
".",
"ui",
".",
"version",
".",
"substring",
"(",
"2",
")",
")",
">=",
"8",
"?",
"'_default'",
":",
"showSpeed",
")",
";",
"if",
"(",
"$",
".",
"effects",
"&&",
"(",
"$",
".",
"effects",
"[",
"showAnim",
"]",
"||",
"(",
"$",
".",
"effects",
".",
"effect",
"&&",
"$",
".",
"effects",
".",
"effect",
"[",
"showAnim",
"]",
")",
")",
")",
"{",
"var",
"data",
"=",
"inst",
".",
"div",
".",
"data",
"(",
")",
";",
"for",
"(",
"var",
"key",
"in",
"data",
")",
"{",
"if",
"(",
"key",
".",
"match",
"(",
"/",
"^ec\\.storage\\.",
"/",
")",
")",
"{",
"data",
"[",
"key",
"]",
"=",
"inst",
".",
"_mainDiv",
".",
"css",
"(",
"key",
".",
"replace",
"(",
"/",
"ec\\.storage\\.",
"/",
",",
"''",
")",
")",
";",
"}",
"}",
"inst",
".",
"div",
".",
"data",
"(",
"data",
")",
".",
"show",
"(",
"showAnim",
",",
"inst",
".",
"options",
".",
"showOptions",
",",
"showSpeed",
")",
";",
"}",
"else",
"{",
"inst",
".",
"div",
"[",
"showAnim",
"||",
"'show'",
"]",
"(",
"showAnim",
"?",
"showSpeed",
":",
"0",
")",
";",
"}",
"}",
"}"
]
| Show a popup datepicker.
@memberof CalendarsPicker
@param elem {Event|Element} a focus event or the control to use.
@example $(selector).datepick('show') | [
"Show",
"a",
"popup",
"datepicker",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L747-L788 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(inst, datesText) {
if (datesText === inst.lastVal) {
return;
}
inst.lastVal = datesText;
datesText = datesText.split(inst.options.multiSelect ? inst.options.multiSeparator :
(inst.options.rangeSelect ? inst.options.rangeSeparator : '\x00'));
var dates = [];
for (var i = 0; i < datesText.length; i++) {
try {
var date = inst.options.calendar.parseDate(inst.get('dateFormat'), datesText[i]);
if (date) {
var found = false;
for (var j = 0; j < dates.length; j++) {
if (dates[j].compareTo(date) === 0) {
found = true;
break;
}
}
if (!found) {
dates.push(date);
}
}
}
catch (e) {
// Ignore
}
}
dates.splice(inst.options.multiSelect || (inst.options.rangeSelect ? 2 : 1), dates.length);
if (inst.options.rangeSelect && dates.length === 1) {
dates[1] = dates[0];
}
return dates;
} | javascript | function(inst, datesText) {
if (datesText === inst.lastVal) {
return;
}
inst.lastVal = datesText;
datesText = datesText.split(inst.options.multiSelect ? inst.options.multiSeparator :
(inst.options.rangeSelect ? inst.options.rangeSeparator : '\x00'));
var dates = [];
for (var i = 0; i < datesText.length; i++) {
try {
var date = inst.options.calendar.parseDate(inst.get('dateFormat'), datesText[i]);
if (date) {
var found = false;
for (var j = 0; j < dates.length; j++) {
if (dates[j].compareTo(date) === 0) {
found = true;
break;
}
}
if (!found) {
dates.push(date);
}
}
}
catch (e) {
// Ignore
}
}
dates.splice(inst.options.multiSelect || (inst.options.rangeSelect ? 2 : 1), dates.length);
if (inst.options.rangeSelect && dates.length === 1) {
dates[1] = dates[0];
}
return dates;
} | [
"function",
"(",
"inst",
",",
"datesText",
")",
"{",
"if",
"(",
"datesText",
"===",
"inst",
".",
"lastVal",
")",
"{",
"return",
";",
"}",
"inst",
".",
"lastVal",
"=",
"datesText",
";",
"datesText",
"=",
"datesText",
".",
"split",
"(",
"inst",
".",
"options",
".",
"multiSelect",
"?",
"inst",
".",
"options",
".",
"multiSeparator",
":",
"(",
"inst",
".",
"options",
".",
"rangeSelect",
"?",
"inst",
".",
"options",
".",
"rangeSeparator",
":",
"'\\x00'",
")",
")",
";",
"\\x00",
"var",
"dates",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"datesText",
".",
"length",
";",
"i",
"++",
")",
"{",
"try",
"{",
"var",
"date",
"=",
"inst",
".",
"options",
".",
"calendar",
".",
"parseDate",
"(",
"inst",
".",
"get",
"(",
"'dateFormat'",
")",
",",
"datesText",
"[",
"i",
"]",
")",
";",
"if",
"(",
"date",
")",
"{",
"var",
"found",
"=",
"false",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"dates",
".",
"length",
";",
"j",
"++",
")",
"{",
"if",
"(",
"dates",
"[",
"j",
"]",
".",
"compareTo",
"(",
"date",
")",
"===",
"0",
")",
"{",
"found",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"found",
")",
"{",
"dates",
".",
"push",
"(",
"date",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"e",
")",
"{",
"}",
"}",
"dates",
".",
"splice",
"(",
"inst",
".",
"options",
".",
"multiSelect",
"||",
"(",
"inst",
".",
"options",
".",
"rangeSelect",
"?",
"2",
":",
"1",
")",
",",
"dates",
".",
"length",
")",
";",
"if",
"(",
"inst",
".",
"options",
".",
"rangeSelect",
"&&",
"dates",
".",
"length",
"===",
"1",
")",
"{",
"dates",
"[",
"1",
"]",
"=",
"dates",
"[",
"0",
"]",
";",
"}",
"}"
]
| Extract possible dates from a string.
@memberof CalendarsPicker
@private
@param inst {object} The current instance settings.
@param text {string} The text to extract from.
@return {CDate[]} The extracted dates. | [
"Extract",
"possible",
"dates",
"from",
"a",
"string",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L796-L829 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem, hidden) {
elem = $(elem.target || elem);
var inst = plugin._getInst(elem);
if (!$.isEmptyObject(inst)) {
if (inst.inline || plugin.curInst === inst) {
if ($.isFunction(inst.options.onChangeMonthYear) && (!inst.prevDate ||
inst.prevDate.year() !== inst.drawDate.year() ||
inst.prevDate.month() !== inst.drawDate.month())) {
inst.options.onChangeMonthYear.apply(elem[0],
[inst.drawDate.year(), inst.drawDate.month()]);
}
}
if (inst.inline) {
var index = $('a, :input', elem).index($(':focus', elem));
elem.html(this._generateContent(elem[0], inst));
var focus = elem.find('a, :input');
focus.eq(Math.max(Math.min(index, focus.length - 1), 0)).focus();
}
else if (plugin.curInst === inst) {
if (!inst.div) {
inst.div = $('<div></div>').addClass(this._popupClass).
css({display: (hidden ? 'none' : 'static'), position: 'absolute',
left: elem.offset().left, top: elem.offset().top + elem.outerHeight()}).
appendTo($(inst.options.popupContainer || 'body'));
if ($.fn.mousewheel) {
inst.div.mousewheel(this._doMouseWheel);
}
}
inst.div.html(this._generateContent(elem[0], inst));
elem.focus();
}
}
} | javascript | function(elem, hidden) {
elem = $(elem.target || elem);
var inst = plugin._getInst(elem);
if (!$.isEmptyObject(inst)) {
if (inst.inline || plugin.curInst === inst) {
if ($.isFunction(inst.options.onChangeMonthYear) && (!inst.prevDate ||
inst.prevDate.year() !== inst.drawDate.year() ||
inst.prevDate.month() !== inst.drawDate.month())) {
inst.options.onChangeMonthYear.apply(elem[0],
[inst.drawDate.year(), inst.drawDate.month()]);
}
}
if (inst.inline) {
var index = $('a, :input', elem).index($(':focus', elem));
elem.html(this._generateContent(elem[0], inst));
var focus = elem.find('a, :input');
focus.eq(Math.max(Math.min(index, focus.length - 1), 0)).focus();
}
else if (plugin.curInst === inst) {
if (!inst.div) {
inst.div = $('<div></div>').addClass(this._popupClass).
css({display: (hidden ? 'none' : 'static'), position: 'absolute',
left: elem.offset().left, top: elem.offset().top + elem.outerHeight()}).
appendTo($(inst.options.popupContainer || 'body'));
if ($.fn.mousewheel) {
inst.div.mousewheel(this._doMouseWheel);
}
}
inst.div.html(this._generateContent(elem[0], inst));
elem.focus();
}
}
} | [
"function",
"(",
"elem",
",",
"hidden",
")",
"{",
"elem",
"=",
"$",
"(",
"elem",
".",
"target",
"||",
"elem",
")",
";",
"var",
"inst",
"=",
"plugin",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"!",
"$",
".",
"isEmptyObject",
"(",
"inst",
")",
")",
"{",
"if",
"(",
"inst",
".",
"inline",
"||",
"plugin",
".",
"curInst",
"===",
"inst",
")",
"{",
"if",
"(",
"$",
".",
"isFunction",
"(",
"inst",
".",
"options",
".",
"onChangeMonthYear",
")",
"&&",
"(",
"!",
"inst",
".",
"prevDate",
"||",
"inst",
".",
"prevDate",
".",
"year",
"(",
")",
"!==",
"inst",
".",
"drawDate",
".",
"year",
"(",
")",
"||",
"inst",
".",
"prevDate",
".",
"month",
"(",
")",
"!==",
"inst",
".",
"drawDate",
".",
"month",
"(",
")",
")",
")",
"{",
"inst",
".",
"options",
".",
"onChangeMonthYear",
".",
"apply",
"(",
"elem",
"[",
"0",
"]",
",",
"[",
"inst",
".",
"drawDate",
".",
"year",
"(",
")",
",",
"inst",
".",
"drawDate",
".",
"month",
"(",
")",
"]",
")",
";",
"}",
"}",
"if",
"(",
"inst",
".",
"inline",
")",
"{",
"var",
"index",
"=",
"$",
"(",
"'a, :input'",
",",
"elem",
")",
".",
"index",
"(",
"$",
"(",
"':focus'",
",",
"elem",
")",
")",
";",
"elem",
".",
"html",
"(",
"this",
".",
"_generateContent",
"(",
"elem",
"[",
"0",
"]",
",",
"inst",
")",
")",
";",
"var",
"focus",
"=",
"elem",
".",
"find",
"(",
"'a, :input'",
")",
";",
"focus",
".",
"eq",
"(",
"Math",
".",
"max",
"(",
"Math",
".",
"min",
"(",
"index",
",",
"focus",
".",
"length",
"-",
"1",
")",
",",
"0",
")",
")",
".",
"focus",
"(",
")",
";",
"}",
"else",
"if",
"(",
"plugin",
".",
"curInst",
"===",
"inst",
")",
"{",
"if",
"(",
"!",
"inst",
".",
"div",
")",
"{",
"inst",
".",
"div",
"=",
"$",
"(",
"'<div></div>'",
")",
".",
"addClass",
"(",
"this",
".",
"_popupClass",
")",
".",
"css",
"(",
"{",
"display",
":",
"(",
"hidden",
"?",
"'none'",
":",
"'static'",
")",
",",
"position",
":",
"'absolute'",
",",
"left",
":",
"elem",
".",
"offset",
"(",
")",
".",
"left",
",",
"top",
":",
"elem",
".",
"offset",
"(",
")",
".",
"top",
"+",
"elem",
".",
"outerHeight",
"(",
")",
"}",
")",
".",
"appendTo",
"(",
"$",
"(",
"inst",
".",
"options",
".",
"popupContainer",
"||",
"'body'",
")",
")",
";",
"if",
"(",
"$",
".",
"fn",
".",
"mousewheel",
")",
"{",
"inst",
".",
"div",
".",
"mousewheel",
"(",
"this",
".",
"_doMouseWheel",
")",
";",
"}",
"}",
"inst",
".",
"div",
".",
"html",
"(",
"this",
".",
"_generateContent",
"(",
"elem",
"[",
"0",
"]",
",",
"inst",
")",
")",
";",
"elem",
".",
"focus",
"(",
")",
";",
"}",
"}",
"}"
]
| Update the datepicker display.
@memberof CalendarsPicker
@private
@param elem {Event|Element} a focus event or the control to use.
@param hidden {boolean} <code>true</code> to initially hide the datepicker. | [
"Update",
"the",
"datepicker",
"display",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L836-L868 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem, keyUp) {
var inst = this._getInst(elem);
if (!$.isEmptyObject(inst)) {
var value = '';
var altValue = '';
var sep = (inst.options.multiSelect ? inst.options.multiSeparator :
inst.options.rangeSeparator);
var calendar = inst.options.calendar;
var dateFormat = inst.get('dateFormat');
var altFormat = inst.options.altFormat || dateFormat;
var settings = {localNumbers: inst.options.localNumbers};
for (var i = 0; i < inst.selectedDates.length; i++) {
value += (keyUp ? '' : (i > 0 ? sep : '') +
calendar.formatDate(dateFormat, inst.selectedDates[i], settings));
altValue += (i > 0 ? sep : '') +
calendar.formatDate(altFormat, inst.selectedDates[i], settings);
}
if (!inst.inline && !keyUp) {
$(elem).val(value);
}
$(inst.options.altField).val(altValue);
if ($.isFunction(inst.options.onSelect) && !keyUp && !inst.inSelect) {
inst.inSelect = true; // Prevent endless loops
inst.options.onSelect.apply(elem, [inst.selectedDates]);
inst.inSelect = false;
}
}
} | javascript | function(elem, keyUp) {
var inst = this._getInst(elem);
if (!$.isEmptyObject(inst)) {
var value = '';
var altValue = '';
var sep = (inst.options.multiSelect ? inst.options.multiSeparator :
inst.options.rangeSeparator);
var calendar = inst.options.calendar;
var dateFormat = inst.get('dateFormat');
var altFormat = inst.options.altFormat || dateFormat;
var settings = {localNumbers: inst.options.localNumbers};
for (var i = 0; i < inst.selectedDates.length; i++) {
value += (keyUp ? '' : (i > 0 ? sep : '') +
calendar.formatDate(dateFormat, inst.selectedDates[i], settings));
altValue += (i > 0 ? sep : '') +
calendar.formatDate(altFormat, inst.selectedDates[i], settings);
}
if (!inst.inline && !keyUp) {
$(elem).val(value);
}
$(inst.options.altField).val(altValue);
if ($.isFunction(inst.options.onSelect) && !keyUp && !inst.inSelect) {
inst.inSelect = true; // Prevent endless loops
inst.options.onSelect.apply(elem, [inst.selectedDates]);
inst.inSelect = false;
}
}
} | [
"function",
"(",
"elem",
",",
"keyUp",
")",
"{",
"var",
"inst",
"=",
"this",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"!",
"$",
".",
"isEmptyObject",
"(",
"inst",
")",
")",
"{",
"var",
"value",
"=",
"''",
";",
"var",
"altValue",
"=",
"''",
";",
"var",
"sep",
"=",
"(",
"inst",
".",
"options",
".",
"multiSelect",
"?",
"inst",
".",
"options",
".",
"multiSeparator",
":",
"inst",
".",
"options",
".",
"rangeSeparator",
")",
";",
"var",
"calendar",
"=",
"inst",
".",
"options",
".",
"calendar",
";",
"var",
"dateFormat",
"=",
"inst",
".",
"get",
"(",
"'dateFormat'",
")",
";",
"var",
"altFormat",
"=",
"inst",
".",
"options",
".",
"altFormat",
"||",
"dateFormat",
";",
"var",
"settings",
"=",
"{",
"localNumbers",
":",
"inst",
".",
"options",
".",
"localNumbers",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"inst",
".",
"selectedDates",
".",
"length",
";",
"i",
"++",
")",
"{",
"value",
"+=",
"(",
"keyUp",
"?",
"''",
":",
"(",
"i",
">",
"0",
"?",
"sep",
":",
"''",
")",
"+",
"calendar",
".",
"formatDate",
"(",
"dateFormat",
",",
"inst",
".",
"selectedDates",
"[",
"i",
"]",
",",
"settings",
")",
")",
";",
"altValue",
"+=",
"(",
"i",
">",
"0",
"?",
"sep",
":",
"''",
")",
"+",
"calendar",
".",
"formatDate",
"(",
"altFormat",
",",
"inst",
".",
"selectedDates",
"[",
"i",
"]",
",",
"settings",
")",
";",
"}",
"if",
"(",
"!",
"inst",
".",
"inline",
"&&",
"!",
"keyUp",
")",
"{",
"$",
"(",
"elem",
")",
".",
"val",
"(",
"value",
")",
";",
"}",
"$",
"(",
"inst",
".",
"options",
".",
"altField",
")",
".",
"val",
"(",
"altValue",
")",
";",
"if",
"(",
"$",
".",
"isFunction",
"(",
"inst",
".",
"options",
".",
"onSelect",
")",
"&&",
"!",
"keyUp",
"&&",
"!",
"inst",
".",
"inSelect",
")",
"{",
"inst",
".",
"inSelect",
"=",
"true",
";",
"inst",
".",
"options",
".",
"onSelect",
".",
"apply",
"(",
"elem",
",",
"[",
"inst",
".",
"selectedDates",
"]",
")",
";",
"inst",
".",
"inSelect",
"=",
"false",
";",
"}",
"}",
"}"
]
| Update the input field and any alternate field with the current dates.
@memberof CalendarsPicker
@private
@param elem {Element} The control to use.
@param keyUp {boolean} <code>true</code> if coming from <code>keyUp</code> processing (internal). | [
"Update",
"the",
"input",
"field",
"and",
"any",
"alternate",
"field",
"with",
"the",
"current",
"dates",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L875-L902 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem) {
var convert = function(value) {
return {thin: 1, medium: 3, thick: 5}[value] || value;
};
return [parseFloat(convert(elem.css('border-left-width'))),
parseFloat(convert(elem.css('border-top-width')))];
} | javascript | function(elem) {
var convert = function(value) {
return {thin: 1, medium: 3, thick: 5}[value] || value;
};
return [parseFloat(convert(elem.css('border-left-width'))),
parseFloat(convert(elem.css('border-top-width')))];
} | [
"function",
"(",
"elem",
")",
"{",
"var",
"convert",
"=",
"function",
"(",
"value",
")",
"{",
"return",
"{",
"thin",
":",
"1",
",",
"medium",
":",
"3",
",",
"thick",
":",
"5",
"}",
"[",
"value",
"]",
"||",
"value",
";",
"}",
";",
"return",
"[",
"parseFloat",
"(",
"convert",
"(",
"elem",
".",
"css",
"(",
"'border-left-width'",
")",
")",
")",
",",
"parseFloat",
"(",
"convert",
"(",
"elem",
".",
"css",
"(",
"'border-top-width'",
")",
")",
")",
"]",
";",
"}"
]
| Retrieve the size of left and top borders for an element.
@memberof CalendarsPicker
@private
@param elem {jQuery} The element of interest.
@return {number[]} The left and top borders. | [
"Retrieve",
"the",
"size",
"of",
"left",
"and",
"top",
"borders",
"for",
"an",
"element",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L909-L915 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(inst) {
var base = (inst.elem.is(':hidden') && inst.trigger ? inst.trigger : inst.elem);
var offset = base.offset();
var browserWidth = $(window).width();
var browserHeight = $(window).height();
if (browserWidth === 0) {
return offset;
}
var isFixed = false;
$(inst.elem).parents().each(function() {
isFixed |= $(this).css('position') === 'fixed';
return !isFixed;
});
var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
var above = offset.top - (isFixed ? scrollY : 0) - inst.div.outerHeight();
var below = offset.top - (isFixed ? scrollY : 0) + base.outerHeight();
var alignL = offset.left - (isFixed ? scrollX : 0);
var alignR = offset.left - (isFixed ? scrollX : 0) + base.outerWidth() - inst.div.outerWidth();
var tooWide = (offset.left - scrollX + inst.div.outerWidth()) > browserWidth;
var tooHigh = (offset.top - scrollY + inst.elem.outerHeight() +
inst.div.outerHeight()) > browserHeight;
inst.div.css('position', isFixed ? 'fixed' : 'absolute');
var alignment = inst.options.alignment;
if (alignment === 'topLeft') {
offset = {left: alignL, top: above};
}
else if (alignment === 'topRight') {
offset = {left: alignR, top: above};
}
else if (alignment === 'bottomLeft') {
offset = {left: alignL, top: below};
}
else if (alignment === 'bottomRight') {
offset = {left: alignR, top: below};
}
else if (alignment === 'top') {
offset = {left: (inst.options.isRTL || tooWide ? alignR : alignL), top: above};
}
else { // bottom
offset = {left: (inst.options.isRTL || tooWide ? alignR : alignL),
top: (tooHigh ? above : below)};
}
offset.left = Math.max((isFixed ? 0 : scrollX), offset.left);
offset.top = Math.max((isFixed ? 0 : scrollY), offset.top);
return offset;
} | javascript | function(inst) {
var base = (inst.elem.is(':hidden') && inst.trigger ? inst.trigger : inst.elem);
var offset = base.offset();
var browserWidth = $(window).width();
var browserHeight = $(window).height();
if (browserWidth === 0) {
return offset;
}
var isFixed = false;
$(inst.elem).parents().each(function() {
isFixed |= $(this).css('position') === 'fixed';
return !isFixed;
});
var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
var above = offset.top - (isFixed ? scrollY : 0) - inst.div.outerHeight();
var below = offset.top - (isFixed ? scrollY : 0) + base.outerHeight();
var alignL = offset.left - (isFixed ? scrollX : 0);
var alignR = offset.left - (isFixed ? scrollX : 0) + base.outerWidth() - inst.div.outerWidth();
var tooWide = (offset.left - scrollX + inst.div.outerWidth()) > browserWidth;
var tooHigh = (offset.top - scrollY + inst.elem.outerHeight() +
inst.div.outerHeight()) > browserHeight;
inst.div.css('position', isFixed ? 'fixed' : 'absolute');
var alignment = inst.options.alignment;
if (alignment === 'topLeft') {
offset = {left: alignL, top: above};
}
else if (alignment === 'topRight') {
offset = {left: alignR, top: above};
}
else if (alignment === 'bottomLeft') {
offset = {left: alignL, top: below};
}
else if (alignment === 'bottomRight') {
offset = {left: alignR, top: below};
}
else if (alignment === 'top') {
offset = {left: (inst.options.isRTL || tooWide ? alignR : alignL), top: above};
}
else { // bottom
offset = {left: (inst.options.isRTL || tooWide ? alignR : alignL),
top: (tooHigh ? above : below)};
}
offset.left = Math.max((isFixed ? 0 : scrollX), offset.left);
offset.top = Math.max((isFixed ? 0 : scrollY), offset.top);
return offset;
} | [
"function",
"(",
"inst",
")",
"{",
"var",
"base",
"=",
"(",
"inst",
".",
"elem",
".",
"is",
"(",
"':hidden'",
")",
"&&",
"inst",
".",
"trigger",
"?",
"inst",
".",
"trigger",
":",
"inst",
".",
"elem",
")",
";",
"var",
"offset",
"=",
"base",
".",
"offset",
"(",
")",
";",
"var",
"browserWidth",
"=",
"$",
"(",
"window",
")",
".",
"width",
"(",
")",
";",
"var",
"browserHeight",
"=",
"$",
"(",
"window",
")",
".",
"height",
"(",
")",
";",
"if",
"(",
"browserWidth",
"===",
"0",
")",
"{",
"return",
"offset",
";",
"}",
"var",
"isFixed",
"=",
"false",
";",
"$",
"(",
"inst",
".",
"elem",
")",
".",
"parents",
"(",
")",
".",
"each",
"(",
"function",
"(",
")",
"{",
"isFixed",
"|=",
"$",
"(",
"this",
")",
".",
"css",
"(",
"'position'",
")",
"===",
"'fixed'",
";",
"return",
"!",
"isFixed",
";",
"}",
")",
";",
"var",
"scrollX",
"=",
"document",
".",
"documentElement",
".",
"scrollLeft",
"||",
"document",
".",
"body",
".",
"scrollLeft",
";",
"var",
"scrollY",
"=",
"document",
".",
"documentElement",
".",
"scrollTop",
"||",
"document",
".",
"body",
".",
"scrollTop",
";",
"var",
"above",
"=",
"offset",
".",
"top",
"-",
"(",
"isFixed",
"?",
"scrollY",
":",
"0",
")",
"-",
"inst",
".",
"div",
".",
"outerHeight",
"(",
")",
";",
"var",
"below",
"=",
"offset",
".",
"top",
"-",
"(",
"isFixed",
"?",
"scrollY",
":",
"0",
")",
"+",
"base",
".",
"outerHeight",
"(",
")",
";",
"var",
"alignL",
"=",
"offset",
".",
"left",
"-",
"(",
"isFixed",
"?",
"scrollX",
":",
"0",
")",
";",
"var",
"alignR",
"=",
"offset",
".",
"left",
"-",
"(",
"isFixed",
"?",
"scrollX",
":",
"0",
")",
"+",
"base",
".",
"outerWidth",
"(",
")",
"-",
"inst",
".",
"div",
".",
"outerWidth",
"(",
")",
";",
"var",
"tooWide",
"=",
"(",
"offset",
".",
"left",
"-",
"scrollX",
"+",
"inst",
".",
"div",
".",
"outerWidth",
"(",
")",
")",
">",
"browserWidth",
";",
"var",
"tooHigh",
"=",
"(",
"offset",
".",
"top",
"-",
"scrollY",
"+",
"inst",
".",
"elem",
".",
"outerHeight",
"(",
")",
"+",
"inst",
".",
"div",
".",
"outerHeight",
"(",
")",
")",
">",
"browserHeight",
";",
"inst",
".",
"div",
".",
"css",
"(",
"'position'",
",",
"isFixed",
"?",
"'fixed'",
":",
"'absolute'",
")",
";",
"var",
"alignment",
"=",
"inst",
".",
"options",
".",
"alignment",
";",
"if",
"(",
"alignment",
"===",
"'topLeft'",
")",
"{",
"offset",
"=",
"{",
"left",
":",
"alignL",
",",
"top",
":",
"above",
"}",
";",
"}",
"else",
"if",
"(",
"alignment",
"===",
"'topRight'",
")",
"{",
"offset",
"=",
"{",
"left",
":",
"alignR",
",",
"top",
":",
"above",
"}",
";",
"}",
"else",
"if",
"(",
"alignment",
"===",
"'bottomLeft'",
")",
"{",
"offset",
"=",
"{",
"left",
":",
"alignL",
",",
"top",
":",
"below",
"}",
";",
"}",
"else",
"if",
"(",
"alignment",
"===",
"'bottomRight'",
")",
"{",
"offset",
"=",
"{",
"left",
":",
"alignR",
",",
"top",
":",
"below",
"}",
";",
"}",
"else",
"if",
"(",
"alignment",
"===",
"'top'",
")",
"{",
"offset",
"=",
"{",
"left",
":",
"(",
"inst",
".",
"options",
".",
"isRTL",
"||",
"tooWide",
"?",
"alignR",
":",
"alignL",
")",
",",
"top",
":",
"above",
"}",
";",
"}",
"else",
"{",
"offset",
"=",
"{",
"left",
":",
"(",
"inst",
".",
"options",
".",
"isRTL",
"||",
"tooWide",
"?",
"alignR",
":",
"alignL",
")",
",",
"top",
":",
"(",
"tooHigh",
"?",
"above",
":",
"below",
")",
"}",
";",
"}",
"offset",
".",
"left",
"=",
"Math",
".",
"max",
"(",
"(",
"isFixed",
"?",
"0",
":",
"scrollX",
")",
",",
"offset",
".",
"left",
")",
";",
"offset",
".",
"top",
"=",
"Math",
".",
"max",
"(",
"(",
"isFixed",
"?",
"0",
":",
"scrollY",
")",
",",
"offset",
".",
"top",
")",
";",
"return",
"offset",
";",
"}"
]
| Check positioning to remain on the screen.
@memberof CalendarsPicker
@private
@param inst {object} The current instance settings.
@return {object} The updated offset for the datepicker. | [
"Check",
"positioning",
"to",
"remain",
"on",
"the",
"screen",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L922-L968 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(event) {
if (!plugin.curInst) {
return;
}
var elem = $(event.target);
if (elem.closest('.' + plugin._popupClass + ',.' + plugin._triggerClass).length === 0 &&
!elem.hasClass(plugin._getMarker())) {
plugin.hide(plugin.curInst);
}
} | javascript | function(event) {
if (!plugin.curInst) {
return;
}
var elem = $(event.target);
if (elem.closest('.' + plugin._popupClass + ',.' + plugin._triggerClass).length === 0 &&
!elem.hasClass(plugin._getMarker())) {
plugin.hide(plugin.curInst);
}
} | [
"function",
"(",
"event",
")",
"{",
"if",
"(",
"!",
"plugin",
".",
"curInst",
")",
"{",
"return",
";",
"}",
"var",
"elem",
"=",
"$",
"(",
"event",
".",
"target",
")",
";",
"if",
"(",
"elem",
".",
"closest",
"(",
"'.'",
"+",
"plugin",
".",
"_popupClass",
"+",
"',.'",
"+",
"plugin",
".",
"_triggerClass",
")",
".",
"length",
"===",
"0",
"&&",
"!",
"elem",
".",
"hasClass",
"(",
"plugin",
".",
"_getMarker",
"(",
")",
")",
")",
"{",
"plugin",
".",
"hide",
"(",
"plugin",
".",
"curInst",
")",
";",
"}",
"}"
]
| Close date picker if clicked elsewhere.
@memberof CalendarsPicker
@private
@param event {MouseEvent} The mouse click to check. | [
"Close",
"date",
"picker",
"if",
"clicked",
"elsewhere",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L974-L983 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem, immediate) {
if (!elem) {
return;
}
var inst = this._getInst(elem);
if ($.isEmptyObject(inst)) {
inst = elem;
}
if (inst && inst === plugin.curInst) {
var showAnim = (immediate ? '' : inst.options.showAnim);
var showSpeed = inst.options.showSpeed;
showSpeed = (showSpeed === 'normal' && $.ui &&
parseInt($.ui.version.substring(2)) >= 8 ? '_default' : showSpeed);
var postProcess = function() {
if (!inst.div) {
return;
}
inst.div.remove();
inst.div = null;
plugin.curInst = null;
if ($.isFunction(inst.options.onClose)) {
inst.options.onClose.apply(elem, [inst.selectedDates]);
}
};
inst.div.stop();
if ($.effects && ($.effects[showAnim] || ($.effects.effect && $.effects.effect[showAnim]))) {
inst.div.hide(showAnim, inst.options.showOptions, showSpeed, postProcess);
}
else {
var hideAnim = (showAnim === 'slideDown' ? 'slideUp' :
(showAnim === 'fadeIn' ? 'fadeOut' : 'hide'));
inst.div[hideAnim]((showAnim ? showSpeed : ''), postProcess);
}
if (!showAnim) {
postProcess();
}
}
} | javascript | function(elem, immediate) {
if (!elem) {
return;
}
var inst = this._getInst(elem);
if ($.isEmptyObject(inst)) {
inst = elem;
}
if (inst && inst === plugin.curInst) {
var showAnim = (immediate ? '' : inst.options.showAnim);
var showSpeed = inst.options.showSpeed;
showSpeed = (showSpeed === 'normal' && $.ui &&
parseInt($.ui.version.substring(2)) >= 8 ? '_default' : showSpeed);
var postProcess = function() {
if (!inst.div) {
return;
}
inst.div.remove();
inst.div = null;
plugin.curInst = null;
if ($.isFunction(inst.options.onClose)) {
inst.options.onClose.apply(elem, [inst.selectedDates]);
}
};
inst.div.stop();
if ($.effects && ($.effects[showAnim] || ($.effects.effect && $.effects.effect[showAnim]))) {
inst.div.hide(showAnim, inst.options.showOptions, showSpeed, postProcess);
}
else {
var hideAnim = (showAnim === 'slideDown' ? 'slideUp' :
(showAnim === 'fadeIn' ? 'fadeOut' : 'hide'));
inst.div[hideAnim]((showAnim ? showSpeed : ''), postProcess);
}
if (!showAnim) {
postProcess();
}
}
} | [
"function",
"(",
"elem",
",",
"immediate",
")",
"{",
"if",
"(",
"!",
"elem",
")",
"{",
"return",
";",
"}",
"var",
"inst",
"=",
"this",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"$",
".",
"isEmptyObject",
"(",
"inst",
")",
")",
"{",
"inst",
"=",
"elem",
";",
"}",
"if",
"(",
"inst",
"&&",
"inst",
"===",
"plugin",
".",
"curInst",
")",
"{",
"var",
"showAnim",
"=",
"(",
"immediate",
"?",
"''",
":",
"inst",
".",
"options",
".",
"showAnim",
")",
";",
"var",
"showSpeed",
"=",
"inst",
".",
"options",
".",
"showSpeed",
";",
"showSpeed",
"=",
"(",
"showSpeed",
"===",
"'normal'",
"&&",
"$",
".",
"ui",
"&&",
"parseInt",
"(",
"$",
".",
"ui",
".",
"version",
".",
"substring",
"(",
"2",
")",
")",
">=",
"8",
"?",
"'_default'",
":",
"showSpeed",
")",
";",
"var",
"postProcess",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"inst",
".",
"div",
")",
"{",
"return",
";",
"}",
"inst",
".",
"div",
".",
"remove",
"(",
")",
";",
"inst",
".",
"div",
"=",
"null",
";",
"plugin",
".",
"curInst",
"=",
"null",
";",
"if",
"(",
"$",
".",
"isFunction",
"(",
"inst",
".",
"options",
".",
"onClose",
")",
")",
"{",
"inst",
".",
"options",
".",
"onClose",
".",
"apply",
"(",
"elem",
",",
"[",
"inst",
".",
"selectedDates",
"]",
")",
";",
"}",
"}",
";",
"inst",
".",
"div",
".",
"stop",
"(",
")",
";",
"if",
"(",
"$",
".",
"effects",
"&&",
"(",
"$",
".",
"effects",
"[",
"showAnim",
"]",
"||",
"(",
"$",
".",
"effects",
".",
"effect",
"&&",
"$",
".",
"effects",
".",
"effect",
"[",
"showAnim",
"]",
")",
")",
")",
"{",
"inst",
".",
"div",
".",
"hide",
"(",
"showAnim",
",",
"inst",
".",
"options",
".",
"showOptions",
",",
"showSpeed",
",",
"postProcess",
")",
";",
"}",
"else",
"{",
"var",
"hideAnim",
"=",
"(",
"showAnim",
"===",
"'slideDown'",
"?",
"'slideUp'",
":",
"(",
"showAnim",
"===",
"'fadeIn'",
"?",
"'fadeOut'",
":",
"'hide'",
")",
")",
";",
"inst",
".",
"div",
"[",
"hideAnim",
"]",
"(",
"(",
"showAnim",
"?",
"showSpeed",
":",
"''",
")",
",",
"postProcess",
")",
";",
"}",
"if",
"(",
"!",
"showAnim",
")",
"{",
"postProcess",
"(",
")",
";",
"}",
"}",
"}"
]
| Hide a popup datepicker.
@memberof CalendarsPicker
@param elem {Element|object} The control to use or the current instance settings.
@param immediate {boolean} <code>true</code> to close immediately without animation (internal).
@example $(selector).datepick('hide') | [
"Hide",
"a",
"popup",
"datepicker",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L990-L1027 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(event) {
var elem = (event.data && event.data.elem) || event.target;
var inst = plugin._getInst(elem);
var handled = false;
if (inst.inline || inst.div) {
if (event.keyCode === 9) { // Tab - close
plugin.hide(elem);
}
else if (event.keyCode === 13) { // Enter - select
plugin.selectDate(elem,
$('a.' + inst.options.renderer.highlightedClass, inst.div)[0]);
handled = true;
}
else { // Command keystrokes
var commands = inst.options.commands;
for (var name in commands) {
var command = commands[name];
if (command.keystroke.keyCode === event.keyCode &&
!!command.keystroke.ctrlKey === !!(event.ctrlKey || event.metaKey) &&
!!command.keystroke.altKey === event.altKey &&
!!command.keystroke.shiftKey === event.shiftKey) {
plugin.performAction(elem, name);
handled = true;
break;
}
}
}
}
else { // Show on 'current' keystroke
var command = inst.options.commands.current;
if (command.keystroke.keyCode === event.keyCode &&
!!command.keystroke.ctrlKey === !!(event.ctrlKey || event.metaKey) &&
!!command.keystroke.altKey === event.altKey &&
!!command.keystroke.shiftKey === event.shiftKey) {
plugin.show(elem);
handled = true;
}
}
inst.ctrlKey = ((event.keyCode < 48 && event.keyCode !== 32) || event.ctrlKey || event.metaKey);
if (handled) {
event.preventDefault();
event.stopPropagation();
}
return !handled;
} | javascript | function(event) {
var elem = (event.data && event.data.elem) || event.target;
var inst = plugin._getInst(elem);
var handled = false;
if (inst.inline || inst.div) {
if (event.keyCode === 9) { // Tab - close
plugin.hide(elem);
}
else if (event.keyCode === 13) { // Enter - select
plugin.selectDate(elem,
$('a.' + inst.options.renderer.highlightedClass, inst.div)[0]);
handled = true;
}
else { // Command keystrokes
var commands = inst.options.commands;
for (var name in commands) {
var command = commands[name];
if (command.keystroke.keyCode === event.keyCode &&
!!command.keystroke.ctrlKey === !!(event.ctrlKey || event.metaKey) &&
!!command.keystroke.altKey === event.altKey &&
!!command.keystroke.shiftKey === event.shiftKey) {
plugin.performAction(elem, name);
handled = true;
break;
}
}
}
}
else { // Show on 'current' keystroke
var command = inst.options.commands.current;
if (command.keystroke.keyCode === event.keyCode &&
!!command.keystroke.ctrlKey === !!(event.ctrlKey || event.metaKey) &&
!!command.keystroke.altKey === event.altKey &&
!!command.keystroke.shiftKey === event.shiftKey) {
plugin.show(elem);
handled = true;
}
}
inst.ctrlKey = ((event.keyCode < 48 && event.keyCode !== 32) || event.ctrlKey || event.metaKey);
if (handled) {
event.preventDefault();
event.stopPropagation();
}
return !handled;
} | [
"function",
"(",
"event",
")",
"{",
"var",
"elem",
"=",
"(",
"event",
".",
"data",
"&&",
"event",
".",
"data",
".",
"elem",
")",
"||",
"event",
".",
"target",
";",
"var",
"inst",
"=",
"plugin",
".",
"_getInst",
"(",
"elem",
")",
";",
"var",
"handled",
"=",
"false",
";",
"if",
"(",
"inst",
".",
"inline",
"||",
"inst",
".",
"div",
")",
"{",
"if",
"(",
"event",
".",
"keyCode",
"===",
"9",
")",
"{",
"plugin",
".",
"hide",
"(",
"elem",
")",
";",
"}",
"else",
"if",
"(",
"event",
".",
"keyCode",
"===",
"13",
")",
"{",
"plugin",
".",
"selectDate",
"(",
"elem",
",",
"$",
"(",
"'a.'",
"+",
"inst",
".",
"options",
".",
"renderer",
".",
"highlightedClass",
",",
"inst",
".",
"div",
")",
"[",
"0",
"]",
")",
";",
"handled",
"=",
"true",
";",
"}",
"else",
"{",
"var",
"commands",
"=",
"inst",
".",
"options",
".",
"commands",
";",
"for",
"(",
"var",
"name",
"in",
"commands",
")",
"{",
"var",
"command",
"=",
"commands",
"[",
"name",
"]",
";",
"if",
"(",
"command",
".",
"keystroke",
".",
"keyCode",
"===",
"event",
".",
"keyCode",
"&&",
"!",
"!",
"command",
".",
"keystroke",
".",
"ctrlKey",
"===",
"!",
"!",
"(",
"event",
".",
"ctrlKey",
"||",
"event",
".",
"metaKey",
")",
"&&",
"!",
"!",
"command",
".",
"keystroke",
".",
"altKey",
"===",
"event",
".",
"altKey",
"&&",
"!",
"!",
"command",
".",
"keystroke",
".",
"shiftKey",
"===",
"event",
".",
"shiftKey",
")",
"{",
"plugin",
".",
"performAction",
"(",
"elem",
",",
"name",
")",
";",
"handled",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"var",
"command",
"=",
"inst",
".",
"options",
".",
"commands",
".",
"current",
";",
"if",
"(",
"command",
".",
"keystroke",
".",
"keyCode",
"===",
"event",
".",
"keyCode",
"&&",
"!",
"!",
"command",
".",
"keystroke",
".",
"ctrlKey",
"===",
"!",
"!",
"(",
"event",
".",
"ctrlKey",
"||",
"event",
".",
"metaKey",
")",
"&&",
"!",
"!",
"command",
".",
"keystroke",
".",
"altKey",
"===",
"event",
".",
"altKey",
"&&",
"!",
"!",
"command",
".",
"keystroke",
".",
"shiftKey",
"===",
"event",
".",
"shiftKey",
")",
"{",
"plugin",
".",
"show",
"(",
"elem",
")",
";",
"handled",
"=",
"true",
";",
"}",
"}",
"inst",
".",
"ctrlKey",
"=",
"(",
"(",
"event",
".",
"keyCode",
"<",
"48",
"&&",
"event",
".",
"keyCode",
"!==",
"32",
")",
"||",
"event",
".",
"ctrlKey",
"||",
"event",
".",
"metaKey",
")",
";",
"if",
"(",
"handled",
")",
"{",
"event",
".",
"preventDefault",
"(",
")",
";",
"event",
".",
"stopPropagation",
"(",
")",
";",
"}",
"return",
"!",
"handled",
";",
"}"
]
| Handle keystrokes in the datepicker.
@memberof CalendarsPicker
@private
@param event {KeyEvent} The keystroke.
@return {boolean} <code>true</code> if not handled, <code>false</code> if handled. | [
"Handle",
"keystrokes",
"in",
"the",
"datepicker",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L1034-L1078 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(event) {
var inst = plugin._getInst((event.data && event.data.elem) || event.target);
if (!$.isEmptyObject(inst) && inst.options.constrainInput) {
var ch = String.fromCharCode(event.keyCode || event.charCode);
var allowedChars = plugin._allowedChars(inst);
return (event.metaKey || inst.ctrlKey || ch < ' ' ||
!allowedChars || allowedChars.indexOf(ch) > -1);
}
return true;
} | javascript | function(event) {
var inst = plugin._getInst((event.data && event.data.elem) || event.target);
if (!$.isEmptyObject(inst) && inst.options.constrainInput) {
var ch = String.fromCharCode(event.keyCode || event.charCode);
var allowedChars = plugin._allowedChars(inst);
return (event.metaKey || inst.ctrlKey || ch < ' ' ||
!allowedChars || allowedChars.indexOf(ch) > -1);
}
return true;
} | [
"function",
"(",
"event",
")",
"{",
"var",
"inst",
"=",
"plugin",
".",
"_getInst",
"(",
"(",
"event",
".",
"data",
"&&",
"event",
".",
"data",
".",
"elem",
")",
"||",
"event",
".",
"target",
")",
";",
"if",
"(",
"!",
"$",
".",
"isEmptyObject",
"(",
"inst",
")",
"&&",
"inst",
".",
"options",
".",
"constrainInput",
")",
"{",
"var",
"ch",
"=",
"String",
".",
"fromCharCode",
"(",
"event",
".",
"keyCode",
"||",
"event",
".",
"charCode",
")",
";",
"var",
"allowedChars",
"=",
"plugin",
".",
"_allowedChars",
"(",
"inst",
")",
";",
"return",
"(",
"event",
".",
"metaKey",
"||",
"inst",
".",
"ctrlKey",
"||",
"ch",
"<",
"' '",
"||",
"!",
"allowedChars",
"||",
"allowedChars",
".",
"indexOf",
"(",
"ch",
")",
">",
"-",
"1",
")",
";",
"}",
"return",
"true",
";",
"}"
]
| Filter keystrokes in the datepicker.
@memberof CalendarsPicker
@private
@param event {KeyEvent} The keystroke.
@return {boolean} <code>true</code> if allowed, <code>false</code> if not allowed. | [
"Filter",
"keystrokes",
"in",
"the",
"datepicker",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L1085-L1094 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(inst) {
var allowedChars = (inst.options.multiSelect ? inst.options.multiSeparator :
(inst.options.rangeSelect ? inst.options.rangeSeparator : ''));
var literal = false;
var hasNum = false;
var dateFormat = inst.get('dateFormat');
for (var i = 0; i < dateFormat.length; i++) {
var ch = dateFormat.charAt(i);
if (literal) {
if (ch === "'" && dateFormat.charAt(i + 1) !== "'") {
literal = false;
}
else {
allowedChars += ch;
}
}
else {
switch (ch) {
case 'd': case 'm': case 'o': case 'w':
allowedChars += (hasNum ? '' : '0123456789'); hasNum = true; break;
case 'y': case '@': case '!':
allowedChars += (hasNum ? '' : '0123456789') + '-'; hasNum = true; break;
case 'J':
allowedChars += (hasNum ? '' : '0123456789') + '-.'; hasNum = true; break;
case 'D': case 'M': case 'Y':
return null; // Accept anything
case "'":
if (dateFormat.charAt(i + 1) === "'") {
allowedChars += "'";
}
else {
literal = true;
}
break;
default:
allowedChars += ch;
}
}
}
return allowedChars;
} | javascript | function(inst) {
var allowedChars = (inst.options.multiSelect ? inst.options.multiSeparator :
(inst.options.rangeSelect ? inst.options.rangeSeparator : ''));
var literal = false;
var hasNum = false;
var dateFormat = inst.get('dateFormat');
for (var i = 0; i < dateFormat.length; i++) {
var ch = dateFormat.charAt(i);
if (literal) {
if (ch === "'" && dateFormat.charAt(i + 1) !== "'") {
literal = false;
}
else {
allowedChars += ch;
}
}
else {
switch (ch) {
case 'd': case 'm': case 'o': case 'w':
allowedChars += (hasNum ? '' : '0123456789'); hasNum = true; break;
case 'y': case '@': case '!':
allowedChars += (hasNum ? '' : '0123456789') + '-'; hasNum = true; break;
case 'J':
allowedChars += (hasNum ? '' : '0123456789') + '-.'; hasNum = true; break;
case 'D': case 'M': case 'Y':
return null; // Accept anything
case "'":
if (dateFormat.charAt(i + 1) === "'") {
allowedChars += "'";
}
else {
literal = true;
}
break;
default:
allowedChars += ch;
}
}
}
return allowedChars;
} | [
"function",
"(",
"inst",
")",
"{",
"var",
"allowedChars",
"=",
"(",
"inst",
".",
"options",
".",
"multiSelect",
"?",
"inst",
".",
"options",
".",
"multiSeparator",
":",
"(",
"inst",
".",
"options",
".",
"rangeSelect",
"?",
"inst",
".",
"options",
".",
"rangeSeparator",
":",
"''",
")",
")",
";",
"var",
"literal",
"=",
"false",
";",
"var",
"hasNum",
"=",
"false",
";",
"var",
"dateFormat",
"=",
"inst",
".",
"get",
"(",
"'dateFormat'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"dateFormat",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"ch",
"=",
"dateFormat",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"literal",
")",
"{",
"if",
"(",
"ch",
"===",
"\"'\"",
"&&",
"dateFormat",
".",
"charAt",
"(",
"i",
"+",
"1",
")",
"!==",
"\"'\"",
")",
"{",
"literal",
"=",
"false",
";",
"}",
"else",
"{",
"allowedChars",
"+=",
"ch",
";",
"}",
"}",
"else",
"{",
"switch",
"(",
"ch",
")",
"{",
"case",
"'d'",
":",
"case",
"'m'",
":",
"case",
"'o'",
":",
"case",
"'w'",
":",
"allowedChars",
"+=",
"(",
"hasNum",
"?",
"''",
":",
"'0123456789'",
")",
";",
"hasNum",
"=",
"true",
";",
"break",
";",
"case",
"'y'",
":",
"case",
"'@'",
":",
"case",
"'!'",
":",
"allowedChars",
"+=",
"(",
"hasNum",
"?",
"''",
":",
"'0123456789'",
")",
"+",
"'-'",
";",
"hasNum",
"=",
"true",
";",
"break",
";",
"case",
"'J'",
":",
"allowedChars",
"+=",
"(",
"hasNum",
"?",
"''",
":",
"'0123456789'",
")",
"+",
"'-.'",
";",
"hasNum",
"=",
"true",
";",
"break",
";",
"case",
"'D'",
":",
"case",
"'M'",
":",
"case",
"'Y'",
":",
"return",
"null",
";",
"case",
"\"'\"",
":",
"if",
"(",
"dateFormat",
".",
"charAt",
"(",
"i",
"+",
"1",
")",
"===",
"\"'\"",
")",
"{",
"allowedChars",
"+=",
"\"'\"",
";",
"}",
"else",
"{",
"literal",
"=",
"true",
";",
"}",
"break",
";",
"default",
":",
"allowedChars",
"+=",
"ch",
";",
"}",
"}",
"}",
"return",
"allowedChars",
";",
"}"
]
| Determine the set of characters allowed by the date format.
@memberof CalendarsPicker
@private
@param inst {object} The current instance settings.
@return {string} The set of allowed characters, or <code>null</code> if anything allowed. | [
"Determine",
"the",
"set",
"of",
"characters",
"allowed",
"by",
"the",
"date",
"format",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L1101-L1141 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(event) {
var elem = (event.data && event.data.elem) || event.target;
var inst = plugin._getInst(elem);
if (!$.isEmptyObject(inst) && !inst.ctrlKey && inst.lastVal !== inst.elem.val()) {
try {
var dates = plugin._extractDates(inst, inst.elem.val());
if (dates.length > 0) {
plugin.setDate(elem, dates, null, true);
}
}
catch (event) {
// Ignore
}
}
return true;
} | javascript | function(event) {
var elem = (event.data && event.data.elem) || event.target;
var inst = plugin._getInst(elem);
if (!$.isEmptyObject(inst) && !inst.ctrlKey && inst.lastVal !== inst.elem.val()) {
try {
var dates = plugin._extractDates(inst, inst.elem.val());
if (dates.length > 0) {
plugin.setDate(elem, dates, null, true);
}
}
catch (event) {
// Ignore
}
}
return true;
} | [
"function",
"(",
"event",
")",
"{",
"var",
"elem",
"=",
"(",
"event",
".",
"data",
"&&",
"event",
".",
"data",
".",
"elem",
")",
"||",
"event",
".",
"target",
";",
"var",
"inst",
"=",
"plugin",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"!",
"$",
".",
"isEmptyObject",
"(",
"inst",
")",
"&&",
"!",
"inst",
".",
"ctrlKey",
"&&",
"inst",
".",
"lastVal",
"!==",
"inst",
".",
"elem",
".",
"val",
"(",
")",
")",
"{",
"try",
"{",
"var",
"dates",
"=",
"plugin",
".",
"_extractDates",
"(",
"inst",
",",
"inst",
".",
"elem",
".",
"val",
"(",
")",
")",
";",
"if",
"(",
"dates",
".",
"length",
">",
"0",
")",
"{",
"plugin",
".",
"setDate",
"(",
"elem",
",",
"dates",
",",
"null",
",",
"true",
")",
";",
"}",
"}",
"catch",
"(",
"event",
")",
"{",
"}",
"}",
"return",
"true",
";",
"}"
]
| Synchronise datepicker with the field.
@memberof CalendarsPicker
@private
@param event {KeyEvent} The keystroke.
@return {boolean} <code>true</code> if allowed, <code>false</code> if not allowed. | [
"Synchronise",
"datepicker",
"with",
"the",
"field",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L1148-L1163 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem) {
var inst = this._getInst(elem);
if (!$.isEmptyObject(inst)) {
inst.selectedDates = [];
this.hide(elem);
var defaultDate = inst.get('defaultDate');
if (inst.options.selectDefaultDate && defaultDate) {
this.setDate(elem, (defaultDate || inst.options.calendar.today()).newDate());
}
else {
this._updateInput(elem);
}
}
} | javascript | function(elem) {
var inst = this._getInst(elem);
if (!$.isEmptyObject(inst)) {
inst.selectedDates = [];
this.hide(elem);
var defaultDate = inst.get('defaultDate');
if (inst.options.selectDefaultDate && defaultDate) {
this.setDate(elem, (defaultDate || inst.options.calendar.today()).newDate());
}
else {
this._updateInput(elem);
}
}
} | [
"function",
"(",
"elem",
")",
"{",
"var",
"inst",
"=",
"this",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"!",
"$",
".",
"isEmptyObject",
"(",
"inst",
")",
")",
"{",
"inst",
".",
"selectedDates",
"=",
"[",
"]",
";",
"this",
".",
"hide",
"(",
"elem",
")",
";",
"var",
"defaultDate",
"=",
"inst",
".",
"get",
"(",
"'defaultDate'",
")",
";",
"if",
"(",
"inst",
".",
"options",
".",
"selectDefaultDate",
"&&",
"defaultDate",
")",
"{",
"this",
".",
"setDate",
"(",
"elem",
",",
"(",
"defaultDate",
"||",
"inst",
".",
"options",
".",
"calendar",
".",
"today",
"(",
")",
")",
".",
"newDate",
"(",
")",
")",
";",
"}",
"else",
"{",
"this",
".",
"_updateInput",
"(",
"elem",
")",
";",
"}",
"}",
"}"
]
| Clear an input and close a popup datepicker.
@memberof CalendarsPicker
@param elem {Element} The control to use.
@example $(selector).datepick('clear') | [
"Clear",
"an",
"input",
"and",
"close",
"a",
"popup",
"datepicker",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L1188-L1201 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem, date) {
var inst = this._getInst(elem);
if ($.isEmptyObject(inst)) {
return false;
}
date = inst.options.calendar.determineDate(date,
inst.selectedDates[0] || inst.options.calendar.today(), null,
inst.options.dateFormat, inst.getConfig());
return this._isSelectable(elem, date, inst.options.onDate,
inst.get('minDate'), inst.get('maxDate'));
} | javascript | function(elem, date) {
var inst = this._getInst(elem);
if ($.isEmptyObject(inst)) {
return false;
}
date = inst.options.calendar.determineDate(date,
inst.selectedDates[0] || inst.options.calendar.today(), null,
inst.options.dateFormat, inst.getConfig());
return this._isSelectable(elem, date, inst.options.onDate,
inst.get('minDate'), inst.get('maxDate'));
} | [
"function",
"(",
"elem",
",",
"date",
")",
"{",
"var",
"inst",
"=",
"this",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"$",
".",
"isEmptyObject",
"(",
"inst",
")",
")",
"{",
"return",
"false",
";",
"}",
"date",
"=",
"inst",
".",
"options",
".",
"calendar",
".",
"determineDate",
"(",
"date",
",",
"inst",
".",
"selectedDates",
"[",
"0",
"]",
"||",
"inst",
".",
"options",
".",
"calendar",
".",
"today",
"(",
")",
",",
"null",
",",
"inst",
".",
"options",
".",
"dateFormat",
",",
"inst",
".",
"getConfig",
"(",
")",
")",
";",
"return",
"this",
".",
"_isSelectable",
"(",
"elem",
",",
"date",
",",
"inst",
".",
"options",
".",
"onDate",
",",
"inst",
".",
"get",
"(",
"'minDate'",
")",
",",
"inst",
".",
"get",
"(",
"'maxDate'",
")",
")",
";",
"}"
]
| Determine whether a date is selectable for this datepicker.
@memberof CalendarsPicker
@private
@param elem {Element} The control to check.
@param date {CDate|string|number} The date to check.
@return {boolean} <code>true</code> if selectable, <code>false</code> if not.
@example var selectable = $(selector).datepick('isSelectable', date) | [
"Determine",
"whether",
"a",
"date",
"is",
"selectable",
"for",
"this",
"datepicker",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L1283-L1293 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem, date, onDate, minDate, maxDate) {
var dateInfo = (typeof onDate === 'boolean' ? {selectable: onDate} :
(!$.isFunction(onDate) ? {} : onDate.apply(elem, [date, true])));
return (dateInfo.selectable !== false) &&
(!minDate || date.toJD() >= minDate.toJD()) && (!maxDate || date.toJD() <= maxDate.toJD());
} | javascript | function(elem, date, onDate, minDate, maxDate) {
var dateInfo = (typeof onDate === 'boolean' ? {selectable: onDate} :
(!$.isFunction(onDate) ? {} : onDate.apply(elem, [date, true])));
return (dateInfo.selectable !== false) &&
(!minDate || date.toJD() >= minDate.toJD()) && (!maxDate || date.toJD() <= maxDate.toJD());
} | [
"function",
"(",
"elem",
",",
"date",
",",
"onDate",
",",
"minDate",
",",
"maxDate",
")",
"{",
"var",
"dateInfo",
"=",
"(",
"typeof",
"onDate",
"===",
"'boolean'",
"?",
"{",
"selectable",
":",
"onDate",
"}",
":",
"(",
"!",
"$",
".",
"isFunction",
"(",
"onDate",
")",
"?",
"{",
"}",
":",
"onDate",
".",
"apply",
"(",
"elem",
",",
"[",
"date",
",",
"true",
"]",
")",
")",
")",
";",
"return",
"(",
"dateInfo",
".",
"selectable",
"!==",
"false",
")",
"&&",
"(",
"!",
"minDate",
"||",
"date",
".",
"toJD",
"(",
")",
">=",
"minDate",
".",
"toJD",
"(",
")",
")",
"&&",
"(",
"!",
"maxDate",
"||",
"date",
".",
"toJD",
"(",
")",
"<=",
"maxDate",
".",
"toJD",
"(",
")",
")",
";",
"}"
]
| Internally determine whether a date is selectable for this datepicker.
@memberof CalendarsPicker
@private
@param elem {Element} the control to check.
@param date {CDate} The date to check.
@param onDate {function|boolean} Any <code>onDate</code> callback or <code>callback.selectable</code>.
@param minDate {CDate} The minimum allowed date.
@param maxDate {CDate} The maximum allowed date.
@return {boolean} <code>true</code> if selectable, <code>false</code> if not. | [
"Internally",
"determine",
"whether",
"a",
"date",
"is",
"selectable",
"for",
"this",
"datepicker",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L1304-L1309 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem, action) {
var inst = this._getInst(elem);
if (!$.isEmptyObject(inst) && !this.isDisabled(elem)) {
var commands = inst.options.commands;
if (commands[action] && commands[action].enabled.apply(elem, [inst])) {
commands[action].action.apply(elem, [inst]);
}
}
} | javascript | function(elem, action) {
var inst = this._getInst(elem);
if (!$.isEmptyObject(inst) && !this.isDisabled(elem)) {
var commands = inst.options.commands;
if (commands[action] && commands[action].enabled.apply(elem, [inst])) {
commands[action].action.apply(elem, [inst]);
}
}
} | [
"function",
"(",
"elem",
",",
"action",
")",
"{",
"var",
"inst",
"=",
"this",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"!",
"$",
".",
"isEmptyObject",
"(",
"inst",
")",
"&&",
"!",
"this",
".",
"isDisabled",
"(",
"elem",
")",
")",
"{",
"var",
"commands",
"=",
"inst",
".",
"options",
".",
"commands",
";",
"if",
"(",
"commands",
"[",
"action",
"]",
"&&",
"commands",
"[",
"action",
"]",
".",
"enabled",
".",
"apply",
"(",
"elem",
",",
"[",
"inst",
"]",
")",
")",
"{",
"commands",
"[",
"action",
"]",
".",
"action",
".",
"apply",
"(",
"elem",
",",
"[",
"inst",
"]",
")",
";",
"}",
"}",
"}"
]
| Perform a named action for a datepicker.
@memberof CalendarsPicker
@param elem {element} The control to affect.
@param action {string} The name of the action. | [
"Perform",
"a",
"named",
"action",
"for",
"a",
"datepicker",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L1315-L1323 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem, year, month, day) {
var inst = this._getInst(elem);
if (!$.isEmptyObject(inst) && (day != null ||
(inst.drawDate.year() !== year || inst.drawDate.month() !== month))) {
inst.prevDate = inst.drawDate.newDate();
var calendar = inst.options.calendar;
var show = this._checkMinMax((year != null ?
calendar.newDate(year, month, 1) : calendar.today()), inst);
inst.drawDate.date(show.year(), show.month(),
(day != null ? day : Math.min(inst.drawDate.day(),
calendar.daysInMonth(show.year(), show.month()))));
this._update(elem);
}
} | javascript | function(elem, year, month, day) {
var inst = this._getInst(elem);
if (!$.isEmptyObject(inst) && (day != null ||
(inst.drawDate.year() !== year || inst.drawDate.month() !== month))) {
inst.prevDate = inst.drawDate.newDate();
var calendar = inst.options.calendar;
var show = this._checkMinMax((year != null ?
calendar.newDate(year, month, 1) : calendar.today()), inst);
inst.drawDate.date(show.year(), show.month(),
(day != null ? day : Math.min(inst.drawDate.day(),
calendar.daysInMonth(show.year(), show.month()))));
this._update(elem);
}
} | [
"function",
"(",
"elem",
",",
"year",
",",
"month",
",",
"day",
")",
"{",
"var",
"inst",
"=",
"this",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"!",
"$",
".",
"isEmptyObject",
"(",
"inst",
")",
"&&",
"(",
"day",
"!=",
"null",
"||",
"(",
"inst",
".",
"drawDate",
".",
"year",
"(",
")",
"!==",
"year",
"||",
"inst",
".",
"drawDate",
".",
"month",
"(",
")",
"!==",
"month",
")",
")",
")",
"{",
"inst",
".",
"prevDate",
"=",
"inst",
".",
"drawDate",
".",
"newDate",
"(",
")",
";",
"var",
"calendar",
"=",
"inst",
".",
"options",
".",
"calendar",
";",
"var",
"show",
"=",
"this",
".",
"_checkMinMax",
"(",
"(",
"year",
"!=",
"null",
"?",
"calendar",
".",
"newDate",
"(",
"year",
",",
"month",
",",
"1",
")",
":",
"calendar",
".",
"today",
"(",
")",
")",
",",
"inst",
")",
";",
"inst",
".",
"drawDate",
".",
"date",
"(",
"show",
".",
"year",
"(",
")",
",",
"show",
".",
"month",
"(",
")",
",",
"(",
"day",
"!=",
"null",
"?",
"day",
":",
"Math",
".",
"min",
"(",
"inst",
".",
"drawDate",
".",
"day",
"(",
")",
",",
"calendar",
".",
"daysInMonth",
"(",
"show",
".",
"year",
"(",
")",
",",
"show",
".",
"month",
"(",
")",
")",
")",
")",
")",
";",
"this",
".",
"_update",
"(",
"elem",
")",
";",
"}",
"}"
]
| Set the currently shown month, defaulting to today's.
@memberof CalendarsPicker
@param elem {Element} The control to affect.
@param [year] {number} The year to show.
@param [month] {number} The month to show (1-12).
@param [day] {number} The day to show.
@example $(selector).datepick('showMonth', 2014, 12, 25) | [
"Set",
"the",
"currently",
"shown",
"month",
"defaulting",
"to",
"today",
"s",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L1332-L1345 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem, offset) {
var inst = this._getInst(elem);
if (!$.isEmptyObject(inst)) {
var date = inst.drawDate.newDate().add(offset, 'm');
this.showMonth(elem, date.year(), date.month());
}
} | javascript | function(elem, offset) {
var inst = this._getInst(elem);
if (!$.isEmptyObject(inst)) {
var date = inst.drawDate.newDate().add(offset, 'm');
this.showMonth(elem, date.year(), date.month());
}
} | [
"function",
"(",
"elem",
",",
"offset",
")",
"{",
"var",
"inst",
"=",
"this",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"!",
"$",
".",
"isEmptyObject",
"(",
"inst",
")",
")",
"{",
"var",
"date",
"=",
"inst",
".",
"drawDate",
".",
"newDate",
"(",
")",
".",
"add",
"(",
"offset",
",",
"'m'",
")",
";",
"this",
".",
"showMonth",
"(",
"elem",
",",
"date",
".",
"year",
"(",
")",
",",
"date",
".",
"month",
"(",
")",
")",
";",
"}",
"}"
]
| Adjust the currently shown month.
@memberof CalendarsPicker
@param elem {Element} The control to affect.
@param offset {number} The number of months to change by.
@example $(selector).datepick('changeMonth', 2) | [
"Adjust",
"the",
"currently",
"shown",
"month",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L1352-L1358 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem, target) {
var inst = this._getInst(elem);
return ($.isEmptyObject(inst) ? null : inst.options.calendar.fromJD(
parseFloat(target.className.replace(/^.*jd(\d+\.5).*$/, '$1'))));
} | javascript | function(elem, target) {
var inst = this._getInst(elem);
return ($.isEmptyObject(inst) ? null : inst.options.calendar.fromJD(
parseFloat(target.className.replace(/^.*jd(\d+\.5).*$/, '$1'))));
} | [
"function",
"(",
"elem",
",",
"target",
")",
"{",
"var",
"inst",
"=",
"this",
".",
"_getInst",
"(",
"elem",
")",
";",
"return",
"(",
"$",
".",
"isEmptyObject",
"(",
"inst",
")",
"?",
"null",
":",
"inst",
".",
"options",
".",
"calendar",
".",
"fromJD",
"(",
"parseFloat",
"(",
"target",
".",
"className",
".",
"replace",
"(",
"/",
"^.*jd(\\d+\\.5).*$",
"/",
",",
"'$1'",
")",
")",
")",
")",
";",
"}"
]
| Retrieve the date associated with an entry in the datepicker.
@memberof CalendarsPicker
@param elem {Element} The control to examine.
@param target {Element} The selected datepicker element.
@return {CDate} The corresponding date, or <code>null</code>.
@example var date = $(selector).datepick('retrieveDate', $('div.datepick-popup a:contains(10)')[0]) | [
"Retrieve",
"the",
"date",
"associated",
"with",
"an",
"entry",
"in",
"the",
"datepicker",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L1392-L1396 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem, target) {
var inst = this._getInst(elem);
if (!$.isEmptyObject(inst) && !this.isDisabled(elem)) {
var date = this.retrieveDate(elem, target);
if (inst.options.multiSelect) {
var found = false;
for (var i = 0; i < inst.selectedDates.length; i++) {
if (date.compareTo(inst.selectedDates[i]) === 0) {
inst.selectedDates.splice(i, 1);
found = true;
break;
}
}
if (!found && inst.selectedDates.length < inst.options.multiSelect) {
inst.selectedDates.push(date);
}
}
else if (inst.options.rangeSelect) {
if (inst.pickingRange) {
inst.selectedDates[1] = date;
}
else {
inst.selectedDates = [date, date];
}
inst.pickingRange = !inst.pickingRange;
}
else {
inst.selectedDates = [date];
}
inst.prevDate = inst.drawDate = date.newDate();
this._updateInput(elem);
if (inst.inline || inst.pickingRange || inst.selectedDates.length <
(inst.options.multiSelect || (inst.options.rangeSelect ? 2 : 1))) {
this._update(elem);
}
else {
this.hide(elem);
}
}
} | javascript | function(elem, target) {
var inst = this._getInst(elem);
if (!$.isEmptyObject(inst) && !this.isDisabled(elem)) {
var date = this.retrieveDate(elem, target);
if (inst.options.multiSelect) {
var found = false;
for (var i = 0; i < inst.selectedDates.length; i++) {
if (date.compareTo(inst.selectedDates[i]) === 0) {
inst.selectedDates.splice(i, 1);
found = true;
break;
}
}
if (!found && inst.selectedDates.length < inst.options.multiSelect) {
inst.selectedDates.push(date);
}
}
else if (inst.options.rangeSelect) {
if (inst.pickingRange) {
inst.selectedDates[1] = date;
}
else {
inst.selectedDates = [date, date];
}
inst.pickingRange = !inst.pickingRange;
}
else {
inst.selectedDates = [date];
}
inst.prevDate = inst.drawDate = date.newDate();
this._updateInput(elem);
if (inst.inline || inst.pickingRange || inst.selectedDates.length <
(inst.options.multiSelect || (inst.options.rangeSelect ? 2 : 1))) {
this._update(elem);
}
else {
this.hide(elem);
}
}
} | [
"function",
"(",
"elem",
",",
"target",
")",
"{",
"var",
"inst",
"=",
"this",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"!",
"$",
".",
"isEmptyObject",
"(",
"inst",
")",
"&&",
"!",
"this",
".",
"isDisabled",
"(",
"elem",
")",
")",
"{",
"var",
"date",
"=",
"this",
".",
"retrieveDate",
"(",
"elem",
",",
"target",
")",
";",
"if",
"(",
"inst",
".",
"options",
".",
"multiSelect",
")",
"{",
"var",
"found",
"=",
"false",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"inst",
".",
"selectedDates",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"date",
".",
"compareTo",
"(",
"inst",
".",
"selectedDates",
"[",
"i",
"]",
")",
"===",
"0",
")",
"{",
"inst",
".",
"selectedDates",
".",
"splice",
"(",
"i",
",",
"1",
")",
";",
"found",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"found",
"&&",
"inst",
".",
"selectedDates",
".",
"length",
"<",
"inst",
".",
"options",
".",
"multiSelect",
")",
"{",
"inst",
".",
"selectedDates",
".",
"push",
"(",
"date",
")",
";",
"}",
"}",
"else",
"if",
"(",
"inst",
".",
"options",
".",
"rangeSelect",
")",
"{",
"if",
"(",
"inst",
".",
"pickingRange",
")",
"{",
"inst",
".",
"selectedDates",
"[",
"1",
"]",
"=",
"date",
";",
"}",
"else",
"{",
"inst",
".",
"selectedDates",
"=",
"[",
"date",
",",
"date",
"]",
";",
"}",
"inst",
".",
"pickingRange",
"=",
"!",
"inst",
".",
"pickingRange",
";",
"}",
"else",
"{",
"inst",
".",
"selectedDates",
"=",
"[",
"date",
"]",
";",
"}",
"inst",
".",
"prevDate",
"=",
"inst",
".",
"drawDate",
"=",
"date",
".",
"newDate",
"(",
")",
";",
"this",
".",
"_updateInput",
"(",
"elem",
")",
";",
"if",
"(",
"inst",
".",
"inline",
"||",
"inst",
".",
"pickingRange",
"||",
"inst",
".",
"selectedDates",
".",
"length",
"<",
"(",
"inst",
".",
"options",
".",
"multiSelect",
"||",
"(",
"inst",
".",
"options",
".",
"rangeSelect",
"?",
"2",
":",
"1",
")",
")",
")",
"{",
"this",
".",
"_update",
"(",
"elem",
")",
";",
"}",
"else",
"{",
"this",
".",
"hide",
"(",
"elem",
")",
";",
"}",
"}",
"}"
]
| Select a date for this datepicker.
@memberof CalendarsPicker
@param elem {Element} The control to examine.
@param target {Element} The selected datepicker element.
@example $(selector).datepick('selectDate', $('div.datepick-popup a:contains(10)')[0]) | [
"Select",
"a",
"date",
"for",
"this",
"datepicker",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L1403-L1442 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(value) {
return (inst.options.localNumbers && calendar.local.digits ? calendar.local.digits(value) : value);
} | javascript | function(value) {
return (inst.options.localNumbers && calendar.local.digits ? calendar.local.digits(value) : value);
} | [
"function",
"(",
"value",
")",
"{",
"return",
"(",
"inst",
".",
"options",
".",
"localNumbers",
"&&",
"calendar",
".",
"local",
".",
"digits",
"?",
"calendar",
".",
"local",
".",
"digits",
"(",
"value",
")",
":",
"value",
")",
";",
"}"
]
| Localise numbers if requested and available | [
"Localise",
"numbers",
"if",
"requested",
"and",
"available"
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L1609-L1611 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(inst, calendar, renderer) {
var firstDay = inst.options.firstDay;
firstDay = (firstDay == null ? calendar.local.firstDay : firstDay);
var header = '';
for (var day = 0; day < calendar.daysInWeek(); day++) {
var dow = (day + firstDay) % calendar.daysInWeek();
header += this._prepare(renderer.dayHeader, inst).replace(/\{day\}/g,
'<span class="' + this._curDoWClass + dow + '" title="' +
calendar.local.dayNames[dow] + '">' + calendar.local.dayNamesMin[dow] + '</span>');
}
return header;
} | javascript | function(inst, calendar, renderer) {
var firstDay = inst.options.firstDay;
firstDay = (firstDay == null ? calendar.local.firstDay : firstDay);
var header = '';
for (var day = 0; day < calendar.daysInWeek(); day++) {
var dow = (day + firstDay) % calendar.daysInWeek();
header += this._prepare(renderer.dayHeader, inst).replace(/\{day\}/g,
'<span class="' + this._curDoWClass + dow + '" title="' +
calendar.local.dayNames[dow] + '">' + calendar.local.dayNamesMin[dow] + '</span>');
}
return header;
} | [
"function",
"(",
"inst",
",",
"calendar",
",",
"renderer",
")",
"{",
"var",
"firstDay",
"=",
"inst",
".",
"options",
".",
"firstDay",
";",
"firstDay",
"=",
"(",
"firstDay",
"==",
"null",
"?",
"calendar",
".",
"local",
".",
"firstDay",
":",
"firstDay",
")",
";",
"var",
"header",
"=",
"''",
";",
"for",
"(",
"var",
"day",
"=",
"0",
";",
"day",
"<",
"calendar",
".",
"daysInWeek",
"(",
")",
";",
"day",
"++",
")",
"{",
"var",
"dow",
"=",
"(",
"day",
"+",
"firstDay",
")",
"%",
"calendar",
".",
"daysInWeek",
"(",
")",
";",
"header",
"+=",
"this",
".",
"_prepare",
"(",
"renderer",
".",
"dayHeader",
",",
"inst",
")",
".",
"replace",
"(",
"/",
"\\{day\\}",
"/",
"g",
",",
"'<span class=\"'",
"+",
"this",
".",
"_curDoWClass",
"+",
"dow",
"+",
"'\" title=\"'",
"+",
"calendar",
".",
"local",
".",
"dayNames",
"[",
"dow",
"]",
"+",
"'\">'",
"+",
"calendar",
".",
"local",
".",
"dayNamesMin",
"[",
"dow",
"]",
"+",
"'</span>'",
")",
";",
"}",
"return",
"header",
";",
"}"
]
| Generate the HTML for the day headers.
@memberof CalendarsPicker
@private
@param inst {object} The current instance settings.
@param calendar {BaseCalendar} The current calendar.
@param renderer {object} The rendering templates.
@return {string} A week's worth of day headers. | [
"Generate",
"the",
"HTML",
"for",
"the",
"day",
"headers",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L1681-L1692 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.hebrew.js | function(year, month, day) {
var date = this._validate(year, month, day, $.calendars.local.invalidDate);
return {yearType: (this.leapYear(date) ? 'embolismic' : 'common') + ' ' +
['deficient', 'regular', 'complete'][this.daysInYear(date) % 10 - 3]};
} | javascript | function(year, month, day) {
var date = this._validate(year, month, day, $.calendars.local.invalidDate);
return {yearType: (this.leapYear(date) ? 'embolismic' : 'common') + ' ' +
['deficient', 'regular', 'complete'][this.daysInYear(date) % 10 - 3]};
} | [
"function",
"(",
"year",
",",
"month",
",",
"day",
")",
"{",
"var",
"date",
"=",
"this",
".",
"_validate",
"(",
"year",
",",
"month",
",",
"day",
",",
"$",
".",
"calendars",
".",
"local",
".",
"invalidDate",
")",
";",
"return",
"{",
"yearType",
":",
"(",
"this",
".",
"leapYear",
"(",
"date",
")",
"?",
"'embolismic'",
":",
"'common'",
")",
"+",
"' '",
"+",
"[",
"'deficient'",
",",
"'regular'",
",",
"'complete'",
"]",
"[",
"this",
".",
"daysInYear",
"(",
"date",
")",
"%",
"10",
"-",
"3",
"]",
"}",
";",
"}"
]
| Retrieve additional information about a date - year type.
@memberof HebrewCalendar
@param year {CDate|number} The date to examine or the year to examine.
@param [month] {number} The month to examine.
@param [day] {number} The day to examine.
@return {object} Additional information - contents depends on calendar.
@throws Error if an invalid date or a different calendar used. | [
"Retrieve",
"additional",
"information",
"about",
"a",
"date",
"-",
"year",
"type",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.hebrew.js#L167-L171 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.hebrew.js | function(year) {
var months = Math.floor((235 * year - 234) / 19);
var parts = 12084 + 13753 * months;
var day = months * 29 + Math.floor(parts / 25920);
if (mod(3 * (day + 1), 7) < 3) {
day++;
}
return day;
} | javascript | function(year) {
var months = Math.floor((235 * year - 234) / 19);
var parts = 12084 + 13753 * months;
var day = months * 29 + Math.floor(parts / 25920);
if (mod(3 * (day + 1), 7) < 3) {
day++;
}
return day;
} | [
"function",
"(",
"year",
")",
"{",
"var",
"months",
"=",
"Math",
".",
"floor",
"(",
"(",
"235",
"*",
"year",
"-",
"234",
")",
"/",
"19",
")",
";",
"var",
"parts",
"=",
"12084",
"+",
"13753",
"*",
"months",
";",
"var",
"day",
"=",
"months",
"*",
"29",
"+",
"Math",
".",
"floor",
"(",
"parts",
"/",
"25920",
")",
";",
"if",
"(",
"mod",
"(",
"3",
"*",
"(",
"day",
"+",
"1",
")",
",",
"7",
")",
"<",
"3",
")",
"{",
"day",
"++",
";",
"}",
"return",
"day",
";",
"}"
]
| Test for delay of start of new year and to avoid
Sunday, Wednesday, or Friday as start of the new year.
@memberof HebrewCalendar
@private
@param year {number} The year to examine.
@return {number} The days to offset by. | [
"Test",
"for",
"delay",
"of",
"start",
"of",
"new",
"year",
"and",
"to",
"avoid",
"Sunday",
"Wednesday",
"or",
"Friday",
"as",
"start",
"of",
"the",
"new",
"year",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.hebrew.js#L211-L219 | train |
|
alexcjohnson/world-calendars | jquery-src/jquery.calendars.hebrew.js | function(year) {
var last = this._delay1(year - 1);
var present = this._delay1(year);
var next = this._delay1(year + 1);
return ((next - present) === 356 ? 2 : ((present - last) === 382 ? 1 : 0));
} | javascript | function(year) {
var last = this._delay1(year - 1);
var present = this._delay1(year);
var next = this._delay1(year + 1);
return ((next - present) === 356 ? 2 : ((present - last) === 382 ? 1 : 0));
} | [
"function",
"(",
"year",
")",
"{",
"var",
"last",
"=",
"this",
".",
"_delay1",
"(",
"year",
"-",
"1",
")",
";",
"var",
"present",
"=",
"this",
".",
"_delay1",
"(",
"year",
")",
";",
"var",
"next",
"=",
"this",
".",
"_delay1",
"(",
"year",
"+",
"1",
")",
";",
"return",
"(",
"(",
"next",
"-",
"present",
")",
"===",
"356",
"?",
"2",
":",
"(",
"(",
"present",
"-",
"last",
")",
"===",
"382",
"?",
"1",
":",
"0",
")",
")",
";",
"}"
]
| Check for delay in start of new year due to length of adjacent years.
@memberof HebrewCalendar
@private
@param year {number} The year to examine.
@return {number} The days to offset by. | [
"Check",
"for",
"delay",
"in",
"start",
"of",
"new",
"year",
"due",
"to",
"length",
"of",
"adjacent",
"years",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.hebrew.js#L226-L231 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.