id
int32 0
58k
| repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
sequence | docstring
stringlengths 4
11.8k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 86
226
|
---|---|---|---|---|---|---|---|---|---|---|---|
6,600 | imba/imba | lib/jison/jison.js | addSymbol | function addSymbol (s) {
if (s && !symbols_[s]) {
symbols_[s] = ++symbolId;
symbols.push(s);
}
} | javascript | function addSymbol (s) {
if (s && !symbols_[s]) {
symbols_[s] = ++symbolId;
symbols.push(s);
}
} | [
"function",
"addSymbol",
"(",
"s",
")",
"{",
"if",
"(",
"s",
"&&",
"!",
"symbols_",
"[",
"s",
"]",
")",
"{",
"symbols_",
"[",
"s",
"]",
"=",
"++",
"symbolId",
";",
"symbols",
".",
"push",
"(",
"s",
")",
";",
"}",
"}"
] | has error recovery | [
"has",
"error",
"recovery"
] | cbf24f7ba961c33c105a8fd5a9fff18286d119bb | https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/jison/jison.js#L191-L196 |
6,601 | imba/imba | lib/jison/jison.js | tokenStackLex | function tokenStackLex() {
var token;
token = tstack.pop() || lexer.lex() || EOF;
// if token isn't its numeric value, convert
if (typeof token !== 'number') {
if (token instanceof Array) {
tstack = token;
token = tstack.pop();
}
token = self.symbols_[token] || token;
}
return token;
} | javascript | function tokenStackLex() {
var token;
token = tstack.pop() || lexer.lex() || EOF;
// if token isn't its numeric value, convert
if (typeof token !== 'number') {
if (token instanceof Array) {
tstack = token;
token = tstack.pop();
}
token = self.symbols_[token] || token;
}
return token;
} | [
"function",
"tokenStackLex",
"(",
")",
"{",
"var",
"token",
";",
"token",
"=",
"tstack",
".",
"pop",
"(",
")",
"||",
"lexer",
".",
"lex",
"(",
")",
"||",
"EOF",
";",
"// if token isn't its numeric value, convert",
"if",
"(",
"typeof",
"token",
"!==",
"'number'",
")",
"{",
"if",
"(",
"token",
"instanceof",
"Array",
")",
"{",
"tstack",
"=",
"token",
";",
"token",
"=",
"tstack",
".",
"pop",
"(",
")",
";",
"}",
"token",
"=",
"self",
".",
"symbols_",
"[",
"token",
"]",
"||",
"token",
";",
"}",
"return",
"token",
";",
"}"
] | lex function that supports token stacks | [
"lex",
"function",
"that",
"supports",
"token",
"stacks"
] | cbf24f7ba961c33c105a8fd5a9fff18286d119bb | https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/jison/jison.js#L1002-L1014 |
6,602 | imba/imba | lib/jison/jison.js | createVariable | function createVariable() {
var id = nextVariableId++;
var name = '$V';
do {
name += variableTokens[id % variableTokensLength];
id = ~~(id / variableTokensLength);
} while (id !== 0);
return name;
} | javascript | function createVariable() {
var id = nextVariableId++;
var name = '$V';
do {
name += variableTokens[id % variableTokensLength];
id = ~~(id / variableTokensLength);
} while (id !== 0);
return name;
} | [
"function",
"createVariable",
"(",
")",
"{",
"var",
"id",
"=",
"nextVariableId",
"++",
";",
"var",
"name",
"=",
"'$V'",
";",
"do",
"{",
"name",
"+=",
"variableTokens",
"[",
"id",
"%",
"variableTokensLength",
"]",
";",
"id",
"=",
"~",
"~",
"(",
"id",
"/",
"variableTokensLength",
")",
";",
"}",
"while",
"(",
"id",
"!==",
"0",
")",
";",
"return",
"name",
";",
"}"
] | Creates a variable with a unique name | [
"Creates",
"a",
"variable",
"with",
"a",
"unique",
"name"
] | cbf24f7ba961c33c105a8fd5a9fff18286d119bb | https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/jison/jison.js#L1139-L1149 |
6,603 | imba/imba | lib/jison/jison.js | locateNearestErrorRecoveryRule | function locateNearestErrorRecoveryRule(state) {
var stack_probe = stack.length - 1;
var depth = 0;
// try to recover from error
for(;;) {
// check for error recovery rule in this state
if ((TERROR.toString()) in table[state]) {
return depth;
}
if (state === 0 || stack_probe < 2) {
return false; // No suitable error recovery rule available.
}
stack_probe -= 2; // popStack(1): [symbol, action]
state = stack[stack_probe];
++depth;
}
} | javascript | function locateNearestErrorRecoveryRule(state) {
var stack_probe = stack.length - 1;
var depth = 0;
// try to recover from error
for(;;) {
// check for error recovery rule in this state
if ((TERROR.toString()) in table[state]) {
return depth;
}
if (state === 0 || stack_probe < 2) {
return false; // No suitable error recovery rule available.
}
stack_probe -= 2; // popStack(1): [symbol, action]
state = stack[stack_probe];
++depth;
}
} | [
"function",
"locateNearestErrorRecoveryRule",
"(",
"state",
")",
"{",
"var",
"stack_probe",
"=",
"stack",
".",
"length",
"-",
"1",
";",
"var",
"depth",
"=",
"0",
";",
"// try to recover from error",
"for",
"(",
";",
";",
")",
"{",
"// check for error recovery rule in this state",
"if",
"(",
"(",
"TERROR",
".",
"toString",
"(",
")",
")",
"in",
"table",
"[",
"state",
"]",
")",
"{",
"return",
"depth",
";",
"}",
"if",
"(",
"state",
"===",
"0",
"||",
"stack_probe",
"<",
"2",
")",
"{",
"return",
"false",
";",
"// No suitable error recovery rule available.",
"}",
"stack_probe",
"-=",
"2",
";",
"// popStack(1): [symbol, action]",
"state",
"=",
"stack",
"[",
"stack_probe",
"]",
";",
"++",
"depth",
";",
"}",
"}"
] | Return the rule stack depth where the nearest error rule can be found. Return FALSE when no error recovery rule was found. we have no rules now | [
"Return",
"the",
"rule",
"stack",
"depth",
"where",
"the",
"nearest",
"error",
"rule",
"can",
"be",
"found",
".",
"Return",
"FALSE",
"when",
"no",
"error",
"recovery",
"rule",
"was",
"found",
".",
"we",
"have",
"no",
"rules",
"now"
] | cbf24f7ba961c33c105a8fd5a9fff18286d119bb | https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/jison/jison.js#L1291-L1308 |
6,604 | imba/imba | lib/jison/jison.js | LALR_buildNewGrammar | function LALR_buildNewGrammar () {
var self = this,
newg = this.newg;
this.states.forEach(function (state, i) {
state.forEach(function (item) {
if (item.dotPosition === 0) {
// new symbols are a combination of state and transition symbol
var symbol = i+":"+item.production.symbol;
self.terms_[symbol] = item.production.symbol;
newg.nterms_[symbol] = i;
if (!newg.nonterminals[symbol])
newg.nonterminals[symbol] = new Nonterminal(symbol);
var pathInfo = self.goPath(i, item.production.handle);
var p = new Production(symbol, pathInfo.path, newg.productions.length);
newg.productions.push(p);
newg.nonterminals[symbol].productions.push(p);
// store the transition that get's 'backed up to' after reduction on path
var handle = item.production.handle.join(' ');
var goes = self.states.item(pathInfo.endState).goes;
if (!goes[handle])
goes[handle] = [];
goes[handle].push(symbol);
//self.trace('new production:',p);
}
});
if (state.inadequate)
self.inadequateStates.push(i);
});
} | javascript | function LALR_buildNewGrammar () {
var self = this,
newg = this.newg;
this.states.forEach(function (state, i) {
state.forEach(function (item) {
if (item.dotPosition === 0) {
// new symbols are a combination of state and transition symbol
var symbol = i+":"+item.production.symbol;
self.terms_[symbol] = item.production.symbol;
newg.nterms_[symbol] = i;
if (!newg.nonterminals[symbol])
newg.nonterminals[symbol] = new Nonterminal(symbol);
var pathInfo = self.goPath(i, item.production.handle);
var p = new Production(symbol, pathInfo.path, newg.productions.length);
newg.productions.push(p);
newg.nonterminals[symbol].productions.push(p);
// store the transition that get's 'backed up to' after reduction on path
var handle = item.production.handle.join(' ');
var goes = self.states.item(pathInfo.endState).goes;
if (!goes[handle])
goes[handle] = [];
goes[handle].push(symbol);
//self.trace('new production:',p);
}
});
if (state.inadequate)
self.inadequateStates.push(i);
});
} | [
"function",
"LALR_buildNewGrammar",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"newg",
"=",
"this",
".",
"newg",
";",
"this",
".",
"states",
".",
"forEach",
"(",
"function",
"(",
"state",
",",
"i",
")",
"{",
"state",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"if",
"(",
"item",
".",
"dotPosition",
"===",
"0",
")",
"{",
"// new symbols are a combination of state and transition symbol",
"var",
"symbol",
"=",
"i",
"+",
"\":\"",
"+",
"item",
".",
"production",
".",
"symbol",
";",
"self",
".",
"terms_",
"[",
"symbol",
"]",
"=",
"item",
".",
"production",
".",
"symbol",
";",
"newg",
".",
"nterms_",
"[",
"symbol",
"]",
"=",
"i",
";",
"if",
"(",
"!",
"newg",
".",
"nonterminals",
"[",
"symbol",
"]",
")",
"newg",
".",
"nonterminals",
"[",
"symbol",
"]",
"=",
"new",
"Nonterminal",
"(",
"symbol",
")",
";",
"var",
"pathInfo",
"=",
"self",
".",
"goPath",
"(",
"i",
",",
"item",
".",
"production",
".",
"handle",
")",
";",
"var",
"p",
"=",
"new",
"Production",
"(",
"symbol",
",",
"pathInfo",
".",
"path",
",",
"newg",
".",
"productions",
".",
"length",
")",
";",
"newg",
".",
"productions",
".",
"push",
"(",
"p",
")",
";",
"newg",
".",
"nonterminals",
"[",
"symbol",
"]",
".",
"productions",
".",
"push",
"(",
"p",
")",
";",
"// store the transition that get's 'backed up to' after reduction on path",
"var",
"handle",
"=",
"item",
".",
"production",
".",
"handle",
".",
"join",
"(",
"' '",
")",
";",
"var",
"goes",
"=",
"self",
".",
"states",
".",
"item",
"(",
"pathInfo",
".",
"endState",
")",
".",
"goes",
";",
"if",
"(",
"!",
"goes",
"[",
"handle",
"]",
")",
"goes",
"[",
"handle",
"]",
"=",
"[",
"]",
";",
"goes",
"[",
"handle",
"]",
".",
"push",
"(",
"symbol",
")",
";",
"//self.trace('new production:',p);",
"}",
"}",
")",
";",
"if",
"(",
"state",
".",
"inadequate",
")",
"self",
".",
"inadequateStates",
".",
"push",
"(",
"i",
")",
";",
"}",
")",
";",
"}"
] | every disjoint reduction of a nonterminal becomes a produciton in G' | [
"every",
"disjoint",
"reduction",
"of",
"a",
"nonterminal",
"becomes",
"a",
"produciton",
"in",
"G"
] | cbf24f7ba961c33c105a8fd5a9fff18286d119bb | https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/jison/jison.js#L1516-L1547 |
6,605 | imolorhe/altair | chrome-ext-files/js/background.js | focusTab | function focusTab(tabId) {
var updateProperties = { "active": true };
chrome.tabs.update(tabId, updateProperties, function (tab) { });
} | javascript | function focusTab(tabId) {
var updateProperties = { "active": true };
chrome.tabs.update(tabId, updateProperties, function (tab) { });
} | [
"function",
"focusTab",
"(",
"tabId",
")",
"{",
"var",
"updateProperties",
"=",
"{",
"\"active\"",
":",
"true",
"}",
";",
"chrome",
".",
"tabs",
".",
"update",
"(",
"tabId",
",",
"updateProperties",
",",
"function",
"(",
"tab",
")",
"{",
"}",
")",
";",
"}"
] | Focus on the open extension tab | [
"Focus",
"on",
"the",
"open",
"extension",
"tab"
] | d228f435ad05de9fca673b6c67f3cc995f348284 | https://github.com/imolorhe/altair/blob/d228f435ad05de9fca673b6c67f3cc995f348284/chrome-ext-files/js/background.js#L12-L15 |
6,606 | imolorhe/altair | chrome-ext-files/js/options.js | save_options | function save_options() {
var showChangeLog = document.getElementById('show_changelog').checked;
chrome.storage.sync.set({
showChangeLog: showChangeLog
}, function () {
// Update status to let user know options were saved.
var status = document.getElementById('status');
status.textContent = 'Options saved.';
setTimeout(function () {
status.textContent = '';
}, 750);
});
} | javascript | function save_options() {
var showChangeLog = document.getElementById('show_changelog').checked;
chrome.storage.sync.set({
showChangeLog: showChangeLog
}, function () {
// Update status to let user know options were saved.
var status = document.getElementById('status');
status.textContent = 'Options saved.';
setTimeout(function () {
status.textContent = '';
}, 750);
});
} | [
"function",
"save_options",
"(",
")",
"{",
"var",
"showChangeLog",
"=",
"document",
".",
"getElementById",
"(",
"'show_changelog'",
")",
".",
"checked",
";",
"chrome",
".",
"storage",
".",
"sync",
".",
"set",
"(",
"{",
"showChangeLog",
":",
"showChangeLog",
"}",
",",
"function",
"(",
")",
"{",
"// Update status to let user know options were saved.",
"var",
"status",
"=",
"document",
".",
"getElementById",
"(",
"'status'",
")",
";",
"status",
".",
"textContent",
"=",
"'Options saved.'",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"status",
".",
"textContent",
"=",
"''",
";",
"}",
",",
"750",
")",
";",
"}",
")",
";",
"}"
] | Saves options to chrome.storage | [
"Saves",
"options",
"to",
"chrome",
".",
"storage"
] | d228f435ad05de9fca673b6c67f3cc995f348284 | https://github.com/imolorhe/altair/blob/d228f435ad05de9fca673b6c67f3cc995f348284/chrome-ext-files/js/options.js#L2-L14 |
6,607 | imolorhe/altair | chrome-ext-files/js/options.js | restore_options | function restore_options() {
// Use default value showChangeLog = true.
chrome.storage.sync.get({
showChangeLog: true
}, function (items) {
document.getElementById('show_changelog').checked = items.showChangeLog;
});
} | javascript | function restore_options() {
// Use default value showChangeLog = true.
chrome.storage.sync.get({
showChangeLog: true
}, function (items) {
document.getElementById('show_changelog').checked = items.showChangeLog;
});
} | [
"function",
"restore_options",
"(",
")",
"{",
"// Use default value showChangeLog = true.",
"chrome",
".",
"storage",
".",
"sync",
".",
"get",
"(",
"{",
"showChangeLog",
":",
"true",
"}",
",",
"function",
"(",
"items",
")",
"{",
"document",
".",
"getElementById",
"(",
"'show_changelog'",
")",
".",
"checked",
"=",
"items",
".",
"showChangeLog",
";",
"}",
")",
";",
"}"
] | Restores select box and checkbox state using the preferences stored in chrome.storage. | [
"Restores",
"select",
"box",
"and",
"checkbox",
"state",
"using",
"the",
"preferences",
"stored",
"in",
"chrome",
".",
"storage",
"."
] | d228f435ad05de9fca673b6c67f3cc995f348284 | https://github.com/imolorhe/altair/blob/d228f435ad05de9fca673b6c67f3cc995f348284/chrome-ext-files/js/options.js#L18-L25 |
6,608 | heroku/cli | packages/addons-v5/lib/util.js | style | function style (s, t) {
if (!t) return (text) => style(s, text)
return cli.color[styles[s] || s](t)
} | javascript | function style (s, t) {
if (!t) return (text) => style(s, text)
return cli.color[styles[s] || s](t)
} | [
"function",
"style",
"(",
"s",
",",
"t",
")",
"{",
"if",
"(",
"!",
"t",
")",
"return",
"(",
"text",
")",
"=>",
"style",
"(",
"s",
",",
"text",
")",
"return",
"cli",
".",
"color",
"[",
"styles",
"[",
"s",
"]",
"||",
"s",
"]",
"(",
"t",
")",
"}"
] | style given text or return a function that styles text according to provided style | [
"style",
"given",
"text",
"or",
"return",
"a",
"function",
"that",
"styles",
"text",
"according",
"to",
"provided",
"style"
] | 4d4f88817f9812f9a25d529863270155be3cda23 | https://github.com/heroku/cli/blob/4d4f88817f9812f9a25d529863270155be3cda23/packages/addons-v5/lib/util.js#L14-L17 |
6,609 | pa11y/pa11y | lib/reporter.js | buildReporter | function buildReporter(methods) {
return {
supports: methods.supports,
begin: buildReporterMethod(methods.begin),
results: buildReporterMethod(methods.results),
log: {
debug: buildReporterMethod(methods.debug),
error: buildReporterMethod(methods.error, 'error'),
info: buildReporterMethod(methods.info)
}
};
} | javascript | function buildReporter(methods) {
return {
supports: methods.supports,
begin: buildReporterMethod(methods.begin),
results: buildReporterMethod(methods.results),
log: {
debug: buildReporterMethod(methods.debug),
error: buildReporterMethod(methods.error, 'error'),
info: buildReporterMethod(methods.info)
}
};
} | [
"function",
"buildReporter",
"(",
"methods",
")",
"{",
"return",
"{",
"supports",
":",
"methods",
".",
"supports",
",",
"begin",
":",
"buildReporterMethod",
"(",
"methods",
".",
"begin",
")",
",",
"results",
":",
"buildReporterMethod",
"(",
"methods",
".",
"results",
")",
",",
"log",
":",
"{",
"debug",
":",
"buildReporterMethod",
"(",
"methods",
".",
"debug",
")",
",",
"error",
":",
"buildReporterMethod",
"(",
"methods",
".",
"error",
",",
"'error'",
")",
",",
"info",
":",
"buildReporterMethod",
"(",
"methods",
".",
"info",
")",
"}",
"}",
";",
"}"
] | Build a Pa11y reporter.
@private
@param {Object} methods - The reporter methods.
@returns {Promise} Returns a promise which resolves with the new reporter. | [
"Build",
"a",
"Pa11y",
"reporter",
"."
] | ddcbb3696a43f775e32399bbafeea7f12c9d6cbb | https://github.com/pa11y/pa11y/blob/ddcbb3696a43f775e32399bbafeea7f12c9d6cbb/lib/reporter.js#L11-L22 |
6,610 | pa11y/pa11y | lib/reporter.js | buildReporterMethod | function buildReporterMethod(method, consoleMethod = 'log') {
if (typeof method !== 'function') {
method = () => {};
}
return async input => {
const output = await method(input);
if (output) {
console[consoleMethod](output);
}
};
} | javascript | function buildReporterMethod(method, consoleMethod = 'log') {
if (typeof method !== 'function') {
method = () => {};
}
return async input => {
const output = await method(input);
if (output) {
console[consoleMethod](output);
}
};
} | [
"function",
"buildReporterMethod",
"(",
"method",
",",
"consoleMethod",
"=",
"'log'",
")",
"{",
"if",
"(",
"typeof",
"method",
"!==",
"'function'",
")",
"{",
"method",
"=",
"(",
")",
"=>",
"{",
"}",
";",
"}",
"return",
"async",
"input",
"=>",
"{",
"const",
"output",
"=",
"await",
"method",
"(",
"input",
")",
";",
"if",
"(",
"output",
")",
"{",
"console",
"[",
"consoleMethod",
"]",
"(",
"output",
")",
";",
"}",
"}",
";",
"}"
] | Build a Pa11y reporter method, making it async and only outputting when
actual output is returned.
@private
@param {Function} method - The reporter method to build.
@param {String} [consoleMethod='log'] - The console method to use in reporting.
@returns {Function} Returns a built async reporter method. | [
"Build",
"a",
"Pa11y",
"reporter",
"method",
"making",
"it",
"async",
"and",
"only",
"outputting",
"when",
"actual",
"output",
"is",
"returned",
"."
] | ddcbb3696a43f775e32399bbafeea7f12c9d6cbb | https://github.com/pa11y/pa11y/blob/ddcbb3696a43f775e32399bbafeea7f12c9d6cbb/lib/reporter.js#L32-L42 |
6,611 | pa11y/pa11y | lib/action.js | isValidAction | function isValidAction(actionString) {
return module.exports.actions.some(foundAction => {
return foundAction.match.test(actionString);
});
} | javascript | function isValidAction(actionString) {
return module.exports.actions.some(foundAction => {
return foundAction.match.test(actionString);
});
} | [
"function",
"isValidAction",
"(",
"actionString",
")",
"{",
"return",
"module",
".",
"exports",
".",
"actions",
".",
"some",
"(",
"foundAction",
"=>",
"{",
"return",
"foundAction",
".",
"match",
".",
"test",
"(",
"actionString",
")",
";",
"}",
")",
";",
"}"
] | Check whether an action string is valid.
@public
@param {String} actionString - The action string to validate.
@returns {Boolean} Returns whether the action string is valid. | [
"Check",
"whether",
"an",
"action",
"string",
"is",
"valid",
"."
] | ddcbb3696a43f775e32399bbafeea7f12c9d6cbb | https://github.com/pa11y/pa11y/blob/ddcbb3696a43f775e32399bbafeea7f12c9d6cbb/lib/action.js#L39-L43 |
6,612 | pa11y/pa11y | lib/pa11y.js | pa11y | async function pa11y(url, options = {}, callback) {
const state = {};
/* eslint-disable prefer-rest-params */
// Check for presence of a callback function
if (typeof arguments[arguments.length - 1] === 'function') {
callback = arguments[arguments.length - 1];
} else {
callback = undefined;
}
/* eslint-enable prefer-rest-params */
try {
// Switch parameters if only an options object is provided,
// and default the options
if (typeof url !== 'string') {
options = url;
url = options.url;
}
url = sanitizeUrl(url);
options = defaultOptions(options);
// Verify that the given options are valid
verifyOptions(options);
// Call the actual Pa11y test runner with
// a timeout if it takes too long
const results = await promiseTimeout(
runPa11yTest(url, options, state),
options.timeout,
`Pa11y timed out (${options.timeout}ms)`
);
// Run callback if present, and resolve with results
if (callback) {
return callback(null, results);
}
return results;
} catch (error) {
if (state.browser && state.autoClose) {
state.browser.close();
} else if (state.page && state.autoClosePage) {
state.page.close();
}
// Run callback if present, and reject with error
if (callback) {
return callback(error);
}
throw error;
}
} | javascript | async function pa11y(url, options = {}, callback) {
const state = {};
/* eslint-disable prefer-rest-params */
// Check for presence of a callback function
if (typeof arguments[arguments.length - 1] === 'function') {
callback = arguments[arguments.length - 1];
} else {
callback = undefined;
}
/* eslint-enable prefer-rest-params */
try {
// Switch parameters if only an options object is provided,
// and default the options
if (typeof url !== 'string') {
options = url;
url = options.url;
}
url = sanitizeUrl(url);
options = defaultOptions(options);
// Verify that the given options are valid
verifyOptions(options);
// Call the actual Pa11y test runner with
// a timeout if it takes too long
const results = await promiseTimeout(
runPa11yTest(url, options, state),
options.timeout,
`Pa11y timed out (${options.timeout}ms)`
);
// Run callback if present, and resolve with results
if (callback) {
return callback(null, results);
}
return results;
} catch (error) {
if (state.browser && state.autoClose) {
state.browser.close();
} else if (state.page && state.autoClosePage) {
state.page.close();
}
// Run callback if present, and reject with error
if (callback) {
return callback(error);
}
throw error;
}
} | [
"async",
"function",
"pa11y",
"(",
"url",
",",
"options",
"=",
"{",
"}",
",",
"callback",
")",
"{",
"const",
"state",
"=",
"{",
"}",
";",
"/* eslint-disable prefer-rest-params */",
"// Check for presence of a callback function",
"if",
"(",
"typeof",
"arguments",
"[",
"arguments",
".",
"length",
"-",
"1",
"]",
"===",
"'function'",
")",
"{",
"callback",
"=",
"arguments",
"[",
"arguments",
".",
"length",
"-",
"1",
"]",
";",
"}",
"else",
"{",
"callback",
"=",
"undefined",
";",
"}",
"/* eslint-enable prefer-rest-params */",
"try",
"{",
"// Switch parameters if only an options object is provided,",
"// and default the options",
"if",
"(",
"typeof",
"url",
"!==",
"'string'",
")",
"{",
"options",
"=",
"url",
";",
"url",
"=",
"options",
".",
"url",
";",
"}",
"url",
"=",
"sanitizeUrl",
"(",
"url",
")",
";",
"options",
"=",
"defaultOptions",
"(",
"options",
")",
";",
"// Verify that the given options are valid",
"verifyOptions",
"(",
"options",
")",
";",
"// Call the actual Pa11y test runner with",
"// a timeout if it takes too long",
"const",
"results",
"=",
"await",
"promiseTimeout",
"(",
"runPa11yTest",
"(",
"url",
",",
"options",
",",
"state",
")",
",",
"options",
".",
"timeout",
",",
"`",
"${",
"options",
".",
"timeout",
"}",
"`",
")",
";",
"// Run callback if present, and resolve with results",
"if",
"(",
"callback",
")",
"{",
"return",
"callback",
"(",
"null",
",",
"results",
")",
";",
"}",
"return",
"results",
";",
"}",
"catch",
"(",
"error",
")",
"{",
"if",
"(",
"state",
".",
"browser",
"&&",
"state",
".",
"autoClose",
")",
"{",
"state",
".",
"browser",
".",
"close",
"(",
")",
";",
"}",
"else",
"if",
"(",
"state",
".",
"page",
"&&",
"state",
".",
"autoClosePage",
")",
"{",
"state",
".",
"page",
".",
"close",
"(",
")",
";",
"}",
"// Run callback if present, and reject with error",
"if",
"(",
"callback",
")",
"{",
"return",
"callback",
"(",
"error",
")",
";",
"}",
"throw",
"error",
";",
"}",
"}"
] | Run accessibility tests on a web page.
@public
@param {String} [url] - The URL to run tests against.
@param {Object} [options={}] - Options to change the way tests run.
@param {Function} [callback] - An optional callback to use instead of promises.
@returns {Promise} Returns a promise which resolves with a results object. | [
"Run",
"accessibility",
"tests",
"on",
"a",
"web",
"page",
"."
] | ddcbb3696a43f775e32399bbafeea7f12c9d6cbb | https://github.com/pa11y/pa11y/blob/ddcbb3696a43f775e32399bbafeea7f12c9d6cbb/lib/pa11y.js#L24-L77 |
6,613 | pa11y/pa11y | lib/pa11y.js | defaultOptions | function defaultOptions(options) {
options = extend({}, pa11y.defaults, options);
options.ignore = options.ignore.map(ignored => ignored.toLowerCase());
if (!options.includeNotices) {
options.ignore.push('notice');
}
if (!options.includeWarnings) {
options.ignore.push('warning');
}
return options;
} | javascript | function defaultOptions(options) {
options = extend({}, pa11y.defaults, options);
options.ignore = options.ignore.map(ignored => ignored.toLowerCase());
if (!options.includeNotices) {
options.ignore.push('notice');
}
if (!options.includeWarnings) {
options.ignore.push('warning');
}
return options;
} | [
"function",
"defaultOptions",
"(",
"options",
")",
"{",
"options",
"=",
"extend",
"(",
"{",
"}",
",",
"pa11y",
".",
"defaults",
",",
"options",
")",
";",
"options",
".",
"ignore",
"=",
"options",
".",
"ignore",
".",
"map",
"(",
"ignored",
"=>",
"ignored",
".",
"toLowerCase",
"(",
")",
")",
";",
"if",
"(",
"!",
"options",
".",
"includeNotices",
")",
"{",
"options",
".",
"ignore",
".",
"push",
"(",
"'notice'",
")",
";",
"}",
"if",
"(",
"!",
"options",
".",
"includeWarnings",
")",
"{",
"options",
".",
"ignore",
".",
"push",
"(",
"'warning'",
")",
";",
"}",
"return",
"options",
";",
"}"
] | Default the passed in options using Pa11y's defaults.
@private
@param {Object} [options={}] - The options to apply defaults to.
@returns {Object} Returns the defaulted options. | [
"Default",
"the",
"passed",
"in",
"options",
"using",
"Pa11y",
"s",
"defaults",
"."
] | ddcbb3696a43f775e32399bbafeea7f12c9d6cbb | https://github.com/pa11y/pa11y/blob/ddcbb3696a43f775e32399bbafeea7f12c9d6cbb/lib/pa11y.js#L258-L268 |
6,614 | pa11y/pa11y | lib/pa11y.js | verifyOptions | function verifyOptions(options) {
if (!pa11y.allowedStandards.includes(options.standard)) {
throw new Error(`Standard must be one of ${pa11y.allowedStandards.join(', ')}`);
}
if (options.page && !options.browser) {
throw new Error('The page option must only be set alongside the browser option');
}
} | javascript | function verifyOptions(options) {
if (!pa11y.allowedStandards.includes(options.standard)) {
throw new Error(`Standard must be one of ${pa11y.allowedStandards.join(', ')}`);
}
if (options.page && !options.browser) {
throw new Error('The page option must only be set alongside the browser option');
}
} | [
"function",
"verifyOptions",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"pa11y",
".",
"allowedStandards",
".",
"includes",
"(",
"options",
".",
"standard",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"pa11y",
".",
"allowedStandards",
".",
"join",
"(",
"', '",
")",
"}",
"`",
")",
";",
"}",
"if",
"(",
"options",
".",
"page",
"&&",
"!",
"options",
".",
"browser",
")",
"{",
"throw",
"new",
"Error",
"(",
"'The page option must only be set alongside the browser option'",
")",
";",
"}",
"}"
] | Verify that passed in options are valid.
@private
@param {Object} [options={}] - The options to verify.
@returns {Undefined} Returns nothing.
@throws {Error} Throws if options are not valid. | [
"Verify",
"that",
"passed",
"in",
"options",
"are",
"valid",
"."
] | ddcbb3696a43f775e32399bbafeea7f12c9d6cbb | https://github.com/pa11y/pa11y/blob/ddcbb3696a43f775e32399bbafeea7f12c9d6cbb/lib/pa11y.js#L277-L284 |
6,615 | pa11y/pa11y | lib/runner.js | configureHtmlCodeSniffer | function configureHtmlCodeSniffer() {
if (options.rules.length && options.standard !== 'Section508') {
for (const rule of options.rules) {
if (window.HTMLCS_WCAG2AAA.sniffs.includes(rule)) {
window[`HTMLCS_${options.standard}`].sniffs[0].include.push(rule);
} else {
throw new Error(`${rule} is not a valid WCAG 2.0 rule`);
}
}
}
} | javascript | function configureHtmlCodeSniffer() {
if (options.rules.length && options.standard !== 'Section508') {
for (const rule of options.rules) {
if (window.HTMLCS_WCAG2AAA.sniffs.includes(rule)) {
window[`HTMLCS_${options.standard}`].sniffs[0].include.push(rule);
} else {
throw new Error(`${rule} is not a valid WCAG 2.0 rule`);
}
}
}
} | [
"function",
"configureHtmlCodeSniffer",
"(",
")",
"{",
"if",
"(",
"options",
".",
"rules",
".",
"length",
"&&",
"options",
".",
"standard",
"!==",
"'Section508'",
")",
"{",
"for",
"(",
"const",
"rule",
"of",
"options",
".",
"rules",
")",
"{",
"if",
"(",
"window",
".",
"HTMLCS_WCAG2AAA",
".",
"sniffs",
".",
"includes",
"(",
"rule",
")",
")",
"{",
"window",
"[",
"`",
"${",
"options",
".",
"standard",
"}",
"`",
"]",
".",
"sniffs",
"[",
"0",
"]",
".",
"include",
".",
"push",
"(",
"rule",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"rule",
"}",
"`",
")",
";",
"}",
"}",
"}",
"}"
] | Configure HTML CodeSniffer.
@private
@returns {Undefined} Returns nothing. | [
"Configure",
"HTML",
"CodeSniffer",
"."
] | ddcbb3696a43f775e32399bbafeea7f12c9d6cbb | https://github.com/pa11y/pa11y/blob/ddcbb3696a43f775e32399bbafeea7f12c9d6cbb/lib/runner.js#L54-L64 |
6,616 | pa11y/pa11y | lib/runner.js | runHtmlCodeSniffer | function runHtmlCodeSniffer() {
return new Promise((resolve, reject) => {
window.HTMLCS.process(options.standard, window.document, error => {
if (error) {
return reject(error);
}
resolve(window.HTMLCS.getMessages());
});
});
} | javascript | function runHtmlCodeSniffer() {
return new Promise((resolve, reject) => {
window.HTMLCS.process(options.standard, window.document, error => {
if (error) {
return reject(error);
}
resolve(window.HTMLCS.getMessages());
});
});
} | [
"function",
"runHtmlCodeSniffer",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"window",
".",
"HTMLCS",
".",
"process",
"(",
"options",
".",
"standard",
",",
"window",
".",
"document",
",",
"error",
"=>",
"{",
"if",
"(",
"error",
")",
"{",
"return",
"reject",
"(",
"error",
")",
";",
"}",
"resolve",
"(",
"window",
".",
"HTMLCS",
".",
"getMessages",
"(",
")",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Run HTML CodeSniffer on the current page.
@private
@returns {Promise} Returns a promise which resolves with HTML CodeSniffer issues. | [
"Run",
"HTML",
"CodeSniffer",
"on",
"the",
"current",
"page",
"."
] | ddcbb3696a43f775e32399bbafeea7f12c9d6cbb | https://github.com/pa11y/pa11y/blob/ddcbb3696a43f775e32399bbafeea7f12c9d6cbb/lib/runner.js#L71-L80 |
6,617 | pa11y/pa11y | lib/runner.js | processIssues | function processIssues(issues) {
if (options.rootElement) {
issues = issues.filter(isIssueInTestArea);
}
if (options.hideElements) {
issues = issues.filter(isElementOutsideHiddenArea);
}
return issues.map(processIssue).filter(isIssueNotIgnored);
} | javascript | function processIssues(issues) {
if (options.rootElement) {
issues = issues.filter(isIssueInTestArea);
}
if (options.hideElements) {
issues = issues.filter(isElementOutsideHiddenArea);
}
return issues.map(processIssue).filter(isIssueNotIgnored);
} | [
"function",
"processIssues",
"(",
"issues",
")",
"{",
"if",
"(",
"options",
".",
"rootElement",
")",
"{",
"issues",
"=",
"issues",
".",
"filter",
"(",
"isIssueInTestArea",
")",
";",
"}",
"if",
"(",
"options",
".",
"hideElements",
")",
"{",
"issues",
"=",
"issues",
".",
"filter",
"(",
"isElementOutsideHiddenArea",
")",
";",
"}",
"return",
"issues",
".",
"map",
"(",
"processIssue",
")",
".",
"filter",
"(",
"isIssueNotIgnored",
")",
";",
"}"
] | Process HTML CodeSniffer issues.
@private
@param {Array} issues - An array of HTML CodeSniffer issues to process.
@returns {Array} Returns an array of processed issues. | [
"Process",
"HTML",
"CodeSniffer",
"issues",
"."
] | ddcbb3696a43f775e32399bbafeea7f12c9d6cbb | https://github.com/pa11y/pa11y/blob/ddcbb3696a43f775e32399bbafeea7f12c9d6cbb/lib/runner.js#L88-L96 |
6,618 | pa11y/pa11y | lib/runner.js | processIssue | function processIssue(issue) {
return {
code: issue.code,
context: processIssueHtml(issue.element),
message: issue.msg,
type: issueTypeMap[issue.type] || 'unknown',
typeCode: issue.type,
selector: getCssSelectorForElement(issue.element)
};
} | javascript | function processIssue(issue) {
return {
code: issue.code,
context: processIssueHtml(issue.element),
message: issue.msg,
type: issueTypeMap[issue.type] || 'unknown',
typeCode: issue.type,
selector: getCssSelectorForElement(issue.element)
};
} | [
"function",
"processIssue",
"(",
"issue",
")",
"{",
"return",
"{",
"code",
":",
"issue",
".",
"code",
",",
"context",
":",
"processIssueHtml",
"(",
"issue",
".",
"element",
")",
",",
"message",
":",
"issue",
".",
"msg",
",",
"type",
":",
"issueTypeMap",
"[",
"issue",
".",
"type",
"]",
"||",
"'unknown'",
",",
"typeCode",
":",
"issue",
".",
"type",
",",
"selector",
":",
"getCssSelectorForElement",
"(",
"issue",
".",
"element",
")",
"}",
";",
"}"
] | Process a HTML CodeSniffer issue.
@private
@param {Object} issue - An HTML CodeSniffer issue to process.
@returns {Object} Returns the processed issue. | [
"Process",
"a",
"HTML",
"CodeSniffer",
"issue",
"."
] | ddcbb3696a43f775e32399bbafeea7f12c9d6cbb | https://github.com/pa11y/pa11y/blob/ddcbb3696a43f775e32399bbafeea7f12c9d6cbb/lib/runner.js#L104-L113 |
6,619 | pa11y/pa11y | lib/runner.js | processIssueHtml | function processIssueHtml(element) {
let outerHTML = null;
let innerHTML = null;
if (!element.outerHTML) {
return outerHTML;
}
outerHTML = element.outerHTML;
if (element.innerHTML.length > 31) {
innerHTML = `${element.innerHTML.substr(0, 31)}...`;
outerHTML = outerHTML.replace(element.innerHTML, innerHTML);
}
if (outerHTML.length > 251) {
outerHTML = `${outerHTML.substr(0, 250)}...`;
}
return outerHTML;
} | javascript | function processIssueHtml(element) {
let outerHTML = null;
let innerHTML = null;
if (!element.outerHTML) {
return outerHTML;
}
outerHTML = element.outerHTML;
if (element.innerHTML.length > 31) {
innerHTML = `${element.innerHTML.substr(0, 31)}...`;
outerHTML = outerHTML.replace(element.innerHTML, innerHTML);
}
if (outerHTML.length > 251) {
outerHTML = `${outerHTML.substr(0, 250)}...`;
}
return outerHTML;
} | [
"function",
"processIssueHtml",
"(",
"element",
")",
"{",
"let",
"outerHTML",
"=",
"null",
";",
"let",
"innerHTML",
"=",
"null",
";",
"if",
"(",
"!",
"element",
".",
"outerHTML",
")",
"{",
"return",
"outerHTML",
";",
"}",
"outerHTML",
"=",
"element",
".",
"outerHTML",
";",
"if",
"(",
"element",
".",
"innerHTML",
".",
"length",
">",
"31",
")",
"{",
"innerHTML",
"=",
"`",
"${",
"element",
".",
"innerHTML",
".",
"substr",
"(",
"0",
",",
"31",
")",
"}",
"`",
";",
"outerHTML",
"=",
"outerHTML",
".",
"replace",
"(",
"element",
".",
"innerHTML",
",",
"innerHTML",
")",
";",
"}",
"if",
"(",
"outerHTML",
".",
"length",
">",
"251",
")",
"{",
"outerHTML",
"=",
"`",
"${",
"outerHTML",
".",
"substr",
"(",
"0",
",",
"250",
")",
"}",
"`",
";",
"}",
"return",
"outerHTML",
";",
"}"
] | Get a short version of an element's outer HTML.
@private
@param {HTMLElement} element - An element to get short HTML for.
@returns {String} Returns the short HTML as a string. | [
"Get",
"a",
"short",
"version",
"of",
"an",
"element",
"s",
"outer",
"HTML",
"."
] | ddcbb3696a43f775e32399bbafeea7f12c9d6cbb | https://github.com/pa11y/pa11y/blob/ddcbb3696a43f775e32399bbafeea7f12c9d6cbb/lib/runner.js#L121-L136 |
6,620 | pa11y/pa11y | lib/runner.js | getCssSelectorForElement | function getCssSelectorForElement(element, selectorParts = []) {
if (isElementNode(element)) {
const identifier = buildElementIdentifier(element);
selectorParts.unshift(identifier);
if (!element.id && element.parentNode) {
return getCssSelectorForElement(element.parentNode, selectorParts);
}
}
return selectorParts.join(' > ');
} | javascript | function getCssSelectorForElement(element, selectorParts = []) {
if (isElementNode(element)) {
const identifier = buildElementIdentifier(element);
selectorParts.unshift(identifier);
if (!element.id && element.parentNode) {
return getCssSelectorForElement(element.parentNode, selectorParts);
}
}
return selectorParts.join(' > ');
} | [
"function",
"getCssSelectorForElement",
"(",
"element",
",",
"selectorParts",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"isElementNode",
"(",
"element",
")",
")",
"{",
"const",
"identifier",
"=",
"buildElementIdentifier",
"(",
"element",
")",
";",
"selectorParts",
".",
"unshift",
"(",
"identifier",
")",
";",
"if",
"(",
"!",
"element",
".",
"id",
"&&",
"element",
".",
"parentNode",
")",
"{",
"return",
"getCssSelectorForElement",
"(",
"element",
".",
"parentNode",
",",
"selectorParts",
")",
";",
"}",
"}",
"return",
"selectorParts",
".",
"join",
"(",
"' > '",
")",
";",
"}"
] | Get a CSS selector for an element.
@private
@param {HTMLElement} element - An element to get a selector for.
@param {Array} [selectorParts=[]] - Internal parameter used for recursion.
@returns {String} Returns the CSS selector as a string. | [
"Get",
"a",
"CSS",
"selector",
"for",
"an",
"element",
"."
] | ddcbb3696a43f775e32399bbafeea7f12c9d6cbb | https://github.com/pa11y/pa11y/blob/ddcbb3696a43f775e32399bbafeea7f12c9d6cbb/lib/runner.js#L145-L154 |
6,621 | pa11y/pa11y | lib/runner.js | buildElementIdentifier | function buildElementIdentifier(element) {
if (element.id) {
return `#${element.id}`;
}
let identifier = element.tagName.toLowerCase();
if (!element.parentNode) {
return identifier;
}
const siblings = getSiblings(element);
const childIndex = siblings.indexOf(element);
if (!isOnlySiblingOfType(element, siblings) && childIndex !== -1) {
identifier += `:nth-child(${childIndex + 1})`;
}
return identifier;
} | javascript | function buildElementIdentifier(element) {
if (element.id) {
return `#${element.id}`;
}
let identifier = element.tagName.toLowerCase();
if (!element.parentNode) {
return identifier;
}
const siblings = getSiblings(element);
const childIndex = siblings.indexOf(element);
if (!isOnlySiblingOfType(element, siblings) && childIndex !== -1) {
identifier += `:nth-child(${childIndex + 1})`;
}
return identifier;
} | [
"function",
"buildElementIdentifier",
"(",
"element",
")",
"{",
"if",
"(",
"element",
".",
"id",
")",
"{",
"return",
"`",
"${",
"element",
".",
"id",
"}",
"`",
";",
"}",
"let",
"identifier",
"=",
"element",
".",
"tagName",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"!",
"element",
".",
"parentNode",
")",
"{",
"return",
"identifier",
";",
"}",
"const",
"siblings",
"=",
"getSiblings",
"(",
"element",
")",
";",
"const",
"childIndex",
"=",
"siblings",
".",
"indexOf",
"(",
"element",
")",
";",
"if",
"(",
"!",
"isOnlySiblingOfType",
"(",
"element",
",",
"siblings",
")",
"&&",
"childIndex",
"!==",
"-",
"1",
")",
"{",
"identifier",
"+=",
"`",
"${",
"childIndex",
"+",
"1",
"}",
"`",
";",
"}",
"return",
"identifier",
";",
"}"
] | Build a unique CSS element identifier.
@private
@param {HTMLElement} element - An element to get a CSS element identifier for.
@returns {String} Returns the CSS element identifier as a string. | [
"Build",
"a",
"unique",
"CSS",
"element",
"identifier",
"."
] | ddcbb3696a43f775e32399bbafeea7f12c9d6cbb | https://github.com/pa11y/pa11y/blob/ddcbb3696a43f775e32399bbafeea7f12c9d6cbb/lib/runner.js#L162-L176 |
6,622 | pa11y/pa11y | lib/runner.js | isOnlySiblingOfType | function isOnlySiblingOfType(element, siblings) {
const siblingsOfType = siblings.filter(sibling => {
return (sibling.tagName === element.tagName);
});
return (siblingsOfType.length <= 1);
} | javascript | function isOnlySiblingOfType(element, siblings) {
const siblingsOfType = siblings.filter(sibling => {
return (sibling.tagName === element.tagName);
});
return (siblingsOfType.length <= 1);
} | [
"function",
"isOnlySiblingOfType",
"(",
"element",
",",
"siblings",
")",
"{",
"const",
"siblingsOfType",
"=",
"siblings",
".",
"filter",
"(",
"sibling",
"=>",
"{",
"return",
"(",
"sibling",
".",
"tagName",
"===",
"element",
".",
"tagName",
")",
";",
"}",
")",
";",
"return",
"(",
"siblingsOfType",
".",
"length",
"<=",
"1",
")",
";",
"}"
] | Check whether an element is the only sibling of its type.
@private
@param {HTMLElement} element - An element to check siblings of.
@param {Array} siblings - The siblings of the element.
@returns {Boolean} Returns whether the element is the only sibling of its type. | [
"Check",
"whether",
"an",
"element",
"is",
"the",
"only",
"sibling",
"of",
"its",
"type",
"."
] | ddcbb3696a43f775e32399bbafeea7f12c9d6cbb | https://github.com/pa11y/pa11y/blob/ddcbb3696a43f775e32399bbafeea7f12c9d6cbb/lib/runner.js#L195-L200 |
6,623 | pa11y/pa11y | lib/runner.js | isIssueNotIgnored | function isIssueNotIgnored(issue) {
if (options.ignore.indexOf(issue.code.toLowerCase()) !== -1) {
return false;
}
if (options.ignore.indexOf(issue.type) !== -1) {
return false;
}
return true;
} | javascript | function isIssueNotIgnored(issue) {
if (options.ignore.indexOf(issue.code.toLowerCase()) !== -1) {
return false;
}
if (options.ignore.indexOf(issue.type) !== -1) {
return false;
}
return true;
} | [
"function",
"isIssueNotIgnored",
"(",
"issue",
")",
"{",
"if",
"(",
"options",
".",
"ignore",
".",
"indexOf",
"(",
"issue",
".",
"code",
".",
"toLowerCase",
"(",
")",
")",
"!==",
"-",
"1",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"options",
".",
"ignore",
".",
"indexOf",
"(",
"issue",
".",
"type",
")",
"!==",
"-",
"1",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Check whether an issue should be returned, and is not ignored.
@private
@param {Object} issue - The issue to check.
@returns {Boolean} Returns whether the issue should be returned. | [
"Check",
"whether",
"an",
"issue",
"should",
"be",
"returned",
"and",
"is",
"not",
"ignored",
"."
] | ddcbb3696a43f775e32399bbafeea7f12c9d6cbb | https://github.com/pa11y/pa11y/blob/ddcbb3696a43f775e32399bbafeea7f12c9d6cbb/lib/runner.js#L218-L226 |
6,624 | pa11y/pa11y | lib/runner.js | isElementOutsideHiddenArea | function isElementOutsideHiddenArea(issue) {
const hiddenElements = [...window.document.querySelectorAll(options.hideElements)];
return !hiddenElements.some(hiddenElement => {
return hiddenElement.contains(issue.element);
});
} | javascript | function isElementOutsideHiddenArea(issue) {
const hiddenElements = [...window.document.querySelectorAll(options.hideElements)];
return !hiddenElements.some(hiddenElement => {
return hiddenElement.contains(issue.element);
});
} | [
"function",
"isElementOutsideHiddenArea",
"(",
"issue",
")",
"{",
"const",
"hiddenElements",
"=",
"[",
"...",
"window",
".",
"document",
".",
"querySelectorAll",
"(",
"options",
".",
"hideElements",
")",
"]",
";",
"return",
"!",
"hiddenElements",
".",
"some",
"(",
"hiddenElement",
"=>",
"{",
"return",
"hiddenElement",
".",
"contains",
"(",
"issue",
".",
"element",
")",
";",
"}",
")",
";",
"}"
] | Check whether an element is outside of all hidden selectors.
@private
@param {Object} issue - The issue to check.
@returns {Boolean} Returns whether the issue is outside of a hidden area. | [
"Check",
"whether",
"an",
"element",
"is",
"outside",
"of",
"all",
"hidden",
"selectors",
"."
] | ddcbb3696a43f775e32399bbafeea7f12c9d6cbb | https://github.com/pa11y/pa11y/blob/ddcbb3696a43f775e32399bbafeea7f12c9d6cbb/lib/runner.js#L245-L250 |
6,625 | expressjs/session | index.js | generate | function generate() {
store.generate(req);
originalId = req.sessionID;
originalHash = hash(req.session);
wrapmethods(req.session);
} | javascript | function generate() {
store.generate(req);
originalId = req.sessionID;
originalHash = hash(req.session);
wrapmethods(req.session);
} | [
"function",
"generate",
"(",
")",
"{",
"store",
".",
"generate",
"(",
"req",
")",
";",
"originalId",
"=",
"req",
".",
"sessionID",
";",
"originalHash",
"=",
"hash",
"(",
"req",
".",
"session",
")",
";",
"wrapmethods",
"(",
"req",
".",
"session",
")",
";",
"}"
] | generate the session | [
"generate",
"the",
"session"
] | 327695e3d1dd4d7a5d3857f2afbb5852b7710213 | https://github.com/expressjs/session/blob/327695e3d1dd4d7a5d3857f2afbb5852b7710213/index.js#L359-L364 |
6,626 | expressjs/session | index.js | inflate | function inflate (req, sess) {
store.createSession(req, sess)
originalId = req.sessionID
originalHash = hash(sess)
if (!resaveSession) {
savedHash = originalHash
}
wrapmethods(req.session)
} | javascript | function inflate (req, sess) {
store.createSession(req, sess)
originalId = req.sessionID
originalHash = hash(sess)
if (!resaveSession) {
savedHash = originalHash
}
wrapmethods(req.session)
} | [
"function",
"inflate",
"(",
"req",
",",
"sess",
")",
"{",
"store",
".",
"createSession",
"(",
"req",
",",
"sess",
")",
"originalId",
"=",
"req",
".",
"sessionID",
"originalHash",
"=",
"hash",
"(",
"sess",
")",
"if",
"(",
"!",
"resaveSession",
")",
"{",
"savedHash",
"=",
"originalHash",
"}",
"wrapmethods",
"(",
"req",
".",
"session",
")",
"}"
] | inflate the session | [
"inflate",
"the",
"session"
] | 327695e3d1dd4d7a5d3857f2afbb5852b7710213 | https://github.com/expressjs/session/blob/327695e3d1dd4d7a5d3857f2afbb5852b7710213/index.js#L367-L377 |
6,627 | expressjs/session | index.js | shouldSave | function shouldSave(req) {
// cannot set cookie without a session ID
if (typeof req.sessionID !== 'string') {
debug('session ignored because of bogus req.sessionID %o', req.sessionID);
return false;
}
return !saveUninitializedSession && cookieId !== req.sessionID
? isModified(req.session)
: !isSaved(req.session)
} | javascript | function shouldSave(req) {
// cannot set cookie without a session ID
if (typeof req.sessionID !== 'string') {
debug('session ignored because of bogus req.sessionID %o', req.sessionID);
return false;
}
return !saveUninitializedSession && cookieId !== req.sessionID
? isModified(req.session)
: !isSaved(req.session)
} | [
"function",
"shouldSave",
"(",
"req",
")",
"{",
"// cannot set cookie without a session ID",
"if",
"(",
"typeof",
"req",
".",
"sessionID",
"!==",
"'string'",
")",
"{",
"debug",
"(",
"'session ignored because of bogus req.sessionID %o'",
",",
"req",
".",
"sessionID",
")",
";",
"return",
"false",
";",
"}",
"return",
"!",
"saveUninitializedSession",
"&&",
"cookieId",
"!==",
"req",
".",
"sessionID",
"?",
"isModified",
"(",
"req",
".",
"session",
")",
":",
"!",
"isSaved",
"(",
"req",
".",
"session",
")",
"}"
] | determine if session should be saved to store | [
"determine",
"if",
"session",
"should",
"be",
"saved",
"to",
"store"
] | 327695e3d1dd4d7a5d3857f2afbb5852b7710213 | https://github.com/expressjs/session/blob/327695e3d1dd4d7a5d3857f2afbb5852b7710213/index.js#L429-L439 |
6,628 | expressjs/session | index.js | shouldTouch | function shouldTouch(req) {
// cannot set cookie without a session ID
if (typeof req.sessionID !== 'string') {
debug('session ignored because of bogus req.sessionID %o', req.sessionID);
return false;
}
return cookieId === req.sessionID && !shouldSave(req);
} | javascript | function shouldTouch(req) {
// cannot set cookie without a session ID
if (typeof req.sessionID !== 'string') {
debug('session ignored because of bogus req.sessionID %o', req.sessionID);
return false;
}
return cookieId === req.sessionID && !shouldSave(req);
} | [
"function",
"shouldTouch",
"(",
"req",
")",
"{",
"// cannot set cookie without a session ID",
"if",
"(",
"typeof",
"req",
".",
"sessionID",
"!==",
"'string'",
")",
"{",
"debug",
"(",
"'session ignored because of bogus req.sessionID %o'",
",",
"req",
".",
"sessionID",
")",
";",
"return",
"false",
";",
"}",
"return",
"cookieId",
"===",
"req",
".",
"sessionID",
"&&",
"!",
"shouldSave",
"(",
"req",
")",
";",
"}"
] | determine if session should be touched | [
"determine",
"if",
"session",
"should",
"be",
"touched"
] | 327695e3d1dd4d7a5d3857f2afbb5852b7710213 | https://github.com/expressjs/session/blob/327695e3d1dd4d7a5d3857f2afbb5852b7710213/index.js#L442-L450 |
6,629 | expressjs/session | index.js | shouldSetCookie | function shouldSetCookie(req) {
// cannot set cookie without a session ID
if (typeof req.sessionID !== 'string') {
return false;
}
return cookieId !== req.sessionID
? saveUninitializedSession || isModified(req.session)
: rollingSessions || req.session.cookie.expires != null && isModified(req.session);
} | javascript | function shouldSetCookie(req) {
// cannot set cookie without a session ID
if (typeof req.sessionID !== 'string') {
return false;
}
return cookieId !== req.sessionID
? saveUninitializedSession || isModified(req.session)
: rollingSessions || req.session.cookie.expires != null && isModified(req.session);
} | [
"function",
"shouldSetCookie",
"(",
"req",
")",
"{",
"// cannot set cookie without a session ID",
"if",
"(",
"typeof",
"req",
".",
"sessionID",
"!==",
"'string'",
")",
"{",
"return",
"false",
";",
"}",
"return",
"cookieId",
"!==",
"req",
".",
"sessionID",
"?",
"saveUninitializedSession",
"||",
"isModified",
"(",
"req",
".",
"session",
")",
":",
"rollingSessions",
"||",
"req",
".",
"session",
".",
"cookie",
".",
"expires",
"!=",
"null",
"&&",
"isModified",
"(",
"req",
".",
"session",
")",
";",
"}"
] | determine if cookie should be set on response | [
"determine",
"if",
"cookie",
"should",
"be",
"set",
"on",
"response"
] | 327695e3d1dd4d7a5d3857f2afbb5852b7710213 | https://github.com/expressjs/session/blob/327695e3d1dd4d7a5d3857f2afbb5852b7710213/index.js#L453-L462 |
6,630 | expressjs/session | index.js | hash | function hash(sess) {
// serialize
var str = JSON.stringify(sess, function (key, val) {
// ignore sess.cookie property
if (this === sess && key === 'cookie') {
return
}
return val
})
// hash
return crypto
.createHash('sha1')
.update(str, 'utf8')
.digest('hex')
} | javascript | function hash(sess) {
// serialize
var str = JSON.stringify(sess, function (key, val) {
// ignore sess.cookie property
if (this === sess && key === 'cookie') {
return
}
return val
})
// hash
return crypto
.createHash('sha1')
.update(str, 'utf8')
.digest('hex')
} | [
"function",
"hash",
"(",
"sess",
")",
"{",
"// serialize",
"var",
"str",
"=",
"JSON",
".",
"stringify",
"(",
"sess",
",",
"function",
"(",
"key",
",",
"val",
")",
"{",
"// ignore sess.cookie property",
"if",
"(",
"this",
"===",
"sess",
"&&",
"key",
"===",
"'cookie'",
")",
"{",
"return",
"}",
"return",
"val",
"}",
")",
"// hash",
"return",
"crypto",
".",
"createHash",
"(",
"'sha1'",
")",
".",
"update",
"(",
"str",
",",
"'utf8'",
")",
".",
"digest",
"(",
"'hex'",
")",
"}"
] | Hash the given `sess` object omitting changes to `.cookie`.
@param {Object} sess
@return {String}
@private | [
"Hash",
"the",
"given",
"sess",
"object",
"omitting",
"changes",
"to",
".",
"cookie",
"."
] | 327695e3d1dd4d7a5d3857f2afbb5852b7710213 | https://github.com/expressjs/session/blob/327695e3d1dd4d7a5d3857f2afbb5852b7710213/index.js#L585-L601 |
6,631 | expressjs/session | index.js | issecure | function issecure(req, trustProxy) {
// socket is https server
if (req.connection && req.connection.encrypted) {
return true;
}
// do not trust proxy
if (trustProxy === false) {
return false;
}
// no explicit trust; try req.secure from express
if (trustProxy !== true) {
return req.secure === true
}
// read the proto from x-forwarded-proto header
var header = req.headers['x-forwarded-proto'] || '';
var index = header.indexOf(',');
var proto = index !== -1
? header.substr(0, index).toLowerCase().trim()
: header.toLowerCase().trim()
return proto === 'https';
} | javascript | function issecure(req, trustProxy) {
// socket is https server
if (req.connection && req.connection.encrypted) {
return true;
}
// do not trust proxy
if (trustProxy === false) {
return false;
}
// no explicit trust; try req.secure from express
if (trustProxy !== true) {
return req.secure === true
}
// read the proto from x-forwarded-proto header
var header = req.headers['x-forwarded-proto'] || '';
var index = header.indexOf(',');
var proto = index !== -1
? header.substr(0, index).toLowerCase().trim()
: header.toLowerCase().trim()
return proto === 'https';
} | [
"function",
"issecure",
"(",
"req",
",",
"trustProxy",
")",
"{",
"// socket is https server",
"if",
"(",
"req",
".",
"connection",
"&&",
"req",
".",
"connection",
".",
"encrypted",
")",
"{",
"return",
"true",
";",
"}",
"// do not trust proxy",
"if",
"(",
"trustProxy",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"// no explicit trust; try req.secure from express",
"if",
"(",
"trustProxy",
"!==",
"true",
")",
"{",
"return",
"req",
".",
"secure",
"===",
"true",
"}",
"// read the proto from x-forwarded-proto header",
"var",
"header",
"=",
"req",
".",
"headers",
"[",
"'x-forwarded-proto'",
"]",
"||",
"''",
";",
"var",
"index",
"=",
"header",
".",
"indexOf",
"(",
"','",
")",
";",
"var",
"proto",
"=",
"index",
"!==",
"-",
"1",
"?",
"header",
".",
"substr",
"(",
"0",
",",
"index",
")",
".",
"toLowerCase",
"(",
")",
".",
"trim",
"(",
")",
":",
"header",
".",
"toLowerCase",
"(",
")",
".",
"trim",
"(",
")",
"return",
"proto",
"===",
"'https'",
";",
"}"
] | Determine if request is secure.
@param {Object} req
@param {Boolean} [trustProxy]
@return {Boolean}
@private | [
"Determine",
"if",
"request",
"is",
"secure",
"."
] | 327695e3d1dd4d7a5d3857f2afbb5852b7710213 | https://github.com/expressjs/session/blob/327695e3d1dd4d7a5d3857f2afbb5852b7710213/index.js#L612-L636 |
6,632 | expressjs/session | index.js | unsigncookie | function unsigncookie(val, secrets) {
for (var i = 0; i < secrets.length; i++) {
var result = signature.unsign(val, secrets[i]);
if (result !== false) {
return result;
}
}
return false;
} | javascript | function unsigncookie(val, secrets) {
for (var i = 0; i < secrets.length; i++) {
var result = signature.unsign(val, secrets[i]);
if (result !== false) {
return result;
}
}
return false;
} | [
"function",
"unsigncookie",
"(",
"val",
",",
"secrets",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"secrets",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"result",
"=",
"signature",
".",
"unsign",
"(",
"val",
",",
"secrets",
"[",
"i",
"]",
")",
";",
"if",
"(",
"result",
"!==",
"false",
")",
"{",
"return",
"result",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Verify and decode the given `val` with `secrets`.
@param {String} val
@param {Array} secrets
@returns {String|Boolean}
@private | [
"Verify",
"and",
"decode",
"the",
"given",
"val",
"with",
"secrets",
"."
] | 327695e3d1dd4d7a5d3857f2afbb5852b7710213 | https://github.com/expressjs/session/blob/327695e3d1dd4d7a5d3857f2afbb5852b7710213/index.js#L664-L674 |
6,633 | expressjs/session | session/session.js | Session | function Session(req, data) {
Object.defineProperty(this, 'req', { value: req });
Object.defineProperty(this, 'id', { value: req.sessionID });
if (typeof data === 'object' && data !== null) {
// merge data into this, ignoring prototype properties
for (var prop in data) {
if (!(prop in this)) {
this[prop] = data[prop]
}
}
}
} | javascript | function Session(req, data) {
Object.defineProperty(this, 'req', { value: req });
Object.defineProperty(this, 'id', { value: req.sessionID });
if (typeof data === 'object' && data !== null) {
// merge data into this, ignoring prototype properties
for (var prop in data) {
if (!(prop in this)) {
this[prop] = data[prop]
}
}
}
} | [
"function",
"Session",
"(",
"req",
",",
"data",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"'req'",
",",
"{",
"value",
":",
"req",
"}",
")",
";",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"'id'",
",",
"{",
"value",
":",
"req",
".",
"sessionID",
"}",
")",
";",
"if",
"(",
"typeof",
"data",
"===",
"'object'",
"&&",
"data",
"!==",
"null",
")",
"{",
"// merge data into this, ignoring prototype properties",
"for",
"(",
"var",
"prop",
"in",
"data",
")",
"{",
"if",
"(",
"!",
"(",
"prop",
"in",
"this",
")",
")",
"{",
"this",
"[",
"prop",
"]",
"=",
"data",
"[",
"prop",
"]",
"}",
"}",
"}",
"}"
] | Create a new `Session` with the given request and `data`.
@param {IncomingRequest} req
@param {Object} data
@api private | [
"Create",
"a",
"new",
"Session",
"with",
"the",
"given",
"request",
"and",
"data",
"."
] | 327695e3d1dd4d7a5d3857f2afbb5852b7710213 | https://github.com/expressjs/session/blob/327695e3d1dd4d7a5d3857f2afbb5852b7710213/session/session.js#L24-L36 |
6,634 | MikeMcl/bignumber.js | perf/lib/bigdecimal_GWT/bigdecimal.js | fix_and_export | function fix_and_export(class_name) {
var Src = window.bigdecimal[class_name];
var Fixed = Src;
if(Src.__init__) {
Fixed = function wrap_constructor() {
var args = Array.prototype.slice.call(arguments);
return Src.__init__(args);
};
Fixed.prototype = Src.prototype;
for (var a in Src)
if(Src.hasOwnProperty(a)) {
if((typeof Src[a] != 'function') || !a.match(/_va$/))
Fixed[a] = Src[a];
else {
var pub_name = a.replace(/_va$/, '');
Fixed[pub_name] = function wrap_classmeth () {
var args = Array.prototype.slice.call(arguments);
return wrap_classmeth.inner_method(args);
};
Fixed[pub_name].inner_method = Src[a];
}
}
}
var proto = Fixed.prototype;
for (var a in proto) {
if(proto.hasOwnProperty(a) && (typeof proto[a] == 'function') && a.match(/_va$/)) {
var pub_name = a.replace(/_va$/, '');
proto[pub_name] = function wrap_meth() {
var args = Array.prototype.slice.call(arguments);
return wrap_meth.inner_method.apply(this, [args]);
};
proto[pub_name].inner_method = proto[a];
delete proto[a];
}
}
exports[class_name] = Fixed;
} | javascript | function fix_and_export(class_name) {
var Src = window.bigdecimal[class_name];
var Fixed = Src;
if(Src.__init__) {
Fixed = function wrap_constructor() {
var args = Array.prototype.slice.call(arguments);
return Src.__init__(args);
};
Fixed.prototype = Src.prototype;
for (var a in Src)
if(Src.hasOwnProperty(a)) {
if((typeof Src[a] != 'function') || !a.match(/_va$/))
Fixed[a] = Src[a];
else {
var pub_name = a.replace(/_va$/, '');
Fixed[pub_name] = function wrap_classmeth () {
var args = Array.prototype.slice.call(arguments);
return wrap_classmeth.inner_method(args);
};
Fixed[pub_name].inner_method = Src[a];
}
}
}
var proto = Fixed.prototype;
for (var a in proto) {
if(proto.hasOwnProperty(a) && (typeof proto[a] == 'function') && a.match(/_va$/)) {
var pub_name = a.replace(/_va$/, '');
proto[pub_name] = function wrap_meth() {
var args = Array.prototype.slice.call(arguments);
return wrap_meth.inner_method.apply(this, [args]);
};
proto[pub_name].inner_method = proto[a];
delete proto[a];
}
}
exports[class_name] = Fixed;
} | [
"function",
"fix_and_export",
"(",
"class_name",
")",
"{",
"var",
"Src",
"=",
"window",
".",
"bigdecimal",
"[",
"class_name",
"]",
";",
"var",
"Fixed",
"=",
"Src",
";",
"if",
"(",
"Src",
".",
"__init__",
")",
"{",
"Fixed",
"=",
"function",
"wrap_constructor",
"(",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"return",
"Src",
".",
"__init__",
"(",
"args",
")",
";",
"}",
";",
"Fixed",
".",
"prototype",
"=",
"Src",
".",
"prototype",
";",
"for",
"(",
"var",
"a",
"in",
"Src",
")",
"if",
"(",
"Src",
".",
"hasOwnProperty",
"(",
"a",
")",
")",
"{",
"if",
"(",
"(",
"typeof",
"Src",
"[",
"a",
"]",
"!=",
"'function'",
")",
"||",
"!",
"a",
".",
"match",
"(",
"/",
"_va$",
"/",
")",
")",
"Fixed",
"[",
"a",
"]",
"=",
"Src",
"[",
"a",
"]",
";",
"else",
"{",
"var",
"pub_name",
"=",
"a",
".",
"replace",
"(",
"/",
"_va$",
"/",
",",
"''",
")",
";",
"Fixed",
"[",
"pub_name",
"]",
"=",
"function",
"wrap_classmeth",
"(",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"return",
"wrap_classmeth",
".",
"inner_method",
"(",
"args",
")",
";",
"}",
";",
"Fixed",
"[",
"pub_name",
"]",
".",
"inner_method",
"=",
"Src",
"[",
"a",
"]",
";",
"}",
"}",
"}",
"var",
"proto",
"=",
"Fixed",
".",
"prototype",
";",
"for",
"(",
"var",
"a",
"in",
"proto",
")",
"{",
"if",
"(",
"proto",
".",
"hasOwnProperty",
"(",
"a",
")",
"&&",
"(",
"typeof",
"proto",
"[",
"a",
"]",
"==",
"'function'",
")",
"&&",
"a",
".",
"match",
"(",
"/",
"_va$",
"/",
")",
")",
"{",
"var",
"pub_name",
"=",
"a",
".",
"replace",
"(",
"/",
"_va$",
"/",
",",
"''",
")",
";",
"proto",
"[",
"pub_name",
"]",
"=",
"function",
"wrap_meth",
"(",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"return",
"wrap_meth",
".",
"inner_method",
".",
"apply",
"(",
"this",
",",
"[",
"args",
"]",
")",
";",
"}",
";",
"proto",
"[",
"pub_name",
"]",
".",
"inner_method",
"=",
"proto",
"[",
"a",
"]",
";",
"delete",
"proto",
"[",
"a",
"]",
";",
"}",
"}",
"exports",
"[",
"class_name",
"]",
"=",
"Fixed",
";",
"}"
] | This is an unfortunate kludge because Java methods and constructors cannot accept vararg parameters. | [
"This",
"is",
"an",
"unfortunate",
"kludge",
"because",
"Java",
"methods",
"and",
"constructors",
"cannot",
"accept",
"vararg",
"parameters",
"."
] | 2601c3eda90da68c22bec168df3b709b2d42a638 | https://github.com/MikeMcl/bignumber.js/blob/2601c3eda90da68c22bec168df3b709b2d42a638/perf/lib/bigdecimal_GWT/bigdecimal.js#L549-L590 |
6,635 | MikeMcl/bignumber.js | bignumber.js | multiply | function multiply(x, k, base) {
var m, temp, xlo, xhi,
carry = 0,
i = x.length,
klo = k % SQRT_BASE,
khi = k / SQRT_BASE | 0;
for (x = x.slice(); i--;) {
xlo = x[i] % SQRT_BASE;
xhi = x[i] / SQRT_BASE | 0;
m = khi * xlo + xhi * klo;
temp = klo * xlo + ((m % SQRT_BASE) * SQRT_BASE) + carry;
carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
x[i] = temp % base;
}
if (carry) x = [carry].concat(x);
return x;
} | javascript | function multiply(x, k, base) {
var m, temp, xlo, xhi,
carry = 0,
i = x.length,
klo = k % SQRT_BASE,
khi = k / SQRT_BASE | 0;
for (x = x.slice(); i--;) {
xlo = x[i] % SQRT_BASE;
xhi = x[i] / SQRT_BASE | 0;
m = khi * xlo + xhi * klo;
temp = klo * xlo + ((m % SQRT_BASE) * SQRT_BASE) + carry;
carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
x[i] = temp % base;
}
if (carry) x = [carry].concat(x);
return x;
} | [
"function",
"multiply",
"(",
"x",
",",
"k",
",",
"base",
")",
"{",
"var",
"m",
",",
"temp",
",",
"xlo",
",",
"xhi",
",",
"carry",
"=",
"0",
",",
"i",
"=",
"x",
".",
"length",
",",
"klo",
"=",
"k",
"%",
"SQRT_BASE",
",",
"khi",
"=",
"k",
"/",
"SQRT_BASE",
"|",
"0",
";",
"for",
"(",
"x",
"=",
"x",
".",
"slice",
"(",
")",
";",
"i",
"--",
";",
")",
"{",
"xlo",
"=",
"x",
"[",
"i",
"]",
"%",
"SQRT_BASE",
";",
"xhi",
"=",
"x",
"[",
"i",
"]",
"/",
"SQRT_BASE",
"|",
"0",
";",
"m",
"=",
"khi",
"*",
"xlo",
"+",
"xhi",
"*",
"klo",
";",
"temp",
"=",
"klo",
"*",
"xlo",
"+",
"(",
"(",
"m",
"%",
"SQRT_BASE",
")",
"*",
"SQRT_BASE",
")",
"+",
"carry",
";",
"carry",
"=",
"(",
"temp",
"/",
"base",
"|",
"0",
")",
"+",
"(",
"m",
"/",
"SQRT_BASE",
"|",
"0",
")",
"+",
"khi",
"*",
"xhi",
";",
"x",
"[",
"i",
"]",
"=",
"temp",
"%",
"base",
";",
"}",
"if",
"(",
"carry",
")",
"x",
"=",
"[",
"carry",
"]",
".",
"concat",
"(",
"x",
")",
";",
"return",
"x",
";",
"}"
] | Assume non-zero x and k. | [
"Assume",
"non",
"-",
"zero",
"x",
"and",
"k",
"."
] | 2601c3eda90da68c22bec168df3b709b2d42a638 | https://github.com/MikeMcl/bignumber.js/blob/2601c3eda90da68c22bec168df3b709b2d42a638/bignumber.js#L970-L989 |
6,636 | MikeMcl/bignumber.js | bignumber.js | isOdd | function isOdd(n) {
var k = n.c.length - 1;
return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0;
} | javascript | function isOdd(n) {
var k = n.c.length - 1;
return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0;
} | [
"function",
"isOdd",
"(",
"n",
")",
"{",
"var",
"k",
"=",
"n",
".",
"c",
".",
"length",
"-",
"1",
";",
"return",
"bitFloor",
"(",
"n",
".",
"e",
"/",
"LOG_BASE",
")",
"==",
"k",
"&&",
"n",
".",
"c",
"[",
"k",
"]",
"%",
"2",
"!=",
"0",
";",
"}"
] | Assumes finite n. | [
"Assumes",
"finite",
"n",
"."
] | 2601c3eda90da68c22bec168df3b709b2d42a638 | https://github.com/MikeMcl/bignumber.js/blob/2601c3eda90da68c22bec168df3b709b2d42a638/bignumber.js#L2850-L2853 |
6,637 | nodeca/pako | lib/deflate.js | Deflate | function Deflate(options) {
if (!(this instanceof Deflate)) return new Deflate(options);
this.options = utils.assign({
level: Z_DEFAULT_COMPRESSION,
method: Z_DEFLATED,
chunkSize: 16384,
windowBits: 15,
memLevel: 8,
strategy: Z_DEFAULT_STRATEGY,
to: ''
}, options || {});
var opt = this.options;
if (opt.raw && (opt.windowBits > 0)) {
opt.windowBits = -opt.windowBits;
}
else if (opt.gzip && (opt.windowBits > 0) && (opt.windowBits < 16)) {
opt.windowBits += 16;
}
this.err = 0; // error code, if happens (0 = Z_OK)
this.msg = ''; // error message
this.ended = false; // used to avoid multiple onEnd() calls
this.chunks = []; // chunks of compressed data
this.strm = new ZStream();
this.strm.avail_out = 0;
var status = zlib_deflate.deflateInit2(
this.strm,
opt.level,
opt.method,
opt.windowBits,
opt.memLevel,
opt.strategy
);
if (status !== Z_OK) {
throw new Error(msg[status]);
}
if (opt.header) {
zlib_deflate.deflateSetHeader(this.strm, opt.header);
}
if (opt.dictionary) {
var dict;
// Convert data if needed
if (typeof opt.dictionary === 'string') {
// If we need to compress text, change encoding to utf8.
dict = strings.string2buf(opt.dictionary);
} else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {
dict = new Uint8Array(opt.dictionary);
} else {
dict = opt.dictionary;
}
status = zlib_deflate.deflateSetDictionary(this.strm, dict);
if (status !== Z_OK) {
throw new Error(msg[status]);
}
this._dict_set = true;
}
} | javascript | function Deflate(options) {
if (!(this instanceof Deflate)) return new Deflate(options);
this.options = utils.assign({
level: Z_DEFAULT_COMPRESSION,
method: Z_DEFLATED,
chunkSize: 16384,
windowBits: 15,
memLevel: 8,
strategy: Z_DEFAULT_STRATEGY,
to: ''
}, options || {});
var opt = this.options;
if (opt.raw && (opt.windowBits > 0)) {
opt.windowBits = -opt.windowBits;
}
else if (opt.gzip && (opt.windowBits > 0) && (opt.windowBits < 16)) {
opt.windowBits += 16;
}
this.err = 0; // error code, if happens (0 = Z_OK)
this.msg = ''; // error message
this.ended = false; // used to avoid multiple onEnd() calls
this.chunks = []; // chunks of compressed data
this.strm = new ZStream();
this.strm.avail_out = 0;
var status = zlib_deflate.deflateInit2(
this.strm,
opt.level,
opt.method,
opt.windowBits,
opt.memLevel,
opt.strategy
);
if (status !== Z_OK) {
throw new Error(msg[status]);
}
if (opt.header) {
zlib_deflate.deflateSetHeader(this.strm, opt.header);
}
if (opt.dictionary) {
var dict;
// Convert data if needed
if (typeof opt.dictionary === 'string') {
// If we need to compress text, change encoding to utf8.
dict = strings.string2buf(opt.dictionary);
} else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {
dict = new Uint8Array(opt.dictionary);
} else {
dict = opt.dictionary;
}
status = zlib_deflate.deflateSetDictionary(this.strm, dict);
if (status !== Z_OK) {
throw new Error(msg[status]);
}
this._dict_set = true;
}
} | [
"function",
"Deflate",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Deflate",
")",
")",
"return",
"new",
"Deflate",
"(",
"options",
")",
";",
"this",
".",
"options",
"=",
"utils",
".",
"assign",
"(",
"{",
"level",
":",
"Z_DEFAULT_COMPRESSION",
",",
"method",
":",
"Z_DEFLATED",
",",
"chunkSize",
":",
"16384",
",",
"windowBits",
":",
"15",
",",
"memLevel",
":",
"8",
",",
"strategy",
":",
"Z_DEFAULT_STRATEGY",
",",
"to",
":",
"''",
"}",
",",
"options",
"||",
"{",
"}",
")",
";",
"var",
"opt",
"=",
"this",
".",
"options",
";",
"if",
"(",
"opt",
".",
"raw",
"&&",
"(",
"opt",
".",
"windowBits",
">",
"0",
")",
")",
"{",
"opt",
".",
"windowBits",
"=",
"-",
"opt",
".",
"windowBits",
";",
"}",
"else",
"if",
"(",
"opt",
".",
"gzip",
"&&",
"(",
"opt",
".",
"windowBits",
">",
"0",
")",
"&&",
"(",
"opt",
".",
"windowBits",
"<",
"16",
")",
")",
"{",
"opt",
".",
"windowBits",
"+=",
"16",
";",
"}",
"this",
".",
"err",
"=",
"0",
";",
"// error code, if happens (0 = Z_OK)",
"this",
".",
"msg",
"=",
"''",
";",
"// error message",
"this",
".",
"ended",
"=",
"false",
";",
"// used to avoid multiple onEnd() calls",
"this",
".",
"chunks",
"=",
"[",
"]",
";",
"// chunks of compressed data",
"this",
".",
"strm",
"=",
"new",
"ZStream",
"(",
")",
";",
"this",
".",
"strm",
".",
"avail_out",
"=",
"0",
";",
"var",
"status",
"=",
"zlib_deflate",
".",
"deflateInit2",
"(",
"this",
".",
"strm",
",",
"opt",
".",
"level",
",",
"opt",
".",
"method",
",",
"opt",
".",
"windowBits",
",",
"opt",
".",
"memLevel",
",",
"opt",
".",
"strategy",
")",
";",
"if",
"(",
"status",
"!==",
"Z_OK",
")",
"{",
"throw",
"new",
"Error",
"(",
"msg",
"[",
"status",
"]",
")",
";",
"}",
"if",
"(",
"opt",
".",
"header",
")",
"{",
"zlib_deflate",
".",
"deflateSetHeader",
"(",
"this",
".",
"strm",
",",
"opt",
".",
"header",
")",
";",
"}",
"if",
"(",
"opt",
".",
"dictionary",
")",
"{",
"var",
"dict",
";",
"// Convert data if needed",
"if",
"(",
"typeof",
"opt",
".",
"dictionary",
"===",
"'string'",
")",
"{",
"// If we need to compress text, change encoding to utf8.",
"dict",
"=",
"strings",
".",
"string2buf",
"(",
"opt",
".",
"dictionary",
")",
";",
"}",
"else",
"if",
"(",
"toString",
".",
"call",
"(",
"opt",
".",
"dictionary",
")",
"===",
"'[object ArrayBuffer]'",
")",
"{",
"dict",
"=",
"new",
"Uint8Array",
"(",
"opt",
".",
"dictionary",
")",
";",
"}",
"else",
"{",
"dict",
"=",
"opt",
".",
"dictionary",
";",
"}",
"status",
"=",
"zlib_deflate",
".",
"deflateSetDictionary",
"(",
"this",
".",
"strm",
",",
"dict",
")",
";",
"if",
"(",
"status",
"!==",
"Z_OK",
")",
"{",
"throw",
"new",
"Error",
"(",
"msg",
"[",
"status",
"]",
")",
";",
"}",
"this",
".",
"_dict_set",
"=",
"true",
";",
"}",
"}"
] | Deflate.msg -> String
Error message, if [[Deflate.err]] != 0
new Deflate(options)
- options (Object): zlib deflate options.
Creates new deflator instance with specified params. Throws exception
on bad params. Supported options:
- `level`
- `windowBits`
- `memLevel`
- `strategy`
- `dictionary`
[http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
for more information on these.
Additional options, for internal needs:
- `chunkSize` - size of generated data chunks (16K by default)
- `raw` (Boolean) - do raw deflate
- `gzip` (Boolean) - create gzip wrapper
- `to` (String) - if equal to 'string', then result will be "binary string"
(each char code [0..255])
- `header` (Object) - custom header for gzip
- `text` (Boolean) - true if compressed data believed to be text
- `time` (Number) - modification time, unix timestamp
- `os` (Number) - operation system code
- `extra` (Array) - array of bytes with extra data (max 65536)
- `name` (String) - file name (binary string)
- `comment` (String) - comment (binary string)
- `hcrc` (Boolean) - true if header crc should be added
##### Example:
```javascript
var pako = require('pako')
, chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])
, chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);
var deflate = new pako.Deflate({ level: 3});
deflate.push(chunk1, false);
deflate.push(chunk2, true); // true -> last chunk
if (deflate.err) { throw new Error(deflate.err); }
console.log(deflate.result);
``` | [
"Deflate",
".",
"msg",
"-",
">",
"String"
] | 69798959ca01d40bc692d4fe9c54b9d23a4994bf | https://github.com/nodeca/pako/blob/69798959ca01d40bc692d4fe9c54b9d23a4994bf/lib/deflate.js#L120-L188 |
6,638 | nodeca/pako | lib/inflate.js | Inflate | function Inflate(options) {
if (!(this instanceof Inflate)) return new Inflate(options);
this.options = utils.assign({
chunkSize: 16384,
windowBits: 0,
to: ''
}, options || {});
var opt = this.options;
// Force window size for `raw` data, if not set directly,
// because we have no header for autodetect.
if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {
opt.windowBits = -opt.windowBits;
if (opt.windowBits === 0) { opt.windowBits = -15; }
}
// If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate
if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&
!(options && options.windowBits)) {
opt.windowBits += 32;
}
// Gzip header has no info about windows size, we can do autodetect only
// for deflate. So, if window size not set, force it to max when gzip possible
if ((opt.windowBits > 15) && (opt.windowBits < 48)) {
// bit 3 (16) -> gzipped data
// bit 4 (32) -> autodetect gzip/deflate
if ((opt.windowBits & 15) === 0) {
opt.windowBits |= 15;
}
}
this.err = 0; // error code, if happens (0 = Z_OK)
this.msg = ''; // error message
this.ended = false; // used to avoid multiple onEnd() calls
this.chunks = []; // chunks of compressed data
this.strm = new ZStream();
this.strm.avail_out = 0;
var status = zlib_inflate.inflateInit2(
this.strm,
opt.windowBits
);
if (status !== c.Z_OK) {
throw new Error(msg[status]);
}
this.header = new GZheader();
zlib_inflate.inflateGetHeader(this.strm, this.header);
// Setup dictionary
if (opt.dictionary) {
// Convert data if needed
if (typeof opt.dictionary === 'string') {
opt.dictionary = strings.string2buf(opt.dictionary);
} else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {
opt.dictionary = new Uint8Array(opt.dictionary);
}
if (opt.raw) { //In raw mode we need to set the dictionary early
status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary);
if (status !== c.Z_OK) {
throw new Error(msg[status]);
}
}
}
} | javascript | function Inflate(options) {
if (!(this instanceof Inflate)) return new Inflate(options);
this.options = utils.assign({
chunkSize: 16384,
windowBits: 0,
to: ''
}, options || {});
var opt = this.options;
// Force window size for `raw` data, if not set directly,
// because we have no header for autodetect.
if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {
opt.windowBits = -opt.windowBits;
if (opt.windowBits === 0) { opt.windowBits = -15; }
}
// If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate
if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&
!(options && options.windowBits)) {
opt.windowBits += 32;
}
// Gzip header has no info about windows size, we can do autodetect only
// for deflate. So, if window size not set, force it to max when gzip possible
if ((opt.windowBits > 15) && (opt.windowBits < 48)) {
// bit 3 (16) -> gzipped data
// bit 4 (32) -> autodetect gzip/deflate
if ((opt.windowBits & 15) === 0) {
opt.windowBits |= 15;
}
}
this.err = 0; // error code, if happens (0 = Z_OK)
this.msg = ''; // error message
this.ended = false; // used to avoid multiple onEnd() calls
this.chunks = []; // chunks of compressed data
this.strm = new ZStream();
this.strm.avail_out = 0;
var status = zlib_inflate.inflateInit2(
this.strm,
opt.windowBits
);
if (status !== c.Z_OK) {
throw new Error(msg[status]);
}
this.header = new GZheader();
zlib_inflate.inflateGetHeader(this.strm, this.header);
// Setup dictionary
if (opt.dictionary) {
// Convert data if needed
if (typeof opt.dictionary === 'string') {
opt.dictionary = strings.string2buf(opt.dictionary);
} else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {
opt.dictionary = new Uint8Array(opt.dictionary);
}
if (opt.raw) { //In raw mode we need to set the dictionary early
status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary);
if (status !== c.Z_OK) {
throw new Error(msg[status]);
}
}
}
} | [
"function",
"Inflate",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Inflate",
")",
")",
"return",
"new",
"Inflate",
"(",
"options",
")",
";",
"this",
".",
"options",
"=",
"utils",
".",
"assign",
"(",
"{",
"chunkSize",
":",
"16384",
",",
"windowBits",
":",
"0",
",",
"to",
":",
"''",
"}",
",",
"options",
"||",
"{",
"}",
")",
";",
"var",
"opt",
"=",
"this",
".",
"options",
";",
"// Force window size for `raw` data, if not set directly,",
"// because we have no header for autodetect.",
"if",
"(",
"opt",
".",
"raw",
"&&",
"(",
"opt",
".",
"windowBits",
">=",
"0",
")",
"&&",
"(",
"opt",
".",
"windowBits",
"<",
"16",
")",
")",
"{",
"opt",
".",
"windowBits",
"=",
"-",
"opt",
".",
"windowBits",
";",
"if",
"(",
"opt",
".",
"windowBits",
"===",
"0",
")",
"{",
"opt",
".",
"windowBits",
"=",
"-",
"15",
";",
"}",
"}",
"// If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate",
"if",
"(",
"(",
"opt",
".",
"windowBits",
">=",
"0",
")",
"&&",
"(",
"opt",
".",
"windowBits",
"<",
"16",
")",
"&&",
"!",
"(",
"options",
"&&",
"options",
".",
"windowBits",
")",
")",
"{",
"opt",
".",
"windowBits",
"+=",
"32",
";",
"}",
"// Gzip header has no info about windows size, we can do autodetect only",
"// for deflate. So, if window size not set, force it to max when gzip possible",
"if",
"(",
"(",
"opt",
".",
"windowBits",
">",
"15",
")",
"&&",
"(",
"opt",
".",
"windowBits",
"<",
"48",
")",
")",
"{",
"// bit 3 (16) -> gzipped data",
"// bit 4 (32) -> autodetect gzip/deflate",
"if",
"(",
"(",
"opt",
".",
"windowBits",
"&",
"15",
")",
"===",
"0",
")",
"{",
"opt",
".",
"windowBits",
"|=",
"15",
";",
"}",
"}",
"this",
".",
"err",
"=",
"0",
";",
"// error code, if happens (0 = Z_OK)",
"this",
".",
"msg",
"=",
"''",
";",
"// error message",
"this",
".",
"ended",
"=",
"false",
";",
"// used to avoid multiple onEnd() calls",
"this",
".",
"chunks",
"=",
"[",
"]",
";",
"// chunks of compressed data",
"this",
".",
"strm",
"=",
"new",
"ZStream",
"(",
")",
";",
"this",
".",
"strm",
".",
"avail_out",
"=",
"0",
";",
"var",
"status",
"=",
"zlib_inflate",
".",
"inflateInit2",
"(",
"this",
".",
"strm",
",",
"opt",
".",
"windowBits",
")",
";",
"if",
"(",
"status",
"!==",
"c",
".",
"Z_OK",
")",
"{",
"throw",
"new",
"Error",
"(",
"msg",
"[",
"status",
"]",
")",
";",
"}",
"this",
".",
"header",
"=",
"new",
"GZheader",
"(",
")",
";",
"zlib_inflate",
".",
"inflateGetHeader",
"(",
"this",
".",
"strm",
",",
"this",
".",
"header",
")",
";",
"// Setup dictionary",
"if",
"(",
"opt",
".",
"dictionary",
")",
"{",
"// Convert data if needed",
"if",
"(",
"typeof",
"opt",
".",
"dictionary",
"===",
"'string'",
")",
"{",
"opt",
".",
"dictionary",
"=",
"strings",
".",
"string2buf",
"(",
"opt",
".",
"dictionary",
")",
";",
"}",
"else",
"if",
"(",
"toString",
".",
"call",
"(",
"opt",
".",
"dictionary",
")",
"===",
"'[object ArrayBuffer]'",
")",
"{",
"opt",
".",
"dictionary",
"=",
"new",
"Uint8Array",
"(",
"opt",
".",
"dictionary",
")",
";",
"}",
"if",
"(",
"opt",
".",
"raw",
")",
"{",
"//In raw mode we need to set the dictionary early",
"status",
"=",
"zlib_inflate",
".",
"inflateSetDictionary",
"(",
"this",
".",
"strm",
",",
"opt",
".",
"dictionary",
")",
";",
"if",
"(",
"status",
"!==",
"c",
".",
"Z_OK",
")",
"{",
"throw",
"new",
"Error",
"(",
"msg",
"[",
"status",
"]",
")",
";",
"}",
"}",
"}",
"}"
] | Inflate.msg -> String
Error message, if [[Inflate.err]] != 0
new Inflate(options)
- options (Object): zlib inflate options.
Creates new inflator instance with specified params. Throws exception
on bad params. Supported options:
- `windowBits`
- `dictionary`
[http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
for more information on these.
Additional options, for internal needs:
- `chunkSize` - size of generated data chunks (16K by default)
- `raw` (Boolean) - do raw inflate
- `to` (String) - if equal to 'string', then result will be converted
from utf8 to utf16 (javascript) string. When string output requested,
chunk length can differ from `chunkSize`, depending on content.
By default, when no options set, autodetect deflate/gzip data format via
wrapper header.
##### Example:
```javascript
var pako = require('pako')
, chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])
, chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);
var inflate = new pako.Inflate({ level: 3});
inflate.push(chunk1, false);
inflate.push(chunk2, true); // true -> last chunk
if (inflate.err) { throw new Error(inflate.err); }
console.log(inflate.result);
``` | [
"Inflate",
".",
"msg",
"-",
">",
"String"
] | 69798959ca01d40bc692d4fe9c54b9d23a4994bf | https://github.com/nodeca/pako/blob/69798959ca01d40bc692d4fe9c54b9d23a4994bf/lib/inflate.js#L93-L163 |
6,639 | uw-labs/bloomrpc | webpack.config.base.js | filterDepWithoutEntryPoints | function filterDepWithoutEntryPoints(dep) {
// Return true if we want to add a dependency to externals
try {
// If the root of the dependency has an index.js, return true
if (fs.existsSync(path.join(__dirname, `node_modules/${dep}/index.js`))) {
return false;
}
const pgkString = fs
.readFileSync(path.join(__dirname, `node_modules/${dep}/package.json`))
.toString();
const pkg = JSON.parse(pgkString);
const fields = ['main', 'module', 'jsnext:main', 'browser'];
return !fields.some(field => field in pkg);
} catch (e) {
console.log(e);
return true;
}
} | javascript | function filterDepWithoutEntryPoints(dep) {
// Return true if we want to add a dependency to externals
try {
// If the root of the dependency has an index.js, return true
if (fs.existsSync(path.join(__dirname, `node_modules/${dep}/index.js`))) {
return false;
}
const pgkString = fs
.readFileSync(path.join(__dirname, `node_modules/${dep}/package.json`))
.toString();
const pkg = JSON.parse(pgkString);
const fields = ['main', 'module', 'jsnext:main', 'browser'];
return !fields.some(field => field in pkg);
} catch (e) {
console.log(e);
return true;
}
} | [
"function",
"filterDepWithoutEntryPoints",
"(",
"dep",
")",
"{",
"// Return true if we want to add a dependency to externals",
"try",
"{",
"// If the root of the dependency has an index.js, return true",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"path",
".",
"join",
"(",
"__dirname",
",",
"`",
"${",
"dep",
"}",
"`",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"const",
"pgkString",
"=",
"fs",
".",
"readFileSync",
"(",
"path",
".",
"join",
"(",
"__dirname",
",",
"`",
"${",
"dep",
"}",
"`",
")",
")",
".",
"toString",
"(",
")",
";",
"const",
"pkg",
"=",
"JSON",
".",
"parse",
"(",
"pgkString",
")",
";",
"const",
"fields",
"=",
"[",
"'main'",
",",
"'module'",
",",
"'jsnext:main'",
",",
"'browser'",
"]",
";",
"return",
"!",
"fields",
".",
"some",
"(",
"field",
"=>",
"field",
"in",
"pkg",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"console",
".",
"log",
"(",
"e",
")",
";",
"return",
"true",
";",
"}",
"}"
] | Find all the dependencies without a `main` property and add them as webpack externals | [
"Find",
"all",
"the",
"dependencies",
"without",
"a",
"main",
"property",
"and",
"add",
"them",
"as",
"webpack",
"externals"
] | 18acf5d04277547bdd42c372a40155f5ce994c64 | https://github.com/uw-labs/bloomrpc/blob/18acf5d04277547bdd42c372a40155f5ce994c64/webpack.config.base.js#L12-L29 |
6,640 | visionmedia/debug | src/common.js | createDebug | function createDebug(namespace) {
let prevTime;
function debug(...args) {
// Disabled?
if (!debug.enabled) {
return;
}
const self = debug;
// Set `diff` timestamp
const curr = Number(new Date());
const ms = curr - (prevTime || curr);
self.diff = ms;
self.prev = prevTime;
self.curr = curr;
prevTime = curr;
args[0] = createDebug.coerce(args[0]);
if (typeof args[0] !== 'string') {
// Anything else let's inspect with %O
args.unshift('%O');
}
// Apply any `formatters` transformations
let index = 0;
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
// If we encounter an escaped % then don't increase the array index
if (match === '%%') {
return match;
}
index++;
const formatter = createDebug.formatters[format];
if (typeof formatter === 'function') {
const val = args[index];
match = formatter.call(self, val);
// Now we need to remove `args[index]` since it's inlined in the `format`
args.splice(index, 1);
index--;
}
return match;
});
// Apply env-specific formatting (colors, etc.)
createDebug.formatArgs.call(self, args);
const logFn = self.log || createDebug.log;
logFn.apply(self, args);
}
debug.namespace = namespace;
debug.enabled = createDebug.enabled(namespace);
debug.useColors = createDebug.useColors();
debug.color = selectColor(namespace);
debug.destroy = destroy;
debug.extend = extend;
// Debug.formatArgs = formatArgs;
// debug.rawLog = rawLog;
// env-specific initialization logic for debug instances
if (typeof createDebug.init === 'function') {
createDebug.init(debug);
}
createDebug.instances.push(debug);
return debug;
} | javascript | function createDebug(namespace) {
let prevTime;
function debug(...args) {
// Disabled?
if (!debug.enabled) {
return;
}
const self = debug;
// Set `diff` timestamp
const curr = Number(new Date());
const ms = curr - (prevTime || curr);
self.diff = ms;
self.prev = prevTime;
self.curr = curr;
prevTime = curr;
args[0] = createDebug.coerce(args[0]);
if (typeof args[0] !== 'string') {
// Anything else let's inspect with %O
args.unshift('%O');
}
// Apply any `formatters` transformations
let index = 0;
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
// If we encounter an escaped % then don't increase the array index
if (match === '%%') {
return match;
}
index++;
const formatter = createDebug.formatters[format];
if (typeof formatter === 'function') {
const val = args[index];
match = formatter.call(self, val);
// Now we need to remove `args[index]` since it's inlined in the `format`
args.splice(index, 1);
index--;
}
return match;
});
// Apply env-specific formatting (colors, etc.)
createDebug.formatArgs.call(self, args);
const logFn = self.log || createDebug.log;
logFn.apply(self, args);
}
debug.namespace = namespace;
debug.enabled = createDebug.enabled(namespace);
debug.useColors = createDebug.useColors();
debug.color = selectColor(namespace);
debug.destroy = destroy;
debug.extend = extend;
// Debug.formatArgs = formatArgs;
// debug.rawLog = rawLog;
// env-specific initialization logic for debug instances
if (typeof createDebug.init === 'function') {
createDebug.init(debug);
}
createDebug.instances.push(debug);
return debug;
} | [
"function",
"createDebug",
"(",
"namespace",
")",
"{",
"let",
"prevTime",
";",
"function",
"debug",
"(",
"...",
"args",
")",
"{",
"// Disabled?",
"if",
"(",
"!",
"debug",
".",
"enabled",
")",
"{",
"return",
";",
"}",
"const",
"self",
"=",
"debug",
";",
"// Set `diff` timestamp",
"const",
"curr",
"=",
"Number",
"(",
"new",
"Date",
"(",
")",
")",
";",
"const",
"ms",
"=",
"curr",
"-",
"(",
"prevTime",
"||",
"curr",
")",
";",
"self",
".",
"diff",
"=",
"ms",
";",
"self",
".",
"prev",
"=",
"prevTime",
";",
"self",
".",
"curr",
"=",
"curr",
";",
"prevTime",
"=",
"curr",
";",
"args",
"[",
"0",
"]",
"=",
"createDebug",
".",
"coerce",
"(",
"args",
"[",
"0",
"]",
")",
";",
"if",
"(",
"typeof",
"args",
"[",
"0",
"]",
"!==",
"'string'",
")",
"{",
"// Anything else let's inspect with %O",
"args",
".",
"unshift",
"(",
"'%O'",
")",
";",
"}",
"// Apply any `formatters` transformations",
"let",
"index",
"=",
"0",
";",
"args",
"[",
"0",
"]",
"=",
"args",
"[",
"0",
"]",
".",
"replace",
"(",
"/",
"%([a-zA-Z%])",
"/",
"g",
",",
"(",
"match",
",",
"format",
")",
"=>",
"{",
"// If we encounter an escaped % then don't increase the array index",
"if",
"(",
"match",
"===",
"'%%'",
")",
"{",
"return",
"match",
";",
"}",
"index",
"++",
";",
"const",
"formatter",
"=",
"createDebug",
".",
"formatters",
"[",
"format",
"]",
";",
"if",
"(",
"typeof",
"formatter",
"===",
"'function'",
")",
"{",
"const",
"val",
"=",
"args",
"[",
"index",
"]",
";",
"match",
"=",
"formatter",
".",
"call",
"(",
"self",
",",
"val",
")",
";",
"// Now we need to remove `args[index]` since it's inlined in the `format`",
"args",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"index",
"--",
";",
"}",
"return",
"match",
";",
"}",
")",
";",
"// Apply env-specific formatting (colors, etc.)",
"createDebug",
".",
"formatArgs",
".",
"call",
"(",
"self",
",",
"args",
")",
";",
"const",
"logFn",
"=",
"self",
".",
"log",
"||",
"createDebug",
".",
"log",
";",
"logFn",
".",
"apply",
"(",
"self",
",",
"args",
")",
";",
"}",
"debug",
".",
"namespace",
"=",
"namespace",
";",
"debug",
".",
"enabled",
"=",
"createDebug",
".",
"enabled",
"(",
"namespace",
")",
";",
"debug",
".",
"useColors",
"=",
"createDebug",
".",
"useColors",
"(",
")",
";",
"debug",
".",
"color",
"=",
"selectColor",
"(",
"namespace",
")",
";",
"debug",
".",
"destroy",
"=",
"destroy",
";",
"debug",
".",
"extend",
"=",
"extend",
";",
"// Debug.formatArgs = formatArgs;",
"// debug.rawLog = rawLog;",
"// env-specific initialization logic for debug instances",
"if",
"(",
"typeof",
"createDebug",
".",
"init",
"===",
"'function'",
")",
"{",
"createDebug",
".",
"init",
"(",
"debug",
")",
";",
"}",
"createDebug",
".",
"instances",
".",
"push",
"(",
"debug",
")",
";",
"return",
"debug",
";",
"}"
] | Create a debugger with the given `namespace`.
@param {String} namespace
@return {Function}
@api public | [
"Create",
"a",
"debugger",
"with",
"the",
"given",
"namespace",
"."
] | 5c7c61dc0df0db4eb5de25707d8cd1b9be1add4f | https://github.com/visionmedia/debug/blob/5c7c61dc0df0db4eb5de25707d8cd1b9be1add4f/src/common.js#L64-L134 |
6,641 | visionmedia/debug | src/common.js | disable | function disable() {
const namespaces = [
...createDebug.names.map(toNamespace),
...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
].join(',');
createDebug.enable('');
return namespaces;
} | javascript | function disable() {
const namespaces = [
...createDebug.names.map(toNamespace),
...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
].join(',');
createDebug.enable('');
return namespaces;
} | [
"function",
"disable",
"(",
")",
"{",
"const",
"namespaces",
"=",
"[",
"...",
"createDebug",
".",
"names",
".",
"map",
"(",
"toNamespace",
")",
",",
"...",
"createDebug",
".",
"skips",
".",
"map",
"(",
"toNamespace",
")",
".",
"map",
"(",
"namespace",
"=>",
"'-'",
"+",
"namespace",
")",
"]",
".",
"join",
"(",
"','",
")",
";",
"createDebug",
".",
"enable",
"(",
"''",
")",
";",
"return",
"namespaces",
";",
"}"
] | Disable debug output.
@return {String} namespaces
@api public | [
"Disable",
"debug",
"output",
"."
] | 5c7c61dc0df0db4eb5de25707d8cd1b9be1add4f | https://github.com/visionmedia/debug/blob/5c7c61dc0df0db4eb5de25707d8cd1b9be1add4f/src/common.js#L195-L202 |
6,642 | visionmedia/debug | src/common.js | enabled | function enabled(name) {
if (name[name.length - 1] === '*') {
return true;
}
let i;
let len;
for (i = 0, len = createDebug.skips.length; i < len; i++) {
if (createDebug.skips[i].test(name)) {
return false;
}
}
for (i = 0, len = createDebug.names.length; i < len; i++) {
if (createDebug.names[i].test(name)) {
return true;
}
}
return false;
} | javascript | function enabled(name) {
if (name[name.length - 1] === '*') {
return true;
}
let i;
let len;
for (i = 0, len = createDebug.skips.length; i < len; i++) {
if (createDebug.skips[i].test(name)) {
return false;
}
}
for (i = 0, len = createDebug.names.length; i < len; i++) {
if (createDebug.names[i].test(name)) {
return true;
}
}
return false;
} | [
"function",
"enabled",
"(",
"name",
")",
"{",
"if",
"(",
"name",
"[",
"name",
".",
"length",
"-",
"1",
"]",
"===",
"'*'",
")",
"{",
"return",
"true",
";",
"}",
"let",
"i",
";",
"let",
"len",
";",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"createDebug",
".",
"skips",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"createDebug",
".",
"skips",
"[",
"i",
"]",
".",
"test",
"(",
"name",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"createDebug",
".",
"names",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"createDebug",
".",
"names",
"[",
"i",
"]",
".",
"test",
"(",
"name",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns true if the given mode name is enabled, false otherwise.
@param {String} name
@return {Boolean}
@api public | [
"Returns",
"true",
"if",
"the",
"given",
"mode",
"name",
"is",
"enabled",
"false",
"otherwise",
"."
] | 5c7c61dc0df0db4eb5de25707d8cd1b9be1add4f | https://github.com/visionmedia/debug/blob/5c7c61dc0df0db4eb5de25707d8cd1b9be1add4f/src/common.js#L211-L232 |
6,643 | visionmedia/debug | src/browser.js | load | function load() {
let r;
try {
r = exports.storage.getItem('debug');
} catch (error) {
// Swallow
// XXX (@Qix-) should we be logging these?
}
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
if (!r && typeof process !== 'undefined' && 'env' in process) {
r = process.env.DEBUG;
}
return r;
} | javascript | function load() {
let r;
try {
r = exports.storage.getItem('debug');
} catch (error) {
// Swallow
// XXX (@Qix-) should we be logging these?
}
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
if (!r && typeof process !== 'undefined' && 'env' in process) {
r = process.env.DEBUG;
}
return r;
} | [
"function",
"load",
"(",
")",
"{",
"let",
"r",
";",
"try",
"{",
"r",
"=",
"exports",
".",
"storage",
".",
"getItem",
"(",
"'debug'",
")",
";",
"}",
"catch",
"(",
"error",
")",
"{",
"// Swallow",
"// XXX (@Qix-) should we be logging these?",
"}",
"// If debug isn't set in LS, and we're in Electron, try to load $DEBUG",
"if",
"(",
"!",
"r",
"&&",
"typeof",
"process",
"!==",
"'undefined'",
"&&",
"'env'",
"in",
"process",
")",
"{",
"r",
"=",
"process",
".",
"env",
".",
"DEBUG",
";",
"}",
"return",
"r",
";",
"}"
] | Load `namespaces`.
@return {String} returns the previously persisted debug modes
@api private | [
"Load",
"namespaces",
"."
] | 5c7c61dc0df0db4eb5de25707d8cd1b9be1add4f | https://github.com/visionmedia/debug/blob/5c7c61dc0df0db4eb5de25707d8cd1b9be1add4f/src/browser.js#L206-L221 |
6,644 | visionmedia/debug | src/node.js | useColors | function useColors() {
return 'colors' in exports.inspectOpts ?
Boolean(exports.inspectOpts.colors) :
tty.isatty(process.stderr.fd);
} | javascript | function useColors() {
return 'colors' in exports.inspectOpts ?
Boolean(exports.inspectOpts.colors) :
tty.isatty(process.stderr.fd);
} | [
"function",
"useColors",
"(",
")",
"{",
"return",
"'colors'",
"in",
"exports",
".",
"inspectOpts",
"?",
"Boolean",
"(",
"exports",
".",
"inspectOpts",
".",
"colors",
")",
":",
"tty",
".",
"isatty",
"(",
"process",
".",
"stderr",
".",
"fd",
")",
";",
"}"
] | Is stdout a TTY? Colored output is enabled when `true`. | [
"Is",
"stdout",
"a",
"TTY?",
"Colored",
"output",
"is",
"enabled",
"when",
"true",
"."
] | 5c7c61dc0df0db4eb5de25707d8cd1b9be1add4f | https://github.com/visionmedia/debug/blob/5c7c61dc0df0db4eb5de25707d8cd1b9be1add4f/src/node.js#L151-L155 |
6,645 | visionmedia/debug | src/node.js | formatArgs | function formatArgs(args) {
const {namespace: name, useColors} = this;
if (useColors) {
const c = this.color;
const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
} else {
args[0] = getDate() + name + ' ' + args[0];
}
} | javascript | function formatArgs(args) {
const {namespace: name, useColors} = this;
if (useColors) {
const c = this.color;
const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
} else {
args[0] = getDate() + name + ' ' + args[0];
}
} | [
"function",
"formatArgs",
"(",
"args",
")",
"{",
"const",
"{",
"namespace",
":",
"name",
",",
"useColors",
"}",
"=",
"this",
";",
"if",
"(",
"useColors",
")",
"{",
"const",
"c",
"=",
"this",
".",
"color",
";",
"const",
"colorCode",
"=",
"'\\u001B[3'",
"+",
"(",
"c",
"<",
"8",
"?",
"c",
":",
"'8;5;'",
"+",
"c",
")",
";",
"const",
"prefix",
"=",
"`",
"${",
"colorCode",
"}",
"${",
"name",
"}",
"\\u001B",
"`",
";",
"args",
"[",
"0",
"]",
"=",
"prefix",
"+",
"args",
"[",
"0",
"]",
".",
"split",
"(",
"'\\n'",
")",
".",
"join",
"(",
"'\\n'",
"+",
"prefix",
")",
";",
"args",
".",
"push",
"(",
"colorCode",
"+",
"'m+'",
"+",
"module",
".",
"exports",
".",
"humanize",
"(",
"this",
".",
"diff",
")",
"+",
"'\\u001B[0m'",
")",
";",
"}",
"else",
"{",
"args",
"[",
"0",
"]",
"=",
"getDate",
"(",
")",
"+",
"name",
"+",
"' '",
"+",
"args",
"[",
"0",
"]",
";",
"}",
"}"
] | Adds ANSI color escape codes if enabled.
@api public | [
"Adds",
"ANSI",
"color",
"escape",
"codes",
"if",
"enabled",
"."
] | 5c7c61dc0df0db4eb5de25707d8cd1b9be1add4f | https://github.com/visionmedia/debug/blob/5c7c61dc0df0db4eb5de25707d8cd1b9be1add4f/src/node.js#L163-L176 |
6,646 | visionmedia/debug | src/node.js | init | function init(debug) {
debug.inspectOpts = {};
const keys = Object.keys(exports.inspectOpts);
for (let i = 0; i < keys.length; i++) {
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
}
} | javascript | function init(debug) {
debug.inspectOpts = {};
const keys = Object.keys(exports.inspectOpts);
for (let i = 0; i < keys.length; i++) {
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
}
} | [
"function",
"init",
"(",
"debug",
")",
"{",
"debug",
".",
"inspectOpts",
"=",
"{",
"}",
";",
"const",
"keys",
"=",
"Object",
".",
"keys",
"(",
"exports",
".",
"inspectOpts",
")",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"i",
"++",
")",
"{",
"debug",
".",
"inspectOpts",
"[",
"keys",
"[",
"i",
"]",
"]",
"=",
"exports",
".",
"inspectOpts",
"[",
"keys",
"[",
"i",
"]",
"]",
";",
"}",
"}"
] | Init logic for `debug` instances.
Create a new `inspectOpts` object in case `useColors` is set
differently for a particular `debug` instance. | [
"Init",
"logic",
"for",
"debug",
"instances",
"."
] | 5c7c61dc0df0db4eb5de25707d8cd1b9be1add4f | https://github.com/visionmedia/debug/blob/5c7c61dc0df0db4eb5de25707d8cd1b9be1add4f/src/node.js#L227-L234 |
6,647 | jupyter-widgets/ipywidgets | widgetsnbextension/src/extension.js | function(Jupyter, kernel) {
if (kernel.comm_manager && kernel.widget_manager === undefined) {
// Clear any old widget manager
if (Jupyter.WidgetManager) {
Jupyter.WidgetManager._managers[0].clear_state();
}
// Create a new widget manager instance. Use the global
// Jupyter.notebook handle.
var manager = new mngr.WidgetManager(kernel.comm_manager, Jupyter.notebook);
// For backwards compatibility and interactive use.
Jupyter.WidgetManager = mngr.WidgetManager;
// Store a handle to the manager so we know not to
// another for this kernel. This also is a convenience
// for the user.
kernel.widget_manager = manager;
}
} | javascript | function(Jupyter, kernel) {
if (kernel.comm_manager && kernel.widget_manager === undefined) {
// Clear any old widget manager
if (Jupyter.WidgetManager) {
Jupyter.WidgetManager._managers[0].clear_state();
}
// Create a new widget manager instance. Use the global
// Jupyter.notebook handle.
var manager = new mngr.WidgetManager(kernel.comm_manager, Jupyter.notebook);
// For backwards compatibility and interactive use.
Jupyter.WidgetManager = mngr.WidgetManager;
// Store a handle to the manager so we know not to
// another for this kernel. This also is a convenience
// for the user.
kernel.widget_manager = manager;
}
} | [
"function",
"(",
"Jupyter",
",",
"kernel",
")",
"{",
"if",
"(",
"kernel",
".",
"comm_manager",
"&&",
"kernel",
".",
"widget_manager",
"===",
"undefined",
")",
"{",
"// Clear any old widget manager",
"if",
"(",
"Jupyter",
".",
"WidgetManager",
")",
"{",
"Jupyter",
".",
"WidgetManager",
".",
"_managers",
"[",
"0",
"]",
".",
"clear_state",
"(",
")",
";",
"}",
"// Create a new widget manager instance. Use the global",
"// Jupyter.notebook handle.",
"var",
"manager",
"=",
"new",
"mngr",
".",
"WidgetManager",
"(",
"kernel",
".",
"comm_manager",
",",
"Jupyter",
".",
"notebook",
")",
";",
"// For backwards compatibility and interactive use.",
"Jupyter",
".",
"WidgetManager",
"=",
"mngr",
".",
"WidgetManager",
";",
"// Store a handle to the manager so we know not to",
"// another for this kernel. This also is a convenience",
"// for the user.",
"kernel",
".",
"widget_manager",
"=",
"manager",
";",
"}",
"}"
] | Create a widget manager for a kernel instance. | [
"Create",
"a",
"widget",
"manager",
"for",
"a",
"kernel",
"instance",
"."
] | 36fe37594cd5a268def228709ca27e37b99ac606 | https://github.com/jupyter-widgets/ipywidgets/blob/36fe37594cd5a268def228709ca27e37b99ac606/widgetsnbextension/src/extension.js#L26-L46 |
|
6,648 | jupyter-widgets/ipywidgets | widgetsnbextension/src/extension.js | render | function render(output, data, node) {
// data is a model id
var manager = Jupyter.notebook && Jupyter.notebook.kernel && Jupyter.notebook.kernel.widget_manager;
if (!manager) {
node.textContent = "Error rendering Jupyter widget: missing widget manager";
return;
}
// Missing model id means the view was removed. Hide this element.
if (data.model_id === '') {
node.style.display = 'none';
return;
}
var model = manager.get_model(data.model_id);
if (model) {
model.then(function(model) {
return manager.display_model(void 0, model, {output: output});
}).then(function(view) {
var id = view.cid;
output._jupyterWidgetViews = output._jupyterWidgetViews || [];
output._jupyterWidgetViews.push(id);
views[id] = view;
PhosphorWidget.Widget.attach(view.pWidget, node);
// Make the node completely disappear if the view is removed.
view.once('remove', () => {
// Since we have a mutable reference to the data, delete the
// model id to indicate the view is removed.
data.model_id = '';
node.style.display = 'none';
})
});
} else {
node.textContent = 'A Jupyter widget could not be displayed because the widget state could not be found. This could happen if the kernel storing the widget is no longer available, or if the widget state was not saved in the notebook. You may be able to create the widget by running the appropriate cells.';
}
} | javascript | function render(output, data, node) {
// data is a model id
var manager = Jupyter.notebook && Jupyter.notebook.kernel && Jupyter.notebook.kernel.widget_manager;
if (!manager) {
node.textContent = "Error rendering Jupyter widget: missing widget manager";
return;
}
// Missing model id means the view was removed. Hide this element.
if (data.model_id === '') {
node.style.display = 'none';
return;
}
var model = manager.get_model(data.model_id);
if (model) {
model.then(function(model) {
return manager.display_model(void 0, model, {output: output});
}).then(function(view) {
var id = view.cid;
output._jupyterWidgetViews = output._jupyterWidgetViews || [];
output._jupyterWidgetViews.push(id);
views[id] = view;
PhosphorWidget.Widget.attach(view.pWidget, node);
// Make the node completely disappear if the view is removed.
view.once('remove', () => {
// Since we have a mutable reference to the data, delete the
// model id to indicate the view is removed.
data.model_id = '';
node.style.display = 'none';
})
});
} else {
node.textContent = 'A Jupyter widget could not be displayed because the widget state could not be found. This could happen if the kernel storing the widget is no longer available, or if the widget state was not saved in the notebook. You may be able to create the widget by running the appropriate cells.';
}
} | [
"function",
"render",
"(",
"output",
",",
"data",
",",
"node",
")",
"{",
"// data is a model id",
"var",
"manager",
"=",
"Jupyter",
".",
"notebook",
"&&",
"Jupyter",
".",
"notebook",
".",
"kernel",
"&&",
"Jupyter",
".",
"notebook",
".",
"kernel",
".",
"widget_manager",
";",
"if",
"(",
"!",
"manager",
")",
"{",
"node",
".",
"textContent",
"=",
"\"Error rendering Jupyter widget: missing widget manager\"",
";",
"return",
";",
"}",
"// Missing model id means the view was removed. Hide this element.",
"if",
"(",
"data",
".",
"model_id",
"===",
"''",
")",
"{",
"node",
".",
"style",
".",
"display",
"=",
"'none'",
";",
"return",
";",
"}",
"var",
"model",
"=",
"manager",
".",
"get_model",
"(",
"data",
".",
"model_id",
")",
";",
"if",
"(",
"model",
")",
"{",
"model",
".",
"then",
"(",
"function",
"(",
"model",
")",
"{",
"return",
"manager",
".",
"display_model",
"(",
"void",
"0",
",",
"model",
",",
"{",
"output",
":",
"output",
"}",
")",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
"view",
")",
"{",
"var",
"id",
"=",
"view",
".",
"cid",
";",
"output",
".",
"_jupyterWidgetViews",
"=",
"output",
".",
"_jupyterWidgetViews",
"||",
"[",
"]",
";",
"output",
".",
"_jupyterWidgetViews",
".",
"push",
"(",
"id",
")",
";",
"views",
"[",
"id",
"]",
"=",
"view",
";",
"PhosphorWidget",
".",
"Widget",
".",
"attach",
"(",
"view",
".",
"pWidget",
",",
"node",
")",
";",
"// Make the node completely disappear if the view is removed.",
"view",
".",
"once",
"(",
"'remove'",
",",
"(",
")",
"=>",
"{",
"// Since we have a mutable reference to the data, delete the",
"// model id to indicate the view is removed.",
"data",
".",
"model_id",
"=",
"''",
";",
"node",
".",
"style",
".",
"display",
"=",
"'none'",
";",
"}",
")",
"}",
")",
";",
"}",
"else",
"{",
"node",
".",
"textContent",
"=",
"'A Jupyter widget could not be displayed because the widget state could not be found. This could happen if the kernel storing the widget is no longer available, or if the widget state was not saved in the notebook. You may be able to create the widget by running the appropriate cells.'",
";",
"}",
"}"
] | Render data to the output area. | [
"Render",
"data",
"to",
"the",
"output",
"area",
"."
] | 36fe37594cd5a268def228709ca27e37b99ac606 | https://github.com/jupyter-widgets/ipywidgets/blob/36fe37594cd5a268def228709ca27e37b99ac606/widgetsnbextension/src/extension.js#L103-L139 |
6,649 | jupyter-widgets/ipywidgets | widgetsnbextension/src/extension.js | function(json, md, element) {
var toinsert = this.create_output_subarea(md, CLASS_NAME, MIME_TYPE);
this.keyboard_manager.register_events(toinsert);
render(this, json, toinsert[0]);
element.append(toinsert);
return toinsert;
} | javascript | function(json, md, element) {
var toinsert = this.create_output_subarea(md, CLASS_NAME, MIME_TYPE);
this.keyboard_manager.register_events(toinsert);
render(this, json, toinsert[0]);
element.append(toinsert);
return toinsert;
} | [
"function",
"(",
"json",
",",
"md",
",",
"element",
")",
"{",
"var",
"toinsert",
"=",
"this",
".",
"create_output_subarea",
"(",
"md",
",",
"CLASS_NAME",
",",
"MIME_TYPE",
")",
";",
"this",
".",
"keyboard_manager",
".",
"register_events",
"(",
"toinsert",
")",
";",
"render",
"(",
"this",
",",
"json",
",",
"toinsert",
"[",
"0",
"]",
")",
";",
"element",
".",
"append",
"(",
"toinsert",
")",
";",
"return",
"toinsert",
";",
"}"
] | `this` is the output area we are appending to | [
"this",
"is",
"the",
"output",
"area",
"we",
"are",
"appending",
"to"
] | 36fe37594cd5a268def228709ca27e37b99ac606 | https://github.com/jupyter-widgets/ipywidgets/blob/36fe37594cd5a268def228709ca27e37b99ac606/widgetsnbextension/src/extension.js#L142-L148 |
|
6,650 | jupyter-widgets/ipywidgets | examples/web1/index.js | createWidget | function createWidget(widgetType, value, description) {
// Create the widget model.
return manager.new_model({
model_module: '@jupyter-widgets/controls',
model_name: widgetType + 'Model',
model_id: 'widget-1'
// Create a view for the model.
}).then(function(model) {
console.log(widgetType + ' model created');
model.set({
description: description || '',
value: value,
});
return manager.create_view(model);
}, console.error.bind(console))
.then(function(view) {
console.log(widgetType + ' view created');
manager.display_view(null, view);
return view;
}, console.error.bind(console));
} | javascript | function createWidget(widgetType, value, description) {
// Create the widget model.
return manager.new_model({
model_module: '@jupyter-widgets/controls',
model_name: widgetType + 'Model',
model_id: 'widget-1'
// Create a view for the model.
}).then(function(model) {
console.log(widgetType + ' model created');
model.set({
description: description || '',
value: value,
});
return manager.create_view(model);
}, console.error.bind(console))
.then(function(view) {
console.log(widgetType + ' view created');
manager.display_view(null, view);
return view;
}, console.error.bind(console));
} | [
"function",
"createWidget",
"(",
"widgetType",
",",
"value",
",",
"description",
")",
"{",
"// Create the widget model.",
"return",
"manager",
".",
"new_model",
"(",
"{",
"model_module",
":",
"'@jupyter-widgets/controls'",
",",
"model_name",
":",
"widgetType",
"+",
"'Model'",
",",
"model_id",
":",
"'widget-1'",
"// Create a view for the model.",
"}",
")",
".",
"then",
"(",
"function",
"(",
"model",
")",
"{",
"console",
".",
"log",
"(",
"widgetType",
"+",
"' model created'",
")",
";",
"model",
".",
"set",
"(",
"{",
"description",
":",
"description",
"||",
"''",
",",
"value",
":",
"value",
",",
"}",
")",
";",
"return",
"manager",
".",
"create_view",
"(",
"model",
")",
";",
"}",
",",
"console",
".",
"error",
".",
"bind",
"(",
"console",
")",
")",
".",
"then",
"(",
"function",
"(",
"view",
")",
"{",
"console",
".",
"log",
"(",
"widgetType",
"+",
"' view created'",
")",
";",
"manager",
".",
"display_view",
"(",
"null",
",",
"view",
")",
";",
"return",
"view",
";",
"}",
",",
"console",
".",
"error",
".",
"bind",
"(",
"console",
")",
")",
";",
"}"
] | Helper function for creating and displaying widgets.
@return {Promise<WidgetView>} | [
"Helper",
"function",
"for",
"creating",
"and",
"displaying",
"widgets",
"."
] | 36fe37594cd5a268def228709ca27e37b99ac606 | https://github.com/jupyter-widgets/ipywidgets/blob/36fe37594cd5a268def228709ca27e37b99ac606/examples/web1/index.js#L13-L36 |
6,651 | jupyter-widgets/ipywidgets | scripts/package-integrity.js | getImports | function getImports(sourceFile) {
var imports = [];
handleNode(sourceFile);
function handleNode(node) {
switch (node.kind) {
case ts.SyntaxKind.ImportDeclaration:
imports.push(node.moduleSpecifier.text);
break;
case ts.SyntaxKind.ImportEqualsDeclaration:
imports.push(node.moduleReference.expression.text);
break;
}
ts.forEachChild(node, handleNode);
}
return imports;
} | javascript | function getImports(sourceFile) {
var imports = [];
handleNode(sourceFile);
function handleNode(node) {
switch (node.kind) {
case ts.SyntaxKind.ImportDeclaration:
imports.push(node.moduleSpecifier.text);
break;
case ts.SyntaxKind.ImportEqualsDeclaration:
imports.push(node.moduleReference.expression.text);
break;
}
ts.forEachChild(node, handleNode);
}
return imports;
} | [
"function",
"getImports",
"(",
"sourceFile",
")",
"{",
"var",
"imports",
"=",
"[",
"]",
";",
"handleNode",
"(",
"sourceFile",
")",
";",
"function",
"handleNode",
"(",
"node",
")",
"{",
"switch",
"(",
"node",
".",
"kind",
")",
"{",
"case",
"ts",
".",
"SyntaxKind",
".",
"ImportDeclaration",
":",
"imports",
".",
"push",
"(",
"node",
".",
"moduleSpecifier",
".",
"text",
")",
";",
"break",
";",
"case",
"ts",
".",
"SyntaxKind",
".",
"ImportEqualsDeclaration",
":",
"imports",
".",
"push",
"(",
"node",
".",
"moduleReference",
".",
"expression",
".",
"text",
")",
";",
"break",
";",
"}",
"ts",
".",
"forEachChild",
"(",
"node",
",",
"handleNode",
")",
";",
"}",
"return",
"imports",
";",
"}"
] | Extract the module imports from a TypeScript source file. | [
"Extract",
"the",
"module",
"imports",
"from",
"a",
"TypeScript",
"source",
"file",
"."
] | 36fe37594cd5a268def228709ca27e37b99ac606 | https://github.com/jupyter-widgets/ipywidgets/blob/36fe37594cd5a268def228709ca27e37b99ac606/scripts/package-integrity.js#L29-L45 |
6,652 | jupyter-widgets/ipywidgets | scripts/package-integrity.js | validate | function validate(dname) {
var filenames = glob.sync(dname + '/src/*.ts*');
filenames = filenames.concat(glob.sync(dname + '/src/**/*.ts*'));
if (filenames.length == 0) {
return [];
}
var imports = [];
try {
var pkg = require(path.resolve(dname) + '/package.json');
} catch (e) {
return [];
}
var ignore = IGNORE[pkg['name']] || [];
var deps = pkg['dependencies'];
// Extract all of the imports from the TypeScript files.
filenames.forEach(fileName => {
var sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);
imports = imports.concat(getImports(sourceFile));
//console.log(fileName, getImports(sourceFile));
});
var names = Array.from(new Set(imports)).sort();
names = names.map(function(name) {
var parts = name.split('/');
if (name.indexOf('@') === 0) {
return parts[0] + '/' + parts[1];
}
return parts[0];
})
var problems = [];
names.forEach(function(name) {
if (name === '..' || name === '.' || ignore.indexOf(name) !== -1) {
return;
}
if (!deps[name]) {
problems.push('Missing package: ' + name);
}
});
Object.keys(deps).forEach(function(name) {
if (versions[name]) {
var desired = '^' + versions[name];
if (deps[name] !== desired) {
problems.push('Bad core version: ' + name + ' should be ' + desired);
}
}
if (ignore.indexOf(name) !== -1) {
return;
}
if (names.indexOf(name) === -1) {
problems.push('Unused package: ' + name);
}
});
return problems;
} | javascript | function validate(dname) {
var filenames = glob.sync(dname + '/src/*.ts*');
filenames = filenames.concat(glob.sync(dname + '/src/**/*.ts*'));
if (filenames.length == 0) {
return [];
}
var imports = [];
try {
var pkg = require(path.resolve(dname) + '/package.json');
} catch (e) {
return [];
}
var ignore = IGNORE[pkg['name']] || [];
var deps = pkg['dependencies'];
// Extract all of the imports from the TypeScript files.
filenames.forEach(fileName => {
var sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);
imports = imports.concat(getImports(sourceFile));
//console.log(fileName, getImports(sourceFile));
});
var names = Array.from(new Set(imports)).sort();
names = names.map(function(name) {
var parts = name.split('/');
if (name.indexOf('@') === 0) {
return parts[0] + '/' + parts[1];
}
return parts[0];
})
var problems = [];
names.forEach(function(name) {
if (name === '..' || name === '.' || ignore.indexOf(name) !== -1) {
return;
}
if (!deps[name]) {
problems.push('Missing package: ' + name);
}
});
Object.keys(deps).forEach(function(name) {
if (versions[name]) {
var desired = '^' + versions[name];
if (deps[name] !== desired) {
problems.push('Bad core version: ' + name + ' should be ' + desired);
}
}
if (ignore.indexOf(name) !== -1) {
return;
}
if (names.indexOf(name) === -1) {
problems.push('Unused package: ' + name);
}
});
return problems;
} | [
"function",
"validate",
"(",
"dname",
")",
"{",
"var",
"filenames",
"=",
"glob",
".",
"sync",
"(",
"dname",
"+",
"'/src/*.ts*'",
")",
";",
"filenames",
"=",
"filenames",
".",
"concat",
"(",
"glob",
".",
"sync",
"(",
"dname",
"+",
"'/src/**/*.ts*'",
")",
")",
";",
"if",
"(",
"filenames",
".",
"length",
"==",
"0",
")",
"{",
"return",
"[",
"]",
";",
"}",
"var",
"imports",
"=",
"[",
"]",
";",
"try",
"{",
"var",
"pkg",
"=",
"require",
"(",
"path",
".",
"resolve",
"(",
"dname",
")",
"+",
"'/package.json'",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"return",
"[",
"]",
";",
"}",
"var",
"ignore",
"=",
"IGNORE",
"[",
"pkg",
"[",
"'name'",
"]",
"]",
"||",
"[",
"]",
";",
"var",
"deps",
"=",
"pkg",
"[",
"'dependencies'",
"]",
";",
"// Extract all of the imports from the TypeScript files.",
"filenames",
".",
"forEach",
"(",
"fileName",
"=>",
"{",
"var",
"sourceFile",
"=",
"ts",
".",
"createSourceFile",
"(",
"fileName",
",",
"readFileSync",
"(",
"fileName",
")",
".",
"toString",
"(",
")",
",",
"ts",
".",
"ScriptTarget",
".",
"ES6",
",",
"/*setParentNodes */",
"true",
")",
";",
"imports",
"=",
"imports",
".",
"concat",
"(",
"getImports",
"(",
"sourceFile",
")",
")",
";",
"//console.log(fileName, getImports(sourceFile));",
"}",
")",
";",
"var",
"names",
"=",
"Array",
".",
"from",
"(",
"new",
"Set",
"(",
"imports",
")",
")",
".",
"sort",
"(",
")",
";",
"names",
"=",
"names",
".",
"map",
"(",
"function",
"(",
"name",
")",
"{",
"var",
"parts",
"=",
"name",
".",
"split",
"(",
"'/'",
")",
";",
"if",
"(",
"name",
".",
"indexOf",
"(",
"'@'",
")",
"===",
"0",
")",
"{",
"return",
"parts",
"[",
"0",
"]",
"+",
"'/'",
"+",
"parts",
"[",
"1",
"]",
";",
"}",
"return",
"parts",
"[",
"0",
"]",
";",
"}",
")",
"var",
"problems",
"=",
"[",
"]",
";",
"names",
".",
"forEach",
"(",
"function",
"(",
"name",
")",
"{",
"if",
"(",
"name",
"===",
"'..'",
"||",
"name",
"===",
"'.'",
"||",
"ignore",
".",
"indexOf",
"(",
"name",
")",
"!==",
"-",
"1",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"deps",
"[",
"name",
"]",
")",
"{",
"problems",
".",
"push",
"(",
"'Missing package: '",
"+",
"name",
")",
";",
"}",
"}",
")",
";",
"Object",
".",
"keys",
"(",
"deps",
")",
".",
"forEach",
"(",
"function",
"(",
"name",
")",
"{",
"if",
"(",
"versions",
"[",
"name",
"]",
")",
"{",
"var",
"desired",
"=",
"'^'",
"+",
"versions",
"[",
"name",
"]",
";",
"if",
"(",
"deps",
"[",
"name",
"]",
"!==",
"desired",
")",
"{",
"problems",
".",
"push",
"(",
"'Bad core version: '",
"+",
"name",
"+",
"' should be '",
"+",
"desired",
")",
";",
"}",
"}",
"if",
"(",
"ignore",
".",
"indexOf",
"(",
"name",
")",
"!==",
"-",
"1",
")",
"{",
"return",
";",
"}",
"if",
"(",
"names",
".",
"indexOf",
"(",
"name",
")",
"===",
"-",
"1",
")",
"{",
"problems",
".",
"push",
"(",
"'Unused package: '",
"+",
"name",
")",
";",
"}",
"}",
")",
";",
"return",
"problems",
";",
"}"
] | Validate the integrity of a package in a directory. | [
"Validate",
"the",
"integrity",
"of",
"a",
"package",
"in",
"a",
"directory",
"."
] | 36fe37594cd5a268def228709ca27e37b99ac606 | https://github.com/jupyter-widgets/ipywidgets/blob/36fe37594cd5a268def228709ca27e37b99ac606/scripts/package-integrity.js#L50-L107 |
6,653 | jupyter-widgets/ipywidgets | scripts/update-dependency.js | handlePackage | function handlePackage(packagePath) {
// Read in the package.json.
var packagePath = path.join(packagePath, 'package.json');
try {
var package = require(packagePath);
} catch (e) {
console.log('Skipping package ' + packagePath);
return;
}
// Update dependencies as appropriate.
if (package.dependencies && target in package['dependencies']) {
package['dependencies'][target] = specifier;
} else if (package.devDependencies && target in package['devDependencies']) {
package['devDependencies'][target] = specifier;
}
// Write the file back to disk.
fs.writeFileSync(packagePath, JSON.stringify(package, null, 2) + '\n');
} | javascript | function handlePackage(packagePath) {
// Read in the package.json.
var packagePath = path.join(packagePath, 'package.json');
try {
var package = require(packagePath);
} catch (e) {
console.log('Skipping package ' + packagePath);
return;
}
// Update dependencies as appropriate.
if (package.dependencies && target in package['dependencies']) {
package['dependencies'][target] = specifier;
} else if (package.devDependencies && target in package['devDependencies']) {
package['devDependencies'][target] = specifier;
}
// Write the file back to disk.
fs.writeFileSync(packagePath, JSON.stringify(package, null, 2) + '\n');
} | [
"function",
"handlePackage",
"(",
"packagePath",
")",
"{",
"// Read in the package.json.",
"var",
"packagePath",
"=",
"path",
".",
"join",
"(",
"packagePath",
",",
"'package.json'",
")",
";",
"try",
"{",
"var",
"package",
"=",
"require",
"(",
"packagePath",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"console",
".",
"log",
"(",
"'Skipping package '",
"+",
"packagePath",
")",
";",
"return",
";",
"}",
"// Update dependencies as appropriate.",
"if",
"(",
"package",
".",
"dependencies",
"&&",
"target",
"in",
"package",
"[",
"'dependencies'",
"]",
")",
"{",
"package",
"[",
"'dependencies'",
"]",
"[",
"target",
"]",
"=",
"specifier",
";",
"}",
"else",
"if",
"(",
"package",
".",
"devDependencies",
"&&",
"target",
"in",
"package",
"[",
"'devDependencies'",
"]",
")",
"{",
"package",
"[",
"'devDependencies'",
"]",
"[",
"target",
"]",
"=",
"specifier",
";",
"}",
"// Write the file back to disk.",
"fs",
".",
"writeFileSync",
"(",
"packagePath",
",",
"JSON",
".",
"stringify",
"(",
"package",
",",
"null",
",",
"2",
")",
"+",
"'\\n'",
")",
";",
"}"
] | Handle an individual package on the path - update the dependency. | [
"Handle",
"an",
"individual",
"package",
"on",
"the",
"path",
"-",
"update",
"the",
"dependency",
"."
] | 36fe37594cd5a268def228709ca27e37b99ac606 | https://github.com/jupyter-widgets/ipywidgets/blob/36fe37594cd5a268def228709ca27e37b99ac606/scripts/update-dependency.js#L45-L64 |
6,654 | golden-layout/golden-layout | website/files/v0.9.2/js/goldenlayout.js | function( name, constructor ) {
if( typeof constructor !== 'function' ) {
throw new Error( 'Please register a constructor function' );
}
if( this._components[ name ] !== undefined ) {
throw new Error( 'Component ' + name + ' is already registered' );
}
this._components[ name ] = constructor;
} | javascript | function( name, constructor ) {
if( typeof constructor !== 'function' ) {
throw new Error( 'Please register a constructor function' );
}
if( this._components[ name ] !== undefined ) {
throw new Error( 'Component ' + name + ' is already registered' );
}
this._components[ name ] = constructor;
} | [
"function",
"(",
"name",
",",
"constructor",
")",
"{",
"if",
"(",
"typeof",
"constructor",
"!==",
"'function'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Please register a constructor function'",
")",
";",
"}",
"if",
"(",
"this",
".",
"_components",
"[",
"name",
"]",
"!==",
"undefined",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Component '",
"+",
"name",
"+",
"' is already registered'",
")",
";",
"}",
"this",
".",
"_components",
"[",
"name",
"]",
"=",
"constructor",
";",
"}"
] | Register a component with the layout manager. If a configuration node
of type component is reached it will look up componentName and create the
associated component
{
type: "component",
componentName: "EquityNewsFeed",
componentState: { "feedTopic": "us-bluechips" }
}
@param {String} name
@param {Function} constructor
@returns {void} | [
"Register",
"a",
"component",
"with",
"the",
"layout",
"manager",
".",
"If",
"a",
"configuration",
"node",
"of",
"type",
"component",
"is",
"reached",
"it",
"will",
"look",
"up",
"componentName",
"and",
"create",
"the",
"associated",
"component"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/website/files/v0.9.2/js/goldenlayout.js#L347-L357 |
|
6,655 | golden-layout/golden-layout | website/files/v0.9.2/js/goldenlayout.js | function() {
var config = $.extend( true, {}, this.config );
config.content = [];
var next = function( configNode, item ) {
var key, i;
for( key in item.config ) {
if( key !== 'content' ) {
configNode[ key ] = item.config[ key ];
}
}
if( item.contentItems.length ) {
configNode.content = [];
for( i = 0; i < item.contentItems.length; i++ ) {
configNode.content[ i ] = {};
next( configNode.content[ i ], item.contentItems[ i ] );
}
}
};
next( config, this.root );
return config;
} | javascript | function() {
var config = $.extend( true, {}, this.config );
config.content = [];
var next = function( configNode, item ) {
var key, i;
for( key in item.config ) {
if( key !== 'content' ) {
configNode[ key ] = item.config[ key ];
}
}
if( item.contentItems.length ) {
configNode.content = [];
for( i = 0; i < item.contentItems.length; i++ ) {
configNode.content[ i ] = {};
next( configNode.content[ i ], item.contentItems[ i ] );
}
}
};
next( config, this.root );
return config;
} | [
"function",
"(",
")",
"{",
"var",
"config",
"=",
"$",
".",
"extend",
"(",
"true",
",",
"{",
"}",
",",
"this",
".",
"config",
")",
";",
"config",
".",
"content",
"=",
"[",
"]",
";",
"var",
"next",
"=",
"function",
"(",
"configNode",
",",
"item",
")",
"{",
"var",
"key",
",",
"i",
";",
"for",
"(",
"key",
"in",
"item",
".",
"config",
")",
"{",
"if",
"(",
"key",
"!==",
"'content'",
")",
"{",
"configNode",
"[",
"key",
"]",
"=",
"item",
".",
"config",
"[",
"key",
"]",
";",
"}",
"}",
"if",
"(",
"item",
".",
"contentItems",
".",
"length",
")",
"{",
"configNode",
".",
"content",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"item",
".",
"contentItems",
".",
"length",
";",
"i",
"++",
")",
"{",
"configNode",
".",
"content",
"[",
"i",
"]",
"=",
"{",
"}",
";",
"next",
"(",
"configNode",
".",
"content",
"[",
"i",
"]",
",",
"item",
".",
"contentItems",
"[",
"i",
"]",
")",
";",
"}",
"}",
"}",
";",
"next",
"(",
"config",
",",
"this",
".",
"root",
")",
";",
"return",
"config",
";",
"}"
] | Creates a layout configuration out of the current state
@returns {Object} GoldenLayout configuration | [
"Creates",
"a",
"layout",
"configuration",
"out",
"of",
"the",
"current",
"state"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/website/files/v0.9.2/js/goldenlayout.js#L364-L389 |
|
6,656 | golden-layout/golden-layout | website/files/v0.9.2/js/goldenlayout.js | function( name ) {
if( this._components[ name ] === undefined ) {
throw new lm.errors.ConfigurationError( 'Unknown component ' + name );
}
return this._components[ name ];
} | javascript | function( name ) {
if( this._components[ name ] === undefined ) {
throw new lm.errors.ConfigurationError( 'Unknown component ' + name );
}
return this._components[ name ];
} | [
"function",
"(",
"name",
")",
"{",
"if",
"(",
"this",
".",
"_components",
"[",
"name",
"]",
"===",
"undefined",
")",
"{",
"throw",
"new",
"lm",
".",
"errors",
".",
"ConfigurationError",
"(",
"'Unknown component '",
"+",
"name",
")",
";",
"}",
"return",
"this",
".",
"_components",
"[",
"name",
"]",
";",
"}"
] | Returns a previously registered component
@param {String} name The name used
@returns {Function} | [
"Returns",
"a",
"previously",
"registered",
"component"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/website/files/v0.9.2/js/goldenlayout.js#L398-L404 |
|
6,657 | golden-layout/golden-layout | website/files/v0.9.2/js/goldenlayout.js | function() {
if( document.readyState === 'loading' || document.body === null ) {
$(document).ready( lm.utils.fnBind( this.init, this ));
return;
}
this._setContainer();
this.dropTargetIndicator = new lm.controls.DropTargetIndicator( this.container );
this.transitionIndicator = new lm.controls.TransitionIndicator();
this.updateSize();
this._create( this.config );
this._bindEvents();
this.isInitialised = true;
this.emit( 'initialised' );
} | javascript | function() {
if( document.readyState === 'loading' || document.body === null ) {
$(document).ready( lm.utils.fnBind( this.init, this ));
return;
}
this._setContainer();
this.dropTargetIndicator = new lm.controls.DropTargetIndicator( this.container );
this.transitionIndicator = new lm.controls.TransitionIndicator();
this.updateSize();
this._create( this.config );
this._bindEvents();
this.isInitialised = true;
this.emit( 'initialised' );
} | [
"function",
"(",
")",
"{",
"if",
"(",
"document",
".",
"readyState",
"===",
"'loading'",
"||",
"document",
".",
"body",
"===",
"null",
")",
"{",
"$",
"(",
"document",
")",
".",
"ready",
"(",
"lm",
".",
"utils",
".",
"fnBind",
"(",
"this",
".",
"init",
",",
"this",
")",
")",
";",
"return",
";",
"}",
"this",
".",
"_setContainer",
"(",
")",
";",
"this",
".",
"dropTargetIndicator",
"=",
"new",
"lm",
".",
"controls",
".",
"DropTargetIndicator",
"(",
"this",
".",
"container",
")",
";",
"this",
".",
"transitionIndicator",
"=",
"new",
"lm",
".",
"controls",
".",
"TransitionIndicator",
"(",
")",
";",
"this",
".",
"updateSize",
"(",
")",
";",
"this",
".",
"_create",
"(",
"this",
".",
"config",
")",
";",
"this",
".",
"_bindEvents",
"(",
")",
";",
"this",
".",
"isInitialised",
"=",
"true",
";",
"this",
".",
"emit",
"(",
"'initialised'",
")",
";",
"}"
] | Creates the actual layout. Must be called after all initial components
are registered. Recourses through the configuration and sets up
the item tree.
If called before the document is ready it adds itself as a listener
to the document.ready event
@returns {void} | [
"Creates",
"the",
"actual",
"layout",
".",
"Must",
"be",
"called",
"after",
"all",
"initial",
"components",
"are",
"registered",
".",
"Recourses",
"through",
"the",
"configuration",
"and",
"sets",
"up",
"the",
"item",
"tree",
"."
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/website/files/v0.9.2/js/goldenlayout.js#L416-L431 |
|
6,658 | golden-layout/golden-layout | website/files/v0.9.2/js/goldenlayout.js | function( config, parent ) {
var typeErrorMsg, contentItem;
if( typeof config.type !== 'string' ) {
throw new lm.errors.ConfigurationError( 'Missing parameter \'type\'', config );
}
if( !this._typeToItem[ config.type ] ) {
typeErrorMsg = 'Unknown type \'' + config.type + '\'. ' +
'Valid types are ' + lm.utils.objectKeys( this._typeToItem ).join( ',' );
throw new lm.errors.ConfigurationError( typeErrorMsg );
}
/**
* We add an additional stack around every component that's not within a stack anyways
*/
if( config.type === 'component' && !( parent instanceof lm.items.Stack ) && !!parent ) {
config = {
type: 'stack',
isClosable: config.isClosable,
width: config.width,
height: config.height,
content: [ config ]
};
}
contentItem = new this._typeToItem[ config.type ]( this, config, parent );
return contentItem;
} | javascript | function( config, parent ) {
var typeErrorMsg, contentItem;
if( typeof config.type !== 'string' ) {
throw new lm.errors.ConfigurationError( 'Missing parameter \'type\'', config );
}
if( !this._typeToItem[ config.type ] ) {
typeErrorMsg = 'Unknown type \'' + config.type + '\'. ' +
'Valid types are ' + lm.utils.objectKeys( this._typeToItem ).join( ',' );
throw new lm.errors.ConfigurationError( typeErrorMsg );
}
/**
* We add an additional stack around every component that's not within a stack anyways
*/
if( config.type === 'component' && !( parent instanceof lm.items.Stack ) && !!parent ) {
config = {
type: 'stack',
isClosable: config.isClosable,
width: config.width,
height: config.height,
content: [ config ]
};
}
contentItem = new this._typeToItem[ config.type ]( this, config, parent );
return contentItem;
} | [
"function",
"(",
"config",
",",
"parent",
")",
"{",
"var",
"typeErrorMsg",
",",
"contentItem",
";",
"if",
"(",
"typeof",
"config",
".",
"type",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"lm",
".",
"errors",
".",
"ConfigurationError",
"(",
"'Missing parameter \\'type\\''",
",",
"config",
")",
";",
"}",
"if",
"(",
"!",
"this",
".",
"_typeToItem",
"[",
"config",
".",
"type",
"]",
")",
"{",
"typeErrorMsg",
"=",
"'Unknown type \\''",
"+",
"config",
".",
"type",
"+",
"'\\'. '",
"+",
"'Valid types are '",
"+",
"lm",
".",
"utils",
".",
"objectKeys",
"(",
"this",
".",
"_typeToItem",
")",
".",
"join",
"(",
"','",
")",
";",
"throw",
"new",
"lm",
".",
"errors",
".",
"ConfigurationError",
"(",
"typeErrorMsg",
")",
";",
"}",
"/**\n\t\t * We add an additional stack around every component that's not within a stack anyways\n\t\t */",
"if",
"(",
"config",
".",
"type",
"===",
"'component'",
"&&",
"!",
"(",
"parent",
"instanceof",
"lm",
".",
"items",
".",
"Stack",
")",
"&&",
"!",
"!",
"parent",
")",
"{",
"config",
"=",
"{",
"type",
":",
"'stack'",
",",
"isClosable",
":",
"config",
".",
"isClosable",
",",
"width",
":",
"config",
".",
"width",
",",
"height",
":",
"config",
".",
"height",
",",
"content",
":",
"[",
"config",
"]",
"}",
";",
"}",
"contentItem",
"=",
"new",
"this",
".",
"_typeToItem",
"[",
"config",
".",
"type",
"]",
"(",
"this",
",",
"config",
",",
"parent",
")",
";",
"return",
"contentItem",
";",
"}"
] | Recoursively creates new item tree structures based on a provided
ItemConfiguration object
@param {Object} config ItemConfig
@param {[ContentItem]} parent The item the newly created item should be a child of
@returns {lm.items.ContentItem} | [
"Recoursively",
"creates",
"new",
"item",
"tree",
"structures",
"based",
"on",
"a",
"provided",
"ItemConfiguration",
"object"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/website/files/v0.9.2/js/goldenlayout.js#L482-L513 |
|
6,659 | golden-layout/golden-layout | website/files/v0.9.2/js/goldenlayout.js | function( contentItem, index ) {
var tab = new lm.controls.Tab( this, contentItem );
if( this.tabs.length === 0 ) {
this.tabs.push( tab );
this.tabsContainer.append( tab.element );
return;
}
if( index === undefined ) {
index = this.tabs.length;
}
if( index > 0 ) {
this.tabs[ index - 1 ].element.after( tab.element );
} else {
this.tabs[ 0 ].element.before( tab.element );
}
this.tabs.splice( index, 0, tab );
} | javascript | function( contentItem, index ) {
var tab = new lm.controls.Tab( this, contentItem );
if( this.tabs.length === 0 ) {
this.tabs.push( tab );
this.tabsContainer.append( tab.element );
return;
}
if( index === undefined ) {
index = this.tabs.length;
}
if( index > 0 ) {
this.tabs[ index - 1 ].element.after( tab.element );
} else {
this.tabs[ 0 ].element.before( tab.element );
}
this.tabs.splice( index, 0, tab );
} | [
"function",
"(",
"contentItem",
",",
"index",
")",
"{",
"var",
"tab",
"=",
"new",
"lm",
".",
"controls",
".",
"Tab",
"(",
"this",
",",
"contentItem",
")",
";",
"if",
"(",
"this",
".",
"tabs",
".",
"length",
"===",
"0",
")",
"{",
"this",
".",
"tabs",
".",
"push",
"(",
"tab",
")",
";",
"this",
".",
"tabsContainer",
".",
"append",
"(",
"tab",
".",
"element",
")",
";",
"return",
";",
"}",
"if",
"(",
"index",
"===",
"undefined",
")",
"{",
"index",
"=",
"this",
".",
"tabs",
".",
"length",
";",
"}",
"if",
"(",
"index",
">",
"0",
")",
"{",
"this",
".",
"tabs",
"[",
"index",
"-",
"1",
"]",
".",
"element",
".",
"after",
"(",
"tab",
".",
"element",
")",
";",
"}",
"else",
"{",
"this",
".",
"tabs",
"[",
"0",
"]",
".",
"element",
".",
"before",
"(",
"tab",
".",
"element",
")",
";",
"}",
"this",
".",
"tabs",
".",
"splice",
"(",
"index",
",",
"0",
",",
"tab",
")",
";",
"}"
] | Creates a new tab and associates it with a contentItem
@param {lm.item.AbstractContentItem} contentItem
@param {Integer} index The position of the tab
@returns {void} | [
"Creates",
"a",
"new",
"tab",
"and",
"associates",
"it",
"with",
"a",
"contentItem"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/website/files/v0.9.2/js/goldenlayout.js#L1265-L1285 |
|
6,660 | golden-layout/golden-layout | website/files/v0.9.2/js/goldenlayout.js | function( contentItem ) {
for( var i = 0; i < this.tabs.length; i++ ) {
if( this.tabs[ i ].contentItem === contentItem ) {
this.tabs[ i ]._$destroy();
this.tabs.splice( i, 1 );
return;
}
}
throw new Error( 'contentItem is not controlled by this header' );
} | javascript | function( contentItem ) {
for( var i = 0; i < this.tabs.length; i++ ) {
if( this.tabs[ i ].contentItem === contentItem ) {
this.tabs[ i ]._$destroy();
this.tabs.splice( i, 1 );
return;
}
}
throw new Error( 'contentItem is not controlled by this header' );
} | [
"function",
"(",
"contentItem",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"tabs",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"this",
".",
"tabs",
"[",
"i",
"]",
".",
"contentItem",
"===",
"contentItem",
")",
"{",
"this",
".",
"tabs",
"[",
"i",
"]",
".",
"_$destroy",
"(",
")",
";",
"this",
".",
"tabs",
".",
"splice",
"(",
"i",
",",
"1",
")",
";",
"return",
";",
"}",
"}",
"throw",
"new",
"Error",
"(",
"'contentItem is not controlled by this header'",
")",
";",
"}"
] | Finds a tab based on the contentItem its associated with and removes it.
@param {lm.item.AbstractContentItem} contentItem
@returns {void} | [
"Finds",
"a",
"tab",
"based",
"on",
"the",
"contentItem",
"its",
"associated",
"with",
"and",
"removes",
"it",
"."
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/website/files/v0.9.2/js/goldenlayout.js#L1294-L1304 |
|
6,661 | golden-layout/golden-layout | website/files/v0.9.2/js/goldenlayout.js | function() {
var availableWidth = this.element.outerWidth() - this.controlsContainer.outerWidth(),
totalTabWidth = 0,
tabElement,
i,
marginLeft,
gap;
for( i = 0; i < this.tabs.length; i++ ) {
tabElement = this.tabs[ i ].element;
/*
* In order to show every tab's close icon, decrement the z-index from left to right
*/
tabElement.css( 'z-index', this.tabs.length - i );
totalTabWidth += tabElement.outerWidth() + parseInt( tabElement.css( 'margin-right' ), 10 );
}
gap = ( totalTabWidth - availableWidth ) / ( this.tabs.length - 1 )
for( i = 0; i < this.tabs.length; i++ ) {
/*
* The active tab keeps it's original width
*/
if( !this.tabs[ i ].isActive && gap > 0 ) {
marginLeft = '-' + Math.floor( gap )+ 'px';
} else {
marginLeft = '';
}
this.tabs[ i ].element.css( 'margin-left', marginLeft );
}
if( this.element.outerWidth() < this.tabs[ 0 ].element.outerWidth() ) {
this.element.css( 'overflow', 'hidden' );
} else {
this.element.css( 'overflow', 'visible' );
}
} | javascript | function() {
var availableWidth = this.element.outerWidth() - this.controlsContainer.outerWidth(),
totalTabWidth = 0,
tabElement,
i,
marginLeft,
gap;
for( i = 0; i < this.tabs.length; i++ ) {
tabElement = this.tabs[ i ].element;
/*
* In order to show every tab's close icon, decrement the z-index from left to right
*/
tabElement.css( 'z-index', this.tabs.length - i );
totalTabWidth += tabElement.outerWidth() + parseInt( tabElement.css( 'margin-right' ), 10 );
}
gap = ( totalTabWidth - availableWidth ) / ( this.tabs.length - 1 )
for( i = 0; i < this.tabs.length; i++ ) {
/*
* The active tab keeps it's original width
*/
if( !this.tabs[ i ].isActive && gap > 0 ) {
marginLeft = '-' + Math.floor( gap )+ 'px';
} else {
marginLeft = '';
}
this.tabs[ i ].element.css( 'margin-left', marginLeft );
}
if( this.element.outerWidth() < this.tabs[ 0 ].element.outerWidth() ) {
this.element.css( 'overflow', 'hidden' );
} else {
this.element.css( 'overflow', 'visible' );
}
} | [
"function",
"(",
")",
"{",
"var",
"availableWidth",
"=",
"this",
".",
"element",
".",
"outerWidth",
"(",
")",
"-",
"this",
".",
"controlsContainer",
".",
"outerWidth",
"(",
")",
",",
"totalTabWidth",
"=",
"0",
",",
"tabElement",
",",
"i",
",",
"marginLeft",
",",
"gap",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"tabs",
".",
"length",
";",
"i",
"++",
")",
"{",
"tabElement",
"=",
"this",
".",
"tabs",
"[",
"i",
"]",
".",
"element",
";",
"/*\n\t\t\t * In order to show every tab's close icon, decrement the z-index from left to right\n\t\t\t */",
"tabElement",
".",
"css",
"(",
"'z-index'",
",",
"this",
".",
"tabs",
".",
"length",
"-",
"i",
")",
";",
"totalTabWidth",
"+=",
"tabElement",
".",
"outerWidth",
"(",
")",
"+",
"parseInt",
"(",
"tabElement",
".",
"css",
"(",
"'margin-right'",
")",
",",
"10",
")",
";",
"}",
"gap",
"=",
"(",
"totalTabWidth",
"-",
"availableWidth",
")",
"/",
"(",
"this",
".",
"tabs",
".",
"length",
"-",
"1",
")",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"tabs",
".",
"length",
";",
"i",
"++",
")",
"{",
"/*\n\t\t\t * The active tab keeps it's original width\n\t\t\t */",
"if",
"(",
"!",
"this",
".",
"tabs",
"[",
"i",
"]",
".",
"isActive",
"&&",
"gap",
">",
"0",
")",
"{",
"marginLeft",
"=",
"'-'",
"+",
"Math",
".",
"floor",
"(",
"gap",
")",
"+",
"'px'",
";",
"}",
"else",
"{",
"marginLeft",
"=",
"''",
";",
"}",
"this",
".",
"tabs",
"[",
"i",
"]",
".",
"element",
".",
"css",
"(",
"'margin-left'",
",",
"marginLeft",
")",
";",
"}",
"if",
"(",
"this",
".",
"element",
".",
"outerWidth",
"(",
")",
"<",
"this",
".",
"tabs",
"[",
"0",
"]",
".",
"element",
".",
"outerWidth",
"(",
")",
")",
"{",
"this",
".",
"element",
".",
"css",
"(",
"'overflow'",
",",
"'hidden'",
")",
";",
"}",
"else",
"{",
"this",
".",
"element",
".",
"css",
"(",
"'overflow'",
",",
"'visible'",
")",
";",
"}",
"}"
] | Shrinks the tabs if the available space is not sufficient
@returns {void} | [
"Shrinks",
"the",
"tabs",
"if",
"the",
"available",
"space",
"is",
"not",
"sufficient"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/website/files/v0.9.2/js/goldenlayout.js#L1386-L1425 |
|
6,662 | golden-layout/golden-layout | website/files/v0.9.2/js/goldenlayout.js | function( functionName, functionArguments, bottomUp, skipSelf ) {
var i;
if( bottomUp !== true && skipSelf !== true ) {
this[ functionName ].apply( this, functionArguments || [] );
}
for( i = 0; i < this.contentItems.length; i++ ) {
this.contentItems[ i ].callDownwards( functionName, functionArguments, bottomUp );
}
if( bottomUp === true && skipSelf !== true ) {
this[ functionName ].apply( this, functionArguments || [] );
}
} | javascript | function( functionName, functionArguments, bottomUp, skipSelf ) {
var i;
if( bottomUp !== true && skipSelf !== true ) {
this[ functionName ].apply( this, functionArguments || [] );
}
for( i = 0; i < this.contentItems.length; i++ ) {
this.contentItems[ i ].callDownwards( functionName, functionArguments, bottomUp );
}
if( bottomUp === true && skipSelf !== true ) {
this[ functionName ].apply( this, functionArguments || [] );
}
} | [
"function",
"(",
"functionName",
",",
"functionArguments",
",",
"bottomUp",
",",
"skipSelf",
")",
"{",
"var",
"i",
";",
"if",
"(",
"bottomUp",
"!==",
"true",
"&&",
"skipSelf",
"!==",
"true",
")",
"{",
"this",
"[",
"functionName",
"]",
".",
"apply",
"(",
"this",
",",
"functionArguments",
"||",
"[",
"]",
")",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"contentItems",
".",
"length",
";",
"i",
"++",
")",
"{",
"this",
".",
"contentItems",
"[",
"i",
"]",
".",
"callDownwards",
"(",
"functionName",
",",
"functionArguments",
",",
"bottomUp",
")",
";",
"}",
"if",
"(",
"bottomUp",
"===",
"true",
"&&",
"skipSelf",
"!==",
"true",
")",
"{",
"this",
"[",
"functionName",
"]",
".",
"apply",
"(",
"this",
",",
"functionArguments",
"||",
"[",
"]",
")",
";",
"}",
"}"
] | Calls a method recoursively downwards on the tree
@param {String} functionName the name of the function to be called
@param {[Array]}functionArguments optional arguments that are passed to every function
@param {[bool]} bottomUp Call methods from bottom to top, defaults to false
@param {[bool]} skipSelf Don't invoke the method on the class that calls it, defaults to false
@returns {void} | [
"Calls",
"a",
"method",
"recoursively",
"downwards",
"on",
"the",
"tree"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/website/files/v0.9.2/js/goldenlayout.js#L1699-L1711 |
|
6,663 | golden-layout/golden-layout | website/files/v0.9.2/js/goldenlayout.js | function( element ) {
element = element || this.element;
var offset = element.offset(),
width = element.width(),
height = element.height();
return {
x1: offset.left,
y1: offset.top,
x2: offset.left + width,
y2: offset.top + height,
surface: width * height,
contentItem: this
};
} | javascript | function( element ) {
element = element || this.element;
var offset = element.offset(),
width = element.width(),
height = element.height();
return {
x1: offset.left,
y1: offset.top,
x2: offset.left + width,
y2: offset.top + height,
surface: width * height,
contentItem: this
};
} | [
"function",
"(",
"element",
")",
"{",
"element",
"=",
"element",
"||",
"this",
".",
"element",
";",
"var",
"offset",
"=",
"element",
".",
"offset",
"(",
")",
",",
"width",
"=",
"element",
".",
"width",
"(",
")",
",",
"height",
"=",
"element",
".",
"height",
"(",
")",
";",
"return",
"{",
"x1",
":",
"offset",
".",
"left",
",",
"y1",
":",
"offset",
".",
"top",
",",
"x2",
":",
"offset",
".",
"left",
"+",
"width",
",",
"y2",
":",
"offset",
".",
"top",
"+",
"height",
",",
"surface",
":",
"width",
"*",
"height",
",",
"contentItem",
":",
"this",
"}",
";",
"}"
] | Returns the area the component currently occupies in the format
{
x1: int
xy: int
y1: int
y2: int
contentItem: contentItem
} | [
"Returns",
"the",
"area",
"the",
"component",
"currently",
"occupies",
"in",
"the",
"format"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/website/files/v0.9.2/js/goldenlayout.js#L1961-L1976 |
|
6,664 | golden-layout/golden-layout | website/files/v0.9.2/js/goldenlayout.js | function( name, event ) {
if( event instanceof lm.utils.BubblingEvent &&
event.isPropagationStopped === false &&
this.isInitialised === true ) {
/**
* In some cases (e.g. if an element is created from a DragSource) it
* doesn't have a parent and is not below root. If that's the case
* propagate the bubbling event from the top level of the substree directly
* to the layoutManager
*/
if( this.isRoot === false && this.parent ) {
this.parent.emit.apply( this.parent, Array.prototype.slice.call( arguments, 0 ) );
} else {
this._scheduleEventPropagationToLayoutManager( name, event );
}
}
} | javascript | function( name, event ) {
if( event instanceof lm.utils.BubblingEvent &&
event.isPropagationStopped === false &&
this.isInitialised === true ) {
/**
* In some cases (e.g. if an element is created from a DragSource) it
* doesn't have a parent and is not below root. If that's the case
* propagate the bubbling event from the top level of the substree directly
* to the layoutManager
*/
if( this.isRoot === false && this.parent ) {
this.parent.emit.apply( this.parent, Array.prototype.slice.call( arguments, 0 ) );
} else {
this._scheduleEventPropagationToLayoutManager( name, event );
}
}
} | [
"function",
"(",
"name",
",",
"event",
")",
"{",
"if",
"(",
"event",
"instanceof",
"lm",
".",
"utils",
".",
"BubblingEvent",
"&&",
"event",
".",
"isPropagationStopped",
"===",
"false",
"&&",
"this",
".",
"isInitialised",
"===",
"true",
")",
"{",
"/**\n\t\t\t * In some cases (e.g. if an element is created from a DragSource) it\n\t\t\t * doesn't have a parent and is not below root. If that's the case\n\t\t\t * propagate the bubbling event from the top level of the substree directly\n\t\t\t * to the layoutManager\n\t\t\t */",
"if",
"(",
"this",
".",
"isRoot",
"===",
"false",
"&&",
"this",
".",
"parent",
")",
"{",
"this",
".",
"parent",
".",
"emit",
".",
"apply",
"(",
"this",
".",
"parent",
",",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
")",
";",
"}",
"else",
"{",
"this",
".",
"_scheduleEventPropagationToLayoutManager",
"(",
"name",
",",
"event",
")",
";",
"}",
"}",
"}"
] | Called for every event on the item tree. Decides whether the event is a bubbling
event and propagates it to its parent
@param {String} name the name of the event
@param {lm.utils.BubblingEvent} event
@returns {void} | [
"Called",
"for",
"every",
"event",
"on",
"the",
"item",
"tree",
".",
"Decides",
"whether",
"the",
"event",
"is",
"a",
"bubbling",
"event",
"and",
"propagates",
"it",
"to",
"its",
"parent"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/website/files/v0.9.2/js/goldenlayout.js#L2062-L2079 |
|
6,665 | golden-layout/golden-layout | website/files/v0.9.2/js/goldenlayout.js | function( name, event ) {
if( lm.utils.indexOf( name, this._throttledEvents ) === -1 ) {
this.layoutManager.emit( name, event.origin );
} else {
if( this._pendingEventPropagations[ name ] !== true ) {
this._pendingEventPropagations[ name ] = true;
lm.utils.animFrame( lm.utils.fnBind( this._propagateEventToLayoutManager, this, [ name, event ] ) );
}
}
} | javascript | function( name, event ) {
if( lm.utils.indexOf( name, this._throttledEvents ) === -1 ) {
this.layoutManager.emit( name, event.origin );
} else {
if( this._pendingEventPropagations[ name ] !== true ) {
this._pendingEventPropagations[ name ] = true;
lm.utils.animFrame( lm.utils.fnBind( this._propagateEventToLayoutManager, this, [ name, event ] ) );
}
}
} | [
"function",
"(",
"name",
",",
"event",
")",
"{",
"if",
"(",
"lm",
".",
"utils",
".",
"indexOf",
"(",
"name",
",",
"this",
".",
"_throttledEvents",
")",
"===",
"-",
"1",
")",
"{",
"this",
".",
"layoutManager",
".",
"emit",
"(",
"name",
",",
"event",
".",
"origin",
")",
";",
"}",
"else",
"{",
"if",
"(",
"this",
".",
"_pendingEventPropagations",
"[",
"name",
"]",
"!==",
"true",
")",
"{",
"this",
".",
"_pendingEventPropagations",
"[",
"name",
"]",
"=",
"true",
";",
"lm",
".",
"utils",
".",
"animFrame",
"(",
"lm",
".",
"utils",
".",
"fnBind",
"(",
"this",
".",
"_propagateEventToLayoutManager",
",",
"this",
",",
"[",
"name",
",",
"event",
"]",
")",
")",
";",
"}",
"}",
"}"
] | All raw events bubble up to the root element. Some events that
are propagated to - and emitted by - the layoutManager however are
only string-based, batched and sanitized to make them more usable
@param {String} name the name of the event
@private
@returns {void} | [
"All",
"raw",
"events",
"bubble",
"up",
"to",
"the",
"root",
"element",
".",
"Some",
"events",
"that",
"are",
"propagated",
"to",
"-",
"and",
"emitted",
"by",
"-",
"the",
"layoutManager",
"however",
"are",
"only",
"string",
"-",
"based",
"batched",
"and",
"sanitized",
"to",
"make",
"them",
"more",
"usable"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/website/files/v0.9.2/js/goldenlayout.js#L2091-L2101 |
|
6,666 | golden-layout/golden-layout | website/files/v0.9.2/js/goldenlayout.js | function( oldChild, newChild ) {
var size = oldChild.config[ this._dimension ];
lm.items.AbstractContentItem.prototype.replaceChild.call( this, oldChild, newChild );
newChild.config[ this._dimension ] = size;
this.callDownwards( 'setSize' );
this.emitBubblingEvent( 'stateChanged' );
} | javascript | function( oldChild, newChild ) {
var size = oldChild.config[ this._dimension ];
lm.items.AbstractContentItem.prototype.replaceChild.call( this, oldChild, newChild );
newChild.config[ this._dimension ] = size;
this.callDownwards( 'setSize' );
this.emitBubblingEvent( 'stateChanged' );
} | [
"function",
"(",
"oldChild",
",",
"newChild",
")",
"{",
"var",
"size",
"=",
"oldChild",
".",
"config",
"[",
"this",
".",
"_dimension",
"]",
";",
"lm",
".",
"items",
".",
"AbstractContentItem",
".",
"prototype",
".",
"replaceChild",
".",
"call",
"(",
"this",
",",
"oldChild",
",",
"newChild",
")",
";",
"newChild",
".",
"config",
"[",
"this",
".",
"_dimension",
"]",
"=",
"size",
";",
"this",
".",
"callDownwards",
"(",
"'setSize'",
")",
";",
"this",
".",
"emitBubblingEvent",
"(",
"'stateChanged'",
")",
";",
"}"
] | Replaces a child of this Row or Column with another contentItem
@param {lm.items.AbstractContentItem} oldChild
@param {lm.items.AbstractContentItem} newChild
@returns {void} | [
"Replaces",
"a",
"child",
"of",
"this",
"Row",
"or",
"Column",
"with",
"another",
"contentItem"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/website/files/v0.9.2/js/goldenlayout.js#L2354-L2360 |
|
6,667 | golden-layout/golden-layout | website/files/v0.9.2/js/goldenlayout.js | function() {
if( this.isInitialised === true ) return;
var i;
lm.items.AbstractContentItem.prototype._$init.call( this );
for( i = 0; i < this.contentItems.length - 1; i++ ) {
this.contentItems[ i ].element.after( this._createSplitter( i ).element );
}
} | javascript | function() {
if( this.isInitialised === true ) return;
var i;
lm.items.AbstractContentItem.prototype._$init.call( this );
for( i = 0; i < this.contentItems.length - 1; i++ ) {
this.contentItems[ i ].element.after( this._createSplitter( i ).element );
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"isInitialised",
"===",
"true",
")",
"return",
";",
"var",
"i",
";",
"lm",
".",
"items",
".",
"AbstractContentItem",
".",
"prototype",
".",
"_$init",
".",
"call",
"(",
"this",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"contentItems",
".",
"length",
"-",
"1",
";",
"i",
"++",
")",
"{",
"this",
".",
"contentItems",
"[",
"i",
"]",
".",
"element",
".",
"after",
"(",
"this",
".",
"_createSplitter",
"(",
"i",
")",
".",
"element",
")",
";",
"}",
"}"
] | Invoked recoursively by the layout manager. AbstractContentItem.init appends
the contentItem's DOM elements to the container, RowOrColumn init adds splitters
in between them
@package private
@override AbstractContentItem._$init
@returns {void} | [
"Invoked",
"recoursively",
"by",
"the",
"layout",
"manager",
".",
"AbstractContentItem",
".",
"init",
"appends",
"the",
"contentItem",
"s",
"DOM",
"elements",
"to",
"the",
"container",
"RowOrColumn",
"init",
"adds",
"splitters",
"in",
"between",
"them"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/website/files/v0.9.2/js/goldenlayout.js#L2385-L2395 |
|
6,668 | golden-layout/golden-layout | website/files/v0.9.2/js/goldenlayout.js | function( splitter ) {
var index = lm.utils.indexOf( splitter, this._splitter );
return {
before: this.contentItems[ index ],
after: this.contentItems[ index + 1 ]
};
} | javascript | function( splitter ) {
var index = lm.utils.indexOf( splitter, this._splitter );
return {
before: this.contentItems[ index ],
after: this.contentItems[ index + 1 ]
};
} | [
"function",
"(",
"splitter",
")",
"{",
"var",
"index",
"=",
"lm",
".",
"utils",
".",
"indexOf",
"(",
"splitter",
",",
"this",
".",
"_splitter",
")",
";",
"return",
"{",
"before",
":",
"this",
".",
"contentItems",
"[",
"index",
"]",
",",
"after",
":",
"this",
".",
"contentItems",
"[",
"index",
"+",
"1",
"]",
"}",
";",
"}"
] | Locates the instance of lm.controls.Splitter in the array of
registered splitters and returns a map containing the contentItem
before and after the splitters, both of which are affected if the
splitter is moved
@param {lm.controls.Splitter} splitter
@returns {Object} A map of contentItems that the splitter affects | [
"Locates",
"the",
"instance",
"of",
"lm",
".",
"controls",
".",
"Splitter",
"in",
"the",
"array",
"of",
"registered",
"splitters",
"and",
"returns",
"a",
"map",
"containing",
"the",
"contentItem",
"before",
"and",
"after",
"the",
"splitters",
"both",
"of",
"which",
"are",
"affected",
"if",
"the",
"splitter",
"is",
"moved"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/website/files/v0.9.2/js/goldenlayout.js#L2554-L2561 |
|
6,669 | golden-layout/golden-layout | website/files/v0.9.2/js/goldenlayout.js | function( splitter, offsetX, offsetY ) {
var offset = this._isColumn ? offsetY : offsetX;
if( offset > this._splitterMinPosition && offset < this._splitterMaxPosition ) {
this._splitterPosition = offset;
splitter.element.css( this._isColumn ? 'top' : 'left', offset );
}
} | javascript | function( splitter, offsetX, offsetY ) {
var offset = this._isColumn ? offsetY : offsetX;
if( offset > this._splitterMinPosition && offset < this._splitterMaxPosition ) {
this._splitterPosition = offset;
splitter.element.css( this._isColumn ? 'top' : 'left', offset );
}
} | [
"function",
"(",
"splitter",
",",
"offsetX",
",",
"offsetY",
")",
"{",
"var",
"offset",
"=",
"this",
".",
"_isColumn",
"?",
"offsetY",
":",
"offsetX",
";",
"if",
"(",
"offset",
">",
"this",
".",
"_splitterMinPosition",
"&&",
"offset",
"<",
"this",
".",
"_splitterMaxPosition",
")",
"{",
"this",
".",
"_splitterPosition",
"=",
"offset",
";",
"splitter",
".",
"element",
".",
"css",
"(",
"this",
".",
"_isColumn",
"?",
"'top'",
":",
"'left'",
",",
"offset",
")",
";",
"}",
"}"
] | Invoked when a splitter's DragListener fires drag. Updates the splitters DOM position,
but not the sizes of the elements the splitter controls in order to minimize resize events
@param {lm.controls.Splitter} splitter
@param {Int} offsetX Relative pixel values to the splitters original position. Can be negative
@param {Int} offsetY Relative pixel values to the splitters original position. Can be negative
@returns {void} | [
"Invoked",
"when",
"a",
"splitter",
"s",
"DragListener",
"fires",
"drag",
".",
"Updates",
"the",
"splitters",
"DOM",
"position",
"but",
"not",
"the",
"sizes",
"of",
"the",
"elements",
"the",
"splitter",
"controls",
"in",
"order",
"to",
"minimize",
"resize",
"events"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/website/files/v0.9.2/js/goldenlayout.js#L2590-L2597 |
|
6,670 | golden-layout/golden-layout | website/files/v0.9.2/js/goldenlayout.js | function( splitter ) {
var items = this._getItemsForSplitter( splitter ),
sizeBefore = items.before.element[ this._dimension ](),
sizeAfter = items.after.element[ this._dimension ](),
splitterPositionInRange = ( this._splitterPosition + sizeBefore ) / ( sizeBefore + sizeAfter ),
totalRelativeSize = items.before.config[ this._dimension ] + items.after.config[ this._dimension ];
items.before.config[ this._dimension ] = splitterPositionInRange * totalRelativeSize;
items.after.config[ this._dimension ] = ( 1 - splitterPositionInRange ) * totalRelativeSize;
splitter.element.css({
'top': 0,
'left': 0
});
lm.utils.animFrame( lm.utils.fnBind( this.callDownwards, this, [ 'setSize' ] ) );
} | javascript | function( splitter ) {
var items = this._getItemsForSplitter( splitter ),
sizeBefore = items.before.element[ this._dimension ](),
sizeAfter = items.after.element[ this._dimension ](),
splitterPositionInRange = ( this._splitterPosition + sizeBefore ) / ( sizeBefore + sizeAfter ),
totalRelativeSize = items.before.config[ this._dimension ] + items.after.config[ this._dimension ];
items.before.config[ this._dimension ] = splitterPositionInRange * totalRelativeSize;
items.after.config[ this._dimension ] = ( 1 - splitterPositionInRange ) * totalRelativeSize;
splitter.element.css({
'top': 0,
'left': 0
});
lm.utils.animFrame( lm.utils.fnBind( this.callDownwards, this, [ 'setSize' ] ) );
} | [
"function",
"(",
"splitter",
")",
"{",
"var",
"items",
"=",
"this",
".",
"_getItemsForSplitter",
"(",
"splitter",
")",
",",
"sizeBefore",
"=",
"items",
".",
"before",
".",
"element",
"[",
"this",
".",
"_dimension",
"]",
"(",
")",
",",
"sizeAfter",
"=",
"items",
".",
"after",
".",
"element",
"[",
"this",
".",
"_dimension",
"]",
"(",
")",
",",
"splitterPositionInRange",
"=",
"(",
"this",
".",
"_splitterPosition",
"+",
"sizeBefore",
")",
"/",
"(",
"sizeBefore",
"+",
"sizeAfter",
")",
",",
"totalRelativeSize",
"=",
"items",
".",
"before",
".",
"config",
"[",
"this",
".",
"_dimension",
"]",
"+",
"items",
".",
"after",
".",
"config",
"[",
"this",
".",
"_dimension",
"]",
";",
"items",
".",
"before",
".",
"config",
"[",
"this",
".",
"_dimension",
"]",
"=",
"splitterPositionInRange",
"*",
"totalRelativeSize",
";",
"items",
".",
"after",
".",
"config",
"[",
"this",
".",
"_dimension",
"]",
"=",
"(",
"1",
"-",
"splitterPositionInRange",
")",
"*",
"totalRelativeSize",
";",
"splitter",
".",
"element",
".",
"css",
"(",
"{",
"'top'",
":",
"0",
",",
"'left'",
":",
"0",
"}",
")",
";",
"lm",
".",
"utils",
".",
"animFrame",
"(",
"lm",
".",
"utils",
".",
"fnBind",
"(",
"this",
".",
"callDownwards",
",",
"this",
",",
"[",
"'setSize'",
"]",
")",
")",
";",
"}"
] | Invoked when a splitter's DragListener fires dragStop. Resets the splitters DOM position,
and applies the new sizes to the elements before and after the splitter and their children
on the next animation frame
@param {lm.controls.Splitter} splitter
@returns {void} | [
"Invoked",
"when",
"a",
"splitter",
"s",
"DragListener",
"fires",
"dragStop",
".",
"Resets",
"the",
"splitters",
"DOM",
"position",
"and",
"applies",
"the",
"new",
"sizes",
"to",
"the",
"elements",
"before",
"and",
"after",
"the",
"splitter",
"and",
"their",
"children",
"on",
"the",
"next",
"animation",
"frame"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/website/files/v0.9.2/js/goldenlayout.js#L2608-L2625 |
|
6,671 | golden-layout/golden-layout | src/js/LayoutManager.js | function( root ) {
var config, next, i;
if( this.isInitialised === false ) {
throw new Error( 'Can\'t create config, layout not yet initialised' );
}
if( root && !( root instanceof lm.items.AbstractContentItem ) ) {
throw new Error( 'Root must be a ContentItem' );
}
/*
* settings & labels
*/
config = {
settings: lm.utils.copy( {}, this.config.settings ),
dimensions: lm.utils.copy( {}, this.config.dimensions ),
labels: lm.utils.copy( {}, this.config.labels )
};
/*
* Content
*/
config.content = [];
next = function( configNode, item ) {
var key, i;
for( key in item.config ) {
if( key !== 'content' ) {
configNode[ key ] = item.config[ key ];
}
}
if( item.contentItems.length ) {
configNode.content = [];
for( i = 0; i < item.contentItems.length; i++ ) {
configNode.content[ i ] = {};
next( configNode.content[ i ], item.contentItems[ i ] );
}
}
};
if( root ) {
next( config, { contentItems: [ root ] } );
} else {
next( config, this.root );
}
/*
* Retrieve config for subwindows
*/
this._$reconcilePopoutWindows();
config.openPopouts = [];
for( i = 0; i < this.openPopouts.length; i++ ) {
config.openPopouts.push( this.openPopouts[ i ].toConfig() );
}
/*
* Add maximised item
*/
config.maximisedItemId = this._maximisedItem ? '__glMaximised' : null;
return config;
} | javascript | function( root ) {
var config, next, i;
if( this.isInitialised === false ) {
throw new Error( 'Can\'t create config, layout not yet initialised' );
}
if( root && !( root instanceof lm.items.AbstractContentItem ) ) {
throw new Error( 'Root must be a ContentItem' );
}
/*
* settings & labels
*/
config = {
settings: lm.utils.copy( {}, this.config.settings ),
dimensions: lm.utils.copy( {}, this.config.dimensions ),
labels: lm.utils.copy( {}, this.config.labels )
};
/*
* Content
*/
config.content = [];
next = function( configNode, item ) {
var key, i;
for( key in item.config ) {
if( key !== 'content' ) {
configNode[ key ] = item.config[ key ];
}
}
if( item.contentItems.length ) {
configNode.content = [];
for( i = 0; i < item.contentItems.length; i++ ) {
configNode.content[ i ] = {};
next( configNode.content[ i ], item.contentItems[ i ] );
}
}
};
if( root ) {
next( config, { contentItems: [ root ] } );
} else {
next( config, this.root );
}
/*
* Retrieve config for subwindows
*/
this._$reconcilePopoutWindows();
config.openPopouts = [];
for( i = 0; i < this.openPopouts.length; i++ ) {
config.openPopouts.push( this.openPopouts[ i ].toConfig() );
}
/*
* Add maximised item
*/
config.maximisedItemId = this._maximisedItem ? '__glMaximised' : null;
return config;
} | [
"function",
"(",
"root",
")",
"{",
"var",
"config",
",",
"next",
",",
"i",
";",
"if",
"(",
"this",
".",
"isInitialised",
"===",
"false",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Can\\'t create config, layout not yet initialised'",
")",
";",
"}",
"if",
"(",
"root",
"&&",
"!",
"(",
"root",
"instanceof",
"lm",
".",
"items",
".",
"AbstractContentItem",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Root must be a ContentItem'",
")",
";",
"}",
"/*\n\t\t * settings & labels\n\t\t */",
"config",
"=",
"{",
"settings",
":",
"lm",
".",
"utils",
".",
"copy",
"(",
"{",
"}",
",",
"this",
".",
"config",
".",
"settings",
")",
",",
"dimensions",
":",
"lm",
".",
"utils",
".",
"copy",
"(",
"{",
"}",
",",
"this",
".",
"config",
".",
"dimensions",
")",
",",
"labels",
":",
"lm",
".",
"utils",
".",
"copy",
"(",
"{",
"}",
",",
"this",
".",
"config",
".",
"labels",
")",
"}",
";",
"/*\n\t\t * Content\n\t\t */",
"config",
".",
"content",
"=",
"[",
"]",
";",
"next",
"=",
"function",
"(",
"configNode",
",",
"item",
")",
"{",
"var",
"key",
",",
"i",
";",
"for",
"(",
"key",
"in",
"item",
".",
"config",
")",
"{",
"if",
"(",
"key",
"!==",
"'content'",
")",
"{",
"configNode",
"[",
"key",
"]",
"=",
"item",
".",
"config",
"[",
"key",
"]",
";",
"}",
"}",
"if",
"(",
"item",
".",
"contentItems",
".",
"length",
")",
"{",
"configNode",
".",
"content",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"item",
".",
"contentItems",
".",
"length",
";",
"i",
"++",
")",
"{",
"configNode",
".",
"content",
"[",
"i",
"]",
"=",
"{",
"}",
";",
"next",
"(",
"configNode",
".",
"content",
"[",
"i",
"]",
",",
"item",
".",
"contentItems",
"[",
"i",
"]",
")",
";",
"}",
"}",
"}",
";",
"if",
"(",
"root",
")",
"{",
"next",
"(",
"config",
",",
"{",
"contentItems",
":",
"[",
"root",
"]",
"}",
")",
";",
"}",
"else",
"{",
"next",
"(",
"config",
",",
"this",
".",
"root",
")",
";",
"}",
"/*\n\t\t * Retrieve config for subwindows\n\t\t */",
"this",
".",
"_$reconcilePopoutWindows",
"(",
")",
";",
"config",
".",
"openPopouts",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"openPopouts",
".",
"length",
";",
"i",
"++",
")",
"{",
"config",
".",
"openPopouts",
".",
"push",
"(",
"this",
".",
"openPopouts",
"[",
"i",
"]",
".",
"toConfig",
"(",
")",
")",
";",
"}",
"/*\n\t\t * Add maximised item\n\t\t */",
"config",
".",
"maximisedItemId",
"=",
"this",
".",
"_maximisedItem",
"?",
"'__glMaximised'",
":",
"null",
";",
"return",
"config",
";",
"}"
] | Creates a layout configuration object based on the the current state
@public
@returns {Object} GoldenLayout configuration | [
"Creates",
"a",
"layout",
"configuration",
"object",
"based",
"on",
"the",
"the",
"current",
"state"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/LayoutManager.js#L132-L195 |
|
6,672 | golden-layout/golden-layout | src/js/LayoutManager.js | function() {
/**
* Create the popout windows straight away. If popouts are blocked
* an error is thrown on the same 'thread' rather than a timeout and can
* be caught. This also prevents any further initilisation from taking place.
*/
if( this._subWindowsCreated === false ) {
this._createSubWindows();
this._subWindowsCreated = true;
}
/**
* If the document isn't ready yet, wait for it.
*/
if( document.readyState === 'loading' || document.body === null ) {
$( document ).ready( lm.utils.fnBind( this.init, this ) );
return;
}
/**
* If this is a subwindow, wait a few milliseconds for the original
* page's js calls to be executed, then replace the bodies content
* with GoldenLayout
*/
if( this.isSubWindow === true && this._creationTimeoutPassed === false ) {
setTimeout( lm.utils.fnBind( this.init, this ), 7 );
this._creationTimeoutPassed = true;
return;
}
if( this.isSubWindow === true ) {
this._adjustToWindowMode();
}
this._setContainer();
this.dropTargetIndicator = new lm.controls.DropTargetIndicator( this.container );
this.transitionIndicator = new lm.controls.TransitionIndicator();
this.updateSize();
this._create( this.config );
this._bindEvents();
this.isInitialised = true;
this._adjustColumnsResponsive();
this.emit( 'initialised' );
} | javascript | function() {
/**
* Create the popout windows straight away. If popouts are blocked
* an error is thrown on the same 'thread' rather than a timeout and can
* be caught. This also prevents any further initilisation from taking place.
*/
if( this._subWindowsCreated === false ) {
this._createSubWindows();
this._subWindowsCreated = true;
}
/**
* If the document isn't ready yet, wait for it.
*/
if( document.readyState === 'loading' || document.body === null ) {
$( document ).ready( lm.utils.fnBind( this.init, this ) );
return;
}
/**
* If this is a subwindow, wait a few milliseconds for the original
* page's js calls to be executed, then replace the bodies content
* with GoldenLayout
*/
if( this.isSubWindow === true && this._creationTimeoutPassed === false ) {
setTimeout( lm.utils.fnBind( this.init, this ), 7 );
this._creationTimeoutPassed = true;
return;
}
if( this.isSubWindow === true ) {
this._adjustToWindowMode();
}
this._setContainer();
this.dropTargetIndicator = new lm.controls.DropTargetIndicator( this.container );
this.transitionIndicator = new lm.controls.TransitionIndicator();
this.updateSize();
this._create( this.config );
this._bindEvents();
this.isInitialised = true;
this._adjustColumnsResponsive();
this.emit( 'initialised' );
} | [
"function",
"(",
")",
"{",
"/**\n\t\t * Create the popout windows straight away. If popouts are blocked\n\t\t * an error is thrown on the same 'thread' rather than a timeout and can\n\t\t * be caught. This also prevents any further initilisation from taking place.\n\t\t */",
"if",
"(",
"this",
".",
"_subWindowsCreated",
"===",
"false",
")",
"{",
"this",
".",
"_createSubWindows",
"(",
")",
";",
"this",
".",
"_subWindowsCreated",
"=",
"true",
";",
"}",
"/**\n\t\t * If the document isn't ready yet, wait for it.\n\t\t */",
"if",
"(",
"document",
".",
"readyState",
"===",
"'loading'",
"||",
"document",
".",
"body",
"===",
"null",
")",
"{",
"$",
"(",
"document",
")",
".",
"ready",
"(",
"lm",
".",
"utils",
".",
"fnBind",
"(",
"this",
".",
"init",
",",
"this",
")",
")",
";",
"return",
";",
"}",
"/**\n\t\t * If this is a subwindow, wait a few milliseconds for the original\n\t\t * page's js calls to be executed, then replace the bodies content\n\t\t * with GoldenLayout\n\t\t */",
"if",
"(",
"this",
".",
"isSubWindow",
"===",
"true",
"&&",
"this",
".",
"_creationTimeoutPassed",
"===",
"false",
")",
"{",
"setTimeout",
"(",
"lm",
".",
"utils",
".",
"fnBind",
"(",
"this",
".",
"init",
",",
"this",
")",
",",
"7",
")",
";",
"this",
".",
"_creationTimeoutPassed",
"=",
"true",
";",
"return",
";",
"}",
"if",
"(",
"this",
".",
"isSubWindow",
"===",
"true",
")",
"{",
"this",
".",
"_adjustToWindowMode",
"(",
")",
";",
"}",
"this",
".",
"_setContainer",
"(",
")",
";",
"this",
".",
"dropTargetIndicator",
"=",
"new",
"lm",
".",
"controls",
".",
"DropTargetIndicator",
"(",
"this",
".",
"container",
")",
";",
"this",
".",
"transitionIndicator",
"=",
"new",
"lm",
".",
"controls",
".",
"TransitionIndicator",
"(",
")",
";",
"this",
".",
"updateSize",
"(",
")",
";",
"this",
".",
"_create",
"(",
"this",
".",
"config",
")",
";",
"this",
".",
"_bindEvents",
"(",
")",
";",
"this",
".",
"isInitialised",
"=",
"true",
";",
"this",
".",
"_adjustColumnsResponsive",
"(",
")",
";",
"this",
".",
"emit",
"(",
"'initialised'",
")",
";",
"}"
] | Creates the actual layout. Must be called after all initial components
are registered. Recurses through the configuration and sets up
the item tree.
If called before the document is ready it adds itself as a listener
to the document.ready event
@public
@returns {void} | [
"Creates",
"the",
"actual",
"layout",
".",
"Must",
"be",
"called",
"after",
"all",
"initial",
"components",
"are",
"registered",
".",
"Recurses",
"through",
"the",
"configuration",
"and",
"sets",
"up",
"the",
"item",
"tree",
"."
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/LayoutManager.js#L225-L270 |
|
6,673 | golden-layout/golden-layout | src/js/LayoutManager.js | function( config, parent ) {
var typeErrorMsg, contentItem;
if( typeof config.type !== 'string' ) {
throw new lm.errors.ConfigurationError( 'Missing parameter \'type\'', config );
}
if( config.type === 'react-component' ) {
config.type = 'component';
config.componentName = 'lm-react-component';
}
if( !this._typeToItem[ config.type ] ) {
typeErrorMsg = 'Unknown type \'' + config.type + '\'. ' +
'Valid types are ' + lm.utils.objectKeys( this._typeToItem ).join( ',' );
throw new lm.errors.ConfigurationError( typeErrorMsg );
}
/**
* We add an additional stack around every component that's not within a stack anyways.
*/
if(
// If this is a component
config.type === 'component' &&
// and it's not already within a stack
!( parent instanceof lm.items.Stack ) &&
// and we have a parent
!!parent &&
// and it's not the topmost item in a new window
!( this.isSubWindow === true && parent instanceof lm.items.Root )
) {
config = {
type: 'stack',
width: config.width,
height: config.height,
content: [ config ]
};
}
contentItem = new this._typeToItem[ config.type ]( this, config, parent );
return contentItem;
} | javascript | function( config, parent ) {
var typeErrorMsg, contentItem;
if( typeof config.type !== 'string' ) {
throw new lm.errors.ConfigurationError( 'Missing parameter \'type\'', config );
}
if( config.type === 'react-component' ) {
config.type = 'component';
config.componentName = 'lm-react-component';
}
if( !this._typeToItem[ config.type ] ) {
typeErrorMsg = 'Unknown type \'' + config.type + '\'. ' +
'Valid types are ' + lm.utils.objectKeys( this._typeToItem ).join( ',' );
throw new lm.errors.ConfigurationError( typeErrorMsg );
}
/**
* We add an additional stack around every component that's not within a stack anyways.
*/
if(
// If this is a component
config.type === 'component' &&
// and it's not already within a stack
!( parent instanceof lm.items.Stack ) &&
// and we have a parent
!!parent &&
// and it's not the topmost item in a new window
!( this.isSubWindow === true && parent instanceof lm.items.Root )
) {
config = {
type: 'stack',
width: config.width,
height: config.height,
content: [ config ]
};
}
contentItem = new this._typeToItem[ config.type ]( this, config, parent );
return contentItem;
} | [
"function",
"(",
"config",
",",
"parent",
")",
"{",
"var",
"typeErrorMsg",
",",
"contentItem",
";",
"if",
"(",
"typeof",
"config",
".",
"type",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"lm",
".",
"errors",
".",
"ConfigurationError",
"(",
"'Missing parameter \\'type\\''",
",",
"config",
")",
";",
"}",
"if",
"(",
"config",
".",
"type",
"===",
"'react-component'",
")",
"{",
"config",
".",
"type",
"=",
"'component'",
";",
"config",
".",
"componentName",
"=",
"'lm-react-component'",
";",
"}",
"if",
"(",
"!",
"this",
".",
"_typeToItem",
"[",
"config",
".",
"type",
"]",
")",
"{",
"typeErrorMsg",
"=",
"'Unknown type \\''",
"+",
"config",
".",
"type",
"+",
"'\\'. '",
"+",
"'Valid types are '",
"+",
"lm",
".",
"utils",
".",
"objectKeys",
"(",
"this",
".",
"_typeToItem",
")",
".",
"join",
"(",
"','",
")",
";",
"throw",
"new",
"lm",
".",
"errors",
".",
"ConfigurationError",
"(",
"typeErrorMsg",
")",
";",
"}",
"/**\n\t\t * We add an additional stack around every component that's not within a stack anyways.\n\t\t */",
"if",
"(",
"// If this is a component",
"config",
".",
"type",
"===",
"'component'",
"&&",
"// and it's not already within a stack",
"!",
"(",
"parent",
"instanceof",
"lm",
".",
"items",
".",
"Stack",
")",
"&&",
"// and we have a parent",
"!",
"!",
"parent",
"&&",
"// and it's not the topmost item in a new window",
"!",
"(",
"this",
".",
"isSubWindow",
"===",
"true",
"&&",
"parent",
"instanceof",
"lm",
".",
"items",
".",
"Root",
")",
")",
"{",
"config",
"=",
"{",
"type",
":",
"'stack'",
",",
"width",
":",
"config",
".",
"width",
",",
"height",
":",
"config",
".",
"height",
",",
"content",
":",
"[",
"config",
"]",
"}",
";",
"}",
"contentItem",
"=",
"new",
"this",
".",
"_typeToItem",
"[",
"config",
".",
"type",
"]",
"(",
"this",
",",
"config",
",",
"parent",
")",
";",
"return",
"contentItem",
";",
"}"
] | Recursively creates new item tree structures based on a provided
ItemConfiguration object
@public
@param {Object} config ItemConfig
@param {[ContentItem]} parent The item the newly created item should be a child of
@returns {lm.items.ContentItem} | [
"Recursively",
"creates",
"new",
"item",
"tree",
"structures",
"based",
"on",
"a",
"provided",
"ItemConfiguration",
"object"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/LayoutManager.js#L343-L389 |
|
6,674 | golden-layout/golden-layout | src/js/LayoutManager.js | function( configOrContentItem, dimensions, parentId, indexInParent ) {
var config = configOrContentItem,
isItem = configOrContentItem instanceof lm.items.AbstractContentItem,
self = this,
windowLeft,
windowTop,
offset,
parent,
child,
browserPopout;
parentId = parentId || null;
if( isItem ) {
config = this.toConfig( configOrContentItem ).content;
parentId = lm.utils.getUniqueId();
/**
* If the item is the only component within a stack or for some
* other reason the only child of its parent the parent will be destroyed
* when the child is removed.
*
* In order to support this we move up the tree until we find something
* that will remain after the item is being popped out
*/
parent = configOrContentItem.parent;
child = configOrContentItem;
while( parent.contentItems.length === 1 && !parent.isRoot ) {
parent = parent.parent;
child = child.parent;
}
parent.addId( parentId );
if( isNaN( indexInParent ) ) {
indexInParent = lm.utils.indexOf( child, parent.contentItems );
}
} else {
if( !( config instanceof Array ) ) {
config = [ config ];
}
}
if( !dimensions && isItem ) {
windowLeft = window.screenX || window.screenLeft;
windowTop = window.screenY || window.screenTop;
offset = configOrContentItem.element.offset();
dimensions = {
left: windowLeft + offset.left,
top: windowTop + offset.top,
width: configOrContentItem.element.width(),
height: configOrContentItem.element.height()
};
}
if( !dimensions && !isItem ) {
dimensions = {
left: window.screenX || window.screenLeft + 20,
top: window.screenY || window.screenTop + 20,
width: 500,
height: 309
};
}
if( isItem ) {
configOrContentItem.remove();
}
browserPopout = new lm.controls.BrowserPopout( config, dimensions, parentId, indexInParent, this );
browserPopout.on( 'initialised', function() {
self.emit( 'windowOpened', browserPopout );
} );
browserPopout.on( 'closed', function() {
self._$reconcilePopoutWindows();
} );
this.openPopouts.push( browserPopout );
return browserPopout;
} | javascript | function( configOrContentItem, dimensions, parentId, indexInParent ) {
var config = configOrContentItem,
isItem = configOrContentItem instanceof lm.items.AbstractContentItem,
self = this,
windowLeft,
windowTop,
offset,
parent,
child,
browserPopout;
parentId = parentId || null;
if( isItem ) {
config = this.toConfig( configOrContentItem ).content;
parentId = lm.utils.getUniqueId();
/**
* If the item is the only component within a stack or for some
* other reason the only child of its parent the parent will be destroyed
* when the child is removed.
*
* In order to support this we move up the tree until we find something
* that will remain after the item is being popped out
*/
parent = configOrContentItem.parent;
child = configOrContentItem;
while( parent.contentItems.length === 1 && !parent.isRoot ) {
parent = parent.parent;
child = child.parent;
}
parent.addId( parentId );
if( isNaN( indexInParent ) ) {
indexInParent = lm.utils.indexOf( child, parent.contentItems );
}
} else {
if( !( config instanceof Array ) ) {
config = [ config ];
}
}
if( !dimensions && isItem ) {
windowLeft = window.screenX || window.screenLeft;
windowTop = window.screenY || window.screenTop;
offset = configOrContentItem.element.offset();
dimensions = {
left: windowLeft + offset.left,
top: windowTop + offset.top,
width: configOrContentItem.element.width(),
height: configOrContentItem.element.height()
};
}
if( !dimensions && !isItem ) {
dimensions = {
left: window.screenX || window.screenLeft + 20,
top: window.screenY || window.screenTop + 20,
width: 500,
height: 309
};
}
if( isItem ) {
configOrContentItem.remove();
}
browserPopout = new lm.controls.BrowserPopout( config, dimensions, parentId, indexInParent, this );
browserPopout.on( 'initialised', function() {
self.emit( 'windowOpened', browserPopout );
} );
browserPopout.on( 'closed', function() {
self._$reconcilePopoutWindows();
} );
this.openPopouts.push( browserPopout );
return browserPopout;
} | [
"function",
"(",
"configOrContentItem",
",",
"dimensions",
",",
"parentId",
",",
"indexInParent",
")",
"{",
"var",
"config",
"=",
"configOrContentItem",
",",
"isItem",
"=",
"configOrContentItem",
"instanceof",
"lm",
".",
"items",
".",
"AbstractContentItem",
",",
"self",
"=",
"this",
",",
"windowLeft",
",",
"windowTop",
",",
"offset",
",",
"parent",
",",
"child",
",",
"browserPopout",
";",
"parentId",
"=",
"parentId",
"||",
"null",
";",
"if",
"(",
"isItem",
")",
"{",
"config",
"=",
"this",
".",
"toConfig",
"(",
"configOrContentItem",
")",
".",
"content",
";",
"parentId",
"=",
"lm",
".",
"utils",
".",
"getUniqueId",
"(",
")",
";",
"/**\n\t\t\t * If the item is the only component within a stack or for some\n\t\t\t * other reason the only child of its parent the parent will be destroyed\n\t\t\t * when the child is removed.\n\t\t\t *\n\t\t\t * In order to support this we move up the tree until we find something\n\t\t\t * that will remain after the item is being popped out\n\t\t\t */",
"parent",
"=",
"configOrContentItem",
".",
"parent",
";",
"child",
"=",
"configOrContentItem",
";",
"while",
"(",
"parent",
".",
"contentItems",
".",
"length",
"===",
"1",
"&&",
"!",
"parent",
".",
"isRoot",
")",
"{",
"parent",
"=",
"parent",
".",
"parent",
";",
"child",
"=",
"child",
".",
"parent",
";",
"}",
"parent",
".",
"addId",
"(",
"parentId",
")",
";",
"if",
"(",
"isNaN",
"(",
"indexInParent",
")",
")",
"{",
"indexInParent",
"=",
"lm",
".",
"utils",
".",
"indexOf",
"(",
"child",
",",
"parent",
".",
"contentItems",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"(",
"config",
"instanceof",
"Array",
")",
")",
"{",
"config",
"=",
"[",
"config",
"]",
";",
"}",
"}",
"if",
"(",
"!",
"dimensions",
"&&",
"isItem",
")",
"{",
"windowLeft",
"=",
"window",
".",
"screenX",
"||",
"window",
".",
"screenLeft",
";",
"windowTop",
"=",
"window",
".",
"screenY",
"||",
"window",
".",
"screenTop",
";",
"offset",
"=",
"configOrContentItem",
".",
"element",
".",
"offset",
"(",
")",
";",
"dimensions",
"=",
"{",
"left",
":",
"windowLeft",
"+",
"offset",
".",
"left",
",",
"top",
":",
"windowTop",
"+",
"offset",
".",
"top",
",",
"width",
":",
"configOrContentItem",
".",
"element",
".",
"width",
"(",
")",
",",
"height",
":",
"configOrContentItem",
".",
"element",
".",
"height",
"(",
")",
"}",
";",
"}",
"if",
"(",
"!",
"dimensions",
"&&",
"!",
"isItem",
")",
"{",
"dimensions",
"=",
"{",
"left",
":",
"window",
".",
"screenX",
"||",
"window",
".",
"screenLeft",
"+",
"20",
",",
"top",
":",
"window",
".",
"screenY",
"||",
"window",
".",
"screenTop",
"+",
"20",
",",
"width",
":",
"500",
",",
"height",
":",
"309",
"}",
";",
"}",
"if",
"(",
"isItem",
")",
"{",
"configOrContentItem",
".",
"remove",
"(",
")",
";",
"}",
"browserPopout",
"=",
"new",
"lm",
".",
"controls",
".",
"BrowserPopout",
"(",
"config",
",",
"dimensions",
",",
"parentId",
",",
"indexInParent",
",",
"this",
")",
";",
"browserPopout",
".",
"on",
"(",
"'initialised'",
",",
"function",
"(",
")",
"{",
"self",
".",
"emit",
"(",
"'windowOpened'",
",",
"browserPopout",
")",
";",
"}",
")",
";",
"browserPopout",
".",
"on",
"(",
"'closed'",
",",
"function",
"(",
")",
"{",
"self",
".",
"_$reconcilePopoutWindows",
"(",
")",
";",
"}",
")",
";",
"this",
".",
"openPopouts",
".",
"push",
"(",
"browserPopout",
")",
";",
"return",
"browserPopout",
";",
"}"
] | Creates a popout window with the specified content and dimensions
@param {Object|lm.itemsAbstractContentItem} configOrContentItem
@param {[Object]} dimensions A map with width, height, left and top
@param {[String]} parentId the id of the element this item will be appended to
when popIn is called
@param {[Number]} indexInParent The position of this item within its parent element
@returns {lm.controls.BrowserPopout} | [
"Creates",
"a",
"popout",
"window",
"with",
"the",
"specified",
"content",
"and",
"dimensions"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/LayoutManager.js#L402-L484 |
|
6,675 | golden-layout/golden-layout | src/js/LayoutManager.js | function( contentItemOrConfig, parent ) {
if( !contentItemOrConfig ) {
throw new Error( 'No content item defined' );
}
if( lm.utils.isFunction( contentItemOrConfig ) ) {
contentItemOrConfig = contentItemOrConfig();
}
if( contentItemOrConfig instanceof lm.items.AbstractContentItem ) {
return contentItemOrConfig;
}
if( $.isPlainObject( contentItemOrConfig ) && contentItemOrConfig.type ) {
var newContentItem = this.createContentItem( contentItemOrConfig, parent );
newContentItem.callDownwards( '_$init' );
return newContentItem;
} else {
throw new Error( 'Invalid contentItem' );
}
} | javascript | function( contentItemOrConfig, parent ) {
if( !contentItemOrConfig ) {
throw new Error( 'No content item defined' );
}
if( lm.utils.isFunction( contentItemOrConfig ) ) {
contentItemOrConfig = contentItemOrConfig();
}
if( contentItemOrConfig instanceof lm.items.AbstractContentItem ) {
return contentItemOrConfig;
}
if( $.isPlainObject( contentItemOrConfig ) && contentItemOrConfig.type ) {
var newContentItem = this.createContentItem( contentItemOrConfig, parent );
newContentItem.callDownwards( '_$init' );
return newContentItem;
} else {
throw new Error( 'Invalid contentItem' );
}
} | [
"function",
"(",
"contentItemOrConfig",
",",
"parent",
")",
"{",
"if",
"(",
"!",
"contentItemOrConfig",
")",
"{",
"throw",
"new",
"Error",
"(",
"'No content item defined'",
")",
";",
"}",
"if",
"(",
"lm",
".",
"utils",
".",
"isFunction",
"(",
"contentItemOrConfig",
")",
")",
"{",
"contentItemOrConfig",
"=",
"contentItemOrConfig",
"(",
")",
";",
"}",
"if",
"(",
"contentItemOrConfig",
"instanceof",
"lm",
".",
"items",
".",
"AbstractContentItem",
")",
"{",
"return",
"contentItemOrConfig",
";",
"}",
"if",
"(",
"$",
".",
"isPlainObject",
"(",
"contentItemOrConfig",
")",
"&&",
"contentItemOrConfig",
".",
"type",
")",
"{",
"var",
"newContentItem",
"=",
"this",
".",
"createContentItem",
"(",
"contentItemOrConfig",
",",
"parent",
")",
";",
"newContentItem",
".",
"callDownwards",
"(",
"'_$init'",
")",
";",
"return",
"newContentItem",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"'Invalid contentItem'",
")",
";",
"}",
"}"
] | Takes a contentItem or a configuration and optionally a parent
item and returns an initialised instance of the contentItem.
If the contentItem is a function, it is first called
@packagePrivate
@param {lm.items.AbtractContentItem|Object|Function} contentItemOrConfig
@param {lm.items.AbtractContentItem} parent Only necessary when passing in config
@returns {lm.items.AbtractContentItem} | [
"Takes",
"a",
"contentItem",
"or",
"a",
"configuration",
"and",
"optionally",
"a",
"parent",
"item",
"and",
"returns",
"an",
"initialised",
"instance",
"of",
"the",
"contentItem",
".",
"If",
"the",
"contentItem",
"is",
"a",
"function",
"it",
"is",
"first",
"called"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/LayoutManager.js#L686-L706 |
|
6,676 | golden-layout/golden-layout | src/js/LayoutManager.js | function() {
var popInButton = $( '<div class="lm_popin" title="' + this.config.labels.popin + '">' +
'<div class="lm_icon"></div>' +
'<div class="lm_bg"></div>' +
'</div>' );
popInButton.on( 'click', lm.utils.fnBind( function() {
this.emit( 'popIn' );
}, this ) );
document.title = lm.utils.stripTags( this.config.content[ 0 ].title );
$( 'head' ).append( $( 'body link, body style, template, .gl_keep' ) );
this.container = $( 'body' )
.html( '' )
.css( 'visibility', 'visible' )
.append( popInButton );
/*
* This seems a bit pointless, but actually causes a reflow/re-evaluation getting around
* slickgrid's "Cannot find stylesheet." bug in chrome
*/
var x = document.body.offsetHeight; // jshint ignore:line
/*
* Expose this instance on the window object
* to allow the opening window to interact with
* it
*/
window.__glInstance = this;
} | javascript | function() {
var popInButton = $( '<div class="lm_popin" title="' + this.config.labels.popin + '">' +
'<div class="lm_icon"></div>' +
'<div class="lm_bg"></div>' +
'</div>' );
popInButton.on( 'click', lm.utils.fnBind( function() {
this.emit( 'popIn' );
}, this ) );
document.title = lm.utils.stripTags( this.config.content[ 0 ].title );
$( 'head' ).append( $( 'body link, body style, template, .gl_keep' ) );
this.container = $( 'body' )
.html( '' )
.css( 'visibility', 'visible' )
.append( popInButton );
/*
* This seems a bit pointless, but actually causes a reflow/re-evaluation getting around
* slickgrid's "Cannot find stylesheet." bug in chrome
*/
var x = document.body.offsetHeight; // jshint ignore:line
/*
* Expose this instance on the window object
* to allow the opening window to interact with
* it
*/
window.__glInstance = this;
} | [
"function",
"(",
")",
"{",
"var",
"popInButton",
"=",
"$",
"(",
"'<div class=\"lm_popin\" title=\"'",
"+",
"this",
".",
"config",
".",
"labels",
".",
"popin",
"+",
"'\">'",
"+",
"'<div class=\"lm_icon\"></div>'",
"+",
"'<div class=\"lm_bg\"></div>'",
"+",
"'</div>'",
")",
";",
"popInButton",
".",
"on",
"(",
"'click'",
",",
"lm",
".",
"utils",
".",
"fnBind",
"(",
"function",
"(",
")",
"{",
"this",
".",
"emit",
"(",
"'popIn'",
")",
";",
"}",
",",
"this",
")",
")",
";",
"document",
".",
"title",
"=",
"lm",
".",
"utils",
".",
"stripTags",
"(",
"this",
".",
"config",
".",
"content",
"[",
"0",
"]",
".",
"title",
")",
";",
"$",
"(",
"'head'",
")",
".",
"append",
"(",
"$",
"(",
"'body link, body style, template, .gl_keep'",
")",
")",
";",
"this",
".",
"container",
"=",
"$",
"(",
"'body'",
")",
".",
"html",
"(",
"''",
")",
".",
"css",
"(",
"'visibility'",
",",
"'visible'",
")",
".",
"append",
"(",
"popInButton",
")",
";",
"/*\n\t\t * This seems a bit pointless, but actually causes a reflow/re-evaluation getting around\n\t\t * slickgrid's \"Cannot find stylesheet.\" bug in chrome\n\t\t */",
"var",
"x",
"=",
"document",
".",
"body",
".",
"offsetHeight",
";",
"// jshint ignore:line",
"/*\n\t\t * Expose this instance on the window object\n\t\t * to allow the opening window to interact with\n\t\t * it\n\t\t */",
"window",
".",
"__glInstance",
"=",
"this",
";",
"}"
] | This is executed when GoldenLayout detects that it is run
within a previously opened popout window.
@private
@returns {void} | [
"This",
"is",
"executed",
"when",
"GoldenLayout",
"detects",
"that",
"it",
"is",
"run",
"within",
"a",
"previously",
"opened",
"popout",
"window",
"."
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/LayoutManager.js#L841-L872 |
|
6,677 | golden-layout/golden-layout | src/js/LayoutManager.js | function() {
if( this.config.settings.closePopoutsOnUnload === true ) {
for( var i = 0; i < this.openPopouts.length; i++ ) {
this.openPopouts[ i ].close();
}
}
} | javascript | function() {
if( this.config.settings.closePopoutsOnUnload === true ) {
for( var i = 0; i < this.openPopouts.length; i++ ) {
this.openPopouts[ i ].close();
}
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"config",
".",
"settings",
".",
"closePopoutsOnUnload",
"===",
"true",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"openPopouts",
".",
"length",
";",
"i",
"++",
")",
"{",
"this",
".",
"openPopouts",
"[",
"i",
"]",
".",
"close",
"(",
")",
";",
"}",
"}",
"}"
] | Called when the window is closed or the user navigates away
from the page
@returns {void} | [
"Called",
"when",
"the",
"window",
"is",
"closed",
"or",
"the",
"user",
"navigates",
"away",
"from",
"the",
"page"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/LayoutManager.js#L966-L972 |
|
6,678 | golden-layout/golden-layout | src/js/LayoutManager.js | function() {
// If there is no min width set, or not content items, do nothing.
if( !this._useResponsiveLayout() || this._updatingColumnsResponsive || !this.config.dimensions || !this.config.dimensions.minItemWidth || this.root.contentItems.length === 0 || !this.root.contentItems[ 0 ].isRow ) {
this._firstLoad = false;
return;
}
this._firstLoad = false;
// If there is only one column, do nothing.
var columnCount = this.root.contentItems[ 0 ].contentItems.length;
if( columnCount <= 1 ) {
return;
}
// If they all still fit, do nothing.
var minItemWidth = this.config.dimensions.minItemWidth;
var totalMinWidth = columnCount * minItemWidth;
if( totalMinWidth <= this.width ) {
return;
}
// Prevent updates while it is already happening.
this._updatingColumnsResponsive = true;
// Figure out how many columns to stack, and put them all in the first stack container.
var finalColumnCount = Math.max( Math.floor( this.width / minItemWidth ), 1 );
var stackColumnCount = columnCount - finalColumnCount;
var rootContentItem = this.root.contentItems[ 0 ];
var firstStackContainer = this._findAllStackContainers()[ 0 ];
for( var i = 0; i < stackColumnCount; i++ ) {
// Stack from right.
var column = rootContentItem.contentItems[ rootContentItem.contentItems.length - 1 ];
this._addChildContentItemsToContainer( firstStackContainer, column );
}
this._updatingColumnsResponsive = false;
} | javascript | function() {
// If there is no min width set, or not content items, do nothing.
if( !this._useResponsiveLayout() || this._updatingColumnsResponsive || !this.config.dimensions || !this.config.dimensions.minItemWidth || this.root.contentItems.length === 0 || !this.root.contentItems[ 0 ].isRow ) {
this._firstLoad = false;
return;
}
this._firstLoad = false;
// If there is only one column, do nothing.
var columnCount = this.root.contentItems[ 0 ].contentItems.length;
if( columnCount <= 1 ) {
return;
}
// If they all still fit, do nothing.
var minItemWidth = this.config.dimensions.minItemWidth;
var totalMinWidth = columnCount * minItemWidth;
if( totalMinWidth <= this.width ) {
return;
}
// Prevent updates while it is already happening.
this._updatingColumnsResponsive = true;
// Figure out how many columns to stack, and put them all in the first stack container.
var finalColumnCount = Math.max( Math.floor( this.width / minItemWidth ), 1 );
var stackColumnCount = columnCount - finalColumnCount;
var rootContentItem = this.root.contentItems[ 0 ];
var firstStackContainer = this._findAllStackContainers()[ 0 ];
for( var i = 0; i < stackColumnCount; i++ ) {
// Stack from right.
var column = rootContentItem.contentItems[ rootContentItem.contentItems.length - 1 ];
this._addChildContentItemsToContainer( firstStackContainer, column );
}
this._updatingColumnsResponsive = false;
} | [
"function",
"(",
")",
"{",
"// If there is no min width set, or not content items, do nothing.",
"if",
"(",
"!",
"this",
".",
"_useResponsiveLayout",
"(",
")",
"||",
"this",
".",
"_updatingColumnsResponsive",
"||",
"!",
"this",
".",
"config",
".",
"dimensions",
"||",
"!",
"this",
".",
"config",
".",
"dimensions",
".",
"minItemWidth",
"||",
"this",
".",
"root",
".",
"contentItems",
".",
"length",
"===",
"0",
"||",
"!",
"this",
".",
"root",
".",
"contentItems",
"[",
"0",
"]",
".",
"isRow",
")",
"{",
"this",
".",
"_firstLoad",
"=",
"false",
";",
"return",
";",
"}",
"this",
".",
"_firstLoad",
"=",
"false",
";",
"// If there is only one column, do nothing.",
"var",
"columnCount",
"=",
"this",
".",
"root",
".",
"contentItems",
"[",
"0",
"]",
".",
"contentItems",
".",
"length",
";",
"if",
"(",
"columnCount",
"<=",
"1",
")",
"{",
"return",
";",
"}",
"// If they all still fit, do nothing.",
"var",
"minItemWidth",
"=",
"this",
".",
"config",
".",
"dimensions",
".",
"minItemWidth",
";",
"var",
"totalMinWidth",
"=",
"columnCount",
"*",
"minItemWidth",
";",
"if",
"(",
"totalMinWidth",
"<=",
"this",
".",
"width",
")",
"{",
"return",
";",
"}",
"// Prevent updates while it is already happening.",
"this",
".",
"_updatingColumnsResponsive",
"=",
"true",
";",
"// Figure out how many columns to stack, and put them all in the first stack container.",
"var",
"finalColumnCount",
"=",
"Math",
".",
"max",
"(",
"Math",
".",
"floor",
"(",
"this",
".",
"width",
"/",
"minItemWidth",
")",
",",
"1",
")",
";",
"var",
"stackColumnCount",
"=",
"columnCount",
"-",
"finalColumnCount",
";",
"var",
"rootContentItem",
"=",
"this",
".",
"root",
".",
"contentItems",
"[",
"0",
"]",
";",
"var",
"firstStackContainer",
"=",
"this",
".",
"_findAllStackContainers",
"(",
")",
"[",
"0",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"stackColumnCount",
";",
"i",
"++",
")",
"{",
"// Stack from right.",
"var",
"column",
"=",
"rootContentItem",
".",
"contentItems",
"[",
"rootContentItem",
".",
"contentItems",
".",
"length",
"-",
"1",
"]",
";",
"this",
".",
"_addChildContentItemsToContainer",
"(",
"firstStackContainer",
",",
"column",
")",
";",
"}",
"this",
".",
"_updatingColumnsResponsive",
"=",
"false",
";",
"}"
] | Adjusts the number of columns to be lower to fit the screen and still maintain minItemWidth.
@returns {void} | [
"Adjusts",
"the",
"number",
"of",
"columns",
"to",
"be",
"lower",
"to",
"fit",
"the",
"screen",
"and",
"still",
"maintain",
"minItemWidth",
"."
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/LayoutManager.js#L979-L1018 |
|
6,679 | golden-layout/golden-layout | src/js/LayoutManager.js | function( container, node ) {
if( node.type === 'stack' ) {
node.contentItems.forEach( function( item ) {
container.addChild( item );
node.removeChild( item, true );
} );
}
else {
node.contentItems.forEach( lm.utils.fnBind( function( item ) {
this._addChildContentItemsToContainer( container, item );
}, this ) );
}
} | javascript | function( container, node ) {
if( node.type === 'stack' ) {
node.contentItems.forEach( function( item ) {
container.addChild( item );
node.removeChild( item, true );
} );
}
else {
node.contentItems.forEach( lm.utils.fnBind( function( item ) {
this._addChildContentItemsToContainer( container, item );
}, this ) );
}
} | [
"function",
"(",
"container",
",",
"node",
")",
"{",
"if",
"(",
"node",
".",
"type",
"===",
"'stack'",
")",
"{",
"node",
".",
"contentItems",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"container",
".",
"addChild",
"(",
"item",
")",
";",
"node",
".",
"removeChild",
"(",
"item",
",",
"true",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"node",
".",
"contentItems",
".",
"forEach",
"(",
"lm",
".",
"utils",
".",
"fnBind",
"(",
"function",
"(",
"item",
")",
"{",
"this",
".",
"_addChildContentItemsToContainer",
"(",
"container",
",",
"item",
")",
";",
"}",
",",
"this",
")",
")",
";",
"}",
"}"
] | Adds all children of a node to another container recursively.
@param {object} container - Container to add child content items to.
@param {object} node - Node to search for content items.
@returns {void} | [
"Adds",
"all",
"children",
"of",
"a",
"node",
"to",
"another",
"container",
"recursively",
"."
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/LayoutManager.js#L1035-L1047 |
|
6,680 | golden-layout/golden-layout | src/js/LayoutManager.js | function( stackContainers, node ) {
node.contentItems.forEach( lm.utils.fnBind( function( item ) {
if( item.type == 'stack' ) {
stackContainers.push( item );
}
else if( !item.isComponent ) {
this._findAllStackContainersRecursive( stackContainers, item );
}
}, this ) );
} | javascript | function( stackContainers, node ) {
node.contentItems.forEach( lm.utils.fnBind( function( item ) {
if( item.type == 'stack' ) {
stackContainers.push( item );
}
else if( !item.isComponent ) {
this._findAllStackContainersRecursive( stackContainers, item );
}
}, this ) );
} | [
"function",
"(",
"stackContainers",
",",
"node",
")",
"{",
"node",
".",
"contentItems",
".",
"forEach",
"(",
"lm",
".",
"utils",
".",
"fnBind",
"(",
"function",
"(",
"item",
")",
"{",
"if",
"(",
"item",
".",
"type",
"==",
"'stack'",
")",
"{",
"stackContainers",
".",
"push",
"(",
"item",
")",
";",
"}",
"else",
"if",
"(",
"!",
"item",
".",
"isComponent",
")",
"{",
"this",
".",
"_findAllStackContainersRecursive",
"(",
"stackContainers",
",",
"item",
")",
";",
"}",
"}",
",",
"this",
")",
")",
";",
"}"
] | Finds all the stack containers.
@param {array} - Set of containers to populate.
@param {object} - Current node to process.
@returns {void} | [
"Finds",
"all",
"the",
"stack",
"containers",
"."
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/LayoutManager.js#L1068-L1077 |
|
6,681 | golden-layout/golden-layout | src/js/items/Stack.js | function() {
var contentItem,
isClosable,
len,
i;
isClosable = this.header._isClosable();
for( i = 0, len = this.contentItems.length; i < len; i++ ) {
if( !isClosable ) {
break;
}
isClosable = this.contentItems[ i ].config.isClosable;
}
this.header._$setClosable( isClosable );
} | javascript | function() {
var contentItem,
isClosable,
len,
i;
isClosable = this.header._isClosable();
for( i = 0, len = this.contentItems.length; i < len; i++ ) {
if( !isClosable ) {
break;
}
isClosable = this.contentItems[ i ].config.isClosable;
}
this.header._$setClosable( isClosable );
} | [
"function",
"(",
")",
"{",
"var",
"contentItem",
",",
"isClosable",
",",
"len",
",",
"i",
";",
"isClosable",
"=",
"this",
".",
"header",
".",
"_isClosable",
"(",
")",
";",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"this",
".",
"contentItems",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"isClosable",
")",
"{",
"break",
";",
"}",
"isClosable",
"=",
"this",
".",
"contentItems",
"[",
"i",
"]",
".",
"config",
".",
"isClosable",
";",
"}",
"this",
".",
"header",
".",
"_$setClosable",
"(",
"isClosable",
")",
";",
"}"
] | Validates that the stack is still closable or not. If a stack is able
to close, but has a non closable component added to it, the stack is no
longer closable until all components are closable.
@returns {void} | [
"Validates",
"that",
"the",
"stack",
"is",
"still",
"closable",
"or",
"not",
".",
"If",
"a",
"stack",
"is",
"able",
"to",
"close",
"but",
"has",
"a",
"non",
"closable",
"component",
"added",
"to",
"it",
"the",
"stack",
"is",
"no",
"longer",
"closable",
"until",
"all",
"components",
"are",
"closable",
"."
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/items/Stack.js#L159-L176 |
|
6,682 | golden-layout/golden-layout | src/js/items/Stack.js | function( x, y ) {
var segment, area;
for( segment in this._contentAreaDimensions ) {
area = this._contentAreaDimensions[ segment ].hoverArea;
if( area.x1 < x && area.x2 > x && area.y1 < y && area.y2 > y ) {
if( segment === 'header' ) {
this._dropSegment = 'header';
this._highlightHeaderDropZone( this._sided ? y : x );
} else {
this._resetHeaderDropZone();
this._highlightBodyDropZone( segment );
}
return;
}
}
} | javascript | function( x, y ) {
var segment, area;
for( segment in this._contentAreaDimensions ) {
area = this._contentAreaDimensions[ segment ].hoverArea;
if( area.x1 < x && area.x2 > x && area.y1 < y && area.y2 > y ) {
if( segment === 'header' ) {
this._dropSegment = 'header';
this._highlightHeaderDropZone( this._sided ? y : x );
} else {
this._resetHeaderDropZone();
this._highlightBodyDropZone( segment );
}
return;
}
}
} | [
"function",
"(",
"x",
",",
"y",
")",
"{",
"var",
"segment",
",",
"area",
";",
"for",
"(",
"segment",
"in",
"this",
".",
"_contentAreaDimensions",
")",
"{",
"area",
"=",
"this",
".",
"_contentAreaDimensions",
"[",
"segment",
"]",
".",
"hoverArea",
";",
"if",
"(",
"area",
".",
"x1",
"<",
"x",
"&&",
"area",
".",
"x2",
">",
"x",
"&&",
"area",
".",
"y1",
"<",
"y",
"&&",
"area",
".",
"y2",
">",
"y",
")",
"{",
"if",
"(",
"segment",
"===",
"'header'",
")",
"{",
"this",
".",
"_dropSegment",
"=",
"'header'",
";",
"this",
".",
"_highlightHeaderDropZone",
"(",
"this",
".",
"_sided",
"?",
"y",
":",
"x",
")",
";",
"}",
"else",
"{",
"this",
".",
"_resetHeaderDropZone",
"(",
")",
";",
"this",
".",
"_highlightBodyDropZone",
"(",
"segment",
")",
";",
"}",
"return",
";",
"}",
"}",
"}"
] | If the user hovers above the header part of the stack, indicate drop positions for tabs.
otherwise indicate which segment of the body the dragged item would be dropped on
@param {Int} x Absolute Screen X
@param {Int} y Absolute Screen Y
@returns {void} | [
"If",
"the",
"user",
"hovers",
"above",
"the",
"header",
"part",
"of",
"the",
"stack",
"indicate",
"drop",
"positions",
"for",
"tabs",
".",
"otherwise",
"indicate",
"which",
"segment",
"of",
"the",
"body",
"the",
"dragged",
"item",
"would",
"be",
"dropped",
"on"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/items/Stack.js#L291-L310 |
|
6,683 | golden-layout/golden-layout | src/js/items/AbstractContentItem.js | function( e ) {
e && e.preventDefault();
if( this.isMaximised === true ) {
this.layoutManager._$minimiseItem( this );
} else {
this.layoutManager._$maximiseItem( this );
}
this.isMaximised = !this.isMaximised;
this.emitBubblingEvent( 'stateChanged' );
} | javascript | function( e ) {
e && e.preventDefault();
if( this.isMaximised === true ) {
this.layoutManager._$minimiseItem( this );
} else {
this.layoutManager._$maximiseItem( this );
}
this.isMaximised = !this.isMaximised;
this.emitBubblingEvent( 'stateChanged' );
} | [
"function",
"(",
"e",
")",
"{",
"e",
"&&",
"e",
".",
"preventDefault",
"(",
")",
";",
"if",
"(",
"this",
".",
"isMaximised",
"===",
"true",
")",
"{",
"this",
".",
"layoutManager",
".",
"_$minimiseItem",
"(",
"this",
")",
";",
"}",
"else",
"{",
"this",
".",
"layoutManager",
".",
"_$maximiseItem",
"(",
"this",
")",
";",
"}",
"this",
".",
"isMaximised",
"=",
"!",
"this",
".",
"isMaximised",
";",
"this",
".",
"emitBubblingEvent",
"(",
"'stateChanged'",
")",
";",
"}"
] | Maximises the Item or minimises it if it is already maximised
@returns {void} | [
"Maximises",
"the",
"Item",
"or",
"minimises",
"it",
"if",
"it",
"is",
"already",
"maximised"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/items/AbstractContentItem.js#L244-L254 |
|
6,684 | golden-layout/golden-layout | src/js/items/AbstractContentItem.js | function( id ) {
if( !this.config.id ) {
return false;
} else if( typeof this.config.id === 'string' ) {
return this.config.id === id;
} else if( this.config.id instanceof Array ) {
return lm.utils.indexOf( id, this.config.id ) !== -1;
}
} | javascript | function( id ) {
if( !this.config.id ) {
return false;
} else if( typeof this.config.id === 'string' ) {
return this.config.id === id;
} else if( this.config.id instanceof Array ) {
return lm.utils.indexOf( id, this.config.id ) !== -1;
}
} | [
"function",
"(",
"id",
")",
"{",
"if",
"(",
"!",
"this",
".",
"config",
".",
"id",
")",
"{",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"typeof",
"this",
".",
"config",
".",
"id",
"===",
"'string'",
")",
"{",
"return",
"this",
".",
"config",
".",
"id",
"===",
"id",
";",
"}",
"else",
"if",
"(",
"this",
".",
"config",
".",
"id",
"instanceof",
"Array",
")",
"{",
"return",
"lm",
".",
"utils",
".",
"indexOf",
"(",
"id",
",",
"this",
".",
"config",
".",
"id",
")",
"!==",
"-",
"1",
";",
"}",
"}"
] | Checks whether a provided id is present
@public
@param {String} id
@returns {Boolean} isPresent | [
"Checks",
"whether",
"a",
"provided",
"id",
"is",
"present"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/items/AbstractContentItem.js#L302-L310 |
|
6,685 | golden-layout/golden-layout | src/js/items/AbstractContentItem.js | function( id ) {
if( !this.hasId( id ) ) {
throw new Error( 'Id not found' );
}
if( typeof this.config.id === 'string' ) {
delete this.config.id;
} else if( this.config.id instanceof Array ) {
var index = lm.utils.indexOf( id, this.config.id );
this.config.id.splice( index, 1 );
}
} | javascript | function( id ) {
if( !this.hasId( id ) ) {
throw new Error( 'Id not found' );
}
if( typeof this.config.id === 'string' ) {
delete this.config.id;
} else if( this.config.id instanceof Array ) {
var index = lm.utils.indexOf( id, this.config.id );
this.config.id.splice( index, 1 );
}
} | [
"function",
"(",
"id",
")",
"{",
"if",
"(",
"!",
"this",
".",
"hasId",
"(",
"id",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Id not found'",
")",
";",
"}",
"if",
"(",
"typeof",
"this",
".",
"config",
".",
"id",
"===",
"'string'",
")",
"{",
"delete",
"this",
".",
"config",
".",
"id",
";",
"}",
"else",
"if",
"(",
"this",
".",
"config",
".",
"id",
"instanceof",
"Array",
")",
"{",
"var",
"index",
"=",
"lm",
".",
"utils",
".",
"indexOf",
"(",
"id",
",",
"this",
".",
"config",
".",
"id",
")",
";",
"this",
".",
"config",
".",
"id",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"}",
"}"
] | Removes an existing id. Throws an error
if the id is not present
@public
@param {String} id
@returns {void} | [
"Removes",
"an",
"existing",
"id",
".",
"Throws",
"an",
"error",
"if",
"the",
"id",
"is",
"not",
"present"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/items/AbstractContentItem.js#L344-L355 |
|
6,686 | golden-layout/golden-layout | src/js/controls/BrowserPopout.js | function() {
var childConfig,
parentItem,
index = this._indexInParent;
if( this._parentId ) {
/*
* The $.extend call seems a bit pointless, but it's crucial to
* copy the config returned by this.getGlInstance().toConfig()
* onto a new object. Internet Explorer keeps the references
* to objects on the child window, resulting in the following error
* once the child window is closed:
*
* The callee (server [not server application]) is not available and disappeared
*/
childConfig = $.extend( true, {}, this.getGlInstance().toConfig() ).content[ 0 ];
parentItem = this._layoutManager.root.getItemsById( this._parentId )[ 0 ];
/*
* Fallback if parentItem is not available. Either add it to the topmost
* item or make it the topmost item if the layout is empty
*/
if( !parentItem ) {
if( this._layoutManager.root.contentItems.length > 0 ) {
parentItem = this._layoutManager.root.contentItems[ 0 ];
} else {
parentItem = this._layoutManager.root;
}
index = 0;
}
}
parentItem.addChild( childConfig, this._indexInParent );
this.close();
} | javascript | function() {
var childConfig,
parentItem,
index = this._indexInParent;
if( this._parentId ) {
/*
* The $.extend call seems a bit pointless, but it's crucial to
* copy the config returned by this.getGlInstance().toConfig()
* onto a new object. Internet Explorer keeps the references
* to objects on the child window, resulting in the following error
* once the child window is closed:
*
* The callee (server [not server application]) is not available and disappeared
*/
childConfig = $.extend( true, {}, this.getGlInstance().toConfig() ).content[ 0 ];
parentItem = this._layoutManager.root.getItemsById( this._parentId )[ 0 ];
/*
* Fallback if parentItem is not available. Either add it to the topmost
* item or make it the topmost item if the layout is empty
*/
if( !parentItem ) {
if( this._layoutManager.root.contentItems.length > 0 ) {
parentItem = this._layoutManager.root.contentItems[ 0 ];
} else {
parentItem = this._layoutManager.root;
}
index = 0;
}
}
parentItem.addChild( childConfig, this._indexInParent );
this.close();
} | [
"function",
"(",
")",
"{",
"var",
"childConfig",
",",
"parentItem",
",",
"index",
"=",
"this",
".",
"_indexInParent",
";",
"if",
"(",
"this",
".",
"_parentId",
")",
"{",
"/*\n\t\t\t * The $.extend call seems a bit pointless, but it's crucial to\n\t\t\t * copy the config returned by this.getGlInstance().toConfig()\n\t\t\t * onto a new object. Internet Explorer keeps the references\n\t\t\t * to objects on the child window, resulting in the following error\n\t\t\t * once the child window is closed:\n\t\t\t *\n\t\t\t * The callee (server [not server application]) is not available and disappeared\n\t\t\t */",
"childConfig",
"=",
"$",
".",
"extend",
"(",
"true",
",",
"{",
"}",
",",
"this",
".",
"getGlInstance",
"(",
")",
".",
"toConfig",
"(",
")",
")",
".",
"content",
"[",
"0",
"]",
";",
"parentItem",
"=",
"this",
".",
"_layoutManager",
".",
"root",
".",
"getItemsById",
"(",
"this",
".",
"_parentId",
")",
"[",
"0",
"]",
";",
"/*\n\t\t\t * Fallback if parentItem is not available. Either add it to the topmost\n\t\t\t * item or make it the topmost item if the layout is empty\n\t\t\t */",
"if",
"(",
"!",
"parentItem",
")",
"{",
"if",
"(",
"this",
".",
"_layoutManager",
".",
"root",
".",
"contentItems",
".",
"length",
">",
"0",
")",
"{",
"parentItem",
"=",
"this",
".",
"_layoutManager",
".",
"root",
".",
"contentItems",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"parentItem",
"=",
"this",
".",
"_layoutManager",
".",
"root",
";",
"}",
"index",
"=",
"0",
";",
"}",
"}",
"parentItem",
".",
"addChild",
"(",
"childConfig",
",",
"this",
".",
"_indexInParent",
")",
";",
"this",
".",
"close",
"(",
")",
";",
"}"
] | Returns the popped out item to its original position. If the original
parent isn't available anymore it falls back to the layout's topmost element | [
"Returns",
"the",
"popped",
"out",
"item",
"to",
"its",
"original",
"position",
".",
"If",
"the",
"original",
"parent",
"isn",
"t",
"available",
"anymore",
"it",
"falls",
"back",
"to",
"the",
"layout",
"s",
"topmost",
"element"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/controls/BrowserPopout.js#L74-L109 |
|
6,687 | golden-layout/golden-layout | src/js/controls/BrowserPopout.js | function() {
var checkReadyInterval,
url = this._createUrl(),
/**
* Bogus title to prevent re-usage of existing window with the
* same title. The actual title will be set by the new window's
* GoldenLayout instance if it detects that it is in subWindowMode
*/
title = Math.floor( Math.random() * 1000000 ).toString( 36 ),
/**
* The options as used in the window.open string
*/
options = this._serializeWindowOptions( {
width: this._dimensions.width,
height: this._dimensions.height,
innerWidth: this._dimensions.width,
innerHeight: this._dimensions.height,
menubar: 'no',
toolbar: 'no',
location: 'no',
personalbar: 'no',
resizable: 'yes',
scrollbars: 'no',
status: 'no'
} );
this._popoutWindow = window.open( url, title, options );
if( !this._popoutWindow ) {
if( this._layoutManager.config.settings.blockedPopoutsThrowError === true ) {
var error = new Error( 'Popout blocked' );
error.type = 'popoutBlocked';
throw error;
} else {
return;
}
}
$( this._popoutWindow )
.on( 'load', lm.utils.fnBind( this._positionWindow, this ) )
.on( 'unload beforeunload', lm.utils.fnBind( this._onClose, this ) );
/**
* Polling the childwindow to find out if GoldenLayout has been initialised
* doesn't seem optimal, but the alternatives - adding a callback to the parent
* window or raising an event on the window object - both would introduce knowledge
* about the parent to the child window which we'd rather avoid
*/
checkReadyInterval = setInterval( lm.utils.fnBind( function() {
if( this._popoutWindow.__glInstance && this._popoutWindow.__glInstance.isInitialised ) {
this._onInitialised();
clearInterval( checkReadyInterval );
}
}, this ), 10 );
} | javascript | function() {
var checkReadyInterval,
url = this._createUrl(),
/**
* Bogus title to prevent re-usage of existing window with the
* same title. The actual title will be set by the new window's
* GoldenLayout instance if it detects that it is in subWindowMode
*/
title = Math.floor( Math.random() * 1000000 ).toString( 36 ),
/**
* The options as used in the window.open string
*/
options = this._serializeWindowOptions( {
width: this._dimensions.width,
height: this._dimensions.height,
innerWidth: this._dimensions.width,
innerHeight: this._dimensions.height,
menubar: 'no',
toolbar: 'no',
location: 'no',
personalbar: 'no',
resizable: 'yes',
scrollbars: 'no',
status: 'no'
} );
this._popoutWindow = window.open( url, title, options );
if( !this._popoutWindow ) {
if( this._layoutManager.config.settings.blockedPopoutsThrowError === true ) {
var error = new Error( 'Popout blocked' );
error.type = 'popoutBlocked';
throw error;
} else {
return;
}
}
$( this._popoutWindow )
.on( 'load', lm.utils.fnBind( this._positionWindow, this ) )
.on( 'unload beforeunload', lm.utils.fnBind( this._onClose, this ) );
/**
* Polling the childwindow to find out if GoldenLayout has been initialised
* doesn't seem optimal, but the alternatives - adding a callback to the parent
* window or raising an event on the window object - both would introduce knowledge
* about the parent to the child window which we'd rather avoid
*/
checkReadyInterval = setInterval( lm.utils.fnBind( function() {
if( this._popoutWindow.__glInstance && this._popoutWindow.__glInstance.isInitialised ) {
this._onInitialised();
clearInterval( checkReadyInterval );
}
}, this ), 10 );
} | [
"function",
"(",
")",
"{",
"var",
"checkReadyInterval",
",",
"url",
"=",
"this",
".",
"_createUrl",
"(",
")",
",",
"/**\n\t\t\t * Bogus title to prevent re-usage of existing window with the\n\t\t\t * same title. The actual title will be set by the new window's\n\t\t\t * GoldenLayout instance if it detects that it is in subWindowMode\n\t\t\t */",
"title",
"=",
"Math",
".",
"floor",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"1000000",
")",
".",
"toString",
"(",
"36",
")",
",",
"/**\n\t\t\t * The options as used in the window.open string\n\t\t\t */",
"options",
"=",
"this",
".",
"_serializeWindowOptions",
"(",
"{",
"width",
":",
"this",
".",
"_dimensions",
".",
"width",
",",
"height",
":",
"this",
".",
"_dimensions",
".",
"height",
",",
"innerWidth",
":",
"this",
".",
"_dimensions",
".",
"width",
",",
"innerHeight",
":",
"this",
".",
"_dimensions",
".",
"height",
",",
"menubar",
":",
"'no'",
",",
"toolbar",
":",
"'no'",
",",
"location",
":",
"'no'",
",",
"personalbar",
":",
"'no'",
",",
"resizable",
":",
"'yes'",
",",
"scrollbars",
":",
"'no'",
",",
"status",
":",
"'no'",
"}",
")",
";",
"this",
".",
"_popoutWindow",
"=",
"window",
".",
"open",
"(",
"url",
",",
"title",
",",
"options",
")",
";",
"if",
"(",
"!",
"this",
".",
"_popoutWindow",
")",
"{",
"if",
"(",
"this",
".",
"_layoutManager",
".",
"config",
".",
"settings",
".",
"blockedPopoutsThrowError",
"===",
"true",
")",
"{",
"var",
"error",
"=",
"new",
"Error",
"(",
"'Popout blocked'",
")",
";",
"error",
".",
"type",
"=",
"'popoutBlocked'",
";",
"throw",
"error",
";",
"}",
"else",
"{",
"return",
";",
"}",
"}",
"$",
"(",
"this",
".",
"_popoutWindow",
")",
".",
"on",
"(",
"'load'",
",",
"lm",
".",
"utils",
".",
"fnBind",
"(",
"this",
".",
"_positionWindow",
",",
"this",
")",
")",
".",
"on",
"(",
"'unload beforeunload'",
",",
"lm",
".",
"utils",
".",
"fnBind",
"(",
"this",
".",
"_onClose",
",",
"this",
")",
")",
";",
"/**\n\t\t * Polling the childwindow to find out if GoldenLayout has been initialised\n\t\t * doesn't seem optimal, but the alternatives - adding a callback to the parent\n\t\t * window or raising an event on the window object - both would introduce knowledge\n\t\t * about the parent to the child window which we'd rather avoid\n\t\t */",
"checkReadyInterval",
"=",
"setInterval",
"(",
"lm",
".",
"utils",
".",
"fnBind",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_popoutWindow",
".",
"__glInstance",
"&&",
"this",
".",
"_popoutWindow",
".",
"__glInstance",
".",
"isInitialised",
")",
"{",
"this",
".",
"_onInitialised",
"(",
")",
";",
"clearInterval",
"(",
"checkReadyInterval",
")",
";",
"}",
"}",
",",
"this",
")",
",",
"10",
")",
";",
"}"
] | Creates the URL and window parameter
and opens a new window
@private
@returns {void} | [
"Creates",
"the",
"URL",
"and",
"window",
"parameter",
"and",
"opens",
"a",
"new",
"window"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/controls/BrowserPopout.js#L119-L175 |
|
6,688 | golden-layout/golden-layout | src/js/controls/BrowserPopout.js | function() {
var config = { content: this._config },
storageKey = 'gl-window-config-' + lm.utils.getUniqueId(),
urlParts;
config = ( new lm.utils.ConfigMinifier() ).minifyConfig( config );
try {
localStorage.setItem( storageKey, JSON.stringify( config ) );
} catch( e ) {
throw new Error( 'Error while writing to localStorage ' + e.toString() );
}
urlParts = document.location.href.split( '?' );
// URL doesn't contain GET-parameters
if( urlParts.length === 1 ) {
return urlParts[ 0 ] + '?gl-window=' + storageKey;
// URL contains GET-parameters
} else {
return document.location.href + '&gl-window=' + storageKey;
}
} | javascript | function() {
var config = { content: this._config },
storageKey = 'gl-window-config-' + lm.utils.getUniqueId(),
urlParts;
config = ( new lm.utils.ConfigMinifier() ).minifyConfig( config );
try {
localStorage.setItem( storageKey, JSON.stringify( config ) );
} catch( e ) {
throw new Error( 'Error while writing to localStorage ' + e.toString() );
}
urlParts = document.location.href.split( '?' );
// URL doesn't contain GET-parameters
if( urlParts.length === 1 ) {
return urlParts[ 0 ] + '?gl-window=' + storageKey;
// URL contains GET-parameters
} else {
return document.location.href + '&gl-window=' + storageKey;
}
} | [
"function",
"(",
")",
"{",
"var",
"config",
"=",
"{",
"content",
":",
"this",
".",
"_config",
"}",
",",
"storageKey",
"=",
"'gl-window-config-'",
"+",
"lm",
".",
"utils",
".",
"getUniqueId",
"(",
")",
",",
"urlParts",
";",
"config",
"=",
"(",
"new",
"lm",
".",
"utils",
".",
"ConfigMinifier",
"(",
")",
")",
".",
"minifyConfig",
"(",
"config",
")",
";",
"try",
"{",
"localStorage",
".",
"setItem",
"(",
"storageKey",
",",
"JSON",
".",
"stringify",
"(",
"config",
")",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Error while writing to localStorage '",
"+",
"e",
".",
"toString",
"(",
")",
")",
";",
"}",
"urlParts",
"=",
"document",
".",
"location",
".",
"href",
".",
"split",
"(",
"'?'",
")",
";",
"// URL doesn't contain GET-parameters",
"if",
"(",
"urlParts",
".",
"length",
"===",
"1",
")",
"{",
"return",
"urlParts",
"[",
"0",
"]",
"+",
"'?gl-window='",
"+",
"storageKey",
";",
"// URL contains GET-parameters",
"}",
"else",
"{",
"return",
"document",
".",
"location",
".",
"href",
"+",
"'&gl-window='",
"+",
"storageKey",
";",
"}",
"}"
] | Creates the URL for the new window, including the
config GET parameter
@returns {String} URL | [
"Creates",
"the",
"URL",
"for",
"the",
"new",
"window",
"including",
"the",
"config",
"GET",
"parameter"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/controls/BrowserPopout.js#L200-L223 |
|
6,689 | golden-layout/golden-layout | website/assets/js/payment.js | function( form ) {
var inputGroups = form.find( '.inputGroup' ),
isValid = true,
inputGroup,
i;
for( i = 0; i < inputGroups.length; i++ ) {
inputGroup = $( inputGroups[ i ] );
if( $.trim( inputGroup.find( 'input' ).val() ).length === 0 ) {
inputGroup.addClass( 'error' );
isValid = false;
} else {
inputGroup.removeClass( 'error' );
}
}
return isValid;
} | javascript | function( form ) {
var inputGroups = form.find( '.inputGroup' ),
isValid = true,
inputGroup,
i;
for( i = 0; i < inputGroups.length; i++ ) {
inputGroup = $( inputGroups[ i ] );
if( $.trim( inputGroup.find( 'input' ).val() ).length === 0 ) {
inputGroup.addClass( 'error' );
isValid = false;
} else {
inputGroup.removeClass( 'error' );
}
}
return isValid;
} | [
"function",
"(",
"form",
")",
"{",
"var",
"inputGroups",
"=",
"form",
".",
"find",
"(",
"'.inputGroup'",
")",
",",
"isValid",
"=",
"true",
",",
"inputGroup",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"inputGroups",
".",
"length",
";",
"i",
"++",
")",
"{",
"inputGroup",
"=",
"$",
"(",
"inputGroups",
"[",
"i",
"]",
")",
";",
"if",
"(",
"$",
".",
"trim",
"(",
"inputGroup",
".",
"find",
"(",
"'input'",
")",
".",
"val",
"(",
")",
")",
".",
"length",
"===",
"0",
")",
"{",
"inputGroup",
".",
"addClass",
"(",
"'error'",
")",
";",
"isValid",
"=",
"false",
";",
"}",
"else",
"{",
"inputGroup",
".",
"removeClass",
"(",
"'error'",
")",
";",
"}",
"}",
"return",
"isValid",
";",
"}"
] | Validate the forms input fields
@param {jQuery Element} form
@returns {Boolean} | [
"Validate",
"the",
"forms",
"input",
"fields"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/website/assets/js/payment.js#L12-L30 |
|
6,690 | golden-layout/golden-layout | src/js/controls/DragProxy.js | function( offsetX, offsetY, event ) {
event = event.originalEvent && event.originalEvent.touches ? event.originalEvent.touches[ 0 ] : event;
var x = event.pageX,
y = event.pageY,
isWithinContainer = x > this._minX && x < this._maxX && y > this._minY && y < this._maxY;
if( !isWithinContainer && this._layoutManager.config.settings.constrainDragToContainer === true ) {
return;
}
this._setDropPosition( x, y );
} | javascript | function( offsetX, offsetY, event ) {
event = event.originalEvent && event.originalEvent.touches ? event.originalEvent.touches[ 0 ] : event;
var x = event.pageX,
y = event.pageY,
isWithinContainer = x > this._minX && x < this._maxX && y > this._minY && y < this._maxY;
if( !isWithinContainer && this._layoutManager.config.settings.constrainDragToContainer === true ) {
return;
}
this._setDropPosition( x, y );
} | [
"function",
"(",
"offsetX",
",",
"offsetY",
",",
"event",
")",
"{",
"event",
"=",
"event",
".",
"originalEvent",
"&&",
"event",
".",
"originalEvent",
".",
"touches",
"?",
"event",
".",
"originalEvent",
".",
"touches",
"[",
"0",
"]",
":",
"event",
";",
"var",
"x",
"=",
"event",
".",
"pageX",
",",
"y",
"=",
"event",
".",
"pageY",
",",
"isWithinContainer",
"=",
"x",
">",
"this",
".",
"_minX",
"&&",
"x",
"<",
"this",
".",
"_maxX",
"&&",
"y",
">",
"this",
".",
"_minY",
"&&",
"y",
"<",
"this",
".",
"_maxY",
";",
"if",
"(",
"!",
"isWithinContainer",
"&&",
"this",
".",
"_layoutManager",
".",
"config",
".",
"settings",
".",
"constrainDragToContainer",
"===",
"true",
")",
"{",
"return",
";",
"}",
"this",
".",
"_setDropPosition",
"(",
"x",
",",
"y",
")",
";",
"}"
] | Callback on every mouseMove event during a drag. Determines if the drag is
still within the valid drag area and calls the layoutManager to highlight the
current drop area
@param {Number} offsetX The difference from the original x position in px
@param {Number} offsetY The difference from the original y position in px
@param {jQuery DOM event} event
@private
@returns {void} | [
"Callback",
"on",
"every",
"mouseMove",
"event",
"during",
"a",
"drag",
".",
"Determines",
"if",
"the",
"drag",
"is",
"still",
"within",
"the",
"valid",
"drag",
"area",
"and",
"calls",
"the",
"layoutManager",
"to",
"highlight",
"the",
"current",
"drop",
"area"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/controls/DragProxy.js#L88-L101 |
|
6,691 | golden-layout/golden-layout | src/js/controls/DragProxy.js | function( x, y ) {
this.element.css( { left: x, top: y } );
this._area = this._layoutManager._$getArea( x, y );
if( this._area !== null ) {
this._lastValidArea = this._area;
this._area.contentItem._$highlightDropZone( x, y, this._area );
}
} | javascript | function( x, y ) {
this.element.css( { left: x, top: y } );
this._area = this._layoutManager._$getArea( x, y );
if( this._area !== null ) {
this._lastValidArea = this._area;
this._area.contentItem._$highlightDropZone( x, y, this._area );
}
} | [
"function",
"(",
"x",
",",
"y",
")",
"{",
"this",
".",
"element",
".",
"css",
"(",
"{",
"left",
":",
"x",
",",
"top",
":",
"y",
"}",
")",
";",
"this",
".",
"_area",
"=",
"this",
".",
"_layoutManager",
".",
"_$getArea",
"(",
"x",
",",
"y",
")",
";",
"if",
"(",
"this",
".",
"_area",
"!==",
"null",
")",
"{",
"this",
".",
"_lastValidArea",
"=",
"this",
".",
"_area",
";",
"this",
".",
"_area",
".",
"contentItem",
".",
"_$highlightDropZone",
"(",
"x",
",",
"y",
",",
"this",
".",
"_area",
")",
";",
"}",
"}"
] | Sets the target position, highlighting the appropriate area
@param {Number} x The x position in px
@param {Number} y The y position in px
@private
@returns {void} | [
"Sets",
"the",
"target",
"position",
"highlighting",
"the",
"appropriate",
"area"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/controls/DragProxy.js#L113-L121 |
|
6,692 | golden-layout/golden-layout | src/js/controls/DragProxy.js | function() {
var dimensions = this._layoutManager.config.dimensions,
width = dimensions.dragProxyWidth,
height = dimensions.dragProxyHeight;
this.element.width( width );
this.element.height( height );
width -= ( this._sided ? dimensions.headerHeight : 0 );
height -= ( !this._sided ? dimensions.headerHeight : 0 );
this.childElementContainer.width( width );
this.childElementContainer.height( height );
this._contentItem.element.width( width );
this._contentItem.element.height( height );
this._contentItem.callDownwards( '_$show' );
this._contentItem.callDownwards( 'setSize' );
} | javascript | function() {
var dimensions = this._layoutManager.config.dimensions,
width = dimensions.dragProxyWidth,
height = dimensions.dragProxyHeight;
this.element.width( width );
this.element.height( height );
width -= ( this._sided ? dimensions.headerHeight : 0 );
height -= ( !this._sided ? dimensions.headerHeight : 0 );
this.childElementContainer.width( width );
this.childElementContainer.height( height );
this._contentItem.element.width( width );
this._contentItem.element.height( height );
this._contentItem.callDownwards( '_$show' );
this._contentItem.callDownwards( 'setSize' );
} | [
"function",
"(",
")",
"{",
"var",
"dimensions",
"=",
"this",
".",
"_layoutManager",
".",
"config",
".",
"dimensions",
",",
"width",
"=",
"dimensions",
".",
"dragProxyWidth",
",",
"height",
"=",
"dimensions",
".",
"dragProxyHeight",
";",
"this",
".",
"element",
".",
"width",
"(",
"width",
")",
";",
"this",
".",
"element",
".",
"height",
"(",
"height",
")",
";",
"width",
"-=",
"(",
"this",
".",
"_sided",
"?",
"dimensions",
".",
"headerHeight",
":",
"0",
")",
";",
"height",
"-=",
"(",
"!",
"this",
".",
"_sided",
"?",
"dimensions",
".",
"headerHeight",
":",
"0",
")",
";",
"this",
".",
"childElementContainer",
".",
"width",
"(",
"width",
")",
";",
"this",
".",
"childElementContainer",
".",
"height",
"(",
"height",
")",
";",
"this",
".",
"_contentItem",
".",
"element",
".",
"width",
"(",
"width",
")",
";",
"this",
".",
"_contentItem",
".",
"element",
".",
"height",
"(",
"height",
")",
";",
"this",
".",
"_contentItem",
".",
"callDownwards",
"(",
"'_$show'",
")",
";",
"this",
".",
"_contentItem",
".",
"callDownwards",
"(",
"'setSize'",
")",
";",
"}"
] | Updates the Drag Proxie's dimensions
@private
@returns {void} | [
"Updates",
"the",
"Drag",
"Proxie",
"s",
"dimensions"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/controls/DragProxy.js#L195-L210 |
|
6,693 | golden-layout/golden-layout | src/js/controls/Header.js | function( position ) {
var previous = this.parent._header.show;
if( this.parent._docker && this.parent._docker.docked )
throw new Error( 'Can\'t change header position in docked stack' );
if( previous && !this.parent._side )
previous = 'top';
if( position !== undefined && this.parent._header.show != position ) {
this.parent._header.show = position;
this.parent.config.header ? this.parent.config.header.show = position : this.parent.config.header = { show:position };
this.parent._setupHeaderPosition();
}
return previous;
} | javascript | function( position ) {
var previous = this.parent._header.show;
if( this.parent._docker && this.parent._docker.docked )
throw new Error( 'Can\'t change header position in docked stack' );
if( previous && !this.parent._side )
previous = 'top';
if( position !== undefined && this.parent._header.show != position ) {
this.parent._header.show = position;
this.parent.config.header ? this.parent.config.header.show = position : this.parent.config.header = { show:position };
this.parent._setupHeaderPosition();
}
return previous;
} | [
"function",
"(",
"position",
")",
"{",
"var",
"previous",
"=",
"this",
".",
"parent",
".",
"_header",
".",
"show",
";",
"if",
"(",
"this",
".",
"parent",
".",
"_docker",
"&&",
"this",
".",
"parent",
".",
"_docker",
".",
"docked",
")",
"throw",
"new",
"Error",
"(",
"'Can\\'t change header position in docked stack'",
")",
";",
"if",
"(",
"previous",
"&&",
"!",
"this",
".",
"parent",
".",
"_side",
")",
"previous",
"=",
"'top'",
";",
"if",
"(",
"position",
"!==",
"undefined",
"&&",
"this",
".",
"parent",
".",
"_header",
".",
"show",
"!=",
"position",
")",
"{",
"this",
".",
"parent",
".",
"_header",
".",
"show",
"=",
"position",
";",
"this",
".",
"parent",
".",
"config",
".",
"header",
"?",
"this",
".",
"parent",
".",
"config",
".",
"header",
".",
"show",
"=",
"position",
":",
"this",
".",
"parent",
".",
"config",
".",
"header",
"=",
"{",
"show",
":",
"position",
"}",
";",
"this",
".",
"parent",
".",
"_setupHeaderPosition",
"(",
")",
";",
"}",
"return",
"previous",
";",
"}"
] | Programmatically operate with header position.
@param {string} position one of ('top','left','right','bottom') to set or empty to get it.
@returns {string} previous header position | [
"Programmatically",
"operate",
"with",
"header",
"position",
"."
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/controls/Header.js#L152-L164 |
|
6,694 | golden-layout/golden-layout | src/js/controls/Header.js | function( isClosable ) {
this._canDestroy = isClosable || this.tabs.length > 1;
if( this.closeButton && this._isClosable() ) {
this.closeButton.element[ isClosable ? "show" : "hide" ]();
return true;
}
return false;
} | javascript | function( isClosable ) {
this._canDestroy = isClosable || this.tabs.length > 1;
if( this.closeButton && this._isClosable() ) {
this.closeButton.element[ isClosable ? "show" : "hide" ]();
return true;
}
return false;
} | [
"function",
"(",
"isClosable",
")",
"{",
"this",
".",
"_canDestroy",
"=",
"isClosable",
"||",
"this",
".",
"tabs",
".",
"length",
">",
"1",
";",
"if",
"(",
"this",
".",
"closeButton",
"&&",
"this",
".",
"_isClosable",
"(",
")",
")",
"{",
"this",
".",
"closeButton",
".",
"element",
"[",
"isClosable",
"?",
"\"show\"",
":",
"\"hide\"",
"]",
"(",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Programmatically set closability.
@package private
@param {Boolean} isClosable Whether to enable/disable closability.
@returns {Boolean} Whether the action was successful | [
"Programmatically",
"set",
"closability",
"."
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/controls/Header.js#L174-L182 |
|
6,695 | golden-layout/golden-layout | src/js/controls/Header.js | function( isDockable ) {
if ( this.dockButton && this.parent._header && this.parent._header.dock ) {
this.dockButton.element.toggle( !!isDockable );
return true;
}
return false;
} | javascript | function( isDockable ) {
if ( this.dockButton && this.parent._header && this.parent._header.dock ) {
this.dockButton.element.toggle( !!isDockable );
return true;
}
return false;
} | [
"function",
"(",
"isDockable",
")",
"{",
"if",
"(",
"this",
".",
"dockButton",
"&&",
"this",
".",
"parent",
".",
"_header",
"&&",
"this",
".",
"parent",
".",
"_header",
".",
"dock",
")",
"{",
"this",
".",
"dockButton",
".",
"element",
".",
"toggle",
"(",
"!",
"!",
"isDockable",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Programmatically set ability to dock.
@package private
@param {Boolean} isDockable Whether to enable/disable ability to dock.
@returns {Boolean} Whether the action was successful | [
"Programmatically",
"set",
"ability",
"to",
"dock",
"."
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/controls/Header.js#L192-L198 |
|
6,696 | golden-layout/golden-layout | src/js/utils/ReactComponentHandler.js | function() {
ReactDOM.unmountComponentAtNode( this._container.getElement()[ 0 ] );
this._container.off( 'open', this._render, this );
this._container.off( 'destroy', this._destroy, this );
} | javascript | function() {
ReactDOM.unmountComponentAtNode( this._container.getElement()[ 0 ] );
this._container.off( 'open', this._render, this );
this._container.off( 'destroy', this._destroy, this );
} | [
"function",
"(",
")",
"{",
"ReactDOM",
".",
"unmountComponentAtNode",
"(",
"this",
".",
"_container",
".",
"getElement",
"(",
")",
"[",
"0",
"]",
")",
";",
"this",
".",
"_container",
".",
"off",
"(",
"'open'",
",",
"this",
".",
"_render",
",",
"this",
")",
";",
"this",
".",
"_container",
".",
"off",
"(",
"'destroy'",
",",
"this",
".",
"_destroy",
",",
"this",
")",
";",
"}"
] | Removes the component from the DOM and thus invokes React's unmount lifecycle
@private
@returns {void} | [
"Removes",
"the",
"component",
"from",
"the",
"DOM",
"and",
"thus",
"invokes",
"React",
"s",
"unmount",
"lifecycle"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/utils/ReactComponentHandler.js#L61-L65 |
|
6,697 | golden-layout/golden-layout | src/js/utils/ReactComponentHandler.js | function( nextProps, nextState ) {
this._container.setState( nextState );
this._originalComponentWillUpdate.call( this._reactComponent, nextProps, nextState );
} | javascript | function( nextProps, nextState ) {
this._container.setState( nextState );
this._originalComponentWillUpdate.call( this._reactComponent, nextProps, nextState );
} | [
"function",
"(",
"nextProps",
",",
"nextState",
")",
"{",
"this",
".",
"_container",
".",
"setState",
"(",
"nextState",
")",
";",
"this",
".",
"_originalComponentWillUpdate",
".",
"call",
"(",
"this",
".",
"_reactComponent",
",",
"nextProps",
",",
"nextState",
")",
";",
"}"
] | Hooks into React's state management and applies the componentstate
to GoldenLayout
@private
@returns {void} | [
"Hooks",
"into",
"React",
"s",
"state",
"management",
"and",
"applies",
"the",
"componentstate",
"to",
"GoldenLayout"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/utils/ReactComponentHandler.js#L74-L77 |
|
6,698 | golden-layout/golden-layout | src/js/utils/ReactComponentHandler.js | function() {
var componentName = this._container._config.component;
var reactClass;
if( !componentName ) {
throw new Error( 'No react component name. type: react-component needs a field `component`' );
}
reactClass = this._container.layoutManager.getComponent( componentName );
if( !reactClass ) {
throw new Error( 'React component "' + componentName + '" not found. ' +
'Please register all components with GoldenLayout using `registerComponent(name, component)`' );
}
return reactClass;
} | javascript | function() {
var componentName = this._container._config.component;
var reactClass;
if( !componentName ) {
throw new Error( 'No react component name. type: react-component needs a field `component`' );
}
reactClass = this._container.layoutManager.getComponent( componentName );
if( !reactClass ) {
throw new Error( 'React component "' + componentName + '" not found. ' +
'Please register all components with GoldenLayout using `registerComponent(name, component)`' );
}
return reactClass;
} | [
"function",
"(",
")",
"{",
"var",
"componentName",
"=",
"this",
".",
"_container",
".",
"_config",
".",
"component",
";",
"var",
"reactClass",
";",
"if",
"(",
"!",
"componentName",
")",
"{",
"throw",
"new",
"Error",
"(",
"'No react component name. type: react-component needs a field `component`'",
")",
";",
"}",
"reactClass",
"=",
"this",
".",
"_container",
".",
"layoutManager",
".",
"getComponent",
"(",
"componentName",
")",
";",
"if",
"(",
"!",
"reactClass",
")",
"{",
"throw",
"new",
"Error",
"(",
"'React component \"'",
"+",
"componentName",
"+",
"'\" not found. '",
"+",
"'Please register all components with GoldenLayout using `registerComponent(name, component)`'",
")",
";",
"}",
"return",
"reactClass",
";",
"}"
] | Retrieves the react class from GoldenLayout's registry
@private
@returns {React.Class} | [
"Retrieves",
"the",
"react",
"class",
"from",
"GoldenLayout",
"s",
"registry"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/utils/ReactComponentHandler.js#L85-L101 |
|
6,699 | golden-layout/golden-layout | src/js/utils/ReactComponentHandler.js | function() {
var defaultProps = {
glEventHub: this._container.layoutManager.eventHub,
glContainer: this._container,
ref: this._gotReactComponent.bind( this )
};
var props = $.extend( defaultProps, this._container._config.props );
return React.createElement( this._reactClass, props );
} | javascript | function() {
var defaultProps = {
glEventHub: this._container.layoutManager.eventHub,
glContainer: this._container,
ref: this._gotReactComponent.bind( this )
};
var props = $.extend( defaultProps, this._container._config.props );
return React.createElement( this._reactClass, props );
} | [
"function",
"(",
")",
"{",
"var",
"defaultProps",
"=",
"{",
"glEventHub",
":",
"this",
".",
"_container",
".",
"layoutManager",
".",
"eventHub",
",",
"glContainer",
":",
"this",
".",
"_container",
",",
"ref",
":",
"this",
".",
"_gotReactComponent",
".",
"bind",
"(",
"this",
")",
"}",
";",
"var",
"props",
"=",
"$",
".",
"extend",
"(",
"defaultProps",
",",
"this",
".",
"_container",
".",
"_config",
".",
"props",
")",
";",
"return",
"React",
".",
"createElement",
"(",
"this",
".",
"_reactClass",
",",
"props",
")",
";",
"}"
] | Copies and extends the properties array and returns the React element
@private
@returns {React.Element} | [
"Copies",
"and",
"extends",
"the",
"properties",
"array",
"and",
"returns",
"the",
"React",
"element"
] | 41ffb9f693b810132760d7b1218237820e5f9612 | https://github.com/golden-layout/golden-layout/blob/41ffb9f693b810132760d7b1218237820e5f9612/src/js/utils/ReactComponentHandler.js#L109-L117 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.