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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
titon/toolkit | dist/toolkit.js | function(element, block) {
var selector = 'data-' + (block || this.keyName);
if (element) {
selector += '-' + element;
}
if (this.namespace) {
selector += '="' + this.namespace + '"';
}
return '[' + selector + ']';
} | javascript | function(element, block) {
var selector = 'data-' + (block || this.keyName);
if (element) {
selector += '-' + element;
}
if (this.namespace) {
selector += '="' + this.namespace + '"';
}
return '[' + selector + ']';
} | [
"function",
"(",
"element",
",",
"block",
")",
"{",
"var",
"selector",
"=",
"'data-'",
"+",
"(",
"block",
"||",
"this",
".",
"keyName",
")",
";",
"if",
"(",
"element",
")",
"{",
"selector",
"+=",
"'-'",
"+",
"element",
";",
"}",
"if",
"(",
"this",
... | Generate a valid data attribute selector based on the current component name and namespace.
@param {String} [element]
@param {String} [block]
@returns {string} | [
"Generate",
"a",
"valid",
"data",
"attribute",
"selector",
"based",
"on",
"the",
"current",
"component",
"name",
"and",
"namespace",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L812-L824 | train | |
titon/toolkit | dist/toolkit.js | function(content) {
if (content.callback) {
var namespaces = content.callback.split('.'),
func = window, prev = func;
for (var i = 0; i < namespaces.length; i++) {
prev = func;
func = func[namespaces[i]];
}
func.ca... | javascript | function(content) {
if (content.callback) {
var namespaces = content.callback.split('.'),
func = window, prev = func;
for (var i = 0; i < namespaces.length; i++) {
prev = func;
func = func[namespaces[i]];
}
func.ca... | [
"function",
"(",
"content",
")",
"{",
"if",
"(",
"content",
".",
"callback",
")",
"{",
"var",
"namespaces",
"=",
"content",
".",
"callback",
".",
"split",
"(",
"'.'",
")",
",",
"func",
"=",
"window",
",",
"prev",
"=",
"func",
";",
"for",
"(",
"var"... | Handle and process non-HTML responses.
@param {*} content | [
"Handle",
"and",
"process",
"non",
"-",
"HTML",
"responses",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L840-L856 | train | |
titon/toolkit | dist/toolkit.js | function(element, key) {
var value = element.data((this.keyName + '-' + key).toLowerCase());
if ($.type(value) === 'undefined') {
value = this.options[key];
}
return value;
} | javascript | function(element, key) {
var value = element.data((this.keyName + '-' + key).toLowerCase());
if ($.type(value) === 'undefined') {
value = this.options[key];
}
return value;
} | [
"function",
"(",
"element",
",",
"key",
")",
"{",
"var",
"value",
"=",
"element",
".",
"data",
"(",
"(",
"this",
".",
"keyName",
"+",
"'-'",
"+",
"key",
")",
".",
"toLowerCase",
"(",
")",
")",
";",
"if",
"(",
"$",
".",
"type",
"(",
"value",
")"... | Read a class option from a data attribute.
If no attribute exists, return the option value.
@param {jQuery} element
@param {String} key
@returns {*} | [
"Read",
"a",
"class",
"option",
"from",
"a",
"data",
"attribute",
".",
"If",
"no",
"attribute",
"exists",
"return",
"the",
"option",
"value",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L866-L874 | train | |
titon/toolkit | dist/toolkit.js | function(element, query) {
if (!query) {
return null;
}
element = $(element);
if ($.type(query) === 'function') {
return query.call(this, element);
}
return element.attr(query);
} | javascript | function(element, query) {
if (!query) {
return null;
}
element = $(element);
if ($.type(query) === 'function') {
return query.call(this, element);
}
return element.attr(query);
} | [
"function",
"(",
"element",
",",
"query",
")",
"{",
"if",
"(",
"!",
"query",
")",
"{",
"return",
"null",
";",
"}",
"element",
"=",
"$",
"(",
"element",
")",
";",
"if",
"(",
"$",
".",
"type",
"(",
"query",
")",
"===",
"'function'",
")",
"{",
"re... | Attempt to read a value from an element using the query.
Query can either be an attribute name, or a callback function.
@param {jQuery} element
@param {String|Function} query
@returns {String} | [
"Attempt",
"to",
"read",
"a",
"value",
"from",
"an",
"element",
"using",
"the",
"query",
".",
"Query",
"can",
"either",
"be",
"an",
"attribute",
"name",
"or",
"a",
"callback",
"function",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L884-L896 | train | |
titon/toolkit | dist/toolkit.js | function(options, params) {
var ajax = {};
// Determine base options
if ($.type(this.options.ajax) === 'object') {
ajax = this.options.ajax;
}
// Set default options
if ($.type(options) === 'string') {
ajax.url = options;
} else {
... | javascript | function(options, params) {
var ajax = {};
// Determine base options
if ($.type(this.options.ajax) === 'object') {
ajax = this.options.ajax;
}
// Set default options
if ($.type(options) === 'string') {
ajax.url = options;
} else {
... | [
"function",
"(",
"options",
",",
"params",
")",
"{",
"var",
"ajax",
"=",
"{",
"}",
";",
"// Determine base options",
"if",
"(",
"$",
".",
"type",
"(",
"this",
".",
"options",
".",
"ajax",
")",
"===",
"'object'",
")",
"{",
"ajax",
"=",
"this",
".",
... | Request data from a URL and handle all the possible scenarios.
@param {Object} options
@param {Object} [params]
@returns {jQuery.ajax} | [
"Request",
"data",
"from",
"a",
"URL",
"and",
"handle",
"all",
"the",
"possible",
"scenarios",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L915-L945 | train | |
titon/toolkit | dist/toolkit.js | function(options, inheritFrom) {
// Inherit options from a group if the data attribute exists
// Do this first so responsive options can be triggered afterwards
if (inheritFrom) {
var group = this.readOption(inheritFrom, 'group');
if (group && options.groups[group]) {
... | javascript | function(options, inheritFrom) {
// Inherit options from a group if the data attribute exists
// Do this first so responsive options can be triggered afterwards
if (inheritFrom) {
var group = this.readOption(inheritFrom, 'group');
if (group && options.groups[group]) {
... | [
"function",
"(",
"options",
",",
"inheritFrom",
")",
"{",
"// Inherit options from a group if the data attribute exists",
"// Do this first so responsive options can be triggered afterwards",
"if",
"(",
"inheritFrom",
")",
"{",
"var",
"group",
"=",
"this",
".",
"readOption",
... | After merging options with the default options,
inherit options from an elements data attributes.
@param {Object} [options]
@param {jQuery} [inheritFrom]
@returns {Object} | [
"After",
"merging",
"options",
"with",
"the",
"default",
"options",
"inherit",
"options",
"from",
"an",
"elements",
"data",
"attributes",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L970-L997 | train | |
titon/toolkit | dist/toolkit.js | function(element, options) {
var self = this;
element = this.setElement(element).attr('role', 'tablist');
options = this.setOptions(options, element);
// Find headers and cache the index of each header and set ARIA attributes
this.headers = element.find(this.ns('header')).each(... | javascript | function(element, options) {
var self = this;
element = this.setElement(element).attr('role', 'tablist');
options = this.setOptions(options, element);
// Find headers and cache the index of each header and set ARIA attributes
this.headers = element.find(this.ns('header')).each(... | [
"function",
"(",
"element",
",",
"options",
")",
"{",
"var",
"self",
"=",
"this",
";",
"element",
"=",
"this",
".",
"setElement",
"(",
"element",
")",
".",
"attr",
"(",
"'role'",
",",
"'tablist'",
")",
";",
"options",
"=",
"this",
".",
"setOptions",
... | Initialize the accordion.
@param {jQuery} element
@param {Object} [options] | [
"Initialize",
"the",
"accordion",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L1197-L1241 | train | |
titon/toolkit | dist/toolkit.js | function(options) {
options = this.setOptions(options);
this.element = this.createElement();
// Generate loader elements
this.loader = this.render(options.loaderTemplate).appendTo(this.element);
this.message = this.loader.find(this.ns('message', 'loader'));
if (options.... | javascript | function(options) {
options = this.setOptions(options);
this.element = this.createElement();
// Generate loader elements
this.loader = this.render(options.loaderTemplate).appendTo(this.element);
this.message = this.loader.find(this.ns('message', 'loader'));
if (options.... | [
"function",
"(",
"options",
")",
"{",
"options",
"=",
"this",
".",
"setOptions",
"(",
"options",
")",
";",
"this",
".",
"element",
"=",
"this",
".",
"createElement",
"(",
")",
";",
"// Generate loader elements",
"this",
".",
"loader",
"=",
"this",
".",
"... | Create the blackout and loader elements.
@param {Object} [options] | [
"Create",
"the",
"blackout",
"and",
"loader",
"elements",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L1433-L1447 | train | |
titon/toolkit | dist/toolkit.js | function() {
this.fireEvent('hiding');
var count = this.count - 1;
if (count <= 0) {
this.count = 0;
this.element.conceal();
} else {
this.count = count;
}
this.hideLoader();
this.fireEvent('hidden', [(count <= 0)]);
} | javascript | function() {
this.fireEvent('hiding');
var count = this.count - 1;
if (count <= 0) {
this.count = 0;
this.element.conceal();
} else {
this.count = count;
}
this.hideLoader();
this.fireEvent('hidden', [(count <= 0)]);
} | [
"function",
"(",
")",
"{",
"this",
".",
"fireEvent",
"(",
"'hiding'",
")",
";",
"var",
"count",
"=",
"this",
".",
"count",
"-",
"1",
";",
"if",
"(",
"count",
"<=",
"0",
")",
"{",
"this",
".",
"count",
"=",
"0",
";",
"this",
".",
"element",
".",... | Hide the blackout if count reaches 0. | [
"Hide",
"the",
"blackout",
"if",
"count",
"reaches",
"0",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L1460-L1475 | train | |
titon/toolkit | dist/toolkit.js | function() {
this.fireEvent('showing');
var show = false;
this.count++;
if (this.count === 1) {
this.element.reveal();
show = true;
}
this.showLoader();
this.fireEvent('shown', [show]);
} | javascript | function() {
this.fireEvent('showing');
var show = false;
this.count++;
if (this.count === 1) {
this.element.reveal();
show = true;
}
this.showLoader();
this.fireEvent('shown', [show]);
} | [
"function",
"(",
")",
"{",
"this",
".",
"fireEvent",
"(",
"'showing'",
")",
";",
"var",
"show",
"=",
"false",
";",
"this",
".",
"count",
"++",
";",
"if",
"(",
"this",
".",
"count",
"===",
"1",
")",
"{",
"this",
".",
"element",
".",
"reveal",
"(",... | Show the blackout and increase open count. | [
"Show",
"the",
"blackout",
"and",
"increase",
"open",
"count",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L1489-L1504 | train | |
titon/toolkit | dist/toolkit.js | function() {
var self = $(this),
start,
target;
/**
* There's a major bug in Android devices where `touchend` events do not fire
* without calling `preventDefault()` in `touchstart` or `touchmove`.
* Because of this, we have... | javascript | function() {
var self = $(this),
start,
target;
/**
* There's a major bug in Android devices where `touchend` events do not fire
* without calling `preventDefault()` in `touchstart` or `touchmove`.
* Because of this, we have... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"$",
"(",
"this",
")",
",",
"start",
",",
"target",
";",
"/**\n * There's a major bug in Android devices where `touchend` events do not fire\n * without calling `preventDefault()` in `touchstart` or `touchmove`.\n... | Maximum distance to travel in the opposite direction | [
"Maximum",
"distance",
"to",
"travel",
"in",
"the",
"opposite",
"direction"
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L1607-L1679 | train | |
titon/toolkit | dist/toolkit.js | cleanup | function cleanup() {
start = target = null;
swiping = false;
self.off(moveEvent, move);
} | javascript | function cleanup() {
start = target = null;
swiping = false;
self.off(moveEvent, move);
} | [
"function",
"cleanup",
"(",
")",
"{",
"start",
"=",
"target",
"=",
"null",
";",
"swiping",
"=",
"false",
";",
"self",
".",
"off",
"(",
"moveEvent",
",",
"move",
")",
";",
"}"
] | When `touchend` or `touchcancel` is triggered, clean up the swipe state.
Also unbind `touchmove` events until another swipe occurs. | [
"When",
"touchend",
"or",
"touchcancel",
"is",
"triggered",
"clean",
"up",
"the",
"swipe",
"state",
".",
"Also",
"unbind",
"touchmove",
"events",
"until",
"another",
"swipe",
"occurs",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L1640-L1645 | train |
titon/toolkit | dist/toolkit.js | function() {
var options = this.options;
return this.wrapper = this.render(options.wrapperTemplate)
.addClass(Toolkit.buildTemplate(options.wrapperClass))
.attr('id', this.id('wrapper'))
.appendTo('body');
} | javascript | function() {
var options = this.options;
return this.wrapper = this.render(options.wrapperTemplate)
.addClass(Toolkit.buildTemplate(options.wrapperClass))
.attr('id', this.id('wrapper'))
.appendTo('body');
} | [
"function",
"(",
")",
"{",
"var",
"options",
"=",
"this",
".",
"options",
";",
"return",
"this",
".",
"wrapper",
"=",
"this",
".",
"render",
"(",
"options",
".",
"wrapperTemplate",
")",
".",
"addClass",
"(",
"Toolkit",
".",
"buildTemplate",
"(",
"options... | Create the elements wrapper.
@return {jQuery} | [
"Create",
"the",
"elements",
"wrapper",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L2387-L2394 | train | |
titon/toolkit | dist/toolkit.js | function(node, callback) {
var elements = this.elements,
el,
id = $(node).cache('toolkit.cid', function() {
return Math.random().toString(32).substr(2);
});
if (elements[id]) {
el = elements[id];
} else {
el = elements[... | javascript | function(node, callback) {
var elements = this.elements,
el,
id = $(node).cache('toolkit.cid', function() {
return Math.random().toString(32).substr(2);
});
if (elements[id]) {
el = elements[id];
} else {
el = elements[... | [
"function",
"(",
"node",
",",
"callback",
")",
"{",
"var",
"elements",
"=",
"this",
".",
"elements",
",",
"el",
",",
"id",
"=",
"$",
"(",
"node",
")",
".",
"cache",
"(",
"'toolkit.cid'",
",",
"function",
"(",
")",
"{",
"return",
"Math",
".",
"rando... | Attempt to find and return an element by a unique composite ID.
Each element is unique per node. If the element does not exist, create it.
@param {jQuery} node
@param {Function} [callback] - Callback to trigger once an element is created
@returns {jQuery} | [
"Attempt",
"to",
"find",
"and",
"return",
"an",
"element",
"by",
"a",
"unique",
"composite",
"ID",
".",
"Each",
"element",
"is",
"unique",
"per",
"node",
".",
"If",
"the",
"element",
"does",
"not",
"exist",
"create",
"it",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L2413-L2431 | train | |
titon/toolkit | dist/toolkit.js | function(e) {
var node = $(e.currentTarget),
element,
isNode = (this.node && this.node.is(node)),
cid = node.data('toolkit.cid');
// Set the current element based on the nodes composite ID
if (cid && this.elements[cid]) {
element = this.elements[c... | javascript | function(e) {
var node = $(e.currentTarget),
element,
isNode = (this.node && this.node.is(node)),
cid = node.data('toolkit.cid');
// Set the current element based on the nodes composite ID
if (cid && this.elements[cid]) {
element = this.elements[c... | [
"function",
"(",
"e",
")",
"{",
"var",
"node",
"=",
"$",
"(",
"e",
".",
"currentTarget",
")",
",",
"element",
",",
"isNode",
"=",
"(",
"this",
".",
"node",
"&&",
"this",
".",
"node",
".",
"is",
"(",
"node",
")",
")",
",",
"cid",
"=",
"node",
... | Event handler for toggling an element through click or hover events.
@param {jQuery.Event} e
@private | [
"Event",
"handler",
"for",
"toggling",
"an",
"element",
"through",
"click",
"or",
"hover",
"events",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L2461-L2502 | train | |
titon/toolkit | dist/toolkit.js | function(node) {
var target = this.readValue(node, this.options.getTarget);
if (!target || target.substr(0, 1) !== '#') {
throw new Error('Drop menu ' + target + ' does not exist');
}
return $(target);
} | javascript | function(node) {
var target = this.readValue(node, this.options.getTarget);
if (!target || target.substr(0, 1) !== '#') {
throw new Error('Drop menu ' + target + ' does not exist');
}
return $(target);
} | [
"function",
"(",
"node",
")",
"{",
"var",
"target",
"=",
"this",
".",
"readValue",
"(",
"node",
",",
"this",
".",
"options",
".",
"getTarget",
")",
";",
"if",
"(",
"!",
"target",
"||",
"target",
".",
"substr",
"(",
"0",
",",
"1",
")",
"!==",
"'#'... | Find the menu for the current node.
@param {jQuery} node | [
"Find",
"the",
"menu",
"for",
"the",
"current",
"node",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L2620-L2628 | train | |
titon/toolkit | dist/toolkit.js | function() {
var element = this.element,
node = this.node;
// Clickout check
if (!element && !node) {
return;
}
this.fireEvent('hiding', [element, node]);
element.conceal();
node
.aria('toggled', false)
.removeCl... | javascript | function() {
var element = this.element,
node = this.node;
// Clickout check
if (!element && !node) {
return;
}
this.fireEvent('hiding', [element, node]);
element.conceal();
node
.aria('toggled', false)
.removeCl... | [
"function",
"(",
")",
"{",
"var",
"element",
"=",
"this",
".",
"element",
",",
"node",
"=",
"this",
".",
"node",
";",
"// Clickout check",
"if",
"(",
"!",
"element",
"&&",
"!",
"node",
")",
"{",
"return",
";",
"}",
"this",
".",
"fireEvent",
"(",
"'... | Hide the opened menu and reset the nodes active state. | [
"Hide",
"the",
"opened",
"menu",
"and",
"reset",
"the",
"nodes",
"active",
"state",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L2633-L2651 | train | |
titon/toolkit | dist/toolkit.js | function(node) {
this.node = node = $(node);
var element = this.loadElement(node);
this.fireEvent('showing', [element, node]);
element.reveal();
node
.aria('toggled', true)
.addClass('is-active');
this.fireEvent('shown', [element, node]);
... | javascript | function(node) {
this.node = node = $(node);
var element = this.loadElement(node);
this.fireEvent('showing', [element, node]);
element.reveal();
node
.aria('toggled', true)
.addClass('is-active');
this.fireEvent('shown', [element, node]);
... | [
"function",
"(",
"node",
")",
"{",
"this",
".",
"node",
"=",
"node",
"=",
"$",
"(",
"node",
")",
";",
"var",
"element",
"=",
"this",
".",
"loadElement",
"(",
"node",
")",
";",
"this",
".",
"fireEvent",
"(",
"'showing'",
",",
"[",
"element",
",",
... | Open the target menu and apply active state to the node.
@param {jQuery} node | [
"Open",
"the",
"target",
"menu",
"and",
"apply",
"active",
"state",
"to",
"the",
"node",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L2658-L2672 | train | |
titon/toolkit | dist/toolkit.js | function(e) {
e.preventDefault();
// Hide previous drops
this.hide();
// Toggle the menu
var node = $(e.currentTarget),
menu = this.loadElement(node);
if (!menu.is(':shown')) {
this.show(node);
} else {
this.hide();
... | javascript | function(e) {
e.preventDefault();
// Hide previous drops
this.hide();
// Toggle the menu
var node = $(e.currentTarget),
menu = this.loadElement(node);
if (!menu.is(':shown')) {
this.show(node);
} else {
this.hide();
... | [
"function",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"// Hide previous drops",
"this",
".",
"hide",
"(",
")",
";",
"// Toggle the menu",
"var",
"node",
"=",
"$",
"(",
"e",
".",
"currentTarget",
")",
",",
"menu",
"=",
"this",
".",
... | When a node is clicked, grab the target from the attribute.
Validate the target element, then either display or hide.
@param {jQuery.Event} e
@private | [
"When",
"a",
"node",
"is",
"clicked",
"grab",
"the",
"target",
"from",
"the",
"attribute",
".",
"Validate",
"the",
"target",
"element",
"then",
"either",
"display",
"or",
"hide",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L2681-L2697 | train | |
titon/toolkit | dist/toolkit.js | function(nodes, url, options) {
if (Toolkit.isTouch) {
return; // Flyouts shouldn't be usable on touch devices
}
this.nodes = $(nodes);
options = this.setOptions(options);
this.createWrapper();
if (options.mode === 'click') {
this.addEvents([
... | javascript | function(nodes, url, options) {
if (Toolkit.isTouch) {
return; // Flyouts shouldn't be usable on touch devices
}
this.nodes = $(nodes);
options = this.setOptions(options);
this.createWrapper();
if (options.mode === 'click') {
this.addEvents([
... | [
"function",
"(",
"nodes",
",",
"url",
",",
"options",
")",
"{",
"if",
"(",
"Toolkit",
".",
"isTouch",
")",
"{",
"return",
";",
"// Flyouts shouldn't be usable on touch devices",
"}",
"this",
".",
"nodes",
"=",
"$",
"(",
"nodes",
")",
";",
"options",
"=",
... | Initialize the flyout. A URL is required during construction.
@param {jQuery} nodes
@param {String} url
@param {Object} [options] | [
"Initialize",
"the",
"flyout",
".",
"A",
"URL",
"is",
"required",
"during",
"construction",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L2731-L2761 | train | |
titon/toolkit | dist/toolkit.js | function(data, depth) {
depth = depth || 0;
// If root, store the data
if (!depth) {
this.data = data;
}
// Store the data indexed by URL
if (data.url) {
this.dataMap[data.url] = data;
}
if (data.children) {
for (var ... | javascript | function(data, depth) {
depth = depth || 0;
// If root, store the data
if (!depth) {
this.data = data;
}
// Store the data indexed by URL
if (data.url) {
this.dataMap[data.url] = data;
}
if (data.children) {
for (var ... | [
"function",
"(",
"data",
",",
"depth",
")",
"{",
"depth",
"=",
"depth",
"||",
"0",
";",
"// If root, store the data",
"if",
"(",
"!",
"depth",
")",
"{",
"this",
".",
"data",
"=",
"data",
";",
"}",
"// Store the data indexed by URL",
"if",
"(",
"data",
".... | Load the data into the class and save a mapping of it.
@param {Object} data
@param {Number} [depth] | [
"Load",
"the",
"data",
"into",
"the",
"class",
"and",
"save",
"a",
"mapping",
"of",
"it",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L2800-L2818 | train | |
titon/toolkit | dist/toolkit.js | function() {
var options = this.options,
node = this.node,
element = this.loadElement(node);
// Only position if the menu has children
if (!element.children().length) {
return;
}
this.fireEvent('showing');
var height = element.outerH... | javascript | function() {
var options = this.options,
node = this.node,
element = this.loadElement(node);
// Only position if the menu has children
if (!element.children().length) {
return;
}
this.fireEvent('showing');
var height = element.outerH... | [
"function",
"(",
")",
"{",
"var",
"options",
"=",
"this",
".",
"options",
",",
"node",
"=",
"this",
".",
"node",
",",
"element",
"=",
"this",
".",
"loadElement",
"(",
"node",
")",
";",
"// Only position if the menu has children",
"if",
"(",
"!",
"element",... | Position the menu below the target node. | [
"Position",
"the",
"menu",
"below",
"the",
"target",
"node",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L2823-L2859 | train | |
titon/toolkit | dist/toolkit.js | function(node) {
node = $(node);
var target = this.readValue(node, this.options.getUrl) || node.attr('href');
// When jumping from one node to another
// Immediately hide the other menu and start the timer for the current one
if (this.url && target !== this.url) {
t... | javascript | function(node) {
node = $(node);
var target = this.readValue(node, this.options.getUrl) || node.attr('href');
// When jumping from one node to another
// Immediately hide the other menu and start the timer for the current one
if (this.url && target !== this.url) {
t... | [
"function",
"(",
"node",
")",
"{",
"node",
"=",
"$",
"(",
"node",
")",
";",
"var",
"target",
"=",
"this",
".",
"readValue",
"(",
"node",
",",
"this",
".",
"options",
".",
"getUrl",
")",
"||",
"node",
".",
"attr",
"(",
"'href'",
")",
";",
"// When... | Show the menu below the node.
@param {jQuery} node | [
"Show",
"the",
"menu",
"below",
"the",
"node",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L2866-L2895 | train | |
titon/toolkit | dist/toolkit.js | function(key, delay, args) {
this.clearTimer(key);
var func;
if (key === 'show') {
func = this.position;
} else {
func = this.hide;
}
if (func) {
this.timers[key] = setTimeout(function() {
func.apply(this, args || [])... | javascript | function(key, delay, args) {
this.clearTimer(key);
var func;
if (key === 'show') {
func = this.position;
} else {
func = this.hide;
}
if (func) {
this.timers[key] = setTimeout(function() {
func.apply(this, args || [])... | [
"function",
"(",
"key",
",",
"delay",
",",
"args",
")",
"{",
"this",
".",
"clearTimer",
"(",
"key",
")",
";",
"var",
"func",
";",
"if",
"(",
"key",
"===",
"'show'",
")",
"{",
"func",
"=",
"this",
".",
"position",
";",
"}",
"else",
"{",
"func",
... | Add a timer that should trigger a function after a delay.
@param {String} key
@param {Number} delay
@param {Array} [args] | [
"Add",
"a",
"timer",
"that",
"should",
"trigger",
"a",
"function",
"after",
"a",
"delay",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L2904-L2920 | train | |
titon/toolkit | dist/toolkit.js | function(parent) {
parent = $(parent);
parent.removeClass('is-open');
parent.children(this.ns('menu'))
.removeAttr('style')
.aria({
expanded: false,
hidden: false
})
.conceal();
this.fireEvent('hideChild', [... | javascript | function(parent) {
parent = $(parent);
parent.removeClass('is-open');
parent.children(this.ns('menu'))
.removeAttr('style')
.aria({
expanded: false,
hidden: false
})
.conceal();
this.fireEvent('hideChild', [... | [
"function",
"(",
"parent",
")",
"{",
"parent",
"=",
"$",
"(",
"parent",
")",
";",
"parent",
".",
"removeClass",
"(",
"'is-open'",
")",
";",
"parent",
".",
"children",
"(",
"this",
".",
"ns",
"(",
"'menu'",
")",
")",
".",
"removeAttr",
"(",
"'style'",... | Event handler to hide the child menu after exiting parent li.
@private
@param {jQuery} parent | [
"Event",
"handler",
"to",
"hide",
"the",
"child",
"menu",
"after",
"exiting",
"parent",
"li",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L3046-L3058 | train | |
titon/toolkit | dist/toolkit.js | function(parent) {
var menu = parent.children(this.ns('menu'));
if (!menu) {
return;
}
menu.aria({
expanded: true,
hidden: true
});
// Alter width because of columns
var children = menu.children();
menu.css('width', ... | javascript | function(parent) {
var menu = parent.children(this.ns('menu'));
if (!menu) {
return;
}
menu.aria({
expanded: true,
hidden: true
});
// Alter width because of columns
var children = menu.children();
menu.css('width', ... | [
"function",
"(",
"parent",
")",
"{",
"var",
"menu",
"=",
"parent",
".",
"children",
"(",
"this",
".",
"ns",
"(",
"'menu'",
")",
")",
";",
"if",
"(",
"!",
"menu",
")",
"{",
"return",
";",
"}",
"menu",
".",
"aria",
"(",
"{",
"expanded",
":",
"tru... | Event handler to position the child menu dependent on the position in the page.
@private
@param {jQuery} parent | [
"Event",
"handler",
"to",
"position",
"the",
"child",
"menu",
"dependent",
"on",
"the",
"position",
"in",
"the",
"page",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L3076-L3126 | train | |
titon/toolkit | dist/toolkit.js | function(element, options) {
element = this.setElement(element);
options = this.setOptions(options, element);
if (options.checkbox) {
element.find(options.checkbox).inputCheckbox(options);
}
if (options.radio) {
element.find(options.radio).inputRadio(opt... | javascript | function(element, options) {
element = this.setElement(element);
options = this.setOptions(options, element);
if (options.checkbox) {
element.find(options.checkbox).inputCheckbox(options);
}
if (options.radio) {
element.find(options.radio).inputRadio(opt... | [
"function",
"(",
"element",
",",
"options",
")",
"{",
"element",
"=",
"this",
".",
"setElement",
"(",
"element",
")",
";",
"options",
"=",
"this",
".",
"setOptions",
"(",
"options",
",",
"element",
")",
";",
"if",
"(",
"options",
".",
"checkbox",
")",
... | Initialize the input.
@param {jQuery} element
@param {Object} [options] | [
"Initialize",
"the",
"input",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L3167-L3184 | train | |
titon/toolkit | dist/toolkit.js | function() {
var options = this.options,
element = this.element;
if (this.name === 'Input') {
if (options.checkbox) {
element.find(options.checkbox).each(function() {
$(this).toolkit('inputCheckbox', 'destroy');
});
... | javascript | function() {
var options = this.options,
element = this.element;
if (this.name === 'Input') {
if (options.checkbox) {
element.find(options.checkbox).each(function() {
$(this).toolkit('inputCheckbox', 'destroy');
});
... | [
"function",
"(",
")",
"{",
"var",
"options",
"=",
"this",
".",
"options",
",",
"element",
"=",
"this",
".",
"element",
";",
"if",
"(",
"this",
".",
"name",
"===",
"'Input'",
")",
"{",
"if",
"(",
"options",
".",
"checkbox",
")",
"{",
"element",
".",... | Remove the wrapper before destroying. | [
"Remove",
"the",
"wrapper",
"before",
"destroying",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L3189-L3218 | train | |
titon/toolkit | dist/toolkit.js | function(from, to) {
var classes = ($(from).attr('class') || '').replace(this.options.filterClasses, '').trim();
if (classes) {
$(to).addClass(classes);
}
} | javascript | function(from, to) {
var classes = ($(from).attr('class') || '').replace(this.options.filterClasses, '').trim();
if (classes) {
$(to).addClass(classes);
}
} | [
"function",
"(",
"from",
",",
"to",
")",
"{",
"var",
"classes",
"=",
"(",
"$",
"(",
"from",
")",
".",
"attr",
"(",
"'class'",
")",
"||",
"''",
")",
".",
"replace",
"(",
"this",
".",
"options",
".",
"filterClasses",
",",
"''",
")",
".",
"trim",
... | Copy classes from one element to another, but do not copy `filterClasses` classes.
@param {jQuery} from
@param {jQuery} to | [
"Copy",
"classes",
"from",
"one",
"element",
"to",
"another",
"but",
"do",
"not",
"copy",
"filterClasses",
"classes",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L3226-L3232 | train | |
titon/toolkit | dist/toolkit.js | function() {
var input = this.element,
wrapper = this.render(this.options.template)
.insertBefore(input)
.append(input);
if (this.options.copyClasses) {
this.copyClasses(input, wrapper);
}
return wrapper;
} | javascript | function() {
var input = this.element,
wrapper = this.render(this.options.template)
.insertBefore(input)
.append(input);
if (this.options.copyClasses) {
this.copyClasses(input, wrapper);
}
return wrapper;
} | [
"function",
"(",
")",
"{",
"var",
"input",
"=",
"this",
".",
"element",
",",
"wrapper",
"=",
"this",
".",
"render",
"(",
"this",
".",
"options",
".",
"template",
")",
".",
"insertBefore",
"(",
"input",
")",
".",
"append",
"(",
"input",
")",
";",
"i... | Build the element to wrap custom inputs with.
Copy over the original class names.
@returns {jQuery} | [
"Build",
"the",
"element",
"to",
"wrap",
"custom",
"inputs",
"with",
".",
"Copy",
"over",
"the",
"original",
"class",
"names",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L3240-L3251 | train | |
titon/toolkit | dist/toolkit.js | function(checkbox, options) {
this.element = checkbox = $(checkbox);
options = this.setOptions(options, checkbox);
this.wrapper = this._buildWrapper();
// Create custom input
this.input = this.render(options.checkboxTemplate)
.attr('for', checkbox.attr('id'))
... | javascript | function(checkbox, options) {
this.element = checkbox = $(checkbox);
options = this.setOptions(options, checkbox);
this.wrapper = this._buildWrapper();
// Create custom input
this.input = this.render(options.checkboxTemplate)
.attr('for', checkbox.attr('id'))
... | [
"function",
"(",
"checkbox",
",",
"options",
")",
"{",
"this",
".",
"element",
"=",
"checkbox",
"=",
"$",
"(",
"checkbox",
")",
";",
"options",
"=",
"this",
".",
"setOptions",
"(",
"options",
",",
"checkbox",
")",
";",
"this",
".",
"wrapper",
"=",
"t... | Initialize the checkbox.
@param {jQuery} checkbox
@param {Object} [options] | [
"Initialize",
"the",
"checkbox",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L3278-L3290 | train | |
titon/toolkit | dist/toolkit.js | function(radio, options) {
this.element = radio = $(radio);
options = this.setOptions(options, radio);
this.wrapper = this._buildWrapper();
// Create custom input
this.input = this.render(options.radioTemplate)
.attr('for', radio.attr('id'))
.insertAfter(... | javascript | function(radio, options) {
this.element = radio = $(radio);
options = this.setOptions(options, radio);
this.wrapper = this._buildWrapper();
// Create custom input
this.input = this.render(options.radioTemplate)
.attr('for', radio.attr('id'))
.insertAfter(... | [
"function",
"(",
"radio",
",",
"options",
")",
"{",
"this",
".",
"element",
"=",
"radio",
"=",
"$",
"(",
"radio",
")",
";",
"options",
"=",
"this",
".",
"setOptions",
"(",
"options",
",",
"radio",
")",
";",
"this",
".",
"wrapper",
"=",
"this",
".",... | Initialize the radio.
@param {jQuery} radio
@param {Object} [options] | [
"Initialize",
"the",
"radio",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L3312-L3324 | train | |
titon/toolkit | dist/toolkit.js | function(select, options) {
this.element = select = $(select);
options = this.setOptions(options, select);
this.multiple = select.prop('multiple');
// Multiple selects must use native controls
if (this.multiple && options.native) {
return;
}
// Wrapp... | javascript | function(select, options) {
this.element = select = $(select);
options = this.setOptions(options, select);
this.multiple = select.prop('multiple');
// Multiple selects must use native controls
if (this.multiple && options.native) {
return;
}
// Wrapp... | [
"function",
"(",
"select",
",",
"options",
")",
"{",
"this",
".",
"element",
"=",
"select",
"=",
"$",
"(",
"select",
")",
";",
"options",
"=",
"this",
".",
"setOptions",
"(",
"options",
",",
"select",
")",
";",
"this",
".",
"multiple",
"=",
"select",... | Initialize the select.
@param {jQuery} select
@param {Object} [options] | [
"Initialize",
"the",
"select",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L3364-L3406 | train | |
titon/toolkit | dist/toolkit.js | function() {
var options = this.options,
button = this.render(options.selectTemplate)
.find(this.ns('arrow', 'select')).html(this.render(options.arrowTemplate)).end()
.find(this.ns('label', 'select')).html(Toolkit.messages.loading).end()
.css('min-widt... | javascript | function() {
var options = this.options,
button = this.render(options.selectTemplate)
.find(this.ns('arrow', 'select')).html(this.render(options.arrowTemplate)).end()
.find(this.ns('label', 'select')).html(Toolkit.messages.loading).end()
.css('min-widt... | [
"function",
"(",
")",
"{",
"var",
"options",
"=",
"this",
".",
"options",
",",
"button",
"=",
"this",
".",
"render",
"(",
"options",
".",
"selectTemplate",
")",
".",
"find",
"(",
"this",
".",
"ns",
"(",
"'arrow'",
",",
"'select'",
")",
")",
".",
"h... | Build the element to represent the select button with label and arrow.
@returns {jQuery} | [
"Build",
"the",
"element",
"to",
"represent",
"the",
"select",
"button",
"with",
"label",
"and",
"arrow",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L3449-L3461 | train | |
titon/toolkit | dist/toolkit.js | function() {
var select = this.element,
options = this.options,
buildOption = this._buildOption.bind(this),
renderTemplate = this.render.bind(this),
dropdown = renderTemplate(options.optionsTemplate).attr('role', 'listbox').aria('multiselectable', this.multiple),
... | javascript | function() {
var select = this.element,
options = this.options,
buildOption = this._buildOption.bind(this),
renderTemplate = this.render.bind(this),
dropdown = renderTemplate(options.optionsTemplate).attr('role', 'listbox').aria('multiselectable', this.multiple),
... | [
"function",
"(",
")",
"{",
"var",
"select",
"=",
"this",
".",
"element",
",",
"options",
"=",
"this",
".",
"options",
",",
"buildOption",
"=",
"this",
".",
"_buildOption",
".",
"bind",
"(",
"this",
")",
",",
"renderTemplate",
"=",
"this",
".",
"render"... | Build the custom dropdown to hold a list of option items.
@returns {jQuery} | [
"Build",
"the",
"custom",
"dropdown",
"to",
"hold",
"a",
"list",
"of",
"option",
"items",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L3468-L3532 | train | |
titon/toolkit | dist/toolkit.js | function(option, index) {
var select = this.element,
dropdown = this.dropdown,
options = this.options,
selected = option.prop('selected'),
activeClass = 'is-active';
// Create elements
var li = $('<li/>'),
content = option.text(),
... | javascript | function(option, index) {
var select = this.element,
dropdown = this.dropdown,
options = this.options,
selected = option.prop('selected'),
activeClass = 'is-active';
// Create elements
var li = $('<li/>'),
content = option.text(),
... | [
"function",
"(",
"option",
",",
"index",
")",
"{",
"var",
"select",
"=",
"this",
".",
"element",
",",
"dropdown",
"=",
"this",
".",
"dropdown",
",",
"options",
"=",
"this",
".",
"options",
",",
"selected",
"=",
"option",
".",
"prop",
"(",
"'selected'",... | Build the list item to represent the select option.
@param {jQuery} option
@param {Number} index
@returns {jQuery} | [
"Build",
"the",
"list",
"item",
"to",
"represent",
"the",
"select",
"option",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L3541-L3623 | train | |
titon/toolkit | dist/toolkit.js | function(index, step, options) {
var hideFirst = this.options.hideFirst;
index += step;
while (($.type(options[index]) === 'undefined') || options[index].disabled || (index === 0 && hideFirst)) {
index += step;
if (index >= options.length) {
index = 0;
... | javascript | function(index, step, options) {
var hideFirst = this.options.hideFirst;
index += step;
while (($.type(options[index]) === 'undefined') || options[index].disabled || (index === 0 && hideFirst)) {
index += step;
if (index >= options.length) {
index = 0;
... | [
"function",
"(",
"index",
",",
"step",
",",
"options",
")",
"{",
"var",
"hideFirst",
"=",
"this",
".",
"options",
".",
"hideFirst",
";",
"index",
"+=",
"step",
";",
"while",
"(",
"(",
"$",
".",
"type",
"(",
"options",
"[",
"index",
"]",
")",
"===",... | Loop through the options and determine the index to
Skip over missing options, disabled options, or hidden options.
@private
@param {Number} index
@param {Number} step
@param {jQuery} options
@returns {Number} | [
"Loop",
"through",
"the",
"options",
"and",
"determine",
"the",
"index",
"to",
"Skip",
"over",
"missing",
"options",
"disabled",
"options",
"or",
"hidden",
"options",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L3635-L3651 | train | |
titon/toolkit | dist/toolkit.js | function(e) {
var select = $(e.target),
options = select.find('option'),
opts = this.options,
selected = [],
label = [],
self = this;
// Fetch label from selected option
options.each(function() {
if (this.selected) {
... | javascript | function(e) {
var select = $(e.target),
options = select.find('option'),
opts = this.options,
selected = [],
label = [],
self = this;
// Fetch label from selected option
options.each(function() {
if (this.selected) {
... | [
"function",
"(",
"e",
")",
"{",
"var",
"select",
"=",
"$",
"(",
"e",
".",
"target",
")",
",",
"options",
"=",
"select",
".",
"find",
"(",
"'option'",
")",
",",
"opts",
"=",
"this",
".",
"options",
",",
"selected",
"=",
"[",
"]",
",",
"label",
"... | Event handler for select option changing.
@private
@param {jQuery.Event} e | [
"Event",
"handler",
"for",
"select",
"option",
"changing",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L3659-L3711 | train | |
titon/toolkit | dist/toolkit.js | function(e) {
if (!this.dropdown.is(':shown')) {
return;
}
if ($.inArray(e.keyCode, [38, 40, 13, 27]) >= 0) {
e.preventDefault();
} else {
return;
}
var options = this.element.find('option'),
items = this.dropdown.find('a'... | javascript | function(e) {
if (!this.dropdown.is(':shown')) {
return;
}
if ($.inArray(e.keyCode, [38, 40, 13, 27]) >= 0) {
e.preventDefault();
} else {
return;
}
var options = this.element.find('option'),
items = this.dropdown.find('a'... | [
"function",
"(",
"e",
")",
"{",
"if",
"(",
"!",
"this",
".",
"dropdown",
".",
"is",
"(",
"':shown'",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
".",
"inArray",
"(",
"e",
".",
"keyCode",
",",
"[",
"38",
",",
"40",
",",
"13",
",",
"27... | Event handler for cycling through options with up and down keys.
@private
@param {jQuery.Event} e | [
"Event",
"handler",
"for",
"cycling",
"through",
"options",
"with",
"up",
"and",
"down",
"keys",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L3719-L3756 | train | |
titon/toolkit | dist/toolkit.js | function(container, options) {
container = $(container);
options = this.setOptions(options, container);
this.items = container.find(this.options.lazyClass);
if (container.css('overflow') === 'auto') {
this.container = container;
}
var callback = $.throttle(... | javascript | function(container, options) {
container = $(container);
options = this.setOptions(options, container);
this.items = container.find(this.options.lazyClass);
if (container.css('overflow') === 'auto') {
this.container = container;
}
var callback = $.throttle(... | [
"function",
"(",
"container",
",",
"options",
")",
"{",
"container",
"=",
"$",
"(",
"container",
")",
";",
"options",
"=",
"this",
".",
"setOptions",
"(",
"options",
",",
"container",
")",
";",
"this",
".",
"items",
"=",
"container",
".",
"find",
"(",
... | Initialize the lazy load.
@param {jQuery} container
@param {Object} [options] | [
"Initialize",
"the",
"lazy",
"load",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L3831-L3851 | train | |
titon/toolkit | dist/toolkit.js | function() {
if (this.loaded >= this.items.length) {
this.shutdown();
return;
}
this.fireEvent('loading');
this.items.each(function(index, item) {
if (item && this.inViewport(item)) {
this.show(item, index);
}
}.bi... | javascript | function() {
if (this.loaded >= this.items.length) {
this.shutdown();
return;
}
this.fireEvent('loading');
this.items.each(function(index, item) {
if (item && this.inViewport(item)) {
this.show(item, index);
}
}.bi... | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"loaded",
">=",
"this",
".",
"items",
".",
"length",
")",
"{",
"this",
".",
"shutdown",
"(",
")",
";",
"return",
";",
"}",
"this",
".",
"fireEvent",
"(",
"'loading'",
")",
";",
"this",
".",
"item... | Loop over the lazy loaded items and verify they are within the viewport. | [
"Loop",
"over",
"the",
"lazy",
"loaded",
"items",
"and",
"verify",
"they",
"are",
"within",
"the",
"viewport",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L3906-L3921 | train | |
titon/toolkit | dist/toolkit.js | function(node, index) {
node = $(node);
this.fireEvent('showing', [node]);
// Set the item being loaded for so that events can be fired
this.element = node.removeClass(this.options.lazyClass.substr(1));
// Replace src attributes on images
node.find('img').each(function... | javascript | function(node, index) {
node = $(node);
this.fireEvent('showing', [node]);
// Set the item being loaded for so that events can be fired
this.element = node.removeClass(this.options.lazyClass.substr(1));
// Replace src attributes on images
node.find('img').each(function... | [
"function",
"(",
"node",
",",
"index",
")",
"{",
"node",
"=",
"$",
"(",
"node",
")",
";",
"this",
".",
"fireEvent",
"(",
"'showing'",
",",
"[",
"node",
"]",
")",
";",
"// Set the item being loaded for so that events can be fired",
"this",
".",
"element",
"="... | Show the item by removing the lazy load class.
@param {jQuery} node
@param {Number} index | [
"Show",
"the",
"item",
"by",
"removing",
"the",
"lazy",
"load",
"class",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L3944-L3974 | train | |
titon/toolkit | dist/toolkit.js | function(element, options) {
element = this.setElement(element);
options = this.setOptions(options, element);
// Add class and set relative positioning
if (!element.is('body')) {
element.addClass('is-maskable');
var position = element.css('position');
... | javascript | function(element, options) {
element = this.setElement(element);
options = this.setOptions(options, element);
// Add class and set relative positioning
if (!element.is('body')) {
element.addClass('is-maskable');
var position = element.css('position');
... | [
"function",
"(",
"element",
",",
"options",
")",
"{",
"element",
"=",
"this",
".",
"setElement",
"(",
"element",
")",
";",
"options",
"=",
"this",
".",
"setOptions",
"(",
"options",
",",
"element",
")",
";",
"// Add class and set relative positioning",
"if",
... | Initialize the mask.
@param {jQuery} element
@param {Object} [options] | [
"Initialize",
"the",
"mask",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L4029-L4058 | train | |
titon/toolkit | dist/toolkit.js | function(mask) {
var options = this.options,
message;
// Prepare mask
mask.addClass('hide').appendTo(this.element);
if (this.element.is('body')) {
mask.css('position', 'fixed');
}
if (options.revealOnClick) {
mask.click(this.hide.bin... | javascript | function(mask) {
var options = this.options,
message;
// Prepare mask
mask.addClass('hide').appendTo(this.element);
if (this.element.is('body')) {
mask.css('position', 'fixed');
}
if (options.revealOnClick) {
mask.click(this.hide.bin... | [
"function",
"(",
"mask",
")",
"{",
"var",
"options",
"=",
"this",
".",
"options",
",",
"message",
";",
"// Prepare mask",
"mask",
".",
"addClass",
"(",
"'hide'",
")",
".",
"appendTo",
"(",
"this",
".",
"element",
")",
";",
"if",
"(",
"this",
".",
"el... | Set the element to use as a mask and append it to the target element.
Apply optional classes, events, and styles dependent on implementation.
@param {jQuery} mask | [
"Set",
"the",
"element",
"to",
"use",
"as",
"a",
"mask",
"and",
"append",
"it",
"to",
"the",
"target",
"element",
".",
"Apply",
"optional",
"classes",
"events",
"and",
"styles",
"dependent",
"on",
"implementation",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L4089-L4116 | train | |
titon/toolkit | dist/toolkit.js | function(nodes, options) {
this.nodes = $(nodes);
options = this.setOptions(options);
this.element = this.createElement()
.attr('role', 'dialog')
.aria('labelledby', this.id('title'))
.aria('describedby', this.id('content'));
// Enable fullscreen
... | javascript | function(nodes, options) {
this.nodes = $(nodes);
options = this.setOptions(options);
this.element = this.createElement()
.attr('role', 'dialog')
.aria('labelledby', this.id('title'))
.aria('describedby', this.id('content'));
// Enable fullscreen
... | [
"function",
"(",
"nodes",
",",
"options",
")",
"{",
"this",
".",
"nodes",
"=",
"$",
"(",
"nodes",
")",
";",
"options",
"=",
"this",
".",
"setOptions",
"(",
"options",
")",
";",
"this",
".",
"element",
"=",
"this",
".",
"createElement",
"(",
")",
".... | Initialize the modal.
@param {jQuery} nodes
@param {Object} [options] | [
"Initialize",
"the",
"modal",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L4543-L4574 | train | |
titon/toolkit | dist/toolkit.js | function(content) {
// AJAX is currently loading
if (content === true) {
return;
}
// Hide blackout loading message
if (this.blackout) {
this.blackout.hideLoader();
}
this.fireEvent('showing');
var body = this.element.find(this.n... | javascript | function(content) {
// AJAX is currently loading
if (content === true) {
return;
}
// Hide blackout loading message
if (this.blackout) {
this.blackout.hideLoader();
}
this.fireEvent('showing');
var body = this.element.find(this.n... | [
"function",
"(",
"content",
")",
"{",
"// AJAX is currently loading",
"if",
"(",
"content",
"===",
"true",
")",
"{",
"return",
";",
"}",
"// Hide blackout loading message",
"if",
"(",
"this",
".",
"blackout",
")",
"{",
"this",
".",
"blackout",
".",
"hideLoader... | Position the modal in the center of the screen.
@param {String|jQuery} content | [
"Position",
"the",
"modal",
"in",
"the",
"center",
"of",
"the",
"screen",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L4600-L4627 | train | |
titon/toolkit | dist/toolkit.js | function(node, content) {
if (node) {
this.node = node = $(node);
if (!content) {
content = this.readValue(node, this.readOption(node, 'getContent')) || node.attr('href');
}
}
// Show blackout if the element is hidden
// If it is visi... | javascript | function(node, content) {
if (node) {
this.node = node = $(node);
if (!content) {
content = this.readValue(node, this.readOption(node, 'getContent')) || node.attr('href');
}
}
// Show blackout if the element is hidden
// If it is visi... | [
"function",
"(",
"node",
",",
"content",
")",
"{",
"if",
"(",
"node",
")",
"{",
"this",
".",
"node",
"=",
"node",
"=",
"$",
"(",
"node",
")",
";",
"if",
"(",
"!",
"content",
")",
"{",
"content",
"=",
"this",
".",
"readValue",
"(",
"node",
",",
... | Show the modal with the specified content.
@param {jQuery} node
@param {String} [content] | [
"Show",
"the",
"modal",
"with",
"the",
"specified",
"content",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L4635-L4656 | train | |
titon/toolkit | dist/toolkit.js | function() {
var form = this.element.find('form:first');
if (!form) {
return;
}
this.fireEvent('submit', [form]);
var options = {
url: form.attr('action'),
type: (form.attr('method') || 'post').toUpperCase()
};
if (window.Fo... | javascript | function() {
var form = this.element.find('form:first');
if (!form) {
return;
}
this.fireEvent('submit', [form]);
var options = {
url: form.attr('action'),
type: (form.attr('method') || 'post').toUpperCase()
};
if (window.Fo... | [
"function",
"(",
")",
"{",
"var",
"form",
"=",
"this",
".",
"element",
".",
"find",
"(",
"'form:first'",
")",
";",
"if",
"(",
"!",
"form",
")",
"{",
"return",
";",
"}",
"this",
".",
"fireEvent",
"(",
"'submit'",
",",
"[",
"form",
"]",
")",
";",
... | Submit the form found within the modal. | [
"Submit",
"the",
"form",
"found",
"within",
"the",
"modal",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L4661-L4684 | train | |
titon/toolkit | dist/toolkit.js | function(element, options) {
element = this.setElement(element).attr('role', 'complementary').conceal();
options = this.setOptions(options, element);
var animation = options.animation;
// Touch devices cannot use squish
if (Toolkit.isTouch && animation === 'squish') {
... | javascript | function(element, options) {
element = this.setElement(element).attr('role', 'complementary').conceal();
options = this.setOptions(options, element);
var animation = options.animation;
// Touch devices cannot use squish
if (Toolkit.isTouch && animation === 'squish') {
... | [
"function",
"(",
"element",
",",
"options",
")",
"{",
"element",
"=",
"this",
".",
"setElement",
"(",
"element",
")",
".",
"attr",
"(",
"'role'",
",",
"'complementary'",
")",
".",
"conceal",
"(",
")",
";",
"options",
"=",
"this",
".",
"setOptions",
"("... | Initialize off canvas.
@param {jQuery} element
@param {Object} [options] | [
"Initialize",
"off",
"canvas",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L4786-L4836 | train | |
titon/toolkit | dist/toolkit.js | function() {
this.fireEvent('hiding');
this.container.removeClass('move-' + this.opposite);
this.element
.conceal()
.removeClass('is-expanded')
.aria('expanded', false);
if (this.options.stopScroll) {
$('body').removeClass('no-scroll');
... | javascript | function() {
this.fireEvent('hiding');
this.container.removeClass('move-' + this.opposite);
this.element
.conceal()
.removeClass('is-expanded')
.aria('expanded', false);
if (this.options.stopScroll) {
$('body').removeClass('no-scroll');
... | [
"function",
"(",
")",
"{",
"this",
".",
"fireEvent",
"(",
"'hiding'",
")",
";",
"this",
".",
"container",
".",
"removeClass",
"(",
"'move-'",
"+",
"this",
".",
"opposite",
")",
";",
"this",
".",
"element",
".",
"conceal",
"(",
")",
".",
"removeClass",
... | Hide the sidebar and reset the container. | [
"Hide",
"the",
"sidebar",
"and",
"reset",
"the",
"container",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L4848-L4863 | train | |
titon/toolkit | dist/toolkit.js | function() {
var options = this.options;
if (options.hideOthers) {
this.secondary.each(function() {
var sidebar = $(this);
if (sidebar.hasClass('is-expanded')) {
sidebar.toolkit('offCanvas', 'hide');
}
});
... | javascript | function() {
var options = this.options;
if (options.hideOthers) {
this.secondary.each(function() {
var sidebar = $(this);
if (sidebar.hasClass('is-expanded')) {
sidebar.toolkit('offCanvas', 'hide');
}
});
... | [
"function",
"(",
")",
"{",
"var",
"options",
"=",
"this",
".",
"options",
";",
"if",
"(",
"options",
".",
"hideOthers",
")",
"{",
"this",
".",
"secondary",
".",
"each",
"(",
"function",
"(",
")",
"{",
"var",
"sidebar",
"=",
"$",
"(",
"this",
")",
... | Show the sidebar and squish the container to make room for the sidebar.
If hideOthers is true, hide other open sidebars. | [
"Show",
"the",
"sidebar",
"and",
"squish",
"the",
"container",
"to",
"make",
"room",
"for",
"the",
"sidebar",
".",
"If",
"hideOthers",
"is",
"true",
"hide",
"other",
"open",
"sidebars",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L4869-L4896 | train | |
titon/toolkit | dist/toolkit.js | function() {
if (!this.options.openOnLoad || this._loaded) {
return;
}
var sidebar = this.element,
inner = this.primary,
transClass = 'no-transition';
sidebar.addClass(transClass);
inner.addClass(transClass);
this.show();
//... | javascript | function() {
if (!this.options.openOnLoad || this._loaded) {
return;
}
var sidebar = this.element,
inner = this.primary,
transClass = 'no-transition';
sidebar.addClass(transClass);
inner.addClass(transClass);
this.show();
//... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"options",
".",
"openOnLoad",
"||",
"this",
".",
"_loaded",
")",
"{",
"return",
";",
"}",
"var",
"sidebar",
"=",
"this",
".",
"element",
",",
"inner",
"=",
"this",
".",
"primary",
",",
"transC... | On page load, immediately display the sidebar.
Remove transitions from the sidebar and container so there is no page jumping.
Also disable `hideOthers` so multiple sidebars can be displayed on load.
@private | [
"On",
"page",
"load",
"immediately",
"display",
"the",
"sidebar",
".",
"Remove",
"transitions",
"from",
"the",
"sidebar",
"and",
"container",
"so",
"there",
"is",
"no",
"page",
"jumping",
".",
"Also",
"disable",
"hideOthers",
"so",
"multiple",
"sidebars",
"can... | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L4916-L4937 | train | |
titon/toolkit | dist/toolkit.js | function(e) {
e.preventDefault();
var target = $(e.target),
selector = '[data-offcanvas-sidebar]';
if (target.is(selector) || target.parents(selector).length) {
return;
}
this.show();
} | javascript | function(e) {
e.preventDefault();
var target = $(e.target),
selector = '[data-offcanvas-sidebar]';
if (target.is(selector) || target.parents(selector).length) {
return;
}
this.show();
} | [
"function",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"var",
"target",
"=",
"$",
"(",
"e",
".",
"target",
")",
",",
"selector",
"=",
"'[data-offcanvas-sidebar]'",
";",
"if",
"(",
"target",
".",
"is",
"(",
"selector",
")",
"||",
... | When swiping on the container, don't trigger a show if we are trying to hide a sidebar.
@private
@param {jQuery.Event} e | [
"When",
"swiping",
"on",
"the",
"container",
"don",
"t",
"trigger",
"a",
"show",
"if",
"we",
"are",
"trying",
"to",
"hide",
"a",
"sidebar",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L4954-L4965 | train | |
titon/toolkit | dist/toolkit.js | function(element, options) {
element = this.setElement(element);
options = this.setOptions(options, element);
// Setup classes and ARIA
element
.attr('role', 'complementary')
.addClass(options.animation);
// Determine before calculations
var init... | javascript | function(element, options) {
element = this.setElement(element);
options = this.setOptions(options, element);
// Setup classes and ARIA
element
.attr('role', 'complementary')
.addClass(options.animation);
// Determine before calculations
var init... | [
"function",
"(",
"element",
",",
"options",
")",
"{",
"element",
"=",
"this",
".",
"setElement",
"(",
"element",
")",
";",
"options",
"=",
"this",
".",
"setOptions",
"(",
"options",
",",
"element",
")",
";",
"// Setup classes and ARIA",
"element",
".",
"at... | Initialize the pin.
@param {jQuery} element
@param {Object} [options] | [
"Initialize",
"the",
"pin",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L5014-L5039 | train | |
titon/toolkit | dist/toolkit.js | function() {
var win = $(window),
options = this.options,
element = this.element,
parent = options.context ? element.parents(options.context) : element.parent();
this.viewport = {
width: win.width(),
height: win.height()
};
th... | javascript | function() {
var win = $(window),
options = this.options,
element = this.element,
parent = options.context ? element.parents(options.context) : element.parent();
this.viewport = {
width: win.width(),
height: win.height()
};
th... | [
"function",
"(",
")",
"{",
"var",
"win",
"=",
"$",
"(",
"window",
")",
",",
"options",
"=",
"this",
".",
"options",
",",
"element",
"=",
"this",
".",
"element",
",",
"parent",
"=",
"options",
".",
"context",
"?",
"element",
".",
"parents",
"(",
"op... | Calculate the dimensions and offsets of the interacting elements. | [
"Calculate",
"the",
"dimensions",
"and",
"offsets",
"of",
"the",
"interacting",
"elements",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L5054-L5077 | train | |
titon/toolkit | dist/toolkit.js | function() {
var options = this.options;
if (options.calculate) {
this.calculate();
}
if (!this.active) {
return;
}
var eHeight = this.elementHeight,
eTop = this.elementTop,
pHeight = this.parentHeight,
pTop =... | javascript | function() {
var options = this.options;
if (options.calculate) {
this.calculate();
}
if (!this.active) {
return;
}
var eHeight = this.elementHeight,
eTop = this.elementTop,
pHeight = this.parentHeight,
pTop =... | [
"function",
"(",
")",
"{",
"var",
"options",
"=",
"this",
".",
"options",
";",
"if",
"(",
"options",
".",
"calculate",
")",
"{",
"this",
".",
"calculate",
"(",
")",
";",
"}",
"if",
"(",
"!",
"this",
".",
"active",
")",
"{",
"return",
";",
"}",
... | Pin the element along the vertical axis while staying contained within the parent. | [
"Pin",
"the",
"element",
"along",
"the",
"vertical",
"axis",
"while",
"staying",
"contained",
"within",
"the",
"parent",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L5082-L5158 | train | |
titon/toolkit | dist/toolkit.js | function(nodes, options) {
this.nodes = $(nodes);
options = this.setOptions(options);
this.createWrapper();
// Remove title attributes
if (options.getTitle === 'title') {
options.getTitle = 'data-' + this.keyName + '-title';
this.nodes.each(function(i, n... | javascript | function(nodes, options) {
this.nodes = $(nodes);
options = this.setOptions(options);
this.createWrapper();
// Remove title attributes
if (options.getTitle === 'title') {
options.getTitle = 'data-' + this.keyName + '-title';
this.nodes.each(function(i, n... | [
"function",
"(",
"nodes",
",",
"options",
")",
"{",
"this",
".",
"nodes",
"=",
"$",
"(",
"nodes",
")",
";",
"options",
"=",
"this",
".",
"setOptions",
"(",
"options",
")",
";",
"this",
".",
"createWrapper",
"(",
")",
";",
"// Remove title attributes",
... | Initialize the tooltip.
@param {jQuery} nodes
@param {Object} [options] | [
"Initialize",
"the",
"tooltip",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L5329-L5356 | train | |
titon/toolkit | dist/toolkit.js | function(node, content) {
this.node = node = $(node).addClass('is-active');
// Load the new element
this.loadElement(node, function(tooltip) {
tooltip
.addClass(this.readOption(node, 'position'))
.attr('role', 'tooltip');
});
// Load ... | javascript | function(node, content) {
this.node = node = $(node).addClass('is-active');
// Load the new element
this.loadElement(node, function(tooltip) {
tooltip
.addClass(this.readOption(node, 'position'))
.attr('role', 'tooltip');
});
// Load ... | [
"function",
"(",
"node",
",",
"content",
")",
"{",
"this",
".",
"node",
"=",
"node",
"=",
"$",
"(",
"node",
")",
".",
"addClass",
"(",
"'is-active'",
")",
";",
"// Load the new element",
"this",
".",
"loadElement",
"(",
"node",
",",
"function",
"(",
"t... | Show the tooltip and determine whether to grab the content from an AJAX call,
a DOM node, or plain text. The content can also be passed as an argument.
@param {jQuery} node
@param {String|jQuery} [content] | [
"Show",
"the",
"tooltip",
"and",
"determine",
"whether",
"to",
"grab",
"the",
"content",
"from",
"an",
"AJAX",
"call",
"a",
"DOM",
"node",
"or",
"plain",
"text",
".",
"The",
"content",
"can",
"also",
"be",
"passed",
"as",
"an",
"argument",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L5434-L5446 | train | |
titon/toolkit | dist/toolkit.js | function(e) {
e.preventDefault();
var options = this.options;
this.element.reveal().positionTo(options.position, e, {
left: options.xOffset,
top: options.yOffset
}, true);
} | javascript | function(e) {
e.preventDefault();
var options = this.options;
this.element.reveal().positionTo(options.position, e, {
left: options.xOffset,
top: options.yOffset
}, true);
} | [
"function",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"var",
"options",
"=",
"this",
".",
"options",
";",
"this",
".",
"element",
".",
"reveal",
"(",
")",
".",
"positionTo",
"(",
"options",
".",
"position",
",",
"e",
",",
"{",
... | Event handler for positioning the tooltip by the mouse.
@private
@param {jQuery.Event} e | [
"Event",
"handler",
"for",
"positioning",
"the",
"tooltip",
"by",
"the",
"mouse",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L5454-L5463 | train | |
titon/toolkit | dist/toolkit.js | function(nodes, options) {
options = options || {};
options.mode = 'click'; // Click only
options.follow = false; // Disable mouse follow
Tooltip.prototype.constructor.call(this, nodes, options);
} | javascript | function(nodes, options) {
options = options || {};
options.mode = 'click'; // Click only
options.follow = false; // Disable mouse follow
Tooltip.prototype.constructor.call(this, nodes, options);
} | [
"function",
"(",
"nodes",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"options",
".",
"mode",
"=",
"'click'",
";",
"// Click only",
"options",
".",
"follow",
"=",
"false",
";",
"// Disable mouse follow",
"Tooltip",
".",
"proto... | Initialize the popover.
@param {jQuery} nodes
@param {Object} [options] | [
"Initialize",
"the",
"popover",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L5531-L5537 | train | |
titon/toolkit | dist/toolkit.js | function(element, options) {
var sections, tabs, self = this;
element = this.setElement(element);
options = this.setOptions(options, element);
// Determine cookie name
if (!options.cookie) {
options.cookie = element.attr('id');
}
// Find all the sec... | javascript | function(element, options) {
var sections, tabs, self = this;
element = this.setElement(element);
options = this.setOptions(options, element);
// Determine cookie name
if (!options.cookie) {
options.cookie = element.attr('id');
}
// Find all the sec... | [
"function",
"(",
"element",
",",
"options",
")",
"{",
"var",
"sections",
",",
"tabs",
",",
"self",
"=",
"this",
";",
"element",
"=",
"this",
".",
"setElement",
"(",
"element",
")",
";",
"options",
"=",
"this",
".",
"setOptions",
"(",
"options",
",",
... | Initialize the tab.
@param {jQuery} element
@param {Object} [options] | [
"Initialize",
"the",
"tab",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L6221-L6293 | train | |
titon/toolkit | dist/toolkit.js | function(tab) {
tab = $(tab);
var index = tab.data('tab-index'),
section = this.sections.eq(index),
options = this.options,
url = this.readValue(tab, this.readOption(tab, 'getUrl'));
this.fireEvent('showing', [this.index]);
// Load content for AJAX ... | javascript | function(tab) {
tab = $(tab);
var index = tab.data('tab-index'),
section = this.sections.eq(index),
options = this.options,
url = this.readValue(tab, this.readOption(tab, 'getUrl'));
this.fireEvent('showing', [this.index]);
// Load content for AJAX ... | [
"function",
"(",
"tab",
")",
"{",
"tab",
"=",
"$",
"(",
"tab",
")",
";",
"var",
"index",
"=",
"tab",
".",
"data",
"(",
"'tab-index'",
")",
",",
"section",
"=",
"this",
".",
"sections",
".",
"eq",
"(",
"index",
")",
",",
"options",
"=",
"this",
... | Show the content based on the tab. Can either pass an integer as the index in the collection,
or pass an element object for a tab in the collection.
@param {jQuery} tab | [
"Show",
"the",
"content",
"based",
"on",
"the",
"tab",
".",
"Can",
"either",
"pass",
"an",
"integer",
"as",
"the",
"index",
"in",
"the",
"collection",
"or",
"pass",
"an",
"element",
"object",
"for",
"a",
"tab",
"in",
"the",
"collection",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L6328-L6375 | train | |
titon/toolkit | dist/toolkit.js | function(e) {
if (this.options.preventDefault || e.currentTarget.getAttribute('href').substr(0, 1) !== '#') {
e.preventDefault();
}
this.show(e.currentTarget);
} | javascript | function(e) {
if (this.options.preventDefault || e.currentTarget.getAttribute('href').substr(0, 1) !== '#') {
e.preventDefault();
}
this.show(e.currentTarget);
} | [
"function",
"(",
"e",
")",
"{",
"if",
"(",
"this",
".",
"options",
".",
"preventDefault",
"||",
"e",
".",
"currentTarget",
".",
"getAttribute",
"(",
"'href'",
")",
".",
"substr",
"(",
"0",
",",
"1",
")",
"!==",
"'#'",
")",
"{",
"e",
".",
"preventDe... | Event callback for tab element click.
@private
@param {jQuery.Event} e | [
"Event",
"callback",
"for",
"tab",
"element",
"click",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L6420-L6426 | train | |
titon/toolkit | dist/toolkit.js | function(element, options) {
this.nodes = element = $(element); // Set to nodes so instances are unset during destroy()
options = this.setOptions(options, element);
// Create the toasts wrapper
this.createWrapper()
.addClass(options.position)
.attr('role', 'log')... | javascript | function(element, options) {
this.nodes = element = $(element); // Set to nodes so instances are unset during destroy()
options = this.setOptions(options, element);
// Create the toasts wrapper
this.createWrapper()
.addClass(options.position)
.attr('role', 'log')... | [
"function",
"(",
"element",
",",
"options",
")",
"{",
"this",
".",
"nodes",
"=",
"element",
"=",
"$",
"(",
"element",
")",
";",
"// Set to nodes so instances are unset during destroy()",
"options",
"=",
"this",
".",
"setOptions",
"(",
"options",
",",
"element",
... | Initialize the toast.
@param {jQuery} element
@param {Object} [options] | [
"Initialize",
"the",
"toast",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L6454-L6468 | train | |
titon/toolkit | dist/toolkit.js | function(content, options) {
options = $.extend({}, this.options, options || {});
var self = this,
toast = this.render(options.template)
.addClass(options.animation)
.attr('role', 'note')
.html(content)
.conceal()
... | javascript | function(content, options) {
options = $.extend({}, this.options, options || {});
var self = this,
toast = this.render(options.template)
.addClass(options.animation)
.attr('role', 'note')
.html(content)
.conceal()
... | [
"function",
"(",
"content",
",",
"options",
")",
"{",
"options",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"this",
".",
"options",
",",
"options",
"||",
"{",
"}",
")",
";",
"var",
"self",
"=",
"this",
",",
"toast",
"=",
"this",
".",
"render",
... | Create a toast element, insert content into it, and append it to the container.
@param {*} content
@param {Object} [options] | [
"Create",
"a",
"toast",
"element",
"insert",
"content",
"into",
"it",
"and",
"append",
"it",
"to",
"the",
"container",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L6476-L6500 | train | |
titon/toolkit | dist/toolkit.js | function(element) {
element = $(element);
// Pass the element since it gets removed
this.fireEvent('hiding', [element]);
element.transitionend(function() {
element.remove();
this.fireEvent('hidden');
}.bind(this)).conceal();
} | javascript | function(element) {
element = $(element);
// Pass the element since it gets removed
this.fireEvent('hiding', [element]);
element.transitionend(function() {
element.remove();
this.fireEvent('hidden');
}.bind(this)).conceal();
} | [
"function",
"(",
"element",
")",
"{",
"element",
"=",
"$",
"(",
"element",
")",
";",
"// Pass the element since it gets removed",
"this",
".",
"fireEvent",
"(",
"'hiding'",
",",
"[",
"element",
"]",
")",
";",
"element",
".",
"transitionend",
"(",
"function",
... | Hide the toast after the duration is up.
Also remove the element from the DOM once the transition is complete.
@param {jQuery} element | [
"Hide",
"the",
"toast",
"after",
"the",
"duration",
"is",
"up",
".",
"Also",
"remove",
"the",
"element",
"from",
"the",
"DOM",
"once",
"the",
"transition",
"is",
"complete",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L6508-L6518 | train | |
titon/toolkit | dist/toolkit.js | function(input, options) {
input = $(input);
if (input.prop('tagName').toLowerCase() !== 'input') {
throw new Error('TypeAhead must be initialized on an input field');
}
var self = this;
options = this.setOptions(options, input);
this.element = this.createE... | javascript | function(input, options) {
input = $(input);
if (input.prop('tagName').toLowerCase() !== 'input') {
throw new Error('TypeAhead must be initialized on an input field');
}
var self = this;
options = this.setOptions(options, input);
this.element = this.createE... | [
"function",
"(",
"input",
",",
"options",
")",
"{",
"input",
"=",
"$",
"(",
"input",
")",
";",
"if",
"(",
"input",
".",
"prop",
"(",
"'tagName'",
")",
".",
"toLowerCase",
"(",
")",
"!==",
"'input'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'TypeAhe... | Initialize the type ahead.
@param {jQuery} input
@param {Object} [options] | [
"Initialize",
"the",
"type",
"ahead",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L6582-L6668 | train | |
titon/toolkit | dist/toolkit.js | function(item) {
var a = $('<a/>', {
href: 'javascript:;',
role: 'option',
'aria-selected': 'false'
});
a.append( this.render(this.options.titleTemplate).html(this.highlight(item.title)) );
if (item.description) {
a.append( this.render(th... | javascript | function(item) {
var a = $('<a/>', {
href: 'javascript:;',
role: 'option',
'aria-selected': 'false'
});
a.append( this.render(this.options.titleTemplate).html(this.highlight(item.title)) );
if (item.description) {
a.append( this.render(th... | [
"function",
"(",
"item",
")",
"{",
"var",
"a",
"=",
"$",
"(",
"'<a/>'",
",",
"{",
"href",
":",
"'javascript:;'",
",",
"role",
":",
"'option'",
",",
"'aria-selected'",
":",
"'false'",
"}",
")",
";",
"a",
".",
"append",
"(",
"this",
".",
"render",
"(... | Build the anchor link that will be used in the list.
@param {Object} item
@returns {jQuery} | [
"Build",
"the",
"anchor",
"link",
"that",
"will",
"be",
"used",
"in",
"the",
"list",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L6686-L6700 | train | |
titon/toolkit | dist/toolkit.js | function() {
this.fireEvent('hiding');
if (this.shadow) {
this.shadow.val('');
}
this.input.aria('expanded', false);
this.element.conceal();
this.fireEvent('hidden');
} | javascript | function() {
this.fireEvent('hiding');
if (this.shadow) {
this.shadow.val('');
}
this.input.aria('expanded', false);
this.element.conceal();
this.fireEvent('hidden');
} | [
"function",
"(",
")",
"{",
"this",
".",
"fireEvent",
"(",
"'hiding'",
")",
";",
"if",
"(",
"this",
".",
"shadow",
")",
"{",
"this",
".",
"shadow",
".",
"val",
"(",
"''",
")",
";",
"}",
"this",
".",
"input",
".",
"aria",
"(",
"'expanded'",
",",
... | Hide the list and reset shadow. | [
"Hide",
"the",
"list",
"and",
"reset",
"shadow",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L6705-L6716 | train | |
titon/toolkit | dist/toolkit.js | function(item) {
var terms = this.term.replace(/[\-\[\]\{\}()*+?.,\\^$|#]/g, '\\$&').split(' '),
options = this.options,
callback = function(match) {
return this.render(options.highlightTemplate).html(match).toString();
}.bind(this);
for (var i = 0, t... | javascript | function(item) {
var terms = this.term.replace(/[\-\[\]\{\}()*+?.,\\^$|#]/g, '\\$&').split(' '),
options = this.options,
callback = function(match) {
return this.render(options.highlightTemplate).html(match).toString();
}.bind(this);
for (var i = 0, t... | [
"function",
"(",
"item",
")",
"{",
"var",
"terms",
"=",
"this",
".",
"term",
".",
"replace",
"(",
"/",
"[\\-\\[\\]\\{\\}()*+?.,\\\\^$|#]",
"/",
"g",
",",
"'\\\\$&'",
")",
".",
"split",
"(",
"' '",
")",
",",
"options",
"=",
"this",
".",
"options",
",",
... | Highlight the current term within the item string.
Split multi-word terms to highlight separately.
@param {String} item
@returns {String} | [
"Highlight",
"the",
"current",
"term",
"within",
"the",
"item",
"string",
".",
"Split",
"multi",
"-",
"word",
"terms",
"to",
"highlight",
"separately",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L6725-L6737 | train | |
titon/toolkit | dist/toolkit.js | function() {
if (!this.items.length) {
this.hide();
return;
}
this.fireEvent('showing');
var iPos = this.input.offset();
this.element
.css('top', iPos.top + this.input.outerHeight())
.css(Toolkit.isRTL ? 'right' : 'left', iPos.le... | javascript | function() {
if (!this.items.length) {
this.hide();
return;
}
this.fireEvent('showing');
var iPos = this.input.offset();
this.element
.css('top', iPos.top + this.input.outerHeight())
.css(Toolkit.isRTL ? 'right' : 'left', iPos.le... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"items",
".",
"length",
")",
"{",
"this",
".",
"hide",
"(",
")",
";",
"return",
";",
"}",
"this",
".",
"fireEvent",
"(",
"'showing'",
")",
";",
"var",
"iPos",
"=",
"this",
".",
"input",
".... | Position the menu below the input. | [
"Position",
"the",
"menu",
"below",
"the",
"input",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L6764-L6782 | train | |
titon/toolkit | dist/toolkit.js | function(index, event) {
this.index = index;
var rows = this.element.find('li');
rows
.removeClass('is-active')
.find('a')
.aria('selected', false);
// Select
if (index >= 0) {
if (this.items[index]) {
var ite... | javascript | function(index, event) {
this.index = index;
var rows = this.element.find('li');
rows
.removeClass('is-active')
.find('a')
.aria('selected', false);
// Select
if (index >= 0) {
if (this.items[index]) {
var ite... | [
"function",
"(",
"index",
",",
"event",
")",
"{",
"this",
".",
"index",
"=",
"index",
";",
"var",
"rows",
"=",
"this",
".",
"element",
".",
"find",
"(",
"'li'",
")",
";",
"rows",
".",
"removeClass",
"(",
"'is-active'",
")",
".",
"find",
"(",
"'a'",... | Select an item in the list.
@param {Number} index
@param {String} [event] | [
"Select",
"an",
"item",
"in",
"the",
"list",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L6798-L6829 | train | |
titon/toolkit | dist/toolkit.js | function(items) {
return items.sort(function(a, b) {
return a.title.localeCompare(b.title);
});
} | javascript | function(items) {
return items.sort(function(a, b) {
return a.title.localeCompare(b.title);
});
} | [
"function",
"(",
"items",
")",
"{",
"return",
"items",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"return",
"a",
".",
"title",
".",
"localeCompare",
"(",
"b",
".",
"title",
")",
";",
"}",
")",
";",
"}"
] | Sort the items.
@param {Array} items
@returns {Array} | [
"Sort",
"the",
"items",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L6837-L6841 | train | |
titon/toolkit | dist/toolkit.js | function(items) {
if (!this.term.length || !items.length) {
this.hide();
return;
}
var options = this.options,
term = this.term,
categories = { _empty_: [] },
item,
list = $('<ul/>');
// Reset
this.items = ... | javascript | function(items) {
if (!this.term.length || !items.length) {
this.hide();
return;
}
var options = this.options,
term = this.term,
categories = { _empty_: [] },
item,
list = $('<ul/>');
// Reset
this.items = ... | [
"function",
"(",
"items",
")",
"{",
"if",
"(",
"!",
"this",
".",
"term",
".",
"length",
"||",
"!",
"items",
".",
"length",
")",
"{",
"this",
".",
"hide",
"(",
")",
";",
"return",
";",
"}",
"var",
"options",
"=",
"this",
".",
"options",
",",
"te... | Process the list of items be generating new elements and positioning below the input.
@param {Array} items | [
"Process",
"the",
"list",
"of",
"items",
"be",
"generating",
"new",
"elements",
"and",
"positioning",
"below",
"the",
"input",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L6848-L6942 | train | |
titon/toolkit | dist/toolkit.js | function() {
if (!this.shadow) {
return;
}
var term = this.input.val(),
termLower = term.toLowerCase(),
value = '';
if (this.cache[termLower] && this.cache[termLower][0]) {
var title = this.cache[termLower][0].title;
if (titl... | javascript | function() {
if (!this.shadow) {
return;
}
var term = this.input.val(),
termLower = term.toLowerCase(),
value = '';
if (this.cache[termLower] && this.cache[termLower][0]) {
var title = this.cache[termLower][0].title;
if (titl... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"shadow",
")",
"{",
"return",
";",
"}",
"var",
"term",
"=",
"this",
".",
"input",
".",
"val",
"(",
")",
",",
"termLower",
"=",
"term",
".",
"toLowerCase",
"(",
")",
",",
"value",
"=",
"''"... | Monitor the current input term to determine the shadow text.
Shadow text will reference the term cache.
@private | [
"Monitor",
"the",
"current",
"input",
"term",
"to",
"determine",
"the",
"shadow",
"text",
".",
"Shadow",
"text",
"will",
"reference",
"the",
"term",
"cache",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L6950-L6968 | train | |
titon/toolkit | dist/toolkit.js | function(e) {
var items = this.items,
length = Math.min(this.options.itemLimit, Math.max(0, items.length)),
event = 'cycle';
if (!length || !this.element.is(':shown')) {
return;
}
switch (e.keyCode) {
// Cycle upwards (up)
cas... | javascript | function(e) {
var items = this.items,
length = Math.min(this.options.itemLimit, Math.max(0, items.length)),
event = 'cycle';
if (!length || !this.element.is(':shown')) {
return;
}
switch (e.keyCode) {
// Cycle upwards (up)
cas... | [
"function",
"(",
"e",
")",
"{",
"var",
"items",
"=",
"this",
".",
"items",
",",
"length",
"=",
"Math",
".",
"min",
"(",
"this",
".",
"options",
".",
"itemLimit",
",",
"Math",
".",
"max",
"(",
"0",
",",
"items",
".",
"length",
")",
")",
",",
"ev... | Cycle through the items in the list when an arrow key, esc or enter is released.
@private
@param {jQuery.Event} e | [
"Cycle",
"through",
"the",
"items",
"in",
"the",
"list",
"when",
"an",
"arrow",
"key",
"esc",
"or",
"enter",
"is",
"released",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L6976-L7044 | train | |
titon/toolkit | dist/toolkit.js | function() {
var term = this.term,
options = this.options,
sourceType = $.type(options.source);
// Check the cache first
if (this.cache[term.toLowerCase()]) {
this.source(this.cache[term.toLowerCase()]);
// Use the response of an AJAX request
... | javascript | function() {
var term = this.term,
options = this.options,
sourceType = $.type(options.source);
// Check the cache first
if (this.cache[term.toLowerCase()]) {
this.source(this.cache[term.toLowerCase()]);
// Use the response of an AJAX request
... | [
"function",
"(",
")",
"{",
"var",
"term",
"=",
"this",
".",
"term",
",",
"options",
"=",
"this",
".",
"options",
",",
"sourceType",
"=",
"$",
".",
"type",
"(",
"options",
".",
"source",
")",
";",
"// Check the cache first",
"if",
"(",
"this",
".",
"c... | Event handler called for a lookup. | [
"Event",
"handler",
"called",
"for",
"a",
"lookup",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L7049-L7086 | train | |
titon/toolkit | dist/toolkit.js | function(e) {
if ($.inArray(e.keyCode, [38, 40, 27, 9, 13]) >= 0) {
return; // Handle with onCycle()
}
clearTimeout(this.timer);
var term = this.input.val().trim();
if (term.length < this.options.minLength) {
this.fireEvent('reset');
this.hi... | javascript | function(e) {
if ($.inArray(e.keyCode, [38, 40, 27, 9, 13]) >= 0) {
return; // Handle with onCycle()
}
clearTimeout(this.timer);
var term = this.input.val().trim();
if (term.length < this.options.minLength) {
this.fireEvent('reset');
this.hi... | [
"function",
"(",
"e",
")",
"{",
"if",
"(",
"$",
".",
"inArray",
"(",
"e",
".",
"keyCode",
",",
"[",
"38",
",",
"40",
",",
"27",
",",
"9",
",",
"13",
"]",
")",
">=",
"0",
")",
"{",
"return",
";",
"// Handle with onCycle()",
"}",
"clearTimeout",
... | Lookup items based on the current input value.
@private
@param {jQuery.Event} e | [
"Lookup",
"items",
"based",
"on",
"the",
"current",
"input",
"value",
"."
] | f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c | https://github.com/titon/toolkit/blob/f0ed36d14cc6d72a7bdbc09da4b5bf7d3d664f0c/dist/toolkit.js#L7094-L7111 | train | |
w8r/avl | src/utils.js | height | function height(node) {
return node ? (1 + Math.max(height(node.left), height(node.right))) : 0;
} | javascript | function height(node) {
return node ? (1 + Math.max(height(node.left), height(node.right))) : 0;
} | [
"function",
"height",
"(",
"node",
")",
"{",
"return",
"node",
"?",
"(",
"1",
"+",
"Math",
".",
"max",
"(",
"height",
"(",
"node",
".",
"left",
")",
",",
"height",
"(",
"node",
".",
"right",
")",
")",
")",
":",
"0",
";",
"}"
] | The function Compute the 'height' of a tree.
Height is the number of nodes along the longest path
from the root node down to the farthest leaf node.
@param {Node} node
@return {Number} | [
"The",
"function",
"Compute",
"the",
"height",
"of",
"a",
"tree",
".",
"Height",
"is",
"the",
"number",
"of",
"nodes",
"along",
"the",
"longest",
"path",
"from",
"the",
"root",
"node",
"down",
"to",
"the",
"farthest",
"leaf",
"node",
"."
] | 601107b38287449aeb01bb7e6da712ac3d0f0c2f | https://github.com/w8r/avl/blob/601107b38287449aeb01bb7e6da712ac3d0f0c2f/src/utils.js#L60-L62 | train |
w8r/avl | src/index.js | rotateLeft | function rotateLeft (node) {
var rightNode = node.right;
node.right = rightNode.left;
if (rightNode.left) rightNode.left.parent = node;
rightNode.parent = node.parent;
if (rightNode.parent) {
if (rightNode.parent.left === node) {
rightNode.parent.left = rightNode;
} else {
rightNode.p... | javascript | function rotateLeft (node) {
var rightNode = node.right;
node.right = rightNode.left;
if (rightNode.left) rightNode.left.parent = node;
rightNode.parent = node.parent;
if (rightNode.parent) {
if (rightNode.parent.left === node) {
rightNode.parent.left = rightNode;
} else {
rightNode.p... | [
"function",
"rotateLeft",
"(",
"node",
")",
"{",
"var",
"rightNode",
"=",
"node",
".",
"right",
";",
"node",
".",
"right",
"=",
"rightNode",
".",
"left",
";",
"if",
"(",
"rightNode",
".",
"left",
")",
"rightNode",
".",
"left",
".",
"parent",
"=",
"no... | Single left rotation
@param {Node} node
@return {Node} | [
"Single",
"left",
"rotation"
] | 601107b38287449aeb01bb7e6da712ac3d0f0c2f | https://github.com/w8r/avl/blob/601107b38287449aeb01bb7e6da712ac3d0f0c2f/src/index.js#L41-L69 | train |
Orbs/jspm-git | git.js | function(repo, version, hash, meta, outDir) {
var url, tempRepoDir, packageJSONData, self = this;
if (meta.vPrefix) {
version = 'v' + version;
}
// Automatically track and cleanup files at exit
temp.track();
url = createGitUrl(self.options.baseurl, repo, self.options.reposuffix, self.a... | javascript | function(repo, version, hash, meta, outDir) {
var url, tempRepoDir, packageJSONData, self = this;
if (meta.vPrefix) {
version = 'v' + version;
}
// Automatically track and cleanup files at exit
temp.track();
url = createGitUrl(self.options.baseurl, repo, self.options.reposuffix, self.a... | [
"function",
"(",
"repo",
",",
"version",
",",
"hash",
",",
"meta",
",",
"outDir",
")",
"{",
"var",
"url",
",",
"tempRepoDir",
",",
"packageJSONData",
",",
"self",
"=",
"this",
";",
"if",
"(",
"meta",
".",
"vPrefix",
")",
"{",
"version",
"=",
"'v'",
... | always an exact version assumed that this is run after getVersions so the repo exists | [
"always",
"an",
"exact",
"version",
"assumed",
"that",
"this",
"is",
"run",
"after",
"getVersions",
"so",
"the",
"repo",
"exists"
] | 92c8c81835af17970f989dd9083ed2105c24ed69 | https://github.com/Orbs/jspm-git/blob/92c8c81835af17970f989dd9083ed2105c24ed69/git.js#L450-L474 | train | |
Orbs/jspm-git | git.js | function(pjson, dir) {
var main = pjson.main || '';
var libDir = pjson.directories && (pjson.directories.dist || pjson.directories.lib) || '.';
// convert to windows-style paths if necessary
main = path.normalize(main);
libDir = path.normalize(libDir);
if (main.indexOf('!') !== -1) {
ret... | javascript | function(pjson, dir) {
var main = pjson.main || '';
var libDir = pjson.directories && (pjson.directories.dist || pjson.directories.lib) || '.';
// convert to windows-style paths if necessary
main = path.normalize(main);
libDir = path.normalize(libDir);
if (main.indexOf('!') !== -1) {
ret... | [
"function",
"(",
"pjson",
",",
"dir",
")",
"{",
"var",
"main",
"=",
"pjson",
".",
"main",
"||",
"''",
";",
"var",
"libDir",
"=",
"pjson",
".",
"directories",
"&&",
"(",
"pjson",
".",
"directories",
".",
"dist",
"||",
"pjson",
".",
"directories",
".",... | check if the main entry point exists. If not, try the bower.json main. | [
"check",
"if",
"the",
"main",
"entry",
"point",
"exists",
".",
"If",
"not",
"try",
"the",
"bower",
".",
"json",
"main",
"."
] | 92c8c81835af17970f989dd9083ed2105c24ed69 | https://github.com/Orbs/jspm-git/blob/92c8c81835af17970f989dd9083ed2105c24ed69/git.js#L477-L534 | train | |
opentok/accelerator-screen-sharing-js | src/opentok-screen-sharing.js | function () {
var createPublisher = function (publisherDiv) {
var innerDeferred = $.Deferred();
var getContainer = function () {
if (publisherDiv) { return publisherDiv; }
if (typeof _this.screenSharingContainer === 'function') {
return document.querySelector(_this.screenSha... | javascript | function () {
var createPublisher = function (publisherDiv) {
var innerDeferred = $.Deferred();
var getContainer = function () {
if (publisherDiv) { return publisherDiv; }
if (typeof _this.screenSharingContainer === 'function') {
return document.querySelector(_this.screenSha... | [
"function",
"(",
")",
"{",
"var",
"createPublisher",
"=",
"function",
"(",
"publisherDiv",
")",
"{",
"var",
"innerDeferred",
"=",
"$",
".",
"Deferred",
"(",
")",
";",
"var",
"getContainer",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"publisherDiv",
")",
... | Create a publisher for the screen. If we're using annotation, we first need
to create the annotion window and get a reference to its annotation container
element so that we can pass it to the initPublisher function.
@returns {promise} < Resolve: [Object] Container element for annotation in external window > | [
"Create",
"a",
"publisher",
"for",
"the",
"screen",
".",
"If",
"we",
"re",
"using",
"annotation",
"we",
"first",
"need",
"to",
"create",
"the",
"annotion",
"window",
"and",
"get",
"a",
"reference",
"to",
"its",
"annotation",
"container",
"element",
"so",
"... | cfa1b55525ed193ea1dd5caa4ba5c0eb4a902bf7 | https://github.com/opentok/accelerator-screen-sharing-js/blob/cfa1b55525ed193ea1dd5caa4ba5c0eb4a902bf7/src/opentok-screen-sharing.js#L160-L223 | train | |
opentok/accelerator-screen-sharing-js | src/opentok-screen-sharing.js | function (annotationContainer) {
_session.publish(_this.publisher, function (error) {
if (error) {
// Let's write our own error message
var customError = _.omit(error, 'message');
if (error.code === 1500 && navigator.userAgent.indexOf('Firefox') !== -1) {
$('#dialog-form-f... | javascript | function (annotationContainer) {
_session.publish(_this.publisher, function (error) {
if (error) {
// Let's write our own error message
var customError = _.omit(error, 'message');
if (error.code === 1500 && navigator.userAgent.indexOf('Firefox') !== -1) {
$('#dialog-form-f... | [
"function",
"(",
"annotationContainer",
")",
"{",
"_session",
".",
"publish",
"(",
"_this",
".",
"publisher",
",",
"function",
"(",
"error",
")",
"{",
"if",
"(",
"error",
")",
"{",
"// Let's write our own error message",
"var",
"customError",
"=",
"_",
".",
... | Start publishing the screen
@param annotationContainer | [
"Start",
"publishing",
"the",
"screen"
] | cfa1b55525ed193ea1dd5caa4ba5c0eb4a902bf7 | https://github.com/opentok/accelerator-screen-sharing-js/blob/cfa1b55525ed193ea1dd5caa4ba5c0eb4a902bf7/src/opentok-screen-sharing.js#L230-L265 | train | |
rain1017/quick-pomelo | template/app.js | function(){
if(Object.keys(app.getServers()).length === 0){
quick.logger.shutdown(shutdown);
}
else{
setTimeout(tryShutdown, 200);
}
} | javascript | function(){
if(Object.keys(app.getServers()).length === 0){
quick.logger.shutdown(shutdown);
}
else{
setTimeout(tryShutdown, 200);
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"Object",
".",
"keys",
"(",
"app",
".",
"getServers",
"(",
")",
")",
".",
"length",
"===",
"0",
")",
"{",
"quick",
".",
"logger",
".",
"shutdown",
"(",
"shutdown",
")",
";",
"}",
"else",
"{",
"setTimeout",
"(... | Wait for all server stop | [
"Wait",
"for",
"all",
"server",
"stop"
] | 3d2c83d81ab190e99a3ab8f64385aa29f44c5383 | https://github.com/rain1017/quick-pomelo/blob/3d2c83d81ab190e99a3ab8f64385aa29f44c5383/template/app.js#L82-L89 | train | |
MariusRumpf/node-lifx | lib/lifx/light.js | Light | function Light(constr) {
this.client = constr.client;
this.id = constr.id; // Used to target the light
this.address = constr.address;
this.port = constr.port;
this.label = null;
this.status = 'on';
this.seenOnDiscovery = constr.seenOnDiscovery;
} | javascript | function Light(constr) {
this.client = constr.client;
this.id = constr.id; // Used to target the light
this.address = constr.address;
this.port = constr.port;
this.label = null;
this.status = 'on';
this.seenOnDiscovery = constr.seenOnDiscovery;
} | [
"function",
"Light",
"(",
"constr",
")",
"{",
"this",
".",
"client",
"=",
"constr",
".",
"client",
";",
"this",
".",
"id",
"=",
"constr",
".",
"id",
";",
"// Used to target the light",
"this",
".",
"address",
"=",
"constr",
".",
"address",
";",
"this",
... | A representation of a light bulb
@class
@param {Obj} constr constructor object
@param {Lifx/Client} constr.client the client the light belongs to
@param {String} constr.id the id used to target the light
@param {String} constr.address ip address of the light
@param {Number} constr.port port of the light
@param {Number}... | [
"A",
"representation",
"of",
"a",
"light",
"bulb"
] | c5bb37309895f7e8aa86eda69c4ed8a72f6fedf1 | https://github.com/MariusRumpf/node-lifx/blob/c5bb37309895f7e8aa86eda69c4ed8a72f6fedf1/lib/lifx/light.js#L18-L27 | train |
MariusRumpf/node-lifx | lib/lifx/client.js | Client | function Client() {
EventEmitter.call(this);
this.debug = false;
this.socket = dgram.createSocket('udp4');
this.isSocketBound = false;
this.devices = {};
this.port = null;
this.messagesQueue = [];
this.sendTimer = null;
this.discoveryTimer = null;
this.discoveryPacketSequence = 0;
this.messageHan... | javascript | function Client() {
EventEmitter.call(this);
this.debug = false;
this.socket = dgram.createSocket('udp4');
this.isSocketBound = false;
this.devices = {};
this.port = null;
this.messagesQueue = [];
this.sendTimer = null;
this.discoveryTimer = null;
this.discoveryPacketSequence = 0;
this.messageHan... | [
"function",
"Client",
"(",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"debug",
"=",
"false",
";",
"this",
".",
"socket",
"=",
"dgram",
".",
"createSocket",
"(",
"'udp4'",
")",
";",
"this",
".",
"isSocketBound",
"=",
"f... | Creates a lifx client
@extends EventEmitter | [
"Creates",
"a",
"lifx",
"client"
] | c5bb37309895f7e8aa86eda69c4ed8a72f6fedf1 | https://github.com/MariusRumpf/node-lifx/blob/c5bb37309895f7e8aa86eda69c4ed8a72f6fedf1/lib/lifx/client.js#L16-L45 | train |
samclarke/robots-parser | Robots.js | trimLine | function trimLine(line) {
if (!line) {
return null;
}
if (Array.isArray(line)) {
return line.map(trimLine);
}
return String(line).trim();
} | javascript | function trimLine(line) {
if (!line) {
return null;
}
if (Array.isArray(line)) {
return line.map(trimLine);
}
return String(line).trim();
} | [
"function",
"trimLine",
"(",
"line",
")",
"{",
"if",
"(",
"!",
"line",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"Array",
".",
"isArray",
"(",
"line",
")",
")",
"{",
"return",
"line",
".",
"map",
"(",
"trimLine",
")",
";",
"}",
"return",
... | Trims the white space from the start and end of the line.
If the line is an array it will strip the white space from
the start and end of each element of the array.
@param {string|Array} line
@return {string|Array}
@private | [
"Trims",
"the",
"white",
"space",
"from",
"the",
"start",
"and",
"end",
"of",
"the",
"line",
"."
] | 888df9e4d820c36d57191ad7ca6b37218051ea65 | https://github.com/samclarke/robots-parser/blob/888df9e4d820c36d57191ad7ca6b37218051ea65/Robots.js#L13-L23 | train |
samclarke/robots-parser | Robots.js | removeComments | function removeComments(line) {
var commentStartIndex = line.indexOf('#');
if (commentStartIndex > -1) {
return line.substr(0, commentStartIndex);
}
return line;
} | javascript | function removeComments(line) {
var commentStartIndex = line.indexOf('#');
if (commentStartIndex > -1) {
return line.substr(0, commentStartIndex);
}
return line;
} | [
"function",
"removeComments",
"(",
"line",
")",
"{",
"var",
"commentStartIndex",
"=",
"line",
".",
"indexOf",
"(",
"'#'",
")",
";",
"if",
"(",
"commentStartIndex",
">",
"-",
"1",
")",
"{",
"return",
"line",
".",
"substr",
"(",
"0",
",",
"commentStartInde... | Remove comments from lines
@param {string} line
@return {string}
@private | [
"Remove",
"comments",
"from",
"lines"
] | 888df9e4d820c36d57191ad7ca6b37218051ea65 | https://github.com/samclarke/robots-parser/blob/888df9e4d820c36d57191ad7ca6b37218051ea65/Robots.js#L32-L39 | train |
samclarke/robots-parser | Robots.js | formatUserAgent | function formatUserAgent(userAgent) {
var formattedUserAgent = userAgent.toLowerCase();
// Strip the version number from robot/1.0 user agents
var idx = formattedUserAgent.indexOf('/');
if (idx > -1) {
formattedUserAgent = formattedUserAgent.substr(0, idx);
}
return formattedUserAgent.trim();
} | javascript | function formatUserAgent(userAgent) {
var formattedUserAgent = userAgent.toLowerCase();
// Strip the version number from robot/1.0 user agents
var idx = formattedUserAgent.indexOf('/');
if (idx > -1) {
formattedUserAgent = formattedUserAgent.substr(0, idx);
}
return formattedUserAgent.trim();
} | [
"function",
"formatUserAgent",
"(",
"userAgent",
")",
"{",
"var",
"formattedUserAgent",
"=",
"userAgent",
".",
"toLowerCase",
"(",
")",
";",
"// Strip the version number from robot/1.0 user agents",
"var",
"idx",
"=",
"formattedUserAgent",
".",
"indexOf",
"(",
"'/'",
... | Normalises the user-agent string by converting it to
lower case and removing any version numbers.
@param {string} userAgent
@return {string}
@private | [
"Normalises",
"the",
"user",
"-",
"agent",
"string",
"by",
"converting",
"it",
"to",
"lower",
"case",
"and",
"removing",
"any",
"version",
"numbers",
"."
] | 888df9e4d820c36d57191ad7ca6b37218051ea65 | https://github.com/samclarke/robots-parser/blob/888df9e4d820c36d57191ad7ca6b37218051ea65/Robots.js#L66-L76 | train |
samclarke/robots-parser | Robots.js | parsePattern | function parsePattern(pattern) {
var regexSpecialChars = /[\-\[\]\/\{\}\(\)\+\?\.\\\^\$\|]/g;
// Treat consecutive wildcards as one (#12)
var wildCardPattern = /\*+/g;
var endOfLinePattern = /\\\$$/;
pattern = normaliseEncoding(pattern)
if (pattern.indexOf('*') < 0 && pattern.indexOf('$') < 0) {
return patter... | javascript | function parsePattern(pattern) {
var regexSpecialChars = /[\-\[\]\/\{\}\(\)\+\?\.\\\^\$\|]/g;
// Treat consecutive wildcards as one (#12)
var wildCardPattern = /\*+/g;
var endOfLinePattern = /\\\$$/;
pattern = normaliseEncoding(pattern)
if (pattern.indexOf('*') < 0 && pattern.indexOf('$') < 0) {
return patter... | [
"function",
"parsePattern",
"(",
"pattern",
")",
"{",
"var",
"regexSpecialChars",
"=",
"/",
"[\\-\\[\\]\\/\\{\\}\\(\\)\\+\\?\\.\\\\\\^\\$\\|]",
"/",
"g",
";",
"// Treat consecutive wildcards as one (#12)",
"var",
"wildCardPattern",
"=",
"/",
"\\*+",
"/",
"g",
";",
"var"... | Converts the pattern into a regexp if it is a wildcard
pattern.
Returns a string if the pattern isn't a wildcard pattern
@param {string} pattern
@return {string|RegExp}
@private | [
"Converts",
"the",
"pattern",
"into",
"a",
"regexp",
"if",
"it",
"is",
"a",
"wildcard",
"pattern",
"."
] | 888df9e4d820c36d57191ad7ca6b37218051ea65 | https://github.com/samclarke/robots-parser/blob/888df9e4d820c36d57191ad7ca6b37218051ea65/Robots.js#L119-L137 | train |
samclarke/robots-parser | Robots.js | findRule | function findRule(path, rules) {
var matchingRule = null;
for (var i=0; i < rules.length; i++) {
var rule = rules[i];
if (typeof rule.pattern === 'string') {
if (path.indexOf(rule.pattern) !== 0) {
continue;
}
// The longest matching rule takes precedence
if (!matchingRule || ... | javascript | function findRule(path, rules) {
var matchingRule = null;
for (var i=0; i < rules.length; i++) {
var rule = rules[i];
if (typeof rule.pattern === 'string') {
if (path.indexOf(rule.pattern) !== 0) {
continue;
}
// The longest matching rule takes precedence
if (!matchingRule || ... | [
"function",
"findRule",
"(",
"path",
",",
"rules",
")",
"{",
"var",
"matchingRule",
"=",
"null",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"rules",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"rule",
"=",
"rules",
"[",
"i",
"]",... | Returns if a pattern is allowed by the specified rules.
@param {string} path
@param {Array.<Object>} rules
@return {Object?}
@private | [
"Returns",
"if",
"a",
"pattern",
"is",
"allowed",
"by",
"the",
"specified",
"rules",
"."
] | 888df9e4d820c36d57191ad7ca6b37218051ea65 | https://github.com/samclarke/robots-parser/blob/888df9e4d820c36d57191ad7ca6b37218051ea65/Robots.js#L199-L222 | train |
SpoonX/aurelia-orm | dist/aurelia-orm.js | asJson | function asJson(entity, shallow) {
let json;
try {
json = JSON.stringify(asObject(entity, shallow));
} catch (error) {
json = '';
}
return json;
} | javascript | function asJson(entity, shallow) {
let json;
try {
json = JSON.stringify(asObject(entity, shallow));
} catch (error) {
json = '';
}
return json;
} | [
"function",
"asJson",
"(",
"entity",
",",
"shallow",
")",
"{",
"let",
"json",
";",
"try",
"{",
"json",
"=",
"JSON",
".",
"stringify",
"(",
"asObject",
"(",
"entity",
",",
"shallow",
")",
")",
";",
"}",
"catch",
"(",
"error",
")",
"{",
"json",
"=",
... | Entity representation as json
@param {Entity} entity
@param {boolean} [shallow]
@return {string} | [
"Entity",
"representation",
"as",
"json"
] | d6b5dece74e1f44038de917c38fadb57d6655c18 | https://github.com/SpoonX/aurelia-orm/blob/d6b5dece74e1f44038de917c38fadb57d6655c18/dist/aurelia-orm.js#L1112-L1122 | train |
SpoonX/aurelia-orm | dist/aurelia-orm.js | getFlat | function getFlat(entity, json) {
let flat = {
entity : asObject(entity, true),
collections: getCollectionsCompact(entity)
};
if (json) {
flat = JSON.stringify(flat);
}
return flat;
} | javascript | function getFlat(entity, json) {
let flat = {
entity : asObject(entity, true),
collections: getCollectionsCompact(entity)
};
if (json) {
flat = JSON.stringify(flat);
}
return flat;
} | [
"function",
"getFlat",
"(",
"entity",
",",
"json",
")",
"{",
"let",
"flat",
"=",
"{",
"entity",
":",
"asObject",
"(",
"entity",
",",
"true",
")",
",",
"collections",
":",
"getCollectionsCompact",
"(",
"entity",
")",
"}",
";",
"if",
"(",
"json",
")",
... | Get a flat, plain representation of the entity and its associations.
@param {Entity} entity
@param {boolean} [json]
@return {{}} {entity, collections} | [
"Get",
"a",
"flat",
"plain",
"representation",
"of",
"the",
"entity",
"and",
"its",
"associations",
"."
] | d6b5dece74e1f44038de917c38fadb57d6655c18 | https://github.com/SpoonX/aurelia-orm/blob/d6b5dece74e1f44038de917c38fadb57d6655c18/dist/aurelia-orm.js#L1184-L1195 | train |
SpoonX/aurelia-orm | dist/aurelia-orm.js | getPropertyForAssociation | function getPropertyForAssociation(forEntity, entity) {
let associations = forEntity.getMeta().fetch('associations');
return Object.keys(associations).filter(key => {
return associations[key].entity === entity.getResource();
})[0];
} | javascript | function getPropertyForAssociation(forEntity, entity) {
let associations = forEntity.getMeta().fetch('associations');
return Object.keys(associations).filter(key => {
return associations[key].entity === entity.getResource();
})[0];
} | [
"function",
"getPropertyForAssociation",
"(",
"forEntity",
",",
"entity",
")",
"{",
"let",
"associations",
"=",
"forEntity",
".",
"getMeta",
"(",
")",
".",
"fetch",
"(",
"'associations'",
")",
";",
"return",
"Object",
".",
"keys",
"(",
"associations",
")",
"... | Get the property of the association on this entity.
@param {Entity} forEntity
@param {Entity} entity
@return {string} | [
"Get",
"the",
"property",
"of",
"the",
"association",
"on",
"this",
"entity",
"."
] | d6b5dece74e1f44038de917c38fadb57d6655c18 | https://github.com/SpoonX/aurelia-orm/blob/d6b5dece74e1f44038de917c38fadb57d6655c18/dist/aurelia-orm.js#L1205-L1211 | train |
hoodiehq/hoodie-client | lib/events.js | trigger | function trigger (state, eventName) {
var args = [].slice.call(arguments, 1)
state.emitter.emit.apply(state.emitter, args)
return this
} | javascript | function trigger (state, eventName) {
var args = [].slice.call(arguments, 1)
state.emitter.emit.apply(state.emitter, args)
return this
} | [
"function",
"trigger",
"(",
"state",
",",
"eventName",
")",
"{",
"var",
"args",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
"state",
".",
"emitter",
".",
"emit",
".",
"apply",
"(",
"state",
".",
"emitter",
",",
"args"... | trigger a specified event
@param {String} eventName Name of event
@param {...*} [options] Options | [
"trigger",
"a",
"specified",
"event"
] | e9ceb07e01da0d0a0136fd28b413a8e4fac5ea2b | https://github.com/hoodiehq/hoodie-client/blob/e9ceb07e01da0d0a0136fd28b413a8e4fac5ea2b/lib/events.js#L54-L60 | train |
jhermsmeier/node-vcf | lib/vcard.js | function( key ) {
if( this.data[ key ] == null ) {
return this.data[ key ]
}
if( Array.isArray( this.data[ key ] ) ) {
return this.data[ key ].map( function( prop ) {
return prop.clone()
})
} else {
return this.data[ key ].clone()
}
} | javascript | function( key ) {
if( this.data[ key ] == null ) {
return this.data[ key ]
}
if( Array.isArray( this.data[ key ] ) ) {
return this.data[ key ].map( function( prop ) {
return prop.clone()
})
} else {
return this.data[ key ].clone()
}
} | [
"function",
"(",
"key",
")",
"{",
"if",
"(",
"this",
".",
"data",
"[",
"key",
"]",
"==",
"null",
")",
"{",
"return",
"this",
".",
"data",
"[",
"key",
"]",
"}",
"if",
"(",
"Array",
".",
"isArray",
"(",
"this",
".",
"data",
"[",
"key",
"]",
")"... | Get a vCard property
@param {String} key
@return {Object|Array} | [
"Get",
"a",
"vCard",
"property"
] | e0a984fb294fb2b76f0e6bba009357f15195b92d | https://github.com/jhermsmeier/node-vcf/blob/e0a984fb294fb2b76f0e6bba009357f15195b92d/lib/vcard.js#L179-L193 | train | |
jhermsmeier/node-vcf | lib/vcard.js | function( key, value, params ) {
var prop = new vCard.Property( key, value, params )
this.addProperty( prop )
return this
} | javascript | function( key, value, params ) {
var prop = new vCard.Property( key, value, params )
this.addProperty( prop )
return this
} | [
"function",
"(",
"key",
",",
"value",
",",
"params",
")",
"{",
"var",
"prop",
"=",
"new",
"vCard",
".",
"Property",
"(",
"key",
",",
"value",
",",
"params",
")",
"this",
".",
"addProperty",
"(",
"prop",
")",
"return",
"this",
"}"
] | Add a vCard property
@param {String} key
@param {String} value
@param {Object} params | [
"Add",
"a",
"vCard",
"property"
] | e0a984fb294fb2b76f0e6bba009357f15195b92d | https://github.com/jhermsmeier/node-vcf/blob/e0a984fb294fb2b76f0e6bba009357f15195b92d/lib/vcard.js#L211-L215 | train | |
jhermsmeier/node-vcf | lib/vcard.js | function( prop ) {
var key = prop._field
if( Array.isArray( this.data[ key ] ) ) {
this.data[ key ].push( prop )
} else if( this.data[ key ] != null ) {
this.data[ key ] = [ this.data[ key ], prop ]
} else {
this.data[ key ] = prop
}
return this
} | javascript | function( prop ) {
var key = prop._field
if( Array.isArray( this.data[ key ] ) ) {
this.data[ key ].push( prop )
} else if( this.data[ key ] != null ) {
this.data[ key ] = [ this.data[ key ], prop ]
} else {
this.data[ key ] = prop
}
return this
} | [
"function",
"(",
"prop",
")",
"{",
"var",
"key",
"=",
"prop",
".",
"_field",
"if",
"(",
"Array",
".",
"isArray",
"(",
"this",
".",
"data",
"[",
"key",
"]",
")",
")",
"{",
"this",
".",
"data",
"[",
"key",
"]",
".",
"push",
"(",
"prop",
")",
"}... | Add a vCard property from an already
constructed vCard.Property
@param {vCard.Property} prop | [
"Add",
"a",
"vCard",
"property",
"from",
"an",
"already",
"constructed",
"vCard",
".",
"Property"
] | e0a984fb294fb2b76f0e6bba009357f15195b92d | https://github.com/jhermsmeier/node-vcf/blob/e0a984fb294fb2b76f0e6bba009357f15195b92d/lib/vcard.js#L232-L246 | train | |
jhermsmeier/node-vcf | lib/vcard.js | function( value ) {
// Normalize & split
var lines = vCard.normalize( value )
.split( /\r?\n/g )
// Keep begin and end markers
// for eventual error messages
var begin = lines[0]
var version = lines[1]
var end = lines[ lines.length - 1 ]
if( !/BEGIN:VCARD/i.test( begin ) )
... | javascript | function( value ) {
// Normalize & split
var lines = vCard.normalize( value )
.split( /\r?\n/g )
// Keep begin and end markers
// for eventual error messages
var begin = lines[0]
var version = lines[1]
var end = lines[ lines.length - 1 ]
if( !/BEGIN:VCARD/i.test( begin ) )
... | [
"function",
"(",
"value",
")",
"{",
"// Normalize & split",
"var",
"lines",
"=",
"vCard",
".",
"normalize",
"(",
"value",
")",
".",
"split",
"(",
"/",
"\\r?\\n",
"/",
"g",
")",
"// Keep begin and end markers",
"// for eventual error messages",
"var",
"begin",
"=... | Parse a vcf formatted vCard
@param {String} value
@return {vCard} | [
"Parse",
"a",
"vcf",
"formatted",
"vCard"
] | e0a984fb294fb2b76f0e6bba009357f15195b92d | https://github.com/jhermsmeier/node-vcf/blob/e0a984fb294fb2b76f0e6bba009357f15195b92d/lib/vcard.js#L253-L284 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.