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
|
---|---|---|---|---|---|---|---|---|---|---|---|
39,400 | S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js | function ()
{
var aoColumns = this.s.dt.aoColumns;
this.s.aoTargets.splice( 0, this.s.aoTargets.length );
this.s.aoTargets.push( {
"x": $(this.s.dt.nTable).offset().left,
"to": 0
} );
var iToPoint = 0;
for ( var i=0, iLen=aoColumns.length ; i<iLen ; i++ )
{
/* For the column / header in question, we want it's position to remain the same if the
* position is just to it's immediate left or right, so we only incremement the counter for
* other columns
*/
if ( i != this.s.mouse.fromIndex )
{
iToPoint++;
}
if ( aoColumns[i].bVisible )
{
this.s.aoTargets.push( {
"x": $(aoColumns[i].nTh).offset().left + $(aoColumns[i].nTh).outerWidth(),
"to": iToPoint
} );
}
}
/* Disallow columns for being reordered by drag and drop, counting right to left */
if ( this.s.fixedRight !== 0 )
{
this.s.aoTargets.splice( this.s.aoTargets.length - this.s.fixedRight );
}
/* Disallow columns for being reordered by drag and drop, counting left to right */
if ( this.s.fixed !== 0 )
{
this.s.aoTargets.splice( 0, this.s.fixed );
}
} | javascript | function ()
{
var aoColumns = this.s.dt.aoColumns;
this.s.aoTargets.splice( 0, this.s.aoTargets.length );
this.s.aoTargets.push( {
"x": $(this.s.dt.nTable).offset().left,
"to": 0
} );
var iToPoint = 0;
for ( var i=0, iLen=aoColumns.length ; i<iLen ; i++ )
{
/* For the column / header in question, we want it's position to remain the same if the
* position is just to it's immediate left or right, so we only incremement the counter for
* other columns
*/
if ( i != this.s.mouse.fromIndex )
{
iToPoint++;
}
if ( aoColumns[i].bVisible )
{
this.s.aoTargets.push( {
"x": $(aoColumns[i].nTh).offset().left + $(aoColumns[i].nTh).outerWidth(),
"to": iToPoint
} );
}
}
/* Disallow columns for being reordered by drag and drop, counting right to left */
if ( this.s.fixedRight !== 0 )
{
this.s.aoTargets.splice( this.s.aoTargets.length - this.s.fixedRight );
}
/* Disallow columns for being reordered by drag and drop, counting left to right */
if ( this.s.fixed !== 0 )
{
this.s.aoTargets.splice( 0, this.s.fixed );
}
} | [
"function",
"(",
")",
"{",
"var",
"aoColumns",
"=",
"this",
".",
"s",
".",
"dt",
".",
"aoColumns",
";",
"this",
".",
"s",
".",
"aoTargets",
".",
"splice",
"(",
"0",
",",
"this",
".",
"s",
".",
"aoTargets",
".",
"length",
")",
";",
"this",
".",
"s",
".",
"aoTargets",
".",
"push",
"(",
"{",
"\"x\"",
":",
"$",
"(",
"this",
".",
"s",
".",
"dt",
".",
"nTable",
")",
".",
"offset",
"(",
")",
".",
"left",
",",
"\"to\"",
":",
"0",
"}",
")",
";",
"var",
"iToPoint",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"iLen",
"=",
"aoColumns",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"/* For the column / header in question, we want it's position to remain the same if the\n\t\t\t * position is just to it's immediate left or right, so we only incremement the counter for\n\t\t\t * other columns\n\t\t\t */",
"if",
"(",
"i",
"!=",
"this",
".",
"s",
".",
"mouse",
".",
"fromIndex",
")",
"{",
"iToPoint",
"++",
";",
"}",
"if",
"(",
"aoColumns",
"[",
"i",
"]",
".",
"bVisible",
")",
"{",
"this",
".",
"s",
".",
"aoTargets",
".",
"push",
"(",
"{",
"\"x\"",
":",
"$",
"(",
"aoColumns",
"[",
"i",
"]",
".",
"nTh",
")",
".",
"offset",
"(",
")",
".",
"left",
"+",
"$",
"(",
"aoColumns",
"[",
"i",
"]",
".",
"nTh",
")",
".",
"outerWidth",
"(",
")",
",",
"\"to\"",
":",
"iToPoint",
"}",
")",
";",
"}",
"}",
"/* Disallow columns for being reordered by drag and drop, counting right to left */",
"if",
"(",
"this",
".",
"s",
".",
"fixedRight",
"!==",
"0",
")",
"{",
"this",
".",
"s",
".",
"aoTargets",
".",
"splice",
"(",
"this",
".",
"s",
".",
"aoTargets",
".",
"length",
"-",
"this",
".",
"s",
".",
"fixedRight",
")",
";",
"}",
"/* Disallow columns for being reordered by drag and drop, counting left to right */",
"if",
"(",
"this",
".",
"s",
".",
"fixed",
"!==",
"0",
")",
"{",
"this",
".",
"s",
".",
"aoTargets",
".",
"splice",
"(",
"0",
",",
"this",
".",
"s",
".",
"fixed",
")",
";",
"}",
"}"
]
| Calculate a cached array with the points of the column inserts, and the
'to' points
@method _fnRegions
@returns void
@private | [
"Calculate",
"a",
"cached",
"array",
"with",
"the",
"points",
"of",
"the",
"column",
"inserts",
"and",
"the",
"to",
"points"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js#L989-L1032 |
|
39,401 | S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js | function ()
{
var scrolling = this.s.dt.oScroll.sX !== "" || this.s.dt.oScroll.sY !== "";
var origCell = this.s.dt.aoColumns[ this.s.mouse.targetIndex ].nTh;
var origTr = origCell.parentNode;
var origThead = origTr.parentNode;
var origTable = origThead.parentNode;
var cloneCell = $(origCell).clone();
// This is a slightly odd combination of jQuery and DOM, but it is the
// fastest and least resource intensive way I could think of cloning
// the table with just a single header cell in it.
this.dom.drag = $(origTable.cloneNode(false))
.addClass( 'DTCR_clonedTable' )
.append(
$(origThead.cloneNode(false)).append(
$(origTr.cloneNode(false)).append(
cloneCell[0]
)
)
)
.css( {
position: 'absolute',
top: 0,
left: 0,
width: $(origCell).outerWidth(),
height: $(origCell).outerHeight()
} )
.appendTo( 'body' );
this.dom.pointer = $('<div></div>')
.addClass( 'DTCR_pointer' )
.css( {
position: 'absolute',
top: scrolling ?
$('div.dataTables_scroll', this.s.dt.nTableWrapper).offset().top :
$(this.s.dt.nTable).offset().top,
height : scrolling ?
$('div.dataTables_scroll', this.s.dt.nTableWrapper).height() :
$(this.s.dt.nTable).height()
} )
.appendTo( 'body' );
} | javascript | function ()
{
var scrolling = this.s.dt.oScroll.sX !== "" || this.s.dt.oScroll.sY !== "";
var origCell = this.s.dt.aoColumns[ this.s.mouse.targetIndex ].nTh;
var origTr = origCell.parentNode;
var origThead = origTr.parentNode;
var origTable = origThead.parentNode;
var cloneCell = $(origCell).clone();
// This is a slightly odd combination of jQuery and DOM, but it is the
// fastest and least resource intensive way I could think of cloning
// the table with just a single header cell in it.
this.dom.drag = $(origTable.cloneNode(false))
.addClass( 'DTCR_clonedTable' )
.append(
$(origThead.cloneNode(false)).append(
$(origTr.cloneNode(false)).append(
cloneCell[0]
)
)
)
.css( {
position: 'absolute',
top: 0,
left: 0,
width: $(origCell).outerWidth(),
height: $(origCell).outerHeight()
} )
.appendTo( 'body' );
this.dom.pointer = $('<div></div>')
.addClass( 'DTCR_pointer' )
.css( {
position: 'absolute',
top: scrolling ?
$('div.dataTables_scroll', this.s.dt.nTableWrapper).offset().top :
$(this.s.dt.nTable).offset().top,
height : scrolling ?
$('div.dataTables_scroll', this.s.dt.nTableWrapper).height() :
$(this.s.dt.nTable).height()
} )
.appendTo( 'body' );
} | [
"function",
"(",
")",
"{",
"var",
"scrolling",
"=",
"this",
".",
"s",
".",
"dt",
".",
"oScroll",
".",
"sX",
"!==",
"\"\"",
"||",
"this",
".",
"s",
".",
"dt",
".",
"oScroll",
".",
"sY",
"!==",
"\"\"",
";",
"var",
"origCell",
"=",
"this",
".",
"s",
".",
"dt",
".",
"aoColumns",
"[",
"this",
".",
"s",
".",
"mouse",
".",
"targetIndex",
"]",
".",
"nTh",
";",
"var",
"origTr",
"=",
"origCell",
".",
"parentNode",
";",
"var",
"origThead",
"=",
"origTr",
".",
"parentNode",
";",
"var",
"origTable",
"=",
"origThead",
".",
"parentNode",
";",
"var",
"cloneCell",
"=",
"$",
"(",
"origCell",
")",
".",
"clone",
"(",
")",
";",
"// This is a slightly odd combination of jQuery and DOM, but it is the",
"// fastest and least resource intensive way I could think of cloning",
"// the table with just a single header cell in it.",
"this",
".",
"dom",
".",
"drag",
"=",
"$",
"(",
"origTable",
".",
"cloneNode",
"(",
"false",
")",
")",
".",
"addClass",
"(",
"'DTCR_clonedTable'",
")",
".",
"append",
"(",
"$",
"(",
"origThead",
".",
"cloneNode",
"(",
"false",
")",
")",
".",
"append",
"(",
"$",
"(",
"origTr",
".",
"cloneNode",
"(",
"false",
")",
")",
".",
"append",
"(",
"cloneCell",
"[",
"0",
"]",
")",
")",
")",
".",
"css",
"(",
"{",
"position",
":",
"'absolute'",
",",
"top",
":",
"0",
",",
"left",
":",
"0",
",",
"width",
":",
"$",
"(",
"origCell",
")",
".",
"outerWidth",
"(",
")",
",",
"height",
":",
"$",
"(",
"origCell",
")",
".",
"outerHeight",
"(",
")",
"}",
")",
".",
"appendTo",
"(",
"'body'",
")",
";",
"this",
".",
"dom",
".",
"pointer",
"=",
"$",
"(",
"'<div></div>'",
")",
".",
"addClass",
"(",
"'DTCR_pointer'",
")",
".",
"css",
"(",
"{",
"position",
":",
"'absolute'",
",",
"top",
":",
"scrolling",
"?",
"$",
"(",
"'div.dataTables_scroll'",
",",
"this",
".",
"s",
".",
"dt",
".",
"nTableWrapper",
")",
".",
"offset",
"(",
")",
".",
"top",
":",
"$",
"(",
"this",
".",
"s",
".",
"dt",
".",
"nTable",
")",
".",
"offset",
"(",
")",
".",
"top",
",",
"height",
":",
"scrolling",
"?",
"$",
"(",
"'div.dataTables_scroll'",
",",
"this",
".",
"s",
".",
"dt",
".",
"nTableWrapper",
")",
".",
"height",
"(",
")",
":",
"$",
"(",
"this",
".",
"s",
".",
"dt",
".",
"nTable",
")",
".",
"height",
"(",
")",
"}",
")",
".",
"appendTo",
"(",
"'body'",
")",
";",
"}"
]
| Copy the TH element that is being drags so the user has the idea that they are actually
moving it around the page.
@method _fnCreateDragNode
@returns void
@private | [
"Copy",
"the",
"TH",
"element",
"that",
"is",
"being",
"drags",
"so",
"the",
"user",
"has",
"the",
"idea",
"that",
"they",
"are",
"actually",
"moving",
"it",
"around",
"the",
"page",
"."
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js#L1042-L1085 |
|
39,402 | S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js | function ()
{
var i, iLen;
for ( i=0, iLen=this.s.dt.aoDrawCallback.length ; i<iLen ; i++ )
{
if ( this.s.dt.aoDrawCallback[i].sName === 'ColReorder_Pre' )
{
this.s.dt.aoDrawCallback.splice( i, 1 );
break;
}
}
$(this.s.dt.nTHead).find( '*' ).off( '.ColReorder' );
$.each( this.s.dt.aoColumns, function (i, column) {
$(column.nTh).removeAttr('data-column-index');
} );
this.s.dt._colReorder = null;
this.s = null;
} | javascript | function ()
{
var i, iLen;
for ( i=0, iLen=this.s.dt.aoDrawCallback.length ; i<iLen ; i++ )
{
if ( this.s.dt.aoDrawCallback[i].sName === 'ColReorder_Pre' )
{
this.s.dt.aoDrawCallback.splice( i, 1 );
break;
}
}
$(this.s.dt.nTHead).find( '*' ).off( '.ColReorder' );
$.each( this.s.dt.aoColumns, function (i, column) {
$(column.nTh).removeAttr('data-column-index');
} );
this.s.dt._colReorder = null;
this.s = null;
} | [
"function",
"(",
")",
"{",
"var",
"i",
",",
"iLen",
";",
"for",
"(",
"i",
"=",
"0",
",",
"iLen",
"=",
"this",
".",
"s",
".",
"dt",
".",
"aoDrawCallback",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"if",
"(",
"this",
".",
"s",
".",
"dt",
".",
"aoDrawCallback",
"[",
"i",
"]",
".",
"sName",
"===",
"'ColReorder_Pre'",
")",
"{",
"this",
".",
"s",
".",
"dt",
".",
"aoDrawCallback",
".",
"splice",
"(",
"i",
",",
"1",
")",
";",
"break",
";",
"}",
"}",
"$",
"(",
"this",
".",
"s",
".",
"dt",
".",
"nTHead",
")",
".",
"find",
"(",
"'*'",
")",
".",
"off",
"(",
"'.ColReorder'",
")",
";",
"$",
".",
"each",
"(",
"this",
".",
"s",
".",
"dt",
".",
"aoColumns",
",",
"function",
"(",
"i",
",",
"column",
")",
"{",
"$",
"(",
"column",
".",
"nTh",
")",
".",
"removeAttr",
"(",
"'data-column-index'",
")",
";",
"}",
")",
";",
"this",
".",
"s",
".",
"dt",
".",
"_colReorder",
"=",
"null",
";",
"this",
".",
"s",
"=",
"null",
";",
"}"
]
| Clean up ColReorder memory references and event handlers
@method _fnDestroy
@returns void
@private | [
"Clean",
"up",
"ColReorder",
"memory",
"references",
"and",
"event",
"handlers"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js#L1093-L1114 |
|
39,403 | S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js | function ()
{
$.each( this.s.dt.aoColumns, function (i, column) {
$(column.nTh).attr('data-column-index', i);
} );
} | javascript | function ()
{
$.each( this.s.dt.aoColumns, function (i, column) {
$(column.nTh).attr('data-column-index', i);
} );
} | [
"function",
"(",
")",
"{",
"$",
".",
"each",
"(",
"this",
".",
"s",
".",
"dt",
".",
"aoColumns",
",",
"function",
"(",
"i",
",",
"column",
")",
"{",
"$",
"(",
"column",
".",
"nTh",
")",
".",
"attr",
"(",
"'data-column-index'",
",",
"i",
")",
";",
"}",
")",
";",
"}"
]
| Add a data attribute to the column headers, so we know the index of
the row to be reordered. This allows fast detection of the index, and
for this plug-in to work with FixedHeader which clones the nodes.
@private | [
"Add",
"a",
"data",
"attribute",
"to",
"the",
"column",
"headers",
"so",
"we",
"know",
"the",
"index",
"of",
"the",
"row",
"to",
"be",
"reordered",
".",
"This",
"allows",
"fast",
"detection",
"of",
"the",
"index",
"and",
"for",
"this",
"plug",
"-",
"in",
"to",
"work",
"with",
"FixedHeader",
"which",
"clones",
"the",
"nodes",
"."
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js#L1123-L1128 |
|
39,404 | Mozu/grunt-mozu-appdev-sync | tasks/mozusync.js | function() {
return appdev.getMetadata(['./assets/functions.json']).then(function() {
if (!appdev.client.context['user-claims']) {
grunt.fail.fatal('failed to authenticate to Mozu');
done();
return false;
}
return false;
}).catch(
function(err) {
grunt.fail.fatal('failed to authenticate to Mozu');
done();
return true;
});
} | javascript | function() {
return appdev.getMetadata(['./assets/functions.json']).then(function() {
if (!appdev.client.context['user-claims']) {
grunt.fail.fatal('failed to authenticate to Mozu');
done();
return false;
}
return false;
}).catch(
function(err) {
grunt.fail.fatal('failed to authenticate to Mozu');
done();
return true;
});
} | [
"function",
"(",
")",
"{",
"return",
"appdev",
".",
"getMetadata",
"(",
"[",
"'./assets/functions.json'",
"]",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"appdev",
".",
"client",
".",
"context",
"[",
"'user-claims'",
"]",
")",
"{",
"grunt",
".",
"fail",
".",
"fatal",
"(",
"'failed to authenticate to Mozu'",
")",
";",
"done",
"(",
")",
";",
"return",
"false",
";",
"}",
"return",
"false",
";",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"err",
")",
"{",
"grunt",
".",
"fail",
".",
"fatal",
"(",
"'failed to authenticate to Mozu'",
")",
";",
"done",
"(",
")",
";",
"return",
"true",
";",
"}",
")",
";",
"}"
]
| add a single get call to initialize the credentials. Paralallezing calls caused issues reading from the console . | [
"add",
"a",
"single",
"get",
"call",
"to",
"initialize",
"the",
"credentials",
".",
"Paralallezing",
"calls",
"caused",
"issues",
"reading",
"from",
"the",
"console",
"."
]
| 5eb27b91113c8b30420404b767895bcb7e9a92b5 | https://github.com/Mozu/grunt-mozu-appdev-sync/blob/5eb27b91113c8b30420404b767895bcb7e9a92b5/tasks/mozusync.js#L246-L260 |
|
39,405 | tywei90/arr-del | index.js | arrDel | function arrDel(arr, indexArr) {
// check params
if (arr == null) {
return [];
}else if(Object.prototype.toString.call(arr) !== "[object Array]"){
throw new TypeError('PARAM MUST BE ARRAY');
}
if(indexArr == null){
return arr
}else if(Object.prototype.toString.call(indexArr) !== "[object Array]"){
throw new TypeError('PARAM MUST BE ARRAY');
}
var arrLen = arr.length;
for(var i=0, len=indexArr.length; i < len; i++){
if(typeof indexArr[i] !== "number"){
throw new TypeError('PARAM MUST BE NUMBER ARRAY');
}
if(Math.abs(indexArr[i]) > arrLen){
indexArr[i] = arrLen + 1;
}
if(indexArr[i] >= -arrLen && indexArr[i] < 0){
indexArr[i] = indexArr[i] + arrLen;
}
}
// first sort indexArr, then remove redupliction
indexArr.sort(function(a, b){
return a - b
})
var tmpArr = [];
for(var i=0, len=indexArr.length; i < len; i++){
if(tmpArr.indexOf(indexArr[i]) == -1){
tmpArr.push(indexArr[i])
}
}
// should not change the value of input arr
var outArr = JSON.parse(JSON.stringify(arr));
if (arr.length === 0) {
return [];
}
for (var i = 0, len = tmpArr.length; i < len; i++) {
outArr.splice(tmpArr[i] - i, 1);
}
return outArr
} | javascript | function arrDel(arr, indexArr) {
// check params
if (arr == null) {
return [];
}else if(Object.prototype.toString.call(arr) !== "[object Array]"){
throw new TypeError('PARAM MUST BE ARRAY');
}
if(indexArr == null){
return arr
}else if(Object.prototype.toString.call(indexArr) !== "[object Array]"){
throw new TypeError('PARAM MUST BE ARRAY');
}
var arrLen = arr.length;
for(var i=0, len=indexArr.length; i < len; i++){
if(typeof indexArr[i] !== "number"){
throw new TypeError('PARAM MUST BE NUMBER ARRAY');
}
if(Math.abs(indexArr[i]) > arrLen){
indexArr[i] = arrLen + 1;
}
if(indexArr[i] >= -arrLen && indexArr[i] < 0){
indexArr[i] = indexArr[i] + arrLen;
}
}
// first sort indexArr, then remove redupliction
indexArr.sort(function(a, b){
return a - b
})
var tmpArr = [];
for(var i=0, len=indexArr.length; i < len; i++){
if(tmpArr.indexOf(indexArr[i]) == -1){
tmpArr.push(indexArr[i])
}
}
// should not change the value of input arr
var outArr = JSON.parse(JSON.stringify(arr));
if (arr.length === 0) {
return [];
}
for (var i = 0, len = tmpArr.length; i < len; i++) {
outArr.splice(tmpArr[i] - i, 1);
}
return outArr
} | [
"function",
"arrDel",
"(",
"arr",
",",
"indexArr",
")",
"{",
"// check params",
"if",
"(",
"arr",
"==",
"null",
")",
"{",
"return",
"[",
"]",
";",
"}",
"else",
"if",
"(",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"arr",
")",
"!==",
"\"[object Array]\"",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'PARAM MUST BE ARRAY'",
")",
";",
"}",
"if",
"(",
"indexArr",
"==",
"null",
")",
"{",
"return",
"arr",
"}",
"else",
"if",
"(",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"indexArr",
")",
"!==",
"\"[object Array]\"",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'PARAM MUST BE ARRAY'",
")",
";",
"}",
"var",
"arrLen",
"=",
"arr",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"indexArr",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"typeof",
"indexArr",
"[",
"i",
"]",
"!==",
"\"number\"",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'PARAM MUST BE NUMBER ARRAY'",
")",
";",
"}",
"if",
"(",
"Math",
".",
"abs",
"(",
"indexArr",
"[",
"i",
"]",
")",
">",
"arrLen",
")",
"{",
"indexArr",
"[",
"i",
"]",
"=",
"arrLen",
"+",
"1",
";",
"}",
"if",
"(",
"indexArr",
"[",
"i",
"]",
">=",
"-",
"arrLen",
"&&",
"indexArr",
"[",
"i",
"]",
"<",
"0",
")",
"{",
"indexArr",
"[",
"i",
"]",
"=",
"indexArr",
"[",
"i",
"]",
"+",
"arrLen",
";",
"}",
"}",
"// first sort indexArr, then remove redupliction",
"indexArr",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"return",
"a",
"-",
"b",
"}",
")",
"var",
"tmpArr",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"indexArr",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"tmpArr",
".",
"indexOf",
"(",
"indexArr",
"[",
"i",
"]",
")",
"==",
"-",
"1",
")",
"{",
"tmpArr",
".",
"push",
"(",
"indexArr",
"[",
"i",
"]",
")",
"}",
"}",
"// should not change the value of input arr",
"var",
"outArr",
"=",
"JSON",
".",
"parse",
"(",
"JSON",
".",
"stringify",
"(",
"arr",
")",
")",
";",
"if",
"(",
"arr",
".",
"length",
"===",
"0",
")",
"{",
"return",
"[",
"]",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"tmpArr",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"outArr",
".",
"splice",
"(",
"tmpArr",
"[",
"i",
"]",
"-",
"i",
",",
"1",
")",
";",
"}",
"return",
"outArr",
"}"
]
| Delete array elements in one time by array consists of their indexes
@param {Array} `arr` The Array to sort.
@param {Number Array} `indexArr` Array consists of indexes which you want to delete.
@return {Array} Returns a new deleted array.
@api public | [
"Delete",
"array",
"elements",
"in",
"one",
"time",
"by",
"array",
"consists",
"of",
"their",
"indexes"
]
| c1f55b9621a154785d8ef35bfc60fb4d1c3a2d62 | https://github.com/tywei90/arr-del/blob/c1f55b9621a154785d8ef35bfc60fb4d1c3a2d62/index.js#L21-L64 |
39,406 | gillesruppert/nodecopter-leap | leap-remote.js | getGesture | function getGesture(gestures, type) {
if (!gestures.length) return;
var types = _.pluck(gestures, 'type');
var index = types.indexOf(type);
if (index > -1) return gestures[index];
} | javascript | function getGesture(gestures, type) {
if (!gestures.length) return;
var types = _.pluck(gestures, 'type');
var index = types.indexOf(type);
if (index > -1) return gestures[index];
} | [
"function",
"getGesture",
"(",
"gestures",
",",
"type",
")",
"{",
"if",
"(",
"!",
"gestures",
".",
"length",
")",
"return",
";",
"var",
"types",
"=",
"_",
".",
"pluck",
"(",
"gestures",
",",
"'type'",
")",
";",
"var",
"index",
"=",
"types",
".",
"indexOf",
"(",
"type",
")",
";",
"if",
"(",
"index",
">",
"-",
"1",
")",
"return",
"gestures",
"[",
"index",
"]",
";",
"}"
]
| get only the circle gesture from the gestures array | [
"get",
"only",
"the",
"circle",
"gesture",
"from",
"the",
"gestures",
"array"
]
| d0fea0166bc13f0bec5ede97dd418be0016260f6 | https://github.com/gillesruppert/nodecopter-leap/blob/d0fea0166bc13f0bec5ede97dd418be0016260f6/leap-remote.js#L94-L99 |
39,407 | tarunc/mongoose-stamp | lib/mongoose-stamps.js | timestampsPlugin | function timestampsPlugin(schema, options) {
// Add the fields to the schema
schema.add({
createdAt: {
type: Date,
'default': Date.now
},
updatedAt: {
type: Date,
'default': Date.now
},
deletedAt: {
type: Date,
sparse: true
}
});
// Define the pre save hook
schema.pre('save', function (next) {
this.updatedAt = new Date();
next();
});
// Create an index on all the paths
schema.path('createdAt').index(true);
schema.path('updatedAt').index(true);
schema.path('deletedAt').index(true);
} | javascript | function timestampsPlugin(schema, options) {
// Add the fields to the schema
schema.add({
createdAt: {
type: Date,
'default': Date.now
},
updatedAt: {
type: Date,
'default': Date.now
},
deletedAt: {
type: Date,
sparse: true
}
});
// Define the pre save hook
schema.pre('save', function (next) {
this.updatedAt = new Date();
next();
});
// Create an index on all the paths
schema.path('createdAt').index(true);
schema.path('updatedAt').index(true);
schema.path('deletedAt').index(true);
} | [
"function",
"timestampsPlugin",
"(",
"schema",
",",
"options",
")",
"{",
"// Add the fields to the schema",
"schema",
".",
"add",
"(",
"{",
"createdAt",
":",
"{",
"type",
":",
"Date",
",",
"'default'",
":",
"Date",
".",
"now",
"}",
",",
"updatedAt",
":",
"{",
"type",
":",
"Date",
",",
"'default'",
":",
"Date",
".",
"now",
"}",
",",
"deletedAt",
":",
"{",
"type",
":",
"Date",
",",
"sparse",
":",
"true",
"}",
"}",
")",
";",
"// Define the pre save hook",
"schema",
".",
"pre",
"(",
"'save'",
",",
"function",
"(",
"next",
")",
"{",
"this",
".",
"updatedAt",
"=",
"new",
"Date",
"(",
")",
";",
"next",
"(",
")",
";",
"}",
")",
";",
"// Create an index on all the paths",
"schema",
".",
"path",
"(",
"'createdAt'",
")",
".",
"index",
"(",
"true",
")",
";",
"schema",
".",
"path",
"(",
"'updatedAt'",
")",
".",
"index",
"(",
"true",
")",
";",
"schema",
".",
"path",
"(",
"'deletedAt'",
")",
".",
"index",
"(",
"true",
")",
";",
"}"
]
| `Timestamps` Plugin for Mongoose.
@param {mongoose.Schema} schema -
@param {Object} options - some options
@api public | [
"Timestamps",
"Plugin",
"for",
"Mongoose",
"."
]
| 9714b79b5cd1ee17195fc4812c28cf5534f7764a | https://github.com/tarunc/mongoose-stamp/blob/9714b79b5cd1ee17195fc4812c28cf5534f7764a/lib/mongoose-stamps.js#L9-L37 |
39,408 | alexcjohnson/world-calendars | dist/main.js | function(date) {
if (this._calendar.name !== date._calendar.name) {
throw (_exports.local.differentCalendars || _exports.regionalOptions[''].differentCalendars).
replace(/\{0\}/, this._calendar.local.name).replace(/\{1\}/, date._calendar.local.name);
}
var c = (this._year !== date._year ? this._year - date._year :
this._month !== date._month ? this.monthOfYear() - date.monthOfYear() :
this._day - date._day);
return (c === 0 ? 0 : (c < 0 ? -1 : +1));
} | javascript | function(date) {
if (this._calendar.name !== date._calendar.name) {
throw (_exports.local.differentCalendars || _exports.regionalOptions[''].differentCalendars).
replace(/\{0\}/, this._calendar.local.name).replace(/\{1\}/, date._calendar.local.name);
}
var c = (this._year !== date._year ? this._year - date._year :
this._month !== date._month ? this.monthOfYear() - date.monthOfYear() :
this._day - date._day);
return (c === 0 ? 0 : (c < 0 ? -1 : +1));
} | [
"function",
"(",
"date",
")",
"{",
"if",
"(",
"this",
".",
"_calendar",
".",
"name",
"!==",
"date",
".",
"_calendar",
".",
"name",
")",
"{",
"throw",
"(",
"_exports",
".",
"local",
".",
"differentCalendars",
"||",
"_exports",
".",
"regionalOptions",
"[",
"''",
"]",
".",
"differentCalendars",
")",
".",
"replace",
"(",
"/",
"\\{0\\}",
"/",
",",
"this",
".",
"_calendar",
".",
"local",
".",
"name",
")",
".",
"replace",
"(",
"/",
"\\{1\\}",
"/",
",",
"date",
".",
"_calendar",
".",
"local",
".",
"name",
")",
";",
"}",
"var",
"c",
"=",
"(",
"this",
".",
"_year",
"!==",
"date",
".",
"_year",
"?",
"this",
".",
"_year",
"-",
"date",
".",
"_year",
":",
"this",
".",
"_month",
"!==",
"date",
".",
"_month",
"?",
"this",
".",
"monthOfYear",
"(",
")",
"-",
"date",
".",
"monthOfYear",
"(",
")",
":",
"this",
".",
"_day",
"-",
"date",
".",
"_day",
")",
";",
"return",
"(",
"c",
"===",
"0",
"?",
"0",
":",
"(",
"c",
"<",
"0",
"?",
"-",
"1",
":",
"+",
"1",
")",
")",
";",
"}"
]
| Compare this date to another date.
@memberof CDate
@param date {CDate} The other date.
@return {number} -1 if this date is before the other date,
0 if they are equal, or +1 if this date is after the other date. | [
"Compare",
"this",
"date",
"to",
"another",
"date",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/dist/main.js#L302-L311 |
|
39,409 | alexcjohnson/world-calendars | dist/main.js | function(year) {
var date = this._validate(year, this.minMonth, this.minDay,
_exports.local.invalidYear || _exports.regionalOptions[''].invalidYear);
return (date.year() < 0 ? '-' : '') + pad(Math.abs(date.year()), 4)
} | javascript | function(year) {
var date = this._validate(year, this.minMonth, this.minDay,
_exports.local.invalidYear || _exports.regionalOptions[''].invalidYear);
return (date.year() < 0 ? '-' : '') + pad(Math.abs(date.year()), 4)
} | [
"function",
"(",
"year",
")",
"{",
"var",
"date",
"=",
"this",
".",
"_validate",
"(",
"year",
",",
"this",
".",
"minMonth",
",",
"this",
".",
"minDay",
",",
"_exports",
".",
"local",
".",
"invalidYear",
"||",
"_exports",
".",
"regionalOptions",
"[",
"''",
"]",
".",
"invalidYear",
")",
";",
"return",
"(",
"date",
".",
"year",
"(",
")",
"<",
"0",
"?",
"'-'",
":",
"''",
")",
"+",
"pad",
"(",
"Math",
".",
"abs",
"(",
"date",
".",
"year",
"(",
")",
")",
",",
"4",
")",
"}"
]
| Format the year, if not a simple sequential number
@memberof BaseCalendar
@param year {CDate|number} The date to format or the year to format.
@return {string} The formatted year.
@throws Error if an invalid year or a different calendar used. | [
"Format",
"the",
"year",
"if",
"not",
"a",
"simple",
"sequential",
"number"
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/dist/main.js#L415-L419 |
|
39,410 | alexcjohnson/world-calendars | dist/main.js | function(year, ord) {
var m = (ord + this.firstMonth - 2 * this.minMonth) %
this.monthsInYear(year) + this.minMonth;
this._validate(year, m, this.minDay,
_exports.local.invalidMonth || _exports.regionalOptions[''].invalidMonth);
return m;
} | javascript | function(year, ord) {
var m = (ord + this.firstMonth - 2 * this.minMonth) %
this.monthsInYear(year) + this.minMonth;
this._validate(year, m, this.minDay,
_exports.local.invalidMonth || _exports.regionalOptions[''].invalidMonth);
return m;
} | [
"function",
"(",
"year",
",",
"ord",
")",
"{",
"var",
"m",
"=",
"(",
"ord",
"+",
"this",
".",
"firstMonth",
"-",
"2",
"*",
"this",
".",
"minMonth",
")",
"%",
"this",
".",
"monthsInYear",
"(",
"year",
")",
"+",
"this",
".",
"minMonth",
";",
"this",
".",
"_validate",
"(",
"year",
",",
"m",
",",
"this",
".",
"minDay",
",",
"_exports",
".",
"local",
".",
"invalidMonth",
"||",
"_exports",
".",
"regionalOptions",
"[",
"''",
"]",
".",
"invalidMonth",
")",
";",
"return",
"m",
";",
"}"
]
| Calculate actual month from ordinal position, starting from minMonth.
@memberof BaseCalendar
@param year {number} The year to examine.
@param ord {number} The month's ordinal position.
@return {number} The month's number.
@throws Error if an invalid year/month. | [
"Calculate",
"actual",
"month",
"from",
"ordinal",
"position",
"starting",
"from",
"minMonth",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/dist/main.js#L452-L458 |
|
39,411 | alexcjohnson/world-calendars | dist/main.js | function(year, month, day) {
var date = this._validate(year, month, day,
_exports.local.invalidDate || _exports.regionalOptions[''].invalidDate);
return date.toJD() - this.newDate(date.year(),
this.fromMonthOfYear(date.year(), this.minMonth), this.minDay).toJD() + 1;
} | javascript | function(year, month, day) {
var date = this._validate(year, month, day,
_exports.local.invalidDate || _exports.regionalOptions[''].invalidDate);
return date.toJD() - this.newDate(date.year(),
this.fromMonthOfYear(date.year(), this.minMonth), this.minDay).toJD() + 1;
} | [
"function",
"(",
"year",
",",
"month",
",",
"day",
")",
"{",
"var",
"date",
"=",
"this",
".",
"_validate",
"(",
"year",
",",
"month",
",",
"day",
",",
"_exports",
".",
"local",
".",
"invalidDate",
"||",
"_exports",
".",
"regionalOptions",
"[",
"''",
"]",
".",
"invalidDate",
")",
";",
"return",
"date",
".",
"toJD",
"(",
")",
"-",
"this",
".",
"newDate",
"(",
"date",
".",
"year",
"(",
")",
",",
"this",
".",
"fromMonthOfYear",
"(",
"date",
".",
"year",
"(",
")",
",",
"this",
".",
"minMonth",
")",
",",
"this",
".",
"minDay",
")",
".",
"toJD",
"(",
")",
"+",
"1",
";",
"}"
]
| Retrieve the day of the year for a date.
@memberof BaseCalendar
@param year {CDate|number} The date to convert or the year to convert.
@param [month] {number} The month to convert.
@param [day] {number} The day to convert.
@return {number} The day of the year.
@throws Error if an invalid date or a different calendar used. | [
"Retrieve",
"the",
"day",
"of",
"the",
"year",
"for",
"a",
"date",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/dist/main.js#L478-L483 |
|
39,412 | alexcjohnson/world-calendars | dist/main.js | function(year, month, day) {
var date = this._validate(year, month, day,
_exports.local.invalidDate || _exports.regionalOptions[''].invalidDate);
return (Math.floor(this.toJD(date)) + 2) % this.daysInWeek();
} | javascript | function(year, month, day) {
var date = this._validate(year, month, day,
_exports.local.invalidDate || _exports.regionalOptions[''].invalidDate);
return (Math.floor(this.toJD(date)) + 2) % this.daysInWeek();
} | [
"function",
"(",
"year",
",",
"month",
",",
"day",
")",
"{",
"var",
"date",
"=",
"this",
".",
"_validate",
"(",
"year",
",",
"month",
",",
"day",
",",
"_exports",
".",
"local",
".",
"invalidDate",
"||",
"_exports",
".",
"regionalOptions",
"[",
"''",
"]",
".",
"invalidDate",
")",
";",
"return",
"(",
"Math",
".",
"floor",
"(",
"this",
".",
"toJD",
"(",
"date",
")",
")",
"+",
"2",
")",
"%",
"this",
".",
"daysInWeek",
"(",
")",
";",
"}"
]
| Retrieve the day of the week for a date.
@memberof BaseCalendar
@param year {CDate|number} The date to examine or the year to examine.
@param [month] {number} The month to examine.
@param [day] {number} The day to examine.
@return {number} The day of the week: 0 to number of days - 1.
@throws Error if an invalid date or a different calendar used. | [
"Retrieve",
"the",
"day",
"of",
"the",
"week",
"for",
"a",
"date",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/dist/main.js#L499-L503 |
|
39,413 | alexcjohnson/world-calendars | dist/main.js | function(year, month, day) {
this._validate(year, month, day,
_exports.local.invalidDate || _exports.regionalOptions[''].invalidDate);
return {};
} | javascript | function(year, month, day) {
this._validate(year, month, day,
_exports.local.invalidDate || _exports.regionalOptions[''].invalidDate);
return {};
} | [
"function",
"(",
"year",
",",
"month",
",",
"day",
")",
"{",
"this",
".",
"_validate",
"(",
"year",
",",
"month",
",",
"day",
",",
"_exports",
".",
"local",
".",
"invalidDate",
"||",
"_exports",
".",
"regionalOptions",
"[",
"''",
"]",
".",
"invalidDate",
")",
";",
"return",
"{",
"}",
";",
"}"
]
| Retrieve additional information about a date.
@memberof BaseCalendar
@param year {CDate|number} The date to examine or the year to examine.
@param [month] {number} The month to examine.
@param [day] {number} The day to examine.
@return {object} Additional information - contents depends on calendar.
@throws Error if an invalid date or a different calendar used. | [
"Retrieve",
"additional",
"information",
"about",
"a",
"date",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/dist/main.js#L512-L516 |
|
39,414 | alexcjohnson/world-calendars | dist/main.js | function(date, value, period) {
this._validate(date, this.minMonth, this.minDay,
_exports.local.invalidDate || _exports.regionalOptions[''].invalidDate);
var y = (period === 'y' ? value : date.year());
var m = (period === 'm' ? value : date.month());
var d = (period === 'd' ? value : date.day());
if (period === 'y' || period === 'm') {
d = Math.min(d, this.daysInMonth(y, m));
}
return date.date(y, m, d);
} | javascript | function(date, value, period) {
this._validate(date, this.minMonth, this.minDay,
_exports.local.invalidDate || _exports.regionalOptions[''].invalidDate);
var y = (period === 'y' ? value : date.year());
var m = (period === 'm' ? value : date.month());
var d = (period === 'd' ? value : date.day());
if (period === 'y' || period === 'm') {
d = Math.min(d, this.daysInMonth(y, m));
}
return date.date(y, m, d);
} | [
"function",
"(",
"date",
",",
"value",
",",
"period",
")",
"{",
"this",
".",
"_validate",
"(",
"date",
",",
"this",
".",
"minMonth",
",",
"this",
".",
"minDay",
",",
"_exports",
".",
"local",
".",
"invalidDate",
"||",
"_exports",
".",
"regionalOptions",
"[",
"''",
"]",
".",
"invalidDate",
")",
";",
"var",
"y",
"=",
"(",
"period",
"===",
"'y'",
"?",
"value",
":",
"date",
".",
"year",
"(",
")",
")",
";",
"var",
"m",
"=",
"(",
"period",
"===",
"'m'",
"?",
"value",
":",
"date",
".",
"month",
"(",
")",
")",
";",
"var",
"d",
"=",
"(",
"period",
"===",
"'d'",
"?",
"value",
":",
"date",
".",
"day",
"(",
")",
")",
";",
"if",
"(",
"period",
"===",
"'y'",
"||",
"period",
"===",
"'m'",
")",
"{",
"d",
"=",
"Math",
".",
"min",
"(",
"d",
",",
"this",
".",
"daysInMonth",
"(",
"y",
",",
"m",
")",
")",
";",
"}",
"return",
"date",
".",
"date",
"(",
"y",
",",
"m",
",",
"d",
")",
";",
"}"
]
| Set a portion of the date.
@memberof BaseCalendar
@param date {CDate} The starting date.
@param value {number} The new value for the period.
@param period {string} One of 'y' for year, 'm' for month, 'd' for day.
@return {CDate} The updated date.
@throws Error if an invalid date or a different calendar used. | [
"Set",
"a",
"portion",
"of",
"the",
"date",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/dist/main.js#L615-L625 |
|
39,415 | S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/dist/js/app.js | function () {
//Get the object
var _this = this;
//Update options
var o = $.AdminLTE.options.controlSidebarOptions;
//Get the sidebar
var sidebar = $(o.selector);
//The toggle button
var btn = $(o.toggleBtnSelector);
//Listen to the click event
btn.on('click', function (e) {
e.preventDefault();
//If the sidebar is not open
if (!sidebar.hasClass('control-sidebar-open')
&& !$('body').hasClass('control-sidebar-open')) {
//Open the sidebar
_this.open(sidebar, o.slide);
} else {
_this.close(sidebar, o.slide);
}
});
//If the body has a boxed layout, fix the sidebar bg position
var bg = $(".control-sidebar-bg");
_this._fix(bg);
//If the body has a fixed layout, make the control sidebar fixed
if ($('body').hasClass('fixed')) {
_this._fixForFixed(sidebar);
} else {
//If the content height is less than the sidebar's height, force max height
if ($('.content-wrapper, .right-side').height() < sidebar.height()) {
_this._fixForContent(sidebar);
}
}
} | javascript | function () {
//Get the object
var _this = this;
//Update options
var o = $.AdminLTE.options.controlSidebarOptions;
//Get the sidebar
var sidebar = $(o.selector);
//The toggle button
var btn = $(o.toggleBtnSelector);
//Listen to the click event
btn.on('click', function (e) {
e.preventDefault();
//If the sidebar is not open
if (!sidebar.hasClass('control-sidebar-open')
&& !$('body').hasClass('control-sidebar-open')) {
//Open the sidebar
_this.open(sidebar, o.slide);
} else {
_this.close(sidebar, o.slide);
}
});
//If the body has a boxed layout, fix the sidebar bg position
var bg = $(".control-sidebar-bg");
_this._fix(bg);
//If the body has a fixed layout, make the control sidebar fixed
if ($('body').hasClass('fixed')) {
_this._fixForFixed(sidebar);
} else {
//If the content height is less than the sidebar's height, force max height
if ($('.content-wrapper, .right-side').height() < sidebar.height()) {
_this._fixForContent(sidebar);
}
}
} | [
"function",
"(",
")",
"{",
"//Get the object",
"var",
"_this",
"=",
"this",
";",
"//Update options",
"var",
"o",
"=",
"$",
".",
"AdminLTE",
".",
"options",
".",
"controlSidebarOptions",
";",
"//Get the sidebar",
"var",
"sidebar",
"=",
"$",
"(",
"o",
".",
"selector",
")",
";",
"//The toggle button",
"var",
"btn",
"=",
"$",
"(",
"o",
".",
"toggleBtnSelector",
")",
";",
"//Listen to the click event",
"btn",
".",
"on",
"(",
"'click'",
",",
"function",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"//If the sidebar is not open",
"if",
"(",
"!",
"sidebar",
".",
"hasClass",
"(",
"'control-sidebar-open'",
")",
"&&",
"!",
"$",
"(",
"'body'",
")",
".",
"hasClass",
"(",
"'control-sidebar-open'",
")",
")",
"{",
"//Open the sidebar",
"_this",
".",
"open",
"(",
"sidebar",
",",
"o",
".",
"slide",
")",
";",
"}",
"else",
"{",
"_this",
".",
"close",
"(",
"sidebar",
",",
"o",
".",
"slide",
")",
";",
"}",
"}",
")",
";",
"//If the body has a boxed layout, fix the sidebar bg position",
"var",
"bg",
"=",
"$",
"(",
"\".control-sidebar-bg\"",
")",
";",
"_this",
".",
"_fix",
"(",
"bg",
")",
";",
"//If the body has a fixed layout, make the control sidebar fixed",
"if",
"(",
"$",
"(",
"'body'",
")",
".",
"hasClass",
"(",
"'fixed'",
")",
")",
"{",
"_this",
".",
"_fixForFixed",
"(",
"sidebar",
")",
";",
"}",
"else",
"{",
"//If the content height is less than the sidebar's height, force max height",
"if",
"(",
"$",
"(",
"'.content-wrapper, .right-side'",
")",
".",
"height",
"(",
")",
"<",
"sidebar",
".",
"height",
"(",
")",
")",
"{",
"_this",
".",
"_fixForContent",
"(",
"sidebar",
")",
";",
"}",
"}",
"}"
]
| instantiate the object | [
"instantiate",
"the",
"object"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/dist/js/app.js#L443-L479 |
|
39,416 | burnnat/grunt-debug | tasks/debug.js | function(name, brk, debugChildren) {
var deferred = Q.defer();
var args = process.argv;
grunt.task.clearQueue();
var tasks = args.slice(args.indexOf(name) + 1);
if (debugChildren) {
tasks.unshift('debug:hook' + (brk ? '-break' : ''));
}
var child = child_process.fork(
args[1],
tasks,
{
execArgv: [
brk
? '--debug-brk'
: '--debug'
]
}
);
child.on('exit', function(code) {
if (code == 0) {
deferred.resolve();
}
else {
deferred.reject(code);
}
});
return deferred.promise;
} | javascript | function(name, brk, debugChildren) {
var deferred = Q.defer();
var args = process.argv;
grunt.task.clearQueue();
var tasks = args.slice(args.indexOf(name) + 1);
if (debugChildren) {
tasks.unshift('debug:hook' + (brk ? '-break' : ''));
}
var child = child_process.fork(
args[1],
tasks,
{
execArgv: [
brk
? '--debug-brk'
: '--debug'
]
}
);
child.on('exit', function(code) {
if (code == 0) {
deferred.resolve();
}
else {
deferred.reject(code);
}
});
return deferred.promise;
} | [
"function",
"(",
"name",
",",
"brk",
",",
"debugChildren",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"var",
"args",
"=",
"process",
".",
"argv",
";",
"grunt",
".",
"task",
".",
"clearQueue",
"(",
")",
";",
"var",
"tasks",
"=",
"args",
".",
"slice",
"(",
"args",
".",
"indexOf",
"(",
"name",
")",
"+",
"1",
")",
";",
"if",
"(",
"debugChildren",
")",
"{",
"tasks",
".",
"unshift",
"(",
"'debug:hook'",
"+",
"(",
"brk",
"?",
"'-break'",
":",
"''",
")",
")",
";",
"}",
"var",
"child",
"=",
"child_process",
".",
"fork",
"(",
"args",
"[",
"1",
"]",
",",
"tasks",
",",
"{",
"execArgv",
":",
"[",
"brk",
"?",
"'--debug-brk'",
":",
"'--debug'",
"]",
"}",
")",
";",
"child",
".",
"on",
"(",
"'exit'",
",",
"function",
"(",
"code",
")",
"{",
"if",
"(",
"code",
"==",
"0",
")",
"{",
"deferred",
".",
"resolve",
"(",
")",
";",
"}",
"else",
"{",
"deferred",
".",
"reject",
"(",
"code",
")",
";",
"}",
"}",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}"
]
| Manually forks the Grunt process for debugging | [
"Manually",
"forks",
"the",
"Grunt",
"process",
"for",
"debugging"
]
| 968fefb5c99621752bc8b81d0fe865c1f90b8eb0 | https://github.com/burnnat/grunt-debug/blob/968fefb5c99621752bc8b81d0fe865c1f90b8eb0/tasks/debug.js#L17-L51 |
|
39,417 | burnnat/grunt-debug | tasks/debug.js | function() {
var pid = process.pid;
return Q.fcall(function() {
if (process.platform === 'win32') {
process._debugProcess(pid);
}
else {
process.kill(pid, 'SIGUSR1');
}
});
} | javascript | function() {
var pid = process.pid;
return Q.fcall(function() {
if (process.platform === 'win32') {
process._debugProcess(pid);
}
else {
process.kill(pid, 'SIGUSR1');
}
});
} | [
"function",
"(",
")",
"{",
"var",
"pid",
"=",
"process",
".",
"pid",
";",
"return",
"Q",
".",
"fcall",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"process",
".",
"platform",
"===",
"'win32'",
")",
"{",
"process",
".",
"_debugProcess",
"(",
"pid",
")",
";",
"}",
"else",
"{",
"process",
".",
"kill",
"(",
"pid",
",",
"'SIGUSR1'",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Sets up existing Grunt process for debugging | [
"Sets",
"up",
"existing",
"Grunt",
"process",
"for",
"debugging"
]
| 968fefb5c99621752bc8b81d0fe865c1f90b8eb0 | https://github.com/burnnat/grunt-debug/blob/968fefb5c99621752bc8b81d0fe865c1f90b8eb0/tasks/debug.js#L56-L67 |
|
39,418 | burnnat/grunt-debug | tasks/debug.js | function(brk) {
hooks.enableHooks(
brk,
function(module, port) {
grunt.log.ok('Debugging forked process %s on port %d', module, port);
}
);
} | javascript | function(brk) {
hooks.enableHooks(
brk,
function(module, port) {
grunt.log.ok('Debugging forked process %s on port %d', module, port);
}
);
} | [
"function",
"(",
"brk",
")",
"{",
"hooks",
".",
"enableHooks",
"(",
"brk",
",",
"function",
"(",
"module",
",",
"port",
")",
"{",
"grunt",
".",
"log",
".",
"ok",
"(",
"'Debugging forked process %s on port %d'",
",",
"module",
",",
"port",
")",
";",
"}",
")",
";",
"}"
]
| Enabled debugging hooks for child processes | [
"Enabled",
"debugging",
"hooks",
"for",
"child",
"processes"
]
| 968fefb5c99621752bc8b81d0fe865c1f90b8eb0 | https://github.com/burnnat/grunt-debug/blob/968fefb5c99621752bc8b81d0fe865c1f90b8eb0/tasks/debug.js#L72-L79 |
|
39,419 | wearefractal/warlock | warlock.js | Transport | function Transport (opts) {
this.path = opts.path;
this.host = opts.host;
this.port = opts.port;
this.secure = opts.secure;
this.query = opts.query;
this.timestampParam = opts.timestampParam;
this.timestampRequests = opts.timestampRequests;
this.readyState = '';
} | javascript | function Transport (opts) {
this.path = opts.path;
this.host = opts.host;
this.port = opts.port;
this.secure = opts.secure;
this.query = opts.query;
this.timestampParam = opts.timestampParam;
this.timestampRequests = opts.timestampRequests;
this.readyState = '';
} | [
"function",
"Transport",
"(",
"opts",
")",
"{",
"this",
".",
"path",
"=",
"opts",
".",
"path",
";",
"this",
".",
"host",
"=",
"opts",
".",
"host",
";",
"this",
".",
"port",
"=",
"opts",
".",
"port",
";",
"this",
".",
"secure",
"=",
"opts",
".",
"secure",
";",
"this",
".",
"query",
"=",
"opts",
".",
"query",
";",
"this",
".",
"timestampParam",
"=",
"opts",
".",
"timestampParam",
";",
"this",
".",
"timestampRequests",
"=",
"opts",
".",
"timestampRequests",
";",
"this",
".",
"readyState",
"=",
"''",
";",
"}"
]
| Transport abstract constructor.
@param {Object} options.
@api private | [
"Transport",
"abstract",
"constructor",
"."
]
| de4a9ad1d030f3cdf1dc5c4560c7653c50ce3cde | https://github.com/wearefractal/warlock/blob/de4a9ad1d030f3cdf1dc5c4560c7653c50ce3cde/warlock.js#L906-L915 |
39,420 | wearefractal/warlock | warlock.js | create | function create (path, fn) {
if (scripts[path]) return fn();
var el = document.createElement('script');
var loaded = false;
// debug: loading "%s", path
el.onload = el.onreadystatechange = function () {
if (loaded || scripts[path]) return;
var rs = el.readyState;
if (!rs || 'loaded' == rs || 'complete' == rs) {
// debug: loaded "%s", path
el.onload = el.onreadystatechange = null;
loaded = true;
scripts[path] = true;
fn();
}
};
el.async = 1;
el.src = path;
var head = document.getElementsByTagName('head')[0];
head.insertBefore(el, head.firstChild);
} | javascript | function create (path, fn) {
if (scripts[path]) return fn();
var el = document.createElement('script');
var loaded = false;
// debug: loading "%s", path
el.onload = el.onreadystatechange = function () {
if (loaded || scripts[path]) return;
var rs = el.readyState;
if (!rs || 'loaded' == rs || 'complete' == rs) {
// debug: loaded "%s", path
el.onload = el.onreadystatechange = null;
loaded = true;
scripts[path] = true;
fn();
}
};
el.async = 1;
el.src = path;
var head = document.getElementsByTagName('head')[0];
head.insertBefore(el, head.firstChild);
} | [
"function",
"create",
"(",
"path",
",",
"fn",
")",
"{",
"if",
"(",
"scripts",
"[",
"path",
"]",
")",
"return",
"fn",
"(",
")",
";",
"var",
"el",
"=",
"document",
".",
"createElement",
"(",
"'script'",
")",
";",
"var",
"loaded",
"=",
"false",
";",
"// debug: loading \"%s\", path",
"el",
".",
"onload",
"=",
"el",
".",
"onreadystatechange",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"loaded",
"||",
"scripts",
"[",
"path",
"]",
")",
"return",
";",
"var",
"rs",
"=",
"el",
".",
"readyState",
";",
"if",
"(",
"!",
"rs",
"||",
"'loaded'",
"==",
"rs",
"||",
"'complete'",
"==",
"rs",
")",
"{",
"// debug: loaded \"%s\", path",
"el",
".",
"onload",
"=",
"el",
".",
"onreadystatechange",
"=",
"null",
";",
"loaded",
"=",
"true",
";",
"scripts",
"[",
"path",
"]",
"=",
"true",
";",
"fn",
"(",
")",
";",
"}",
"}",
";",
"el",
".",
"async",
"=",
"1",
";",
"el",
".",
"src",
"=",
"path",
";",
"var",
"head",
"=",
"document",
".",
"getElementsByTagName",
"(",
"'head'",
")",
"[",
"0",
"]",
";",
"head",
".",
"insertBefore",
"(",
"el",
",",
"head",
".",
"firstChild",
")",
";",
"}"
]
| Injects a script. Keeps tracked of injected ones.
@param {String} path
@param {Function} callback
@api private | [
"Injects",
"a",
"script",
".",
"Keeps",
"tracked",
"of",
"injected",
"ones",
"."
]
| de4a9ad1d030f3cdf1dc5c4560c7653c50ce3cde | https://github.com/wearefractal/warlock/blob/de4a9ad1d030f3cdf1dc5c4560c7653c50ce3cde/warlock.js#L1237-L1261 |
39,421 | express-bem/express-bem | lib/index.js | initVar | function initVar (key, envKey, def) {
var negate = !def;
switch (true) {
case cacheObj.hasOwnProperty(key):
return cacheObj[key];
case process.env.hasOwnProperty(envGlobalCacheKey):
return process.env[envGlobalCacheKey] !== '';
case process.env.hasOwnProperty(envKey):
return negate ? process.env[envKey] === 'YES' : process.env[envKey] !== 'NO';
default:
return def;
}
} | javascript | function initVar (key, envKey, def) {
var negate = !def;
switch (true) {
case cacheObj.hasOwnProperty(key):
return cacheObj[key];
case process.env.hasOwnProperty(envGlobalCacheKey):
return process.env[envGlobalCacheKey] !== '';
case process.env.hasOwnProperty(envKey):
return negate ? process.env[envKey] === 'YES' : process.env[envKey] !== 'NO';
default:
return def;
}
} | [
"function",
"initVar",
"(",
"key",
",",
"envKey",
",",
"def",
")",
"{",
"var",
"negate",
"=",
"!",
"def",
";",
"switch",
"(",
"true",
")",
"{",
"case",
"cacheObj",
".",
"hasOwnProperty",
"(",
"key",
")",
":",
"return",
"cacheObj",
"[",
"key",
"]",
";",
"case",
"process",
".",
"env",
".",
"hasOwnProperty",
"(",
"envGlobalCacheKey",
")",
":",
"return",
"process",
".",
"env",
"[",
"envGlobalCacheKey",
"]",
"!==",
"''",
";",
"case",
"process",
".",
"env",
".",
"hasOwnProperty",
"(",
"envKey",
")",
":",
"return",
"negate",
"?",
"process",
".",
"env",
"[",
"envKey",
"]",
"===",
"'YES'",
":",
"process",
".",
"env",
"[",
"envKey",
"]",
"!==",
"'NO'",
";",
"default",
":",
"return",
"def",
";",
"}",
"}"
]
| cache variable initializer
@param {String} key
@param {String} envKey
@param {Boolean} def
@returns {Boolean} | [
"cache",
"variable",
"initializer"
]
| 6ea49e5ecdd8e949dd5051ecc5762e40cbcead9c | https://github.com/express-bem/express-bem/blob/6ea49e5ecdd8e949dd5051ecc5762e40cbcead9c/lib/index.js#L213-L225 |
39,422 | CodingKoopa/eslint-plugin-more-naming-conventions | Source/Rules/UpperCamelCase.js | function(node)
{
// declarations is an array of the comma-separated variable declarations like "var foo, zerp;"
node.declarations.forEach(declaration =>
{
// id contains info about the variable being declare.
var variable_name = declaration.id.name;
// Skip if the variable is already whitelisted.
if (variable_whitelist.indexOf(variable_name) > -1)
return;
// init contains info about the value being initialized to. It is null when the variable is
// being declared without being initialized.
// If initialization type is "CallExpression", that means that the variable is being
// initialized to a function.
// init.callee contains info about the function that the value is being initialized to,
// undefined if it's not being initialized to a function, or at all.
// So, this filters down into variables being initialized to the "require" function.
if (declaration.init && declaration.init.type === `CallExpression` &&
declaration.init.callee.name === `require`)
{
var module_name;
// init.arguments is an array of the arguments being passed to the callee, undefinied if
// the variable isn't being initialized to a function, or at all. Unlike the declarations,
// we won't iterate over this because we only care about the first argument.
if (declaration.init.arguments[0].type === `TemplateLiteral`)
// The quasis array is a bit weird. Parsed template literals have them, and the number
// of elements is equal to the number of placeholders, plus one for the non-placeholder
// section. However, the values of the placeholder sections are always empty, so I'm
// not sure what purpose they serve.
// This takes the cooked non-placeholder portion as-is.
module_name = declaration.init.arguments[0].quasis[0].value.cooked;
else if (declaration.init.arguments[0].type === `Literal`)
// Literals are easy. The value is right there.
module_name = declaration.init.arguments[0].value;
else
// Something other than `, ', or "? ¯\_(ツ)_/¯
return;
// Detect if the module is being included via a path. This means that it is a part of the
// project, and not from an external dependency. This means that it's alright to correct
// the case in it.
if (module_name.includes(`/`))
variable_whitelist.push(variable_name);
}
});
} | javascript | function(node)
{
// declarations is an array of the comma-separated variable declarations like "var foo, zerp;"
node.declarations.forEach(declaration =>
{
// id contains info about the variable being declare.
var variable_name = declaration.id.name;
// Skip if the variable is already whitelisted.
if (variable_whitelist.indexOf(variable_name) > -1)
return;
// init contains info about the value being initialized to. It is null when the variable is
// being declared without being initialized.
// If initialization type is "CallExpression", that means that the variable is being
// initialized to a function.
// init.callee contains info about the function that the value is being initialized to,
// undefined if it's not being initialized to a function, or at all.
// So, this filters down into variables being initialized to the "require" function.
if (declaration.init && declaration.init.type === `CallExpression` &&
declaration.init.callee.name === `require`)
{
var module_name;
// init.arguments is an array of the arguments being passed to the callee, undefinied if
// the variable isn't being initialized to a function, or at all. Unlike the declarations,
// we won't iterate over this because we only care about the first argument.
if (declaration.init.arguments[0].type === `TemplateLiteral`)
// The quasis array is a bit weird. Parsed template literals have them, and the number
// of elements is equal to the number of placeholders, plus one for the non-placeholder
// section. However, the values of the placeholder sections are always empty, so I'm
// not sure what purpose they serve.
// This takes the cooked non-placeholder portion as-is.
module_name = declaration.init.arguments[0].quasis[0].value.cooked;
else if (declaration.init.arguments[0].type === `Literal`)
// Literals are easy. The value is right there.
module_name = declaration.init.arguments[0].value;
else
// Something other than `, ', or "? ¯\_(ツ)_/¯
return;
// Detect if the module is being included via a path. This means that it is a part of the
// project, and not from an external dependency. This means that it's alright to correct
// the case in it.
if (module_name.includes(`/`))
variable_whitelist.push(variable_name);
}
});
} | [
"function",
"(",
"node",
")",
"{",
"// declarations is an array of the comma-separated variable declarations like \"var foo, zerp;\"",
"node",
".",
"declarations",
".",
"forEach",
"(",
"declaration",
"=>",
"{",
"// id contains info about the variable being declare.",
"var",
"variable_name",
"=",
"declaration",
".",
"id",
".",
"name",
";",
"// Skip if the variable is already whitelisted.",
"if",
"(",
"variable_whitelist",
".",
"indexOf",
"(",
"variable_name",
")",
">",
"-",
"1",
")",
"return",
";",
"// init contains info about the value being initialized to. It is null when the variable is",
"// being declared without being initialized.",
"// If initialization type is \"CallExpression\", that means that the variable is being",
"// initialized to a function.",
"// init.callee contains info about the function that the value is being initialized to,",
"// undefined if it's not being initialized to a function, or at all.",
"// So, this filters down into variables being initialized to the \"require\" function.",
"if",
"(",
"declaration",
".",
"init",
"&&",
"declaration",
".",
"init",
".",
"type",
"===",
"`",
"`",
"&&",
"declaration",
".",
"init",
".",
"callee",
".",
"name",
"===",
"`",
"`",
")",
"{",
"var",
"module_name",
";",
"// init.arguments is an array of the arguments being passed to the callee, undefinied if",
"// the variable isn't being initialized to a function, or at all. Unlike the declarations,",
"// we won't iterate over this because we only care about the first argument.",
"if",
"(",
"declaration",
".",
"init",
".",
"arguments",
"[",
"0",
"]",
".",
"type",
"===",
"`",
"`",
")",
"// The quasis array is a bit weird. Parsed template literals have them, and the number",
"// of elements is equal to the number of placeholders, plus one for the non-placeholder",
"// section. However, the values of the placeholder sections are always empty, so I'm",
"// not sure what purpose they serve.",
"// This takes the cooked non-placeholder portion as-is.",
"module_name",
"=",
"declaration",
".",
"init",
".",
"arguments",
"[",
"0",
"]",
".",
"quasis",
"[",
"0",
"]",
".",
"value",
".",
"cooked",
";",
"else",
"if",
"(",
"declaration",
".",
"init",
".",
"arguments",
"[",
"0",
"]",
".",
"type",
"===",
"`",
"`",
")",
"// Literals are easy. The value is right there.",
"module_name",
"=",
"declaration",
".",
"init",
".",
"arguments",
"[",
"0",
"]",
".",
"value",
";",
"else",
"// Something other than `, ', or \"? ¯\\_(ツ)_/¯",
"return",
";",
"// Detect if the module is being included via a path. This means that it is a part of the",
"// project, and not from an external dependency. This means that it's alright to correct",
"// the case in it.",
"if",
"(",
"module_name",
".",
"includes",
"(",
"`",
"`",
")",
")",
"variable_whitelist",
".",
"push",
"(",
"variable_name",
")",
";",
"}",
"}",
")",
";",
"}"
]
| When a new variable is declared. This is where we whitelist nodes to check function calls of. | [
"When",
"a",
"new",
"variable",
"is",
"declared",
".",
"This",
"is",
"where",
"we",
"whitelist",
"nodes",
"to",
"check",
"function",
"calls",
"of",
"."
]
| 98ad46204e7d50b0886fd11d90b1571eb6991de7 | https://github.com/CodingKoopa/eslint-plugin-more-naming-conventions/blob/98ad46204e7d50b0886fd11d90b1571eb6991de7/Source/Rules/UpperCamelCase.js#L38-L83 |
|
39,423 | XadillaX/illyria2 | lib/server_zookeeper.js | function(connectString, options, root, prefix) {
EventEmitter.call(this);
if(util.isArray(connectString)) {
connectString = connectString.join(",");
}
this.connectString = connectString;
this.options = options;
this.root = root || "/illyria";
this.prefix = prefix || "/HB_";
this.path = null;
this.root = this.root.trim();
this.prefix = this.prefix.trim();
if(!this.root.length) this.root = "/illyria";
if(!this.prefix.length) this.prefix = "/HB_";
if(this.root[0] !== "/") this.root = "/" + this.root;
if(this.prefix[0] !== "/") this.prefix = "/" + this.prefix;
this.client = zookeeper.createClient(this.connectString, options);
this.server = {
host: "127.0.0.1",
port: 3721,
clients: 0
};
this.clientStatus = ZK_STATUS.NOT_CONNECTED;
this._setup();
} | javascript | function(connectString, options, root, prefix) {
EventEmitter.call(this);
if(util.isArray(connectString)) {
connectString = connectString.join(",");
}
this.connectString = connectString;
this.options = options;
this.root = root || "/illyria";
this.prefix = prefix || "/HB_";
this.path = null;
this.root = this.root.trim();
this.prefix = this.prefix.trim();
if(!this.root.length) this.root = "/illyria";
if(!this.prefix.length) this.prefix = "/HB_";
if(this.root[0] !== "/") this.root = "/" + this.root;
if(this.prefix[0] !== "/") this.prefix = "/" + this.prefix;
this.client = zookeeper.createClient(this.connectString, options);
this.server = {
host: "127.0.0.1",
port: 3721,
clients: 0
};
this.clientStatus = ZK_STATUS.NOT_CONNECTED;
this._setup();
} | [
"function",
"(",
"connectString",
",",
"options",
",",
"root",
",",
"prefix",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"if",
"(",
"util",
".",
"isArray",
"(",
"connectString",
")",
")",
"{",
"connectString",
"=",
"connectString",
".",
"join",
"(",
"\",\"",
")",
";",
"}",
"this",
".",
"connectString",
"=",
"connectString",
";",
"this",
".",
"options",
"=",
"options",
";",
"this",
".",
"root",
"=",
"root",
"||",
"\"/illyria\"",
";",
"this",
".",
"prefix",
"=",
"prefix",
"||",
"\"/HB_\"",
";",
"this",
".",
"path",
"=",
"null",
";",
"this",
".",
"root",
"=",
"this",
".",
"root",
".",
"trim",
"(",
")",
";",
"this",
".",
"prefix",
"=",
"this",
".",
"prefix",
".",
"trim",
"(",
")",
";",
"if",
"(",
"!",
"this",
".",
"root",
".",
"length",
")",
"this",
".",
"root",
"=",
"\"/illyria\"",
";",
"if",
"(",
"!",
"this",
".",
"prefix",
".",
"length",
")",
"this",
".",
"prefix",
"=",
"\"/HB_\"",
";",
"if",
"(",
"this",
".",
"root",
"[",
"0",
"]",
"!==",
"\"/\"",
")",
"this",
".",
"root",
"=",
"\"/\"",
"+",
"this",
".",
"root",
";",
"if",
"(",
"this",
".",
"prefix",
"[",
"0",
"]",
"!==",
"\"/\"",
")",
"this",
".",
"prefix",
"=",
"\"/\"",
"+",
"this",
".",
"prefix",
";",
"this",
".",
"client",
"=",
"zookeeper",
".",
"createClient",
"(",
"this",
".",
"connectString",
",",
"options",
")",
";",
"this",
".",
"server",
"=",
"{",
"host",
":",
"\"127.0.0.1\"",
",",
"port",
":",
"3721",
",",
"clients",
":",
"0",
"}",
";",
"this",
".",
"clientStatus",
"=",
"ZK_STATUS",
".",
"NOT_CONNECTED",
";",
"this",
".",
"_setup",
"(",
")",
";",
"}"
]
| illyria zookeeper wrapper
@param {String|Array} connectString the connect string(s)
@param {Object} options the connect options, refer to
https://github.com/alexguan/node-zookeeper-client
#client-createclientconnectionstring-options
@param {String} [root] the root path
@param {String} [prefix] the path's prefix
@constructor | [
"illyria",
"zookeeper",
"wrapper"
]
| ced0cc71cdcda11afcbab33f13739cbe547a2a17 | https://github.com/XadillaX/illyria2/blob/ced0cc71cdcda11afcbab33f13739cbe547a2a17/lib/server_zookeeper.js#L32-L64 |
|
39,424 | patsissons/hubot-giphy | src/giphy.js | extend | function extend(object, properties) {
object = object || { };
const anotherObject = properties || { };
for (const key in anotherObject) {
const val = anotherObject[key];
if (val || (val === '')) {
object[key] = val;
}
}
return object;
} | javascript | function extend(object, properties) {
object = object || { };
const anotherObject = properties || { };
for (const key in anotherObject) {
const val = anotherObject[key];
if (val || (val === '')) {
object[key] = val;
}
}
return object;
} | [
"function",
"extend",
"(",
"object",
",",
"properties",
")",
"{",
"object",
"=",
"object",
"||",
"{",
"}",
";",
"const",
"anotherObject",
"=",
"properties",
"||",
"{",
"}",
";",
"for",
"(",
"const",
"key",
"in",
"anotherObject",
")",
"{",
"const",
"val",
"=",
"anotherObject",
"[",
"key",
"]",
";",
"if",
"(",
"val",
"||",
"(",
"val",
"===",
"''",
")",
")",
"{",
"object",
"[",
"key",
"]",
"=",
"val",
";",
"}",
"}",
"return",
"object",
";",
"}"
]
| utility method for extending an object definition | [
"utility",
"method",
"for",
"extending",
"an",
"object",
"definition"
]
| 59d8904a66206ba2147b5016a4a20bb1bea6f34b | https://github.com/patsissons/hubot-giphy/blob/59d8904a66206ba2147b5016a4a20bb1bea6f34b/src/giphy.js#L35-L47 |
39,425 | divio/browserslist-saucelabs | getdata.js | eliminateDuplicates | function eliminateDuplicates(browsers) {
var set = {};
browsers.forEach(function (browser) {
var osgroup = browser.os;
var subgroup = browser.long_name;
var version = browser.short_version;
var device;
var browserName;
if (browser.api_name === "iphone") {
osgroup = device = "iPhone Simulator";
} else if (browser.api_name === "ipad") {
osgroup = device = "iPad Simulator";
} else if (browser.long_name === "Google Chrome") {
browserName = 'Chrome';
} else if (browser.long_name === "Microsoft Edge") {
browserName = 'MicrosoftEdge';
version = browser.long_version.substr(0, 8);
} else if (browser.api_name === "android") {
browserName = 'Android';
osgroup = "Android " + browser.short_version;
device = browser.long_name;
if (subgroup === "Android") {
subgroup += " " + version + " Emulator";
device = "Android Emulator";
}
} else if (osgroup in OS_ID_TO_GROUPNAME) {
osgroup = OS_ID_TO_GROUPNAME[osgroup];
}
set[JSON.stringify([osgroup, subgroup, version])] = {
browserName: browserName || browser.long_name,
platform: OS_ID_TO_GROUPNAME[browser.os] || browser.os,
version: version,
deviceName: device || browser.device
};
});
var uniques = Object.keys(set).sort().map(function (id) {
return set[id];
});
return uniques;
} | javascript | function eliminateDuplicates(browsers) {
var set = {};
browsers.forEach(function (browser) {
var osgroup = browser.os;
var subgroup = browser.long_name;
var version = browser.short_version;
var device;
var browserName;
if (browser.api_name === "iphone") {
osgroup = device = "iPhone Simulator";
} else if (browser.api_name === "ipad") {
osgroup = device = "iPad Simulator";
} else if (browser.long_name === "Google Chrome") {
browserName = 'Chrome';
} else if (browser.long_name === "Microsoft Edge") {
browserName = 'MicrosoftEdge';
version = browser.long_version.substr(0, 8);
} else if (browser.api_name === "android") {
browserName = 'Android';
osgroup = "Android " + browser.short_version;
device = browser.long_name;
if (subgroup === "Android") {
subgroup += " " + version + " Emulator";
device = "Android Emulator";
}
} else if (osgroup in OS_ID_TO_GROUPNAME) {
osgroup = OS_ID_TO_GROUPNAME[osgroup];
}
set[JSON.stringify([osgroup, subgroup, version])] = {
browserName: browserName || browser.long_name,
platform: OS_ID_TO_GROUPNAME[browser.os] || browser.os,
version: version,
deviceName: device || browser.device
};
});
var uniques = Object.keys(set).sort().map(function (id) {
return set[id];
});
return uniques;
} | [
"function",
"eliminateDuplicates",
"(",
"browsers",
")",
"{",
"var",
"set",
"=",
"{",
"}",
";",
"browsers",
".",
"forEach",
"(",
"function",
"(",
"browser",
")",
"{",
"var",
"osgroup",
"=",
"browser",
".",
"os",
";",
"var",
"subgroup",
"=",
"browser",
".",
"long_name",
";",
"var",
"version",
"=",
"browser",
".",
"short_version",
";",
"var",
"device",
";",
"var",
"browserName",
";",
"if",
"(",
"browser",
".",
"api_name",
"===",
"\"iphone\"",
")",
"{",
"osgroup",
"=",
"device",
"=",
"\"iPhone Simulator\"",
";",
"}",
"else",
"if",
"(",
"browser",
".",
"api_name",
"===",
"\"ipad\"",
")",
"{",
"osgroup",
"=",
"device",
"=",
"\"iPad Simulator\"",
";",
"}",
"else",
"if",
"(",
"browser",
".",
"long_name",
"===",
"\"Google Chrome\"",
")",
"{",
"browserName",
"=",
"'Chrome'",
";",
"}",
"else",
"if",
"(",
"browser",
".",
"long_name",
"===",
"\"Microsoft Edge\"",
")",
"{",
"browserName",
"=",
"'MicrosoftEdge'",
";",
"version",
"=",
"browser",
".",
"long_version",
".",
"substr",
"(",
"0",
",",
"8",
")",
";",
"}",
"else",
"if",
"(",
"browser",
".",
"api_name",
"===",
"\"android\"",
")",
"{",
"browserName",
"=",
"'Android'",
";",
"osgroup",
"=",
"\"Android \"",
"+",
"browser",
".",
"short_version",
";",
"device",
"=",
"browser",
".",
"long_name",
";",
"if",
"(",
"subgroup",
"===",
"\"Android\"",
")",
"{",
"subgroup",
"+=",
"\" \"",
"+",
"version",
"+",
"\" Emulator\"",
";",
"device",
"=",
"\"Android Emulator\"",
";",
"}",
"}",
"else",
"if",
"(",
"osgroup",
"in",
"OS_ID_TO_GROUPNAME",
")",
"{",
"osgroup",
"=",
"OS_ID_TO_GROUPNAME",
"[",
"osgroup",
"]",
";",
"}",
"set",
"[",
"JSON",
".",
"stringify",
"(",
"[",
"osgroup",
",",
"subgroup",
",",
"version",
"]",
")",
"]",
"=",
"{",
"browserName",
":",
"browserName",
"||",
"browser",
".",
"long_name",
",",
"platform",
":",
"OS_ID_TO_GROUPNAME",
"[",
"browser",
".",
"os",
"]",
"||",
"browser",
".",
"os",
",",
"version",
":",
"version",
",",
"deviceName",
":",
"device",
"||",
"browser",
".",
"device",
"}",
";",
"}",
")",
";",
"var",
"uniques",
"=",
"Object",
".",
"keys",
"(",
"set",
")",
".",
"sort",
"(",
")",
".",
"map",
"(",
"function",
"(",
"id",
")",
"{",
"return",
"set",
"[",
"id",
"]",
";",
"}",
")",
";",
"return",
"uniques",
";",
"}"
]
| The platforms API lists multiple versions of platforms with different properties. Pull out just the essentials, and eliminate duplicates. | [
"The",
"platforms",
"API",
"lists",
"multiple",
"versions",
"of",
"platforms",
"with",
"different",
"properties",
".",
"Pull",
"out",
"just",
"the",
"essentials",
"and",
"eliminate",
"duplicates",
"."
]
| e28f1a163cde9c48b0d6e0f9861ffd5dea523106 | https://github.com/divio/browserslist-saucelabs/blob/e28f1a163cde9c48b0d6e0f9861ffd5dea523106/getdata.js#L21-L62 |
39,426 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.validation.js | function(elem, target) {
this.selectDateOrig(elem, target);
var inst = $.calendarsPicker._getInst(elem);
if (!inst.inline && $.fn.validate) {
var validation = $(elem).parents('form').validate();
if (validation) {
validation.element('#' + elem.id);
}
}
} | javascript | function(elem, target) {
this.selectDateOrig(elem, target);
var inst = $.calendarsPicker._getInst(elem);
if (!inst.inline && $.fn.validate) {
var validation = $(elem).parents('form').validate();
if (validation) {
validation.element('#' + elem.id);
}
}
} | [
"function",
"(",
"elem",
",",
"target",
")",
"{",
"this",
".",
"selectDateOrig",
"(",
"elem",
",",
"target",
")",
";",
"var",
"inst",
"=",
"$",
".",
"calendarsPicker",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"!",
"inst",
".",
"inline",
"&&",
"$",
".",
"fn",
".",
"validate",
")",
"{",
"var",
"validation",
"=",
"$",
"(",
"elem",
")",
".",
"parents",
"(",
"'form'",
")",
".",
"validate",
"(",
")",
";",
"if",
"(",
"validation",
")",
"{",
"validation",
".",
"element",
"(",
"'#'",
"+",
"elem",
".",
"id",
")",
";",
"}",
"}",
"}"
]
| Trigger a validation after updating the input field with the selected date.
@param elem {Element} The control to examine.
@param target {Element} The selected datepicker element. | [
"Trigger",
"a",
"validation",
"after",
"updating",
"the",
"input",
"field",
"with",
"the",
"selected",
"date",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.validation.js#L38-L47 |
|
39,427 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.validation.js | function(error, elem) {
var inst = $.calendarsPicker._getInst(elem);
if (inst) {
error[inst.options.isRTL ? 'insertBefore' : 'insertAfter'](
inst.trigger.length > 0 ? inst.trigger : elem);
}
else {
error.insertAfter(elem);
}
} | javascript | function(error, elem) {
var inst = $.calendarsPicker._getInst(elem);
if (inst) {
error[inst.options.isRTL ? 'insertBefore' : 'insertAfter'](
inst.trigger.length > 0 ? inst.trigger : elem);
}
else {
error.insertAfter(elem);
}
} | [
"function",
"(",
"error",
",",
"elem",
")",
"{",
"var",
"inst",
"=",
"$",
".",
"calendarsPicker",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"inst",
")",
"{",
"error",
"[",
"inst",
".",
"options",
".",
"isRTL",
"?",
"'insertBefore'",
":",
"'insertAfter'",
"]",
"(",
"inst",
".",
"trigger",
".",
"length",
">",
"0",
"?",
"inst",
".",
"trigger",
":",
"elem",
")",
";",
"}",
"else",
"{",
"error",
".",
"insertAfter",
"(",
"elem",
")",
";",
"}",
"}"
]
| Correct error placement for validation errors - after any trigger.
@param error {jQuery} The error message.
@param elem {jQuery} The field in error. | [
"Correct",
"error",
"placement",
"for",
"validation",
"errors",
"-",
"after",
"any",
"trigger",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.validation.js#L52-L61 |
|
39,428 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.validation.js | function(source, params) {
var format = ($.calendarsPicker.curInst ?
$.calendarsPicker.curInst.get('dateFormat') :
$.calendarsPicker.defaultOptions.dateFormat);
$.each(params, function(index, value) {
source = source.replace(new RegExp('\\{' + index + '\\}', 'g'),
value.formatDate(format) || 'nothing');
});
return source;
} | javascript | function(source, params) {
var format = ($.calendarsPicker.curInst ?
$.calendarsPicker.curInst.get('dateFormat') :
$.calendarsPicker.defaultOptions.dateFormat);
$.each(params, function(index, value) {
source = source.replace(new RegExp('\\{' + index + '\\}', 'g'),
value.formatDate(format) || 'nothing');
});
return source;
} | [
"function",
"(",
"source",
",",
"params",
")",
"{",
"var",
"format",
"=",
"(",
"$",
".",
"calendarsPicker",
".",
"curInst",
"?",
"$",
".",
"calendarsPicker",
".",
"curInst",
".",
"get",
"(",
"'dateFormat'",
")",
":",
"$",
".",
"calendarsPicker",
".",
"defaultOptions",
".",
"dateFormat",
")",
";",
"$",
".",
"each",
"(",
"params",
",",
"function",
"(",
"index",
",",
"value",
")",
"{",
"source",
"=",
"source",
".",
"replace",
"(",
"new",
"RegExp",
"(",
"'\\\\{'",
"+",
"index",
"+",
"'\\\\}'",
",",
"'g'",
")",
",",
"value",
".",
"formatDate",
"(",
"format",
")",
"||",
"'nothing'",
")",
";",
"}",
")",
";",
"return",
"source",
";",
"}"
]
| Format a validation error message involving dates.
@param source {string} The error message.
@param params {Date[]} The dates.
@return {string} The formatted message. | [
"Format",
"a",
"validation",
"error",
"message",
"involving",
"dates",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.validation.js#L67-L76 |
|
39,429 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.validation.js | validateEach | function validateEach(value, elem) {
var inst = $.calendarsPicker._getInst(elem);
var dates = (inst.options.multiSelect ? value.split(inst.options.multiSeparator) :
(inst.options.rangeSelect ? value.split(inst.options.rangeSeparator) : [value]));
var ok = (inst.options.multiSelect && dates.length <= inst.options.multiSelect) ||
(!inst.options.multiSelect && inst.options.rangeSelect && dates.length === 2) ||
(!inst.options.multiSelect && !inst.options.rangeSelect && dates.length === 1);
if (ok) {
try {
var dateFormat = inst.get('dateFormat');
var minDate = inst.get('minDate');
var maxDate = inst.get('maxDate');
var cp = $(elem);
$.each(dates, function(i, v) {
dates[i] = inst.options.calendar.parseDate(dateFormat, v);
ok = ok && (!dates[i] || (cp.calendarsPicker('isSelectable', dates[i]) &&
(!minDate || dates[i].compareTo(minDate) !== -1) &&
(!maxDate || dates[i].compareTo(maxDate) !== +1)));
});
}
catch (e) {
ok = false;
}
}
if (ok && inst.options.rangeSelect) {
ok = (dates[0].compareTo(dates[1]) !== +1);
}
return ok;
} | javascript | function validateEach(value, elem) {
var inst = $.calendarsPicker._getInst(elem);
var dates = (inst.options.multiSelect ? value.split(inst.options.multiSeparator) :
(inst.options.rangeSelect ? value.split(inst.options.rangeSeparator) : [value]));
var ok = (inst.options.multiSelect && dates.length <= inst.options.multiSelect) ||
(!inst.options.multiSelect && inst.options.rangeSelect && dates.length === 2) ||
(!inst.options.multiSelect && !inst.options.rangeSelect && dates.length === 1);
if (ok) {
try {
var dateFormat = inst.get('dateFormat');
var minDate = inst.get('minDate');
var maxDate = inst.get('maxDate');
var cp = $(elem);
$.each(dates, function(i, v) {
dates[i] = inst.options.calendar.parseDate(dateFormat, v);
ok = ok && (!dates[i] || (cp.calendarsPicker('isSelectable', dates[i]) &&
(!minDate || dates[i].compareTo(minDate) !== -1) &&
(!maxDate || dates[i].compareTo(maxDate) !== +1)));
});
}
catch (e) {
ok = false;
}
}
if (ok && inst.options.rangeSelect) {
ok = (dates[0].compareTo(dates[1]) !== +1);
}
return ok;
} | [
"function",
"validateEach",
"(",
"value",
",",
"elem",
")",
"{",
"var",
"inst",
"=",
"$",
".",
"calendarsPicker",
".",
"_getInst",
"(",
"elem",
")",
";",
"var",
"dates",
"=",
"(",
"inst",
".",
"options",
".",
"multiSelect",
"?",
"value",
".",
"split",
"(",
"inst",
".",
"options",
".",
"multiSeparator",
")",
":",
"(",
"inst",
".",
"options",
".",
"rangeSelect",
"?",
"value",
".",
"split",
"(",
"inst",
".",
"options",
".",
"rangeSeparator",
")",
":",
"[",
"value",
"]",
")",
")",
";",
"var",
"ok",
"=",
"(",
"inst",
".",
"options",
".",
"multiSelect",
"&&",
"dates",
".",
"length",
"<=",
"inst",
".",
"options",
".",
"multiSelect",
")",
"||",
"(",
"!",
"inst",
".",
"options",
".",
"multiSelect",
"&&",
"inst",
".",
"options",
".",
"rangeSelect",
"&&",
"dates",
".",
"length",
"===",
"2",
")",
"||",
"(",
"!",
"inst",
".",
"options",
".",
"multiSelect",
"&&",
"!",
"inst",
".",
"options",
".",
"rangeSelect",
"&&",
"dates",
".",
"length",
"===",
"1",
")",
";",
"if",
"(",
"ok",
")",
"{",
"try",
"{",
"var",
"dateFormat",
"=",
"inst",
".",
"get",
"(",
"'dateFormat'",
")",
";",
"var",
"minDate",
"=",
"inst",
".",
"get",
"(",
"'minDate'",
")",
";",
"var",
"maxDate",
"=",
"inst",
".",
"get",
"(",
"'maxDate'",
")",
";",
"var",
"cp",
"=",
"$",
"(",
"elem",
")",
";",
"$",
".",
"each",
"(",
"dates",
",",
"function",
"(",
"i",
",",
"v",
")",
"{",
"dates",
"[",
"i",
"]",
"=",
"inst",
".",
"options",
".",
"calendar",
".",
"parseDate",
"(",
"dateFormat",
",",
"v",
")",
";",
"ok",
"=",
"ok",
"&&",
"(",
"!",
"dates",
"[",
"i",
"]",
"||",
"(",
"cp",
".",
"calendarsPicker",
"(",
"'isSelectable'",
",",
"dates",
"[",
"i",
"]",
")",
"&&",
"(",
"!",
"minDate",
"||",
"dates",
"[",
"i",
"]",
".",
"compareTo",
"(",
"minDate",
")",
"!==",
"-",
"1",
")",
"&&",
"(",
"!",
"maxDate",
"||",
"dates",
"[",
"i",
"]",
".",
"compareTo",
"(",
"maxDate",
")",
"!==",
"+",
"1",
")",
")",
")",
";",
"}",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"ok",
"=",
"false",
";",
"}",
"}",
"if",
"(",
"ok",
"&&",
"inst",
".",
"options",
".",
"rangeSelect",
")",
"{",
"ok",
"=",
"(",
"dates",
"[",
"0",
"]",
".",
"compareTo",
"(",
"dates",
"[",
"1",
"]",
")",
"!==",
"+",
"1",
")",
";",
"}",
"return",
"ok",
";",
"}"
]
| Apply a validation test to each date provided.
@private
@param value {string} The current field value.
@param elem {Element} The field control.
@return {boolean} <code>true</code> if OK, <code>false</code> if failed validation. | [
"Apply",
"a",
"validation",
"test",
"to",
"each",
"date",
"provided",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.validation.js#L103-L131 |
39,430 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.validation.js | normaliseParams | function normaliseParams(params) {
if (typeof params === 'string') {
params = params.split(' ');
}
else if (!$.isArray(params)) {
var opts = [];
for (var name in params) {
opts[0] = name;
opts[1] = params[name];
}
params = opts;
}
return params;
} | javascript | function normaliseParams(params) {
if (typeof params === 'string') {
params = params.split(' ');
}
else if (!$.isArray(params)) {
var opts = [];
for (var name in params) {
opts[0] = name;
opts[1] = params[name];
}
params = opts;
}
return params;
} | [
"function",
"normaliseParams",
"(",
"params",
")",
"{",
"if",
"(",
"typeof",
"params",
"===",
"'string'",
")",
"{",
"params",
"=",
"params",
".",
"split",
"(",
"' '",
")",
";",
"}",
"else",
"if",
"(",
"!",
"$",
".",
"isArray",
"(",
"params",
")",
")",
"{",
"var",
"opts",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"name",
"in",
"params",
")",
"{",
"opts",
"[",
"0",
"]",
"=",
"name",
";",
"opts",
"[",
"1",
"]",
"=",
"params",
"[",
"name",
"]",
";",
"}",
"params",
"=",
"opts",
";",
"}",
"return",
"params",
";",
"}"
]
| Normalise the comparison parameters to an array.
@param params {Array|object|string} The original parameters.
@return {Array} The normalised parameters. | [
"Normalise",
"the",
"comparison",
"parameters",
"to",
"an",
"array",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.validation.js#L189-L202 |
39,431 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.validation.js | extractOtherDate | function extractOtherDate(elem, source, noOther) {
if (source.newDate && source.extraInfo) { // Already a CDate
return [source];
}
var inst = $.calendarsPicker._getInst(elem);
var thatDate = null;
try {
if (typeof source === 'string' && source !== 'today') {
thatDate = inst.options.calendar.parseDate(inst.get('dateFormat'), source);
}
}
catch (e) {
// Ignore
}
thatDate = (thatDate ? [thatDate] : (source === 'today' ?
[inst.options.calendar.today()] : (noOther ? [] : $(source).calendarsPicker('getDate'))));
return thatDate;
} | javascript | function extractOtherDate(elem, source, noOther) {
if (source.newDate && source.extraInfo) { // Already a CDate
return [source];
}
var inst = $.calendarsPicker._getInst(elem);
var thatDate = null;
try {
if (typeof source === 'string' && source !== 'today') {
thatDate = inst.options.calendar.parseDate(inst.get('dateFormat'), source);
}
}
catch (e) {
// Ignore
}
thatDate = (thatDate ? [thatDate] : (source === 'today' ?
[inst.options.calendar.today()] : (noOther ? [] : $(source).calendarsPicker('getDate'))));
return thatDate;
} | [
"function",
"extractOtherDate",
"(",
"elem",
",",
"source",
",",
"noOther",
")",
"{",
"if",
"(",
"source",
".",
"newDate",
"&&",
"source",
".",
"extraInfo",
")",
"{",
"// Already a CDate",
"return",
"[",
"source",
"]",
";",
"}",
"var",
"inst",
"=",
"$",
".",
"calendarsPicker",
".",
"_getInst",
"(",
"elem",
")",
";",
"var",
"thatDate",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"typeof",
"source",
"===",
"'string'",
"&&",
"source",
"!==",
"'today'",
")",
"{",
"thatDate",
"=",
"inst",
".",
"options",
".",
"calendar",
".",
"parseDate",
"(",
"inst",
".",
"get",
"(",
"'dateFormat'",
")",
",",
"source",
")",
";",
"}",
"}",
"catch",
"(",
"e",
")",
"{",
"// Ignore",
"}",
"thatDate",
"=",
"(",
"thatDate",
"?",
"[",
"thatDate",
"]",
":",
"(",
"source",
"===",
"'today'",
"?",
"[",
"inst",
".",
"options",
".",
"calendar",
".",
"today",
"(",
")",
"]",
":",
"(",
"noOther",
"?",
"[",
"]",
":",
"$",
"(",
"source",
")",
".",
"calendarsPicker",
"(",
"'getDate'",
")",
")",
")",
")",
";",
"return",
"thatDate",
";",
"}"
]
| Determine the comparison date.
@param elem {Element} The current datepicker element.
@param source {string|CDate|jQueryElement} The source of the other date.
@param noOther {boolean} <code>true</code> to not get the date from another field.
@return {CDate[]} The date for comparison. | [
"Determine",
"the",
"comparison",
"date",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.validation.js#L209-L226 |
39,432 | Neil-G/redux-mastermind | lib/helpers.js | objectToArray | function objectToArray(object) {
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'id';
var convertedArray = [];
Object.keys(object).forEach(function (_key) {
var item = object[_key];
item[key] = _key;
convertedArray.push(item);
});
return convertedArray;
} | javascript | function objectToArray(object) {
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'id';
var convertedArray = [];
Object.keys(object).forEach(function (_key) {
var item = object[_key];
item[key] = _key;
convertedArray.push(item);
});
return convertedArray;
} | [
"function",
"objectToArray",
"(",
"object",
")",
"{",
"var",
"key",
"=",
"arguments",
".",
"length",
">",
"1",
"&&",
"arguments",
"[",
"1",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"1",
"]",
":",
"'id'",
";",
"var",
"convertedArray",
"=",
"[",
"]",
";",
"Object",
".",
"keys",
"(",
"object",
")",
".",
"forEach",
"(",
"function",
"(",
"_key",
")",
"{",
"var",
"item",
"=",
"object",
"[",
"_key",
"]",
";",
"item",
"[",
"key",
"]",
"=",
"_key",
";",
"convertedArray",
".",
"push",
"(",
"item",
")",
";",
"}",
")",
";",
"return",
"convertedArray",
";",
"}"
]
| converts an object to an array | [
"converts",
"an",
"object",
"to",
"an",
"array"
]
| 669e2978b4a7cdd48fbd33d4fd6dbe47e92d3cef | https://github.com/Neil-G/redux-mastermind/blob/669e2978b4a7cdd48fbd33d4fd6dbe47e92d3cef/lib/helpers.js#L22-L34 |
39,433 | HasakiUI/hsk-jinx | src/component/intro/intro.js | _nextStep | function _nextStep() {
this._direction = 'forward';
if (typeof this._currentStepNumber !== 'undefined') {
for (var i = 0, len = this._introItems.length; i < len; i++) {
var item = this._introItems[i];
if (item.step === this._currentStepNumber) {
this._currentStep = i - 1;
this._currentStepNumber = undefined;
}
}
}
if (typeof this._currentStep === 'undefined') {
this._currentStep = 0;
} else {
++this._currentStep;
}
if (typeof this._introBeforeChangeCallback !== 'undefined') {
var continueStep = this._introBeforeChangeCallback.call(this);
}
// if `onbeforechange` returned `false`, stop displaying the element
if (continueStep === false) {
--this._currentStep;
return false;
}
if (this._introItems.length <= this._currentStep) {
//end of the intro
//check if any callback is defined
if (typeof this._introCompleteCallback === 'function') {
this._introCompleteCallback.call(this);
}
_exitIntro.call(this, this._targetElement);
return;
}
var nextStep = this._introItems[this._currentStep];
_showElement.call(this, nextStep);
} | javascript | function _nextStep() {
this._direction = 'forward';
if (typeof this._currentStepNumber !== 'undefined') {
for (var i = 0, len = this._introItems.length; i < len; i++) {
var item = this._introItems[i];
if (item.step === this._currentStepNumber) {
this._currentStep = i - 1;
this._currentStepNumber = undefined;
}
}
}
if (typeof this._currentStep === 'undefined') {
this._currentStep = 0;
} else {
++this._currentStep;
}
if (typeof this._introBeforeChangeCallback !== 'undefined') {
var continueStep = this._introBeforeChangeCallback.call(this);
}
// if `onbeforechange` returned `false`, stop displaying the element
if (continueStep === false) {
--this._currentStep;
return false;
}
if (this._introItems.length <= this._currentStep) {
//end of the intro
//check if any callback is defined
if (typeof this._introCompleteCallback === 'function') {
this._introCompleteCallback.call(this);
}
_exitIntro.call(this, this._targetElement);
return;
}
var nextStep = this._introItems[this._currentStep];
_showElement.call(this, nextStep);
} | [
"function",
"_nextStep",
"(",
")",
"{",
"this",
".",
"_direction",
"=",
"'forward'",
";",
"if",
"(",
"typeof",
"this",
".",
"_currentStepNumber",
"!==",
"'undefined'",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"this",
".",
"_introItems",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"item",
"=",
"this",
".",
"_introItems",
"[",
"i",
"]",
";",
"if",
"(",
"item",
".",
"step",
"===",
"this",
".",
"_currentStepNumber",
")",
"{",
"this",
".",
"_currentStep",
"=",
"i",
"-",
"1",
";",
"this",
".",
"_currentStepNumber",
"=",
"undefined",
";",
"}",
"}",
"}",
"if",
"(",
"typeof",
"this",
".",
"_currentStep",
"===",
"'undefined'",
")",
"{",
"this",
".",
"_currentStep",
"=",
"0",
";",
"}",
"else",
"{",
"++",
"this",
".",
"_currentStep",
";",
"}",
"if",
"(",
"typeof",
"this",
".",
"_introBeforeChangeCallback",
"!==",
"'undefined'",
")",
"{",
"var",
"continueStep",
"=",
"this",
".",
"_introBeforeChangeCallback",
".",
"call",
"(",
"this",
")",
";",
"}",
"// if `onbeforechange` returned `false`, stop displaying the element",
"if",
"(",
"continueStep",
"===",
"false",
")",
"{",
"--",
"this",
".",
"_currentStep",
";",
"return",
"false",
";",
"}",
"if",
"(",
"this",
".",
"_introItems",
".",
"length",
"<=",
"this",
".",
"_currentStep",
")",
"{",
"//end of the intro",
"//check if any callback is defined",
"if",
"(",
"typeof",
"this",
".",
"_introCompleteCallback",
"===",
"'function'",
")",
"{",
"this",
".",
"_introCompleteCallback",
".",
"call",
"(",
"this",
")",
";",
"}",
"_exitIntro",
".",
"call",
"(",
"this",
",",
"this",
".",
"_targetElement",
")",
";",
"return",
";",
"}",
"var",
"nextStep",
"=",
"this",
".",
"_introItems",
"[",
"this",
".",
"_currentStep",
"]",
";",
"_showElement",
".",
"call",
"(",
"this",
",",
"nextStep",
")",
";",
"}"
]
| Go to next step on intro
@api private
@method _nextStep | [
"Go",
"to",
"next",
"step",
"on",
"intro"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L357-L398 |
39,434 | HasakiUI/hsk-jinx | src/component/intro/intro.js | _exitIntro | function _exitIntro(targetElement, force) {
var continueExit = true;
// calling onbeforeexit callback
//
// If this callback return `false`, it would halt the process
if (this._introBeforeExitCallback != undefined) {
continueExit = this._introBeforeExitCallback.call(self);
}
// skip this check if `force` parameter is `true`
// otherwise, if `onbeforeexit` returned `false`, don't exit the intro
if (!force && continueExit === false) return;
//remove overlay layers from the page
var overlayLayers = targetElement.querySelectorAll('.introjs-overlay');
if (overlayLayers && overlayLayers.length > 0) {
for (var i = overlayLayers.length - 1; i >= 0; i--) {
//for fade-out animation
var overlayLayer = overlayLayers[i];
overlayLayer.style.opacity = 0;
setTimeout(
function() {
if (this.parentNode) {
this.parentNode.removeChild(this);
}
}.bind(overlayLayer),
500
);
}
}
//remove all helper layers
var helperLayer = targetElement.querySelector('.introjs-helperLayer');
if (helperLayer) {
helperLayer.parentNode.removeChild(helperLayer);
}
var referenceLayer = targetElement.querySelector('.introjs-tooltipReferenceLayer');
if (referenceLayer) {
referenceLayer.parentNode.removeChild(referenceLayer);
}
//remove disableInteractionLayer
var disableInteractionLayer = targetElement.querySelector('.introjs-disableInteraction');
if (disableInteractionLayer) {
disableInteractionLayer.parentNode.removeChild(disableInteractionLayer);
}
//remove intro floating element
var floatingElement = document.querySelector('.introjsFloatingElement');
if (floatingElement) {
floatingElement.parentNode.removeChild(floatingElement);
}
_removeShowElement();
//remove `introjs-fixParent` class from the elements
var fixParents = document.querySelectorAll('.introjs-fixParent');
if (fixParents && fixParents.length > 0) {
for (var i = fixParents.length - 1; i >= 0; i--) {
fixParents[i].className = fixParents[i].className
.replace(/introjs-fixParent/g, '')
.replace(/^\s+|\s+$/g, '');
}
}
//clean listeners
if (window.removeEventListener) {
window.removeEventListener('keydown', this._onKeyDown, true);
} else if (document.detachEvent) {
//IE
document.detachEvent('onkeydown', this._onKeyDown);
}
//check if any callback is defined
if (this._introExitCallback != undefined) {
this._introExitCallback.call(self);
}
//set the step to zero
this._currentStep = undefined;
} | javascript | function _exitIntro(targetElement, force) {
var continueExit = true;
// calling onbeforeexit callback
//
// If this callback return `false`, it would halt the process
if (this._introBeforeExitCallback != undefined) {
continueExit = this._introBeforeExitCallback.call(self);
}
// skip this check if `force` parameter is `true`
// otherwise, if `onbeforeexit` returned `false`, don't exit the intro
if (!force && continueExit === false) return;
//remove overlay layers from the page
var overlayLayers = targetElement.querySelectorAll('.introjs-overlay');
if (overlayLayers && overlayLayers.length > 0) {
for (var i = overlayLayers.length - 1; i >= 0; i--) {
//for fade-out animation
var overlayLayer = overlayLayers[i];
overlayLayer.style.opacity = 0;
setTimeout(
function() {
if (this.parentNode) {
this.parentNode.removeChild(this);
}
}.bind(overlayLayer),
500
);
}
}
//remove all helper layers
var helperLayer = targetElement.querySelector('.introjs-helperLayer');
if (helperLayer) {
helperLayer.parentNode.removeChild(helperLayer);
}
var referenceLayer = targetElement.querySelector('.introjs-tooltipReferenceLayer');
if (referenceLayer) {
referenceLayer.parentNode.removeChild(referenceLayer);
}
//remove disableInteractionLayer
var disableInteractionLayer = targetElement.querySelector('.introjs-disableInteraction');
if (disableInteractionLayer) {
disableInteractionLayer.parentNode.removeChild(disableInteractionLayer);
}
//remove intro floating element
var floatingElement = document.querySelector('.introjsFloatingElement');
if (floatingElement) {
floatingElement.parentNode.removeChild(floatingElement);
}
_removeShowElement();
//remove `introjs-fixParent` class from the elements
var fixParents = document.querySelectorAll('.introjs-fixParent');
if (fixParents && fixParents.length > 0) {
for (var i = fixParents.length - 1; i >= 0; i--) {
fixParents[i].className = fixParents[i].className
.replace(/introjs-fixParent/g, '')
.replace(/^\s+|\s+$/g, '');
}
}
//clean listeners
if (window.removeEventListener) {
window.removeEventListener('keydown', this._onKeyDown, true);
} else if (document.detachEvent) {
//IE
document.detachEvent('onkeydown', this._onKeyDown);
}
//check if any callback is defined
if (this._introExitCallback != undefined) {
this._introExitCallback.call(self);
}
//set the step to zero
this._currentStep = undefined;
} | [
"function",
"_exitIntro",
"(",
"targetElement",
",",
"force",
")",
"{",
"var",
"continueExit",
"=",
"true",
";",
"// calling onbeforeexit callback",
"//",
"// If this callback return `false`, it would halt the process",
"if",
"(",
"this",
".",
"_introBeforeExitCallback",
"!=",
"undefined",
")",
"{",
"continueExit",
"=",
"this",
".",
"_introBeforeExitCallback",
".",
"call",
"(",
"self",
")",
";",
"}",
"// skip this check if `force` parameter is `true`",
"// otherwise, if `onbeforeexit` returned `false`, don't exit the intro",
"if",
"(",
"!",
"force",
"&&",
"continueExit",
"===",
"false",
")",
"return",
";",
"//remove overlay layers from the page",
"var",
"overlayLayers",
"=",
"targetElement",
".",
"querySelectorAll",
"(",
"'.introjs-overlay'",
")",
";",
"if",
"(",
"overlayLayers",
"&&",
"overlayLayers",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"overlayLayers",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"//for fade-out animation",
"var",
"overlayLayer",
"=",
"overlayLayers",
"[",
"i",
"]",
";",
"overlayLayer",
".",
"style",
".",
"opacity",
"=",
"0",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"parentNode",
")",
"{",
"this",
".",
"parentNode",
".",
"removeChild",
"(",
"this",
")",
";",
"}",
"}",
".",
"bind",
"(",
"overlayLayer",
")",
",",
"500",
")",
";",
"}",
"}",
"//remove all helper layers",
"var",
"helperLayer",
"=",
"targetElement",
".",
"querySelector",
"(",
"'.introjs-helperLayer'",
")",
";",
"if",
"(",
"helperLayer",
")",
"{",
"helperLayer",
".",
"parentNode",
".",
"removeChild",
"(",
"helperLayer",
")",
";",
"}",
"var",
"referenceLayer",
"=",
"targetElement",
".",
"querySelector",
"(",
"'.introjs-tooltipReferenceLayer'",
")",
";",
"if",
"(",
"referenceLayer",
")",
"{",
"referenceLayer",
".",
"parentNode",
".",
"removeChild",
"(",
"referenceLayer",
")",
";",
"}",
"//remove disableInteractionLayer",
"var",
"disableInteractionLayer",
"=",
"targetElement",
".",
"querySelector",
"(",
"'.introjs-disableInteraction'",
")",
";",
"if",
"(",
"disableInteractionLayer",
")",
"{",
"disableInteractionLayer",
".",
"parentNode",
".",
"removeChild",
"(",
"disableInteractionLayer",
")",
";",
"}",
"//remove intro floating element",
"var",
"floatingElement",
"=",
"document",
".",
"querySelector",
"(",
"'.introjsFloatingElement'",
")",
";",
"if",
"(",
"floatingElement",
")",
"{",
"floatingElement",
".",
"parentNode",
".",
"removeChild",
"(",
"floatingElement",
")",
";",
"}",
"_removeShowElement",
"(",
")",
";",
"//remove `introjs-fixParent` class from the elements",
"var",
"fixParents",
"=",
"document",
".",
"querySelectorAll",
"(",
"'.introjs-fixParent'",
")",
";",
"if",
"(",
"fixParents",
"&&",
"fixParents",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"fixParents",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"fixParents",
"[",
"i",
"]",
".",
"className",
"=",
"fixParents",
"[",
"i",
"]",
".",
"className",
".",
"replace",
"(",
"/",
"introjs-fixParent",
"/",
"g",
",",
"''",
")",
".",
"replace",
"(",
"/",
"^\\s+|\\s+$",
"/",
"g",
",",
"''",
")",
";",
"}",
"}",
"//clean listeners",
"if",
"(",
"window",
".",
"removeEventListener",
")",
"{",
"window",
".",
"removeEventListener",
"(",
"'keydown'",
",",
"this",
".",
"_onKeyDown",
",",
"true",
")",
";",
"}",
"else",
"if",
"(",
"document",
".",
"detachEvent",
")",
"{",
"//IE",
"document",
".",
"detachEvent",
"(",
"'onkeydown'",
",",
"this",
".",
"_onKeyDown",
")",
";",
"}",
"//check if any callback is defined",
"if",
"(",
"this",
".",
"_introExitCallback",
"!=",
"undefined",
")",
"{",
"this",
".",
"_introExitCallback",
".",
"call",
"(",
"self",
")",
";",
"}",
"//set the step to zero",
"this",
".",
"_currentStep",
"=",
"undefined",
";",
"}"
]
| Exit from intro
@api private
@method _exitIntro
@param {Object} targetElement
@param {Boolean} force - Setting to `true` will skip the result of beforeExit callback | [
"Exit",
"from",
"intro"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L466-L549 |
39,435 | HasakiUI/hsk-jinx | src/component/intro/intro.js | _checkRight | function _checkRight(targetOffset, tooltipLayerStyleLeft, tooltipOffset, windowSize, tooltipLayer) {
if (targetOffset.left + tooltipLayerStyleLeft + tooltipOffset.width > windowSize.width) {
// off the right side of the window
tooltipLayer.style.left = windowSize.width - tooltipOffset.width - targetOffset.left + 'px';
return false;
}
tooltipLayer.style.left = tooltipLayerStyleLeft + 'px';
return true;
} | javascript | function _checkRight(targetOffset, tooltipLayerStyleLeft, tooltipOffset, windowSize, tooltipLayer) {
if (targetOffset.left + tooltipLayerStyleLeft + tooltipOffset.width > windowSize.width) {
// off the right side of the window
tooltipLayer.style.left = windowSize.width - tooltipOffset.width - targetOffset.left + 'px';
return false;
}
tooltipLayer.style.left = tooltipLayerStyleLeft + 'px';
return true;
} | [
"function",
"_checkRight",
"(",
"targetOffset",
",",
"tooltipLayerStyleLeft",
",",
"tooltipOffset",
",",
"windowSize",
",",
"tooltipLayer",
")",
"{",
"if",
"(",
"targetOffset",
".",
"left",
"+",
"tooltipLayerStyleLeft",
"+",
"tooltipOffset",
".",
"width",
">",
"windowSize",
".",
"width",
")",
"{",
"// off the right side of the window",
"tooltipLayer",
".",
"style",
".",
"left",
"=",
"windowSize",
".",
"width",
"-",
"tooltipOffset",
".",
"width",
"-",
"targetOffset",
".",
"left",
"+",
"'px'",
";",
"return",
"false",
";",
"}",
"tooltipLayer",
".",
"style",
".",
"left",
"=",
"tooltipLayerStyleLeft",
"+",
"'px'",
";",
"return",
"true",
";",
"}"
]
| Set tooltip left so it doesn't go off the right side of the window
@return boolean true, if tooltipLayerStyleLeft is ok. false, otherwise. | [
"Set",
"tooltip",
"left",
"so",
"it",
"doesn",
"t",
"go",
"off",
"the",
"right",
"side",
"of",
"the",
"window"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L739-L747 |
39,436 | HasakiUI/hsk-jinx | src/component/intro/intro.js | _determineAutoPosition | function _determineAutoPosition(targetElement, tooltipLayer, desiredTooltipPosition) {
// Take a clone of position precedence. These will be the available
var possiblePositions = this._options.positionPrecedence.slice();
var windowSize = _getWinSize();
var tooltipHeight = _getOffset(tooltipLayer).height + 10;
var tooltipWidth = _getOffset(tooltipLayer).width + 20;
var targetOffset = _getOffset(targetElement);
// If we check all the possible areas, and there are no valid places for the tooltip, the element
// must take up most of the screen real estate. Show the tooltip floating in the middle of the screen.
var calculatedPosition = 'floating';
// TODO Update by joyer
// Check if the width of the tooltip + the starting point would spill off the right side of the screen
// If no, neither bottom or top are valid
// if (targetOffset.left + tooltipWidth > windowSize.width || ((targetOffset.left + (targetOffset.width / 2)) - tooltipWidth) < 0) {
// _removeEntry(possiblePositions, "bottom");
// _removeEntry(possiblePositions, "top");
// } else {
// Check for space below
if (targetOffset.height + targetOffset.top + tooltipHeight > windowSize.height) {
_removeEntry(possiblePositions, 'bottom');
}
// Check for space above
if (targetOffset.top - tooltipHeight < 0) {
_removeEntry(possiblePositions, 'top');
}
// }
// Check for space to the right
if (targetOffset.width + targetOffset.left + tooltipWidth > windowSize.width) {
_removeEntry(possiblePositions, 'right');
}
// Check for space to the left
if (targetOffset.left - tooltipWidth < 0) {
_removeEntry(possiblePositions, 'left');
}
// At this point, our array only has positions that are valid. Pick the first one, as it remains in order
if (possiblePositions.length > 0) {
calculatedPosition = possiblePositions[0];
}
// If the requested position is in the list, replace our calculated choice with that
if (desiredTooltipPosition && desiredTooltipPosition != 'auto') {
if (possiblePositions.indexOf(desiredTooltipPosition) > -1) {
calculatedPosition = desiredTooltipPosition;
}
}
return calculatedPosition;
} | javascript | function _determineAutoPosition(targetElement, tooltipLayer, desiredTooltipPosition) {
// Take a clone of position precedence. These will be the available
var possiblePositions = this._options.positionPrecedence.slice();
var windowSize = _getWinSize();
var tooltipHeight = _getOffset(tooltipLayer).height + 10;
var tooltipWidth = _getOffset(tooltipLayer).width + 20;
var targetOffset = _getOffset(targetElement);
// If we check all the possible areas, and there are no valid places for the tooltip, the element
// must take up most of the screen real estate. Show the tooltip floating in the middle of the screen.
var calculatedPosition = 'floating';
// TODO Update by joyer
// Check if the width of the tooltip + the starting point would spill off the right side of the screen
// If no, neither bottom or top are valid
// if (targetOffset.left + tooltipWidth > windowSize.width || ((targetOffset.left + (targetOffset.width / 2)) - tooltipWidth) < 0) {
// _removeEntry(possiblePositions, "bottom");
// _removeEntry(possiblePositions, "top");
// } else {
// Check for space below
if (targetOffset.height + targetOffset.top + tooltipHeight > windowSize.height) {
_removeEntry(possiblePositions, 'bottom');
}
// Check for space above
if (targetOffset.top - tooltipHeight < 0) {
_removeEntry(possiblePositions, 'top');
}
// }
// Check for space to the right
if (targetOffset.width + targetOffset.left + tooltipWidth > windowSize.width) {
_removeEntry(possiblePositions, 'right');
}
// Check for space to the left
if (targetOffset.left - tooltipWidth < 0) {
_removeEntry(possiblePositions, 'left');
}
// At this point, our array only has positions that are valid. Pick the first one, as it remains in order
if (possiblePositions.length > 0) {
calculatedPosition = possiblePositions[0];
}
// If the requested position is in the list, replace our calculated choice with that
if (desiredTooltipPosition && desiredTooltipPosition != 'auto') {
if (possiblePositions.indexOf(desiredTooltipPosition) > -1) {
calculatedPosition = desiredTooltipPosition;
}
}
return calculatedPosition;
} | [
"function",
"_determineAutoPosition",
"(",
"targetElement",
",",
"tooltipLayer",
",",
"desiredTooltipPosition",
")",
"{",
"// Take a clone of position precedence. These will be the available",
"var",
"possiblePositions",
"=",
"this",
".",
"_options",
".",
"positionPrecedence",
".",
"slice",
"(",
")",
";",
"var",
"windowSize",
"=",
"_getWinSize",
"(",
")",
";",
"var",
"tooltipHeight",
"=",
"_getOffset",
"(",
"tooltipLayer",
")",
".",
"height",
"+",
"10",
";",
"var",
"tooltipWidth",
"=",
"_getOffset",
"(",
"tooltipLayer",
")",
".",
"width",
"+",
"20",
";",
"var",
"targetOffset",
"=",
"_getOffset",
"(",
"targetElement",
")",
";",
"// If we check all the possible areas, and there are no valid places for the tooltip, the element",
"// must take up most of the screen real estate. Show the tooltip floating in the middle of the screen.",
"var",
"calculatedPosition",
"=",
"'floating'",
";",
"// TODO Update by joyer",
"// Check if the width of the tooltip + the starting point would spill off the right side of the screen",
"// If no, neither bottom or top are valid",
"// if (targetOffset.left + tooltipWidth > windowSize.width || ((targetOffset.left + (targetOffset.width / 2)) - tooltipWidth) < 0) {",
"// _removeEntry(possiblePositions, \"bottom\");",
"// _removeEntry(possiblePositions, \"top\");",
"// } else {",
"// Check for space below",
"if",
"(",
"targetOffset",
".",
"height",
"+",
"targetOffset",
".",
"top",
"+",
"tooltipHeight",
">",
"windowSize",
".",
"height",
")",
"{",
"_removeEntry",
"(",
"possiblePositions",
",",
"'bottom'",
")",
";",
"}",
"// Check for space above",
"if",
"(",
"targetOffset",
".",
"top",
"-",
"tooltipHeight",
"<",
"0",
")",
"{",
"_removeEntry",
"(",
"possiblePositions",
",",
"'top'",
")",
";",
"}",
"// }",
"// Check for space to the right",
"if",
"(",
"targetOffset",
".",
"width",
"+",
"targetOffset",
".",
"left",
"+",
"tooltipWidth",
">",
"windowSize",
".",
"width",
")",
"{",
"_removeEntry",
"(",
"possiblePositions",
",",
"'right'",
")",
";",
"}",
"// Check for space to the left",
"if",
"(",
"targetOffset",
".",
"left",
"-",
"tooltipWidth",
"<",
"0",
")",
"{",
"_removeEntry",
"(",
"possiblePositions",
",",
"'left'",
")",
";",
"}",
"// At this point, our array only has positions that are valid. Pick the first one, as it remains in order",
"if",
"(",
"possiblePositions",
".",
"length",
">",
"0",
")",
"{",
"calculatedPosition",
"=",
"possiblePositions",
"[",
"0",
"]",
";",
"}",
"// If the requested position is in the list, replace our calculated choice with that",
"if",
"(",
"desiredTooltipPosition",
"&&",
"desiredTooltipPosition",
"!=",
"'auto'",
")",
"{",
"if",
"(",
"possiblePositions",
".",
"indexOf",
"(",
"desiredTooltipPosition",
")",
">",
"-",
"1",
")",
"{",
"calculatedPosition",
"=",
"desiredTooltipPosition",
";",
"}",
"}",
"return",
"calculatedPosition",
";",
"}"
]
| Determines the position of the tooltip based on the position precedence and availability
of screen space.
@param {Object} targetElement
@param {Object} tooltipLayer
@param {Object} desiredTooltipPosition | [
"Determines",
"the",
"position",
"of",
"the",
"tooltip",
"based",
"on",
"the",
"position",
"precedence",
"and",
"availability",
"of",
"screen",
"space",
"."
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L773-L827 |
39,437 | HasakiUI/hsk-jinx | src/component/intro/intro.js | _removeEntry | function _removeEntry(stringArray, stringToRemove) {
if (stringArray.indexOf(stringToRemove) > -1) {
stringArray.splice(stringArray.indexOf(stringToRemove), 1);
}
} | javascript | function _removeEntry(stringArray, stringToRemove) {
if (stringArray.indexOf(stringToRemove) > -1) {
stringArray.splice(stringArray.indexOf(stringToRemove), 1);
}
} | [
"function",
"_removeEntry",
"(",
"stringArray",
",",
"stringToRemove",
")",
"{",
"if",
"(",
"stringArray",
".",
"indexOf",
"(",
"stringToRemove",
")",
">",
"-",
"1",
")",
"{",
"stringArray",
".",
"splice",
"(",
"stringArray",
".",
"indexOf",
"(",
"stringToRemove",
")",
",",
"1",
")",
";",
"}",
"}"
]
| Remove an entry from a string array if it's there, does nothing if it isn't there.
@param {Array} stringArray
@param {String} stringToRemove | [
"Remove",
"an",
"entry",
"from",
"a",
"string",
"array",
"if",
"it",
"s",
"there",
"does",
"nothing",
"if",
"it",
"isn",
"t",
"there",
"."
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L835-L839 |
39,438 | HasakiUI/hsk-jinx | src/component/intro/intro.js | _setHelperLayerPosition | function _setHelperLayerPosition(helperLayer) {
if (helperLayer) {
//prevent error when `this._currentStep` in undefined
if (!this._introItems[this._currentStep]) return;
var currentElement = this._introItems[this._currentStep],
elementPosition = _getOffset(currentElement.element),
widthHeightPadding = 10;
// If the target element is fixed, the tooltip should be fixed as well.
// Otherwise, remove a fixed class that may be left over from the previous
// step.
if (_isFixed(currentElement.element)) {
helperLayer.className += ' introjs-fixedTooltip';
} else {
helperLayer.className = helperLayer.className.replace(' introjs-fixedTooltip', '');
}
if (currentElement.position == 'floating') {
widthHeightPadding = 0;
}
//set new position to helper layer
helperLayer.setAttribute(
'style',
'width: ' +
(elementPosition.width + widthHeightPadding) +
'px; ' +
'height:' +
(elementPosition.height + widthHeightPadding) +
'px; ' +
'top:' +
(elementPosition.top - 5) +
'px;' +
'left: ' +
(elementPosition.left - 5) +
'px;'
);
}
} | javascript | function _setHelperLayerPosition(helperLayer) {
if (helperLayer) {
//prevent error when `this._currentStep` in undefined
if (!this._introItems[this._currentStep]) return;
var currentElement = this._introItems[this._currentStep],
elementPosition = _getOffset(currentElement.element),
widthHeightPadding = 10;
// If the target element is fixed, the tooltip should be fixed as well.
// Otherwise, remove a fixed class that may be left over from the previous
// step.
if (_isFixed(currentElement.element)) {
helperLayer.className += ' introjs-fixedTooltip';
} else {
helperLayer.className = helperLayer.className.replace(' introjs-fixedTooltip', '');
}
if (currentElement.position == 'floating') {
widthHeightPadding = 0;
}
//set new position to helper layer
helperLayer.setAttribute(
'style',
'width: ' +
(elementPosition.width + widthHeightPadding) +
'px; ' +
'height:' +
(elementPosition.height + widthHeightPadding) +
'px; ' +
'top:' +
(elementPosition.top - 5) +
'px;' +
'left: ' +
(elementPosition.left - 5) +
'px;'
);
}
} | [
"function",
"_setHelperLayerPosition",
"(",
"helperLayer",
")",
"{",
"if",
"(",
"helperLayer",
")",
"{",
"//prevent error when `this._currentStep` in undefined",
"if",
"(",
"!",
"this",
".",
"_introItems",
"[",
"this",
".",
"_currentStep",
"]",
")",
"return",
";",
"var",
"currentElement",
"=",
"this",
".",
"_introItems",
"[",
"this",
".",
"_currentStep",
"]",
",",
"elementPosition",
"=",
"_getOffset",
"(",
"currentElement",
".",
"element",
")",
",",
"widthHeightPadding",
"=",
"10",
";",
"// If the target element is fixed, the tooltip should be fixed as well.",
"// Otherwise, remove a fixed class that may be left over from the previous",
"// step.",
"if",
"(",
"_isFixed",
"(",
"currentElement",
".",
"element",
")",
")",
"{",
"helperLayer",
".",
"className",
"+=",
"' introjs-fixedTooltip'",
";",
"}",
"else",
"{",
"helperLayer",
".",
"className",
"=",
"helperLayer",
".",
"className",
".",
"replace",
"(",
"' introjs-fixedTooltip'",
",",
"''",
")",
";",
"}",
"if",
"(",
"currentElement",
".",
"position",
"==",
"'floating'",
")",
"{",
"widthHeightPadding",
"=",
"0",
";",
"}",
"//set new position to helper layer",
"helperLayer",
".",
"setAttribute",
"(",
"'style'",
",",
"'width: '",
"+",
"(",
"elementPosition",
".",
"width",
"+",
"widthHeightPadding",
")",
"+",
"'px; '",
"+",
"'height:'",
"+",
"(",
"elementPosition",
".",
"height",
"+",
"widthHeightPadding",
")",
"+",
"'px; '",
"+",
"'top:'",
"+",
"(",
"elementPosition",
".",
"top",
"-",
"5",
")",
"+",
"'px;'",
"+",
"'left: '",
"+",
"(",
"elementPosition",
".",
"left",
"-",
"5",
")",
"+",
"'px;'",
")",
";",
"}",
"}"
]
| Update the position of the helper layer on the screen
@api private
@method _setHelperLayerPosition
@param {Object} helperLayer | [
"Update",
"the",
"position",
"of",
"the",
"helper",
"layer",
"on",
"the",
"screen"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L848-L887 |
39,439 | HasakiUI/hsk-jinx | src/component/intro/intro.js | _disableInteraction | function _disableInteraction() {
var disableInteractionLayer = document.querySelector('.introjs-disableInteraction');
if (disableInteractionLayer === null) {
disableInteractionLayer = document.createElement('div');
disableInteractionLayer.className = 'introjs-disableInteraction';
this._targetElement.appendChild(disableInteractionLayer);
}
_setHelperLayerPosition.call(this, disableInteractionLayer);
} | javascript | function _disableInteraction() {
var disableInteractionLayer = document.querySelector('.introjs-disableInteraction');
if (disableInteractionLayer === null) {
disableInteractionLayer = document.createElement('div');
disableInteractionLayer.className = 'introjs-disableInteraction';
this._targetElement.appendChild(disableInteractionLayer);
}
_setHelperLayerPosition.call(this, disableInteractionLayer);
} | [
"function",
"_disableInteraction",
"(",
")",
"{",
"var",
"disableInteractionLayer",
"=",
"document",
".",
"querySelector",
"(",
"'.introjs-disableInteraction'",
")",
";",
"if",
"(",
"disableInteractionLayer",
"===",
"null",
")",
"{",
"disableInteractionLayer",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"disableInteractionLayer",
".",
"className",
"=",
"'introjs-disableInteraction'",
";",
"this",
".",
"_targetElement",
".",
"appendChild",
"(",
"disableInteractionLayer",
")",
";",
"}",
"_setHelperLayerPosition",
".",
"call",
"(",
"this",
",",
"disableInteractionLayer",
")",
";",
"}"
]
| Add disableinteraction layer and adjust the size and position of the layer
@api private
@method _disableInteraction | [
"Add",
"disableinteraction",
"layer",
"and",
"adjust",
"the",
"size",
"and",
"position",
"of",
"the",
"layer"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L895-L905 |
39,440 | HasakiUI/hsk-jinx | src/component/intro/intro.js | _scrollTo | function _scrollTo(scrollTo, targetElement, tooltipLayer) {
if (!this._options.scrollToElement) return;
if (scrollTo === 'tooltip') {
var rect = tooltipLayer.getBoundingClientRect();
} else {
var rect = targetElement.element.getBoundingClientRect();
}
if (!_elementInViewport(targetElement.element)) {
var winHeight = _getWinSize().height;
var top = rect.bottom - (rect.bottom - rect.top);
var bottom = rect.bottom - winHeight;
// TODO (afshinm): do we need scroll padding now?
// I have changed the scroll option and now it scrolls the window to
// the center of the target element or tooltip.
if (top < 0 || targetElement.element.clientHeight > winHeight) {
window.scrollBy(
0,
rect.top - (winHeight / 2 - rect.height / 2) - this._options.scrollPadding
); // 30px padding from edge to look nice
//Scroll down
} else {
window.scrollBy(
0,
rect.top - (winHeight / 2 - rect.height / 2) + this._options.scrollPadding
); // 30px padding from edge to look nice
}
}
} | javascript | function _scrollTo(scrollTo, targetElement, tooltipLayer) {
if (!this._options.scrollToElement) return;
if (scrollTo === 'tooltip') {
var rect = tooltipLayer.getBoundingClientRect();
} else {
var rect = targetElement.element.getBoundingClientRect();
}
if (!_elementInViewport(targetElement.element)) {
var winHeight = _getWinSize().height;
var top = rect.bottom - (rect.bottom - rect.top);
var bottom = rect.bottom - winHeight;
// TODO (afshinm): do we need scroll padding now?
// I have changed the scroll option and now it scrolls the window to
// the center of the target element or tooltip.
if (top < 0 || targetElement.element.clientHeight > winHeight) {
window.scrollBy(
0,
rect.top - (winHeight / 2 - rect.height / 2) - this._options.scrollPadding
); // 30px padding from edge to look nice
//Scroll down
} else {
window.scrollBy(
0,
rect.top - (winHeight / 2 - rect.height / 2) + this._options.scrollPadding
); // 30px padding from edge to look nice
}
}
} | [
"function",
"_scrollTo",
"(",
"scrollTo",
",",
"targetElement",
",",
"tooltipLayer",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_options",
".",
"scrollToElement",
")",
"return",
";",
"if",
"(",
"scrollTo",
"===",
"'tooltip'",
")",
"{",
"var",
"rect",
"=",
"tooltipLayer",
".",
"getBoundingClientRect",
"(",
")",
";",
"}",
"else",
"{",
"var",
"rect",
"=",
"targetElement",
".",
"element",
".",
"getBoundingClientRect",
"(",
")",
";",
"}",
"if",
"(",
"!",
"_elementInViewport",
"(",
"targetElement",
".",
"element",
")",
")",
"{",
"var",
"winHeight",
"=",
"_getWinSize",
"(",
")",
".",
"height",
";",
"var",
"top",
"=",
"rect",
".",
"bottom",
"-",
"(",
"rect",
".",
"bottom",
"-",
"rect",
".",
"top",
")",
";",
"var",
"bottom",
"=",
"rect",
".",
"bottom",
"-",
"winHeight",
";",
"// TODO (afshinm): do we need scroll padding now?",
"// I have changed the scroll option and now it scrolls the window to",
"// the center of the target element or tooltip.",
"if",
"(",
"top",
"<",
"0",
"||",
"targetElement",
".",
"element",
".",
"clientHeight",
">",
"winHeight",
")",
"{",
"window",
".",
"scrollBy",
"(",
"0",
",",
"rect",
".",
"top",
"-",
"(",
"winHeight",
"/",
"2",
"-",
"rect",
".",
"height",
"/",
"2",
")",
"-",
"this",
".",
"_options",
".",
"scrollPadding",
")",
";",
"// 30px padding from edge to look nice",
"//Scroll down",
"}",
"else",
"{",
"window",
".",
"scrollBy",
"(",
"0",
",",
"rect",
".",
"top",
"-",
"(",
"winHeight",
"/",
"2",
"-",
"rect",
".",
"height",
"/",
"2",
")",
"+",
"this",
".",
"_options",
".",
"scrollPadding",
")",
";",
"// 30px padding from edge to look nice",
"}",
"}",
"}"
]
| To change the scroll of `window` after highlighting an element
@api private
@method _scrollTo
@param {String} scrollTo
@param {Object} targetElement
@param {Object} tooltipLayer | [
"To",
"change",
"the",
"scroll",
"of",
"window",
"after",
"highlighting",
"an",
"element"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L1309-L1341 |
39,441 | HasakiUI/hsk-jinx | src/component/intro/intro.js | _populateHints | function _populateHints(targetElm) {
var self = this;
this._introItems = [];
if (this._options.hints) {
for (var i = 0, l = this._options.hints.length; i < l; i++) {
var currentItem = _cloneObject(this._options.hints[i]);
if (typeof currentItem.element === 'string') {
//grab the element with given selector from the page
currentItem.element = document.querySelector(currentItem.element);
}
currentItem.hintPosition = currentItem.hintPosition || this._options.hintPosition;
currentItem.hintAnimation = currentItem.hintAnimation || this._options.hintAnimation;
if (currentItem.element != null) {
this._introItems.push(currentItem);
}
}
} else {
var hints = targetElm.querySelectorAll('*[data-hint]');
if (hints.length < 1) {
return false;
}
//first add intro items with data-step
for (var i = 0, l = hints.length; i < l; i++) {
var currentElement = hints[i];
// hint animation
var hintAnimation = currentElement.getAttribute('data-hintAnimation');
if (hintAnimation) {
hintAnimation = hintAnimation == 'true';
} else {
hintAnimation = this._options.hintAnimation;
}
this._introItems.push({
element: currentElement,
hint: currentElement.getAttribute('data-hint'),
hintPosition:
currentElement.getAttribute('data-hintPosition') || this._options.hintPosition,
hintAnimation: hintAnimation,
tooltipClass: currentElement.getAttribute('data-tooltipClass'),
position:
currentElement.getAttribute('data-position') || this._options.tooltipPosition
});
}
}
_addHints.call(this);
if (document.addEventListener) {
document.addEventListener('click', _removeHintTooltip.bind(this), false);
//for window resize
window.addEventListener('resize', _reAlignHints.bind(this), true);
} else if (document.attachEvent) {
//IE
//for window resize
document.attachEvent('onclick', _removeHintTooltip.bind(this));
document.attachEvent('onresize', _reAlignHints.bind(this));
}
} | javascript | function _populateHints(targetElm) {
var self = this;
this._introItems = [];
if (this._options.hints) {
for (var i = 0, l = this._options.hints.length; i < l; i++) {
var currentItem = _cloneObject(this._options.hints[i]);
if (typeof currentItem.element === 'string') {
//grab the element with given selector from the page
currentItem.element = document.querySelector(currentItem.element);
}
currentItem.hintPosition = currentItem.hintPosition || this._options.hintPosition;
currentItem.hintAnimation = currentItem.hintAnimation || this._options.hintAnimation;
if (currentItem.element != null) {
this._introItems.push(currentItem);
}
}
} else {
var hints = targetElm.querySelectorAll('*[data-hint]');
if (hints.length < 1) {
return false;
}
//first add intro items with data-step
for (var i = 0, l = hints.length; i < l; i++) {
var currentElement = hints[i];
// hint animation
var hintAnimation = currentElement.getAttribute('data-hintAnimation');
if (hintAnimation) {
hintAnimation = hintAnimation == 'true';
} else {
hintAnimation = this._options.hintAnimation;
}
this._introItems.push({
element: currentElement,
hint: currentElement.getAttribute('data-hint'),
hintPosition:
currentElement.getAttribute('data-hintPosition') || this._options.hintPosition,
hintAnimation: hintAnimation,
tooltipClass: currentElement.getAttribute('data-tooltipClass'),
position:
currentElement.getAttribute('data-position') || this._options.tooltipPosition
});
}
}
_addHints.call(this);
if (document.addEventListener) {
document.addEventListener('click', _removeHintTooltip.bind(this), false);
//for window resize
window.addEventListener('resize', _reAlignHints.bind(this), true);
} else if (document.attachEvent) {
//IE
//for window resize
document.attachEvent('onclick', _removeHintTooltip.bind(this));
document.attachEvent('onresize', _reAlignHints.bind(this));
}
} | [
"function",
"_populateHints",
"(",
"targetElm",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"_introItems",
"=",
"[",
"]",
";",
"if",
"(",
"this",
".",
"_options",
".",
"hints",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"this",
".",
"_options",
".",
"hints",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"currentItem",
"=",
"_cloneObject",
"(",
"this",
".",
"_options",
".",
"hints",
"[",
"i",
"]",
")",
";",
"if",
"(",
"typeof",
"currentItem",
".",
"element",
"===",
"'string'",
")",
"{",
"//grab the element with given selector from the page",
"currentItem",
".",
"element",
"=",
"document",
".",
"querySelector",
"(",
"currentItem",
".",
"element",
")",
";",
"}",
"currentItem",
".",
"hintPosition",
"=",
"currentItem",
".",
"hintPosition",
"||",
"this",
".",
"_options",
".",
"hintPosition",
";",
"currentItem",
".",
"hintAnimation",
"=",
"currentItem",
".",
"hintAnimation",
"||",
"this",
".",
"_options",
".",
"hintAnimation",
";",
"if",
"(",
"currentItem",
".",
"element",
"!=",
"null",
")",
"{",
"this",
".",
"_introItems",
".",
"push",
"(",
"currentItem",
")",
";",
"}",
"}",
"}",
"else",
"{",
"var",
"hints",
"=",
"targetElm",
".",
"querySelectorAll",
"(",
"'*[data-hint]'",
")",
";",
"if",
"(",
"hints",
".",
"length",
"<",
"1",
")",
"{",
"return",
"false",
";",
"}",
"//first add intro items with data-step",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"hints",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"currentElement",
"=",
"hints",
"[",
"i",
"]",
";",
"// hint animation",
"var",
"hintAnimation",
"=",
"currentElement",
".",
"getAttribute",
"(",
"'data-hintAnimation'",
")",
";",
"if",
"(",
"hintAnimation",
")",
"{",
"hintAnimation",
"=",
"hintAnimation",
"==",
"'true'",
";",
"}",
"else",
"{",
"hintAnimation",
"=",
"this",
".",
"_options",
".",
"hintAnimation",
";",
"}",
"this",
".",
"_introItems",
".",
"push",
"(",
"{",
"element",
":",
"currentElement",
",",
"hint",
":",
"currentElement",
".",
"getAttribute",
"(",
"'data-hint'",
")",
",",
"hintPosition",
":",
"currentElement",
".",
"getAttribute",
"(",
"'data-hintPosition'",
")",
"||",
"this",
".",
"_options",
".",
"hintPosition",
",",
"hintAnimation",
":",
"hintAnimation",
",",
"tooltipClass",
":",
"currentElement",
".",
"getAttribute",
"(",
"'data-tooltipClass'",
")",
",",
"position",
":",
"currentElement",
".",
"getAttribute",
"(",
"'data-position'",
")",
"||",
"this",
".",
"_options",
".",
"tooltipPosition",
"}",
")",
";",
"}",
"}",
"_addHints",
".",
"call",
"(",
"this",
")",
";",
"if",
"(",
"document",
".",
"addEventListener",
")",
"{",
"document",
".",
"addEventListener",
"(",
"'click'",
",",
"_removeHintTooltip",
".",
"bind",
"(",
"this",
")",
",",
"false",
")",
";",
"//for window resize",
"window",
".",
"addEventListener",
"(",
"'resize'",
",",
"_reAlignHints",
".",
"bind",
"(",
"this",
")",
",",
"true",
")",
";",
"}",
"else",
"if",
"(",
"document",
".",
"attachEvent",
")",
"{",
"//IE",
"//for window resize",
"document",
".",
"attachEvent",
"(",
"'onclick'",
",",
"_removeHintTooltip",
".",
"bind",
"(",
"this",
")",
")",
";",
"document",
".",
"attachEvent",
"(",
"'onresize'",
",",
"_reAlignHints",
".",
"bind",
"(",
"this",
")",
")",
";",
"}",
"}"
]
| Start parsing hint items
@api private
@param {Object} targetElm
@method _startHint | [
"Start",
"parsing",
"hint",
"items"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L1604-L1669 |
39,442 | HasakiUI/hsk-jinx | src/component/intro/intro.js | _reAlignHints | function _reAlignHints() {
for (var i = 0, l = this._introItems.length; i < l; i++) {
var item = this._introItems[i];
if (typeof item.targetElement == 'undefined') continue;
_alignHintPosition.call(this, item.hintPosition, item.element, item.targetElement);
}
} | javascript | function _reAlignHints() {
for (var i = 0, l = this._introItems.length; i < l; i++) {
var item = this._introItems[i];
if (typeof item.targetElement == 'undefined') continue;
_alignHintPosition.call(this, item.hintPosition, item.element, item.targetElement);
}
} | [
"function",
"_reAlignHints",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"this",
".",
"_introItems",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"item",
"=",
"this",
".",
"_introItems",
"[",
"i",
"]",
";",
"if",
"(",
"typeof",
"item",
".",
"targetElement",
"==",
"'undefined'",
")",
"continue",
";",
"_alignHintPosition",
".",
"call",
"(",
"this",
",",
"item",
".",
"hintPosition",
",",
"item",
".",
"element",
",",
"item",
".",
"targetElement",
")",
";",
"}",
"}"
]
| Re-aligns all hint elements
@api private
@method _reAlignHints | [
"Re",
"-",
"aligns",
"all",
"hint",
"elements"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L1677-L1685 |
39,443 | HasakiUI/hsk-jinx | src/component/intro/intro.js | _hideHint | function _hideHint(stepId) {
_removeHintTooltip.call(this);
var hint = this._targetElement.querySelector('.introjs-hint[data-step="' + stepId + '"]');
if (hint) {
hint.className += ' introjs-hidehint';
}
// call the callback function (if any)
if (typeof this._hintCloseCallback !== 'undefined') {
this._hintCloseCallback.call(this, stepId);
}
} | javascript | function _hideHint(stepId) {
_removeHintTooltip.call(this);
var hint = this._targetElement.querySelector('.introjs-hint[data-step="' + stepId + '"]');
if (hint) {
hint.className += ' introjs-hidehint';
}
// call the callback function (if any)
if (typeof this._hintCloseCallback !== 'undefined') {
this._hintCloseCallback.call(this, stepId);
}
} | [
"function",
"_hideHint",
"(",
"stepId",
")",
"{",
"_removeHintTooltip",
".",
"call",
"(",
"this",
")",
";",
"var",
"hint",
"=",
"this",
".",
"_targetElement",
".",
"querySelector",
"(",
"'.introjs-hint[data-step=\"'",
"+",
"stepId",
"+",
"'\"]'",
")",
";",
"if",
"(",
"hint",
")",
"{",
"hint",
".",
"className",
"+=",
"' introjs-hidehint'",
";",
"}",
"// call the callback function (if any)",
"if",
"(",
"typeof",
"this",
".",
"_hintCloseCallback",
"!==",
"'undefined'",
")",
"{",
"this",
".",
"_hintCloseCallback",
".",
"call",
"(",
"this",
",",
"stepId",
")",
";",
"}",
"}"
]
| Hide a hint
@api private
@method _hideHint | [
"Hide",
"a",
"hint"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L1693-L1705 |
39,444 | HasakiUI/hsk-jinx | src/component/intro/intro.js | _hideHints | function _hideHints() {
var hints = this._targetElement.querySelectorAll('.introjs-hint');
if (hints && hints.length > 0) {
for (var i = 0; i < hints.length; i++) {
_hideHint.call(this, hints[i].getAttribute('data-step'));
}
}
} | javascript | function _hideHints() {
var hints = this._targetElement.querySelectorAll('.introjs-hint');
if (hints && hints.length > 0) {
for (var i = 0; i < hints.length; i++) {
_hideHint.call(this, hints[i].getAttribute('data-step'));
}
}
} | [
"function",
"_hideHints",
"(",
")",
"{",
"var",
"hints",
"=",
"this",
".",
"_targetElement",
".",
"querySelectorAll",
"(",
"'.introjs-hint'",
")",
";",
"if",
"(",
"hints",
"&&",
"hints",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"hints",
".",
"length",
";",
"i",
"++",
")",
"{",
"_hideHint",
".",
"call",
"(",
"this",
",",
"hints",
"[",
"i",
"]",
".",
"getAttribute",
"(",
"'data-step'",
")",
")",
";",
"}",
"}",
"}"
]
| Hide all hints
@api private
@method _hideHints | [
"Hide",
"all",
"hints"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L1713-L1721 |
39,445 | HasakiUI/hsk-jinx | src/component/intro/intro.js | _showHints | function _showHints() {
var hints = this._targetElement.querySelectorAll('.introjs-hint');
if (hints && hints.length > 0) {
for (var i = 0; i < hints.length; i++) {
_showHint.call(this, hints[i].getAttribute('data-step'));
}
} else {
_populateHints.call(this, this._targetElement);
}
} | javascript | function _showHints() {
var hints = this._targetElement.querySelectorAll('.introjs-hint');
if (hints && hints.length > 0) {
for (var i = 0; i < hints.length; i++) {
_showHint.call(this, hints[i].getAttribute('data-step'));
}
} else {
_populateHints.call(this, this._targetElement);
}
} | [
"function",
"_showHints",
"(",
")",
"{",
"var",
"hints",
"=",
"this",
".",
"_targetElement",
".",
"querySelectorAll",
"(",
"'.introjs-hint'",
")",
";",
"if",
"(",
"hints",
"&&",
"hints",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"hints",
".",
"length",
";",
"i",
"++",
")",
"{",
"_showHint",
".",
"call",
"(",
"this",
",",
"hints",
"[",
"i",
"]",
".",
"getAttribute",
"(",
"'data-step'",
")",
")",
";",
"}",
"}",
"else",
"{",
"_populateHints",
".",
"call",
"(",
"this",
",",
"this",
".",
"_targetElement",
")",
";",
"}",
"}"
]
| Show all hints
@api private
@method _showHints | [
"Show",
"all",
"hints"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L1729-L1739 |
39,446 | HasakiUI/hsk-jinx | src/component/intro/intro.js | _showHint | function _showHint(stepId) {
var hint = this._targetElement.querySelector('.introjs-hint[data-step="' + stepId + '"]');
if (hint) {
hint.className = hint.className.replace(/introjs\-hidehint/g, '');
}
} | javascript | function _showHint(stepId) {
var hint = this._targetElement.querySelector('.introjs-hint[data-step="' + stepId + '"]');
if (hint) {
hint.className = hint.className.replace(/introjs\-hidehint/g, '');
}
} | [
"function",
"_showHint",
"(",
"stepId",
")",
"{",
"var",
"hint",
"=",
"this",
".",
"_targetElement",
".",
"querySelector",
"(",
"'.introjs-hint[data-step=\"'",
"+",
"stepId",
"+",
"'\"]'",
")",
";",
"if",
"(",
"hint",
")",
"{",
"hint",
".",
"className",
"=",
"hint",
".",
"className",
".",
"replace",
"(",
"/",
"introjs\\-hidehint",
"/",
"g",
",",
"''",
")",
";",
"}",
"}"
]
| Show a hint
@api private
@method _showHint | [
"Show",
"a",
"hint"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L1747-L1753 |
39,447 | HasakiUI/hsk-jinx | src/component/intro/intro.js | _addHints | function _addHints() {
var self = this;
var oldHintsWrapper = document.querySelector('.introjs-hints');
if (oldHintsWrapper != null) {
hintsWrapper = oldHintsWrapper;
} else {
var hintsWrapper = document.createElement('div');
hintsWrapper.className = 'introjs-hints';
}
for (var i = 0, l = this._introItems.length; i < l; i++) {
var item = this._introItems[i];
// avoid append a hint twice
if (document.querySelector('.introjs-hint[data-step="' + i + '"]')) continue;
var hint = document.createElement('a');
_setAnchorAsButton(hint);
(function(hint, item, i) {
// when user clicks on the hint element
hint.onclick = function(e) {
var evt = e ? e : window.event;
if (evt.stopPropagation) evt.stopPropagation();
if (evt.cancelBubble != null) evt.cancelBubble = true;
_showHintDialog.call(self, i);
};
})(hint, item, i);
hint.className = 'introjs-hint';
if (!item.hintAnimation) {
hint.className += ' introjs-hint-no-anim';
}
// hint's position should be fixed if the target element's position is fixed
if (_isFixed(item.element)) {
hint.className += ' introjs-fixedhint';
}
var hintDot = document.createElement('div');
hintDot.className = 'introjs-hint-dot';
var hintPulse = document.createElement('div');
hintPulse.className = 'introjs-hint-pulse';
hint.appendChild(hintDot);
hint.appendChild(hintPulse);
hint.setAttribute('data-step', i);
// we swap the hint element with target element
// because _setHelperLayerPosition uses `element` property
item.targetElement = item.element;
item.element = hint;
// align the hint position
_alignHintPosition.call(this, item.hintPosition, hint, item.targetElement);
hintsWrapper.appendChild(hint);
}
// adding the hints wrapper
document.body.appendChild(hintsWrapper);
// call the callback function (if any)
if (typeof this._hintsAddedCallback !== 'undefined') {
this._hintsAddedCallback.call(this);
}
} | javascript | function _addHints() {
var self = this;
var oldHintsWrapper = document.querySelector('.introjs-hints');
if (oldHintsWrapper != null) {
hintsWrapper = oldHintsWrapper;
} else {
var hintsWrapper = document.createElement('div');
hintsWrapper.className = 'introjs-hints';
}
for (var i = 0, l = this._introItems.length; i < l; i++) {
var item = this._introItems[i];
// avoid append a hint twice
if (document.querySelector('.introjs-hint[data-step="' + i + '"]')) continue;
var hint = document.createElement('a');
_setAnchorAsButton(hint);
(function(hint, item, i) {
// when user clicks on the hint element
hint.onclick = function(e) {
var evt = e ? e : window.event;
if (evt.stopPropagation) evt.stopPropagation();
if (evt.cancelBubble != null) evt.cancelBubble = true;
_showHintDialog.call(self, i);
};
})(hint, item, i);
hint.className = 'introjs-hint';
if (!item.hintAnimation) {
hint.className += ' introjs-hint-no-anim';
}
// hint's position should be fixed if the target element's position is fixed
if (_isFixed(item.element)) {
hint.className += ' introjs-fixedhint';
}
var hintDot = document.createElement('div');
hintDot.className = 'introjs-hint-dot';
var hintPulse = document.createElement('div');
hintPulse.className = 'introjs-hint-pulse';
hint.appendChild(hintDot);
hint.appendChild(hintPulse);
hint.setAttribute('data-step', i);
// we swap the hint element with target element
// because _setHelperLayerPosition uses `element` property
item.targetElement = item.element;
item.element = hint;
// align the hint position
_alignHintPosition.call(this, item.hintPosition, hint, item.targetElement);
hintsWrapper.appendChild(hint);
}
// adding the hints wrapper
document.body.appendChild(hintsWrapper);
// call the callback function (if any)
if (typeof this._hintsAddedCallback !== 'undefined') {
this._hintsAddedCallback.call(this);
}
} | [
"function",
"_addHints",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"oldHintsWrapper",
"=",
"document",
".",
"querySelector",
"(",
"'.introjs-hints'",
")",
";",
"if",
"(",
"oldHintsWrapper",
"!=",
"null",
")",
"{",
"hintsWrapper",
"=",
"oldHintsWrapper",
";",
"}",
"else",
"{",
"var",
"hintsWrapper",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"hintsWrapper",
".",
"className",
"=",
"'introjs-hints'",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"this",
".",
"_introItems",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"item",
"=",
"this",
".",
"_introItems",
"[",
"i",
"]",
";",
"// avoid append a hint twice",
"if",
"(",
"document",
".",
"querySelector",
"(",
"'.introjs-hint[data-step=\"'",
"+",
"i",
"+",
"'\"]'",
")",
")",
"continue",
";",
"var",
"hint",
"=",
"document",
".",
"createElement",
"(",
"'a'",
")",
";",
"_setAnchorAsButton",
"(",
"hint",
")",
";",
"(",
"function",
"(",
"hint",
",",
"item",
",",
"i",
")",
"{",
"// when user clicks on the hint element",
"hint",
".",
"onclick",
"=",
"function",
"(",
"e",
")",
"{",
"var",
"evt",
"=",
"e",
"?",
"e",
":",
"window",
".",
"event",
";",
"if",
"(",
"evt",
".",
"stopPropagation",
")",
"evt",
".",
"stopPropagation",
"(",
")",
";",
"if",
"(",
"evt",
".",
"cancelBubble",
"!=",
"null",
")",
"evt",
".",
"cancelBubble",
"=",
"true",
";",
"_showHintDialog",
".",
"call",
"(",
"self",
",",
"i",
")",
";",
"}",
";",
"}",
")",
"(",
"hint",
",",
"item",
",",
"i",
")",
";",
"hint",
".",
"className",
"=",
"'introjs-hint'",
";",
"if",
"(",
"!",
"item",
".",
"hintAnimation",
")",
"{",
"hint",
".",
"className",
"+=",
"' introjs-hint-no-anim'",
";",
"}",
"// hint's position should be fixed if the target element's position is fixed",
"if",
"(",
"_isFixed",
"(",
"item",
".",
"element",
")",
")",
"{",
"hint",
".",
"className",
"+=",
"' introjs-fixedhint'",
";",
"}",
"var",
"hintDot",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"hintDot",
".",
"className",
"=",
"'introjs-hint-dot'",
";",
"var",
"hintPulse",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"hintPulse",
".",
"className",
"=",
"'introjs-hint-pulse'",
";",
"hint",
".",
"appendChild",
"(",
"hintDot",
")",
";",
"hint",
".",
"appendChild",
"(",
"hintPulse",
")",
";",
"hint",
".",
"setAttribute",
"(",
"'data-step'",
",",
"i",
")",
";",
"// we swap the hint element with target element",
"// because _setHelperLayerPosition uses `element` property",
"item",
".",
"targetElement",
"=",
"item",
".",
"element",
";",
"item",
".",
"element",
"=",
"hint",
";",
"// align the hint position",
"_alignHintPosition",
".",
"call",
"(",
"this",
",",
"item",
".",
"hintPosition",
",",
"hint",
",",
"item",
".",
"targetElement",
")",
";",
"hintsWrapper",
".",
"appendChild",
"(",
"hint",
")",
";",
"}",
"// adding the hints wrapper",
"document",
".",
"body",
".",
"appendChild",
"(",
"hintsWrapper",
")",
";",
"// call the callback function (if any)",
"if",
"(",
"typeof",
"this",
".",
"_hintsAddedCallback",
"!==",
"'undefined'",
")",
"{",
"this",
".",
"_hintsAddedCallback",
".",
"call",
"(",
"this",
")",
";",
"}",
"}"
]
| Add all available hints to the page
@api private
@method _addHints | [
"Add",
"all",
"available",
"hints",
"to",
"the",
"page"
]
| 6e32220356e2aa336c36a8d2092db4ccddfdc328 | https://github.com/HasakiUI/hsk-jinx/blob/6e32220356e2aa336c36a8d2092db4ccddfdc328/src/component/intro/intro.js#L1794-L1864 |
39,448 | canjs/can-bind | can-bind.js | turnOffListeningAndUpdate | function turnOffListeningAndUpdate(listenToObservable, updateObservable, updateFunction, queue) {
var offValueOrOffEmitFn;
// Use either offValue or offEmit depending on which Symbols are on the `observable`
if (listenToObservable[onValueSymbol]) {
offValueOrOffEmitFn = canReflect.offValue;
} else if (listenToObservable[onEmitSymbol]) {
offValueOrOffEmitFn = offEmit;
}
if (offValueOrOffEmitFn) {
offValueOrOffEmitFn(listenToObservable, updateFunction, queue);
//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
// The updateObservable is no longer mutated by listenToObservable
canReflectDeps.deleteMutatedBy(updateObservable, listenToObservable);
// The updateFunction no longer mutates anything
updateFunction[getChangesSymbol] = function getChangesDependencyRecord() {
};
}
//!steal-remove-end
}
} | javascript | function turnOffListeningAndUpdate(listenToObservable, updateObservable, updateFunction, queue) {
var offValueOrOffEmitFn;
// Use either offValue or offEmit depending on which Symbols are on the `observable`
if (listenToObservable[onValueSymbol]) {
offValueOrOffEmitFn = canReflect.offValue;
} else if (listenToObservable[onEmitSymbol]) {
offValueOrOffEmitFn = offEmit;
}
if (offValueOrOffEmitFn) {
offValueOrOffEmitFn(listenToObservable, updateFunction, queue);
//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
// The updateObservable is no longer mutated by listenToObservable
canReflectDeps.deleteMutatedBy(updateObservable, listenToObservable);
// The updateFunction no longer mutates anything
updateFunction[getChangesSymbol] = function getChangesDependencyRecord() {
};
}
//!steal-remove-end
}
} | [
"function",
"turnOffListeningAndUpdate",
"(",
"listenToObservable",
",",
"updateObservable",
",",
"updateFunction",
",",
"queue",
")",
"{",
"var",
"offValueOrOffEmitFn",
";",
"// Use either offValue or offEmit depending on which Symbols are on the `observable`",
"if",
"(",
"listenToObservable",
"[",
"onValueSymbol",
"]",
")",
"{",
"offValueOrOffEmitFn",
"=",
"canReflect",
".",
"offValue",
";",
"}",
"else",
"if",
"(",
"listenToObservable",
"[",
"onEmitSymbol",
"]",
")",
"{",
"offValueOrOffEmitFn",
"=",
"offEmit",
";",
"}",
"if",
"(",
"offValueOrOffEmitFn",
")",
"{",
"offValueOrOffEmitFn",
"(",
"listenToObservable",
",",
"updateFunction",
",",
"queue",
")",
";",
"//!steal-remove-start",
"if",
"(",
"process",
".",
"env",
".",
"NODE_ENV",
"!==",
"'production'",
")",
"{",
"// The updateObservable is no longer mutated by listenToObservable",
"canReflectDeps",
".",
"deleteMutatedBy",
"(",
"updateObservable",
",",
"listenToObservable",
")",
";",
"// The updateFunction no longer mutates anything",
"updateFunction",
"[",
"getChangesSymbol",
"]",
"=",
"function",
"getChangesDependencyRecord",
"(",
")",
"{",
"}",
";",
"}",
"//!steal-remove-end",
"}",
"}"
]
| Given an observable, stop listening to it and tear down the mutation dependencies | [
"Given",
"an",
"observable",
"stop",
"listening",
"to",
"it",
"and",
"tear",
"down",
"the",
"mutation",
"dependencies"
]
| 22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761 | https://github.com/canjs/can-bind/blob/22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761/can-bind.js#L39-L65 |
39,449 | canjs/can-bind | can-bind.js | turnOnListeningAndUpdate | function turnOnListeningAndUpdate(listenToObservable, updateObservable, updateFunction, queue) {
var onValueOrOnEmitFn;
// Use either onValue or onEmit depending on which Symbols are on the `observable`
if (listenToObservable[onValueSymbol]) {
onValueOrOnEmitFn = canReflect.onValue;
} else if (listenToObservable[onEmitSymbol]) {
onValueOrOnEmitFn = onEmit;
}
if (onValueOrOnEmitFn) {
onValueOrOnEmitFn(listenToObservable, updateFunction, queue);
//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
// The updateObservable is mutated by listenToObservable
canReflectDeps.addMutatedBy(updateObservable, listenToObservable);
// The updateFunction mutates updateObservable
updateFunction[getChangesSymbol] = function getChangesDependencyRecord() {
var s = new Set();
s.add(updateObservable);
return {
valueDependencies: s
};
};
}
//!steal-remove-end
}
} | javascript | function turnOnListeningAndUpdate(listenToObservable, updateObservable, updateFunction, queue) {
var onValueOrOnEmitFn;
// Use either onValue or onEmit depending on which Symbols are on the `observable`
if (listenToObservable[onValueSymbol]) {
onValueOrOnEmitFn = canReflect.onValue;
} else if (listenToObservable[onEmitSymbol]) {
onValueOrOnEmitFn = onEmit;
}
if (onValueOrOnEmitFn) {
onValueOrOnEmitFn(listenToObservable, updateFunction, queue);
//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
// The updateObservable is mutated by listenToObservable
canReflectDeps.addMutatedBy(updateObservable, listenToObservable);
// The updateFunction mutates updateObservable
updateFunction[getChangesSymbol] = function getChangesDependencyRecord() {
var s = new Set();
s.add(updateObservable);
return {
valueDependencies: s
};
};
}
//!steal-remove-end
}
} | [
"function",
"turnOnListeningAndUpdate",
"(",
"listenToObservable",
",",
"updateObservable",
",",
"updateFunction",
",",
"queue",
")",
"{",
"var",
"onValueOrOnEmitFn",
";",
"// Use either onValue or onEmit depending on which Symbols are on the `observable`",
"if",
"(",
"listenToObservable",
"[",
"onValueSymbol",
"]",
")",
"{",
"onValueOrOnEmitFn",
"=",
"canReflect",
".",
"onValue",
";",
"}",
"else",
"if",
"(",
"listenToObservable",
"[",
"onEmitSymbol",
"]",
")",
"{",
"onValueOrOnEmitFn",
"=",
"onEmit",
";",
"}",
"if",
"(",
"onValueOrOnEmitFn",
")",
"{",
"onValueOrOnEmitFn",
"(",
"listenToObservable",
",",
"updateFunction",
",",
"queue",
")",
";",
"//!steal-remove-start",
"if",
"(",
"process",
".",
"env",
".",
"NODE_ENV",
"!==",
"'production'",
")",
"{",
"// The updateObservable is mutated by listenToObservable",
"canReflectDeps",
".",
"addMutatedBy",
"(",
"updateObservable",
",",
"listenToObservable",
")",
";",
"// The updateFunction mutates updateObservable",
"updateFunction",
"[",
"getChangesSymbol",
"]",
"=",
"function",
"getChangesDependencyRecord",
"(",
")",
"{",
"var",
"s",
"=",
"new",
"Set",
"(",
")",
";",
"s",
".",
"add",
"(",
"updateObservable",
")",
";",
"return",
"{",
"valueDependencies",
":",
"s",
"}",
";",
"}",
";",
"}",
"//!steal-remove-end",
"}",
"}"
]
| Given an observable, start listening to it and set up the mutation dependencies | [
"Given",
"an",
"observable",
"start",
"listening",
"to",
"it",
"and",
"set",
"up",
"the",
"mutation",
"dependencies"
]
| 22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761 | https://github.com/canjs/can-bind/blob/22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761/can-bind.js#L68-L100 |
39,450 | canjs/can-bind | can-bind.js | function() {
if (this._bindingState.child === false && this._childToParent === true) {
var options = this._options;
this._bindingState.child = true;
turnOnListeningAndUpdate(options.child, options.parent, this._updateParent, options.queue);
}
} | javascript | function() {
if (this._bindingState.child === false && this._childToParent === true) {
var options = this._options;
this._bindingState.child = true;
turnOnListeningAndUpdate(options.child, options.parent, this._updateParent, options.queue);
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_bindingState",
".",
"child",
"===",
"false",
"&&",
"this",
".",
"_childToParent",
"===",
"true",
")",
"{",
"var",
"options",
"=",
"this",
".",
"_options",
";",
"this",
".",
"_bindingState",
".",
"child",
"=",
"true",
";",
"turnOnListeningAndUpdate",
"(",
"options",
".",
"child",
",",
"options",
".",
"parent",
",",
"this",
".",
"_updateParent",
",",
"options",
".",
"queue",
")",
";",
"}",
"}"
]
| Listen for changes to the child observable and update the parent | [
"Listen",
"for",
"changes",
"to",
"the",
"child",
"observable",
"and",
"update",
"the",
"parent"
]
| 22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761 | https://github.com/canjs/can-bind/blob/22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761/can-bind.js#L402-L408 |
|
39,451 | canjs/can-bind | can-bind.js | function() {
if (this._bindingState.parent === false && this._parentToChild === true) {
var options = this._options;
this._bindingState.parent = true;
turnOnListeningAndUpdate(options.parent, options.child, this._updateChild, options.queue);
}
} | javascript | function() {
if (this._bindingState.parent === false && this._parentToChild === true) {
var options = this._options;
this._bindingState.parent = true;
turnOnListeningAndUpdate(options.parent, options.child, this._updateChild, options.queue);
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_bindingState",
".",
"parent",
"===",
"false",
"&&",
"this",
".",
"_parentToChild",
"===",
"true",
")",
"{",
"var",
"options",
"=",
"this",
".",
"_options",
";",
"this",
".",
"_bindingState",
".",
"parent",
"=",
"true",
";",
"turnOnListeningAndUpdate",
"(",
"options",
".",
"parent",
",",
"options",
".",
"child",
",",
"this",
".",
"_updateChild",
",",
"options",
".",
"queue",
")",
";",
"}",
"}"
]
| Listen for changes to the parent observable and update the child | [
"Listen",
"for",
"changes",
"to",
"the",
"parent",
"observable",
"and",
"update",
"the",
"child"
]
| 22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761 | https://github.com/canjs/can-bind/blob/22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761/can-bind.js#L411-L417 |
|
39,452 | canjs/can-bind | can-bind.js | function() {
var bindingState = this._bindingState;
var options = this._options;
// Turn off the parent listener
if (bindingState.parent === true && this._parentToChild === true) {
bindingState.parent = false;
turnOffListeningAndUpdate(options.parent, options.child, this._updateChild, options.queue);
}
// Turn off the child listener
if (bindingState.child === true && this._childToParent === true) {
bindingState.child = false;
turnOffListeningAndUpdate(options.child, options.parent, this._updateParent, options.queue);
}
} | javascript | function() {
var bindingState = this._bindingState;
var options = this._options;
// Turn off the parent listener
if (bindingState.parent === true && this._parentToChild === true) {
bindingState.parent = false;
turnOffListeningAndUpdate(options.parent, options.child, this._updateChild, options.queue);
}
// Turn off the child listener
if (bindingState.child === true && this._childToParent === true) {
bindingState.child = false;
turnOffListeningAndUpdate(options.child, options.parent, this._updateParent, options.queue);
}
} | [
"function",
"(",
")",
"{",
"var",
"bindingState",
"=",
"this",
".",
"_bindingState",
";",
"var",
"options",
"=",
"this",
".",
"_options",
";",
"// Turn off the parent listener",
"if",
"(",
"bindingState",
".",
"parent",
"===",
"true",
"&&",
"this",
".",
"_parentToChild",
"===",
"true",
")",
"{",
"bindingState",
".",
"parent",
"=",
"false",
";",
"turnOffListeningAndUpdate",
"(",
"options",
".",
"parent",
",",
"options",
".",
"child",
",",
"this",
".",
"_updateChild",
",",
"options",
".",
"queue",
")",
";",
"}",
"// Turn off the child listener",
"if",
"(",
"bindingState",
".",
"child",
"===",
"true",
"&&",
"this",
".",
"_childToParent",
"===",
"true",
")",
"{",
"bindingState",
".",
"child",
"=",
"false",
";",
"turnOffListeningAndUpdate",
"(",
"options",
".",
"child",
",",
"options",
".",
"parent",
",",
"this",
".",
"_updateParent",
",",
"options",
".",
"queue",
")",
";",
"}",
"}"
]
| Turn off all the bindings | [
"Turn",
"off",
"all",
"the",
"bindings"
]
| 22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761 | https://github.com/canjs/can-bind/blob/22be6557a5e2e1c5fc04bf4bca3eb6a16bdda761/can-bind.js#L420-L435 |
|
39,453 | verma/greyhound.js | lib/greyhound.js | function(mins, maxs) {
// make sure correct number of elements in both mins and maxs
if (mins.length != 3 ||
maxs.length != 3)
throw new Error("Mins and Maxs should have 3 elements each");
// make sure all maxes are greater than mins
mins.forEach(function(v, i) {
if (v >= maxs[i])
throw new Error("All elements of maxs should be greater than mins");
});
this.mins = mins;
this.maxs = maxs;
} | javascript | function(mins, maxs) {
// make sure correct number of elements in both mins and maxs
if (mins.length != 3 ||
maxs.length != 3)
throw new Error("Mins and Maxs should have 3 elements each");
// make sure all maxes are greater than mins
mins.forEach(function(v, i) {
if (v >= maxs[i])
throw new Error("All elements of maxs should be greater than mins");
});
this.mins = mins;
this.maxs = maxs;
} | [
"function",
"(",
"mins",
",",
"maxs",
")",
"{",
"// make sure correct number of elements in both mins and maxs",
"if",
"(",
"mins",
".",
"length",
"!=",
"3",
"||",
"maxs",
".",
"length",
"!=",
"3",
")",
"throw",
"new",
"Error",
"(",
"\"Mins and Maxs should have 3 elements each\"",
")",
";",
"// make sure all maxes are greater than mins",
"mins",
".",
"forEach",
"(",
"function",
"(",
"v",
",",
"i",
")",
"{",
"if",
"(",
"v",
">=",
"maxs",
"[",
"i",
"]",
")",
"throw",
"new",
"Error",
"(",
"\"All elements of maxs should be greater than mins\"",
")",
";",
"}",
")",
";",
"this",
".",
"mins",
"=",
"mins",
";",
"this",
".",
"maxs",
"=",
"maxs",
";",
"}"
]
| A bounding box abstraction class which can be passed to or returned by the reader. This bounding box is not a general
purpose bounding box, but is rather geared towards geo data. It is also, always axis aligned.
The ground is in the X,Y plane and Z represents the height, the Z coordinate is never touched when perfoming
splitting actions. Top refers to North, Left to West, Right to East and Bottom to South.
@class
@return {BBox} | [
"A",
"bounding",
"box",
"abstraction",
"class",
"which",
"can",
"be",
"passed",
"to",
"or",
"returned",
"by",
"the",
"reader",
".",
"This",
"bounding",
"box",
"is",
"not",
"a",
"general",
"purpose",
"bounding",
"box",
"but",
"is",
"rather",
"geared",
"towards",
"geo",
"data",
".",
"It",
"is",
"also",
"always",
"axis",
"aligned",
".",
"The",
"ground",
"is",
"in",
"the",
"X",
"Y",
"plane",
"and",
"Z",
"represents",
"the",
"height",
"the",
"Z",
"coordinate",
"is",
"never",
"touched",
"when",
"perfoming",
"splitting",
"actions",
".",
"Top",
"refers",
"to",
"North",
"Left",
"to",
"West",
"Right",
"to",
"East",
"and",
"Bottom",
"to",
"South",
"."
]
| d219b9eb9ec12af6a006f29d604543b61d2ae0a9 | https://github.com/verma/greyhound.js/blob/d219b9eb9ec12af6a006f29d604543b61d2ae0a9/lib/greyhound.js#L206-L220 |
|
39,454 | verma/greyhound.js | lib/greyhound.js | function(host) {
if (!host)
throw new Error('Need hostname to initialize reader');
if (host.match(/^(\S+):\/\//))
throw new Error('Protocol specified, need bare hostname');
this.host = host;
var portParts = this.host.match(/:(\d+)$/);
if (portParts !== null)
this.port = parseInt(portParts[1]);
else
this.port = 80;
// make sure port stuff is taken out of the host
//
var hostParts = this.host.match(/^(\S+):/);
if (hostParts)
this.host = hostParts[1];
} | javascript | function(host) {
if (!host)
throw new Error('Need hostname to initialize reader');
if (host.match(/^(\S+):\/\//))
throw new Error('Protocol specified, need bare hostname');
this.host = host;
var portParts = this.host.match(/:(\d+)$/);
if (portParts !== null)
this.port = parseInt(portParts[1]);
else
this.port = 80;
// make sure port stuff is taken out of the host
//
var hostParts = this.host.match(/^(\S+):/);
if (hostParts)
this.host = hostParts[1];
} | [
"function",
"(",
"host",
")",
"{",
"if",
"(",
"!",
"host",
")",
"throw",
"new",
"Error",
"(",
"'Need hostname to initialize reader'",
")",
";",
"if",
"(",
"host",
".",
"match",
"(",
"/",
"^(\\S+):\\/\\/",
"/",
")",
")",
"throw",
"new",
"Error",
"(",
"'Protocol specified, need bare hostname'",
")",
";",
"this",
".",
"host",
"=",
"host",
";",
"var",
"portParts",
"=",
"this",
".",
"host",
".",
"match",
"(",
"/",
":(\\d+)$",
"/",
")",
";",
"if",
"(",
"portParts",
"!==",
"null",
")",
"this",
".",
"port",
"=",
"parseInt",
"(",
"portParts",
"[",
"1",
"]",
")",
";",
"else",
"this",
".",
"port",
"=",
"80",
";",
"// make sure port stuff is taken out of the host",
"//",
"var",
"hostParts",
"=",
"this",
".",
"host",
".",
"match",
"(",
"/",
"^(\\S+):",
"/",
")",
";",
"if",
"(",
"hostParts",
")",
"this",
".",
"host",
"=",
"hostParts",
"[",
"1",
"]",
";",
"}"
]
| A greyhound data reader implementation. This class abstracts the details of reading data
from greyhound servers.
@example
var gh = new GrehoundReader("myserver.com");
// create a session
//
gh.createSession("pipelineid", function(err, id) {
// read some stats just for kicks
gh.getStats(id, function(err, stats) {
// print some informations
console.log("Mins:", stats.mins(), "Maxs:", stats.maxs());
// Read EVERYTHING
gh.read(id, function(err, data) {
// Do fun stuff with data
console.log("Read all the data");
// Finally destroy the session
gh.destroy(id, function(err) {
console.log("Bye");
// always a good practice to close this stuff
gh.close();
});
});
});
});
@class
@param {string} host - Should be a bare hostname with no protocol specified, but may specify a port name .e.g myserver.com:8012
@return {GreyhoundReader} When initialized with new, returns a new reader instance | [
"A",
"greyhound",
"data",
"reader",
"implementation",
".",
"This",
"class",
"abstracts",
"the",
"details",
"of",
"reading",
"data",
"from",
"greyhound",
"servers",
"."
]
| d219b9eb9ec12af6a006f29d604543b61d2ae0a9 | https://github.com/verma/greyhound.js/blob/d219b9eb9ec12af6a006f29d604543b61d2ae0a9/lib/greyhound.js#L426-L446 |
|
39,455 | owejs/owe | src/filter.js | filterGenerator | function filterGenerator(filter) {
if(typeof filter === "boolean")
return () => filter;
if(typeof filter === "function")
return filter;
if(filter instanceof RegExp)
return input => filter.test(input);
if(filter instanceof Set)
return input => filter.has(input);
if(filter instanceof Map)
return input => !!filter.get(input);
if(Array.isArray(filter))
return input => filter.indexOf(input) !== -1;
if(filter && typeof filter === "object")
return input => !!filter[input];
throw new TypeError("Invalid filter type.");
} | javascript | function filterGenerator(filter) {
if(typeof filter === "boolean")
return () => filter;
if(typeof filter === "function")
return filter;
if(filter instanceof RegExp)
return input => filter.test(input);
if(filter instanceof Set)
return input => filter.has(input);
if(filter instanceof Map)
return input => !!filter.get(input);
if(Array.isArray(filter))
return input => filter.indexOf(input) !== -1;
if(filter && typeof filter === "object")
return input => !!filter[input];
throw new TypeError("Invalid filter type.");
} | [
"function",
"filterGenerator",
"(",
"filter",
")",
"{",
"if",
"(",
"typeof",
"filter",
"===",
"\"boolean\"",
")",
"return",
"(",
")",
"=>",
"filter",
";",
"if",
"(",
"typeof",
"filter",
"===",
"\"function\"",
")",
"return",
"filter",
";",
"if",
"(",
"filter",
"instanceof",
"RegExp",
")",
"return",
"input",
"=>",
"filter",
".",
"test",
"(",
"input",
")",
";",
"if",
"(",
"filter",
"instanceof",
"Set",
")",
"return",
"input",
"=>",
"filter",
".",
"has",
"(",
"input",
")",
";",
"if",
"(",
"filter",
"instanceof",
"Map",
")",
"return",
"input",
"=>",
"!",
"!",
"filter",
".",
"get",
"(",
"input",
")",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"filter",
")",
")",
"return",
"input",
"=>",
"filter",
".",
"indexOf",
"(",
"input",
")",
"!==",
"-",
"1",
";",
"if",
"(",
"filter",
"&&",
"typeof",
"filter",
"===",
"\"object\"",
")",
"return",
"input",
"=>",
"!",
"!",
"filter",
"[",
"input",
"]",
";",
"throw",
"new",
"TypeError",
"(",
"\"Invalid filter type.\"",
")",
";",
"}"
]
| Generates a filter function out of the given filter.
@param {any} filter The filter.
@return {function} A filter function for `filter`. | [
"Generates",
"a",
"filter",
"function",
"out",
"of",
"the",
"given",
"filter",
"."
]
| 5e1ed342a9b2f20af4e633d706543da7f3a64b8a | https://github.com/owejs/owe/blob/5e1ed342a9b2f20af4e633d706543da7f3a64b8a/src/filter.js#L8-L31 |
39,456 | nearform/nscale-docker-ssh-analyzer | dockerApi.js | preconnect | function preconnect(user, sshKeyPath, ipaddress, cb, pollCount) {
if (pollCount === undefined) {
pollCount = 0;
}
logger.info({
user: user,
identityFile: sshKeyPath,
ipAddress: ipaddress
}, 'waiting for connectivity');
portscanner.checkPortStatus(22, ipaddress, function(err, status) {
if (status === 'closed') {
if (pollCount > MAX_POLLS) {
pollCount = 0;
cb('timeout exceeded - unable to connect to: ' + ipaddress);
}
else {
pollCount = pollCount + 1;
setTimeout(function() { preconnect(user, sshKeyPath, ipaddress, cb, pollCount); }, POLL_INTERVAL);
}
}
else if (status === 'open') {
pollCount = 0;
sshCheck.check(ipaddress, user, sshKeyPath, null, function(err) {
cb(err);
});
}
});
} | javascript | function preconnect(user, sshKeyPath, ipaddress, cb, pollCount) {
if (pollCount === undefined) {
pollCount = 0;
}
logger.info({
user: user,
identityFile: sshKeyPath,
ipAddress: ipaddress
}, 'waiting for connectivity');
portscanner.checkPortStatus(22, ipaddress, function(err, status) {
if (status === 'closed') {
if (pollCount > MAX_POLLS) {
pollCount = 0;
cb('timeout exceeded - unable to connect to: ' + ipaddress);
}
else {
pollCount = pollCount + 1;
setTimeout(function() { preconnect(user, sshKeyPath, ipaddress, cb, pollCount); }, POLL_INTERVAL);
}
}
else if (status === 'open') {
pollCount = 0;
sshCheck.check(ipaddress, user, sshKeyPath, null, function(err) {
cb(err);
});
}
});
} | [
"function",
"preconnect",
"(",
"user",
",",
"sshKeyPath",
",",
"ipaddress",
",",
"cb",
",",
"pollCount",
")",
"{",
"if",
"(",
"pollCount",
"===",
"undefined",
")",
"{",
"pollCount",
"=",
"0",
";",
"}",
"logger",
".",
"info",
"(",
"{",
"user",
":",
"user",
",",
"identityFile",
":",
"sshKeyPath",
",",
"ipAddress",
":",
"ipaddress",
"}",
",",
"'waiting for connectivity'",
")",
";",
"portscanner",
".",
"checkPortStatus",
"(",
"22",
",",
"ipaddress",
",",
"function",
"(",
"err",
",",
"status",
")",
"{",
"if",
"(",
"status",
"===",
"'closed'",
")",
"{",
"if",
"(",
"pollCount",
">",
"MAX_POLLS",
")",
"{",
"pollCount",
"=",
"0",
";",
"cb",
"(",
"'timeout exceeded - unable to connect to: '",
"+",
"ipaddress",
")",
";",
"}",
"else",
"{",
"pollCount",
"=",
"pollCount",
"+",
"1",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"preconnect",
"(",
"user",
",",
"sshKeyPath",
",",
"ipaddress",
",",
"cb",
",",
"pollCount",
")",
";",
"}",
",",
"POLL_INTERVAL",
")",
";",
"}",
"}",
"else",
"if",
"(",
"status",
"===",
"'open'",
")",
"{",
"pollCount",
"=",
"0",
";",
"sshCheck",
".",
"check",
"(",
"ipaddress",
",",
"user",
",",
"sshKeyPath",
",",
"null",
",",
"function",
"(",
"err",
")",
"{",
"cb",
"(",
"err",
")",
";",
"}",
")",
";",
"}",
"}",
")",
";",
"}"
]
| preconnect in the case that ssh multiplexing is operative | [
"preconnect",
"in",
"the",
"case",
"that",
"ssh",
"multiplexing",
"is",
"operative"
]
| 2e983b2e58ce40aba5842d0d97aea86a90654b02 | https://github.com/nearform/nscale-docker-ssh-analyzer/blob/2e983b2e58ce40aba5842d0d97aea86a90654b02/dockerApi.js#L58-L87 |
39,457 | seattleacademy/mcp9808 | examples/graph-webpage/js/main.js | UpdateChartData | function UpdateChartData()
{
while(Points > 10)
{
Points -= 1;
myLineChart.removeData();
}
myLineChart.addData([Data["Temperature"]], Math.floor((Date.now() - StartTime) / 1000.0));
myLineChart.update();
Points+=1;
} | javascript | function UpdateChartData()
{
while(Points > 10)
{
Points -= 1;
myLineChart.removeData();
}
myLineChart.addData([Data["Temperature"]], Math.floor((Date.now() - StartTime) / 1000.0));
myLineChart.update();
Points+=1;
} | [
"function",
"UpdateChartData",
"(",
")",
"{",
"while",
"(",
"Points",
">",
"10",
")",
"{",
"Points",
"-=",
"1",
";",
"myLineChart",
".",
"removeData",
"(",
")",
";",
"}",
"myLineChart",
".",
"addData",
"(",
"[",
"Data",
"[",
"\"Temperature\"",
"]",
"]",
",",
"Math",
".",
"floor",
"(",
"(",
"Date",
".",
"now",
"(",
")",
"-",
"StartTime",
")",
"/",
"1000.0",
")",
")",
";",
"myLineChart",
".",
"update",
"(",
")",
";",
"Points",
"+=",
"1",
";",
"}"
]
| update the chart function | [
"update",
"the",
"chart",
"function"
]
| 211c07158e0585dfc3c2149b1e5e93d105d89723 | https://github.com/seattleacademy/mcp9808/blob/211c07158e0585dfc3c2149b1e5e93d105d89723/examples/graph-webpage/js/main.js#L10-L22 |
39,458 | redturn/jsonresponse | lib/jsonresponse.js | function(err, results) {
if(err) {
this.success = false;
this.error = err;
this.results = null;
// customize error for error types
if(util.isError(err)) {
this.error = {
message: err.message,
type: err.type,
arguments: err.arguments
};
if(NODE_ENV === 'development') {
this.error.stack = err.stack;
}
}
} else {
this.success = true;
this.error = null;
this.results = convertToClient(results);
}
} | javascript | function(err, results) {
if(err) {
this.success = false;
this.error = err;
this.results = null;
// customize error for error types
if(util.isError(err)) {
this.error = {
message: err.message,
type: err.type,
arguments: err.arguments
};
if(NODE_ENV === 'development') {
this.error.stack = err.stack;
}
}
} else {
this.success = true;
this.error = null;
this.results = convertToClient(results);
}
} | [
"function",
"(",
"err",
",",
"results",
")",
"{",
"if",
"(",
"err",
")",
"{",
"this",
".",
"success",
"=",
"false",
";",
"this",
".",
"error",
"=",
"err",
";",
"this",
".",
"results",
"=",
"null",
";",
"// customize error for error types",
"if",
"(",
"util",
".",
"isError",
"(",
"err",
")",
")",
"{",
"this",
".",
"error",
"=",
"{",
"message",
":",
"err",
".",
"message",
",",
"type",
":",
"err",
".",
"type",
",",
"arguments",
":",
"err",
".",
"arguments",
"}",
";",
"if",
"(",
"NODE_ENV",
"===",
"'development'",
")",
"{",
"this",
".",
"error",
".",
"stack",
"=",
"err",
".",
"stack",
";",
"}",
"}",
"}",
"else",
"{",
"this",
".",
"success",
"=",
"true",
";",
"this",
".",
"error",
"=",
"null",
";",
"this",
".",
"results",
"=",
"convertToClient",
"(",
"results",
")",
";",
"}",
"}"
]
| Creates a uniform Json response object
@param err the optional error
@param results the optional results
@constructor | [
"Creates",
"a",
"uniform",
"Json",
"response",
"object"
]
| 2b8ca09784a3596c758e14230b4c1bb6111fd991 | https://github.com/redturn/jsonresponse/blob/2b8ca09784a3596c758e14230b4c1bb6111fd991/lib/jsonresponse.js#L10-L33 |
|
39,459 | iximiuz/js-itertools | lib/permutations.js | permutations | function permutations(iterable, r) {
// (ABCD, 2) -> AB AC AD BA BC BD CA CB CD DA DB DC
// (012, 3) -> 012 021 102 120 201 210
/*
0 1 2 3, 3
______
(0, 1, 2)
(0, 1, 3)
(0, 2, 1)
(0, 2, 3)
(0, 3, 1)
(0, 3, 2)
(1, 0, 2)
(1, 0, 3)
(1, 2, 0)
(1, 2, 3)
(1, 3, 0)
(1, 3, 2)
(2, 0, 1)
(2, 0, 3)
(2, 1, 0)
(2, 1, 3)
(2, 3, 0)
(2, 3, 1)
(3, 0, 1)
(3, 0, 2)
(3, 1, 0)
(3, 1, 2)
(3, 2, 0)
(3, 2, 1)
*/
var pool = tools.toArray(tools.ensureIter(iterable));
var n = pool.length;
r = r || n;
if (r > n) {
throw new Error(
'Parameter r cannot be greater than amount of elements in the iterable [' + n + ']'
);
}
var indices = tools.newArray(r, 0, 1);
function fromIndices() {
state.current = indices.map(function(idx) {
state.used[idx] = true;
return pool[idx];
});
}
function next() {
// 0. indices: 0, 1, 2
// 1. indices: 0, 1, 3
// 2. indices: 0, 1, 4 -> carry = t 0, 1, -1 -> 0, 1, 0 -> 0, 1, 1 -> 0, 1, 2
var backtrack = null;
var i = indices.length - 1;
for (; i >= 0; i--) {
indices[i]++;
if (indices[i] === n) {
// Time to reset current index and increase previous one.
if (i === 0) {
// There is no previous index, so it's the end of generation.
continue;
}
delete state.used[indices[i - 1]]; // Release previous index
backtrack = indices[i] - 1; // Pre-save current index to be able to release it in future.
indices[i] = -1; // Reset current index
i++;
continue;
}
if (state.used[indices[i]]) {
// Trying to increase current index until find the
// lowest free value or reach the end of the range.
i++;
continue;
}
// First free value found. Release previous one.
if (backtrack !== null) {
// If we need to backtrack, doing it!
delete state.used[backtrack];
backtrack = null;
continue;
}
// Otherwise exiting from the generation.
break;
}
if (i < 0) {
state.finished = true;
} else {
fromIndices();
}
}
var state = {current: null, finished: false, used: {}};
var permutIter = {
next: function() {
state.current
? next()
: fromIndices();
return {
done: state.finished,
value: state.finished
? undefined
: state.current
};
}
};
return tools.fuseIter(permutIter, function() { return permutIter; });
} | javascript | function permutations(iterable, r) {
// (ABCD, 2) -> AB AC AD BA BC BD CA CB CD DA DB DC
// (012, 3) -> 012 021 102 120 201 210
/*
0 1 2 3, 3
______
(0, 1, 2)
(0, 1, 3)
(0, 2, 1)
(0, 2, 3)
(0, 3, 1)
(0, 3, 2)
(1, 0, 2)
(1, 0, 3)
(1, 2, 0)
(1, 2, 3)
(1, 3, 0)
(1, 3, 2)
(2, 0, 1)
(2, 0, 3)
(2, 1, 0)
(2, 1, 3)
(2, 3, 0)
(2, 3, 1)
(3, 0, 1)
(3, 0, 2)
(3, 1, 0)
(3, 1, 2)
(3, 2, 0)
(3, 2, 1)
*/
var pool = tools.toArray(tools.ensureIter(iterable));
var n = pool.length;
r = r || n;
if (r > n) {
throw new Error(
'Parameter r cannot be greater than amount of elements in the iterable [' + n + ']'
);
}
var indices = tools.newArray(r, 0, 1);
function fromIndices() {
state.current = indices.map(function(idx) {
state.used[idx] = true;
return pool[idx];
});
}
function next() {
// 0. indices: 0, 1, 2
// 1. indices: 0, 1, 3
// 2. indices: 0, 1, 4 -> carry = t 0, 1, -1 -> 0, 1, 0 -> 0, 1, 1 -> 0, 1, 2
var backtrack = null;
var i = indices.length - 1;
for (; i >= 0; i--) {
indices[i]++;
if (indices[i] === n) {
// Time to reset current index and increase previous one.
if (i === 0) {
// There is no previous index, so it's the end of generation.
continue;
}
delete state.used[indices[i - 1]]; // Release previous index
backtrack = indices[i] - 1; // Pre-save current index to be able to release it in future.
indices[i] = -1; // Reset current index
i++;
continue;
}
if (state.used[indices[i]]) {
// Trying to increase current index until find the
// lowest free value or reach the end of the range.
i++;
continue;
}
// First free value found. Release previous one.
if (backtrack !== null) {
// If we need to backtrack, doing it!
delete state.used[backtrack];
backtrack = null;
continue;
}
// Otherwise exiting from the generation.
break;
}
if (i < 0) {
state.finished = true;
} else {
fromIndices();
}
}
var state = {current: null, finished: false, used: {}};
var permutIter = {
next: function() {
state.current
? next()
: fromIndices();
return {
done: state.finished,
value: state.finished
? undefined
: state.current
};
}
};
return tools.fuseIter(permutIter, function() { return permutIter; });
} | [
"function",
"permutations",
"(",
"iterable",
",",
"r",
")",
"{",
"// (ABCD, 2) -> AB AC AD BA BC BD CA CB CD DA DB DC",
"// (012, 3) -> 012 021 102 120 201 210",
"/*\n 0 1 2 3, 3\n ______\n (0, 1, 2)\n (0, 1, 3)\n (0, 2, 1)\n (0, 2, 3)\n (0, 3, 1)\n (0, 3, 2)\n (1, 0, 2)\n (1, 0, 3)\n (1, 2, 0)\n (1, 2, 3)\n (1, 3, 0)\n (1, 3, 2)\n (2, 0, 1)\n (2, 0, 3)\n (2, 1, 0)\n (2, 1, 3)\n (2, 3, 0)\n (2, 3, 1)\n (3, 0, 1)\n (3, 0, 2)\n (3, 1, 0)\n (3, 1, 2)\n (3, 2, 0)\n (3, 2, 1)\n*/",
"var",
"pool",
"=",
"tools",
".",
"toArray",
"(",
"tools",
".",
"ensureIter",
"(",
"iterable",
")",
")",
";",
"var",
"n",
"=",
"pool",
".",
"length",
";",
"r",
"=",
"r",
"||",
"n",
";",
"if",
"(",
"r",
">",
"n",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Parameter r cannot be greater than amount of elements in the iterable ['",
"+",
"n",
"+",
"']'",
")",
";",
"}",
"var",
"indices",
"=",
"tools",
".",
"newArray",
"(",
"r",
",",
"0",
",",
"1",
")",
";",
"function",
"fromIndices",
"(",
")",
"{",
"state",
".",
"current",
"=",
"indices",
".",
"map",
"(",
"function",
"(",
"idx",
")",
"{",
"state",
".",
"used",
"[",
"idx",
"]",
"=",
"true",
";",
"return",
"pool",
"[",
"idx",
"]",
";",
"}",
")",
";",
"}",
"function",
"next",
"(",
")",
"{",
"// 0. indices: 0, 1, 2",
"// 1. indices: 0, 1, 3",
"// 2. indices: 0, 1, 4 -> carry = t 0, 1, -1 -> 0, 1, 0 -> 0, 1, 1 -> 0, 1, 2",
"var",
"backtrack",
"=",
"null",
";",
"var",
"i",
"=",
"indices",
".",
"length",
"-",
"1",
";",
"for",
"(",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"indices",
"[",
"i",
"]",
"++",
";",
"if",
"(",
"indices",
"[",
"i",
"]",
"===",
"n",
")",
"{",
"// Time to reset current index and increase previous one.",
"if",
"(",
"i",
"===",
"0",
")",
"{",
"// There is no previous index, so it's the end of generation.",
"continue",
";",
"}",
"delete",
"state",
".",
"used",
"[",
"indices",
"[",
"i",
"-",
"1",
"]",
"]",
";",
"// Release previous index",
"backtrack",
"=",
"indices",
"[",
"i",
"]",
"-",
"1",
";",
"// Pre-save current index to be able to release it in future.",
"indices",
"[",
"i",
"]",
"=",
"-",
"1",
";",
"// Reset current index",
"i",
"++",
";",
"continue",
";",
"}",
"if",
"(",
"state",
".",
"used",
"[",
"indices",
"[",
"i",
"]",
"]",
")",
"{",
"// Trying to increase current index until find the",
"// lowest free value or reach the end of the range.",
"i",
"++",
";",
"continue",
";",
"}",
"// First free value found. Release previous one.",
"if",
"(",
"backtrack",
"!==",
"null",
")",
"{",
"// If we need to backtrack, doing it!",
"delete",
"state",
".",
"used",
"[",
"backtrack",
"]",
";",
"backtrack",
"=",
"null",
";",
"continue",
";",
"}",
"// Otherwise exiting from the generation.",
"break",
";",
"}",
"if",
"(",
"i",
"<",
"0",
")",
"{",
"state",
".",
"finished",
"=",
"true",
";",
"}",
"else",
"{",
"fromIndices",
"(",
")",
";",
"}",
"}",
"var",
"state",
"=",
"{",
"current",
":",
"null",
",",
"finished",
":",
"false",
",",
"used",
":",
"{",
"}",
"}",
";",
"var",
"permutIter",
"=",
"{",
"next",
":",
"function",
"(",
")",
"{",
"state",
".",
"current",
"?",
"next",
"(",
")",
":",
"fromIndices",
"(",
")",
";",
"return",
"{",
"done",
":",
"state",
".",
"finished",
",",
"value",
":",
"state",
".",
"finished",
"?",
"undefined",
":",
"state",
".",
"current",
"}",
";",
"}",
"}",
";",
"return",
"tools",
".",
"fuseIter",
"(",
"permutIter",
",",
"function",
"(",
")",
"{",
"return",
"permutIter",
";",
"}",
")",
";",
"}"
]
| Return successive r length permutations of elements in the iterable.
@param {Iterator|Iterable|Array|String} iterable
@param {Number} r - length of permutations.
@returns {Iterator|Iterable} | [
"Return",
"successive",
"r",
"length",
"permutations",
"of",
"elements",
"in",
"the",
"iterable",
"."
]
| a228cc89c39e959f0461a04cabb4f625bea1fe33 | https://github.com/iximiuz/js-itertools/blob/a228cc89c39e959f0461a04cabb4f625bea1fe33/lib/permutations.js#L12-L125 |
39,460 | lemonde/knex-schema | lib/drop.js | drop | function drop(schemas) {
var resolver = new Resolver(schemas);
var knex = this.knex;
return Promise.map(schemas || [], function(schema) {
return (schema.preDrop || _.noop)(knex);
})
.then(function () {
// Reduce force sequential execution.
return Promise.reduce(resolver.resolve().reverse(), dropSchema.bind(this), []);
}.bind(this));
} | javascript | function drop(schemas) {
var resolver = new Resolver(schemas);
var knex = this.knex;
return Promise.map(schemas || [], function(schema) {
return (schema.preDrop || _.noop)(knex);
})
.then(function () {
// Reduce force sequential execution.
return Promise.reduce(resolver.resolve().reverse(), dropSchema.bind(this), []);
}.bind(this));
} | [
"function",
"drop",
"(",
"schemas",
")",
"{",
"var",
"resolver",
"=",
"new",
"Resolver",
"(",
"schemas",
")",
";",
"var",
"knex",
"=",
"this",
".",
"knex",
";",
"return",
"Promise",
".",
"map",
"(",
"schemas",
"||",
"[",
"]",
",",
"function",
"(",
"schema",
")",
"{",
"return",
"(",
"schema",
".",
"preDrop",
"||",
"_",
".",
"noop",
")",
"(",
"knex",
")",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"// Reduce force sequential execution.",
"return",
"Promise",
".",
"reduce",
"(",
"resolver",
".",
"resolve",
"(",
")",
".",
"reverse",
"(",
")",
",",
"dropSchema",
".",
"bind",
"(",
"this",
")",
",",
"[",
"]",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
]
| Drop schemas tables. If it exists, it calls `preDrop` beforehand
@param {[Schemas]} schemas
@return {Promise} | [
"Drop",
"schemas",
"tables",
".",
"If",
"it",
"exists",
"it",
"calls",
"preDrop",
"beforehand"
]
| 3e0f6cde374d240552eb08e50e123a513fda44ae | https://github.com/lemonde/knex-schema/blob/3e0f6cde374d240552eb08e50e123a513fda44ae/lib/drop.js#L20-L30 |
39,461 | lemonde/knex-schema | lib/drop.js | dropSchema | function dropSchema(result, schema) {
return this.knex.schema.dropTableIfExists(schema.tableName)
.then(function () {
return result.concat([schema]);
});
} | javascript | function dropSchema(result, schema) {
return this.knex.schema.dropTableIfExists(schema.tableName)
.then(function () {
return result.concat([schema]);
});
} | [
"function",
"dropSchema",
"(",
"result",
",",
"schema",
")",
"{",
"return",
"this",
".",
"knex",
".",
"schema",
".",
"dropTableIfExists",
"(",
"schema",
".",
"tableName",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"result",
".",
"concat",
"(",
"[",
"schema",
"]",
")",
";",
"}",
")",
";",
"}"
]
| Drop schema table.
@param {[Schema]} result - reduce accumulator
@param {Schema} schema
@return {Promise} | [
"Drop",
"schema",
"table",
"."
]
| 3e0f6cde374d240552eb08e50e123a513fda44ae | https://github.com/lemonde/knex-schema/blob/3e0f6cde374d240552eb08e50e123a513fda44ae/lib/drop.js#L40-L45 |
39,462 | IDfr-Corporation/format-number-french | index.js | formatNumber | function formatNumber(value, options) {
options = options || {};
value += ''; // must be String Type
// not a number !!
if (!__isNumber(value)) {
return false;
}
var valueArr = __splitValue(value),
integer = valueArr[0],
negative = integer < 0,
absInteger = Math.abs(integer) + '',
formattedValue;
if (options.reduce) {
if (absInteger >= 100000 && absInteger <= 999999) {
options.prefix = 'k' + options.prefix;
integer = integer.slice(0, -3);
} else if (absInteger > 999999 && absInteger <= 9999999) {
options.prefix = 'Mio ' + options.prefix;
integer = negative ? '-' + absInteger[0] + ',' + absInteger[1] : absInteger[0] + ',' + absInteger[1];
} else if (absInteger > 9999999 && absInteger <= 999999999) {
options.prefix = 'Mio ' + options.prefix;
integer = integer.slice(0, -6);
} else if (absInteger > 999999999 && absInteger <= 9999999999) {
options.prefix = 'Mrd ' + options.prefix;
integer = integer.slice(0, -8);
integer = negative ? '-' + absInteger[0] + ',' + absInteger[1] : absInteger[0] + ',' + absInteger[1];
} else if (absInteger > 9999999999) {
options.prefix = 'Mrd ' + options.prefix;
integer = integer.slice(0, -9);
}
// add spaces
formattedValue = __addSpacesSeparator(integer);
} else {
// add spaces
valueArr[0] = __addSpacesSeparator(integer);
formattedValue = valueArr.join(',');
}
if (options.prefix) {
formattedValue += ' ' + options.prefix;
}
return formattedValue;
} | javascript | function formatNumber(value, options) {
options = options || {};
value += ''; // must be String Type
// not a number !!
if (!__isNumber(value)) {
return false;
}
var valueArr = __splitValue(value),
integer = valueArr[0],
negative = integer < 0,
absInteger = Math.abs(integer) + '',
formattedValue;
if (options.reduce) {
if (absInteger >= 100000 && absInteger <= 999999) {
options.prefix = 'k' + options.prefix;
integer = integer.slice(0, -3);
} else if (absInteger > 999999 && absInteger <= 9999999) {
options.prefix = 'Mio ' + options.prefix;
integer = negative ? '-' + absInteger[0] + ',' + absInteger[1] : absInteger[0] + ',' + absInteger[1];
} else if (absInteger > 9999999 && absInteger <= 999999999) {
options.prefix = 'Mio ' + options.prefix;
integer = integer.slice(0, -6);
} else if (absInteger > 999999999 && absInteger <= 9999999999) {
options.prefix = 'Mrd ' + options.prefix;
integer = integer.slice(0, -8);
integer = negative ? '-' + absInteger[0] + ',' + absInteger[1] : absInteger[0] + ',' + absInteger[1];
} else if (absInteger > 9999999999) {
options.prefix = 'Mrd ' + options.prefix;
integer = integer.slice(0, -9);
}
// add spaces
formattedValue = __addSpacesSeparator(integer);
} else {
// add spaces
valueArr[0] = __addSpacesSeparator(integer);
formattedValue = valueArr.join(',');
}
if (options.prefix) {
formattedValue += ' ' + options.prefix;
}
return formattedValue;
} | [
"function",
"formatNumber",
"(",
"value",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"value",
"+=",
"''",
";",
"// must be String Type",
"// not a number !!",
"if",
"(",
"!",
"__isNumber",
"(",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"var",
"valueArr",
"=",
"__splitValue",
"(",
"value",
")",
",",
"integer",
"=",
"valueArr",
"[",
"0",
"]",
",",
"negative",
"=",
"integer",
"<",
"0",
",",
"absInteger",
"=",
"Math",
".",
"abs",
"(",
"integer",
")",
"+",
"''",
",",
"formattedValue",
";",
"if",
"(",
"options",
".",
"reduce",
")",
"{",
"if",
"(",
"absInteger",
">=",
"100000",
"&&",
"absInteger",
"<=",
"999999",
")",
"{",
"options",
".",
"prefix",
"=",
"'k'",
"+",
"options",
".",
"prefix",
";",
"integer",
"=",
"integer",
".",
"slice",
"(",
"0",
",",
"-",
"3",
")",
";",
"}",
"else",
"if",
"(",
"absInteger",
">",
"999999",
"&&",
"absInteger",
"<=",
"9999999",
")",
"{",
"options",
".",
"prefix",
"=",
"'Mio '",
"+",
"options",
".",
"prefix",
";",
"integer",
"=",
"negative",
"?",
"'-'",
"+",
"absInteger",
"[",
"0",
"]",
"+",
"','",
"+",
"absInteger",
"[",
"1",
"]",
":",
"absInteger",
"[",
"0",
"]",
"+",
"','",
"+",
"absInteger",
"[",
"1",
"]",
";",
"}",
"else",
"if",
"(",
"absInteger",
">",
"9999999",
"&&",
"absInteger",
"<=",
"999999999",
")",
"{",
"options",
".",
"prefix",
"=",
"'Mio '",
"+",
"options",
".",
"prefix",
";",
"integer",
"=",
"integer",
".",
"slice",
"(",
"0",
",",
"-",
"6",
")",
";",
"}",
"else",
"if",
"(",
"absInteger",
">",
"999999999",
"&&",
"absInteger",
"<=",
"9999999999",
")",
"{",
"options",
".",
"prefix",
"=",
"'Mrd '",
"+",
"options",
".",
"prefix",
";",
"integer",
"=",
"integer",
".",
"slice",
"(",
"0",
",",
"-",
"8",
")",
";",
"integer",
"=",
"negative",
"?",
"'-'",
"+",
"absInteger",
"[",
"0",
"]",
"+",
"','",
"+",
"absInteger",
"[",
"1",
"]",
":",
"absInteger",
"[",
"0",
"]",
"+",
"','",
"+",
"absInteger",
"[",
"1",
"]",
";",
"}",
"else",
"if",
"(",
"absInteger",
">",
"9999999999",
")",
"{",
"options",
".",
"prefix",
"=",
"'Mrd '",
"+",
"options",
".",
"prefix",
";",
"integer",
"=",
"integer",
".",
"slice",
"(",
"0",
",",
"-",
"9",
")",
";",
"}",
"// add spaces",
"formattedValue",
"=",
"__addSpacesSeparator",
"(",
"integer",
")",
";",
"}",
"else",
"{",
"// add spaces",
"valueArr",
"[",
"0",
"]",
"=",
"__addSpacesSeparator",
"(",
"integer",
")",
";",
"formattedValue",
"=",
"valueArr",
".",
"join",
"(",
"','",
")",
";",
"}",
"if",
"(",
"options",
".",
"prefix",
")",
"{",
"formattedValue",
"+=",
"' '",
"+",
"options",
".",
"prefix",
";",
"}",
"return",
"formattedValue",
";",
"}"
]
| Return a well formatted number according to french rules
@param value
@param options | [
"Return",
"a",
"well",
"formatted",
"number",
"according",
"to",
"french",
"rules"
]
| 55dd37f034cbbb8f82ad964c1ae75975e396f642 | https://github.com/IDfr-Corporation/format-number-french/blob/55dd37f034cbbb8f82ad964c1ae75975e396f642/index.js#L21-L68 |
39,463 | IDfr-Corporation/format-number-french | index.js | __addSpacesSeparator | function __addSpacesSeparator(val) {
var reg = /(\d+)(\d{3})/,
sep = ' ';
// val must be a type String
val += '';
while (reg.test(val)) {
val = val.replace(reg, '$1' + sep + '$2');
}
return val;
} | javascript | function __addSpacesSeparator(val) {
var reg = /(\d+)(\d{3})/,
sep = ' ';
// val must be a type String
val += '';
while (reg.test(val)) {
val = val.replace(reg, '$1' + sep + '$2');
}
return val;
} | [
"function",
"__addSpacesSeparator",
"(",
"val",
")",
"{",
"var",
"reg",
"=",
"/",
"(\\d+)(\\d{3})",
"/",
",",
"sep",
"=",
"' '",
";",
"// val must be a type String",
"val",
"+=",
"''",
";",
"while",
"(",
"reg",
".",
"test",
"(",
"val",
")",
")",
"{",
"val",
"=",
"val",
".",
"replace",
"(",
"reg",
",",
"'$1'",
"+",
"sep",
"+",
"'$2'",
")",
";",
"}",
"return",
"val",
";",
"}"
]
| Add a space every three characters
@param val
@returns {string}
@private | [
"Add",
"a",
"space",
"every",
"three",
"characters"
]
| 55dd37f034cbbb8f82ad964c1ae75975e396f642 | https://github.com/IDfr-Corporation/format-number-french/blob/55dd37f034cbbb8f82ad964c1ae75975e396f642/index.js#L97-L107 |
39,464 | alexcjohnson/world-calendars | jquery-src/jquery.plugin.js | function(name, otherArgs) {
if (name === 'option' && (otherArgs.length === 0 ||
(otherArgs.length === 1 && typeof otherArgs[0] === 'string'))) {
return true;
}
return $.inArray(name, this._getters) > -1;
} | javascript | function(name, otherArgs) {
if (name === 'option' && (otherArgs.length === 0 ||
(otherArgs.length === 1 && typeof otherArgs[0] === 'string'))) {
return true;
}
return $.inArray(name, this._getters) > -1;
} | [
"function",
"(",
"name",
",",
"otherArgs",
")",
"{",
"if",
"(",
"name",
"===",
"'option'",
"&&",
"(",
"otherArgs",
".",
"length",
"===",
"0",
"||",
"(",
"otherArgs",
".",
"length",
"===",
"1",
"&&",
"typeof",
"otherArgs",
"[",
"0",
"]",
"===",
"'string'",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"$",
".",
"inArray",
"(",
"name",
",",
"this",
".",
"_getters",
")",
">",
"-",
"1",
";",
"}"
]
| Determine whether a method is a getter and doesn't permit chaining.
@private
@param name {string} The method name.
@param otherArgs {any[]} Any other arguments for the method.
@return {boolean} True if this method is a getter, false otherwise. | [
"Determine",
"whether",
"a",
"method",
"is",
"a",
"getter",
"and",
"doesn",
"t",
"permit",
"chaining",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.plugin.js#L155-L161 |
|
39,465 | alexcjohnson/world-calendars | jquery-src/jquery.plugin.js | function(elem, options) {
elem = $(elem);
if (elem.hasClass(this._getMarker())) {
return;
}
elem.addClass(this._getMarker());
options = $.extend({}, this.defaultOptions, this._getMetadata(elem), options || {});
var inst = $.extend({name: this.name, elem: elem, options: options},
this._instSettings(elem, options));
elem.data(this.name, inst); // Save instance against element
this._postAttach(elem, inst);
this.option(elem, options);
} | javascript | function(elem, options) {
elem = $(elem);
if (elem.hasClass(this._getMarker())) {
return;
}
elem.addClass(this._getMarker());
options = $.extend({}, this.defaultOptions, this._getMetadata(elem), options || {});
var inst = $.extend({name: this.name, elem: elem, options: options},
this._instSettings(elem, options));
elem.data(this.name, inst); // Save instance against element
this._postAttach(elem, inst);
this.option(elem, options);
} | [
"function",
"(",
"elem",
",",
"options",
")",
"{",
"elem",
"=",
"$",
"(",
"elem",
")",
";",
"if",
"(",
"elem",
".",
"hasClass",
"(",
"this",
".",
"_getMarker",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"elem",
".",
"addClass",
"(",
"this",
".",
"_getMarker",
"(",
")",
")",
";",
"options",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"this",
".",
"defaultOptions",
",",
"this",
".",
"_getMetadata",
"(",
"elem",
")",
",",
"options",
"||",
"{",
"}",
")",
";",
"var",
"inst",
"=",
"$",
".",
"extend",
"(",
"{",
"name",
":",
"this",
".",
"name",
",",
"elem",
":",
"elem",
",",
"options",
":",
"options",
"}",
",",
"this",
".",
"_instSettings",
"(",
"elem",
",",
"options",
")",
")",
";",
"elem",
".",
"data",
"(",
"this",
".",
"name",
",",
"inst",
")",
";",
"// Save instance against element",
"this",
".",
"_postAttach",
"(",
"elem",
",",
"inst",
")",
";",
"this",
".",
"option",
"(",
"elem",
",",
"options",
")",
";",
"}"
]
| Initialise an element. Called internally only.
Adds an instance object as data named for the plugin.
@param elem {Element} The element to enhance.
@param options {object} Overriding settings. | [
"Initialise",
"an",
"element",
".",
"Called",
"internally",
"only",
".",
"Adds",
"an",
"instance",
"object",
"as",
"data",
"named",
"for",
"the",
"plugin",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.plugin.js#L167-L179 |
|
39,466 | alexcjohnson/world-calendars | jquery-src/jquery.plugin.js | function(elem, name, value) {
elem = $(elem);
var inst = elem.data(this.name);
if (!name || (typeof name === 'string' && value == null)) {
var options = (inst || {}).options;
return (options && name ? options[name] : options);
}
if (!elem.hasClass(this._getMarker())) {
return;
}
var options = name || {};
if (typeof name === 'string') {
options = {};
options[name] = value;
}
this._optionsChanged(elem, inst, options);
$.extend(inst.options, options);
} | javascript | function(elem, name, value) {
elem = $(elem);
var inst = elem.data(this.name);
if (!name || (typeof name === 'string' && value == null)) {
var options = (inst || {}).options;
return (options && name ? options[name] : options);
}
if (!elem.hasClass(this._getMarker())) {
return;
}
var options = name || {};
if (typeof name === 'string') {
options = {};
options[name] = value;
}
this._optionsChanged(elem, inst, options);
$.extend(inst.options, options);
} | [
"function",
"(",
"elem",
",",
"name",
",",
"value",
")",
"{",
"elem",
"=",
"$",
"(",
"elem",
")",
";",
"var",
"inst",
"=",
"elem",
".",
"data",
"(",
"this",
".",
"name",
")",
";",
"if",
"(",
"!",
"name",
"||",
"(",
"typeof",
"name",
"===",
"'string'",
"&&",
"value",
"==",
"null",
")",
")",
"{",
"var",
"options",
"=",
"(",
"inst",
"||",
"{",
"}",
")",
".",
"options",
";",
"return",
"(",
"options",
"&&",
"name",
"?",
"options",
"[",
"name",
"]",
":",
"options",
")",
";",
"}",
"if",
"(",
"!",
"elem",
".",
"hasClass",
"(",
"this",
".",
"_getMarker",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"var",
"options",
"=",
"name",
"||",
"{",
"}",
";",
"if",
"(",
"typeof",
"name",
"===",
"'string'",
")",
"{",
"options",
"=",
"{",
"}",
";",
"options",
"[",
"name",
"]",
"=",
"value",
";",
"}",
"this",
".",
"_optionsChanged",
"(",
"elem",
",",
"inst",
",",
"options",
")",
";",
"$",
".",
"extend",
"(",
"inst",
".",
"options",
",",
"options",
")",
";",
"}"
]
| Retrieve or reconfigure the settings for a plugin.
@param elem {Element} The source element.
@param name {object|string} The collection of new option values or the name of a single option.
@param [value] {any} The value for a single named option.
@return {any|object} If retrieving a single value or all options.
@example $(selector).plugin('option', 'name', value)
$(selector).plugin('option', {name: value, ...})
var value = $(selector).plugin('option', 'name')
var options = $(selector).plugin('option') | [
"Retrieve",
"or",
"reconfigure",
"the",
"settings",
"for",
"a",
"plugin",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.plugin.js#L250-L267 |
|
39,467 | alexcjohnson/world-calendars | jquery-src/jquery.plugin.js | function(superClass, overrides) {
if (typeof superClass === 'object') {
overrides = superClass;
superClass = 'JQPlugin';
}
superClass = camelCase(superClass);
var className = camelCase(overrides.name);
JQClass.classes[className] = JQClass.classes[superClass].extend(overrides);
new JQClass.classes[className]();
} | javascript | function(superClass, overrides) {
if (typeof superClass === 'object') {
overrides = superClass;
superClass = 'JQPlugin';
}
superClass = camelCase(superClass);
var className = camelCase(overrides.name);
JQClass.classes[className] = JQClass.classes[superClass].extend(overrides);
new JQClass.classes[className]();
} | [
"function",
"(",
"superClass",
",",
"overrides",
")",
"{",
"if",
"(",
"typeof",
"superClass",
"===",
"'object'",
")",
"{",
"overrides",
"=",
"superClass",
";",
"superClass",
"=",
"'JQPlugin'",
";",
"}",
"superClass",
"=",
"camelCase",
"(",
"superClass",
")",
";",
"var",
"className",
"=",
"camelCase",
"(",
"overrides",
".",
"name",
")",
";",
"JQClass",
".",
"classes",
"[",
"className",
"]",
"=",
"JQClass",
".",
"classes",
"[",
"superClass",
"]",
".",
"extend",
"(",
"overrides",
")",
";",
"new",
"JQClass",
".",
"classes",
"[",
"className",
"]",
"(",
")",
";",
"}"
]
| Create a new collection plugin.
@memberof "$.JQPlugin"
@param [superClass='JQPlugin'] {string} The name of the parent class to inherit from.
@param overrides {object} The property/function overrides for the new class.
@example $.JQPlugin.createPlugin({
name: 'tabs',
defaultOptions: {selectedClass: 'selected'},
_initSettings: function(elem, options) { return {...}; },
_postAttach: function(elem, inst) { ... }
}); | [
"Create",
"a",
"new",
"collection",
"plugin",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.plugin.js#L332-L341 |
|
39,468 | ssulleyymmann/ng-all-login | docs/vendor.bundle.js | fingerprint | function fingerprint(str) {
var /** @type {?} */ utf8 = utf8Encode(str);
var _a = [hash32(utf8, 0), hash32(utf8, 102072)], hi = _a[0], lo = _a[1];
if (hi == 0 && (lo == 0 || lo == 1)) {
hi = hi ^ 0x130f9bef;
lo = lo ^ -0x6b5f56d8;
}
return [hi, lo];
} | javascript | function fingerprint(str) {
var /** @type {?} */ utf8 = utf8Encode(str);
var _a = [hash32(utf8, 0), hash32(utf8, 102072)], hi = _a[0], lo = _a[1];
if (hi == 0 && (lo == 0 || lo == 1)) {
hi = hi ^ 0x130f9bef;
lo = lo ^ -0x6b5f56d8;
}
return [hi, lo];
} | [
"function",
"fingerprint",
"(",
"str",
")",
"{",
"var",
"/** @type {?} */",
"utf8",
"=",
"utf8Encode",
"(",
"str",
")",
";",
"var",
"_a",
"=",
"[",
"hash32",
"(",
"utf8",
",",
"0",
")",
",",
"hash32",
"(",
"utf8",
",",
"102072",
")",
"]",
",",
"hi",
"=",
"_a",
"[",
"0",
"]",
",",
"lo",
"=",
"_a",
"[",
"1",
"]",
";",
"if",
"(",
"hi",
"==",
"0",
"&&",
"(",
"lo",
"==",
"0",
"||",
"lo",
"==",
"1",
")",
")",
"{",
"hi",
"=",
"hi",
"^",
"0x130f9bef",
";",
"lo",
"=",
"lo",
"^",
"-",
"0x6b5f56d8",
";",
"}",
"return",
"[",
"hi",
",",
"lo",
"]",
";",
"}"
]
| Compute the fingerprint of the given string
The output is 64 bit number encoded as a decimal string
based on:
https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java
@param {?} str
@return {?} | [
"Compute",
"the",
"fingerprint",
"of",
"the",
"given",
"string"
]
| 4aa73280c4858011894a416760bef34339ab11b1 | https://github.com/ssulleyymmann/ng-all-login/blob/4aa73280c4858011894a416760bef34339ab11b1/docs/vendor.bundle.js#L32838-L32846 |
39,469 | ssulleyymmann/ng-all-login | docs/vendor.bundle.js | _removeDotSegments | function _removeDotSegments(path) {
if (path == '/')
return '/';
var /** @type {?} */ leadingSlash = path[0] == '/' ? '/' : '';
var /** @type {?} */ trailingSlash = path[path.length - 1] === '/' ? '/' : '';
var /** @type {?} */ segments = path.split('/');
var /** @type {?} */ out = [];
var /** @type {?} */ up = 0;
for (var /** @type {?} */ pos = 0; pos < segments.length; pos++) {
var /** @type {?} */ segment = segments[pos];
switch (segment) {
case '':
case '.':
break;
case '..':
if (out.length > 0) {
out.pop();
}
else {
up++;
}
break;
default:
out.push(segment);
}
}
if (leadingSlash == '') {
while (up-- > 0) {
out.unshift('..');
}
if (out.length === 0)
out.push('.');
}
return leadingSlash + out.join('/') + trailingSlash;
} | javascript | function _removeDotSegments(path) {
if (path == '/')
return '/';
var /** @type {?} */ leadingSlash = path[0] == '/' ? '/' : '';
var /** @type {?} */ trailingSlash = path[path.length - 1] === '/' ? '/' : '';
var /** @type {?} */ segments = path.split('/');
var /** @type {?} */ out = [];
var /** @type {?} */ up = 0;
for (var /** @type {?} */ pos = 0; pos < segments.length; pos++) {
var /** @type {?} */ segment = segments[pos];
switch (segment) {
case '':
case '.':
break;
case '..':
if (out.length > 0) {
out.pop();
}
else {
up++;
}
break;
default:
out.push(segment);
}
}
if (leadingSlash == '') {
while (up-- > 0) {
out.unshift('..');
}
if (out.length === 0)
out.push('.');
}
return leadingSlash + out.join('/') + trailingSlash;
} | [
"function",
"_removeDotSegments",
"(",
"path",
")",
"{",
"if",
"(",
"path",
"==",
"'/'",
")",
"return",
"'/'",
";",
"var",
"/** @type {?} */",
"leadingSlash",
"=",
"path",
"[",
"0",
"]",
"==",
"'/'",
"?",
"'/'",
":",
"''",
";",
"var",
"/** @type {?} */",
"trailingSlash",
"=",
"path",
"[",
"path",
".",
"length",
"-",
"1",
"]",
"===",
"'/'",
"?",
"'/'",
":",
"''",
";",
"var",
"/** @type {?} */",
"segments",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
";",
"var",
"/** @type {?} */",
"out",
"=",
"[",
"]",
";",
"var",
"/** @type {?} */",
"up",
"=",
"0",
";",
"for",
"(",
"var",
"/** @type {?} */",
"pos",
"=",
"0",
";",
"pos",
"<",
"segments",
".",
"length",
";",
"pos",
"++",
")",
"{",
"var",
"/** @type {?} */",
"segment",
"=",
"segments",
"[",
"pos",
"]",
";",
"switch",
"(",
"segment",
")",
"{",
"case",
"''",
":",
"case",
"'.'",
":",
"break",
";",
"case",
"'..'",
":",
"if",
"(",
"out",
".",
"length",
">",
"0",
")",
"{",
"out",
".",
"pop",
"(",
")",
";",
"}",
"else",
"{",
"up",
"++",
";",
"}",
"break",
";",
"default",
":",
"out",
".",
"push",
"(",
"segment",
")",
";",
"}",
"}",
"if",
"(",
"leadingSlash",
"==",
"''",
")",
"{",
"while",
"(",
"up",
"--",
">",
"0",
")",
"{",
"out",
".",
"unshift",
"(",
"'..'",
")",
";",
"}",
"if",
"(",
"out",
".",
"length",
"===",
"0",
")",
"out",
".",
"push",
"(",
"'.'",
")",
";",
"}",
"return",
"leadingSlash",
"+",
"out",
".",
"join",
"(",
"'/'",
")",
"+",
"trailingSlash",
";",
"}"
]
| Removes dot segments in given path component, as described in
RFC 3986, section 5.2.4.
@param {?} path A non-empty path component.
@return {?} Path component with removed dot segments. | [
"Removes",
"dot",
"segments",
"in",
"given",
"path",
"component",
"as",
"described",
"in",
"RFC",
"3986",
"section",
"5",
".",
"2",
".",
"4",
"."
]
| 4aa73280c4858011894a416760bef34339ab11b1 | https://github.com/ssulleyymmann/ng-all-login/blob/4aa73280c4858011894a416760bef34339ab11b1/docs/vendor.bundle.js#L39097-L39131 |
39,470 | ssulleyymmann/ng-all-login | docs/vendor.bundle.js | convertPropertyBinding | function convertPropertyBinding(localResolver, implicitReceiver, expressionWithoutBuiltins, bindingId) {
if (!localResolver) {
localResolver = new DefaultLocalResolver();
}
var /** @type {?} */ currValExpr = createCurrValueExpr(bindingId);
var /** @type {?} */ stmts = [];
var /** @type {?} */ visitor = new _AstToIrVisitor(localResolver, implicitReceiver, bindingId);
var /** @type {?} */ outputExpr = expressionWithoutBuiltins.visit(visitor, _Mode.Expression);
if (visitor.temporaryCount) {
for (var /** @type {?} */ i = 0; i < visitor.temporaryCount; i++) {
stmts.push(temporaryDeclaration(bindingId, i));
}
}
stmts.push(currValExpr.set(outputExpr).toDeclStmt(null, [StmtModifier.Final]));
return new ConvertPropertyBindingResult(stmts, currValExpr);
} | javascript | function convertPropertyBinding(localResolver, implicitReceiver, expressionWithoutBuiltins, bindingId) {
if (!localResolver) {
localResolver = new DefaultLocalResolver();
}
var /** @type {?} */ currValExpr = createCurrValueExpr(bindingId);
var /** @type {?} */ stmts = [];
var /** @type {?} */ visitor = new _AstToIrVisitor(localResolver, implicitReceiver, bindingId);
var /** @type {?} */ outputExpr = expressionWithoutBuiltins.visit(visitor, _Mode.Expression);
if (visitor.temporaryCount) {
for (var /** @type {?} */ i = 0; i < visitor.temporaryCount; i++) {
stmts.push(temporaryDeclaration(bindingId, i));
}
}
stmts.push(currValExpr.set(outputExpr).toDeclStmt(null, [StmtModifier.Final]));
return new ConvertPropertyBindingResult(stmts, currValExpr);
} | [
"function",
"convertPropertyBinding",
"(",
"localResolver",
",",
"implicitReceiver",
",",
"expressionWithoutBuiltins",
",",
"bindingId",
")",
"{",
"if",
"(",
"!",
"localResolver",
")",
"{",
"localResolver",
"=",
"new",
"DefaultLocalResolver",
"(",
")",
";",
"}",
"var",
"/** @type {?} */",
"currValExpr",
"=",
"createCurrValueExpr",
"(",
"bindingId",
")",
";",
"var",
"/** @type {?} */",
"stmts",
"=",
"[",
"]",
";",
"var",
"/** @type {?} */",
"visitor",
"=",
"new",
"_AstToIrVisitor",
"(",
"localResolver",
",",
"implicitReceiver",
",",
"bindingId",
")",
";",
"var",
"/** @type {?} */",
"outputExpr",
"=",
"expressionWithoutBuiltins",
".",
"visit",
"(",
"visitor",
",",
"_Mode",
".",
"Expression",
")",
";",
"if",
"(",
"visitor",
".",
"temporaryCount",
")",
"{",
"for",
"(",
"var",
"/** @type {?} */",
"i",
"=",
"0",
";",
"i",
"<",
"visitor",
".",
"temporaryCount",
";",
"i",
"++",
")",
"{",
"stmts",
".",
"push",
"(",
"temporaryDeclaration",
"(",
"bindingId",
",",
"i",
")",
")",
";",
"}",
"}",
"stmts",
".",
"push",
"(",
"currValExpr",
".",
"set",
"(",
"outputExpr",
")",
".",
"toDeclStmt",
"(",
"null",
",",
"[",
"StmtModifier",
".",
"Final",
"]",
")",
")",
";",
"return",
"new",
"ConvertPropertyBindingResult",
"(",
"stmts",
",",
"currValExpr",
")",
";",
"}"
]
| Converts the given expression AST into an executable output AST, assuming the expression
is used in property binding. The expression has to be preprocessed via
`convertPropertyBindingBuiltins`.
@param {?} localResolver
@param {?} implicitReceiver
@param {?} expressionWithoutBuiltins
@param {?} bindingId
@return {?} | [
"Converts",
"the",
"given",
"expression",
"AST",
"into",
"an",
"executable",
"output",
"AST",
"assuming",
"the",
"expression",
"is",
"used",
"in",
"property",
"binding",
".",
"The",
"expression",
"has",
"to",
"be",
"preprocessed",
"via",
"convertPropertyBindingBuiltins",
"."
]
| 4aa73280c4858011894a416760bef34339ab11b1 | https://github.com/ssulleyymmann/ng-all-login/blob/4aa73280c4858011894a416760bef34339ab11b1/docs/vendor.bundle.js#L46432-L46447 |
39,471 | ssulleyymmann/ng-all-login | docs/vendor.bundle.js | Class | function Class(clsDef) {
var /** @type {?} */ constructor = applyParams(clsDef.hasOwnProperty('constructor') ? clsDef.constructor : undefined, 'constructor');
var /** @type {?} */ proto = constructor.prototype;
if (clsDef.hasOwnProperty('extends')) {
if (typeof clsDef.extends === 'function') {
((constructor)).prototype = proto =
Object.create(((clsDef.extends)).prototype);
}
else {
throw new Error("Class definition 'extends' property must be a constructor function was: " + stringify(clsDef.extends));
}
}
for (var /** @type {?} */ key in clsDef) {
if (key !== 'extends' && key !== 'prototype' && clsDef.hasOwnProperty(key)) {
proto[key] = applyParams(clsDef[key], key);
}
}
if (this && this.annotations instanceof Array) {
Reflect.defineMetadata('annotations', this.annotations, constructor);
}
var /** @type {?} */ constructorName = constructor['name'];
if (!constructorName || constructorName === 'constructor') {
((constructor))['overriddenName'] = "class" + _nextClassId++;
}
return (constructor);
} | javascript | function Class(clsDef) {
var /** @type {?} */ constructor = applyParams(clsDef.hasOwnProperty('constructor') ? clsDef.constructor : undefined, 'constructor');
var /** @type {?} */ proto = constructor.prototype;
if (clsDef.hasOwnProperty('extends')) {
if (typeof clsDef.extends === 'function') {
((constructor)).prototype = proto =
Object.create(((clsDef.extends)).prototype);
}
else {
throw new Error("Class definition 'extends' property must be a constructor function was: " + stringify(clsDef.extends));
}
}
for (var /** @type {?} */ key in clsDef) {
if (key !== 'extends' && key !== 'prototype' && clsDef.hasOwnProperty(key)) {
proto[key] = applyParams(clsDef[key], key);
}
}
if (this && this.annotations instanceof Array) {
Reflect.defineMetadata('annotations', this.annotations, constructor);
}
var /** @type {?} */ constructorName = constructor['name'];
if (!constructorName || constructorName === 'constructor') {
((constructor))['overriddenName'] = "class" + _nextClassId++;
}
return (constructor);
} | [
"function",
"Class",
"(",
"clsDef",
")",
"{",
"var",
"/** @type {?} */",
"constructor",
"=",
"applyParams",
"(",
"clsDef",
".",
"hasOwnProperty",
"(",
"'constructor'",
")",
"?",
"clsDef",
".",
"constructor",
":",
"undefined",
",",
"'constructor'",
")",
";",
"var",
"/** @type {?} */",
"proto",
"=",
"constructor",
".",
"prototype",
";",
"if",
"(",
"clsDef",
".",
"hasOwnProperty",
"(",
"'extends'",
")",
")",
"{",
"if",
"(",
"typeof",
"clsDef",
".",
"extends",
"===",
"'function'",
")",
"{",
"(",
"(",
"constructor",
")",
")",
".",
"prototype",
"=",
"proto",
"=",
"Object",
".",
"create",
"(",
"(",
"(",
"clsDef",
".",
"extends",
")",
")",
".",
"prototype",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"\"Class definition 'extends' property must be a constructor function was: \"",
"+",
"stringify",
"(",
"clsDef",
".",
"extends",
")",
")",
";",
"}",
"}",
"for",
"(",
"var",
"/** @type {?} */",
"key",
"in",
"clsDef",
")",
"{",
"if",
"(",
"key",
"!==",
"'extends'",
"&&",
"key",
"!==",
"'prototype'",
"&&",
"clsDef",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"proto",
"[",
"key",
"]",
"=",
"applyParams",
"(",
"clsDef",
"[",
"key",
"]",
",",
"key",
")",
";",
"}",
"}",
"if",
"(",
"this",
"&&",
"this",
".",
"annotations",
"instanceof",
"Array",
")",
"{",
"Reflect",
".",
"defineMetadata",
"(",
"'annotations'",
",",
"this",
".",
"annotations",
",",
"constructor",
")",
";",
"}",
"var",
"/** @type {?} */",
"constructorName",
"=",
"constructor",
"[",
"'name'",
"]",
";",
"if",
"(",
"!",
"constructorName",
"||",
"constructorName",
"===",
"'constructor'",
")",
"{",
"(",
"(",
"constructor",
")",
")",
"[",
"'overriddenName'",
"]",
"=",
"\"class\"",
"+",
"_nextClassId",
"++",
";",
"}",
"return",
"(",
"constructor",
")",
";",
"}"
]
| Provides a way for expressing ES6 classes with parameter annotations in ES5.
## Basic Example
```
var Greeter = ng.Class({
constructor: function(name) {
this.name = name;
},
greet: function() {
alert('Hello ' + this.name + '!');
}
});
```
is equivalent to ES6:
```
class Greeter {
constructor(name) {
this.name = name;
}
greet() {
alert('Hello ' + this.name + '!');
}
}
```
or equivalent to ES5:
```
var Greeter = function (name) {
this.name = name;
}
Greeter.prototype.greet = function () {
alert('Hello ' + this.name + '!');
}
```
### Example with parameter annotations
```
var MyService = ng.Class({
constructor: [String, [new Optional(), Service], function(name, myService) {
...
}]
});
```
is equivalent to ES6:
```
class MyService {
constructor(name: string, \@Optional() myService: Service) {
...
}
}
```
### Example with inheritance
```
var Shape = ng.Class({
constructor: (color) {
this.color = color;
}
});
var Square = ng.Class({
extends: Shape,
constructor: function(color, size) {
Shape.call(this, color);
this.size = size;
}
});
```
@suppress {globalThis}
\@stable
@param {?} clsDef
@return {?} | [
"Provides",
"a",
"way",
"for",
"expressing",
"ES6",
"classes",
"with",
"parameter",
"annotations",
"in",
"ES5",
"."
]
| 4aa73280c4858011894a416760bef34339ab11b1 | https://github.com/ssulleyymmann/ng-all-login/blob/4aa73280c4858011894a416760bef34339ab11b1/docs/vendor.bundle.js#L53307-L53332 |
39,472 | elmarburke/hoodie-plugin-angularjs | src/hoodieArray.js | mapFromArray | function mapFromArray(array, prop) {
var map = {};
for (var i = 0; i < array.length; i++) {
map[ array[i][prop] ] = array[i];
}
return map;
} | javascript | function mapFromArray(array, prop) {
var map = {};
for (var i = 0; i < array.length; i++) {
map[ array[i][prop] ] = array[i];
}
return map;
} | [
"function",
"mapFromArray",
"(",
"array",
",",
"prop",
")",
"{",
"var",
"map",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
";",
"i",
"++",
")",
"{",
"map",
"[",
"array",
"[",
"i",
"]",
"[",
"prop",
"]",
"]",
"=",
"array",
"[",
"i",
"]",
";",
"}",
"return",
"map",
";",
"}"
]
| Creates a map out of an array be choosing what property to key by
@param {object[]} array Array that will be converted into a map
@param {string} prop Name of property to key by
@return {object} The mapped array. Example:
mapFromArray([{a:1,b:2}, {a:3,b:4}], 'a')
returns {1: {a:1,b:2}, 3: {a:3,b:4}} | [
"Creates",
"a",
"map",
"out",
"of",
"an",
"array",
"be",
"choosing",
"what",
"property",
"to",
"key",
"by"
]
| 7f38248a0162ebea439e747d81a7423f43fd3cc8 | https://github.com/elmarburke/hoodie-plugin-angularjs/blob/7f38248a0162ebea439e747d81a7423f43fd3cc8/src/hoodieArray.js#L70-L76 |
39,473 | solid/contacts-pane | toolsPane.js | saveCleanPeople | function saveCleanPeople () {
var cleanPeople
return Promise.resolve()
.then(() => {
cleanPeople = kb.sym(stats.book.dir().uri + 'clean-people.ttl')
var sts = []
for (let i = 0; i < stats.uniques.length; i++) {
sts = sts.concat(kb.connectedStatements(stats.uniques[i], stats.nameEmailIndex))
}
var sz = (new $rdf.Serializer(kb)).setBase(stats.nameEmailIndex.uri)
log('Serializing index of uniques...')
var data = sz.statementsToN3(sts)
return kb.fetcher.webOperation('PUT', cleanPeople, { data: data, contentType: 'text/turtle' })
})
.then(function () {
log('Done uniques log ' + cleanPeople)
return true
})
.catch(function (e) {
log('Error saving uniques: ' + e)
})
} | javascript | function saveCleanPeople () {
var cleanPeople
return Promise.resolve()
.then(() => {
cleanPeople = kb.sym(stats.book.dir().uri + 'clean-people.ttl')
var sts = []
for (let i = 0; i < stats.uniques.length; i++) {
sts = sts.concat(kb.connectedStatements(stats.uniques[i], stats.nameEmailIndex))
}
var sz = (new $rdf.Serializer(kb)).setBase(stats.nameEmailIndex.uri)
log('Serializing index of uniques...')
var data = sz.statementsToN3(sts)
return kb.fetcher.webOperation('PUT', cleanPeople, { data: data, contentType: 'text/turtle' })
})
.then(function () {
log('Done uniques log ' + cleanPeople)
return true
})
.catch(function (e) {
log('Error saving uniques: ' + e)
})
} | [
"function",
"saveCleanPeople",
"(",
")",
"{",
"var",
"cleanPeople",
"return",
"Promise",
".",
"resolve",
"(",
")",
".",
"then",
"(",
"(",
")",
"=>",
"{",
"cleanPeople",
"=",
"kb",
".",
"sym",
"(",
"stats",
".",
"book",
".",
"dir",
"(",
")",
".",
"uri",
"+",
"'clean-people.ttl'",
")",
"var",
"sts",
"=",
"[",
"]",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"stats",
".",
"uniques",
".",
"length",
";",
"i",
"++",
")",
"{",
"sts",
"=",
"sts",
".",
"concat",
"(",
"kb",
".",
"connectedStatements",
"(",
"stats",
".",
"uniques",
"[",
"i",
"]",
",",
"stats",
".",
"nameEmailIndex",
")",
")",
"}",
"var",
"sz",
"=",
"(",
"new",
"$rdf",
".",
"Serializer",
"(",
"kb",
")",
")",
".",
"setBase",
"(",
"stats",
".",
"nameEmailIndex",
".",
"uri",
")",
"log",
"(",
"'Serializing index of uniques...'",
")",
"var",
"data",
"=",
"sz",
".",
"statementsToN3",
"(",
"sts",
")",
"return",
"kb",
".",
"fetcher",
".",
"webOperation",
"(",
"'PUT'",
",",
"cleanPeople",
",",
"{",
"data",
":",
"data",
",",
"contentType",
":",
"'text/turtle'",
"}",
")",
"}",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"log",
"(",
"'Done uniques log '",
"+",
"cleanPeople",
")",
"return",
"true",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"e",
")",
"{",
"log",
"(",
"'Error saving uniques: '",
"+",
"e",
")",
"}",
")",
"}"
]
| Save a new clean version | [
"Save",
"a",
"new",
"clean",
"version"
]
| 373c55fc6e2c584603741ee972d036fcb1e2f4b8 | https://github.com/solid/contacts-pane/blob/373c55fc6e2c584603741ee972d036fcb1e2f4b8/toolsPane.js#L465-L488 |
39,474 | alexcjohnson/world-calendars | dist/plus.js | function() {
if (value.charAt(iValue) !== format.charAt(iFormat)) {
throw (main.local.unexpectedLiteralAt ||
main.regionalOptions[''].unexpectedLiteralAt).replace(/\{0\}/, iValue);
}
iValue++;
} | javascript | function() {
if (value.charAt(iValue) !== format.charAt(iFormat)) {
throw (main.local.unexpectedLiteralAt ||
main.regionalOptions[''].unexpectedLiteralAt).replace(/\{0\}/, iValue);
}
iValue++;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"value",
".",
"charAt",
"(",
"iValue",
")",
"!==",
"format",
".",
"charAt",
"(",
"iFormat",
")",
")",
"{",
"throw",
"(",
"main",
".",
"local",
".",
"unexpectedLiteralAt",
"||",
"main",
".",
"regionalOptions",
"[",
"''",
"]",
".",
"unexpectedLiteralAt",
")",
".",
"replace",
"(",
"/",
"\\{0\\}",
"/",
",",
"iValue",
")",
";",
"}",
"iValue",
"++",
";",
"}"
]
| Confirm that a literal character matches the string value | [
"Confirm",
"that",
"a",
"literal",
"character",
"matches",
"the",
"string",
"value"
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/dist/plus.js#L369-L375 |
|
39,475 | sat-utils/sat-api-lib | libs/api.js | function (intersects) {
if (_.isString(intersects)) {
try {
intersects = JSON.parse(intersects);
} catch (e) {
throw new Error('Invalid Geojson');
}
}
return intersects;
} | javascript | function (intersects) {
if (_.isString(intersects)) {
try {
intersects = JSON.parse(intersects);
} catch (e) {
throw new Error('Invalid Geojson');
}
}
return intersects;
} | [
"function",
"(",
"intersects",
")",
"{",
"if",
"(",
"_",
".",
"isString",
"(",
"intersects",
")",
")",
"{",
"try",
"{",
"intersects",
"=",
"JSON",
".",
"parse",
"(",
"intersects",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Invalid Geojson'",
")",
";",
"}",
"}",
"return",
"intersects",
";",
"}"
]
| converts string intersect to js object | [
"converts",
"string",
"intersect",
"to",
"js",
"object"
]
| 74ef1cb09789ecc9c18512781a95eada6fdc3813 | https://github.com/sat-utils/sat-api-lib/blob/74ef1cb09789ecc9c18512781a95eada6fdc3813/libs/api.js#L11-L21 |
|
39,476 | XadillaX/illyria2 | benchmark/index.js | function(callback) {
server = illyria2.createServer();
server.expose("benchmark", {
echo: function(req, resp) {
resp.send(req.params());
}
});
server.listen(SERVER_PORT, function() {
callback();
});
} | javascript | function(callback) {
server = illyria2.createServer();
server.expose("benchmark", {
echo: function(req, resp) {
resp.send(req.params());
}
});
server.listen(SERVER_PORT, function() {
callback();
});
} | [
"function",
"(",
"callback",
")",
"{",
"server",
"=",
"illyria2",
".",
"createServer",
"(",
")",
";",
"server",
".",
"expose",
"(",
"\"benchmark\"",
",",
"{",
"echo",
":",
"function",
"(",
"req",
",",
"resp",
")",
"{",
"resp",
".",
"send",
"(",
"req",
".",
"params",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"server",
".",
"listen",
"(",
"SERVER_PORT",
",",
"function",
"(",
")",
"{",
"callback",
"(",
")",
";",
"}",
")",
";",
"}"
]
| step 1.
create server | [
"step",
"1",
".",
"create",
"server"
]
| ced0cc71cdcda11afcbab33f13739cbe547a2a17 | https://github.com/XadillaX/illyria2/blob/ced0cc71cdcda11afcbab33f13739cbe547a2a17/benchmark/index.js#L80-L90 |
|
39,477 | XadillaX/illyria2 | benchmark/index.js | function(callback) {
var scarlet = new Scarlet(Math.min(opts.n, 100));
function connect(taskObject) {
var client = taskObject.task.client;
var i = taskObject.task.idx;
client.connect(function() {
scarlet.taskDone(taskObject);
});
client.on("error", function(err) {
console.log(err + ": Client " + i);
});
}
console.time("Connect");
// if mode is `clients`, we create (opts.complicating) clients,
// otherwise we create only one.
var max = opts["complicating-mode"] === "clients" ? opts.complicating : 1;
for(var i = 0; i < max; i++) {
var client = illyria2.createClient("127.0.0.1", SERVER_PORT, {
runTimeout: 10000,
retryInterval: 1000,
reconnect: true
});
scarlet.push({ idx: i, client: client }, connect);
clients.push(client);
}
scarlet.afterFinish(max, function() {
console.timeEnd("Connect");
callback();
}, false);
} | javascript | function(callback) {
var scarlet = new Scarlet(Math.min(opts.n, 100));
function connect(taskObject) {
var client = taskObject.task.client;
var i = taskObject.task.idx;
client.connect(function() {
scarlet.taskDone(taskObject);
});
client.on("error", function(err) {
console.log(err + ": Client " + i);
});
}
console.time("Connect");
// if mode is `clients`, we create (opts.complicating) clients,
// otherwise we create only one.
var max = opts["complicating-mode"] === "clients" ? opts.complicating : 1;
for(var i = 0; i < max; i++) {
var client = illyria2.createClient("127.0.0.1", SERVER_PORT, {
runTimeout: 10000,
retryInterval: 1000,
reconnect: true
});
scarlet.push({ idx: i, client: client }, connect);
clients.push(client);
}
scarlet.afterFinish(max, function() {
console.timeEnd("Connect");
callback();
}, false);
} | [
"function",
"(",
"callback",
")",
"{",
"var",
"scarlet",
"=",
"new",
"Scarlet",
"(",
"Math",
".",
"min",
"(",
"opts",
".",
"n",
",",
"100",
")",
")",
";",
"function",
"connect",
"(",
"taskObject",
")",
"{",
"var",
"client",
"=",
"taskObject",
".",
"task",
".",
"client",
";",
"var",
"i",
"=",
"taskObject",
".",
"task",
".",
"idx",
";",
"client",
".",
"connect",
"(",
"function",
"(",
")",
"{",
"scarlet",
".",
"taskDone",
"(",
"taskObject",
")",
";",
"}",
")",
";",
"client",
".",
"on",
"(",
"\"error\"",
",",
"function",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"err",
"+",
"\": Client \"",
"+",
"i",
")",
";",
"}",
")",
";",
"}",
"console",
".",
"time",
"(",
"\"Connect\"",
")",
";",
"// if mode is `clients`, we create (opts.complicating) clients,",
"// otherwise we create only one.",
"var",
"max",
"=",
"opts",
"[",
"\"complicating-mode\"",
"]",
"===",
"\"clients\"",
"?",
"opts",
".",
"complicating",
":",
"1",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"max",
";",
"i",
"++",
")",
"{",
"var",
"client",
"=",
"illyria2",
".",
"createClient",
"(",
"\"127.0.0.1\"",
",",
"SERVER_PORT",
",",
"{",
"runTimeout",
":",
"10000",
",",
"retryInterval",
":",
"1000",
",",
"reconnect",
":",
"true",
"}",
")",
";",
"scarlet",
".",
"push",
"(",
"{",
"idx",
":",
"i",
",",
"client",
":",
"client",
"}",
",",
"connect",
")",
";",
"clients",
".",
"push",
"(",
"client",
")",
";",
"}",
"scarlet",
".",
"afterFinish",
"(",
"max",
",",
"function",
"(",
")",
"{",
"console",
".",
"timeEnd",
"(",
"\"Connect\"",
")",
";",
"callback",
"(",
")",
";",
"}",
",",
"false",
")",
";",
"}"
]
| step 2.
create clients and connect to server | [
"step",
"2",
".",
"create",
"clients",
"and",
"connect",
"to",
"server"
]
| ced0cc71cdcda11afcbab33f13739cbe547a2a17 | https://github.com/XadillaX/illyria2/blob/ced0cc71cdcda11afcbab33f13739cbe547a2a17/benchmark/index.js#L96-L133 |
|
39,478 | XadillaX/illyria2 | benchmark/index.js | function(callback) {
block = "";
for(var i = 0; i < opts.size; i++) block + ".";
testAbility(callback);
} | javascript | function(callback) {
block = "";
for(var i = 0; i < opts.size; i++) block + ".";
testAbility(callback);
} | [
"function",
"(",
"callback",
")",
"{",
"block",
"=",
"\"\"",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"opts",
".",
"size",
";",
"i",
"++",
")",
"block",
"+",
"\".\"",
";",
"testAbility",
"(",
"callback",
")",
";",
"}"
]
| step 3.
start testing | [
"step",
"3",
".",
"start",
"testing"
]
| ced0cc71cdcda11afcbab33f13739cbe547a2a17 | https://github.com/XadillaX/illyria2/blob/ced0cc71cdcda11afcbab33f13739cbe547a2a17/benchmark/index.js#L139-L143 |
|
39,479 | balderdashy/mast | dist/mast.dev.js | function (events, options) {
var eventKeys = _.keys(events || {}),
limitEvents,
parsedEvents = [];
// Optionally filter using set of acceptable event types
limitEvents = options.only;
eventKeys = _.filter(eventKeys, function checkEventName (eventKey) {
// Parse event string into semantic representation
var event = Events.parseDOMEvent(eventKey);
parsedEvents.push(event);
// Optional filter
if (limitEvents) {
return _.contains(limitEvents, event.name);
}
return true;
});
return parsedEvents;
} | javascript | function (events, options) {
var eventKeys = _.keys(events || {}),
limitEvents,
parsedEvents = [];
// Optionally filter using set of acceptable event types
limitEvents = options.only;
eventKeys = _.filter(eventKeys, function checkEventName (eventKey) {
// Parse event string into semantic representation
var event = Events.parseDOMEvent(eventKey);
parsedEvents.push(event);
// Optional filter
if (limitEvents) {
return _.contains(limitEvents, event.name);
}
return true;
});
return parsedEvents;
} | [
"function",
"(",
"events",
",",
"options",
")",
"{",
"var",
"eventKeys",
"=",
"_",
".",
"keys",
"(",
"events",
"||",
"{",
"}",
")",
",",
"limitEvents",
",",
"parsedEvents",
"=",
"[",
"]",
";",
"// Optionally filter using set of acceptable event types",
"limitEvents",
"=",
"options",
".",
"only",
";",
"eventKeys",
"=",
"_",
".",
"filter",
"(",
"eventKeys",
",",
"function",
"checkEventName",
"(",
"eventKey",
")",
"{",
"// Parse event string into semantic representation",
"var",
"event",
"=",
"Events",
".",
"parseDOMEvent",
"(",
"eventKey",
")",
";",
"parsedEvents",
".",
"push",
"(",
"event",
")",
";",
"// Optional filter",
"if",
"(",
"limitEvents",
")",
"{",
"return",
"_",
".",
"contains",
"(",
"limitEvents",
",",
"event",
".",
"name",
")",
";",
"}",
"return",
"true",
";",
"}",
")",
";",
"return",
"parsedEvents",
";",
"}"
]
| Parses a dictionary of events and optionally filters by the event type. If the event
@param {Object} events [A Backbone.View events object]
@param {Object} options [Options object that allows us to filter parsing to certain event
names]
@return {Array} [Array containing parsedEvents that are matching event keys] | [
"Parses",
"a",
"dictionary",
"of",
"events",
"and",
"optionally",
"filters",
"by",
"the",
"event",
"type",
".",
"If",
"the",
"event"
]
| 6fc2b07849ec6a6fe15f66e456e556e5270ed37f | https://github.com/balderdashy/mast/blob/6fc2b07849ec6a6fe15f66e456e556e5270ed37f/dist/mast.dev.js#L2350-L2372 |
|
39,480 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(inst) {
var maxDate = inst.get('maxDate');
return (!maxDate || inst.drawDate.newDate().
add(inst.options.monthsToJump - inst.options.monthsOffset, 'm').
day(inst.options.calendar.minDay).compareTo(maxDate) !== +1); } | javascript | function(inst) {
var maxDate = inst.get('maxDate');
return (!maxDate || inst.drawDate.newDate().
add(inst.options.monthsToJump - inst.options.monthsOffset, 'm').
day(inst.options.calendar.minDay).compareTo(maxDate) !== +1); } | [
"function",
"(",
"inst",
")",
"{",
"var",
"maxDate",
"=",
"inst",
".",
"get",
"(",
"'maxDate'",
")",
";",
"return",
"(",
"!",
"maxDate",
"||",
"inst",
".",
"drawDate",
".",
"newDate",
"(",
")",
".",
"add",
"(",
"inst",
".",
"options",
".",
"monthsToJump",
"-",
"inst",
".",
"options",
".",
"monthsOffset",
",",
"'m'",
")",
".",
"day",
"(",
"inst",
".",
"options",
".",
"calendar",
".",
"minDay",
")",
".",
"compareTo",
"(",
"maxDate",
")",
"!==",
"+",
"1",
")",
";",
"}"
]
| Ctrl + Page down | [
"Ctrl",
"+",
"Page",
"down"
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L164-L168 |
|
39,481 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(inst) {
var minDate = inst.curMinDate();
var maxDate = inst.get('maxDate');
var curDate = inst.selectedDates[0] || inst.options.calendar.today();
return (!minDate || curDate.compareTo(minDate) !== -1) &&
(!maxDate || curDate.compareTo(maxDate) !== +1); } | javascript | function(inst) {
var minDate = inst.curMinDate();
var maxDate = inst.get('maxDate');
var curDate = inst.selectedDates[0] || inst.options.calendar.today();
return (!minDate || curDate.compareTo(minDate) !== -1) &&
(!maxDate || curDate.compareTo(maxDate) !== +1); } | [
"function",
"(",
"inst",
")",
"{",
"var",
"minDate",
"=",
"inst",
".",
"curMinDate",
"(",
")",
";",
"var",
"maxDate",
"=",
"inst",
".",
"get",
"(",
"'maxDate'",
")",
";",
"var",
"curDate",
"=",
"inst",
".",
"selectedDates",
"[",
"0",
"]",
"||",
"inst",
".",
"options",
".",
"calendar",
".",
"today",
"(",
")",
";",
"return",
"(",
"!",
"minDate",
"||",
"curDate",
".",
"compareTo",
"(",
"minDate",
")",
"!==",
"-",
"1",
")",
"&&",
"(",
"!",
"maxDate",
"||",
"curDate",
".",
"compareTo",
"(",
"maxDate",
")",
"!==",
"+",
"1",
")",
";",
"}"
]
| Ctrl + Home | [
"Ctrl",
"+",
"Home"
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L178-L183 |
|
39,482 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(inst) {
var minDate = inst.curMinDate();
return (!minDate || inst.drawDate.newDate().
add(-inst.options.calendar.daysInWeek(), 'd').compareTo(minDate) !== -1); } | javascript | function(inst) {
var minDate = inst.curMinDate();
return (!minDate || inst.drawDate.newDate().
add(-inst.options.calendar.daysInWeek(), 'd').compareTo(minDate) !== -1); } | [
"function",
"(",
"inst",
")",
"{",
"var",
"minDate",
"=",
"inst",
".",
"curMinDate",
"(",
")",
";",
"return",
"(",
"!",
"minDate",
"||",
"inst",
".",
"drawDate",
".",
"newDate",
"(",
")",
".",
"add",
"(",
"-",
"inst",
".",
"options",
".",
"calendar",
".",
"daysInWeek",
"(",
")",
",",
"'d'",
")",
".",
"compareTo",
"(",
"minDate",
")",
"!==",
"-",
"1",
")",
";",
"}"
]
| Ctrl + Up | [
"Ctrl",
"+",
"Up"
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L214-L217 |
|
39,483 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(inst) {
var minDate = inst.curMinDate();
return (!minDate || inst.drawDate.newDate().add(-1, 'd').
compareTo(minDate) !== -1); } | javascript | function(inst) {
var minDate = inst.curMinDate();
return (!minDate || inst.drawDate.newDate().add(-1, 'd').
compareTo(minDate) !== -1); } | [
"function",
"(",
"inst",
")",
"{",
"var",
"minDate",
"=",
"inst",
".",
"curMinDate",
"(",
")",
";",
"return",
"(",
"!",
"minDate",
"||",
"inst",
".",
"drawDate",
".",
"newDate",
"(",
")",
".",
"add",
"(",
"-",
"1",
",",
"'d'",
")",
".",
"compareTo",
"(",
"minDate",
")",
"!==",
"-",
"1",
")",
";",
"}"
]
| Ctrl + Left | [
"Ctrl",
"+",
"Left"
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L224-L227 |
|
39,484 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(inst) {
var maxDate = inst.get('maxDate');
return (!maxDate || inst.drawDate.newDate().add(1, 'd').
compareTo(maxDate) !== +1); } | javascript | function(inst) {
var maxDate = inst.get('maxDate');
return (!maxDate || inst.drawDate.newDate().add(1, 'd').
compareTo(maxDate) !== +1); } | [
"function",
"(",
"inst",
")",
"{",
"var",
"maxDate",
"=",
"inst",
".",
"get",
"(",
"'maxDate'",
")",
";",
"return",
"(",
"!",
"maxDate",
"||",
"inst",
".",
"drawDate",
".",
"newDate",
"(",
")",
".",
"add",
"(",
"1",
",",
"'d'",
")",
".",
"compareTo",
"(",
"maxDate",
")",
"!==",
"+",
"1",
")",
";",
"}"
]
| Ctrl + Right | [
"Ctrl",
"+",
"Right"
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L233-L236 |
|
39,485 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(inst) {
var maxDate = inst.get('maxDate');
return (!maxDate || inst.drawDate.newDate().
add(inst.options.calendar.daysInWeek(), 'd').compareTo(maxDate) !== +1); } | javascript | function(inst) {
var maxDate = inst.get('maxDate');
return (!maxDate || inst.drawDate.newDate().
add(inst.options.calendar.daysInWeek(), 'd').compareTo(maxDate) !== +1); } | [
"function",
"(",
"inst",
")",
"{",
"var",
"maxDate",
"=",
"inst",
".",
"get",
"(",
"'maxDate'",
")",
";",
"return",
"(",
"!",
"maxDate",
"||",
"inst",
".",
"drawDate",
".",
"newDate",
"(",
")",
".",
"add",
"(",
"inst",
".",
"options",
".",
"calendar",
".",
"daysInWeek",
"(",
")",
",",
"'d'",
")",
".",
"compareTo",
"(",
"maxDate",
")",
"!==",
"+",
"1",
")",
";",
"}"
]
| Ctrl + Down | [
"Ctrl",
"+",
"Down"
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L242-L245 |
|
39,486 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem, inst) {
elem.off('focus.' + inst.name);
if (inst.options.showOnFocus) {
elem.on('focus.' + inst.name, this.show);
}
if (inst.trigger) {
inst.trigger.remove();
}
var trigger = inst.options.showTrigger;
inst.trigger = (!trigger ? $([]) :
$(trigger).clone().removeAttr('id').addClass(this._triggerClass)
[inst.options.isRTL ? 'insertBefore' : 'insertAfter'](elem).
click(function() {
if (!plugin.isDisabled(elem[0])) {
plugin[plugin.curInst === inst ? 'hide' : 'show'](elem[0]);
}
}));
this._autoSize(elem, inst);
var dates = this._extractDates(inst, elem.val());
if (dates) {
this.setDate(elem[0], dates, null, true);
}
var defaultDate = inst.get('defaultDate');
if (inst.options.selectDefaultDate && defaultDate && inst.selectedDates.length === 0) {
this.setDate(elem[0], (defaultDate || inst.options.calendar.today()).newDate());
}
} | javascript | function(elem, inst) {
elem.off('focus.' + inst.name);
if (inst.options.showOnFocus) {
elem.on('focus.' + inst.name, this.show);
}
if (inst.trigger) {
inst.trigger.remove();
}
var trigger = inst.options.showTrigger;
inst.trigger = (!trigger ? $([]) :
$(trigger).clone().removeAttr('id').addClass(this._triggerClass)
[inst.options.isRTL ? 'insertBefore' : 'insertAfter'](elem).
click(function() {
if (!plugin.isDisabled(elem[0])) {
plugin[plugin.curInst === inst ? 'hide' : 'show'](elem[0]);
}
}));
this._autoSize(elem, inst);
var dates = this._extractDates(inst, elem.val());
if (dates) {
this.setDate(elem[0], dates, null, true);
}
var defaultDate = inst.get('defaultDate');
if (inst.options.selectDefaultDate && defaultDate && inst.selectedDates.length === 0) {
this.setDate(elem[0], (defaultDate || inst.options.calendar.today()).newDate());
}
} | [
"function",
"(",
"elem",
",",
"inst",
")",
"{",
"elem",
".",
"off",
"(",
"'focus.'",
"+",
"inst",
".",
"name",
")",
";",
"if",
"(",
"inst",
".",
"options",
".",
"showOnFocus",
")",
"{",
"elem",
".",
"on",
"(",
"'focus.'",
"+",
"inst",
".",
"name",
",",
"this",
".",
"show",
")",
";",
"}",
"if",
"(",
"inst",
".",
"trigger",
")",
"{",
"inst",
".",
"trigger",
".",
"remove",
"(",
")",
";",
"}",
"var",
"trigger",
"=",
"inst",
".",
"options",
".",
"showTrigger",
";",
"inst",
".",
"trigger",
"=",
"(",
"!",
"trigger",
"?",
"$",
"(",
"[",
"]",
")",
":",
"$",
"(",
"trigger",
")",
".",
"clone",
"(",
")",
".",
"removeAttr",
"(",
"'id'",
")",
".",
"addClass",
"(",
"this",
".",
"_triggerClass",
")",
"[",
"inst",
".",
"options",
".",
"isRTL",
"?",
"'insertBefore'",
":",
"'insertAfter'",
"]",
"(",
"elem",
")",
".",
"click",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"plugin",
".",
"isDisabled",
"(",
"elem",
"[",
"0",
"]",
")",
")",
"{",
"plugin",
"[",
"plugin",
".",
"curInst",
"===",
"inst",
"?",
"'hide'",
":",
"'show'",
"]",
"(",
"elem",
"[",
"0",
"]",
")",
";",
"}",
"}",
")",
")",
";",
"this",
".",
"_autoSize",
"(",
"elem",
",",
"inst",
")",
";",
"var",
"dates",
"=",
"this",
".",
"_extractDates",
"(",
"inst",
",",
"elem",
".",
"val",
"(",
")",
")",
";",
"if",
"(",
"dates",
")",
"{",
"this",
".",
"setDate",
"(",
"elem",
"[",
"0",
"]",
",",
"dates",
",",
"null",
",",
"true",
")",
";",
"}",
"var",
"defaultDate",
"=",
"inst",
".",
"get",
"(",
"'defaultDate'",
")",
";",
"if",
"(",
"inst",
".",
"options",
".",
"selectDefaultDate",
"&&",
"defaultDate",
"&&",
"inst",
".",
"selectedDates",
".",
"length",
"===",
"0",
")",
"{",
"this",
".",
"setDate",
"(",
"elem",
"[",
"0",
"]",
",",
"(",
"defaultDate",
"||",
"inst",
".",
"options",
".",
"calendar",
".",
"today",
"(",
")",
")",
".",
"newDate",
"(",
")",
")",
";",
"}",
"}"
]
| Attach events and trigger, if necessary.
@memberof CalendarsPicker
@private
@param elem {jQuery} The control to affect.
@param inst {object} The current instance settings. | [
"Attach",
"events",
"and",
"trigger",
"if",
"necessary",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L585-L611 |
|
39,487 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem, inst) {
if (inst.options.autoSize && !inst.inline) {
var calendar = inst.options.calendar;
var date = calendar.newDate(2009, 10, 20); // Ensure double digits
var dateFormat = inst.get('dateFormat');
if (dateFormat.match(/[DM]/)) {
var findMax = function(names) {
var max = 0;
var maxI = 0;
for (var i = 0; i < names.length; i++) {
if (names[i].length > max) {
max = names[i].length;
maxI = i;
}
}
return maxI;
};
date.month(findMax(calendar.local[dateFormat.match(/MM/) ? // Longest month
'monthNames' : 'monthNamesShort']) + 1);
date.day(findMax(calendar.local[dateFormat.match(/DD/) ? // Longest day
'dayNames' : 'dayNamesShort']) + 20 - date.dayOfWeek());
}
inst.elem.attr('size', date.formatDate(dateFormat,
{localNumbers: inst.options.localnumbers}).length);
}
} | javascript | function(elem, inst) {
if (inst.options.autoSize && !inst.inline) {
var calendar = inst.options.calendar;
var date = calendar.newDate(2009, 10, 20); // Ensure double digits
var dateFormat = inst.get('dateFormat');
if (dateFormat.match(/[DM]/)) {
var findMax = function(names) {
var max = 0;
var maxI = 0;
for (var i = 0; i < names.length; i++) {
if (names[i].length > max) {
max = names[i].length;
maxI = i;
}
}
return maxI;
};
date.month(findMax(calendar.local[dateFormat.match(/MM/) ? // Longest month
'monthNames' : 'monthNamesShort']) + 1);
date.day(findMax(calendar.local[dateFormat.match(/DD/) ? // Longest day
'dayNames' : 'dayNamesShort']) + 20 - date.dayOfWeek());
}
inst.elem.attr('size', date.formatDate(dateFormat,
{localNumbers: inst.options.localnumbers}).length);
}
} | [
"function",
"(",
"elem",
",",
"inst",
")",
"{",
"if",
"(",
"inst",
".",
"options",
".",
"autoSize",
"&&",
"!",
"inst",
".",
"inline",
")",
"{",
"var",
"calendar",
"=",
"inst",
".",
"options",
".",
"calendar",
";",
"var",
"date",
"=",
"calendar",
".",
"newDate",
"(",
"2009",
",",
"10",
",",
"20",
")",
";",
"// Ensure double digits",
"var",
"dateFormat",
"=",
"inst",
".",
"get",
"(",
"'dateFormat'",
")",
";",
"if",
"(",
"dateFormat",
".",
"match",
"(",
"/",
"[DM]",
"/",
")",
")",
"{",
"var",
"findMax",
"=",
"function",
"(",
"names",
")",
"{",
"var",
"max",
"=",
"0",
";",
"var",
"maxI",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"names",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"names",
"[",
"i",
"]",
".",
"length",
">",
"max",
")",
"{",
"max",
"=",
"names",
"[",
"i",
"]",
".",
"length",
";",
"maxI",
"=",
"i",
";",
"}",
"}",
"return",
"maxI",
";",
"}",
";",
"date",
".",
"month",
"(",
"findMax",
"(",
"calendar",
".",
"local",
"[",
"dateFormat",
".",
"match",
"(",
"/",
"MM",
"/",
")",
"?",
"// Longest month",
"'monthNames'",
":",
"'monthNamesShort'",
"]",
")",
"+",
"1",
")",
";",
"date",
".",
"day",
"(",
"findMax",
"(",
"calendar",
".",
"local",
"[",
"dateFormat",
".",
"match",
"(",
"/",
"DD",
"/",
")",
"?",
"// Longest day",
"'dayNames'",
":",
"'dayNamesShort'",
"]",
")",
"+",
"20",
"-",
"date",
".",
"dayOfWeek",
"(",
")",
")",
";",
"}",
"inst",
".",
"elem",
".",
"attr",
"(",
"'size'",
",",
"date",
".",
"formatDate",
"(",
"dateFormat",
",",
"{",
"localNumbers",
":",
"inst",
".",
"options",
".",
"localnumbers",
"}",
")",
".",
"length",
")",
";",
"}",
"}"
]
| Apply the maximum length for the date format.
@memberof CalendarsPicker
@private
@param elem {jQuery} The control to affect.
@param inst {object} The current instance settings. | [
"Apply",
"the",
"maximum",
"length",
"for",
"the",
"date",
"format",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L618-L643 |
|
39,488 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(fns) {
var funcs = arguments;
return function(args) {
for (var i = 0; i < funcs.length; i++) {
funcs[i].apply(this, arguments);
}
};
} | javascript | function(fns) {
var funcs = arguments;
return function(args) {
for (var i = 0; i < funcs.length; i++) {
funcs[i].apply(this, arguments);
}
};
} | [
"function",
"(",
"fns",
")",
"{",
"var",
"funcs",
"=",
"arguments",
";",
"return",
"function",
"(",
"args",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"funcs",
".",
"length",
";",
"i",
"++",
")",
"{",
"funcs",
"[",
"i",
"]",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}",
"}",
";",
"}"
]
| Apply multiple event functions.
@memberof CalendarsPicker
@param fns {function} The functions to apply.
@example onShow: multipleEvents(fn1, fn2, ...) | [
"Apply",
"multiple",
"event",
"functions",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L662-L669 |
|
39,489 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem) {
elem = $(elem);
if (!elem.hasClass(this._getMarker())) {
return;
}
var inst = this._getInst(elem);
if (inst.inline) {
elem.children('.' + this._disableClass).remove().end().
find('button,select').prop('disabled', false).end().
find('a').attr('href', 'javascript:void(0)');
}
else {
elem.prop('disabled', false);
inst.trigger.filter('button.' + this._triggerClass).prop('disabled', false).end().
filter('img.' + this._triggerClass).css({opacity: '1.0', cursor: ''});
}
this._disabled = $.map(this._disabled,
function(value) { return (value === elem[0] ? null : value); }); // Delete entry
} | javascript | function(elem) {
elem = $(elem);
if (!elem.hasClass(this._getMarker())) {
return;
}
var inst = this._getInst(elem);
if (inst.inline) {
elem.children('.' + this._disableClass).remove().end().
find('button,select').prop('disabled', false).end().
find('a').attr('href', 'javascript:void(0)');
}
else {
elem.prop('disabled', false);
inst.trigger.filter('button.' + this._triggerClass).prop('disabled', false).end().
filter('img.' + this._triggerClass).css({opacity: '1.0', cursor: ''});
}
this._disabled = $.map(this._disabled,
function(value) { return (value === elem[0] ? null : value); }); // Delete entry
} | [
"function",
"(",
"elem",
")",
"{",
"elem",
"=",
"$",
"(",
"elem",
")",
";",
"if",
"(",
"!",
"elem",
".",
"hasClass",
"(",
"this",
".",
"_getMarker",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"var",
"inst",
"=",
"this",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"inst",
".",
"inline",
")",
"{",
"elem",
".",
"children",
"(",
"'.'",
"+",
"this",
".",
"_disableClass",
")",
".",
"remove",
"(",
")",
".",
"end",
"(",
")",
".",
"find",
"(",
"'button,select'",
")",
".",
"prop",
"(",
"'disabled'",
",",
"false",
")",
".",
"end",
"(",
")",
".",
"find",
"(",
"'a'",
")",
".",
"attr",
"(",
"'href'",
",",
"'javascript:void(0)'",
")",
";",
"}",
"else",
"{",
"elem",
".",
"prop",
"(",
"'disabled'",
",",
"false",
")",
";",
"inst",
".",
"trigger",
".",
"filter",
"(",
"'button.'",
"+",
"this",
".",
"_triggerClass",
")",
".",
"prop",
"(",
"'disabled'",
",",
"false",
")",
".",
"end",
"(",
")",
".",
"filter",
"(",
"'img.'",
"+",
"this",
".",
"_triggerClass",
")",
".",
"css",
"(",
"{",
"opacity",
":",
"'1.0'",
",",
"cursor",
":",
"''",
"}",
")",
";",
"}",
"this",
".",
"_disabled",
"=",
"$",
".",
"map",
"(",
"this",
".",
"_disabled",
",",
"function",
"(",
"value",
")",
"{",
"return",
"(",
"value",
"===",
"elem",
"[",
"0",
"]",
"?",
"null",
":",
"value",
")",
";",
"}",
")",
";",
"// Delete entry",
"}"
]
| Enable the control.
@memberof CalendarsPicker
@param elem {Element} The control to affect.
@example $(selector).datepick('enable') | [
"Enable",
"the",
"control",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L675-L693 |
|
39,490 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem) {
elem = $(elem);
if (!elem.hasClass(this._getMarker())) {
return;
}
var inst = this._getInst(elem);
if (inst.inline) {
var inline = elem.children(':last');
var offset = inline.offset();
var relOffset = {left: 0, top: 0};
inline.parents().each(function() {
if ($(this).css('position') === 'relative') {
relOffset = $(this).offset();
return false;
}
});
var zIndex = elem.css('zIndex');
zIndex = (zIndex === 'auto' ? 0 : parseInt(zIndex, 10)) + 1;
elem.prepend('<div class="' + this._disableClass + '" style="' +
'width: ' + inline.outerWidth() + 'px; height: ' + inline.outerHeight() +
'px; left: ' + (offset.left - relOffset.left) + 'px; top: ' +
(offset.top - relOffset.top) + 'px; z-index: ' + zIndex + '"></div>').
find('button,select').prop('disabled', true).end().
find('a').removeAttr('href');
}
else {
elem.prop('disabled', true);
inst.trigger.filter('button.' + this._triggerClass).prop('disabled', true).end().
filter('img.' + this._triggerClass).css({opacity: '0.5', cursor: 'default'});
}
this._disabled = $.map(this._disabled,
function(value) { return (value === elem[0] ? null : value); }); // Delete entry
this._disabled.push(elem[0]);
} | javascript | function(elem) {
elem = $(elem);
if (!elem.hasClass(this._getMarker())) {
return;
}
var inst = this._getInst(elem);
if (inst.inline) {
var inline = elem.children(':last');
var offset = inline.offset();
var relOffset = {left: 0, top: 0};
inline.parents().each(function() {
if ($(this).css('position') === 'relative') {
relOffset = $(this).offset();
return false;
}
});
var zIndex = elem.css('zIndex');
zIndex = (zIndex === 'auto' ? 0 : parseInt(zIndex, 10)) + 1;
elem.prepend('<div class="' + this._disableClass + '" style="' +
'width: ' + inline.outerWidth() + 'px; height: ' + inline.outerHeight() +
'px; left: ' + (offset.left - relOffset.left) + 'px; top: ' +
(offset.top - relOffset.top) + 'px; z-index: ' + zIndex + '"></div>').
find('button,select').prop('disabled', true).end().
find('a').removeAttr('href');
}
else {
elem.prop('disabled', true);
inst.trigger.filter('button.' + this._triggerClass).prop('disabled', true).end().
filter('img.' + this._triggerClass).css({opacity: '0.5', cursor: 'default'});
}
this._disabled = $.map(this._disabled,
function(value) { return (value === elem[0] ? null : value); }); // Delete entry
this._disabled.push(elem[0]);
} | [
"function",
"(",
"elem",
")",
"{",
"elem",
"=",
"$",
"(",
"elem",
")",
";",
"if",
"(",
"!",
"elem",
".",
"hasClass",
"(",
"this",
".",
"_getMarker",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"var",
"inst",
"=",
"this",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"inst",
".",
"inline",
")",
"{",
"var",
"inline",
"=",
"elem",
".",
"children",
"(",
"':last'",
")",
";",
"var",
"offset",
"=",
"inline",
".",
"offset",
"(",
")",
";",
"var",
"relOffset",
"=",
"{",
"left",
":",
"0",
",",
"top",
":",
"0",
"}",
";",
"inline",
".",
"parents",
"(",
")",
".",
"each",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"$",
"(",
"this",
")",
".",
"css",
"(",
"'position'",
")",
"===",
"'relative'",
")",
"{",
"relOffset",
"=",
"$",
"(",
"this",
")",
".",
"offset",
"(",
")",
";",
"return",
"false",
";",
"}",
"}",
")",
";",
"var",
"zIndex",
"=",
"elem",
".",
"css",
"(",
"'zIndex'",
")",
";",
"zIndex",
"=",
"(",
"zIndex",
"===",
"'auto'",
"?",
"0",
":",
"parseInt",
"(",
"zIndex",
",",
"10",
")",
")",
"+",
"1",
";",
"elem",
".",
"prepend",
"(",
"'<div class=\"'",
"+",
"this",
".",
"_disableClass",
"+",
"'\" style=\"'",
"+",
"'width: '",
"+",
"inline",
".",
"outerWidth",
"(",
")",
"+",
"'px; height: '",
"+",
"inline",
".",
"outerHeight",
"(",
")",
"+",
"'px; left: '",
"+",
"(",
"offset",
".",
"left",
"-",
"relOffset",
".",
"left",
")",
"+",
"'px; top: '",
"+",
"(",
"offset",
".",
"top",
"-",
"relOffset",
".",
"top",
")",
"+",
"'px; z-index: '",
"+",
"zIndex",
"+",
"'\"></div>'",
")",
".",
"find",
"(",
"'button,select'",
")",
".",
"prop",
"(",
"'disabled'",
",",
"true",
")",
".",
"end",
"(",
")",
".",
"find",
"(",
"'a'",
")",
".",
"removeAttr",
"(",
"'href'",
")",
";",
"}",
"else",
"{",
"elem",
".",
"prop",
"(",
"'disabled'",
",",
"true",
")",
";",
"inst",
".",
"trigger",
".",
"filter",
"(",
"'button.'",
"+",
"this",
".",
"_triggerClass",
")",
".",
"prop",
"(",
"'disabled'",
",",
"true",
")",
".",
"end",
"(",
")",
".",
"filter",
"(",
"'img.'",
"+",
"this",
".",
"_triggerClass",
")",
".",
"css",
"(",
"{",
"opacity",
":",
"'0.5'",
",",
"cursor",
":",
"'default'",
"}",
")",
";",
"}",
"this",
".",
"_disabled",
"=",
"$",
".",
"map",
"(",
"this",
".",
"_disabled",
",",
"function",
"(",
"value",
")",
"{",
"return",
"(",
"value",
"===",
"elem",
"[",
"0",
"]",
"?",
"null",
":",
"value",
")",
";",
"}",
")",
";",
"// Delete entry",
"this",
".",
"_disabled",
".",
"push",
"(",
"elem",
"[",
"0",
"]",
")",
";",
"}"
]
| Disable the control.
@memberof CalendarsPicker
@param elem {Element} The control to affect.
@example $(selector).datepick('disable') | [
"Disable",
"the",
"control",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L699-L732 |
|
39,491 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem) {
elem = $(elem.target || elem);
var inst = plugin._getInst(elem);
if (plugin.curInst === inst) {
return;
}
if (plugin.curInst) {
plugin.hide(plugin.curInst, true);
}
if (!$.isEmptyObject(inst)) {
// Retrieve existing date(s)
inst.lastVal = null;
inst.selectedDates = plugin._extractDates(inst, elem.val());
inst.pickingRange = false;
inst.drawDate = plugin._checkMinMax((inst.selectedDates[0] ||
inst.get('defaultDate') || inst.options.calendar.today()).newDate(), inst);
inst.prevDate = inst.drawDate.newDate();
plugin.curInst = inst;
// Generate content
plugin._update(elem[0], true);
// Adjust position before showing
var offset = plugin._checkOffset(inst);
inst.div.css({left: offset.left, top: offset.top});
// And display
var showAnim = inst.options.showAnim;
var showSpeed = inst.options.showSpeed;
showSpeed = (showSpeed === 'normal' && $.ui &&
parseInt($.ui.version.substring(2)) >= 8 ? '_default' : showSpeed);
if ($.effects && ($.effects[showAnim] || ($.effects.effect && $.effects.effect[showAnim]))) {
var data = inst.div.data(); // Update old effects data
for (var key in data) {
if (key.match(/^ec\.storage\./)) {
data[key] = inst._mainDiv.css(key.replace(/ec\.storage\./, ''));
}
}
inst.div.data(data).show(showAnim, inst.options.showOptions, showSpeed);
}
else {
inst.div[showAnim || 'show'](showAnim ? showSpeed : 0);
}
}
} | javascript | function(elem) {
elem = $(elem.target || elem);
var inst = plugin._getInst(elem);
if (plugin.curInst === inst) {
return;
}
if (plugin.curInst) {
plugin.hide(plugin.curInst, true);
}
if (!$.isEmptyObject(inst)) {
// Retrieve existing date(s)
inst.lastVal = null;
inst.selectedDates = plugin._extractDates(inst, elem.val());
inst.pickingRange = false;
inst.drawDate = plugin._checkMinMax((inst.selectedDates[0] ||
inst.get('defaultDate') || inst.options.calendar.today()).newDate(), inst);
inst.prevDate = inst.drawDate.newDate();
plugin.curInst = inst;
// Generate content
plugin._update(elem[0], true);
// Adjust position before showing
var offset = plugin._checkOffset(inst);
inst.div.css({left: offset.left, top: offset.top});
// And display
var showAnim = inst.options.showAnim;
var showSpeed = inst.options.showSpeed;
showSpeed = (showSpeed === 'normal' && $.ui &&
parseInt($.ui.version.substring(2)) >= 8 ? '_default' : showSpeed);
if ($.effects && ($.effects[showAnim] || ($.effects.effect && $.effects.effect[showAnim]))) {
var data = inst.div.data(); // Update old effects data
for (var key in data) {
if (key.match(/^ec\.storage\./)) {
data[key] = inst._mainDiv.css(key.replace(/ec\.storage\./, ''));
}
}
inst.div.data(data).show(showAnim, inst.options.showOptions, showSpeed);
}
else {
inst.div[showAnim || 'show'](showAnim ? showSpeed : 0);
}
}
} | [
"function",
"(",
"elem",
")",
"{",
"elem",
"=",
"$",
"(",
"elem",
".",
"target",
"||",
"elem",
")",
";",
"var",
"inst",
"=",
"plugin",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"plugin",
".",
"curInst",
"===",
"inst",
")",
"{",
"return",
";",
"}",
"if",
"(",
"plugin",
".",
"curInst",
")",
"{",
"plugin",
".",
"hide",
"(",
"plugin",
".",
"curInst",
",",
"true",
")",
";",
"}",
"if",
"(",
"!",
"$",
".",
"isEmptyObject",
"(",
"inst",
")",
")",
"{",
"// Retrieve existing date(s)",
"inst",
".",
"lastVal",
"=",
"null",
";",
"inst",
".",
"selectedDates",
"=",
"plugin",
".",
"_extractDates",
"(",
"inst",
",",
"elem",
".",
"val",
"(",
")",
")",
";",
"inst",
".",
"pickingRange",
"=",
"false",
";",
"inst",
".",
"drawDate",
"=",
"plugin",
".",
"_checkMinMax",
"(",
"(",
"inst",
".",
"selectedDates",
"[",
"0",
"]",
"||",
"inst",
".",
"get",
"(",
"'defaultDate'",
")",
"||",
"inst",
".",
"options",
".",
"calendar",
".",
"today",
"(",
")",
")",
".",
"newDate",
"(",
")",
",",
"inst",
")",
";",
"inst",
".",
"prevDate",
"=",
"inst",
".",
"drawDate",
".",
"newDate",
"(",
")",
";",
"plugin",
".",
"curInst",
"=",
"inst",
";",
"// Generate content",
"plugin",
".",
"_update",
"(",
"elem",
"[",
"0",
"]",
",",
"true",
")",
";",
"// Adjust position before showing",
"var",
"offset",
"=",
"plugin",
".",
"_checkOffset",
"(",
"inst",
")",
";",
"inst",
".",
"div",
".",
"css",
"(",
"{",
"left",
":",
"offset",
".",
"left",
",",
"top",
":",
"offset",
".",
"top",
"}",
")",
";",
"// And display",
"var",
"showAnim",
"=",
"inst",
".",
"options",
".",
"showAnim",
";",
"var",
"showSpeed",
"=",
"inst",
".",
"options",
".",
"showSpeed",
";",
"showSpeed",
"=",
"(",
"showSpeed",
"===",
"'normal'",
"&&",
"$",
".",
"ui",
"&&",
"parseInt",
"(",
"$",
".",
"ui",
".",
"version",
".",
"substring",
"(",
"2",
")",
")",
">=",
"8",
"?",
"'_default'",
":",
"showSpeed",
")",
";",
"if",
"(",
"$",
".",
"effects",
"&&",
"(",
"$",
".",
"effects",
"[",
"showAnim",
"]",
"||",
"(",
"$",
".",
"effects",
".",
"effect",
"&&",
"$",
".",
"effects",
".",
"effect",
"[",
"showAnim",
"]",
")",
")",
")",
"{",
"var",
"data",
"=",
"inst",
".",
"div",
".",
"data",
"(",
")",
";",
"// Update old effects data",
"for",
"(",
"var",
"key",
"in",
"data",
")",
"{",
"if",
"(",
"key",
".",
"match",
"(",
"/",
"^ec\\.storage\\.",
"/",
")",
")",
"{",
"data",
"[",
"key",
"]",
"=",
"inst",
".",
"_mainDiv",
".",
"css",
"(",
"key",
".",
"replace",
"(",
"/",
"ec\\.storage\\.",
"/",
",",
"''",
")",
")",
";",
"}",
"}",
"inst",
".",
"div",
".",
"data",
"(",
"data",
")",
".",
"show",
"(",
"showAnim",
",",
"inst",
".",
"options",
".",
"showOptions",
",",
"showSpeed",
")",
";",
"}",
"else",
"{",
"inst",
".",
"div",
"[",
"showAnim",
"||",
"'show'",
"]",
"(",
"showAnim",
"?",
"showSpeed",
":",
"0",
")",
";",
"}",
"}",
"}"
]
| Show a popup datepicker.
@memberof CalendarsPicker
@param elem {Event|Element} a focus event or the control to use.
@example $(selector).datepick('show') | [
"Show",
"a",
"popup",
"datepicker",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L747-L788 |
|
39,492 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(inst, datesText) {
if (datesText === inst.lastVal) {
return;
}
inst.lastVal = datesText;
datesText = datesText.split(inst.options.multiSelect ? inst.options.multiSeparator :
(inst.options.rangeSelect ? inst.options.rangeSeparator : '\x00'));
var dates = [];
for (var i = 0; i < datesText.length; i++) {
try {
var date = inst.options.calendar.parseDate(inst.get('dateFormat'), datesText[i]);
if (date) {
var found = false;
for (var j = 0; j < dates.length; j++) {
if (dates[j].compareTo(date) === 0) {
found = true;
break;
}
}
if (!found) {
dates.push(date);
}
}
}
catch (e) {
// Ignore
}
}
dates.splice(inst.options.multiSelect || (inst.options.rangeSelect ? 2 : 1), dates.length);
if (inst.options.rangeSelect && dates.length === 1) {
dates[1] = dates[0];
}
return dates;
} | javascript | function(inst, datesText) {
if (datesText === inst.lastVal) {
return;
}
inst.lastVal = datesText;
datesText = datesText.split(inst.options.multiSelect ? inst.options.multiSeparator :
(inst.options.rangeSelect ? inst.options.rangeSeparator : '\x00'));
var dates = [];
for (var i = 0; i < datesText.length; i++) {
try {
var date = inst.options.calendar.parseDate(inst.get('dateFormat'), datesText[i]);
if (date) {
var found = false;
for (var j = 0; j < dates.length; j++) {
if (dates[j].compareTo(date) === 0) {
found = true;
break;
}
}
if (!found) {
dates.push(date);
}
}
}
catch (e) {
// Ignore
}
}
dates.splice(inst.options.multiSelect || (inst.options.rangeSelect ? 2 : 1), dates.length);
if (inst.options.rangeSelect && dates.length === 1) {
dates[1] = dates[0];
}
return dates;
} | [
"function",
"(",
"inst",
",",
"datesText",
")",
"{",
"if",
"(",
"datesText",
"===",
"inst",
".",
"lastVal",
")",
"{",
"return",
";",
"}",
"inst",
".",
"lastVal",
"=",
"datesText",
";",
"datesText",
"=",
"datesText",
".",
"split",
"(",
"inst",
".",
"options",
".",
"multiSelect",
"?",
"inst",
".",
"options",
".",
"multiSeparator",
":",
"(",
"inst",
".",
"options",
".",
"rangeSelect",
"?",
"inst",
".",
"options",
".",
"rangeSeparator",
":",
"'\\x00'",
")",
")",
";",
"var",
"dates",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"datesText",
".",
"length",
";",
"i",
"++",
")",
"{",
"try",
"{",
"var",
"date",
"=",
"inst",
".",
"options",
".",
"calendar",
".",
"parseDate",
"(",
"inst",
".",
"get",
"(",
"'dateFormat'",
")",
",",
"datesText",
"[",
"i",
"]",
")",
";",
"if",
"(",
"date",
")",
"{",
"var",
"found",
"=",
"false",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"dates",
".",
"length",
";",
"j",
"++",
")",
"{",
"if",
"(",
"dates",
"[",
"j",
"]",
".",
"compareTo",
"(",
"date",
")",
"===",
"0",
")",
"{",
"found",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"found",
")",
"{",
"dates",
".",
"push",
"(",
"date",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"e",
")",
"{",
"// Ignore",
"}",
"}",
"dates",
".",
"splice",
"(",
"inst",
".",
"options",
".",
"multiSelect",
"||",
"(",
"inst",
".",
"options",
".",
"rangeSelect",
"?",
"2",
":",
"1",
")",
",",
"dates",
".",
"length",
")",
";",
"if",
"(",
"inst",
".",
"options",
".",
"rangeSelect",
"&&",
"dates",
".",
"length",
"===",
"1",
")",
"{",
"dates",
"[",
"1",
"]",
"=",
"dates",
"[",
"0",
"]",
";",
"}",
"return",
"dates",
";",
"}"
]
| Extract possible dates from a string.
@memberof CalendarsPicker
@private
@param inst {object} The current instance settings.
@param text {string} The text to extract from.
@return {CDate[]} The extracted dates. | [
"Extract",
"possible",
"dates",
"from",
"a",
"string",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L796-L829 |
|
39,493 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem, hidden) {
elem = $(elem.target || elem);
var inst = plugin._getInst(elem);
if (!$.isEmptyObject(inst)) {
if (inst.inline || plugin.curInst === inst) {
if ($.isFunction(inst.options.onChangeMonthYear) && (!inst.prevDate ||
inst.prevDate.year() !== inst.drawDate.year() ||
inst.prevDate.month() !== inst.drawDate.month())) {
inst.options.onChangeMonthYear.apply(elem[0],
[inst.drawDate.year(), inst.drawDate.month()]);
}
}
if (inst.inline) {
var index = $('a, :input', elem).index($(':focus', elem));
elem.html(this._generateContent(elem[0], inst));
var focus = elem.find('a, :input');
focus.eq(Math.max(Math.min(index, focus.length - 1), 0)).focus();
}
else if (plugin.curInst === inst) {
if (!inst.div) {
inst.div = $('<div></div>').addClass(this._popupClass).
css({display: (hidden ? 'none' : 'static'), position: 'absolute',
left: elem.offset().left, top: elem.offset().top + elem.outerHeight()}).
appendTo($(inst.options.popupContainer || 'body'));
if ($.fn.mousewheel) {
inst.div.mousewheel(this._doMouseWheel);
}
}
inst.div.html(this._generateContent(elem[0], inst));
elem.focus();
}
}
} | javascript | function(elem, hidden) {
elem = $(elem.target || elem);
var inst = plugin._getInst(elem);
if (!$.isEmptyObject(inst)) {
if (inst.inline || plugin.curInst === inst) {
if ($.isFunction(inst.options.onChangeMonthYear) && (!inst.prevDate ||
inst.prevDate.year() !== inst.drawDate.year() ||
inst.prevDate.month() !== inst.drawDate.month())) {
inst.options.onChangeMonthYear.apply(elem[0],
[inst.drawDate.year(), inst.drawDate.month()]);
}
}
if (inst.inline) {
var index = $('a, :input', elem).index($(':focus', elem));
elem.html(this._generateContent(elem[0], inst));
var focus = elem.find('a, :input');
focus.eq(Math.max(Math.min(index, focus.length - 1), 0)).focus();
}
else if (plugin.curInst === inst) {
if (!inst.div) {
inst.div = $('<div></div>').addClass(this._popupClass).
css({display: (hidden ? 'none' : 'static'), position: 'absolute',
left: elem.offset().left, top: elem.offset().top + elem.outerHeight()}).
appendTo($(inst.options.popupContainer || 'body'));
if ($.fn.mousewheel) {
inst.div.mousewheel(this._doMouseWheel);
}
}
inst.div.html(this._generateContent(elem[0], inst));
elem.focus();
}
}
} | [
"function",
"(",
"elem",
",",
"hidden",
")",
"{",
"elem",
"=",
"$",
"(",
"elem",
".",
"target",
"||",
"elem",
")",
";",
"var",
"inst",
"=",
"plugin",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"!",
"$",
".",
"isEmptyObject",
"(",
"inst",
")",
")",
"{",
"if",
"(",
"inst",
".",
"inline",
"||",
"plugin",
".",
"curInst",
"===",
"inst",
")",
"{",
"if",
"(",
"$",
".",
"isFunction",
"(",
"inst",
".",
"options",
".",
"onChangeMonthYear",
")",
"&&",
"(",
"!",
"inst",
".",
"prevDate",
"||",
"inst",
".",
"prevDate",
".",
"year",
"(",
")",
"!==",
"inst",
".",
"drawDate",
".",
"year",
"(",
")",
"||",
"inst",
".",
"prevDate",
".",
"month",
"(",
")",
"!==",
"inst",
".",
"drawDate",
".",
"month",
"(",
")",
")",
")",
"{",
"inst",
".",
"options",
".",
"onChangeMonthYear",
".",
"apply",
"(",
"elem",
"[",
"0",
"]",
",",
"[",
"inst",
".",
"drawDate",
".",
"year",
"(",
")",
",",
"inst",
".",
"drawDate",
".",
"month",
"(",
")",
"]",
")",
";",
"}",
"}",
"if",
"(",
"inst",
".",
"inline",
")",
"{",
"var",
"index",
"=",
"$",
"(",
"'a, :input'",
",",
"elem",
")",
".",
"index",
"(",
"$",
"(",
"':focus'",
",",
"elem",
")",
")",
";",
"elem",
".",
"html",
"(",
"this",
".",
"_generateContent",
"(",
"elem",
"[",
"0",
"]",
",",
"inst",
")",
")",
";",
"var",
"focus",
"=",
"elem",
".",
"find",
"(",
"'a, :input'",
")",
";",
"focus",
".",
"eq",
"(",
"Math",
".",
"max",
"(",
"Math",
".",
"min",
"(",
"index",
",",
"focus",
".",
"length",
"-",
"1",
")",
",",
"0",
")",
")",
".",
"focus",
"(",
")",
";",
"}",
"else",
"if",
"(",
"plugin",
".",
"curInst",
"===",
"inst",
")",
"{",
"if",
"(",
"!",
"inst",
".",
"div",
")",
"{",
"inst",
".",
"div",
"=",
"$",
"(",
"'<div></div>'",
")",
".",
"addClass",
"(",
"this",
".",
"_popupClass",
")",
".",
"css",
"(",
"{",
"display",
":",
"(",
"hidden",
"?",
"'none'",
":",
"'static'",
")",
",",
"position",
":",
"'absolute'",
",",
"left",
":",
"elem",
".",
"offset",
"(",
")",
".",
"left",
",",
"top",
":",
"elem",
".",
"offset",
"(",
")",
".",
"top",
"+",
"elem",
".",
"outerHeight",
"(",
")",
"}",
")",
".",
"appendTo",
"(",
"$",
"(",
"inst",
".",
"options",
".",
"popupContainer",
"||",
"'body'",
")",
")",
";",
"if",
"(",
"$",
".",
"fn",
".",
"mousewheel",
")",
"{",
"inst",
".",
"div",
".",
"mousewheel",
"(",
"this",
".",
"_doMouseWheel",
")",
";",
"}",
"}",
"inst",
".",
"div",
".",
"html",
"(",
"this",
".",
"_generateContent",
"(",
"elem",
"[",
"0",
"]",
",",
"inst",
")",
")",
";",
"elem",
".",
"focus",
"(",
")",
";",
"}",
"}",
"}"
]
| Update the datepicker display.
@memberof CalendarsPicker
@private
@param elem {Event|Element} a focus event or the control to use.
@param hidden {boolean} <code>true</code> to initially hide the datepicker. | [
"Update",
"the",
"datepicker",
"display",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L836-L868 |
|
39,494 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem, keyUp) {
var inst = this._getInst(elem);
if (!$.isEmptyObject(inst)) {
var value = '';
var altValue = '';
var sep = (inst.options.multiSelect ? inst.options.multiSeparator :
inst.options.rangeSeparator);
var calendar = inst.options.calendar;
var dateFormat = inst.get('dateFormat');
var altFormat = inst.options.altFormat || dateFormat;
var settings = {localNumbers: inst.options.localNumbers};
for (var i = 0; i < inst.selectedDates.length; i++) {
value += (keyUp ? '' : (i > 0 ? sep : '') +
calendar.formatDate(dateFormat, inst.selectedDates[i], settings));
altValue += (i > 0 ? sep : '') +
calendar.formatDate(altFormat, inst.selectedDates[i], settings);
}
if (!inst.inline && !keyUp) {
$(elem).val(value);
}
$(inst.options.altField).val(altValue);
if ($.isFunction(inst.options.onSelect) && !keyUp && !inst.inSelect) {
inst.inSelect = true; // Prevent endless loops
inst.options.onSelect.apply(elem, [inst.selectedDates]);
inst.inSelect = false;
}
}
} | javascript | function(elem, keyUp) {
var inst = this._getInst(elem);
if (!$.isEmptyObject(inst)) {
var value = '';
var altValue = '';
var sep = (inst.options.multiSelect ? inst.options.multiSeparator :
inst.options.rangeSeparator);
var calendar = inst.options.calendar;
var dateFormat = inst.get('dateFormat');
var altFormat = inst.options.altFormat || dateFormat;
var settings = {localNumbers: inst.options.localNumbers};
for (var i = 0; i < inst.selectedDates.length; i++) {
value += (keyUp ? '' : (i > 0 ? sep : '') +
calendar.formatDate(dateFormat, inst.selectedDates[i], settings));
altValue += (i > 0 ? sep : '') +
calendar.formatDate(altFormat, inst.selectedDates[i], settings);
}
if (!inst.inline && !keyUp) {
$(elem).val(value);
}
$(inst.options.altField).val(altValue);
if ($.isFunction(inst.options.onSelect) && !keyUp && !inst.inSelect) {
inst.inSelect = true; // Prevent endless loops
inst.options.onSelect.apply(elem, [inst.selectedDates]);
inst.inSelect = false;
}
}
} | [
"function",
"(",
"elem",
",",
"keyUp",
")",
"{",
"var",
"inst",
"=",
"this",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"!",
"$",
".",
"isEmptyObject",
"(",
"inst",
")",
")",
"{",
"var",
"value",
"=",
"''",
";",
"var",
"altValue",
"=",
"''",
";",
"var",
"sep",
"=",
"(",
"inst",
".",
"options",
".",
"multiSelect",
"?",
"inst",
".",
"options",
".",
"multiSeparator",
":",
"inst",
".",
"options",
".",
"rangeSeparator",
")",
";",
"var",
"calendar",
"=",
"inst",
".",
"options",
".",
"calendar",
";",
"var",
"dateFormat",
"=",
"inst",
".",
"get",
"(",
"'dateFormat'",
")",
";",
"var",
"altFormat",
"=",
"inst",
".",
"options",
".",
"altFormat",
"||",
"dateFormat",
";",
"var",
"settings",
"=",
"{",
"localNumbers",
":",
"inst",
".",
"options",
".",
"localNumbers",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"inst",
".",
"selectedDates",
".",
"length",
";",
"i",
"++",
")",
"{",
"value",
"+=",
"(",
"keyUp",
"?",
"''",
":",
"(",
"i",
">",
"0",
"?",
"sep",
":",
"''",
")",
"+",
"calendar",
".",
"formatDate",
"(",
"dateFormat",
",",
"inst",
".",
"selectedDates",
"[",
"i",
"]",
",",
"settings",
")",
")",
";",
"altValue",
"+=",
"(",
"i",
">",
"0",
"?",
"sep",
":",
"''",
")",
"+",
"calendar",
".",
"formatDate",
"(",
"altFormat",
",",
"inst",
".",
"selectedDates",
"[",
"i",
"]",
",",
"settings",
")",
";",
"}",
"if",
"(",
"!",
"inst",
".",
"inline",
"&&",
"!",
"keyUp",
")",
"{",
"$",
"(",
"elem",
")",
".",
"val",
"(",
"value",
")",
";",
"}",
"$",
"(",
"inst",
".",
"options",
".",
"altField",
")",
".",
"val",
"(",
"altValue",
")",
";",
"if",
"(",
"$",
".",
"isFunction",
"(",
"inst",
".",
"options",
".",
"onSelect",
")",
"&&",
"!",
"keyUp",
"&&",
"!",
"inst",
".",
"inSelect",
")",
"{",
"inst",
".",
"inSelect",
"=",
"true",
";",
"// Prevent endless loops",
"inst",
".",
"options",
".",
"onSelect",
".",
"apply",
"(",
"elem",
",",
"[",
"inst",
".",
"selectedDates",
"]",
")",
";",
"inst",
".",
"inSelect",
"=",
"false",
";",
"}",
"}",
"}"
]
| Update the input field and any alternate field with the current dates.
@memberof CalendarsPicker
@private
@param elem {Element} The control to use.
@param keyUp {boolean} <code>true</code> if coming from <code>keyUp</code> processing (internal). | [
"Update",
"the",
"input",
"field",
"and",
"any",
"alternate",
"field",
"with",
"the",
"current",
"dates",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L875-L902 |
|
39,495 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem) {
var convert = function(value) {
return {thin: 1, medium: 3, thick: 5}[value] || value;
};
return [parseFloat(convert(elem.css('border-left-width'))),
parseFloat(convert(elem.css('border-top-width')))];
} | javascript | function(elem) {
var convert = function(value) {
return {thin: 1, medium: 3, thick: 5}[value] || value;
};
return [parseFloat(convert(elem.css('border-left-width'))),
parseFloat(convert(elem.css('border-top-width')))];
} | [
"function",
"(",
"elem",
")",
"{",
"var",
"convert",
"=",
"function",
"(",
"value",
")",
"{",
"return",
"{",
"thin",
":",
"1",
",",
"medium",
":",
"3",
",",
"thick",
":",
"5",
"}",
"[",
"value",
"]",
"||",
"value",
";",
"}",
";",
"return",
"[",
"parseFloat",
"(",
"convert",
"(",
"elem",
".",
"css",
"(",
"'border-left-width'",
")",
")",
")",
",",
"parseFloat",
"(",
"convert",
"(",
"elem",
".",
"css",
"(",
"'border-top-width'",
")",
")",
")",
"]",
";",
"}"
]
| Retrieve the size of left and top borders for an element.
@memberof CalendarsPicker
@private
@param elem {jQuery} The element of interest.
@return {number[]} The left and top borders. | [
"Retrieve",
"the",
"size",
"of",
"left",
"and",
"top",
"borders",
"for",
"an",
"element",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L909-L915 |
|
39,496 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(inst) {
var base = (inst.elem.is(':hidden') && inst.trigger ? inst.trigger : inst.elem);
var offset = base.offset();
var browserWidth = $(window).width();
var browserHeight = $(window).height();
if (browserWidth === 0) {
return offset;
}
var isFixed = false;
$(inst.elem).parents().each(function() {
isFixed |= $(this).css('position') === 'fixed';
return !isFixed;
});
var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
var above = offset.top - (isFixed ? scrollY : 0) - inst.div.outerHeight();
var below = offset.top - (isFixed ? scrollY : 0) + base.outerHeight();
var alignL = offset.left - (isFixed ? scrollX : 0);
var alignR = offset.left - (isFixed ? scrollX : 0) + base.outerWidth() - inst.div.outerWidth();
var tooWide = (offset.left - scrollX + inst.div.outerWidth()) > browserWidth;
var tooHigh = (offset.top - scrollY + inst.elem.outerHeight() +
inst.div.outerHeight()) > browserHeight;
inst.div.css('position', isFixed ? 'fixed' : 'absolute');
var alignment = inst.options.alignment;
if (alignment === 'topLeft') {
offset = {left: alignL, top: above};
}
else if (alignment === 'topRight') {
offset = {left: alignR, top: above};
}
else if (alignment === 'bottomLeft') {
offset = {left: alignL, top: below};
}
else if (alignment === 'bottomRight') {
offset = {left: alignR, top: below};
}
else if (alignment === 'top') {
offset = {left: (inst.options.isRTL || tooWide ? alignR : alignL), top: above};
}
else { // bottom
offset = {left: (inst.options.isRTL || tooWide ? alignR : alignL),
top: (tooHigh ? above : below)};
}
offset.left = Math.max((isFixed ? 0 : scrollX), offset.left);
offset.top = Math.max((isFixed ? 0 : scrollY), offset.top);
return offset;
} | javascript | function(inst) {
var base = (inst.elem.is(':hidden') && inst.trigger ? inst.trigger : inst.elem);
var offset = base.offset();
var browserWidth = $(window).width();
var browserHeight = $(window).height();
if (browserWidth === 0) {
return offset;
}
var isFixed = false;
$(inst.elem).parents().each(function() {
isFixed |= $(this).css('position') === 'fixed';
return !isFixed;
});
var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
var above = offset.top - (isFixed ? scrollY : 0) - inst.div.outerHeight();
var below = offset.top - (isFixed ? scrollY : 0) + base.outerHeight();
var alignL = offset.left - (isFixed ? scrollX : 0);
var alignR = offset.left - (isFixed ? scrollX : 0) + base.outerWidth() - inst.div.outerWidth();
var tooWide = (offset.left - scrollX + inst.div.outerWidth()) > browserWidth;
var tooHigh = (offset.top - scrollY + inst.elem.outerHeight() +
inst.div.outerHeight()) > browserHeight;
inst.div.css('position', isFixed ? 'fixed' : 'absolute');
var alignment = inst.options.alignment;
if (alignment === 'topLeft') {
offset = {left: alignL, top: above};
}
else if (alignment === 'topRight') {
offset = {left: alignR, top: above};
}
else if (alignment === 'bottomLeft') {
offset = {left: alignL, top: below};
}
else if (alignment === 'bottomRight') {
offset = {left: alignR, top: below};
}
else if (alignment === 'top') {
offset = {left: (inst.options.isRTL || tooWide ? alignR : alignL), top: above};
}
else { // bottom
offset = {left: (inst.options.isRTL || tooWide ? alignR : alignL),
top: (tooHigh ? above : below)};
}
offset.left = Math.max((isFixed ? 0 : scrollX), offset.left);
offset.top = Math.max((isFixed ? 0 : scrollY), offset.top);
return offset;
} | [
"function",
"(",
"inst",
")",
"{",
"var",
"base",
"=",
"(",
"inst",
".",
"elem",
".",
"is",
"(",
"':hidden'",
")",
"&&",
"inst",
".",
"trigger",
"?",
"inst",
".",
"trigger",
":",
"inst",
".",
"elem",
")",
";",
"var",
"offset",
"=",
"base",
".",
"offset",
"(",
")",
";",
"var",
"browserWidth",
"=",
"$",
"(",
"window",
")",
".",
"width",
"(",
")",
";",
"var",
"browserHeight",
"=",
"$",
"(",
"window",
")",
".",
"height",
"(",
")",
";",
"if",
"(",
"browserWidth",
"===",
"0",
")",
"{",
"return",
"offset",
";",
"}",
"var",
"isFixed",
"=",
"false",
";",
"$",
"(",
"inst",
".",
"elem",
")",
".",
"parents",
"(",
")",
".",
"each",
"(",
"function",
"(",
")",
"{",
"isFixed",
"|=",
"$",
"(",
"this",
")",
".",
"css",
"(",
"'position'",
")",
"===",
"'fixed'",
";",
"return",
"!",
"isFixed",
";",
"}",
")",
";",
"var",
"scrollX",
"=",
"document",
".",
"documentElement",
".",
"scrollLeft",
"||",
"document",
".",
"body",
".",
"scrollLeft",
";",
"var",
"scrollY",
"=",
"document",
".",
"documentElement",
".",
"scrollTop",
"||",
"document",
".",
"body",
".",
"scrollTop",
";",
"var",
"above",
"=",
"offset",
".",
"top",
"-",
"(",
"isFixed",
"?",
"scrollY",
":",
"0",
")",
"-",
"inst",
".",
"div",
".",
"outerHeight",
"(",
")",
";",
"var",
"below",
"=",
"offset",
".",
"top",
"-",
"(",
"isFixed",
"?",
"scrollY",
":",
"0",
")",
"+",
"base",
".",
"outerHeight",
"(",
")",
";",
"var",
"alignL",
"=",
"offset",
".",
"left",
"-",
"(",
"isFixed",
"?",
"scrollX",
":",
"0",
")",
";",
"var",
"alignR",
"=",
"offset",
".",
"left",
"-",
"(",
"isFixed",
"?",
"scrollX",
":",
"0",
")",
"+",
"base",
".",
"outerWidth",
"(",
")",
"-",
"inst",
".",
"div",
".",
"outerWidth",
"(",
")",
";",
"var",
"tooWide",
"=",
"(",
"offset",
".",
"left",
"-",
"scrollX",
"+",
"inst",
".",
"div",
".",
"outerWidth",
"(",
")",
")",
">",
"browserWidth",
";",
"var",
"tooHigh",
"=",
"(",
"offset",
".",
"top",
"-",
"scrollY",
"+",
"inst",
".",
"elem",
".",
"outerHeight",
"(",
")",
"+",
"inst",
".",
"div",
".",
"outerHeight",
"(",
")",
")",
">",
"browserHeight",
";",
"inst",
".",
"div",
".",
"css",
"(",
"'position'",
",",
"isFixed",
"?",
"'fixed'",
":",
"'absolute'",
")",
";",
"var",
"alignment",
"=",
"inst",
".",
"options",
".",
"alignment",
";",
"if",
"(",
"alignment",
"===",
"'topLeft'",
")",
"{",
"offset",
"=",
"{",
"left",
":",
"alignL",
",",
"top",
":",
"above",
"}",
";",
"}",
"else",
"if",
"(",
"alignment",
"===",
"'topRight'",
")",
"{",
"offset",
"=",
"{",
"left",
":",
"alignR",
",",
"top",
":",
"above",
"}",
";",
"}",
"else",
"if",
"(",
"alignment",
"===",
"'bottomLeft'",
")",
"{",
"offset",
"=",
"{",
"left",
":",
"alignL",
",",
"top",
":",
"below",
"}",
";",
"}",
"else",
"if",
"(",
"alignment",
"===",
"'bottomRight'",
")",
"{",
"offset",
"=",
"{",
"left",
":",
"alignR",
",",
"top",
":",
"below",
"}",
";",
"}",
"else",
"if",
"(",
"alignment",
"===",
"'top'",
")",
"{",
"offset",
"=",
"{",
"left",
":",
"(",
"inst",
".",
"options",
".",
"isRTL",
"||",
"tooWide",
"?",
"alignR",
":",
"alignL",
")",
",",
"top",
":",
"above",
"}",
";",
"}",
"else",
"{",
"// bottom",
"offset",
"=",
"{",
"left",
":",
"(",
"inst",
".",
"options",
".",
"isRTL",
"||",
"tooWide",
"?",
"alignR",
":",
"alignL",
")",
",",
"top",
":",
"(",
"tooHigh",
"?",
"above",
":",
"below",
")",
"}",
";",
"}",
"offset",
".",
"left",
"=",
"Math",
".",
"max",
"(",
"(",
"isFixed",
"?",
"0",
":",
"scrollX",
")",
",",
"offset",
".",
"left",
")",
";",
"offset",
".",
"top",
"=",
"Math",
".",
"max",
"(",
"(",
"isFixed",
"?",
"0",
":",
"scrollY",
")",
",",
"offset",
".",
"top",
")",
";",
"return",
"offset",
";",
"}"
]
| Check positioning to remain on the screen.
@memberof CalendarsPicker
@private
@param inst {object} The current instance settings.
@return {object} The updated offset for the datepicker. | [
"Check",
"positioning",
"to",
"remain",
"on",
"the",
"screen",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L922-L968 |
|
39,497 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(event) {
if (!plugin.curInst) {
return;
}
var elem = $(event.target);
if (elem.closest('.' + plugin._popupClass + ',.' + plugin._triggerClass).length === 0 &&
!elem.hasClass(plugin._getMarker())) {
plugin.hide(plugin.curInst);
}
} | javascript | function(event) {
if (!plugin.curInst) {
return;
}
var elem = $(event.target);
if (elem.closest('.' + plugin._popupClass + ',.' + plugin._triggerClass).length === 0 &&
!elem.hasClass(plugin._getMarker())) {
plugin.hide(plugin.curInst);
}
} | [
"function",
"(",
"event",
")",
"{",
"if",
"(",
"!",
"plugin",
".",
"curInst",
")",
"{",
"return",
";",
"}",
"var",
"elem",
"=",
"$",
"(",
"event",
".",
"target",
")",
";",
"if",
"(",
"elem",
".",
"closest",
"(",
"'.'",
"+",
"plugin",
".",
"_popupClass",
"+",
"',.'",
"+",
"plugin",
".",
"_triggerClass",
")",
".",
"length",
"===",
"0",
"&&",
"!",
"elem",
".",
"hasClass",
"(",
"plugin",
".",
"_getMarker",
"(",
")",
")",
")",
"{",
"plugin",
".",
"hide",
"(",
"plugin",
".",
"curInst",
")",
";",
"}",
"}"
]
| Close date picker if clicked elsewhere.
@memberof CalendarsPicker
@private
@param event {MouseEvent} The mouse click to check. | [
"Close",
"date",
"picker",
"if",
"clicked",
"elsewhere",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L974-L983 |
|
39,498 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(elem, immediate) {
if (!elem) {
return;
}
var inst = this._getInst(elem);
if ($.isEmptyObject(inst)) {
inst = elem;
}
if (inst && inst === plugin.curInst) {
var showAnim = (immediate ? '' : inst.options.showAnim);
var showSpeed = inst.options.showSpeed;
showSpeed = (showSpeed === 'normal' && $.ui &&
parseInt($.ui.version.substring(2)) >= 8 ? '_default' : showSpeed);
var postProcess = function() {
if (!inst.div) {
return;
}
inst.div.remove();
inst.div = null;
plugin.curInst = null;
if ($.isFunction(inst.options.onClose)) {
inst.options.onClose.apply(elem, [inst.selectedDates]);
}
};
inst.div.stop();
if ($.effects && ($.effects[showAnim] || ($.effects.effect && $.effects.effect[showAnim]))) {
inst.div.hide(showAnim, inst.options.showOptions, showSpeed, postProcess);
}
else {
var hideAnim = (showAnim === 'slideDown' ? 'slideUp' :
(showAnim === 'fadeIn' ? 'fadeOut' : 'hide'));
inst.div[hideAnim]((showAnim ? showSpeed : ''), postProcess);
}
if (!showAnim) {
postProcess();
}
}
} | javascript | function(elem, immediate) {
if (!elem) {
return;
}
var inst = this._getInst(elem);
if ($.isEmptyObject(inst)) {
inst = elem;
}
if (inst && inst === plugin.curInst) {
var showAnim = (immediate ? '' : inst.options.showAnim);
var showSpeed = inst.options.showSpeed;
showSpeed = (showSpeed === 'normal' && $.ui &&
parseInt($.ui.version.substring(2)) >= 8 ? '_default' : showSpeed);
var postProcess = function() {
if (!inst.div) {
return;
}
inst.div.remove();
inst.div = null;
plugin.curInst = null;
if ($.isFunction(inst.options.onClose)) {
inst.options.onClose.apply(elem, [inst.selectedDates]);
}
};
inst.div.stop();
if ($.effects && ($.effects[showAnim] || ($.effects.effect && $.effects.effect[showAnim]))) {
inst.div.hide(showAnim, inst.options.showOptions, showSpeed, postProcess);
}
else {
var hideAnim = (showAnim === 'slideDown' ? 'slideUp' :
(showAnim === 'fadeIn' ? 'fadeOut' : 'hide'));
inst.div[hideAnim]((showAnim ? showSpeed : ''), postProcess);
}
if (!showAnim) {
postProcess();
}
}
} | [
"function",
"(",
"elem",
",",
"immediate",
")",
"{",
"if",
"(",
"!",
"elem",
")",
"{",
"return",
";",
"}",
"var",
"inst",
"=",
"this",
".",
"_getInst",
"(",
"elem",
")",
";",
"if",
"(",
"$",
".",
"isEmptyObject",
"(",
"inst",
")",
")",
"{",
"inst",
"=",
"elem",
";",
"}",
"if",
"(",
"inst",
"&&",
"inst",
"===",
"plugin",
".",
"curInst",
")",
"{",
"var",
"showAnim",
"=",
"(",
"immediate",
"?",
"''",
":",
"inst",
".",
"options",
".",
"showAnim",
")",
";",
"var",
"showSpeed",
"=",
"inst",
".",
"options",
".",
"showSpeed",
";",
"showSpeed",
"=",
"(",
"showSpeed",
"===",
"'normal'",
"&&",
"$",
".",
"ui",
"&&",
"parseInt",
"(",
"$",
".",
"ui",
".",
"version",
".",
"substring",
"(",
"2",
")",
")",
">=",
"8",
"?",
"'_default'",
":",
"showSpeed",
")",
";",
"var",
"postProcess",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"inst",
".",
"div",
")",
"{",
"return",
";",
"}",
"inst",
".",
"div",
".",
"remove",
"(",
")",
";",
"inst",
".",
"div",
"=",
"null",
";",
"plugin",
".",
"curInst",
"=",
"null",
";",
"if",
"(",
"$",
".",
"isFunction",
"(",
"inst",
".",
"options",
".",
"onClose",
")",
")",
"{",
"inst",
".",
"options",
".",
"onClose",
".",
"apply",
"(",
"elem",
",",
"[",
"inst",
".",
"selectedDates",
"]",
")",
";",
"}",
"}",
";",
"inst",
".",
"div",
".",
"stop",
"(",
")",
";",
"if",
"(",
"$",
".",
"effects",
"&&",
"(",
"$",
".",
"effects",
"[",
"showAnim",
"]",
"||",
"(",
"$",
".",
"effects",
".",
"effect",
"&&",
"$",
".",
"effects",
".",
"effect",
"[",
"showAnim",
"]",
")",
")",
")",
"{",
"inst",
".",
"div",
".",
"hide",
"(",
"showAnim",
",",
"inst",
".",
"options",
".",
"showOptions",
",",
"showSpeed",
",",
"postProcess",
")",
";",
"}",
"else",
"{",
"var",
"hideAnim",
"=",
"(",
"showAnim",
"===",
"'slideDown'",
"?",
"'slideUp'",
":",
"(",
"showAnim",
"===",
"'fadeIn'",
"?",
"'fadeOut'",
":",
"'hide'",
")",
")",
";",
"inst",
".",
"div",
"[",
"hideAnim",
"]",
"(",
"(",
"showAnim",
"?",
"showSpeed",
":",
"''",
")",
",",
"postProcess",
")",
";",
"}",
"if",
"(",
"!",
"showAnim",
")",
"{",
"postProcess",
"(",
")",
";",
"}",
"}",
"}"
]
| Hide a popup datepicker.
@memberof CalendarsPicker
@param elem {Element|object} The control to use or the current instance settings.
@param immediate {boolean} <code>true</code> to close immediately without animation (internal).
@example $(selector).datepick('hide') | [
"Hide",
"a",
"popup",
"datepicker",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L990-L1027 |
|
39,499 | alexcjohnson/world-calendars | jquery-src/jquery.calendars.picker.js | function(event) {
var elem = (event.data && event.data.elem) || event.target;
var inst = plugin._getInst(elem);
var handled = false;
if (inst.inline || inst.div) {
if (event.keyCode === 9) { // Tab - close
plugin.hide(elem);
}
else if (event.keyCode === 13) { // Enter - select
plugin.selectDate(elem,
$('a.' + inst.options.renderer.highlightedClass, inst.div)[0]);
handled = true;
}
else { // Command keystrokes
var commands = inst.options.commands;
for (var name in commands) {
var command = commands[name];
if (command.keystroke.keyCode === event.keyCode &&
!!command.keystroke.ctrlKey === !!(event.ctrlKey || event.metaKey) &&
!!command.keystroke.altKey === event.altKey &&
!!command.keystroke.shiftKey === event.shiftKey) {
plugin.performAction(elem, name);
handled = true;
break;
}
}
}
}
else { // Show on 'current' keystroke
var command = inst.options.commands.current;
if (command.keystroke.keyCode === event.keyCode &&
!!command.keystroke.ctrlKey === !!(event.ctrlKey || event.metaKey) &&
!!command.keystroke.altKey === event.altKey &&
!!command.keystroke.shiftKey === event.shiftKey) {
plugin.show(elem);
handled = true;
}
}
inst.ctrlKey = ((event.keyCode < 48 && event.keyCode !== 32) || event.ctrlKey || event.metaKey);
if (handled) {
event.preventDefault();
event.stopPropagation();
}
return !handled;
} | javascript | function(event) {
var elem = (event.data && event.data.elem) || event.target;
var inst = plugin._getInst(elem);
var handled = false;
if (inst.inline || inst.div) {
if (event.keyCode === 9) { // Tab - close
plugin.hide(elem);
}
else if (event.keyCode === 13) { // Enter - select
plugin.selectDate(elem,
$('a.' + inst.options.renderer.highlightedClass, inst.div)[0]);
handled = true;
}
else { // Command keystrokes
var commands = inst.options.commands;
for (var name in commands) {
var command = commands[name];
if (command.keystroke.keyCode === event.keyCode &&
!!command.keystroke.ctrlKey === !!(event.ctrlKey || event.metaKey) &&
!!command.keystroke.altKey === event.altKey &&
!!command.keystroke.shiftKey === event.shiftKey) {
plugin.performAction(elem, name);
handled = true;
break;
}
}
}
}
else { // Show on 'current' keystroke
var command = inst.options.commands.current;
if (command.keystroke.keyCode === event.keyCode &&
!!command.keystroke.ctrlKey === !!(event.ctrlKey || event.metaKey) &&
!!command.keystroke.altKey === event.altKey &&
!!command.keystroke.shiftKey === event.shiftKey) {
plugin.show(elem);
handled = true;
}
}
inst.ctrlKey = ((event.keyCode < 48 && event.keyCode !== 32) || event.ctrlKey || event.metaKey);
if (handled) {
event.preventDefault();
event.stopPropagation();
}
return !handled;
} | [
"function",
"(",
"event",
")",
"{",
"var",
"elem",
"=",
"(",
"event",
".",
"data",
"&&",
"event",
".",
"data",
".",
"elem",
")",
"||",
"event",
".",
"target",
";",
"var",
"inst",
"=",
"plugin",
".",
"_getInst",
"(",
"elem",
")",
";",
"var",
"handled",
"=",
"false",
";",
"if",
"(",
"inst",
".",
"inline",
"||",
"inst",
".",
"div",
")",
"{",
"if",
"(",
"event",
".",
"keyCode",
"===",
"9",
")",
"{",
"// Tab - close",
"plugin",
".",
"hide",
"(",
"elem",
")",
";",
"}",
"else",
"if",
"(",
"event",
".",
"keyCode",
"===",
"13",
")",
"{",
"// Enter - select",
"plugin",
".",
"selectDate",
"(",
"elem",
",",
"$",
"(",
"'a.'",
"+",
"inst",
".",
"options",
".",
"renderer",
".",
"highlightedClass",
",",
"inst",
".",
"div",
")",
"[",
"0",
"]",
")",
";",
"handled",
"=",
"true",
";",
"}",
"else",
"{",
"// Command keystrokes",
"var",
"commands",
"=",
"inst",
".",
"options",
".",
"commands",
";",
"for",
"(",
"var",
"name",
"in",
"commands",
")",
"{",
"var",
"command",
"=",
"commands",
"[",
"name",
"]",
";",
"if",
"(",
"command",
".",
"keystroke",
".",
"keyCode",
"===",
"event",
".",
"keyCode",
"&&",
"!",
"!",
"command",
".",
"keystroke",
".",
"ctrlKey",
"===",
"!",
"!",
"(",
"event",
".",
"ctrlKey",
"||",
"event",
".",
"metaKey",
")",
"&&",
"!",
"!",
"command",
".",
"keystroke",
".",
"altKey",
"===",
"event",
".",
"altKey",
"&&",
"!",
"!",
"command",
".",
"keystroke",
".",
"shiftKey",
"===",
"event",
".",
"shiftKey",
")",
"{",
"plugin",
".",
"performAction",
"(",
"elem",
",",
"name",
")",
";",
"handled",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"// Show on 'current' keystroke",
"var",
"command",
"=",
"inst",
".",
"options",
".",
"commands",
".",
"current",
";",
"if",
"(",
"command",
".",
"keystroke",
".",
"keyCode",
"===",
"event",
".",
"keyCode",
"&&",
"!",
"!",
"command",
".",
"keystroke",
".",
"ctrlKey",
"===",
"!",
"!",
"(",
"event",
".",
"ctrlKey",
"||",
"event",
".",
"metaKey",
")",
"&&",
"!",
"!",
"command",
".",
"keystroke",
".",
"altKey",
"===",
"event",
".",
"altKey",
"&&",
"!",
"!",
"command",
".",
"keystroke",
".",
"shiftKey",
"===",
"event",
".",
"shiftKey",
")",
"{",
"plugin",
".",
"show",
"(",
"elem",
")",
";",
"handled",
"=",
"true",
";",
"}",
"}",
"inst",
".",
"ctrlKey",
"=",
"(",
"(",
"event",
".",
"keyCode",
"<",
"48",
"&&",
"event",
".",
"keyCode",
"!==",
"32",
")",
"||",
"event",
".",
"ctrlKey",
"||",
"event",
".",
"metaKey",
")",
";",
"if",
"(",
"handled",
")",
"{",
"event",
".",
"preventDefault",
"(",
")",
";",
"event",
".",
"stopPropagation",
"(",
")",
";",
"}",
"return",
"!",
"handled",
";",
"}"
]
| Handle keystrokes in the datepicker.
@memberof CalendarsPicker
@private
@param event {KeyEvent} The keystroke.
@return {boolean} <code>true</code> if not handled, <code>false</code> if handled. | [
"Handle",
"keystrokes",
"in",
"the",
"datepicker",
"."
]
| 810693882512dec1b804456f8d435b962bd6cf31 | https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.picker.js#L1034-L1078 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.