id
int32 0
58k
| repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
list | docstring
stringlengths 4
11.8k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 86
226
|
|---|---|---|---|---|---|---|---|---|---|---|---|
11,000
|
ternjs/tern
|
lib/tern.js
|
invalidDoc
|
function invalidDoc(doc) {
if (doc.query) {
if (typeof doc.query.type != "string") return ".query.type must be a string";
if (doc.query.start && !isPosition(doc.query.start)) return ".query.start must be a position";
if (doc.query.end && !isPosition(doc.query.end)) return ".query.end must be a position";
}
if (doc.files) {
if (!Array.isArray(doc.files)) return "Files property must be an array";
for (var i = 0; i < doc.files.length; ++i) {
var file = doc.files[i];
if (typeof file != "object") return ".files[n] must be objects";
else if (typeof file.name != "string") return ".files[n].name must be a string";
else if (file.type == "delete") continue;
else if (typeof file.text != "string") return ".files[n].text must be a string";
else if (file.type == "part") {
if (!isPosition(file.offset) && typeof file.offsetLines != "number")
return ".files[n].offset must be a position";
} else if (file.type != "full") return ".files[n].type must be \"full\" or \"part\"";
}
}
}
|
javascript
|
function invalidDoc(doc) {
if (doc.query) {
if (typeof doc.query.type != "string") return ".query.type must be a string";
if (doc.query.start && !isPosition(doc.query.start)) return ".query.start must be a position";
if (doc.query.end && !isPosition(doc.query.end)) return ".query.end must be a position";
}
if (doc.files) {
if (!Array.isArray(doc.files)) return "Files property must be an array";
for (var i = 0; i < doc.files.length; ++i) {
var file = doc.files[i];
if (typeof file != "object") return ".files[n] must be objects";
else if (typeof file.name != "string") return ".files[n].name must be a string";
else if (file.type == "delete") continue;
else if (typeof file.text != "string") return ".files[n].text must be a string";
else if (file.type == "part") {
if (!isPosition(file.offset) && typeof file.offsetLines != "number")
return ".files[n].offset must be a position";
} else if (file.type != "full") return ".files[n].type must be \"full\" or \"part\"";
}
}
}
|
[
"function",
"invalidDoc",
"(",
"doc",
")",
"{",
"if",
"(",
"doc",
".",
"query",
")",
"{",
"if",
"(",
"typeof",
"doc",
".",
"query",
".",
"type",
"!=",
"\"string\"",
")",
"return",
"\".query.type must be a string\"",
";",
"if",
"(",
"doc",
".",
"query",
".",
"start",
"&&",
"!",
"isPosition",
"(",
"doc",
".",
"query",
".",
"start",
")",
")",
"return",
"\".query.start must be a position\"",
";",
"if",
"(",
"doc",
".",
"query",
".",
"end",
"&&",
"!",
"isPosition",
"(",
"doc",
".",
"query",
".",
"end",
")",
")",
"return",
"\".query.end must be a position\"",
";",
"}",
"if",
"(",
"doc",
".",
"files",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"doc",
".",
"files",
")",
")",
"return",
"\"Files property must be an array\"",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"doc",
".",
"files",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"file",
"=",
"doc",
".",
"files",
"[",
"i",
"]",
";",
"if",
"(",
"typeof",
"file",
"!=",
"\"object\"",
")",
"return",
"\".files[n] must be objects\"",
";",
"else",
"if",
"(",
"typeof",
"file",
".",
"name",
"!=",
"\"string\"",
")",
"return",
"\".files[n].name must be a string\"",
";",
"else",
"if",
"(",
"file",
".",
"type",
"==",
"\"delete\"",
")",
"continue",
";",
"else",
"if",
"(",
"typeof",
"file",
".",
"text",
"!=",
"\"string\"",
")",
"return",
"\".files[n].text must be a string\"",
";",
"else",
"if",
"(",
"file",
".",
"type",
"==",
"\"part\"",
")",
"{",
"if",
"(",
"!",
"isPosition",
"(",
"file",
".",
"offset",
")",
"&&",
"typeof",
"file",
".",
"offsetLines",
"!=",
"\"number\"",
")",
"return",
"\".files[n].offset must be a position\"",
";",
"}",
"else",
"if",
"(",
"file",
".",
"type",
"!=",
"\"full\"",
")",
"return",
"\".files[n].type must be \\\"full\\\" or \\\"part\\\"\"",
";",
"}",
"}",
"}"
] |
Baseline query document validation
|
[
"Baseline",
"query",
"document",
"validation"
] |
3b2707c1c4fa82af8949dd6bb180b439883762be
|
https://github.com/ternjs/tern/blob/3b2707c1c4fa82af8949dd6bb180b439883762be/lib/tern.js#L546-L566
|
11,001
|
ternjs/tern
|
lib/tern.js
|
clean
|
function clean(obj) {
for (var prop in obj) if (obj[prop] == null) delete obj[prop];
return obj;
}
|
javascript
|
function clean(obj) {
for (var prop in obj) if (obj[prop] == null) delete obj[prop];
return obj;
}
|
[
"function",
"clean",
"(",
"obj",
")",
"{",
"for",
"(",
"var",
"prop",
"in",
"obj",
")",
"if",
"(",
"obj",
"[",
"prop",
"]",
"==",
"null",
")",
"delete",
"obj",
"[",
"prop",
"]",
";",
"return",
"obj",
";",
"}"
] |
Delete empty fields from result objects
|
[
"Delete",
"empty",
"fields",
"from",
"result",
"objects"
] |
3b2707c1c4fa82af8949dd6bb180b439883762be
|
https://github.com/ternjs/tern/blob/3b2707c1c4fa82af8949dd6bb180b439883762be/lib/tern.js#L651-L654
|
11,002
|
ternjs/tern
|
lib/tern.js
|
compareCompletions
|
function compareCompletions(a, b) {
if (typeof a != "string") { a = a.name; b = b.name; }
var aUp = /^[A-Z]/.test(a), bUp = /^[A-Z]/.test(b);
if (aUp == bUp) return a < b ? -1 : a == b ? 0 : 1;
else return aUp ? 1 : -1;
}
|
javascript
|
function compareCompletions(a, b) {
if (typeof a != "string") { a = a.name; b = b.name; }
var aUp = /^[A-Z]/.test(a), bUp = /^[A-Z]/.test(b);
if (aUp == bUp) return a < b ? -1 : a == b ? 0 : 1;
else return aUp ? 1 : -1;
}
|
[
"function",
"compareCompletions",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"typeof",
"a",
"!=",
"\"string\"",
")",
"{",
"a",
"=",
"a",
".",
"name",
";",
"b",
"=",
"b",
".",
"name",
";",
"}",
"var",
"aUp",
"=",
"/",
"^[A-Z]",
"/",
".",
"test",
"(",
"a",
")",
",",
"bUp",
"=",
"/",
"^[A-Z]",
"/",
".",
"test",
"(",
"b",
")",
";",
"if",
"(",
"aUp",
"==",
"bUp",
")",
"return",
"a",
"<",
"b",
"?",
"-",
"1",
":",
"a",
"==",
"b",
"?",
"0",
":",
"1",
";",
"else",
"return",
"aUp",
"?",
"1",
":",
"-",
"1",
";",
"}"
] |
Built-in query types
|
[
"Built",
"-",
"in",
"query",
"types"
] |
3b2707c1c4fa82af8949dd6bb180b439883762be
|
https://github.com/ternjs/tern/blob/3b2707c1c4fa82af8949dd6bb180b439883762be/lib/tern.js#L661-L666
|
11,003
|
Semantic-Org/Semantic-UI-CSS
|
components/state.js
|
function() {
var
activeText = text.active || $module.data(metadata.storedText),
inactiveText = text.inactive || $module.data(metadata.storedText)
;
if( module.is.textEnabled() ) {
if( module.is.active() && activeText) {
module.verbose('Resetting active text', activeText);
module.update.text(activeText);
}
else if(inactiveText) {
module.verbose('Resetting inactive text', activeText);
module.update.text(inactiveText);
}
}
}
|
javascript
|
function() {
var
activeText = text.active || $module.data(metadata.storedText),
inactiveText = text.inactive || $module.data(metadata.storedText)
;
if( module.is.textEnabled() ) {
if( module.is.active() && activeText) {
module.verbose('Resetting active text', activeText);
module.update.text(activeText);
}
else if(inactiveText) {
module.verbose('Resetting inactive text', activeText);
module.update.text(inactiveText);
}
}
}
|
[
"function",
"(",
")",
"{",
"var",
"activeText",
"=",
"text",
".",
"active",
"||",
"$module",
".",
"data",
"(",
"metadata",
".",
"storedText",
")",
",",
"inactiveText",
"=",
"text",
".",
"inactive",
"||",
"$module",
".",
"data",
"(",
"metadata",
".",
"storedText",
")",
";",
"if",
"(",
"module",
".",
"is",
".",
"textEnabled",
"(",
")",
")",
"{",
"if",
"(",
"module",
".",
"is",
".",
"active",
"(",
")",
"&&",
"activeText",
")",
"{",
"module",
".",
"verbose",
"(",
"'Resetting active text'",
",",
"activeText",
")",
";",
"module",
".",
"update",
".",
"text",
"(",
"activeText",
")",
";",
"}",
"else",
"if",
"(",
"inactiveText",
")",
"{",
"module",
".",
"verbose",
"(",
"'Resetting inactive text'",
",",
"activeText",
")",
";",
"module",
".",
"update",
".",
"text",
"(",
"inactiveText",
")",
";",
"}",
"}",
"}"
] |
on mouseout sets text to previous value
|
[
"on",
"mouseout",
"sets",
"text",
"to",
"previous",
"value"
] |
fc9f8bd7e4f5934756ec60c0423f77d1c7be7c6f
|
https://github.com/Semantic-Org/Semantic-UI-CSS/blob/fc9f8bd7e4f5934756ec60c0423f77d1c7be7c6f/components/state.js#L367-L382
|
|
11,004
|
Semantic-Org/Semantic-UI-CSS
|
semantic.js
|
function(errors) {
var
html = '<ul class="list">'
;
$.each(errors, function(index, value) {
html += '<li>' + value + '</li>';
});
html += '</ul>';
return $(html);
}
|
javascript
|
function(errors) {
var
html = '<ul class="list">'
;
$.each(errors, function(index, value) {
html += '<li>' + value + '</li>';
});
html += '</ul>';
return $(html);
}
|
[
"function",
"(",
"errors",
")",
"{",
"var",
"html",
"=",
"'<ul class=\"list\">'",
";",
"$",
".",
"each",
"(",
"errors",
",",
"function",
"(",
"index",
",",
"value",
")",
"{",
"html",
"+=",
"'<li>'",
"+",
"value",
"+",
"'</li>'",
";",
"}",
")",
";",
"html",
"+=",
"'</ul>'",
";",
"return",
"$",
"(",
"html",
")",
";",
"}"
] |
template that produces error message
|
[
"template",
"that",
"produces",
"error",
"message"
] |
fc9f8bd7e4f5934756ec60c0423f77d1c7be7c6f
|
https://github.com/Semantic-Org/Semantic-UI-CSS/blob/fc9f8bd7e4f5934756ec60c0423f77d1c7be7c6f/semantic.js#L1812-L1821
|
|
11,005
|
Semantic-Org/Semantic-UI-CSS
|
semantic.js
|
function(value, regExp) {
if(regExp instanceof RegExp) {
return value.match(regExp);
}
var
regExpParts = regExp.match($.fn.form.settings.regExp.flags),
flags
;
// regular expression specified as /baz/gi (flags)
if(regExpParts) {
regExp = (regExpParts.length >= 2)
? regExpParts[1]
: regExp
;
flags = (regExpParts.length >= 3)
? regExpParts[2]
: ''
;
}
return value.match( new RegExp(regExp, flags) );
}
|
javascript
|
function(value, regExp) {
if(regExp instanceof RegExp) {
return value.match(regExp);
}
var
regExpParts = regExp.match($.fn.form.settings.regExp.flags),
flags
;
// regular expression specified as /baz/gi (flags)
if(regExpParts) {
regExp = (regExpParts.length >= 2)
? regExpParts[1]
: regExp
;
flags = (regExpParts.length >= 3)
? regExpParts[2]
: ''
;
}
return value.match( new RegExp(regExp, flags) );
}
|
[
"function",
"(",
"value",
",",
"regExp",
")",
"{",
"if",
"(",
"regExp",
"instanceof",
"RegExp",
")",
"{",
"return",
"value",
".",
"match",
"(",
"regExp",
")",
";",
"}",
"var",
"regExpParts",
"=",
"regExp",
".",
"match",
"(",
"$",
".",
"fn",
".",
"form",
".",
"settings",
".",
"regExp",
".",
"flags",
")",
",",
"flags",
";",
"// regular expression specified as /baz/gi (flags)",
"if",
"(",
"regExpParts",
")",
"{",
"regExp",
"=",
"(",
"regExpParts",
".",
"length",
">=",
"2",
")",
"?",
"regExpParts",
"[",
"1",
"]",
":",
"regExp",
";",
"flags",
"=",
"(",
"regExpParts",
".",
"length",
">=",
"3",
")",
"?",
"regExpParts",
"[",
"2",
"]",
":",
"''",
";",
"}",
"return",
"value",
".",
"match",
"(",
"new",
"RegExp",
"(",
"regExp",
",",
"flags",
")",
")",
";",
"}"
] |
matches specified regExp
|
[
"matches",
"specified",
"regExp"
] |
fc9f8bd7e4f5934756ec60c0423f77d1c7be7c6f
|
https://github.com/Semantic-Org/Semantic-UI-CSS/blob/fc9f8bd7e4f5934756ec60c0423f77d1c7be7c6f/semantic.js#L1855-L1875
|
|
11,006
|
Semantic-Org/Semantic-UI-CSS
|
semantic.js
|
function(value, range) {
var
intRegExp = $.fn.form.settings.regExp.integer,
min,
max,
parts
;
if( !range || ['', '..'].indexOf(range) !== -1) {
// do nothing
}
else if(range.indexOf('..') == -1) {
if(intRegExp.test(range)) {
min = max = range - 0;
}
}
else {
parts = range.split('..', 2);
if(intRegExp.test(parts[0])) {
min = parts[0] - 0;
}
if(intRegExp.test(parts[1])) {
max = parts[1] - 0;
}
}
return (
intRegExp.test(value) &&
(min === undefined || value >= min) &&
(max === undefined || value <= max)
);
}
|
javascript
|
function(value, range) {
var
intRegExp = $.fn.form.settings.regExp.integer,
min,
max,
parts
;
if( !range || ['', '..'].indexOf(range) !== -1) {
// do nothing
}
else if(range.indexOf('..') == -1) {
if(intRegExp.test(range)) {
min = max = range - 0;
}
}
else {
parts = range.split('..', 2);
if(intRegExp.test(parts[0])) {
min = parts[0] - 0;
}
if(intRegExp.test(parts[1])) {
max = parts[1] - 0;
}
}
return (
intRegExp.test(value) &&
(min === undefined || value >= min) &&
(max === undefined || value <= max)
);
}
|
[
"function",
"(",
"value",
",",
"range",
")",
"{",
"var",
"intRegExp",
"=",
"$",
".",
"fn",
".",
"form",
".",
"settings",
".",
"regExp",
".",
"integer",
",",
"min",
",",
"max",
",",
"parts",
";",
"if",
"(",
"!",
"range",
"||",
"[",
"''",
",",
"'..'",
"]",
".",
"indexOf",
"(",
"range",
")",
"!==",
"-",
"1",
")",
"{",
"// do nothing",
"}",
"else",
"if",
"(",
"range",
".",
"indexOf",
"(",
"'..'",
")",
"==",
"-",
"1",
")",
"{",
"if",
"(",
"intRegExp",
".",
"test",
"(",
"range",
")",
")",
"{",
"min",
"=",
"max",
"=",
"range",
"-",
"0",
";",
"}",
"}",
"else",
"{",
"parts",
"=",
"range",
".",
"split",
"(",
"'..'",
",",
"2",
")",
";",
"if",
"(",
"intRegExp",
".",
"test",
"(",
"parts",
"[",
"0",
"]",
")",
")",
"{",
"min",
"=",
"parts",
"[",
"0",
"]",
"-",
"0",
";",
"}",
"if",
"(",
"intRegExp",
".",
"test",
"(",
"parts",
"[",
"1",
"]",
")",
")",
"{",
"max",
"=",
"parts",
"[",
"1",
"]",
"-",
"0",
";",
"}",
"}",
"return",
"(",
"intRegExp",
".",
"test",
"(",
"value",
")",
"&&",
"(",
"min",
"===",
"undefined",
"||",
"value",
">=",
"min",
")",
"&&",
"(",
"max",
"===",
"undefined",
"||",
"value",
"<=",
"max",
")",
")",
";",
"}"
] |
is valid integer or matches range
|
[
"is",
"valid",
"integer",
"or",
"matches",
"range"
] |
fc9f8bd7e4f5934756ec60c0423f77d1c7be7c6f
|
https://github.com/Semantic-Org/Semantic-UI-CSS/blob/fc9f8bd7e4f5934756ec60c0423f77d1c7be7c6f/semantic.js#L1878-L1907
|
|
11,007
|
Semantic-Org/Semantic-UI-CSS
|
semantic.js
|
function(value, identifier) {
var
$form = $(this),
matchingValue
;
if( $('[data-validate="'+ identifier +'"]').length > 0 ) {
matchingValue = $('[data-validate="'+ identifier +'"]').val();
}
else if($('#' + identifier).length > 0) {
matchingValue = $('#' + identifier).val();
}
else if($('[name="' + identifier +'"]').length > 0) {
matchingValue = $('[name="' + identifier + '"]').val();
}
else if( $('[name="' + identifier +'[]"]').length > 0 ) {
matchingValue = $('[name="' + identifier +'[]"]');
}
return (matchingValue !== undefined)
? ( value.toString() == matchingValue.toString() )
: false
;
}
|
javascript
|
function(value, identifier) {
var
$form = $(this),
matchingValue
;
if( $('[data-validate="'+ identifier +'"]').length > 0 ) {
matchingValue = $('[data-validate="'+ identifier +'"]').val();
}
else if($('#' + identifier).length > 0) {
matchingValue = $('#' + identifier).val();
}
else if($('[name="' + identifier +'"]').length > 0) {
matchingValue = $('[name="' + identifier + '"]').val();
}
else if( $('[name="' + identifier +'[]"]').length > 0 ) {
matchingValue = $('[name="' + identifier +'[]"]');
}
return (matchingValue !== undefined)
? ( value.toString() == matchingValue.toString() )
: false
;
}
|
[
"function",
"(",
"value",
",",
"identifier",
")",
"{",
"var",
"$form",
"=",
"$",
"(",
"this",
")",
",",
"matchingValue",
";",
"if",
"(",
"$",
"(",
"'[data-validate=\"'",
"+",
"identifier",
"+",
"'\"]'",
")",
".",
"length",
">",
"0",
")",
"{",
"matchingValue",
"=",
"$",
"(",
"'[data-validate=\"'",
"+",
"identifier",
"+",
"'\"]'",
")",
".",
"val",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$",
"(",
"'#'",
"+",
"identifier",
")",
".",
"length",
">",
"0",
")",
"{",
"matchingValue",
"=",
"$",
"(",
"'#'",
"+",
"identifier",
")",
".",
"val",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$",
"(",
"'[name=\"'",
"+",
"identifier",
"+",
"'\"]'",
")",
".",
"length",
">",
"0",
")",
"{",
"matchingValue",
"=",
"$",
"(",
"'[name=\"'",
"+",
"identifier",
"+",
"'\"]'",
")",
".",
"val",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$",
"(",
"'[name=\"'",
"+",
"identifier",
"+",
"'[]\"]'",
")",
".",
"length",
">",
"0",
")",
"{",
"matchingValue",
"=",
"$",
"(",
"'[name=\"'",
"+",
"identifier",
"+",
"'[]\"]'",
")",
";",
"}",
"return",
"(",
"matchingValue",
"!==",
"undefined",
")",
"?",
"(",
"value",
".",
"toString",
"(",
")",
"==",
"matchingValue",
".",
"toString",
"(",
")",
")",
":",
"false",
";",
"}"
] |
matches another field
|
[
"matches",
"another",
"field"
] |
fc9f8bd7e4f5934756ec60c0423f77d1c7be7c6f
|
https://github.com/Semantic-Org/Semantic-UI-CSS/blob/fc9f8bd7e4f5934756ec60c0423f77d1c7be7c6f/semantic.js#L2016-L2037
|
|
11,008
|
Semantic-Org/Semantic-UI-CSS
|
semantic.js
|
function(select) {
var
placeholder = select.placeholder || false,
values = select.values || {},
html = ''
;
html += '<i class="dropdown icon"></i>';
if(select.placeholder) {
html += '<div class="default text">' + placeholder + '</div>';
}
else {
html += '<div class="text"></div>';
}
html += '<div class="menu">';
$.each(select.values, function(index, option) {
html += (option.disabled)
? '<div class="disabled item" data-value="' + option.value + '">' + option.name + '</div>'
: '<div class="item" data-value="' + option.value + '">' + option.name + '</div>'
;
});
html += '</div>';
return html;
}
|
javascript
|
function(select) {
var
placeholder = select.placeholder || false,
values = select.values || {},
html = ''
;
html += '<i class="dropdown icon"></i>';
if(select.placeholder) {
html += '<div class="default text">' + placeholder + '</div>';
}
else {
html += '<div class="text"></div>';
}
html += '<div class="menu">';
$.each(select.values, function(index, option) {
html += (option.disabled)
? '<div class="disabled item" data-value="' + option.value + '">' + option.name + '</div>'
: '<div class="item" data-value="' + option.value + '">' + option.name + '</div>'
;
});
html += '</div>';
return html;
}
|
[
"function",
"(",
"select",
")",
"{",
"var",
"placeholder",
"=",
"select",
".",
"placeholder",
"||",
"false",
",",
"values",
"=",
"select",
".",
"values",
"||",
"{",
"}",
",",
"html",
"=",
"''",
";",
"html",
"+=",
"'<i class=\"dropdown icon\"></i>'",
";",
"if",
"(",
"select",
".",
"placeholder",
")",
"{",
"html",
"+=",
"'<div class=\"default text\">'",
"+",
"placeholder",
"+",
"'</div>'",
";",
"}",
"else",
"{",
"html",
"+=",
"'<div class=\"text\"></div>'",
";",
"}",
"html",
"+=",
"'<div class=\"menu\">'",
";",
"$",
".",
"each",
"(",
"select",
".",
"values",
",",
"function",
"(",
"index",
",",
"option",
")",
"{",
"html",
"+=",
"(",
"option",
".",
"disabled",
")",
"?",
"'<div class=\"disabled item\" data-value=\"'",
"+",
"option",
".",
"value",
"+",
"'\">'",
"+",
"option",
".",
"name",
"+",
"'</div>'",
":",
"'<div class=\"item\" data-value=\"'",
"+",
"option",
".",
"value",
"+",
"'\">'",
"+",
"option",
".",
"name",
"+",
"'</div>'",
";",
"}",
")",
";",
"html",
"+=",
"'</div>'",
";",
"return",
"html",
";",
"}"
] |
generates dropdown from select values
|
[
"generates",
"dropdown",
"from",
"select",
"values"
] |
fc9f8bd7e4f5934756ec60c0423f77d1c7be7c6f
|
https://github.com/Semantic-Org/Semantic-UI-CSS/blob/fc9f8bd7e4f5934756ec60c0423f77d1c7be7c6f/semantic.js#L8276-L8298
|
|
11,009
|
Semantic-Org/Semantic-UI-CSS
|
semantic.js
|
function(response, fields) {
var
values = response[fields.values] || {},
html = ''
;
$.each(values, function(index, option) {
var
maybeText = (option[fields.text])
? 'data-text="' + option[fields.text] + '"'
: '',
maybeDisabled = (option[fields.disabled])
? 'disabled '
: ''
;
html += '<div class="'+ maybeDisabled +'item" data-value="' + option[fields.value] + '"' + maybeText + '>';
html += option[fields.name];
html += '</div>';
});
return html;
}
|
javascript
|
function(response, fields) {
var
values = response[fields.values] || {},
html = ''
;
$.each(values, function(index, option) {
var
maybeText = (option[fields.text])
? 'data-text="' + option[fields.text] + '"'
: '',
maybeDisabled = (option[fields.disabled])
? 'disabled '
: ''
;
html += '<div class="'+ maybeDisabled +'item" data-value="' + option[fields.value] + '"' + maybeText + '>';
html += option[fields.name];
html += '</div>';
});
return html;
}
|
[
"function",
"(",
"response",
",",
"fields",
")",
"{",
"var",
"values",
"=",
"response",
"[",
"fields",
".",
"values",
"]",
"||",
"{",
"}",
",",
"html",
"=",
"''",
";",
"$",
".",
"each",
"(",
"values",
",",
"function",
"(",
"index",
",",
"option",
")",
"{",
"var",
"maybeText",
"=",
"(",
"option",
"[",
"fields",
".",
"text",
"]",
")",
"?",
"'data-text=\"'",
"+",
"option",
"[",
"fields",
".",
"text",
"]",
"+",
"'\"'",
":",
"''",
",",
"maybeDisabled",
"=",
"(",
"option",
"[",
"fields",
".",
"disabled",
"]",
")",
"?",
"'disabled '",
":",
"''",
";",
"html",
"+=",
"'<div class=\"'",
"+",
"maybeDisabled",
"+",
"'item\" data-value=\"'",
"+",
"option",
"[",
"fields",
".",
"value",
"]",
"+",
"'\"'",
"+",
"maybeText",
"+",
"'>'",
";",
"html",
"+=",
"option",
"[",
"fields",
".",
"name",
"]",
";",
"html",
"+=",
"'</div>'",
";",
"}",
")",
";",
"return",
"html",
";",
"}"
] |
generates just menu from select
|
[
"generates",
"just",
"menu",
"from",
"select"
] |
fc9f8bd7e4f5934756ec60c0423f77d1c7be7c6f
|
https://github.com/Semantic-Org/Semantic-UI-CSS/blob/fc9f8bd7e4f5934756ec60c0423f77d1c7be7c6f/semantic.js#L8301-L8320
|
|
11,010
|
Semantic-Org/Semantic-UI-CSS
|
semantic.js
|
function(source, id, url) {
module.debug('Changing video to ', source, id, url);
$module
.data(metadata.source, source)
.data(metadata.id, id)
;
if(url) {
$module.data(metadata.url, url);
}
else {
$module.removeData(metadata.url);
}
if(module.has.embed()) {
module.changeEmbed();
}
else {
module.create();
}
}
|
javascript
|
function(source, id, url) {
module.debug('Changing video to ', source, id, url);
$module
.data(metadata.source, source)
.data(metadata.id, id)
;
if(url) {
$module.data(metadata.url, url);
}
else {
$module.removeData(metadata.url);
}
if(module.has.embed()) {
module.changeEmbed();
}
else {
module.create();
}
}
|
[
"function",
"(",
"source",
",",
"id",
",",
"url",
")",
"{",
"module",
".",
"debug",
"(",
"'Changing video to '",
",",
"source",
",",
"id",
",",
"url",
")",
";",
"$module",
".",
"data",
"(",
"metadata",
".",
"source",
",",
"source",
")",
".",
"data",
"(",
"metadata",
".",
"id",
",",
"id",
")",
";",
"if",
"(",
"url",
")",
"{",
"$module",
".",
"data",
"(",
"metadata",
".",
"url",
",",
"url",
")",
";",
"}",
"else",
"{",
"$module",
".",
"removeData",
"(",
"metadata",
".",
"url",
")",
";",
"}",
"if",
"(",
"module",
".",
"has",
".",
"embed",
"(",
")",
")",
"{",
"module",
".",
"changeEmbed",
"(",
")",
";",
"}",
"else",
"{",
"module",
".",
"create",
"(",
")",
";",
"}",
"}"
] |
sets new embed
|
[
"sets",
"new",
"embed"
] |
fc9f8bd7e4f5934756ec60c0423f77d1c7be7c6f
|
https://github.com/Semantic-Org/Semantic-UI-CSS/blob/fc9f8bd7e4f5934756ec60c0423f77d1c7be7c6f/semantic.js#L8502-L8520
|
|
11,011
|
Semantic-Org/Semantic-UI-CSS
|
semantic.js
|
function() {
if(settings.throttle) {
clearTimeout(module.timer);
module.timer = setTimeout(function() {
$context.triggerHandler('scrollchange' + eventNamespace, [ $context.scrollTop() ]);
}, settings.throttle);
}
else {
requestAnimationFrame(function() {
$context.triggerHandler('scrollchange' + eventNamespace, [ $context.scrollTop() ]);
});
}
}
|
javascript
|
function() {
if(settings.throttle) {
clearTimeout(module.timer);
module.timer = setTimeout(function() {
$context.triggerHandler('scrollchange' + eventNamespace, [ $context.scrollTop() ]);
}, settings.throttle);
}
else {
requestAnimationFrame(function() {
$context.triggerHandler('scrollchange' + eventNamespace, [ $context.scrollTop() ]);
});
}
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"settings",
".",
"throttle",
")",
"{",
"clearTimeout",
"(",
"module",
".",
"timer",
")",
";",
"module",
".",
"timer",
"=",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"$context",
".",
"triggerHandler",
"(",
"'scrollchange'",
"+",
"eventNamespace",
",",
"[",
"$context",
".",
"scrollTop",
"(",
")",
"]",
")",
";",
"}",
",",
"settings",
".",
"throttle",
")",
";",
"}",
"else",
"{",
"requestAnimationFrame",
"(",
"function",
"(",
")",
"{",
"$context",
".",
"triggerHandler",
"(",
"'scrollchange'",
"+",
"eventNamespace",
",",
"[",
"$context",
".",
"scrollTop",
"(",
")",
"]",
")",
";",
"}",
")",
";",
"}",
"}"
] |
publishes scrollchange event on one scroll
|
[
"publishes",
"scrollchange",
"event",
"on",
"one",
"scroll"
] |
fc9f8bd7e4f5934756ec60c0423f77d1c7be7c6f
|
https://github.com/Semantic-Org/Semantic-UI-CSS/blob/fc9f8bd7e4f5934756ec60c0423f77d1c7be7c6f/semantic.js#L21416-L21428
|
|
11,012
|
dthree/vorpal
|
lib/session.js
|
Session
|
function Session(options) {
options = options || {};
this.id = options.id || this._guid();
this.parent = options.parent || undefined;
this.authenticating = options.authenticating || false;
this.authenticated = options.authenticated || undefined;
this.user = options.user || 'guest';
this.host = options.host;
this.address = options.address || undefined;
this._isLocal = options.local || undefined;
this._delimiter = options.delimiter || String(os.hostname()).split('.')[0] + '~$';
this._modeDelimiter = undefined;
// Keeps history of how many times in a row `tab` was
// pressed on the keyboard.
this._tabCtr = 0;
this.cmdHistory = this.parent.cmdHistory;
// Special command mode vorpal is in at the moment,
// such as REPL. See mode documentation.
this._mode = undefined;
return this;
}
|
javascript
|
function Session(options) {
options = options || {};
this.id = options.id || this._guid();
this.parent = options.parent || undefined;
this.authenticating = options.authenticating || false;
this.authenticated = options.authenticated || undefined;
this.user = options.user || 'guest';
this.host = options.host;
this.address = options.address || undefined;
this._isLocal = options.local || undefined;
this._delimiter = options.delimiter || String(os.hostname()).split('.')[0] + '~$';
this._modeDelimiter = undefined;
// Keeps history of how many times in a row `tab` was
// pressed on the keyboard.
this._tabCtr = 0;
this.cmdHistory = this.parent.cmdHistory;
// Special command mode vorpal is in at the moment,
// such as REPL. See mode documentation.
this._mode = undefined;
return this;
}
|
[
"function",
"Session",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"id",
"=",
"options",
".",
"id",
"||",
"this",
".",
"_guid",
"(",
")",
";",
"this",
".",
"parent",
"=",
"options",
".",
"parent",
"||",
"undefined",
";",
"this",
".",
"authenticating",
"=",
"options",
".",
"authenticating",
"||",
"false",
";",
"this",
".",
"authenticated",
"=",
"options",
".",
"authenticated",
"||",
"undefined",
";",
"this",
".",
"user",
"=",
"options",
".",
"user",
"||",
"'guest'",
";",
"this",
".",
"host",
"=",
"options",
".",
"host",
";",
"this",
".",
"address",
"=",
"options",
".",
"address",
"||",
"undefined",
";",
"this",
".",
"_isLocal",
"=",
"options",
".",
"local",
"||",
"undefined",
";",
"this",
".",
"_delimiter",
"=",
"options",
".",
"delimiter",
"||",
"String",
"(",
"os",
".",
"hostname",
"(",
")",
")",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
"+",
"'~$'",
";",
"this",
".",
"_modeDelimiter",
"=",
"undefined",
";",
"// Keeps history of how many times in a row `tab` was",
"// pressed on the keyboard.",
"this",
".",
"_tabCtr",
"=",
"0",
";",
"this",
".",
"cmdHistory",
"=",
"this",
".",
"parent",
".",
"cmdHistory",
";",
"// Special command mode vorpal is in at the moment,",
"// such as REPL. See mode documentation.",
"this",
".",
"_mode",
"=",
"undefined",
";",
"return",
"this",
";",
"}"
] |
Initialize a new `Session` instance.
@param {String} name
@return {Session}
@api public
|
[
"Initialize",
"a",
"new",
"Session",
"instance",
"."
] |
51f5e2b545631b6a86c9781c274a1b0916a67ee8
|
https://github.com/dthree/vorpal/blob/51f5e2b545631b6a86c9781c274a1b0916a67ee8/lib/session.js#L22-L46
|
11,013
|
dthree/vorpal
|
lib/vorpal.js
|
Vorpal
|
function Vorpal() {
if (!(this instanceof Vorpal)) {
return new Vorpal();
}
// Program version
// Exposed through vorpal.version(str);
this._version = '';
// Program title
this._title = '';
// Program description
this._description = '';
// Program baner
this._banner = '';
// Command line history instance
this.cmdHistory = new this.CmdHistoryExtension();
// Registered `vorpal.command` commands and
// their options.
this.commands = [];
// Queue of IP requests, executed async, in sync.
this._queue = [];
// Current command being executed.
this._command = undefined;
// Expose UI.
this.ui = ui;
// Expose chalk as a convenience.
this.chalk = chalk;
// Expose lodash as a convenience.
this.lodash = _;
// Exposed through vorpal.delimiter(str).
this._delimiter = 'local@' + String(os.hostname()).split('.')[0] + '~$ ';
ui.setDelimiter(this._delimiter);
// Placeholder for vantage server. If vantage
// is used, this will be over-written.
this.server = {
sessions: []
};
// Whether all stdout is being hooked through a function.
this._hooked = false;
this._useDeprecatedAutocompletion = false;
// Expose common utilities, like padding.
this.util = VorpalUtil;
this.Session = Session;
// Active vorpal server session.
this.session = new this.Session({
local: true,
user: 'local',
parent: this,
delimiter: this._delimiter
});
// Allow unix-like key value pair normalization to be turned off by toggling this switch on.
this.isCommandArgKeyPairNormalized = true;
this._init();
return this;
}
|
javascript
|
function Vorpal() {
if (!(this instanceof Vorpal)) {
return new Vorpal();
}
// Program version
// Exposed through vorpal.version(str);
this._version = '';
// Program title
this._title = '';
// Program description
this._description = '';
// Program baner
this._banner = '';
// Command line history instance
this.cmdHistory = new this.CmdHistoryExtension();
// Registered `vorpal.command` commands and
// their options.
this.commands = [];
// Queue of IP requests, executed async, in sync.
this._queue = [];
// Current command being executed.
this._command = undefined;
// Expose UI.
this.ui = ui;
// Expose chalk as a convenience.
this.chalk = chalk;
// Expose lodash as a convenience.
this.lodash = _;
// Exposed through vorpal.delimiter(str).
this._delimiter = 'local@' + String(os.hostname()).split('.')[0] + '~$ ';
ui.setDelimiter(this._delimiter);
// Placeholder for vantage server. If vantage
// is used, this will be over-written.
this.server = {
sessions: []
};
// Whether all stdout is being hooked through a function.
this._hooked = false;
this._useDeprecatedAutocompletion = false;
// Expose common utilities, like padding.
this.util = VorpalUtil;
this.Session = Session;
// Active vorpal server session.
this.session = new this.Session({
local: true,
user: 'local',
parent: this,
delimiter: this._delimiter
});
// Allow unix-like key value pair normalization to be turned off by toggling this switch on.
this.isCommandArgKeyPairNormalized = true;
this._init();
return this;
}
|
[
"function",
"Vorpal",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Vorpal",
")",
")",
"{",
"return",
"new",
"Vorpal",
"(",
")",
";",
"}",
"// Program version",
"// Exposed through vorpal.version(str);",
"this",
".",
"_version",
"=",
"''",
";",
"// Program title",
"this",
".",
"_title",
"=",
"''",
";",
"// Program description",
"this",
".",
"_description",
"=",
"''",
";",
"// Program baner",
"this",
".",
"_banner",
"=",
"''",
";",
"// Command line history instance",
"this",
".",
"cmdHistory",
"=",
"new",
"this",
".",
"CmdHistoryExtension",
"(",
")",
";",
"// Registered `vorpal.command` commands and",
"// their options.",
"this",
".",
"commands",
"=",
"[",
"]",
";",
"// Queue of IP requests, executed async, in sync.",
"this",
".",
"_queue",
"=",
"[",
"]",
";",
"// Current command being executed.",
"this",
".",
"_command",
"=",
"undefined",
";",
"// Expose UI.",
"this",
".",
"ui",
"=",
"ui",
";",
"// Expose chalk as a convenience.",
"this",
".",
"chalk",
"=",
"chalk",
";",
"// Expose lodash as a convenience.",
"this",
".",
"lodash",
"=",
"_",
";",
"// Exposed through vorpal.delimiter(str).",
"this",
".",
"_delimiter",
"=",
"'local@'",
"+",
"String",
"(",
"os",
".",
"hostname",
"(",
")",
")",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
"+",
"'~$ '",
";",
"ui",
".",
"setDelimiter",
"(",
"this",
".",
"_delimiter",
")",
";",
"// Placeholder for vantage server. If vantage",
"// is used, this will be over-written.",
"this",
".",
"server",
"=",
"{",
"sessions",
":",
"[",
"]",
"}",
";",
"// Whether all stdout is being hooked through a function.",
"this",
".",
"_hooked",
"=",
"false",
";",
"this",
".",
"_useDeprecatedAutocompletion",
"=",
"false",
";",
"// Expose common utilities, like padding.",
"this",
".",
"util",
"=",
"VorpalUtil",
";",
"this",
".",
"Session",
"=",
"Session",
";",
"// Active vorpal server session.",
"this",
".",
"session",
"=",
"new",
"this",
".",
"Session",
"(",
"{",
"local",
":",
"true",
",",
"user",
":",
"'local'",
",",
"parent",
":",
"this",
",",
"delimiter",
":",
"this",
".",
"_delimiter",
"}",
")",
";",
"// Allow unix-like key value pair normalization to be turned off by toggling this switch on.",
"this",
".",
"isCommandArgKeyPairNormalized",
"=",
"true",
";",
"this",
".",
"_init",
"(",
")",
";",
"return",
"this",
";",
"}"
] |
Initialize a new `Vorpal` instance.
@return {Vorpal}
@api public
|
[
"Initialize",
"a",
"new",
"Vorpal",
"instance",
"."
] |
51f5e2b545631b6a86c9781c274a1b0916a67ee8
|
https://github.com/dthree/vorpal/blob/51f5e2b545631b6a86c9781c274a1b0916a67ee8/lib/vorpal.js#L40-L113
|
11,014
|
dthree/vorpal
|
dist/command.js
|
Command
|
function Command(name, parent) {
if (!(this instanceof Command)) {
return new Command();
}
this.commands = [];
this.options = [];
this._args = [];
this._aliases = [];
this._name = name;
this._relay = false;
this._hidden = false;
this._parent = parent;
this._mode = false;
this._catch = false;
this._help = undefined;
this._init = undefined;
this._after = undefined;
this._allowUnknownOptions = false;
}
|
javascript
|
function Command(name, parent) {
if (!(this instanceof Command)) {
return new Command();
}
this.commands = [];
this.options = [];
this._args = [];
this._aliases = [];
this._name = name;
this._relay = false;
this._hidden = false;
this._parent = parent;
this._mode = false;
this._catch = false;
this._help = undefined;
this._init = undefined;
this._after = undefined;
this._allowUnknownOptions = false;
}
|
[
"function",
"Command",
"(",
"name",
",",
"parent",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Command",
")",
")",
"{",
"return",
"new",
"Command",
"(",
")",
";",
"}",
"this",
".",
"commands",
"=",
"[",
"]",
";",
"this",
".",
"options",
"=",
"[",
"]",
";",
"this",
".",
"_args",
"=",
"[",
"]",
";",
"this",
".",
"_aliases",
"=",
"[",
"]",
";",
"this",
".",
"_name",
"=",
"name",
";",
"this",
".",
"_relay",
"=",
"false",
";",
"this",
".",
"_hidden",
"=",
"false",
";",
"this",
".",
"_parent",
"=",
"parent",
";",
"this",
".",
"_mode",
"=",
"false",
";",
"this",
".",
"_catch",
"=",
"false",
";",
"this",
".",
"_help",
"=",
"undefined",
";",
"this",
".",
"_init",
"=",
"undefined",
";",
"this",
".",
"_after",
"=",
"undefined",
";",
"this",
".",
"_allowUnknownOptions",
"=",
"false",
";",
"}"
] |
Initialize a new `Command` instance.
@param {String} name
@param {Vorpal} parent
@return {Command}
@api public
|
[
"Initialize",
"a",
"new",
"Command",
"instance",
"."
] |
51f5e2b545631b6a86c9781c274a1b0916a67ee8
|
https://github.com/dthree/vorpal/blob/51f5e2b545631b6a86c9781c274a1b0916a67ee8/dist/command.js#L33-L51
|
11,015
|
dthree/vorpal
|
dist/command.js
|
_camelcase
|
function _camelcase(flag) {
return flag.split('-').reduce(function (str, word) {
return str + word[0].toUpperCase() + word.slice(1);
});
}
|
javascript
|
function _camelcase(flag) {
return flag.split('-').reduce(function (str, word) {
return str + word[0].toUpperCase() + word.slice(1);
});
}
|
[
"function",
"_camelcase",
"(",
"flag",
")",
"{",
"return",
"flag",
".",
"split",
"(",
"'-'",
")",
".",
"reduce",
"(",
"function",
"(",
"str",
",",
"word",
")",
"{",
"return",
"str",
"+",
"word",
"[",
"0",
"]",
".",
"toUpperCase",
"(",
")",
"+",
"word",
".",
"slice",
"(",
"1",
")",
";",
"}",
")",
";",
"}"
] |
Converts string to camel case.
@param {String} flag
@return {String}
@api private
|
[
"Converts",
"string",
"to",
"camel",
"case",
"."
] |
51f5e2b545631b6a86c9781c274a1b0916a67ee8
|
https://github.com/dthree/vorpal/blob/51f5e2b545631b6a86c9781c274a1b0916a67ee8/dist/command.js#L567-L571
|
11,016
|
dthree/vorpal
|
dist/autocomplete.js
|
handleTabCounts
|
function handleTabCounts(str, freezeTabs) {
var result;
if (_.isArray(str)) {
this._tabCtr += 1;
if (this._tabCtr > 1) {
result = str.length === 0 ? undefined : str;
}
} else {
this._tabCtr = freezeTabs === true ? this._tabCtr + 1 : 0;
result = str;
}
return result;
}
|
javascript
|
function handleTabCounts(str, freezeTabs) {
var result;
if (_.isArray(str)) {
this._tabCtr += 1;
if (this._tabCtr > 1) {
result = str.length === 0 ? undefined : str;
}
} else {
this._tabCtr = freezeTabs === true ? this._tabCtr + 1 : 0;
result = str;
}
return result;
}
|
[
"function",
"handleTabCounts",
"(",
"str",
",",
"freezeTabs",
")",
"{",
"var",
"result",
";",
"if",
"(",
"_",
".",
"isArray",
"(",
"str",
")",
")",
"{",
"this",
".",
"_tabCtr",
"+=",
"1",
";",
"if",
"(",
"this",
".",
"_tabCtr",
">",
"1",
")",
"{",
"result",
"=",
"str",
".",
"length",
"===",
"0",
"?",
"undefined",
":",
"str",
";",
"}",
"}",
"else",
"{",
"this",
".",
"_tabCtr",
"=",
"freezeTabs",
"===",
"true",
"?",
"this",
".",
"_tabCtr",
"+",
"1",
":",
"0",
";",
"result",
"=",
"str",
";",
"}",
"return",
"result",
";",
"}"
] |
Tracks how many times tab was pressed
based on whether the UI changed.
@param {String} str
@return {String} result
@api private
|
[
"Tracks",
"how",
"many",
"times",
"tab",
"was",
"pressed",
"based",
"on",
"whether",
"the",
"UI",
"changed",
"."
] |
51f5e2b545631b6a86c9781c274a1b0916a67ee8
|
https://github.com/dthree/vorpal/blob/51f5e2b545631b6a86c9781c274a1b0916a67ee8/dist/autocomplete.js#L136-L148
|
11,017
|
dthree/vorpal
|
dist/autocomplete.js
|
getMatch
|
function getMatch(ctx, data, options) {
// Look for a command match, eliminating and then
// re-introducing leading spaces.
var len = ctx.length;
var trimmed = ctx.replace(/^\s+/g, '');
var match = autocomplete.match(trimmed, data.slice(), options);
if (_.isArray(match)) {
return match;
}
var prefix = new Array(len - trimmed.length + 1).join(' ');
// If we get an autocomplete match on a command, finish it.
if (match) {
// Put the leading spaces back in.
match = prefix + match;
return match;
}
return undefined;
}
|
javascript
|
function getMatch(ctx, data, options) {
// Look for a command match, eliminating and then
// re-introducing leading spaces.
var len = ctx.length;
var trimmed = ctx.replace(/^\s+/g, '');
var match = autocomplete.match(trimmed, data.slice(), options);
if (_.isArray(match)) {
return match;
}
var prefix = new Array(len - trimmed.length + 1).join(' ');
// If we get an autocomplete match on a command, finish it.
if (match) {
// Put the leading spaces back in.
match = prefix + match;
return match;
}
return undefined;
}
|
[
"function",
"getMatch",
"(",
"ctx",
",",
"data",
",",
"options",
")",
"{",
"// Look for a command match, eliminating and then",
"// re-introducing leading spaces.",
"var",
"len",
"=",
"ctx",
".",
"length",
";",
"var",
"trimmed",
"=",
"ctx",
".",
"replace",
"(",
"/",
"^\\s+",
"/",
"g",
",",
"''",
")",
";",
"var",
"match",
"=",
"autocomplete",
".",
"match",
"(",
"trimmed",
",",
"data",
".",
"slice",
"(",
")",
",",
"options",
")",
";",
"if",
"(",
"_",
".",
"isArray",
"(",
"match",
")",
")",
"{",
"return",
"match",
";",
"}",
"var",
"prefix",
"=",
"new",
"Array",
"(",
"len",
"-",
"trimmed",
".",
"length",
"+",
"1",
")",
".",
"join",
"(",
"' '",
")",
";",
"// If we get an autocomplete match on a command, finish it.",
"if",
"(",
"match",
")",
"{",
"// Put the leading spaces back in.",
"match",
"=",
"prefix",
"+",
"match",
";",
"return",
"match",
";",
"}",
"return",
"undefined",
";",
"}"
] |
Looks for a potential exact match
based on given data.
@param {String} ctx
@param {Array} data
@return {String}
@api private
|
[
"Looks",
"for",
"a",
"potential",
"exact",
"match",
"based",
"on",
"given",
"data",
"."
] |
51f5e2b545631b6a86c9781c274a1b0916a67ee8
|
https://github.com/dthree/vorpal/blob/51f5e2b545631b6a86c9781c274a1b0916a67ee8/dist/autocomplete.js#L160-L177
|
11,018
|
dthree/vorpal
|
dist/autocomplete.js
|
assembleInput
|
function assembleInput(input) {
if (_.isArray(input.context)) {
return input.context;
}
var result = (input.prefix || '') + (input.context || '') + (input.suffix || '');
return strip(result);
}
|
javascript
|
function assembleInput(input) {
if (_.isArray(input.context)) {
return input.context;
}
var result = (input.prefix || '') + (input.context || '') + (input.suffix || '');
return strip(result);
}
|
[
"function",
"assembleInput",
"(",
"input",
")",
"{",
"if",
"(",
"_",
".",
"isArray",
"(",
"input",
".",
"context",
")",
")",
"{",
"return",
"input",
".",
"context",
";",
"}",
"var",
"result",
"=",
"(",
"input",
".",
"prefix",
"||",
"''",
")",
"+",
"(",
"input",
".",
"context",
"||",
"''",
")",
"+",
"(",
"input",
".",
"suffix",
"||",
"''",
")",
";",
"return",
"strip",
"(",
"result",
")",
";",
"}"
] |
Takes the input object and assembles
the final result to display on the screen.
@param {Object} input
@return {String}
@api private
|
[
"Takes",
"the",
"input",
"object",
"and",
"assembles",
"the",
"final",
"result",
"to",
"display",
"on",
"the",
"screen",
"."
] |
51f5e2b545631b6a86c9781c274a1b0916a67ee8
|
https://github.com/dthree/vorpal/blob/51f5e2b545631b6a86c9781c274a1b0916a67ee8/dist/autocomplete.js#L188-L194
|
11,019
|
dthree/vorpal
|
dist/autocomplete.js
|
parseInput
|
function parseInput(str, idx) {
var raw = String(str || '');
var sliced = raw.slice(0, idx);
var sections = sliced.split('|');
var prefix = sections.slice(0, sections.length - 1) || [];
prefix.push('');
prefix = prefix.join('|');
var suffix = getSuffix(raw.slice(idx));
var context = sections[sections.length - 1];
return {
raw: raw,
prefix: prefix,
suffix: suffix,
context: context
};
}
|
javascript
|
function parseInput(str, idx) {
var raw = String(str || '');
var sliced = raw.slice(0, idx);
var sections = sliced.split('|');
var prefix = sections.slice(0, sections.length - 1) || [];
prefix.push('');
prefix = prefix.join('|');
var suffix = getSuffix(raw.slice(idx));
var context = sections[sections.length - 1];
return {
raw: raw,
prefix: prefix,
suffix: suffix,
context: context
};
}
|
[
"function",
"parseInput",
"(",
"str",
",",
"idx",
")",
"{",
"var",
"raw",
"=",
"String",
"(",
"str",
"||",
"''",
")",
";",
"var",
"sliced",
"=",
"raw",
".",
"slice",
"(",
"0",
",",
"idx",
")",
";",
"var",
"sections",
"=",
"sliced",
".",
"split",
"(",
"'|'",
")",
";",
"var",
"prefix",
"=",
"sections",
".",
"slice",
"(",
"0",
",",
"sections",
".",
"length",
"-",
"1",
")",
"||",
"[",
"]",
";",
"prefix",
".",
"push",
"(",
"''",
")",
";",
"prefix",
"=",
"prefix",
".",
"join",
"(",
"'|'",
")",
";",
"var",
"suffix",
"=",
"getSuffix",
"(",
"raw",
".",
"slice",
"(",
"idx",
")",
")",
";",
"var",
"context",
"=",
"sections",
"[",
"sections",
".",
"length",
"-",
"1",
"]",
";",
"return",
"{",
"raw",
":",
"raw",
",",
"prefix",
":",
"prefix",
",",
"suffix",
":",
"suffix",
",",
"context",
":",
"context",
"}",
";",
"}"
] |
Takes the user's current prompt
string and breaks it into its
integral parts for analysis and
modification.
@param {String} str
@param {Integer} idx
@return {Object}
@api private
|
[
"Takes",
"the",
"user",
"s",
"current",
"prompt",
"string",
"and",
"breaks",
"it",
"into",
"its",
"integral",
"parts",
"for",
"analysis",
"and",
"modification",
"."
] |
51f5e2b545631b6a86c9781c274a1b0916a67ee8
|
https://github.com/dthree/vorpal/blob/51f5e2b545631b6a86c9781c274a1b0916a67ee8/dist/autocomplete.js#L239-L254
|
11,020
|
dthree/vorpal
|
dist/autocomplete.js
|
parseMatchSection
|
function parseMatchSection(input) {
var parts = (input.context || '').split(' ');
var last = parts.pop();
var beforeLast = strip(parts[parts.length - 1] || '').trim();
if (beforeLast.slice(0, 1) === '-') {
input.option = beforeLast;
}
input.context = last;
input.prefix = (input.prefix || '') + parts.join(' ') + ' ';
return input;
}
|
javascript
|
function parseMatchSection(input) {
var parts = (input.context || '').split(' ');
var last = parts.pop();
var beforeLast = strip(parts[parts.length - 1] || '').trim();
if (beforeLast.slice(0, 1) === '-') {
input.option = beforeLast;
}
input.context = last;
input.prefix = (input.prefix || '') + parts.join(' ') + ' ';
return input;
}
|
[
"function",
"parseMatchSection",
"(",
"input",
")",
"{",
"var",
"parts",
"=",
"(",
"input",
".",
"context",
"||",
"''",
")",
".",
"split",
"(",
"' '",
")",
";",
"var",
"last",
"=",
"parts",
".",
"pop",
"(",
")",
";",
"var",
"beforeLast",
"=",
"strip",
"(",
"parts",
"[",
"parts",
".",
"length",
"-",
"1",
"]",
"||",
"''",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"beforeLast",
".",
"slice",
"(",
"0",
",",
"1",
")",
"===",
"'-'",
")",
"{",
"input",
".",
"option",
"=",
"beforeLast",
";",
"}",
"input",
".",
"context",
"=",
"last",
";",
"input",
".",
"prefix",
"=",
"(",
"input",
".",
"prefix",
"||",
"''",
")",
"+",
"parts",
".",
"join",
"(",
"' '",
")",
"+",
"' '",
";",
"return",
"input",
";",
"}"
] |
Takes the context after a
matched command and figures
out the applicable context,
including assigning its role
such as being an option
parameter, etc.
@param {Object} input
@return {Object}
@api private
|
[
"Takes",
"the",
"context",
"after",
"a",
"matched",
"command",
"and",
"figures",
"out",
"the",
"applicable",
"context",
"including",
"assigning",
"its",
"role",
"such",
"as",
"being",
"an",
"option",
"parameter",
"etc",
"."
] |
51f5e2b545631b6a86c9781c274a1b0916a67ee8
|
https://github.com/dthree/vorpal/blob/51f5e2b545631b6a86c9781c274a1b0916a67ee8/dist/autocomplete.js#L269-L279
|
11,021
|
dthree/vorpal
|
dist/autocomplete.js
|
getCommandNames
|
function getCommandNames(cmds) {
var commands = _.map(cmds, '_name');
commands = commands.concat.apply(commands, _.map(cmds, '_aliases'));
commands.sort();
return commands;
}
|
javascript
|
function getCommandNames(cmds) {
var commands = _.map(cmds, '_name');
commands = commands.concat.apply(commands, _.map(cmds, '_aliases'));
commands.sort();
return commands;
}
|
[
"function",
"getCommandNames",
"(",
"cmds",
")",
"{",
"var",
"commands",
"=",
"_",
".",
"map",
"(",
"cmds",
",",
"'_name'",
")",
";",
"commands",
"=",
"commands",
".",
"concat",
".",
"apply",
"(",
"commands",
",",
"_",
".",
"map",
"(",
"cmds",
",",
"'_aliases'",
")",
")",
";",
"commands",
".",
"sort",
"(",
")",
";",
"return",
"commands",
";",
"}"
] |
Compile all available commands and aliases
in alphabetical order.
@param {Array} cmds
@return {Array}
@api private
|
[
"Compile",
"all",
"available",
"commands",
"and",
"aliases",
"in",
"alphabetical",
"order",
"."
] |
51f5e2b545631b6a86c9781c274a1b0916a67ee8
|
https://github.com/dthree/vorpal/blob/51f5e2b545631b6a86c9781c274a1b0916a67ee8/dist/autocomplete.js#L305-L310
|
11,022
|
dthree/vorpal
|
dist/autocomplete.js
|
getMatchData
|
function getMatchData(input, cb) {
var string = input.context;
var cmd = input.match;
var midOption = String(string).trim().slice(0, 1) === '-';
var afterOption = input.option !== undefined;
if (midOption === true && !cmd._allowUnknownOptions) {
var results = [];
for (var i = 0; i < cmd.options.length; ++i) {
var long = cmd.options[i].long;
var short = cmd.options[i].short;
if (!long && short) {
results.push(short);
} else if (long) {
results.push(long);
}
}
cb(results);
return;
}
function handleDataFormat(str, config, callback) {
var data = [];
if (_.isArray(config)) {
data = config;
} else if (_.isFunction(config)) {
var cbk = config.length < 2 ? function () {} : function (res) {
callback(res || []);
};
var res = config(str, cbk);
if (res && _.isFunction(res.then)) {
res.then(function (resp) {
callback(resp);
}).catch(function (err) {
callback(err);
});
} else if (config.length < 2) {
callback(res);
}
return;
}
callback(data);
return;
}
if (afterOption === true) {
var opt = strip(input.option).trim();
var shortMatch = _.find(cmd.options, { short: opt });
var longMatch = _.find(cmd.options, { long: opt });
var match = longMatch || shortMatch;
if (match) {
var config = match.autocomplete;
handleDataFormat(string, config, cb);
return;
}
}
var conf = cmd._autocomplete;
conf = conf && conf.data ? conf.data : conf;
handleDataFormat(string, conf, cb);
return;
}
|
javascript
|
function getMatchData(input, cb) {
var string = input.context;
var cmd = input.match;
var midOption = String(string).trim().slice(0, 1) === '-';
var afterOption = input.option !== undefined;
if (midOption === true && !cmd._allowUnknownOptions) {
var results = [];
for (var i = 0; i < cmd.options.length; ++i) {
var long = cmd.options[i].long;
var short = cmd.options[i].short;
if (!long && short) {
results.push(short);
} else if (long) {
results.push(long);
}
}
cb(results);
return;
}
function handleDataFormat(str, config, callback) {
var data = [];
if (_.isArray(config)) {
data = config;
} else if (_.isFunction(config)) {
var cbk = config.length < 2 ? function () {} : function (res) {
callback(res || []);
};
var res = config(str, cbk);
if (res && _.isFunction(res.then)) {
res.then(function (resp) {
callback(resp);
}).catch(function (err) {
callback(err);
});
} else if (config.length < 2) {
callback(res);
}
return;
}
callback(data);
return;
}
if (afterOption === true) {
var opt = strip(input.option).trim();
var shortMatch = _.find(cmd.options, { short: opt });
var longMatch = _.find(cmd.options, { long: opt });
var match = longMatch || shortMatch;
if (match) {
var config = match.autocomplete;
handleDataFormat(string, config, cb);
return;
}
}
var conf = cmd._autocomplete;
conf = conf && conf.data ? conf.data : conf;
handleDataFormat(string, conf, cb);
return;
}
|
[
"function",
"getMatchData",
"(",
"input",
",",
"cb",
")",
"{",
"var",
"string",
"=",
"input",
".",
"context",
";",
"var",
"cmd",
"=",
"input",
".",
"match",
";",
"var",
"midOption",
"=",
"String",
"(",
"string",
")",
".",
"trim",
"(",
")",
".",
"slice",
"(",
"0",
",",
"1",
")",
"===",
"'-'",
";",
"var",
"afterOption",
"=",
"input",
".",
"option",
"!==",
"undefined",
";",
"if",
"(",
"midOption",
"===",
"true",
"&&",
"!",
"cmd",
".",
"_allowUnknownOptions",
")",
"{",
"var",
"results",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"cmd",
".",
"options",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"long",
"=",
"cmd",
".",
"options",
"[",
"i",
"]",
".",
"long",
";",
"var",
"short",
"=",
"cmd",
".",
"options",
"[",
"i",
"]",
".",
"short",
";",
"if",
"(",
"!",
"long",
"&&",
"short",
")",
"{",
"results",
".",
"push",
"(",
"short",
")",
";",
"}",
"else",
"if",
"(",
"long",
")",
"{",
"results",
".",
"push",
"(",
"long",
")",
";",
"}",
"}",
"cb",
"(",
"results",
")",
";",
"return",
";",
"}",
"function",
"handleDataFormat",
"(",
"str",
",",
"config",
",",
"callback",
")",
"{",
"var",
"data",
"=",
"[",
"]",
";",
"if",
"(",
"_",
".",
"isArray",
"(",
"config",
")",
")",
"{",
"data",
"=",
"config",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isFunction",
"(",
"config",
")",
")",
"{",
"var",
"cbk",
"=",
"config",
".",
"length",
"<",
"2",
"?",
"function",
"(",
")",
"{",
"}",
":",
"function",
"(",
"res",
")",
"{",
"callback",
"(",
"res",
"||",
"[",
"]",
")",
";",
"}",
";",
"var",
"res",
"=",
"config",
"(",
"str",
",",
"cbk",
")",
";",
"if",
"(",
"res",
"&&",
"_",
".",
"isFunction",
"(",
"res",
".",
"then",
")",
")",
"{",
"res",
".",
"then",
"(",
"function",
"(",
"resp",
")",
"{",
"callback",
"(",
"resp",
")",
";",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
")",
";",
"}",
"else",
"if",
"(",
"config",
".",
"length",
"<",
"2",
")",
"{",
"callback",
"(",
"res",
")",
";",
"}",
"return",
";",
"}",
"callback",
"(",
"data",
")",
";",
"return",
";",
"}",
"if",
"(",
"afterOption",
"===",
"true",
")",
"{",
"var",
"opt",
"=",
"strip",
"(",
"input",
".",
"option",
")",
".",
"trim",
"(",
")",
";",
"var",
"shortMatch",
"=",
"_",
".",
"find",
"(",
"cmd",
".",
"options",
",",
"{",
"short",
":",
"opt",
"}",
")",
";",
"var",
"longMatch",
"=",
"_",
".",
"find",
"(",
"cmd",
".",
"options",
",",
"{",
"long",
":",
"opt",
"}",
")",
";",
"var",
"match",
"=",
"longMatch",
"||",
"shortMatch",
";",
"if",
"(",
"match",
")",
"{",
"var",
"config",
"=",
"match",
".",
"autocomplete",
";",
"handleDataFormat",
"(",
"string",
",",
"config",
",",
"cb",
")",
";",
"return",
";",
"}",
"}",
"var",
"conf",
"=",
"cmd",
".",
"_autocomplete",
";",
"conf",
"=",
"conf",
"&&",
"conf",
".",
"data",
"?",
"conf",
".",
"data",
":",
"conf",
";",
"handleDataFormat",
"(",
"string",
",",
"conf",
",",
"cb",
")",
";",
"return",
";",
"}"
] |
Takes a known matched command, and reads
the applicable data by calling its autocompletion
instructions, whether it is the command's
autocompletion or one of its options.
@param {Object} input
@param {Function} cb
@return {Array}
@api private
|
[
"Takes",
"a",
"known",
"matched",
"command",
"and",
"reads",
"the",
"applicable",
"data",
"by",
"calling",
"its",
"autocompletion",
"instructions",
"whether",
"it",
"is",
"the",
"command",
"s",
"autocompletion",
"or",
"one",
"of",
"its",
"options",
"."
] |
51f5e2b545631b6a86c9781c274a1b0916a67ee8
|
https://github.com/dthree/vorpal/blob/51f5e2b545631b6a86c9781c274a1b0916a67ee8/dist/autocomplete.js#L383-L443
|
11,023
|
dthree/vorpal
|
lib/autocomplete.js
|
function (str, cb) {
var self = this;
var input = parseInput(str, this.parent.ui._activePrompt.screen.rl.cursor);
var commands = getCommandNames(this.parent.commands);
var vorpalMatch = getMatch(input.context, commands, {ignoreSlashes: true});
var freezeTabs = false;
function end(str) {
var res = handleTabCounts.call(self, str, freezeTabs);
cb(undefined, res);
}
function evaluateTabs(input) {
if (input.context && input.context[input.context.length - 1] === '/') {
freezeTabs = true;
}
}
if (vorpalMatch) {
input.context = vorpalMatch;
evaluateTabs(input);
end(assembleInput(input));
return;
}
input = getMatchObject.call(this, input, commands);
if (input.match) {
input = parseMatchSection.call(this, input);
getMatchData.call(self, input, function (data) {
var dataMatch = getMatch(input.context, data);
if (dataMatch) {
input.context = dataMatch;
evaluateTabs(input);
end(assembleInput(input));
return;
}
end(filterData(input.context, data));
});
return;
}
end(filterData(input.context, commands));
}
|
javascript
|
function (str, cb) {
var self = this;
var input = parseInput(str, this.parent.ui._activePrompt.screen.rl.cursor);
var commands = getCommandNames(this.parent.commands);
var vorpalMatch = getMatch(input.context, commands, {ignoreSlashes: true});
var freezeTabs = false;
function end(str) {
var res = handleTabCounts.call(self, str, freezeTabs);
cb(undefined, res);
}
function evaluateTabs(input) {
if (input.context && input.context[input.context.length - 1] === '/') {
freezeTabs = true;
}
}
if (vorpalMatch) {
input.context = vorpalMatch;
evaluateTabs(input);
end(assembleInput(input));
return;
}
input = getMatchObject.call(this, input, commands);
if (input.match) {
input = parseMatchSection.call(this, input);
getMatchData.call(self, input, function (data) {
var dataMatch = getMatch(input.context, data);
if (dataMatch) {
input.context = dataMatch;
evaluateTabs(input);
end(assembleInput(input));
return;
}
end(filterData(input.context, data));
});
return;
}
end(filterData(input.context, commands));
}
|
[
"function",
"(",
"str",
",",
"cb",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"input",
"=",
"parseInput",
"(",
"str",
",",
"this",
".",
"parent",
".",
"ui",
".",
"_activePrompt",
".",
"screen",
".",
"rl",
".",
"cursor",
")",
";",
"var",
"commands",
"=",
"getCommandNames",
"(",
"this",
".",
"parent",
".",
"commands",
")",
";",
"var",
"vorpalMatch",
"=",
"getMatch",
"(",
"input",
".",
"context",
",",
"commands",
",",
"{",
"ignoreSlashes",
":",
"true",
"}",
")",
";",
"var",
"freezeTabs",
"=",
"false",
";",
"function",
"end",
"(",
"str",
")",
"{",
"var",
"res",
"=",
"handleTabCounts",
".",
"call",
"(",
"self",
",",
"str",
",",
"freezeTabs",
")",
";",
"cb",
"(",
"undefined",
",",
"res",
")",
";",
"}",
"function",
"evaluateTabs",
"(",
"input",
")",
"{",
"if",
"(",
"input",
".",
"context",
"&&",
"input",
".",
"context",
"[",
"input",
".",
"context",
".",
"length",
"-",
"1",
"]",
"===",
"'/'",
")",
"{",
"freezeTabs",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"vorpalMatch",
")",
"{",
"input",
".",
"context",
"=",
"vorpalMatch",
";",
"evaluateTabs",
"(",
"input",
")",
";",
"end",
"(",
"assembleInput",
"(",
"input",
")",
")",
";",
"return",
";",
"}",
"input",
"=",
"getMatchObject",
".",
"call",
"(",
"this",
",",
"input",
",",
"commands",
")",
";",
"if",
"(",
"input",
".",
"match",
")",
"{",
"input",
"=",
"parseMatchSection",
".",
"call",
"(",
"this",
",",
"input",
")",
";",
"getMatchData",
".",
"call",
"(",
"self",
",",
"input",
",",
"function",
"(",
"data",
")",
"{",
"var",
"dataMatch",
"=",
"getMatch",
"(",
"input",
".",
"context",
",",
"data",
")",
";",
"if",
"(",
"dataMatch",
")",
"{",
"input",
".",
"context",
"=",
"dataMatch",
";",
"evaluateTabs",
"(",
"input",
")",
";",
"end",
"(",
"assembleInput",
"(",
"input",
")",
")",
";",
"return",
";",
"}",
"end",
"(",
"filterData",
"(",
"input",
".",
"context",
",",
"data",
")",
")",
";",
"}",
")",
";",
"return",
";",
"}",
"end",
"(",
"filterData",
"(",
"input",
".",
"context",
",",
"commands",
")",
")",
";",
"}"
] |
Handles tabbed autocompletion.
- Initial tabbing lists all registered commands.
- Completes a command halfway typed.
- Recognizes options and lists all possible options.
- Recognizes option arguments and lists them.
- Supports cursor positions anywhere in the string.
- Supports piping.
@param {String} str
@return {String} cb
@api public
|
[
"Handles",
"tabbed",
"autocompletion",
"."
] |
51f5e2b545631b6a86c9781c274a1b0916a67ee8
|
https://github.com/dthree/vorpal/blob/51f5e2b545631b6a86c9781c274a1b0916a67ee8/lib/autocomplete.js#L23-L64
|
|
11,024
|
dthree/vorpal
|
lib/autocomplete.js
|
filterData
|
function filterData(str, data) {
data = data || [];
var ctx = String(str || '').trim();
var slashParts = ctx.split('/');
ctx = slashParts.pop();
var wordParts = String(ctx).trim().split(' ');
var res = data.filter(function (item) {
return (strip(item).slice(0, ctx.length) === ctx);
});
res = res.map(function (item) {
var parts = String(item).trim().split(' ');
if (parts.length > 1) {
parts = parts.slice(wordParts.length);
return parts.join(' ');
}
return item;
});
return res;
}
|
javascript
|
function filterData(str, data) {
data = data || [];
var ctx = String(str || '').trim();
var slashParts = ctx.split('/');
ctx = slashParts.pop();
var wordParts = String(ctx).trim().split(' ');
var res = data.filter(function (item) {
return (strip(item).slice(0, ctx.length) === ctx);
});
res = res.map(function (item) {
var parts = String(item).trim().split(' ');
if (parts.length > 1) {
parts = parts.slice(wordParts.length);
return parts.join(' ');
}
return item;
});
return res;
}
|
[
"function",
"filterData",
"(",
"str",
",",
"data",
")",
"{",
"data",
"=",
"data",
"||",
"[",
"]",
";",
"var",
"ctx",
"=",
"String",
"(",
"str",
"||",
"''",
")",
".",
"trim",
"(",
")",
";",
"var",
"slashParts",
"=",
"ctx",
".",
"split",
"(",
"'/'",
")",
";",
"ctx",
"=",
"slashParts",
".",
"pop",
"(",
")",
";",
"var",
"wordParts",
"=",
"String",
"(",
"ctx",
")",
".",
"trim",
"(",
")",
".",
"split",
"(",
"' '",
")",
";",
"var",
"res",
"=",
"data",
".",
"filter",
"(",
"function",
"(",
"item",
")",
"{",
"return",
"(",
"strip",
"(",
"item",
")",
".",
"slice",
"(",
"0",
",",
"ctx",
".",
"length",
")",
"===",
"ctx",
")",
";",
"}",
")",
";",
"res",
"=",
"res",
".",
"map",
"(",
"function",
"(",
"item",
")",
"{",
"var",
"parts",
"=",
"String",
"(",
"item",
")",
".",
"trim",
"(",
")",
".",
"split",
"(",
"' '",
")",
";",
"if",
"(",
"parts",
".",
"length",
">",
"1",
")",
"{",
"parts",
"=",
"parts",
".",
"slice",
"(",
"wordParts",
".",
"length",
")",
";",
"return",
"parts",
".",
"join",
"(",
"' '",
")",
";",
"}",
"return",
"item",
";",
"}",
")",
";",
"return",
"res",
";",
"}"
] |
Reduces an array of possible
matches to list based on a given
string.
@param {String} str
@param {Array} data
@return {Array}
@api private
|
[
"Reduces",
"an",
"array",
"of",
"possible",
"matches",
"to",
"list",
"based",
"on",
"a",
"given",
"string",
"."
] |
51f5e2b545631b6a86c9781c274a1b0916a67ee8
|
https://github.com/dthree/vorpal/blob/51f5e2b545631b6a86c9781c274a1b0916a67ee8/lib/autocomplete.js#L211-L229
|
11,025
|
dthree/vorpal
|
lib/autocomplete.js
|
getSuffix
|
function getSuffix(suffix) {
suffix = (suffix.slice(0, 1) === ' ') ?
suffix :
suffix.replace(/.+?(?=\s)/, '');
suffix = suffix.slice(1, suffix.length);
return suffix;
}
|
javascript
|
function getSuffix(suffix) {
suffix = (suffix.slice(0, 1) === ' ') ?
suffix :
suffix.replace(/.+?(?=\s)/, '');
suffix = suffix.slice(1, suffix.length);
return suffix;
}
|
[
"function",
"getSuffix",
"(",
"suffix",
")",
"{",
"suffix",
"=",
"(",
"suffix",
".",
"slice",
"(",
"0",
",",
"1",
")",
"===",
"' '",
")",
"?",
"suffix",
":",
"suffix",
".",
"replace",
"(",
"/",
".+?(?=\\s)",
"/",
",",
"''",
")",
";",
"suffix",
"=",
"suffix",
".",
"slice",
"(",
"1",
",",
"suffix",
".",
"length",
")",
";",
"return",
"suffix",
";",
"}"
] |
Returns a cleaned up version of the
remaining text to the right of the cursor.
@param {String} suffix
@return {String}
@api private
|
[
"Returns",
"a",
"cleaned",
"up",
"version",
"of",
"the",
"remaining",
"text",
"to",
"the",
"right",
"of",
"the",
"cursor",
"."
] |
51f5e2b545631b6a86c9781c274a1b0916a67ee8
|
https://github.com/dthree/vorpal/blob/51f5e2b545631b6a86c9781c274a1b0916a67ee8/lib/autocomplete.js#L294-L300
|
11,026
|
dthree/vorpal
|
lib/autocomplete.js
|
getMatchObject
|
function getMatchObject(input, commands) {
var len = input.context.length;
var trimmed = String(input.context).replace(/^\s+/g, '');
var prefix = new Array((len - trimmed.length) + 1).join(' ');
var match;
var suffix;
commands.forEach(function (cmd) {
var nextChar = trimmed.substr(cmd.length, 1);
if (trimmed.substr(0, cmd.length) === cmd && String(cmd).trim() !== '' && nextChar === ' ') {
match = cmd;
suffix = trimmed.substr(cmd.length);
prefix += trimmed.substr(0, cmd.length);
}
});
var matchObject = (match) ?
_.find(this.parent.commands, {_name: String(match).trim()}) :
undefined;
if (!matchObject) {
this.parent.commands.forEach(function (cmd) {
if ((cmd._aliases || []).indexOf(String(match).trim()) > -1) {
matchObject = cmd;
}
return;
});
}
if (!matchObject) {
matchObject = _.find(this.parent.commands, {_catch: true});
if (matchObject) {
suffix = input.context;
}
}
if (!matchObject) {
prefix = input.context;
suffix = '';
}
if (matchObject) {
input.match = matchObject;
input.prefix += prefix;
input.context = suffix;
}
return input;
}
|
javascript
|
function getMatchObject(input, commands) {
var len = input.context.length;
var trimmed = String(input.context).replace(/^\s+/g, '');
var prefix = new Array((len - trimmed.length) + 1).join(' ');
var match;
var suffix;
commands.forEach(function (cmd) {
var nextChar = trimmed.substr(cmd.length, 1);
if (trimmed.substr(0, cmd.length) === cmd && String(cmd).trim() !== '' && nextChar === ' ') {
match = cmd;
suffix = trimmed.substr(cmd.length);
prefix += trimmed.substr(0, cmd.length);
}
});
var matchObject = (match) ?
_.find(this.parent.commands, {_name: String(match).trim()}) :
undefined;
if (!matchObject) {
this.parent.commands.forEach(function (cmd) {
if ((cmd._aliases || []).indexOf(String(match).trim()) > -1) {
matchObject = cmd;
}
return;
});
}
if (!matchObject) {
matchObject = _.find(this.parent.commands, {_catch: true});
if (matchObject) {
suffix = input.context;
}
}
if (!matchObject) {
prefix = input.context;
suffix = '';
}
if (matchObject) {
input.match = matchObject;
input.prefix += prefix;
input.context = suffix;
}
return input;
}
|
[
"function",
"getMatchObject",
"(",
"input",
",",
"commands",
")",
"{",
"var",
"len",
"=",
"input",
".",
"context",
".",
"length",
";",
"var",
"trimmed",
"=",
"String",
"(",
"input",
".",
"context",
")",
".",
"replace",
"(",
"/",
"^\\s+",
"/",
"g",
",",
"''",
")",
";",
"var",
"prefix",
"=",
"new",
"Array",
"(",
"(",
"len",
"-",
"trimmed",
".",
"length",
")",
"+",
"1",
")",
".",
"join",
"(",
"' '",
")",
";",
"var",
"match",
";",
"var",
"suffix",
";",
"commands",
".",
"forEach",
"(",
"function",
"(",
"cmd",
")",
"{",
"var",
"nextChar",
"=",
"trimmed",
".",
"substr",
"(",
"cmd",
".",
"length",
",",
"1",
")",
";",
"if",
"(",
"trimmed",
".",
"substr",
"(",
"0",
",",
"cmd",
".",
"length",
")",
"===",
"cmd",
"&&",
"String",
"(",
"cmd",
")",
".",
"trim",
"(",
")",
"!==",
"''",
"&&",
"nextChar",
"===",
"' '",
")",
"{",
"match",
"=",
"cmd",
";",
"suffix",
"=",
"trimmed",
".",
"substr",
"(",
"cmd",
".",
"length",
")",
";",
"prefix",
"+=",
"trimmed",
".",
"substr",
"(",
"0",
",",
"cmd",
".",
"length",
")",
";",
"}",
"}",
")",
";",
"var",
"matchObject",
"=",
"(",
"match",
")",
"?",
"_",
".",
"find",
"(",
"this",
".",
"parent",
".",
"commands",
",",
"{",
"_name",
":",
"String",
"(",
"match",
")",
".",
"trim",
"(",
")",
"}",
")",
":",
"undefined",
";",
"if",
"(",
"!",
"matchObject",
")",
"{",
"this",
".",
"parent",
".",
"commands",
".",
"forEach",
"(",
"function",
"(",
"cmd",
")",
"{",
"if",
"(",
"(",
"cmd",
".",
"_aliases",
"||",
"[",
"]",
")",
".",
"indexOf",
"(",
"String",
"(",
"match",
")",
".",
"trim",
"(",
")",
")",
">",
"-",
"1",
")",
"{",
"matchObject",
"=",
"cmd",
";",
"}",
"return",
";",
"}",
")",
";",
"}",
"if",
"(",
"!",
"matchObject",
")",
"{",
"matchObject",
"=",
"_",
".",
"find",
"(",
"this",
".",
"parent",
".",
"commands",
",",
"{",
"_catch",
":",
"true",
"}",
")",
";",
"if",
"(",
"matchObject",
")",
"{",
"suffix",
"=",
"input",
".",
"context",
";",
"}",
"}",
"if",
"(",
"!",
"matchObject",
")",
"{",
"prefix",
"=",
"input",
".",
"context",
";",
"suffix",
"=",
"''",
";",
"}",
"if",
"(",
"matchObject",
")",
"{",
"input",
".",
"match",
"=",
"matchObject",
";",
"input",
".",
"prefix",
"+=",
"prefix",
";",
"input",
".",
"context",
"=",
"suffix",
";",
"}",
"return",
"input",
";",
"}"
] |
When we know that we've
exceeded a known command, grab
on to that command and return it,
fixing the overall input context
at the same time.
@param {Object} input
@param {Array} commands
@return {Object}
@api private
|
[
"When",
"we",
"know",
"that",
"we",
"ve",
"exceeded",
"a",
"known",
"command",
"grab",
"on",
"to",
"that",
"command",
"and",
"return",
"it",
"fixing",
"the",
"overall",
"input",
"context",
"at",
"the",
"same",
"time",
"."
] |
51f5e2b545631b6a86c9781c274a1b0916a67ee8
|
https://github.com/dthree/vorpal/blob/51f5e2b545631b6a86c9781c274a1b0916a67ee8/lib/autocomplete.js#L331-L377
|
11,027
|
Microsoft/maker.js
|
docs/demos/js/pixel-heart.js
|
PixelWalker
|
function PixelWalker(firstPoint, pixel_path) {
// go clockwise starting first point
var points = [];
points.push(firstPoint);
var moveHorizontal = true; // alternate horizontal and vertical movements to form pixel heart
pixel_path.forEach(function (p) {
var previous_point = points[points.length - 1];
var point_to_add;
if (moveHorizontal) {
point_to_add = [p, 0];
} else {
point_to_add = [0, p];
}
var e = makerjs.point.add(previous_point, point_to_add);
points.push(e);
// flip direction each time
moveHorizontal = !moveHorizontal;
});
return points;
}
|
javascript
|
function PixelWalker(firstPoint, pixel_path) {
// go clockwise starting first point
var points = [];
points.push(firstPoint);
var moveHorizontal = true; // alternate horizontal and vertical movements to form pixel heart
pixel_path.forEach(function (p) {
var previous_point = points[points.length - 1];
var point_to_add;
if (moveHorizontal) {
point_to_add = [p, 0];
} else {
point_to_add = [0, p];
}
var e = makerjs.point.add(previous_point, point_to_add);
points.push(e);
// flip direction each time
moveHorizontal = !moveHorizontal;
});
return points;
}
|
[
"function",
"PixelWalker",
"(",
"firstPoint",
",",
"pixel_path",
")",
"{",
"// go clockwise starting first point",
"var",
"points",
"=",
"[",
"]",
";",
"points",
".",
"push",
"(",
"firstPoint",
")",
";",
"var",
"moveHorizontal",
"=",
"true",
";",
"// alternate horizontal and vertical movements to form pixel heart",
"pixel_path",
".",
"forEach",
"(",
"function",
"(",
"p",
")",
"{",
"var",
"previous_point",
"=",
"points",
"[",
"points",
".",
"length",
"-",
"1",
"]",
";",
"var",
"point_to_add",
";",
"if",
"(",
"moveHorizontal",
")",
"{",
"point_to_add",
"=",
"[",
"p",
",",
"0",
"]",
";",
"}",
"else",
"{",
"point_to_add",
"=",
"[",
"0",
",",
"p",
"]",
";",
"}",
"var",
"e",
"=",
"makerjs",
".",
"point",
".",
"add",
"(",
"previous_point",
",",
"point_to_add",
")",
";",
"points",
".",
"push",
"(",
"e",
")",
";",
"// flip direction each time",
"moveHorizontal",
"=",
"!",
"moveHorizontal",
";",
"}",
")",
";",
"return",
"points",
";",
"}"
] |
starting point so the heart is located properly in space
Builds an array of points that define a model by generating points
from the `path` defined above.
|
[
"starting",
"point",
"so",
"the",
"heart",
"is",
"located",
"properly",
"in",
"space",
"Builds",
"an",
"array",
"of",
"points",
"that",
"define",
"a",
"model",
"by",
"generating",
"points",
"from",
"the",
"path",
"defined",
"above",
"."
] |
22cc3b46abb1997b301dd3b2b300aa848d431efd
|
https://github.com/Microsoft/maker.js/blob/22cc3b46abb1997b301dd3b2b300aa848d431efd/docs/demos/js/pixel-heart.js#L37-L63
|
11,028
|
Microsoft/maker.js
|
docs/demos/js/pixel-heart.js
|
Heart
|
function Heart(desired_width) {
var points = PixelWalker(STARTING_POINT, path);
var pathModel = new makerjs.models.ConnectTheDots(true, points);
if (typeof desired_width != 'undefined') {
var scale = desired_width / HEART_WIDTH;
makerjs.model.scale(pathModel, scale);
}
return pathModel;
}
|
javascript
|
function Heart(desired_width) {
var points = PixelWalker(STARTING_POINT, path);
var pathModel = new makerjs.models.ConnectTheDots(true, points);
if (typeof desired_width != 'undefined') {
var scale = desired_width / HEART_WIDTH;
makerjs.model.scale(pathModel, scale);
}
return pathModel;
}
|
[
"function",
"Heart",
"(",
"desired_width",
")",
"{",
"var",
"points",
"=",
"PixelWalker",
"(",
"STARTING_POINT",
",",
"path",
")",
";",
"var",
"pathModel",
"=",
"new",
"makerjs",
".",
"models",
".",
"ConnectTheDots",
"(",
"true",
",",
"points",
")",
";",
"if",
"(",
"typeof",
"desired_width",
"!=",
"'undefined'",
")",
"{",
"var",
"scale",
"=",
"desired_width",
"/",
"HEART_WIDTH",
";",
"makerjs",
".",
"model",
".",
"scale",
"(",
"pathModel",
",",
"scale",
")",
";",
"}",
"return",
"pathModel",
";",
"}"
] |
Builds a pixel heart model and scale it to the specified input width.
|
[
"Builds",
"a",
"pixel",
"heart",
"model",
"and",
"scale",
"it",
"to",
"the",
"specified",
"input",
"width",
"."
] |
22cc3b46abb1997b301dd3b2b300aa848d431efd
|
https://github.com/Microsoft/maker.js/blob/22cc3b46abb1997b301dd3b2b300aa848d431efd/docs/demos/js/pixel-heart.js#L68-L77
|
11,029
|
Microsoft/maker.js
|
docs/playground/js/require-iframe.js
|
complete2
|
function complete2() {
//reset any calls to document.write
resetLog();
//reinstate alert
window.alert = originalAlert;
var originalFn = parent.makerjs.exporter.toSVG;
var captureExportedModel;
parent.makerjs.exporter.toSVG = function (itemToExport, options) {
if (parent.makerjs.isModel(itemToExport)) {
captureExportedModel = itemToExport;
}
else if (Array.isArray(itemToExport)) {
captureExportedModel = {};
itemToExport.forEach(function (x, i) {
if (makerjs.isModel(x)) {
captureExportedModel.models = captureExportedModel.models || {};
captureExportedModel.models[i] = x;
}
if (makerjs.isPath(x)) {
captureExportedModel.paths = captureExportedModel.paths || {};
captureExportedModel.paths[i] = x;
}
});
}
else if (parent.makerjs.isPath(itemToExport)) {
captureExportedModel = { paths: { "0": itemToExport } };
}
return originalFn(itemToExport, options);
};
//when all requirements are collected, run the code again, using its requirements
runCodeGlobal(javaScript);
parent.makerjs.exporter.toSVG = originalFn;
if (errorReported)
return;
//yield thread for the script tag to execute
setTimeout(function () {
var model;
if (captureExportedModel) {
model = captureExportedModel;
}
else {
//restore properties from the "this" keyword
model = {};
var props = ['layer', 'models', 'notes', 'origin', 'paths', 'type', 'units', 'caption', 'exporterOptions'];
var hasProps = false;
for (var i = 0; i < props.length; i++) {
var prop = props[i];
if (prop in window) {
model[prop] = window[prop];
hasProps = true;
}
}
if (!hasProps) {
model = null;
}
}
var orderedDependencies = [];
var scripts = head.getElementsByTagName('script');
for (var i = 0; i < scripts.length; i++) {
if (scripts[i].hasAttribute('id')) {
orderedDependencies.push(scripts[i].id);
}
}
//send results back to parent window
parent.MakerJsPlayground.processResult({ html: getHtml(), result: window.module.exports || model, orderedDependencies: orderedDependencies, paramValues: window.paramValues });
}, 0);
}
|
javascript
|
function complete2() {
//reset any calls to document.write
resetLog();
//reinstate alert
window.alert = originalAlert;
var originalFn = parent.makerjs.exporter.toSVG;
var captureExportedModel;
parent.makerjs.exporter.toSVG = function (itemToExport, options) {
if (parent.makerjs.isModel(itemToExport)) {
captureExportedModel = itemToExport;
}
else if (Array.isArray(itemToExport)) {
captureExportedModel = {};
itemToExport.forEach(function (x, i) {
if (makerjs.isModel(x)) {
captureExportedModel.models = captureExportedModel.models || {};
captureExportedModel.models[i] = x;
}
if (makerjs.isPath(x)) {
captureExportedModel.paths = captureExportedModel.paths || {};
captureExportedModel.paths[i] = x;
}
});
}
else if (parent.makerjs.isPath(itemToExport)) {
captureExportedModel = { paths: { "0": itemToExport } };
}
return originalFn(itemToExport, options);
};
//when all requirements are collected, run the code again, using its requirements
runCodeGlobal(javaScript);
parent.makerjs.exporter.toSVG = originalFn;
if (errorReported)
return;
//yield thread for the script tag to execute
setTimeout(function () {
var model;
if (captureExportedModel) {
model = captureExportedModel;
}
else {
//restore properties from the "this" keyword
model = {};
var props = ['layer', 'models', 'notes', 'origin', 'paths', 'type', 'units', 'caption', 'exporterOptions'];
var hasProps = false;
for (var i = 0; i < props.length; i++) {
var prop = props[i];
if (prop in window) {
model[prop] = window[prop];
hasProps = true;
}
}
if (!hasProps) {
model = null;
}
}
var orderedDependencies = [];
var scripts = head.getElementsByTagName('script');
for (var i = 0; i < scripts.length; i++) {
if (scripts[i].hasAttribute('id')) {
orderedDependencies.push(scripts[i].id);
}
}
//send results back to parent window
parent.MakerJsPlayground.processResult({ html: getHtml(), result: window.module.exports || model, orderedDependencies: orderedDependencies, paramValues: window.paramValues });
}, 0);
}
|
[
"function",
"complete2",
"(",
")",
"{",
"//reset any calls to document.write",
"resetLog",
"(",
")",
";",
"//reinstate alert",
"window",
".",
"alert",
"=",
"originalAlert",
";",
"var",
"originalFn",
"=",
"parent",
".",
"makerjs",
".",
"exporter",
".",
"toSVG",
";",
"var",
"captureExportedModel",
";",
"parent",
".",
"makerjs",
".",
"exporter",
".",
"toSVG",
"=",
"function",
"(",
"itemToExport",
",",
"options",
")",
"{",
"if",
"(",
"parent",
".",
"makerjs",
".",
"isModel",
"(",
"itemToExport",
")",
")",
"{",
"captureExportedModel",
"=",
"itemToExport",
";",
"}",
"else",
"if",
"(",
"Array",
".",
"isArray",
"(",
"itemToExport",
")",
")",
"{",
"captureExportedModel",
"=",
"{",
"}",
";",
"itemToExport",
".",
"forEach",
"(",
"function",
"(",
"x",
",",
"i",
")",
"{",
"if",
"(",
"makerjs",
".",
"isModel",
"(",
"x",
")",
")",
"{",
"captureExportedModel",
".",
"models",
"=",
"captureExportedModel",
".",
"models",
"||",
"{",
"}",
";",
"captureExportedModel",
".",
"models",
"[",
"i",
"]",
"=",
"x",
";",
"}",
"if",
"(",
"makerjs",
".",
"isPath",
"(",
"x",
")",
")",
"{",
"captureExportedModel",
".",
"paths",
"=",
"captureExportedModel",
".",
"paths",
"||",
"{",
"}",
";",
"captureExportedModel",
".",
"paths",
"[",
"i",
"]",
"=",
"x",
";",
"}",
"}",
")",
";",
"}",
"else",
"if",
"(",
"parent",
".",
"makerjs",
".",
"isPath",
"(",
"itemToExport",
")",
")",
"{",
"captureExportedModel",
"=",
"{",
"paths",
":",
"{",
"\"0\"",
":",
"itemToExport",
"}",
"}",
";",
"}",
"return",
"originalFn",
"(",
"itemToExport",
",",
"options",
")",
";",
"}",
";",
"//when all requirements are collected, run the code again, using its requirements",
"runCodeGlobal",
"(",
"javaScript",
")",
";",
"parent",
".",
"makerjs",
".",
"exporter",
".",
"toSVG",
"=",
"originalFn",
";",
"if",
"(",
"errorReported",
")",
"return",
";",
"//yield thread for the script tag to execute",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"var",
"model",
";",
"if",
"(",
"captureExportedModel",
")",
"{",
"model",
"=",
"captureExportedModel",
";",
"}",
"else",
"{",
"//restore properties from the \"this\" keyword",
"model",
"=",
"{",
"}",
";",
"var",
"props",
"=",
"[",
"'layer'",
",",
"'models'",
",",
"'notes'",
",",
"'origin'",
",",
"'paths'",
",",
"'type'",
",",
"'units'",
",",
"'caption'",
",",
"'exporterOptions'",
"]",
";",
"var",
"hasProps",
"=",
"false",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"props",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"prop",
"=",
"props",
"[",
"i",
"]",
";",
"if",
"(",
"prop",
"in",
"window",
")",
"{",
"model",
"[",
"prop",
"]",
"=",
"window",
"[",
"prop",
"]",
";",
"hasProps",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"hasProps",
")",
"{",
"model",
"=",
"null",
";",
"}",
"}",
"var",
"orderedDependencies",
"=",
"[",
"]",
";",
"var",
"scripts",
"=",
"head",
".",
"getElementsByTagName",
"(",
"'script'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"scripts",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"scripts",
"[",
"i",
"]",
".",
"hasAttribute",
"(",
"'id'",
")",
")",
"{",
"orderedDependencies",
".",
"push",
"(",
"scripts",
"[",
"i",
"]",
".",
"id",
")",
";",
"}",
"}",
"//send results back to parent window",
"parent",
".",
"MakerJsPlayground",
".",
"processResult",
"(",
"{",
"html",
":",
"getHtml",
"(",
")",
",",
"result",
":",
"window",
".",
"module",
".",
"exports",
"||",
"model",
",",
"orderedDependencies",
":",
"orderedDependencies",
",",
"paramValues",
":",
"window",
".",
"paramValues",
"}",
")",
";",
"}",
",",
"0",
")",
";",
"}"
] |
run the code in 2 passes, first - to cache all required libraries, secondly the actual execution
|
[
"run",
"the",
"code",
"in",
"2",
"passes",
"first",
"-",
"to",
"cache",
"all",
"required",
"libraries",
"secondly",
"the",
"actual",
"execution"
] |
22cc3b46abb1997b301dd3b2b300aa848d431efd
|
https://github.com/Microsoft/maker.js/blob/22cc3b46abb1997b301dd3b2b300aa848d431efd/docs/playground/js/require-iframe.js#L175-L241
|
11,030
|
ghettovoice/vuelayers
|
src/index.js
|
plugin
|
function plugin (Vue, options = {}) {
if (plugin.installed) {
return
}
plugin.installed = true
// install components
Vue.use(ArcgisRestSource, options)
Vue.use(BingmapsSource, options)
Vue.use(CircleGeom, options)
Vue.use(CircleStyle, options)
Vue.use(ClusterSource, options)
Vue.use(DrawInteraction, options)
Vue.use(Feature, options)
Vue.use(FillStyle, options)
Vue.use(Geoloc, options)
Vue.use(Graticule, options)
Vue.use(GroupLayer, options)
Vue.use(IconStyle, options)
Vue.use(ImageLayer, options)
Vue.use(ImageStaticSource, options)
Vue.use(ImageWmsSource, options)
Vue.use(LineStringGeom, options)
Vue.use(Map, options)
Vue.use(MapboxSource, options)
Vue.use(ModifyInteraction, options)
Vue.use(MultiLineStringGeom, options)
Vue.use(MultiPointGeom, options)
Vue.use(MultiPolygonGeom, options)
Vue.use(OsmSource, options)
Vue.use(Overlay, options)
Vue.use(PointGeom, options)
Vue.use(PolygonGeom, options)
Vue.use(RegShapeStyle, options)
Vue.use(SelectInteraction, options)
Vue.use(SnapInteraction, options)
Vue.use(SputnikSource, options)
Vue.use(StamenSource, options)
Vue.use(StrokeStyle, options)
Vue.use(StyleBox, options)
Vue.use(StyleFunc, options)
Vue.use(TextStyle, options)
Vue.use(TileLayer, options)
Vue.use(VectorLayer, options)
Vue.use(VectorSource, options)
Vue.use(VectorTileLayer, options)
Vue.use(VectorTileSource, options)
Vue.use(WmsSource, options)
Vue.use(WmtsSource, options)
Vue.use(XyzSource, options)
}
|
javascript
|
function plugin (Vue, options = {}) {
if (plugin.installed) {
return
}
plugin.installed = true
// install components
Vue.use(ArcgisRestSource, options)
Vue.use(BingmapsSource, options)
Vue.use(CircleGeom, options)
Vue.use(CircleStyle, options)
Vue.use(ClusterSource, options)
Vue.use(DrawInteraction, options)
Vue.use(Feature, options)
Vue.use(FillStyle, options)
Vue.use(Geoloc, options)
Vue.use(Graticule, options)
Vue.use(GroupLayer, options)
Vue.use(IconStyle, options)
Vue.use(ImageLayer, options)
Vue.use(ImageStaticSource, options)
Vue.use(ImageWmsSource, options)
Vue.use(LineStringGeom, options)
Vue.use(Map, options)
Vue.use(MapboxSource, options)
Vue.use(ModifyInteraction, options)
Vue.use(MultiLineStringGeom, options)
Vue.use(MultiPointGeom, options)
Vue.use(MultiPolygonGeom, options)
Vue.use(OsmSource, options)
Vue.use(Overlay, options)
Vue.use(PointGeom, options)
Vue.use(PolygonGeom, options)
Vue.use(RegShapeStyle, options)
Vue.use(SelectInteraction, options)
Vue.use(SnapInteraction, options)
Vue.use(SputnikSource, options)
Vue.use(StamenSource, options)
Vue.use(StrokeStyle, options)
Vue.use(StyleBox, options)
Vue.use(StyleFunc, options)
Vue.use(TextStyle, options)
Vue.use(TileLayer, options)
Vue.use(VectorLayer, options)
Vue.use(VectorSource, options)
Vue.use(VectorTileLayer, options)
Vue.use(VectorTileSource, options)
Vue.use(WmsSource, options)
Vue.use(WmtsSource, options)
Vue.use(XyzSource, options)
}
|
[
"function",
"plugin",
"(",
"Vue",
",",
"options",
"=",
"{",
"}",
")",
"{",
"if",
"(",
"plugin",
".",
"installed",
")",
"{",
"return",
"}",
"plugin",
".",
"installed",
"=",
"true",
"// install components",
"Vue",
".",
"use",
"(",
"ArcgisRestSource",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"BingmapsSource",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"CircleGeom",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"CircleStyle",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"ClusterSource",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"DrawInteraction",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"Feature",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"FillStyle",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"Geoloc",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"Graticule",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"GroupLayer",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"IconStyle",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"ImageLayer",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"ImageStaticSource",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"ImageWmsSource",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"LineStringGeom",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"Map",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"MapboxSource",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"ModifyInteraction",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"MultiLineStringGeom",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"MultiPointGeom",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"MultiPolygonGeom",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"OsmSource",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"Overlay",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"PointGeom",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"PolygonGeom",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"RegShapeStyle",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"SelectInteraction",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"SnapInteraction",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"SputnikSource",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"StamenSource",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"StrokeStyle",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"StyleBox",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"StyleFunc",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"TextStyle",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"TileLayer",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"VectorLayer",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"VectorSource",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"VectorTileLayer",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"VectorTileSource",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"WmsSource",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"WmtsSource",
",",
"options",
")",
"Vue",
".",
"use",
"(",
"XyzSource",
",",
"options",
")",
"}"
] |
Registers all VueLayers components.
@param {Vue|VueConstructor} Vue
@param {VueLayersOptions} [options]
|
[
"Registers",
"all",
"VueLayers",
"components",
"."
] |
73bf8aa6fb08c4a683324706d54177552808a32d
|
https://github.com/ghettovoice/vuelayers/blob/73bf8aa6fb08c4a683324706d54177552808a32d/src/index.js#L56-L106
|
11,031
|
anvaka/panzoom
|
index.js
|
getBoundingBox
|
function getBoundingBox() {
if (!bounds) return // client does not want to restrict movement
if (typeof bounds === 'boolean') {
// for boolean type we use parent container bounds
var ownerRect = owner.getBoundingClientRect()
var sceneWidth = ownerRect.width
var sceneHeight = ownerRect.height
return {
left: sceneWidth * boundsPadding,
top: sceneHeight * boundsPadding,
right: sceneWidth * (1 - boundsPadding),
bottom: sceneHeight * (1 - boundsPadding),
}
}
return bounds
}
|
javascript
|
function getBoundingBox() {
if (!bounds) return // client does not want to restrict movement
if (typeof bounds === 'boolean') {
// for boolean type we use parent container bounds
var ownerRect = owner.getBoundingClientRect()
var sceneWidth = ownerRect.width
var sceneHeight = ownerRect.height
return {
left: sceneWidth * boundsPadding,
top: sceneHeight * boundsPadding,
right: sceneWidth * (1 - boundsPadding),
bottom: sceneHeight * (1 - boundsPadding),
}
}
return bounds
}
|
[
"function",
"getBoundingBox",
"(",
")",
"{",
"if",
"(",
"!",
"bounds",
")",
"return",
"// client does not want to restrict movement",
"if",
"(",
"typeof",
"bounds",
"===",
"'boolean'",
")",
"{",
"// for boolean type we use parent container bounds",
"var",
"ownerRect",
"=",
"owner",
".",
"getBoundingClientRect",
"(",
")",
"var",
"sceneWidth",
"=",
"ownerRect",
".",
"width",
"var",
"sceneHeight",
"=",
"ownerRect",
".",
"height",
"return",
"{",
"left",
":",
"sceneWidth",
"*",
"boundsPadding",
",",
"top",
":",
"sceneHeight",
"*",
"boundsPadding",
",",
"right",
":",
"sceneWidth",
"*",
"(",
"1",
"-",
"boundsPadding",
")",
",",
"bottom",
":",
"sceneHeight",
"*",
"(",
"1",
"-",
"boundsPadding",
")",
",",
"}",
"}",
"return",
"bounds",
"}"
] |
Returns bounding box that should be used to restrict scene movement.
|
[
"Returns",
"bounding",
"box",
"that",
"should",
"be",
"used",
"to",
"restrict",
"scene",
"movement",
"."
] |
57bb78383a371eccea115035d24c631e0e6819bb
|
https://github.com/anvaka/panzoom/blob/57bb78383a371eccea115035d24c631e0e6819bb/index.js#L280-L298
|
11,032
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(source) {
var copy, i, len, prop;
if (typeof source !== "object" || source == null || typeof source.nodeType === "number") {
copy = source;
} else if (typeof source.length === "number") {
copy = [];
for (i = 0, len = source.length; i < len; i++) {
if (_hasOwn.call(source, i)) {
copy[i] = _deepCopy(source[i]);
}
}
} else {
copy = {};
for (prop in source) {
if (_hasOwn.call(source, prop)) {
copy[prop] = _deepCopy(source[prop]);
}
}
}
return copy;
}
|
javascript
|
function(source) {
var copy, i, len, prop;
if (typeof source !== "object" || source == null || typeof source.nodeType === "number") {
copy = source;
} else if (typeof source.length === "number") {
copy = [];
for (i = 0, len = source.length; i < len; i++) {
if (_hasOwn.call(source, i)) {
copy[i] = _deepCopy(source[i]);
}
}
} else {
copy = {};
for (prop in source) {
if (_hasOwn.call(source, prop)) {
copy[prop] = _deepCopy(source[prop]);
}
}
}
return copy;
}
|
[
"function",
"(",
"source",
")",
"{",
"var",
"copy",
",",
"i",
",",
"len",
",",
"prop",
";",
"if",
"(",
"typeof",
"source",
"!==",
"\"object\"",
"||",
"source",
"==",
"null",
"||",
"typeof",
"source",
".",
"nodeType",
"===",
"\"number\"",
")",
"{",
"copy",
"=",
"source",
";",
"}",
"else",
"if",
"(",
"typeof",
"source",
".",
"length",
"===",
"\"number\"",
")",
"{",
"copy",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"source",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"_hasOwn",
".",
"call",
"(",
"source",
",",
"i",
")",
")",
"{",
"copy",
"[",
"i",
"]",
"=",
"_deepCopy",
"(",
"source",
"[",
"i",
"]",
")",
";",
"}",
"}",
"}",
"else",
"{",
"copy",
"=",
"{",
"}",
";",
"for",
"(",
"prop",
"in",
"source",
")",
"{",
"if",
"(",
"_hasOwn",
".",
"call",
"(",
"source",
",",
"prop",
")",
")",
"{",
"copy",
"[",
"prop",
"]",
"=",
"_deepCopy",
"(",
"source",
"[",
"prop",
"]",
")",
";",
"}",
"}",
"}",
"return",
"copy",
";",
"}"
] |
Return a deep copy of the source object or array.
@returns Object or Array
@private
|
[
"Return",
"a",
"deep",
"copy",
"of",
"the",
"source",
"object",
"or",
"array",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L68-L88
|
|
11,033
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(obj) {
if (obj) {
for (var prop in obj) {
if (_hasOwn.call(obj, prop)) {
delete obj[prop];
}
}
}
return obj;
}
|
javascript
|
function(obj) {
if (obj) {
for (var prop in obj) {
if (_hasOwn.call(obj, prop)) {
delete obj[prop];
}
}
}
return obj;
}
|
[
"function",
"(",
"obj",
")",
"{",
"if",
"(",
"obj",
")",
"{",
"for",
"(",
"var",
"prop",
"in",
"obj",
")",
"{",
"if",
"(",
"_hasOwn",
".",
"call",
"(",
"obj",
",",
"prop",
")",
")",
"{",
"delete",
"obj",
"[",
"prop",
"]",
";",
"}",
"}",
"}",
"return",
"obj",
";",
"}"
] |
Remove all owned, enumerable properties from an object.
@returns The original object without its owned, enumerable properties.
@private
|
[
"Remove",
"all",
"owned",
"enumerable",
"properties",
"from",
"an",
"object",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L128-L137
|
|
11,034
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(el, ancestorEl) {
if (el && el.nodeType === 1 && el.ownerDocument && ancestorEl && (ancestorEl.nodeType === 1 && ancestorEl.ownerDocument && ancestorEl.ownerDocument === el.ownerDocument || ancestorEl.nodeType === 9 && !ancestorEl.ownerDocument && ancestorEl === el.ownerDocument)) {
do {
if (el === ancestorEl) {
return true;
}
el = el.parentNode;
} while (el);
}
return false;
}
|
javascript
|
function(el, ancestorEl) {
if (el && el.nodeType === 1 && el.ownerDocument && ancestorEl && (ancestorEl.nodeType === 1 && ancestorEl.ownerDocument && ancestorEl.ownerDocument === el.ownerDocument || ancestorEl.nodeType === 9 && !ancestorEl.ownerDocument && ancestorEl === el.ownerDocument)) {
do {
if (el === ancestorEl) {
return true;
}
el = el.parentNode;
} while (el);
}
return false;
}
|
[
"function",
"(",
"el",
",",
"ancestorEl",
")",
"{",
"if",
"(",
"el",
"&&",
"el",
".",
"nodeType",
"===",
"1",
"&&",
"el",
".",
"ownerDocument",
"&&",
"ancestorEl",
"&&",
"(",
"ancestorEl",
".",
"nodeType",
"===",
"1",
"&&",
"ancestorEl",
".",
"ownerDocument",
"&&",
"ancestorEl",
".",
"ownerDocument",
"===",
"el",
".",
"ownerDocument",
"||",
"ancestorEl",
".",
"nodeType",
"===",
"9",
"&&",
"!",
"ancestorEl",
".",
"ownerDocument",
"&&",
"ancestorEl",
"===",
"el",
".",
"ownerDocument",
")",
")",
"{",
"do",
"{",
"if",
"(",
"el",
"===",
"ancestorEl",
")",
"{",
"return",
"true",
";",
"}",
"el",
"=",
"el",
".",
"parentNode",
";",
"}",
"while",
"(",
"el",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Determine if an element is contained within another element.
@returns Boolean
@private
|
[
"Determine",
"if",
"an",
"element",
"is",
"contained",
"within",
"another",
"element",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L144-L154
|
|
11,035
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(url) {
var dir;
if (typeof url === "string" && url) {
dir = url.split("#")[0].split("?")[0];
dir = url.slice(0, url.lastIndexOf("/") + 1);
}
return dir;
}
|
javascript
|
function(url) {
var dir;
if (typeof url === "string" && url) {
dir = url.split("#")[0].split("?")[0];
dir = url.slice(0, url.lastIndexOf("/") + 1);
}
return dir;
}
|
[
"function",
"(",
"url",
")",
"{",
"var",
"dir",
";",
"if",
"(",
"typeof",
"url",
"===",
"\"string\"",
"&&",
"url",
")",
"{",
"dir",
"=",
"url",
".",
"split",
"(",
"\"#\"",
")",
"[",
"0",
"]",
".",
"split",
"(",
"\"?\"",
")",
"[",
"0",
"]",
";",
"dir",
"=",
"url",
".",
"slice",
"(",
"0",
",",
"url",
".",
"lastIndexOf",
"(",
"\"/\"",
")",
"+",
"1",
")",
";",
"}",
"return",
"dir",
";",
"}"
] |
Get the URL path's parent directory.
@returns String or `undefined`
@private
|
[
"Get",
"the",
"URL",
"path",
"s",
"parent",
"directory",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L161-L168
|
|
11,036
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function() {
var jsPath, scripts, i;
if (_document.currentScript && (jsPath = _document.currentScript.src)) {
return jsPath;
}
scripts = _document.getElementsByTagName("script");
if (scripts.length === 1) {
return scripts[0].src || undefined;
}
if ("readyState" in (scripts[0] || document.createElement("script"))) {
for (i = scripts.length; i--; ) {
if (scripts[i].readyState === "interactive" && (jsPath = scripts[i].src)) {
return jsPath;
}
}
}
if (_document.readyState === "loading" && (jsPath = scripts[scripts.length - 1].src)) {
return jsPath;
}
if (jsPath = _getCurrentScriptUrlFromError()) {
return jsPath;
}
return undefined;
}
|
javascript
|
function() {
var jsPath, scripts, i;
if (_document.currentScript && (jsPath = _document.currentScript.src)) {
return jsPath;
}
scripts = _document.getElementsByTagName("script");
if (scripts.length === 1) {
return scripts[0].src || undefined;
}
if ("readyState" in (scripts[0] || document.createElement("script"))) {
for (i = scripts.length; i--; ) {
if (scripts[i].readyState === "interactive" && (jsPath = scripts[i].src)) {
return jsPath;
}
}
}
if (_document.readyState === "loading" && (jsPath = scripts[scripts.length - 1].src)) {
return jsPath;
}
if (jsPath = _getCurrentScriptUrlFromError()) {
return jsPath;
}
return undefined;
}
|
[
"function",
"(",
")",
"{",
"var",
"jsPath",
",",
"scripts",
",",
"i",
";",
"if",
"(",
"_document",
".",
"currentScript",
"&&",
"(",
"jsPath",
"=",
"_document",
".",
"currentScript",
".",
"src",
")",
")",
"{",
"return",
"jsPath",
";",
"}",
"scripts",
"=",
"_document",
".",
"getElementsByTagName",
"(",
"\"script\"",
")",
";",
"if",
"(",
"scripts",
".",
"length",
"===",
"1",
")",
"{",
"return",
"scripts",
"[",
"0",
"]",
".",
"src",
"||",
"undefined",
";",
"}",
"if",
"(",
"\"readyState\"",
"in",
"(",
"scripts",
"[",
"0",
"]",
"||",
"document",
".",
"createElement",
"(",
"\"script\"",
")",
")",
")",
"{",
"for",
"(",
"i",
"=",
"scripts",
".",
"length",
";",
"i",
"--",
";",
")",
"{",
"if",
"(",
"scripts",
"[",
"i",
"]",
".",
"readyState",
"===",
"\"interactive\"",
"&&",
"(",
"jsPath",
"=",
"scripts",
"[",
"i",
"]",
".",
"src",
")",
")",
"{",
"return",
"jsPath",
";",
"}",
"}",
"}",
"if",
"(",
"_document",
".",
"readyState",
"===",
"\"loading\"",
"&&",
"(",
"jsPath",
"=",
"scripts",
"[",
"scripts",
".",
"length",
"-",
"1",
"]",
".",
"src",
")",
")",
"{",
"return",
"jsPath",
";",
"}",
"if",
"(",
"jsPath",
"=",
"_getCurrentScriptUrlFromError",
"(",
")",
")",
"{",
"return",
"jsPath",
";",
"}",
"return",
"undefined",
";",
"}"
] |
Get the current script's URL.
@returns String or `undefined`
@private
|
[
"Get",
"the",
"current",
"script",
"s",
"URL",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L214-L237
|
|
11,037
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function() {
var isWindowsRegex = /win(dows|[\s]?(nt|me|ce|xp|vista|[\d]+))/i;
return !!_navigator && (isWindowsRegex.test(_navigator.appVersion || "") || isWindowsRegex.test(_navigator.platform || "") || (_navigator.userAgent || "").indexOf("Windows") !== -1);
}
|
javascript
|
function() {
var isWindowsRegex = /win(dows|[\s]?(nt|me|ce|xp|vista|[\d]+))/i;
return !!_navigator && (isWindowsRegex.test(_navigator.appVersion || "") || isWindowsRegex.test(_navigator.platform || "") || (_navigator.userAgent || "").indexOf("Windows") !== -1);
}
|
[
"function",
"(",
")",
"{",
"var",
"isWindowsRegex",
"=",
"/",
"win(dows|[\\s]?(nt|me|ce|xp|vista|[\\d]+))",
"/",
"i",
";",
"return",
"!",
"!",
"_navigator",
"&&",
"(",
"isWindowsRegex",
".",
"test",
"(",
"_navigator",
".",
"appVersion",
"||",
"\"\"",
")",
"||",
"isWindowsRegex",
".",
"test",
"(",
"_navigator",
".",
"platform",
"||",
"\"\"",
")",
"||",
"(",
"_navigator",
".",
"userAgent",
"||",
"\"\"",
")",
".",
"indexOf",
"(",
"\"Windows\"",
")",
"!==",
"-",
"1",
")",
";",
"}"
] |
Is the client's operating system some version of Windows?
@returns Boolean
@private
|
[
"Is",
"the",
"client",
"s",
"operating",
"system",
"some",
"version",
"of",
"Windows?"
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L280-L283
|
|
11,038
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(options) {
if (typeof options === "object" && options && !("length" in options)) {
_keys(options).forEach(function(prop) {
if (/^(?:forceHandCursor|title|zIndex|bubbleEvents|fixLineEndings)$/.test(prop)) {
_globalConfig[prop] = options[prop];
} else if (_flashState.bridge == null) {
if (prop === "containerId" || prop === "swfObjectId") {
if (_isValidHtml4Id(options[prop])) {
_globalConfig[prop] = options[prop];
} else {
throw new Error("The specified `" + prop + "` value is not valid as an HTML4 Element ID");
}
} else {
_globalConfig[prop] = options[prop];
}
}
});
}
if (typeof options === "string" && options) {
if (_hasOwn.call(_globalConfig, options)) {
return _globalConfig[options];
}
return;
}
return _deepCopy(_globalConfig);
}
|
javascript
|
function(options) {
if (typeof options === "object" && options && !("length" in options)) {
_keys(options).forEach(function(prop) {
if (/^(?:forceHandCursor|title|zIndex|bubbleEvents|fixLineEndings)$/.test(prop)) {
_globalConfig[prop] = options[prop];
} else if (_flashState.bridge == null) {
if (prop === "containerId" || prop === "swfObjectId") {
if (_isValidHtml4Id(options[prop])) {
_globalConfig[prop] = options[prop];
} else {
throw new Error("The specified `" + prop + "` value is not valid as an HTML4 Element ID");
}
} else {
_globalConfig[prop] = options[prop];
}
}
});
}
if (typeof options === "string" && options) {
if (_hasOwn.call(_globalConfig, options)) {
return _globalConfig[options];
}
return;
}
return _deepCopy(_globalConfig);
}
|
[
"function",
"(",
"options",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"\"object\"",
"&&",
"options",
"&&",
"!",
"(",
"\"length\"",
"in",
"options",
")",
")",
"{",
"_keys",
"(",
"options",
")",
".",
"forEach",
"(",
"function",
"(",
"prop",
")",
"{",
"if",
"(",
"/",
"^(?:forceHandCursor|title|zIndex|bubbleEvents|fixLineEndings)$",
"/",
".",
"test",
"(",
"prop",
")",
")",
"{",
"_globalConfig",
"[",
"prop",
"]",
"=",
"options",
"[",
"prop",
"]",
";",
"}",
"else",
"if",
"(",
"_flashState",
".",
"bridge",
"==",
"null",
")",
"{",
"if",
"(",
"prop",
"===",
"\"containerId\"",
"||",
"prop",
"===",
"\"swfObjectId\"",
")",
"{",
"if",
"(",
"_isValidHtml4Id",
"(",
"options",
"[",
"prop",
"]",
")",
")",
"{",
"_globalConfig",
"[",
"prop",
"]",
"=",
"options",
"[",
"prop",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"\"The specified `\"",
"+",
"prop",
"+",
"\"` value is not valid as an HTML4 Element ID\"",
")",
";",
"}",
"}",
"else",
"{",
"_globalConfig",
"[",
"prop",
"]",
"=",
"options",
"[",
"prop",
"]",
";",
"}",
"}",
"}",
")",
";",
"}",
"if",
"(",
"typeof",
"options",
"===",
"\"string\"",
"&&",
"options",
")",
"{",
"if",
"(",
"_hasOwn",
".",
"call",
"(",
"_globalConfig",
",",
"options",
")",
")",
"{",
"return",
"_globalConfig",
"[",
"options",
"]",
";",
"}",
"return",
";",
"}",
"return",
"_deepCopy",
"(",
"_globalConfig",
")",
";",
"}"
] |
The underlying implementation of `ZeroClipboard.config`.
@private
|
[
"The",
"underlying",
"implementation",
"of",
"ZeroClipboard",
".",
"config",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L437-L462
|
|
11,039
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function() {
_detectSandbox();
return {
browser: _extend(_pick(_navigator, [ "userAgent", "platform", "appName", "appVersion" ]), {
isSupported: _isBrowserSupported()
}),
flash: _omit(_flashState, [ "bridge" ]),
zeroclipboard: {
version: ZeroClipboard.version,
config: ZeroClipboard.config()
}
};
}
|
javascript
|
function() {
_detectSandbox();
return {
browser: _extend(_pick(_navigator, [ "userAgent", "platform", "appName", "appVersion" ]), {
isSupported: _isBrowserSupported()
}),
flash: _omit(_flashState, [ "bridge" ]),
zeroclipboard: {
version: ZeroClipboard.version,
config: ZeroClipboard.config()
}
};
}
|
[
"function",
"(",
")",
"{",
"_detectSandbox",
"(",
")",
";",
"return",
"{",
"browser",
":",
"_extend",
"(",
"_pick",
"(",
"_navigator",
",",
"[",
"\"userAgent\"",
",",
"\"platform\"",
",",
"\"appName\"",
",",
"\"appVersion\"",
"]",
")",
",",
"{",
"isSupported",
":",
"_isBrowserSupported",
"(",
")",
"}",
")",
",",
"flash",
":",
"_omit",
"(",
"_flashState",
",",
"[",
"\"bridge\"",
"]",
")",
",",
"zeroclipboard",
":",
"{",
"version",
":",
"ZeroClipboard",
".",
"version",
",",
"config",
":",
"ZeroClipboard",
".",
"config",
"(",
")",
"}",
"}",
";",
"}"
] |
The underlying implementation of `ZeroClipboard.state`.
@private
|
[
"The",
"underlying",
"implementation",
"of",
"ZeroClipboard",
".",
"state",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L467-L479
|
|
11,040
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function() {
return !!(_flashState.sandboxed || _flashState.disabled || _flashState.outdated || _flashState.unavailable || _flashState.degraded || _flashState.deactivated);
}
|
javascript
|
function() {
return !!(_flashState.sandboxed || _flashState.disabled || _flashState.outdated || _flashState.unavailable || _flashState.degraded || _flashState.deactivated);
}
|
[
"function",
"(",
")",
"{",
"return",
"!",
"!",
"(",
"_flashState",
".",
"sandboxed",
"||",
"_flashState",
".",
"disabled",
"||",
"_flashState",
".",
"outdated",
"||",
"_flashState",
".",
"unavailable",
"||",
"_flashState",
".",
"degraded",
"||",
"_flashState",
".",
"deactivated",
")",
";",
"}"
] |
The underlying implementation of `ZeroClipboard.isFlashUnusable`.
@private
|
[
"The",
"underlying",
"implementation",
"of",
"ZeroClipboard",
".",
"isFlashUnusable",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L491-L493
|
|
11,041
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(eventType, listener) {
var i, len, events, added = {};
if (typeof eventType === "string" && eventType) {
events = eventType.toLowerCase().split(/\s+/);
} else if (typeof eventType === "object" && eventType && !("length" in eventType) && typeof listener === "undefined") {
_keys(eventType).forEach(function(key) {
var listener = eventType[key];
if (typeof listener === "function") {
ZeroClipboard.on(key, listener);
}
});
}
if (events && events.length && listener) {
for (i = 0, len = events.length; i < len; i++) {
eventType = events[i].replace(/^on/, "");
added[eventType] = true;
if (!_handlers[eventType]) {
_handlers[eventType] = [];
}
_handlers[eventType].push(listener);
}
if (added.ready && _flashState.ready) {
ZeroClipboard.emit({
type: "ready"
});
}
if (added.error) {
if (!_isBrowserSupported()) {
ZeroClipboard.emit({
type: "error",
name: "browser-unsupported"
});
}
for (i = 0, len = _flashStateErrorNames.length; i < len; i++) {
if (_flashState[_flashStateErrorNames[i].replace(/^flash-/, "")] === true) {
ZeroClipboard.emit({
type: "error",
name: _flashStateErrorNames[i]
});
break;
}
}
if (_zcSwfVersion !== undefined && ZeroClipboard.version !== _zcSwfVersion) {
ZeroClipboard.emit({
type: "error",
name: "version-mismatch",
jsVersion: ZeroClipboard.version,
swfVersion: _zcSwfVersion
});
}
}
}
return ZeroClipboard;
}
|
javascript
|
function(eventType, listener) {
var i, len, events, added = {};
if (typeof eventType === "string" && eventType) {
events = eventType.toLowerCase().split(/\s+/);
} else if (typeof eventType === "object" && eventType && !("length" in eventType) && typeof listener === "undefined") {
_keys(eventType).forEach(function(key) {
var listener = eventType[key];
if (typeof listener === "function") {
ZeroClipboard.on(key, listener);
}
});
}
if (events && events.length && listener) {
for (i = 0, len = events.length; i < len; i++) {
eventType = events[i].replace(/^on/, "");
added[eventType] = true;
if (!_handlers[eventType]) {
_handlers[eventType] = [];
}
_handlers[eventType].push(listener);
}
if (added.ready && _flashState.ready) {
ZeroClipboard.emit({
type: "ready"
});
}
if (added.error) {
if (!_isBrowserSupported()) {
ZeroClipboard.emit({
type: "error",
name: "browser-unsupported"
});
}
for (i = 0, len = _flashStateErrorNames.length; i < len; i++) {
if (_flashState[_flashStateErrorNames[i].replace(/^flash-/, "")] === true) {
ZeroClipboard.emit({
type: "error",
name: _flashStateErrorNames[i]
});
break;
}
}
if (_zcSwfVersion !== undefined && ZeroClipboard.version !== _zcSwfVersion) {
ZeroClipboard.emit({
type: "error",
name: "version-mismatch",
jsVersion: ZeroClipboard.version,
swfVersion: _zcSwfVersion
});
}
}
}
return ZeroClipboard;
}
|
[
"function",
"(",
"eventType",
",",
"listener",
")",
"{",
"var",
"i",
",",
"len",
",",
"events",
",",
"added",
"=",
"{",
"}",
";",
"if",
"(",
"typeof",
"eventType",
"===",
"\"string\"",
"&&",
"eventType",
")",
"{",
"events",
"=",
"eventType",
".",
"toLowerCase",
"(",
")",
".",
"split",
"(",
"/",
"\\s+",
"/",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"eventType",
"===",
"\"object\"",
"&&",
"eventType",
"&&",
"!",
"(",
"\"length\"",
"in",
"eventType",
")",
"&&",
"typeof",
"listener",
"===",
"\"undefined\"",
")",
"{",
"_keys",
"(",
"eventType",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"var",
"listener",
"=",
"eventType",
"[",
"key",
"]",
";",
"if",
"(",
"typeof",
"listener",
"===",
"\"function\"",
")",
"{",
"ZeroClipboard",
".",
"on",
"(",
"key",
",",
"listener",
")",
";",
"}",
"}",
")",
";",
"}",
"if",
"(",
"events",
"&&",
"events",
".",
"length",
"&&",
"listener",
")",
"{",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"events",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"eventType",
"=",
"events",
"[",
"i",
"]",
".",
"replace",
"(",
"/",
"^on",
"/",
",",
"\"\"",
")",
";",
"added",
"[",
"eventType",
"]",
"=",
"true",
";",
"if",
"(",
"!",
"_handlers",
"[",
"eventType",
"]",
")",
"{",
"_handlers",
"[",
"eventType",
"]",
"=",
"[",
"]",
";",
"}",
"_handlers",
"[",
"eventType",
"]",
".",
"push",
"(",
"listener",
")",
";",
"}",
"if",
"(",
"added",
".",
"ready",
"&&",
"_flashState",
".",
"ready",
")",
"{",
"ZeroClipboard",
".",
"emit",
"(",
"{",
"type",
":",
"\"ready\"",
"}",
")",
";",
"}",
"if",
"(",
"added",
".",
"error",
")",
"{",
"if",
"(",
"!",
"_isBrowserSupported",
"(",
")",
")",
"{",
"ZeroClipboard",
".",
"emit",
"(",
"{",
"type",
":",
"\"error\"",
",",
"name",
":",
"\"browser-unsupported\"",
"}",
")",
";",
"}",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"_flashStateErrorNames",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"_flashState",
"[",
"_flashStateErrorNames",
"[",
"i",
"]",
".",
"replace",
"(",
"/",
"^flash-",
"/",
",",
"\"\"",
")",
"]",
"===",
"true",
")",
"{",
"ZeroClipboard",
".",
"emit",
"(",
"{",
"type",
":",
"\"error\"",
",",
"name",
":",
"_flashStateErrorNames",
"[",
"i",
"]",
"}",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"_zcSwfVersion",
"!==",
"undefined",
"&&",
"ZeroClipboard",
".",
"version",
"!==",
"_zcSwfVersion",
")",
"{",
"ZeroClipboard",
".",
"emit",
"(",
"{",
"type",
":",
"\"error\"",
",",
"name",
":",
"\"version-mismatch\"",
",",
"jsVersion",
":",
"ZeroClipboard",
".",
"version",
",",
"swfVersion",
":",
"_zcSwfVersion",
"}",
")",
";",
"}",
"}",
"}",
"return",
"ZeroClipboard",
";",
"}"
] |
The underlying implementation of `ZeroClipboard.on`.
@private
|
[
"The",
"underlying",
"implementation",
"of",
"ZeroClipboard",
".",
"on",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L498-L551
|
|
11,042
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(eventType, listener) {
var i, len, foundIndex, events, perEventHandlers;
if (arguments.length === 0) {
events = _keys(_handlers);
} else if (typeof eventType === "string" && eventType) {
events = eventType.toLowerCase().split(/\s+/);
} else if (typeof eventType === "object" && eventType && !("length" in eventType) && typeof listener === "undefined") {
_keys(eventType).forEach(function(key) {
var listener = eventType[key];
if (typeof listener === "function") {
ZeroClipboard.off(key, listener);
}
});
}
if (events && events.length) {
for (i = 0, len = events.length; i < len; i++) {
eventType = events[i].replace(/^on/, "");
perEventHandlers = _handlers[eventType];
if (perEventHandlers && perEventHandlers.length) {
if (listener) {
foundIndex = perEventHandlers.indexOf(listener);
while (foundIndex !== -1) {
perEventHandlers.splice(foundIndex, 1);
foundIndex = perEventHandlers.indexOf(listener, foundIndex);
}
} else {
perEventHandlers.length = 0;
}
}
}
}
return ZeroClipboard;
}
|
javascript
|
function(eventType, listener) {
var i, len, foundIndex, events, perEventHandlers;
if (arguments.length === 0) {
events = _keys(_handlers);
} else if (typeof eventType === "string" && eventType) {
events = eventType.toLowerCase().split(/\s+/);
} else if (typeof eventType === "object" && eventType && !("length" in eventType) && typeof listener === "undefined") {
_keys(eventType).forEach(function(key) {
var listener = eventType[key];
if (typeof listener === "function") {
ZeroClipboard.off(key, listener);
}
});
}
if (events && events.length) {
for (i = 0, len = events.length; i < len; i++) {
eventType = events[i].replace(/^on/, "");
perEventHandlers = _handlers[eventType];
if (perEventHandlers && perEventHandlers.length) {
if (listener) {
foundIndex = perEventHandlers.indexOf(listener);
while (foundIndex !== -1) {
perEventHandlers.splice(foundIndex, 1);
foundIndex = perEventHandlers.indexOf(listener, foundIndex);
}
} else {
perEventHandlers.length = 0;
}
}
}
}
return ZeroClipboard;
}
|
[
"function",
"(",
"eventType",
",",
"listener",
")",
"{",
"var",
"i",
",",
"len",
",",
"foundIndex",
",",
"events",
",",
"perEventHandlers",
";",
"if",
"(",
"arguments",
".",
"length",
"===",
"0",
")",
"{",
"events",
"=",
"_keys",
"(",
"_handlers",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"eventType",
"===",
"\"string\"",
"&&",
"eventType",
")",
"{",
"events",
"=",
"eventType",
".",
"toLowerCase",
"(",
")",
".",
"split",
"(",
"/",
"\\s+",
"/",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"eventType",
"===",
"\"object\"",
"&&",
"eventType",
"&&",
"!",
"(",
"\"length\"",
"in",
"eventType",
")",
"&&",
"typeof",
"listener",
"===",
"\"undefined\"",
")",
"{",
"_keys",
"(",
"eventType",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"var",
"listener",
"=",
"eventType",
"[",
"key",
"]",
";",
"if",
"(",
"typeof",
"listener",
"===",
"\"function\"",
")",
"{",
"ZeroClipboard",
".",
"off",
"(",
"key",
",",
"listener",
")",
";",
"}",
"}",
")",
";",
"}",
"if",
"(",
"events",
"&&",
"events",
".",
"length",
")",
"{",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"events",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"eventType",
"=",
"events",
"[",
"i",
"]",
".",
"replace",
"(",
"/",
"^on",
"/",
",",
"\"\"",
")",
";",
"perEventHandlers",
"=",
"_handlers",
"[",
"eventType",
"]",
";",
"if",
"(",
"perEventHandlers",
"&&",
"perEventHandlers",
".",
"length",
")",
"{",
"if",
"(",
"listener",
")",
"{",
"foundIndex",
"=",
"perEventHandlers",
".",
"indexOf",
"(",
"listener",
")",
";",
"while",
"(",
"foundIndex",
"!==",
"-",
"1",
")",
"{",
"perEventHandlers",
".",
"splice",
"(",
"foundIndex",
",",
"1",
")",
";",
"foundIndex",
"=",
"perEventHandlers",
".",
"indexOf",
"(",
"listener",
",",
"foundIndex",
")",
";",
"}",
"}",
"else",
"{",
"perEventHandlers",
".",
"length",
"=",
"0",
";",
"}",
"}",
"}",
"}",
"return",
"ZeroClipboard",
";",
"}"
] |
The underlying implementation of `ZeroClipboard.off`.
@private
|
[
"The",
"underlying",
"implementation",
"of",
"ZeroClipboard",
".",
"off",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L556-L588
|
|
11,043
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(eventType) {
var copy;
if (typeof eventType === "string" && eventType) {
copy = _deepCopy(_handlers[eventType]) || null;
} else {
copy = _deepCopy(_handlers);
}
return copy;
}
|
javascript
|
function(eventType) {
var copy;
if (typeof eventType === "string" && eventType) {
copy = _deepCopy(_handlers[eventType]) || null;
} else {
copy = _deepCopy(_handlers);
}
return copy;
}
|
[
"function",
"(",
"eventType",
")",
"{",
"var",
"copy",
";",
"if",
"(",
"typeof",
"eventType",
"===",
"\"string\"",
"&&",
"eventType",
")",
"{",
"copy",
"=",
"_deepCopy",
"(",
"_handlers",
"[",
"eventType",
"]",
")",
"||",
"null",
";",
"}",
"else",
"{",
"copy",
"=",
"_deepCopy",
"(",
"_handlers",
")",
";",
"}",
"return",
"copy",
";",
"}"
] |
The underlying implementation of `ZeroClipboard.handlers`.
@private
|
[
"The",
"underlying",
"implementation",
"of",
"ZeroClipboard",
".",
"handlers",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L593-L601
|
|
11,044
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(event) {
var eventCopy, returnVal, tmp;
event = _createEvent(event);
if (!event) {
return;
}
if (_preprocessEvent(event)) {
return;
}
if (event.type === "ready" && _flashState.overdue === true) {
return ZeroClipboard.emit({
type: "error",
name: "flash-overdue"
});
}
eventCopy = _extend({}, event);
_dispatchCallbacks.call(this, eventCopy);
if (event.type === "copy") {
tmp = _mapClipDataToFlash(_clipData);
returnVal = tmp.data;
_clipDataFormatMap = tmp.formatMap;
}
return returnVal;
}
|
javascript
|
function(event) {
var eventCopy, returnVal, tmp;
event = _createEvent(event);
if (!event) {
return;
}
if (_preprocessEvent(event)) {
return;
}
if (event.type === "ready" && _flashState.overdue === true) {
return ZeroClipboard.emit({
type: "error",
name: "flash-overdue"
});
}
eventCopy = _extend({}, event);
_dispatchCallbacks.call(this, eventCopy);
if (event.type === "copy") {
tmp = _mapClipDataToFlash(_clipData);
returnVal = tmp.data;
_clipDataFormatMap = tmp.formatMap;
}
return returnVal;
}
|
[
"function",
"(",
"event",
")",
"{",
"var",
"eventCopy",
",",
"returnVal",
",",
"tmp",
";",
"event",
"=",
"_createEvent",
"(",
"event",
")",
";",
"if",
"(",
"!",
"event",
")",
"{",
"return",
";",
"}",
"if",
"(",
"_preprocessEvent",
"(",
"event",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"event",
".",
"type",
"===",
"\"ready\"",
"&&",
"_flashState",
".",
"overdue",
"===",
"true",
")",
"{",
"return",
"ZeroClipboard",
".",
"emit",
"(",
"{",
"type",
":",
"\"error\"",
",",
"name",
":",
"\"flash-overdue\"",
"}",
")",
";",
"}",
"eventCopy",
"=",
"_extend",
"(",
"{",
"}",
",",
"event",
")",
";",
"_dispatchCallbacks",
".",
"call",
"(",
"this",
",",
"eventCopy",
")",
";",
"if",
"(",
"event",
".",
"type",
"===",
"\"copy\"",
")",
"{",
"tmp",
"=",
"_mapClipDataToFlash",
"(",
"_clipData",
")",
";",
"returnVal",
"=",
"tmp",
".",
"data",
";",
"_clipDataFormatMap",
"=",
"tmp",
".",
"formatMap",
";",
"}",
"return",
"returnVal",
";",
"}"
] |
The underlying implementation of `ZeroClipboard.emit`.
@private
|
[
"The",
"underlying",
"implementation",
"of",
"ZeroClipboard",
".",
"emit",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L606-L629
|
|
11,045
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function() {
var swfPath = _globalConfig.swfPath || "", swfPathFirstTwoChars = swfPath.slice(0, 2), swfProtocol = swfPath.slice(0, swfPath.indexOf("://") + 1);
return swfPathFirstTwoChars === "\\\\" ? "file:" : swfPathFirstTwoChars === "//" || swfProtocol === "" ? _window.location.protocol : swfProtocol;
}
|
javascript
|
function() {
var swfPath = _globalConfig.swfPath || "", swfPathFirstTwoChars = swfPath.slice(0, 2), swfProtocol = swfPath.slice(0, swfPath.indexOf("://") + 1);
return swfPathFirstTwoChars === "\\\\" ? "file:" : swfPathFirstTwoChars === "//" || swfProtocol === "" ? _window.location.protocol : swfProtocol;
}
|
[
"function",
"(",
")",
"{",
"var",
"swfPath",
"=",
"_globalConfig",
".",
"swfPath",
"||",
"\"\"",
",",
"swfPathFirstTwoChars",
"=",
"swfPath",
".",
"slice",
"(",
"0",
",",
"2",
")",
",",
"swfProtocol",
"=",
"swfPath",
".",
"slice",
"(",
"0",
",",
"swfPath",
".",
"indexOf",
"(",
"\"://\"",
")",
"+",
"1",
")",
";",
"return",
"swfPathFirstTwoChars",
"===",
"\"\\\\\\\\\"",
"?",
"\"file:\"",
":",
"swfPathFirstTwoChars",
"===",
"\"//\"",
"||",
"swfProtocol",
"===",
"\"\"",
"?",
"_window",
".",
"location",
".",
"protocol",
":",
"swfProtocol",
";",
"}"
] |
Get the protocol of the configured SWF path.
@private
|
[
"Get",
"the",
"protocol",
"of",
"the",
"configured",
"SWF",
"path",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L634-L637
|
|
11,046
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function() {
var maxWait, swfProtocol, previousState = _flashState.sandboxed;
if (!_isBrowserSupported()) {
_flashState.ready = false;
ZeroClipboard.emit({
type: "error",
name: "browser-unsupported"
});
return;
}
_detectSandbox();
if (typeof _flashState.ready !== "boolean") {
_flashState.ready = false;
}
if (_flashState.sandboxed !== previousState && _flashState.sandboxed === true) {
_flashState.ready = false;
ZeroClipboard.emit({
type: "error",
name: "flash-sandboxed"
});
} else if (!ZeroClipboard.isFlashUnusable() && _flashState.bridge === null) {
swfProtocol = _getSwfPathProtocol();
if (swfProtocol && swfProtocol !== _window.location.protocol) {
ZeroClipboard.emit({
type: "error",
name: "flash-insecure"
});
} else {
maxWait = _globalConfig.flashLoadTimeout;
if (typeof maxWait === "number" && maxWait >= 0) {
_flashCheckTimeout = _setTimeout(function() {
if (typeof _flashState.deactivated !== "boolean") {
_flashState.deactivated = true;
}
if (_flashState.deactivated === true) {
ZeroClipboard.emit({
type: "error",
name: "flash-deactivated"
});
}
}, maxWait);
}
_flashState.overdue = false;
_embedSwf();
}
}
}
|
javascript
|
function() {
var maxWait, swfProtocol, previousState = _flashState.sandboxed;
if (!_isBrowserSupported()) {
_flashState.ready = false;
ZeroClipboard.emit({
type: "error",
name: "browser-unsupported"
});
return;
}
_detectSandbox();
if (typeof _flashState.ready !== "boolean") {
_flashState.ready = false;
}
if (_flashState.sandboxed !== previousState && _flashState.sandboxed === true) {
_flashState.ready = false;
ZeroClipboard.emit({
type: "error",
name: "flash-sandboxed"
});
} else if (!ZeroClipboard.isFlashUnusable() && _flashState.bridge === null) {
swfProtocol = _getSwfPathProtocol();
if (swfProtocol && swfProtocol !== _window.location.protocol) {
ZeroClipboard.emit({
type: "error",
name: "flash-insecure"
});
} else {
maxWait = _globalConfig.flashLoadTimeout;
if (typeof maxWait === "number" && maxWait >= 0) {
_flashCheckTimeout = _setTimeout(function() {
if (typeof _flashState.deactivated !== "boolean") {
_flashState.deactivated = true;
}
if (_flashState.deactivated === true) {
ZeroClipboard.emit({
type: "error",
name: "flash-deactivated"
});
}
}, maxWait);
}
_flashState.overdue = false;
_embedSwf();
}
}
}
|
[
"function",
"(",
")",
"{",
"var",
"maxWait",
",",
"swfProtocol",
",",
"previousState",
"=",
"_flashState",
".",
"sandboxed",
";",
"if",
"(",
"!",
"_isBrowserSupported",
"(",
")",
")",
"{",
"_flashState",
".",
"ready",
"=",
"false",
";",
"ZeroClipboard",
".",
"emit",
"(",
"{",
"type",
":",
"\"error\"",
",",
"name",
":",
"\"browser-unsupported\"",
"}",
")",
";",
"return",
";",
"}",
"_detectSandbox",
"(",
")",
";",
"if",
"(",
"typeof",
"_flashState",
".",
"ready",
"!==",
"\"boolean\"",
")",
"{",
"_flashState",
".",
"ready",
"=",
"false",
";",
"}",
"if",
"(",
"_flashState",
".",
"sandboxed",
"!==",
"previousState",
"&&",
"_flashState",
".",
"sandboxed",
"===",
"true",
")",
"{",
"_flashState",
".",
"ready",
"=",
"false",
";",
"ZeroClipboard",
".",
"emit",
"(",
"{",
"type",
":",
"\"error\"",
",",
"name",
":",
"\"flash-sandboxed\"",
"}",
")",
";",
"}",
"else",
"if",
"(",
"!",
"ZeroClipboard",
".",
"isFlashUnusable",
"(",
")",
"&&",
"_flashState",
".",
"bridge",
"===",
"null",
")",
"{",
"swfProtocol",
"=",
"_getSwfPathProtocol",
"(",
")",
";",
"if",
"(",
"swfProtocol",
"&&",
"swfProtocol",
"!==",
"_window",
".",
"location",
".",
"protocol",
")",
"{",
"ZeroClipboard",
".",
"emit",
"(",
"{",
"type",
":",
"\"error\"",
",",
"name",
":",
"\"flash-insecure\"",
"}",
")",
";",
"}",
"else",
"{",
"maxWait",
"=",
"_globalConfig",
".",
"flashLoadTimeout",
";",
"if",
"(",
"typeof",
"maxWait",
"===",
"\"number\"",
"&&",
"maxWait",
">=",
"0",
")",
"{",
"_flashCheckTimeout",
"=",
"_setTimeout",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"typeof",
"_flashState",
".",
"deactivated",
"!==",
"\"boolean\"",
")",
"{",
"_flashState",
".",
"deactivated",
"=",
"true",
";",
"}",
"if",
"(",
"_flashState",
".",
"deactivated",
"===",
"true",
")",
"{",
"ZeroClipboard",
".",
"emit",
"(",
"{",
"type",
":",
"\"error\"",
",",
"name",
":",
"\"flash-deactivated\"",
"}",
")",
";",
"}",
"}",
",",
"maxWait",
")",
";",
"}",
"_flashState",
".",
"overdue",
"=",
"false",
";",
"_embedSwf",
"(",
")",
";",
"}",
"}",
"}"
] |
The underlying implementation of `ZeroClipboard.create`.
@private
|
[
"The",
"underlying",
"implementation",
"of",
"ZeroClipboard",
".",
"create",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L642-L688
|
|
11,047
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(format, data) {
var dataObj;
if (typeof format === "object" && format && typeof data === "undefined") {
dataObj = format;
ZeroClipboard.clearData();
} else if (typeof format === "string" && format) {
dataObj = {};
dataObj[format] = data;
} else {
return;
}
for (var dataFormat in dataObj) {
if (typeof dataFormat === "string" && dataFormat && _hasOwn.call(dataObj, dataFormat) && typeof dataObj[dataFormat] === "string" && dataObj[dataFormat]) {
_clipData[dataFormat] = _fixLineEndings(dataObj[dataFormat]);
}
}
}
|
javascript
|
function(format, data) {
var dataObj;
if (typeof format === "object" && format && typeof data === "undefined") {
dataObj = format;
ZeroClipboard.clearData();
} else if (typeof format === "string" && format) {
dataObj = {};
dataObj[format] = data;
} else {
return;
}
for (var dataFormat in dataObj) {
if (typeof dataFormat === "string" && dataFormat && _hasOwn.call(dataObj, dataFormat) && typeof dataObj[dataFormat] === "string" && dataObj[dataFormat]) {
_clipData[dataFormat] = _fixLineEndings(dataObj[dataFormat]);
}
}
}
|
[
"function",
"(",
"format",
",",
"data",
")",
"{",
"var",
"dataObj",
";",
"if",
"(",
"typeof",
"format",
"===",
"\"object\"",
"&&",
"format",
"&&",
"typeof",
"data",
"===",
"\"undefined\"",
")",
"{",
"dataObj",
"=",
"format",
";",
"ZeroClipboard",
".",
"clearData",
"(",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"format",
"===",
"\"string\"",
"&&",
"format",
")",
"{",
"dataObj",
"=",
"{",
"}",
";",
"dataObj",
"[",
"format",
"]",
"=",
"data",
";",
"}",
"else",
"{",
"return",
";",
"}",
"for",
"(",
"var",
"dataFormat",
"in",
"dataObj",
")",
"{",
"if",
"(",
"typeof",
"dataFormat",
"===",
"\"string\"",
"&&",
"dataFormat",
"&&",
"_hasOwn",
".",
"call",
"(",
"dataObj",
",",
"dataFormat",
")",
"&&",
"typeof",
"dataObj",
"[",
"dataFormat",
"]",
"===",
"\"string\"",
"&&",
"dataObj",
"[",
"dataFormat",
"]",
")",
"{",
"_clipData",
"[",
"dataFormat",
"]",
"=",
"_fixLineEndings",
"(",
"dataObj",
"[",
"dataFormat",
"]",
")",
";",
"}",
"}",
"}"
] |
The underlying implementation of `ZeroClipboard.setData`.
@private
|
[
"The",
"underlying",
"implementation",
"of",
"ZeroClipboard",
".",
"setData",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L704-L720
|
|
11,048
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(format) {
if (typeof format === "undefined") {
_deleteOwnProperties(_clipData);
_clipDataFormatMap = null;
} else if (typeof format === "string" && _hasOwn.call(_clipData, format)) {
delete _clipData[format];
}
}
|
javascript
|
function(format) {
if (typeof format === "undefined") {
_deleteOwnProperties(_clipData);
_clipDataFormatMap = null;
} else if (typeof format === "string" && _hasOwn.call(_clipData, format)) {
delete _clipData[format];
}
}
|
[
"function",
"(",
"format",
")",
"{",
"if",
"(",
"typeof",
"format",
"===",
"\"undefined\"",
")",
"{",
"_deleteOwnProperties",
"(",
"_clipData",
")",
";",
"_clipDataFormatMap",
"=",
"null",
";",
"}",
"else",
"if",
"(",
"typeof",
"format",
"===",
"\"string\"",
"&&",
"_hasOwn",
".",
"call",
"(",
"_clipData",
",",
"format",
")",
")",
"{",
"delete",
"_clipData",
"[",
"format",
"]",
";",
"}",
"}"
] |
The underlying implementation of `ZeroClipboard.clearData`.
@private
|
[
"The",
"underlying",
"implementation",
"of",
"ZeroClipboard",
".",
"clearData",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L725-L732
|
|
11,049
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(format) {
if (typeof format === "undefined") {
return _deepCopy(_clipData);
} else if (typeof format === "string" && _hasOwn.call(_clipData, format)) {
return _clipData[format];
}
}
|
javascript
|
function(format) {
if (typeof format === "undefined") {
return _deepCopy(_clipData);
} else if (typeof format === "string" && _hasOwn.call(_clipData, format)) {
return _clipData[format];
}
}
|
[
"function",
"(",
"format",
")",
"{",
"if",
"(",
"typeof",
"format",
"===",
"\"undefined\"",
")",
"{",
"return",
"_deepCopy",
"(",
"_clipData",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"format",
"===",
"\"string\"",
"&&",
"_hasOwn",
".",
"call",
"(",
"_clipData",
",",
"format",
")",
")",
"{",
"return",
"_clipData",
"[",
"format",
"]",
";",
"}",
"}"
] |
The underlying implementation of `ZeroClipboard.getData`.
@private
|
[
"The",
"underlying",
"implementation",
"of",
"ZeroClipboard",
".",
"getData",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L737-L743
|
|
11,050
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(event) {
var eventType;
if (typeof event === "string" && event) {
eventType = event;
event = {};
} else if (typeof event === "object" && event && typeof event.type === "string" && event.type) {
eventType = event.type;
}
if (!eventType) {
return;
}
eventType = eventType.toLowerCase();
if (!event.target && (/^(copy|aftercopy|_click)$/.test(eventType) || eventType === "error" && event.name === "clipboard-error")) {
event.target = _copyTarget;
}
_extend(event, {
type: eventType,
target: event.target || _currentElement || null,
relatedTarget: event.relatedTarget || null,
currentTarget: _flashState && _flashState.bridge || null,
timeStamp: event.timeStamp || _now() || null
});
var msg = _eventMessages[event.type];
if (event.type === "error" && event.name && msg) {
msg = msg[event.name];
}
if (msg) {
event.message = msg;
}
if (event.type === "ready") {
_extend(event, {
target: null,
version: _flashState.version
});
}
if (event.type === "error") {
if (_flashStateErrorNameMatchingRegex.test(event.name)) {
_extend(event, {
target: null,
minimumVersion: _minimumFlashVersion
});
}
if (_flashStateEnabledErrorNameMatchingRegex.test(event.name)) {
_extend(event, {
version: _flashState.version
});
}
if (event.name === "flash-insecure") {
_extend(event, {
pageProtocol: _window.location.protocol,
swfProtocol: _getSwfPathProtocol()
});
}
}
if (event.type === "copy") {
event.clipboardData = {
setData: ZeroClipboard.setData,
clearData: ZeroClipboard.clearData
};
}
if (event.type === "aftercopy") {
event = _mapClipResultsFromFlash(event, _clipDataFormatMap);
}
if (event.target && !event.relatedTarget) {
event.relatedTarget = _getRelatedTarget(event.target);
}
return _addMouseData(event);
}
|
javascript
|
function(event) {
var eventType;
if (typeof event === "string" && event) {
eventType = event;
event = {};
} else if (typeof event === "object" && event && typeof event.type === "string" && event.type) {
eventType = event.type;
}
if (!eventType) {
return;
}
eventType = eventType.toLowerCase();
if (!event.target && (/^(copy|aftercopy|_click)$/.test(eventType) || eventType === "error" && event.name === "clipboard-error")) {
event.target = _copyTarget;
}
_extend(event, {
type: eventType,
target: event.target || _currentElement || null,
relatedTarget: event.relatedTarget || null,
currentTarget: _flashState && _flashState.bridge || null,
timeStamp: event.timeStamp || _now() || null
});
var msg = _eventMessages[event.type];
if (event.type === "error" && event.name && msg) {
msg = msg[event.name];
}
if (msg) {
event.message = msg;
}
if (event.type === "ready") {
_extend(event, {
target: null,
version: _flashState.version
});
}
if (event.type === "error") {
if (_flashStateErrorNameMatchingRegex.test(event.name)) {
_extend(event, {
target: null,
minimumVersion: _minimumFlashVersion
});
}
if (_flashStateEnabledErrorNameMatchingRegex.test(event.name)) {
_extend(event, {
version: _flashState.version
});
}
if (event.name === "flash-insecure") {
_extend(event, {
pageProtocol: _window.location.protocol,
swfProtocol: _getSwfPathProtocol()
});
}
}
if (event.type === "copy") {
event.clipboardData = {
setData: ZeroClipboard.setData,
clearData: ZeroClipboard.clearData
};
}
if (event.type === "aftercopy") {
event = _mapClipResultsFromFlash(event, _clipDataFormatMap);
}
if (event.target && !event.relatedTarget) {
event.relatedTarget = _getRelatedTarget(event.target);
}
return _addMouseData(event);
}
|
[
"function",
"(",
"event",
")",
"{",
"var",
"eventType",
";",
"if",
"(",
"typeof",
"event",
"===",
"\"string\"",
"&&",
"event",
")",
"{",
"eventType",
"=",
"event",
";",
"event",
"=",
"{",
"}",
";",
"}",
"else",
"if",
"(",
"typeof",
"event",
"===",
"\"object\"",
"&&",
"event",
"&&",
"typeof",
"event",
".",
"type",
"===",
"\"string\"",
"&&",
"event",
".",
"type",
")",
"{",
"eventType",
"=",
"event",
".",
"type",
";",
"}",
"if",
"(",
"!",
"eventType",
")",
"{",
"return",
";",
"}",
"eventType",
"=",
"eventType",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"!",
"event",
".",
"target",
"&&",
"(",
"/",
"^(copy|aftercopy|_click)$",
"/",
".",
"test",
"(",
"eventType",
")",
"||",
"eventType",
"===",
"\"error\"",
"&&",
"event",
".",
"name",
"===",
"\"clipboard-error\"",
")",
")",
"{",
"event",
".",
"target",
"=",
"_copyTarget",
";",
"}",
"_extend",
"(",
"event",
",",
"{",
"type",
":",
"eventType",
",",
"target",
":",
"event",
".",
"target",
"||",
"_currentElement",
"||",
"null",
",",
"relatedTarget",
":",
"event",
".",
"relatedTarget",
"||",
"null",
",",
"currentTarget",
":",
"_flashState",
"&&",
"_flashState",
".",
"bridge",
"||",
"null",
",",
"timeStamp",
":",
"event",
".",
"timeStamp",
"||",
"_now",
"(",
")",
"||",
"null",
"}",
")",
";",
"var",
"msg",
"=",
"_eventMessages",
"[",
"event",
".",
"type",
"]",
";",
"if",
"(",
"event",
".",
"type",
"===",
"\"error\"",
"&&",
"event",
".",
"name",
"&&",
"msg",
")",
"{",
"msg",
"=",
"msg",
"[",
"event",
".",
"name",
"]",
";",
"}",
"if",
"(",
"msg",
")",
"{",
"event",
".",
"message",
"=",
"msg",
";",
"}",
"if",
"(",
"event",
".",
"type",
"===",
"\"ready\"",
")",
"{",
"_extend",
"(",
"event",
",",
"{",
"target",
":",
"null",
",",
"version",
":",
"_flashState",
".",
"version",
"}",
")",
";",
"}",
"if",
"(",
"event",
".",
"type",
"===",
"\"error\"",
")",
"{",
"if",
"(",
"_flashStateErrorNameMatchingRegex",
".",
"test",
"(",
"event",
".",
"name",
")",
")",
"{",
"_extend",
"(",
"event",
",",
"{",
"target",
":",
"null",
",",
"minimumVersion",
":",
"_minimumFlashVersion",
"}",
")",
";",
"}",
"if",
"(",
"_flashStateEnabledErrorNameMatchingRegex",
".",
"test",
"(",
"event",
".",
"name",
")",
")",
"{",
"_extend",
"(",
"event",
",",
"{",
"version",
":",
"_flashState",
".",
"version",
"}",
")",
";",
"}",
"if",
"(",
"event",
".",
"name",
"===",
"\"flash-insecure\"",
")",
"{",
"_extend",
"(",
"event",
",",
"{",
"pageProtocol",
":",
"_window",
".",
"location",
".",
"protocol",
",",
"swfProtocol",
":",
"_getSwfPathProtocol",
"(",
")",
"}",
")",
";",
"}",
"}",
"if",
"(",
"event",
".",
"type",
"===",
"\"copy\"",
")",
"{",
"event",
".",
"clipboardData",
"=",
"{",
"setData",
":",
"ZeroClipboard",
".",
"setData",
",",
"clearData",
":",
"ZeroClipboard",
".",
"clearData",
"}",
";",
"}",
"if",
"(",
"event",
".",
"type",
"===",
"\"aftercopy\"",
")",
"{",
"event",
"=",
"_mapClipResultsFromFlash",
"(",
"event",
",",
"_clipDataFormatMap",
")",
";",
"}",
"if",
"(",
"event",
".",
"target",
"&&",
"!",
"event",
".",
"relatedTarget",
")",
"{",
"event",
".",
"relatedTarget",
"=",
"_getRelatedTarget",
"(",
"event",
".",
"target",
")",
";",
"}",
"return",
"_addMouseData",
"(",
"event",
")",
";",
"}"
] |
Create or update an `event` object, based on the `eventType`.
@private
|
[
"Create",
"or",
"update",
"an",
"event",
"object",
"based",
"on",
"the",
"eventType",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L808-L875
|
|
11,051
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(targetEl) {
var relatedTargetId = targetEl && targetEl.getAttribute && targetEl.getAttribute("data-clipboard-target");
return relatedTargetId ? _document.getElementById(relatedTargetId) : null;
}
|
javascript
|
function(targetEl) {
var relatedTargetId = targetEl && targetEl.getAttribute && targetEl.getAttribute("data-clipboard-target");
return relatedTargetId ? _document.getElementById(relatedTargetId) : null;
}
|
[
"function",
"(",
"targetEl",
")",
"{",
"var",
"relatedTargetId",
"=",
"targetEl",
"&&",
"targetEl",
".",
"getAttribute",
"&&",
"targetEl",
".",
"getAttribute",
"(",
"\"data-clipboard-target\"",
")",
";",
"return",
"relatedTargetId",
"?",
"_document",
".",
"getElementById",
"(",
"relatedTargetId",
")",
":",
"null",
";",
"}"
] |
Get a relatedTarget from the target's `data-clipboard-target` attribute
@private
|
[
"Get",
"a",
"relatedTarget",
"from",
"the",
"target",
"s",
"data",
"-",
"clipboard",
"-",
"target",
"attribute"
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L880-L883
|
|
11,052
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(event) {
if (event && /^_(?:click|mouse(?:over|out|down|up|move))$/.test(event.type)) {
var srcElement = event.target;
var fromElement = event.type === "_mouseover" && event.relatedTarget ? event.relatedTarget : undefined;
var toElement = event.type === "_mouseout" && event.relatedTarget ? event.relatedTarget : undefined;
var pos = _getElementPosition(srcElement);
var screenLeft = _window.screenLeft || _window.screenX || 0;
var screenTop = _window.screenTop || _window.screenY || 0;
var scrollLeft = _document.body.scrollLeft + _document.documentElement.scrollLeft;
var scrollTop = _document.body.scrollTop + _document.documentElement.scrollTop;
var pageX = pos.left + (typeof event._stageX === "number" ? event._stageX : 0);
var pageY = pos.top + (typeof event._stageY === "number" ? event._stageY : 0);
var clientX = pageX - scrollLeft;
var clientY = pageY - scrollTop;
var screenX = screenLeft + clientX;
var screenY = screenTop + clientY;
var moveX = typeof event.movementX === "number" ? event.movementX : 0;
var moveY = typeof event.movementY === "number" ? event.movementY : 0;
delete event._stageX;
delete event._stageY;
_extend(event, {
srcElement: srcElement,
fromElement: fromElement,
toElement: toElement,
screenX: screenX,
screenY: screenY,
pageX: pageX,
pageY: pageY,
clientX: clientX,
clientY: clientY,
x: clientX,
y: clientY,
movementX: moveX,
movementY: moveY,
offsetX: 0,
offsetY: 0,
layerX: 0,
layerY: 0
});
}
return event;
}
|
javascript
|
function(event) {
if (event && /^_(?:click|mouse(?:over|out|down|up|move))$/.test(event.type)) {
var srcElement = event.target;
var fromElement = event.type === "_mouseover" && event.relatedTarget ? event.relatedTarget : undefined;
var toElement = event.type === "_mouseout" && event.relatedTarget ? event.relatedTarget : undefined;
var pos = _getElementPosition(srcElement);
var screenLeft = _window.screenLeft || _window.screenX || 0;
var screenTop = _window.screenTop || _window.screenY || 0;
var scrollLeft = _document.body.scrollLeft + _document.documentElement.scrollLeft;
var scrollTop = _document.body.scrollTop + _document.documentElement.scrollTop;
var pageX = pos.left + (typeof event._stageX === "number" ? event._stageX : 0);
var pageY = pos.top + (typeof event._stageY === "number" ? event._stageY : 0);
var clientX = pageX - scrollLeft;
var clientY = pageY - scrollTop;
var screenX = screenLeft + clientX;
var screenY = screenTop + clientY;
var moveX = typeof event.movementX === "number" ? event.movementX : 0;
var moveY = typeof event.movementY === "number" ? event.movementY : 0;
delete event._stageX;
delete event._stageY;
_extend(event, {
srcElement: srcElement,
fromElement: fromElement,
toElement: toElement,
screenX: screenX,
screenY: screenY,
pageX: pageX,
pageY: pageY,
clientX: clientX,
clientY: clientY,
x: clientX,
y: clientY,
movementX: moveX,
movementY: moveY,
offsetX: 0,
offsetY: 0,
layerX: 0,
layerY: 0
});
}
return event;
}
|
[
"function",
"(",
"event",
")",
"{",
"if",
"(",
"event",
"&&",
"/",
"^_(?:click|mouse(?:over|out|down|up|move))$",
"/",
".",
"test",
"(",
"event",
".",
"type",
")",
")",
"{",
"var",
"srcElement",
"=",
"event",
".",
"target",
";",
"var",
"fromElement",
"=",
"event",
".",
"type",
"===",
"\"_mouseover\"",
"&&",
"event",
".",
"relatedTarget",
"?",
"event",
".",
"relatedTarget",
":",
"undefined",
";",
"var",
"toElement",
"=",
"event",
".",
"type",
"===",
"\"_mouseout\"",
"&&",
"event",
".",
"relatedTarget",
"?",
"event",
".",
"relatedTarget",
":",
"undefined",
";",
"var",
"pos",
"=",
"_getElementPosition",
"(",
"srcElement",
")",
";",
"var",
"screenLeft",
"=",
"_window",
".",
"screenLeft",
"||",
"_window",
".",
"screenX",
"||",
"0",
";",
"var",
"screenTop",
"=",
"_window",
".",
"screenTop",
"||",
"_window",
".",
"screenY",
"||",
"0",
";",
"var",
"scrollLeft",
"=",
"_document",
".",
"body",
".",
"scrollLeft",
"+",
"_document",
".",
"documentElement",
".",
"scrollLeft",
";",
"var",
"scrollTop",
"=",
"_document",
".",
"body",
".",
"scrollTop",
"+",
"_document",
".",
"documentElement",
".",
"scrollTop",
";",
"var",
"pageX",
"=",
"pos",
".",
"left",
"+",
"(",
"typeof",
"event",
".",
"_stageX",
"===",
"\"number\"",
"?",
"event",
".",
"_stageX",
":",
"0",
")",
";",
"var",
"pageY",
"=",
"pos",
".",
"top",
"+",
"(",
"typeof",
"event",
".",
"_stageY",
"===",
"\"number\"",
"?",
"event",
".",
"_stageY",
":",
"0",
")",
";",
"var",
"clientX",
"=",
"pageX",
"-",
"scrollLeft",
";",
"var",
"clientY",
"=",
"pageY",
"-",
"scrollTop",
";",
"var",
"screenX",
"=",
"screenLeft",
"+",
"clientX",
";",
"var",
"screenY",
"=",
"screenTop",
"+",
"clientY",
";",
"var",
"moveX",
"=",
"typeof",
"event",
".",
"movementX",
"===",
"\"number\"",
"?",
"event",
".",
"movementX",
":",
"0",
";",
"var",
"moveY",
"=",
"typeof",
"event",
".",
"movementY",
"===",
"\"number\"",
"?",
"event",
".",
"movementY",
":",
"0",
";",
"delete",
"event",
".",
"_stageX",
";",
"delete",
"event",
".",
"_stageY",
";",
"_extend",
"(",
"event",
",",
"{",
"srcElement",
":",
"srcElement",
",",
"fromElement",
":",
"fromElement",
",",
"toElement",
":",
"toElement",
",",
"screenX",
":",
"screenX",
",",
"screenY",
":",
"screenY",
",",
"pageX",
":",
"pageX",
",",
"pageY",
":",
"pageY",
",",
"clientX",
":",
"clientX",
",",
"clientY",
":",
"clientY",
",",
"x",
":",
"clientX",
",",
"y",
":",
"clientY",
",",
"movementX",
":",
"moveX",
",",
"movementY",
":",
"moveY",
",",
"offsetX",
":",
"0",
",",
"offsetY",
":",
"0",
",",
"layerX",
":",
"0",
",",
"layerY",
":",
"0",
"}",
")",
";",
"}",
"return",
"event",
";",
"}"
] |
Add element and position data to `MouseEvent` instances
@private
|
[
"Add",
"element",
"and",
"position",
"data",
"to",
"MouseEvent",
"instances"
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L888-L929
|
|
11,053
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(func, context, args, async) {
if (async) {
_setTimeout(function() {
func.apply(context, args);
}, 0);
} else {
func.apply(context, args);
}
}
|
javascript
|
function(func, context, args, async) {
if (async) {
_setTimeout(function() {
func.apply(context, args);
}, 0);
} else {
func.apply(context, args);
}
}
|
[
"function",
"(",
"func",
",",
"context",
",",
"args",
",",
"async",
")",
"{",
"if",
"(",
"async",
")",
"{",
"_setTimeout",
"(",
"function",
"(",
")",
"{",
"func",
".",
"apply",
"(",
"context",
",",
"args",
")",
";",
"}",
",",
"0",
")",
";",
"}",
"else",
"{",
"func",
".",
"apply",
"(",
"context",
",",
"args",
")",
";",
"}",
"}"
] |
Control if a callback should be executed asynchronously or not.
@returns `undefined`
@private
|
[
"Control",
"if",
"a",
"callback",
"should",
"be",
"executed",
"asynchronously",
"or",
"not",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L946-L954
|
|
11,054
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(event) {
var isSandboxed = null;
if (_pageIsFramed === false || event && event.type === "error" && event.name && _errorsThatOnlyOccurAfterFlashLoads.indexOf(event.name) !== -1) {
isSandboxed = false;
}
return isSandboxed;
}
|
javascript
|
function(event) {
var isSandboxed = null;
if (_pageIsFramed === false || event && event.type === "error" && event.name && _errorsThatOnlyOccurAfterFlashLoads.indexOf(event.name) !== -1) {
isSandboxed = false;
}
return isSandboxed;
}
|
[
"function",
"(",
"event",
")",
"{",
"var",
"isSandboxed",
"=",
"null",
";",
"if",
"(",
"_pageIsFramed",
"===",
"false",
"||",
"event",
"&&",
"event",
".",
"type",
"===",
"\"error\"",
"&&",
"event",
".",
"name",
"&&",
"_errorsThatOnlyOccurAfterFlashLoads",
".",
"indexOf",
"(",
"event",
".",
"name",
")",
"!==",
"-",
"1",
")",
"{",
"isSandboxed",
"=",
"false",
";",
"}",
"return",
"isSandboxed",
";",
"}"
] |
Check an `error` event's `name` property to see if Flash has
already loaded, which rules out possible `iframe` sandboxing.
@private
|
[
"Check",
"an",
"error",
"event",
"s",
"name",
"property",
"to",
"see",
"if",
"Flash",
"has",
"already",
"loaded",
"which",
"rules",
"out",
"possible",
"iframe",
"sandboxing",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L994-L1000
|
|
11,055
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(aftercopyEvent) {
if (aftercopyEvent.errors && aftercopyEvent.errors.length > 0) {
var errorEvent = _deepCopy(aftercopyEvent);
_extend(errorEvent, {
type: "error",
name: "clipboard-error"
});
delete errorEvent.success;
_setTimeout(function() {
ZeroClipboard.emit(errorEvent);
}, 0);
}
}
|
javascript
|
function(aftercopyEvent) {
if (aftercopyEvent.errors && aftercopyEvent.errors.length > 0) {
var errorEvent = _deepCopy(aftercopyEvent);
_extend(errorEvent, {
type: "error",
name: "clipboard-error"
});
delete errorEvent.success;
_setTimeout(function() {
ZeroClipboard.emit(errorEvent);
}, 0);
}
}
|
[
"function",
"(",
"aftercopyEvent",
")",
"{",
"if",
"(",
"aftercopyEvent",
".",
"errors",
"&&",
"aftercopyEvent",
".",
"errors",
".",
"length",
">",
"0",
")",
"{",
"var",
"errorEvent",
"=",
"_deepCopy",
"(",
"aftercopyEvent",
")",
";",
"_extend",
"(",
"errorEvent",
",",
"{",
"type",
":",
"\"error\"",
",",
"name",
":",
"\"clipboard-error\"",
"}",
")",
";",
"delete",
"errorEvent",
".",
"success",
";",
"_setTimeout",
"(",
"function",
"(",
")",
"{",
"ZeroClipboard",
".",
"emit",
"(",
"errorEvent",
")",
";",
"}",
",",
"0",
")",
";",
"}",
"}"
] |
Check an "aftercopy" event for clipboard errors and emit a corresponding "error" event.
@private
|
[
"Check",
"an",
"aftercopy",
"event",
"for",
"clipboard",
"errors",
"and",
"emit",
"a",
"corresponding",
"error",
"event",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L1171-L1183
|
|
11,056
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(event) {
if (!(event && typeof event.type === "string" && event)) {
return;
}
var e, target = event.target || null, doc = target && target.ownerDocument || _document, defaults = {
view: doc.defaultView || _window,
canBubble: true,
cancelable: true,
detail: event.type === "click" ? 1 : 0,
button: typeof event.which === "number" ? event.which - 1 : typeof event.button === "number" ? event.button : doc.createEvent ? 0 : 1
}, args = _extend(defaults, event);
if (!target) {
return;
}
if (doc.createEvent && target.dispatchEvent) {
args = [ args.type, args.canBubble, args.cancelable, args.view, args.detail, args.screenX, args.screenY, args.clientX, args.clientY, args.ctrlKey, args.altKey, args.shiftKey, args.metaKey, args.button, args.relatedTarget ];
e = doc.createEvent("MouseEvents");
if (e.initMouseEvent) {
e.initMouseEvent.apply(e, args);
e._source = "js";
target.dispatchEvent(e);
}
}
}
|
javascript
|
function(event) {
if (!(event && typeof event.type === "string" && event)) {
return;
}
var e, target = event.target || null, doc = target && target.ownerDocument || _document, defaults = {
view: doc.defaultView || _window,
canBubble: true,
cancelable: true,
detail: event.type === "click" ? 1 : 0,
button: typeof event.which === "number" ? event.which - 1 : typeof event.button === "number" ? event.button : doc.createEvent ? 0 : 1
}, args = _extend(defaults, event);
if (!target) {
return;
}
if (doc.createEvent && target.dispatchEvent) {
args = [ args.type, args.canBubble, args.cancelable, args.view, args.detail, args.screenX, args.screenY, args.clientX, args.clientY, args.ctrlKey, args.altKey, args.shiftKey, args.metaKey, args.button, args.relatedTarget ];
e = doc.createEvent("MouseEvents");
if (e.initMouseEvent) {
e.initMouseEvent.apply(e, args);
e._source = "js";
target.dispatchEvent(e);
}
}
}
|
[
"function",
"(",
"event",
")",
"{",
"if",
"(",
"!",
"(",
"event",
"&&",
"typeof",
"event",
".",
"type",
"===",
"\"string\"",
"&&",
"event",
")",
")",
"{",
"return",
";",
"}",
"var",
"e",
",",
"target",
"=",
"event",
".",
"target",
"||",
"null",
",",
"doc",
"=",
"target",
"&&",
"target",
".",
"ownerDocument",
"||",
"_document",
",",
"defaults",
"=",
"{",
"view",
":",
"doc",
".",
"defaultView",
"||",
"_window",
",",
"canBubble",
":",
"true",
",",
"cancelable",
":",
"true",
",",
"detail",
":",
"event",
".",
"type",
"===",
"\"click\"",
"?",
"1",
":",
"0",
",",
"button",
":",
"typeof",
"event",
".",
"which",
"===",
"\"number\"",
"?",
"event",
".",
"which",
"-",
"1",
":",
"typeof",
"event",
".",
"button",
"===",
"\"number\"",
"?",
"event",
".",
"button",
":",
"doc",
".",
"createEvent",
"?",
"0",
":",
"1",
"}",
",",
"args",
"=",
"_extend",
"(",
"defaults",
",",
"event",
")",
";",
"if",
"(",
"!",
"target",
")",
"{",
"return",
";",
"}",
"if",
"(",
"doc",
".",
"createEvent",
"&&",
"target",
".",
"dispatchEvent",
")",
"{",
"args",
"=",
"[",
"args",
".",
"type",
",",
"args",
".",
"canBubble",
",",
"args",
".",
"cancelable",
",",
"args",
".",
"view",
",",
"args",
".",
"detail",
",",
"args",
".",
"screenX",
",",
"args",
".",
"screenY",
",",
"args",
".",
"clientX",
",",
"args",
".",
"clientY",
",",
"args",
".",
"ctrlKey",
",",
"args",
".",
"altKey",
",",
"args",
".",
"shiftKey",
",",
"args",
".",
"metaKey",
",",
"args",
".",
"button",
",",
"args",
".",
"relatedTarget",
"]",
";",
"e",
"=",
"doc",
".",
"createEvent",
"(",
"\"MouseEvents\"",
")",
";",
"if",
"(",
"e",
".",
"initMouseEvent",
")",
"{",
"e",
".",
"initMouseEvent",
".",
"apply",
"(",
"e",
",",
"args",
")",
";",
"e",
".",
"_source",
"=",
"\"js\"",
";",
"target",
".",
"dispatchEvent",
"(",
"e",
")",
";",
"}",
"}",
"}"
] |
Dispatch a synthetic MouseEvent.
@returns `undefined`
@private
|
[
"Dispatch",
"a",
"synthetic",
"MouseEvent",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L1190-L1213
|
|
11,057
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function() {
var container = _document.createElement("div");
container.id = _globalConfig.containerId;
container.className = _globalConfig.containerClass;
container.style.position = "absolute";
container.style.left = "0px";
container.style.top = "-9999px";
container.style.width = "1px";
container.style.height = "1px";
container.style.zIndex = "" + _getSafeZIndex(_globalConfig.zIndex);
return container;
}
|
javascript
|
function() {
var container = _document.createElement("div");
container.id = _globalConfig.containerId;
container.className = _globalConfig.containerClass;
container.style.position = "absolute";
container.style.left = "0px";
container.style.top = "-9999px";
container.style.width = "1px";
container.style.height = "1px";
container.style.zIndex = "" + _getSafeZIndex(_globalConfig.zIndex);
return container;
}
|
[
"function",
"(",
")",
"{",
"var",
"container",
"=",
"_document",
".",
"createElement",
"(",
"\"div\"",
")",
";",
"container",
".",
"id",
"=",
"_globalConfig",
".",
"containerId",
";",
"container",
".",
"className",
"=",
"_globalConfig",
".",
"containerClass",
";",
"container",
".",
"style",
".",
"position",
"=",
"\"absolute\"",
";",
"container",
".",
"style",
".",
"left",
"=",
"\"0px\"",
";",
"container",
".",
"style",
".",
"top",
"=",
"\"-9999px\"",
";",
"container",
".",
"style",
".",
"width",
"=",
"\"1px\"",
";",
"container",
".",
"style",
".",
"height",
"=",
"\"1px\"",
";",
"container",
".",
"style",
".",
"zIndex",
"=",
"\"\"",
"+",
"_getSafeZIndex",
"(",
"_globalConfig",
".",
"zIndex",
")",
";",
"return",
"container",
";",
"}"
] |
Create the HTML bridge element to embed the Flash object into.
@private
|
[
"Create",
"the",
"HTML",
"bridge",
"element",
"to",
"embed",
"the",
"Flash",
"object",
"into",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L1252-L1263
|
|
11,058
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function() {
var len, flashBridge = _flashState.bridge, container = _getHtmlBridge(flashBridge);
if (!flashBridge) {
var allowScriptAccess = _determineScriptAccess(_window.location.host, _globalConfig);
var allowNetworking = allowScriptAccess === "never" ? "none" : "all";
var flashvars = _vars(_extend({
jsVersion: ZeroClipboard.version
}, _globalConfig));
var swfUrl = _globalConfig.swfPath + _cacheBust(_globalConfig.swfPath, _globalConfig);
if (_pageIsXhtml) {
swfUrl = _escapeXmlValue(swfUrl);
}
container = _createHtmlBridge();
var divToBeReplaced = _document.createElement("div");
container.appendChild(divToBeReplaced);
_document.body.appendChild(container);
var tmpDiv = _document.createElement("div");
var usingActiveX = _flashState.pluginType === "activex";
tmpDiv.innerHTML = '<object id="' + _globalConfig.swfObjectId + '" name="' + _globalConfig.swfObjectId + '" ' + 'width="100%" height="100%" ' + (usingActiveX ? 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' : 'type="application/x-shockwave-flash" data="' + swfUrl + '"') + ">" + (usingActiveX ? '<param name="movie" value="' + swfUrl + '"/>' : "") + '<param name="allowScriptAccess" value="' + allowScriptAccess + '"/>' + '<param name="allowNetworking" value="' + allowNetworking + '"/>' + '<param name="menu" value="false"/>' + '<param name="wmode" value="transparent"/>' + '<param name="flashvars" value="' + flashvars + '"/>' + '<div id="' + _globalConfig.swfObjectId + '_fallbackContent"> </div>' + "</object>";
flashBridge = tmpDiv.firstChild;
tmpDiv = null;
_unwrap(flashBridge).ZeroClipboard = ZeroClipboard;
container.replaceChild(flashBridge, divToBeReplaced);
_watchForSwfFallbackContent();
}
if (!flashBridge) {
flashBridge = _document[_globalConfig.swfObjectId];
if (flashBridge && (len = flashBridge.length)) {
flashBridge = flashBridge[len - 1];
}
if (!flashBridge && container) {
flashBridge = container.firstChild;
}
}
_flashState.bridge = flashBridge || null;
return flashBridge;
}
|
javascript
|
function() {
var len, flashBridge = _flashState.bridge, container = _getHtmlBridge(flashBridge);
if (!flashBridge) {
var allowScriptAccess = _determineScriptAccess(_window.location.host, _globalConfig);
var allowNetworking = allowScriptAccess === "never" ? "none" : "all";
var flashvars = _vars(_extend({
jsVersion: ZeroClipboard.version
}, _globalConfig));
var swfUrl = _globalConfig.swfPath + _cacheBust(_globalConfig.swfPath, _globalConfig);
if (_pageIsXhtml) {
swfUrl = _escapeXmlValue(swfUrl);
}
container = _createHtmlBridge();
var divToBeReplaced = _document.createElement("div");
container.appendChild(divToBeReplaced);
_document.body.appendChild(container);
var tmpDiv = _document.createElement("div");
var usingActiveX = _flashState.pluginType === "activex";
tmpDiv.innerHTML = '<object id="' + _globalConfig.swfObjectId + '" name="' + _globalConfig.swfObjectId + '" ' + 'width="100%" height="100%" ' + (usingActiveX ? 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' : 'type="application/x-shockwave-flash" data="' + swfUrl + '"') + ">" + (usingActiveX ? '<param name="movie" value="' + swfUrl + '"/>' : "") + '<param name="allowScriptAccess" value="' + allowScriptAccess + '"/>' + '<param name="allowNetworking" value="' + allowNetworking + '"/>' + '<param name="menu" value="false"/>' + '<param name="wmode" value="transparent"/>' + '<param name="flashvars" value="' + flashvars + '"/>' + '<div id="' + _globalConfig.swfObjectId + '_fallbackContent"> </div>' + "</object>";
flashBridge = tmpDiv.firstChild;
tmpDiv = null;
_unwrap(flashBridge).ZeroClipboard = ZeroClipboard;
container.replaceChild(flashBridge, divToBeReplaced);
_watchForSwfFallbackContent();
}
if (!flashBridge) {
flashBridge = _document[_globalConfig.swfObjectId];
if (flashBridge && (len = flashBridge.length)) {
flashBridge = flashBridge[len - 1];
}
if (!flashBridge && container) {
flashBridge = container.firstChild;
}
}
_flashState.bridge = flashBridge || null;
return flashBridge;
}
|
[
"function",
"(",
")",
"{",
"var",
"len",
",",
"flashBridge",
"=",
"_flashState",
".",
"bridge",
",",
"container",
"=",
"_getHtmlBridge",
"(",
"flashBridge",
")",
";",
"if",
"(",
"!",
"flashBridge",
")",
"{",
"var",
"allowScriptAccess",
"=",
"_determineScriptAccess",
"(",
"_window",
".",
"location",
".",
"host",
",",
"_globalConfig",
")",
";",
"var",
"allowNetworking",
"=",
"allowScriptAccess",
"===",
"\"never\"",
"?",
"\"none\"",
":",
"\"all\"",
";",
"var",
"flashvars",
"=",
"_vars",
"(",
"_extend",
"(",
"{",
"jsVersion",
":",
"ZeroClipboard",
".",
"version",
"}",
",",
"_globalConfig",
")",
")",
";",
"var",
"swfUrl",
"=",
"_globalConfig",
".",
"swfPath",
"+",
"_cacheBust",
"(",
"_globalConfig",
".",
"swfPath",
",",
"_globalConfig",
")",
";",
"if",
"(",
"_pageIsXhtml",
")",
"{",
"swfUrl",
"=",
"_escapeXmlValue",
"(",
"swfUrl",
")",
";",
"}",
"container",
"=",
"_createHtmlBridge",
"(",
")",
";",
"var",
"divToBeReplaced",
"=",
"_document",
".",
"createElement",
"(",
"\"div\"",
")",
";",
"container",
".",
"appendChild",
"(",
"divToBeReplaced",
")",
";",
"_document",
".",
"body",
".",
"appendChild",
"(",
"container",
")",
";",
"var",
"tmpDiv",
"=",
"_document",
".",
"createElement",
"(",
"\"div\"",
")",
";",
"var",
"usingActiveX",
"=",
"_flashState",
".",
"pluginType",
"===",
"\"activex\"",
";",
"tmpDiv",
".",
"innerHTML",
"=",
"'<object id=\"'",
"+",
"_globalConfig",
".",
"swfObjectId",
"+",
"'\" name=\"'",
"+",
"_globalConfig",
".",
"swfObjectId",
"+",
"'\" '",
"+",
"'width=\"100%\" height=\"100%\" '",
"+",
"(",
"usingActiveX",
"?",
"'classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\"'",
":",
"'type=\"application/x-shockwave-flash\" data=\"'",
"+",
"swfUrl",
"+",
"'\"'",
")",
"+",
"\">\"",
"+",
"(",
"usingActiveX",
"?",
"'<param name=\"movie\" value=\"'",
"+",
"swfUrl",
"+",
"'\"/>'",
":",
"\"\"",
")",
"+",
"'<param name=\"allowScriptAccess\" value=\"'",
"+",
"allowScriptAccess",
"+",
"'\"/>'",
"+",
"'<param name=\"allowNetworking\" value=\"'",
"+",
"allowNetworking",
"+",
"'\"/>'",
"+",
"'<param name=\"menu\" value=\"false\"/>'",
"+",
"'<param name=\"wmode\" value=\"transparent\"/>'",
"+",
"'<param name=\"flashvars\" value=\"'",
"+",
"flashvars",
"+",
"'\"/>'",
"+",
"'<div id=\"'",
"+",
"_globalConfig",
".",
"swfObjectId",
"+",
"'_fallbackContent\"> </div>'",
"+",
"\"</object>\"",
";",
"flashBridge",
"=",
"tmpDiv",
".",
"firstChild",
";",
"tmpDiv",
"=",
"null",
";",
"_unwrap",
"(",
"flashBridge",
")",
".",
"ZeroClipboard",
"=",
"ZeroClipboard",
";",
"container",
".",
"replaceChild",
"(",
"flashBridge",
",",
"divToBeReplaced",
")",
";",
"_watchForSwfFallbackContent",
"(",
")",
";",
"}",
"if",
"(",
"!",
"flashBridge",
")",
"{",
"flashBridge",
"=",
"_document",
"[",
"_globalConfig",
".",
"swfObjectId",
"]",
";",
"if",
"(",
"flashBridge",
"&&",
"(",
"len",
"=",
"flashBridge",
".",
"length",
")",
")",
"{",
"flashBridge",
"=",
"flashBridge",
"[",
"len",
"-",
"1",
"]",
";",
"}",
"if",
"(",
"!",
"flashBridge",
"&&",
"container",
")",
"{",
"flashBridge",
"=",
"container",
".",
"firstChild",
";",
"}",
"}",
"_flashState",
".",
"bridge",
"=",
"flashBridge",
"||",
"null",
";",
"return",
"flashBridge",
";",
"}"
] |
Create the SWF object.
@returns The SWF object reference.
@private
|
[
"Create",
"the",
"SWF",
"object",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L1311-L1347
|
|
11,059
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function() {
var flashBridge = _flashState.bridge;
if (flashBridge) {
var htmlBridge = _getHtmlBridge(flashBridge);
if (htmlBridge) {
if (_flashState.pluginType === "activex" && "readyState" in flashBridge) {
flashBridge.style.display = "none";
(function removeSwfFromIE() {
if (flashBridge.readyState === 4) {
for (var prop in flashBridge) {
if (typeof flashBridge[prop] === "function") {
flashBridge[prop] = null;
}
}
if (flashBridge.parentNode) {
flashBridge.parentNode.removeChild(flashBridge);
}
if (htmlBridge.parentNode) {
htmlBridge.parentNode.removeChild(htmlBridge);
}
} else {
_setTimeout(removeSwfFromIE, 10);
}
})();
} else {
if (flashBridge.parentNode) {
flashBridge.parentNode.removeChild(flashBridge);
}
if (htmlBridge.parentNode) {
htmlBridge.parentNode.removeChild(htmlBridge);
}
}
}
_clearTimeoutsAndPolling();
_flashState.ready = null;
_flashState.bridge = null;
_flashState.deactivated = null;
_flashState.insecure = null;
_zcSwfVersion = undefined;
}
}
|
javascript
|
function() {
var flashBridge = _flashState.bridge;
if (flashBridge) {
var htmlBridge = _getHtmlBridge(flashBridge);
if (htmlBridge) {
if (_flashState.pluginType === "activex" && "readyState" in flashBridge) {
flashBridge.style.display = "none";
(function removeSwfFromIE() {
if (flashBridge.readyState === 4) {
for (var prop in flashBridge) {
if (typeof flashBridge[prop] === "function") {
flashBridge[prop] = null;
}
}
if (flashBridge.parentNode) {
flashBridge.parentNode.removeChild(flashBridge);
}
if (htmlBridge.parentNode) {
htmlBridge.parentNode.removeChild(htmlBridge);
}
} else {
_setTimeout(removeSwfFromIE, 10);
}
})();
} else {
if (flashBridge.parentNode) {
flashBridge.parentNode.removeChild(flashBridge);
}
if (htmlBridge.parentNode) {
htmlBridge.parentNode.removeChild(htmlBridge);
}
}
}
_clearTimeoutsAndPolling();
_flashState.ready = null;
_flashState.bridge = null;
_flashState.deactivated = null;
_flashState.insecure = null;
_zcSwfVersion = undefined;
}
}
|
[
"function",
"(",
")",
"{",
"var",
"flashBridge",
"=",
"_flashState",
".",
"bridge",
";",
"if",
"(",
"flashBridge",
")",
"{",
"var",
"htmlBridge",
"=",
"_getHtmlBridge",
"(",
"flashBridge",
")",
";",
"if",
"(",
"htmlBridge",
")",
"{",
"if",
"(",
"_flashState",
".",
"pluginType",
"===",
"\"activex\"",
"&&",
"\"readyState\"",
"in",
"flashBridge",
")",
"{",
"flashBridge",
".",
"style",
".",
"display",
"=",
"\"none\"",
";",
"(",
"function",
"removeSwfFromIE",
"(",
")",
"{",
"if",
"(",
"flashBridge",
".",
"readyState",
"===",
"4",
")",
"{",
"for",
"(",
"var",
"prop",
"in",
"flashBridge",
")",
"{",
"if",
"(",
"typeof",
"flashBridge",
"[",
"prop",
"]",
"===",
"\"function\"",
")",
"{",
"flashBridge",
"[",
"prop",
"]",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"flashBridge",
".",
"parentNode",
")",
"{",
"flashBridge",
".",
"parentNode",
".",
"removeChild",
"(",
"flashBridge",
")",
";",
"}",
"if",
"(",
"htmlBridge",
".",
"parentNode",
")",
"{",
"htmlBridge",
".",
"parentNode",
".",
"removeChild",
"(",
"htmlBridge",
")",
";",
"}",
"}",
"else",
"{",
"_setTimeout",
"(",
"removeSwfFromIE",
",",
"10",
")",
";",
"}",
"}",
")",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"flashBridge",
".",
"parentNode",
")",
"{",
"flashBridge",
".",
"parentNode",
".",
"removeChild",
"(",
"flashBridge",
")",
";",
"}",
"if",
"(",
"htmlBridge",
".",
"parentNode",
")",
"{",
"htmlBridge",
".",
"parentNode",
".",
"removeChild",
"(",
"htmlBridge",
")",
";",
"}",
"}",
"}",
"_clearTimeoutsAndPolling",
"(",
")",
";",
"_flashState",
".",
"ready",
"=",
"null",
";",
"_flashState",
".",
"bridge",
"=",
"null",
";",
"_flashState",
".",
"deactivated",
"=",
"null",
";",
"_flashState",
".",
"insecure",
"=",
"null",
";",
"_zcSwfVersion",
"=",
"undefined",
";",
"}",
"}"
] |
Destroy the SWF object.
@private
|
[
"Destroy",
"the",
"SWF",
"object",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L1352-L1392
|
|
11,060
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(clipData) {
var newClipData = {}, formatMap = {};
if (!(typeof clipData === "object" && clipData)) {
return;
}
for (var dataFormat in clipData) {
if (dataFormat && _hasOwn.call(clipData, dataFormat) && typeof clipData[dataFormat] === "string" && clipData[dataFormat]) {
switch (dataFormat.toLowerCase()) {
case "text/plain":
case "text":
case "air:text":
case "flash:text":
newClipData.text = clipData[dataFormat];
formatMap.text = dataFormat;
break;
case "text/html":
case "html":
case "air:html":
case "flash:html":
newClipData.html = clipData[dataFormat];
formatMap.html = dataFormat;
break;
case "application/rtf":
case "text/rtf":
case "rtf":
case "richtext":
case "air:rtf":
case "flash:rtf":
newClipData.rtf = clipData[dataFormat];
formatMap.rtf = dataFormat;
break;
default:
break;
}
}
}
return {
data: newClipData,
formatMap: formatMap
};
}
|
javascript
|
function(clipData) {
var newClipData = {}, formatMap = {};
if (!(typeof clipData === "object" && clipData)) {
return;
}
for (var dataFormat in clipData) {
if (dataFormat && _hasOwn.call(clipData, dataFormat) && typeof clipData[dataFormat] === "string" && clipData[dataFormat]) {
switch (dataFormat.toLowerCase()) {
case "text/plain":
case "text":
case "air:text":
case "flash:text":
newClipData.text = clipData[dataFormat];
formatMap.text = dataFormat;
break;
case "text/html":
case "html":
case "air:html":
case "flash:html":
newClipData.html = clipData[dataFormat];
formatMap.html = dataFormat;
break;
case "application/rtf":
case "text/rtf":
case "rtf":
case "richtext":
case "air:rtf":
case "flash:rtf":
newClipData.rtf = clipData[dataFormat];
formatMap.rtf = dataFormat;
break;
default:
break;
}
}
}
return {
data: newClipData,
formatMap: formatMap
};
}
|
[
"function",
"(",
"clipData",
")",
"{",
"var",
"newClipData",
"=",
"{",
"}",
",",
"formatMap",
"=",
"{",
"}",
";",
"if",
"(",
"!",
"(",
"typeof",
"clipData",
"===",
"\"object\"",
"&&",
"clipData",
")",
")",
"{",
"return",
";",
"}",
"for",
"(",
"var",
"dataFormat",
"in",
"clipData",
")",
"{",
"if",
"(",
"dataFormat",
"&&",
"_hasOwn",
".",
"call",
"(",
"clipData",
",",
"dataFormat",
")",
"&&",
"typeof",
"clipData",
"[",
"dataFormat",
"]",
"===",
"\"string\"",
"&&",
"clipData",
"[",
"dataFormat",
"]",
")",
"{",
"switch",
"(",
"dataFormat",
".",
"toLowerCase",
"(",
")",
")",
"{",
"case",
"\"text/plain\"",
":",
"case",
"\"text\"",
":",
"case",
"\"air:text\"",
":",
"case",
"\"flash:text\"",
":",
"newClipData",
".",
"text",
"=",
"clipData",
"[",
"dataFormat",
"]",
";",
"formatMap",
".",
"text",
"=",
"dataFormat",
";",
"break",
";",
"case",
"\"text/html\"",
":",
"case",
"\"html\"",
":",
"case",
"\"air:html\"",
":",
"case",
"\"flash:html\"",
":",
"newClipData",
".",
"html",
"=",
"clipData",
"[",
"dataFormat",
"]",
";",
"formatMap",
".",
"html",
"=",
"dataFormat",
";",
"break",
";",
"case",
"\"application/rtf\"",
":",
"case",
"\"text/rtf\"",
":",
"case",
"\"rtf\"",
":",
"case",
"\"richtext\"",
":",
"case",
"\"air:rtf\"",
":",
"case",
"\"flash:rtf\"",
":",
"newClipData",
".",
"rtf",
"=",
"clipData",
"[",
"dataFormat",
"]",
";",
"formatMap",
".",
"rtf",
"=",
"dataFormat",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"}",
"}",
"return",
"{",
"data",
":",
"newClipData",
",",
"formatMap",
":",
"formatMap",
"}",
";",
"}"
] |
Map the data format names of the "clipData" to Flash-friendly names.
@returns A new transformed object.
@private
|
[
"Map",
"the",
"data",
"format",
"names",
"of",
"the",
"clipData",
"to",
"Flash",
"-",
"friendly",
"names",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L1399-L1442
|
|
11,061
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(options) {
var i, len, domain, domains, str = "", trustedOriginsExpanded = [];
if (options.trustedDomains) {
if (typeof options.trustedDomains === "string") {
domains = [ options.trustedDomains ];
} else if (typeof options.trustedDomains === "object" && "length" in options.trustedDomains) {
domains = options.trustedDomains;
}
}
if (domains && domains.length) {
for (i = 0, len = domains.length; i < len; i++) {
if (_hasOwn.call(domains, i) && domains[i] && typeof domains[i] === "string") {
domain = _extractDomain(domains[i]);
if (!domain) {
continue;
}
if (domain === "*") {
trustedOriginsExpanded.length = 0;
trustedOriginsExpanded.push(domain);
break;
}
trustedOriginsExpanded.push.apply(trustedOriginsExpanded, [ domain, "//" + domain, _window.location.protocol + "//" + domain ]);
}
}
}
if (trustedOriginsExpanded.length) {
str += "trustedOrigins=" + _encodeURIComponent(trustedOriginsExpanded.join(","));
}
if (options.forceEnhancedClipboard === true) {
str += (str ? "&" : "") + "forceEnhancedClipboard=true";
}
if (typeof options.swfObjectId === "string" && options.swfObjectId) {
str += (str ? "&" : "") + "swfObjectId=" + _encodeURIComponent(options.swfObjectId);
}
if (typeof options.jsVersion === "string" && options.jsVersion) {
str += (str ? "&" : "") + "jsVersion=" + _encodeURIComponent(options.jsVersion);
}
return str;
}
|
javascript
|
function(options) {
var i, len, domain, domains, str = "", trustedOriginsExpanded = [];
if (options.trustedDomains) {
if (typeof options.trustedDomains === "string") {
domains = [ options.trustedDomains ];
} else if (typeof options.trustedDomains === "object" && "length" in options.trustedDomains) {
domains = options.trustedDomains;
}
}
if (domains && domains.length) {
for (i = 0, len = domains.length; i < len; i++) {
if (_hasOwn.call(domains, i) && domains[i] && typeof domains[i] === "string") {
domain = _extractDomain(domains[i]);
if (!domain) {
continue;
}
if (domain === "*") {
trustedOriginsExpanded.length = 0;
trustedOriginsExpanded.push(domain);
break;
}
trustedOriginsExpanded.push.apply(trustedOriginsExpanded, [ domain, "//" + domain, _window.location.protocol + "//" + domain ]);
}
}
}
if (trustedOriginsExpanded.length) {
str += "trustedOrigins=" + _encodeURIComponent(trustedOriginsExpanded.join(","));
}
if (options.forceEnhancedClipboard === true) {
str += (str ? "&" : "") + "forceEnhancedClipboard=true";
}
if (typeof options.swfObjectId === "string" && options.swfObjectId) {
str += (str ? "&" : "") + "swfObjectId=" + _encodeURIComponent(options.swfObjectId);
}
if (typeof options.jsVersion === "string" && options.jsVersion) {
str += (str ? "&" : "") + "jsVersion=" + _encodeURIComponent(options.jsVersion);
}
return str;
}
|
[
"function",
"(",
"options",
")",
"{",
"var",
"i",
",",
"len",
",",
"domain",
",",
"domains",
",",
"str",
"=",
"\"\"",
",",
"trustedOriginsExpanded",
"=",
"[",
"]",
";",
"if",
"(",
"options",
".",
"trustedDomains",
")",
"{",
"if",
"(",
"typeof",
"options",
".",
"trustedDomains",
"===",
"\"string\"",
")",
"{",
"domains",
"=",
"[",
"options",
".",
"trustedDomains",
"]",
";",
"}",
"else",
"if",
"(",
"typeof",
"options",
".",
"trustedDomains",
"===",
"\"object\"",
"&&",
"\"length\"",
"in",
"options",
".",
"trustedDomains",
")",
"{",
"domains",
"=",
"options",
".",
"trustedDomains",
";",
"}",
"}",
"if",
"(",
"domains",
"&&",
"domains",
".",
"length",
")",
"{",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"domains",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"_hasOwn",
".",
"call",
"(",
"domains",
",",
"i",
")",
"&&",
"domains",
"[",
"i",
"]",
"&&",
"typeof",
"domains",
"[",
"i",
"]",
"===",
"\"string\"",
")",
"{",
"domain",
"=",
"_extractDomain",
"(",
"domains",
"[",
"i",
"]",
")",
";",
"if",
"(",
"!",
"domain",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"domain",
"===",
"\"*\"",
")",
"{",
"trustedOriginsExpanded",
".",
"length",
"=",
"0",
";",
"trustedOriginsExpanded",
".",
"push",
"(",
"domain",
")",
";",
"break",
";",
"}",
"trustedOriginsExpanded",
".",
"push",
".",
"apply",
"(",
"trustedOriginsExpanded",
",",
"[",
"domain",
",",
"\"//\"",
"+",
"domain",
",",
"_window",
".",
"location",
".",
"protocol",
"+",
"\"//\"",
"+",
"domain",
"]",
")",
";",
"}",
"}",
"}",
"if",
"(",
"trustedOriginsExpanded",
".",
"length",
")",
"{",
"str",
"+=",
"\"trustedOrigins=\"",
"+",
"_encodeURIComponent",
"(",
"trustedOriginsExpanded",
".",
"join",
"(",
"\",\"",
")",
")",
";",
"}",
"if",
"(",
"options",
".",
"forceEnhancedClipboard",
"===",
"true",
")",
"{",
"str",
"+=",
"(",
"str",
"?",
"\"&\"",
":",
"\"\"",
")",
"+",
"\"forceEnhancedClipboard=true\"",
";",
"}",
"if",
"(",
"typeof",
"options",
".",
"swfObjectId",
"===",
"\"string\"",
"&&",
"options",
".",
"swfObjectId",
")",
"{",
"str",
"+=",
"(",
"str",
"?",
"\"&\"",
":",
"\"\"",
")",
"+",
"\"swfObjectId=\"",
"+",
"_encodeURIComponent",
"(",
"options",
".",
"swfObjectId",
")",
";",
"}",
"if",
"(",
"typeof",
"options",
".",
"jsVersion",
"===",
"\"string\"",
"&&",
"options",
".",
"jsVersion",
")",
"{",
"str",
"+=",
"(",
"str",
"?",
"\"&\"",
":",
"\"\"",
")",
"+",
"\"jsVersion=\"",
"+",
"_encodeURIComponent",
"(",
"options",
".",
"jsVersion",
")",
";",
"}",
"return",
"str",
";",
"}"
] |
Creates a query string for the FlashVars param.
Does NOT include the cache-busting query param.
@returns FlashVars query string
@private
|
[
"Creates",
"a",
"query",
"string",
"for",
"the",
"FlashVars",
"param",
".",
"Does",
"NOT",
"include",
"the",
"cache",
"-",
"busting",
"query",
"param",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L1499-L1537
|
|
11,062
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(element, value) {
var c, cl, className, classNames = [];
if (typeof value === "string" && value) {
classNames = value.split(/\s+/);
}
if (element && element.nodeType === 1 && classNames.length > 0) {
className = (" " + (element.className || "") + " ").replace(/[\t\r\n\f]/g, " ");
for (c = 0, cl = classNames.length; c < cl; c++) {
if (className.indexOf(" " + classNames[c] + " ") === -1) {
className += classNames[c] + " ";
}
}
className = className.replace(/^\s+|\s+$/g, "");
if (className !== element.className) {
element.className = className;
}
}
return element;
}
|
javascript
|
function(element, value) {
var c, cl, className, classNames = [];
if (typeof value === "string" && value) {
classNames = value.split(/\s+/);
}
if (element && element.nodeType === 1 && classNames.length > 0) {
className = (" " + (element.className || "") + " ").replace(/[\t\r\n\f]/g, " ");
for (c = 0, cl = classNames.length; c < cl; c++) {
if (className.indexOf(" " + classNames[c] + " ") === -1) {
className += classNames[c] + " ";
}
}
className = className.replace(/^\s+|\s+$/g, "");
if (className !== element.className) {
element.className = className;
}
}
return element;
}
|
[
"function",
"(",
"element",
",",
"value",
")",
"{",
"var",
"c",
",",
"cl",
",",
"className",
",",
"classNames",
"=",
"[",
"]",
";",
"if",
"(",
"typeof",
"value",
"===",
"\"string\"",
"&&",
"value",
")",
"{",
"classNames",
"=",
"value",
".",
"split",
"(",
"/",
"\\s+",
"/",
")",
";",
"}",
"if",
"(",
"element",
"&&",
"element",
".",
"nodeType",
"===",
"1",
"&&",
"classNames",
".",
"length",
">",
"0",
")",
"{",
"className",
"=",
"(",
"\" \"",
"+",
"(",
"element",
".",
"className",
"||",
"\"\"",
")",
"+",
"\" \"",
")",
".",
"replace",
"(",
"/",
"[\\t\\r\\n\\f]",
"/",
"g",
",",
"\" \"",
")",
";",
"for",
"(",
"c",
"=",
"0",
",",
"cl",
"=",
"classNames",
".",
"length",
";",
"c",
"<",
"cl",
";",
"c",
"++",
")",
"{",
"if",
"(",
"className",
".",
"indexOf",
"(",
"\" \"",
"+",
"classNames",
"[",
"c",
"]",
"+",
"\" \"",
")",
"===",
"-",
"1",
")",
"{",
"className",
"+=",
"classNames",
"[",
"c",
"]",
"+",
"\" \"",
";",
"}",
"}",
"className",
"=",
"className",
".",
"replace",
"(",
"/",
"^\\s+|\\s+$",
"/",
"g",
",",
"\"\"",
")",
";",
"if",
"(",
"className",
"!==",
"element",
".",
"className",
")",
"{",
"element",
".",
"className",
"=",
"className",
";",
"}",
"}",
"return",
"element",
";",
"}"
] |
Add a class to an element, if it doesn't already have it.
@returns The element, with its new class added.
@private
|
[
"Add",
"a",
"class",
"to",
"an",
"element",
"if",
"it",
"doesn",
"t",
"already",
"have",
"it",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L1631-L1649
|
|
11,063
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(el) {
var pos = {
left: 0,
top: 0,
width: 0,
height: 0
};
if (el.getBoundingClientRect) {
var elRect = el.getBoundingClientRect();
var pageXOffset = _window.pageXOffset;
var pageYOffset = _window.pageYOffset;
var leftBorderWidth = _document.documentElement.clientLeft || 0;
var topBorderWidth = _document.documentElement.clientTop || 0;
var leftBodyOffset = 0;
var topBodyOffset = 0;
if (_getStyle(_document.body, "position") === "relative") {
var bodyRect = _document.body.getBoundingClientRect();
var htmlRect = _document.documentElement.getBoundingClientRect();
leftBodyOffset = bodyRect.left - htmlRect.left || 0;
topBodyOffset = bodyRect.top - htmlRect.top || 0;
}
pos.left = elRect.left + pageXOffset - leftBorderWidth - leftBodyOffset;
pos.top = elRect.top + pageYOffset - topBorderWidth - topBodyOffset;
pos.width = "width" in elRect ? elRect.width : elRect.right - elRect.left;
pos.height = "height" in elRect ? elRect.height : elRect.bottom - elRect.top;
}
return pos;
}
|
javascript
|
function(el) {
var pos = {
left: 0,
top: 0,
width: 0,
height: 0
};
if (el.getBoundingClientRect) {
var elRect = el.getBoundingClientRect();
var pageXOffset = _window.pageXOffset;
var pageYOffset = _window.pageYOffset;
var leftBorderWidth = _document.documentElement.clientLeft || 0;
var topBorderWidth = _document.documentElement.clientTop || 0;
var leftBodyOffset = 0;
var topBodyOffset = 0;
if (_getStyle(_document.body, "position") === "relative") {
var bodyRect = _document.body.getBoundingClientRect();
var htmlRect = _document.documentElement.getBoundingClientRect();
leftBodyOffset = bodyRect.left - htmlRect.left || 0;
topBodyOffset = bodyRect.top - htmlRect.top || 0;
}
pos.left = elRect.left + pageXOffset - leftBorderWidth - leftBodyOffset;
pos.top = elRect.top + pageYOffset - topBorderWidth - topBodyOffset;
pos.width = "width" in elRect ? elRect.width : elRect.right - elRect.left;
pos.height = "height" in elRect ? elRect.height : elRect.bottom - elRect.top;
}
return pos;
}
|
[
"function",
"(",
"el",
")",
"{",
"var",
"pos",
"=",
"{",
"left",
":",
"0",
",",
"top",
":",
"0",
",",
"width",
":",
"0",
",",
"height",
":",
"0",
"}",
";",
"if",
"(",
"el",
".",
"getBoundingClientRect",
")",
"{",
"var",
"elRect",
"=",
"el",
".",
"getBoundingClientRect",
"(",
")",
";",
"var",
"pageXOffset",
"=",
"_window",
".",
"pageXOffset",
";",
"var",
"pageYOffset",
"=",
"_window",
".",
"pageYOffset",
";",
"var",
"leftBorderWidth",
"=",
"_document",
".",
"documentElement",
".",
"clientLeft",
"||",
"0",
";",
"var",
"topBorderWidth",
"=",
"_document",
".",
"documentElement",
".",
"clientTop",
"||",
"0",
";",
"var",
"leftBodyOffset",
"=",
"0",
";",
"var",
"topBodyOffset",
"=",
"0",
";",
"if",
"(",
"_getStyle",
"(",
"_document",
".",
"body",
",",
"\"position\"",
")",
"===",
"\"relative\"",
")",
"{",
"var",
"bodyRect",
"=",
"_document",
".",
"body",
".",
"getBoundingClientRect",
"(",
")",
";",
"var",
"htmlRect",
"=",
"_document",
".",
"documentElement",
".",
"getBoundingClientRect",
"(",
")",
";",
"leftBodyOffset",
"=",
"bodyRect",
".",
"left",
"-",
"htmlRect",
".",
"left",
"||",
"0",
";",
"topBodyOffset",
"=",
"bodyRect",
".",
"top",
"-",
"htmlRect",
".",
"top",
"||",
"0",
";",
"}",
"pos",
".",
"left",
"=",
"elRect",
".",
"left",
"+",
"pageXOffset",
"-",
"leftBorderWidth",
"-",
"leftBodyOffset",
";",
"pos",
".",
"top",
"=",
"elRect",
".",
"top",
"+",
"pageYOffset",
"-",
"topBorderWidth",
"-",
"topBodyOffset",
";",
"pos",
".",
"width",
"=",
"\"width\"",
"in",
"elRect",
"?",
"elRect",
".",
"width",
":",
"elRect",
".",
"right",
"-",
"elRect",
".",
"left",
";",
"pos",
".",
"height",
"=",
"\"height\"",
"in",
"elRect",
"?",
"elRect",
".",
"height",
":",
"elRect",
".",
"bottom",
"-",
"elRect",
".",
"top",
";",
"}",
"return",
"pos",
";",
"}"
] |
Get the absolutely positioned coordinates of a DOM element.
@returns Object containing the element's position, width, and height.
@private
|
[
"Get",
"the",
"absolutely",
"positioned",
"coordinates",
"of",
"a",
"DOM",
"element",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L1700-L1727
|
|
11,064
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function() {
var htmlBridge;
if (_currentElement && (htmlBridge = _getHtmlBridge(_flashState.bridge))) {
var pos = _getElementPosition(_currentElement);
_extend(htmlBridge.style, {
width: pos.width + "px",
height: pos.height + "px",
top: pos.top + "px",
left: pos.left + "px",
zIndex: "" + _getSafeZIndex(_globalConfig.zIndex)
});
}
}
|
javascript
|
function() {
var htmlBridge;
if (_currentElement && (htmlBridge = _getHtmlBridge(_flashState.bridge))) {
var pos = _getElementPosition(_currentElement);
_extend(htmlBridge.style, {
width: pos.width + "px",
height: pos.height + "px",
top: pos.top + "px",
left: pos.left + "px",
zIndex: "" + _getSafeZIndex(_globalConfig.zIndex)
});
}
}
|
[
"function",
"(",
")",
"{",
"var",
"htmlBridge",
";",
"if",
"(",
"_currentElement",
"&&",
"(",
"htmlBridge",
"=",
"_getHtmlBridge",
"(",
"_flashState",
".",
"bridge",
")",
")",
")",
"{",
"var",
"pos",
"=",
"_getElementPosition",
"(",
"_currentElement",
")",
";",
"_extend",
"(",
"htmlBridge",
".",
"style",
",",
"{",
"width",
":",
"pos",
".",
"width",
"+",
"\"px\"",
",",
"height",
":",
"pos",
".",
"height",
"+",
"\"px\"",
",",
"top",
":",
"pos",
".",
"top",
"+",
"\"px\"",
",",
"left",
":",
"pos",
".",
"left",
"+",
"\"px\"",
",",
"zIndex",
":",
"\"\"",
"+",
"_getSafeZIndex",
"(",
"_globalConfig",
".",
"zIndex",
")",
"}",
")",
";",
"}",
"}"
] |
Reposition the Flash object to cover the currently activated element.
@returns `undefined`
@private
|
[
"Reposition",
"the",
"Flash",
"object",
"to",
"cover",
"the",
"currently",
"activated",
"element",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L1769-L1781
|
|
11,065
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(enabled) {
if (_flashState.ready === true) {
if (_flashState.bridge && typeof _flashState.bridge.setHandCursor === "function") {
_flashState.bridge.setHandCursor(enabled);
} else {
_flashState.ready = false;
}
}
}
|
javascript
|
function(enabled) {
if (_flashState.ready === true) {
if (_flashState.bridge && typeof _flashState.bridge.setHandCursor === "function") {
_flashState.bridge.setHandCursor(enabled);
} else {
_flashState.ready = false;
}
}
}
|
[
"function",
"(",
"enabled",
")",
"{",
"if",
"(",
"_flashState",
".",
"ready",
"===",
"true",
")",
"{",
"if",
"(",
"_flashState",
".",
"bridge",
"&&",
"typeof",
"_flashState",
".",
"bridge",
".",
"setHandCursor",
"===",
"\"function\"",
")",
"{",
"_flashState",
".",
"bridge",
".",
"setHandCursor",
"(",
"enabled",
")",
";",
"}",
"else",
"{",
"_flashState",
".",
"ready",
"=",
"false",
";",
"}",
"}",
"}"
] |
Sends a signal to the Flash object to display the hand cursor if `true`.
@returns `undefined`
@private
|
[
"Sends",
"a",
"signal",
"to",
"the",
"Flash",
"object",
"to",
"display",
"the",
"hand",
"cursor",
"if",
"true",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L1788-L1796
|
|
11,066
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(val) {
if (/^(?:auto|inherit)$/.test(val)) {
return val;
}
var zIndex;
if (typeof val === "number" && !_isNaN(val)) {
zIndex = val;
} else if (typeof val === "string") {
zIndex = _getSafeZIndex(_parseInt(val, 10));
}
return typeof zIndex === "number" ? zIndex : "auto";
}
|
javascript
|
function(val) {
if (/^(?:auto|inherit)$/.test(val)) {
return val;
}
var zIndex;
if (typeof val === "number" && !_isNaN(val)) {
zIndex = val;
} else if (typeof val === "string") {
zIndex = _getSafeZIndex(_parseInt(val, 10));
}
return typeof zIndex === "number" ? zIndex : "auto";
}
|
[
"function",
"(",
"val",
")",
"{",
"if",
"(",
"/",
"^(?:auto|inherit)$",
"/",
".",
"test",
"(",
"val",
")",
")",
"{",
"return",
"val",
";",
"}",
"var",
"zIndex",
";",
"if",
"(",
"typeof",
"val",
"===",
"\"number\"",
"&&",
"!",
"_isNaN",
"(",
"val",
")",
")",
"{",
"zIndex",
"=",
"val",
";",
"}",
"else",
"if",
"(",
"typeof",
"val",
"===",
"\"string\"",
")",
"{",
"zIndex",
"=",
"_getSafeZIndex",
"(",
"_parseInt",
"(",
"val",
",",
"10",
")",
")",
";",
"}",
"return",
"typeof",
"zIndex",
"===",
"\"number\"",
"?",
"zIndex",
":",
"\"auto\"",
";",
"}"
] |
Get a safe value for `zIndex`
@returns an integer, or "auto"
@private
|
[
"Get",
"a",
"safe",
"value",
"for",
"zIndex"
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L1803-L1814
|
|
11,067
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(content) {
var replaceRegex = /(\r\n|\r|\n)/g;
if (typeof content === "string" && _globalConfig.fixLineEndings === true) {
if (_isWindows()) {
if (/((^|[^\r])\n|\r([^\n]|$))/.test(content)) {
content = content.replace(replaceRegex, "\r\n");
}
} else if (/\r/.test(content)) {
content = content.replace(replaceRegex, "\n");
}
}
return content;
}
|
javascript
|
function(content) {
var replaceRegex = /(\r\n|\r|\n)/g;
if (typeof content === "string" && _globalConfig.fixLineEndings === true) {
if (_isWindows()) {
if (/((^|[^\r])\n|\r([^\n]|$))/.test(content)) {
content = content.replace(replaceRegex, "\r\n");
}
} else if (/\r/.test(content)) {
content = content.replace(replaceRegex, "\n");
}
}
return content;
}
|
[
"function",
"(",
"content",
")",
"{",
"var",
"replaceRegex",
"=",
"/",
"(\\r\\n|\\r|\\n)",
"/",
"g",
";",
"if",
"(",
"typeof",
"content",
"===",
"\"string\"",
"&&",
"_globalConfig",
".",
"fixLineEndings",
"===",
"true",
")",
"{",
"if",
"(",
"_isWindows",
"(",
")",
")",
"{",
"if",
"(",
"/",
"((^|[^\\r])\\n|\\r([^\\n]|$))",
"/",
".",
"test",
"(",
"content",
")",
")",
"{",
"content",
"=",
"content",
".",
"replace",
"(",
"replaceRegex",
",",
"\"\\r\\n\"",
")",
";",
"}",
"}",
"else",
"if",
"(",
"/",
"\\r",
"/",
".",
"test",
"(",
"content",
")",
")",
"{",
"content",
"=",
"content",
".",
"replace",
"(",
"replaceRegex",
",",
"\"\\n\"",
")",
";",
"}",
"}",
"return",
"content",
";",
"}"
] |
Ensure OS-compliant line endings, i.e. "\r\n" on Windows, "\n" elsewhere
@returns string
@private
|
[
"Ensure",
"OS",
"-",
"compliant",
"line",
"endings",
"i",
".",
"e",
".",
"\\",
"r",
"\\",
"n",
"on",
"Windows",
"\\",
"n",
"elsewhere"
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L1821-L1833
|
|
11,068
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(doNotReassessFlashSupport) {
var effectiveScriptOrigin, frame, frameError, previousState = _flashState.sandboxed, isSandboxed = null;
doNotReassessFlashSupport = doNotReassessFlashSupport === true;
if (_pageIsFramed === false) {
isSandboxed = false;
} else {
try {
frame = window.frameElement || null;
} catch (e) {
frameError = {
name: e.name,
message: e.message
};
}
if (frame && frame.nodeType === 1 && frame.nodeName === "IFRAME") {
try {
isSandboxed = frame.hasAttribute("sandbox");
} catch (e) {
isSandboxed = null;
}
} else {
try {
effectiveScriptOrigin = document.domain || null;
} catch (e) {
effectiveScriptOrigin = null;
}
if (effectiveScriptOrigin === null || frameError && frameError.name === "SecurityError" && /(^|[\s\(\[@])sandbox(es|ed|ing|[\s\.,!\)\]@]|$)/.test(frameError.message.toLowerCase())) {
isSandboxed = true;
}
}
}
_flashState.sandboxed = isSandboxed;
if (previousState !== isSandboxed && !doNotReassessFlashSupport) {
_detectFlashSupport(_ActiveXObject);
}
return isSandboxed;
}
|
javascript
|
function(doNotReassessFlashSupport) {
var effectiveScriptOrigin, frame, frameError, previousState = _flashState.sandboxed, isSandboxed = null;
doNotReassessFlashSupport = doNotReassessFlashSupport === true;
if (_pageIsFramed === false) {
isSandboxed = false;
} else {
try {
frame = window.frameElement || null;
} catch (e) {
frameError = {
name: e.name,
message: e.message
};
}
if (frame && frame.nodeType === 1 && frame.nodeName === "IFRAME") {
try {
isSandboxed = frame.hasAttribute("sandbox");
} catch (e) {
isSandboxed = null;
}
} else {
try {
effectiveScriptOrigin = document.domain || null;
} catch (e) {
effectiveScriptOrigin = null;
}
if (effectiveScriptOrigin === null || frameError && frameError.name === "SecurityError" && /(^|[\s\(\[@])sandbox(es|ed|ing|[\s\.,!\)\]@]|$)/.test(frameError.message.toLowerCase())) {
isSandboxed = true;
}
}
}
_flashState.sandboxed = isSandboxed;
if (previousState !== isSandboxed && !doNotReassessFlashSupport) {
_detectFlashSupport(_ActiveXObject);
}
return isSandboxed;
}
|
[
"function",
"(",
"doNotReassessFlashSupport",
")",
"{",
"var",
"effectiveScriptOrigin",
",",
"frame",
",",
"frameError",
",",
"previousState",
"=",
"_flashState",
".",
"sandboxed",
",",
"isSandboxed",
"=",
"null",
";",
"doNotReassessFlashSupport",
"=",
"doNotReassessFlashSupport",
"===",
"true",
";",
"if",
"(",
"_pageIsFramed",
"===",
"false",
")",
"{",
"isSandboxed",
"=",
"false",
";",
"}",
"else",
"{",
"try",
"{",
"frame",
"=",
"window",
".",
"frameElement",
"||",
"null",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"frameError",
"=",
"{",
"name",
":",
"e",
".",
"name",
",",
"message",
":",
"e",
".",
"message",
"}",
";",
"}",
"if",
"(",
"frame",
"&&",
"frame",
".",
"nodeType",
"===",
"1",
"&&",
"frame",
".",
"nodeName",
"===",
"\"IFRAME\"",
")",
"{",
"try",
"{",
"isSandboxed",
"=",
"frame",
".",
"hasAttribute",
"(",
"\"sandbox\"",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"isSandboxed",
"=",
"null",
";",
"}",
"}",
"else",
"{",
"try",
"{",
"effectiveScriptOrigin",
"=",
"document",
".",
"domain",
"||",
"null",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"effectiveScriptOrigin",
"=",
"null",
";",
"}",
"if",
"(",
"effectiveScriptOrigin",
"===",
"null",
"||",
"frameError",
"&&",
"frameError",
".",
"name",
"===",
"\"SecurityError\"",
"&&",
"/",
"(^|[\\s\\(\\[@])sandbox(es|ed|ing|[\\s\\.,!\\)\\]@]|$)",
"/",
".",
"test",
"(",
"frameError",
".",
"message",
".",
"toLowerCase",
"(",
")",
")",
")",
"{",
"isSandboxed",
"=",
"true",
";",
"}",
"}",
"}",
"_flashState",
".",
"sandboxed",
"=",
"isSandboxed",
";",
"if",
"(",
"previousState",
"!==",
"isSandboxed",
"&&",
"!",
"doNotReassessFlashSupport",
")",
"{",
"_detectFlashSupport",
"(",
"_ActiveXObject",
")",
";",
"}",
"return",
"isSandboxed",
";",
"}"
] |
Attempt to detect if ZeroClipboard is executing inside of a sandboxed iframe.
If it is, Flash Player cannot be used, so ZeroClipboard is dead in the water.
@see {@link http://lists.w3.org/Archives/Public/public-whatwg-archive/2014Dec/0002.html}
@see {@link https://github.com/zeroclipboard/zeroclipboard/issues/511}
@see {@link http://zeroclipboard.github.io/test-iframes.html}
@returns `true` (is sandboxed), `false` (is not sandboxed), or `null` (uncertain)
@private
|
[
"Attempt",
"to",
"detect",
"if",
"ZeroClipboard",
"is",
"executing",
"inside",
"of",
"a",
"sandboxed",
"iframe",
".",
"If",
"it",
"is",
"Flash",
"Player",
"cannot",
"be",
"used",
"so",
"ZeroClipboard",
"is",
"dead",
"in",
"the",
"water",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L1845-L1881
|
|
11,069
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
parseFlashVersion
|
function parseFlashVersion(desc) {
var matches = desc.match(/[\d]+/g);
matches.length = 3;
return matches.join(".");
}
|
javascript
|
function parseFlashVersion(desc) {
var matches = desc.match(/[\d]+/g);
matches.length = 3;
return matches.join(".");
}
|
[
"function",
"parseFlashVersion",
"(",
"desc",
")",
"{",
"var",
"matches",
"=",
"desc",
".",
"match",
"(",
"/",
"[\\d]+",
"/",
"g",
")",
";",
"matches",
".",
"length",
"=",
"3",
";",
"return",
"matches",
".",
"join",
"(",
"\".\"",
")",
";",
"}"
] |
Derived from Apple's suggested sniffer.
@param {String} desc e.g. "Shockwave Flash 7.0 r61"
@returns {String} "7.0.61"
@private
|
[
"Derived",
"from",
"Apple",
"s",
"suggested",
"sniffer",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L1899-L1903
|
11,070
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(elements) {
var meta, client = this;
client.id = "" + _clientIdCounter++;
meta = {
instance: client,
elements: [],
handlers: {},
coreWildcardHandler: function(event) {
return client.emit(event);
}
};
_clientMeta[client.id] = meta;
if (elements) {
client.clip(elements);
}
ZeroClipboard.on("*", meta.coreWildcardHandler);
ZeroClipboard.on("destroy", function() {
client.destroy();
});
ZeroClipboard.create();
}
|
javascript
|
function(elements) {
var meta, client = this;
client.id = "" + _clientIdCounter++;
meta = {
instance: client,
elements: [],
handlers: {},
coreWildcardHandler: function(event) {
return client.emit(event);
}
};
_clientMeta[client.id] = meta;
if (elements) {
client.clip(elements);
}
ZeroClipboard.on("*", meta.coreWildcardHandler);
ZeroClipboard.on("destroy", function() {
client.destroy();
});
ZeroClipboard.create();
}
|
[
"function",
"(",
"elements",
")",
"{",
"var",
"meta",
",",
"client",
"=",
"this",
";",
"client",
".",
"id",
"=",
"\"\"",
"+",
"_clientIdCounter",
"++",
";",
"meta",
"=",
"{",
"instance",
":",
"client",
",",
"elements",
":",
"[",
"]",
",",
"handlers",
":",
"{",
"}",
",",
"coreWildcardHandler",
":",
"function",
"(",
"event",
")",
"{",
"return",
"client",
".",
"emit",
"(",
"event",
")",
";",
"}",
"}",
";",
"_clientMeta",
"[",
"client",
".",
"id",
"]",
"=",
"meta",
";",
"if",
"(",
"elements",
")",
"{",
"client",
".",
"clip",
"(",
"elements",
")",
";",
"}",
"ZeroClipboard",
".",
"on",
"(",
"\"*\"",
",",
"meta",
".",
"coreWildcardHandler",
")",
";",
"ZeroClipboard",
".",
"on",
"(",
"\"destroy\"",
",",
"function",
"(",
")",
"{",
"client",
".",
"destroy",
"(",
")",
";",
"}",
")",
";",
"ZeroClipboard",
".",
"create",
"(",
")",
";",
"}"
] |
The real constructor for `ZeroClipboard` client instances.
@private
|
[
"The",
"real",
"constructor",
"for",
"ZeroClipboard",
"client",
"instances",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L2183-L2203
|
|
11,071
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(eventType, listener) {
var i, len, events, added = {}, client = this, meta = _clientMeta[client.id], handlers = meta && meta.handlers;
if (!meta) {
throw new Error("Attempted to add new listener(s) to a destroyed ZeroClipboard client instance");
}
if (typeof eventType === "string" && eventType) {
events = eventType.toLowerCase().split(/\s+/);
} else if (typeof eventType === "object" && eventType && !("length" in eventType) && typeof listener === "undefined") {
_keys(eventType).forEach(function(key) {
var listener = eventType[key];
if (typeof listener === "function") {
client.on(key, listener);
}
});
}
if (events && events.length && listener) {
for (i = 0, len = events.length; i < len; i++) {
eventType = events[i].replace(/^on/, "");
added[eventType] = true;
if (!handlers[eventType]) {
handlers[eventType] = [];
}
handlers[eventType].push(listener);
}
if (added.ready && _flashState.ready) {
this.emit({
type: "ready",
client: this
});
}
if (added.error) {
for (i = 0, len = _flashStateErrorNames.length; i < len; i++) {
if (_flashState[_flashStateErrorNames[i].replace(/^flash-/, "")]) {
this.emit({
type: "error",
name: _flashStateErrorNames[i],
client: this
});
break;
}
}
if (_zcSwfVersion !== undefined && ZeroClipboard.version !== _zcSwfVersion) {
this.emit({
type: "error",
name: "version-mismatch",
jsVersion: ZeroClipboard.version,
swfVersion: _zcSwfVersion
});
}
}
}
return client;
}
|
javascript
|
function(eventType, listener) {
var i, len, events, added = {}, client = this, meta = _clientMeta[client.id], handlers = meta && meta.handlers;
if (!meta) {
throw new Error("Attempted to add new listener(s) to a destroyed ZeroClipboard client instance");
}
if (typeof eventType === "string" && eventType) {
events = eventType.toLowerCase().split(/\s+/);
} else if (typeof eventType === "object" && eventType && !("length" in eventType) && typeof listener === "undefined") {
_keys(eventType).forEach(function(key) {
var listener = eventType[key];
if (typeof listener === "function") {
client.on(key, listener);
}
});
}
if (events && events.length && listener) {
for (i = 0, len = events.length; i < len; i++) {
eventType = events[i].replace(/^on/, "");
added[eventType] = true;
if (!handlers[eventType]) {
handlers[eventType] = [];
}
handlers[eventType].push(listener);
}
if (added.ready && _flashState.ready) {
this.emit({
type: "ready",
client: this
});
}
if (added.error) {
for (i = 0, len = _flashStateErrorNames.length; i < len; i++) {
if (_flashState[_flashStateErrorNames[i].replace(/^flash-/, "")]) {
this.emit({
type: "error",
name: _flashStateErrorNames[i],
client: this
});
break;
}
}
if (_zcSwfVersion !== undefined && ZeroClipboard.version !== _zcSwfVersion) {
this.emit({
type: "error",
name: "version-mismatch",
jsVersion: ZeroClipboard.version,
swfVersion: _zcSwfVersion
});
}
}
}
return client;
}
|
[
"function",
"(",
"eventType",
",",
"listener",
")",
"{",
"var",
"i",
",",
"len",
",",
"events",
",",
"added",
"=",
"{",
"}",
",",
"client",
"=",
"this",
",",
"meta",
"=",
"_clientMeta",
"[",
"client",
".",
"id",
"]",
",",
"handlers",
"=",
"meta",
"&&",
"meta",
".",
"handlers",
";",
"if",
"(",
"!",
"meta",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Attempted to add new listener(s) to a destroyed ZeroClipboard client instance\"",
")",
";",
"}",
"if",
"(",
"typeof",
"eventType",
"===",
"\"string\"",
"&&",
"eventType",
")",
"{",
"events",
"=",
"eventType",
".",
"toLowerCase",
"(",
")",
".",
"split",
"(",
"/",
"\\s+",
"/",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"eventType",
"===",
"\"object\"",
"&&",
"eventType",
"&&",
"!",
"(",
"\"length\"",
"in",
"eventType",
")",
"&&",
"typeof",
"listener",
"===",
"\"undefined\"",
")",
"{",
"_keys",
"(",
"eventType",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"var",
"listener",
"=",
"eventType",
"[",
"key",
"]",
";",
"if",
"(",
"typeof",
"listener",
"===",
"\"function\"",
")",
"{",
"client",
".",
"on",
"(",
"key",
",",
"listener",
")",
";",
"}",
"}",
")",
";",
"}",
"if",
"(",
"events",
"&&",
"events",
".",
"length",
"&&",
"listener",
")",
"{",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"events",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"eventType",
"=",
"events",
"[",
"i",
"]",
".",
"replace",
"(",
"/",
"^on",
"/",
",",
"\"\"",
")",
";",
"added",
"[",
"eventType",
"]",
"=",
"true",
";",
"if",
"(",
"!",
"handlers",
"[",
"eventType",
"]",
")",
"{",
"handlers",
"[",
"eventType",
"]",
"=",
"[",
"]",
";",
"}",
"handlers",
"[",
"eventType",
"]",
".",
"push",
"(",
"listener",
")",
";",
"}",
"if",
"(",
"added",
".",
"ready",
"&&",
"_flashState",
".",
"ready",
")",
"{",
"this",
".",
"emit",
"(",
"{",
"type",
":",
"\"ready\"",
",",
"client",
":",
"this",
"}",
")",
";",
"}",
"if",
"(",
"added",
".",
"error",
")",
"{",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"_flashStateErrorNames",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"_flashState",
"[",
"_flashStateErrorNames",
"[",
"i",
"]",
".",
"replace",
"(",
"/",
"^flash-",
"/",
",",
"\"\"",
")",
"]",
")",
"{",
"this",
".",
"emit",
"(",
"{",
"type",
":",
"\"error\"",
",",
"name",
":",
"_flashStateErrorNames",
"[",
"i",
"]",
",",
"client",
":",
"this",
"}",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"_zcSwfVersion",
"!==",
"undefined",
"&&",
"ZeroClipboard",
".",
"version",
"!==",
"_zcSwfVersion",
")",
"{",
"this",
".",
"emit",
"(",
"{",
"type",
":",
"\"error\"",
",",
"name",
":",
"\"version-mismatch\"",
",",
"jsVersion",
":",
"ZeroClipboard",
".",
"version",
",",
"swfVersion",
":",
"_zcSwfVersion",
"}",
")",
";",
"}",
"}",
"}",
"return",
"client",
";",
"}"
] |
The underlying implementation of `ZeroClipboard.Client.prototype.on`.
@private
|
[
"The",
"underlying",
"implementation",
"of",
"ZeroClipboard",
".",
"Client",
".",
"prototype",
".",
"on",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L2208-L2260
|
|
11,072
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(eventType, listener) {
var i, len, foundIndex, events, perEventHandlers, client = this, meta = _clientMeta[client.id], handlers = meta && meta.handlers;
if (!handlers) {
return client;
}
if (arguments.length === 0) {
events = _keys(handlers);
} else if (typeof eventType === "string" && eventType) {
events = eventType.split(/\s+/);
} else if (typeof eventType === "object" && eventType && !("length" in eventType) && typeof listener === "undefined") {
_keys(eventType).forEach(function(key) {
var listener = eventType[key];
if (typeof listener === "function") {
client.off(key, listener);
}
});
}
if (events && events.length) {
for (i = 0, len = events.length; i < len; i++) {
eventType = events[i].toLowerCase().replace(/^on/, "");
perEventHandlers = handlers[eventType];
if (perEventHandlers && perEventHandlers.length) {
if (listener) {
foundIndex = perEventHandlers.indexOf(listener);
while (foundIndex !== -1) {
perEventHandlers.splice(foundIndex, 1);
foundIndex = perEventHandlers.indexOf(listener, foundIndex);
}
} else {
perEventHandlers.length = 0;
}
}
}
}
return client;
}
|
javascript
|
function(eventType, listener) {
var i, len, foundIndex, events, perEventHandlers, client = this, meta = _clientMeta[client.id], handlers = meta && meta.handlers;
if (!handlers) {
return client;
}
if (arguments.length === 0) {
events = _keys(handlers);
} else if (typeof eventType === "string" && eventType) {
events = eventType.split(/\s+/);
} else if (typeof eventType === "object" && eventType && !("length" in eventType) && typeof listener === "undefined") {
_keys(eventType).forEach(function(key) {
var listener = eventType[key];
if (typeof listener === "function") {
client.off(key, listener);
}
});
}
if (events && events.length) {
for (i = 0, len = events.length; i < len; i++) {
eventType = events[i].toLowerCase().replace(/^on/, "");
perEventHandlers = handlers[eventType];
if (perEventHandlers && perEventHandlers.length) {
if (listener) {
foundIndex = perEventHandlers.indexOf(listener);
while (foundIndex !== -1) {
perEventHandlers.splice(foundIndex, 1);
foundIndex = perEventHandlers.indexOf(listener, foundIndex);
}
} else {
perEventHandlers.length = 0;
}
}
}
}
return client;
}
|
[
"function",
"(",
"eventType",
",",
"listener",
")",
"{",
"var",
"i",
",",
"len",
",",
"foundIndex",
",",
"events",
",",
"perEventHandlers",
",",
"client",
"=",
"this",
",",
"meta",
"=",
"_clientMeta",
"[",
"client",
".",
"id",
"]",
",",
"handlers",
"=",
"meta",
"&&",
"meta",
".",
"handlers",
";",
"if",
"(",
"!",
"handlers",
")",
"{",
"return",
"client",
";",
"}",
"if",
"(",
"arguments",
".",
"length",
"===",
"0",
")",
"{",
"events",
"=",
"_keys",
"(",
"handlers",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"eventType",
"===",
"\"string\"",
"&&",
"eventType",
")",
"{",
"events",
"=",
"eventType",
".",
"split",
"(",
"/",
"\\s+",
"/",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"eventType",
"===",
"\"object\"",
"&&",
"eventType",
"&&",
"!",
"(",
"\"length\"",
"in",
"eventType",
")",
"&&",
"typeof",
"listener",
"===",
"\"undefined\"",
")",
"{",
"_keys",
"(",
"eventType",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"var",
"listener",
"=",
"eventType",
"[",
"key",
"]",
";",
"if",
"(",
"typeof",
"listener",
"===",
"\"function\"",
")",
"{",
"client",
".",
"off",
"(",
"key",
",",
"listener",
")",
";",
"}",
"}",
")",
";",
"}",
"if",
"(",
"events",
"&&",
"events",
".",
"length",
")",
"{",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"events",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"eventType",
"=",
"events",
"[",
"i",
"]",
".",
"toLowerCase",
"(",
")",
".",
"replace",
"(",
"/",
"^on",
"/",
",",
"\"\"",
")",
";",
"perEventHandlers",
"=",
"handlers",
"[",
"eventType",
"]",
";",
"if",
"(",
"perEventHandlers",
"&&",
"perEventHandlers",
".",
"length",
")",
"{",
"if",
"(",
"listener",
")",
"{",
"foundIndex",
"=",
"perEventHandlers",
".",
"indexOf",
"(",
"listener",
")",
";",
"while",
"(",
"foundIndex",
"!==",
"-",
"1",
")",
"{",
"perEventHandlers",
".",
"splice",
"(",
"foundIndex",
",",
"1",
")",
";",
"foundIndex",
"=",
"perEventHandlers",
".",
"indexOf",
"(",
"listener",
",",
"foundIndex",
")",
";",
"}",
"}",
"else",
"{",
"perEventHandlers",
".",
"length",
"=",
"0",
";",
"}",
"}",
"}",
"}",
"return",
"client",
";",
"}"
] |
The underlying implementation of `ZeroClipboard.Client.prototype.off`.
@private
|
[
"The",
"underlying",
"implementation",
"of",
"ZeroClipboard",
".",
"Client",
".",
"prototype",
".",
"off",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L2265-L2300
|
|
11,073
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(eventType) {
var copy = null, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers;
if (handlers) {
if (typeof eventType === "string" && eventType) {
copy = handlers[eventType] ? handlers[eventType].slice(0) : [];
} else {
copy = _deepCopy(handlers);
}
}
return copy;
}
|
javascript
|
function(eventType) {
var copy = null, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers;
if (handlers) {
if (typeof eventType === "string" && eventType) {
copy = handlers[eventType] ? handlers[eventType].slice(0) : [];
} else {
copy = _deepCopy(handlers);
}
}
return copy;
}
|
[
"function",
"(",
"eventType",
")",
"{",
"var",
"copy",
"=",
"null",
",",
"handlers",
"=",
"_clientMeta",
"[",
"this",
".",
"id",
"]",
"&&",
"_clientMeta",
"[",
"this",
".",
"id",
"]",
".",
"handlers",
";",
"if",
"(",
"handlers",
")",
"{",
"if",
"(",
"typeof",
"eventType",
"===",
"\"string\"",
"&&",
"eventType",
")",
"{",
"copy",
"=",
"handlers",
"[",
"eventType",
"]",
"?",
"handlers",
"[",
"eventType",
"]",
".",
"slice",
"(",
"0",
")",
":",
"[",
"]",
";",
"}",
"else",
"{",
"copy",
"=",
"_deepCopy",
"(",
"handlers",
")",
";",
"}",
"}",
"return",
"copy",
";",
"}"
] |
The underlying implementation of `ZeroClipboard.Client.prototype.handlers`.
@private
|
[
"The",
"underlying",
"implementation",
"of",
"ZeroClipboard",
".",
"Client",
".",
"prototype",
".",
"handlers",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L2305-L2315
|
|
11,074
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(event) {
var eventCopy, client = this;
if (_clientShouldEmit.call(client, event)) {
if (typeof event === "object" && event && typeof event.type === "string" && event.type) {
event = _extend({}, event);
}
eventCopy = _extend({}, _createEvent(event), {
client: client
});
_clientDispatchCallbacks.call(client, eventCopy);
}
return client;
}
|
javascript
|
function(event) {
var eventCopy, client = this;
if (_clientShouldEmit.call(client, event)) {
if (typeof event === "object" && event && typeof event.type === "string" && event.type) {
event = _extend({}, event);
}
eventCopy = _extend({}, _createEvent(event), {
client: client
});
_clientDispatchCallbacks.call(client, eventCopy);
}
return client;
}
|
[
"function",
"(",
"event",
")",
"{",
"var",
"eventCopy",
",",
"client",
"=",
"this",
";",
"if",
"(",
"_clientShouldEmit",
".",
"call",
"(",
"client",
",",
"event",
")",
")",
"{",
"if",
"(",
"typeof",
"event",
"===",
"\"object\"",
"&&",
"event",
"&&",
"typeof",
"event",
".",
"type",
"===",
"\"string\"",
"&&",
"event",
".",
"type",
")",
"{",
"event",
"=",
"_extend",
"(",
"{",
"}",
",",
"event",
")",
";",
"}",
"eventCopy",
"=",
"_extend",
"(",
"{",
"}",
",",
"_createEvent",
"(",
"event",
")",
",",
"{",
"client",
":",
"client",
"}",
")",
";",
"_clientDispatchCallbacks",
".",
"call",
"(",
"client",
",",
"eventCopy",
")",
";",
"}",
"return",
"client",
";",
"}"
] |
The underlying implementation of `ZeroClipboard.Client.prototype.emit`.
@private
|
[
"The",
"underlying",
"implementation",
"of",
"ZeroClipboard",
".",
"Client",
".",
"prototype",
".",
"emit",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L2320-L2332
|
|
11,075
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(elements) {
if (!_clientMeta[this.id]) {
throw new Error("Attempted to clip element(s) to a destroyed ZeroClipboard client instance");
}
elements = _prepClip(elements);
for (var i = 0; i < elements.length; i++) {
if (_hasOwn.call(elements, i) && elements[i] && elements[i].nodeType === 1) {
if (!elements[i].zcClippingId) {
elements[i].zcClippingId = "zcClippingId_" + _elementIdCounter++;
_elementMeta[elements[i].zcClippingId] = [ this.id ];
if (_globalConfig.autoActivate === true) {
_addMouseHandlers(elements[i]);
}
} else if (_elementMeta[elements[i].zcClippingId].indexOf(this.id) === -1) {
_elementMeta[elements[i].zcClippingId].push(this.id);
}
var clippedElements = _clientMeta[this.id] && _clientMeta[this.id].elements;
if (clippedElements.indexOf(elements[i]) === -1) {
clippedElements.push(elements[i]);
}
}
}
return this;
}
|
javascript
|
function(elements) {
if (!_clientMeta[this.id]) {
throw new Error("Attempted to clip element(s) to a destroyed ZeroClipboard client instance");
}
elements = _prepClip(elements);
for (var i = 0; i < elements.length; i++) {
if (_hasOwn.call(elements, i) && elements[i] && elements[i].nodeType === 1) {
if (!elements[i].zcClippingId) {
elements[i].zcClippingId = "zcClippingId_" + _elementIdCounter++;
_elementMeta[elements[i].zcClippingId] = [ this.id ];
if (_globalConfig.autoActivate === true) {
_addMouseHandlers(elements[i]);
}
} else if (_elementMeta[elements[i].zcClippingId].indexOf(this.id) === -1) {
_elementMeta[elements[i].zcClippingId].push(this.id);
}
var clippedElements = _clientMeta[this.id] && _clientMeta[this.id].elements;
if (clippedElements.indexOf(elements[i]) === -1) {
clippedElements.push(elements[i]);
}
}
}
return this;
}
|
[
"function",
"(",
"elements",
")",
"{",
"if",
"(",
"!",
"_clientMeta",
"[",
"this",
".",
"id",
"]",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Attempted to clip element(s) to a destroyed ZeroClipboard client instance\"",
")",
";",
"}",
"elements",
"=",
"_prepClip",
"(",
"elements",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"elements",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"_hasOwn",
".",
"call",
"(",
"elements",
",",
"i",
")",
"&&",
"elements",
"[",
"i",
"]",
"&&",
"elements",
"[",
"i",
"]",
".",
"nodeType",
"===",
"1",
")",
"{",
"if",
"(",
"!",
"elements",
"[",
"i",
"]",
".",
"zcClippingId",
")",
"{",
"elements",
"[",
"i",
"]",
".",
"zcClippingId",
"=",
"\"zcClippingId_\"",
"+",
"_elementIdCounter",
"++",
";",
"_elementMeta",
"[",
"elements",
"[",
"i",
"]",
".",
"zcClippingId",
"]",
"=",
"[",
"this",
".",
"id",
"]",
";",
"if",
"(",
"_globalConfig",
".",
"autoActivate",
"===",
"true",
")",
"{",
"_addMouseHandlers",
"(",
"elements",
"[",
"i",
"]",
")",
";",
"}",
"}",
"else",
"if",
"(",
"_elementMeta",
"[",
"elements",
"[",
"i",
"]",
".",
"zcClippingId",
"]",
".",
"indexOf",
"(",
"this",
".",
"id",
")",
"===",
"-",
"1",
")",
"{",
"_elementMeta",
"[",
"elements",
"[",
"i",
"]",
".",
"zcClippingId",
"]",
".",
"push",
"(",
"this",
".",
"id",
")",
";",
"}",
"var",
"clippedElements",
"=",
"_clientMeta",
"[",
"this",
".",
"id",
"]",
"&&",
"_clientMeta",
"[",
"this",
".",
"id",
"]",
".",
"elements",
";",
"if",
"(",
"clippedElements",
".",
"indexOf",
"(",
"elements",
"[",
"i",
"]",
")",
"===",
"-",
"1",
")",
"{",
"clippedElements",
".",
"push",
"(",
"elements",
"[",
"i",
"]",
")",
";",
"}",
"}",
"}",
"return",
"this",
";",
"}"
] |
The underlying implementation of `ZeroClipboard.Client.prototype.clip`.
@private
|
[
"The",
"underlying",
"implementation",
"of",
"ZeroClipboard",
".",
"Client",
".",
"prototype",
".",
"clip",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L2337-L2360
|
|
11,076
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(elements) {
var meta = _clientMeta[this.id];
if (!meta) {
return this;
}
var clippedElements = meta.elements;
var arrayIndex;
if (typeof elements === "undefined") {
elements = clippedElements.slice(0);
} else {
elements = _prepClip(elements);
}
for (var i = elements.length; i--; ) {
if (_hasOwn.call(elements, i) && elements[i] && elements[i].nodeType === 1) {
arrayIndex = 0;
while ((arrayIndex = clippedElements.indexOf(elements[i], arrayIndex)) !== -1) {
clippedElements.splice(arrayIndex, 1);
}
var clientIds = _elementMeta[elements[i].zcClippingId];
if (clientIds) {
arrayIndex = 0;
while ((arrayIndex = clientIds.indexOf(this.id, arrayIndex)) !== -1) {
clientIds.splice(arrayIndex, 1);
}
if (clientIds.length === 0) {
if (_globalConfig.autoActivate === true) {
_removeMouseHandlers(elements[i]);
}
delete elements[i].zcClippingId;
}
}
}
}
return this;
}
|
javascript
|
function(elements) {
var meta = _clientMeta[this.id];
if (!meta) {
return this;
}
var clippedElements = meta.elements;
var arrayIndex;
if (typeof elements === "undefined") {
elements = clippedElements.slice(0);
} else {
elements = _prepClip(elements);
}
for (var i = elements.length; i--; ) {
if (_hasOwn.call(elements, i) && elements[i] && elements[i].nodeType === 1) {
arrayIndex = 0;
while ((arrayIndex = clippedElements.indexOf(elements[i], arrayIndex)) !== -1) {
clippedElements.splice(arrayIndex, 1);
}
var clientIds = _elementMeta[elements[i].zcClippingId];
if (clientIds) {
arrayIndex = 0;
while ((arrayIndex = clientIds.indexOf(this.id, arrayIndex)) !== -1) {
clientIds.splice(arrayIndex, 1);
}
if (clientIds.length === 0) {
if (_globalConfig.autoActivate === true) {
_removeMouseHandlers(elements[i]);
}
delete elements[i].zcClippingId;
}
}
}
}
return this;
}
|
[
"function",
"(",
"elements",
")",
"{",
"var",
"meta",
"=",
"_clientMeta",
"[",
"this",
".",
"id",
"]",
";",
"if",
"(",
"!",
"meta",
")",
"{",
"return",
"this",
";",
"}",
"var",
"clippedElements",
"=",
"meta",
".",
"elements",
";",
"var",
"arrayIndex",
";",
"if",
"(",
"typeof",
"elements",
"===",
"\"undefined\"",
")",
"{",
"elements",
"=",
"clippedElements",
".",
"slice",
"(",
"0",
")",
";",
"}",
"else",
"{",
"elements",
"=",
"_prepClip",
"(",
"elements",
")",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"elements",
".",
"length",
";",
"i",
"--",
";",
")",
"{",
"if",
"(",
"_hasOwn",
".",
"call",
"(",
"elements",
",",
"i",
")",
"&&",
"elements",
"[",
"i",
"]",
"&&",
"elements",
"[",
"i",
"]",
".",
"nodeType",
"===",
"1",
")",
"{",
"arrayIndex",
"=",
"0",
";",
"while",
"(",
"(",
"arrayIndex",
"=",
"clippedElements",
".",
"indexOf",
"(",
"elements",
"[",
"i",
"]",
",",
"arrayIndex",
")",
")",
"!==",
"-",
"1",
")",
"{",
"clippedElements",
".",
"splice",
"(",
"arrayIndex",
",",
"1",
")",
";",
"}",
"var",
"clientIds",
"=",
"_elementMeta",
"[",
"elements",
"[",
"i",
"]",
".",
"zcClippingId",
"]",
";",
"if",
"(",
"clientIds",
")",
"{",
"arrayIndex",
"=",
"0",
";",
"while",
"(",
"(",
"arrayIndex",
"=",
"clientIds",
".",
"indexOf",
"(",
"this",
".",
"id",
",",
"arrayIndex",
")",
")",
"!==",
"-",
"1",
")",
"{",
"clientIds",
".",
"splice",
"(",
"arrayIndex",
",",
"1",
")",
";",
"}",
"if",
"(",
"clientIds",
".",
"length",
"===",
"0",
")",
"{",
"if",
"(",
"_globalConfig",
".",
"autoActivate",
"===",
"true",
")",
"{",
"_removeMouseHandlers",
"(",
"elements",
"[",
"i",
"]",
")",
";",
"}",
"delete",
"elements",
"[",
"i",
"]",
".",
"zcClippingId",
";",
"}",
"}",
"}",
"}",
"return",
"this",
";",
"}"
] |
The underlying implementation of `ZeroClipboard.Client.prototype.unclip`.
@private
|
[
"The",
"underlying",
"implementation",
"of",
"ZeroClipboard",
".",
"Client",
".",
"prototype",
".",
"unclip",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L2365-L2399
|
|
11,077
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function() {
var meta = _clientMeta[this.id];
if (!meta) {
return;
}
this.unclip();
this.off();
ZeroClipboard.off("*", meta.coreWildcardHandler);
delete _clientMeta[this.id];
}
|
javascript
|
function() {
var meta = _clientMeta[this.id];
if (!meta) {
return;
}
this.unclip();
this.off();
ZeroClipboard.off("*", meta.coreWildcardHandler);
delete _clientMeta[this.id];
}
|
[
"function",
"(",
")",
"{",
"var",
"meta",
"=",
"_clientMeta",
"[",
"this",
".",
"id",
"]",
";",
"if",
"(",
"!",
"meta",
")",
"{",
"return",
";",
"}",
"this",
".",
"unclip",
"(",
")",
";",
"this",
".",
"off",
"(",
")",
";",
"ZeroClipboard",
".",
"off",
"(",
"\"*\"",
",",
"meta",
".",
"coreWildcardHandler",
")",
";",
"delete",
"_clientMeta",
"[",
"this",
".",
"id",
"]",
";",
"}"
] |
The underlying implementation of `ZeroClipboard.Client.prototype.destroy`.
@private
|
[
"The",
"underlying",
"implementation",
"of",
"ZeroClipboard",
".",
"Client",
".",
"prototype",
".",
"destroy",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L2412-L2421
|
|
11,078
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(event) {
var meta = _clientMeta[this.id];
if (!(typeof event === "object" && event && event.type && meta)) {
return;
}
var async = _shouldPerformAsync(event);
var wildcardTypeHandlers = meta && meta.handlers["*"] || [];
var specificTypeHandlers = meta && meta.handlers[event.type] || [];
var handlers = wildcardTypeHandlers.concat(specificTypeHandlers);
if (handlers && handlers.length) {
var i, len, func, context, eventCopy, originalContext = this;
for (i = 0, len = handlers.length; i < len; i++) {
func = handlers[i];
context = originalContext;
if (typeof func === "string" && typeof _window[func] === "function") {
func = _window[func];
}
if (typeof func === "object" && func && typeof func.handleEvent === "function") {
context = func;
func = func.handleEvent;
}
if (typeof func === "function") {
eventCopy = _extend({}, event);
_dispatchCallback(func, context, [ eventCopy ], async);
}
}
}
}
|
javascript
|
function(event) {
var meta = _clientMeta[this.id];
if (!(typeof event === "object" && event && event.type && meta)) {
return;
}
var async = _shouldPerformAsync(event);
var wildcardTypeHandlers = meta && meta.handlers["*"] || [];
var specificTypeHandlers = meta && meta.handlers[event.type] || [];
var handlers = wildcardTypeHandlers.concat(specificTypeHandlers);
if (handlers && handlers.length) {
var i, len, func, context, eventCopy, originalContext = this;
for (i = 0, len = handlers.length; i < len; i++) {
func = handlers[i];
context = originalContext;
if (typeof func === "string" && typeof _window[func] === "function") {
func = _window[func];
}
if (typeof func === "object" && func && typeof func.handleEvent === "function") {
context = func;
func = func.handleEvent;
}
if (typeof func === "function") {
eventCopy = _extend({}, event);
_dispatchCallback(func, context, [ eventCopy ], async);
}
}
}
}
|
[
"function",
"(",
"event",
")",
"{",
"var",
"meta",
"=",
"_clientMeta",
"[",
"this",
".",
"id",
"]",
";",
"if",
"(",
"!",
"(",
"typeof",
"event",
"===",
"\"object\"",
"&&",
"event",
"&&",
"event",
".",
"type",
"&&",
"meta",
")",
")",
"{",
"return",
";",
"}",
"var",
"async",
"=",
"_shouldPerformAsync",
"(",
"event",
")",
";",
"var",
"wildcardTypeHandlers",
"=",
"meta",
"&&",
"meta",
".",
"handlers",
"[",
"\"*\"",
"]",
"||",
"[",
"]",
";",
"var",
"specificTypeHandlers",
"=",
"meta",
"&&",
"meta",
".",
"handlers",
"[",
"event",
".",
"type",
"]",
"||",
"[",
"]",
";",
"var",
"handlers",
"=",
"wildcardTypeHandlers",
".",
"concat",
"(",
"specificTypeHandlers",
")",
";",
"if",
"(",
"handlers",
"&&",
"handlers",
".",
"length",
")",
"{",
"var",
"i",
",",
"len",
",",
"func",
",",
"context",
",",
"eventCopy",
",",
"originalContext",
"=",
"this",
";",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"handlers",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"func",
"=",
"handlers",
"[",
"i",
"]",
";",
"context",
"=",
"originalContext",
";",
"if",
"(",
"typeof",
"func",
"===",
"\"string\"",
"&&",
"typeof",
"_window",
"[",
"func",
"]",
"===",
"\"function\"",
")",
"{",
"func",
"=",
"_window",
"[",
"func",
"]",
";",
"}",
"if",
"(",
"typeof",
"func",
"===",
"\"object\"",
"&&",
"func",
"&&",
"typeof",
"func",
".",
"handleEvent",
"===",
"\"function\"",
")",
"{",
"context",
"=",
"func",
";",
"func",
"=",
"func",
".",
"handleEvent",
";",
"}",
"if",
"(",
"typeof",
"func",
"===",
"\"function\"",
")",
"{",
"eventCopy",
"=",
"_extend",
"(",
"{",
"}",
",",
"event",
")",
";",
"_dispatchCallback",
"(",
"func",
",",
"context",
",",
"[",
"eventCopy",
"]",
",",
"async",
")",
";",
"}",
"}",
"}",
"}"
] |
Handle the actual dispatching of events to a client instance.
@returns `undefined`
@private
|
[
"Handle",
"the",
"actual",
"dispatching",
"of",
"events",
"to",
"a",
"client",
"instance",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L2450-L2477
|
|
11,079
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(element) {
if (!(element && element.nodeType === 1)) {
return;
}
var _suppressMouseEvents = function(event) {
if (!(event || (event = _window.event))) {
return;
}
if (event._source !== "js") {
event.stopImmediatePropagation();
event.preventDefault();
}
delete event._source;
};
var _elementMouseOver = function(event) {
if (!(event || (event = _window.event))) {
return;
}
_suppressMouseEvents(event);
ZeroClipboard.focus(element);
};
element.addEventListener("mouseover", _elementMouseOver, false);
element.addEventListener("mouseout", _suppressMouseEvents, false);
element.addEventListener("mouseenter", _suppressMouseEvents, false);
element.addEventListener("mouseleave", _suppressMouseEvents, false);
element.addEventListener("mousemove", _suppressMouseEvents, false);
_mouseHandlers[element.zcClippingId] = {
mouseover: _elementMouseOver,
mouseout: _suppressMouseEvents,
mouseenter: _suppressMouseEvents,
mouseleave: _suppressMouseEvents,
mousemove: _suppressMouseEvents
};
}
|
javascript
|
function(element) {
if (!(element && element.nodeType === 1)) {
return;
}
var _suppressMouseEvents = function(event) {
if (!(event || (event = _window.event))) {
return;
}
if (event._source !== "js") {
event.stopImmediatePropagation();
event.preventDefault();
}
delete event._source;
};
var _elementMouseOver = function(event) {
if (!(event || (event = _window.event))) {
return;
}
_suppressMouseEvents(event);
ZeroClipboard.focus(element);
};
element.addEventListener("mouseover", _elementMouseOver, false);
element.addEventListener("mouseout", _suppressMouseEvents, false);
element.addEventListener("mouseenter", _suppressMouseEvents, false);
element.addEventListener("mouseleave", _suppressMouseEvents, false);
element.addEventListener("mousemove", _suppressMouseEvents, false);
_mouseHandlers[element.zcClippingId] = {
mouseover: _elementMouseOver,
mouseout: _suppressMouseEvents,
mouseenter: _suppressMouseEvents,
mouseleave: _suppressMouseEvents,
mousemove: _suppressMouseEvents
};
}
|
[
"function",
"(",
"element",
")",
"{",
"if",
"(",
"!",
"(",
"element",
"&&",
"element",
".",
"nodeType",
"===",
"1",
")",
")",
"{",
"return",
";",
"}",
"var",
"_suppressMouseEvents",
"=",
"function",
"(",
"event",
")",
"{",
"if",
"(",
"!",
"(",
"event",
"||",
"(",
"event",
"=",
"_window",
".",
"event",
")",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"event",
".",
"_source",
"!==",
"\"js\"",
")",
"{",
"event",
".",
"stopImmediatePropagation",
"(",
")",
";",
"event",
".",
"preventDefault",
"(",
")",
";",
"}",
"delete",
"event",
".",
"_source",
";",
"}",
";",
"var",
"_elementMouseOver",
"=",
"function",
"(",
"event",
")",
"{",
"if",
"(",
"!",
"(",
"event",
"||",
"(",
"event",
"=",
"_window",
".",
"event",
")",
")",
")",
"{",
"return",
";",
"}",
"_suppressMouseEvents",
"(",
"event",
")",
";",
"ZeroClipboard",
".",
"focus",
"(",
"element",
")",
";",
"}",
";",
"element",
".",
"addEventListener",
"(",
"\"mouseover\"",
",",
"_elementMouseOver",
",",
"false",
")",
";",
"element",
".",
"addEventListener",
"(",
"\"mouseout\"",
",",
"_suppressMouseEvents",
",",
"false",
")",
";",
"element",
".",
"addEventListener",
"(",
"\"mouseenter\"",
",",
"_suppressMouseEvents",
",",
"false",
")",
";",
"element",
".",
"addEventListener",
"(",
"\"mouseleave\"",
",",
"_suppressMouseEvents",
",",
"false",
")",
";",
"element",
".",
"addEventListener",
"(",
"\"mousemove\"",
",",
"_suppressMouseEvents",
",",
"false",
")",
";",
"_mouseHandlers",
"[",
"element",
".",
"zcClippingId",
"]",
"=",
"{",
"mouseover",
":",
"_elementMouseOver",
",",
"mouseout",
":",
"_suppressMouseEvents",
",",
"mouseenter",
":",
"_suppressMouseEvents",
",",
"mouseleave",
":",
"_suppressMouseEvents",
",",
"mousemove",
":",
"_suppressMouseEvents",
"}",
";",
"}"
] |
Add a `mouseover` handler function for a clipped element.
@returns `undefined`
@private
|
[
"Add",
"a",
"mouseover",
"handler",
"function",
"for",
"a",
"clipped",
"element",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L2496-L2529
|
|
11,080
|
zeroclipboard/zeroclipboard
|
dist/ZeroClipboard.js
|
function(element) {
if (!(element && element.nodeType === 1)) {
return;
}
var mouseHandlers = _mouseHandlers[element.zcClippingId];
if (!(typeof mouseHandlers === "object" && mouseHandlers)) {
return;
}
var key, val, mouseEvents = [ "move", "leave", "enter", "out", "over" ];
for (var i = 0, len = mouseEvents.length; i < len; i++) {
key = "mouse" + mouseEvents[i];
val = mouseHandlers[key];
if (typeof val === "function") {
element.removeEventListener(key, val, false);
}
}
delete _mouseHandlers[element.zcClippingId];
}
|
javascript
|
function(element) {
if (!(element && element.nodeType === 1)) {
return;
}
var mouseHandlers = _mouseHandlers[element.zcClippingId];
if (!(typeof mouseHandlers === "object" && mouseHandlers)) {
return;
}
var key, val, mouseEvents = [ "move", "leave", "enter", "out", "over" ];
for (var i = 0, len = mouseEvents.length; i < len; i++) {
key = "mouse" + mouseEvents[i];
val = mouseHandlers[key];
if (typeof val === "function") {
element.removeEventListener(key, val, false);
}
}
delete _mouseHandlers[element.zcClippingId];
}
|
[
"function",
"(",
"element",
")",
"{",
"if",
"(",
"!",
"(",
"element",
"&&",
"element",
".",
"nodeType",
"===",
"1",
")",
")",
"{",
"return",
";",
"}",
"var",
"mouseHandlers",
"=",
"_mouseHandlers",
"[",
"element",
".",
"zcClippingId",
"]",
";",
"if",
"(",
"!",
"(",
"typeof",
"mouseHandlers",
"===",
"\"object\"",
"&&",
"mouseHandlers",
")",
")",
"{",
"return",
";",
"}",
"var",
"key",
",",
"val",
",",
"mouseEvents",
"=",
"[",
"\"move\"",
",",
"\"leave\"",
",",
"\"enter\"",
",",
"\"out\"",
",",
"\"over\"",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"mouseEvents",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"key",
"=",
"\"mouse\"",
"+",
"mouseEvents",
"[",
"i",
"]",
";",
"val",
"=",
"mouseHandlers",
"[",
"key",
"]",
";",
"if",
"(",
"typeof",
"val",
"===",
"\"function\"",
")",
"{",
"element",
".",
"removeEventListener",
"(",
"key",
",",
"val",
",",
"false",
")",
";",
"}",
"}",
"delete",
"_mouseHandlers",
"[",
"element",
".",
"zcClippingId",
"]",
";",
"}"
] |
Remove a `mouseover` handler function for a clipped element.
@returns `undefined`
@private
|
[
"Remove",
"a",
"mouseover",
"handler",
"function",
"for",
"a",
"clipped",
"element",
"."
] |
09660421dd377fda5bd66ce9bb69c916470bfbb5
|
https://github.com/zeroclipboard/zeroclipboard/blob/09660421dd377fda5bd66ce9bb69c916470bfbb5/dist/ZeroClipboard.js#L2536-L2553
|
|
11,081
|
whitedogg13/react-native-nfc-manager
|
ndef-lib/ndef-text.js
|
decode
|
function decode(data) {
var languageCodeLength = (data[0] & 0x3F), // 6 LSBs
languageCode = data.slice(1, 1 + languageCodeLength),
utf16 = (data[0] & 0x80) !== 0; // assuming UTF-16BE
// TODO need to deal with UTF in the future
// console.log("lang " + languageCode + (utf16 ? " utf16" : " utf8"));
return util.bytesToString(data.slice(languageCodeLength + 1));
}
|
javascript
|
function decode(data) {
var languageCodeLength = (data[0] & 0x3F), // 6 LSBs
languageCode = data.slice(1, 1 + languageCodeLength),
utf16 = (data[0] & 0x80) !== 0; // assuming UTF-16BE
// TODO need to deal with UTF in the future
// console.log("lang " + languageCode + (utf16 ? " utf16" : " utf8"));
return util.bytesToString(data.slice(languageCodeLength + 1));
}
|
[
"function",
"decode",
"(",
"data",
")",
"{",
"var",
"languageCodeLength",
"=",
"(",
"data",
"[",
"0",
"]",
"&",
"0x3F",
")",
",",
"// 6 LSBs",
"languageCode",
"=",
"data",
".",
"slice",
"(",
"1",
",",
"1",
"+",
"languageCodeLength",
")",
",",
"utf16",
"=",
"(",
"data",
"[",
"0",
"]",
"&",
"0x80",
")",
"!==",
"0",
";",
"// assuming UTF-16BE",
"// TODO need to deal with UTF in the future",
"// console.log(\"lang \" + languageCode + (utf16 ? \" utf16\" : \" utf8\"));",
"return",
"util",
".",
"bytesToString",
"(",
"data",
".",
"slice",
"(",
"languageCodeLength",
"+",
"1",
")",
")",
";",
"}"
] |
decode text bytes from ndef record payload @returns a string
|
[
"decode",
"text",
"bytes",
"from",
"ndef",
"record",
"payload"
] |
77ad9a17be20c89e0a45956870c4e9d732981dee
|
https://github.com/whitedogg13/react-native-nfc-manager/blob/77ad9a17be20c89e0a45956870c4e9d732981dee/ndef-lib/ndef-text.js#L5-L15
|
11,082
|
whitedogg13/react-native-nfc-manager
|
ndef-lib/ndef-text.js
|
encode
|
function encode(text, lang, encoding) {
// ISO/IANA language code, but we're not enforcing
if (!lang) { lang = 'en'; }
var encoded = util.stringToBytes(lang + text);
encoded.unshift(lang.length);
return encoded;
}
|
javascript
|
function encode(text, lang, encoding) {
// ISO/IANA language code, but we're not enforcing
if (!lang) { lang = 'en'; }
var encoded = util.stringToBytes(lang + text);
encoded.unshift(lang.length);
return encoded;
}
|
[
"function",
"encode",
"(",
"text",
",",
"lang",
",",
"encoding",
")",
"{",
"// ISO/IANA language code, but we're not enforcing",
"if",
"(",
"!",
"lang",
")",
"{",
"lang",
"=",
"'en'",
";",
"}",
"var",
"encoded",
"=",
"util",
".",
"stringToBytes",
"(",
"lang",
"+",
"text",
")",
";",
"encoded",
".",
"unshift",
"(",
"lang",
".",
"length",
")",
";",
"return",
"encoded",
";",
"}"
] |
encode text payload @returns an array of bytes
|
[
"encode",
"text",
"payload"
] |
77ad9a17be20c89e0a45956870c4e9d732981dee
|
https://github.com/whitedogg13/react-native-nfc-manager/blob/77ad9a17be20c89e0a45956870c4e9d732981dee/ndef-lib/ndef-text.js#L19-L28
|
11,083
|
whitedogg13/react-native-nfc-manager
|
ndef-lib/index.js
|
function (text, languageCode, id) {
var payload = textHelper.encodePayload(text, languageCode);
if (!id) { id = []; }
return ndef.record(ndef.TNF_WELL_KNOWN, ndef.RTD_TEXT, id, payload);
}
|
javascript
|
function (text, languageCode, id) {
var payload = textHelper.encodePayload(text, languageCode);
if (!id) { id = []; }
return ndef.record(ndef.TNF_WELL_KNOWN, ndef.RTD_TEXT, id, payload);
}
|
[
"function",
"(",
"text",
",",
"languageCode",
",",
"id",
")",
"{",
"var",
"payload",
"=",
"textHelper",
".",
"encodePayload",
"(",
"text",
",",
"languageCode",
")",
";",
"if",
"(",
"!",
"id",
")",
"{",
"id",
"=",
"[",
"]",
";",
"}",
"return",
"ndef",
".",
"record",
"(",
"ndef",
".",
"TNF_WELL_KNOWN",
",",
"ndef",
".",
"RTD_TEXT",
",",
"id",
",",
"payload",
")",
";",
"}"
] |
Helper that creates an NDEF record containing plain text.
@text String of text to encode
@languageCode ISO/IANA language code. Examples: “fi”, “en-US”, “fr-CA”, “jp”. (optional)
@id byte[] (optional)
|
[
"Helper",
"that",
"creates",
"an",
"NDEF",
"record",
"containing",
"plain",
"text",
"."
] |
77ad9a17be20c89e0a45956870c4e9d732981dee
|
https://github.com/whitedogg13/react-native-nfc-manager/blob/77ad9a17be20c89e0a45956870c4e9d732981dee/ndef-lib/index.js#L96-L101
|
|
11,084
|
whitedogg13/react-native-nfc-manager
|
ndef-lib/index.js
|
function (uri, id) {
var payload = uriHelper.encodePayload(uri);
if (!id) { id = []; }
return ndef.record(ndef.TNF_WELL_KNOWN, ndef.RTD_URI, id, payload);
}
|
javascript
|
function (uri, id) {
var payload = uriHelper.encodePayload(uri);
if (!id) { id = []; }
return ndef.record(ndef.TNF_WELL_KNOWN, ndef.RTD_URI, id, payload);
}
|
[
"function",
"(",
"uri",
",",
"id",
")",
"{",
"var",
"payload",
"=",
"uriHelper",
".",
"encodePayload",
"(",
"uri",
")",
";",
"if",
"(",
"!",
"id",
")",
"{",
"id",
"=",
"[",
"]",
";",
"}",
"return",
"ndef",
".",
"record",
"(",
"ndef",
".",
"TNF_WELL_KNOWN",
",",
"ndef",
".",
"RTD_URI",
",",
"id",
",",
"payload",
")",
";",
"}"
] |
Helper that creates a NDEF record containing a URI.
@uri String
@id byte[] (optional)
|
[
"Helper",
"that",
"creates",
"a",
"NDEF",
"record",
"containing",
"a",
"URI",
"."
] |
77ad9a17be20c89e0a45956870c4e9d732981dee
|
https://github.com/whitedogg13/react-native-nfc-manager/blob/77ad9a17be20c89e0a45956870c4e9d732981dee/ndef-lib/index.js#L109-L113
|
|
11,085
|
whitedogg13/react-native-nfc-manager
|
ndef-lib/index.js
|
function (uri, payload, id) {
if (!id) { id = []; }
if (!payload) { payload = []; }
return ndef.record(ndef.TNF_ABSOLUTE_URI, uri, id, payload);
}
|
javascript
|
function (uri, payload, id) {
if (!id) { id = []; }
if (!payload) { payload = []; }
return ndef.record(ndef.TNF_ABSOLUTE_URI, uri, id, payload);
}
|
[
"function",
"(",
"uri",
",",
"payload",
",",
"id",
")",
"{",
"if",
"(",
"!",
"id",
")",
"{",
"id",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"payload",
")",
"{",
"payload",
"=",
"[",
"]",
";",
"}",
"return",
"ndef",
".",
"record",
"(",
"ndef",
".",
"TNF_ABSOLUTE_URI",
",",
"uri",
",",
"id",
",",
"payload",
")",
";",
"}"
] |
Helper that creates a NDEF record containing an absolute URI.
An Absolute URI record means the URI describes the payload of the record.
For example a SOAP message could use "http://schemas.xmlsoap.org/soap/envelope/"
as the type and XML content for the payload.
Absolute URI can also be used to write LaunchApp records for Windows.
See 2.4.2 Payload Type of the NDEF Specification
http://www.nfc-forum.org/specs/spec_list#ndefts
Note that by default, Android will open the URI defined in the type
field of an Absolute URI record (TNF=3) and ignore the payload.
BlackBerry and Windows do not open the browser for TNF=3.
To write a URI as the payload use ndef.uriRecord(uri)
@uri String
@payload byte[] or String
@id byte[] (optional)
|
[
"Helper",
"that",
"creates",
"a",
"NDEF",
"record",
"containing",
"an",
"absolute",
"URI",
"."
] |
77ad9a17be20c89e0a45956870c4e9d732981dee
|
https://github.com/whitedogg13/react-native-nfc-manager/blob/77ad9a17be20c89e0a45956870c4e9d732981dee/ndef-lib/index.js#L138-L142
|
|
11,086
|
whitedogg13/react-native-nfc-manager
|
ndef-lib/index.js
|
function (mimeType, payload, id) {
if (!id) { id = []; }
return ndef.record(ndef.TNF_MIME_MEDIA, mimeType, id, payload);
}
|
javascript
|
function (mimeType, payload, id) {
if (!id) { id = []; }
return ndef.record(ndef.TNF_MIME_MEDIA, mimeType, id, payload);
}
|
[
"function",
"(",
"mimeType",
",",
"payload",
",",
"id",
")",
"{",
"if",
"(",
"!",
"id",
")",
"{",
"id",
"=",
"[",
"]",
";",
"}",
"return",
"ndef",
".",
"record",
"(",
"ndef",
".",
"TNF_MIME_MEDIA",
",",
"mimeType",
",",
"id",
",",
"payload",
")",
";",
"}"
] |
Helper that creates a NDEF record containing an mimeMediaRecord.
@mimeType String
@payload byte[]
@id byte[] (optional)
|
[
"Helper",
"that",
"creates",
"a",
"NDEF",
"record",
"containing",
"an",
"mimeMediaRecord",
"."
] |
77ad9a17be20c89e0a45956870c4e9d732981dee
|
https://github.com/whitedogg13/react-native-nfc-manager/blob/77ad9a17be20c89e0a45956870c4e9d732981dee/ndef-lib/index.js#L151-L154
|
|
11,087
|
whitedogg13/react-native-nfc-manager
|
ndef-lib/index.js
|
function (ndefRecords, id) {
var payload = [];
if (!id) { id = []; }
if (ndefRecords)
{
// make sure we have an array of something like NDEF records before encoding
if (ndefRecords[0] instanceof Object && ndefRecords[0].hasOwnProperty('tnf')) {
payload = ndef.encodeMessage(ndefRecords);
} else {
// assume the caller has already encoded the NDEF records into a byte array
payload = ndefRecords;
}
} else {
console.log("WARNING: Expecting an array of NDEF records");
}
return ndef.record(ndef.TNF_WELL_KNOWN, ndef.RTD_SMART_POSTER, id, payload);
}
|
javascript
|
function (ndefRecords, id) {
var payload = [];
if (!id) { id = []; }
if (ndefRecords)
{
// make sure we have an array of something like NDEF records before encoding
if (ndefRecords[0] instanceof Object && ndefRecords[0].hasOwnProperty('tnf')) {
payload = ndef.encodeMessage(ndefRecords);
} else {
// assume the caller has already encoded the NDEF records into a byte array
payload = ndefRecords;
}
} else {
console.log("WARNING: Expecting an array of NDEF records");
}
return ndef.record(ndef.TNF_WELL_KNOWN, ndef.RTD_SMART_POSTER, id, payload);
}
|
[
"function",
"(",
"ndefRecords",
",",
"id",
")",
"{",
"var",
"payload",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"id",
")",
"{",
"id",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"ndefRecords",
")",
"{",
"// make sure we have an array of something like NDEF records before encoding",
"if",
"(",
"ndefRecords",
"[",
"0",
"]",
"instanceof",
"Object",
"&&",
"ndefRecords",
"[",
"0",
"]",
".",
"hasOwnProperty",
"(",
"'tnf'",
")",
")",
"{",
"payload",
"=",
"ndef",
".",
"encodeMessage",
"(",
"ndefRecords",
")",
";",
"}",
"else",
"{",
"// assume the caller has already encoded the NDEF records into a byte array",
"payload",
"=",
"ndefRecords",
";",
"}",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"\"WARNING: Expecting an array of NDEF records\"",
")",
";",
"}",
"return",
"ndef",
".",
"record",
"(",
"ndef",
".",
"TNF_WELL_KNOWN",
",",
"ndef",
".",
"RTD_SMART_POSTER",
",",
"id",
",",
"payload",
")",
";",
"}"
] |
Helper that creates an NDEF record containing an Smart Poster.
@ndefRecords array of NDEF Records
@id byte[] (optional)
|
[
"Helper",
"that",
"creates",
"an",
"NDEF",
"record",
"containing",
"an",
"Smart",
"Poster",
"."
] |
77ad9a17be20c89e0a45956870c4e9d732981dee
|
https://github.com/whitedogg13/react-native-nfc-manager/blob/77ad9a17be20c89e0a45956870c4e9d732981dee/ndef-lib/index.js#L162-L181
|
|
11,088
|
whitedogg13/react-native-nfc-manager
|
ndef-lib/index.js
|
function (ndefRecords) {
var encoded = [],
tnf_byte,
record_type,
payload_length,
id_length,
i,
mb, me, // messageBegin, messageEnd
cf = false, // chunkFlag TODO implement
sr, // boolean shortRecord
il; // boolean idLengthFieldIsPresent
for(i = 0; i < ndefRecords.length; i++) {
mb = (i === 0);
me = (i === (ndefRecords.length - 1));
sr = (ndefRecords[i].payload.length < 0xFF);
il = (ndefRecords[i].id.length > 0);
tnf_byte = ndef.encodeTnf(mb, me, cf, sr, il, ndefRecords[i].tnf);
encoded.push(tnf_byte);
// type is stored as String, converting to bytes for storage
record_type = util.stringToBytes(ndefRecords[i].type);
encoded.push(record_type.length);
if (sr) {
payload_length = ndefRecords[i].payload.length;
encoded.push(payload_length);
} else {
payload_length = ndefRecords[i].payload.length;
// 4 bytes
encoded.push((payload_length >> 24));
encoded.push((payload_length >> 16));
encoded.push((payload_length >> 8));
encoded.push((payload_length & 0xFF));
}
if (il) {
id_length = ndefRecords[i].id.length;
encoded.push(id_length);
}
encoded = encoded.concat(record_type);
if (il) {
encoded = encoded.concat(ndefRecords[i].id);
}
encoded = encoded.concat(ndefRecords[i].payload);
}
return encoded;
}
|
javascript
|
function (ndefRecords) {
var encoded = [],
tnf_byte,
record_type,
payload_length,
id_length,
i,
mb, me, // messageBegin, messageEnd
cf = false, // chunkFlag TODO implement
sr, // boolean shortRecord
il; // boolean idLengthFieldIsPresent
for(i = 0; i < ndefRecords.length; i++) {
mb = (i === 0);
me = (i === (ndefRecords.length - 1));
sr = (ndefRecords[i].payload.length < 0xFF);
il = (ndefRecords[i].id.length > 0);
tnf_byte = ndef.encodeTnf(mb, me, cf, sr, il, ndefRecords[i].tnf);
encoded.push(tnf_byte);
// type is stored as String, converting to bytes for storage
record_type = util.stringToBytes(ndefRecords[i].type);
encoded.push(record_type.length);
if (sr) {
payload_length = ndefRecords[i].payload.length;
encoded.push(payload_length);
} else {
payload_length = ndefRecords[i].payload.length;
// 4 bytes
encoded.push((payload_length >> 24));
encoded.push((payload_length >> 16));
encoded.push((payload_length >> 8));
encoded.push((payload_length & 0xFF));
}
if (il) {
id_length = ndefRecords[i].id.length;
encoded.push(id_length);
}
encoded = encoded.concat(record_type);
if (il) {
encoded = encoded.concat(ndefRecords[i].id);
}
encoded = encoded.concat(ndefRecords[i].payload);
}
return encoded;
}
|
[
"function",
"(",
"ndefRecords",
")",
"{",
"var",
"encoded",
"=",
"[",
"]",
",",
"tnf_byte",
",",
"record_type",
",",
"payload_length",
",",
"id_length",
",",
"i",
",",
"mb",
",",
"me",
",",
"// messageBegin, messageEnd",
"cf",
"=",
"false",
",",
"// chunkFlag TODO implement",
"sr",
",",
"// boolean shortRecord",
"il",
";",
"// boolean idLengthFieldIsPresent",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"ndefRecords",
".",
"length",
";",
"i",
"++",
")",
"{",
"mb",
"=",
"(",
"i",
"===",
"0",
")",
";",
"me",
"=",
"(",
"i",
"===",
"(",
"ndefRecords",
".",
"length",
"-",
"1",
")",
")",
";",
"sr",
"=",
"(",
"ndefRecords",
"[",
"i",
"]",
".",
"payload",
".",
"length",
"<",
"0xFF",
")",
";",
"il",
"=",
"(",
"ndefRecords",
"[",
"i",
"]",
".",
"id",
".",
"length",
">",
"0",
")",
";",
"tnf_byte",
"=",
"ndef",
".",
"encodeTnf",
"(",
"mb",
",",
"me",
",",
"cf",
",",
"sr",
",",
"il",
",",
"ndefRecords",
"[",
"i",
"]",
".",
"tnf",
")",
";",
"encoded",
".",
"push",
"(",
"tnf_byte",
")",
";",
"// type is stored as String, converting to bytes for storage",
"record_type",
"=",
"util",
".",
"stringToBytes",
"(",
"ndefRecords",
"[",
"i",
"]",
".",
"type",
")",
";",
"encoded",
".",
"push",
"(",
"record_type",
".",
"length",
")",
";",
"if",
"(",
"sr",
")",
"{",
"payload_length",
"=",
"ndefRecords",
"[",
"i",
"]",
".",
"payload",
".",
"length",
";",
"encoded",
".",
"push",
"(",
"payload_length",
")",
";",
"}",
"else",
"{",
"payload_length",
"=",
"ndefRecords",
"[",
"i",
"]",
".",
"payload",
".",
"length",
";",
"// 4 bytes",
"encoded",
".",
"push",
"(",
"(",
"payload_length",
">>",
"24",
")",
")",
";",
"encoded",
".",
"push",
"(",
"(",
"payload_length",
">>",
"16",
")",
")",
";",
"encoded",
".",
"push",
"(",
"(",
"payload_length",
">>",
"8",
")",
")",
";",
"encoded",
".",
"push",
"(",
"(",
"payload_length",
"&",
"0xFF",
")",
")",
";",
"}",
"if",
"(",
"il",
")",
"{",
"id_length",
"=",
"ndefRecords",
"[",
"i",
"]",
".",
"id",
".",
"length",
";",
"encoded",
".",
"push",
"(",
"id_length",
")",
";",
"}",
"encoded",
"=",
"encoded",
".",
"concat",
"(",
"record_type",
")",
";",
"if",
"(",
"il",
")",
"{",
"encoded",
"=",
"encoded",
".",
"concat",
"(",
"ndefRecords",
"[",
"i",
"]",
".",
"id",
")",
";",
"}",
"encoded",
"=",
"encoded",
".",
"concat",
"(",
"ndefRecords",
"[",
"i",
"]",
".",
"payload",
")",
";",
"}",
"return",
"encoded",
";",
"}"
] |
Encodes an NDEF Message into bytes that can be written to a NFC tag.
@ndefRecords an Array of NDEF Records
@returns byte array
@see NFC Data Exchange Format (NDEF) http://www.nfc-forum.org/specs/spec_list/
|
[
"Encodes",
"an",
"NDEF",
"Message",
"into",
"bytes",
"that",
"can",
"be",
"written",
"to",
"a",
"NFC",
"tag",
"."
] |
77ad9a17be20c89e0a45956870c4e9d732981dee
|
https://github.com/whitedogg13/react-native-nfc-manager/blob/77ad9a17be20c89e0a45956870c4e9d732981dee/ndef-lib/index.js#L210-L263
|
|
11,089
|
whitedogg13/react-native-nfc-manager
|
ndef-lib/index.js
|
function (ndefBytes) {
// ndefBytes can be an array of bytes e.g. [0x03, 0x31, 0xd1] or a Buffer
var bytes;
// if (ndefBytes instanceof Buffer) {
// // get an array of bytes
// bytes = Array.prototype.slice.call(ndefBytes, 0);
// } else if (ndefBytes instanceof Array) {
if (ndefBytes instanceof Array) {
bytes = ndefBytes.slice(0);
} else {
throw new Error('ndef.decodeMessage requires a Buffer or an Array of bytes');
}
var bytes = bytes.slice(0), // clone since parsing is destructive
ndef_message = [],
tnf_byte,
header,
type_length = 0,
payload_length = 0,
id_length = 0,
record_type = [],
id = [],
payload = [];
while(bytes.length) {
tnf_byte = bytes.shift();
header = ndef.decodeTnf(tnf_byte);
type_length = bytes.shift();
if (header.sr) {
payload_length = bytes.shift();
} else {
// next 4 bytes are length
payload_length = ((0xFF & bytes.shift()) << 24) |
((0xFF & bytes.shift()) << 16) |
((0xFF & bytes.shift()) << 8) |
(0xFF & bytes.shift());
}
id_length = header.il ? bytes.shift() : 0;
record_type = bytes.splice(0, type_length);
id = bytes.splice(0, id_length);
payload = bytes.splice(0, payload_length);
ndef_message.push(
ndef.record(header.tnf, record_type, id, payload)
);
if (header.me) break; // last message
}
return ndef_message;
}
|
javascript
|
function (ndefBytes) {
// ndefBytes can be an array of bytes e.g. [0x03, 0x31, 0xd1] or a Buffer
var bytes;
// if (ndefBytes instanceof Buffer) {
// // get an array of bytes
// bytes = Array.prototype.slice.call(ndefBytes, 0);
// } else if (ndefBytes instanceof Array) {
if (ndefBytes instanceof Array) {
bytes = ndefBytes.slice(0);
} else {
throw new Error('ndef.decodeMessage requires a Buffer or an Array of bytes');
}
var bytes = bytes.slice(0), // clone since parsing is destructive
ndef_message = [],
tnf_byte,
header,
type_length = 0,
payload_length = 0,
id_length = 0,
record_type = [],
id = [],
payload = [];
while(bytes.length) {
tnf_byte = bytes.shift();
header = ndef.decodeTnf(tnf_byte);
type_length = bytes.shift();
if (header.sr) {
payload_length = bytes.shift();
} else {
// next 4 bytes are length
payload_length = ((0xFF & bytes.shift()) << 24) |
((0xFF & bytes.shift()) << 16) |
((0xFF & bytes.shift()) << 8) |
(0xFF & bytes.shift());
}
id_length = header.il ? bytes.shift() : 0;
record_type = bytes.splice(0, type_length);
id = bytes.splice(0, id_length);
payload = bytes.splice(0, payload_length);
ndef_message.push(
ndef.record(header.tnf, record_type, id, payload)
);
if (header.me) break; // last message
}
return ndef_message;
}
|
[
"function",
"(",
"ndefBytes",
")",
"{",
"// ndefBytes can be an array of bytes e.g. [0x03, 0x31, 0xd1] or a Buffer",
"var",
"bytes",
";",
"// if (ndefBytes instanceof Buffer) {",
"// // get an array of bytes",
"// bytes = Array.prototype.slice.call(ndefBytes, 0);",
"// } else if (ndefBytes instanceof Array) {",
"if",
"(",
"ndefBytes",
"instanceof",
"Array",
")",
"{",
"bytes",
"=",
"ndefBytes",
".",
"slice",
"(",
"0",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"'ndef.decodeMessage requires a Buffer or an Array of bytes'",
")",
";",
"}",
"var",
"bytes",
"=",
"bytes",
".",
"slice",
"(",
"0",
")",
",",
"// clone since parsing is destructive",
"ndef_message",
"=",
"[",
"]",
",",
"tnf_byte",
",",
"header",
",",
"type_length",
"=",
"0",
",",
"payload_length",
"=",
"0",
",",
"id_length",
"=",
"0",
",",
"record_type",
"=",
"[",
"]",
",",
"id",
"=",
"[",
"]",
",",
"payload",
"=",
"[",
"]",
";",
"while",
"(",
"bytes",
".",
"length",
")",
"{",
"tnf_byte",
"=",
"bytes",
".",
"shift",
"(",
")",
";",
"header",
"=",
"ndef",
".",
"decodeTnf",
"(",
"tnf_byte",
")",
";",
"type_length",
"=",
"bytes",
".",
"shift",
"(",
")",
";",
"if",
"(",
"header",
".",
"sr",
")",
"{",
"payload_length",
"=",
"bytes",
".",
"shift",
"(",
")",
";",
"}",
"else",
"{",
"// next 4 bytes are length",
"payload_length",
"=",
"(",
"(",
"0xFF",
"&",
"bytes",
".",
"shift",
"(",
")",
")",
"<<",
"24",
")",
"|",
"(",
"(",
"0xFF",
"&",
"bytes",
".",
"shift",
"(",
")",
")",
"<<",
"16",
")",
"|",
"(",
"(",
"0xFF",
"&",
"bytes",
".",
"shift",
"(",
")",
")",
"<<",
"8",
")",
"|",
"(",
"0xFF",
"&",
"bytes",
".",
"shift",
"(",
")",
")",
";",
"}",
"id_length",
"=",
"header",
".",
"il",
"?",
"bytes",
".",
"shift",
"(",
")",
":",
"0",
";",
"record_type",
"=",
"bytes",
".",
"splice",
"(",
"0",
",",
"type_length",
")",
";",
"id",
"=",
"bytes",
".",
"splice",
"(",
"0",
",",
"id_length",
")",
";",
"payload",
"=",
"bytes",
".",
"splice",
"(",
"0",
",",
"payload_length",
")",
";",
"ndef_message",
".",
"push",
"(",
"ndef",
".",
"record",
"(",
"header",
".",
"tnf",
",",
"record_type",
",",
"id",
",",
"payload",
")",
")",
";",
"if",
"(",
"header",
".",
"me",
")",
"break",
";",
"// last message",
"}",
"return",
"ndef_message",
";",
"}"
] |
Decodes an array bytes into an NDEF Message
@ndefBytes an array bytes or Buffer that was read from a NFC tag
@returns array of NDEF Records
@see NFC Data Exchange Format (NDEF) http://www.nfc-forum.org/specs/spec_list/
|
[
"Decodes",
"an",
"array",
"bytes",
"into",
"an",
"NDEF",
"Message"
] |
77ad9a17be20c89e0a45956870c4e9d732981dee
|
https://github.com/whitedogg13/react-native-nfc-manager/blob/77ad9a17be20c89e0a45956870c4e9d732981dee/ndef-lib/index.js#L274-L330
|
|
11,090
|
whitedogg13/react-native-nfc-manager
|
ndef-lib/index.js
|
function (tnf_byte) {
return {
mb: (tnf_byte & 0x80) !== 0,
me: (tnf_byte & 0x40) !== 0,
cf: (tnf_byte & 0x20) !== 0,
sr: (tnf_byte & 0x10) !== 0,
il: (tnf_byte & 0x8) !== 0,
tnf: (tnf_byte & 0x7)
};
}
|
javascript
|
function (tnf_byte) {
return {
mb: (tnf_byte & 0x80) !== 0,
me: (tnf_byte & 0x40) !== 0,
cf: (tnf_byte & 0x20) !== 0,
sr: (tnf_byte & 0x10) !== 0,
il: (tnf_byte & 0x8) !== 0,
tnf: (tnf_byte & 0x7)
};
}
|
[
"function",
"(",
"tnf_byte",
")",
"{",
"return",
"{",
"mb",
":",
"(",
"tnf_byte",
"&",
"0x80",
")",
"!==",
"0",
",",
"me",
":",
"(",
"tnf_byte",
"&",
"0x40",
")",
"!==",
"0",
",",
"cf",
":",
"(",
"tnf_byte",
"&",
"0x20",
")",
"!==",
"0",
",",
"sr",
":",
"(",
"tnf_byte",
"&",
"0x10",
")",
"!==",
"0",
",",
"il",
":",
"(",
"tnf_byte",
"&",
"0x8",
")",
"!==",
"0",
",",
"tnf",
":",
"(",
"tnf_byte",
"&",
"0x7",
")",
"}",
";",
"}"
] |
Decode the bit flags from a TNF Byte.
@returns object with decoded data
See NFC Data Exchange Format (NDEF) Specification Section 3.2 RecordLayout
|
[
"Decode",
"the",
"bit",
"flags",
"from",
"a",
"TNF",
"Byte",
"."
] |
77ad9a17be20c89e0a45956870c4e9d732981dee
|
https://github.com/whitedogg13/react-native-nfc-manager/blob/77ad9a17be20c89e0a45956870c4e9d732981dee/ndef-lib/index.js#L339-L348
|
|
11,091
|
whitedogg13/react-native-nfc-manager
|
ndef-lib/index.js
|
function (mb, me, cf, sr, il, tnf) {
var value = tnf;
if (mb) {
value = value | 0x80;
}
if (me) {
value = value | 0x40;
}
// note if cf: me, mb, li must be false and tnf must be 0x6
if (cf) {
value = value | 0x20;
}
if (sr) {
value = value | 0x10;
}
if (il) {
value = value | 0x8;
}
return value;
}
|
javascript
|
function (mb, me, cf, sr, il, tnf) {
var value = tnf;
if (mb) {
value = value | 0x80;
}
if (me) {
value = value | 0x40;
}
// note if cf: me, mb, li must be false and tnf must be 0x6
if (cf) {
value = value | 0x20;
}
if (sr) {
value = value | 0x10;
}
if (il) {
value = value | 0x8;
}
return value;
}
|
[
"function",
"(",
"mb",
",",
"me",
",",
"cf",
",",
"sr",
",",
"il",
",",
"tnf",
")",
"{",
"var",
"value",
"=",
"tnf",
";",
"if",
"(",
"mb",
")",
"{",
"value",
"=",
"value",
"|",
"0x80",
";",
"}",
"if",
"(",
"me",
")",
"{",
"value",
"=",
"value",
"|",
"0x40",
";",
"}",
"// note if cf: me, mb, li must be false and tnf must be 0x6",
"if",
"(",
"cf",
")",
"{",
"value",
"=",
"value",
"|",
"0x20",
";",
"}",
"if",
"(",
"sr",
")",
"{",
"value",
"=",
"value",
"|",
"0x10",
";",
"}",
"if",
"(",
"il",
")",
"{",
"value",
"=",
"value",
"|",
"0x8",
";",
"}",
"return",
"value",
";",
"}"
] |
Encode NDEF bit flags into a TNF Byte.
@returns tnf byte
See NFC Data Exchange Format (NDEF) Specification Section 3.2 RecordLayout
|
[
"Encode",
"NDEF",
"bit",
"flags",
"into",
"a",
"TNF",
"Byte",
"."
] |
77ad9a17be20c89e0a45956870c4e9d732981dee
|
https://github.com/whitedogg13/react-native-nfc-manager/blob/77ad9a17be20c89e0a45956870c4e9d732981dee/ndef-lib/index.js#L357-L383
|
|
11,092
|
whitedogg13/react-native-nfc-manager
|
ndef-lib/index.js
|
s
|
function s(bytes) {
if (typeof(bytes) === 'string') {
return bytes;
}
return bytes.reduce(function (acc, byte) {
return acc + String.fromCharCode(byte);
}, '')
// return new Buffer(bytes).toString();
}
|
javascript
|
function s(bytes) {
if (typeof(bytes) === 'string') {
return bytes;
}
return bytes.reduce(function (acc, byte) {
return acc + String.fromCharCode(byte);
}, '')
// return new Buffer(bytes).toString();
}
|
[
"function",
"s",
"(",
"bytes",
")",
"{",
"if",
"(",
"typeof",
"(",
"bytes",
")",
"===",
"'string'",
")",
"{",
"return",
"bytes",
";",
"}",
"return",
"bytes",
".",
"reduce",
"(",
"function",
"(",
"acc",
",",
"byte",
")",
"{",
"return",
"acc",
"+",
"String",
".",
"fromCharCode",
"(",
"byte",
")",
";",
"}",
",",
"''",
")",
"// return new Buffer(bytes).toString();",
"}"
] |
convert bytes to a String
|
[
"convert",
"bytes",
"to",
"a",
"String"
] |
77ad9a17be20c89e0a45956870c4e9d732981dee
|
https://github.com/whitedogg13/react-native-nfc-manager/blob/77ad9a17be20c89e0a45956870c4e9d732981dee/ndef-lib/index.js#L552-L561
|
11,093
|
whitedogg13/react-native-nfc-manager
|
ndef-lib/ndef-uri.js
|
decode
|
function decode(data) {
var prefix = protocols[data[0]];
if (!prefix) { // 36 to 255 should be ""
prefix = "";
}
return prefix + util.bytesToString(data.slice(1));
}
|
javascript
|
function decode(data) {
var prefix = protocols[data[0]];
if (!prefix) { // 36 to 255 should be ""
prefix = "";
}
return prefix + util.bytesToString(data.slice(1));
}
|
[
"function",
"decode",
"(",
"data",
")",
"{",
"var",
"prefix",
"=",
"protocols",
"[",
"data",
"[",
"0",
"]",
"]",
";",
"if",
"(",
"!",
"prefix",
")",
"{",
"// 36 to 255 should be \"\"",
"prefix",
"=",
"\"\"",
";",
"}",
"return",
"prefix",
"+",
"util",
".",
"bytesToString",
"(",
"data",
".",
"slice",
"(",
"1",
")",
")",
";",
"}"
] |
decode a URI payload bytes @returns a string
|
[
"decode",
"a",
"URI",
"payload",
"bytes"
] |
77ad9a17be20c89e0a45956870c4e9d732981dee
|
https://github.com/whitedogg13/react-native-nfc-manager/blob/77ad9a17be20c89e0a45956870c4e9d732981dee/ndef-lib/ndef-uri.js#L9-L15
|
11,094
|
whitedogg13/react-native-nfc-manager
|
ndef-lib/ndef-uri.js
|
encode
|
function encode(uri) {
var prefix,
protocolCode,
encoded;
// check each protocol, unless we've found a match
// "urn:" is the one exception where we need to keep checking
// slice so we don't check ""
protocols.slice(1).forEach(function(protocol) {
if ((!prefix || prefix === "urn:") && uri.indexOf(protocol) === 0) {
prefix = protocol;
}
});
if (!prefix) {
prefix = "";
}
encoded = util.stringToBytes(uri.slice(prefix.length));
protocolCode = protocols.indexOf(prefix);
// prepend protocol code
encoded.unshift(protocolCode);
return encoded;
}
|
javascript
|
function encode(uri) {
var prefix,
protocolCode,
encoded;
// check each protocol, unless we've found a match
// "urn:" is the one exception where we need to keep checking
// slice so we don't check ""
protocols.slice(1).forEach(function(protocol) {
if ((!prefix || prefix === "urn:") && uri.indexOf(protocol) === 0) {
prefix = protocol;
}
});
if (!prefix) {
prefix = "";
}
encoded = util.stringToBytes(uri.slice(prefix.length));
protocolCode = protocols.indexOf(prefix);
// prepend protocol code
encoded.unshift(protocolCode);
return encoded;
}
|
[
"function",
"encode",
"(",
"uri",
")",
"{",
"var",
"prefix",
",",
"protocolCode",
",",
"encoded",
";",
"// check each protocol, unless we've found a match",
"// \"urn:\" is the one exception where we need to keep checking",
"// slice so we don't check \"\"",
"protocols",
".",
"slice",
"(",
"1",
")",
".",
"forEach",
"(",
"function",
"(",
"protocol",
")",
"{",
"if",
"(",
"(",
"!",
"prefix",
"||",
"prefix",
"===",
"\"urn:\"",
")",
"&&",
"uri",
".",
"indexOf",
"(",
"protocol",
")",
"===",
"0",
")",
"{",
"prefix",
"=",
"protocol",
";",
"}",
"}",
")",
";",
"if",
"(",
"!",
"prefix",
")",
"{",
"prefix",
"=",
"\"\"",
";",
"}",
"encoded",
"=",
"util",
".",
"stringToBytes",
"(",
"uri",
".",
"slice",
"(",
"prefix",
".",
"length",
")",
")",
";",
"protocolCode",
"=",
"protocols",
".",
"indexOf",
"(",
"prefix",
")",
";",
"// prepend protocol code",
"encoded",
".",
"unshift",
"(",
"protocolCode",
")",
";",
"return",
"encoded",
";",
"}"
] |
shorten a URI with standard prefix @returns an array of bytes
|
[
"shorten",
"a",
"URI",
"with",
"standard",
"prefix"
] |
77ad9a17be20c89e0a45956870c4e9d732981dee
|
https://github.com/whitedogg13/react-native-nfc-manager/blob/77ad9a17be20c89e0a45956870c4e9d732981dee/ndef-lib/ndef-uri.js#L19-L44
|
11,095
|
whitedogg13/react-native-nfc-manager
|
ndef-lib/ndef-util.js
|
bytesToHexString
|
function bytesToHexString(bytes) {
var dec, hexstring, bytesAsHexString = "";
for (var i = 0; i < bytes.length; i++) {
if (bytes[i] >= 0) {
dec = bytes[i];
} else {
dec = 256 + bytes[i];
}
hexstring = dec.toString(16);
// zero padding
if (hexstring.length == 1) {
hexstring = "0" + hexstring;
}
bytesAsHexString += hexstring;
}
return bytesAsHexString;
}
|
javascript
|
function bytesToHexString(bytes) {
var dec, hexstring, bytesAsHexString = "";
for (var i = 0; i < bytes.length; i++) {
if (bytes[i] >= 0) {
dec = bytes[i];
} else {
dec = 256 + bytes[i];
}
hexstring = dec.toString(16);
// zero padding
if (hexstring.length == 1) {
hexstring = "0" + hexstring;
}
bytesAsHexString += hexstring;
}
return bytesAsHexString;
}
|
[
"function",
"bytesToHexString",
"(",
"bytes",
")",
"{",
"var",
"dec",
",",
"hexstring",
",",
"bytesAsHexString",
"=",
"\"\"",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"bytes",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"bytes",
"[",
"i",
"]",
">=",
"0",
")",
"{",
"dec",
"=",
"bytes",
"[",
"i",
"]",
";",
"}",
"else",
"{",
"dec",
"=",
"256",
"+",
"bytes",
"[",
"i",
"]",
";",
"}",
"hexstring",
"=",
"dec",
".",
"toString",
"(",
"16",
")",
";",
"// zero padding",
"if",
"(",
"hexstring",
".",
"length",
"==",
"1",
")",
"{",
"hexstring",
"=",
"\"0\"",
"+",
"hexstring",
";",
"}",
"bytesAsHexString",
"+=",
"hexstring",
";",
"}",
"return",
"bytesAsHexString",
";",
"}"
] |
useful for readable version of Tag UID
|
[
"useful",
"for",
"readable",
"version",
"of",
"Tag",
"UID"
] |
77ad9a17be20c89e0a45956870c4e9d732981dee
|
https://github.com/whitedogg13/react-native-nfc-manager/blob/77ad9a17be20c89e0a45956870c4e9d732981dee/ndef-lib/ndef-util.js#L89-L105
|
11,096
|
whitedogg13/react-native-nfc-manager
|
ndef-lib/ndef-util.js
|
toHex
|
function toHex(i) {
var hex;
if (i < 0) {
i += 256;
}
hex = i.toString(16);
// zero padding
if (hex.length == 1) {
hex = "0" + hex;
}
return hex;
}
|
javascript
|
function toHex(i) {
var hex;
if (i < 0) {
i += 256;
}
hex = i.toString(16);
// zero padding
if (hex.length == 1) {
hex = "0" + hex;
}
return hex;
}
|
[
"function",
"toHex",
"(",
"i",
")",
"{",
"var",
"hex",
";",
"if",
"(",
"i",
"<",
"0",
")",
"{",
"i",
"+=",
"256",
";",
"}",
"hex",
"=",
"i",
".",
"toString",
"(",
"16",
")",
";",
"// zero padding",
"if",
"(",
"hex",
".",
"length",
"==",
"1",
")",
"{",
"hex",
"=",
"\"0\"",
"+",
"hex",
";",
"}",
"return",
"hex",
";",
"}"
] |
i must be <= 256
|
[
"i",
"must",
"be",
"<",
"=",
"256"
] |
77ad9a17be20c89e0a45956870c4e9d732981dee
|
https://github.com/whitedogg13/react-native-nfc-manager/blob/77ad9a17be20c89e0a45956870c4e9d732981dee/ndef-lib/ndef-util.js#L108-L121
|
11,097
|
auth0/auth0.js
|
src/authentication/index.js
|
Authentication
|
function Authentication(auth0, options) {
// If we have two arguments, the first one is a WebAuth instance, so we assign that
// if not, it's an options object and then we should use that as options instead
// this is here because we don't want to break people coming from v8
if (arguments.length === 2) {
this.auth0 = auth0;
} else {
options = auth0;
}
/* eslint-disable */
assert.check(
options,
{ type: 'object', message: 'options parameter is not valid' },
{
domain: { type: 'string', message: 'domain option is required' },
clientID: { type: 'string', message: 'clientID option is required' },
responseType: { optional: true, type: 'string', message: 'responseType is not valid' },
responseMode: { optional: true, type: 'string', message: 'responseMode is not valid' },
redirectUri: { optional: true, type: 'string', message: 'redirectUri is not valid' },
scope: { optional: true, type: 'string', message: 'scope is not valid' },
audience: { optional: true, type: 'string', message: 'audience is not valid' },
_disableDeprecationWarnings: {
optional: true,
type: 'boolean',
message: '_disableDeprecationWarnings option is not valid'
},
_sendTelemetry: {
optional: true,
type: 'boolean',
message: '_sendTelemetry option is not valid'
},
_telemetryInfo: {
optional: true,
type: 'object',
message: '_telemetryInfo option is not valid'
}
}
);
/* eslint-enable */
this.baseOptions = options;
this.baseOptions._sendTelemetry =
this.baseOptions._sendTelemetry === false ? this.baseOptions._sendTelemetry : true;
this.baseOptions.rootUrl = 'https://' + this.baseOptions.domain;
this.request = new RequestBuilder(this.baseOptions);
this.passwordless = new PasswordlessAuthentication(this.request, this.baseOptions);
this.dbConnection = new DBConnection(this.request, this.baseOptions);
this.warn = new Warn({
disableWarnings: !!options._disableDeprecationWarnings
});
this.ssodataStorage = new SSODataStorage(this.baseOptions);
}
|
javascript
|
function Authentication(auth0, options) {
// If we have two arguments, the first one is a WebAuth instance, so we assign that
// if not, it's an options object and then we should use that as options instead
// this is here because we don't want to break people coming from v8
if (arguments.length === 2) {
this.auth0 = auth0;
} else {
options = auth0;
}
/* eslint-disable */
assert.check(
options,
{ type: 'object', message: 'options parameter is not valid' },
{
domain: { type: 'string', message: 'domain option is required' },
clientID: { type: 'string', message: 'clientID option is required' },
responseType: { optional: true, type: 'string', message: 'responseType is not valid' },
responseMode: { optional: true, type: 'string', message: 'responseMode is not valid' },
redirectUri: { optional: true, type: 'string', message: 'redirectUri is not valid' },
scope: { optional: true, type: 'string', message: 'scope is not valid' },
audience: { optional: true, type: 'string', message: 'audience is not valid' },
_disableDeprecationWarnings: {
optional: true,
type: 'boolean',
message: '_disableDeprecationWarnings option is not valid'
},
_sendTelemetry: {
optional: true,
type: 'boolean',
message: '_sendTelemetry option is not valid'
},
_telemetryInfo: {
optional: true,
type: 'object',
message: '_telemetryInfo option is not valid'
}
}
);
/* eslint-enable */
this.baseOptions = options;
this.baseOptions._sendTelemetry =
this.baseOptions._sendTelemetry === false ? this.baseOptions._sendTelemetry : true;
this.baseOptions.rootUrl = 'https://' + this.baseOptions.domain;
this.request = new RequestBuilder(this.baseOptions);
this.passwordless = new PasswordlessAuthentication(this.request, this.baseOptions);
this.dbConnection = new DBConnection(this.request, this.baseOptions);
this.warn = new Warn({
disableWarnings: !!options._disableDeprecationWarnings
});
this.ssodataStorage = new SSODataStorage(this.baseOptions);
}
|
[
"function",
"Authentication",
"(",
"auth0",
",",
"options",
")",
"{",
"// If we have two arguments, the first one is a WebAuth instance, so we assign that",
"// if not, it's an options object and then we should use that as options instead",
"// this is here because we don't want to break people coming from v8",
"if",
"(",
"arguments",
".",
"length",
"===",
"2",
")",
"{",
"this",
".",
"auth0",
"=",
"auth0",
";",
"}",
"else",
"{",
"options",
"=",
"auth0",
";",
"}",
"/* eslint-disable */",
"assert",
".",
"check",
"(",
"options",
",",
"{",
"type",
":",
"'object'",
",",
"message",
":",
"'options parameter is not valid'",
"}",
",",
"{",
"domain",
":",
"{",
"type",
":",
"'string'",
",",
"message",
":",
"'domain option is required'",
"}",
",",
"clientID",
":",
"{",
"type",
":",
"'string'",
",",
"message",
":",
"'clientID option is required'",
"}",
",",
"responseType",
":",
"{",
"optional",
":",
"true",
",",
"type",
":",
"'string'",
",",
"message",
":",
"'responseType is not valid'",
"}",
",",
"responseMode",
":",
"{",
"optional",
":",
"true",
",",
"type",
":",
"'string'",
",",
"message",
":",
"'responseMode is not valid'",
"}",
",",
"redirectUri",
":",
"{",
"optional",
":",
"true",
",",
"type",
":",
"'string'",
",",
"message",
":",
"'redirectUri is not valid'",
"}",
",",
"scope",
":",
"{",
"optional",
":",
"true",
",",
"type",
":",
"'string'",
",",
"message",
":",
"'scope is not valid'",
"}",
",",
"audience",
":",
"{",
"optional",
":",
"true",
",",
"type",
":",
"'string'",
",",
"message",
":",
"'audience is not valid'",
"}",
",",
"_disableDeprecationWarnings",
":",
"{",
"optional",
":",
"true",
",",
"type",
":",
"'boolean'",
",",
"message",
":",
"'_disableDeprecationWarnings option is not valid'",
"}",
",",
"_sendTelemetry",
":",
"{",
"optional",
":",
"true",
",",
"type",
":",
"'boolean'",
",",
"message",
":",
"'_sendTelemetry option is not valid'",
"}",
",",
"_telemetryInfo",
":",
"{",
"optional",
":",
"true",
",",
"type",
":",
"'object'",
",",
"message",
":",
"'_telemetryInfo option is not valid'",
"}",
"}",
")",
";",
"/* eslint-enable */",
"this",
".",
"baseOptions",
"=",
"options",
";",
"this",
".",
"baseOptions",
".",
"_sendTelemetry",
"=",
"this",
".",
"baseOptions",
".",
"_sendTelemetry",
"===",
"false",
"?",
"this",
".",
"baseOptions",
".",
"_sendTelemetry",
":",
"true",
";",
"this",
".",
"baseOptions",
".",
"rootUrl",
"=",
"'https://'",
"+",
"this",
".",
"baseOptions",
".",
"domain",
";",
"this",
".",
"request",
"=",
"new",
"RequestBuilder",
"(",
"this",
".",
"baseOptions",
")",
";",
"this",
".",
"passwordless",
"=",
"new",
"PasswordlessAuthentication",
"(",
"this",
".",
"request",
",",
"this",
".",
"baseOptions",
")",
";",
"this",
".",
"dbConnection",
"=",
"new",
"DBConnection",
"(",
"this",
".",
"request",
",",
"this",
".",
"baseOptions",
")",
";",
"this",
".",
"warn",
"=",
"new",
"Warn",
"(",
"{",
"disableWarnings",
":",
"!",
"!",
"options",
".",
"_disableDeprecationWarnings",
"}",
")",
";",
"this",
".",
"ssodataStorage",
"=",
"new",
"SSODataStorage",
"(",
"this",
".",
"baseOptions",
")",
";",
"}"
] |
Creates a new Auth0 Authentication API client
@constructor
@param {Object} options
@param {String} options.domain your Auth0 domain
@param {String} options.clientID the Client ID found on your Application settings page
@param {String} [options.redirectUri] url that the Auth0 will redirect after Auth with the Authorization Response
@param {String} [options.responseType] type of the response used by OAuth 2.0 flow. It can be any space separated list of the values `code`, `token`, `id_token`. {@link https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html}
@param {String} [options.responseMode] how the Auth response is encoded and redirected back to the client. Supported values are `query`, `fragment` and `form_post`. {@link https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html#ResponseModes}
@param {String} [options.scope] scopes to be requested during Auth. e.g. `openid email`
@param {String} [options.audience] identifier of the resource server who will consume the access token issued after Auth
@see {@link https://auth0.com/docs/api/authentication}
|
[
"Creates",
"a",
"new",
"Auth0",
"Authentication",
"API",
"client"
] |
c9861c406946c22904250a69a0fddaa04c679850
|
https://github.com/auth0/auth0.js/blob/c9861c406946c22904250a69a0fddaa04c679850/src/authentication/index.js#L29-L85
|
11,098
|
fperucic/treant-js
|
vendor/perfect-scrollbar/perfect-scrollbar.js
|
function() {
var applyTouchMove = function(difference_x, difference_y) {
$this.scrollTop($this.scrollTop() - difference_y);
$this.scrollLeft($this.scrollLeft() - difference_x);
// update bar position
updateBarSizeAndPosition();
};
var start_coords = {},
start_time = 0,
speed = {},
breaking_process = null;
$this.bind("touchstart.perfect-scroll", function(e) {
var touch = e.originalEvent.targetTouches[0];
start_coords.pageX = touch.pageX;
start_coords.pageY = touch.pageY;
start_time = (new Date()).getTime();
if (breaking_process !== null) {
clearInterval(breaking_process);
}
});
$this.bind("touchmove.perfect-scroll", function(e) {
var touch = e.originalEvent.targetTouches[0];
var current_coords = {};
current_coords.pageX = touch.pageX;
current_coords.pageY = touch.pageY;
var difference_x = current_coords.pageX - start_coords.pageX,
difference_y = current_coords.pageY - start_coords.pageY;
applyTouchMove(difference_x, difference_y);
start_coords = current_coords;
var current_time = (new Date()).getTime();
speed.x = difference_x / (current_time - start_time);
speed.y = difference_y / (current_time - start_time);
start_time = current_time;
e.preventDefault();
});
$this.bind("touchend.perfect-scroll", function(e) {
breaking_process = setInterval(function() {
if(Math.abs(speed.x) < 0.01 && Math.abs(speed.y) < 0.01) {
clearInterval(breaking_process);
return;
}
applyTouchMove(speed.x * 30, speed.y * 30);
speed.x *= 0.8;
speed.y *= 0.8;
}, 10);
});
}
|
javascript
|
function() {
var applyTouchMove = function(difference_x, difference_y) {
$this.scrollTop($this.scrollTop() - difference_y);
$this.scrollLeft($this.scrollLeft() - difference_x);
// update bar position
updateBarSizeAndPosition();
};
var start_coords = {},
start_time = 0,
speed = {},
breaking_process = null;
$this.bind("touchstart.perfect-scroll", function(e) {
var touch = e.originalEvent.targetTouches[0];
start_coords.pageX = touch.pageX;
start_coords.pageY = touch.pageY;
start_time = (new Date()).getTime();
if (breaking_process !== null) {
clearInterval(breaking_process);
}
});
$this.bind("touchmove.perfect-scroll", function(e) {
var touch = e.originalEvent.targetTouches[0];
var current_coords = {};
current_coords.pageX = touch.pageX;
current_coords.pageY = touch.pageY;
var difference_x = current_coords.pageX - start_coords.pageX,
difference_y = current_coords.pageY - start_coords.pageY;
applyTouchMove(difference_x, difference_y);
start_coords = current_coords;
var current_time = (new Date()).getTime();
speed.x = difference_x / (current_time - start_time);
speed.y = difference_y / (current_time - start_time);
start_time = current_time;
e.preventDefault();
});
$this.bind("touchend.perfect-scroll", function(e) {
breaking_process = setInterval(function() {
if(Math.abs(speed.x) < 0.01 && Math.abs(speed.y) < 0.01) {
clearInterval(breaking_process);
return;
}
applyTouchMove(speed.x * 30, speed.y * 30);
speed.x *= 0.8;
speed.y *= 0.8;
}, 10);
});
}
|
[
"function",
"(",
")",
"{",
"var",
"applyTouchMove",
"=",
"function",
"(",
"difference_x",
",",
"difference_y",
")",
"{",
"$this",
".",
"scrollTop",
"(",
"$this",
".",
"scrollTop",
"(",
")",
"-",
"difference_y",
")",
";",
"$this",
".",
"scrollLeft",
"(",
"$this",
".",
"scrollLeft",
"(",
")",
"-",
"difference_x",
")",
";",
"// update bar position",
"updateBarSizeAndPosition",
"(",
")",
";",
"}",
";",
"var",
"start_coords",
"=",
"{",
"}",
",",
"start_time",
"=",
"0",
",",
"speed",
"=",
"{",
"}",
",",
"breaking_process",
"=",
"null",
";",
"$this",
".",
"bind",
"(",
"\"touchstart.perfect-scroll\"",
",",
"function",
"(",
"e",
")",
"{",
"var",
"touch",
"=",
"e",
".",
"originalEvent",
".",
"targetTouches",
"[",
"0",
"]",
";",
"start_coords",
".",
"pageX",
"=",
"touch",
".",
"pageX",
";",
"start_coords",
".",
"pageY",
"=",
"touch",
".",
"pageY",
";",
"start_time",
"=",
"(",
"new",
"Date",
"(",
")",
")",
".",
"getTime",
"(",
")",
";",
"if",
"(",
"breaking_process",
"!==",
"null",
")",
"{",
"clearInterval",
"(",
"breaking_process",
")",
";",
"}",
"}",
")",
";",
"$this",
".",
"bind",
"(",
"\"touchmove.perfect-scroll\"",
",",
"function",
"(",
"e",
")",
"{",
"var",
"touch",
"=",
"e",
".",
"originalEvent",
".",
"targetTouches",
"[",
"0",
"]",
";",
"var",
"current_coords",
"=",
"{",
"}",
";",
"current_coords",
".",
"pageX",
"=",
"touch",
".",
"pageX",
";",
"current_coords",
".",
"pageY",
"=",
"touch",
".",
"pageY",
";",
"var",
"difference_x",
"=",
"current_coords",
".",
"pageX",
"-",
"start_coords",
".",
"pageX",
",",
"difference_y",
"=",
"current_coords",
".",
"pageY",
"-",
"start_coords",
".",
"pageY",
";",
"applyTouchMove",
"(",
"difference_x",
",",
"difference_y",
")",
";",
"start_coords",
"=",
"current_coords",
";",
"var",
"current_time",
"=",
"(",
"new",
"Date",
"(",
")",
")",
".",
"getTime",
"(",
")",
";",
"speed",
".",
"x",
"=",
"difference_x",
"/",
"(",
"current_time",
"-",
"start_time",
")",
";",
"speed",
".",
"y",
"=",
"difference_y",
"/",
"(",
"current_time",
"-",
"start_time",
")",
";",
"start_time",
"=",
"current_time",
";",
"e",
".",
"preventDefault",
"(",
")",
";",
"}",
")",
";",
"$this",
".",
"bind",
"(",
"\"touchend.perfect-scroll\"",
",",
"function",
"(",
"e",
")",
"{",
"breaking_process",
"=",
"setInterval",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"Math",
".",
"abs",
"(",
"speed",
".",
"x",
")",
"<",
"0.01",
"&&",
"Math",
".",
"abs",
"(",
"speed",
".",
"y",
")",
"<",
"0.01",
")",
"{",
"clearInterval",
"(",
"breaking_process",
")",
";",
"return",
";",
"}",
"applyTouchMove",
"(",
"speed",
".",
"x",
"*",
"30",
",",
"speed",
".",
"y",
"*",
"30",
")",
";",
"speed",
".",
"x",
"*=",
"0.8",
";",
"speed",
".",
"y",
"*=",
"0.8",
";",
"}",
",",
"10",
")",
";",
"}",
")",
";",
"}"
] |
bind mobile touch handler
|
[
"bind",
"mobile",
"touch",
"handler"
] |
a5f95627baa265a891858678de47dff180848613
|
https://github.com/fperucic/treant-js/blob/a5f95627baa265a891858678de47dff180848613/vendor/perfect-scrollbar/perfect-scrollbar.js#L220-L279
|
|
11,099
|
fperucic/treant-js
|
Treant.js
|
function( obj1, obj2 ) {
var newObj = {};
if ( obj1 ) {
this.inheritAttrs( newObj, this.cloneObj( obj1 ) );
}
if ( obj2 ) {
this.inheritAttrs( newObj, obj2 );
}
return newObj;
}
|
javascript
|
function( obj1, obj2 ) {
var newObj = {};
if ( obj1 ) {
this.inheritAttrs( newObj, this.cloneObj( obj1 ) );
}
if ( obj2 ) {
this.inheritAttrs( newObj, obj2 );
}
return newObj;
}
|
[
"function",
"(",
"obj1",
",",
"obj2",
")",
"{",
"var",
"newObj",
"=",
"{",
"}",
";",
"if",
"(",
"obj1",
")",
"{",
"this",
".",
"inheritAttrs",
"(",
"newObj",
",",
"this",
".",
"cloneObj",
"(",
"obj1",
")",
")",
";",
"}",
"if",
"(",
"obj2",
")",
"{",
"this",
".",
"inheritAttrs",
"(",
"newObj",
",",
"obj2",
")",
";",
"}",
"return",
"newObj",
";",
"}"
] |
Returns a new object by merging the two supplied objects
@param {object} obj1
@param {object} obj2
@returns {object}
|
[
"Returns",
"a",
"new",
"object",
"by",
"merging",
"the",
"two",
"supplied",
"objects"
] |
a5f95627baa265a891858678de47dff180848613
|
https://github.com/fperucic/treant-js/blob/a5f95627baa265a891858678de47dff180848613/Treant.js#L58-L67
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.